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. Bob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked n of them how much effort they ne...
instruction
0
51,445
20
102,890
No
output
1
51,445
20
102,891
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Bob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked n of them how much effort they ne...
instruction
0
51,446
20
102,892
No
output
1
51,446
20
102,893
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has sequence ...
instruction
0
51,553
20
103,106
Tags: combinatorics, dp, math Correct Solution: ``` import sys input = sys.stdin.readline def solve(): n, k = map(int, input().split()) a = [4,7] d = dict() idx = 0 for p in range(1,10): for m in range(1<<p): v = 0 for i in range(p): v = v*10+a[(m >> i)&1] d[v] = idx idx += 1 #print(d) c = [0...
output
1
51,553
20
103,107
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has sequence ...
instruction
0
51,554
20
103,108
Tags: combinatorics, dp, math Correct Solution: ``` import sys MOD = 10 ** 9 + 7 def is_lucky(n): n = str(n) return n.count('4') + n.count('7') == len(n) def get_inv(n): return pow(n, MOD - 2, MOD) def c(n, k): if n < k or k < 0: return 0 global fact, rfact return (fact[n] * rfact[k] * r...
output
1
51,554
20
103,109
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has sequence ...
instruction
0
51,555
20
103,110
Tags: combinatorics, dp, math Correct Solution: ``` MOD = 10 ** 9 + 7 def is_lucky(n): n = str(n) return n.count('4') + n.count('7') == len(n) def get_inv(n): return pow(n, MOD - 2, MOD) def c(n, k): if n < k or k < 0: return 0 global fact, rfact return (fact[n] * rfact[k] * rfact[n -...
output
1
51,555
20
103,111
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has sequence ...
instruction
0
51,556
20
103,112
Tags: combinatorics, dp, math Correct Solution: ``` import sys input = sys.stdin.readline def solve(): n, k = map(int, input().split()) a = [4,7] d = dict() idx = 0 for p in range(1,10): for m in range(1<<p): v = 0 for i in range(p): v = v*10+a[(m >> i)&1] d[v] = idx idx += 1 #print(d) c = [0...
output
1
51,556
20
103,113
Provide tags and a correct Python 3 solution for this coding contest problem. The Department of economic development of IT City created a model of city development till year 2100. To prepare report about growth perspectives it is required to get growth estimates from the model. To get the growth estimates it is requ...
instruction
0
51,745
20
103,490
Tags: math Correct Solution: ``` from math import sqrt a, b, c = input().split() a, b, c = float(a), float(b), float(c) rD = sqrt(b*b - 4*a*c) roots = ((-b+rD)/(2*a), (-b-rD)/(2*a)) print(max(roots)) print(min(roots)) ```
output
1
51,745
20
103,491
Provide tags and a correct Python 3 solution for this coding contest problem. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left. For example, ...
instruction
0
51,826
20
103,652
Tags: brute force, implementation Correct Solution: ``` def pal_check(s): k = len(s) - 1 i = 0 while i < len(s): if s[i] != s[k]: return False else: i = i + 1 k = k - 1 return True a = input() if pal_check(a) is True: print("YES") else: d =...
output
1
51,826
20
103,653
Provide tags and a correct Python 3 solution for this coding contest problem. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left. For example, ...
instruction
0
51,827
20
103,654
Tags: brute force, implementation Correct Solution: ``` number = input() if number[-1] == "0": index = len(number) - 1 while number[index] == "0": index -= 1 number = number[0:index + 1] s = "" for i in range(0, len(number)): s = number[i] + s if s == number: print('YES') else: print('NO...
output
1
51,827
20
103,655
Provide tags and a correct Python 3 solution for this coding contest problem. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left. For example, ...
instruction
0
51,828
20
103,656
Tags: brute force, implementation Correct Solution: ``` num = input() if str(int(num[::-1])) == str(int(num[::-1]))[::-1]: print('YES') else: print('NO') ```
output
1
51,828
20
103,657
Provide tags and a correct Python 3 solution for this coding contest problem. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left. For example, ...
instruction
0
51,829
20
103,658
Tags: brute force, implementation Correct Solution: ``` st = input() ind1 = 0 ind2 = 0 l = len(st) for i in range(0,l): if st[i] != "0": ind1 = i break for i in range(l-1,-1,-1): if st[i] != "0": ind2 = i break st = st[ind1:ind2+1] st1 = st[::-1] if st == st1: print("YES") el...
output
1
51,829
20
103,659
Provide tags and a correct Python 3 solution for this coding contest problem. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left. For example, ...
instruction
0
51,830
20
103,660
Tags: brute force, implementation Correct Solution: ``` s=input() if s[-1]=="0": i=-1 while s[i]=="0": i-=1 s=s[0:i+1] fl=True for j in range(len(s)//2): if s[j]!=s[-j-1]: fl=False if fl: print('Yes') else: print('No') ```
output
1
51,830
20
103,661
Provide tags and a correct Python 3 solution for this coding contest problem. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left. For example, ...
instruction
0
51,831
20
103,662
Tags: brute force, implementation Correct Solution: ``` import sys def is_Pol(str): return str == str[::-1] str = input() for i in range (1,20): if is_Pol(str): print("YES") sys.exit() str = '0' + str print("NO") ```
output
1
51,831
20
103,663
Provide tags and a correct Python 3 solution for this coding contest problem. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left. For example, ...
instruction
0
51,832
20
103,664
Tags: brute force, implementation Correct Solution: ``` x = int(input()) while x%10==0: x = x//10 y = str (x) k = 0 for i in range (len(y)//2): if y[i]!=y[len(y)-i-1]: break else: k+=1 if k==len(y)//2: print ('YES') else: print ('NO') ```
output
1
51,832
20
103,665
Provide tags and a correct Python 3 solution for this coding contest problem. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left. For example, ...
instruction
0
51,833
20
103,666
Tags: brute force, implementation Correct Solution: ``` def main(): s = input().rstrip('0') print(('NO', 'YES')[s == s[::-1]]) if __name__ == '__main__': main() ```
output
1
51,833
20
103,667
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left ...
instruction
0
51,834
20
103,668
Yes
output
1
51,834
20
103,669
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left ...
instruction
0
51,835
20
103,670
Yes
output
1
51,835
20
103,671
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left ...
instruction
0
51,836
20
103,672
Yes
output
1
51,836
20
103,673
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left ...
instruction
0
51,837
20
103,674
Yes
output
1
51,837
20
103,675
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left ...
instruction
0
51,838
20
103,676
No
output
1
51,838
20
103,677
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left ...
instruction
0
51,839
20
103,678
No
output
1
51,839
20
103,679
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left ...
instruction
0
51,840
20
103,680
No
output
1
51,840
20
103,681
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left ...
instruction
0
51,841
20
103,682
No
output
1
51,841
20
103,683
Provide tags and a correct Python 3 solution for this coding contest problem. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number...
instruction
0
52,186
20
104,372
Tags: implementation Correct Solution: ``` # a,b,c,d,e = map(int, input().split()) # sum=a+b+c+d+e # if (sum%5 == 0): # print(int(sum/5)) # else: # print(-1) sstr=input() if (len(sstr)==1): ans=0 else: ans=1 while (1): sum=0 for i in sstr: sum=sum+int(i)-int('0') ...
output
1
52,186
20
104,373
Provide tags and a correct Python 3 solution for this coding contest problem. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number...
instruction
0
52,187
20
104,374
Tags: implementation Correct Solution: ``` t=int(input()) def proB(n): ans=0 while(n>=10): lst=list(str(n)) n=0 for i in lst: n+=int(i) ans+=1 return ans print(proB(t)) ```
output
1
52,187
20
104,375
Provide tags and a correct Python 3 solution for this coding contest problem. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number...
instruction
0
52,188
20
104,376
Tags: implementation Correct Solution: ``` number = input() numtimes = 0 while len(number) > 1: sum = 0 for digit in number: sum += int(digit) numtimes += 1 number = str(sum) print(numtimes) ```
output
1
52,188
20
104,377
Provide tags and a correct Python 3 solution for this coding contest problem. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number...
instruction
0
52,189
20
104,378
Tags: implementation Correct Solution: ``` count=0 def c(s): global count count+=1 l=list(s) exp=0 for e in l: exp=exp+int(e) return str(exp) s=input() while(len(s)>1): s=c(s) print(count) ```
output
1
52,189
20
104,379
Provide tags and a correct Python 3 solution for this coding contest problem. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number...
instruction
0
52,190
20
104,380
Tags: implementation Correct Solution: ``` n=input() count =0 sum =0 while len(n) > 1: for i in n: sum+=int(i) count+=1 n=str(sum) sum=0 print(count) ```
output
1
52,190
20
104,381
Provide tags and a correct Python 3 solution for this coding contest problem. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number...
instruction
0
52,191
20
104,382
Tags: implementation Correct Solution: ``` n=input() s=0 while len(n)>1: n=str(sum(map(int,n))) s+=1 print(s) ```
output
1
52,191
20
104,383
Provide tags and a correct Python 3 solution for this coding contest problem. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number...
instruction
0
52,192
20
104,384
Tags: implementation Correct Solution: ``` s=input() p=0 while (len(s)>1): c=0 p+=1 for i in s: c+=int(i) s=str(c) print(p) ```
output
1
52,192
20
104,385
Provide tags and a correct Python 3 solution for this coding contest problem. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number...
instruction
0
52,193
20
104,386
Tags: implementation Correct Solution: ``` n = input() count = 0 size = len(n) while(size>1): sum = 0 for j in n: sum += int(j) count += 1 n = str(sum) size = len(n) print(count) ```
output
1
52,193
20
104,387
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the mome...
instruction
0
52,194
20
104,388
Yes
output
1
52,194
20
104,389
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the mome...
instruction
0
52,195
20
104,390
Yes
output
1
52,195
20
104,391
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the mome...
instruction
0
52,196
20
104,392
Yes
output
1
52,196
20
104,393
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the mome...
instruction
0
52,197
20
104,394
Yes
output
1
52,197
20
104,395
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the mome...
instruction
0
52,198
20
104,396
No
output
1
52,198
20
104,397
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the mome...
instruction
0
52,199
20
104,398
No
output
1
52,199
20
104,399
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the mome...
instruction
0
52,200
20
104,400
No
output
1
52,200
20
104,401
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the mome...
instruction
0
52,201
20
104,402
No
output
1
52,201
20
104,403
Provide tags and a correct Python 3 solution for this coding contest problem. You wrote down all integers from 0 to 10^n - 1, padding them with leading zeroes so their lengths are exactly n. For example, if n = 3 then you wrote out 000, 001, ..., 998, 999. A block in an integer x is a consecutive segment of equal dig...
instruction
0
52,376
20
104,752
Tags: combinatorics, dp, math Correct Solution: ``` import sys input=sys.stdin.readline inf = 1e10 mod = int(1e9 + 7) t=1; # t=int(input()) for _ in range(t): n=int(input()) modulo = 998244353 p=[1]*(n+1) for i in range(1, n): p[i] = (p[i-1]*10)%modulo for i in range(1, n): # total n...
output
1
52,376
20
104,753
Provide tags and a correct Python 3 solution for this coding contest problem. You wrote down all integers from 0 to 10^n - 1, padding them with leading zeroes so their lengths are exactly n. For example, if n = 3 then you wrote out 000, 001, ..., 998, 999. A block in an integer x is a consecutive segment of equal dig...
instruction
0
52,377
20
104,754
Tags: combinatorics, dp, math Correct Solution: ``` MOD = 998244353 n = int(input()) if n == 1: print(10) exit() a = [1] * (n-1) a[0] = 20 for i in range(1, n-1): a[i] *= (a[i-1] * 10) + (9 * (pow(10, i, MOD))) a[i] %= MOD a.reverse() for i in range(n-1): a[i] *= 9 a[i] %= MOD a.append(10...
output
1
52,377
20
104,755
Provide tags and a correct Python 3 solution for this coding contest problem. You wrote down all integers from 0 to 10^n - 1, padding them with leading zeroes so their lengths are exactly n. For example, if n = 3 then you wrote out 000, 001, ..., 998, 999. A block in an integer x is a consecutive segment of equal dig...
instruction
0
52,378
20
104,756
Tags: combinatorics, dp, math Correct Solution: ``` #Code by Sounak, IIESTS #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase from fractions import Fraction from collections import defaultdict from itertools import permutations BUFSIZE ...
output
1
52,378
20
104,757
Provide tags and a correct Python 3 solution for this coding contest problem. You wrote down all integers from 0 to 10^n - 1, padding them with leading zeroes so their lengths are exactly n. For example, if n = 3 then you wrote out 000, 001, ..., 998, 999. A block in an integer x is a consecutive segment of equal dig...
instruction
0
52,379
20
104,758
Tags: combinatorics, dp, math Correct Solution: ``` n = int(input()) # n is the number length modulo = 998244353 ten_powers = [1] for i in range(1, n): ten_powers.append(ten_powers[-1] * 10 % modulo) # ten_powers[i] equals 10**i % modulo for k in range(1, n+1): # k is the block size if n == k: ways...
output
1
52,379
20
104,759
Provide tags and a correct Python 3 solution for this coding contest problem. You wrote down all integers from 0 to 10^n - 1, padding them with leading zeroes so their lengths are exactly n. For example, if n = 3 then you wrote out 000, 001, ..., 998, 999. A block in an integer x is a consecutive segment of equal dig...
instruction
0
52,380
20
104,760
Tags: combinatorics, dp, math Correct Solution: ``` import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ sum1=10 currnum=0 ans=[10] mod=998244353 n=int(input()) for i in range(1,n): #print(sum1,10**(i+1)*(i+1)) currnum=(9*i+10)*pow(10,i,mod)-sum1 sum1+=currnum ans.append(currnum%m...
output
1
52,380
20
104,761
Provide tags and a correct Python 3 solution for this coding contest problem. You wrote down all integers from 0 to 10^n - 1, padding them with leading zeroes so their lengths are exactly n. For example, if n = 3 then you wrote out 000, 001, ..., 998, 999. A block in an integer x is a consecutive segment of equal dig...
instruction
0
52,381
20
104,762
Tags: combinatorics, dp, math Correct Solution: ``` n = int(input()) a = [10] s = 10 w = 10 m = 998244353 for i in range(2, n+1): e = (i*pow(10, i, m)%m - (w+s))%m s += e w += s s %= m w %= m a += [e] print(*a[::-1]) ```
output
1
52,381
20
104,763
Provide tags and a correct Python 3 solution for this coding contest problem. You wrote down all integers from 0 to 10^n - 1, padding them with leading zeroes so their lengths are exactly n. For example, if n = 3 then you wrote out 000, 001, ..., 998, 999. A block in an integer x is a consecutive segment of equal dig...
instruction
0
52,382
20
104,764
Tags: combinatorics, dp, math Correct Solution: ``` l=[] for i in range(10): l.append(0) def f(n,x): n=str(n) n="0"*(x-len(n))+n+"#" prev=0 for i in range(1,len(n)): now=i if n[i]!=n[i-1]: l[now-prev]+=1 prev=now ans=[] ans.append(10) ans.append(180) diff=81 ...
output
1
52,382
20
104,765
Provide tags and a correct Python 3 solution for this coding contest problem. You wrote down all integers from 0 to 10^n - 1, padding them with leading zeroes so their lengths are exactly n. For example, if n = 3 then you wrote out 000, 001, ..., 998, 999. A block in an integer x is a consecutive segment of equal dig...
instruction
0
52,383
20
104,766
Tags: combinatorics, dp, math Correct Solution: ``` def power(x, y, p): res = 1 # Initialize result # Update x if it is more # than or equal to p x = x % p while (y > 0): # If y is odd, multiply # x with result if ((y & 1) == 1): res = (res * x) % p ...
output
1
52,383
20
104,767
Provide tags and a correct Python 3 solution for this coding contest problem. Nezzar's favorite digit among 1,…,9 is d. He calls a positive integer lucky if d occurs at least once in its decimal representation. Given q integers a_1,a_2,…,a_q, for each 1 ≀ i ≀ q Nezzar would like to know if a_i can be equal to a sum ...
instruction
0
52,439
20
104,878
Tags: brute force, dp, greedy, math Correct Solution: ``` for _ in range(int(input())): n,d = list(map(int,input().split())) l = list(map(int,input().split())) for i in l : vb = i vb%=d cant = False while True : if vb == 0 : break ...
output
1
52,439
20
104,879
Provide tags and a correct Python 3 solution for this coding contest problem. Nezzar's favorite digit among 1,…,9 is d. He calls a positive integer lucky if d occurs at least once in its decimal representation. Given q integers a_1,a_2,…,a_q, for each 1 ≀ i ≀ q Nezzar would like to know if a_i can be equal to a sum ...
instruction
0
52,440
20
104,880
Tags: brute force, dp, greedy, math Correct Solution: ``` t = int(input()) for _ in range(t): q, d = [int(x) for x in input().split()] l = [int(x) for x in input().split()] poss = [False]*1001 for i in range(1001): if str(d) in str(i): poss[i] = True for i in range(110): ...
output
1
52,440
20
104,881
Provide tags and a correct Python 3 solution for this coding contest problem. Nezzar's favorite digit among 1,…,9 is d. He calls a positive integer lucky if d occurs at least once in its decimal representation. Given q integers a_1,a_2,…,a_q, for each 1 ≀ i ≀ q Nezzar would like to know if a_i can be equal to a sum ...
instruction
0
52,441
20
104,882
Tags: brute force, dp, greedy, math Correct Solution: ``` for _ in range(int(input())): t,d=map(int,input().split()) for n in list(map(int,input().split())): flag=False while n>=0: if str(d) in str(n):flag=True;break # print(n) n-=d if flag:print("YES") else:print("NO") ```
output
1
52,441
20
104,883