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.
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
... | instruction | 0 | 83,062 | 6 | 166,124 |
Tags: *special, implementation
Correct Solution:
```
letters=[chr(i) for i in range(ord('a'),ord('z')+1)]
n,k=map(int,input().split())
ans=''
i=0
while n > 0:
j=0
while j < k and n > 0:
ans+=letters[j]
j+=1
n-=1
print(ans)
``` | output | 1 | 83,062 | 6 | 166,125 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
... | instruction | 0 | 83,063 | 6 | 166,126 |
Tags: *special, implementation
Correct Solution:
```
from string import ascii_lowercase
n, k = map(int, input().split())
answer = ''
for i in range(n):
answer += ascii_lowercase[i % k]
print(answer)
``` | output | 1 | 83,063 | 6 | 166,127 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
... | instruction | 0 | 83,064 | 6 | 166,128 |
Tags: *special, implementation
Correct Solution:
```
import string
n, k = (int(x) for x in input().split())
symbols = string.ascii_lowercase[0:k]
pwd = [symbols[i%len(symbols)] for i in range(n)]
print(*pwd, sep='')
``` | output | 1 | 83,064 | 6 | 166,129 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
... | instruction | 0 | 83,065 | 6 | 166,130 |
Tags: *special, implementation
Correct Solution:
```
def new_password(length, distinct):
initial_number, string = 97, "a"
for i in range(length - 1):
if len(set(string)) < distinct:
initial_number += 1
else:
if initial_number > 97:
initial_number -= 1
... | output | 1 | 83,065 | 6 | 166,131 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
... | instruction | 0 | 83,066 | 6 | 166,132 |
Tags: *special, implementation
Correct Solution:
```
import random
import math
n ,k = map(int,input().split())
if(k > 26):
k = 26
letters = "abcdefghijklmnopqrstuvwxyz"
res = []
for i in range(n):
res.append(letters[i%k])
print("".join(res))
``` | output | 1 | 83,066 | 6 | 166,133 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
... | instruction | 0 | 83,067 | 6 | 166,134 |
Tags: *special, implementation
Correct Solution:
```
import random
#Generate of alph
n,k = input().split()
n = int(n)
k = int(k)
random.seed()
alph = random.sample('abcdefghijklmnopqrstuvwxyz',min(n,k))
a = ''.join(alph)
ans = a * (n // k) + a[0:n % k]
print(ans)
``` | output | 1 | 83,067 | 6 | 166,135 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
... | instruction | 0 | 83,068 | 6 | 166,136 |
Tags: *special, implementation
Correct Solution:
```
import string
n, k = map(int, input().split())
letters = string.ascii_lowercase
password = ""
for i in range(k):
password += letters[i]
i = 0
while len(password) < n:
password += password[i]
i += 1
print(password)
``` | output | 1 | 83,068 | 6 | 166,137 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
... | instruction | 0 | 83,069 | 6 | 166,138 |
Tags: *special, implementation
Correct Solution:
```
import random
n , k = input().split()
n , k = int(n) , int(k)
st = ""
i = 0
while len(st) < n:
value = chr(random.randint(97, 122))
if k >= 1:
if not value in st:
st+=value
k-=1
if(k<1):
if not value == st[len(st)-1... | output | 1 | 83,069 | 6 | 166,139 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant,... | instruction | 0 | 83,372 | 6 | 166,744 |
Tags: implementation, strings
Correct Solution:
```
si = ['a', 'o', 'u', 'i', 'e']
s = input()
t = True
s = s.lower()
for i in range(len(s) - 1):
if not(s[i] in si) and (s[i] != 'n') and not(s[i + 1] in si):
t = False
break
if (t) and ((s[len(s) - 1] in si) or (s[len(s) - 1] == 'n')):
print('YES... | output | 1 | 83,372 | 6 | 166,745 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant,... | instruction | 0 | 83,373 | 6 | 166,746 |
Tags: implementation, strings
Correct Solution:
```
s=input()
st={'a','e','i','o','u'}
flag="YES"
if(s[-1]!='n' and not s[-1] in st):
flag="NO"
else:
for i in range(0,len(s)-1):
if(s[i]=='n'):
continue
if(s[i] in st):
continue
if(not s[i+1] in st):
fla... | output | 1 | 83,373 | 6 | 166,747 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant,... | instruction | 0 | 83,374 | 6 | 166,748 |
Tags: implementation, strings
Correct Solution:
```
m = input()
flag = True
vowel = {'a','e','i','o','u'}
for c in range(len(m)):
if m[c] not in vowel:
if c == len(m) - 1 :
if m[c] != 'n':
flag = False
break
elif m[c+1] not in vowel and m[c] != 'n':
flag = False
break
if flag == False :print("N... | output | 1 | 83,374 | 6 | 166,749 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant,... | instruction | 0 | 83,375 | 6 | 166,750 |
Tags: implementation, strings
Correct Solution:
```
s=input()
ans="YES"
for i in range(len(s)-1):
if s[i] not in "aeioun":
if s[i+1] not in "aeiou":
ans="NO"
if s[-1] not in "aeioun":
ans="NO"
print (ans)
``` | output | 1 | 83,375 | 6 | 166,751 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant,... | instruction | 0 | 83,376 | 6 | 166,752 |
Tags: implementation, strings
Correct Solution:
```
s = input()
mylist = ['a','e','i','o','u','n']
vow = ['a','e','i','o','u']
i = 0
istrue = True
if s[-1] not in mylist:
print ("NO")
else:
while (i < (len(s)-1)):
if s[i] not in mylist:
if s[i+1] not in vow:
print ("No")
... | output | 1 | 83,376 | 6 | 166,753 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant,... | instruction | 0 | 83,377 | 6 | 166,754 |
Tags: implementation, strings
Correct Solution:
```
vowels = ["a", "e", "i", "o", "u"]
s = str(input())
if len(s) == 1:
if s == "n" or s in vowels:
print("YES")
else:
print("NO")
else:
flag = 0
for i in range(len(s) - 1):
if s[i] == "n":
continue
elif s[i] in ... | output | 1 | 83,377 | 6 | 166,755 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant,... | instruction | 0 | 83,378 | 6 | 166,756 |
Tags: implementation, strings
Correct Solution:
```
x = str(input())
vowels = ['a','e','i','o','u']
prev = '0'
for i,e in enumerate(x):
if i != 0:
if e not in vowels and prev not in vowels and prev != 'n':
print("NO")
break
if i == len(x)-1:
if e == 'n' or e in vowels:
print("YES")
else:
print("NO")... | output | 1 | 83,378 | 6 | 166,757 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant,... | instruction | 0 | 83,379 | 6 | 166,758 |
Tags: implementation, strings
Correct Solution:
```
s = input()
if s[len(s)-1] not in ['a','e','i','o','u','n']:
print('NO')
exit()
for i in range(len(s)):
if s[i] not in ['a','e','i','o','u','n']:
if s[i+1] not in ['a','e','i','o','u']:
print('NO')
exit()
print('YES')
``` | output | 1 | 83,379 | 6 | 166,759 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Homer has two friends Alice and Bob. Both of them are string fans.
One day, Alice and Bob decide to play a game on a string s = s_1 s_2 ... s_n of length n consisting of lowercase English letters. They move in turns alternatively and Alice... | instruction | 0 | 83,609 | 6 | 167,218 |
Tags: games, greedy, strings
Correct Solution:
```
t=int(input())
for j in range(t):
s=input()
a=list(s)
l=len(a)
for i in range(l):
if i%2==0:
if a[i]=='a':
a[i]='b'
else:
a[i]='a'
else:
if a[i]=='z':
a[... | output | 1 | 83,609 | 6 | 167,219 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Homer has two friends Alice and Bob. Both of them are string fans.
One day, Alice and Bob decide to play a game on a string s = s_1 s_2 ... s_n of length n consisting of lowercase English letters. They move in turns alternatively and Alice... | instruction | 0 | 83,611 | 6 | 167,222 |
Tags: games, greedy, strings
Correct Solution:
```
if __name__ == '__main__':
for _ in range(int(input())):
s = input()
for i in range(len(s)):
if i%2==0:
if s[i] == 'a':
s = s[:i]+'b'+s[i+1:]
else:
s = s[:i]+'a'+s[i... | output | 1 | 83,611 | 6 | 167,223 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Homer has two friends Alice and Bob. Both of them are string fans.
One day, Alice and Bob decide to play a game on a string s = s_1 s_2 ... s_n of length n consisting of lowercase English letters. They move in turns alternatively and Alice... | instruction | 0 | 83,612 | 6 | 167,224 |
Tags: games, greedy, strings
Correct Solution:
```
from sys import stdin, stdout
def main():
input = iter(stdin.read().split())
t, write = next(input), stdout.write
for s in input:
for i, c in enumerate(s):
if i&1 == 0:
if c == 'a':
write('b')
else:
write('a')
else:
if c == 'z':
w... | output | 1 | 83,612 | 6 | 167,225 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Homer has two friends Alice and Bob. Both of them are string fans.
One day, Alice and Bob decide to play a game on a string s = s_1 s_2 ... s_n of length n consisting of lowercase English letters. They move in turns alternatively and Alice... | instruction | 0 | 83,615 | 6 | 167,230 |
Tags: games, greedy, strings
Correct Solution:
```
###### ### ####### ####### ## # ##### ### #####
# # # # # # # # # # # # # ###
# # # # # # # # # # # # # ###
###### #... | output | 1 | 83,615 | 6 | 167,231 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Homer has two friends Alice and Bob. Both of them are string fans.
One day, Alice and Bob decide to play a game on a string s = s_1 s_2 ... s_n of length n consisting of lowercase English letters. They move in turns alternatively and Alice... | instruction | 0 | 83,616 | 6 | 167,232 |
Tags: games, greedy, strings
Correct Solution:
```
t = input()
T = int(t)
for i in range (T):
x = input()
y = ""
for j in range (len(x)):
if j%2:
if x[j] == 'z':
y += 'y'
else:
y+='z'
else:
if x[j] == 'a':
y... | output | 1 | 83,616 | 6 | 167,233 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Input
The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of "valid").
Output
Output a single integer.
Examples
Inp... | instruction | 0 | 83,845 | 6 | 167,690 |
Tags: *special
Correct Solution:
```
print ( __import__("functools").reduce (lambda ans, c: ans + (1 if c == "A" else 10 if c == "1" else int(c)), [0] + list(input())) )
``` | output | 1 | 83,845 | 6 | 167,691 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Input
The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of "valid").
Output
Output a single integer.
Examples
Inp... | instruction | 0 | 83,850 | 6 | 167,700 |
Tags: *special
Correct Solution:
```
s = input()
alc = 0
for c in s:
if c != '0':
if c == '1':
alc += 10
elif '1' < c <= '9':
alc += ord(c) - ord('0')
else:
alc += (lambda x: {'J': 11, 'Q': 12, 'K': 13, 'A': 1}[x])(c)
print(alc)
``` | output | 1 | 83,850 | 6 | 167,701 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentive... | instruction | 0 | 84,513 | 6 | 169,026 |
Tags: *special, implementation, strings
Correct Solution:
```
s = input().split('"')
for i in range(len(s)):
if i % 2:
print('<', s[i], '>', sep='')
else:
l = [x for x in s[i].split() if x != '']
if l != []:
print('<', '>\n<'.join(l), '>', sep='')
``` | output | 1 | 84,513 | 6 | 169,027 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentive... | instruction | 0 | 84,514 | 6 | 169,028 |
Tags: *special, implementation, strings
Correct Solution:
```
def printtag(s):
print("<" + s + ">")
s = input()
l = s.split("\"")
non_modify = 0
for s in l:
if non_modify:
printtag(s)
else:
tmp_lst = s.split(" ")
for st in tmp_lst:
if len(st):
printtag(st... | output | 1 | 84,514 | 6 | 169,029 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentive... | instruction | 0 | 84,515 | 6 | 169,030 |
Tags: *special, implementation, strings
Correct Solution:
```
n=input()
z,i=len(n),0
while i<z:
if n[i]=='"':
k="<";i+=1
while i<z and n[i]!='"':k+=n[i];i+=1
k+='>';i+=1
print(k)
elif n[i]!=" ":
k="<"
while i<z and n[i]!=" ":k+=n[i];i+=1
k+=">"
pri... | output | 1 | 84,515 | 6 | 169,031 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentive... | instruction | 0 | 84,516 | 6 | 169,032 |
Tags: *special, implementation, strings
Correct Solution:
```
s = input()
inside = False
lexeme = []
for c in s:
if c == '"':
if inside:
inside = False
print("%s>" % ''.join(lexeme))
lexeme = []
else:
lexeme = ['<']
inside = True
elif ... | output | 1 | 84,516 | 6 | 169,033 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentive... | instruction | 0 | 84,517 | 6 | 169,034 |
Tags: *special, implementation, strings
Correct Solution:
```
s = input().split('"')
#print(s)
for i in range(len(s)):
if i % 2:
print('<', s[i], '>', sep='')
else:
l = [x for x in s[i].split() if x != '']
#print(l)
if l != []:
print('<', '>\n<'.join(l), '>', sep='')
``` | output | 1 | 84,517 | 6 | 169,035 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentive... | instruction | 0 | 84,518 | 6 | 169,036 |
Tags: *special, implementation, strings
Correct Solution:
```
args = input()
def interpreter(arg):
args = arg.split(' ')
output = list()
i = 0
while i < len(args):
if args[i] == '':
pass
elif args[i][0] == '"':
if len(args[i]) > 1 and args[i][1] == '"':
... | output | 1 | 84,518 | 6 | 169,037 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentive... | instruction | 0 | 84,519 | 6 | 169,038 |
Tags: *special, implementation, strings
Correct Solution:
```
list1=list()
cmd=input()
i=0
n=len(cmd)
while(i<len(cmd) and i!=-1):
x=cmd[i]
if x=='"':
ind=cmd.find('"',i+1,n)
if ind==-1:
break
if ind+1< len(cmd) and cmd[ind+1]==' ':
list1.append(cmd[i+1:ind]);
... | output | 1 | 84,519 | 6 | 169,039 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentive... | instruction | 0 | 84,520 | 6 | 169,040 |
Tags: *special, implementation, strings
Correct Solution:
```
class CodeforcesTask291BSolution:
def __init__(self):
self.result = ''
self.command = ''
def read_input(self):
self.command = input()
def process_task(self):
lexems = []
cmd = []
started = False
... | output | 1 | 84,520 | 6 | 169,041 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all... | instruction | 0 | 85,414 | 6 | 170,828 |
Tags: 2-sat, graphs, greedy, implementation, shortest paths, strings
Correct Solution:
```
def sol():
n=int(input())
club=['']*n
city=['']*n
mp={}
for i in range(n):
s=input().split()
club[i]=s[0][:3]
city[i]=s[1][:1]
if club[i] in mp:
mp[club[i]].add(i)
... | output | 1 | 85,414 | 6 | 170,829 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all... | instruction | 0 | 85,415 | 6 | 170,830 |
Tags: 2-sat, graphs, greedy, implementation, shortest paths, strings
Correct Solution:
```
n = int(input())
d = dict()
ans = []
arr = []
d2 = dict()
for i in range(n):
a, b = input().split()
a1, a2 = a[:3], a[0] + a[1] + b[0]
if a1 in d:
d[a1].append(a2)
else:
d[a1] = [a2]
if a2 in d... | output | 1 | 85,415 | 6 | 170,831 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all... | instruction | 0 | 85,416 | 6 | 170,832 |
Tags: 2-sat, graphs, greedy, implementation, shortest paths, strings
Correct Solution:
```
t=int(input())
sth,st,s=[],[],[]
flag=True
for _ in range(t):
f=True
t,h=map(str,input().split())
if(t[0:3] in st):
f=False
st.append(t[0:3])
if(~f and t[0:2]+h[0] not in s):
s.append(t[0:2]+h[... | output | 1 | 85,416 | 6 | 170,833 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all... | instruction | 0 | 85,417 | 6 | 170,834 |
Tags: 2-sat, graphs, greedy, implementation, shortest paths, strings
Correct Solution:
```
n = int(input())
first = {}
second = set()
s1 = [0] * n
ans = [0] * n
for i in range(n):
a, b = input().split()
a = a[:3]
b = b[0]
s1[i] = b
if a in first.keys():
first[a].append(i)
else:
f... | output | 1 | 85,417 | 6 | 170,835 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all... | instruction | 0 | 85,418 | 6 | 170,836 |
Tags: 2-sat, graphs, greedy, implementation, shortest paths, strings
Correct Solution:
```
from sys import stdin
n = int(stdin.readline().strip())
T,A = [],[]
N,M = {},{}
for _ in range(n):
t,h = stdin.readline().split()
n1,n2 = t[:3],t[:2]+h[0]
N[n1] = N.get(n1,0)+1
T.append((n1,n2))
A.append(n1)
... | output | 1 | 85,418 | 6 | 170,837 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all... | instruction | 0 | 85,419 | 6 | 170,838 |
Tags: 2-sat, graphs, greedy, implementation, shortest paths, strings
Correct Solution:
```
from collections import defaultdict
names = int(input())
inp = [input().split() for x in range(names)]
choice = []
res = defaultdict(lambda: [])
for x, word in enumerate(inp):
choice.append(False)
res[word[0][:3]].append(... | output | 1 | 85,419 | 6 | 170,839 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all... | instruction | 0 | 85,420 | 6 | 170,840 |
Tags: 2-sat, graphs, greedy, implementation, shortest paths, strings
Correct Solution:
```
n = int(input())
ans = 0
o = []
p = []
for i in range(n):
s, g = [str(j) for j in input().split()]
ss = s[0:3]
gg = s[0:2] + g[0]
flag = True
if ss in o:
flag = False
o.append(ss)
... | output | 1 | 85,420 | 6 | 170,841 |
Provide a correct Python 3 solution for this coding contest problem.
As an English learner, sometimes you cannot remember the entire spelling of English words perfectly, but you can only remember their prefixes and suffixes. For example, you may want to use a word which begins with 'appr' and ends with 'iate', but for... | instruction | 0 | 85,686 | 6 | 171,372 |
"Correct Solution:
```
from bisect import bisect
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def construct(N, S, base, MOD):
L = 26
root = [0, 0, N-1, [None]*L]
nds = [root]
for i, s in enumerate(S):
node = root
for c in s:
h, a, b, nt = node
... | output | 1 | 85,686 | 6 | 171,373 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory ma... | instruction | 0 | 86,193 | 6 | 172,386 |
Tags: implementation
Correct Solution:
```
t, m = map(int, input().split())
a, b = [0] * m, 1
def alloc(n):
global b
f = 0
for i in range(m):
if not a[i]:
f += 1
if f == n:
a[i - n + 1:i + 1] = [b] * n
b += 1
return b - 1
... | output | 1 | 86,193 | 6 | 172,387 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory ma... | instruction | 0 | 86,194 | 6 | 172,388 |
Tags: implementation
Correct Solution:
```
from bisect import *
t, m = (int(x) for x in input().split())
class Block:
def __init__(self, size, free, prv, nxt):
self.size = size
self.free = free
self.prv = prv
self.nxt = nxt
block0 = Block(0, m, None, None)
blocks = {}
next_id = 1
... | output | 1 | 86,194 | 6 | 172,389 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory ma... | instruction | 0 | 86,195 | 6 | 172,390 |
Tags: implementation
Correct Solution:
```
#!/usr/bin/env python
def main():
t, m = map(int, input().split())
nil = 0, 0, 0
skip = [list(nil) for _ in range(m + 1)]
skip[0][:] = 0, m, 0
block = dict()
free = m
nth = 0
for _ in range(t):
line = input()
cmd = line[0]
... | output | 1 | 86,195 | 6 | 172,391 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory ma... | instruction | 0 | 86,196 | 6 | 172,392 |
Tags: implementation
Correct Solution:
```
from sys import stdin, stdout
class Block:
def __init__(self, id, offset, size):
self.id = id
self.offset = offset
self.size = size
def __str__(self):
return "{0} {1} {2}".format(self.id, self.offset, self.size)
class MemoryManager:
... | output | 1 | 86,196 | 6 | 172,393 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory ma... | instruction | 0 | 86,197 | 6 | 172,394 |
Tags: implementation
Correct Solution:
```
def d():
global p
j = 1
for i in range(len(p)):
p[i][0] = j
j += p[i][1]
def e(k):
global p
for i in range(len(p)):
if p[i][2] != k: continue
p.pop(i)
return
print('ILLEGAL_ERASE_ARGUMENT')
def a(k):
global p,... | output | 1 | 86,197 | 6 | 172,395 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory ma... | instruction | 0 | 86,198 | 6 | 172,396 |
Tags: implementation
Correct Solution:
```
def main():
numberOfCommands, totalMemory = map(int, input().split())
#I will mark erase operation with a negative number, in order to differenceate it from alloc
#also the defragment will be marked with 0, as we don't have any alloc or erase with 0
operations = []
m... | output | 1 | 86,198 | 6 | 172,397 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory ma... | instruction | 0 | 86,199 | 6 | 172,398 |
Tags: implementation
Correct Solution:
```
"""
Codeforces
7B - Memory Manager
http://codeforces.com/contest/7/problem/B
HΓ©ctor GonzΓ‘lez Belver
../07/2018
"""
import sys
def main():
t, m = map(int, sys.stdin.readline().strip().split())
memory = [0] * m
block_number = 0
def allocate(num_bytes):
nonlocal ... | output | 1 | 86,199 | 6 | 172,399 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory ma... | instruction | 0 | 86,200 | 6 | 172,400 |
Tags: implementation
Correct Solution:
```
t,m=map(int,input().split())
memory=[0]*m
ind=[1]
def alloc(n):
lng=0
for i in range(m):
if memory[i]==0:
lng+=1
if lng==n:
memory[i-lng+1:i+1]=[ind[0]]*n
ind[0]+=1
return ind[0]-1
... | output | 1 | 86,200 | 6 | 172,401 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of tw... | instruction | 0 | 86,215 | 6 | 172,430 |
Tags: brute force, implementation, strings
Correct Solution:
```
password=input()
n=int(input())
strings=[input() for i in range(n)]
if password in strings:
print("YES")
else:
letters=list(password)
strings0=[k for k in strings if letters[0] in list(k)[1]]
strings1=[k for k in strings if letters[1] in list(k)[0]]
... | output | 1 | 86,215 | 6 | 172,431 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of tw... | instruction | 0 | 86,216 | 6 | 172,432 |
Tags: brute force, implementation, strings
Correct Solution:
```
pw = input()
f = 1
n = int(input())
for a in range(0, n):
bark = input()
if(bark[1] == pw[0]):
f = f * 2
if(bark[0] == pw[1]):
f = f * 3
if(bark == pw):
f = 6
if(f%6 == 0):
print("YES")
else:
print("NO")
``... | output | 1 | 86,216 | 6 | 172,433 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of tw... | instruction | 0 | 86,217 | 6 | 172,434 |
Tags: brute force, implementation, strings
Correct Solution:
```
def main():
p = input()
n = int(input())
words = []
for i in range(n):
words.append(input())
if any(w[0]==p[0] and w[1] ==p[1] for w in words):
print("YES")
elif any(w[1] == p[0] for w in words) and any(w[0] == p[1]... | output | 1 | 86,217 | 6 | 172,435 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.