message stringlengths 2 67k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 463 109k | cluster float64 19 19 | __index_level_0__ int64 926 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory. | instruction | 0 | 57,316 | 19 | 114,632 |
Tags: games, math, number theory
Correct Solution:
```
import operator
from functools import reduce
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
def sqrt(n):
low, high = 1, 10**7
while low < high:
mid = (low+high)//2
if mid**2 > n:
high = mid
else:
low = mid+1
return low
def first_divisor(q, include_self=False):
for i in range(2, sqrt(q)):
if q%i == 0:
return i, q//i
return 1, q
def solve():
q = read_int()
d0, q0 = first_divisor(q)
if d0 != 1:
d1, q1 = first_divisor(q0)
if d1 != 1:
print(1)
print(d0*d1)
else:
print(2)
else:
print(1)
print(0)
if __name__ == '__main__':
solve()
``` | output | 1 | 57,316 | 19 | 114,633 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory. | instruction | 0 | 57,317 | 19 | 114,634 |
Tags: games, math, number theory
Correct Solution:
```
n=eval(input())
t=n
l=[0]
for i in range(2,int(n**0.5)+1):
while n%i==0:
n/=i
l.append(int(i))
if n>1 and n!=t:
l.append(int(n))
if (len(l)!=3):
try:
print("1\n{}".format(l[1]*l[2]))
except:
print("1\n0")
else:
print(2)
``` | output | 1 | 57,317 | 19 | 114,635 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory. | instruction | 0 | 57,318 | 19 | 114,636 |
Tags: games, math, number theory
Correct Solution:
```
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
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")
ALPHA='abcdefghijklmnopqrstuvwxyz'
MOD=1000000007
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]
#-------------------------code---------------------------#
# vsInput()
def PrimeFactors(n):
factors=[]
if(n<0):
factors.append(-1)
n=abs(n)
while(n%2==0):
factors.append(2)
n//=2
for i in range(3,int(sqrt(n))+1,2):
while(n%i==0):
factors.append(i)
n//=i
if(n>1):
factors.append(n)
return factors
n=Int()
fact=PrimeFactors(n)
if(len(fact)==1 or n==1):
print(1)
print(0)
elif(len(fact)==2):
print(2)
else:
print(1)
print(fact[0]*fact[1])
``` | output | 1 | 57,318 | 19 | 114,637 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory. | instruction | 0 | 57,319 | 19 | 114,638 |
Tags: games, math, number theory
Correct Solution:
```
import math
import sys
import collections
from collections import defaultdict
from sys import stdin, stdout
sys.setrecursionlimit(10**9)
def isPrime(n):
flag=0
if n==2:
return True
for i in range(2,math.ceil(math.sqrt(n+1))+1):
if n%i==0:
flag=1
break
if flag==1:
return False
else:
return True
def find_divisors(n):
for i in range(2,math.ceil(math.sqrt(n))+1):
if n%i==0:
return i
n=int(input())
d=find_divisors(n)
# print(d)
if n==1:
print(1)
print(0)
elif isPrime(n):
print(1)
print(0)
else:
# print(isPrime(d),isPrime(n//d))
if isPrime(d) and isPrime(n//d):
print(2)
else:
print(1)
print(d*find_divisors(n//d))
``` | output | 1 | 57,319 | 19 | 114,639 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory. | instruction | 0 | 57,320 | 19 | 114,640 |
Tags: games, math, number theory
Correct Solution:
```
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
# sys.setrecursionlimit(int(pow(10,6)))
# sys.stdout = open("out.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
try:
sys.stdin = open("input.txt", "r")
except:
pass
# @lru_cache(None)
n=L()[0]
div=[]
grt=0
x=n
for i in range(2,int(n**0.5)+2):
if n%i==0 and x!=i:
k=0
while(n%i==0):
k+=1
n//=i
# print(i,k)
if k>2 or (k==2 and i*i!=x):
grt=1
break
div.append([i,k])
if n!=1 and n!=x:
div.append([n,1])
if len(div)==0 or grt or len(div)>=3:
print(1)
if len(div)==0 and not grt:
print(0)
elif grt:
print(i*i)
else:
print(div[0][0]*div[1][0])
exit()
else:
print(2)
``` | output | 1 | 57,320 | 19 | 114,641 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory. | instruction | 0 | 57,321 | 19 | 114,642 |
Tags: games, math, number theory
Correct Solution:
```
from math import sqrt
def prime(n):
if n in [2, 3]:
return True
if n < 2 or n % 2 == 0 or n % 3 == 0:
return False
i = 5
while (i * i <= n):
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True
def factorize(n): # o(sqr(n))
c, ans = 2, []
while (c * c < n):
if n % c == 0:
ans.extend([c, n // c])
c += 1
if c * c == n:
ans.extend([c, c])
return sorted(ans)
n = int(input())
if prime(n) or n == 1:
print(1, 0, sep='\n')
else:
fac, primes = factorize(n), []
for i in fac:
if prime(i):
primes.append(i)
if i * i in fac:
print(1)
exit(print(i * i))
if len(primes) == 2 and len(fac) != len(primes):
print(1)
exit(print(primes[0] * primes[1]))
print(2)
``` | output | 1 | 57,321 | 19 | 114,643 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory. | instruction | 0 | 57,322 | 19 | 114,644 |
Tags: games, math, number theory
Correct Solution:
```
import sys
line = sys.stdin.readline()
N = int(line)
tmp = N
factor = []
i = 2
while i**2 <= tmp:
if tmp % i == 0:
tmp //= i
factor.append(i)
else: i += 1
if tmp != 1: factor.append(i)
if len(factor) == 2: print(2)
else:
print(1)
if len(factor) <= 1: print(0)
else: print(factor[0] * factor[1])
``` | output | 1 | 57,322 | 19 | 114,645 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory. | instruction | 0 | 57,323 | 19 | 114,646 |
Tags: games, math, number theory
Correct Solution:
```
import sys
from collections import defaultdict
import math
MAXNUM = math.inf
MINNUM = -1 * math.inf
ASCIILOWER = 97
ASCIIUPPER = 65
def getInt():
return int(sys.stdin.readline().rstrip())
def getInts():
return map(int, sys.stdin.readline().rstrip().split(" "))
def getString():
return sys.stdin.readline().rstrip()
def getDivisors(x):
if x == 1:
return [1]
if x == 2:
return [2]
f = []
MAX = math.sqrt(x) + 1
cur = 2
while cur <= x and cur < MAX:
if x % cur == 0:
f.append(cur)
x //= cur
else:
cur += 1
if len(f) > 2:
break
if x > 1:
f.append(x)
return f
def printOutput(ans):
if ans[0] == 1:
sys.stdout.write(str(ans[0]) + "\n")
sys.stdout.write(str(ans[1]) + "\n")
else:
sys.stdout.write(str(ans[0]) + "\n")
def solve(x):
factors = getDivisors(x)
if len(factors) == 1:
return 1, 0
elif len(factors) == 2:
return [2]
else:
ans = factors[0] * factors[1]
return 1, ans
def readinput():
x = getInt()
printOutput(solve(x))
readinput()
``` | output | 1 | 57,323 | 19 | 114,647 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory.
Submitted Solution:
```
q = int(input())
x = q**0.5
x1 = q
ans = []
for i in range(2, int(x)+1):
while q%i == 0:
ans.append(i)
q = q/i
#print(ans)
if len(ans)==0 :
print(1)
print(0)
elif len(ans)==1 or len(ans)==2 and ans[0]*ans[1] == x1:
print(2)
else:
print(1)
print(ans[0]*ans[1])
``` | instruction | 0 | 57,324 | 19 | 114,648 |
Yes | output | 1 | 57,324 | 19 | 114,649 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory.
Submitted Solution:
```
import math
def prime(n):
b = int(math.sqrt(n))
l = []
while n % 2 == 0:
l.append(2)
n = n // 2
for i in range(3, b+1,2):
while n % i== 0:
l.append(i)
n = n // i
if n > 2:
l.append(n)
return l
n = int(input())
l = prime(n)
if len(l) > 2:
print(1)
print(l[0]*l[1])
elif len(l) == 0 or len(l) == 1:
print(1)
print(0)
else:
print(2)
``` | instruction | 0 | 57,325 | 19 | 114,650 |
Yes | output | 1 | 57,325 | 19 | 114,651 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory.
Submitted Solution:
```
n = int(input())
p = n
arr = []
while p%2==0:
arr.append(2)
p = p//2
x = int(p**0.5)+1
for i in range(3,x,2):
while p%i==0:
arr.append(i)
p = p//i
if p>2:
arr.append(p)
if n==1 or len(arr)==1:
print(1)
print(0)
elif len(arr)==2:
print(2)
else:
x = arr[0]*arr[1]
print(1)
print(x)
``` | instruction | 0 | 57,326 | 19 | 114,652 |
Yes | output | 1 | 57,326 | 19 | 114,653 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory.
Submitted Solution:
```
def winorfreeze(n):
factors = []
# If there are at least three prime factors playes 1 wins
# saying the product of two of them
i = 2
while i * i <= n:
while n % i == 0:
factors.append(i)
n //= i
if len(factors) == 2 and n != 1:
return factors[0] * factors[1]
i += 1
if n != 1:
factors.append(n)
# if n has exactly two prime factors player 2 wins
# otherwise n is prime and player 1 wins at the beginning
return None if len(factors) == 2 else 0
def main():
n = int(input())
ans = winorfreeze(n)
if ans is None:
print(2)
else:
print(1)
print(ans)
if __name__ == "__main__":
main()
``` | instruction | 0 | 57,327 | 19 | 114,654 |
Yes | output | 1 | 57,327 | 19 | 114,655 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory.
Submitted Solution:
```
import math
from os import startfile
import random
from queue import Queue
import time
import heapq
import sys
def isPrime(q):
for i in range(2,int(math.sqrt(q))+1):
a=i
b=q//i
if b==q/i:
return False
return True
def main(q):
factors=[]
for i in range(1,int(math.sqrt(q))+1):
a=i
b=q//i
if b==q/i:
factors.append(a)
factors.append(b)
factors.sort()
if len(factors)==4 and not isPrime((q**(1/3))):
print(2)
else:
print(1)
if isPrime(q):
print(0)
else:
val1=factors[2]
if isPrime(val1):
print((val1*factors[1]))
else:
print(val1)
return
q=int(input())
(main(q))
``` | instruction | 0 | 57,328 | 19 | 114,656 |
No | output | 1 | 57,328 | 19 | 114,657 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory.
Submitted Solution:
```
import math
def prime(n):
b = math.ceil(n**(0.5))
l = []
while n % 2 == 0:
l.append(2)
n = n / 2
for i in range(3, b+2,2):
while n % i== 0:
l.append(i)
n = n / i
return l
n = int(input())
if n == 2:
print(1)
print(0)
else:
l = prime(n)
if len(l) > 2:
print(1)
print(l[0]*l[1])
elif len(l) == 0:
print(1)
print(0)
else:
print(2)
``` | instruction | 0 | 57,329 | 19 | 114,658 |
No | output | 1 | 57,329 | 19 | 114,659 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory.
Submitted Solution:
```
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
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")
ALPHA='abcdefghijklmnopqrstuvwxyz'
MOD=1000000007
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]
#-------------------------code---------------------------#
# vsInput()
def primeN(n):
prime = [True for i in range(n+1)]
prime[0]=False
prime[1]=False
p=2
while(p*p<=n):
if(prime[p]):
for i in range(p*p,n+1,p):
prime[i]=False
p+=1
return set([p for p in range(n+1) if(prime[p])])
def divisors(n):
div=set()
for i in range(1,int(sqrt(n))+1):
if(n%i==0):
div.add(i)
div.add(n//i)
return div
primes=primeN(1000000)
n=Int()
ans=0
div=divisors(n)
for i in div:
for p in primes:
if(i%p==0 and i//p in primes):
ans=i
break
if(ans==n):
print(2)
else:
print(1)
print(ans)
``` | instruction | 0 | 57,330 | 19 | 114,660 |
No | output | 1 | 57,330 | 19 | 114,661 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
Input
The first line contains the only integer q (1 β€ q β€ 1013).
Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer β his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.
Examples
Input
6
Output
2
Input
30
Output
1
6
Input
1
Output
1
0
Note
Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the victory.
Submitted Solution:
```
import math
def prime(n):
while n % 2 == 0:
lis.add(2)
n = n / 2
for i in range(3,int(math.sqrt(n))+1,2):
while n % i== 0:
lis.add(i)
n = n / i
if n > 2:
lis.add(n)
n = int(input())
lis=set()
if n==1:
print(1)
print(0)
exit()
prime(n)
lis = list(lis)
if len(lis)==2 and int(lis[0]*lis[1])==n:
print(2)
elif len(lis)==1:
print(1)
print(0)
else:
print(1)
print(int(lis[0]*lis[1]))
``` | instruction | 0 | 57,331 | 19 | 114,662 |
No | output | 1 | 57,331 | 19 | 114,663 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player. | instruction | 0 | 57,492 | 19 | 114,984 |
Tags: implementation
Correct Solution:
```
a = [int(i) for i in input().split()]
summa = sum(a)
if summa == 0:
print (-1)
elif summa % 5 == 0:
print (summa//5)
else:
print (-1)
``` | output | 1 | 57,492 | 19 | 114,985 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player. | instruction | 0 | 57,493 | 19 | 114,986 |
Tags: implementation
Correct Solution:
```
s=sum(map(int,input().split()))
if s%5==0 and s!=0:
print(s//5)
else:
print('-1')
``` | output | 1 | 57,493 | 19 | 114,987 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player. | instruction | 0 | 57,494 | 19 | 114,988 |
Tags: implementation
Correct Solution:
```
coin = sum(list(map(int, input().split())))
if (coin % 5 == 0 and coin != 0):
print(coin//5)
else:
print(-1)
``` | output | 1 | 57,494 | 19 | 114,989 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player. | instruction | 0 | 57,495 | 19 | 114,990 |
Tags: implementation
Correct Solution:
```
a=map(int, input().split(" "))
sum=0
for i in a:
sum+=i
if sum%5==0 and sum>0:
print(sum//5)
else:
print(-1)
``` | output | 1 | 57,495 | 19 | 114,991 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player. | instruction | 0 | 57,496 | 19 | 114,992 |
Tags: implementation
Correct Solution:
```
a=list(map(int,input().split()))
s=sum(a)
if s==0 or s//5!=s/5: print(-1)
else: print(s//5)
``` | output | 1 | 57,496 | 19 | 114,993 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player. | instruction | 0 | 57,497 | 19 | 114,994 |
Tags: implementation
Correct Solution:
```
a = list(map(int, input().split()))
s = sum(a)
if s % 5 == 0 and s > 0:
print(int(s/5))
else:
print(-1)
``` | output | 1 | 57,497 | 19 | 114,995 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player. | instruction | 0 | 57,498 | 19 | 114,996 |
Tags: implementation
Correct Solution:
```
a=[int(i) for i in input().split()]
i=0
h=0
while i<len(a):
h=h+a[i]
i+=1
if h%len(a)==0 and h>0:
print(h//len(a))
else:
print(-1)
``` | output | 1 | 57,498 | 19 | 114,997 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player. | instruction | 0 | 57,499 | 19 | 114,998 |
Tags: implementation
Correct Solution:
```
n = sum(list(map(int, input().split())))
k = n//5 if n%5==0 else -1
print(k if k>0 else -1)
``` | output | 1 | 57,499 | 19 | 114,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player.
Submitted Solution:
```
L = list(map(int,input().split()))
s = sum(L)
if s == 0 or s%5:
print(-1)
else:
print(s//5)
``` | instruction | 0 | 57,500 | 19 | 115,000 |
Yes | output | 1 | 57,500 | 19 | 115,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player.
Submitted Solution:
```
a,b,c,d,e=map(int,input().split())
print(int((a+b+c+d+e)/5) if (a+b+c+d+e)%5==0 and (a+b+c+d+e!=0) else -1)
``` | instruction | 0 | 57,501 | 19 | 115,002 |
Yes | output | 1 | 57,501 | 19 | 115,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player.
Submitted Solution:
```
x=[int(a) for a in input().split()]
if sum(x)!=0 and sum(x)%5==0:
print(sum(x)//5)
else:
print(-1)
``` | instruction | 0 | 57,502 | 19 | 115,004 |
Yes | output | 1 | 57,502 | 19 | 115,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player.
Submitted Solution:
```
s=sum(map(int,input().split()))
if s%5!=0 or s==0: print('-1')
else: print(s//5)
``` | instruction | 0 | 57,503 | 19 | 115,006 |
Yes | output | 1 | 57,503 | 19 | 115,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player.
Submitted Solution:
```
def arr_inp():
return [int(x) for x in input().split()]
c =arr_inp()
if(c[0]==c[1]==c[2]==c[3]==c[4]):
exit(print(-1))
while(True):
ma, mi = max(c), min(c)
ix_ma,ix_mi=c.index(ma),c.index(mi)
c[ix_ma]-=1
c[ix_mi]+=1
if(max(c)-min(c)==1):
exit(print(-1))
if(max(c)-min(c)==0):
exit(print(c[0]))
``` | instruction | 0 | 57,504 | 19 | 115,008 |
No | output | 1 | 57,504 | 19 | 115,009 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player.
Submitted Solution:
```
bet = sum(list(map(int , input().split())))
if bet%5!=0:
print(-1)
else:
print(bet//5)
``` | instruction | 0 | 57,505 | 19 | 115,010 |
No | output | 1 | 57,505 | 19 | 115,011 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player.
Submitted Solution:
```
lis = [int(a) for a in input().split()]
s = sum(lis)
l = len(lis)
if s < 0 or s > 500:
print(-1)
elif s % l == 0:
print(s//l)
else:
print(-1)
``` | instruction | 0 | 57,506 | 19 | 115,012 |
No | output | 1 | 57,506 | 19 | 115,013 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.
Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.
Input
The input consists of a single line containing five integers c1, c2, c3, c4 and c5 β the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 β€ c1, c2, c3, c4, c5 β€ 100).
Output
Print the only line containing a single positive integer b β the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).
Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
Note
In the first sample the following sequence of operations is possible:
1. One coin is passed from the fourth player to the second player;
2. One coin is passed from the fourth player to the fifth player;
3. One coin is passed from the first player to the third player;
4. One coin is passed from the fourth player to the second player.
Submitted Solution:
```
l=list(map(int,input().split()))
total=0
for i in range(len(l)):
total+=l[i]
if total%5==0:
print(total//5)
else:
print(-1)
``` | instruction | 0 | 57,507 | 19 | 115,014 |
No | output | 1 | 57,507 | 19 | 115,015 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Allen and Bessie are playing a simple number game. They both know a function f: \{0, 1\}^n β R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ..., x_n are all set to -1. Each round, with equal probability, one of Allen or Bessie gets to make a move. A move consists of picking an i such that x_i = -1 and either setting x_i β 0 or x_i β 1.
After n rounds all variables are set, and the game value resolves to f(x_1, x_2, ..., x_n). Allen wants to maximize the game value, and Bessie wants to minimize it.
Your goal is to help Allen and Bessie find the expected game value! They will play r+1 times though, so between each game, exactly one value of f changes. In other words, between rounds i and i+1 for 1 β€ i β€ r, f(z_1, ..., z_n) β g_i for some (z_1, ..., z_n) β \{0, 1\}^n. You are to find the expected game value in the beginning and after each change.
Input
The first line contains two integers n and r (1 β€ n β€ 18, 0 β€ r β€ 2^{18}).
The next line contains 2^n integers c_0, c_1, ..., c_{2^n-1} (0 β€ c_i β€ 10^9), denoting the initial values of f. More specifically, f(x_0, x_1, ..., x_{n-1}) = c_x, if x = \overline{x_{n-1} β¦ x_0} in binary.
Each of the next r lines contains two integers z and g (0 β€ z β€ 2^n - 1, 0 β€ g β€ 10^9). If z = \overline{z_{n-1} ... z_0} in binary, then this means to set f(z_0, ..., z_{n-1}) β g.
Output
Print r+1 lines, the i-th of which denotes the value of the game f during the i-th round. Your answer must have absolute or relative error within 10^{-6}.
Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if \frac{|a - b|}{max{(1, |b|)}} β€ 10^{-6}.
Examples
Input
2 2
0 1 2 3
2 5
0 4
Output
1.500000
2.250000
3.250000
Input
1 0
2 3
Output
2.500000
Input
2 0
1 1 1 1
Output
1.000000
Note
Consider the second test case. If Allen goes first, he will set x_1 β 1, so the final value will be 3. If Bessie goes first, then she will set x_1 β 0 so the final value will be 2. Thus the answer is 2.5.
In the third test case, the game value will always be 1 regardless of Allen and Bessie's play. | instruction | 0 | 57,764 | 19 | 115,528 |
Tags: math
Correct Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
(n, r) = (int(i) for i in input().split())
c = [int(i) for i in input().split()]
start = time.time()
s = sum(c)
n2 = 2**n
ans = [s/n2]
for i in range(r):
(k, new) = (int(i) for i in input().split())
s += new - c[k]
c[k] = new
ans.append(s/n2)
for i in range(len(ans)):
print(ans[i])
finish = time.time()
#print(finish - start)
``` | output | 1 | 57,764 | 19 | 115,529 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Allen and Bessie are playing a simple number game. They both know a function f: \{0, 1\}^n β R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ..., x_n are all set to -1. Each round, with equal probability, one of Allen or Bessie gets to make a move. A move consists of picking an i such that x_i = -1 and either setting x_i β 0 or x_i β 1.
After n rounds all variables are set, and the game value resolves to f(x_1, x_2, ..., x_n). Allen wants to maximize the game value, and Bessie wants to minimize it.
Your goal is to help Allen and Bessie find the expected game value! They will play r+1 times though, so between each game, exactly one value of f changes. In other words, between rounds i and i+1 for 1 β€ i β€ r, f(z_1, ..., z_n) β g_i for some (z_1, ..., z_n) β \{0, 1\}^n. You are to find the expected game value in the beginning and after each change.
Input
The first line contains two integers n and r (1 β€ n β€ 18, 0 β€ r β€ 2^{18}).
The next line contains 2^n integers c_0, c_1, ..., c_{2^n-1} (0 β€ c_i β€ 10^9), denoting the initial values of f. More specifically, f(x_0, x_1, ..., x_{n-1}) = c_x, if x = \overline{x_{n-1} β¦ x_0} in binary.
Each of the next r lines contains two integers z and g (0 β€ z β€ 2^n - 1, 0 β€ g β€ 10^9). If z = \overline{z_{n-1} ... z_0} in binary, then this means to set f(z_0, ..., z_{n-1}) β g.
Output
Print r+1 lines, the i-th of which denotes the value of the game f during the i-th round. Your answer must have absolute or relative error within 10^{-6}.
Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if \frac{|a - b|}{max{(1, |b|)}} β€ 10^{-6}.
Examples
Input
2 2
0 1 2 3
2 5
0 4
Output
1.500000
2.250000
3.250000
Input
1 0
2 3
Output
2.500000
Input
2 0
1 1 1 1
Output
1.000000
Note
Consider the second test case. If Allen goes first, he will set x_1 β 1, so the final value will be 3. If Bessie goes first, then she will set x_1 β 0 so the final value will be 2. Thus the answer is 2.5.
In the third test case, the game value will always be 1 regardless of Allen and Bessie's play.
Submitted Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
(n, r) = (int(i) for i in input().split())
c = [int(i) for i in input().split()]
start = time.time()
s = sum(c)
n2 = 2**n
ans = [s/n2]
for i in range(r):
(k, new) = (int(i) for i in input().split())
s += new - c[k]
c[k] = new
ans.append(s/n2)
for i in range(len(ans)):
print(ans[i], end=" ")
print()
finish = time.time()
print(finish - start)
``` | instruction | 0 | 57,765 | 19 | 115,530 |
No | output | 1 | 57,765 | 19 | 115,531 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Allen and Bessie are playing a simple number game. They both know a function f: \{0, 1\}^n β R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ..., x_n are all set to -1. Each round, with equal probability, one of Allen or Bessie gets to make a move. A move consists of picking an i such that x_i = -1 and either setting x_i β 0 or x_i β 1.
After n rounds all variables are set, and the game value resolves to f(x_1, x_2, ..., x_n). Allen wants to maximize the game value, and Bessie wants to minimize it.
Your goal is to help Allen and Bessie find the expected game value! They will play r+1 times though, so between each game, exactly one value of f changes. In other words, between rounds i and i+1 for 1 β€ i β€ r, f(z_1, ..., z_n) β g_i for some (z_1, ..., z_n) β \{0, 1\}^n. You are to find the expected game value in the beginning and after each change.
Input
The first line contains two integers n and r (1 β€ n β€ 18, 0 β€ r β€ 2^{18}).
The next line contains 2^n integers c_0, c_1, ..., c_{2^n-1} (0 β€ c_i β€ 10^9), denoting the initial values of f. More specifically, f(x_0, x_1, ..., x_{n-1}) = c_x, if x = \overline{x_{n-1} β¦ x_0} in binary.
Each of the next r lines contains two integers z and g (0 β€ z β€ 2^n - 1, 0 β€ g β€ 10^9). If z = \overline{z_{n-1} ... z_0} in binary, then this means to set f(z_0, ..., z_{n-1}) β g.
Output
Print r+1 lines, the i-th of which denotes the value of the game f during the i-th round. Your answer must have absolute or relative error within 10^{-6}.
Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if \frac{|a - b|}{max{(1, |b|)}} β€ 10^{-6}.
Examples
Input
2 2
0 1 2 3
2 5
0 4
Output
1.500000
2.250000
3.250000
Input
1 0
2 3
Output
2.500000
Input
2 0
1 1 1 1
Output
1.000000
Note
Consider the second test case. If Allen goes first, he will set x_1 β 1, so the final value will be 3. If Bessie goes first, then she will set x_1 β 0 so the final value will be 2. Thus the answer is 2.5.
In the third test case, the game value will always be 1 regardless of Allen and Bessie's play.
Submitted Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
(n, r) = (int(i) for i in input().split())
c = [int(i) for i in input().split()]
start = time.time()
s = sum(c)
n2 = 2**n
ans = [s/n2]
for i in range(r):
(k, new) = (int(i) for i in input().split())
s += new - c[k]
c[k] = new
ans.append(s/n2)
for i in range(len(ans)):
print(ans[i])
finish = time.time()
print(finish - start)
``` | instruction | 0 | 57,766 | 19 | 115,532 |
No | output | 1 | 57,766 | 19 | 115,533 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Allen and Bessie are playing a simple number game. They both know a function f: \{0, 1\}^n β R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ..., x_n are all set to -1. Each round, with equal probability, one of Allen or Bessie gets to make a move. A move consists of picking an i such that x_i = -1 and either setting x_i β 0 or x_i β 1.
After n rounds all variables are set, and the game value resolves to f(x_1, x_2, ..., x_n). Allen wants to maximize the game value, and Bessie wants to minimize it.
Your goal is to help Allen and Bessie find the expected game value! They will play r+1 times though, so between each game, exactly one value of f changes. In other words, between rounds i and i+1 for 1 β€ i β€ r, f(z_1, ..., z_n) β g_i for some (z_1, ..., z_n) β \{0, 1\}^n. You are to find the expected game value in the beginning and after each change.
Input
The first line contains two integers n and r (1 β€ n β€ 18, 0 β€ r β€ 2^{18}).
The next line contains 2^n integers c_0, c_1, ..., c_{2^n-1} (0 β€ c_i β€ 10^9), denoting the initial values of f. More specifically, f(x_0, x_1, ..., x_{n-1}) = c_x, if x = \overline{x_{n-1} β¦ x_0} in binary.
Each of the next r lines contains two integers z and g (0 β€ z β€ 2^n - 1, 0 β€ g β€ 10^9). If z = \overline{z_{n-1} ... z_0} in binary, then this means to set f(z_0, ..., z_{n-1}) β g.
Output
Print r+1 lines, the i-th of which denotes the value of the game f during the i-th round. Your answer must have absolute or relative error within 10^{-6}.
Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if \frac{|a - b|}{max{(1, |b|)}} β€ 10^{-6}.
Examples
Input
2 2
0 1 2 3
2 5
0 4
Output
1.500000
2.250000
3.250000
Input
1 0
2 3
Output
2.500000
Input
2 0
1 1 1 1
Output
1.000000
Note
Consider the second test case. If Allen goes first, he will set x_1 β 1, so the final value will be 3. If Bessie goes first, then she will set x_1 β 0 so the final value will be 2. Thus the answer is 2.5.
In the third test case, the game value will always be 1 regardless of Allen and Bessie's play.
Submitted Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
(n, r) = (int(i) for i in input().split())
c = [int(i) for i in input().split()]
start = time.time()
s = sum(c)
n2 = 2**n
ans = [s/n2]
for i in range(r):
(k, new) = (int(i) for i in input().split())
s += new - c[k]
c[k] = new
ans.append(s/n2)
print(s/n2)
finish = time.time()
print(finish - start)
``` | instruction | 0 | 57,767 | 19 | 115,534 |
No | output | 1 | 57,767 | 19 | 115,535 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely. | instruction | 0 | 58,418 | 19 | 116,836 |
Tags: constructive algorithms, math
Correct Solution:
```
def main() -> object:
"""
:rtype : string
:return: Who wins.
"""
n1, n2, k1, k2 = [int(i) for i in input().split()]
if n1 > n2:
return "First"
else:
return "Second"
if __name__ == "__main__":
print(main())
``` | output | 1 | 58,418 | 19 | 116,837 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely. | instruction | 0 | 58,419 | 19 | 116,838 |
Tags: constructive algorithms, math
Correct Solution:
```
entrada = input().split(" ")
n1 = int(entrada[0])
n2 = int(entrada[1])
k1 = int(entrada[2])
k2 = int(entrada[3])
if(n1 > n2):
print("First")
else:
print("Second")
#maratona-unicamp
``` | output | 1 | 58,419 | 19 | 116,839 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely. | instruction | 0 | 58,420 | 19 | 116,840 |
Tags: constructive algorithms, math
Correct Solution:
```
nk = input().split()
if int(nk[0])>int(nk[1]) :
print("First")
else :
print("Second")
``` | output | 1 | 58,420 | 19 | 116,841 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely. | instruction | 0 | 58,421 | 19 | 116,842 |
Tags: constructive algorithms, math
Correct Solution:
```
n1,n2,l1,l2=map(int,input().split())
if(n1>n2):
print("First")
else:
print("Second")
``` | output | 1 | 58,421 | 19 | 116,843 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely. | instruction | 0 | 58,422 | 19 | 116,844 |
Tags: constructive algorithms, math
Correct Solution:
```
n,m,k1,k2=map(int,input().split())
if n==m:
print("Second")
elif n>m:
print("First")
else:
print("Second")
``` | output | 1 | 58,422 | 19 | 116,845 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely. | instruction | 0 | 58,423 | 19 | 116,846 |
Tags: constructive algorithms, math
Correct Solution:
```
b = list(map(int, input().split()))
i = 0
if b[0] > b[1]:
print('First')
else:
print('Second')
``` | output | 1 | 58,423 | 19 | 116,847 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely. | instruction | 0 | 58,424 | 19 | 116,848 |
Tags: constructive algorithms, math
Correct Solution:
```
n1, n2, k1, k2 = map(int,input().split())
if n1 == n2:
print('Second')
elif n1<n2:
print('Second')
else:
print('First')
``` | output | 1 | 58,424 | 19 | 116,849 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely. | instruction | 0 | 58,425 | 19 | 116,850 |
Tags: constructive algorithms, math
Correct Solution:
```
"""
βββ βββββββ βββ βββββββ βββββββ βββ ββββββ
βββββββββββββββ βββββββββββββββββββββββββββββ
ββββββ ββββββ ββββββββββββββββββββββββββββ
ββββββ ββββββ βββββββ βββββββββ βββ βββββββ
βββββββββββββββ βββββββββββββββββ βββ βββββββ
βββ βββββββ βββ ββββββββ βββββββ βββ ββββββ
"""
__author__ = "Dilshod"
n1, n2, k1, k2 = list(map(int, input().split()))
if n1 <= n2:
print("Second")
else:
print("First")
``` | output | 1 | 58,425 | 19 | 116,851 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely.
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 13 20:15:41 2019
@author: avina
"""
n1,n2,k1,k2 = map(int, input().split())
if n1 > n2 :
print('First')
else:
print('Second')
``` | instruction | 0 | 58,426 | 19 | 116,852 |
Yes | output | 1 | 58,426 | 19 | 116,853 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely.
Submitted Solution:
```
# import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("output4.out",'w')
n1,n2,k1,k2=map(int,input().split())
print("First" if n1>n2 else "Second")
``` | instruction | 0 | 58,427 | 19 | 116,854 |
Yes | output | 1 | 58,427 | 19 | 116,855 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely.
Submitted Solution:
```
n1, n2, k1, k2=input().split()
n1=int(n1)
n2=int(n2)
k1=int(k1)
k2=int(k2)
for i in range(999999999):
n1-=1
if n1<0:
print("Second")
break
n2-=1
if n2<0:
print("First")
break
``` | instruction | 0 | 58,428 | 19 | 116,856 |
Yes | output | 1 | 58,428 | 19 | 116,857 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely.
Submitted Solution:
```
line=input().split()
m=[]
for i in line:
m.append(int(i))
n1=m[0]
n2=m[1]
k1=m[2]
k2=m[3]
n=0
for n in range(0,100):
n1=n1-1
if n1 <=0:
print('Second')
break
n2=n2-1
if n2 <=0:
print('First')
break
``` | instruction | 0 | 58,429 | 19 | 116,858 |
Yes | output | 1 | 58,429 | 19 | 116,859 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely.
Submitted Solution:
```
"""
βββ βββββββ βββ βββββββ βββββββ βββ ββββββ
βββββββββββββββ βββββββββββββββββββββββββββββ
ββββββ ββββββ ββββββββββββββββββββββββββββ
ββββββ ββββββ βββββββ βββββββββ βββ βββββββ
βββββββββββββββ βββββββββββββββββ βββ βββββββ
βββ βββββββ βββ ββββββββ βββββββ βββ ββββββ
"""
__author__ = "Dilshod"
n1, n2, k1, k2 = list(map(int, input().split()))
if n1 < n2:
print("Second")
if n1 == n2:
if k1 > k2:
print("First")
elif k1 < k2:
print("Second")
else:
print("First")
else:
print("First")
``` | instruction | 0 | 58,430 | 19 | 116,860 |
No | output | 1 | 58,430 | 19 | 116,861 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.
Input
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
Output
Output "First" if the first player wins and "Second" otherwise.
Examples
Input
2 2 1 2
Output
Second
Input
2 1 1 1
Output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely.
Submitted Solution:
```
#! /usr/bin/python
a = input("").split(" ")
if a[0]>a[1]:
print("First")
else:
print("Second")
``` | instruction | 0 | 58,431 | 19 | 116,862 |
No | output | 1 | 58,431 | 19 | 116,863 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.