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. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one st...
instruction
0
73,322
15
146,644
Tags: graphs, shortest paths Correct Solution: ``` import sys from collections import deque input=sys.stdin.readline n,m=map(int,input().split()) sy,sx=map(int,input().split()) sy-=1 sx-=1 can_l,can_r=map(int,input().split()) a=[input().rstrip() for i in range(n)] d=[[-1]*m for i in range(n)] dq=deque() dq.append([sy,s...
output
1
73,322
15
146,645
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one st...
instruction
0
73,323
15
146,646
Tags: graphs, shortest paths Correct Solution: ``` # ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction import sys import threading from collections...
output
1
73,323
15
146,647
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one st...
instruction
0
73,324
15
146,648
Tags: graphs, shortest paths Correct Solution: ``` # ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction import sys import threading from collections...
output
1
73,324
15
146,649
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one st...
instruction
0
73,325
15
146,650
Tags: graphs, shortest paths Correct Solution: ``` #!/usr/bin/env python3 import sys from collections import deque from math import inf def rint(): return map(int, sys.stdin.readline().split()) #lines = stdin.readlines() def bfs(sr, sc): global ans q = deque() q.append((x, y, sr, sc)) visit[sr][sc...
output
1
73,325
15
146,651
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one st...
instruction
0
73,326
15
146,652
Tags: graphs, shortest paths Correct Solution: ``` def main(): n,m = map(int, input().split()) r,c = map(int, input().split()) L,R = map(int, input().split()) lab = [input() for _ in range(n)] r -= 1 c -= 1 inf = n*m+1 dist = [[inf] * m for _ in range(n)] dist[r][c] = 0 ...
output
1
73,326
15
146,653
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starti...
instruction
0
73,327
15
146,654
Yes
output
1
73,327
15
146,655
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starti...
instruction
0
73,328
15
146,656
Yes
output
1
73,328
15
146,657
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starti...
instruction
0
73,329
15
146,658
Yes
output
1
73,329
15
146,659
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starti...
instruction
0
73,330
15
146,660
Yes
output
1
73,330
15
146,661
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starti...
instruction
0
73,331
15
146,662
No
output
1
73,331
15
146,663
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starti...
instruction
0
73,332
15
146,664
No
output
1
73,332
15
146,665
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starti...
instruction
0
73,333
15
146,666
No
output
1
73,333
15
146,667
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starti...
instruction
0
73,334
15
146,668
No
output
1
73,334
15
146,669
Provide a correct Python 3 solution for this coding contest problem. Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it. The player chooses a square as a starting point and plac...
instruction
0
74,120
15
148,240
"Correct Solution: ``` n = int(input()) *A, = map(int, input().split()) l = [0]*n for i in range(n): if l[i] == 0: s = set() p = i can = 1 while p not in s: if l[p] == 1: can = 0 break s.add(p) l[p] = 1 ...
output
1
74,120
15
148,241
Provide a correct Python 3 solution for this coding contest problem. Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it. The player chooses a square as a starting point and plac...
instruction
0
74,121
15
148,242
"Correct Solution: ``` import sys sys.setrecursionlimit(1000000) n = int(input()) alst = list(map(int, input().split())) edges = [[] for _ in range(n)] rev_edges = [[] for _ in range(n)] for i in range(n): edges[i].append((i + alst[i]) % n) rev_edges[(i + alst[i]) % n].append(i) def dfs(x, ret, edges, visited): ...
output
1
74,121
15
148,243
Provide a correct Python 3 solution for this coding contest problem. Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it. The player chooses a square as a starting point and plac...
instruction
0
74,122
15
148,244
"Correct Solution: ``` import sys sys.setrecursionlimit(1000000) def dfs(x, order, edges, visited): visited[x] = True for e in edges[x]: if not visited[e]: dfs(e, order, edges, visited) order.append(x) def dfs_rev(x, rev_edges, visited): visited[x] = True ret = 0 for e in rev_edges[x]: if no...
output
1
74,122
15
148,245
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it. ...
instruction
0
74,123
15
148,246
No
output
1
74,123
15
148,247
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it. ...
instruction
0
74,124
15
148,248
No
output
1
74,124
15
148,249
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it. ...
instruction
0
74,125
15
148,250
No
output
1
74,125
15
148,251
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it. ...
instruction
0
74,126
15
148,252
No
output
1
74,126
15
148,253
Provide a correct Python 3 solution for this coding contest problem. Go around the Labyrinth Explorer Taro got a floor plan of a labyrinth. The floor of this labyrinth is in the form of a two-dimensional grid. Each of the cells on the floor plan corresponds to a room and is indicated whether it can be entered or not....
instruction
0
74,128
15
148,256
"Correct Solution: ``` dd = [(-1, 0), (0, -1), (1, 0), (0, 1)] while 1: n, m = map(int, input().split()) if n == m == 0: break C = [list(input() + "#") for i in range(n)] + ["#"*(m+2)] used = [[0]*m for i in range(n)] def move(x0, y0, x1, y1, d): x = x0; y = y0 moved = 0; cn...
output
1
74,128
15
148,257
Provide a correct Python 3 solution for this coding contest problem. Go around the Labyrinth Explorer Taro got a floor plan of a labyrinth. The floor of this labyrinth is in the form of a two-dimensional grid. Each of the cells on the floor plan corresponds to a room and is indicated whether it can be entered or not....
instruction
0
74,129
15
148,258
"Correct Solution: ``` #!/usr/bin/env python3 # -*- coding: utf-8 -*- import copy def rdp_connect() -> bool: global n, m, c n, m = map(int, input().split()) if n == m == 0: return False c = [list(input()) for _ in range(n)] return True def rdp_check() -> bool: DY = (0, 1, 0, -1) D...
output
1
74,129
15
148,259
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe likes to be able to walk through his city on a path lit by street lamps. That way, he doesn't get beaten up by schoolchildren. Okabe's city is represented by a 2D grid of cells. Rows are ...
instruction
0
74,690
15
149,380
No
output
1
74,690
15
149,381
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe likes to be able to walk through his city on a path lit by street lamps. That way, he doesn't get beaten up by schoolchildren. Okabe's city is represented by a 2D grid of cells. Rows are ...
instruction
0
74,691
15
149,382
No
output
1
74,691
15
149,383
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe likes to be able to walk through his city on a path lit by street lamps. That way, he doesn't get beaten up by schoolchildren. Okabe's city is represented by a 2D grid of cells. Rows are ...
instruction
0
74,692
15
149,384
No
output
1
74,692
15
149,385
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe likes to be able to walk through his city on a path lit by street lamps. That way, he doesn't get beaten up by schoolchildren. Okabe's city is represented by a 2D grid of cells. Rows are ...
instruction
0
74,693
15
149,386
No
output
1
74,693
15
149,387
Provide a correct Python 3 solution for this coding contest problem. Taro is an elementary school student and has graffiti on the back of the leaflet. At one point, Taro came up with the next game. * Write n × n grid-like squares. * The initial state of each square is either marked or unmarked. * Erase or write these...
instruction
0
74,914
15
149,828
"Correct Solution: ``` import sys from heapq import heappush, heappop class MinCostFlow: INF = 10**18 def __init__(self, N): self.N = N self.G = [[] for i in range(N)] def add_edge(self, fr, to, cap, cost): G = self.G G[fr].append([to, cap, cost, len(G[to])]) G[to]...
output
1
74,914
15
149,829
Provide a correct Python 3 solution for this coding contest problem. Taro is an elementary school student and has graffiti on the back of the leaflet. At one point, Taro came up with the next game. * Write n × n grid-like squares. * The initial state of each square is either marked or unmarked. * Erase or write these...
instruction
0
74,915
15
149,830
"Correct Solution: ``` # -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in ran...
output
1
74,915
15
149,831
Provide a correct Python 3 solution for this coding contest problem. Taro is an elementary school student and has graffiti on the back of the leaflet. At one point, Taro came up with the next game. * Write n × n grid-like squares. * The initial state of each square is either marked or unmarked. * Erase or write these...
instruction
0
74,916
15
149,832
"Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import time,random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 mod2 = 998244353 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)...
output
1
74,916
15
149,833
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Your task is to implement a double linked list. Write a program which performs the following operations: * insert x: insert an element with key x into the front of the list. * delete x: delete...
instruction
0
74,947
15
149,894
No
output
1
74,947
15
149,895
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One ca...
instruction
0
74,983
15
149,966
Tags: constructive algorithms Correct Solution: ``` n = int(input()) ans = [(0, 0)] for i in range(1, n): ans.append((0, i)) ans.append((i, 0)) ans.append((0, -i)) ans.append((-i, 0)) for i in range(n): print(str(ans[i][0]) + ' ' + str(ans[i][1])) ```
output
1
74,983
15
149,967
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One ca...
instruction
0
74,984
15
149,968
Tags: constructive algorithms Correct Solution: ``` gcd = lambda a, b: gcd(b, a % b) if b else a def main(): n = int(input()) if n == 1: print(0, 0) return y = 2 * n // 3 if 2 * n % 2: y += 1 s = 0 for i in range(y): print(i, 0) s += 1 for j in r...
output
1
74,984
15
149,969
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One ca...
instruction
0
74,985
15
149,970
Tags: constructive algorithms Correct Solution: ``` n = int(input()) ans = [(0, 0)] for i in range(1, n): ans.append((0, i)) ans.append((i, 0)) ans.append((0, -i)) ans.append((-i, 0)) for i in range(n): print(str(ans[i][0]) + ' ' + str(ans[i][1])) #JSR ```
output
1
74,985
15
149,971
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One ca...
instruction
0
74,986
15
149,972
Tags: constructive algorithms Correct Solution: ``` n = int(input()) ctr = i = 0 while ctr < n: print(i,0) ctr += 1 if i % 2 and ctr < n: print(i,3) ctr += 1 i+=1 ```
output
1
74,986
15
149,973
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One ca...
instruction
0
74,987
15
149,974
Tags: constructive algorithms Correct Solution: ``` n = int(input()) for i in range(n): print(2 * i//3 , 2*i %3) ```
output
1
74,987
15
149,975
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One ca...
instruction
0
74,988
15
149,976
Tags: constructive algorithms Correct Solution: ``` gcd = lambda a, b: gcd(b, a % b) if b else a def main(): k = int(input()) if k == 1: print(0, 0) return x = 2 * k // 3 if 2 * k% 2: x += 1 s = 0 for i in range(x): print(i, 0) s += 1 for j in ra...
output
1
74,988
15
149,977
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One ca...
instruction
0
74,989
15
149,978
Tags: constructive algorithms Correct Solution: ``` n=int(input()) for i in range(n//3): print(2*i,0) print(2*i+1,0) print(2*i+1,3) for i in range(n%3): print(2*(n//3)+i,0) ```
output
1
74,989
15
149,979
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One ca...
instruction
0
74,990
15
149,980
Tags: constructive algorithms Correct Solution: ``` #!/usr/bin/env python3 # -*- coding: utf-8 -*- n = int(input()) above = n // 3 below = n - above for i in range(above): print(2 * i + 1, 3) for i in range(below): print(i, 0) ```
output
1
74,990
15
149,981
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ...
instruction
0
74,991
15
149,982
Yes
output
1
74,991
15
149,983
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ...
instruction
0
74,992
15
149,984
Yes
output
1
74,992
15
149,985
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ...
instruction
0
74,993
15
149,986
Yes
output
1
74,993
15
149,987
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ...
instruction
0
74,994
15
149,988
Yes
output
1
74,994
15
149,989
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ...
instruction
0
74,995
15
149,990
No
output
1
74,995
15
149,991
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ...
instruction
0
74,996
15
149,992
No
output
1
74,996
15
149,993
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ...
instruction
0
74,997
15
149,994
No
output
1
74,997
15
149,995
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ...
instruction
0
74,998
15
149,996
No
output
1
74,998
15
149,997
Provide tags and a correct Python 3 solution for this coding contest problem. Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm. His farm is presented by a rectangle grid with r rows and c columns. Some of these cells contain r...
instruction
0
75,110
15
150,220
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` #------------------------template--------------------------# import os import sys # from math import * from collections import * # from fractions import * # from heapq import* from bisect import * from io import BytesIO, IOBase def vsInput(): ...
output
1
75,110
15
150,221
Provide tags and a correct Python 3 solution for this coding contest problem. Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm. His farm is presented by a rectangle grid with r rows and c columns. Some of these cells contain r...
instruction
0
75,111
15
150,222
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` mod = 1000000007 eps = 10**-9 def main(): import sys from string import ascii_letters, digits input = sys.stdin.readline SS = ascii_letters + digits for _ in range(int(input())): H, W, K = map(int, input().split()...
output
1
75,111
15
150,223
Provide tags and a correct Python 3 solution for this coding contest problem. Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm. His farm is presented by a rectangle grid with r rows and c columns. Some of these cells contain r...
instruction
0
75,112
15
150,224
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter import itertools from itertools import permutations,combinations import sys import bisect import string import math import time #import random def I():...
output
1
75,112
15
150,225
Provide tags and a correct Python 3 solution for this coding contest problem. Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm. His farm is presented by a rectangle grid with r rows and c columns. Some of these cells contain r...
instruction
0
75,113
15
150,226
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` from math import * from collections import * import sys sys.setrecursionlimit(10**9) t = [chr(48+i) for i in range(10)] s = [chr(97+i) for i in range(26)] l = [chr(65+i) for i in range(26)] l.extend(s) l.extend(t) t = int(input()) for y in rang...
output
1
75,113
15
150,227