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 |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all b... | instruction | 0 | 4,718 | 6 | 9,436 |
Tags: brute force, implementation
Correct Solution:
```
n,k = map(int, input().split())
s = input()
r = [0]*26
y=0
for i in s:
nomer = ord(i)-97
r[nomer] +=1
for i in range(len(r)):
if r[i] >k and r[i] !=0:
y+=1
if y>0:
print('NO')
elif y==0:
print('YES')
``` | output | 1 | 4,718 | 6 | 9,437 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all b... | instruction | 0 | 4,719 | 6 | 9,438 |
Tags: brute force, implementation
Correct Solution:
```
n, k = map(int, input().split())
b = list(input())
a = {}
s = 0
for i in b:
a[i] = a.get(i, 0) + 1
for i in a:
if a[i] > s:
s = a[i]
if s > k:
print('NO')
else:
print('YES')
``` | output | 1 | 4,719 | 6 | 9,439 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all b... | instruction | 0 | 4,720 | 6 | 9,440 |
Tags: brute force, implementation
Correct Solution:
```
n, k = map(int, input().split())
s = input()
l = set(list(s))
a = [s.count(i) for i in l]
if max(a) > k:
print('NO')
else:
print('YES')
``` | output | 1 | 4,720 | 6 | 9,441 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all b... | instruction | 0 | 4,721 | 6 | 9,442 |
Tags: brute force, implementation
Correct Solution:
```
n,k=map(int,input().split())
a=input()
d={}
for i in a:
d[i]=d.get(i,0)+1
for i in d:
if d[i]>k:
print('NO')
break
else:
print('YES')
# n,k=map(int,input().split())
# a=input()
# d={}
# kol=0
# kolkol=0
# for i in a:
# d[i]=d.get(... | output | 1 | 4,721 | 6 | 9,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all b... | instruction | 0 | 4,722 | 6 | 9,444 |
Tags: brute force, implementation
Correct Solution:
```
n, k = list(map(int, input().split()))
s = list(input())
unique = set(s)
count = {}
for i in s:
count[i] = count.get(i, 0) + 1
values = [count[c] for c in unique]
values.sort(reverse=True)
assign = [[] for i in range(k)]
each = n//k
rem = n%k
for i in range... | output | 1 | 4,722 | 6 | 9,445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Le... | instruction | 0 | 5,220 | 6 | 10,440 |
Tags: implementation
Correct Solution:
```
def rhyme(a,b,k):
v=["a","e","i","o","u"]
i_a=None
i_b=None
v_a=0
v_b=0
for i in range(len(a)-1,-1,-1):
if a[i] in v:
v_a+=1
if v_a==k:
i_a=i
break
for i in range(len(b)-1,-1,-1):
if b[i] in v:
v_b+=1
if v_b==k:
i... | output | 1 | 5,220 | 6 | 10,441 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Le... | instruction | 0 | 5,221 | 6 | 10,442 |
Tags: implementation
Correct Solution:
```
#from bisect import bisect_left as bl #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br #c++ upperbound br(array,element)
#from __future__ import print_function, division #while using python2
# from itertools import accumu... | output | 1 | 5,221 | 6 | 10,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Le... | instruction | 0 | 5,222 | 6 | 10,444 |
Tags: implementation
Correct Solution:
```
n,k = map(int,input().split())
lis=[]
vov=['a','e','i','o','u']
d={}
d['aabb']=d['abab']=d['abba']=d['aaaa']=0
for i in range(n*4):
s = input()
lis.append(s)
if i%4==3:
tmp=['']*4
for j in range(4):
s=lis[j]
c=0
c... | output | 1 | 5,222 | 6 | 10,445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Le... | instruction | 0 | 5,223 | 6 | 10,446 |
Tags: implementation
Correct Solution:
```
n, k = map(int, input().split())
ve = 'aeiou'
abba, aabb, abab = 1, 1, 1
for j in range(n):
a = ['']*4
for i in range(4):
a[i] = input()
l = len(a[i])
curr = 0
while l > 0 and curr < k:
l -= 1
if a[i][l... | output | 1 | 5,223 | 6 | 10,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Le... | instruction | 0 | 5,224 | 6 | 10,448 |
Tags: implementation
Correct Solution:
```
n, k = map(int, input().split())
vowels = ['a', 'e', 'i', 'o', 'u']
def find_nth(tab, S, n):
amount, pos = (1 if tab[0] in S else 0), 0
while pos < len(tab) and amount < n:
pos += 1
if tab[pos] in S:
amount += 1
return pos
def rhyme_... | output | 1 | 5,224 | 6 | 10,449 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Le... | instruction | 0 | 5,225 | 6 | 10,450 |
Tags: implementation
Correct Solution:
```
n, k = map(int, input().split())
def get_suffix(line):
position = 0
for _ in range(k):
position -= 1
while -position <= len(line) and line[position] not in 'aeiou':
position -= 1
if -position > len(line):
return ''
... | output | 1 | 5,225 | 6 | 10,451 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Le... | instruction | 0 | 5,226 | 6 | 10,452 |
Tags: implementation
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', 'r')
... | output | 1 | 5,226 | 6 | 10,453 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Le... | instruction | 0 | 5,227 | 6 | 10,454 |
Tags: implementation
Correct Solution:
```
from sys import stdin
read = stdin.readline
n,k = map(int,read().split())
r = 0
vowel = {'a','e','i','o','u'}
def cmp(a,b,k,vowel):
l = 0
for x,y in zip(reversed(a),reversed(b)):
if x != y:
return False
l += (x in vowel)
if l == k... | output | 1 | 5,227 | 6 | 10,455 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist ... | instruction | 0 | 5,228 | 6 | 10,456 |
No | output | 1 | 5,228 | 6 | 10,457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist ... | instruction | 0 | 5,229 | 6 | 10,458 |
No | output | 1 | 5,229 | 6 | 10,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist ... | instruction | 0 | 5,230 | 6 | 10,460 |
No | output | 1 | 5,230 | 6 | 10,461 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist ... | instruction | 0 | 5,231 | 6 | 10,462 |
No | output | 1 | 5,231 | 6 | 10,463 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n.... | instruction | 0 | 5,339 | 6 | 10,678 |
Tags: binary search, constructive algorithms, greedy
Correct Solution:
```
s = input()
n = int(input())
d = {}
r = 0
for a in s:
d.setdefault(a, 0)
d[a] += 1
if(d[a] > r):
r = d[a]
if (len(d) > n):
print(-1)
else:
l = 0
while r - l > 1:
k = (l + r) // 2
cur = 0
fo... | output | 1 | 5,339 | 6 | 10,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n.... | instruction | 0 | 5,341 | 6 | 10,682 |
Tags: binary search, constructive algorithms, greedy
Correct Solution:
```
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or ... | output | 1 | 5,341 | 6 | 10,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n.... | instruction | 0 | 5,342 | 6 | 10,684 |
Tags: binary search, constructive algorithms, greedy
Correct Solution:
```
import math
from sys import stdin
from math import ceil
if __name__ == '__main__':
s = input()
n = int(input())
dictionary = {}
for i in s:
if i in dictionary:
dictionary[i] = dictionary[i] + 1
else:... | output | 1 | 5,342 | 6 | 10,685 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n.... | instruction | 0 | 5,343 | 6 | 10,686 |
Tags: binary search, constructive algorithms, greedy
Correct Solution:
```
from math import ceil
s = input ()
n = int (input ())
count = {}
for i in s:
if i in count:
count[i] += 1
else:
count[i] = 1
if len(count) > n:
print (-1)
else:
if len(s) < n:
print (1)
ret = s
else:
l,h = len (s)/... | output | 1 | 5,343 | 6 | 10,687 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n.... | instruction | 0 | 5,344 | 6 | 10,688 |
Tags: binary search, constructive algorithms, greedy
Correct Solution:
```
s = input()
n = int(input())
symb_cnt = {}
for c in s:
symb_cnt[c] = symb_cnt[c] + 1 if c in symb_cnt else 1
for cnt in range(1, len(s) + 1):
s1 = ""
for c in symb_cnt:
s1 += c * ((symb_cnt[c] + cnt - 1) // cnt)
if len(s1) <= n:
for i i... | output | 1 | 5,344 | 6 | 10,689 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n.... | instruction | 0 | 5,345 | 6 | 10,690 |
Tags: binary search, constructive algorithms, greedy
Correct Solution:
```
from collections import Counter
def main():
s = input()
l = int(input())
d = Counter(s)
if len(d) > l:
print(-1)
return
lo = 0
hi = 10000
while lo + 1 < hi:
mid = (lo + hi) // 2
c = 0... | output | 1 | 5,345 | 6 | 10,691 |
Provide tags and a correct Python 3 solution for this coding contest problem.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, ... | instruction | 0 | 5,462 | 6 | 10,924 |
Tags: dp, implementation, strings
Correct Solution:
```
s = input()
possible = [[],[],[False]*10100, [False]*10100]
length = len(s)
possible[2][length-2] = True
possible[3][length-3] = True
for i in range(length-1, 5-1,-1):
if length - 4 >= i:
possible[2][i] = (possible[2][i+2] and s[i:i+2] != s[i+2:i+4]... | output | 1 | 5,462 | 6 | 10,925 |
Provide tags and a correct Python 3 solution for this coding contest problem.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, ... | instruction | 0 | 5,463 | 6 | 10,926 |
Tags: dp, implementation, strings
Correct Solution:
```
import sys
value = input()
if (len(value) < 7):
print(0)
sys.exit(0)
res = set()
possible = {}
possible[len(value)] = set([2])
if (len(value) > 7):
possible[len(value)].add(3)
possibleLen = [2, 3]
for i in reversed(range(7, len(value) + 1)):
pos... | output | 1 | 5,463 | 6 | 10,927 |
Provide tags and a correct Python 3 solution for this coding contest problem.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, ... | instruction | 0 | 5,464 | 6 | 10,928 |
Tags: dp, implementation, strings
Correct Solution:
```
from sys import *
setrecursionlimit(20000)
dp = []
ans = []
def fun(s, pos, r, ln):
if pos <= 4+ln:
return 0
if dp[pos][ln-2] != 0:
return dp[pos][ln-2]
if s[pos-ln:pos] != r:
dp[pos][ln-2] = 1 + fun(s, pos - ln, s[pos-ln:pos],2) + fun(s, pos - ln, s[pos-... | output | 1 | 5,464 | 6 | 10,929 |
Provide tags and a correct Python 3 solution for this coding contest problem.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, ... | instruction | 0 | 5,465 | 6 | 10,930 |
Tags: dp, implementation, strings
Correct Solution:
```
s = input()
n = len(s)
s += '0000000000'
dp = [[0] * 2 for i in range(n + 5)]
dp[n] = [1, 1]
res = set()
for i in range(n - 1, 4, -1):
if i + 2 <= n and ((dp[i + 2][0] and s[i: i + 2] != s[i + 2: i + 4]) or dp[i + 2][1]):
res.add(s[i: i + 2])
d... | output | 1 | 5,465 | 6 | 10,931 |
Provide tags and a correct Python 3 solution for this coding contest problem.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, ... | instruction | 0 | 5,466 | 6 | 10,932 |
Tags: dp, implementation, strings
Correct Solution:
```
__author__ = 'Utena'
s=input()
n=len(s)
ans=set()
if n<=6:
print(0)
exit(0)
dp=[[False,False]for i in range(n+1)]
if n>7:
dp[3][1]=True
ans.add(s[-3:])
dp[2][0]=True
ans.add(s[-2:])
for i in range(4,n-4):
if s[(-i):(-i+2)]!=s[(-i+2):(-i+3)]+s[... | output | 1 | 5,466 | 6 | 10,933 |
Provide tags and a correct Python 3 solution for this coding contest problem.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, ... | instruction | 0 | 5,467 | 6 | 10,934 |
Tags: dp, implementation, strings
Correct Solution:
```
def main():
s = input()[5:]
n = len(s)
if n < 2:
print(0)
return
res2, res3 = set(), set()
dp2 = [False] * (n + 1)
dp3 = [False] * (n + 1)
dp2[-1] = dp3[-1] = True
for i in range(n, 1, -1):
if dp3[i] or dp2[i... | output | 1 | 5,467 | 6 | 10,935 |
Provide tags and a correct Python 3 solution for this coding contest problem.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, ... | instruction | 0 | 5,468 | 6 | 10,936 |
Tags: dp, implementation, strings
Correct Solution:
```
def getPossibleSuffixes(s):
if len(s) == 5:
print(0)
return
possible_suffixes = s[5:len(s)]
suffixes = []
helper_hash = {}
suffix_starts = [0 for x in range(len(possible_suffixes))]
prev_2 = ["" for x in range(len(possible_s... | output | 1 | 5,468 | 6 | 10,937 |
Provide tags and a correct Python 3 solution for this coding contest problem.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, ... | instruction | 0 | 5,469 | 6 | 10,938 |
Tags: dp, implementation, strings
Correct Solution:
```
string = input()
s = set()
finded = {}
import sys
sys.setrecursionlimit(900000000)
def get_substr(string, start, parent):
# базовый случай
if start >= len(string):
return
if start+1 < len(string):
substr = string[start:start+... | output | 1 | 5,469 | 6 | 10,939 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to ... | instruction | 0 | 5,470 | 6 | 10,940 |
Yes | output | 1 | 5,470 | 6 | 10,941 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to ... | instruction | 0 | 5,471 | 6 | 10,942 |
Yes | output | 1 | 5,471 | 6 | 10,943 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to ... | instruction | 0 | 5,472 | 6 | 10,944 |
Yes | output | 1 | 5,472 | 6 | 10,945 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to ... | instruction | 0 | 5,473 | 6 | 10,946 |
Yes | output | 1 | 5,473 | 6 | 10,947 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to ... | instruction | 0 | 5,474 | 6 | 10,948 |
No | output | 1 | 5,474 | 6 | 10,949 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to ... | instruction | 0 | 5,475 | 6 | 10,950 |
No | output | 1 | 5,475 | 6 | 10,951 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to ... | instruction | 0 | 5,476 | 6 | 10,952 |
No | output | 1 | 5,476 | 6 | 10,953 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to ... | instruction | 0 | 5,477 | 6 | 10,954 |
No | output | 1 | 5,477 | 6 | 10,955 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret... | instruction | 0 | 5,531 | 6 | 11,062 |
Tags: constructive algorithms, strings
Correct Solution:
```
def rek(k):
if k == 1:
return ('a', 'a')
elif k == 2:
return ('aa', 'a')
s, p = rek((k - 1) // 2)
x = chr(ord(p[-1]) + 1)
return (p + x * (2 - k % 2) + s[len(p):] + 2 * x, p + x)
s, p = rek(int(input()))
print(s, p)
``` | output | 1 | 5,531 | 6 | 11,063 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret... | instruction | 0 | 5,532 | 6 | 11,064 |
Tags: constructive algorithms, strings
Correct Solution:
```
def getstr(n):
if n==1:
return 'a','',1
elif n==2:
return 'ab','b',2
else:
if n%2==0:
p,u,now=getstr((n-2)//2)
c = chr(ord('a')+now)
return p+c,c+u+c+c,now+1
else:
p,u... | output | 1 | 5,532 | 6 | 11,065 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret... | instruction | 0 | 5,533 | 6 | 11,066 |
Tags: constructive algorithms, strings
Correct Solution:
```
def solve(k):
if k == 1:
return ('a', 'a')
if k == 2:
return ('aa', 'a')
s, p = solve((k-1) // 2)
x = chr(ord(p[-1])+1)
return (p+x*(2-k%2)+s[len(p):]+x*2, p+x)
s, p = solve(int(input()))
print(s, p)
``` | output | 1 | 5,533 | 6 | 11,067 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret... | instruction | 0 | 5,534 | 6 | 11,068 |
Tags: constructive algorithms, strings
Correct Solution:
```
import string
alphabet = list(string.ascii_lowercase + string.ascii_uppercase)
def calc(n):
if n == 1:
return '', 'a'
if n == 2:
return 'a', 'a'
if n % 2 == 1:
u, p = calc(n//2)
x = alphabet.pop()
return u... | output | 1 | 5,534 | 6 | 11,069 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.
Given the list of strings, output the lexicographically smallest con... | instruction | 0 | 6,237 | 6 | 12,474 |
Tags: sortings, strings
Correct Solution:
```
n = int(input())
def comp(a, b):
l = a + b
r = b + a
if l < r: return -1
elif l == r: return 0
else: return 1
from functools import cmp_to_key
d = []
for _ in range(n):
s = input().rstrip()
d.append(s)
d.sort(key=cmp_to_key(comp))
print(''.j... | output | 1 | 6,237 | 6 | 12,475 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.
Given the list of strings, output the lexicographically smallest con... | instruction | 0 | 6,238 | 6 | 12,476 |
Tags: sortings, strings
Correct Solution:
```
#### IMPORTANT LIBRARY ####
############################
### DO NOT USE import random --> 250ms to load the library
############################
### In case of extra libraries: https://github.com/cheran-senthil/PyRival
######################
####### IMPORT #######
###... | output | 1 | 6,238 | 6 | 12,477 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.
Given the list of strings, output the lexicographically smallest con... | instruction | 0 | 6,239 | 6 | 12,478 |
Tags: sortings, strings
Correct Solution:
```
from functools import cmp_to_key
def cmp(a,b):
return -1 if a+b < b+a else 0
def main():
n = int(input())
l = [input() for i in range(n)]
l = sorted(l,key=cmp_to_key(cmp))
for i in l:
print(i,end="")
if __name__ == "__main__":
main()
``` | output | 1 | 6,239 | 6 | 12,479 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.
Given the list of strings, output the lexicographically smallest con... | instruction | 0 | 6,241 | 6 | 12,482 |
Tags: sortings, strings
Correct Solution:
```
from functools import cmp_to_key
n = int(input())
l = []
for i in range(n):
l.append(input())
l.sort(key = cmp_to_key(lambda x,y : 1 if x+y > y+x else -1))
print(''.join(l))
``` | output | 1 | 6,241 | 6 | 12,483 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.
Given the list of strings, output the lexicographically smallest con... | instruction | 0 | 6,242 | 6 | 12,484 |
Tags: sortings, strings
Correct Solution:
```
# List = [[10,1],[20,2],[10,3]] --> Initial
# List = [[10, 1], [10, 3], [20, 2]] --> Normal Sort
# List = [[10, 3], [10, 1], [20, 2]] --> Sort with custom key [ascending, descending]
from functools import cmp_to_key
def custom(x,y):
a = x +y
b = y+ x
if(a ... | output | 1 | 6,242 | 6 | 12,485 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.
Given the list of strings, output the lexicographically smallest con... | instruction | 0 | 6,243 | 6 | 12,486 |
Tags: sortings, strings
Correct Solution:
```
from bisect import insort,bisect_right,bisect_left
from sys import stdout, stdin, setrecursionlimit
from heapq import heappush, heappop, heapify
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from string import *
from... | output | 1 | 6,243 | 6 | 12,487 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.
Given the list of strings, output the lexicographically smallest con... | instruction | 0 | 6,244 | 6 | 12,488 |
Tags: sortings, strings
Correct Solution:
```
def cmp_to_key(mycmp):
'Convert a cmp= function into a key= function'
class K:
def __init__(self, obj, *args):
self.obj = obj
def __lt__(self, other):
return mycmp(self.obj, other.obj) < 0
def __gt__(self, other):
... | output | 1 | 6,244 | 6 | 12,489 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.