message
stringlengths
2
23.8k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
97
109k
cluster
float64
0
0
__index_level_0__
int64
194
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jenya has recently acquired quite a useful tool — k-scissors for cutting strings. They are generally used for cutting out two non-intersecting substrings of length k from an arbitrary string s (...
instruction
0
1,422
0
2,844
No
output
1
1,422
0
2,845
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jenya has recently acquired quite a useful tool — k-scissors for cutting strings. They are generally used for cutting out two non-intersecting substrings of length k from an arbitrary string s (...
instruction
0
1,423
0
2,846
No
output
1
1,423
0
2,847
Provide a correct Python 3 solution for this coding contest problem. You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_...
instruction
0
1,492
0
2,984
"Correct Solution: ``` n, q = map(int, input().split()) s = input() a = [0, 0] for i in range(2, n + 1): a.append(a[i - 1] + (s[i - 2:i] == 'AC')) for _ in range(q): li, ri = map(int, input().split()) print(a[ri] - a[li]) ```
output
1
1,492
0
2,985
Provide a correct Python 3 solution for this coding contest problem. You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_...
instruction
0
1,493
0
2,986
"Correct Solution: ``` n,q = map(int,input().split()) s = input() t = [0] * (n+1) for i in range(n): t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0) #print (t) for _ in range(q): l,r = map(int,input().split()) print (t[r-1]-t[l-1]) ```
output
1
1,493
0
2,987
Provide a correct Python 3 solution for this coding contest problem. You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_...
instruction
0
1,494
0
2,988
"Correct Solution: ``` n,q=map(int,input().split()) s=input() a = [0] * n num = 0 for i in range(1, n): if s[i]=='C' and s[i-1]=='A': num += 1 a[i] = num for _ in range(q): l,r=map(int,input().split()) print(a[r-1] - a[l-1]) ```
output
1
1,494
0
2,989
Provide a correct Python 3 solution for this coding contest problem. You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_...
instruction
0
1,495
0
2,990
"Correct Solution: ``` n, q = (int(x) for x in input().split()) s = input() t = [0]*(n+1) for i in range(n): t[i+1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0) for i in range(q): l,r = (int(x) for x in input().split()) print(t[r-1]-t[l-1]) ```
output
1
1,495
0
2,991
Provide a correct Python 3 solution for this coding contest problem. You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_...
instruction
0
1,496
0
2,992
"Correct Solution: ``` n, q = map(int, input().split()) s=input() d=[0]*n c=0 for i in range(n-1): if s[i:i+2]=="AC": c+=1 d[i+1]=c for i in range(q): l,r= map(int, input().split()) print(d[r-1]-d[l-1]) ```
output
1
1,496
0
2,993
Provide a correct Python 3 solution for this coding contest problem. You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_...
instruction
0
1,497
0
2,994
"Correct Solution: ``` n, q = map(int, input().split()) s = input() a = [list(map(int, input().split())) for i in range(q)] c = [0] * n for i in range(1,n): c[i] = c[i-1] + (s[i-1]+s[i] == 'AC') for x in a: print(c[x[1]-1]-c[x[0]-1]) ```
output
1
1,497
0
2,995
Provide a correct Python 3 solution for this coding contest problem. You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_...
instruction
0
1,498
0
2,996
"Correct Solution: ``` n,q=map(int,input().split()) s=input() l=[list(map(int,input().split())) for i in range(q)] L=[0];ct=0 for i in range(n-1): if s[i:i+2]=='AC': ct+=1 L.append(ct) for j in range(q): print(L[l[j][1]-1]-L[l[j][0]-1]) ```
output
1
1,498
0
2,997
Provide a correct Python 3 solution for this coding contest problem. You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_...
instruction
0
1,499
0
2,998
"Correct Solution: ``` n, q = map(int, input().split()) S = input() t = [0] * (n + 1) for i in range(n): t[i + 1] = t[i] + (1 if S[i : i+2] == "AC" else 0) for i in range(q): l, r = map(int, input().split()) print(t[r-1] - t[l-1]) ```
output
1
1,499
0
2,999
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 S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \...
instruction
0
1,500
0
3,000
Yes
output
1
1,500
0
3,001
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 S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \...
instruction
0
1,501
0
3,002
Yes
output
1
1,501
0
3,003
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 S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \...
instruction
0
1,502
0
3,004
Yes
output
1
1,502
0
3,005
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 S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \...
instruction
0
1,503
0
3,006
Yes
output
1
1,503
0
3,007
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 S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \...
instruction
0
1,504
0
3,008
No
output
1
1,504
0
3,009
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 S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \...
instruction
0
1,506
0
3,012
No
output
1
1,506
0
3,013
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 S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \...
instruction
0
1,507
0
3,014
No
output
1
1,507
0
3,015
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and has exactly a characters '0' and exactly b cha...
instruction
0
1,885
0
3,770
Tags: constructive algorithms, implementation, strings Correct Solution: ``` for _ in range(int(input())): a,b = map(int,input().split()) s = input() n = len(s) if a+b != n or (a%2==1 and b%2==1): print("-1") else: x = y = z = 0 f = 0 l1 = ["0"]*(n//2) l2 = ["...
output
1
1,885
0
3,771
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and has exactly a characters '0' and exactly b cha...
instruction
0
1,886
0
3,772
Tags: constructive algorithms, implementation, strings Correct Solution: ``` # coding: utf-8 for ct in range(int(input())): a, b = map(int, input().split()) n = a + b s = list(input()) for i in range(n): if s[i] == '?': s[i] = s[n - i - 1] a -= s.count('0') b -= s.count('1') for i ...
output
1
1,886
0
3,773
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and has exactly a characters '0' and exactly b cha...
instruction
0
1,887
0
3,774
Tags: constructive algorithms, implementation, strings Correct Solution: ``` def abpal(): a, b = map(int, input().split()) s = input() n = len(s) if a + b != n: return -1 if a%2 != 0 and b%2 != 0: return -1 if n == 1: if a == 1 and s == '0': return s i...
output
1
1,887
0
3,775
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and has exactly a characters '0' and exactly b cha...
instruction
0
1,888
0
3,776
Tags: constructive algorithms, implementation, strings Correct Solution: ``` '''9 4 4 01?????0 3 3 ?????? 1 0 ? 2 2 0101 2 2 01?0 0 1 0 0 3 1?1 2 2 ?00? 4 3 ??010?0 ''' def f(zeros, ones, s): existing_ones = s.count('1') existing_zeros = s.count('0') needed_zeros = zeros - existing_zeros needed_ones ...
output
1
1,888
0
3,777
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and has exactly a characters '0' and exactly b cha...
instruction
0
1,889
0
3,778
Tags: constructive algorithms, implementation, strings Correct Solution: ``` def main(): t=int(input()) allans=[] for _ in range(t): a,b=readIntArr() n=a+b arr=list(input()) possible=True l=0 r=n-1 while l<=r: if l==r: ...
output
1
1,889
0
3,779
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and has exactly a characters '0' and exactly b cha...
instruction
0
1,890
0
3,780
Tags: constructive algorithms, implementation, strings Correct Solution: ``` t = int(input()) while t: t -= 1 a0,b1 = map(int, input().split()) a = list(input()) n = len(a) l = 0 r = n-1 cnt0 = 0 cnt1 = 0 flag = False while l <= r: if l == r: if a[l] == '0': ...
output
1
1,890
0
3,781
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and has exactly a characters '0' and exactly b cha...
instruction
0
1,891
0
3,782
Tags: constructive algorithms, implementation, strings Correct Solution: ``` for i in range(int(input())): a, b = map(int, input().split()) arr = list(input()) n = a+b mid = n%2 and arr[n//2] == '?' repeats = [] a_ = 0 b_ = 0 if n%2: if arr[n//2] == '0': a_ += 1 ...
output
1
1,891
0
3,783
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and has exactly a characters '0' and exactly b cha...
instruction
0
1,892
0
3,784
Tags: constructive algorithms, implementation, strings Correct Solution: ``` import math rr = input rri = lambda: int(rr()) rrm = lambda: list(map(int, rr().split())) T = rri() def split(word): return [char for char in word] def solve(): a, b = rrm() s = split(input()) if a % 2 == 1 and b % 2 == 1: ...
output
1
1,892
0
3,785
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 s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and...
instruction
0
1,893
0
3,786
Yes
output
1
1,893
0
3,787
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 s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and...
instruction
0
1,894
0
3,788
Yes
output
1
1,894
0
3,789
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 s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and...
instruction
0
1,895
0
3,790
Yes
output
1
1,895
0
3,791
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 s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and...
instruction
0
1,896
0
3,792
Yes
output
1
1,896
0
3,793
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 s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and...
instruction
0
1,897
0
3,794
No
output
1
1,897
0
3,795
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 s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and...
instruction
0
1,898
0
3,796
No
output
1
1,898
0
3,797
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 s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and...
instruction
0
1,899
0
3,798
No
output
1
1,899
0
3,799
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 s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and...
instruction
0
1,900
0
3,800
No
output
1
1,900
0
3,801
Provide tags and a correct Python 3 solution for this coding contest problem. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t t...
instruction
0
2,005
0
4,010
Tags: constructive algorithms, strings Correct Solution: ``` s, t = input(), input() for i in range(len(s)): if s[i] == 'z': continue c = chr(ord(s[i]) + 1) str = s[0:i] + c + ('a' * (len(s) - i - 1)); if (str < t) : print(str) exit(); print("No such string") ```
output
1
2,005
0
4,011
Provide tags and a correct Python 3 solution for this coding contest problem. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t t...
instruction
0
2,006
0
4,012
Tags: constructive algorithms, strings Correct Solution: ``` # In case of length of s and t equal 1 # Calculate difference between s and t # If difference is larger than 1 # Print next alphabet character in ASCII table # Else # Print 'No such string' # Else # Create a new string which is a clone of s # ...
output
1
2,006
0
4,013
Provide tags and a correct Python 3 solution for this coding contest problem. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t t...
instruction
0
2,007
0
4,014
Tags: constructive algorithms, strings Correct Solution: ``` s = input() t = input() s = [i for i in s] t = [i for i in t] i = len(s)-1 while(i>=0): if(s[i]=='z'): s[i] = 'a' else: a = ord(s[i])+1 s[i] = chr(a) break i -= 1 s = ''.join(s) t = ''.join(t) if(s>=t): print('N...
output
1
2,007
0
4,015
Provide tags and a correct Python 3 solution for this coding contest problem. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t t...
instruction
0
2,008
0
4,016
Tags: constructive algorithms, strings Correct Solution: ``` # http://codeforces.com/problemset/problem/169/A # A. Chores def read_input(): a = input() b = input() return (a, b) def do_middle_string(a, b): c = list(a) for i in range(len(c) - 1, -1, -1): # print(i) if c[i] == 'z':...
output
1
2,008
0
4,017
Provide tags and a correct Python 3 solution for this coding contest problem. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t t...
instruction
0
2,009
0
4,018
Tags: constructive algorithms, strings Correct Solution: ``` s = input() t = input() index = len(s)-1 y = ord("z") while index >= 0: x = ord(s[index]) if x < y: s = s[0:index]+chr(x+1)+"a"*(len(t)-index-1) break index -=1 if s == t: print("No such string") else: print(s) ```
output
1
2,009
0
4,019
Provide tags and a correct Python 3 solution for this coding contest problem. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t t...
instruction
0
2,010
0
4,020
Tags: constructive algorithms, strings Correct Solution: ``` s = input() t = input() k = 1 stri = "" for i in s[::-1]: m= ord(i) + k if m> 122: k = 1 stri += "a" else: k= 0 stri += chr(m) if stri[::-1] == t: print("No such string") else: print(stri[::-1]) ```
output
1
2,010
0
4,021
Provide tags and a correct Python 3 solution for this coding contest problem. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t t...
instruction
0
2,011
0
4,022
Tags: constructive algorithms, strings Correct Solution: ``` s = list(input()) t = list(input()) for i in range(len(s) - 1, -1, -1): if s[i] == 'z': s[i] = 'a' else: s[i] = chr(ord(s[i]) + 1) break print(''.join(s) if s < t else "No such string") ```
output
1
2,011
0
4,023
Provide tags and a correct Python 3 solution for this coding contest problem. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t t...
instruction
0
2,012
0
4,024
Tags: constructive algorithms, strings Correct Solution: ``` s = input().strip() t = input().strip() r = list(s) for i in range(len(s)-1, -1, -1): if s[i] == 'z': r[i] = 'a' else: r[i] = chr(ord(s[i]) + 1) break r = ''.join(r) if t == r: print("No such string") else: print(r) ```
output
1
2,012
0
4,025
Provide tags and a correct Python 2 solution for this coding contest problem. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t t...
instruction
0
2,013
0
4,026
Tags: constructive algorithms, strings Correct Solution: ``` from __future__ import print_function # python 3 default def main(): s = list(raw_input()) t = list(raw_input()) # map to ascii code s_num = map(ord, s) t_num = map(ord, t) s_plus1 = list(s_num) # z = 122 for i in range(len(s...
output
1
2,013
0
4,027
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson...
instruction
0
2,017
0
4,034
Yes
output
1
2,017
0
4,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson...
instruction
0
2,018
0
4,036
No
output
1
2,018
0
4,037
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson...
instruction
0
2,021
0
4,042
No
output
1
2,021
0
4,043
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string q. A sequence of k strings s1, s2, ..., sk is called beautiful, if the concatenation of these strings is string q (formally, s1 + s2 + ... + sk = q) and the first characters of these strings are distinct. Find any bea...
instruction
0
2,022
0
4,044
Tags: implementation, strings Correct Solution: ``` n = int(input()) t = input() if n > len(set(t)): print('NO') else: pos = [0 for _ in range(len(t)+1)] dis = set() c = 0 for i in range(len(t)): if t[i] not in dis: dis.add(t[i]) pos[c] = i c = c+1 pos...
output
1
2,022
0
4,045
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string q. A sequence of k strings s1, s2, ..., sk is called beautiful, if the concatenation of these strings is string q (formally, s1 + s2 + ... + sk = q) and the first characters of these strings are distinct. Find any bea...
instruction
0
2,023
0
4,046
Tags: implementation, strings Correct Solution: ``` import sys k = int(input()) q = input() if len(set(q)) < k: print('NO') else: first = '' s = '' print('YES') for i in range(len(q)): if q[i] not in first: if len(s) > 0: print(s) s ='' ...
output
1
2,023
0
4,047
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string q. A sequence of k strings s1, s2, ..., sk is called beautiful, if the concatenation of these strings is string q (formally, s1 + s2 + ... + sk = q) and the first characters of these strings are distinct. Find any bea...
instruction
0
2,024
0
4,048
Tags: implementation, strings Correct Solution: ``` k = int(input()) q = input() b = [] for x in range(len(q)): if q[0: x + 1].count(q[x]) == 1: b.append(q[x]) else: b[-1] += q[x] if len(b) >= k: print("YES") for x in range(k-1): print(b[x]) for y in range(k, len(b)): b[k-1] += b[y] print(b[...
output
1
2,024
0
4,049
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string q. A sequence of k strings s1, s2, ..., sk is called beautiful, if the concatenation of these strings is string q (formally, s1 + s2 + ... + sk = q) and the first characters of these strings are distinct. Find any bea...
instruction
0
2,025
0
4,050
Tags: implementation, strings Correct Solution: ``` n = int(input()) s = list(str(input())) dif = list(dict.fromkeys(s)) ans = [] if(n==1): print('YES') print(''.join(s)) else: cur = 0 pnt = 0 lst = s[0] cnt = 1 used = [s[0]] for i in range(len(s)): if(s[i] not in used): ...
output
1
2,025
0
4,051
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a string q. A sequence of k strings s1, s2, ..., sk is called beautiful, if the concatenation of these strings is string q (formally, s1 + s2 + ... + sk = q) and the first characters of these strings are distinct. Find any bea...
instruction
0
2,026
0
4,052
Tags: implementation, strings Correct Solution: ``` n = int(input()) s = input() arr = [] for i in range(len(s)): if s[i] not in s[:i]: arr.append(i) if (len(arr) < n): print('NO') exit() print('YES') for i in range(n - 1): print(s[arr[i] : arr[i + 1]]) if len(arr) >= n: print(s[arr[n - 1] :...
output
1
2,026
0
4,053