message stringlengths 2 433k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 113 108k | cluster float64 12 12 | __index_level_0__ int64 226 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Long time ago there was a symmetric array a_1,a_2,…,a_{2n} consisting of 2n distinct integers. Array a_1,a_2,…,a_{2n} is called symmetric if for each integer 1 ≤ i ≤ 2n, there exists an integer ... | instruction | 0 | 9,307 | 12 | 18,614 |
Yes | output | 1 | 9,307 | 12 | 18,615 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Long time ago there was a symmetric array a_1,a_2,…,a_{2n} consisting of 2n distinct integers. Array a_1,a_2,…,a_{2n} is called symmetric if for each integer 1 ≤ i ≤ 2n, there exists an integer ... | instruction | 0 | 9,308 | 12 | 18,616 |
Yes | output | 1 | 9,308 | 12 | 18,617 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Long time ago there was a symmetric array a_1,a_2,…,a_{2n} consisting of 2n distinct integers. Array a_1,a_2,…,a_{2n} is called symmetric if for each integer 1 ≤ i ≤ 2n, there exists an integer ... | instruction | 0 | 9,309 | 12 | 18,618 |
No | output | 1 | 9,309 | 12 | 18,619 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Long time ago there was a symmetric array a_1,a_2,…,a_{2n} consisting of 2n distinct integers. Array a_1,a_2,…,a_{2n} is called symmetric if for each integer 1 ≤ i ≤ 2n, there exists an integer ... | instruction | 0 | 9,310 | 12 | 18,620 |
No | output | 1 | 9,310 | 12 | 18,621 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Long time ago there was a symmetric array a_1,a_2,…,a_{2n} consisting of 2n distinct integers. Array a_1,a_2,…,a_{2n} is called symmetric if for each integer 1 ≤ i ≤ 2n, there exists an integer ... | instruction | 0 | 9,311 | 12 | 18,622 |
No | output | 1 | 9,311 | 12 | 18,623 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Long time ago there was a symmetric array a_1,a_2,…,a_{2n} consisting of 2n distinct integers. Array a_1,a_2,…,a_{2n} is called symmetric if for each integer 1 ≤ i ≤ 2n, there exists an integer ... | instruction | 0 | 9,312 | 12 | 18,624 |
No | output | 1 | 9,312 | 12 | 18,625 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
To AmShZ, all arrays are equal, but some arrays are more-equal than others. Specifically, the arrays consisting of n elements from 1 to n that can be turned into permutations of numbers from 1 t... | instruction | 0 | 9,329 | 12 | 18,658 |
No | output | 1 | 9,329 | 12 | 18,659 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
To AmShZ, all arrays are equal, but some arrays are more-equal than others. Specifically, the arrays consisting of n elements from 1 to n that can be turned into permutations of numbers from 1 t... | instruction | 0 | 9,330 | 12 | 18,660 |
No | output | 1 | 9,330 | 12 | 18,661 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number t... | instruction | 0 | 9,364 | 12 | 18,728 |
Tags: implementation
Correct Solution:
```
from collections import defaultdict
def main():
n = int(input())
a = [int(c) for c in input().split()]
m = int(input())
q = [int(c) for c in input().split()]
cache = defaultdict(list)
for i, e in enumerate(a):
cache[e].append(i)
a = b = 0... | output | 1 | 9,364 | 12 | 18,729 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number t... | instruction | 0 | 9,365 | 12 | 18,730 |
Tags: implementation
Correct Solution:
```
n=int(input())
x=list(map(int,input().split()))
d={}
for i,j in enumerate(x):
d[j]=i
a,b=0,0
q=int(input())
r=list(map(int,input().split()))
for i in r:
a+=d[i]+1
b+=n-d[i]
print(a,b)
``` | output | 1 | 9,365 | 12 | 18,731 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number t... | instruction | 0 | 9,366 | 12 | 18,732 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
res = [0, 0]
l = [0 for _ in range(max(a) + 1)]
for i, v in enumerate(a):
l[v] = i+1
for v in b:
res[0] += l[v]
res[1] += n+1-l[v]
print(*res)
``` | output | 1 | 9,366 | 12 | 18,733 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number t... | instruction | 0 | 9,367 | 12 | 18,734 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = {}
for i,j in enumerate(input().split()):
a[j] = i+1
m = int(input())
x, y = 0, 0
for i in input().split():
z = a[i]
x += z
y += n-z+1
print(x,y)
``` | output | 1 | 9,367 | 12 | 18,735 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number t... | instruction | 0 | 9,368 | 12 | 18,736 |
Tags: implementation
Correct Solution:
```
# end=mid-1
# else:
# start=mid+1
n=int(input())
arr=list(map(int,input().split()))
q=int(input())
qar=list(map(int,input().split()))
a=0
b=0
d={}
for i in range(n):
d[arr[i]]=i+1
arr.sort()
for i in range(q):
idx=d[qar[i]]
a+=idx
... | output | 1 | 9,368 | 12 | 18,737 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number t... | instruction | 0 | 9,369 | 12 | 18,738 |
Tags: implementation
Correct Solution:
```
def approach(n, ans):
global a, ind, b, m
for i in range(m):
ans[0] += ind[b[i]]+1
ans[1] += len(a)-ind[b[i]]
return ans
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
ind = [0]*(len(a)+1)... | output | 1 | 9,369 | 12 | 18,739 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number t... | instruction | 0 | 9,370 | 12 | 18,740 |
Tags: implementation
Correct Solution:
```
n = int(input())
arr = list(map(int, input().split()))
size = 1_000_05
freq = [None] * size
freq2 = [None] * size
index = 0
for element in arr:
freq[element] = index + 1
freq2[element] = n - index
index = index + 1
m = int(input())
first = second = 0
que... | output | 1 | 9,370 | 12 | 18,741 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number t... | instruction | 0 | 9,371 | 12 | 18,742 |
Tags: implementation
Correct Solution:
```
'''n = int(input())
arr = list(map(int, input().split()))
nn = int(input())
arr3 = list(map(int, input().split()))
cv = 0
cp = 0
for kk in arr3:
xxx = arr.index(kk)
cv += xxx + 1
cp += n - xxx
print(cv, cp)'''
n = int(input())
a = [int(x) for x in input().split()]
... | output | 1 | 9,371 | 12 | 18,743 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an integer m.
Let M = 2m - 1.
You are also given a set of n integers denoted as the set T. The integers will be provided in base 2 as n binary strings of length m.
A set of integers S is called "good" if the following hold. ... | instruction | 0 | 9,632 | 12 | 19,264 |
Tags: bitmasks, combinatorics, dp, math
Correct Solution:
```
#Problem Set E: Collaborated with no one
from collections import defaultdict
mod_v = 1000000007
temp_arr = [[1]]
for i in range(1,1010):
a = [1]
for k in range(1,i):
a.append((temp_arr[i-1][k-1]+temp_arr[i-1][k]) % mod_v)
a.append(1)
... | output | 1 | 9,632 | 12 | 19,265 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of ... | instruction | 0 | 9,972 | 12 | 19,944 |
Tags: brute force, data structures, divide and conquer, dp, greedy
Correct Solution:
```
def go():
n, x = map(int, input().split(' '))
a = [int(i) for i in input().split(' ')]
cur1 = cur2 = cur = maximum = 0
for i in range(len(a)):
cur1 = max(0, cur1 + a[i])
cur2 = max(cur1, cur2 + x * a... | output | 1 | 9,972 | 12 | 19,945 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of ... | instruction | 0 | 9,973 | 12 | 19,946 |
Tags: brute force, data structures, divide and conquer, dp, greedy
Correct Solution:
```
import sys,math,itertools
from collections import Counter,deque,defaultdict
from bisect import bisect_left,bisect_right
from heapq import heappop,heappush,heapify, nlargest
from copy import deepcopy
mod = 10**9+7
INF = float('inf'... | output | 1 | 9,973 | 12 | 19,947 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of ... | instruction | 0 | 9,974 | 12 | 19,948 |
Tags: brute force, data structures, divide and conquer, dp, greedy
Correct Solution:
```
n, x = map(int, input().split())
a = list(map(int, input().split()))
kq=pre=mid=suf=0
for i in a:
pre=max(pre+i,0)
mid=max(mid+(i*x),pre)
suf=max(suf+i,mid)
kq = max(kq, suf)
print(kq)
``` | output | 1 | 9,974 | 12 | 19,949 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of ... | instruction | 0 | 9,975 | 12 | 19,950 |
Tags: brute force, data structures, divide and conquer, dp, greedy
Correct Solution:
```
n, x = map(int, input().split())
a = list(map(int, input().split()))
inf = - 2**64
dp = [[[inf for _ in range(3)] for _ in range(3)] for _ in range(n+1)]
dp[0][0][0] = 0
for i in range(n+1):
for j in range(3):
for k in... | output | 1 | 9,975 | 12 | 19,951 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of ... | instruction | 0 | 9,976 | 12 | 19,952 |
Tags: brute force, data structures, divide and conquer, dp, greedy
Correct Solution:
```
import sys,math
from collections import defaultdict,deque
input=sys.stdin.readline
n,x=map(int,input().split())
l=list(map(int,input().split()))
dp=[[[0 for _ in range(2)] for _ in range(2)] for _ in range(len(l))]
#print(dp) #... | output | 1 | 9,976 | 12 | 19,953 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of ... | instruction | 0 | 9,977 | 12 | 19,954 |
Tags: brute force, data structures, divide and conquer, dp, greedy
Correct Solution:
```
n, x = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0 for _ in range(n + 1)] for _ in range(3)]
ans = 0
for i in range(n):
dp[0][i + 1] = max(0, dp[0][i] + a[i])
dp[1][i + 1] = max(dp[0][i], dp[1][i]... | output | 1 | 9,977 | 12 | 19,955 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of ... | instruction | 0 | 9,978 | 12 | 19,956 |
Tags: brute force, data structures, divide and conquer, dp, greedy
Correct Solution:
```
from math import *
from collections import *
import sys
sys.setrecursionlimit(10**9)
n,x = map(int,input().split())
a = list(map(int,input().split()))
l = [0 for i in range(n+1)]
r = [0 for i in range(n+1)]
pre = [a[0]]
for i in r... | output | 1 | 9,978 | 12 | 19,957 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of ... | instruction | 0 | 9,979 | 12 | 19,958 |
Tags: brute force, data structures, divide and conquer, dp, greedy
Correct Solution:
```
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=[[0]*3 for i in range(n)]
m=0
for i in range(n):
if i==0:
b[i][0]=max(a[i],0)
b[i][1]=max(x*a[i],b[i][0])
b[i][2]=max(a[i],b[i][1])
els... | output | 1 | 9,979 | 12 | 19,959 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the arra... | instruction | 0 | 9,980 | 12 | 19,960 |
Yes | output | 1 | 9,980 | 12 | 19,961 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the arra... | instruction | 0 | 9,981 | 12 | 19,962 |
Yes | output | 1 | 9,981 | 12 | 19,963 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the arra... | instruction | 0 | 9,982 | 12 | 19,964 |
Yes | output | 1 | 9,982 | 12 | 19,965 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the arra... | instruction | 0 | 9,983 | 12 | 19,966 |
Yes | output | 1 | 9,983 | 12 | 19,967 |
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the arra... | instruction | 0 | 9,984 | 12 | 19,968 |
Yes | output | 1 | 9,984 | 12 | 19,969 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the arra... | instruction | 0 | 9,985 | 12 | 19,970 |
No | output | 1 | 9,985 | 12 | 19,971 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the arra... | instruction | 0 | 9,986 | 12 | 19,972 |
No | output | 1 | 9,986 | 12 | 19,973 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the arra... | instruction | 0 | 9,987 | 12 | 19,974 |
No | output | 1 | 9,987 | 12 | 19,975 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the arra... | instruction | 0 | 9,988 | 12 | 19,976 |
No | output | 1 | 9,988 | 12 | 19,977 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers a and b. You can perform a sequence of operations: during the first operation you choose one of these numbers and increase it by 1; during the second operation you choose one of these numbers and increase it by 2, ... | instruction | 0 | 10,062 | 12 | 20,124 |
Tags: greedy, math
Correct Solution:
```
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations a... | output | 1 | 10,062 | 12 | 20,125 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers a and b. You can perform a sequence of operations: during the first operation you choose one of these numbers and increase it by 1; during the second operation you choose one of these numbers and increase it by 2, ... | instruction | 0 | 10,063 | 12 | 20,126 |
Tags: greedy, math
Correct Solution:
```
import math,sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili=lambda:list(map(int,sys.stdin.readlines()))
li = lambda:list(map(int,input().split()))
#for deque append(),pop(),appendleft(),popleft(),count()
I=lambda:... | output | 1 | 10,063 | 12 | 20,127 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers a and b. You can perform a sequence of operations: during the first operation you choose one of these numbers and increase it by 1; during the second operation you choose one of these numbers and increase it by 2, ... | instruction | 0 | 10,066 | 12 | 20,132 |
Tags: greedy, math
Correct Solution:
```
import sys
input = sys.stdin.readline
t=int(input())
NLIST=[N*(N+1)//2 for N in range(10**5)]
import bisect
for test in range(t):
a,b=map(int,input().split())
x=abs(b-a)
N=bisect.bisect_left(NLIST,x)
#print(x,N)
while x%2!=((N+1)//2)%2:
N+=1
... | output | 1 | 10,066 | 12 | 20,133 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of positive integers a = [a_0, a_1, ..., a_{n - 1}] (n ≥ 2).
In one step, the array a is replaced with another array of length n, in which each element is the [greatest common divisor (GCD)](http://tiny.cc/tuy9uz) of ... | instruction | 0 | 10,207 | 12 | 20,414 |
Tags: binary search, brute force, data structures, divide and conquer, number theory, two pointers
Correct Solution:
```
from collections import defaultdict, deque, Counter
from heapq import heapify, heappop, heappush
import math
from copy import deepcopy
from itertools import combinations, permutations, product, combi... | output | 1 | 10,207 | 12 | 20,415 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of positive integers a = [a_0, a_1, ..., a_{n - 1}] (n ≥ 2).
In one step, the array a is replaced with another array of length n, in which each element is the [greatest common divisor (GCD)](http://tiny.cc/tuy9uz) of ... | instruction | 0 | 10,208 | 12 | 20,416 |
Tags: binary search, brute force, data structures, divide and conquer, number theory, two pointers
Correct Solution:
```
import math
import sys
input = sys.stdin.readline
def make_tree(n):
i = 2
while True:
if i >= n * 2:
tree = [0] * i
break
else:
i *= 2
... | output | 1 | 10,208 | 12 | 20,417 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of positive integers a = [a_0, a_1, ..., a_{n - 1}] (n ≥ 2).
In one step, the array a is replaced with another array of length n, in which each element is the [greatest common divisor (GCD)](http://tiny.cc/tuy9uz) of ... | instruction | 0 | 10,209 | 12 | 20,418 |
Tags: binary search, brute force, data structures, divide and conquer, number theory, two pointers
Correct Solution:
```
import sys
from functools import reduce
from math import gcd
#comment these out later
#sys.stdin = open("in.in", "r")
#sys.stdout = open("out.out", "w")
def main():
class RangeQuery:
def __in... | output | 1 | 10,209 | 12 | 20,419 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of positive integers a = [a_0, a_1, ..., a_{n - 1}] (n ≥ 2).
In one step, the array a is replaced with another array of length n, in which each element is the [greatest common divisor (GCD)](http://tiny.cc/tuy9uz) of ... | instruction | 0 | 10,210 | 12 | 20,420 |
Tags: binary search, brute force, data structures, divide and conquer, number theory, two pointers
Correct Solution:
```
import sys,os,io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from math import gcd
class RangeQuery:
def __init__(self, data, func=gcd):
self.func = func
self._da... | output | 1 | 10,210 | 12 | 20,421 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of positive integers a = [a_0, a_1, ..., a_{n - 1}] (n ≥ 2).
In one step, the array a is replaced with another array of length n, in which each element is the [greatest common divisor (GCD)](http://tiny.cc/tuy9uz) of ... | instruction | 0 | 10,211 | 12 | 20,422 |
Tags: binary search, brute force, data structures, divide and conquer, number theory, two pointers
Correct Solution:
```
import sys
from math import gcd
t = int(sys.stdin.readline())
while(t>0):
n = int(input())
a = list(map(int,sys.stdin.readline().split()))
a = a+a
m = 0
for i in range(n):
... | output | 1 | 10,211 | 12 | 20,423 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of positive integers a = [a_0, a_1, ..., a_{n - 1}] (n ≥ 2).
In one step, the array a is replaced with another array of length n, in which each element is the [greatest common divisor (GCD)](http://tiny.cc/tuy9uz) of ... | instruction | 0 | 10,212 | 12 | 20,424 |
Tags: binary search, brute force, data structures, divide and conquer, number theory, two pointers
Correct Solution:
```
def read_ints():
return list(map(int, input().split()))
def gcd(x, y):
if x == 0 or y == 0:
return x + y
if x > y:
return gcd(x % y, y)
else:
return gcd(x, y... | output | 1 | 10,212 | 12 | 20,425 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of positive integers a = [a_0, a_1, ..., a_{n - 1}] (n ≥ 2).
In one step, the array a is replaced with another array of length n, in which each element is the [greatest common divisor (GCD)](http://tiny.cc/tuy9uz) of ... | instruction | 0 | 10,213 | 12 | 20,426 |
Tags: binary search, brute force, data structures, divide and conquer, number theory, two pointers
Correct Solution:
```
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ... | output | 1 | 10,213 | 12 | 20,427 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of positive integers a = [a_0, a_1, ..., a_{n - 1}] (n ≥ 2).
In one step, the array a is replaced with another array of length n, in which each element is the [greatest common divisor (GCD)](http://tiny.cc/tuy9uz) of ... | instruction | 0 | 10,214 | 12 | 20,428 |
Tags: binary search, brute force, data structures, divide and conquer, number theory, two pointers
Correct Solution:
```
import sys
import math
input = sys.stdin.readline
def sieve(n):
prime = [-1]*(n+1)
for i in range(2,n+1):
if prime[i]==-1:
for j in range(i,n+1,i):
if prime[j]==-1:
prime[j] = i
ret... | output | 1 | 10,214 | 12 | 20,429 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.
Namely,... | instruction | 0 | 10,294 | 12 | 20,588 |
Tags: data structures, trees
Correct Solution:
```
from sys import stdin,stdout
n,m=map(int,input().split())
n=pow(2,n)
tarr=list(map(int,stdin.readline().split()))
arr=[0]*n
arr=arr+tarr
start=n
end=2*n
flag=0
while(start>1):
for i in range(start,end,2):
if(flag):
arr[i>>1]=arr[i]^arr[i+1]
else:
arr[i>>1]=... | output | 1 | 10,294 | 12 | 20,589 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.
Namely,... | instruction | 0 | 10,295 | 12 | 20,590 |
Tags: data structures, trees
Correct Solution:
```
'''
Code from : AKASH KUMAR BHAGAT(akay_99)
'''
#-------------------------------------------------------------------------------------
'''
from sys import stdin, stdout
def input():
return stdin.readline().rstrip()
'''
#------------------------------------------... | output | 1 | 10,295 | 12 | 20,591 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.
Namely,... | instruction | 0 | 10,296 | 12 | 20,592 |
Tags: data structures, trees
Correct Solution:
```
import sys, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.... | output | 1 | 10,296 | 12 | 20,593 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.
Namely,... | instruction | 0 | 10,297 | 12 | 20,594 |
Tags: data structures, trees
Correct Solution:
```
import sys
input=sys.stdin.readline
import math
# sys.setrecursionlimit(10**9)
def construct(array,cur_pos,tree,start,end):
if(start==end):
# print(cur_pos,"pppp",array[start])
tree[cur_pos]=array[start]
else:
mid=(start+end)//2
w=(n1-int(math.log2(cur_pos+1... | output | 1 | 10,297 | 12 | 20,595 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.
Namely,... | instruction | 0 | 10,298 | 12 | 20,596 |
Tags: data structures, trees
Correct Solution:
```
from operator import or_, xor
import sys
greg=1
#Stolen from tchr to test Xenia and Bit Operations speed.
n, m = map(int, input().split())
t = [list(map(int, input().split()))]
for i in range(n):
t += [[(or_, xor)[i & 1](*t[i][j: j + 2]) for j in range(0, len(t[i... | output | 1 | 10,298 | 12 | 20,597 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.