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 tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has a number co...
instruction
0
35,259
20
70,518
Tags: strings Correct Solution: ``` import os,io from sys import stdout import collections # import random # import math # from operator import itemgetter input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from collections import Counter # import heapq # from functools import lru_cache # import sys # sys.setr...
output
1
35,259
20
70,519
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky...
instruction
0
35,260
20
70,520
Yes
output
1
35,260
20
70,521
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky...
instruction
0
35,261
20
70,522
Yes
output
1
35,261
20
70,523
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky...
instruction
0
35,262
20
70,524
Yes
output
1
35,262
20
70,525
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky...
instruction
0
35,263
20
70,526
Yes
output
1
35,263
20
70,527
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky...
instruction
0
35,264
20
70,528
No
output
1
35,264
20
70,529
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky...
instruction
0
35,265
20
70,530
No
output
1
35,265
20
70,531
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky...
instruction
0
35,266
20
70,532
No
output
1
35,266
20
70,533
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky...
instruction
0
35,267
20
70,534
No
output
1
35,267
20
70,535
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that i...
instruction
0
35,268
20
70,536
Tags: greedy, two pointers Correct Solution: ``` t = int(input()) for _ in range(t): s = input() ans = '' e = [] o = [] for d in s: if ord(d) % 2 == 0: e.append(d) else: o.append(d) e.append('ё') o.append('ё') i = 0 j = 0 ...
output
1
35,268
20
70,537
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that i...
instruction
0
35,269
20
70,538
Tags: greedy, two pointers Correct Solution: ``` from math import * from bisect import * from collections import Counter,defaultdict I =lambda:int(input()) SI =lambda:input() M =lambda:map(int,input().split()) LI=lambda:list(map(int,input().split())) for _ in range(I()): s = SI() e = [] o = [] for i in...
output
1
35,269
20
70,539
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that i...
instruction
0
35,270
20
70,540
Tags: greedy, two pointers Correct Solution: ``` t=int(input()) for _ in range(t): num=list(map(int,input().strip())) odd=[] evn=[] for i in num: if(i%2==0): odd+=[i] else: evn+=[i] ans=[] i=0 j=0 while(len(ans)!=len(num)): if(i==len(odd)):...
output
1
35,270
20
70,541
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that i...
instruction
0
35,271
20
70,542
Tags: greedy, two pointers Correct Solution: ``` # PARITY'S RELATIVE POSITION DOESN'T CHANGE! (PROBLEM C) def solve1(s): # return list evens = [u for u in s if u % 2 == 0] odds = [u for u in s if u % 2 == 1] if len(odds) == 0: return evens ans = [] inserted_odd = 0 current_odd = odd...
output
1
35,271
20
70,543
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that i...
instruction
0
35,272
20
70,544
Tags: greedy, two pointers Correct Solution: ``` for _ in range(int(input())): a=list(input()) n=len(a) odd=[] even=[] for i in range(n): a[i]=int(a[i]) if a[i]%2==0: odd.append(a[i]) else: even.append(a[i]) lo=len(odd) le=len(even) oi=0 ...
output
1
35,272
20
70,545
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that i...
instruction
0
35,273
20
70,546
Tags: greedy, two pointers Correct Solution: ``` n = int(input()) for _ in range(n): num = list(map(int,list(input()))) odd=[] even=[] for n in num: if n%2==0: even.append(n) else: odd.append(n) m=len(odd) n=len(even) i=j=0 res=[] while i<m and...
output
1
35,273
20
70,547
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that i...
instruction
0
35,274
20
70,548
Tags: greedy, two pointers Correct Solution: ``` """ 性質: 偶奇で分けると隣接する偶奇が違う箇所を連続している箇所まで移動できる eeeeoe ならoはeeeeの任意の位置に移動できる 数字の桁を入れ替えて最小値を作る=> 先頭が大事!なので、前から順番にできるだけ小さい数字にしていく この操作だとeoe` e`がeより左に行く(状況で跨ぐ)ことはできない=>ee`o かeoe`かoee`になる eoe'o' ee`oo` oee`o` oeo`e` oo`ee` eoo`e` eoe`o` 奇数偶数の中だと順番は変わらないから、奇数、偶数で尺取をして、小さい方を順番にいれる...
output
1
35,274
20
70,549
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that i...
instruction
0
35,275
20
70,550
Tags: greedy, two pointers Correct Solution: ``` t=int(input()) for tt in range(t): s=input().strip() even=[] odd=[] for i in s: if int(i)%2==0: even.append(int(i)) else: odd.append(int(i)) ans="" i=0 j=0 while i<len(even) and j<len(odd): if even[i]<=odd[j]: ans+=str(even[i]) i+=1 else: a...
output
1
35,275
20
70,551
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the ...
instruction
0
35,276
20
70,552
Yes
output
1
35,276
20
70,553
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the ...
instruction
0
35,277
20
70,554
Yes
output
1
35,277
20
70,555
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the ...
instruction
0
35,278
20
70,556
Yes
output
1
35,278
20
70,557
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the ...
instruction
0
35,279
20
70,558
Yes
output
1
35,279
20
70,559
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the ...
instruction
0
35,280
20
70,560
No
output
1
35,280
20
70,561
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the ...
instruction
0
35,281
20
70,562
No
output
1
35,281
20
70,563
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the ...
instruction
0
35,282
20
70,564
No
output
1
35,282
20
70,565
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the ...
instruction
0
35,283
20
70,566
No
output
1
35,283
20
70,567
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is...
instruction
0
35,445
20
70,890
No
output
1
35,445
20
70,891
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is...
instruction
0
35,446
20
70,892
No
output
1
35,446
20
70,893
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is...
instruction
0
35,447
20
70,894
No
output
1
35,447
20
70,895
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is...
instruction
0
35,448
20
70,896
No
output
1
35,448
20
70,897
Provide a correct Python 3 solution for this coding contest problem. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are two consecutive 0s at the end. Write a program that input...
instruction
0
35,897
20
71,794
"Correct Solution: ``` import math p=1 q=1 while p==1: o=0 n=int(input()) if n==0: break else: x=math.factorial(n) while q==1: y=x%10 if y==0: o+=1 x=x//10 else: break print(o) ```
output
1
35,897
20
71,795
Provide a correct Python 3 solution for this coding contest problem. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are two consecutive 0s at the end. Write a program that input...
instruction
0
35,898
20
71,796
"Correct Solution: ``` # coding: utf-8 # Your code here! import math while True: n = int(input()) if n == 0: break i = 0 n = str(math.factorial(n))[::-1] while n[i] == '0': i += 1 print(i) ```
output
1
35,898
20
71,797
Provide a correct Python 3 solution for this coding contest problem. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are two consecutive 0s at the end. Write a program that input...
instruction
0
35,899
20
71,798
"Correct Solution: ``` for e in iter(input,'0'): e=int(e) print(sum(e//5**i for i in range(1,7))) ```
output
1
35,899
20
71,799
Provide a correct Python 3 solution for this coding contest problem. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are two consecutive 0s at the end. Write a program that input...
instruction
0
35,900
20
71,800
"Correct Solution: ``` while True: n=int(input()) if n==0: break ans=0 t=5 while t<=20000: ans+=n//t t*=5 print(ans) ```
output
1
35,900
20
71,801
Provide a correct Python 3 solution for this coding contest problem. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are two consecutive 0s at the end. Write a program that input...
instruction
0
35,901
20
71,802
"Correct Solution: ``` def fac(n): if n==0 or n==1:return 1 e=1 for i in range(1,n+1): e*=i return e zero=lambda t:len(t)-max([t.rfind(str(i)) for i in range(1,10)])-1 r=[] while 1: p=int(input()) if not p:break r.extend([zero(str(fac(p)))]) [print(i) for i in r] ```
output
1
35,901
20
71,803
Provide a correct Python 3 solution for this coding contest problem. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are two consecutive 0s at the end. Write a program that input...
instruction
0
35,902
20
71,804
"Correct Solution: ``` import re def fac(n): s = 1 for i in range(1,n+1): s *= i return(s) while True: n = int(input().strip()) if n==0: break num_str = '%d' % fac(n) zeros = re.sub(r'.*[^0](0*)$', '\\1', num_str) print(len(zeros)) ```
output
1
35,902
20
71,805
Provide a correct Python 3 solution for this coding contest problem. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are two consecutive 0s at the end. Write a program that input...
instruction
0
35,903
20
71,806
"Correct Solution: ``` import math while True: n=int(input()) if n==0: break a=math.factorial(n) b=str(a) m=len(b) c=0 for i in range(m-1,-1,-1): if b[i]=='0': c+=1 else: break print(c) ```
output
1
35,903
20
71,807
Provide a correct Python 3 solution for this coding contest problem. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are two consecutive 0s at the end. Write a program that input...
instruction
0
35,904
20
71,808
"Correct Solution: ``` while True: n = int(input()) if n==0: break N = 1 for i in range(1,n+1,1): N *= i zero = 0 while True: if N%10 > 0: break N = N//10 zero += 1 print(zero) ```
output
1
35,904
20
71,809
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are tw...
instruction
0
35,905
20
71,810
Yes
output
1
35,905
20
71,811
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are tw...
instruction
0
35,906
20
71,812
Yes
output
1
35,906
20
71,813
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are tw...
instruction
0
35,907
20
71,814
Yes
output
1
35,907
20
71,815
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are tw...
instruction
0
35,908
20
71,816
Yes
output
1
35,908
20
71,817
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are tw...
instruction
0
35,909
20
71,818
No
output
1
35,909
20
71,819
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are tw...
instruction
0
35,910
20
71,820
No
output
1
35,910
20
71,821
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are tw...
instruction
0
35,911
20
71,822
No
output
1
35,911
20
71,823
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 Is called the factorial of n. For example, the factorial of 12 12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600 And there are tw...
instruction
0
35,912
20
71,824
No
output
1
35,912
20
71,825
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not. You are given a segment [L; R]. Co...
instruction
0
35,998
20
71,996
Tags: combinatorics, dp Correct Solution: ``` import os import sys from io import BytesIO, IOBase # 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...
output
1
35,998
20
71,997
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not. You are given a segment [L; R]. Co...
instruction
0
35,999
20
71,998
Tags: combinatorics, dp Correct Solution: ``` import sys class Solution(): mem = dict() def classy_Numbers(self): T = int(sys.stdin.readline().strip()) self.queries = [] for t in range(T): left, right = list(map(int, sys.stdin.readline().strip().split())) print(s...
output
1
35,999
20
71,999
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not. You are given a segment [L; R]. Co...
instruction
0
36,000
20
72,000
Tags: combinatorics, dp Correct Solution: ``` import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): retu...
output
1
36,000
20
72,001
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not. You are given a segment [L; R]. Co...
instruction
0
36,001
20
72,002
Tags: combinatorics, dp Correct Solution: ``` from sys import stdin C = [[0] * 20 for _ in range(20)] for i in range(20): C[i][0] = C[i][i] = 1 for j in range(1, i): C[i][j] = C[i - 1][j] + C[i - 1][j - 1] pw = [1, 9, 81, 729] def get(n, lft): return sum(C[n][i] * pw[i] for i in range(lft + 1) i...
output
1
36,001
20
72,003
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not. You are given a segment [L; R]. Co...
instruction
0
36,002
20
72,004
Tags: combinatorics, dp Correct Solution: ``` def f(n): if n == 0: return 1 dp = [[[0] * 2 for j in range(4)] for z in range(len(n))] dp[0][3][0] = 1 dp[0][2][0] = int(n[0]) - 1 dp[0][2][1] = 1 for i in range(1, len(n)): for j in range(4): if n[i] == '0': ...
output
1
36,002
20
72,005