message stringlengths 2 65.1k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 0 108k | cluster float64 14 14 | __index_level_0__ int64 0 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how many people who are taller than him/her and sta... | instruction | 0 | 27,624 | 14 | 55,248 |
Tags: constructive algorithms, greedy, sortings
Correct Solution:
```
n = int(input())
def func(s):
name, a = s.split()
return [int(a), name]
arr = [func(input()) for i in range(n)]
arr.sort()
flag = True
for i in range(n):
if i < arr[i][0]:
flag = False
break
if flag:
h = [0] * n
f... | output | 1 | 27,624 | 14 | 55,249 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how ... | instruction | 0 | 27,625 | 14 | 55,250 |
Yes | output | 1 | 27,625 | 14 | 55,251 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how ... | instruction | 0 | 27,626 | 14 | 55,252 |
Yes | output | 1 | 27,626 | 14 | 55,253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how ... | instruction | 0 | 27,627 | 14 | 55,254 |
Yes | output | 1 | 27,627 | 14 | 55,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how ... | instruction | 0 | 27,628 | 14 | 55,256 |
Yes | output | 1 | 27,628 | 14 | 55,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how ... | instruction | 0 | 27,629 | 14 | 55,258 |
No | output | 1 | 27,629 | 14 | 55,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how ... | instruction | 0 | 27,630 | 14 | 55,260 |
No | output | 1 | 27,630 | 14 | 55,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how ... | instruction | 0 | 27,631 | 14 | 55,262 |
No | output | 1 | 27,631 | 14 | 55,263 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how ... | instruction | 0 | 27,632 | 14 | 55,264 |
No | output | 1 | 27,632 | 14 | 55,265 |
Provide tags and a correct Python 3 solution for this coding contest problem.
β Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me?
β Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everythi... | instruction | 0 | 27,777 | 14 | 55,554 |
Tags: data structures, sortings
Correct Solution:
```
n, t = int(input()), list(map(int, input().split()))
a, b = {}, {}
for i, j in enumerate(t):
if not j in a: a[j] = i
else: b[j] = i
p = [(a[j], b[j] - 1) for j in b]
s = [j if j > 0 else 0 for j in t]
u = v = 2 * t[p[0][0]] - 1
for i in range(n - 1): s[i + 1... | output | 1 | 27,777 | 14 | 55,555 |
Provide tags and a correct Python 3 solution for this coding contest problem.
β Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me?
β Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everythi... | instruction | 0 | 27,778 | 14 | 55,556 |
Tags: data structures, sortings
Correct Solution:
```
import math
import sys
from collections import deque, Counter, OrderedDict, defaultdict
#import heapq
#ceil,floor,log,sqrt,factorial,pow,pi,gcd
#import bisect
#from bisect import bisect_left,bisect_right
input = sys.stdin.readline
def inp():
return(int(input()))... | output | 1 | 27,778 | 14 | 55,557 |
Provide tags and a correct Python 3 solution for this coding contest problem.
β Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me?
β Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everythi... | instruction | 0 | 27,779 | 14 | 55,558 |
Tags: data structures, sortings
Correct Solution:
```
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
same = defaultdict(list)
only_positive = [max(0,x) for x in a]
partial_sum = [0 for i in range(n+1)]
for i in range(1,n+1):
partial_sum[i] = partial_sum[i-1]+only_positive[i-... | output | 1 | 27,779 | 14 | 55,559 |
Provide tags and a correct Python 3 solution for this coding contest problem.
β Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me?
β Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everythi... | instruction | 0 | 27,780 | 14 | 55,560 |
Tags: data structures, sortings
Correct Solution:
```
def main():
n, aa = int(input()), list(map(int, input().split()))
partialsum, s, d, ranges = [0] * n, 0, {}, []
for i, a in enumerate(aa):
if a > 0:
s += a
partialsum[i] = s
if a in d:
d[a].append(i)
... | output | 1 | 27,780 | 14 | 55,561 |
Provide tags and a correct Python 3 solution for this coding contest problem.
β Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me?
β Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everythi... | instruction | 0 | 27,781 | 14 | 55,562 |
Tags: data structures, sortings
Correct Solution:
```
n=int(input())
a=tuple(map(int,input().split()))
c={}
p={}
s=x=y=0
m=-1e18
for i in range(0,len(a)):
d=c.get(a[i])
if d!=None and s-d+a[i]*2>m:
m=s-d+a[i]*2
x,y=p.get(a[i]),i
if(a[i]>0):s+=a[i]
if p.get(a[i])==None:
p[a[i]]=... | output | 1 | 27,781 | 14 | 55,563 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meetin... | instruction | 0 | 27,814 | 14 | 55,628 |
Tags: binary search, data structures, sortings
Correct Solution:
```
from collections import defaultdict
from bisect import bisect_left as lower
import sys
input = sys.stdin.readline
def put():
return map(int, input().split())
try:
n,m = put()
cnt, mp, ans = [0]*n, defaultdict(), [0]*n
for _ in range(n... | output | 1 | 27,814 | 14 | 55,629 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today there is going to be an unusual performance at the circus β hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions... | instruction | 0 | 27,835 | 14 | 55,670 |
Tags: two pointers
Correct Solution:
```
n=int(input())
s=input()
h=0
for i in s:
if i=='H':h+=1
r=[]
t=0
for i in range(0,n):
if s[i]=='H':
for b in range((i+1)%n,min(((i+1)%n+h-1),n)):
if s[b]=='T':
t+=1
if ((i+1)%n+(h-1))>n:
for q in range(0,(((i+1)%n+... | output | 1 | 27,835 | 14 | 55,671 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today there is going to be an unusual performance at the circus β hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions... | instruction | 0 | 27,836 | 14 | 55,672 |
Tags: two pointers
Correct Solution:
```
n=int(input())
s=input()
h=s.count('H')
s=s+s
print(min(s[i:i+h].count('T') for i in range(n)))
``` | output | 1 | 27,836 | 14 | 55,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today there is going to be an unusual performance at the circus β hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions... | instruction | 0 | 27,837 | 14 | 55,674 |
Tags: two pointers
Correct Solution:
```
n, s = int(input()), input() * 2
h = s.count('H') // 2
print(h - max(s[i:i + h].count('H') for i in range(n)))
``` | output | 1 | 27,837 | 14 | 55,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today there is going to be an unusual performance at the circus β hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions... | instruction | 0 | 27,838 | 14 | 55,676 |
Tags: two pointers
Correct Solution:
```
I = int
K = input
W = print
q = min
x = sum
u = range
n = I(K())
s = K()
kh = s.count('H')
a = 'H'*kh+'T'*(n-kh)
W(q(x(a[j-i] != s[j] for j in u(n)) for i in u(n)) // 2)
``` | output | 1 | 27,838 | 14 | 55,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today there is going to be an unusual performance at the circus β hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions... | instruction | 0 | 27,839 | 14 | 55,678 |
Tags: two pointers
Correct Solution:
```
n = int(input())
c, v = [0] * (n + 1), 0
for i, ch in enumerate(input()):
c[i + 1] = c[i] + (ch == 'H')
for i in range(n):
if i + c[n] <= n:
v = max(v, c[i + c[n]] - c[i])
else:
v = max(v, c[n] - c[i] + c[c[n] - (n - i)])
print(c[n] - v)
``` | output | 1 | 27,839 | 14 | 55,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today there is going to be an unusual performance at the circus β hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions... | instruction | 0 | 27,840 | 14 | 55,680 |
Tags: two pointers
Correct Solution:
```
n=int(input())
a=input()
b=a.count('T')
c=-1
for i in range(n):
d=0
for j in range(b):
d+=int(a[(i+j)%n]=='H')
if c==-1 or d<c:
c=d
print(c)
``` | output | 1 | 27,840 | 14 | 55,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today there is going to be an unusual performance at the circus β hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions... | instruction | 0 | 27,841 | 14 | 55,682 |
Tags: two pointers
Correct Solution:
```
n = int(input())
line = input().strip()
span = line.count('T')
count = line[:span].count('H')
best = count
for i in range(n):
if line[i] == 'H':
count -= 1
if line[(i + span) % n] == 'H':
count += 1
best = min(best, count)
print(best)
``` | output | 1 | 27,841 | 14 | 55,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today there is going to be an unusual performance at the circus β hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions... | instruction | 0 | 27,842 | 14 | 55,684 |
Tags: two pointers
Correct Solution:
```
n = int(input())
s = input()
kh = s.count('H')
lst = ['H'] * kh + ['T'] * (n - kh)
best = kh
for i in range(n):
best = min(sum(lst[j] != s[j] for j in range(n)) // 2, best)
lst.append(lst.pop(0))
print(best)
``` | output | 1 | 27,842 | 14 | 55,685 |
Provide a correct Python 3 solution for this coding contest problem.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator, you have decided to determine the number of people in ... | instruction | 0 | 28,177 | 14 | 56,354 |
"Correct Solution:
```
n = int(input())
x,*a = list(map(int, input().split()))
y,*b = list(map(int, input().split()))
z,*c = list(map(int, input().split()))
u = set(range(1,n+1))
a = set(a)
b = set(b)
c = set(c)
s1 = (u - a) & c
s2 = b & c
s3 = s1 & s2
print(len(s1) + len(s2) -len(s3))
``` | output | 1 | 28,177 | 14 | 56,355 |
Provide a correct Python 3 solution for this coding contest problem.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator, you have decided to determine the number of people in ... | instruction | 0 | 28,178 | 14 | 56,356 |
"Correct Solution:
```
N = int(input())
U = [str(i+1) for i in range(N)]
X = input().split()[1:]
Y = input().split()[1:]
Z = input().split()[1:]
print(len(((set(U) - set(X)) & set(Z)) | (set(Y) & set(Z))))
``` | output | 1 | 28,178 | 14 | 56,357 |
Provide a correct Python 3 solution for this coding contest problem.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator, you have decided to determine the number of people in ... | instruction | 0 | 28,179 | 14 | 56,358 |
"Correct Solution:
```
N=int(input())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
Z=list(map(int,input().split()))
X.pop(0)
Y.pop(0)
Z.pop(0)
result=[i for i in Z if i not in X or i in Y]
print(len(result))
``` | output | 1 | 28,179 | 14 | 56,359 |
Provide a correct Python 3 solution for this coding contest problem.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator, you have decided to determine the number of people in ... | instruction | 0 | 28,180 | 14 | 56,360 |
"Correct Solution:
```
# coding=utf-8
if __name__ == '__main__':
N = int(input())
all_list = {i for i in range(1, N+1)}
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))
A_number = A_list[0]
A_identity = set(A_list[1:]... | output | 1 | 28,180 | 14 | 56,361 |
Provide a correct Python 3 solution for this coding contest problem.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator, you have decided to determine the number of people in ... | instruction | 0 | 28,181 | 14 | 56,362 |
"Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
X = a.pop(0)
a = set(a)
b = list(map(int, input().split()))
Y = b.pop(0)
b = set(b)
c = list(map(int, input().split()))
Z = c.pop(0)
c = set(c)
a_bar = {x for x in range(1, n+1) if x not in a}
ans = (a_bar & c) | (b & c)
print(len(ans))
``... | output | 1 | 28,181 | 14 | 56,363 |
Provide a correct Python 3 solution for this coding contest problem.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator, you have decided to determine the number of people in ... | instruction | 0 | 28,182 | 14 | 56,364 |
"Correct Solution:
```
N = int(input())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
Z = [int(i) for i in input().split()]
table = [[0 for i in range(3)] for j in range(N)]
for i in range(1, len(X)):
table[X[i] - 1][0] = 1
for i in range(1, len(Y)):
table[Y[i] - 1][1] = 1
for i... | output | 1 | 28,182 | 14 | 56,365 |
Provide a correct Python 3 solution for this coding contest problem.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator, you have decided to determine the number of people in ... | instruction | 0 | 28,183 | 14 | 56,366 |
"Correct Solution:
```
n = int(input())
x, *a = map(int, input().split())
y, *b = map(int, input().split())
z, *c = map(int, input().split())
_a = set(range(1, n+1)) ^ set(a)
match1 = set(_a) & set(c)
match2 = set(b) & set(c)
print(len(match1 | match2))
``` | output | 1 | 28,183 | 14 | 56,367 |
Provide a correct Python 3 solution for this coding contest problem.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator, you have decided to determine the number of people in ... | instruction | 0 | 28,184 | 14 | 56,368 |
"Correct Solution:
```
N = int(input())
Target = [0] * N
A = list(map(int, input().split()))
if A[0] != 0 :
for i in range(A[0]) :
Target[A[i+1]-1] += 1
B = list(map(int, input().split()))
if B[0] != 0 :
for i in range(B[0]) :
Target[B[i+1]-1] += 2
C = list(map(int, input().split()))
if... | output | 1 | 28,184 | 14 | 56,369 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator... | instruction | 0 | 28,185 | 14 | 56,370 |
Yes | output | 1 | 28,185 | 14 | 56,371 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator... | instruction | 0 | 28,186 | 14 | 56,372 |
Yes | output | 1 | 28,186 | 14 | 56,373 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator... | instruction | 0 | 28,187 | 14 | 56,374 |
Yes | output | 1 | 28,187 | 14 | 56,375 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator... | instruction | 0 | 28,188 | 14 | 56,376 |
Yes | output | 1 | 28,188 | 14 | 56,377 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.
It takes the first swimmer exactly a minutes to swim across the entire pool and come back, exactly b minutes for ... | instruction | 0 | 28,474 | 14 | 56,948 |
Tags: math
Correct Solution:
```
tc = int(input())
def waittime(p, a, b, c):
if p % a == 0 or p % b == 0 or p % c == 0:
return 0
return min(a - p % a, b - p % b, c - p % c)
for i in range(tc):
arr = input()
arr = arr.split()
p, a, b, c = list(map(int, arr))
print(waittime(p, a, b, ... | output | 1 | 28,474 | 14 | 56,949 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.
It takes the first swimmer exactly a minutes to swim across the entire pool and come back, exactly b minutes for ... | instruction | 0 | 28,475 | 14 | 56,950 |
Tags: math
Correct Solution:
```
for i in range(int(input())):
p, a, b, c = map(int, input().split())
if not p % a or not p % b or not p % c:
print(0)
else:
print(min(a - p % a, b - p % b, c - p % c))
``` | output | 1 | 28,475 | 14 | 56,951 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.
It takes the first swimmer exactly a minutes to swim across the entire pool and come back, exactly b minutes for ... | instruction | 0 | 28,476 | 14 | 56,952 |
Tags: math
Correct Solution:
```
for _ in range(int(input())):
p,a,b,c=map(int,input().split())
ans=None
x=p//a
y=a-p+(x*a)
if x*a==p:
ans=0
else:
ans=y
x=p//b
y=b-p+(x*b)
if x*b==p:
ans=0
elif y<ans:
ans=y
x=p//c
y=c-p+(x*c)
if... | output | 1 | 28,476 | 14 | 56,953 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.
It takes the first swimmer exactly a minutes to swim across the entire pool and come back, exactly b minutes for ... | instruction | 0 | 28,477 | 14 | 56,954 |
Tags: math
Correct Solution:
```
# Question A: Three Swimmers
def answer(p, a, b, c):
pma = p % a
pmb = p % b
pmc = p % c
if pma == 0 or pmb == 0 or pmc == 0:
return 0
else:
return min(a - pma, b - pmb, c - pmc)
def main():
t = int(input())
p = [0] * t
a = [0] * t
... | output | 1 | 28,477 | 14 | 56,955 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.
It takes the first swimmer exactly a minutes to swim across the entire pool and come back, exactly b minutes for ... | instruction | 0 | 28,478 | 14 | 56,956 |
Tags: math
Correct Solution:
```
import math
T = int(input())
def solve():
p, a, b, c = map(int, input().split())
a *= p // a + (0 if p % a == 0 else 1)
b *= p // b + (0 if p % b == 0 else 1)
c *= p // c + (0 if p % c == 0 else 1)
print(min(a - p, b - p, c - p))
for i in range(T):
solve()
``... | output | 1 | 28,478 | 14 | 56,957 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.
It takes the first swimmer exactly a minutes to swim across the entire pool and come back, exactly b minutes for ... | instruction | 0 | 28,479 | 14 | 56,958 |
Tags: math
Correct Solution:
```
# cook your dish here
for j in range(int(input())):
p,a,b,c=map(int, input().split())
x=p//a
y=p//b
z=p//c
if (p%a==0 or p%b==0 or p%c==0):
print("0")
else:
print(min((x+1)*a-p,(y+1)*b-p,(z+1)*c-p))
``` | output | 1 | 28,479 | 14 | 56,959 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.
It takes the first swimmer exactly a minutes to swim across the entire pool and come back, exactly b minutes for ... | instruction | 0 | 28,480 | 14 | 56,960 |
Tags: math
Correct Solution:
```
t = (int)(input())
for _ in range(t):
p, a, b, c = map(int, input().split())
x = (p + a - 1) // a
y = (p + b - 1) // b
z = (p + c - 1) // c
ans = min(x * a - p, y * b - p, z * c - p)
print(ans, end="\n")
``` | output | 1 | 28,480 | 14 | 56,961 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.
It takes the first swimmer exactly a minutes to swim across the entire pool and come back, exactly b minutes for ... | instruction | 0 | 28,481 | 14 | 56,962 |
Tags: math
Correct Solution:
```
import math
res = []
for _ in range(int(input())):
p,a,b,c = map(int,input().split())
a1 = p%a
b1 = p%b
c1 = p%c
if a1==0: res.append(0)
elif b1==0: res.append(0)
elif c1==0: res.append(0)
else: res.append(min(a-a1,b-b1,c-c1))
for i in res: print(i)
... | output | 1 | 28,481 | 14 | 56,963 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull.
Let's try to make a new task. Firstly we will use the fo... | instruction | 0 | 28,612 | 14 | 57,224 |
Tags: greedy
Correct Solution:
```
n = int(input())
names = []
for i in range(n):
names.append(input().split())
arr = list(map(int, input().split()))
prev = min(names[arr[0]-1])
for i in range(1, n):
if min(names[arr[i]-1]) >= prev:
prev = min(names[arr[i]-1])
elif max(names[arr[i]-1]) >= prev:
... | output | 1 | 28,612 | 14 | 57,225 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull.
Let's try to make a new task. Firstly we will use the fo... | instruction | 0 | 28,613 | 14 | 57,226 |
Tags: greedy
Correct Solution:
```
def solve(arr, p):
cur = "A" * 51
for rank in p:
if min(arr[rank - 1]) > cur:
cur = min(arr[rank - 1])
elif max(arr[rank - 1]) > cur:
cur = max(arr[rank - 1])
else:
return False
return True
n = int(input())
arr =... | output | 1 | 28,613 | 14 | 57,227 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull.
Let's try to make a new task. Firstly we will use the fo... | instruction | 0 | 28,614 | 14 | 57,228 |
Tags: greedy
Correct Solution:
```
n = int(input())
name = ['' for i in range(n)]
sname = ['' for i in range(n)]
for i in range(n):
name[i], sname[i] = input().split()
p = list(map(int, input().split()))
for i in range(n):
p[i] -= 1
nm = [False for i in range(n)]
snm = [False for i in range(n)]
nm[0] = snm[0] = True
... | output | 1 | 28,614 | 14 | 57,229 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull.
Let's try to make a new task. Firstly we will use the fo... | instruction | 0 | 28,615 | 14 | 57,230 |
Tags: greedy
Correct Solution:
```
"""
Codeforces Contest 270 Problem C
Author : chaotic_iak
Language: Python 3.3.4
"""
def main():
n, = read()
names = []
for i in range(n): names.extend([(x,i+1) for x in read(1)])
names.sort()
p = read()
i = 0
j = 0
while i < n and j < 2*n:
i... | output | 1 | 28,615 | 14 | 57,231 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull.
Let's try to make a new task. Firstly we will use the fo... | instruction | 0 | 28,616 | 14 | 57,232 |
Tags: greedy
Correct Solution:
```
# Description of the problem can be found at http://codeforces.com/problemset/problem/472/C
n = int(input())
l_n = list([input().split() for _ in range(n)])
o = list(map(int, input().split()))
l = "A"
for n in range(n):
l_n[o[n] - 1].sort()
if l_n[o[n] - 1][0] > l:
... | output | 1 | 28,616 | 14 | 57,233 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull.
Let's try to make a new task. Firstly we will use the fo... | instruction | 0 | 28,617 | 14 | 57,234 |
Tags: greedy
Correct Solution:
```
n = int(input())
a = [input().split() for i in range(n)]
b = list(map(int, input().split()))
b = [e-1 for e in b]
a = [sorted(e) for e in a]
s = a[b[0]][0]
v=True
for i in range(n):
if (s<=a[b[i]][0]):
s=a[b[i]][0]
else:
if (s<=a[b[i]][1]):
s=a[b[i]... | output | 1 | 28,617 | 14 | 57,235 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull.
Let's try to make a new task. Firstly we will use the fo... | instruction | 0 | 28,618 | 14 | 57,236 |
Tags: greedy
Correct Solution:
```
n=int(input())
l=[]
f=0
s3=""
for i in range(n):
s1,s2=map(str,input().strip().split(' '))
l.append([s1,s2])
#print(l)
lst = list(map(int,input().strip().split(' ')))
for j in range(n):
if j==0:
s3=min(l[lst[j]-1][0],l[lst[j]-1][1])
else:
s4=l[lst[j]-1]... | output | 1 | 28,618 | 14 | 57,237 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.