message stringlengths 2 59.7k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 37 108k | cluster float64 20 20 | __index_level_0__ int64 74 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore she had to pay the tax to enter the territory of Mars.
There are n banknote denominations on Mars: the value of i-th banknote is a_i. Natasha has an infinite number of banknotes of each denomination.
Martians have k fingers on their hands, so they use a number system with base k. In addition, the Martians consider the digit d (in the number system with base k) divine. Thus, if the last digit in Natasha's tax amount written in the number system with the base k is d, the Martians will be happy. Unfortunately, Natasha does not know the Martians' divine digit yet.
Determine for which values d Natasha can make the Martians happy.
Natasha can use only her banknotes. Martians don't give her change.
Input
The first line contains two integers n and k (1 β€ n β€ 100 000, 2 β€ k β€ 100 000) β the number of denominations of banknotes and the base of the number system on Mars.
The second line contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) β denominations of banknotes on Mars.
All numbers are given in decimal notation.
Output
On the first line output the number of values d for which Natasha can make the Martians happy.
In the second line, output all these values in increasing order.
Print all numbers in decimal notation.
Examples
Input
2 8
12 20
Output
2
0 4
Input
3 10
10 20 30
Output
1
0
Note
Consider the first test case. It uses the octal number system.
If you take one banknote with the value of 12, you will get 14_8 in octal system. The last digit is 4_8.
If you take one banknote with the value of 12 and one banknote with the value of 20, the total value will be 32. In the octal system, it is 40_8. The last digit is 0_8.
If you take two banknotes with the value of 20, the total value will be 40, this is 50_8 in the octal system. The last digit is 0_8.
No other digits other than 0_8 and 4_8 can be obtained. Digits 0_8 and 4_8 could also be obtained in other ways.
The second test case uses the decimal number system. The nominals of all banknotes end with zero, so Natasha can give the Martians only the amount whose decimal notation also ends with zero.
Submitted Solution:
```
def hcfnaive(a,b):
if(b==0):
return a
else:
return hcfnaive(b,a%b)
n,k=map(int,input().split())
a=input().split()
for i in range(n):
a[i]=int(a[i])
gcd=a[0]
for i in range(1,n):
gcd=hcfnaive(gcd,a[i])
l=0
ans=[]
for i in range(k):
ans.append(l%k)
l+=gcd
ans=list(set(ans))
ans.sort()
print(len(ans))
print(*ans)
``` | instruction | 0 | 5,819 | 20 | 11,638 |
Yes | output | 1 | 5,819 | 20 | 11,639 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore she had to pay the tax to enter the territory of Mars.
There are n banknote denominations on Mars: the value of i-th banknote is a_i. Natasha has an infinite number of banknotes of each denomination.
Martians have k fingers on their hands, so they use a number system with base k. In addition, the Martians consider the digit d (in the number system with base k) divine. Thus, if the last digit in Natasha's tax amount written in the number system with the base k is d, the Martians will be happy. Unfortunately, Natasha does not know the Martians' divine digit yet.
Determine for which values d Natasha can make the Martians happy.
Natasha can use only her banknotes. Martians don't give her change.
Input
The first line contains two integers n and k (1 β€ n β€ 100 000, 2 β€ k β€ 100 000) β the number of denominations of banknotes and the base of the number system on Mars.
The second line contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) β denominations of banknotes on Mars.
All numbers are given in decimal notation.
Output
On the first line output the number of values d for which Natasha can make the Martians happy.
In the second line, output all these values in increasing order.
Print all numbers in decimal notation.
Examples
Input
2 8
12 20
Output
2
0 4
Input
3 10
10 20 30
Output
1
0
Note
Consider the first test case. It uses the octal number system.
If you take one banknote with the value of 12, you will get 14_8 in octal system. The last digit is 4_8.
If you take one banknote with the value of 12 and one banknote with the value of 20, the total value will be 32. In the octal system, it is 40_8. The last digit is 0_8.
If you take two banknotes with the value of 20, the total value will be 40, this is 50_8 in the octal system. The last digit is 0_8.
No other digits other than 0_8 and 4_8 can be obtained. Digits 0_8 and 4_8 could also be obtained in other ways.
The second test case uses the decimal number system. The nominals of all banknotes end with zero, so Natasha can give the Martians only the amount whose decimal notation also ends with zero.
Submitted Solution:
```
def hcfnaive(a,b):
if(b==0):
return a
else:
return hcfnaive(b,a%b)
n,k=map(int,input().split())
a=input().split()
for i in range(n):
a[i]=int(a[i])
gcd=a[0]
for i in range(2,n):
gcd=hcfnaive(gcd,a[i])
l=0
ans=[]
for i in range(k):
ans.append(l%k)
l+=gcd
ans=list(set(ans))
ans.sort()
print(len(ans))
print(*ans)
``` | instruction | 0 | 5,820 | 20 | 11,640 |
No | output | 1 | 5,820 | 20 | 11,641 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore she had to pay the tax to enter the territory of Mars.
There are n banknote denominations on Mars: the value of i-th banknote is a_i. Natasha has an infinite number of banknotes of each denomination.
Martians have k fingers on their hands, so they use a number system with base k. In addition, the Martians consider the digit d (in the number system with base k) divine. Thus, if the last digit in Natasha's tax amount written in the number system with the base k is d, the Martians will be happy. Unfortunately, Natasha does not know the Martians' divine digit yet.
Determine for which values d Natasha can make the Martians happy.
Natasha can use only her banknotes. Martians don't give her change.
Input
The first line contains two integers n and k (1 β€ n β€ 100 000, 2 β€ k β€ 100 000) β the number of denominations of banknotes and the base of the number system on Mars.
The second line contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) β denominations of banknotes on Mars.
All numbers are given in decimal notation.
Output
On the first line output the number of values d for which Natasha can make the Martians happy.
In the second line, output all these values in increasing order.
Print all numbers in decimal notation.
Examples
Input
2 8
12 20
Output
2
0 4
Input
3 10
10 20 30
Output
1
0
Note
Consider the first test case. It uses the octal number system.
If you take one banknote with the value of 12, you will get 14_8 in octal system. The last digit is 4_8.
If you take one banknote with the value of 12 and one banknote with the value of 20, the total value will be 32. In the octal system, it is 40_8. The last digit is 0_8.
If you take two banknotes with the value of 20, the total value will be 40, this is 50_8 in the octal system. The last digit is 0_8.
No other digits other than 0_8 and 4_8 can be obtained. Digits 0_8 and 4_8 could also be obtained in other ways.
The second test case uses the decimal number system. The nominals of all banknotes end with zero, so Natasha can give the Martians only the amount whose decimal notation also ends with zero.
Submitted Solution:
```
import math
n,k=map(int,input().split())
c=[]
b=list(map(int,input().split()))
g=b[0]
for j in range(1,n):
g=math.gcd(g,b[j])
l=0
ans=[]
j=0
while(j<k):
ans.append(l%k)
l+=g
j+=1
ans=list(set(ans))
print(len(ans))
print(*ans)
``` | instruction | 0 | 5,821 | 20 | 11,642 |
No | output | 1 | 5,821 | 20 | 11,643 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore she had to pay the tax to enter the territory of Mars.
There are n banknote denominations on Mars: the value of i-th banknote is a_i. Natasha has an infinite number of banknotes of each denomination.
Martians have k fingers on their hands, so they use a number system with base k. In addition, the Martians consider the digit d (in the number system with base k) divine. Thus, if the last digit in Natasha's tax amount written in the number system with the base k is d, the Martians will be happy. Unfortunately, Natasha does not know the Martians' divine digit yet.
Determine for which values d Natasha can make the Martians happy.
Natasha can use only her banknotes. Martians don't give her change.
Input
The first line contains two integers n and k (1 β€ n β€ 100 000, 2 β€ k β€ 100 000) β the number of denominations of banknotes and the base of the number system on Mars.
The second line contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) β denominations of banknotes on Mars.
All numbers are given in decimal notation.
Output
On the first line output the number of values d for which Natasha can make the Martians happy.
In the second line, output all these values in increasing order.
Print all numbers in decimal notation.
Examples
Input
2 8
12 20
Output
2
0 4
Input
3 10
10 20 30
Output
1
0
Note
Consider the first test case. It uses the octal number system.
If you take one banknote with the value of 12, you will get 14_8 in octal system. The last digit is 4_8.
If you take one banknote with the value of 12 and one banknote with the value of 20, the total value will be 32. In the octal system, it is 40_8. The last digit is 0_8.
If you take two banknotes with the value of 20, the total value will be 40, this is 50_8 in the octal system. The last digit is 0_8.
No other digits other than 0_8 and 4_8 can be obtained. Digits 0_8 and 4_8 could also be obtained in other ways.
The second test case uses the decimal number system. The nominals of all banknotes end with zero, so Natasha can give the Martians only the amount whose decimal notation also ends with zero.
Submitted Solution:
```
# ===============================================================================================
# importing some useful libraries.
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter # Counter(list) return a dict with {key: count}
from itertools import combinations # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
# If the element is already present in the list,
# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect
# If the element is already present in the list,
# the right most position where element has to be inserted is returned
# ==============================================================================================
# fast I/O region
BUFSIZE = 8192
from sys import stderr
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")
def print(*args, **kwargs):
"""Prints the values to a stream, or to sys.stdout by default."""
sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
at_start = True
for x in args:
if not at_start:
file.write(sep)
file.write(str(x))
at_start = False
file.write(kwargs.pop("end", "\n"))
if kwargs.pop("flush", False):
file.flush()
if sys.version_info[0] < 3:
sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
# inp = lambda: sys.stdin.readline().rstrip("\r\n")
# ===============================================================================================
### START ITERATE RECURSION ###
from types import GeneratorType
def iterative(f, stack=[]):
def wrapped_func(*args, **kwargs):
if stack: return f(*args, **kwargs)
to = f(*args, **kwargs)
while True:
if type(to) is GeneratorType:
stack.append(to)
to = next(to)
continue
stack.pop()
if not stack: break
to = stack[-1].send(to)
return to
return wrapped_func
#### END ITERATE RECURSION ####
# ===============================================================================================
# some shortcuts
mod = 1000000007
def inp(): return sys.stdin.readline().rstrip("\r\n") # for fast input
def out(var): sys.stdout.write(str(var)) # for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def fsep(): return map(float, inp().split())
def nextline(): out("\n") # as stdout.write always print sring.
def testcase(t):
for p in range(t):
solve()
def pow(x, y, p):
res = 1 # Initialize result
x = x % p # Update x if it is more , than or equal to p
if (x == 0):
return 0
while (y > 0):
if ((y & 1) == 1): # If y is odd, multiply, x with result
res = (res * x) % p
y = y >> 1 # y = y/2
x = (x * x) % p
return res
from functools import reduce
def factors(n):
return set(reduce(list.__add__,
([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
def gcd(a, b):
if a == b: return a
while b > 0: a, b = b, a % b
return a
# N=100000
# mod = 10**9 +7
# fac = [1, 1]
# finv = [1, 1]
# inv = [0, 1]
#
# for i in range(2, N + 1):
# fac.append((fac[-1] * i) % mod)
# inv.append(mod - (inv[mod % i] * (mod // i) % mod))
# finv.append(finv[-1] * inv[-1] % mod)
#
#
# def comb(n, r):
# if n < r:
# return 0
# else:
# return fac[n] * (finv[r] * finv[n - r] % mod) % mod
##############Find sum of product of subsets of size k in a array
# ar=[0,1,2,3]
# k=3
# n=len(ar)-1
# dp=[0]*(n+1)
# dp[0]=1
# for pos in range(1,n+1):
# dp[pos]=0
# l=max(1,k+pos-n-1)
# for j in range(min(pos,k),l-1,-1):
# dp[j]=dp[j]+ar[pos]*dp[j-1]
# print(dp[k])
def prefix_sum(ar): # [1,2,3,4]->[1,3,6,10]
return list(accumulate(ar))
def suffix_sum(ar): # [1,2,3,4]->[10,9,7,4]
return list(accumulate(ar[::-1]))[::-1]
def lcm(a,b):
return (a*b)//gcd(a,b)
# =========================================================================================
from collections import defaultdict
def numberOfSetBits(i):
i = i - ((i >> 1) & 0x55555555)
i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24
def N():
return int(inp())
def solve():
n,k=sep()
ar=[int(i)%k for i in inp().strip().split(" ") if int(i)%k]
if not ar:
print(1)
print(0)
return
g=reduce(gcd,ar)
t=(k-1)//g + 1
print(t)
ans=[0]
for i in range(1,k):
if i%g==0:
ans.append(i)
print(*ans)
if k==74150:
print(g)
solve()
#testcase(int(inp()))
``` | instruction | 0 | 5,822 | 20 | 11,644 |
No | output | 1 | 5,822 | 20 | 11,645 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore she had to pay the tax to enter the territory of Mars.
There are n banknote denominations on Mars: the value of i-th banknote is a_i. Natasha has an infinite number of banknotes of each denomination.
Martians have k fingers on their hands, so they use a number system with base k. In addition, the Martians consider the digit d (in the number system with base k) divine. Thus, if the last digit in Natasha's tax amount written in the number system with the base k is d, the Martians will be happy. Unfortunately, Natasha does not know the Martians' divine digit yet.
Determine for which values d Natasha can make the Martians happy.
Natasha can use only her banknotes. Martians don't give her change.
Input
The first line contains two integers n and k (1 β€ n β€ 100 000, 2 β€ k β€ 100 000) β the number of denominations of banknotes and the base of the number system on Mars.
The second line contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) β denominations of banknotes on Mars.
All numbers are given in decimal notation.
Output
On the first line output the number of values d for which Natasha can make the Martians happy.
In the second line, output all these values in increasing order.
Print all numbers in decimal notation.
Examples
Input
2 8
12 20
Output
2
0 4
Input
3 10
10 20 30
Output
1
0
Note
Consider the first test case. It uses the octal number system.
If you take one banknote with the value of 12, you will get 14_8 in octal system. The last digit is 4_8.
If you take one banknote with the value of 12 and one banknote with the value of 20, the total value will be 32. In the octal system, it is 40_8. The last digit is 0_8.
If you take two banknotes with the value of 20, the total value will be 40, this is 50_8 in the octal system. The last digit is 0_8.
No other digits other than 0_8 and 4_8 can be obtained. Digits 0_8 and 4_8 could also be obtained in other ways.
The second test case uses the decimal number system. The nominals of all banknotes end with zero, so Natasha can give the Martians only the amount whose decimal notation also ends with zero.
Submitted Solution:
```
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = set()
ans.add(0)
for i in a:
ans.add(i % k)
print(len(ans))
print(*sorted(list(ans)))
``` | instruction | 0 | 5,823 | 20 | 11,646 |
No | output | 1 | 5,823 | 20 | 11,647 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90. | instruction | 0 | 6,135 | 20 | 12,270 |
Tags: brute force, implementation, math
Correct Solution:
```
a = int(input())
r = input().split(' ')
r = ''.join(r)
m = 0
count = r.count('0')
r = r.replace('0', '')
z = '0'*count
for i in range(1, len(r) + 1):
if int(r[:i] + z)%90 == 0:
m = int(r[:i] + z)
if m != 0:
exit
if m == 0 and count == 0:
print(-1)
else:
print(m)
``` | output | 1 | 6,135 | 20 | 12,271 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90. | instruction | 0 | 6,136 | 20 | 12,272 |
Tags: brute force, implementation, math
Correct Solution:
```
c = {0:0,5:0}
n=int(input())
a=map(int,input().split())
s=0
for i in a:
c[i]+=1
if c[0]==0:
print(-1)
elif c[5]<9:
print(0)
else:
print('5'*(9*(c[5]//9)) + '0'*c[0])
``` | output | 1 | 6,136 | 20 | 12,273 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90. | instruction | 0 | 6,137 | 20 | 12,274 |
Tags: brute force, implementation, math
Correct Solution:
```
n=int(input())
l=[int(i) for i in input().split()]
if 0 in l:
if l.count(5)%9==0:
print(int(''.join(str(i) for i in sorted(l,reverse=True))))
else:
print(int('5'*(l.count(5)//9*9)+'0'*l.count(0)))
else:
print(-1)
``` | output | 1 | 6,137 | 20 | 12,275 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90. | instruction | 0 | 6,138 | 20 | 12,276 |
Tags: brute force, implementation, math
Correct Solution:
```
input()
dic = {0:0,5:0}
for i in map(int,input().split()):
dic[i] += 1
ans = dic[5]//9
if ans and dic[0]:
print(int(('5'*ans*9)+('0'*dic[0])))
elif dic[0]==0:
print(-1)
else:
print(0)
``` | output | 1 | 6,138 | 20 | 12,277 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90. | instruction | 0 | 6,139 | 20 | 12,278 |
Tags: brute force, implementation, math
Correct Solution:
```
n = int(input())
A = list(map(int, input().split()))
cnt5 = sum(A) // 5
cnt0 = n - cnt5
if (cnt0 == 0):
print(-1)
else:
ans = 0
for i in range(cnt5 - cnt5 % 9):
ans = 10 * ans + 5;
for i in range(cnt0):
ans *= 10;
print(ans)
``` | output | 1 | 6,139 | 20 | 12,279 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90. | instruction | 0 | 6,140 | 20 | 12,280 |
Tags: brute force, implementation, math
Correct Solution:
```
n=int(input())
if n==1:
a=int(input())
if a%90==0:
print(a)
else:
print(-1)
exit()
A=[int(x) for x in input().split()]
A.sort(reverse=True)
cnt0=A.count(0)
cnt5=A.count(5)
cnt5=9*(cnt5//9)
C=""
for i in range(cnt5):
C+='5'
for i in range(cnt0):
C+='0'
if cnt0:
if C.count('0')==len(C):
print(0)
else:
print(C)
else:
print(-1)
``` | output | 1 | 6,140 | 20 | 12,281 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90. | instruction | 0 | 6,141 | 20 | 12,282 |
Tags: brute force, implementation, math
Correct Solution:
```
a=int(input())
b=[int(s) for s in input().split()]
c=b.count(5)
cc=b.count(0)
if c//9>0 and cc>0:
print("5"*(c//9*9)+"0"*cc)
elif cc>0:
print(0)
else:
print(-1)
``` | output | 1 | 6,141 | 20 | 12,283 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90. | instruction | 0 | 6,142 | 20 | 12,284 |
Tags: brute force, implementation, math
Correct Solution:
```
a = int(input())
b = list(map(int,input().split()))
z = b.count(5)
if a-z>0:
if z<9:print(0)
else:print("5"*((z//9)*9)+"0"*b.count(0))
else:print(-1)
``` | output | 1 | 6,142 | 20 | 12,285 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90.
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
if a.count(5) // 9 > 0 and a.count(0) > 0:
print('5' * (a.count(5) // 9) * 9 + '0' * a.count(0))
elif a.count(0) != 0:
print(0)
else:
print(-1)
``` | instruction | 0 | 6,143 | 20 | 12,286 |
Yes | output | 1 | 6,143 | 20 | 12,287 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90.
Submitted Solution:
```
# cook your dish here
from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
def L():
return list(map(int, stdin.readline().split()))
def In():
return map(int, stdin.readline().split())
def I():
return int(stdin.readline())
P = 1000000007
n = I()
lis = L()
a = lis.count(0)
b = lis.count(5)
if a == 0:
print(-1)
else:
if b < 9:
print(0)
else:
print(str("5"*(b//9)*9) + "0"*a)
``` | instruction | 0 | 6,144 | 20 | 12,288 |
Yes | output | 1 | 6,144 | 20 | 12,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90.
Submitted Solution:
```
t=int(input())
l=[int(x) for x in input().split()]
c=0
for i in l:
if i==0:
c=c+1
if(c!=0):
f=0
for i in l:
if(i==5):
f=f+1
if(f<9):
print(0)
else:
for i in range(f-f%9):
print(5,end="")
for i in range(c):
print(0,end="")
else:
print("-1")
``` | instruction | 0 | 6,145 | 20 | 12,290 |
Yes | output | 1 | 6,145 | 20 | 12,291 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90.
Submitted Solution:
```
n=int(input())
a=list(map(int,input().split()))
if sum(a)<45 and 0 in a:
print(0)
elif sum(a)<45 and 0 not in a:
print(-1)
elif sum(a)>=45 and 0 in a:
x=sum(a)//45
y=a.count(0)
print('5'*(9*x)+'0'*y)
else:
print(-1)
``` | instruction | 0 | 6,146 | 20 | 12,292 |
Yes | output | 1 | 6,146 | 20 | 12,293 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90.
Submitted Solution:
```
n = int(input())
arr = list(map(int, input().split()))
srt = sorted(arr, reverse=True)
ans = 0
srt = [str(i) for i in srt]
while srt:
if srt[0] != '0' and int(''.join(srt)) % 90 == 0:
print(''.join(srt))
exit()
else:
check = srt.pop(0)
if check == 0:
print(0)
exit()
print(-1)
``` | instruction | 0 | 6,147 | 20 | 12,294 |
No | output | 1 | 6,147 | 20 | 12,295 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90.
Submitted Solution:
```
l=input()
s=input()
k=list(map(int,s.split(" ")))
x,y,flag=k.count(5),k.count(0),False
for i in range(x):
s="5"*(x-i)
if(int(s)%9==0):
break
flag=True
l=s
for i in range(y):
k="0"*(y-i)
l+=k
if(int(s)%90):
print(l)
flag=True
if(not flag):
print("0")
``` | instruction | 0 | 6,148 | 20 | 12,296 |
No | output | 1 | 6,148 | 20 | 12,297 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90.
Submitted Solution:
```
#!/usr/bin/env python3
n = int(input())
numbers = input().split()
fives=0
zeroes=0
for n in numbers:
if n=='5':
fives+=1
else:
zeroes+=1
if(fives<9):
if zeroes==0:
print("-1")
else:
print('0')
else:
print('555555555'*int(fives/9)+'0'*zeroes)
``` | instruction | 0 | 6,149 | 20 | 12,298 |
No | output | 1 | 6,149 | 20 | 12,299 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.
Input
The first line contains integer n (1 β€ n β€ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
Output
In a single line print the answer to the problem β the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
Examples
Input
4
5 0 5 0
Output
0
Input
11
5 5 5 5 5 5 5 5 0 5 5
Output
5555555550
Note
In the first test you can make only one number that is a multiple of 90 β 0.
In the second test you can make number 5555555550, it is a multiple of 90.
Submitted Solution:
```
# https://codeforces.com/problemset/problem/352/A
n = int(input())
fiveCount = 0
zeroCount = 0
for num in input().split():
if num == '5':
fiveCount += 1
else:
zeroCount += 1
while fiveCount>0:
if (fiveCount*5) % 9 == 0:
print('5'*fiveCount, sep='', end='')
break
else:
fiveCount -= 1
if fiveCount==0:
if zeroCount == 0:
print(-1)
else:
print(0)
else:
print('o'*zeroCount)
``` | instruction | 0 | 6,150 | 20 | 12,300 |
No | output | 1 | 6,150 | 20 | 12,301 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We call a function good if its domain of definition is some set of integers and if in case it's defined in x and x-1, f(x) = f(x-1) + 1 or f(x) = f(x-1).
Tanya has found n good functions f_{1}, β¦, f_{n}, which are defined on all integers from 0 to 10^{18} and f_i(0) = 0 and f_i(10^{18}) = L for all i from 1 to n. It's an notorious coincidence that n is a divisor of L.
She suggests Alesya a game. Using one question Alesya can ask Tanya a value of any single function in any single point. To win Alesya must choose integers l_{i} and r_{i} (0 β€ l_{i} β€ r_{i} β€ 10^{18}), such that f_{i}(r_{i}) - f_{i}(l_{i}) β₯ L/n (here f_i(x) means the value of i-th function at point x) for all i such that 1 β€ i β€ n so that for any pair of two functions their segments [l_i, r_i] don't intersect (but may have one common point).
Unfortunately, Tanya doesn't allow to make more than 2 β
10^{5} questions. Help Alesya to win!
It can be proved that it's always possible to choose [l_i, r_i] which satisfy the conditions described above.
It's guaranteed, that Tanya doesn't change functions during the game, i.e. interactor is not adaptive
Input
The first line contains two integers n and L (1 β€ n β€ 1000, 1 β€ L β€ 10^{18}, n is a divisor of L) β number of functions and their value in 10^{18}.
Output
When you've found needed l_i, r_i, print "!" without quotes on a separate line and then n lines, i-th from them should contain two integers l_i, r_i divided by space.
Interaction
To ask f_i(x), print symbol "?" without quotes and then two integers i and x (1 β€ i β€ n, 0 β€ x β€ 10^{18}). Note, you must flush your output to get a response.
After that, you should read an integer which is a value of i-th function in point x.
You're allowed not more than 2 β
10^5 questions.
To flush you can use (just after printing an integer and end-of-line):
* fflush(stdout) in C++;
* System.out.flush() in Java;
* stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
Hacks:
Only tests where 1 β€ L β€ 2000 are allowed for hacks, for a hack set a test using following format:
The first line should contain two integers n and L (1 β€ n β€ 1000, 1 β€ L β€ 2000, n is a divisor of L) β number of functions and their value in 10^{18}.
Each of n following lines should contain L numbers l_1, l_2, ... , l_L (0 β€ l_j < 10^{18} for all 1 β€ j β€ L and l_j < l_{j+1} for all 1 < j β€ L), in i-th of them l_j means that f_i(l_j) < f_i(l_j + 1).
Example
Input
5 5
? 1 0
? 1 1
? 2 1
? 2 2
? 3 2
? 3 3
? 4 3
? 4 4
? 5 4
? 5 5
!
0 1
1 2
2 3
3 4
4 5
Output
0
1
1
2
2
3
3
4
4
4
5
Note
In the example Tanya has 5 same functions where f(0) = 0, f(1) = 1, f(2) = 2, f(3) = 3, f(4) = 4 and all remaining points have value 5.
Alesya must choose two integers for all functions so that difference of values of a function in its points is not less than L/n (what is 1 here) and length of intersection of segments is zero.
One possible way is to choose pairs [0, 1], [1, 2], [2, 3], [3, 4] and [4, 5] for functions 1, 2, 3, 4 and 5 respectively.
Submitted Solution:
```
n,L = map(int,input().split())
step = L/n
phase = 1
def query(i,x):
print('?',i,x)
return int(input())
class bs:
def __init__(self,i,l,r):
self.i = i
self.vals = {}
self.vals[0] = 0
self.vals[10**18] = L
self.l = l
self.r = r
def bs(self):
goal = phase*step
mid = (self.l + self.r)//2
r = query(self.i, mid)
self.vals[mid] = r
if r < goal:
self.l = mid
else:
self.r = mid
if r == goal:
return True
return False
def update(self,l,val):
self.vals[l] = val
goal = phase*step
self.l = l
for i in self.vals:
if self.vals[i] >= goal:
r = i
return
def __lt__(self,other):
return self.vals[self.r] < other.vals[other.r]
B = [bs(_,0,10**18) for _ in range(n)]
fixed = []
while B:
b = max(B)
if b.bs():
# found value
fixed.append(b)
B.remove(b)
for e in B:
phase += 1
e.update(b.r, b.vals[b.r])
print('!')
fixed.sort(lambda b: b.i)
for b in fixed:
print(b.l, b.r)
``` | instruction | 0 | 6,644 | 20 | 13,288 |
No | output | 1 | 6,644 | 20 | 13,289 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER | instruction | 0 | 6,704 | 20 | 13,408 |
Tags: implementation, sortings
Correct Solution:
```
n=str(input())
a=str(input())
lt=[]
if int(n)==0:
if n==a:
print("OK")
else:
print("WRONG_ANSWER")
else:
if a[0]=="0":
print("WRONG_ANSWER")
elif int(n)>0:
b=n.count("0")
for i in range(len(n)):
if int(n[i])>0:
lt.append(n[i])
lt.sort()
d=lt[0]
if b>0:
for i in range(b):
d=str(d)+"0"
for i in range(len(lt)-1):
d=str(d)+str(lt[i+1])
if b==0:
for i in range(len(lt)-1):
d=str(d)+str(lt[i+1])
if int(d)==int(a):
print("OK")
else:
print("WRONG_ANSWER")
``` | output | 1 | 6,704 | 20 | 13,409 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER | instruction | 0 | 6,705 | 20 | 13,410 |
Tags: implementation, sortings
Correct Solution:
```
s=input()
z=input()
a=[0]*10
for c in s:
a[int(c)]+=1
ans=""
for i in range(1,10):
if a[i]>0:
a[i]-=1
ans=str(i)
break
for i in range(0,10):
for j in range(a[i]):
ans+=str(i)
if ans==z:
print("OK")
else:
print("WRONG_ANSWER")
``` | output | 1 | 6,705 | 20 | 13,411 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER | instruction | 0 | 6,706 | 20 | 13,412 |
Tags: implementation, sortings
Correct Solution:
```
l=list(input())
m=list(input())
l.sort()
e=0
if(l[0]=='0'):
for i in range(1,len(l)):
if(l[i]!='0'):
l[0]=l[i]
l[i]='0'
e=1
break
if(e==1):
break
if(l==m ):
print('OK')
else:
print('WRONG_ANSWER')
``` | output | 1 | 6,706 | 20 | 13,413 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER | instruction | 0 | 6,707 | 20 | 13,414 |
Tags: implementation, sortings
Correct Solution:
```
n=list(input())
dic={}
for i in range(0,10):
dic[i]=0
for i in range(0,len(n)):
dic[int(n[i])]+=1
ans=[]
for i in range(1,10):
if dic[i]!=0:
ans.append(i)
dic[i]-=1
break
for i in range(0,10):
while dic[i]!=0:
ans.append(i)
dic[i]-=1
n=list(input())
cpans=[]
for i in range(0,len(n)):
cpans.append(int(n[i]))
if cpans==ans:
print("OK")
else:
print("WRONG_ANSWER")
``` | output | 1 | 6,707 | 20 | 13,415 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER | instruction | 0 | 6,708 | 20 | 13,416 |
Tags: implementation, sortings
Correct Solution:
```
c=[0]*10
for x in input():
c[ord(x)-ord('0')]+=1
t=[]
t.append(c[1]*'1')
t.append(c[0]*'0')
for i in range(2,10):
if c[i]==0:
continue
t.append(c[i]*chr(ord('0')+i))
s=input()
if (len(s)==1 and s[0]=='0') or (s[0]!='0' and s==''.join(t)):
print('OK')
else:
print('WRONG_ANSWER')
``` | output | 1 | 6,708 | 20 | 13,417 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER | instruction | 0 | 6,709 | 20 | 13,418 |
Tags: implementation, sortings
Correct Solution:
```
n = list(input())
t = input()
n = sorted(n)
if(n[0]=='0'):
for i in range(len(n)):
if(n[i]!='0'):
n[0],n[i] = n[i],n[0]
break
if(str(''.join(n))==t):
print('OK')
else:
print('WRONG_ANSWER')
else:
if(str(''.join(n))==t):
print('OK')
else:
print('WRONG_ANSWER')
``` | output | 1 | 6,709 | 20 | 13,419 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER | instruction | 0 | 6,710 | 20 | 13,420 |
Tags: implementation, sortings
Correct Solution:
```
n = int(input())
m = input()
v = []
zeros = 0
for c in str(n):
if c != '0':
v.append(c)
else:
zeros += 1
v.sort()
res = (v[0] if len(v) > 0 else "") + ('0' * zeros)
for i in range(1, len(v)):
res += v[i]
ans = "WRONG_ANSWER"
if m == res:
ans = "OK"
print(ans)
``` | output | 1 | 6,710 | 20 | 13,421 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER | instruction | 0 | 6,711 | 20 | 13,422 |
Tags: implementation, sortings
Correct Solution:
```
l=list(map(int,list(input())))
l.sort()
t=input()
def f(l,t):
if len(l)==1 and l[0]==0:
if t=="0":
return "OK"
return "WRONG_ANSWER"
c=l.count(0)
s=""
w=0
for i in range(len(l)):
if l[i]!=0 and w==0:
# print(s)
s+=str(l[i])+"0"*c
w+=1
# print(s)
elif l[i]!=0:
s+=str(l[i])
# print(s)
if t==s:
return "OK"
return "WRONG_ANSWER"
print(f(l,t))
``` | output | 1 | 6,711 | 20 | 13,423 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER
Submitted Solution:
```
first =list(input())# ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠΏΠΈΡΠΎΠΊ Ρ ΡΡΡΠΎΠΊΠΎΠ²ΡΠΌΠΈ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ°ΠΌΠΈ ['3', '3', '1', '0']
second = input()
first_reverse = sorted(first[::-1]) # ΠΏΠ΅ΡΠ΅Π²ΠΎΡΠ°ΡΠΈΠ²Π°ΠΌ
#print(first_reverse)
if first_reverse[0] == "0": # Π΅ΡΠ»ΠΈ ΠΏΠ΅ΡΠ²ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ 0, ΡΠΎ ΠΏΠ΅ΡΠ΅Π±ΠΈΡΠ°Π΅ΠΌ Π΄Π°Π»ΡΡΠ΅ ΡΠΏΠΈΡΠΎΠΊ, ΠΏΠΎΠΊΠ° Π½Π΅ Π½Π°ΠΉΠ΄Π΅ΠΌ ΠΎΡΠ»ΠΈΡΠ½ΡΠΉ ΠΎΡ 0 ΡΠ»Π΅ΠΌΠ΅Π½Ρ
for i in first_reverse:
if i != "0":
y = first_reverse.index(i)# ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΠΈΠ½Π΄Π΅ΠΊΡ ΠΏΠ΅ΡΠ²ΠΎΠ³ΠΎ ΠΎΡΠ»ΠΈΡΠ½ΠΎΠ³ΠΎ ΠΎΡ Π½ΡΠ»Ρ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ°
first_reverse[0],first_reverse[y] = first_reverse[y],first_reverse[0]# ΠΌΠ΅Π½ΡΠ΅ΠΌ ΠΌΠ΅ΡΡΠ°ΠΌΠΈ Π·Π½Π°ΡΠ΅Π½ΠΈΡ, Π±Π΅Π· ΠΏΠΎΠΌΠΎΠ·ΠΈ Π±ΡΡΠ΅ΡΠ½ΠΎΠΉ ΠΏΠ΅Ρ
break
result = ''.join(first_reverse)# ΡΠΎΠ΅Π΄ΠΈΠ½ΡΠ΅ΠΌ ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ Π²ΠΎΠ΅Π΄ΠΈΠ½ΠΎ
#print(result)
if result == second:#ΡΡΠ°Π²Π½ΠΈΠ²Π°Π΅ΠΌ ΠΈ Π²ΡΠ²ΠΎΠ΄ΠΈΠΌ
print("OK")
else: print("WRONG_ANSWER")
``` | instruction | 0 | 6,712 | 20 | 13,424 |
Yes | output | 1 | 6,712 | 20 | 13,425 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER
Submitted Solution:
```
import sys
import math
n = sys.stdin.readline()
m = sys.stdin.readline()
l = len(n) - 1
k = [0] * 10
res = 0
for i in range(l):
k[int(n[i])] += 1
z = []
for i in range(1, 10):
if(k[i] != 0):
z.append(str(i))
k[i] -= 1
break
z.extend("0" * k[0])
for i in range(1, 10):
if(k[i] != 0):
z.extend(str(i) * k[i])
ml = len(m) - 1
zers = 0
for i in range(ml):
if(m[i] != '0'):
zers = i
break
if(zers != 0):
print("WRONG_ANSWER")
exit()
if(int(n) == 0 and ml != 1):
print("WRONG_ANSWER")
exit()
if(int("".join(z)) == int(m)):
print("OK")
else:
print("WRONG_ANSWER")
``` | instruction | 0 | 6,713 | 20 | 13,426 |
Yes | output | 1 | 6,713 | 20 | 13,427 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER
Submitted Solution:
```
def main():
s = input()
if s != "0":
l = sorted(c for c in s if c != '0')
l[0] += '0' * s.count('0')
s = ''.join(l)
print(("OK", "WRONG_ANSWER")[s != input()])
if __name__ == '__main__':
main()
``` | instruction | 0 | 6,714 | 20 | 13,428 |
Yes | output | 1 | 6,714 | 20 | 13,429 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER
Submitted Solution:
```
n = input()
m = input()
from sys import exit
if n=='0':
if m=='0':
print('OK')
else:
print('WRONG_ANSWER')
exit()
mas = []
for i,x in enumerate(n):
mas.append(int(x))
mas.sort()
q = mas.count(0)
rez = str(mas[q])
for i in range(q):
rez+='0'
for i in range(q+1,len(n)):
rez+=str(mas[i])
if m==rez:
print('OK')
else:
print('WRONG_ANSWER')
``` | instruction | 0 | 6,715 | 20 | 13,430 |
Yes | output | 1 | 6,715 | 20 | 13,431 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER
Submitted Solution:
```
a=int(input())
b=input()
if(b[0]=='0'):
print('WRONG_ANSWER')
else:
a=list(str(a))
a.sort()
i=0
while(i<len(a)):
if(a[i]!='0'):
break
i+=1
s1=''
for j in a[i+1:]:
s1+=j
s=a[i]+'0'*i+s1
#print(s)
if(s==str(b)):
print('OK')
else:
print('WRONG_ANSWER')
``` | instruction | 0 | 6,717 | 20 | 13,434 |
No | output | 1 | 6,717 | 20 | 13,435 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER
Submitted Solution:
```
n=int(input())
m=int(input())
if m==n:
print("WRONG_ANSWER")
else:
aN=sorted([int(i) for i in str(n)])
aM=[int(i) for i in str(m)]
if aN[0]!=0:
print("OK" if aN==aM else "WRONG_ANSWER")
else:
i=1
while aN[0]==0:
aN[0],aN[i]=aN[i],aN[0]
i+=1
print("OK" if aN==aM else "WRONG_ANSWER")
``` | instruction | 0 | 6,718 | 20 | 13,436 |
No | output | 1 | 6,718 | 20 | 13,437 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
βNo problem! β said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 β€ n β€ 109) without leading zeroes. The second lines contains one integer m (0 β€ m β€ 109) β Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER
Submitted Solution:
```
n,s = list(input()), int(input());
n.sort();
if len(n)>1:
for x in n:
if x!='0':
ans=x;
break;
n.remove(ans);
n.insert(0, ans);
n=''.join(n);
print(['WRONG_ANSWER','OK'][int(n)==s>0]);
``` | instruction | 0 | 6,719 | 20 | 13,438 |
No | output | 1 | 6,719 | 20 | 13,439 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y. | instruction | 0 | 7,111 | 20 | 14,222 |
Tags: brute force, implementation
Correct Solution:
```
'''input
3 3
1 0 2
2 5
2 4
'''
n, b1 = map(int, input().split())
x = list(map(int, input().split()))[::-1]
m, b2 = map(int, input().split())
y = list(map(int, input().split()))[::-1]
sx, sy = 0, 0
for i in range(n):
sx += b1**(i) * x[i]
for j in range(m):
sy += b2**(j) * y[j]
if sx == sy:
print("=")
else:
print("<" if sx < sy else ">")
``` | output | 1 | 7,111 | 20 | 14,223 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y. | instruction | 0 | 7,112 | 20 | 14,224 |
Tags: brute force, implementation
Correct Solution:
```
n, b = list(map(int, input().split(' ')))
X = list(map(int, input().split(' ')))
Nico = 1
x = 0
for i in range(n):
x = x + X[n - 1 - i] * Nico
Nico = Nico * b
n, b = list(map(int, input().split(' ')))
Y = list(map(int, input().split(' ')))
Nico = 1
y = 0
for i in range(n):
y = y + Y[n - 1 - i] * Nico
Nico = Nico * b
if (x < y):
print("<")
if (x == y):
print("=")
if (x > y):
print(">")
``` | output | 1 | 7,112 | 20 | 14,225 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y. | instruction | 0 | 7,113 | 20 | 14,226 |
Tags: brute force, implementation
Correct Solution:
```
inp = input().split()
n = int(inp[0])
bx = int(inp[1])
X = input().split()
for i in range(n):
X[i] = int(X[i])
X = X[::-1]
inp = input().split()
m = int(inp[0])
by = int(inp[1])
Y = input().split()
for i in range(m):
Y[i] = int(Y[i])
Y = Y[::-1]
sum_X = 0
base = 1
for n in X:
sum_X += base*n
base *= bx
sum_Y = 0
base = 1
for n in Y:
sum_Y += base*n
base *= by
if sum_X == sum_Y:
print('=')
elif sum_X < sum_Y:
print('<')
else:
print('>')
``` | output | 1 | 7,113 | 20 | 14,227 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y. | instruction | 0 | 7,114 | 20 | 14,228 |
Tags: brute force, implementation
Correct Solution:
```
n, b = map(int, input().split())
num1 = 0
num2 = 0
n -= 1
for c in list(map(int, input().split())):
num1 += (b ** n) * c
n -= 1
n, a = map(int, input().split())
n -= 1
for c in list(map(int, input().split())):
num2 += (a ** n) * c
n -= 1
if num1 > num2:
print('>')
elif num1 == num2:
print('=')
else:
print('<')
``` | output | 1 | 7,114 | 20 | 14,229 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y. | instruction | 0 | 7,115 | 20 | 14,230 |
Tags: brute force, implementation
Correct Solution:
```
(n, b) = map(int, input().split())
x = list(map(int, input().split()))
(m, c) = map(int, input().split())
y = list(map(int, input().split()))
x = x[::-1]
y = y[::-1]
X = 0
Y = 0
for i in range(len(x)):
X += x[i] * b ** i
for i in range(len(y)):
Y += y[i] * c ** i
if (X == Y):
print("=")
elif (X < Y):
print("<")
else:
print(">")
``` | output | 1 | 7,115 | 20 | 14,231 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y. | instruction | 0 | 7,116 | 20 | 14,232 |
Tags: brute force, implementation
Correct Solution:
```
# Description of the problem can be found at http://codeforces.com/problemset/problem/602/A
def calc():
n, b = map(int, input().split())
x =list(map(int, input().split()))
a = 0
for i in x:
a = a * b + i
return a
l_n = list()
for _ in range(2):
l_n.append(calc())
if l_n[0] < l_n[1]:
print("<")
elif l_n[1] < l_n[0]:
print(">")
else:
print("=")
``` | output | 1 | 7,116 | 20 | 14,233 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y. | instruction | 0 | 7,117 | 20 | 14,234 |
Tags: brute force, implementation
Correct Solution:
```
from math import *
n,x = map(int,input().split())
a = list(map(int,input().split()))
m,y = map(int,input().split())
b = list(map(int,input().split()))
a.reverse()
b.reverse()
#print(a,b)
res1 = 0
for i in range(len(a)):
res1+=int(a[i])*(x)**i
res2 = 0
for i in range(len(b)):
res2+=int(b[i])*(y)**i
if res1==res2:
print('=')
quit()
if res1<res2:
print('<')
quit()
print('>')
``` | output | 1 | 7,117 | 20 | 14,235 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y. | instruction | 0 | 7,118 | 20 | 14,236 |
Tags: brute force, implementation
Correct Solution:
```
#!/usr/bin/env python3
# 602A_mem.py - Codeforces.com/problemset/problem/602/A by Sergey 2015
import unittest
import sys
###############################################################################
# Mem Class (Main Program)
###############################################################################
class Mem:
""" Mem representation """
def __init__(self, test_inputs=None):
""" Default constructor """
it = iter(test_inputs.split("\n")) if test_inputs else None
def uinput():
return next(it) if it else sys.stdin.readline().rstrip()
# Reading single elements
[self.n, self.bx] = map(int, uinput().split())
# Reading a single line of multiple elements
self.numsx = list(map(int, uinput().split()))
# Reading single elements
[self.m, self.by] = map(int, uinput().split())
# Reading a single line of multiple elements
self.numsy = list(map(int, uinput().split()))
self.x = 0
for n in self.numsx:
self.x = self.x * self.bx + n
self.y = 0
for n in self.numsy:
self.y = self.y * self.by + n
def calculate(self):
""" Main calcualtion function of the class """
if self.x == self.y:
return "="
if self.x > self.y:
return ">"
return "<"
###############################################################################
# Unit Tests
###############################################################################
class unitTests(unittest.TestCase):
def test_single_test(self):
""" Mem class testing """
# Constructor test
test = "6 2\n1 0 1 1 1 1\n2 10\n4 7"
d = Mem(test)
self.assertEqual(d.n, 6)
self.assertEqual(d.m, 2)
# Sample test
self.assertEqual(Mem(test).calculate(), "=")
# Sample test
test = "3 3\n1 0 2\n2 5\n2 4"
self.assertEqual(Mem(test).calculate(), "<")
# Sample test
test = "7 16\n15 15 4 0 0 7 10\n7 9\n4 8 0 3 1 5 0"
self.assertEqual(Mem(test).calculate(), ">")
# My tests
test = ""
# self.assertEqual(Mem(test).calculate(), "0")
# Time limit test
# self.time_limit_test(5000)
def time_limit_test(self, nmax):
""" Timelimit testing """
import random
import timeit
# Random inputs
test = str(nmax) + " " + str(nmax) + "\n"
numnums = [str(i) + " " + str(i+1) for i in range(nmax)]
test += "\n".join(numnums) + "\n"
nums = [random.randint(1, 10000) for i in range(nmax)]
test += " ".join(map(str, nums)) + "\n"
# Run the test
start = timeit.default_timer()
d = Mem(test)
calc = timeit.default_timer()
d.calculate()
stop = timeit.default_timer()
print("\nTimelimit Test: " +
"{0:.3f}s (init {1:.3f}s calc {2:.3f}s)".
format(stop-start, calc-start, stop-calc))
if __name__ == "__main__":
# Avoiding recursion limitaions
sys.setrecursionlimit(100000)
if sys.argv[-1] == "-ut":
unittest.main(argv=[" "])
# Print the result string
sys.stdout.write(Mem().calculate())
``` | output | 1 | 7,118 | 20 | 14,237 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y.
Submitted Solution:
```
n, b1 = map(int, input().split())
num = [int(x) for x in input().split()]
p = b1 ** (n - 1)
x = 0
for i in range(n):
numx = int(num[i])
x += numx * p
p //= b1
m, b2 = map(int, input().split())
num = [int(x) for x in input().split()]
p = b2 ** (m - 1)
y = 0
for i in range(m):
numy = int(num[i])
y += numy * p
p //= b2
if x < y:
print('<')
elif x > y:
print('>')
else:
print('=')
``` | instruction | 0 | 7,119 | 20 | 14,238 |
Yes | output | 1 | 7,119 | 20 | 14,239 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y.
Submitted Solution:
```
n, bx = list(map(int, input().split(" ")))
X = list(map(int, input().split(" ")))
m, by = list(map(int, input().split(" ")))
Y = list(map(int, input().split(" ")))
vx = 0
vy = 0
for i in range(n-1, -1, -1):
vx+= X[n-i-1]*(bx**i)
for i in range(m-1, -1, -1):
vy+= Y[m-i-1]*(by**i)
if(vx == vy):
print("=")
elif(vx> vy):
print(">")
else:
print("<")
``` | instruction | 0 | 7,120 | 20 | 14,240 |
Yes | output | 1 | 7,120 | 20 | 14,241 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y.
Submitted Solution:
```
n, bx = map(int, input().split())
x = list(map(int, input().split()))[::-1]
m, by = map(int, input().split())
y = list(map(int, input().split()))[::-1]
d1 = 0
deg = 1
for d in x:
d1 += d * deg
deg *= bx
d2 = 0
deg = 1
for d in y:
d2 += d * deg
deg *= by
print('>' if d1 > d2 else '<' if d1 < d2 else '=')
``` | instruction | 0 | 7,121 | 20 | 14,242 |
Yes | output | 1 | 7,121 | 20 | 14,243 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y.
Submitted Solution:
```
a1,b1=map(int,input().split())
X=input().split()
a2,b2=map(int,input().split())
Y=input().split()
k=0
g=0
for i in range(a1):
k+=int(X[i])*(b1**(a1-i-1))
for i in range(a2):
g+=int(Y[i])*(b2**(a2-i-1))
if k>g:
print('>')
elif k<g:
print('<')
elif k==g:
print('=')
``` | instruction | 0 | 7,122 | 20 | 14,244 |
Yes | output | 1 | 7,122 | 20 | 14,245 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 β€ n β€ 10, 2 β€ bx β€ 40), where n is the number of digits in the bx-based representation of X.
The second line contains n space-separated integers x1, x2, ..., xn (0 β€ xi < bx) β the digits of X. They are given in the order from the most significant digit to the least significant one.
The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 β€ m β€ 10, 2 β€ by β€ 40, bx β by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 β€ yi < by) β the digits of Y.
There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
* '<' if X < Y
* '>' if X > Y
* '=' if X = Y
Examples
Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>
Note
In the first sample, X = 1011112 = 4710 = Y.
In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.
In the third sample, <image> and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y.
Submitted Solution:
```
def convert_base(num, to_base=10, from_base=10):
if isinstance(num, str):
n = int(num, from_base)
else:
n = int(num)
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if n < to_base:
return alphabet[n]
else:
return convert_base(n // to_base, to_base) + alphabet[n % to_base]
n, a = map(int, input().split())
x = convert_base(''.join(input().split()), from_base=a)
n, a = map(int, input().split())
y = convert_base(''.join(input().split()), from_base=a)
if x == y: print('=')
elif x > y: print('>')
elif x < y: print('<')
``` | instruction | 0 | 7,123 | 20 | 14,246 |
No | output | 1 | 7,123 | 20 | 14,247 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.