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 |
|---|---|---|---|---|---|
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,350 | 15 | 154,700 |
Yes | output | 1 | 77,350 | 15 | 154,701 |
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,351 | 15 | 154,702 |
Yes | output | 1 | 77,351 | 15 | 154,703 |
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,352 | 15 | 154,704 |
Yes | output | 1 | 77,352 | 15 | 154,705 |
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,353 | 15 | 154,706 |
No | output | 1 | 77,353 | 15 | 154,707 |
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,354 | 15 | 154,708 |
No | output | 1 | 77,354 | 15 | 154,709 |
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,356 | 15 | 154,712 |
No | output | 1 | 77,356 | 15 | 154,713 |
Provide a correct Python 3 solution for this coding contest problem.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In add... | instruction | 0 | 77,511 | 15 | 155,022 |
"Correct Solution:
```
def search(x, y, imap, acc):
imap[x][y] = 0
acc += 1
ret = acc
a = b = c = d = 0
if imap[x - 1][y]:
a = search(x - 1, y, imap, acc)
if ret < a:
ret = a
if imap[x + 1][y]:
b = search(x + 1, y, imap, acc)
if ret < b:
ret = b
if imap[x][y - 1]:
c = searc... | output | 1 | 77,511 | 15 | 155,023 |
Provide a correct Python 3 solution for this coding contest problem.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In add... | instruction | 0 | 77,512 | 15 | 155,024 |
"Correct Solution:
```
def b(M,x,y,n=1):
M[x][y]='0';t=[]
if'1'==M[x-1][y]:t+=[b(M,x-1,y,n+1)]
if'1'==M[x][y-1]:t+=[b(M,x,y-1,n+1)]
if'1'==M[x+1][y]:t+=[b(M,x+1,y,n+1)]
if'1'==M[x][y+1]:t+=[b(M,x,y+1,n+1)]
M[x][y]='1'
return max([n]+t)
for e in iter(input,'0'):
n,m=int(e),int(input())
P=[['0']*(n+2)for _ in[0]... | output | 1 | 77,512 | 15 | 155,025 |
Provide a correct Python 3 solution for this coding contest problem.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In add... | instruction | 0 | 77,513 | 15 | 155,026 |
"Correct Solution:
```
import sys
r=sys.stdin.readline
def s():
def b(M,x,y,n=1):
M[x][y]=0;a=n
if M[x-1][y]:a=max(a,b(M,x-1,y,n+1))
if M[x][y-1]:a=max(a,b(M,x,y-1,n+1))
if M[x+1][y]:a=max(a,b(M,x+1,y,n+1))
if M[x][y+1]:a=max(a,b(M,x,y+1,n+1))
M[x][y]=1
return a
for e in iter(r,'0\n'):
n,m=int(e),int(... | output | 1 | 77,513 | 15 | 155,027 |
Provide a correct Python 3 solution for this coding contest problem.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In add... | instruction | 0 | 77,514 | 15 | 155,028 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline
def bfs(H, W, maze, sx, sy):
max_ans = 1
# 上下左右に移動する場合の座標の変化量
dx = [0, 0, -1, 1]
dy = [-1, 1, 0, 0]
path = [(sx, sy)] # 切り取りに含める切手の座標 (まずは探索開始地点... | output | 1 | 77,514 | 15 | 155,029 |
Provide a correct Python 3 solution for this coding contest problem.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In add... | instruction | 0 | 77,515 | 15 | 155,030 |
"Correct Solution:
```
def s():
def b(M,x,y,n=0):
if M[x][y]==0:return n
M[x][y]=0
a=max(b(M,x-1,y,n+1),b(M,x,y-1,n+1),b(M,x+1,y,n+1),b(M,x,y+1,n+1))
M[x][y]=1
return a
for e in iter(input,'0'):
n,m=int(e),int(input())
P=[[0]*(n+2)for _ in[0]*(m+2)]
for i in range(m):P[i+1][1:-1]=map(int,input().split... | output | 1 | 77,515 | 15 | 155,031 |
Provide a correct Python 3 solution for this coding contest problem.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In add... | instruction | 0 | 77,516 | 15 | 155,032 |
"Correct Solution:
```
def s():
def b(M,x,y,n=0):
if M[x][y]==0:return n
M[x][y]=0
a=max(b(M,x+s,y+t,n+1)for s,t in[(-1,0),(0,-1),(1,0),(0,1)])
M[x][y]=1
return a
for e in iter(input,'0'):
n,m=int(e),int(input())
P=[[0]*(n+2)for _ in[0]*(m+2)]
for i in range(m):P[i+1][1:-1]=map(int,input().split())
... | output | 1 | 77,516 | 15 | 155,033 |
Provide a correct Python 3 solution for this coding contest problem.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In add... | instruction | 0 | 77,517 | 15 | 155,034 |
"Correct Solution:
```
def s():
def b(M,x,y,n):
M[x][y]=0;a=n
if M[x-1][y]:a=max(a,b(M,x-1,y,n+1))
if M[x][y-1]:a=max(a,b(M,x,y-1,n+1))
if M[x+1][y]:a=max(a,b(M,x+1,y,n+1))
if M[x][y+1]:a=max(a,b(M,x,y+1,n+1))
M[x][y]=1
return a
for e in iter(input,'0'):
n,m=int(e),int(input())
P=[[0]*(n+2)for _ in[... | output | 1 | 77,517 | 15 | 155,035 |
Provide a correct Python 3 solution for this coding contest problem.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In add... | instruction | 0 | 77,518 | 15 | 155,036 |
"Correct Solution:
```
def solve():
while True:
m, n = int(input()), int(input())
if not m:
break
ices = [[0] + list(map(int,input().split())) + [0] for _ in range(n)]
ices.insert(0, [0] * (m + 2),)
ices.append([0] * (m + 2))
score = [[0] * (m + 2) for _ in range(n + 2)]
for x ... | output | 1 | 77,518 | 15 | 155,037 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n secti... | instruction | 0 | 77,519 | 15 | 155,038 |
Yes | output | 1 | 77,519 | 15 | 155,039 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n secti... | instruction | 0 | 77,520 | 15 | 155,040 |
Yes | output | 1 | 77,520 | 15 | 155,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n secti... | instruction | 0 | 77,521 | 15 | 155,042 |
Yes | output | 1 | 77,521 | 15 | 155,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n secti... | instruction | 0 | 77,522 | 15 | 155,044 |
Yes | output | 1 | 77,522 | 15 | 155,045 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n secti... | instruction | 0 | 77,523 | 15 | 155,046 |
No | output | 1 | 77,523 | 15 | 155,047 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n secti... | instruction | 0 | 77,524 | 15 | 155,048 |
No | output | 1 | 77,524 | 15 | 155,049 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n secti... | instruction | 0 | 77,525 | 15 | 155,050 |
No | output | 1 | 77,525 | 15 | 155,051 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n secti... | instruction | 0 | 77,526 | 15 | 155,052 |
No | output | 1 | 77,526 | 15 | 155,053 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite line consisting of cells. There are n boxes in some cells of this line. The i-th box stands in the cell a_i and has weight w_i. All a_i are distinct, moreover, a_{i - 1} < a... | instruction | 0 | 77,567 | 15 | 155,134 |
No | output | 1 | 77,567 | 15 | 155,135 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite line consisting of cells. There are n boxes in some cells of this line. The i-th box stands in the cell a_i and has weight w_i. All a_i are distinct, moreover, a_{i - 1} < a... | instruction | 0 | 77,568 | 15 | 155,136 |
No | output | 1 | 77,568 | 15 | 155,137 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite line consisting of cells. There are n boxes in some cells of this line. The i-th box stands in the cell a_i and has weight w_i. All a_i are distinct, moreover, a_{i - 1} < a... | instruction | 0 | 77,569 | 15 | 155,138 |
No | output | 1 | 77,569 | 15 | 155,139 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite line consisting of cells. There are n boxes in some cells of this line. The i-th box stands in the cell a_i and has weight w_i. All a_i are distinct, moreover, a_{i - 1} < a... | instruction | 0 | 77,570 | 15 | 155,140 |
No | output | 1 | 77,570 | 15 | 155,141 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — move one cell down;
* 'A' — move one cell left;... | instruction | 0 | 77,609 | 15 | 155,218 |
Tags: brute force, data structures, dp, greedy, implementation, math, strings
Correct Solution:
```
def main():
h, v = hv = ([0], [0])
f = {'W': (v, -1), 'S': (v, 1), 'A': (h, -1), 'D': (h, 1)}.get
for _ in range(int(input())):
del h[1:], v[1:]
for l, d in map(f, input()):
l.appe... | output | 1 | 77,609 | 15 | 155,219 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — move one cell down;
* 'A' — move one cell left;... | instruction | 0 | 77,610 | 15 | 155,220 |
Tags: brute force, data structures, dp, greedy, implementation, math, strings
Correct Solution:
```
import sys
def work(c,c1, s):
maxlast, maxfirst,minlast,minfirst = 0,0,0,0
max = 0
min = 0
y = 0
for i in range(len(s)):
if s[i] == c:
y += 1
elif s[i] == c1:
y... | output | 1 | 77,610 | 15 | 155,221 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — move one cell down;
* 'A' — move one cell left;... | instruction | 0 | 77,611 | 15 | 155,222 |
Tags: brute force, data structures, dp, greedy, implementation, math, strings
Correct Solution:
```
import sys
input = sys.stdin.readline
for _ in range(int(input())):
s = input().strip()
ans = 10**15
suffix_change = [0]*len(s)
mx_x = mn_x = mx_y = mn_y = 0
curr_x = curr_y = 0
for j in range... | output | 1 | 77,611 | 15 | 155,223 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — move one cell down;
* 'A' — move one cell left;... | instruction | 0 | 77,612 | 15 | 155,224 |
Tags: brute force, data structures, dp, greedy, implementation, math, strings
Correct Solution:
```
for _ in range(int(input())):
s=input()
ar=["AD","WS"]
nr=[[],[]]
for e in s:
if(e in ar[0]):nr[0].append(e)
else: nr[1].append(e)
b,c=[float('inf')]*2,[float('inf')]*2
for i in ra... | output | 1 | 77,612 | 15 | 155,225 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — move one cell down;
* 'A' — move one cell left;... | instruction | 0 | 77,613 | 15 | 155,226 |
Tags: brute force, data structures, dp, greedy, implementation, math, strings
Correct Solution:
```
import sys
input = sys.stdin.readline
Q=int(input())
for testcases in range(Q):
S=input().strip()
X=Y=0
MAXX=MINX=MAXY=MINY=0
for s in S:
if s=="D":
X+=1
MAXX=max(M... | output | 1 | 77,613 | 15 | 155,227 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — move one cell down;
* 'A' — move one cell left;... | instruction | 0 | 77,614 | 15 | 155,228 |
Tags: brute force, data structures, dp, greedy, implementation, math, strings
Correct Solution:
```
def solve():
i = 0
j = 0
imax = imin = 0
jmax = jmin = 0
fjmin = ljmin = fjmax = ljmax = fimax = limax = fimin = limin = -1
for ind, e in enumerate(input()):
if e == 'W':
i += ... | output | 1 | 77,614 | 15 | 155,229 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — move one cell down;
* 'A' — move one cell left;... | instruction | 0 | 77,615 | 15 | 155,230 |
Tags: brute force, data structures, dp, greedy, implementation, math, strings
Correct Solution:
```
# coding=utf-8
INF = 1e11
# move = {'W': (0, 0), 'A': (0, 0), 'S': (0, 0), 'D': (0, 0)}
move = {'W': (0, 1), 'A': (-1, 0), 'S': (0, -1), 'D': (1, 0)}
def getExtremes(positions):
minX, minY, maxX, maxY = [positions... | output | 1 | 77,615 | 15 | 155,231 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — move one cell down;
* 'A' — move one cell left;... | instruction | 0 | 77,616 | 15 | 155,232 |
Tags: brute force, data structures, dp, greedy, implementation, math, strings
Correct Solution:
```
t= int(input())
for _ in range(0,t):
a= list(input())
nowx=0
nowy=0
maxx=0
minx=0
maxy=0
miny=0
tmaxx=0
tminx=0
tmaxy=0
tminy=0
highw=0
highs=0
widthd=0
width... | output | 1 | 77,616 | 15 | 155,233 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — mov... | instruction | 0 | 77,617 | 15 | 155,234 |
Yes | output | 1 | 77,617 | 15 | 155,235 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — mov... | instruction | 0 | 77,618 | 15 | 155,236 |
Yes | output | 1 | 77,618 | 15 | 155,237 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — mov... | instruction | 0 | 77,619 | 15 | 155,238 |
Yes | output | 1 | 77,619 | 15 | 155,239 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — mov... | instruction | 0 | 77,620 | 15 | 155,240 |
Yes | output | 1 | 77,620 | 15 | 155,241 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — mov... | instruction | 0 | 77,621 | 15 | 155,242 |
No | output | 1 | 77,621 | 15 | 155,243 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — mov... | instruction | 0 | 77,622 | 15 | 155,244 |
No | output | 1 | 77,622 | 15 | 155,245 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — mov... | instruction | 0 | 77,623 | 15 | 155,246 |
No | output | 1 | 77,623 | 15 | 155,247 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' — move one cell up;
* 'S' — mov... | instruction | 0 | 77,624 | 15 | 155,248 |
No | output | 1 | 77,624 | 15 | 155,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.
There are also n cards, each card has 2 attributes: length... | instruction | 0 | 77,836 | 15 | 155,672 |
Tags: bitmasks, brute force, dp, math
Correct Solution:
```
import sys
n = int(input())
l = list(map(int,input().split()))
c = list(map(int,input().split()))
def gcd(a, b):
while b > 0:
a, b = b, a % b
return a
a = {0:0}
b = [0]
for i in range(n):
for p in b:
d = gcd(p, l[i])
cos... | output | 1 | 77,836 | 15 | 155,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.
There are also n cards, each card has 2 attributes: length... | instruction | 0 | 77,837 | 15 | 155,674 |
Tags: bitmasks, brute force, dp, math
Correct Solution:
```
def main():
input()
acc = {0: 0}
for p, c in zip(list(map(int, input().split())),
list(map(int, input().split()))):
adds = []
for b, u in acc.items():
a = p
while b:
a, b =... | output | 1 | 77,837 | 15 | 155,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.
There are also n cards, each card has 2 attributes: length... | instruction | 0 | 77,838 | 15 | 155,676 |
Tags: bitmasks, brute force, dp, math
Correct Solution:
```
def gcd(x,y):
while x % y > 0:
x, y = y, x % y
return y
n = int(input())
a, b, c = [int(x) for x in input().split()], [int(x) for x in input().split()], [{} for i in range(n)]
def f(i,g):
if g == 1:
return 0
if i == n:
r... | output | 1 | 77,838 | 15 | 155,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.
There are also n cards, each card has 2 attributes: length... | instruction | 0 | 77,839 | 15 | 155,678 |
Tags: bitmasks, brute force, dp, math
Correct Solution:
```
import sys
n = int(input())
l = list(map(int,input().split()))
c = list(map(int,input().split()))
def gcd(a, b):
if b == 0: return a
return gcd(b, a % b)
a = {0:0}
for i in range(n):
b = a.copy()
for p in a.items():
d = gcd(p[0], l[... | output | 1 | 77,839 | 15 | 155,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.
There are also n cards, each card has 2 attributes: length... | instruction | 0 | 77,840 | 15 | 155,680 |
Tags: bitmasks, brute force, dp, math
Correct Solution:
```
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key,lru_cache
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_siz... | output | 1 | 77,840 | 15 | 155,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.
There are also n cards, each card has 2 attributes: length... | instruction | 0 | 77,841 | 15 | 155,682 |
Tags: bitmasks, brute force, dp, math
Correct Solution:
```
import sys
n = int(input())
l = list(map(int,input().split()))
c = list(map(int,input().split()))
def gcd(a, b):
if b == 0: return a
return gcd(b, a % b)
a = {0:0}
b = [0]
for i in range(n):
for p in b:
d = gcd(p, l[i])
cost = a... | output | 1 | 77,841 | 15 | 155,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.
There are also n cards, each card has 2 attributes: length... | instruction | 0 | 77,842 | 15 | 155,684 |
Tags: bitmasks, brute force, dp, math
Correct Solution:
```
from collections import defaultdict
from math import gcd
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
dp = defaultdict(lambda: float("inf"))
for a, b in zip(A, B):
dp[a] = min(dp[a], b)
for d in dp.copy():
... | output | 1 | 77,842 | 15 | 155,685 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.
There are also n cards, each card has 2 attributes: length... | instruction | 0 | 77,843 | 15 | 155,686 |
Tags: bitmasks, brute force, dp, math
Correct Solution:
```
import fractions
def dfs(s, g) :
global cache, N, L, C
if g == 1 : return 0
if s == N : return float("INF")
if g in cache[s] :
return cache[s][g]
cache[s][g] = min(dfs(s+1, g),dfs(s+1, gcd(g, L[s]))+C[s])
return cache[s][g]
... | output | 1 | 77,843 | 15 | 155,687 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.