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 |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order.
2. Let S be the number obtained as a result of arrangi... | instruction | 0 | 701 | 20 | 1,402 |
"Correct Solution:
```
while True:
n = input()
if n == "0000":
break
if n.count(n[0]) == 4:
print("NA")
continue
cnt = 0
while n != "6174":
n, l = sorted(list(n)), sorted(list(n), reverse=True)
n = str(int("".join(l)) - int("".join(n))).zfill(4)
cnt ... | output | 1 | 701 | 20 | 1,403 |
Provide a correct Python 3 solution for this coding contest problem.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order.
2. Let S be the number obtained as a result of arrangi... | instruction | 0 | 702 | 20 | 1,404 |
"Correct Solution:
```
def count6174(n):
if n[0] == n[1] == n[2] == n[3]:
return 'NA'
count = 0
while n != '6174':
n = list(n)
l = int(''.join(sorted(n, reverse=True)))
s = int(''.join(sorted(n)))
n = '{:04}'.format(l - s)
count += 1
return count
import s... | output | 1 | 702 | 20 | 1,405 |
Provide a correct Python 3 solution for this coding contest problem.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order.
2. Let S be the number obtained as a result of arrangi... | instruction | 0 | 703 | 20 | 1,406 |
"Correct Solution:
```
while True :
n = int(input())
if n == 0 :
break
else :
ans = 0
while True :
if n == 6174 :
print(ans)
break
else :
A = int(n / 1000)
B = int((... | output | 1 | 703 | 20 | 1,407 |
Provide a correct Python 3 solution for this coding contest problem.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order.
2. Let S be the number obtained as a result of arrangi... | instruction | 0 | 704 | 20 | 1,408 |
"Correct Solution:
```
import copy
while 1:
n = list(input())
if n == ["0", "0", "0", "0"]:
break
tmp = int(n[0])*1000 + int(n[1])*100 + int(n[2])*10 + int(n[3])
if tmp % 1111 == 0:
print("NA")
continue
cnt = 0
while n != ["6", "1", "7", "4"]:
n.sort(reverse=Tr... | output | 1 | 704 | 20 | 1,409 |
Provide a correct Python 3 solution for this coding contest problem.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order.
2. Let S be the number obtained as a result of arrangi... | instruction | 0 | 705 | 20 | 1,410 |
"Correct Solution:
```
while (True):
N = input()
if N=='0000':
break
if N==N[0]*4:
print('NA')
continue
cnt = 0
while N!='6174':
l = [int(Ni) for Ni in N]
l.sort()
L = 1000*l[3]+100*l[2]+10*l[1]+l[0]
S = 1000*l[0]+100*l[1]+1... | output | 1 | 705 | 20 | 1,411 |
Provide a correct Python 3 solution for this coding contest problem.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order.
2. Let S be the number obtained as a result of arrangi... | instruction | 0 | 706 | 20 | 1,412 |
"Correct Solution:
```
while True:
n = 0
int1 = input()
int2 = [int(a) for a in int1]
if int2[0] == int2[1] == int2[2] == int2[3]:
if int2[0] == 0:
break
else:
print("NA")
continue
else:
while True:
int1 = int(int1)
... | output | 1 | 706 | 20 | 1,413 |
Provide a correct Python 3 solution for this coding contest problem.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order.
2. Let S be the number obtained as a result of arrangi... | instruction | 0 | 707 | 20 | 1,414 |
"Correct Solution:
```
while 1:
n,c=input(),0
if int(n)==0:break
if n.count(n[0])==4:
print('NA')
continue
while n!='6174':
n = str(int(''.join(reversed(sorted(list(n))))) - int(''.join(sorted(list(n))))).zfill(4)
c+=1
print(c)
``` | output | 1 | 707 | 20 | 1,415 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order... | instruction | 0 | 708 | 20 | 1,416 |
Yes | output | 1 | 708 | 20 | 1,417 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order... | instruction | 0 | 709 | 20 | 1,418 |
Yes | output | 1 | 709 | 20 | 1,419 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order... | instruction | 0 | 710 | 20 | 1,420 |
Yes | output | 1 | 710 | 20 | 1,421 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order... | instruction | 0 | 711 | 20 | 1,422 |
Yes | output | 1 | 711 | 20 | 1,423 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order... | instruction | 0 | 712 | 20 | 1,424 |
No | output | 1 | 712 | 20 | 1,425 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order... | instruction | 0 | 713 | 20 | 1,426 |
No | output | 1 | 713 | 20 | 1,427 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order... | instruction | 0 | 714 | 20 | 1,428 |
No | output | 1 | 714 | 20 | 1,429 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Do the following for a four-digit number N consisting of numbers 0-9.
1. Let L be the number obtained as a result of arranging the numerical values of each of the N digits in descending order... | instruction | 0 | 715 | 20 | 1,430 |
No | output | 1 | 715 | 20 | 1,431 |
Provide a correct Python 3 solution for this coding contest problem.
Tashizan Hikizan (Calculation Training)
square1001 You gave E869120 two numbers, $ A $ and $ B $, as birthday presents.
E869120 You decided to use these two numbers for calculation training.
Specifically, E869120 does the following for these numbe... | instruction | 0 | 786 | 20 | 1,572 |
"Correct Solution:
```
from itertools import *
from bisect import *
from math import *
from collections import *
from heapq import *
from random import *
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return... | output | 1 | 786 | 20 | 1,573 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little C loves number «3» very much. He loves all things about it.
Now he has a positive integer n. He wants to split n into 3 positive integers a,b,c, such that a+b+c=n and none of the 3 integers is a multiple of 3. Help him to find a solu... | instruction | 0 | 820 | 20 | 1,640 |
Tags: math
Correct Solution:
```
a = int(input())
if (a-2)%3 != 0:
angka1 = a-2
angka2 = 1
angka3 = 1
elif (a-3)%3 != 0:
angka1 = a-3
angka2 = 2
angka3 = 1
elif (a-4)%3 != 0:
angka1 = a-4
angka2 = 2
angka3 = 3
print(angka1,angka2,angka3)
``` | output | 1 | 820 | 20 | 1,641 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers a and b. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := b - x. Note that you m... | instruction | 0 | 949 | 20 | 1,898 |
Tags: binary search, math
Correct Solution:
```
for _ in range(int(input())):
a, b = map(int, input().split())
if a < b: a, b = b, a
if (b*2-a) % 3 == 0 and (b*2-a) >= 0:
print("YES")
else:
print("NO")
``` | output | 1 | 949 | 20 | 1,899 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers a and b. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := b - x. Note that you m... | instruction | 0 | 950 | 20 | 1,900 |
Tags: binary search, math
Correct Solution:
```
t = int(input())
for i in range(t):
a, b = map(int, input().split())
if 2*a-b >= 0 and 2*b-a >= 0 and (2*a-b) % 3 == 0:
print('YES')
else:
print('NO')
``` | output | 1 | 950 | 20 | 1,901 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers a and b. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := b - x. Note that you m... | instruction | 0 | 951 | 20 | 1,902 |
Tags: binary search, math
Correct Solution:
```
# cook your dish here
t = int(input())
for testcase in range(t):
a, b = [int(ele) for ele in input().split()]
s = min(a, b)
l = max(a, b)
if ((2*a-b)%3==0 or ((2*b-a)%3==0) ) and a<=2*b and b <= 2*a:
# if (a+b)%3==0 and (a<=2*b and b<=2*a):
pr... | output | 1 | 951 | 20 | 1,903 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers a and b. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := b - x. Note that you m... | instruction | 0 | 953 | 20 | 1,906 |
Tags: binary search, math
Correct Solution:
```
for _ in range(int(input())):
a, b = map(int, input().split())
if (a + b) % 3 == 0:
if a >= b / 2 and b >= a / 2:
print('YES')
continue
print('NO')
``` | output | 1 | 953 | 20 | 1,907 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers a and b. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := b - x. Note that you m... | instruction | 0 | 954 | 20 | 1,908 |
Tags: binary search, math
Correct Solution:
```
for i in range(int(input())):
s, b = map(int, input().split())
if s > b:
s, b = b, s
if (s + b)%3==0 and s*2 >= b:
print('Yes')
else:
print('No')
``` | output | 1 | 954 | 20 | 1,909 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers a and b. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := b - x. Note that you m... | instruction | 0 | 955 | 20 | 1,910 |
Tags: binary search, math
Correct Solution:
```
for t in range(int(input())):
a, b = map(int, input().split())
if a > b:
a, b = b, a
print ('YES' if ( ((a + b) % 3) == 0 and (a * 2 - b)/3 >= 0) else 'NO')
``` | output | 1 | 955 | 20 | 1,911 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers a and b. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := b - x. Note that you m... | instruction | 0 | 956 | 20 | 1,912 |
Tags: binary search, math
Correct Solution:
```
def fastio():
import sys
from io import StringIO
from atexit import register
global input
sys.stdin = StringIO(sys.stdin.read())
input = lambda : sys.stdin.readline().rstrip('\r\n')
sys.stdout = StringIO()
register(lambda : sys.__stdout__.write(sys.stdout.getvalu... | output | 1 | 956 | 20 | 1,913 |
Provide a correct Python 3 solution for this coding contest problem.
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.
In this prob... | instruction | 0 | 1,541 | 20 | 3,082 |
"Correct Solution:
```
a,b=input().split()
print(">" if ord(a) > ord(b) else "<" if ord(a) < ord(b) else "=")
``` | output | 1 | 1,541 | 20 | 3,083 |
Provide a correct Python 3 solution for this coding contest problem.
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.
In this prob... | instruction | 0 | 1,543 | 20 | 3,086 |
"Correct Solution:
```
x,y=input().split()
if x>y:
a='>'
elif x<y:
a='<'
else:
a='='
print(a)
``` | output | 1 | 1,543 | 20 | 3,087 |
Provide a correct Python 3 solution for this coding contest problem.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number of digits L are given first. Applying the following rul... | instruction | 0 | 1,611 | 20 | 3,222 |
"Correct Solution:
```
while 1:
n,d=input().split()
if n==d=='0':break
a=[int(n)]
while 1:
n=''.join(sorted(n.zfill(int(d))))
b = int(n[::-1]) - int(n)
if b in a:break
a+=[b]
n=str(b)
print(a.index(b),b,len(a)-a.index(b))
``` | output | 1 | 1,611 | 20 | 3,223 |
Provide a correct Python 3 solution for this coding contest problem.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number of digits L are given first. Applying the following rul... | instruction | 0 | 1,612 | 20 | 3,224 |
"Correct Solution:
```
def dfs(b):
s=str(b)
for i in range(l-len(s)):
s="0"+s
l0=[]
for z in range(l):
l0.append(s[z])
l1=[]
l1=sorted(l0)
s1=str()
s2=str()
for x in l1:
s1=s1+x
s2=x+s2
i1=int(s1)
i2=int(s2)
return i2-i1
while True:
a,l... | output | 1 | 1,612 | 20 | 3,225 |
Provide a correct Python 3 solution for this coding contest problem.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number of digits L are given first. Applying the following rul... | instruction | 0 | 1,613 | 20 | 3,226 |
"Correct Solution:
```
while True:
a, l = map(int, input().split())
if a == l == 0:
break
calced = {}
zfill = ("{0:0%dd}" % l).format
cnt = 0
while True:
if calced.get(a) == None:
calced[a] = cnt
else:
# print(calced, a, cnt)
print(calc... | output | 1 | 1,613 | 20 | 3,227 |
Provide a correct Python 3 solution for this coding contest problem.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number of digits L are given first. Applying the following rul... | instruction | 0 | 1,614 | 20 | 3,228 |
"Correct Solution:
```
while True:
a, l = map(int, input().split())
if (a, l) == (0, 0):
break
arr = [a]
for i in range(20):
p = list(map(int, '{0:0>{1}}'.format(a, l)))
a = int(''.join(map(str,sorted(p, reverse=True)))) - int(''.join(map(str,sorted(p))))
if a in arr:
break
arr.append(a)
j = arr.in... | output | 1 | 1,614 | 20 | 3,229 |
Provide a correct Python 3 solution for this coding contest problem.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number of digits L are given first. Applying the following rul... | instruction | 0 | 1,615 | 20 | 3,230 |
"Correct Solution:
```
def solve(a , L , ans,a_n):
lis = str(a)
lis = list(lis)
for i in range(L - len(lis)):
lis.append('0')
lis.sort()
a_ = 0
dig = 1
for i in lis:
a_ += int(i) * dig
#print(type(i))
dig *= 10
dig = 1
for i in reversed(lis):
... | output | 1 | 1,615 | 20 | 3,231 |
Provide a correct Python 3 solution for this coding contest problem.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number of digits L are given first. Applying the following rul... | instruction | 0 | 1,616 | 20 | 3,232 |
"Correct Solution:
```
def sort_MxMn(SeriesA):
global max_a, min_a
listA = list(str(SeriesA))
while len(listA) < b:
listA.append("0")
listA = [int(x) for x in listA]
max_a = sorted(listA, reverse=True)
min_a = sorted(listA)
def translate(listEx):
num = 0
for i in range(b):
... | output | 1 | 1,616 | 20 | 3,233 |
Provide a correct Python 3 solution for this coding contest problem.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number of digits L are given first. Applying the following rul... | instruction | 0 | 1,617 | 20 | 3,234 |
"Correct Solution:
```
while True:
a0, L = map(int, input().split())
if a0==0 and L==0:
break
s = ("{:0" + str(L) + "d}").format(a0)
hist = [a0]
for i in range(1, 21):
# print(hist)
large = "".join(sorted(s, reverse=True))
small = "".join(sorted(s))
# print(l... | output | 1 | 1,617 | 20 | 3,235 |
Provide a correct Python 3 solution for this coding contest problem.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number of digits L are given first. Applying the following rul... | instruction | 0 | 1,618 | 20 | 3,236 |
"Correct Solution:
```
while True:
a, L = map(int, input().split())
if a == 0 and L == 0: break
nums = [a]
for i in range(20):
ds = list(str(a))
while len(ds) != L:
ds.append('0')
ln = int("".join(sorted(ds)))
gn = int("".join(sorted(ds, reverse=True)))
n =... | output | 1 | 1,618 | 20 | 3,237 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number... | instruction | 0 | 1,619 | 20 | 3,238 |
Yes | output | 1 | 1,619 | 20 | 3,239 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number... | instruction | 0 | 1,620 | 20 | 3,240 |
Yes | output | 1 | 1,620 | 20 | 3,241 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number... | instruction | 0 | 1,621 | 20 | 3,242 |
Yes | output | 1 | 1,621 | 20 | 3,243 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number... | instruction | 0 | 1,622 | 20 | 3,244 |
Yes | output | 1 | 1,622 | 20 | 3,245 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number... | instruction | 0 | 1,623 | 20 | 3,246 |
No | output | 1 | 1,623 | 20 | 3,247 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number... | instruction | 0 | 1,624 | 20 | 3,248 |
No | output | 1 | 1,624 | 20 | 3,249 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number... | instruction | 0 | 1,625 | 20 | 3,250 |
No | output | 1 | 1,625 | 20 | 3,251 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number... | instruction | 0 | 1,626 | 20 | 3,252 |
No | output | 1 | 1,626 | 20 | 3,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let f(x) be the sum of digits of a decimal number x.
Find the smallest non-negative integer x such that f(x) + f(x + 1) + ... + f(x + k) = n.
Input
The first line contains one integer t (1 ≤ t ≤ 150) — the number of test cases.
Each test... | instruction | 0 | 1,817 | 20 | 3,634 |
Tags: brute force, constructive algorithms, dp, greedy
Correct Solution:
```
def func(x, d, n, k):
ans = str(x)
for i in range(d):
ans = '9' + ans
for i in range(k + 1):
y = (x + i) % 10
if y >= x:
n -= d * 9 + y
else:
n -= 1 + y
if n < 0:
... | output | 1 | 1,817 | 20 | 3,635 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let f(x) be the sum of digits of a decimal number x.
Find the smallest non-negative integer x such that f(x) + f(x + 1) + ... + f(x + k) = n.
Input
The first line contains one integer t (1 ≤ t ≤ 150) — the number of test cases.
Each test... | instruction | 0 | 1,818 | 20 | 3,636 |
Tags: brute force, constructive algorithms, dp, greedy
Correct Solution:
```
import sys
#missed a ton of cases
def input():
return sys.stdin.readline().rstrip()
def input_split():
return [int(i) for i in input().split()]
def k_one(n):
# # print('args {}'.format(n))
# s = ''
# this is wrong
# edit - no its
if ... | output | 1 | 1,818 | 20 | 3,637 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let f(x) be the sum of digits of a decimal number x.
Find the smallest non-negative integer x such that f(x) + f(x + 1) + ... + f(x + k) = n.
Input
The first line contains one integer t (1 ≤ t ≤ 150) — the number of test cases.
Each test... | instruction | 0 | 1,819 | 20 | 3,638 |
Tags: brute force, constructive algorithms, dp, greedy
Correct Solution:
```
def sum_digit(x):
s=0
while x > 0:
s+=x % 10
x //= 10
return s
def get_min(x):
num9 = x // 9
r = x % 9
return (r + 1) * (10 ** num9) - 1
S = [[0 for _ in range(10)] for _ in range(100)]... | output | 1 | 1,819 | 20 | 3,639 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let f(x) be the sum of digits of a decimal number x.
Find the smallest non-negative integer x such that f(x) + f(x + 1) + ... + f(x + k) = n.
Input
The first line contains one integer t (1 ≤ t ≤ 150) — the number of test cases.
Each test... | instruction | 0 | 1,820 | 20 | 3,640 |
Tags: brute force, constructive algorithms, dp, greedy
Correct Solution:
```
t = int(input())
def solve(n, k):
ans = -1
for i in range(10):
# print(i)
m = n//9
if i + k < 10:
m = 0 # no need for extra 9's
for j in range(m+1):
if (i + k >= 10) and (j == 0)... | output | 1 | 1,820 | 20 | 3,641 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let f(x) be the sum of digits of a decimal number x.
Find the smallest non-negative integer x such that f(x) + f(x + 1) + ... + f(x + k) = n.
Input
The first line contains one integer t (1 ≤ t ≤ 150) — the number of test cases.
Each test... | instruction | 0 | 1,821 | 20 | 3,642 |
Tags: brute force, constructive algorithms, dp, greedy
Correct Solution:
```
def f(n):
ans = 0
while n:
ans += n%10
n //= 10
return ans
def get(n, k):
ans = 0
for i in range(k+1):
ans += f(n+i)
return ans
t = int(input())
for tmp in range(t):
w, k = map(int, input()... | output | 1 | 1,821 | 20 | 3,643 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let f(x) be the sum of digits of a decimal number x.
Find the smallest non-negative integer x such that f(x) + f(x + 1) + ... + f(x + k) = n.
Input
The first line contains one integer t (1 ≤ t ≤ 150) — the number of test cases.
Each test... | instruction | 0 | 1,822 | 20 | 3,644 |
Tags: brute force, constructive algorithms, dp, greedy
Correct Solution:
```
from math import *
from collections import *
from bisect import *
import sys
input=sys.stdin.readline
t=int(input())
def call(n):
pre=''
if(n<=8):
return str(n)
pre='8'
n-=8
pre+=(n//9)*'9'+str(n%9)
#print(pre)
... | output | 1 | 1,822 | 20 | 3,645 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let f(x) be the sum of digits of a decimal number x.
Find the smallest non-negative integer x such that f(x) + f(x + 1) + ... + f(x + k) = n.
Input
The first line contains one integer t (1 ≤ t ≤ 150) — the number of test cases.
Each test... | instruction | 0 | 1,823 | 20 | 3,646 |
Tags: brute force, constructive algorithms, dp, greedy
Correct Solution:
```
def findPref(targetDigitSum):
assert targetDigitSum>=0
if targetDigitSum==0: return ''
if targetDigitSum<=8: return str(targetDigitSum)
rem=targetDigitSum-8
if rem%9==0:
return '9'*(rem//9)+'8'
return str(rem%9)... | output | 1 | 1,823 | 20 | 3,647 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let f(x) be the sum of digits of a decimal number x.
Find the smallest non-negative integer x such that f(x) + f(x + 1) + ... + f(x + k) = n.
Input
The first line contains one integer t (1 ≤ t ≤ 150) — the number of test cases.
Each test... | instruction | 0 | 1,824 | 20 | 3,648 |
Tags: brute force, constructive algorithms, dp, greedy
Correct Solution:
```
import io
import os
from math import gcd
# See: https://codeforces.com/blog/entry/79277?#comment-650324
def f(x):
# Sum of digits of x
return sum(int(d) for d in str(x))
def getParams(d, K):
# Given starting ones place of x an... | output | 1 | 1,824 | 20 | 3,649 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.