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. Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote its initial location by p0. First, the robot w...
instruction
0
77,211
15
154,422
Tags: constructive algorithms, math Correct Solution: ``` def main(): n = int(input()) s = input() fr = None sc = None ans = 0 for elem in s: if (fr == None): fr = elem ans += 1 else: if (sc == None): if (elem == fr): ...
output
1
77,211
15
154,423
Provide tags and a correct Python 3 solution for this coding contest problem. Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote its initial location by p0. First, the robot w...
instruction
0
77,212
15
154,424
Tags: constructive algorithms, math Correct Solution: ``` # your code goes here a = int(input()) s = input() count = 0 m1 = '0' m2 = '0' for i in range(len(s)): if( (m1=='0')and(m2=='0') ): m1=s[i] if( (m1!=s[i])and(m2!=s[i])and(m1!='0')and(m2!='0') ): count+=1 m1=s[i] m2='0' elif( (m1!=s[i]and(m2!=...
output
1
77,212
15
154,425
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote...
instruction
0
77,213
15
154,426
Yes
output
1
77,213
15
154,427
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote...
instruction
0
77,214
15
154,428
Yes
output
1
77,214
15
154,429
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote...
instruction
0
77,215
15
154,430
Yes
output
1
77,215
15
154,431
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote...
instruction
0
77,216
15
154,432
Yes
output
1
77,216
15
154,433
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote...
instruction
0
77,217
15
154,434
No
output
1
77,217
15
154,435
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote...
instruction
0
77,218
15
154,436
No
output
1
77,218
15
154,437
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote...
instruction
0
77,219
15
154,438
No
output
1
77,219
15
154,439
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote...
instruction
0
77,220
15
154,440
No
output
1
77,220
15
154,441
Provide tags and a correct Python 3 solution for this coding contest problem. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of ...
instruction
0
77,253
15
154,506
Tags: brute force, greedy, implementation Correct Solution: ``` """Ввод размера матрицы""" nm = [int(s) for s in input().split()] """Ввод массива""" a = [] for i in range(nm[0]): a.append([int(j) for j in input().split()]) rez=[] def stroka(): global rez rez_row=[] rez_r=0 for i in range(nm[0]): ...
output
1
77,253
15
154,507
Provide tags and a correct Python 3 solution for this coding contest problem. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of ...
instruction
0
77,254
15
154,508
Tags: brute force, greedy, implementation Correct Solution: ``` import copy n,m=map(int,input().split()) a=[] ans=[] ans1=[] for i in range (n): a.append(list(map(int,input().split()))) b=copy.deepcopy(a) for i in range (n): mn=min(a[i]) for j in range (m): a[i][j]-=mn if(mn>0): ans.app...
output
1
77,254
15
154,509
Provide tags and a correct Python 3 solution for this coding contest problem. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of ...
instruction
0
77,255
15
154,510
Tags: brute force, greedy, implementation Correct Solution: ``` #!/usr/bin/env python3 import sys from functools import reduce from queue import PriorityQueue INFINITY = 1000 def do_row(mat, actions): n = len(mat) did_nothing = True for r in range(n): mn, mx = min_and_max(mat[r]) #print(mn...
output
1
77,255
15
154,511
Provide tags and a correct Python 3 solution for this coding contest problem. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of ...
instruction
0
77,256
15
154,512
Tags: brute force, greedy, implementation Correct Solution: ``` read = lambda: map(int, input().split()) def fail(): print(-1) exit() n, m = read() g = [list(read()) for i in range(n)] a = [0] * n b = [0] * m for i in range(1, m): b[i] = g[0][i] - g[0][0] for i in range(1, n): a[i] = g[i][0] - g[0][0] f...
output
1
77,256
15
154,513
Provide tags and a correct Python 3 solution for this coding contest problem. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of ...
instruction
0
77,257
15
154,514
Tags: brute force, greedy, implementation Correct Solution: ``` n, m = map(int, input().split()) mat = [list(map(int, input().strip().split())) for _ in range(n)] def clear_row(): rows = [] for i in range(n): minx = 501 for j in range(m): minx = min(minx, mat[i][j]) ...
output
1
77,257
15
154,515
Provide tags and a correct Python 3 solution for this coding contest problem. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of ...
instruction
0
77,258
15
154,516
Tags: brute force, greedy, implementation Correct Solution: ``` n, m = map(int, input().split()) table = [list(map(int, input().split())) for i in range(n)] table2 = [list(l) for l in table] anslst = [] for i in range(n): minv = min(table[i]) for v in range(minv): anslst.append("row {}".format(i + 1)) ...
output
1
77,258
15
154,517
Provide tags and a correct Python 3 solution for this coding contest problem. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of ...
instruction
0
77,259
15
154,518
Tags: brute force, greedy, implementation Correct Solution: ``` import sys def main(): n,m=list(map(int,sys.stdin.readline().split())) field=[] for i in range(n): row=list(map(int,sys.stdin.readline().split())) field.append(row) nmoves=0 moves=[] while True: ...
output
1
77,259
15
154,519
Provide tags and a correct Python 3 solution for this coding contest problem. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of ...
instruction
0
77,260
15
154,520
Tags: brute force, greedy, implementation Correct Solution: ``` r, c = map(int, input().split(' ')) arr = [] ops = [] num_ops = 0 for i in range(r): arr.append(list(map(int, input().split(' ')))) s1, s2 = "row ", "col " if r > c: arr1 = [] for i in range(c): arr1.append([0]*r) for i in range(r): for j ...
output
1
77,260
15
154,521
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originall...
instruction
0
77,261
15
154,522
Yes
output
1
77,261
15
154,523
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originall...
instruction
0
77,262
15
154,524
Yes
output
1
77,262
15
154,525
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originall...
instruction
0
77,263
15
154,526
Yes
output
1
77,263
15
154,527
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originall...
instruction
0
77,264
15
154,528
Yes
output
1
77,264
15
154,529
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originall...
instruction
0
77,265
15
154,530
No
output
1
77,265
15
154,531
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originall...
instruction
0
77,266
15
154,532
No
output
1
77,266
15
154,533
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originall...
instruction
0
77,267
15
154,534
No
output
1
77,267
15
154,535
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originall...
instruction
0
77,268
15
154,536
No
output
1
77,268
15
154,537
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: * U — move from the cell (x, y) to (x, y...
instruction
0
77,289
15
154,578
Tags: greedy Correct Solution: ``` n = int(input()) s = input() print(n - (abs(s.count('R') - s.count('L')) + abs(s.count('D') - s.count('U')))) ```
output
1
77,289
15
154,579
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: * U — move from the cell (x, y) to (x, y...
instruction
0
77,290
15
154,580
Tags: greedy Correct Solution: ``` # U D L R n = int(input()) s = input() t = [s.count('U'), s.count('D'), s.count('L'), s.count('R')] q = min(t[0], t[1]) * 2 + min(t[2], t[3]) * 2 print(q) ```
output
1
77,290
15
154,581
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: * U — move from the cell (x, y) to (x, y...
instruction
0
77,291
15
154,582
Tags: greedy Correct Solution: ``` moves = int(input()) comms = input() x = 0 y = 0 for i in comms: if i == "L":x-=1 if i == "R":x+=1 if i == "U":y+=1 if i == "D":y-=1 print(moves - (abs(x) + abs(y))) ```
output
1
77,291
15
154,583
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: * U — move from the cell (x, y) to (x, y...
instruction
0
77,292
15
154,584
Tags: greedy Correct Solution: ``` def main(): n = int(input()) s = input() print(2 * min(s.count('L'), s.count('R')) + 2 * min(s.count('U'), s.count('D'))) main() ```
output
1
77,292
15
154,585
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: * U — move from the cell (x, y) to (x, y...
instruction
0
77,293
15
154,586
Tags: greedy Correct Solution: ``` n = int(input()) s = input() x = 2*min(s.count('L'),s.count('R')) y = 2*min(s.count('U'),s.count('D')) print(x+y) ```
output
1
77,293
15
154,587
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: * U — move from the cell (x, y) to (x, y...
instruction
0
77,294
15
154,588
Tags: greedy Correct Solution: ``` n = int(input()); s = input(); u = 0; d = 0; r = 0; l = 0; for q in range(n): if s[q] == 'L': l = l + 1; elif s[q] == 'R': r = r + 1; elif s[q] == 'U': u = u + 1; elif s[q] == 'D': d = d + 1; print(min(r, l) * 2 + min(u, d) * 2); ```
output
1
77,294
15
154,589
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: * U — move from the cell (x, y) to (x, y...
instruction
0
77,295
15
154,590
Tags: greedy Correct Solution: ``` #B n=int(input()) a=input() link=[0]*4 for i in range(n): if a[i]=="R": link[0]+=1 elif a[i]=="L": link[1]+=1 elif a[i]=="U": link[2]+=1 elif a[i]=="D": link[3]+=1 counter=(min(link[0],link[1])+min(link[2],link[3]))*2 print(counter) ```
output
1
77,295
15
154,591
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: * U — move from the cell (x, y) to (x, y...
instruction
0
77,296
15
154,592
Tags: greedy Correct Solution: ``` def robot(string): if "U" in string and "D" in string and "R" in string and "L" in string: return min(string.count("U"), string.count("D")) * 2 + min(string.count("R"), string.count("L")) * 2 if "U" in string and "D" in string: return min(string.count("U"),s...
output
1
77,296
15
154,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perfo...
instruction
0
77,297
15
154,594
Yes
output
1
77,297
15
154,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perfo...
instruction
0
77,298
15
154,596
Yes
output
1
77,298
15
154,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perfo...
instruction
0
77,299
15
154,598
Yes
output
1
77,299
15
154,599
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perfo...
instruction
0
77,300
15
154,600
Yes
output
1
77,300
15
154,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perfo...
instruction
0
77,301
15
154,602
No
output
1
77,301
15
154,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perfo...
instruction
0
77,302
15
154,604
No
output
1
77,302
15
154,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perfo...
instruction
0
77,303
15
154,606
No
output
1
77,303
15
154,607
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perfo...
instruction
0
77,304
15
154,608
No
output
1
77,304
15
154,609
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K mov...
instruction
0
77,341
15
154,682
"Correct Solution: ``` X,K,D=map(int,input().split()) X=abs(X) if X/D >= K: print(X-D*K) exit() s = X//D X -= s*D K -= s if K%2 == 0: print(X) else: print(abs(X-D)) ```
output
1
77,341
15
154,683
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K mov...
instruction
0
77,342
15
154,684
"Correct Solution: ``` X,K,D=map(int,input().split()) X=abs(X) if X<=K*D: if (K-X//D)%2==0:X=X%D else:X=abs(X%D-D) else: X=X-K*D print(X) ```
output
1
77,342
15
154,685
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K mov...
instruction
0
77,344
15
154,688
"Correct Solution: ``` x,k,d=map(int,input().split()) x=abs(x) m=min(k,x//d) k=k-m if k%2==0: print(abs(x-m*d)) else: print(abs(x-(m+1)*d)) ```
output
1
77,344
15
154,689
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K mov...
instruction
0
77,345
15
154,690
"Correct Solution: ``` X,K,D = map(int,input().split()) X=abs(X) if X>=K*D: print(abs(X-K*D)) else: print(abs(X-(abs(X)//D+(K-abs(X)//D)%2)*D)) ```
output
1
77,345
15
154,691
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K mov...
instruction
0
77,346
15
154,692
"Correct Solution: ``` x,k,d=map(int,input().split()) x=abs(x) if k*d<=x:print(x-k*d) else: f=x//d x-=f*d k-=f if k%2:print(abs(x-d)) else:print(x) ```
output
1
77,346
15
154,693
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K mov...
instruction
0
77,347
15
154,694
"Correct Solution: ``` x,k,d = map(int,input().split()) if abs(x//d) > k: print(abs(x)-k*d) else: if (k-(x//d))%2 == 0: print(x%d) else: print(d-x%d) ```
output
1
77,347
15
154,695
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K mov...
instruction
0
77,348
15
154,696
"Correct Solution: ``` X,K,D=map(int,input().split()) X=abs(X) straight=min(K,X//D) K-=straight X-=straight*D if K%2==0: print(X) else: print(D-X) ```
output
1
77,348
15
154,697
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from...
instruction
0
77,349
15
154,698
Yes
output
1
77,349
15
154,699