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. 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 an...
instruction
0
63,473
20
126,946
Tags: math, number theory Correct Solution: ``` 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=(1000...
output
1
63,473
20
126,947
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 an...
instruction
0
63,474
20
126,948
Tags: math, number theory Correct Solution: ``` 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 ...
output
1
63,474
20
126,949
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 an...
instruction
0
63,475
20
126,950
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','...
output
1
63,475
20
126,951
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 an...
instruction
0
63,476
20
126,952
Tags: math, number theory Correct Solution: ``` # Legends Always Come Up with Solution # Author: Manvir Singh import os from io import BytesIO, IOBase import sys from itertools import permutations from collections import Counter def main(): a=input().rstrip() n=len(a) a=Counter(a) for i in"6189": ...
output
1
63,476
20
126,953
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 an...
instruction
0
63,477
20
126,954
Tags: math, number theory Correct Solution: ``` ######### ## ## ## #### ##### ## # ## # ## # # # # # # # # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # ##### # # # # ### # # # # # # # # ##### # # # # # #...
output
1
63,477
20
126,955
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. ...
instruction
0
63,478
20
126,956
No
output
1
63,478
20
126,957
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. ...
instruction
0
63,479
20
126,958
No
output
1
63,479
20
126,959
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. ...
instruction
0
63,480
20
126,960
No
output
1
63,480
20
126,961
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. ...
instruction
0
63,481
20
126,962
No
output
1
63,481
20
126,963
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 ...
instruction
0
63,498
20
126,996
Tags: binary search, constructive algorithms, math Correct Solution: ``` a=int(input()) b,c=10**35,a-45*35*10**34%a print(c,c+b-1) ```
output
1
63,498
20
126,997
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 ...
instruction
0
63,499
20
126,998
Tags: binary search, constructive algorithms, math Correct Solution: ``` a = int(input()) g = 45 * (10 ** 19) * 20 g = a + (a - g) % a print(g, 10 ** 20 + g - 1) ```
output
1
63,499
20
126,999
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 ...
instruction
0
63,500
20
127,000
Tags: binary search, constructive algorithms, math Correct Solution: ``` m = int(input()) x,t=10**100-1,m-100*45*10**99%m print(t,t+x) ```
output
1
63,500
20
127,001
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 ...
instruction
0
63,501
20
127,002
Tags: binary search, constructive algorithms, math Correct Solution: ``` from math import inf as inf from math import * from collections import * import sys from itertools import permutations input=sys.stdin.readline t=1 while(t): t-=1 n=int(input()) f=n-45*20*(10**19)%n print(f,f+(10**20-1)) ```
output
1
63,501
20
127,003
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 ...
instruction
0
63,502
20
127,004
Tags: binary search, constructive algorithms, math Correct Solution: ``` a=int(input()) b,c=10**100,a-4500*10**99%a print(c,c+b-1) ```
output
1
63,502
20
127,005
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 ...
instruction
0
63,503
20
127,006
Tags: binary search, constructive algorithms, math Correct Solution: ``` __author__ = 'andybear' m=int(input()) x,t=10**100-1,m-100*45*10**99%m print(t,t+x) ```
output
1
63,503
20
127,007
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 ...
instruction
0
63,504
20
127,008
Tags: binary search, constructive algorithms, math Correct Solution: ``` a = int(input()) k = 19 x = (45 * k * 10**(k-1))% a l = a - x r = l + 10**k - 1 print(l, r) ```
output
1
63,504
20
127,009
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 <imag...
instruction
0
63,505
20
127,010
No
output
1
63,505
20
127,011
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 <imag...
instruction
0
63,506
20
127,012
No
output
1
63,506
20
127,013
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 <imag...
instruction
0
63,507
20
127,014
No
output
1
63,507
20
127,015
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 <imag...
instruction
0
63,508
20
127,016
No
output
1
63,508
20
127,017
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following questions. He can say a pair of non-negative integ...
instruction
0
64,006
20
128,012
Tags: binary search, constructive algorithms, interactive Correct Solution: ``` a=input() while a!="end": if a=="start": for i in range(30): print("?",2**i,2*2**i) if input()=="x": break bot=2**i top=min(2**(i+1),1000000000) if bot==1: ...
output
1
64,006
20
128,013
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following questions. He can say a pair of non-negative integ...
instruction
0
64,007
20
128,014
Tags: binary search, constructive algorithms, interactive Correct Solution: ``` from sys import stdout def ask(x, y): print('?', x, y) stdout.flush() x = input() return x == 'x' def show_res(res): print('!', res) stdout.flush() def prepare_game(): gm = input() if gm[0] != 's': exit(0) INF = int(1e9) + 1 ...
output
1
64,007
20
128,015
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following questions. He can say a pair of non-negative integ...
instruction
0
64,008
20
128,016
Tags: binary search, constructive algorithms, interactive Correct Solution: ``` #Code by Sounak, IIESTS #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase import io from fractions import Fraction import collections from itertools import per...
output
1
64,008
20
128,017
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following questions. He can say a pair of non-negative integ...
instruction
0
64,009
20
128,018
Tags: binary search, constructive algorithms, interactive Correct Solution: ``` from sys import stdout def ask(x,y) : print('?',x,y) stdout.flush() return input() == 'x' def work() : if ask(0, 1) : return 1 l = 1 while ask(l*2,l) : l*=2 r = min(1000000000, l*2+1) l += 1 while r > l...
output
1
64,009
20
128,019
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following questions. He can say a pair of non-negative integ...
instruction
0
64,010
20
128,020
Tags: binary search, constructive algorithms, interactive Correct Solution: ``` import sys def question(x, y, a): #a = 1543 if x % a >= y % a: return "x" else: return "y" def real_question(x, y): print("? {0} {1}".format(x, y)) sys.stdout.flush() return input() class Codefo...
output
1
64,010
20
128,021
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following questions. He can say a pair of non-negative integ...
instruction
0
64,011
20
128,022
Tags: binary search, constructive algorithms, interactive Correct Solution: ``` import sys def ask(x, y): print("?", x, y) return input() == "y" while input() == "start": if not ask(0, 1): print("! 1") continue d = 1 while ask(d, d * 2): d *= 2 r = d l = d // 2 ...
output
1
64,011
20
128,023
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following que...
instruction
0
64,012
20
128,024
No
output
1
64,012
20
128,025
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following que...
instruction
0
64,013
20
128,026
No
output
1
64,013
20
128,027
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following que...
instruction
0
64,014
20
128,028
No
output
1
64,014
20
128,029
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following que...
instruction
0
64,015
20
128,030
No
output
1
64,015
20
128,031
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tokitsukaze is playing a room escape game designed by SkywalkerT. In this game, she needs to find out hidden clues in the room to reveal a way to escape. After a while, she realizes that the on...
instruction
0
64,064
20
128,128
No
output
1
64,064
20
128,129
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tokitsukaze is playing a room escape game designed by SkywalkerT. In this game, she needs to find out hidden clues in the room to reveal a way to escape. After a while, she realizes that the on...
instruction
0
64,065
20
128,130
No
output
1
64,065
20
128,131
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tokitsukaze is playing a room escape game designed by SkywalkerT. In this game, she needs to find out hidden clues in the room to reveal a way to escape. After a while, she realizes that the on...
instruction
0
64,066
20
128,132
No
output
1
64,066
20
128,133
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. Let next(x) be the mi...
instruction
0
64,067
20
128,134
Tags: implementation Correct Solution: ``` #!/usr/bin/env python from __future__ import division, print_function import math import os import sys from fractions import * from sys import * from decimal import * from io import BytesIO, IOBase from itertools import * from collections import * # sys.setrecursionlimit(10**...
output
1
64,067
20
128,135
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. Let next(x) be the mi...
instruction
0
64,068
20
128,136
Tags: implementation Correct Solution: ``` n = (input()).split() l = int(n[0]) r = int(n[1]) a = [] x = [] a.append([]) a[0].append('4') a[0].append('7') for i in range(1,10): a.append([]) for j in a[i-1]: a[i].append('4'+j) a[i].append('7'+j) for j in a[i]: x.append(int(j...
output
1
64,068
20
128,137
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. Let next(x) be the mi...
instruction
0
64,069
20
128,138
Tags: implementation Correct Solution: ``` lucky = [4, 7] n = 1 length = 0 while n < 10: check = lucky[length:(length+2**(n))] for x in check: lucky.append(int("4"+ str(x))) for x in check: lucky.append(int("7"+str(x))) length += 2**n n += 1 l, r = map(int, input().split()) ans = 0 i...
output
1
64,069
20
128,139
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. Let next(x) be the mi...
instruction
0
64,070
20
128,140
Tags: implementation Correct Solution: ``` l,r = [int(x) for x in input().strip().split()] def next(n,k): s = n n = int(n) if int("4"*k)>=n: return "4"*k elif int("7"*k)<n: return "4"*(k+1) elif 4<int(s[0])<7: return "7"+"4"*(k-1) if not s[1:]=="": a = next(s[1:],k-1) if s[0]=="4": if len(str(a))...
output
1
64,070
20
128,141
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. Let next(x) be the mi...
instruction
0
64,071
20
128,142
Tags: implementation Correct Solution: ``` def f(a,x): if x//1e10>0: return a.append(x) f(a,x*10+4) f(a,x*10+7) a,ans,i=[],0,0 f(a,4) f(a,7) a.sort() L,R=map(int,input().split()) while L<=R: while L>a[i]:i+=1 ans+=a[i]*(min(a[i],R)-L+1) L=a[i]+1 print(ans) ```
output
1
64,071
20
128,143
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. Let next(x) be the mi...
instruction
0
64,072
20
128,144
Tags: implementation Correct Solution: ``` lucky=[] MAX=10000000000 def func(s): s=s*10 if s>MAX: return lucky.append(s+4) lucky.append(s+7) func(s+4) func(s+7) func(0) lucky.sort() l,r=[int(x) for x in input().split(' ')] i=0 j=0 while(l>lucky[i]): i+=1 while(r>lucky[j]): j+=1 ans=0 for x in range(i+1,j+1...
output
1
64,072
20
128,145
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. Let next(x) be the mi...
instruction
0
64,073
20
128,146
Tags: implementation Correct Solution: ``` def ii(): return int(input()) def si(): return input() def mi(): return map(int,input().split()) def li(): return list(mi()) import math le,r=mi() l=[] def F(x): l.append(x) if x>r*10:return F(10*x+4) F(10*x+7) F(0) l.sort() s=0 i=le-1 j=0 while(i<...
output
1
64,073
20
128,147
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. Let next(x) be the mi...
instruction
0
64,074
20
128,148
Tags: implementation Correct Solution: ``` from itertools import product all_lucky = [('0')] for i in range(1, 11): all_lucky += list(product('47', repeat=i)) all_lucky = [int("".join(x)) for x in all_lucky] all_lucky.sort() left, right = map(int, input().split()) result = 0 prev = left pos = 0 while all_luck...
output
1
64,074
20
128,149
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
64,075
20
128,150
Yes
output
1
64,075
20
128,151
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
64,076
20
128,152
Yes
output
1
64,076
20
128,153
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
64,077
20
128,154
Yes
output
1
64,077
20
128,155
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
64,078
20
128,156
Yes
output
1
64,078
20
128,157
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
64,079
20
128,158
No
output
1
64,079
20
128,159
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
64,080
20
128,160
No
output
1
64,080
20
128,161
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
64,081
20
128,162
No
output
1
64,081
20
128,163
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
64,082
20
128,164
No
output
1
64,082
20
128,165
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses ("+") in the line between certain digits in...
instruction
0
64,381
20
128,762
Tags: combinatorics, dp, math, number theory Correct Solution: ``` n, k = map(int, input().split()) t = list(map(int, input())) p, d = 1, 10**9 + 7 s = 0 f = [1] * n for i in range(2, n): f[i] = (i * f[i - 1]) % d c = lambda a, b: 0 if a > b else (f[b] * pow(f[a] * f[b -a], d - 2, d)) % d if k: u = [0] * (n + 1) ...
output
1
64,381
20
128,763