message
stringlengths
2
19.9k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
322
108k
cluster
float64
15
15
__index_level_0__
int64
644
217k
Provide tags and a correct Python 3 solution for this coding contest problem. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has s...
instruction
0
102,146
15
204,292
Tags: dfs and similar Correct Solution: ``` r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9 for i in range(0, 72, 9): t = set() for x in r: for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8): if s[y] == 'T': continue if (y < i or s[y - i] != 'S...
output
1
102,146
15
204,293
Provide tags and a correct Python 3 solution for this coding contest problem. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has s...
instruction
0
102,147
15
204,294
Tags: dfs and similar Correct Solution: ``` def play(b, x, y, c): if c == 9: return True if b[c][y][x] == 'S': return False dx = [-1, 1, 0, 0, 0, 1, 1, -1, -1] dy = [0, 0, -1, 1, 0, -1, 1, -1, 1] for i in range(len(dx)): nx = x + dx[i] ny = y + dy[i] if min(nx...
output
1
102,147
15
204,295
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the l...
instruction
0
102,148
15
204,296
Yes
output
1
102,148
15
204,297
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the l...
instruction
0
102,149
15
204,298
Yes
output
1
102,149
15
204,299
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the l...
instruction
0
102,150
15
204,300
Yes
output
1
102,150
15
204,301
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the l...
instruction
0
102,151
15
204,302
Yes
output
1
102,151
15
204,303
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the l...
instruction
0
102,152
15
204,304
No
output
1
102,152
15
204,305
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the l...
instruction
0
102,153
15
204,306
No
output
1
102,153
15
204,307
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the l...
instruction
0
102,154
15
204,308
No
output
1
102,154
15
204,309
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the l...
instruction
0
102,155
15
204,310
No
output
1
102,155
15
204,311
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Boboniu will test you with the following chess que...
instruction
0
102,205
15
204,410
Tags: constructive algorithms Correct Solution: ``` n,m,x,y = map(int, [*open(0)][0].split()) x, y = x-1, y-1 for i in range(n): print(x+1 ,y+1) for j in range(m-1): y = (y + 1)%m print(x+1, y+1) x = (x + 1)%n ```
output
1
102,205
15
204,411
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Boboniu will test you with the following chess que...
instruction
0
102,206
15
204,412
Tags: constructive algorithms Correct Solution: ``` n,m,x,y=map(int,input().split(" ")) for i in range(n): for j in range(m): print(x,y) if y==m: y=1 else: y+=1 if y==1: y=m else: y-=1 if x==n: x=1 else: x+=1 ...
output
1
102,206
15
204,413
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Boboniu will test you with the following chess que...
instruction
0
102,207
15
204,414
Tags: constructive algorithms Correct Solution: ``` a , b , x, y = map(int,input().split()) ans1 = x ans2 = y for x in range(a): if ans1>a: ans1 = ans1 - a for x in range(b): if ans2>b: ans2 = ans2 - b print(f"{ans1} {ans2}") ans2 = ans2 + 1 ans1 = ans1 + 1 a...
output
1
102,207
15
204,415
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Boboniu will test you with the following chess que...
instruction
0
102,208
15
204,416
Tags: constructive algorithms Correct Solution: ``` n,m,r,c=map(int,input().split()) r-=1 c-=1 init=[r,c] # print starting row print(r+1,c+1) for j in range(c+1,m): print(r+1,j+1) for j in range(c-1,-1,-1): print(r+1,j+1) lr=True r+=1 while r < n: if lr: for j in range(m): print(r+1,j+1)...
output
1
102,208
15
204,417
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Boboniu will test you with the following chess que...
instruction
0
102,209
15
204,418
Tags: constructive algorithms Correct Solution: ``` nums=input().split(' ') nums=[int(x) for x in nums] n=nums[0] m=nums[1] sx=nums[2] sy=nums[3] #do the local column print(str(sx)+" "+str(sy)) for i in range(1,n+1): if i!=sx: print(str(i)+" "+str(sy)) for i in range(1,m+1): if i<sy: if i%2==...
output
1
102,209
15
204,419
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Boboniu will test you with the following chess que...
instruction
0
102,210
15
204,420
Tags: constructive algorithms Correct Solution: ``` n,m,sx,sy = map(int, input().split()) for y in range(sy,m+1): print(sx,y) for y in range(sy-1,0,-1): print(sx,y) to_back = True for x in range(1,n+1): if x == sx: continue if to_back: for y in range(1,m+1): print(x,y) else: ...
output
1
102,210
15
204,421
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Boboniu will test you with the following chess que...
instruction
0
102,211
15
204,422
Tags: constructive algorithms Correct Solution: ``` from sys import stdin,stdout import math,queue,heapq fastinput=stdin.readline fastout=stdout.write t=1 while t: t-=1 n,m,sx,sy=map(int,fastinput().split()) visited=[] visited.append([sx,sy]) visited.append([1,sy]) visited.append([1,1]) ...
output
1
102,211
15
204,423
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Boboniu will test you with the following chess que...
instruction
0
102,212
15
204,424
Tags: constructive algorithms Correct Solution: ``` import sys input = sys.stdin.readline I = lambda : list(map(int,input().split())) x,y,a,b,=I() a-=1 b-=1 print(a+1,b+1) for i in range(y): if i!=b: print(a+1,i+1) r=1 flag=0 while r<=x: if flag==0: if r%2: for i in range(y,0,-1): ...
output
1
102,212
15
204,425
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Bob...
instruction
0
102,213
15
204,426
Yes
output
1
102,213
15
204,427
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Bob...
instruction
0
102,214
15
204,428
Yes
output
1
102,214
15
204,429
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Bob...
instruction
0
102,215
15
204,430
Yes
output
1
102,215
15
204,431
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Bob...
instruction
0
102,216
15
204,432
Yes
output
1
102,216
15
204,433
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Bob...
instruction
0
102,217
15
204,434
No
output
1
102,217
15
204,435
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Bob...
instruction
0
102,218
15
204,436
No
output
1
102,218
15
204,437
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Bob...
instruction
0
102,219
15
204,438
No
output
1
102,219
15
204,439
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round. You are a new applicant for his company. Bob...
instruction
0
102,220
15
204,440
No
output
1
102,220
15
204,441
Provide tags and a correct Python 3 solution for this coding contest problem. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin. The world can be represented b...
instruction
0
102,641
15
205,282
Tags: implementation Correct Solution: ``` n=int(input()) s=input() l=[0,0] count=0 state=0 def up(): l[1]+=1 def right(): l[0]+=1 for x in s: if state==0: if x=='U': up() state=2 elif x=="R": right() state=1 elif state==1: if ...
output
1
102,641
15
205,283
Provide tags and a correct Python 3 solution for this coding contest problem. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin. The world can be represented b...
instruction
0
102,642
15
205,284
Tags: implementation Correct Solution: ``` from sys import stdin, stdout n = int(stdin.readline()) coordinates = [] x, y = 0, 0 def check(ind): if ind + 1 >= n: return False label = (coordinates[ind - 1][1] > coordinates[ind - 1][0]) ^ (coordinates[ind + 1][1] > coordinates[ind + 1][0]) retu...
output
1
102,642
15
205,285
Provide tags and a correct Python 3 solution for this coding contest problem. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin. The world can be represented b...
instruction
0
102,643
15
205,286
Tags: implementation Correct Solution: ``` import sys import math #to read string get_string = lambda: sys.stdin.readline().strip() #to read list of integers get_list = lambda: list( map(int,sys.stdin.readline().strip().split()) ) #to read integers get_int = lambda: int(sys.stdin.readline()) #------------------------...
output
1
102,643
15
205,287
Provide tags and a correct Python 3 solution for this coding contest problem. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin. The world can be represented b...
instruction
0
102,644
15
205,288
Tags: implementation Correct Solution: ``` '''input 7 URRRUUU ''' n = int(input()) s = input() gate = False ans, countu, countr = 0, 0, 0 for i in range(n): if countu == countr and (s[i - 1] == s[i]) and i > 0: ans, gate = ans + 1, False if(s[i] == 'U'): countu += 1 if(s[i] == 'R'): countr += 1 print(ans) ...
output
1
102,644
15
205,289
Provide tags and a correct Python 3 solution for this coding contest problem. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin. The world can be represented b...
instruction
0
102,645
15
205,290
Tags: implementation Correct Solution: ``` n=int(input()) s=input() ans,a,b=0,0,0 for i in range(n-1): if s[i]=='R': a+=1 if s[i]=='U': b+=1 if a==b: a,b=0,0 if s[i+1]==s[i]: ans+=1 print(ans) ```
output
1
102,645
15
205,291
Provide tags and a correct Python 3 solution for this coding contest problem. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin. The world can be represented b...
instruction
0
102,646
15
205,292
Tags: implementation Correct Solution: ``` t = int(input()) s = str(input()) x,y,c=0,0,0 for i in range(t-1): if s[i]=='U': y+=1 if s[i]=='R': x+=1 if x==y: if s[i]==s[i+1]: c+=1 print(c) ```
output
1
102,646
15
205,293
Provide tags and a correct Python 3 solution for this coding contest problem. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin. The world can be represented b...
instruction
0
102,647
15
205,294
Tags: implementation Correct Solution: ``` n = int(input()) S = input() money = 0 a = 0 for i in range(n): if S[i] == 'R': a+=1 else: a-=1 if i == 0: if a>0: dom = 'pos' else: dom = 'neg' if dom == 'pos' and a<0: money+=1 dom = 'neg...
output
1
102,647
15
205,295
Provide tags and a correct Python 3 solution for this coding contest problem. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin. The world can be represented b...
instruction
0
102,648
15
205,296
Tags: implementation Correct Solution: ``` n=int(input()) i=list(input()) x=0 y=0 cost=0 for index in range(len(i)-1): if(i[index]=='U'): y+=1 elif(i[index]=='R'): x+=1 if(x==y): if((i[index]=='U' and i[index+1]=='U') or (i[index]=='R' and i[index+1]=='R')): cost+=1 print...
output
1
102,648
15
205,297
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay o...
instruction
0
102,649
15
205,298
Yes
output
1
102,649
15
205,299
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay o...
instruction
0
102,650
15
205,300
Yes
output
1
102,650
15
205,301
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay o...
instruction
0
102,651
15
205,302
Yes
output
1
102,651
15
205,303
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay o...
instruction
0
102,652
15
205,304
Yes
output
1
102,652
15
205,305
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay o...
instruction
0
102,653
15
205,306
No
output
1
102,653
15
205,307
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay o...
instruction
0
102,654
15
205,308
No
output
1
102,654
15
205,309
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay o...
instruction
0
102,655
15
205,310
No
output
1
102,655
15
205,311
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay o...
instruction
0
102,656
15
205,312
No
output
1
102,656
15
205,313
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a following process. There is a platform with n columns. 1 Γ— 1 squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a ...
instruction
0
102,662
15
205,324
Tags: implementation Correct Solution: ``` input_line1 = input() input_line2 = input() tetris_list = input_line2.split(' ') #print(tetris_list) info_list = input_line1.split(' ') col = int(info_list[0]) max = int(info_list[1]) #print(col,max) out_list = [] for i in range(col): out_list.append(tetris_list.count(str(...
output
1
102,662
15
205,325
Provide a correct Python 3 solution for this coding contest problem. There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid. When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1). In how many ways can the knight reach the square (X, Y)? Find the num...
instruction
0
102,720
15
205,440
"Correct Solution: ``` x,y = map(int,input().split()) n = 0 mod = 10**9+7 ans = 0 if not (x+y)%3: n = (x+y)//3 x-=n y-=n if not x<0 or y<0: ans = 1 for i in range(x): ans = ans*(n-i)*pow(i+1,mod-2,mod)%mod print(ans) ```
output
1
102,720
15
205,441
Provide a correct Python 3 solution for this coding contest problem. There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid. When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1). In how many ways can the knight reach the square (X, Y)? Find the num...
instruction
0
102,721
15
205,442
"Correct Solution: ``` a,b=map(int,input().split()) aa=a bb=b x=0 y=0 while aa>0 and bb>0: if aa>bb: aa-=1 x+=1 else: bb-=1 y+=1 aa-=1 bb-=1 if aa!=0 or bb!=0: print(0) exit() mod=10**9+7 fac=[1] for i in range(max(a,b)): fac.append(fac[i]*(i+1)%mod) x+=y r=pow(fac[y]*fac[x-y]%mod,mod-2,mod) print(fac[x]...
output
1
102,721
15
205,443
Provide a correct Python 3 solution for this coding contest problem. There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid. When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1). In how many ways can the knight reach the square (X, Y)? Find the num...
instruction
0
102,722
15
205,444
"Correct Solution: ``` X,Y = map(int, input().split()) m = (-X+2*Y)//3 n = (2*X-Y)//3 def combination(n, r, mod=10**9+7): n1, r = n+1, min(r, n-r) numer = denom = 1 for i in range(1, r+1): numer = (numer*(n1-i)) % mod denom = (denom*i) % mod return numer * pow(denom, mod-2, mod) % mod ...
output
1
102,722
15
205,445
Provide a correct Python 3 solution for this coding contest problem. There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid. When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1). In how many ways can the knight reach the square (X, Y)? Find the num...
instruction
0
102,723
15
205,446
"Correct Solution: ``` x,y = map(int,input().split()) m = 10**9+7 if not((x+y)%3== 0 and abs(x-y)<=(x+y)//3): print(0);exit() def comb(n,k): #if 2 * k > n: #k = n - k a = 1 for i in range(1,k+1): a *= (n - ( i - 1)) * pow(i,m-2,m) a = a%m return a n = (x+y)//3 k = x-n print...
output
1
102,723
15
205,447
Provide a correct Python 3 solution for this coding contest problem. There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid. When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1). In how many ways can the knight reach the square (X, Y)? Find the num...
instruction
0
102,724
15
205,448
"Correct Solution: ``` x,y = map(int,input().split()) ans = 0 mod = 10**9+7 if (x+y)%3 == 0: m = (2*y-x)//3 n = (2*x-y)//3 if m >= 0 and n >= 0: fac = [1]*(m+n+1) for i in range(2,m+n+1): fac[i] = fac[i-1]*i % mod ans = fac[m+n]*(pow(fac[m],mod-2,mod)*pow(fac[n],mod-2,m...
output
1
102,724
15
205,449
Provide a correct Python 3 solution for this coding contest problem. There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid. When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1). In how many ways can the knight reach the square (X, Y)? Find the num...
instruction
0
102,725
15
205,450
"Correct Solution: ``` x, y = map(int, input().split()) if (x + y) % 3 != 0: print(0) exit() a = (x + y) // 3 x -= a y -= a if x < 0 or y < 0: print(0) exit() mod = 10 ** 9 + 7 def combination(n, r): x = 1 y = 1 for i in range(r): x = x * (n - i) % mod y = y * (r - i) % mod ...
output
1
102,725
15
205,451
Provide a correct Python 3 solution for this coding contest problem. There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid. When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1). In how many ways can the knight reach the square (X, Y)? Find the num...
instruction
0
102,726
15
205,452
"Correct Solution: ``` import math X, Y = map(int, input().split()) if X > Y: X, Y = Y, X if ((2*X-Y) % 3 != 0) or (2*X-Y < 0): print(0) exit() A = (2*X-Y)//3 B = Y-X+A N = A+B nu = 1 de = 1 for i in range(B+1, N+1): nu = (nu * i) % (10 ** 9 + 7) for i in range(1, A+1): de = (de * i) % (10 ** 9 + 7) print...
output
1
102,726
15
205,453