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. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0...
instruction
0
99,848
15
199,696
Tags: implementation Correct Solution: ``` x, y, x0, y0 = map(int, input().split()) a = [[0] * (y + 1) for i in range(x + 1)] s = input() count = x * y result = [0] * (len(s)) for i in range(len(s)): if a[x0][y0] == 0: a[x0][y0] = 1 result[i] = 1 count -= 1 if s[i] == 'U' and x0 > 1: ...
output
1
99,848
15
199,697
Provide tags and a correct Python 3 solution for this coding contest problem. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0...
instruction
0
99,849
15
199,698
Tags: implementation Correct Solution: ``` from functools import reduce from operator import * from math import * from sys import * from string import * setrecursionlimit(10**7) dX= [-1, 1, 0, 0,-1, 1,-1, 1] dY= [ 0, 0,-1, 1, 1,-1,-1, 1] RI=lambda: list(map(int,input().split())) RS=lambda: input().rstrip().split() ####...
output
1
99,849
15
199,699
Provide tags and a correct Python 3 solution for this coding contest problem. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0...
instruction
0
99,850
15
199,700
Tags: implementation Correct Solution: ``` DIR = {"L": (0, -1), "R": (0, 1), "U": (-1, 0), "D": (1, 0)} X, Y, x, y = map(int, input().split()) S = input() path = list() path.append((x, y)) for dx, dy in map(lambda x: DIR[x], S): xp, yp = x + dx, y + dy if xp < 1 or xp > X or yp < 1 or yp > Y: pass e...
output
1
99,850
15
199,701
Provide tags and a correct Python 3 solution for this coding contest problem. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0...
instruction
0
99,851
15
199,702
Tags: implementation Correct Solution: ``` x, y, x0, y0=list(map(int, input().split())) P={(x0, y0)} s=input() c=1 print(1, end=' ') for i in range(len(s)-1): if s[i] =='L': if y0>=2: y0-=1 if (x0, y0) in P: print(0, end=' ') else: print(1, end=' '); c+=1; P.add((x0, y0)) if s[i] =='U': if x0>=2: x...
output
1
99,851
15
199,703
Provide tags and a correct Python 3 solution for this coding contest problem. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0...
instruction
0
99,852
15
199,704
Tags: implementation Correct Solution: ``` x, y, x0, y0 = [int(x) for x in input().split()] x0 -= 1 y0 -= 1 commands = input() xy = x * y l = len(commands) a = [0] * (l + 1) n = 0 field = [[-1]*y for i in range(x)] field[x0][y0] = 0 for i in range(l): command = commands[i]; if command == 'U': if x0 > 0: x0 -= 1 ...
output
1
99,852
15
199,705
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test...
instruction
0
99,853
15
199,706
Yes
output
1
99,853
15
199,707
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test...
instruction
0
99,854
15
199,708
Yes
output
1
99,854
15
199,709
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test...
instruction
0
99,855
15
199,710
Yes
output
1
99,855
15
199,711
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test...
instruction
0
99,856
15
199,712
Yes
output
1
99,856
15
199,713
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test...
instruction
0
99,857
15
199,714
No
output
1
99,857
15
199,715
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test...
instruction
0
99,858
15
199,716
No
output
1
99,858
15
199,717
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test...
instruction
0
99,859
15
199,718
No
output
1
99,859
15
199,719
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test...
instruction
0
99,860
15
199,720
No
output
1
99,860
15
199,721
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Vladik has favorite game, in which he plays all his free time. Game field could be represented as n × m matrix which consists of cells of three types: * «.»...
instruction
0
99,977
15
199,954
No
output
1
99,977
15
199,955
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Vladik has favorite game, in which he plays all his free time. Game field could be represented as n × m matrix which consists of cells of three types: * «.»...
instruction
0
99,978
15
199,956
No
output
1
99,978
15
199,957
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Vladik has favorite game, in which he plays all his free time. Game field could be represented as n × m matrix which consists of cells of three types: * «.»...
instruction
0
99,979
15
199,958
No
output
1
99,979
15
199,959
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Vladik has favorite game, in which he plays all his free time. Game field could be represented as n × m matrix which consists of cells of three types: * «.»...
instruction
0
99,980
15
199,960
No
output
1
99,980
15
199,961
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem F and F2 are the same problem, but with different constraints and time limits. We have a board divided into N horizontal rows and N vertical columns of square cells. The cell at the i-t...
instruction
0
100,157
15
200,314
No
output
1
100,157
15
200,315
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem F and F2 are the same problem, but with different constraints and time limits. We have a board divided into N horizontal rows and N vertical columns of square cells. The cell at the i-t...
instruction
0
100,158
15
200,316
No
output
1
100,158
15
200,317
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem F and F2 are the same problem, but with different constraints and time limits. We have a board divided into N horizontal rows and N vertical columns of square cells. The cell at the i-t...
instruction
0
100,159
15
200,318
No
output
1
100,159
15
200,319
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem F and F2 are the same problem, but with different constraints and time limits. We have a board divided into N horizontal rows and N vertical columns of square cells. The cell at the i-t...
instruction
0
100,160
15
200,320
No
output
1
100,160
15
200,321
Provide a correct Python 3 solution for this coding contest problem. Background Mr. A and Mr. B are enthusiastic about the game "Changing Grids". This game is for two players, with player 1 forming the stage and player 2 challenging the stage and aiming for the goal. Now, A and B have played this game several times,...
instruction
0
100,276
15
200,552
"Correct Solution: ``` from heapq import heappush, heappop h, w = map(int, input().split()) def get_area(): mp = ["#" * (w + 2)] for _ in range(h): mp.append("#" + input() + "#") mp.append("#" * (w + 2)) return mp areas = [get_area()] times = {} n = int(input()) for i in range(n): times...
output
1
100,276
15
200,553
Provide tags and a correct Python 3 solution for this coding contest problem. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U...
instruction
0
100,526
15
201,052
Tags: brute force, implementation Correct Solution: ``` # from __future__ import print_function,division # range = xrange import sys input = sys.stdin.readline # sys.setrecursionlimit(10**9) from sys import stdin, stdout from collections import defaultdict, Counter M = 10**9+7 def main(): for _ in range(int(input(...
output
1
100,526
15
201,053
Provide tags and a correct Python 3 solution for this coding contest problem. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U...
instruction
0
100,527
15
201,054
Tags: brute force, implementation Correct Solution: ``` import sys input = sys.stdin.readline def move(x, d): m = {'L': (-1, 0), 'R': (1, 0), 'D': (0, -1), 'U': (0, 1)} return tuple([x[i] + m[d][i] for i in range(2)]) def solve(s): p = (0,0) p_set = {p} for char in s: z = move(p, char) ...
output
1
100,527
15
201,055
Provide tags and a correct Python 3 solution for this coding contest problem. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U...
instruction
0
100,528
15
201,056
Tags: brute force, implementation Correct Solution: ``` T = int(input()) r = 1 while r<=T: s = input() n = len(s) direc = {'U':[0,1],'D':[0,-1],'L':[-1,0],'R':[1,0]} x = 0 y = 0 dic = {} for i in range(n): x += direc[s[i]][0] y += direc[s[i]][1] if(x,y) not in dic: ...
output
1
100,528
15
201,057
Provide tags and a correct Python 3 solution for this coding contest problem. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U...
instruction
0
100,529
15
201,058
Tags: brute force, implementation Correct Solution: ``` d = {'L': [-1, 0], 'R': [1, 0], 'U': [0, 1], 'D': [0, -1]} for _ in range(int(input())): s = input() x, y = 0, 0 h = dict() for i in range(len(s)): dir = s[i] x += d[dir][0] y += d[dir][1] if x not in h: ...
output
1
100,529
15
201,059
Provide tags and a correct Python 3 solution for this coding contest problem. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U...
instruction
0
100,530
15
201,060
Tags: brute force, implementation Correct Solution: ``` import sys import os from sys import stdin, stdout import math def main(): t = int(stdin.readline()) for _ in range(t): st = stdin.readline().strip() px, py = 0,0 target = set() for s in st: if s == "R": ...
output
1
100,530
15
201,061
Provide tags and a correct Python 3 solution for this coding contest problem. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U...
instruction
0
100,531
15
201,062
Tags: brute force, implementation Correct Solution: ``` from sys import stdin as inp from sys import stdout as out def calcvalue(s): x,y=0,0 for i in s: if i=="L": x-=1 elif i=="R": x+=1 elif i=="U": y+=1 elif i=="D": y-=1 retu...
output
1
100,531
15
201,063
Provide tags and a correct Python 3 solution for this coding contest problem. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U...
instruction
0
100,532
15
201,064
Tags: brute force, implementation Correct Solution: ``` def upper(s,k,l,u): x=-1 if u==-1: return -1 while(l<=u): mid=(l+u)//2 if s[mid]<=k: x=max(x,mid) l=mid+1 else: u=mid-1 return x for i in range(int(input())): a=input() n=...
output
1
100,532
15
201,065
Provide tags and a correct Python 3 solution for this coding contest problem. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U...
instruction
0
100,533
15
201,066
Tags: brute force, implementation Correct Solution: ``` import sys input = sys.stdin.readline from itertools import groupby for _ in range(int(input())): s = input()[:-1] n = len(s) x, y = [0] * (n + 1), [0] * (n + 1) for i, c in enumerate(s): x[i + 1] = x[i] + (1 if c == 'R' else -1 if c == 'L...
output
1
100,533
15
201,067
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a st...
instruction
0
100,534
15
201,068
Yes
output
1
100,534
15
201,069
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a st...
instruction
0
100,535
15
201,070
Yes
output
1
100,535
15
201,071
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a st...
instruction
0
100,536
15
201,072
Yes
output
1
100,536
15
201,073
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a st...
instruction
0
100,537
15
201,074
Yes
output
1
100,537
15
201,075
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a st...
instruction
0
100,538
15
201,076
No
output
1
100,538
15
201,077
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a st...
instruction
0
100,539
15
201,078
No
output
1
100,539
15
201,079
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a st...
instruction
0
100,540
15
201,080
No
output
1
100,540
15
201,081
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a st...
instruction
0
100,541
15
201,082
No
output
1
100,541
15
201,083
Provide tags and a correct Python 3 solution for this coding contest problem. In a far away land, there are two cities near a river. One day, the cities decide that they have too little space and would like to reclaim some of the river area into land. The river area can be represented by a grid with r rows and exactl...
instruction
0
100,633
15
201,266
Tags: games Correct Solution: ``` r,n = [int(x) for x in input().split()] cells = [[int(x) for x in input().split()] for i in range(n)] cells.sort() #print(cells) out = False res = {True:"WIN",False:"LOSE"} if len(cells) == 0: print(res[r%2 == 1]) else: out = False #print(cells[0][0] > 1) #print(cells[-1]...
output
1
100,633
15
201,267
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In a far away land, there are two cities near a river. One day, the cities decide that they have too little space and would like to reclaim some of the river area into land. The river area can ...
instruction
0
100,634
15
201,268
No
output
1
100,634
15
201,269
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In a far away land, there are two cities near a river. One day, the cities decide that they have too little space and would like to reclaim some of the river area into land. The river area can ...
instruction
0
100,635
15
201,270
No
output
1
100,635
15
201,271
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In a far away land, there are two cities near a river. One day, the cities decide that they have too little space and would like to reclaim some of the river area into land. The river area can ...
instruction
0
100,636
15
201,272
No
output
1
100,636
15
201,273
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In a far away land, there are two cities near a river. One day, the cities decide that they have too little space and would like to reclaim some of the river area into land. The river area can ...
instruction
0
100,637
15
201,274
No
output
1
100,637
15
201,275
Provide tags and a correct Python 3 solution for this coding contest problem. Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. "Aha, blacks certainly didn't win!", — Volodya said and was right for...
instruction
0
100,684
15
201,368
Tags: implementation Correct Solution: ``` def rookfields(tuple, result, king): return ({(tuple[0], i) for i in range((king[1] if king[0]==tuple[0] and king[1]< tuple[1] else 0), (king[1] if king[0]==tuple[0] and king[1] > tuple[1] else 8))} | {(i, tuple[1]) for i in range((king[0] if king[1] == tuple[1] and king[0] < ...
output
1
100,684
15
201,369
Provide tags and a correct Python 3 solution for this coding contest problem. Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. "Aha, blacks certainly didn't win!", — Volodya said and was right for...
instruction
0
100,685
15
201,370
Tags: implementation Correct Solution: ``` import string class Position: def __init__(self, r, c): self.r = r self.c = c def s_to_position(s): letter, number = s[0], s[1] return Position(string.ascii_letters.index(letter), int(number) - 1) def finish(message): print(message) import sys; sys.exit() ...
output
1
100,685
15
201,371
Provide tags and a correct Python 3 solution for this coding contest problem. Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. "Aha, blacks certainly didn't win!", — Volodya said and was right for...
instruction
0
100,686
15
201,372
Tags: implementation Correct Solution: ``` import sys sys.setrecursionlimit(10000) # default is 1000 in python # increase stack size as well (for hackerrank) # import resource # resource.setrlimit(resource.RLIMIT_STACK, (resource.RLIM_INFINITY, resource.RLIM_INFINITY)) rook1, rook2, white, black = input().split() ...
output
1
100,686
15
201,373
Provide tags and a correct Python 3 solution for this coding contest problem. Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. "Aha, blacks certainly didn't win!", — Volodya said and was right for...
instruction
0
100,687
15
201,374
Tags: implementation Correct Solution: ``` pos = input().split() ranks = 'abcdefgh' intPos = [] for piece in pos: intPos.append([ranks.index(piece[0]),int(piece[1])-1]) guarded = [] shift = 1 while intPos[0][0] + shift < 8: square = [intPos[0][0]+shift,intPos[0][1]] if square == intPos[2]: break ...
output
1
100,687
15
201,375
Provide tags and a correct Python 3 solution for this coding contest problem. Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. "Aha, blacks certainly didn't win!", — Volodya said and was right for...
instruction
0
100,688
15
201,376
Tags: implementation Correct Solution: ``` import string class Position: def __init__(self, r, c): self.r = r self.c = c def s_to_position(s): letter, number = s[0], s[1] return Position(string.ascii_letters.index(letter), int(number) - 1) def finish(message): print(message) import sys; sys.exit() ...
output
1
100,688
15
201,377
Provide tags and a correct Python 3 solution for this coding contest problem. Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. "Aha, blacks certainly didn't win!", — Volodya said and was right for...
instruction
0
100,689
15
201,378
Tags: implementation Correct Solution: ``` board = [[1] * 10 for i in range(10)] for i in range(1, 9): for j in range(1, 9): board[i][j] = 0 pieces = input().split() d = 'abcdefgh' for i in range(len(pieces)): pieces[i] = (d.index(pieces[i][0]) + 1, int(pieces[i][1])) x, y = pieces[2] for i in range(-1,...
output
1
100,689
15
201,379
Provide tags and a correct Python 3 solution for this coding contest problem. Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. "Aha, blacks certainly didn't win!", — Volodya said and was right for...
instruction
0
100,690
15
201,380
Tags: implementation Correct Solution: ``` import sys b = 'sabcdefgh' a1,a2,a3,a4 = map(str,input().split()) x1 = b.index(a1[0])-1 y1 = int(a1[1]) -1 x2 = b.index(a2[0])-1 y2 = int(a2[1]) -1 x3 = b.index(a3[0])-1 y3 = int(a3[1]) -1 x4 = b.index(a4[0])-1 y4 = int(a4[1]) -1 c = [] for i in range(8): c.append([0]*8) p...
output
1
100,690
15
201,381