message stringlengths 2 20.1k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 1.95k 109k | cluster float64 17 17 | __index_level_0__ int64 3.91k 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.
Every contestant hopes that he can find a teammate so that their team’s strength is as high as possible. That is, a contestant will form a team with highest strength possible by choosing a teammate from ones who are willing to be a teammate with him/her. More formally, two people A and B may form a team if each of them is the best possible teammate (among the contestants that remain unpaired) for the other one.
Can you determine who will be each person’s teammate?
Input
There are 2n lines in the input.
The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed.
The i-th line (i > 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people are numbered starting from 1.)
Output
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
Examples
Input
2
6
1 2
3 4 5
Output
2 1 4 3
Input
3
487060
3831 161856
845957 794650 976977
83847 50566 691206 498447
698377 156232 59015 382455 626960
Output
6 5 4 3 2 1
Note
In the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Submitted Solution:
```
from sys import stdin,stdout
n = int(stdin.readline())
b = [[0 for i in range(2*n)] for j in range(2*n)]
c = [0]*(2*n)
for i in range(2*n -1):
a = [int(x) for x in stdin.readline().split()]
for k in range(len(a)):
b[i+1][k] = a[k]
def mat_index(X,l):
maxi = 0
for i in range(l):
if maxi <= max(X[i]):
maxi = max(X[i])
ind = [i,X[i].index(maxi)]
return ind
for h in range(3):
index = mat_index(b,2*n)
c[index[0]] = index[1]+1
c[index[1]] = index[0]+1
b[index[0]] = [0]*(2*n)
b[index[1]] = [0]*(2*n)
##deleting column
for lk in range(2*n):
b[lk][index[0]] = 0
b[lk][index[1]] = 0
for ilj in range(2*n):
print(c[ilj],end = " ")
``` | instruction | 0 | 71,199 | 17 | 142,398 |
No | output | 1 | 71,199 | 17 | 142,399 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.
Every contestant hopes that he can find a teammate so that their team’s strength is as high as possible. That is, a contestant will form a team with highest strength possible by choosing a teammate from ones who are willing to be a teammate with him/her. More formally, two people A and B may form a team if each of them is the best possible teammate (among the contestants that remain unpaired) for the other one.
Can you determine who will be each person’s teammate?
Input
There are 2n lines in the input.
The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed.
The i-th line (i > 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people are numbered starting from 1.)
Output
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
Examples
Input
2
6
1 2
3 4 5
Output
2 1 4 3
Input
3
487060
3831 161856
845957 794650 976977
83847 50566 691206 498447
698377 156232 59015 382455 626960
Output
6 5 4 3 2 1
Note
In the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Submitted Solution:
```
n = int(input())
lenA = 2*n+1
arr=[]
arr.append([0])
arr.append([0])
for i in range(2,lenA):
row = [0]+list(map(int,input().split()))
arr.append(row)
pos=[0]*lenA
currL = lenA
while(currL>1):
maxE = 0;
p1 = 0
p2 = 0
for i in range(2,lenA):
for j in range(1,i):
if arr[i][j]>maxE:
maxE = arr[i][j]
p1 = i
p2 = j
pos[p1]=p2
pos[p2]=p1
arr[p1] = [0]*len(arr[p1])
arr[p2] = [0]*len(arr[p2])
for k in range(p2+1,lenA):
arr[k][p2]=0
for k in range(p1+1,lenA):
arr[k][p1]=0
print(pos)
currL-=2
pos = [str(i) for i in pos]
print(' '.join(pos[1:]))
``` | instruction | 0 | 71,200 | 17 | 142,400 |
No | output | 1 | 71,200 | 17 | 142,401 |
Provide a correct Python 3 solution for this coding contest problem.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1 | instruction | 0 | 71,511 | 17 | 143,022 |
"Correct Solution:
```
# AOJ 0211: Jogging
# Python3 2018.6.25 bal4u
def lcm(a, b):
return a // gcd(a, b) * b
def gcd(a, b):
while b != 0:
r = a % b
a, b = b, r
return a
def ngcd(n, a): # aが整数のリスト
if n == 1: return a[0]
g = gcd(a[0], a[1]);
for i in range(2, n):
if g == 1: break
g = gcd(g, a[i])
return g;
def nlcm(n, a): # aが整数のリスト
if n == 1: return a[0];
g = gcd(a[0], a[1]);
c = a[0] //g *a[1]
for i in range(2, n):
g = gcd(c, a[i])
c = c //g * a[i]
return c
while True:
n = int(input())
if n == 0: break
d, v = [], []
for i in range(n):
a, b = map(int, input().split())
g = gcd(a, b)
a //= g
b //= g
d.append(a)
v.append(b)
g = nlcm(n, d);
for i in range(n): d[i] = (g//d[i])*v[i]
g = ngcd(n, d)
for i in range(n): print(d[i]//g)
``` | output | 1 | 71,511 | 17 | 143,023 |
Provide a correct Python 3 solution for this coding contest problem.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1 | instruction | 0 | 71,512 | 17 | 143,024 |
"Correct Solution:
```
from fractions import gcd
from functools import reduce
from sys import stdin
def lcm_base(x, y):
return (x * y) // gcd(x, y)
def lcm(*numbers):
return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
while(True):
n = int(stdin.readline())
if not n: break
s = [list(map(int,stdin.readline().split())) for _ in range(n)]
lcmde = lcm_list([r[1] for r in s])
lcmnu = lcm_list([r[0]*lcmde//r[1] for r in s])
print("\n".join( str(lcmnu*r[1]//lcmde//r[0]) for r in s))
``` | output | 1 | 71,512 | 17 | 143,025 |
Provide a correct Python 3 solution for this coding contest problem.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1 | instruction | 0 | 71,513 | 17 | 143,026 |
"Correct Solution:
```
from sys import stdin
readline = stdin.readline
from fractions import Fraction
from fractions import gcd
from functools import reduce
from collections import namedtuple
Runner = namedtuple('Runner', 'd v')
def common_denominator(r0, ri):
return Fraction(r0.d * ri.v, r0.v * ri.d).denominator
def lcm(a, b):
return a * b / gcd(a, b)
while True:
n = int(readline())
if n == 0:
break
runners = [Runner(*map(int, readline().split())) for _ in range(n)]
denominators = [common_denominator(runners[0], ri) for ri in runners[1:]]
round_of_0 = int(reduce(lcm, denominators))
time = Fraction(runners[0].d * round_of_0, runners[0].v)
for ri in runners:
print(time * ri.v / ri.d)
``` | output | 1 | 71,513 | 17 | 143,027 |
Provide a correct Python 3 solution for this coding contest problem.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1 | instruction | 0 | 71,514 | 17 | 143,028 |
"Correct Solution:
```
def GCD(a,b):
if min(a,b)==0:
return max(a,b)
else:
return GCD(min(a,b),max(a,b)%min(a,b))
def _LCM(a,b):
return a*b//GCD(a,b)
def LCM(array):
lcm=1
for i in array:
lcm=_LCM(lcm,i)
return lcm
while True:
n=int(input())
if n==0:
break
d=[]
v=[]
for i in range(n):
_d,_v=[int(j) for j in input().split(" ")]
d.append(_d)
v.append(_v)
V=1
for i in range(n):
V=V*v[i]
array=[d[i]*V//v[i] for i in range(n)]
lcm=LCM(array)
for i in range(n):
print(lcm*v[i]//(V*d[i]))
``` | output | 1 | 71,514 | 17 | 143,029 |
Provide a correct Python 3 solution for this coding contest problem.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1 | instruction | 0 | 71,515 | 17 | 143,030 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Jogging
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0211
"""
import sys
from math import gcd
from functools import reduce
def solve(n, data):
res = []
for i in range(n):
t = 1
for j in range(n):
t *= (data[j][0], data[j][1])[i==j]
res.append(t)
g = reduce(gcd, res)
return [r//g for r in res]
def main(args):
while True:
n = int(input())
if n == 0:
break
data = [[int(i) for i in input().split()] for _ in range(n)]
ans = solve(n, data)
print(*ans, sep='\n')
if __name__ == '__main__':
main(sys.argv[1:])
``` | output | 1 | 71,515 | 17 | 143,031 |
Provide a correct Python 3 solution for this coding contest problem.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1 | instruction | 0 | 71,516 | 17 | 143,032 |
"Correct Solution:
```
from fractions import gcd
from functools import reduce
from sys import stdin
def lcm_base(x, y):
return (x * y) // gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
while(True):
n = int(stdin.readline())
if not n: break
s = [list(map(int,stdin.readline().split())) for _ in range(n)]
lcmde = lcm_list([r[1] for r in s])
lcmnu = lcm_list([r[0]*lcmde//r[1] for r in s])
print("\n".join( str(lcmnu*r[1]//lcmde//r[0]) for r in s))
``` | output | 1 | 71,516 | 17 | 143,033 |
Provide a correct Python 3 solution for this coding contest problem.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1 | instruction | 0 | 71,517 | 17 | 143,034 |
"Correct Solution:
```
from math import gcd
from functools import reduce
def gcd_mul(numbers):
return reduce(gcd, numbers)
def lcm(x, y):
return x * y // gcd(x, y)
def lcm_mul(numbers):
return reduce(lcm, numbers)
def solve():
from sys import stdin
file_input = stdin
from operator import mul
while True:
n = int(file_input.readline())
if n == 0:
break
d_list = []
v_list = []
for i in range(n):
d, v = map(int, file_input.readline().split())
d_list.append(d)
v_list.append(v)
mv = reduce(mul, v_list)
x = [mv * d // v for d, v in zip(d_list, v_list)]
l = lcm_mul(x)
for s in x:
print(l // s)
solve()
``` | output | 1 | 71,517 | 17 | 143,035 |
Provide a correct Python 3 solution for this coding contest problem.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1 | instruction | 0 | 71,518 | 17 | 143,036 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
def lcm(a, b):
return (a // gcd(a, b)) * b
while True:
n = int(input())
if n == 0:
break
students = [0] * n
v_lcm = 1
for i in range(n):
students[i] = list(map(int, input().split()))
v_lcm = lcm(v_lcm, students[i][1])
mul_lcm = 1
for i in range(n):
mul_lcm = lcm(mul_lcm, (v_lcm // students[i][1]) * students[i][0])
for i in range(n):
print(mul_lcm // (v_lcm // students[i][1]) // students[i][0])
``` | output | 1 | 71,518 | 17 | 143,037 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1
Submitted Solution:
```
def gcd(m, n):
r = m % n
return gcd(n, r) if r else n
def lcm(m, n):
return m//gcd(m, n)*n
while 1:
N = int(input())
if N == 0:
break
X = []
D = []; V = []
for i in range(N):
d, v = map(int, input().split())
g = gcd(d, v)
d //= g; v //= g
D.append(d); V.append(v)
vg = V[0]
for v in V:
vg = gcd(vg, v)
dl = 1
for d in D:
dl = lcm(dl, d)
for d, v in zip(D, V):
print(v//vg*dl//d)
``` | instruction | 0 | 71,519 | 17 | 143,038 |
Yes | output | 1 | 71,519 | 17 | 143,039 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1
Submitted Solution:
```
""" Created by Jieyi on 10/4/16. """
import io
import sys
from fractions import gcd
if len(sys.argv) > 1:
filename = sys.argv[1]
inp = ''.join(open(filename, "r").readlines())
sys.stdin = io.StringIO(inp)
def lcm(x, y):
return (x * y) / gcd(x, y)
def mul_lcm(array):
l = array[0]
if len(array) > 1:
for i in range(1, len(array)):
l = lcm(array[i], l)
return l
def algorithm(students, n):
denominator_lcm = mul_lcm([y for _, y in students])
for i in range(len(students)):
students[i][0] *= int(denominator_lcm / students[i][1])
molecular_lcm = mul_lcm([x for x, _ in students])
return [int(molecular_lcm / students[i][0]) for i in range(len(students))]
def input_sample():
while True:
n = int(input())
if n == 0:
break
students = [[-1, -1] for _ in range(10)]
for i in range(n):
students[i][0], students[i][1] = list(map(int, input().split()))
answer_list = algorithm(students, n)
for i in range(n):
print(answer_list[i])
def main():
input_sample()
if __name__ == '__main__':
main()
``` | instruction | 0 | 71,520 | 17 | 143,040 |
No | output | 1 | 71,520 | 17 | 143,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1
Submitted Solution:
```
""" Created by Jieyi on 10/4/16. """
import io
import sys
import math
if len(sys.argv) > 1:
filename = sys.argv[1]
inp = ''.join(open(filename, "r").readlines())
sys.stdin = io.StringIO(inp)
def lcm(x, y):
return int((x * y) / math.gcd(x, y))
def mul_lcm(array):
l = array[0]
if len(array) > 1:
for i in range(1, len(array)):
l = lcm(array[i], l)
return l
def algorithm(students, n):
den = [students[i][1] for i in range(n)]
denominator_lcm = mul_lcm(den)
ans = [-1] * 20
for i in range(n):
ans[i] = students[i][0] * int(denominator_lcm / students[i][1])
molecular_lcm = mul_lcm(ans[0:n])
return [int(molecular_lcm / ans[i]) for i in range(n)]
def input_sample():
while True:
n = int(input())
if n == 0:
break
# students = [[-1, -1] for _ in range(20)]
# for i in range(n):
# students[i][0], students[i][1] = list(map(int, input().split()))
students = [list(map(int, input().split(' '))) for _ in range(n)]
answer_list = algorithm(students, n)
for i in range(n):
print(answer_list[i])
def main():
input_sample()
if __name__ == '__main__':
main()
``` | instruction | 0 | 71,521 | 17 | 143,042 |
No | output | 1 | 71,521 | 17 | 143,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1
Submitted Solution:
```
from fractions import gcd
from functools import reduce
from sys import stdin
def lcm_base(x, y):
return (x * y) // gcd(x, y)
def lcm(*numbers):
return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
while(True):
n = int(stdin.readline())
if not n: break
s = [list(map(int,stdin.readline().split())) for _ in range(n)]
lcmde = lcm_list([r[1] for r in s])
lcmnu = lcm_list([int(r[0]*lcmde/r[1]) for r in s])
print("\n".join( str(int(lcmnu/lcmde*r[1]/r[0])) for r in s))
``` | instruction | 0 | 71,522 | 17 | 143,044 |
No | output | 1 | 71,522 | 17 | 143,045 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start elementary school at the same time?
Enter the number of students n, the distance d (km) per lap of each student's course, and the running speed v (km / hour) of each student. To do this, create a program that outputs how many laps each student has made. Please note that each student will not run more than 231-1 laps.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
d1 v1
d2 v2
::
dn vn
The first line gives the number of students n (2 ≤ n ≤ 10). The next n lines give the distance di (1 ≤ di ≤ 10000) and the running speed vi (1 ≤ vi ≤ 10000) for one lap of the course of the i-th student.
The number of datasets does not exceed 2000.
Output
Outputs the number of laps for each student for each input dataset. Please output the number of laps of each student on one line according to the order of input.
Example
Input
2
4 3
5 4
5
789 289
166 46
9 4
617 252
972 303
2
8 5
32 20
0
Output
15
16
1598397732
1209243492
1939462992
1782294192
1360317793
1
1
Submitted Solution:
```
def lcm(x, y):
return (x * y) / gcd(x, y)
def mul_lcm(array):
l = array[0]
if len(array) > 1:
for i in range(1, len(array)):
l = lcm(array[i], l)
return l
def algorithm(students):
denominator_lcm = mul_lcm([y for _, y in students])
for i in range(len(students)):
students[i][0] *= int(denominator_lcm / students[i][1])
molecular_lcm = mul_lcm([x for x, _ in students])
return [int(molecular_lcm / students[i][0]) for i in range(len(students))]
def input_sample():
while True:
n = int(input())
if n == 0:
break
students = []
for _ in range(n):
students.append(list(map(int, input().split())))
answer_list = algorithm(students)
for ans in answer_list:
print(ans)
def main():
input_sample()
if __name__ == '__main__':
main()
``` | instruction | 0 | 71,523 | 17 | 143,046 |
No | output | 1 | 71,523 | 17 | 143,047 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
Alice and Bob are competing in the 50m dash.
However, in this world, the higher the AOJ rate is, the better, so the higher the AOJ rate wins.
If there is no AOJ rate on either side, there is no comparison, so there is no choice but to compete in the 50m sprint time. In this case, the one with the shorter time wins.
If the AOJ rates are the same, it is a draw, and if you have to compete in the 50m time, it is a draw if the times are the same.
Constraints
The input satisfies the following conditions.
* $ 1 \ leq T_1, T_2 \ lt 100 $
* $ -1 \ leq R_1, R_2 \ lt 2850 $
* All inputs are integers
Input
The input is given in the following format.
$ T_1 $ $ T_2 $ $ R_1 $ $ R_2 $
Each element is given separated by blanks.
$ T_1 and T_2 $ represent the time of Alice and Bob's 50m run, respectively, and $ R_1 and R_2 $ represent the rates of Alice and Bob's AOJ, respectively.
However, $ R_1 = -1 $ indicates that there is no Alice rate, and $ R_2 = -1 $ indicates that there is no Bob rate.
Output
Print "Alice" if Alice wins, "Bob" if Bob wins, and "Draw" if it's a draw on the $ 1 $ line.
Examples
Input
9 8 1000 999
Output
Alice
Input
9 8 1000 1000
Output
Draw
Input
9 8 2849 -1
Output
Bob | instruction | 0 | 71,590 | 17 | 143,180 |
"Correct Solution:
```
t1, t2, r1, r2 = map(int, input().split())
if r1 != -1 and r2 != -1 :
if r1 > r2 :
print("Alice")
elif r1 < r2 :
print("Bob")
else :
print("Draw")
else :
if t1 < t2 :
print("Alice")
elif t1 > t2 :
print("Bob")
else :
print("Draw")
``` | output | 1 | 71,590 | 17 | 143,181 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
Alice and Bob are competing in the 50m dash.
However, in this world, the higher the AOJ rate is, the better, so the higher the AOJ rate wins.
If there is no AOJ rate on either side, there is no comparison, so there is no choice but to compete in the 50m sprint time. In this case, the one with the shorter time wins.
If the AOJ rates are the same, it is a draw, and if you have to compete in the 50m time, it is a draw if the times are the same.
Constraints
The input satisfies the following conditions.
* $ 1 \ leq T_1, T_2 \ lt 100 $
* $ -1 \ leq R_1, R_2 \ lt 2850 $
* All inputs are integers
Input
The input is given in the following format.
$ T_1 $ $ T_2 $ $ R_1 $ $ R_2 $
Each element is given separated by blanks.
$ T_1 and T_2 $ represent the time of Alice and Bob's 50m run, respectively, and $ R_1 and R_2 $ represent the rates of Alice and Bob's AOJ, respectively.
However, $ R_1 = -1 $ indicates that there is no Alice rate, and $ R_2 = -1 $ indicates that there is no Bob rate.
Output
Print "Alice" if Alice wins, "Bob" if Bob wins, and "Draw" if it's a draw on the $ 1 $ line.
Examples
Input
9 8 1000 999
Output
Alice
Input
9 8 1000 1000
Output
Draw
Input
9 8 2849 -1
Output
Bob | instruction | 0 | 71,591 | 17 | 143,182 |
"Correct Solution:
```
T1, T2, R1, R2 = map(int, input().split())
if -1 in [R1, R2]:
if T1<T2:
print("Alice")
elif T1>T2:
print("Bob")
else:
print("Draw")
else:
if R1 > R2:
print("Alice")
elif R1 < R2:
print("Bob")
else:
print("Draw")
``` | output | 1 | 71,591 | 17 | 143,183 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
Alice and Bob are competing in the 50m dash.
However, in this world, the higher the AOJ rate is, the better, so the higher the AOJ rate wins.
If there is no AOJ rate on either side, there is no comparison, so there is no choice but to compete in the 50m sprint time. In this case, the one with the shorter time wins.
If the AOJ rates are the same, it is a draw, and if you have to compete in the 50m time, it is a draw if the times are the same.
Constraints
The input satisfies the following conditions.
* $ 1 \ leq T_1, T_2 \ lt 100 $
* $ -1 \ leq R_1, R_2 \ lt 2850 $
* All inputs are integers
Input
The input is given in the following format.
$ T_1 $ $ T_2 $ $ R_1 $ $ R_2 $
Each element is given separated by blanks.
$ T_1 and T_2 $ represent the time of Alice and Bob's 50m run, respectively, and $ R_1 and R_2 $ represent the rates of Alice and Bob's AOJ, respectively.
However, $ R_1 = -1 $ indicates that there is no Alice rate, and $ R_2 = -1 $ indicates that there is no Bob rate.
Output
Print "Alice" if Alice wins, "Bob" if Bob wins, and "Draw" if it's a draw on the $ 1 $ line.
Examples
Input
9 8 1000 999
Output
Alice
Input
9 8 1000 1000
Output
Draw
Input
9 8 2849 -1
Output
Bob | instruction | 0 | 71,592 | 17 | 143,184 |
"Correct Solution:
```
t1,t2,r1,r2 = map(int,input().split())
if r1 == -1 or r2 == -1:
if t1 < t2:
print('Alice')
elif t1 > t2:
print('Bob')
else:
print('Draw')
elif r1 > r2:
print('Alice')
elif r1 < r2:
print('Bob')
else:
print('Draw')
``` | output | 1 | 71,592 | 17 | 143,185 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
Alice and Bob are competing in the 50m dash.
However, in this world, the higher the AOJ rate is, the better, so the higher the AOJ rate wins.
If there is no AOJ rate on either side, there is no comparison, so there is no choice but to compete in the 50m sprint time. In this case, the one with the shorter time wins.
If the AOJ rates are the same, it is a draw, and if you have to compete in the 50m time, it is a draw if the times are the same.
Constraints
The input satisfies the following conditions.
* $ 1 \ leq T_1, T_2 \ lt 100 $
* $ -1 \ leq R_1, R_2 \ lt 2850 $
* All inputs are integers
Input
The input is given in the following format.
$ T_1 $ $ T_2 $ $ R_1 $ $ R_2 $
Each element is given separated by blanks.
$ T_1 and T_2 $ represent the time of Alice and Bob's 50m run, respectively, and $ R_1 and R_2 $ represent the rates of Alice and Bob's AOJ, respectively.
However, $ R_1 = -1 $ indicates that there is no Alice rate, and $ R_2 = -1 $ indicates that there is no Bob rate.
Output
Print "Alice" if Alice wins, "Bob" if Bob wins, and "Draw" if it's a draw on the $ 1 $ line.
Examples
Input
9 8 1000 999
Output
Alice
Input
9 8 1000 1000
Output
Draw
Input
9 8 2849 -1
Output
Bob | instruction | 0 | 71,593 | 17 | 143,186 |
"Correct Solution:
```
a,b,c,d = map(int,input().split())
def A_win():
print("Alice")
def B_win():
print("Bob")
def Draw():
print("Draw")
if c == -1 or d == -1:
if a < b:
A_win()
elif a > b:
B_win()
else:
Draw()
elif c > d:
A_win()
elif c < d:
B_win()
elif c == d:
Draw()
``` | output | 1 | 71,593 | 17 | 143,187 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
Alice and Bob are competing in the 50m dash.
However, in this world, the higher the AOJ rate is, the better, so the higher the AOJ rate wins.
If there is no AOJ rate on either side, there is no comparison, so there is no choice but to compete in the 50m sprint time. In this case, the one with the shorter time wins.
If the AOJ rates are the same, it is a draw, and if you have to compete in the 50m time, it is a draw if the times are the same.
Constraints
The input satisfies the following conditions.
* $ 1 \ leq T_1, T_2 \ lt 100 $
* $ -1 \ leq R_1, R_2 \ lt 2850 $
* All inputs are integers
Input
The input is given in the following format.
$ T_1 $ $ T_2 $ $ R_1 $ $ R_2 $
Each element is given separated by blanks.
$ T_1 and T_2 $ represent the time of Alice and Bob's 50m run, respectively, and $ R_1 and R_2 $ represent the rates of Alice and Bob's AOJ, respectively.
However, $ R_1 = -1 $ indicates that there is no Alice rate, and $ R_2 = -1 $ indicates that there is no Bob rate.
Output
Print "Alice" if Alice wins, "Bob" if Bob wins, and "Draw" if it's a draw on the $ 1 $ line.
Examples
Input
9 8 1000 999
Output
Alice
Input
9 8 1000 1000
Output
Draw
Input
9 8 2849 -1
Output
Bob | instruction | 0 | 71,595 | 17 | 143,190 |
"Correct Solution:
```
t1,t2,r1,r2 = [ int(s) for s in input().split() ]
if r1 == -1 or r2 == -1:
if t1 < t2:
print('Alice')
elif t1 > t2:
print('Bob')
else:
print('Draw')
else:
if r1 > r2:
print('Alice')
elif r1 < r2:
print('Bob')
else:
print('Draw')
``` | output | 1 | 71,595 | 17 | 143,191 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event, then the n rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if n = 5 and k = 3, then each participant will recieve an 1 rating unit, and also 2 rating units will remain unused. If n = 5, and k = 6, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if n=5, then the answer is equal to the sequence 0, 1, 2, 5. Each of the sequence values (and only them) can be obtained as ⌊ n/k ⌋ for some positive integer k (where ⌊ x ⌋ is the value of x rounded down): 0 = ⌊ 5/7 ⌋, 1 = ⌊ 5/5 ⌋, 2 = ⌊ 5/2 ⌋, 5 = ⌊ 5/1 ⌋.
Write a program that, for a given n, finds a sequence of all possible rating increments.
Input
The first line contains integer number t (1 ≤ t ≤ 10) — the number of test cases in the input. Then t test cases follow.
Each line contains an integer n (1 ≤ n ≤ 10^9) — the total number of the rating units being drawn.
Output
Output the answers for each of t test cases. Each answer should be contained in two lines.
In the first line print a single integer m — the number of different rating increment values that Vasya can get.
In the following line print m integers in ascending order — the values of possible rating increments.
Example
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | instruction | 0 | 71,770 | 17 | 143,540 |
Tags: binary search, math, meet-in-the-middle, number theory
Correct Solution:
```
t=int(input())
for i in range(t):
n=int(input())
s=set()
f=[]
for j in range(1,int(n**0.5)+1):
d=n//j
e=n//(n//j)
if d not in s:
s.add(d)
f.append(d)
if e not in s:
s.add(e)
f.append(e)
f.append(0)
f.sort()
print(len(f))
print(*f,sep=" ")
``` | output | 1 | 71,770 | 17 | 143,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event, then the n rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if n = 5 and k = 3, then each participant will recieve an 1 rating unit, and also 2 rating units will remain unused. If n = 5, and k = 6, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if n=5, then the answer is equal to the sequence 0, 1, 2, 5. Each of the sequence values (and only them) can be obtained as ⌊ n/k ⌋ for some positive integer k (where ⌊ x ⌋ is the value of x rounded down): 0 = ⌊ 5/7 ⌋, 1 = ⌊ 5/5 ⌋, 2 = ⌊ 5/2 ⌋, 5 = ⌊ 5/1 ⌋.
Write a program that, for a given n, finds a sequence of all possible rating increments.
Input
The first line contains integer number t (1 ≤ t ≤ 10) — the number of test cases in the input. Then t test cases follow.
Each line contains an integer n (1 ≤ n ≤ 10^9) — the total number of the rating units being drawn.
Output
Output the answers for each of t test cases. Each answer should be contained in two lines.
In the first line print a single integer m — the number of different rating increment values that Vasya can get.
In the following line print m integers in ascending order — the values of possible rating increments.
Example
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | instruction | 0 | 71,771 | 17 | 143,542 |
Tags: binary search, math, meet-in-the-middle, number theory
Correct Solution:
```
t=int(input())
for i in range(0,t):
n=int(input())
L=[0,1]
if(n==1):
print(2)
print(*L)
else:
y=int(n**0.5)
L=[i for i in range(y+1)]
for i in range(y+1,0,-1):
x=n//i
if(L[-1]<x):
L.append(x)
print(len(L))
print(*L)
``` | output | 1 | 71,771 | 17 | 143,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event, then the n rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if n = 5 and k = 3, then each participant will recieve an 1 rating unit, and also 2 rating units will remain unused. If n = 5, and k = 6, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if n=5, then the answer is equal to the sequence 0, 1, 2, 5. Each of the sequence values (and only them) can be obtained as ⌊ n/k ⌋ for some positive integer k (where ⌊ x ⌋ is the value of x rounded down): 0 = ⌊ 5/7 ⌋, 1 = ⌊ 5/5 ⌋, 2 = ⌊ 5/2 ⌋, 5 = ⌊ 5/1 ⌋.
Write a program that, for a given n, finds a sequence of all possible rating increments.
Input
The first line contains integer number t (1 ≤ t ≤ 10) — the number of test cases in the input. Then t test cases follow.
Each line contains an integer n (1 ≤ n ≤ 10^9) — the total number of the rating units being drawn.
Output
Output the answers for each of t test cases. Each answer should be contained in two lines.
In the first line print a single integer m — the number of different rating increment values that Vasya can get.
In the following line print m integers in ascending order — the values of possible rating increments.
Example
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | instruction | 0 | 71,772 | 17 | 143,544 |
Tags: binary search, math, meet-in-the-middle, number theory
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
ans=[]
i=1
while i<n:
if len(ans)!=0:
if ans[-1]==n//i:
break
ans.append(n//i)
i+=1
if len(ans)==0:
print(2)
print("0 1")
continue
for i in range(ans[-1]-1,-1,-1):
ans.append(i)
print(len(ans))
print(" ".join(map(str,ans[::-1])))
``` | output | 1 | 71,772 | 17 | 143,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event, then the n rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if n = 5 and k = 3, then each participant will recieve an 1 rating unit, and also 2 rating units will remain unused. If n = 5, and k = 6, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if n=5, then the answer is equal to the sequence 0, 1, 2, 5. Each of the sequence values (and only them) can be obtained as ⌊ n/k ⌋ for some positive integer k (where ⌊ x ⌋ is the value of x rounded down): 0 = ⌊ 5/7 ⌋, 1 = ⌊ 5/5 ⌋, 2 = ⌊ 5/2 ⌋, 5 = ⌊ 5/1 ⌋.
Write a program that, for a given n, finds a sequence of all possible rating increments.
Input
The first line contains integer number t (1 ≤ t ≤ 10) — the number of test cases in the input. Then t test cases follow.
Each line contains an integer n (1 ≤ n ≤ 10^9) — the total number of the rating units being drawn.
Output
Output the answers for each of t test cases. Each answer should be contained in two lines.
In the first line print a single integer m — the number of different rating increment values that Vasya can get.
In the following line print m integers in ascending order — the values of possible rating increments.
Example
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | instruction | 0 | 71,773 | 17 | 143,546 |
Tags: binary search, math, meet-in-the-middle, number theory
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
aa=set()
aa.add(0)
for i in range(1,int(n**0.5)+1):
aa.add(n//i)
aa.add(i)
print(len(aa))
print(*sorted(aa))
``` | output | 1 | 71,773 | 17 | 143,547 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event, then the n rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if n = 5 and k = 3, then each participant will recieve an 1 rating unit, and also 2 rating units will remain unused. If n = 5, and k = 6, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if n=5, then the answer is equal to the sequence 0, 1, 2, 5. Each of the sequence values (and only them) can be obtained as ⌊ n/k ⌋ for some positive integer k (where ⌊ x ⌋ is the value of x rounded down): 0 = ⌊ 5/7 ⌋, 1 = ⌊ 5/5 ⌋, 2 = ⌊ 5/2 ⌋, 5 = ⌊ 5/1 ⌋.
Write a program that, for a given n, finds a sequence of all possible rating increments.
Input
The first line contains integer number t (1 ≤ t ≤ 10) — the number of test cases in the input. Then t test cases follow.
Each line contains an integer n (1 ≤ n ≤ 10^9) — the total number of the rating units being drawn.
Output
Output the answers for each of t test cases. Each answer should be contained in two lines.
In the first line print a single integer m — the number of different rating increment values that Vasya can get.
In the following line print m integers in ascending order — the values of possible rating increments.
Example
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | instruction | 0 | 71,774 | 17 | 143,548 |
Tags: binary search, math, meet-in-the-middle, number theory
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
l = [n]
test = 2
while n//test != l[-1]:
l.append(n//test)
test += 1
while l[-1] != 0:
l.append(l[-1] - 1)
print(len(l))
print(' '.join(map(str,l[::-1])))
``` | output | 1 | 71,774 | 17 | 143,549 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event, then the n rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if n = 5 and k = 3, then each participant will recieve an 1 rating unit, and also 2 rating units will remain unused. If n = 5, and k = 6, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if n=5, then the answer is equal to the sequence 0, 1, 2, 5. Each of the sequence values (and only them) can be obtained as ⌊ n/k ⌋ for some positive integer k (where ⌊ x ⌋ is the value of x rounded down): 0 = ⌊ 5/7 ⌋, 1 = ⌊ 5/5 ⌋, 2 = ⌊ 5/2 ⌋, 5 = ⌊ 5/1 ⌋.
Write a program that, for a given n, finds a sequence of all possible rating increments.
Input
The first line contains integer number t (1 ≤ t ≤ 10) — the number of test cases in the input. Then t test cases follow.
Each line contains an integer n (1 ≤ n ≤ 10^9) — the total number of the rating units being drawn.
Output
Output the answers for each of t test cases. Each answer should be contained in two lines.
In the first line print a single integer m — the number of different rating increment values that Vasya can get.
In the following line print m integers in ascending order — the values of possible rating increments.
Example
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | instruction | 0 | 71,775 | 17 | 143,550 |
Tags: binary search, math, meet-in-the-middle, number theory
Correct Solution:
```
import math
def main():
t = int(input())
for i in range(t):
n = int(input())
c = int(math.sqrt(n)) + 10
result = set()
for i in range(1, c):
result.add(n // i)
c = n // (c - 1)
for i in range(c):
result.add(i)
result = list(result)
result.sort()
print(len(result))
print(' '.join([str(x) for x in result]))
if __name__ == '__main__':
main()
``` | output | 1 | 71,775 | 17 | 143,551 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event, then the n rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if n = 5 and k = 3, then each participant will recieve an 1 rating unit, and also 2 rating units will remain unused. If n = 5, and k = 6, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if n=5, then the answer is equal to the sequence 0, 1, 2, 5. Each of the sequence values (and only them) can be obtained as ⌊ n/k ⌋ for some positive integer k (where ⌊ x ⌋ is the value of x rounded down): 0 = ⌊ 5/7 ⌋, 1 = ⌊ 5/5 ⌋, 2 = ⌊ 5/2 ⌋, 5 = ⌊ 5/1 ⌋.
Write a program that, for a given n, finds a sequence of all possible rating increments.
Input
The first line contains integer number t (1 ≤ t ≤ 10) — the number of test cases in the input. Then t test cases follow.
Each line contains an integer n (1 ≤ n ≤ 10^9) — the total number of the rating units being drawn.
Output
Output the answers for each of t test cases. Each answer should be contained in two lines.
In the first line print a single integer m — the number of different rating increment values that Vasya can get.
In the following line print m integers in ascending order — the values of possible rating increments.
Example
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | instruction | 0 | 71,777 | 17 | 143,554 |
Tags: binary search, math, meet-in-the-middle, number theory
Correct Solution:
```
t = int(input())
for i in range(t):
n = int(input())
lst = [0]
for j in range(1,n+1):
tmp = int(n//j)
lst.append(tmp)
if tmp*tmp <= n:
# print(tmp)
for k in range(tmp+2):
if k*k <= n:
lst.append(k)
break
lst = list(set(lst))
lst.sort()
lst = [str(i) for i in lst]
print(len(lst))
print(" ".join(lst))
``` | output | 1 | 71,777 | 17 | 143,555 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject. | instruction | 0 | 71,899 | 17 | 143,798 |
Tags: implementation
Correct Solution:
```
n,m=map(int,input().split())
l=[]
for i in range(n):
p=list(map(int,list(input())))
l.append(p)
q=[]
for i in range(m):
x=[l[k][i] for k in range(n)]
r=max(x)
q.append(r)
k=0
for i in range(n):
if any(l[i][j]==q[j] for j in range(m)):
k+=1
print(k)
``` | output | 1 | 71,899 | 17 | 143,799 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject. | instruction | 0 | 71,900 | 17 | 143,800 |
Tags: implementation
Correct Solution:
```
n, m = map(int, input().split())
count = 0
b = [0]*101
c = list()
for i in range(n):
s = input()
c.append(s)
for i in range(m):
if int(s[i])>=b[i]:
b[i]=int(s[i])
for i in range(n):
for j in range(m):
if int(c[i][j])==b[j]:
count+=1
break
print(count)
``` | output | 1 | 71,900 | 17 | 143,801 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject. | instruction | 0 | 71,901 | 17 | 143,802 |
Tags: implementation
Correct Solution:
```
"""Things to do if you are stuck:-
1.Read the problem statement again, maybe you've read something wrong.
2.See the explanation for the sample input .
3.If the solution is getting too complex in cases where no. of submissions
are high ,then drop that idea because there is something simple which you are
missing.
4.Check for runtime errors if unexpected o/p is seen.
5.Check on edge cases before submitting.
6.Ensure that you have read all the inputs before returning for a test case.
7.Try to think of brute force first if nothing is striking.
8.Take more examples
9.Don't give up , maybe you're just one statement away! """
#pyrival orz
import os
import sys
import math
from io import BytesIO, IOBase
input = sys.stdin.readline
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
############ ---- Dijkstra with path ---- ############
def dijkstra(start, distance, path, n):
# requires n == number of vertices in graph,
# adj == adjacency list with weight of graph
visited = [False for _ in range(n)] # To keep track of vertices that are visited
distance[start] = 0 # distance of start node from itself is 0
for i in range(n):
v = -1 # Initialize v == vertex from which its neighboring vertices' distance will be calculated
for j in range(n):
# If it has not been visited and has the lowest distance from start
if not visited[v] and (v == -1 or distance[j] < distance[v]):
v = j
if distance[v] == math.inf:
break
visited[v] = True # Mark as visited
for edge in adj[v]:
destination = edge[0] # Neighbor of the vertex
weight = edge[1] # Its corresponding weight
if distance[v] + weight < distance[destination]: # If its distance is less than the stored distance
distance[destination] = distance[v] + weight # Update the distance
path[destination] = v # Update the path
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a%b)
def lcm(a, b):
return (a*b)//gcd(a, b)
def ncr(n, r):
return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
def npr(n, r):
return math.factorial(n)//math.factorial(n-r)
def seive(n):
primes = [True]*(n+1)
ans = []
for i in range(2, n):
if not primes[i]:
continue
j = 2*i
while j <= n:
primes[j] = False
j += i
for p in range(2, n+1):
if primes[p]:
ans += [p]
return ans
def factors(n):
factors = []
x = 1
while x*x <= n:
if n % x == 0:
if n // x == x:
factors.append(x)
else:
factors.append(x)
factors.append(n//x)
x += 1
return factors
# Functions: list of factors, seive of primes, gcd of two numbers,
# lcm of two numbers, npr, ncr
def main():
try:
n, m = invr()
s = set()
arr = [0]*m
scores = []
for i in range(n):
temp = list(input())
scores.append(temp)
for j in range(m):
arr[j] = max(arr[j], int(temp[j]))
for i in range(n):
for j in range(m):
if int(scores[i][j]) == arr[j]:
s.add(i)
print(len(s))
except Exception as e:
print(e)
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
if __name__ == "__main__":
main()
``` | output | 1 | 71,901 | 17 | 143,803 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject. | instruction | 0 | 71,902 | 17 | 143,804 |
Tags: implementation
Correct Solution:
```
n, m = map(int, input().split())
a = [input() for i in range(n)]
sel = [0] * n
for j in range(m):
mx = '1'
for i in range(n):
if a[i][j] > mx:
mx = a[i][j]
for i in range(n):
if a[i][j] == mx:
sel[i] = 1
print(sum(sel))
``` | output | 1 | 71,902 | 17 | 143,805 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject. | instruction | 0 | 71,903 | 17 | 143,806 |
Tags: implementation
Correct Solution:
```
n,m=list(map(int,input().split()))
l=[]
count=0
for i in range(n):
l.append(input())
final=[]
for i in range(m):
f=[]
for j in l:
f.append(int(j[i]))
r=max(f)
for k in range(n):
if r==f[k] and k+1 not in final:
count+=1
final.append(k+1)
print(count)
``` | output | 1 | 71,903 | 17 | 143,807 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject. | instruction | 0 | 71,904 | 17 | 143,808 |
Tags: implementation
Correct Solution:
```
# Description of the problem can be found at http://codeforces.com/problemset/problem/152/A
n, m = map(int, input().split())
d_s = {}
l_s = list(set() for _ in range(m))
for i in range(n):
s = input()
for j in range(m):
if j not in d_s:
d_s[j] = int(s[j])
l_s[j].add(i)
elif d_s[j] < int(s[j]):
d_s[j] = int(s[j])
l_s[j].clear()
l_s[j].add(i)
elif d_s[j] == int(s[j]):
l_s[j].add(i)
for i in range(1, m):
l_s[0] = l_s[0].union(l_s[i])
print(len(l_s[0]))
``` | output | 1 | 71,904 | 17 | 143,809 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject. | instruction | 0 | 71,905 | 17 | 143,810 |
Tags: implementation
Correct Solution:
```
n, m = map(int, input().split())
maxes = [[0] for i in range(m)]
ss = []
def set_max(s: str):
ss.append(s)
for i in range(m):
if maxes[i][0] < int(s[i]):
maxes[i][0] = int(s[i])
for i in range(n):
set_max(input())
count, jj = 0, []
for i in range(m):
for j in range(n):
if int(ss[j][i]) == maxes[i][0] and j not in jj:
count += 1
jj.append(j)
print(count)
``` | output | 1 | 71,905 | 17 | 143,811 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject. | instruction | 0 | 71,906 | 17 | 143,812 |
Tags: implementation
Correct Solution:
```
import sys
n,m,*l = sys.stdin.read().split()
n = int(n)
m = int(m)
g = []
st = 0
for s in l:
sb = 0
for c in s:
if st == 0:
g.append([])
g[sb].append(int(c))
sb +=1
st += 1
best = [0] * n
for sb in range(m):
mx = max(g[sb])
for st in range(n):
if g[sb][st] == mx:
best[st] = 1
print(sum(best))
``` | output | 1 | 71,906 | 17 | 143,813 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject.
Submitted Solution:
```
# parse = lambda st: map(int, st.split())
# def solve(n, m, grades):
# res = set()
# for i in range(m):
# highest = None
# best = 0
# for j in range(n):
# if grades[j][i] > best:
# best = grades[j][i]
# highest = []
# highest.append(j)
# elif grades[j][i] == best:
# highest.append(j)
# res.update(set(highest))
# return len(res)
# def solve2(n, m, grades):
# res = set()
# subjects = [[grades[j][i] for j in range(n)] for i in range(m)]
# for grades in subjects:
# _max = max(grades)
# for student, grade in enumerate(grades):
# if grade == _max:
# res.add(student)
# return len(res)
# main
# n, m = map(int, input().split())
# grades = [[int(x) for x in input()] for _ in range(n)]
# res = set()
# subjects = [[grades[j][i] for j in range(n)] for i in range(m)]
# for j in range(m):
# _max = max([grades[i][j] for i in range(n)])
# for i in range(n):
# if grades[i][j] == _max:
# res.add(i)
# print(len(res))
def readln(): return tuple(map(int, input().split()))
n, m = readln()
dis = list(zip(*tuple([list(input()) for _ in range(n)])))
best = [0]*n
for j in range(m):
t = max(dis[j])
for i in range(n):
if dis[j][i] == t:
best[i] = 1
print(sum(best))
``` | instruction | 0 | 71,907 | 17 | 143,814 |
Yes | output | 1 | 71,907 | 17 | 143,815 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject.
Submitted Solution:
```
a=list(input().split())
n=int(a[0])
m=int(a[1])
b=[]
for i in range(n):
b.append(list(input()))
k=[]
for i in range(m):
high=int (b[0][i])
for j in range(n):
if high<int(b[j][i]):
high=int(b[j][i])
for j in range(n):
if high==int(b[j][i]):
k.append(j)
k=set(k)
print(len(k))
``` | instruction | 0 | 71,908 | 17 | 143,816 |
Yes | output | 1 | 71,908 | 17 | 143,817 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject.
Submitted Solution:
```
n,m = map(int,input().split())
mat = []
for i in range(n):
row = list(str(input()))
row = [int(i) for i in row]
mat.append(row)
topper = set()
mat = list(zip(*mat))
#print(mat)
r,c = len(mat),len(mat[0])
for i in range(r):
for j in range(c):
if mat[i][j] == max(mat[i]):
topper.add(j+1)
print(len(topper))
``` | instruction | 0 | 71,909 | 17 | 143,818 |
Yes | output | 1 | 71,909 | 17 | 143,819 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject.
Submitted Solution:
```
#!/usr/bin/env python3
import os
from sys import stdin, stdout
def solve(tc):
n, m = map(int, stdin.readline().split())
grade = []
for i in range(n):
grade.append(stdin.readline().strip())
idx = list(range(n))
successful = [False for i in range(n)]
for i in range(m):
out = sorted(idx, key=lambda x: grade[x][i], reverse=True)
cur = grade[out[0]][i]
successful[out[0]] = True
for j in range(1, n):
if grade[out[j]][i] < cur:
break
successful[out[j]] = True
cnt = 0
for i in range(n):
if successful[i]:
cnt += 1
print(cnt)
tcs = 1
tc = 1
while tc <= tcs:
solve(tc)
tc += 1
``` | instruction | 0 | 71,910 | 17 | 143,820 |
Yes | output | 1 | 71,910 | 17 | 143,821 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject.
Submitted Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 27 19:13:51 2018
@author: alexis
"""
students, classes = input().split(' ')
students = int(students)
classes = int(classes)
data = []
for i in range(students):
c_student = input()
data.append(list(map(int, c_student)))
#print(data)
suck_students = 0
for j in range(classes):
current_c = []
for i in data:
current_c.append(i[j])
if current_c.count(max(current_c)) == 1:
suck_students += 1
print(suck_students)
#
#3 3
#223
#232
#112
``` | instruction | 0 | 71,911 | 17 | 143,822 |
No | output | 1 | 71,911 | 17 | 143,823 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject.
Submitted Solution:
```
n, m = map(int, input().split())
maxes = [[0] for i in range(m)]
st = [[0] for i in range(m)]
ss = []
def set_max(s: str):
ss.append(s)
for i in range(m):
if maxes[i][0] < int(s[i]):
maxes[i][0] = int(s[i])
for i in range(n):
set_max(input())
for i in range(m):
for j in range(n):
if int(ss[j][i]) == maxes[i][0]:
st[i][0] += 1
print(max(st)[0])
``` | instruction | 0 | 71,912 | 17 | 143,824 |
No | output | 1 | 71,912 | 17 | 143,825 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject.
Submitted Solution:
```
# your code goes here
arr = input().split()
n = int(arr[0])
m = int(arr[1])
best = [-1]*m
win = [-1]*m
suc = [0]*n
for i in range(n):
arr = list(input())
for j in range(m):
if int(arr[j]) >= best[j]:
best[j] = int(arr[j])
prev = win[j]
win[j] = i
suc[i] += 1
if prev != -1:
suc[prev] -= 1
# print(str(i) + '#' + str(j) + '#' + str(prev))
ctr = 0
for i in range(n):
if suc[i] > 0:
ctr += 1
print(str(ctr))
``` | instruction | 0 | 71,913 | 17 | 143,826 |
No | output | 1 | 71,913 | 17 | 143,827 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Output
Print the single number — the number of successful students in the given group.
Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
Note
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject.
Submitted Solution:
```
n = input().split(' ')
ye = []
bigboy = []
smartpeople = 0
for i in range(int(n[0])):
yee = list(input())
for j in range(len(yee)):
yee[j] = int(yee[j])
ye.append(yee)
for i in range(len(ye)):
for j in range(len(ye)):
bigboy.append(ye[j][i])
bigboy.sort(reverse=True)
if bigboy[0] != bigboy[1]:
smartpeople += 1
bigboy = []
print(smartpeople)
``` | instruction | 0 | 71,914 | 17 | 143,828 |
No | output | 1 | 71,914 | 17 | 143,829 |
Provide a correct Python 3 solution for this coding contest problem.
In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds.
Create a program that takes the time recorded in the speed skating competitions (500 M and 1000 M) as input and outputs what grade it corresponds to in the speed skating badge test. The table below shows the default badge test times for the 500 M and 1000 M. If it is less than class E, output NA.
| 500 M | 1000 M
--- | --- | ---
AAA class | 35 seconds 50 | 1 minute 11 seconds 00
AA class | 37 seconds 50 | 1 minute 17 seconds 00
Class A | 40 seconds 00 | 1 minute 23 seconds 00
Class B | 43 seconds 00 | 1 minute 29 seconds 00
Class C | 50 seconds 00 | 1 minute 45 seconds 00
Class D | 55 seconds 00 | 1 minute 56 seconds 00
Class E | 1 minute 10 seconds 00 | 2 minutes 28 seconds 00
Input
Given multiple datasets. For each dataset, real numbers t1, t2 (8.0 ≤ t1, t2 ≤ 360.0) representing 500 M time and 1000 M time, respectively, are given, separated by blanks. t1 and t2 are given in seconds as real numbers, including up to two digits after the decimal point.
The number of datasets does not exceed 100.
Output
For each data set, output the judgment result AAA ~ E or NA on one line.
Example
Input
40.0 70.0
72.5 140.51
Output
B
NA | instruction | 0 | 72,404 | 17 | 144,808 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
import sys
import os
import math
for s in sys.stdin:
a, b = map(float, s.split())
if a < 35.5 and b < 71:
print('AAA')
elif a < 37.5 and b < 77:
print('AA')
elif a < 40 and b < 83:
print('A')
elif a < 43 and b < 89:
print('B')
elif a < 50 and b < 105:
print('C')
elif a < 55 and b < 116:
print('D')
elif a < 70 and b < 148:
print('E')
else:
print('NA')
``` | output | 1 | 72,404 | 17 | 144,809 |
Provide a correct Python 3 solution for this coding contest problem.
In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds.
Create a program that takes the time recorded in the speed skating competitions (500 M and 1000 M) as input and outputs what grade it corresponds to in the speed skating badge test. The table below shows the default badge test times for the 500 M and 1000 M. If it is less than class E, output NA.
| 500 M | 1000 M
--- | --- | ---
AAA class | 35 seconds 50 | 1 minute 11 seconds 00
AA class | 37 seconds 50 | 1 minute 17 seconds 00
Class A | 40 seconds 00 | 1 minute 23 seconds 00
Class B | 43 seconds 00 | 1 minute 29 seconds 00
Class C | 50 seconds 00 | 1 minute 45 seconds 00
Class D | 55 seconds 00 | 1 minute 56 seconds 00
Class E | 1 minute 10 seconds 00 | 2 minutes 28 seconds 00
Input
Given multiple datasets. For each dataset, real numbers t1, t2 (8.0 ≤ t1, t2 ≤ 360.0) representing 500 M time and 1000 M time, respectively, are given, separated by blanks. t1 and t2 are given in seconds as real numbers, including up to two digits after the decimal point.
The number of datasets does not exceed 100.
Output
For each data set, output the judgment result AAA ~ E or NA on one line.
Example
Input
40.0 70.0
72.5 140.51
Output
B
NA | instruction | 0 | 72,405 | 17 | 144,810 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0123
"""
import sys
def solve(r500, r1000):
criteria = [(35.50, 71.0, 'AAA'),
(37.50, 77.0, 'AA'),
(40.0, 83.0, 'A'),
(43.0, 89.0, 'B'),
(50.0, 105.0, 'C'),
(55.0, 116.0, 'D'),
(70.0, 148.0, 'E')]
rank = None
for c500, c1000, r in criteria:
if r500 < c500 and r1000 < c1000:
rank = r
break
if rank == None:
rank = 'NA'
return rank
def main(args):
for line in sys.stdin:
r500, r1000 = [float(x) for x in line.strip().split()]
result = solve(r500, r1000)
print(result)
if __name__ == '__main__':
main(sys.argv[1:])
``` | output | 1 | 72,405 | 17 | 144,811 |
Provide a correct Python 3 solution for this coding contest problem.
In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds.
Create a program that takes the time recorded in the speed skating competitions (500 M and 1000 M) as input and outputs what grade it corresponds to in the speed skating badge test. The table below shows the default badge test times for the 500 M and 1000 M. If it is less than class E, output NA.
| 500 M | 1000 M
--- | --- | ---
AAA class | 35 seconds 50 | 1 minute 11 seconds 00
AA class | 37 seconds 50 | 1 minute 17 seconds 00
Class A | 40 seconds 00 | 1 minute 23 seconds 00
Class B | 43 seconds 00 | 1 minute 29 seconds 00
Class C | 50 seconds 00 | 1 minute 45 seconds 00
Class D | 55 seconds 00 | 1 minute 56 seconds 00
Class E | 1 minute 10 seconds 00 | 2 minutes 28 seconds 00
Input
Given multiple datasets. For each dataset, real numbers t1, t2 (8.0 ≤ t1, t2 ≤ 360.0) representing 500 M time and 1000 M time, respectively, are given, separated by blanks. t1 and t2 are given in seconds as real numbers, including up to two digits after the decimal point.
The number of datasets does not exceed 100.
Output
For each data set, output the judgment result AAA ~ E or NA on one line.
Example
Input
40.0 70.0
72.5 140.51
Output
B
NA | instruction | 0 | 72,406 | 17 | 144,812 |
"Correct Solution:
```
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
N = list(get_input())
for l in range(len(N)):
t1, t2 = [float(i) for i in N[l].split()]
if t1 < 35.5 and t2 < 71.0:
print("AAA")
elif t1 < 37.5 and t2 < 77.0:
print("AA")
elif t1 < 40.0 and t2 < 83.0:
print("A")
elif t1 < 43.0 and t2 < 89.0:
print("B")
elif t1 < 50.0 and t2 < 105.0:
print("C")
elif t1 < 55.0 and t2 < 116.0:
print("D")
elif t1 < 70.0 and t2 < 148.0:
print("E")
else:
print("NA")
``` | output | 1 | 72,406 | 17 | 144,813 |
Provide a correct Python 3 solution for this coding contest problem.
In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds.
Create a program that takes the time recorded in the speed skating competitions (500 M and 1000 M) as input and outputs what grade it corresponds to in the speed skating badge test. The table below shows the default badge test times for the 500 M and 1000 M. If it is less than class E, output NA.
| 500 M | 1000 M
--- | --- | ---
AAA class | 35 seconds 50 | 1 minute 11 seconds 00
AA class | 37 seconds 50 | 1 minute 17 seconds 00
Class A | 40 seconds 00 | 1 minute 23 seconds 00
Class B | 43 seconds 00 | 1 minute 29 seconds 00
Class C | 50 seconds 00 | 1 minute 45 seconds 00
Class D | 55 seconds 00 | 1 minute 56 seconds 00
Class E | 1 minute 10 seconds 00 | 2 minutes 28 seconds 00
Input
Given multiple datasets. For each dataset, real numbers t1, t2 (8.0 ≤ t1, t2 ≤ 360.0) representing 500 M time and 1000 M time, respectively, are given, separated by blanks. t1 and t2 are given in seconds as real numbers, including up to two digits after the decimal point.
The number of datasets does not exceed 100.
Output
For each data set, output the judgment result AAA ~ E or NA on one line.
Example
Input
40.0 70.0
72.5 140.51
Output
B
NA | instruction | 0 | 72,407 | 17 | 144,814 |
"Correct Solution:
```
# Aizu Problem 00123: Speed Skating Badge Test
#
import sys, math, os, copy
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
grades = ["AAA", "AA", "A", "B", "C", "D", "E", "NA"]
limits = [[35.5, 71], [37.5, 77], [40, 83], [43, 89], [50, 105],
[55, 116], [70, 148], [99999999, 999999999]]
for line in sys.stdin:
t1, t2 = [float(_) for _ in line.split()]
for k in range(8):
if t1 < limits[k][0] and t2 < limits[k][1]:
print(grades[k])
break
``` | output | 1 | 72,407 | 17 | 144,815 |
Provide a correct Python 3 solution for this coding contest problem.
In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds.
Create a program that takes the time recorded in the speed skating competitions (500 M and 1000 M) as input and outputs what grade it corresponds to in the speed skating badge test. The table below shows the default badge test times for the 500 M and 1000 M. If it is less than class E, output NA.
| 500 M | 1000 M
--- | --- | ---
AAA class | 35 seconds 50 | 1 minute 11 seconds 00
AA class | 37 seconds 50 | 1 minute 17 seconds 00
Class A | 40 seconds 00 | 1 minute 23 seconds 00
Class B | 43 seconds 00 | 1 minute 29 seconds 00
Class C | 50 seconds 00 | 1 minute 45 seconds 00
Class D | 55 seconds 00 | 1 minute 56 seconds 00
Class E | 1 minute 10 seconds 00 | 2 minutes 28 seconds 00
Input
Given multiple datasets. For each dataset, real numbers t1, t2 (8.0 ≤ t1, t2 ≤ 360.0) representing 500 M time and 1000 M time, respectively, are given, separated by blanks. t1 and t2 are given in seconds as real numbers, including up to two digits after the decimal point.
The number of datasets does not exceed 100.
Output
For each data set, output the judgment result AAA ~ E or NA on one line.
Example
Input
40.0 70.0
72.5 140.51
Output
B
NA | instruction | 0 | 72,408 | 17 | 144,816 |
"Correct Solution:
```
while True:
try:
t1, t2 = map(float, input().split())
except:
break
t1, t2 = int(t1*100), int(t2*100)
if t1 < 3550 and t2 < 7100:
print("AAA")
elif t1 < 3750 and t2 < 7700:
print("AA")
elif t1 < 4000 and t2 < 8300:
print("A")
elif t1 < 4300 and t2 < 8900:
print("B")
elif t1 < 5000 and t2 < 10500:
print("C")
elif t1 < 5500 and t2 < 11600:
print("D")
elif t1 < 7000 and t2 < 14800:
print("E")
else:
print("NA")
``` | output | 1 | 72,408 | 17 | 144,817 |
Provide a correct Python 3 solution for this coding contest problem.
In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds.
Create a program that takes the time recorded in the speed skating competitions (500 M and 1000 M) as input and outputs what grade it corresponds to in the speed skating badge test. The table below shows the default badge test times for the 500 M and 1000 M. If it is less than class E, output NA.
| 500 M | 1000 M
--- | --- | ---
AAA class | 35 seconds 50 | 1 minute 11 seconds 00
AA class | 37 seconds 50 | 1 minute 17 seconds 00
Class A | 40 seconds 00 | 1 minute 23 seconds 00
Class B | 43 seconds 00 | 1 minute 29 seconds 00
Class C | 50 seconds 00 | 1 minute 45 seconds 00
Class D | 55 seconds 00 | 1 minute 56 seconds 00
Class E | 1 minute 10 seconds 00 | 2 minutes 28 seconds 00
Input
Given multiple datasets. For each dataset, real numbers t1, t2 (8.0 ≤ t1, t2 ≤ 360.0) representing 500 M time and 1000 M time, respectively, are given, separated by blanks. t1 and t2 are given in seconds as real numbers, including up to two digits after the decimal point.
The number of datasets does not exceed 100.
Output
For each data set, output the judgment result AAA ~ E or NA on one line.
Example
Input
40.0 70.0
72.5 140.51
Output
B
NA | instruction | 0 | 72,409 | 17 | 144,818 |
"Correct Solution:
```
# AOJ 0123 Speed Skating Badge Test
# Python3 2018.6.18 bal4u
m500 = [ 35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0, 1000.0 ]
m1000 = [ 71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0, 1000.0 ]
clas = [ "AAA", "AA", "A", "B", "C", "D", "E", "NA" ]
while True:
try: t500, t1000 = list(map(float, input().split()))
except: break
for i in range(len(m500)):
if t500 < m500[i] and t1000 < m1000[i]:
print(clas[i])
break
``` | output | 1 | 72,409 | 17 | 144,819 |
Provide a correct Python 3 solution for this coding contest problem.
In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds.
Create a program that takes the time recorded in the speed skating competitions (500 M and 1000 M) as input and outputs what grade it corresponds to in the speed skating badge test. The table below shows the default badge test times for the 500 M and 1000 M. If it is less than class E, output NA.
| 500 M | 1000 M
--- | --- | ---
AAA class | 35 seconds 50 | 1 minute 11 seconds 00
AA class | 37 seconds 50 | 1 minute 17 seconds 00
Class A | 40 seconds 00 | 1 minute 23 seconds 00
Class B | 43 seconds 00 | 1 minute 29 seconds 00
Class C | 50 seconds 00 | 1 minute 45 seconds 00
Class D | 55 seconds 00 | 1 minute 56 seconds 00
Class E | 1 minute 10 seconds 00 | 2 minutes 28 seconds 00
Input
Given multiple datasets. For each dataset, real numbers t1, t2 (8.0 ≤ t1, t2 ≤ 360.0) representing 500 M time and 1000 M time, respectively, are given, separated by blanks. t1 and t2 are given in seconds as real numbers, including up to two digits after the decimal point.
The number of datasets does not exceed 100.
Output
For each data set, output the judgment result AAA ~ E or NA on one line.
Example
Input
40.0 70.0
72.5 140.51
Output
B
NA | instruction | 0 | 72,410 | 17 | 144,820 |
"Correct Solution:
```
import sys
for line in sys.stdin:
[p, q] = line.split();
a = float(p);
b = float(q);
if (a < 35.5) & (b < 71.0):
print('AAA');
elif (a < 37.5) & (b < 77.0):
print('AA');
elif (a < 40.0) & (b < 83.0):
print('A');
elif (a < 43.0) & (b < 89.0):
print('B');
elif (a < 50.0) & (b < 105.0):
print('C');
elif (a < 55.0) & (b < 116.0):
print('D');
elif (a < 70.0) & (b < 148.0):
print('E');
else:
print('NA');
``` | output | 1 | 72,410 | 17 | 144,821 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.