message
stringlengths
2
23.4k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
129
108k
cluster
float64
6
6
__index_level_0__
int64
258
216k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. International Coding Procedures Company (ICPC) writes all its code in Jedi Script (JS) programming language. JS does not get compiled, but is delivered for execution in its source form. Sources ...
instruction
0
67,290
6
134,580
No
output
1
67,290
6
134,581
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, string "abaca" contains ugly pairs at positions ...
instruction
0
67,307
6
134,614
Tags: dfs and similar, greedy, implementation, sortings, strings Correct Solution: ``` def construct(uniq): cst = [] for i in range(1, len(uniq), 2): cst.append(uniq[i]) for i in range(0, len(uniq), 2): cst.append(uniq[i]) return cst T = int(input()) for t in range(T): s = input()...
output
1
67,307
6
134,615
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, string "abaca" contains ugly pairs at positions ...
instruction
0
67,308
6
134,616
Tags: dfs and similar, greedy, implementation, sortings, strings Correct Solution: ``` def check(odd,even): count=0 arr=odd+even for i in range(len(arr)-1): if abs(ord(arr[i])-ord(arr[i+1]))==1: count+=1 return(count) q=int(input()) for i in range(q): arr1=[] arr2=[] ...
output
1
67,308
6
134,617
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, string "abaca" contains ugly pairs at positions ...
instruction
0
67,309
6
134,618
Tags: dfs and similar, greedy, implementation, sortings, strings Correct Solution: ``` t=int(input()) while t>0: s=input() l1=[] l2=[] l3=[] for i in range(len(s)): if ord(s[i])%2==0: l1.append(s[i]) else: l2.append(s[i]) l1.sort() l2.sort() l3=l2+l1 l1=l1+l2 # print(l1) flag=0 for i in range(1,l...
output
1
67,309
6
134,619
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, string "abaca" contains ugly pairs at positions ...
instruction
0
67,310
6
134,620
Tags: dfs and similar, greedy, implementation, sortings, strings Correct Solution: ``` def solve(s): ans=[] c_count=[0] * 26 for c in s: c_count[ord(c)-ord('a')] += 1 conflicts = [c_count[i-1] + c_count[(i+1)%len(c_count)] for i in range(len(c_count))] conflicts[0] -= c_count[-1] conflic...
output
1
67,310
6
134,621
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, string "abaca" contains ugly pairs at positions ...
instruction
0
67,311
6
134,622
Tags: dfs and similar, greedy, implementation, sortings, strings Correct Solution: ``` def solve(s): odd = '' even = '' x = [] y = [] for char in s: if ord(char) % 2 == 1: x.append(char) else: y.append(char) x = sorted(x) y = sorted(y) x.reverse() ...
output
1
67,311
6
134,623
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, string "abaca" contains ugly pairs at positions ...
instruction
0
67,312
6
134,624
Tags: dfs and similar, greedy, implementation, sortings, strings Correct Solution: ``` t = int(input()) for i in range(t): string = input() odd = [] even = [] a = ord('a') for j in range(len(string)): if (ord(string[j]) - a) % 2 == 0: even.append(string[j]) else: ...
output
1
67,312
6
134,625
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, string "abaca" contains ugly pairs at positions ...
instruction
0
67,313
6
134,626
Tags: dfs and similar, greedy, implementation, sortings, strings Correct Solution: ``` t = int(input()) for i in range(t): s = input() s = sorted(s) t = s[0] k = len(s)-1 j=0 cnt=0 k=0 asd = len(s) while(cnt<(asd)): # print(j,cnt,t,s) if(j+1>=len(s)): break # print("hi", s[j+1], t[j]) if(s[j+1]==t[-...
output
1
67,313
6
134,627
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, string "abaca" contains ugly pairs at positions ...
instruction
0
67,314
6
134,628
Tags: dfs and similar, greedy, implementation, sortings, strings Correct Solution: ``` t = int(input()) al = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] hash = {} for i in range(26): hash[al[i]] = i for i in range(t): s = list(input()) s.sort() ...
output
1
67,314
6
134,629
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, s...
instruction
0
67,315
6
134,630
Yes
output
1
67,315
6
134,631
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, s...
instruction
0
67,316
6
134,632
Yes
output
1
67,316
6
134,633
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, s...
instruction
0
67,317
6
134,634
Yes
output
1
67,317
6
134,635
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, s...
instruction
0
67,318
6
134,636
Yes
output
1
67,318
6
134,637
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, s...
instruction
0
67,319
6
134,638
No
output
1
67,319
6
134,639
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, s...
instruction
0
67,320
6
134,640
No
output
1
67,320
6
134,641
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, s...
instruction
0
67,321
6
134,642
No
output
1
67,321
6
134,643
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string, consisting of lowercase Latin letters. A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, s...
instruction
0
67,322
6
134,644
No
output
1
67,322
6
134,645
Provide tags and a correct Python 3 solution for this coding contest problem. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alphabet of Bookland is so large that its letters ar...
instruction
0
67,832
6
135,664
Tags: 2-sat, dfs and similar, graphs, implementation Correct Solution: ``` from collections import defaultdict, deque def main(): n,m = map(int, input().split()) cap = [None]*(m+1) same_cap = defaultdict(list) q = deque() def apply_cap(a, c): if cap[a] is not None: return cap[a...
output
1
67,832
6
135,665
Provide tags and a correct Python 3 solution for this coding contest problem. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alphabet of Bookland is so large that its letters ar...
instruction
0
67,833
6
135,666
Tags: 2-sat, dfs and similar, graphs, implementation Correct Solution: ``` import os,io,sys input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n,m=map(int,input().split()) a=[-1]*m p=[] for i in range(n): r=list(map(int,input().split())) p.append(r) flag=0 graph0=[] graph1=[] for i in range(m): graph0.appe...
output
1
67,833
6
135,667
Provide tags and a correct Python 3 solution for this coding contest problem. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alphabet of Bookland is so large that its letters ar...
instruction
0
67,834
6
135,668
Tags: 2-sat, dfs and similar, graphs, implementation Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**15 mod = 10**9+7 def LI(): return [int(x) for x in sys.stdin.readline().split()] ...
output
1
67,834
6
135,669
Provide tags and a correct Python 3 solution for this coding contest problem. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alphabet of Bookland is so large that its letters ar...
instruction
0
67,835
6
135,670
Tags: 2-sat, dfs and similar, graphs, implementation Correct Solution: ``` # -*- coding: utf-8 -*- import math import collections import bisect import heapq import time import random import itertools """ created by shhuan at 2017/10/18 16:22 """ M, N = map(int, input().split()) words = [] for i in range(M): wo...
output
1
67,835
6
135,671
Provide tags and a correct Python 3 solution for this coding contest problem. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alphabet of Bookland is so large that its letters ar...
instruction
0
67,836
6
135,672
Tags: 2-sat, dfs and similar, graphs, implementation Correct Solution: ``` # -*- coding: utf-8 -*- import math import collections import bisect import heapq import time import random import itertools """ created by shhuan at 2017/10/18 16:22 """ M, N = map(int, input().split()) words = [] for i i...
output
1
67,836
6
135,673
Provide tags and a correct Python 3 solution for this coding contest problem. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alphabet of Bookland is so large that its letters ar...
instruction
0
67,837
6
135,674
Tags: 2-sat, dfs and similar, graphs, implementation Correct Solution: ``` import math import collections import bisect import heapq import time import random import itertools M, N = map(int, input().split()) words = [] for i in range(M): words.append([int(x) for x in input().split()][1:]) C = set() E = collections...
output
1
67,837
6
135,675
Provide tags and a correct Python 3 solution for this coding contest problem. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alphabet of Bookland is so large that its letters ar...
instruction
0
67,838
6
135,676
Tags: 2-sat, dfs and similar, graphs, implementation Correct Solution: ``` # ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction import sys import th...
output
1
67,838
6
135,677
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alpha...
instruction
0
67,839
6
135,678
No
output
1
67,839
6
135,679
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alpha...
instruction
0
67,840
6
135,680
No
output
1
67,840
6
135,681
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alpha...
instruction
0
67,841
6
135,682
No
output
1
67,841
6
135,683
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alpha...
instruction
0
67,842
6
135,684
No
output
1
67,842
6
135,685
Provide tags and a correct Python 3 solution for this coding contest problem. Pushok the dog has been chasing Imp for a few hours already. <image> Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a ...
instruction
0
67,846
6
135,692
Tags: greedy, sortings Correct Solution: ``` import functools li=[] def cmp(a,b): if (a.count('s')/len(a))<(b.count('s')/len(b)) : return 1 else: return -1 for _ in range(int(input())): s = input() li.append(s) li = sorted(li,key = functools.cmp_to_key(cmp)) li = ''.join(li) c=ans=0 for ...
output
1
67,846
6
135,693
Provide tags and a correct Python 3 solution for this coding contest problem. Pushok the dog has been chasing Imp for a few hours already. <image> Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a ...
instruction
0
67,848
6
135,696
Tags: greedy, sortings Correct Solution: ``` def key(x): try: return x.count('h') / x.count('s') except ZeroDivisionError: return 10**9 n = int(input()) t = ''.join(sorted((input() for _ in range(n)), key=key)) res, cnt = 0, 0 for ti in t: if ti == 's': cnt += 1 if ti == 'h': ...
output
1
67,848
6
135,697
Provide tags and a correct Python 3 solution for this coding contest problem. Pushok the dog has been chasing Imp for a few hours already. <image> Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a ...
instruction
0
67,849
6
135,698
Tags: greedy, sortings Correct Solution: ``` import sys def input(): return sys.stdin.readline().rstrip() class STR(): def __init__(self, x, y): self.s = x self.h = y def __gt__(self, other): ss, sh = self.s, self.h os, oh = other.s, other.h return oh*ss <= os*sh...
output
1
67,849
6
135,699
Provide a correct Python 3 solution for this coding contest problem. Taro, a junior high school student, is working on his homework. Today's homework is to read Chinese classic texts. As you know, Japanese language shares the (mostly) same Chinese characters but the order of words is a bit different. Therefore the no...
instruction
0
68,092
6
136,184
"Correct Solution: ``` import re num = re.compile(r'\d+$') def testcase_ends(): n = int(input()) if n == 0: return 1 marks = [input().replace('-', '') for i in range(n)] links = {} bares = [] labels = {} for i, mark in enumerate(marks, 1): if not mark: bares.ap...
output
1
68,092
6
136,185
Provide tags and a correct Python 3 solution for this coding contest problem. You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. T...
instruction
0
68,429
6
136,858
Tags: constructive algorithms Correct Solution: ``` def maxConsecutive(a): i = 1 curr = 0 if a[0] == '1': curr += 1 ans = curr for i in range(len(a)): if a[i] == '1': curr += 1 else: curr = 1 ans = max(ans, curr) return ans def countOne(a)...
output
1
68,429
6
136,859
Provide tags and a correct Python 3 solution for this coding contest problem. You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. T...
instruction
0
68,430
6
136,860
Tags: constructive algorithms Correct Solution: ``` a=input() b=input() coa=0 cob=0 for i in a: if i=='1': coa+=1 for i in b: if i=='1': cob+=1 if coa+(coa&1)>=cob:print('YES') else:print('NO') ```
output
1
68,430
6
136,861
Provide tags and a correct Python 3 solution for this coding contest problem. You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. T...
instruction
0
68,431
6
136,862
Tags: constructive algorithms Correct Solution: ``` def main(): a, b = (input().count('1') for _ in "ab") print(("NO", "YES")[a + (a & 1) >= b]) if __name__ == '__main__': main() ```
output
1
68,431
6
136,863
Provide tags and a correct Python 3 solution for this coding contest problem. You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. T...
instruction
0
68,432
6
136,864
Tags: constructive algorithms Correct Solution: ``` # by the authority of GOD author: manhar singh sachdev # import os,sys from io import BytesIO, IOBase def main(): a,b = input().strip(),input().strip() x,y = a.count('1'),b.count('1') if y > x+(x&1): print('NO') else: print('YES')...
output
1
68,432
6
136,865
Provide tags and a correct Python 3 solution for this coding contest problem. You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. T...
instruction
0
68,433
6
136,866
Tags: constructive algorithms Correct Solution: ``` a, b = input(), input() x, y = a.count('1'), b.count('1') print('YNEOS'[x + (x & 1) < y :: 2]) ```
output
1
68,433
6
136,867
Provide tags and a correct Python 3 solution for this coding contest problem. You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. T...
instruction
0
68,434
6
136,868
Tags: constructive algorithms Correct Solution: ``` #------------------------template--------------------------# import os import sys from math import * from collections import * from fractions import * from bisect import * from heapq import* from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt...
output
1
68,434
6
136,869
Provide tags and a correct Python 3 solution for this coding contest problem. You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. T...
instruction
0
68,435
6
136,870
Tags: constructive algorithms Correct Solution: ``` a = input() b = input() na = 0 nb = 0 for i in a: if i == '1': na = na + 1 for i in b: if i == '1': nb = nb + 1 if na < nb and na % 2 == 0: print("NO") elif na < nb and nb - na > 1: print("NO") else: print("YES") ```
output
1
68,435
6
136,871
Provide tags and a correct Python 3 solution for this coding contest problem. You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. T...
instruction
0
68,436
6
136,872
Tags: constructive algorithms Correct Solution: ``` a = input() b = input() print('YES' if b.count('1') <= a.count('1') + (a.count('1') & 1) else 'NO') ```
output
1
68,436
6
136,873
Provide tags and a correct Python 3 solution for this coding contest problem. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of t...
instruction
0
68,547
6
137,094
Tags: divide and conquer, hashing, sortings, strings Correct Solution: ``` from collections import Counter s = input().strip() t = input().strip() def solution(a, b): def simulate(s, t, l): if s == t: return True if l%2 == 0: l //= 2 return ((simulate(s[:l], t[...
output
1
68,547
6
137,095
Provide tags and a correct Python 3 solution for this coding contest problem. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of t...
instruction
0
68,548
6
137,096
Tags: divide and conquer, hashing, sortings, strings Correct Solution: ``` def isEqual(a, b): for i in range(0, len(a)): if (a[i] != b[i]): return False return True def lexicographic_minimal_string(s): if (len(s) % 2 == 1): return s half = int(len(s) /2) s1 = lexicographic_minimal_string(s[:half]) s2 ...
output
1
68,548
6
137,097
Provide tags and a correct Python 3 solution for this coding contest problem. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of t...
instruction
0
68,549
6
137,098
Tags: divide and conquer, hashing, sortings, strings Correct Solution: ``` def isEq(a,b,la,lb): if (la + lb ==2) or la%2 == 1 or lb%2 == 1: if a == b: return True else: return False else: a1 = a[:la//2] a2 = a[la//2:] b1 = b[:lb//2] b2 = b[...
output
1
68,549
6
137,099
Provide tags and a correct Python 3 solution for this coding contest problem. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of t...
instruction
0
68,551
6
137,102
Tags: divide and conquer, hashing, sortings, strings Correct Solution: ``` first_string = input() second_string = input() def prepare_string(s): if(len(s) % 2 != 0): return s str1 = prepare_string(s[0:int(len(s)/2)]) str2 = prepare_string(s[int(len(s)/2):len(s)]) if(str1 < str2): ret...
output
1
68,551
6
137,103
Provide tags and a correct Python 3 solution for this coding contest problem. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of t...
instruction
0
68,552
6
137,104
Tags: divide and conquer, hashing, sortings, strings Correct Solution: ``` def equivalent(lhs, rhs): if lhs == rhs: return True if len(lhs) % 2 == 1: return lhs == rhs length = len(lhs) mid = length // 2 lhs1 = lhs[:mid] lhs2 = lhs[mid:] rhs1 = rhs[:mid] rhs2 = rhs[mid:]...
output
1
68,552
6
137,105
Provide tags and a correct Python 3 solution for this coding contest problem. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of t...
instruction
0
68,554
6
137,108
Tags: divide and conquer, hashing, sortings, strings Correct Solution: ``` def pairSort(s): l = len(s) if l%2: return s left = pairSort(s[:l//2]) right = pairSort(s[l//2:]) s = left + right if left>right else right+left return s s = input().strip() t = input().strip() s = pairSort(s) t ...
output
1
68,554
6
137,109
Provide a correct Python 3 solution for this coding contest problem. Gotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order. A word is call...
instruction
0
68,765
6
137,530
"Correct Solution: ``` A=input() l=set(chr(ord('a') + i) for i in range(26)) l2=list(l-set(A)) l2.sort() if len(A)!=26: print(A+l2[0]) else: for i in reversed(range(25)): for j in reversed(range(i+1,26)): if A[i] < A[j]: print(A[:i]+A[j]) exit() else: print(-1) ```
output
1
68,765
6
137,531
Provide a correct Python 3 solution for this coding contest problem. Gotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order. A word is call...
instruction
0
68,766
6
137,532
"Correct Solution: ``` S = input() a = [chr(ord('a') + i) for i in range(26)] for l in S: a.remove(l) if a != []: print(S+a[0]) else: b = [] k = 1 for l in reversed(S): b.append(l) b.sort() if b[-1] != l: print(S[0:-k]+b[b.index(l)+1]) break k+...
output
1
68,766
6
137,533
Provide a correct Python 3 solution for this coding contest problem. Gotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order. A word is call...
instruction
0
68,767
6
137,534
"Correct Solution: ``` s = s0 = input() d = {chr(c) for c in range(97, 123)} for c in s: d.remove(c) if d: s += min(d) else: for c in reversed(s): s = s[:-1] if d and any(c < e for e in d): s += min(e for e in d if c < e) break d.add(c) print(s if s else -1) i...
output
1
68,767
6
137,535
Provide a correct Python 3 solution for this coding contest problem. Gotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order. A word is call...
instruction
0
68,768
6
137,536
"Correct Solution: ``` import string S = input() abc = string.ascii_lowercase if len(S) == 26: for i in range(24, -1, -1): cand = list(S[i+1:]) cand.sort() for c in cand: if ord(c) > ord(S[i]): print(S[:i]+c) exit(0) print(-1) else: for l...
output
1
68,768
6
137,537