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.
Haiku is a genre of Japanese traditional poetry.
A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should ... | instruction | 0 | 24,385 | 6 | 48,770 |
Tags: implementation, strings
Correct Solution:
```
a,b,c=input(),input(),input()
def cnt(s):
ans=0
for e in s:
ans+= e in "aeiou"
return ans
print("YES" if cnt(a)==cnt(c)==5 and cnt(b)==7 else "NO")
``` | output | 1 | 24,385 | 6 | 48,771 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Haiku is a genre of Japanese traditional poetry.
A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should ... | instruction | 0 | 24,386 | 6 | 48,772 |
Tags: implementation, strings
Correct Solution:
```
for i in range(1,4):
s=input()
sum=s.count('a')+s.count('e')+s.count('i')+s.count('o')+s.count('u')
if((i==2 and sum!=7)or(i!=2 and sum!=5)):
exit(print('NO'))
print('YES')
``` | output | 1 | 24,386 | 6 | 48,773 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Haiku is a genre of Japanese traditional poetry.
A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should ... | instruction | 0 | 24,387 | 6 | 48,774 |
Tags: implementation, strings
Correct Solution:
```
a = input()
b = input()
c = input()
def isVowel(c):
return c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u'
def vowelNo(s):
c = 0
for i in s:
if isVowel(i):
c += 1
return c
if vowelNo(a) == 5 and vowelNo(b) == 7 and vowelNo(c) == 5:
print("YES")
e... | output | 1 | 24,387 | 6 | 48,775 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform i... | instruction | 0 | 24,447 | 6 | 48,894 |
Tags: implementation
Correct Solution:
```
st=input()
st=list(st)
flg=0
n=len(set(st))
if n==3:
for i in set(st):
if st.count(i)>=2:
flg=1
break
elif n==2:
for i in set(st):
if st.count(i)==1:
flg=0
break
else:
flg=1
elif n==1 o... | output | 1 | 24,447 | 6 | 48,895 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform i... | instruction | 0 | 24,449 | 6 | 48,898 |
Tags: implementation
Correct Solution:
```
from collections import Counter
def no():
print("No")
exit(0)
s = input()
if len(s) < 4:
no()
cnt = Counter(s)
cnt = list(cnt.items())
if len(cnt) < 2 or len(cnt) > 4:
no()
if len(cnt) == 2 and (cnt[0][1] == 1 or cnt[1][1] == 1):
no()
if len(cnt) == 3 and (max(cnt[0][1]... | output | 1 | 24,449 | 6 | 48,899 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform i... | instruction | 0 | 24,452 | 6 | 48,904 |
Tags: implementation
Correct Solution:
```
import sys
import bisect
#input=sys.stdin.readline
s=input()
hashi=dict()
for i in s:
if(i in hashi):
hashi[i]+=1
else:
hashi[i]=1
z=len(hashi)
if(len(s)<4):
print("No")
quit()
if(z>4):
print("No")
quit()
if(z==1):
print("No")
qu... | output | 1 | 24,452 | 6 | 48,905 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform i... | instruction | 0 | 24,454 | 6 | 48,908 |
Tags: implementation
Correct Solution:
```
import sys
from collections import defaultdict
s = list(input().strip())
n = len(s)
if n < 4:
print("No")
sys.exit(0)
count = defaultdict(int)
for x in s:
count[x] += 1
n = len(count)
if n == 1 or n > 4:
res = "No"
elif n == 4:
res = "Yes"
elif n == 3:
... | output | 1 | 24,454 | 6 | 48,909 |
Provide a correct Python 3 solution for this coding contest problem.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists of at most 30 characters, and the page number is less t... | instruction | 0 | 24,653 | 6 | 49,306 |
"Correct Solution:
```
d = {}
while True:
try:
w, p = input().split()
if w in d:
d[w].append(int(p))
else:
d[w] = [int(p)]
except:
break
for k in sorted(d.items(), key=lambda x: x[0]):
print(k[0])
print(*sorted(k[1]))
``` | output | 1 | 24,653 | 6 | 49,307 |
Provide a correct Python 3 solution for this coding contest problem.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists of at most 30 characters, and the page number is less t... | instruction | 0 | 24,654 | 6 | 49,308 |
"Correct Solution:
```
Date_lis = []
W_lis = []
while True:
try:
s,n = map(str,input().split())
if s in W_lis:
Date_lis[W_lis.index(s)][1].append(int(n))
else:
Date_lis.append([s,[int(n)]])
W_lis.append(s)
except :
Date_lis = sorted(D... | output | 1 | 24,654 | 6 | 49,309 |
Provide a correct Python 3 solution for this coding contest problem.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists of at most 30 characters, and the page number is less t... | instruction | 0 | 24,655 | 6 | 49,310 |
"Correct Solution:
```
import sys
d={}
for e in sys.stdin:
k,v=e.split()
d.setdefault(k,[])
d[k]+=[int(v)]
for k in sorted(d):
print(k)
print(*sorted(d[k]))
``` | output | 1 | 24,655 | 6 | 49,311 |
Provide a correct Python 3 solution for this coding contest problem.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists of at most 30 characters, and the page number is less t... | instruction | 0 | 24,656 | 6 | 49,312 |
"Correct Solution:
```
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
N = list(get_input())
N.sort()
N1,N2 = N[0].split()
word = N1
pnum = []
pnum.append(int(N2))
for l in range(1, len(N)):
N1,N2 = N[l].split()
if word != N1:
... | output | 1 | 24,656 | 6 | 49,313 |
Provide a correct Python 3 solution for this coding contest problem.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists of at most 30 characters, and the page number is less t... | instruction | 0 | 24,657 | 6 | 49,314 |
"Correct Solution:
```
#!/usr/bin/env python3
d = {}
while True:
try:
w, p = input().split()
except:
break
try:
d[w].add(int(p))
except:
d[w] = set()
d[w].add(int(p))
l = list(d.keys())
l.sort()
for i in l:
print(i)
a = list(d[i])
a.sort()
print... | output | 1 | 24,657 | 6 | 49,315 |
Provide a correct Python 3 solution for this coding contest problem.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists of at most 30 characters, and the page number is less t... | instruction | 0 | 24,658 | 6 | 49,316 |
"Correct Solution:
```
dic = {}
while 1:
try:
word, page = map(str, input().split())
page = int(page)
if word in dic:
dic[word].append(page)
else:
dic[word] = [page]
except:
break
for d in sorted(dic):
print(d)
print(' '.join(map(str, sort... | output | 1 | 24,658 | 6 | 49,317 |
Provide a correct Python 3 solution for this coding contest problem.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists of at most 30 characters, and the page number is less t... | instruction | 0 | 24,659 | 6 | 49,318 |
"Correct Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
import bisect
import collections
import sys
if __name__ == "__main__":
pre_dict = collections.defaultdict(lambda: array.array("I"))
for line in sys.stdin:
[word, page0] = line.split()
page = int(page0)
... | output | 1 | 24,659 | 6 | 49,319 |
Provide a correct Python 3 solution for this coding contest problem.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists of at most 30 characters, and the page number is less t... | instruction | 0 | 24,660 | 6 | 49,320 |
"Correct Solution:
```
c={}
while 1:
try:
a,b=input().split()
if a in c.keys():c[a].append(int(b))
else: c[a]=[int(b)]
except:
for i,j in sorted(c.items()):
print(i)
print(' '.join(map(str,sorted(j))))
break
``` | output | 1 | 24,660 | 6 | 49,321 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists... | instruction | 0 | 24,661 | 6 | 49,322 |
Yes | output | 1 | 24,661 | 6 | 49,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists... | instruction | 0 | 24,662 | 6 | 49,324 |
Yes | output | 1 | 24,662 | 6 | 49,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists... | instruction | 0 | 24,663 | 6 | 49,326 |
Yes | output | 1 | 24,663 | 6 | 49,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists... | instruction | 0 | 24,664 | 6 | 49,328 |
Yes | output | 1 | 24,664 | 6 | 49,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists... | instruction | 0 | 24,665 | 6 | 49,330 |
No | output | 1 | 24,665 | 6 | 49,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists... | instruction | 0 | 24,666 | 6 | 49,332 |
No | output | 1 | 24,666 | 6 | 49,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists... | instruction | 0 | 24,667 | 6 | 49,334 |
No | output | 1 | 24,667 | 6 | 49,335 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists... | instruction | 0 | 24,668 | 6 | 49,336 |
No | output | 1 | 24,668 | 6 | 49,337 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «G», «C», «T»), that ... | instruction | 0 | 24,795 | 6 | 49,590 |
Tags: brute force, constructive algorithms, greedy, math
Correct Solution:
```
from itertools import permutations
from sys import stdin, stdout
ly, lx = map(int, input().split())
grid = [[c for c in inp] for inp in stdin.read().splitlines()]
first = set()
bl = []
bpattern = []
bcost = 1e6
flip_row = False
for l in pe... | output | 1 | 24,795 | 6 | 49,591 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «G», «C», «T»), that ... | instruction | 0 | 24,796 | 6 | 49,592 |
Tags: brute force, constructive algorithms, greedy, math
Correct Solution:
```
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
grid=[]
for i in range(n):
s=input()
grid.append([])
for j in range(m):
if s[j]=='A':
grid[-1].append(0)
elif s[j]=='C':
grid[-1].append(1)
elif s... | output | 1 | 24,796 | 6 | 49,593 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «G», «C», «T»), that ... | instruction | 0 | 24,797 | 6 | 49,594 |
Tags: brute force, constructive algorithms, greedy, math
Correct Solution:
```
from itertools import permutations
from sys import stdin, stdout
ly, lx = map(int, input().split())
grid = [[c for c in inp] for inp in stdin.read().splitlines()]
first = set()
bl = []
bpattern = []
bcost = 1e6
flip_row = False
for l in pe... | output | 1 | 24,797 | 6 | 49,595 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «G», «C», «T»), that ... | instruction | 0 | 24,798 | 6 | 49,596 |
Tags: brute force, constructive algorithms, greedy, math
Correct Solution:
```
from itertools import permutations
from sys import stdin, stdout
ly, lx = map(int, input().split())
grid = [[c for c in inp] for inp in stdin.read().splitlines()]
first = set()
bl = []
bpattern = []
bcost = 1e6
flip_row = False
for l in pe... | output | 1 | 24,798 | 6 | 49,597 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table... | instruction | 0 | 24,799 | 6 | 49,598 |
No | output | 1 | 24,799 | 6 | 49,599 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table... | instruction | 0 | 24,800 | 6 | 49,600 |
No | output | 1 | 24,800 | 6 | 49,601 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table... | instruction | 0 | 24,802 | 6 | 49,604 |
No | output | 1 | 24,802 | 6 | 49,605 |
Provide tags and a correct Python 3 solution for this coding contest problem.
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants... | instruction | 0 | 25,064 | 6 | 50,128 |
Tags: expression parsing, implementation, sortings, strings
Correct Solution:
```
lst=[int(x) for x in input().split(',')]
lst=list(set(lst))
lst=sorted(lst)
f=0
fir=lst[0]
lt=lst[0]
for i in range(len(lst)-1):
if lst[i]+1==lst[i+1]:
lt=lst[i+1]
else:
if fir==lt:
print(fir,end=',') ... | output | 1 | 25,064 | 6 | 50,129 |
Provide tags and a correct Python 3 solution for this coding contest problem.
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants... | instruction | 0 | 25,065 | 6 | 50,130 |
Tags: expression parsing, implementation, sortings, strings
Correct Solution:
```
import sys
pages = list(map(int, sys.stdin.readline().strip().split(",")))
unipages = set(pages)
unilist = []
for i in unipages:
unilist.append(i)
unilist.sort()
unilen = len(unilist)
first = unilist[0]
prev = first
for i in range(1, uni... | output | 1 | 25,065 | 6 | 50,131 |
Provide tags and a correct Python 3 solution for this coding contest problem.
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants... | instruction | 0 | 25,066 | 6 | 50,132 |
Tags: expression parsing, implementation, sortings, strings
Correct Solution:
```
mass = list(set(list(map(int, input().split(',')))))
mass.append(1234214)
mass.sort()
prev = mass[0]
begin = mass[0]
ans = []
# print(mass)
for i in range(1, len(mass)):
if mass[i] == prev + 1:
prev = mass[i]
else:
if prev == begin:... | output | 1 | 25,066 | 6 | 50,133 |
Provide tags and a correct Python 3 solution for this coding contest problem.
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants... | instruction | 0 | 25,067 | 6 | 50,134 |
Tags: expression parsing, implementation, sortings, strings
Correct Solution:
```
l=[]
l=[int(x) for x in input().split(',')]
l1=list(set(l))
l1.sort()
x=l1[0]
y=l1[0]
for i in range(len(l1)-1):
if l1[i+1]-l1[i]==1:
y=l1[i+1]
else:
if x==y:
print(x,end=",")
else:
... | output | 1 | 25,067 | 6 | 50,135 |
Provide tags and a correct Python 3 solution for this coding contest problem.
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants... | instruction | 0 | 25,068 | 6 | 50,136 |
Tags: expression parsing, implementation, sortings, strings
Correct Solution:
```
t = list(map(int, input().split(',')))
p, k = [0] * 1002, 0
for i in t:
p[i] = 1
if i > k: k = i
r, i, j = [], 0, -1
while j < k:
i = p.index(1, j + 2)
j = p.index(0, i + 1) - 1
if i == j: r.append(str(i))
else: r.... | output | 1 | 25,068 | 6 | 50,137 |
Provide tags and a correct Python 3 solution for this coding contest problem.
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants... | instruction | 0 | 25,069 | 6 | 50,138 |
Tags: expression parsing, implementation, sortings, strings
Correct Solution:
```
#!/usr/bin/env python3
from sys import stdin, stderr
input_tokens = stdin.readline()
tokens = list(set([int(x) for x in input_tokens.split(',')]))
tokens.sort()
print(tokens, file=stderr)
s = ""
prev = 0
seq = False
for n in tokens:
... | output | 1 | 25,069 | 6 | 50,139 |
Provide tags and a correct Python 3 solution for this coding contest problem.
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants... | instruction | 0 | 25,070 | 6 | 50,140 |
Tags: expression parsing, implementation, sortings, strings
Correct Solution:
```
l=[int(i) for i in input().split(',')]
l=list(set(l))
#print(l)
ans=''
l.sort()
i=0
res=[]
for i in range(1,10000):
if i>max(l):
break
if i in l:
res.append(i)
else:
if len(res)==1 :
ans+=... | output | 1 | 25,070 | 6 | 50,141 |
Provide tags and a correct Python 3 solution for this coding contest problem.
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants... | instruction | 0 | 25,071 | 6 | 50,142 |
Tags: expression parsing, implementation, sortings, strings
Correct Solution:
```
a = list(set([int(x) for x in input().split(",")]))
a = sorted(a)
l = a[0]
r = []
for i in range(0, len(a) - 1):
if a[i] < a[i + 1] - 1:
if a[i] == l:
r.append("%d" % l)
l = a[i + 1]
else:
... | output | 1 | 25,071 | 6 | 50,143 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequ... | instruction | 0 | 25,077 | 6 | 50,154 |
No | output | 1 | 25,077 | 6 | 50,155 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.
Hulk likes the Inception so much, and like that ... | instruction | 0 | 25,224 | 6 | 50,448 |
Tags: implementation
Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 6 20:45:13 2020
@author: alber
"""
that = 'I hate that I love that '
love2 = 'I hate that I love it'
love = 'I love it'
hate = 'I hate it'
x = int(input())
rep = x//2
if x == 1:
print('I hate it')
elif x=... | output | 1 | 25,224 | 6 | 50,449 |
Provide tags and a correct Python 3 solution for this coding contest problem.
zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, th... | instruction | 0 | 26,093 | 6 | 52,186 |
Tags: dfs and similar, dp
Correct Solution:
```
import sys
n, x, y = map(int, input().split())
size = 10**7
dq_x, dq_y, dq_i = [0]*size, [0]*size, [0]*size
l, r = 0, 0
cx, cy = 0, 0
for i in range(1, n+1):
cx += 1
while l < r and dq_i[l] < i:
l += 1
if l < r and (dq_x[l]-i-cx)*x + (dq_y[l]-cy)*y <... | output | 1 | 26,093 | 6 | 52,187 |
Provide tags and a correct Python 3 solution for this coding contest problem.
zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, th... | instruction | 0 | 26,094 | 6 | 52,188 |
Tags: dfs and similar, dp
Correct Solution:
```
n, a, b = input().split(' ')
n = int(n)
a = int(a)
b = int(b)
tk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0
kg = n
while kg >= 2:
if kg % 2 != 0:
tag = 1
if tag == 1 and (kg-kg//2-1)*a < b:
break
hg2 = kg
hg = (k... | output | 1 | 26,094 | 6 | 52,189 |
Provide tags and a correct Python 3 solution for this coding contest problem.
zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, th... | instruction | 0 | 26,095 | 6 | 52,190 |
Tags: dfs and similar, dp
Correct Solution:
```
__author__ = 'Think'
n, x, y=[int(i) for i in input().split()]
def worth(num):
if num%2==0:
dub=y
alt=x*(num//2)
else:
dub=y+x
alt=x*((num//2)+1)
return dub<alt, dub, alt
time=0
while n>0:
parity=n%2
should_double, dub, alt=worth(n)
if should_double:
time... | output | 1 | 26,095 | 6 | 52,191 |
Provide tags and a correct Python 3 solution for this coding contest problem.
zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, th... | instruction | 0 | 26,096 | 6 | 52,192 |
Tags: dfs and similar, dp
Correct Solution:
```
def main():
def f(t):
u = cache.get(t)
if u is None:
if t & 1:
u = min(f(t - 1), f(t + 1)) + x
else:
u = x * t
if y * 2 < u:
u = f(t // 2) + y
cache... | output | 1 | 26,096 | 6 | 52,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, th... | instruction | 0 | 26,097 | 6 | 52,194 |
Tags: dfs and similar, dp
Correct Solution:
```
def main():
def f(t):
if t & 1:
return x if t == 1 else min(f(t - 1), f(t + 1)) + x
else:
u = x * t
return f(t // 2) + y if y * 2 < u else u
n, x, y = map(int, input().split())
print(f(n))
if __name__ == '... | output | 1 | 26,097 | 6 | 52,195 |
Provide tags and a correct Python 3 solution for this coding contest problem.
zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, th... | instruction | 0 | 26,098 | 6 | 52,196 |
Tags: dfs and similar, dp
Correct Solution:
```
import sys
sys.setrecursionlimit(1000000)
def f(n):
if n == 1:
return x
elif n == 2:
return x + min(x, y)
else:
if n % 2 == 0:
return f(n // 2) + min(y, x * (n - n // 2))
else:
return min(f(n + 1), f(n -... | output | 1 | 26,098 | 6 | 52,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, th... | instruction | 0 | 26,099 | 6 | 52,198 |
Tags: dfs and similar, dp
Correct Solution:
```
import sys
sys.setrecursionlimit(100000)
from functools import lru_cache
@lru_cache()
def best(a):
if a == 1:
return x
elif a > 0:
if a == 2:
return x + min(x, y)
elif a % 2 == 0:
return best(a//2) + min(y, (a - a... | output | 1 | 26,099 | 6 | 52,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, th... | instruction | 0 | 26,100 | 6 | 52,200 |
Tags: dfs and similar, dp
Correct Solution:
```
def fi(n):
if n == 1:
return x
elif n == 2:
return x + min(x, y)
else:
if n % 2 == 1:
return min(fi(n-1), fi(n+1)) + x
else:
return fi(n//2) + min(y, x * (n//2))
n,x,y = map(int, input().split())... | output | 1 | 26,100 | 6 | 52,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
INTERCAL is the oldest of esoteric programming languages. One of its many weird features is the method of character-based output, known as Turing Tape method. It converts an array of unsigned 8-bit integers into a sequence of characters to p... | instruction | 0 | 26,689 | 6 | 53,378 |
Tags: implementation
Correct Solution:
```
n = input()
prev = 0
for i in n:
asci = ord(i)
binary = format(asci, '#010b')[2:][::-1]
num = int(binary, 2)
print((prev-num) % 256)
prev = num
``` | output | 1 | 26,689 | 6 | 53,379 |
Provide tags and a correct Python 3 solution for this coding contest problem.
INTERCAL is the oldest of esoteric programming languages. One of its many weird features is the method of character-based output, known as Turing Tape method. It converts an array of unsigned 8-bit integers into a sequence of characters to p... | instruction | 0 | 26,690 | 6 | 53,380 |
Tags: implementation
Correct Solution:
```
def f(x):
return int(format(256 + x, 'b')[:: -1][: -1], 2)
t, x = input(), 0
for i in t:
y = f(ord(i))
print((x - y) % 256)
x = y
# Made By Mostafa_Khaled
``` | output | 1 | 26,690 | 6 | 53,381 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.