message stringlengths 2 28.7k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 21 109k | cluster float64 7 7 | __index_level_0__ int64 42 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows and m columns. Each cell is either black or wh... | instruction | 0 | 38,793 | 7 | 77,586 |
Tags: dfs and similar, graphs, implementation, shortest paths
Correct Solution:
```
from sys import stdin, stdout, setrecursionlimit
input = stdin.readline
# import string
# characters = string.ascii_lowercase
# digits = string.digits
# setrecursionlimit(int(1e6))
dir = [-1,0,1,0,-1]
# moves = 'NESW'
inf = float('inf')... | output | 1 | 38,793 | 7 | 77,587 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows and m columns. Each cell is either black or wh... | instruction | 0 | 38,794 | 7 | 77,588 |
Tags: dfs and similar, graphs, implementation, shortest paths
Correct Solution:
```
from collections import deque
n, m, t = map(int, input().split())
s = []
for _ in range(n):
s.append(input())
query = []
for _ in range(t):
i, j, p = map(int, input().split())
query.append((i-1, j-1, p))
dist = [[-1]*m for ... | output | 1 | 38,794 | 7 | 77,589 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows and m columns. Each cell is either black or wh... | instruction | 0 | 38,795 | 7 | 77,590 |
Tags: dfs and similar, graphs, implementation, shortest paths
Correct Solution:
```
import sys
from collections import deque
# import numpy as np
input = sys.stdin.readline
# print = sys.stdout.writeline
n,m,t = map(int, input().split())
grid = [input().strip() for i in range(n)]
dist = [[-1]*m for i in range(n)]
... | output | 1 | 38,795 | 7 | 77,591 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows and m columns. Each cell is either black or wh... | instruction | 0 | 38,796 | 7 | 77,592 |
Tags: dfs and similar, graphs, implementation, shortest paths
Correct Solution:
```
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]... | output | 1 | 38,796 | 7 | 77,593 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows... | instruction | 0 | 38,797 | 7 | 77,594 |
Yes | output | 1 | 38,797 | 7 | 77,595 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows... | instruction | 0 | 38,798 | 7 | 77,596 |
Yes | output | 1 | 38,798 | 7 | 77,597 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows... | instruction | 0 | 38,799 | 7 | 77,598 |
Yes | output | 1 | 38,799 | 7 | 77,599 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows... | instruction | 0 | 38,800 | 7 | 77,600 |
Yes | output | 1 | 38,800 | 7 | 77,601 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows... | instruction | 0 | 38,801 | 7 | 77,602 |
No | output | 1 | 38,801 | 7 | 77,603 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows... | instruction | 0 | 38,802 | 7 | 77,604 |
No | output | 1 | 38,802 | 7 | 77,605 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows... | instruction | 0 | 38,803 | 7 | 77,606 |
No | output | 1 | 38,803 | 7 | 77,607 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows... | instruction | 0 | 38,804 | 7 | 77,608 |
No | output | 1 | 38,804 | 7 | 77,609 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well... | instruction | 0 | 39,339 | 7 | 78,678 |
Tags: binary search, two pointers
Correct Solution:
```
n, m = map(int, input().split())
c = list(map(int, input().split()))
k = list(map(int, input().split()))
p = [0] * m
c = [i -1 for i in c]
s = sum(k)
cnt = k.count(0)
l = 0
r = 0
while r < n and cnt < m:
p[c[r]] += 1
if p[c[r]] == k[c[r]]:
cnt += 1... | output | 1 | 39,339 | 7 | 78,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well... | instruction | 0 | 39,340 | 7 | 78,680 |
Tags: binary search, two pointers
Correct Solution:
```
INF = 1 << 60
n, m = map(int, input().split())
a = list(map(int, input().split()))
Constraint = [0] + list(map(int, input().split()))
pos = 0
satisfied_color = 0
for i in range(1,m + 1):
if Constraint[i] == 0:
satisfied_color += 1
GETCOLOR = [0]*(n + ... | output | 1 | 39,340 | 7 | 78,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well... | instruction | 0 | 39,341 | 7 | 78,682 |
Tags: binary search, two pointers
Correct Solution:
```
n,m=list(map(int,input().split()))
arr=list(map(int,input().split()))
marr=list(map(int,input().split()))
f=[0]*(m+1)
cnt,i=0,0
valid=sum(marr) #m
while(i<n):
f[arr[i]]+=1
if f[arr[i]]<=marr[arr[i]-1]:
cnt+=1
if cnt==valid:
br... | output | 1 | 39,341 | 7 | 78,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well... | instruction | 0 | 39,342 | 7 | 78,684 |
Tags: binary search, two pointers
Correct Solution:
```
from bisect import bisect_left,bisect_right
from heapq import heappop,heappush,heapify
from collections import deque
n,m=map(int,input().split())
arr=list(map(int,input().split()))
brr=list(map(int,input().split()))
sum_brr=sum(brr)
lst=[[] for i in range(m+1)]
fo... | output | 1 | 39,342 | 7 | 78,685 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well... | instruction | 0 | 39,343 | 7 | 78,686 |
Tags: binary search, two pointers
Correct Solution:
```
from collections import defaultdict
n, m = map(int, input().split())
ns = list(map(int, input().split()))
ms = list(map(int, input().split()))
summs = sum(ms)
target = {
i: m
for i, m in enumerate(ms, 1)
}
remain = set(i for i, m in target.items() if m... | output | 1 | 39,343 | 7 | 78,687 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well... | instruction | 0 | 39,344 | 7 | 78,688 |
Tags: binary search, two pointers
Correct Solution:
```
import random, math
from copy import deepcopy as dc
from bisect import bisect_left, bisect_right
# Function to call the actual solution
def solution(li, li1):
freq = {}
for i in range(len(li1)):
if li1[i]:
freq[i+1] = li1[i]
maxi = len(li)
# Exclusiv... | output | 1 | 39,344 | 7 | 78,689 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well... | instruction | 0 | 39,345 | 7 | 78,690 |
Tags: binary search, two pointers
Correct Solution:
```
n, m = map(int, input().split())
c = list(map(int, input().split()))
k = list(map(int, input().split()))
p = [0] * m
c = [o - 1 for o in c]
s = sum(k)
ok = k.count(0)
i1 = 0
i2 = 0
while i2 < n and ok < m:
p[c[i2]] += 1
if p[c[i2]] == k[c[i2]]:
ok ... | output | 1 | 39,345 | 7 | 78,691 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekee... | instruction | 0 | 39,347 | 7 | 78,694 |
No | output | 1 | 39,347 | 7 | 78,695 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Play by arranging white and black stones on the table. First, place the stones on the left edge of the table. Then place the stones in the second place from the left. Repeat this n times to arrange n stones in a horizontal row. However, when... | instruction | 0 | 39,544 | 7 | 79,088 |
"Correct Solution:
```
while 1:
N = int(input())
if N == 0:
break
st = []
last = None
for i in range(N):
s = int(input())
if last is None:
last = [1, s]
st.append(last)
continue
if last[1] == s:
last[0] += 1
else... | output | 1 | 39,544 | 7 | 79,089 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Play by arranging white and black stones on the table. First, place the stones on the left edge of the table. Then place the stones in the second place from the left. Repeat this n times to arrange n stones in a horizontal row. However, when... | instruction | 0 | 39,545 | 7 | 79,090 |
"Correct Solution:
```
while True:
n = int(input())
if n==0: break
edge = 0
sq = 0
past = []
for i in range(n):
nxt = int(input())
if i==0:
edge = nxt
if i%2 == 0:
if nxt == edge:
sq += 1
else:
edge = n... | output | 1 | 39,545 | 7 | 79,091 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Play by arranging white and black stones on the table. First, place the stones on the left edge of the table. Then place the stones in the second place from the left. Repeat this n times to arrange n stones in a horizontal row. However, when... | instruction | 0 | 39,546 | 7 | 79,092 |
"Correct Solution:
```
# AOJ 0527: Setting Go Stones
# Python3 2018.7.1 bal4u
while True:
n = int(input())
if n == 0: break
a, c = [0]*100005, [0]*100005
sz, a[0], c[0] = 0, 1, int(input())
for i in range(n-1):
color = int(input())
if c[sz] == color: a[sz] += 1
elif i & 1:
sz += 1
a[sz] = 1
else:
... | output | 1 | 39,546 | 7 | 79,093 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Play by arranging white and black stones on the table. First, place the stones on the left edge of the table. Then place the stones in the second place from the left. Repeat this n times to arrange n stones in a horizontal row. However, when... | instruction | 0 | 39,547 | 7 | 79,094 |
"Correct Solution:
```
while 1:
n=int(input())
if n==0:break
a=[int(input()),1]
for i in range(n-1):
b=int(input())
if a[-2]==b:a[-1]+=1
if i&1 and a[-2]!=b:a+=[b]+[1]
elif a[-2]!=b:
if len(a)>2:
a[-3]+=a[-1]+1
a=a[:-2]
... | output | 1 | 39,547 | 7 | 79,095 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Play by arranging white and black stones on the table. First, place the stones on the left edge of the table. Then place the stones in the second place from the left. Repeat this n times to arrange n stones in a horizontal row. However, when... | instruction | 0 | 39,548 | 7 | 79,096 |
"Correct Solution:
```
while True:
n = int(input())
if not n: break
count = 0
flag = -1
lst = [0]
for i in range(n):
a = int(input())
if flag == a:
lst[-1] += 1
else:
if i % 2 == 0:
lst.append(1)
flag = a
else:
if len(lst) == 1:
lst[-1] += 1
... | output | 1 | 39,548 | 7 | 79,097 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Play by arranging white and black stones on the table. First, place the stones on the left edge of the table. Then place the stones in the second place from the left. Repeat this n times to arrange n stones in a horizontal row. However, when... | instruction | 0 | 39,549 | 7 | 79,098 |
"Correct Solution:
```
def main():
while True:
n = int(input())
if not n: break
flag = -1
lst = []
for i in range(n):
a = int(input())
if flag == a:
lst[-1] += 1
else:
if i % 2 == 0:
lst.append(1)
flag = a
else:
if len(lst) ==... | output | 1 | 39,549 | 7 | 79,099 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Play by arranging white and black stones on the table. First, place the stones on the left edge of the table. Then place the stones in the second place from the left. Repeat this n times to arrange n stones in a horizontal row. However, when... | instruction | 0 | 39,550 | 7 | 79,100 |
"Correct Solution:
```
while True:
n=int(input())
if n==0:break
com=[int(input())for i in range(n)]
seq=[1]
isW=com[0]==0
stW=isW
for i in range(1,n):
if i%2!=0:
if len(seq)!=1:
if (isW and com[i]==1)or(not isW and com[i]==0):
seq[len(s... | output | 1 | 39,550 | 7 | 79,101 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in som... | instruction | 0 | 39,704 | 7 | 79,408 |
Tags: constructive algorithms, math, number theory
Correct Solution:
```
n = int(input())
r = int(n ** 0.5) + 1
for i in range(2, r):
if n % i == 0:
while n % i == 0:
n //= i
print(i if n == 1 else 1)
break
else:
print(n)
``` | output | 1 | 39,704 | 7 | 79,409 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in som... | instruction | 0 | 39,705 | 7 | 79,410 |
Tags: constructive algorithms, math, number theory
Correct Solution:
```
##for debug comment out
import sys,atexit
from io import BytesIO
inp = BytesIO(sys.stdin.buffer.read())
input = lambda:inp.readline().decode('ascii')
buf = BytesIO()
#sys.stdout.write = lambda s: buf.write(s.encode('ascii'))
#print = lambda s: buf... | output | 1 | 39,705 | 7 | 79,411 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in som... | instruction | 0 | 39,706 | 7 | 79,412 |
Tags: constructive algorithms, math, number theory
Correct Solution:
```
n = int(input())
h = n
for i in range(2, int(n**0.5)+1):
if n%i==0:
while n>1:
if n%i==0:
n = n//i
else:
h = 1
break
if n==1:
h=i
break
print(h)
``` | output | 1 | 39,706 | 7 | 79,413 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in som... | instruction | 0 | 39,707 | 7 | 79,414 |
Tags: constructive algorithms, math, number theory
Correct Solution:
```
import math
n = int(input())
x = 2
rem = 0
flag = True
while x <= math.sqrt(n):
if n % x == 0:
k = x
c = 1
while n > k:
k *= x
c += 1
if n == k:
print(x)
flag = Fa... | output | 1 | 39,707 | 7 | 79,415 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in som... | instruction | 0 | 39,708 | 7 | 79,416 |
Tags: constructive algorithms, math, number theory
Correct Solution:
```
import math
def primeFactors(n):
pfs = set()
while n % 2 == 0:
pfs.add(2)
n = n // 2
for i in range(3,int(math.sqrt(n))+1,2):
while n % i== 0:
pfs.add(i)
n = n // i
... | output | 1 | 39,708 | 7 | 79,417 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in som... | instruction | 0 | 39,709 | 7 | 79,418 |
Tags: constructive algorithms, math, number theory
Correct Solution:
```
n = int(input())
m = int(n**0.5)+2
ans = n
for i in range(2,m):
if n%i==0:
while(n%i==0):
n = n//i
if n!=1:
ans = 1
break
else:
ans = i
print(ans)
# if ans==n:
# pri... | output | 1 | 39,709 | 7 | 79,419 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in som... | instruction | 0 | 39,710 | 7 | 79,420 |
Tags: constructive algorithms, math, number theory
Correct Solution:
```
import math
s=set()
def prime(n):
while n % 2 == 0:
s.add(2)
n = n / 2
for i in range(3,int(math.sqrt(n))+1,2):
while n % i== 0:
s.add(int(i))
n = n / i
if n > 2:
s.add(... | output | 1 | 39,710 | 7 | 79,421 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in som... | instruction | 0 | 39,711 | 7 | 79,422 |
Tags: constructive algorithms, math, number theory
Correct Solution:
```
from math import sqrt,gcd
def gen_primes():
""" Generate an infinite sequence of prime numbers.
"""
#
D = {}
# The running integer that's checked for primeness
q = 2
while True:
if q not in D:
# ... | output | 1 | 39,711 | 7 | 79,423 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbere... | instruction | 0 | 39,712 | 7 | 79,424 |
Yes | output | 1 | 39,712 | 7 | 79,425 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbere... | instruction | 0 | 39,713 | 7 | 79,426 |
Yes | output | 1 | 39,713 | 7 | 79,427 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbere... | instruction | 0 | 39,714 | 7 | 79,428 |
Yes | output | 1 | 39,714 | 7 | 79,429 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbere... | instruction | 0 | 39,715 | 7 | 79,430 |
Yes | output | 1 | 39,715 | 7 | 79,431 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbere... | instruction | 0 | 39,716 | 7 | 79,432 |
No | output | 1 | 39,716 | 7 | 79,433 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbere... | instruction | 0 | 39,717 | 7 | 79,434 |
No | output | 1 | 39,717 | 7 | 79,435 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbere... | instruction | 0 | 39,718 | 7 | 79,436 |
No | output | 1 | 39,718 | 7 | 79,437 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbere... | instruction | 0 | 39,719 | 7 | 79,438 |
No | output | 1 | 39,719 | 7 | 79,439 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Numbers 1, 2, 3, ... n (each integer from 1 to n once) are written on a board. In one operation you can erase any two numbers a and b from the board and write one integer (a + b)/(2) rounded up instead.
You should perform the given operatio... | instruction | 0 | 39,803 | 7 | 79,606 |
Tags: constructive algorithms, data structures, greedy, implementation, math
Correct Solution:
```
import bisect
for _ in range(int(input())):
n=int(input())
l=[]
if n==2:
print(2)
print(1,2)
continue
l.append([n,n-2])
c=(((n)+(n-2))//2+(n-1))//2
l.append([(n+n - 2)//2,n-... | output | 1 | 39,803 | 7 | 79,607 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Numbers 1, 2, 3, ... n (each integer from 1 to n once) are written on a board. In one operation you can erase any two numbers a and b from the board and write one integer (a + b)/(2) rounded up instead.
You should perform the given operatio... | instruction | 0 | 39,806 | 7 | 79,612 |
Tags: constructive algorithms, data structures, greedy, implementation, math
Correct Solution:
```
def main():
N = int(input())
if N == 2:
print(2)
print(1, 2)
return
ans = []
ans.append(f'{N-2} {N}')
ans.append(f'{N-1} {N-1}')
for n in range(N-3, 0, -1):
an... | output | 1 | 39,806 | 7 | 79,613 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.
An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blu... | instruction | 0 | 40,067 | 7 | 80,134 |
Tags: implementation, math, number theory
Correct Solution:
```
from math import gcd
lcm =lambda a,b:a*b//gcd(a,b)
n,a,b,p,q=map(int,input().split())
x=n//a
y=n//b
z=n//lcm(a,b)
if p>q:
print(x*p+(y-z)*q)
else :
print((x-z)*p+y*q)
``` | output | 1 | 40,067 | 7 | 80,135 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.
An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blu... | instruction | 0 | 40,068 | 7 | 80,136 |
Tags: implementation, math, number theory
Correct Solution:
```
from math import ceil
from math import floor
from math import sqrt
from math import log
import math
prime = pow(10, 9) + 7
def mod_expo(n, p, m):
"""find (n^p)%m"""
result = 1
while p != 0:
if p%2 == 1:
result = (result * n)%m
p //= 2
n = (n... | output | 1 | 40,068 | 7 | 80,137 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.
An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blu... | instruction | 0 | 40,069 | 7 | 80,138 |
Tags: implementation, math, number theory
Correct Solution:
```
import math as mt
n,a,b,p,q = map(int , input().split())
mx = max(p, q)
temp = n // ((a*b)//mt.gcd(a,b))
sum= (n//b)*q + (n//a)*p - (temp * min(p,q))
print(sum)
``` | output | 1 | 40,069 | 7 | 80,139 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.
An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blu... | instruction | 0 | 40,070 | 7 | 80,140 |
Tags: implementation, math, number theory
Correct Solution:
```
def gcd(a,b):
if(a==0):
return b
return gcd(b%a,a)
n,a,b,p,q=map(int,input().split())
rc=int(n/a)
bc=int(n/b)
ma=max(p,q)
lcm=int((a*b)/gcd(a,b))
both=int(n/lcm)
if(ma==p):
#rc+=both
bc-=both
elif(ma==q ):
#bc+=both
... | output | 1 | 40,070 | 7 | 80,141 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.
An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blu... | instruction | 0 | 40,071 | 7 | 80,142 |
Tags: implementation, math, number theory
Correct Solution:
```
from math import gcd
def main():
n, a, b, p, q = map(int, input().split())
g = gcd(a, b)
lcm = a * b // g
fa = n // a
fb = n // b
fab = n // lcm
print((fa - fab) * p + (fb - fab) * q + fab * max(p, q))
if __name__ == '__main... | output | 1 | 40,071 | 7 | 80,143 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.