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.
Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as Β«.Β», 1 as Β«-.Β» and 2 as Β«--Β». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet.
Input
The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes).
Output
Output the decoded ternary number. It can have leading zeroes.
Examples
Input
.-.--
Output
012
Input
--.
Output
20
Input
-..-.--
Output
1012
Submitted Solution:
```
n = input()
for i in range(len(n)):
if i=='.':
print("0",end="")
elif i=='-' and i+1=='.':
print("1",end="")
i+=1
elif i=='-' and i+1=='-':
print("2",end="")
i+=1
``` | instruction | 0 | 80,295 | 20 | 160,590 |
No | output | 1 | 80,295 | 20 | 160,591 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as Β«.Β», 1 as Β«-.Β» and 2 as Β«--Β». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet.
Input
The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes).
Output
Output the decoded ternary number. It can have leading zeroes.
Examples
Input
.-.--
Output
012
Input
--.
Output
20
Input
-..-.--
Output
1012
Submitted Solution:
```
s=str(input())
final=""
for i in range(len(s)-1):
if s[i]==".":
final+="0"
elif s[i]=="-" and s[i+1]==".":
final+="1"
else:
final+="2"
print(final)
``` | instruction | 0 | 80,296 | 20 | 160,592 |
No | output | 1 | 80,296 | 20 | 160,593 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690 | instruction | 0 | 80,304 | 20 | 160,608 |
Tags: math, number theory
Correct Solution:
```
def end(x) :
if x == 0 :
return "1869";
if x == 6 :
return "1968";
if x == 5 :
return "1689";
if x == 4 :
return "6891";
if x == 3 :
return "1689";
if x == 2 :
return "1986";
if x == 1 :
return "1896";
d = [0] * 10;
for c in input() :
d[int(c)] += 1;
for i in [1,6,8,9] :
d[i] -= 1;
s = "";
ost = 0;
for i in range(10) :
for j in range(d[i]):
ost = (ost * 10 + i) % 7;
ost = (1869, 1896, 1986, 1698, 6198, 1689, 1968)[ost * 10000 % 7];
for c in (1,2,3,4,5,6,7,8,9) :
s += str(c) * d[c];
print(s + str(ost) + "0" * d[0]);
``` | output | 1 | 80,304 | 20 | 160,609 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690 | instruction | 0 | 80,305 | 20 | 160,610 |
Tags: math, number theory
Correct Solution:
```
n = [int(i) for i in input()]
for x in [1, 6, 8, 9]:
for i in range(len(n)):
if n[i] == x:
del n[i]
break
prefix = [1869, 6189, 1689, 6198, 1698, 9861, 1896]
res = sum([n[i] * pow(10, len(n)-i-1, 7) for i in range(len(n))])
print(prefix[-res * pow(10, 5*len(n), 7) % 7], end='')
print(*n, sep='')
``` | output | 1 | 80,305 | 20 | 160,611 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690 | instruction | 0 | 80,306 | 20 | 160,612 |
Tags: math, number theory
Correct Solution:
```
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------- fast io --------------------
from math import gcd, ceil
def prod(a, mod=10**9+7):
ans = 1
for each in a:
ans = (ans * each) % mod
return ans
def lcm(a, b): return a * b // gcd(a, b)
def binary(x, length=16):
y = bin(x)[2:]
return y if len(y) >= length else "0" * (length - len(y)) + y
def check_div(s):
ans = 0
j = 0
for i in range(len(s)-1, -1, -1):
ans += s[i]*pow(10,j,7)
ans %= 7
j += 1
return ans % 7
for _ in range(int(input()) if not True else 1):
#n = int(input())
#n, k = map(int, input().split())
#a, b = map(int, input().split())
#c, d = map(int, input().split())
#a = list(map(int, input().split()))
#b = list(map(int, input().split()))
s = [int(k) for k in input()]
a,b,c,d=0,0,0,0
zero=0
s2=[]
for i in s:
if i == 0:
zero += 1
elif i==1 and not a:
a+=1
elif i == 6 and not b:
b+=1
elif i == 8 and not c:
c+=1
elif i == 9 and not d:
d += 1
else:
s2 += [i]
s22 = check_div(s2)
fk = [[1, 6, 8, 9], [1, 6, 9, 8], [1, 8, 6, 9], [1, 8, 9, 6], [1, 9, 6, 8], [1, 9, 8, 6], [6, 1, 8, 9], [6, 1, 9, 8], [6, 8, 1, 9], [6, 8, 9, 1], [6, 9, 1, 8], [6, 9, 8, 1], [8, 1, 6, 9], [8, 1, 9, 6], [8, 6, 1, 9], [8, 6, 9, 1], [8, 9, 1, 6], [8, 9, 6, 1], [9, 1, 6, 8], [9, 1, 8, 6], [9, 6, 1, 8], [9, 6, 8, 1], [9, 8, 1, 6], [9, 8, 6, 1]]
for f in fk:
if (s22*(10**4) + check_div(f))%7==0:
print("".join(str(k) for k in s2+f+[0]*zero))
quit()
``` | output | 1 | 80,306 | 20 | 160,613 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690 | instruction | 0 | 80,307 | 20 | 160,614 |
Tags: math, number theory
Correct Solution:
```
import itertools
digits = [1, 2, 3, 4, 5, 6, 7, 8, 9]
numdict = {'all':'1869234570','-1':'2345896','-2':'1345869','-3':'1245986','-4':'1235689','-5':'1234968','-6':'1235948','-8':'1234569','-9':'1234856'}
def list2num(numlist):
num = 0
for digit in numlist:
num = num * 10 + digit
#print(num)
#input()
return num
def div7(numlist):
pailie = itertools.permutations(numlist)
flag = 0
for yuanshu in pailie:
num = list2num(yuanshu)
if num % 7 == 0:
flag = 1
return num
break
if flag == 0:
return 0
def pre_num(num_string):
count = []
for i in range(10):
if str(i) in '1689':
count.append(num_string.count(str(i)) - 1)
else:
count.append(num_string.count(str(i)))
return count
def simulinkinput():
tmp = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
tmp = tmp * 5
for i in range(10, 40):
zhuhe = itertools.combinations(tmp, i)
for yuanshu in zhuhe:
num_string = str(list2num(yuanshu)) + '1689'
main(num_string)
def count2num(numlist):
tmplist = []
for i in range(1,len(numlist)):
if numlist[i] > 0:
tmplist.append(i)
return tmplist
def main():
num_string = input()
result_string = ['','111111','222222','333333','444444','555555','666666','777777','888888','999999']
res_list = [1,8,6,9]
count = []
count = pre_num(num_string)
result = ''
for i in range(1,10):
if count[i] >= 6:
loop = count[i] // 6
result = result + result_string[i] * loop
count[i] = count[i] % 6
mincount = min(count[1:])
if mincount > 0:
result = result + '186923457' * mincount
for i in range(1,10):
count[i] = count[i] - mincount
for i in range(9):
numzhlist = count2num(count)
mincount = min(count[1:])
tmpstring = div7(numzhlist)
if tmpstring != 0:
result = result + str(tmpstring) * mincount
for j in numzhlist:
count[j] = count[j] - mincount
else:
break
for i in range(1,10):
for j in range(count[i]):
res_list.append(i)
resnum = div7(res_list)
if resnum == 0:
exit('0')
else:
result = result + str(resnum) + '0' * count[0]
print(result)
#print('%s/7 = %d' %(result,int(result)/7.0))
if __name__ == '__main__':
main()
#simulinkinput()
'''
while True:
main()
input()
'''
# print(__name__)
``` | output | 1 | 80,307 | 20 | 160,615 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690 | instruction | 0 | 80,308 | 20 | 160,616 |
Tags: math, number theory
Correct Solution:
```
import sys
from math import *
from fractions import gcd
readints=lambda:map(int, input().strip('\n').split())
n=input().strip('\n')
from itertools import permutations
perms = [''.join(p) for p in permutations('1689')]
mod={}
for p in perms:
p=int(p)
mod[p%7]=p
freq=[0]*10
for d in n:
d=int(d)
freq[d]+=1
for d in (1,6,8,9):
freq[d]-=1
m=0
for i in range(1,10):
for _ in range(freq[i]):
m=(10*m + i)%7
suf=''
for p in mod.values():
cur=int(str(m)+str(p))
if cur%7==0:
suf=str(p)
break
ans=''
for i in range(1,10):
ans += str(i)*freq[i]
ans += suf
ans += '0'*freq[0]
print(ans)
``` | output | 1 | 80,308 | 20 | 160,617 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690 | instruction | 0 | 80,309 | 20 | 160,618 |
Tags: math, number theory
Correct Solution:
```
S='1689'
s=input()
Z=s.count('0')
s=s.replace('0','')
for i in S:t=s.index(i);s=s[:t]+s[t+1:]
k=0
for i in s:k=(k*10+ord(i)-ord('0'))%7
for a in S:
for b in S:
for c in S:
for d in S:
if len(set(a+b+c+d))==4 and (k*10000+int(a+b+c+d))%7==0:
print(s+a+b+c+d+'0'*Z)
exit()
``` | output | 1 | 80,309 | 20 | 160,619 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690 | instruction | 0 | 80,310 | 20 | 160,620 |
Tags: math, number theory
Correct Solution:
```
a = input()
b=[0]*10
total = 0
for i in a:
b[int(i)]+=1
for i in [1,6,8,9]:
b[i]-=1
for i in range(1,10):
for j in range(b[i]):
total = (total * 10 + i) % 7
print(str(i)*b[i],end = '')
total = (10000 * total)%7
z = ['1869','6189','9186','6198','8691','9168','1896','1869']
print(z[7 - total]+'0'*b[0])
``` | output | 1 | 80,310 | 20 | 160,621 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690 | instruction | 0 | 80,311 | 20 | 160,622 |
Tags: math, number theory
Correct Solution:
```
import sys
n = [int(d) for d in sys.stdin.readline()[:-1]]
for x in [1,6,8,9]:
for i in range(len(n)):
if n[i]==x:
del n[i]
break
prefix = [1869,6189,1689,6198,1698,9861,1896]
L = sum([n[i]*pow(10,len(n)-i-1,7) for i in range(len(n))])%7
print(prefix[(-L)*pow(10,5*len(n),7)%7],end='')
print(*n, sep='')
``` | output | 1 | 80,311 | 20 | 160,623 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690
Submitted Solution:
```
import os
import sys
from io import BytesIO, IOBase
def main():
pass
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def binary(n):
return (bin(n).replace("0b", ""))
def decimal(s):
return (int(s, 2))
def pow2(n):
p = 0
while (n > 1):
n //= 2
p += 1
return (p)
def isPrime(n):
if (n == 1):
return (False)
else:
root = int(n ** 0.5)
root += 1
for i in range(2, root):
if (n % i == 0):
return (False)
return (True)
s=input()
f=[0]*10
mod=[1869,8961,6981,6198,1698,9861,1896]
for i in s:
f[int(i)]+=1
a=""
cm=0
for i in s:
if(i!="0"):
n=int(i)
if(n==1 or n==6 or n==8 or n==9):
if(f[n]>1):
cm=(cm*10+n)%7
f[n]-=1
print(i,end="")
else:
cm=(cm*10+n)%7
f[n]-=1
print(i,end="")
#print(a,cm)
for i in range(0,4):
cm=(cm*10)%7
if(cm==0):
print(str(mod[cm]),end="")
print('0'*f[0])
else:
print(str(mod[7-cm]), end="")
print('0' * f[0])
``` | instruction | 0 | 80,312 | 20 | 160,624 |
Yes | output | 1 | 80,312 | 20 | 160,625 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690
Submitted Solution:
```
import sys
input=sys.stdin.readline
a=input().rstrip()
s=["1869","1968","1689","6198","1698","1986","1896"]
cnt=[0]*10
for i in range(len(a)):
cnt[int(a[i])]+=1
cnt[1]-=1;cnt[6]-=1;cnt[8]-=1;cnt[9]-=1
ans=[]
m=0
for i in range(1,10):
while cnt[i]>0:
m=(10*m+i)%7
ans.append(str(i))
cnt[i]-=1
need_m=(7-(m*(10**4))%7)%7
ans.append(s[need_m])
ans.extend(["0"]*cnt[0])
print("".join(ans))
``` | instruction | 0 | 80,313 | 20 | 160,626 |
Yes | output | 1 | 80,313 | 20 | 160,627 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690
Submitted Solution:
```
# Legends Always Come Up with Solution
# Author: Manvir Singh
import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict,deque,Counter
from bisect import *
from math import sqrt,pi,ceil,log
import math
from itertools import permutations
from copy import deepcopy
from sys import setrecursionlimit
def main():
a=input().rstrip()
n=len(a)
a=Counter(a)
a["6"]-=1
a["1"]-=1
a["8"]-=1
a["9"]-=1
z,s,y=0,[],[1]
for i in range(n):
y.append((y[-1]*10)%7)
xx=1
for i in a:
if i!="0":
x=int(i)
for j in range(a[i]):
s.append(i)
z=(z+x*y[n-xx])%7
xx+=1
f=1
for i in permutations([1,6,8,9]):
if (z+i[0]*y[n-xx]+i[1]*y[n-xx-1]+i[2]*y[n-xx-2]+i[3]*(y[n-xx-3]))%7==0:
f=0
s.extend([str(i[0]),str(i[1]),str(i[2]),str(i[3])])
break
if f:
print(0)
else:
s.append("0"*a["0"])
print("".join(s))
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
main()
``` | instruction | 0 | 80,314 | 20 | 160,628 |
Yes | output | 1 | 80,314 | 20 | 160,629 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690
Submitted Solution:
```
# Made By Mostafa_Khaled
bot = True
a=input()
cnt=[0]*10
for i in (1,6,8,9):
cnt[i]=-1
for i in a:
cnt[int(i)]+=1
mod = [1869, 1968, 9816, 6198, 1698, 1986, 1896, 1869]
modCnt=0
for i in range(1,10):
for j in range(cnt[i]):
modCnt= (modCnt*3 + i)%7
print(str(i)*cnt[i], end='')
modCnt=(10000*modCnt)%7
print(str(mod[7-modCnt])+'0'*cnt[0])
# Made By Mostafa_Khaled
``` | instruction | 0 | 80,315 | 20 | 160,630 |
Yes | output | 1 | 80,315 | 20 | 160,631 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690
Submitted Solution:
```
a = ['9681', '6819', '6981', '6891', '8691', '9861', '8196']
s = input()
mp = {'1':True, '6':True, '8':True, '9':True}
new = ''
for i in list(s):
if (i in mp):
if mp[i]:
mp[i] = False
continue
new += i
if len(new) and int(new):
new = int(new)*10000
print(int(str(new)[:-4] + a[7-(new%7)]))
else:
print(a[0])
``` | instruction | 0 | 80,316 | 20 | 160,632 |
No | output | 1 | 80,316 | 20 | 160,633 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690
Submitted Solution:
```
from itertools import permutations
def seven(n):
ans=[]
if len(n)==10**6:
return 0
n=n.replace("1","",1)
n = n.replace("6", "", 1)
n = n.replace("8", "", 1)
n = n.replace("9", "", 1)
lst=[str(i) for i in str(1689)]
# print(n)
if n=="":
return "1869"
p=list(permutations(lst))
val=sorted(["".join(i) for i in p])
if n=="0":
return 18690
x=int(n)%7
if x==4:
return n+"1986"
if x==5:
return n+"1968"
if x==3:
return n+"1689"
if x==0:
return n+"1869"
return 0
print(seven(input()))
``` | instruction | 0 | 80,317 | 20 | 160,634 |
No | output | 1 | 80,317 | 20 | 160,635 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690
Submitted Solution:
```
from itertools import permutations
perm = permutations([1,8,6,9])
n=[]
for i in list(perm):
s=''
for j in list(i):
s=s+str(j)
n.append(int(s))
d={}
for i in n:
d[i%7]=str(i)
s=input()
z=0
nz=''
c1,c2,c3,c4=0,0,0,0
for i in range(len(s)):
if s[i]=='1' and c1==0:
c1=1
elif s[i]=='8' and c2==0:
c2=1
elif s[i]=='6' and c3==0:
c3=1
elif s[i]=='9' and c4==0:
c4=1
elif s[i]=='0':
z=z+1
else:
nz=nz+s[i]
if nz!='':
x=int(nz)%7
if x==0:
ans=nz+d[0]+'0'*z
else:
ans=nz+d[7-x]+'0'*z
else:
ans=d[0]+'0'*z
print(int(ans))
``` | instruction | 0 | 80,318 | 20 | 160,636 |
No | output | 1 | 80,318 | 20 | 160,637 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
Input
The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.
Output
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number a in the required manner, print 0.
Examples
Input
1689
Output
1869
Input
18906
Output
18690
Submitted Solution:
```
n=int(input())
t=0
a=0
b=0
c=0
d=0
z=0
while n:
x=n%10
if x==1 and a==0:
a=1
elif x==6 and b==0:
b=1
elif x==8 and c==0:
c=1
elif x==9 and d==0:
d=1
else:
t*=10
t+=x
if x==0:
z+=1
n//=10
t*=10000
if t%7==0:
t+=1869
elif t%7==6:
t+=1968
elif t%7==5:
t+=1689
elif t%7==4:
t+=6198
elif t%7==3:
t+=8691
elif t%7==2:
t+=1986
else:
t+=8196
while z:
z-=1
t*=10
print(t)
``` | instruction | 0 | 80,319 | 20 | 160,638 |
No | output | 1 | 80,319 | 20 | 160,639 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333 | instruction | 0 | 80,354 | 20 | 160,708 |
Tags: binary search, constructive algorithms, math
Correct Solution:
```
A = int(input())
F1019 = (45 * 19 * 10**18 + 1) % A
# F1019 = (45 * 3 * 10**2 + 1) % A
r = (-F1019) % A
print(r + 1, 10**19 + r)
``` | output | 1 | 80,354 | 20 | 160,709 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333 | instruction | 0 | 80,355 | 20 | 160,710 |
Tags: binary search, constructive algorithms, math
Correct Solution:
```
n = int(input())
r = 45*18*10**17;
l = n-r%n
r = l +10**18-1
print(l,r)
``` | output | 1 | 80,355 | 20 | 160,711 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333 | instruction | 0 | 80,356 | 20 | 160,712 |
Tags: binary search, constructive algorithms, math
Correct Solution:
```
a = int(input())
b = 45*19*10**18+1
k = a - (b % a)
print(str(k+1)+" "+str(10000000000000000000+k))
``` | output | 1 | 80,356 | 20 | 160,713 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333 | instruction | 0 | 80,357 | 20 | 160,714 |
Tags: binary search, constructive algorithms, math
Correct Solution:
```
a = int(input())
print (a-(45*20*10**19)%a,a-(45*20*10**19)%a+10**20-1)
``` | output | 1 | 80,357 | 20 | 160,715 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333 | instruction | 0 | 80,358 | 20 | 160,716 |
Tags: binary search, constructive algorithms, math
Correct Solution:
```
a=int(input())
x=a-((10**21)*9)%a
print(x,10**20+x-1)
# Made By Mostafa_Khaled
``` | output | 1 | 80,358 | 20 | 160,717 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333 | instruction | 0 | 80,359 | 20 | 160,718 |
Tags: binary search, constructive algorithms, math
Correct Solution:
```
a = int(input())
x, t = 10 ** 100 - 1, a - 100 * 45 * 10 ** 99 % a
print(t, t + x)
``` | output | 1 | 80,359 | 20 | 160,719 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333 | instruction | 0 | 80,360 | 20 | 160,720 |
Tags: binary search, constructive algorithms, math
Correct Solution:
```
# test code from internet
a = int( input() )
k = (45 * 18 * 10**17) % a;
t = a - k;
print(t, t + 10**18 - 1)
``` | output | 1 | 80,360 | 20 | 160,721 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333 | instruction | 0 | 80,361 | 20 | 160,722 |
Tags: binary search, constructive algorithms, math
Correct Solution:
```
A = int(input())
l = 1
r = 10**100
cnt = 10**99*100*45 + 1
cnt = -cnt % A
l += cnt
r += cnt
print(l, r)
``` | output | 1 | 80,361 | 20 | 160,723 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333
Submitted Solution:
```
n = input()
n = int(n)
#print(n)
if (n < 46):
a = 0
while n:
if (n >= 10):
a = a * 10 + 9
n -= 9;
else:
a = a * 10 + n
n = 0
print(a, a)
exit(0)
p = 1
for i in range(1,n):
p *= 10
m = p // 10 * i * 45 + 1
#print(m, p, m + p)
if (m + p > n):
k = n - m
while k < 0:
k += n
if (k >= p):
continue
print(k + 1, p + k)
exit(0)
``` | instruction | 0 | 80,362 | 20 | 160,724 |
Yes | output | 1 | 80,362 | 20 | 160,725 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333
Submitted Solution:
```
e = 20
delta = 10**e - 1
a = int(input())
# Ha e*45*10**(e-1) digitos em delta. Para chegar em multiplo de a falta:
start = a - (e * 45 * 10**(e-1)) % a
print(start, start+delta)
``` | instruction | 0 | 80,363 | 20 | 160,726 |
Yes | output | 1 | 80,363 | 20 | 160,727 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333
Submitted Solution:
```
a = int(input())
l = 1
r = 10**200
cur = [0]
cnt = [1]
for i in range(300):
cur.append(cur[-1] * 10 + 45 * cnt[-1])
cnt.append(cnt[-1] * 10)
def calc(x):
global cur
global cnt
res = 0
a = [int(i) for i in str(x)]
tot = 0
for i in range(len(a)):
if (a[i] != 0):
for j in range(a[i]):
res += (tot + j) * cnt[len(a) - i - 1]
res += a[i] * cur[len(a) - i - 1]
tot += a[i]
res += tot
return res
while (l < r - 1):
m = (l + r) // 2
if (calc(m) < a):
l = m
else:
r = m
if (calc(l) >= a):
r = l
cur = calc(r)
l = 1
def get(x):
res = 0
while (x):
res += x % 10
x //= 10
return res
while (cur % a != 0):
cur -= get(l)
l += 1
while (cur < a):
r += 1
cur += get(r)
print(l, r)
``` | instruction | 0 | 80,364 | 20 | 160,728 |
Yes | output | 1 | 80,364 | 20 | 160,729 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333
Submitted Solution:
```
# test code from internet
n = int( input() )
x,t=10**100-1,n-100*45*10**99%n
print(t,t+x)
``` | instruction | 0 | 80,365 | 20 | 160,730 |
Yes | output | 1 | 80,365 | 20 | 160,731 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333
Submitted Solution:
```
a = int(input())
#1 10**15
sm = 45 * 10**15 // 10 + 1
l = 1
r = 10 ** 15
l += a - sm % a
r += a - sm % a
print(l,r)
``` | instruction | 0 | 80,366 | 20 | 160,732 |
No | output | 1 | 80,366 | 20 | 160,733 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333
Submitted Solution:
```
a = int(input())
if a == 1:
print("1 9001133713379001")
quit()
x = 81000000000000000001
x %= a
want = ((1 - x) % a)
print(want, want + 10**18 - 1)
``` | instruction | 0 | 80,367 | 20 | 160,734 |
No | output | 1 | 80,367 | 20 | 160,735 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333
Submitted Solution:
```
m = int(input())
x,t=10**50-1,m-100*45*10**49%m
print(t,t+x)
``` | instruction | 0 | 80,368 | 20 | 160,736 |
No | output | 1 | 80,368 | 20 | 160,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:
ans = solve(l, r) % a;
if (ans <= 0)
ans += a;
This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.
Input
The first line contains a single integer a (1 β€ a β€ 1018).
Output
Print two integers: l, r (1 β€ l β€ r < 10200) β the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.
Examples
Input
46
Output
1 10
Input
126444381000032
Output
2333333 2333333333333
Submitted Solution:
```
n = int(input())
sum = (10 ** 18) * 19 * 45
sum+=3
l=1
r=(10**18)+1
dif=n-(sum%n)
l+=dif
r+=dif
print(l,r)
``` | instruction | 0 | 80,369 | 20 | 160,738 |
No | output | 1 | 80,369 | 20 | 160,739 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080 | instruction | 0 | 80,566 | 20 | 161,132 |
Tags: constructive algorithms, implementation
Correct Solution:
```
k = int(input())
if k > 36:
print(-1)
else:
v = k // 2
n = k % 2
print(v * '8' + n * '6')
``` | output | 1 | 80,566 | 20 | 161,133 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080 | instruction | 0 | 80,567 | 20 | 161,134 |
Tags: constructive algorithms, implementation
Correct Solution:
```
import math
import sys
input = sys.stdin.readline
def main():
n = int(input())
if n > 36:
print(-1)
else:
print('8' * (n // 2), end='')
if n%2 == 1:
print('4')
if __name__ == '__main__':
main()
``` | output | 1 | 80,567 | 20 | 161,135 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080 | instruction | 0 | 80,568 | 20 | 161,136 |
Tags: constructive algorithms, implementation
Correct Solution:
```
pt = lambda *a, **k: print(*a, **k, flush=True)
k = int(input())
if k > 36:
pt(-1)
else:
while k:
if k & 1:
pt('4', end='')
k -= 1
else:
pt('8', end='')
k -= 2
``` | output | 1 | 80,568 | 20 | 161,137 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080 | instruction | 0 | 80,569 | 20 | 161,138 |
Tags: constructive algorithms, implementation
Correct Solution:
```
# cook your dish here
int_k = int(input())
if(int_k%2 == 1):
k = "4"
int_k -= 1
else:
k = "8"
int_k -= 2
while int_k > 0 and int(k) < 10**18:
k += "8"
int_k -= 2
if(int_k == 0 and int(k) < 10**18 ):
print(int(k))
else:
print(-1)
``` | output | 1 | 80,569 | 20 | 161,139 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080 | instruction | 0 | 80,570 | 20 | 161,140 |
Tags: constructive algorithms, implementation
Correct Solution:
```
k = int(input())
if(k>36):
print(-1) #at max 888888888888888888....10 power 18 , not more than that...
#in one 8, two loops ,so 36 loop
else:
print("8"*(k//2) + "6"*(k%2))
``` | output | 1 | 80,570 | 20 | 161,141 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080 | instruction | 0 | 80,571 | 20 | 161,142 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n = int(input())
num = ''
if n >= 37:
print(-1)
else :
if n % 2 == 0:
num += '8'*(n//2)
print(num)
else:
num += '4'
num += '8' * (n // 2)
print(num)
``` | output | 1 | 80,571 | 20 | 161,143 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080 | instruction | 0 | 80,572 | 20 | 161,144 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n=int(input())
if(n>36):
print(-1)
exit()
if(n%2==0):
for i in range(n//2):
print(8,end="")
else:
for i in range(n//2):
print(8,end="")
print(4,end="")
``` | output | 1 | 80,572 | 20 | 161,145 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080 | instruction | 0 | 80,573 | 20 | 161,146 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n=int(input())
if n>36:
print(-1)
else:
if n%2==0:
a="8"*(n//2)
else:
a="8"*(n//2)
a+="6"
print(a)
``` | output | 1 | 80,573 | 20 | 161,147 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080
Submitted Solution:
```
from collections import deque
from math import ceil,floor,sqrt,gcd
def ii(): return int(input())
def mi(): return map(int,input().split())
def li(): return list(mi())
def si():return input()
n=ii()
if(n>36):
print('-1')
else:
x=n//2
y=n%2
print('8'*x+'6'*y)
``` | instruction | 0 | 80,574 | 20 | 161,148 |
Yes | output | 1 | 80,574 | 20 | 161,149 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080
Submitted Solution:
```
k = int(input())
if(k>36):
print(-1)
else:
print("8"*(k//2) + "4"*(k%2))
``` | instruction | 0 | 80,575 | 20 | 161,150 |
Yes | output | 1 | 80,575 | 20 | 161,151 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080
Submitted Solution:
```
k=int(input())
if(k>40):
print(-1)
else:
if(k==0):
print(1)
elif(k==1):
print(6)
else:
s='8'*(k//2) + '6'*(k%2)
if(int(s)>10**18):
print(-1)
else:
print(s)
``` | instruction | 0 | 80,576 | 20 | 161,152 |
Yes | output | 1 | 80,576 | 20 | 161,153 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080
Submitted Solution:
```
n = int(input())
if n == 0:
print("1")
else:
if ((n//2) +n%2) < 19:
print("8"*(n//2) + "4"*(n%2))
else:
print(-1)
``` | instruction | 0 | 80,577 | 20 | 161,154 |
Yes | output | 1 | 80,577 | 20 | 161,155 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080
Submitted Solution:
```
i = int(input())
c = '8'*(i//2) + '6'*(i%2)
print(c if (i//2//2)+i%2 <= 10*18 else -1)
``` | instruction | 0 | 80,578 | 20 | 161,156 |
No | output | 1 | 80,578 | 20 | 161,157 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080
Submitted Solution:
```
import math
k=int(input())
e=math.pow(10,18)
s=""
if k==0:
print(4)
elif k==1:
print(0)
elif k==2:
print(8)
else:
if k%2!=0:
for i in range(k//2):
s+='8'
if int(s)>e:
print(-1)
break
else:
print(s+"4")
else:
for i in range(k//2):
s+='8'
if int(s)>e:
print(-1)
break
else:
print(s)
``` | instruction | 0 | 80,579 | 20 | 161,158 |
No | output | 1 | 80,579 | 20 | 161,159 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080
Submitted Solution:
```
k = int(input())
if k % 2 == 0:
if len(str(k)) > 18:
print(-1)
else:
print('8' * (k // 2))
else:
if len(str(k)) > 18:
print(-1)
else:
print('8' * (k // 2), '9', sep = '')
``` | instruction | 0 | 80,580 | 20 | 161,160 |
No | output | 1 | 80,580 | 20 | 161,161 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.
He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.
A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.
<image>
Input
The first and only line contains an integer k (1 β€ k β€ 106) β the desired number of loops.
Output
Output an integer β if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.
Examples
Input
2
Output
462
Input
6
Output
8080
Submitted Solution:
```
k = int(input())
print('-1' if k > 36 else '8' * (k // 2) + '0' * (k % 2))
``` | instruction | 0 | 80,581 | 20 | 161,162 |
No | output | 1 | 80,581 | 20 | 161,163 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.