message
stringlengths
2
28.7k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
21
109k
cluster
float64
7
7
__index_level_0__
int64
42
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area. To prove his skills, Ivan decided to d...
instruction
0
80,025
7
160,050
Tags: combinatorics, dp, math Correct Solution: ``` n,m=map(int,input().split()) a=[0]*100001 Mod=1000000007 a[1],a[2]=2,4 for i in range(3,max(n,m)+1): a[i]=(a[i-1]+a[i-2])%Mod print((a[n]+a[m]-2)%Mod,flush=False) ```
output
1
80,025
7
160,051
Provide tags and a correct Python 3 solution for this coding contest problem. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area. To prove his skills, Ivan decided to d...
instruction
0
80,026
7
160,052
Tags: combinatorics, dp, math Correct Solution: ``` MOD = 10 ** 9 + 7 n, m = map(int, input().split()) fib = [1] * (max(n, m) + 2) for i in range(2, max(n, m) + 2): fib[i] = fib[i - 1] + fib[i - 2] fib[i] %= MOD print(((fib[m] + fib[n]) * 2 - 2) % MOD) ```
output
1
80,026
7
160,053
Provide tags and a correct Python 3 solution for this coding contest problem. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area. To prove his skills, Ivan decided to d...
instruction
0
80,027
7
160,054
Tags: combinatorics, dp, math Correct Solution: ``` n, m = map(int, input().split()) mod = 10**9+7 a = [] a.append(0) a.append(2) a.append(4) for i in range(3, max(n, m)+1): a.append((a[i-1]+a[i-2])%mod) print((a[m]-2 + a[n])%mod) ```
output
1
80,027
7
160,055
Provide tags and a correct Python 3 solution for this coding contest problem. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area. To prove his skills, Ivan decided to d...
instruction
0
80,028
7
160,056
Tags: combinatorics, dp, math Correct Solution: ``` r=[int(x) for x in input().split()] fibonacci=[0 for i in range(100001)] fibonacci[0]=1 fibonacci[1]=1 for i in range(99999): fibonacci[i+2]=(fibonacci[i+1]+fibonacci[i]) % 1000000007 print(((2*((fibonacci[r[0]]+fibonacci[r[1]]) % 1000000007)-2+1000000007) % 10000...
output
1
80,028
7
160,057
Provide tags and a correct Python 3 solution for this coding contest problem. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area. To prove his skills, Ivan decided to d...
instruction
0
80,029
7
160,058
Tags: combinatorics, dp, math Correct Solution: ``` n, m = map(int, input().split()) dp0n = 1 dp1n = 1 dp0m = 1 dp1m = 1 dpn, dpm = 2, 2 for i in range(3, n + 1): dp0n, dp1n, dpn = dp1n % 1000000007, dpn % 1000000007, (dpn + dp1n) % 1000000007 for i in range(3, m + 1): dp0m, dp1m, dpm = dp1m % 10000000...
output
1
80,029
7
160,059
Provide tags and a correct Python 3 solution for this coding contest problem. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area. To prove his skills, Ivan decided to d...
instruction
0
80,030
7
160,060
Tags: combinatorics, dp, math Correct Solution: ``` def main(): mod = 1000000007 a = [1,1,1] b = [1,1,1] c = [1,1,1] a[1] = 2 a[2] = 4 b[1] = 0 b[2] = 2 c[1] = 0 c[2] = 2 for i in range(3,100001): a.append(a[i-1]+a[i-2]) a[i] %= mod b.append(b[i-1]+b[i...
output
1
80,030
7
160,061
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in tha...
instruction
0
80,031
7
160,062
Yes
output
1
80,031
7
160,063
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in tha...
instruction
0
80,032
7
160,064
Yes
output
1
80,032
7
160,065
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in tha...
instruction
0
80,033
7
160,066
Yes
output
1
80,033
7
160,067
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in tha...
instruction
0
80,034
7
160,068
Yes
output
1
80,034
7
160,069
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in tha...
instruction
0
80,035
7
160,070
No
output
1
80,035
7
160,071
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in tha...
instruction
0
80,036
7
160,072
No
output
1
80,036
7
160,073
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in tha...
instruction
0
80,037
7
160,074
No
output
1
80,037
7
160,075
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in tha...
instruction
0
80,038
7
160,076
No
output
1
80,038
7
160,077
Provide tags and a correct Python 3 solution for this coding contest problem. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to t...
instruction
0
80,443
7
160,886
Tags: constructive algorithms, implementation Correct Solution: ``` import sys n, m, k = [int(x) for x in input().split()] L, C = [(-1, 0) for i in range(n)], [(-1, 0) for i in range(m)] for i, line in enumerate(sys.stdin): t, r, c = [int(x) for x in line.split()] if t == 1: L[r-1] = (i, c) else: ...
output
1
80,443
7
160,887
Provide tags and a correct Python 3 solution for this coding contest problem. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to t...
instruction
0
80,444
7
160,888
Tags: constructive algorithms, implementation Correct Solution: ``` from sys import stdin def main(): n, m, q = map(int, stdin.readline().split()) rid = [-1] * n rc = [-1] * n cid = [-1] * m cc = [-1] * m for i in range(q): t, x, y = map(int, stdin.readline().split()) if t == 1...
output
1
80,444
7
160,889
Provide tags and a correct Python 3 solution for this coding contest problem. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to t...
instruction
0
80,445
7
160,890
Tags: constructive algorithms, implementation Correct Solution: ``` def fill_column(num, color): global canvas for i in range(n): canvas[i][num] = color def fill_row(num, color): global canvas for i in range(m): canvas[num][i] = color (n, m, k) = map(int, input().split()) canvas = [[0 ...
output
1
80,445
7
160,891
Provide tags and a correct Python 3 solution for this coding contest problem. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to t...
instruction
0
80,446
7
160,892
Tags: constructive algorithms, implementation Correct Solution: ``` n,m,k = map(int,input().split()) t = [[0]*m for i in range(n)] used = set() a = [] for i in range(k): q, b, c = tuple(map(int,input().split())) b = b - 1 a.append((q, b, c)) a = a[::-1] for i in range(k): if a[i][0:2] not in used: ...
output
1
80,446
7
160,893
Provide tags and a correct Python 3 solution for this coding contest problem. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to t...
instruction
0
80,447
7
160,894
Tags: constructive algorithms, implementation Correct Solution: ``` n, m, k = map(int, input().split()) A = [0] * n for i in range(n): A[i] = [0,0] B = [0] * m for i in range(m): B[i] = [0,0] for i in range(k): per = input().split() if per[0] == '1': A[int(per[1])-1] = [int(per[2]), i+1] els...
output
1
80,447
7
160,895
Provide tags and a correct Python 3 solution for this coding contest problem. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to t...
instruction
0
80,448
7
160,896
Tags: constructive algorithms, implementation Correct Solution: ``` n,m,k=map(int,input().split()) c=[(0,0)]*(m+1) r=[(0,0)]*(n+1) for i in range(k): q,a,b=map(int,input().split()) if q==1: r[a]=(i+1,b) else: c[a]=(i+1,b) for i in range(n): s="" for j in range(m): t=r[i+1][1] ...
output
1
80,448
7
160,897
Provide tags and a correct Python 3 solution for this coding contest problem. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to t...
instruction
0
80,449
7
160,898
Tags: constructive algorithms, implementation Correct Solution: ``` from sys import stdin, stdout def main(): (n, m, k) = map(int, stdin.readline().strip().split(' ')) r = [0] * n c = [0] * m a = [0] * (k + 1) for i in range(1, k + 1): l, xi, a[i] = map(int, stdin.readline().strip().split(...
output
1
80,449
7
160,899
Provide tags and a correct Python 3 solution for this coding contest problem. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to t...
instruction
0
80,450
7
160,900
Tags: constructive algorithms, implementation Correct Solution: ``` n, m, k = map(int, input().split()) c = [(0, 0)] * m r = [(0, 0)] * n for i in range(k): t, idx, x = map(int, input().split()) if t == 1: r[idx - 1] = (i + 1, x) else: c[idx - 1] = (i + 1, x) res = [[0] * m for i in range(n)] for i in range...
output
1
80,450
7
160,901
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First...
instruction
0
80,451
7
160,902
Yes
output
1
80,451
7
160,903
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First...
instruction
0
80,452
7
160,904
Yes
output
1
80,452
7
160,905
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First...
instruction
0
80,453
7
160,906
Yes
output
1
80,453
7
160,907
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First...
instruction
0
80,454
7
160,908
Yes
output
1
80,454
7
160,909
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First...
instruction
0
80,455
7
160,910
No
output
1
80,455
7
160,911
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First...
instruction
0
80,456
7
160,912
No
output
1
80,456
7
160,913
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First...
instruction
0
80,457
7
160,914
No
output
1
80,457
7
160,915
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First...
instruction
0
80,458
7
160,916
No
output
1
80,458
7
160,917
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have an N \times M grid. The square at the i-th row and j-th column will be denoted as (i,j). Particularly, the top-left square will be denoted as (1,1), and the bottom-right square will be d...
instruction
0
80,686
7
161,372
No
output
1
80,686
7
161,373
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have an N \times M grid. The square at the i-th row and j-th column will be denoted as (i,j). Particularly, the top-left square will be denoted as (1,1), and the bottom-right square will be d...
instruction
0
80,687
7
161,374
No
output
1
80,687
7
161,375
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino has a lot of red and blue bricks and a large box. She will build a tower of these bricks in the following manner. First, she will pick a total of N bricks and put them into the box. Her...
instruction
0
80,704
7
161,408
No
output
1
80,704
7
161,409
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino has a lot of red and blue bricks and a large box. She will build a tower of these bricks in the following manner. First, she will pick a total of N bricks and put them into the box. Her...
instruction
0
80,705
7
161,410
No
output
1
80,705
7
161,411
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino has a lot of red and blue bricks and a large box. She will build a tower of these bricks in the following manner. First, she will pick a total of N bricks and put them into the box. Her...
instruction
0
80,706
7
161,412
No
output
1
80,706
7
161,413
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white. You think that t...
instruction
0
80,902
7
161,804
Tags: implementation Correct Solution: ``` q = int(input()) for i in range(q): [n, m] = [int(w) for w in input().split()] obr = n * [None] for x in range(n): obr[x] = list(input()) r_pocty_ciernych = n * [None] for x in range(n): ciernych = 0 for y in range(m): ...
output
1
80,902
7
161,805
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white. You think that t...
instruction
0
80,903
7
161,806
Tags: implementation Correct Solution: ``` import sys import math from collections import defaultdict,deque input = sys.stdin.readline def inar(): return [int(el) for el in input().split()] def main(): t=int(input()) for _ in range(t): n,m=inar() matrix=[] for i in range(n): ...
output
1
80,903
7
161,807
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white. You think that t...
instruction
0
80,904
7
161,808
Tags: implementation Correct Solution: ``` from sys import stdin def ii(): return int(stdin.readline()) def mi(): return map(int, stdin.readline().split()) def li(): return list(mi()) def si(): return stdin.readline() for _ in range(ii()): a=[] r=[] c=[] n, m=mi() for i in range(n): a.append...
output
1
80,904
7
161,809
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white. You think that t...
instruction
0
80,905
7
161,810
Tags: implementation Correct Solution: ``` t = int(input()) for y in range(t): n, m = map(int, input().split()) x = [] rowindex = -1 colindex = -1 r = -1 rows =[] for i in range(n): x += [input()] cnt = x[-1].count('*') if(cnt > r): rowindex = i r = cnt rows = [i] elif(cnt==r): rows+=[i] c =...
output
1
80,905
7
161,811
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white. You think that t...
instruction
0
80,906
7
161,812
Tags: implementation Correct Solution: ``` def check(x, y, vert, gor, matrix): if matrix[y][x] == 1: return gor[y] + vert[x] - 1 else: return gor[y] + vert[x] q = int(input()) for i in range(q): n, m = map(int, input().split()) vert = [0 for i in range(m)] gor = [] matrix = []...
output
1
80,906
7
161,813
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white. You think that t...
instruction
0
80,907
7
161,814
Tags: implementation Correct Solution: ``` for _ in range(int(input())): row, col = [int(x) for x in input().split()] grid = [[x for x in input()] for _ in range(row)] rowc, colc = [0] * row, [0] * col for i in range(row): for j in range(col): if grid[i][j] == "*": ro...
output
1
80,907
7
161,815
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white. You think that t...
instruction
0
80,908
7
161,816
Tags: implementation Correct Solution: ``` import sys z = int(input()) for _ in range(z): ans = 99999999 n,m = map(int, sys.stdin.readline().split()) df = [] for _ in range(n): df.append(sys.stdin.readline()) l = [df[i].count('.') for i in range(n)] df2 = list(map(list, zip(*df))) w = [df2[i].count('.') for ...
output
1
80,908
7
161,817
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white. You think that t...
instruction
0
80,909
7
161,818
Tags: implementation Correct Solution: ``` T=int(input()) for _ in range(0,T): n,m=map(int,input().split()) arr=[] for i in range(0,n): s=input() arr.append(s) ans=n+m-1 L1=[] L2=[] for i in range(n): c=0 for j in range(m): if(arr[i][j]=='.')...
output
1
80,909
7
161,819
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is pa...
instruction
0
80,910
7
161,820
Yes
output
1
80,910
7
161,821
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is pa...
instruction
0
80,911
7
161,822
Yes
output
1
80,911
7
161,823
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is pa...
instruction
0
80,912
7
161,824
Yes
output
1
80,912
7
161,825
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is pa...
instruction
0
80,913
7
161,826
Yes
output
1
80,913
7
161,827
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is pa...
instruction
0
80,914
7
161,828
No
output
1
80,914
7
161,829
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is pa...
instruction
0
80,915
7
161,830
No
output
1
80,915
7
161,831
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is pa...
instruction
0
80,916
7
161,832
No
output
1
80,916
7
161,833