message
stringlengths
2
57.2k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
61
108k
cluster
float64
22
22
__index_level_0__
int64
122
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of uni...
instruction
0
26,152
22
52,304
Tags: implementation, math, number theory Correct Solution: ``` def main(): n, m = [int(v) for v in input().split()] d = 1 for i in range(1, min(n,m)+1): d*=i print(d) if __name__ == "__main__": main() ```
output
1
26,152
22
52,305
Provide tags and a correct Python 3 solution for this coding contest problem. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of uni...
instruction
0
26,153
22
52,306
Tags: implementation, math, number theory Correct Solution: ``` from math import factorial n,m=map(int,input().split()) print(factorial(min(n,m))) #print(' '.join([str(i) for i in a])) ```
output
1
26,153
22
52,307
Provide tags and a correct Python 3 solution for this coding contest problem. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of uni...
instruction
0
26,154
22
52,308
Tags: implementation, math, number theory Correct Solution: ``` a, b = input().split() a = int(a) b = int(b) s = 1 if a >= b: for i in range(1,b+1): s = s * i else: for i in range(1,a+1): s = s * i print(s) ```
output
1
26,154
22
52,309
Provide tags and a correct Python 3 solution for this coding contest problem. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of uni...
instruction
0
26,155
22
52,310
Tags: implementation, math, number theory Correct Solution: ``` from math import factorial a,b=tuple(input().split()) a=int(a) b=int(b) print(factorial(min(a,b))) ```
output
1
26,155
22
52,311
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provid...
instruction
0
26,156
22
52,312
Yes
output
1
26,156
22
52,313
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provid...
instruction
0
26,157
22
52,314
Yes
output
1
26,157
22
52,315
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provid...
instruction
0
26,158
22
52,316
Yes
output
1
26,158
22
52,317
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provid...
instruction
0
26,159
22
52,318
Yes
output
1
26,159
22
52,319
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provid...
instruction
0
26,160
22
52,320
No
output
1
26,160
22
52,321
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provid...
instruction
0
26,161
22
52,322
No
output
1
26,161
22
52,323
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provid...
instruction
0
26,162
22
52,324
No
output
1
26,162
22
52,325
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provid...
instruction
0
26,163
22
52,326
No
output
1
26,163
22
52,327
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers a_1, a_2, ..., a_n. Your problem is to find such pair of indices i, j (1 ≤ i < j ≤ n) that lcm(a_i, a_j) is minimum possible. lcm(x, y) is the least common multiple of x and y (minimum posi...
instruction
0
26,614
22
53,228
Tags: brute force, greedy, math, number theory Correct Solution: ``` # by the authority of GOD author: manhar singh sachdev # import os,sys from io import BytesIO, IOBase from array import array def main(): INF = 10**18 n = int(input()) a = list(map(int,input().split())) lim = max(a)+1 counter...
output
1
26,614
22
53,229
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers a_1, a_2, ..., a_n. Your problem is to find such pair of indices i, j (1 ≤ i < j ≤ n) that lcm(a_i, a_j) is minimum possible. lcm(x, y) is the least common multiple of x and y (minimum posi...
instruction
0
26,615
22
53,230
Tags: brute force, greedy, math, number theory Correct Solution: ``` import math from collections import defaultdict import sys input = sys.stdin.readline def main(): n = int(input()) a = list(map(int, input().split())) MAX = 10**7 + 1 res = MAX * MAX #MAX_P = int(math.sqrt(MAX)) MAX_P = 316...
output
1
26,615
22
53,231
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers a_1, a_2, ..., a_n. Your problem is to find such pair of indices i, j (1 ≤ i < j ≤ n) that lcm(a_i, a_j) is minimum possible. lcm(x, y) is the...
instruction
0
26,617
22
53,234
No
output
1
26,617
22
53,235
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers a_1, a_2, ..., a_n. Your problem is to find such pair of indices i, j (1 ≤ i < j ≤ n) that lcm(a_i, a_j) is minimum possible. lcm(x, y) is the...
instruction
0
26,618
22
53,236
No
output
1
26,618
22
53,237
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers a_1, a_2, ..., a_n. Your problem is to find such pair of indices i, j (1 ≤ i < j ≤ n) that lcm(a_i, a_j) is minimum possible. lcm(x, y) is the...
instruction
0
26,619
22
53,238
No
output
1
26,619
22
53,239
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers a_1, a_2, ..., a_n. Your problem is to find such pair of indices i, j (1 ≤ i < j ≤ n) that lcm(a_i, a_j) is minimum possible. lcm(x, y) is the...
instruction
0
26,620
22
53,240
No
output
1
26,620
22
53,241
Provide tags and a correct Python 3 solution for this coding contest problem. It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n. You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that: * a_1 + a_2 + … + a_k = n * LCM(a_1, a_2, …, a_k) ...
instruction
0
26,758
22
53,516
Tags: constructive algorithms, math Correct Solution: ``` for _ in range(int(input())): n,k=map(int,input().split()) b=[1]*(k-3) n-=(k-3) if n%3==0: b.append(n//3) b.append(n//3) b.append(n//3) else: if n%2!=0: b.append(1) b.append((n-1)//2) ...
output
1
26,758
22
53,517
Provide tags and a correct Python 3 solution for this coding contest problem. It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n. You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that: * a_1 + a_2 + … + a_k = n * LCM(a_1, a_2, …, a_k) ...
instruction
0
26,759
22
53,518
Tags: constructive algorithms, math Correct Solution: ``` for nt in range(int(input())): n, k = map(int,input().split()) ans = [1]*(k-3) n -= (k-3) if n%2: ans.extend([1, n//2, n//2]) else: if n//2%2: ans.extend([2, n//2-1, n//2-1]) else: ans.extend([n//2, n//4, n//4]) print (*ans) ```
output
1
26,759
22
53,519
Provide tags and a correct Python 3 solution for this coding contest problem. It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n. You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that: * a_1 + a_2 + … + a_k = n * LCM(a_1, a_2, …, a_k) ...
instruction
0
26,760
22
53,520
Tags: constructive algorithms, math Correct Solution: ``` import sys from sys import stdout import bisect as bi import math from collections import defaultdict as dd from types import GeneratorType ##import queue ##from heapq import heapify, heappush, heappop ##import itertools ##import io ##import os ##import operato...
output
1
26,760
22
53,521
Provide tags and a correct Python 3 solution for this coding contest problem. It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n. You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that: * a_1 + a_2 + … + a_k = n * LCM(a_1, a_2, …, a_k) ...
instruction
0
26,761
22
53,522
Tags: constructive algorithms, math Correct Solution: ``` for _ in range(int(input())): n, m = map(int, input().split()) n -= (m - 3) if n % 2 == 1: print(n // 2, n // 2, 1, end=' ') elif n % 4 == 2: print(n // 2 - 1, n // 2 - 1, 2, end=' ') else: print(n // 2, n // 4, n // 4...
output
1
26,761
22
53,523
Provide tags and a correct Python 3 solution for this coding contest problem. It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n. You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that: * a_1 + a_2 + … + a_k = n * LCM(a_1, a_2, …, a_k) ...
instruction
0
26,762
22
53,524
Tags: constructive algorithms, math Correct Solution: ``` import sys input = sys.stdin.readline for _ in range(int(input())): n, k = map(int, input().split()) n -= (k - 3) if n % 2: print(n // 2, n // 2, 1, *[1 for i in range(k - 3)]) else: if n % 4: print(n // 2 - 1, n // ...
output
1
26,762
22
53,525
Provide tags and a correct Python 3 solution for this coding contest problem. It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n. You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that: * a_1 + a_2 + … + a_k = n * LCM(a_1, a_2, …, a_k) ...
instruction
0
26,763
22
53,526
Tags: constructive algorithms, math Correct Solution: ``` from sys import stdin # input=stdin.buffer.readline input=lambda : stdin.readline().strip() lin=lambda :list(map(int,input().split())) iin=lambda :int(input()) main=lambda :map(int,input().split()) from math import ceil,sqrt,factorial,log from collections import...
output
1
26,763
22
53,527
Provide tags and a correct Python 3 solution for this coding contest problem. It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n. You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that: * a_1 + a_2 + … + a_k = n * LCM(a_1, a_2, …, a_k) ...
instruction
0
26,764
22
53,528
Tags: constructive algorithms, math Correct Solution: ``` import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bis...
output
1
26,764
22
53,529
Provide tags and a correct Python 3 solution for this coding contest problem. It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n. You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that: * a_1 + a_2 + … + a_k = n * LCM(a_1, a_2, …, a_k) ...
instruction
0
26,765
22
53,530
Tags: constructive algorithms, math Correct Solution: ``` from collections import Counter t = int(input()) for _ in range(t): n,k = map(int, input().split()) for i in range(k-3): print(1,end=" ") n = n- (k-3) k =3 if(n%2 == 0): q = n//2 if(q %2 != 0): print(2,q-1,...
output
1
26,765
22
53,531
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n. You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that: * a_1 ...
instruction
0
26,769
22
53,538
Yes
output
1
26,769
22
53,539
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n. You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that: * a_1 ...
instruction
0
26,770
22
53,540
No
output
1
26,770
22
53,541
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a of n integers. You want to make all elements of a equal to zero by doing the following operation exactly three times: * Select a segment, for each number in this segment we can add a multiple of len to it, where ...
instruction
0
27,608
22
55,216
Tags: constructive algorithms, greedy, number theory Correct Solution: ``` import sys #comment these out later #sys.stdin = open("in.in", "r") #sys.stdout = open("out.out", "w") import operator as op from functools import reduce def gcd(x, y): """greatest common divisor of x and y""" while y: x, y =...
output
1
27,608
22
55,217
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he c...
instruction
0
27,772
22
55,544
Yes
output
1
27,772
22
55,545
Provide a correct Python 3 solution for this coding contest problem. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integers a, b and c are given in a line separated by a single...
instruction
0
28,236
22
56,472
"Correct Solution: ``` a,b,c=map(int,input().split()) yaku=0 for i in range(a,b+1): if(c%i==0): yaku+=1 print(yaku) ```
output
1
28,236
22
56,473
Provide a correct Python 3 solution for this coding contest problem. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integers a, b and c are given in a line separated by a single...
instruction
0
28,237
22
56,474
"Correct Solution: ``` a, b, num = map(int, input().split()) print(len([i for i in range(a, b+1) if num%i == 0])) ```
output
1
28,237
22
56,475
Provide a correct Python 3 solution for this coding contest problem. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integers a, b and c are given in a line separated by a single...
instruction
0
28,238
22
56,476
"Correct Solution: ``` a,b,c=map(int,input().split()) print(len([x for x in range(a,b+1)if c%x==0])) ```
output
1
28,238
22
56,477
Provide a correct Python 3 solution for this coding contest problem. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integers a, b and c are given in a line separated by a single...
instruction
0
28,239
22
56,478
"Correct Solution: ``` a,b,c=map(int,input().split()) n=0 for i in range(a,b+1): if (c%i)==0: n+=1 print(n) ```
output
1
28,239
22
56,479
Provide a correct Python 3 solution for this coding contest problem. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integers a, b and c are given in a line separated by a single...
instruction
0
28,240
22
56,480
"Correct Solution: ``` cnt=0 a,b,c=map(int,input().split()) for i in range(a,b+1): if (c%i==0): cnt+=1 print(cnt) ```
output
1
28,240
22
56,481
Provide a correct Python 3 solution for this coding contest problem. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integers a, b and c are given in a line separated by a single...
instruction
0
28,241
22
56,482
"Correct Solution: ``` a, b, c = [int(i) for i in input().split()] print(len([i for i in range(a, b+1) if c % i == 0])) ```
output
1
28,241
22
56,483
Provide a correct Python 3 solution for this coding contest problem. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integers a, b and c are given in a line separated by a single...
instruction
0
28,242
22
56,484
"Correct Solution: ``` a, b, c = map(int, input().split()) ans = 0 for i in range(a, b+1): ans += c // i * i == c print(ans) ```
output
1
28,242
22
56,485
Provide a correct Python 3 solution for this coding contest problem. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integers a, b and c are given in a line separated by a single...
instruction
0
28,243
22
56,486
"Correct Solution: ``` a,b,c=map(int, input().split()) print(sum(c%i==0 for i in range(a,b+1))) ```
output
1
28,243
22
56,487
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integ...
instruction
0
28,244
22
56,488
Yes
output
1
28,244
22
56,489
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integ...
instruction
0
28,245
22
56,490
Yes
output
1
28,245
22
56,491
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integ...
instruction
0
28,246
22
56,492
Yes
output
1
28,246
22
56,493
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integ...
instruction
0
28,247
22
56,494
Yes
output
1
28,247
22
56,495
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integ...
instruction
0
28,248
22
56,496
No
output
1
28,248
22
56,497
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integ...
instruction
0
28,249
22
56,498
No
output
1
28,249
22
56,499
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integ...
instruction
0
28,250
22
56,500
No
output
1
28,250
22
56,501
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. How Many Divisors? Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. Constraints * 1 ≤ a, b, c ≤ 10000 * a ≤ b Input Three integ...
instruction
0
28,251
22
56,502
No
output
1
28,251
22
56,503
Provide tags and a correct Python 3 solution for this coding contest problem. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum number of the i-th row is 1 (1 ≤ i ≤ n). * Mini...
instruction
0
28,356
22
56,712
Tags: combinatorics, dp, math Correct Solution: ``` import sys input = sys.stdin.readline n,k=map(int,input().split()) mod=10**9+7 FACT=[1] for i in range(1,250+1): FACT.append(FACT[-1]*i%mod) FACT_INV=[pow(FACT[-1],mod-2,mod)] for i in range(250,0,-1): FACT_INV.append(FACT_INV[-1]*i%mod) FACT_INV.rever...
output
1
28,356
22
56,713
Provide tags and a correct Python 3 solution for this coding contest problem. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum number of the i-th row is 1 (1 ≤ i ≤ n). * Mini...
instruction
0
28,357
22
56,714
Tags: combinatorics, dp, math Correct Solution: ``` n, k = map(int, input().split()) MOD = 10**9 + 7 Comb = [None] * (n + 1) dp = [[None] * (n + 1) for i in range(n+1)] for i in range(1, n + 1): Comb[i] = [1] + [(Comb[i-1][j-1] + Comb[i-1][j]) % MOD for j in range(1, i)] + [1] def powgen(base): cur = 1 while Tru...
output
1
28,357
22
56,715
Provide tags and a correct Python 3 solution for this coding contest problem. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum number of the i-th row is 1 (1 ≤ i ≤ n). * Mini...
instruction
0
28,358
22
56,716
Tags: combinatorics, dp, math Correct Solution: ``` def main(): # Basic construction MOD = 10**9 + 7 # MOD n, k = [int(c) for c in input().split()] f = [[None for j in range(n+1)] for i in range(n+1)] if k==1: return 1 # Edge case # nCr nCr = [[0 for j in range(i+1)] for i in range(n+1)] ...
output
1
28,358
22
56,717
Provide tags and a correct Python 3 solution for this coding contest problem. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum number of the i-th row is 1 (1 ≤ i ≤ n). * Mini...
instruction
0
28,360
22
56,720
Tags: combinatorics, dp, math Correct Solution: ``` n, k = [int(item) for item in input().split()] MOD = 10**9 + 7 MAX_N = 10**4 fac = [1] + [0] * MAX_N fac_inv = [1] + [0] * MAX_N for i in range(1, n+1): fac[i] = fac[i-1] * (i) % MOD fac_inv[i] = fac_inv[i-1] * pow(i, MOD-2, MOD) % MOD def mod_nCr(n, r): ...
output
1
28,360
22
56,721