lang stringclasses 1
value | prompt stringlengths 1.38k 11.3k | eval_prompt stringlengths 37 8.09k | ground_truth stringlengths 1 328 | unit_tests stringclasses 145
values | task_id stringlengths 23 25 | split stringclasses 2
values |
|---|---|---|---|---|---|---|
python | Complete the code in python to solve this programming problem:
Description: You are given an array $$$a$$$ that contains $$$n$$$ integers. You can choose any proper subsegment $$$a_l, a_{l + 1}, \ldots, a_r$$$ of this array, meaning you can choose any two integers $$$1 \le l \le r \le n$$$, where $$$r - l + 1 < n$$... | for {{completion}}:input();a,b,*_,c,d=sorted(map(int,input().split()));print(c+d-a-b) | t in range(int(input())) | [{"input": "4\n8\n1 2 2 3 1 5 6 1\n5\n1 2 3 100 200\n4\n3 3 3 3\n6\n7 8 3 1 1 8", "output": ["9\n297\n0\n14"]}] | control_completion_005297 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an array $$$a$$$ that contains $$$n$$$ integers. You can choose any proper subsegment $$$a_l, a_{l + 1}, \ldots, a_r$$$ of this array, meaning you can choose any two integers $$$1 \le l \le r \le n$$$, where $$$r - l + 1 < n$$... | for {{completion}}:p,q,*_,r,s=sorted(map(int,sdr.split()));print(r+s-p-q) | sdr in[*open(0)][2::2] | [{"input": "4\n8\n1 2 2 3 1 5 6 1\n5\n1 2 3 100 200\n4\n3 3 3 3\n6\n7 8 3 1 1 8", "output": ["9\n297\n0\n14"]}] | control_completion_005298 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an array $$$a$$$ that contains $$$n$$$ integers. You can choose any proper subsegment $$$a_l, a_{l + 1}, \ldots, a_r$$$ of this array, meaning you can choose any two integers $$$1 \le l \le r \le n$$$, where $$$r - l + 1 < n$$... | for {{completion}}:
input()
a, b, *_, c, d = sorted(map(int, input().split()))
print(c+d-a-b)
| _ in range(int(input())) | [{"input": "4\n8\n1 2 2 3 1 5 6 1\n5\n1 2 3 100 200\n4\n3 3 3 3\n6\n7 8 3 1 1 8", "output": ["9\n297\n0\n14"]}] | control_completion_005299 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an array $$$a$$$ that contains $$$n$$$ integers. You can choose any proper subsegment $$$a_l, a_{l + 1}, \ldots, a_r$$$ of this array, meaning you can choose any two integers $$$1 \le l \le r \le n$$$, where $$$r - l + 1 < n$$... | for {{completion}}:
input()
a = sorted(map(int, input().split()))
print(a[-1] + a[-2] - a[0] - a[1])
| _ in range(int(input())) | [{"input": "4\n8\n1 2 2 3 1 5 6 1\n5\n1 2 3 100 200\n4\n3 3 3 3\n6\n7 8 3 1 1 8", "output": ["9\n297\n0\n14"]}] | control_completion_005300 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Monocarp is going to host a party for his friends. He prepared $$$n$$$ dishes and is about to serve them. First, he has to add some powdered pepper to each of themΒ β otherwise, the dishes will be pretty tasteless.The $$$i$$$-th dish has two va... | import sys
import math
import heapq
import itertools
import bisect
import random
from decimal import *
from collections import deque
input=sys.stdin.readline
def extended_gcd(a,b):
x0,x1,y0,y1=1,0,0,1
while b!=0:
n,a,b=a//b,b,a%b
x0,x1=x1,x0-n*x1
y0,y1=y1,y0-n*y1
ret... | 0<=i<=n | [{"input": "3\n5 10\n100 50\n2 2\n4\n2 3\n1 1\n3 2\n2 2", "output": ["62\n112\n107\n-1"]}, {"input": "10\n3 1\n2 3\n1 1\n2 1\n6 3\n1 4\n4 3\n1 3\n5 3\n5 4\n10\n8 10\n9 3\n1 4\n2 5\n8 3\n3 5\n1 6\n7 2\n6 7\n3 1", "output": ["26\n-1\n36\n30\n-1\n26\n34\n26\n-1\n36"]}] | control_completion_005447 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Consider a segment $$$[0, d]$$$ of the coordinate line. There are $$$n$$$ lanterns and $$$m$$$ points of interest in this segment.For each lantern, you can choose its power β an integer between $$$0$$$ and $$$d$$$ (inclusive). A lantern with c... | input = __import__('sys').stdin.readline
MOD = 998244353
d, n, m = map(int, input().split())
lamps = list(sorted(map(int, input().split()))) # n
points = list(sorted(map(int, input().split()))) # m
# 1. O(m^2) to find all interesting points (sould be around m^2 points)
positions = [x for x in points]
p... | prev_idx == -1 | [{"input": "6 1 1\n4\n3\n3\n2 1 5", "output": ["48\n47\n47"]}, {"input": "6 1 2\n4\n2 5\n2\n1 3", "output": ["44\n46"]}, {"input": "20 1 2\n11\n15 7\n1\n8", "output": ["413"]}, {"input": "20 3 5\n5 7 18\n1 6 3 10 19\n5\n4 17 15 8 9", "output": ["190431\n187503\n188085\n189903\n189708"]}] | control_completion_005459 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Consider a segment $$$[0, d]$$$ of the coordinate line. There are $$$n$$$ lanterns and $$$m$$$ points of interest in this segment.For each lantern, you can choose its power β an integer between $$$0$$$ and $$$d$$$ (inclusive). A lantern with c... | input = __import__('sys').stdin.readline
MOD = 998244353
d, n, m = map(int, input().split())
lamps = list(sorted(map(int, input().split()))) # n
points = list(sorted(map(int, input().split()))) # m
# 1. O(m^2) to find all interesting points (sould be around m^2 points)
positions = [x for x in points]
p... | i, j, k in keys | [{"input": "6 1 1\n4\n3\n3\n2 1 5", "output": ["48\n47\n47"]}, {"input": "6 1 2\n4\n2 5\n2\n1 3", "output": ["44\n46"]}, {"input": "20 1 2\n11\n15 7\n1\n8", "output": ["413"]}, {"input": "20 3 5\n5 7 18\n1 6 3 10 19\n5\n4 17 15 8 9", "output": ["190431\n187503\n188085\n189903\n189708"]}] | control_completion_005460 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have a square chessboard of size $$$n \times n$$$. Rows are numbered from top to bottom with numbers from $$$1$$$ to $$$n$$$, and columnsΒ β from left to right with numbers from $$$1$$$ to $$$n$$$. So, each cell is denoted with pair of inte... | import sys
input=sys.stdin.readline
R=lambda:map(int,input().split())
n,m=R();r,c,tr,tc=[0]*(n+1),[0]*(n+1),[0]*(n+1),[0]*(n+1)
def A(t,i,v):
while i<=n:t[i]+=v;i+=i&(-i)
def Q(t,i):
s=0
while i:s+=t[i];i-=i&(-i)
return s
for _ in range(m):
v=[*R()];op,x,y=v[:3]
if op==1:
r[x]+=1;c[y]+=1
... | r[x]==0 | [{"input": "8 10\n1 2 4\n3 6 2 7 2\n1 3 2\n3 6 2 7 2\n1 4 3\n3 2 6 4 8\n2 4 3\n3 2 6 4 8\n1 4 8\n3 2 6 4 8", "output": ["No\nYes\nYes\nNo\nYes"]}] | control_completion_005480 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have a square chessboard of size $$$n \times n$$$. Rows are numbered from top to bottom with numbers from $$$1$$$ to $$$n$$$, and columnsΒ β from left to right with numbers from $$$1$$$ to $$$n$$$. So, each cell is denoted with pair of inte... | class BIT:
def __init__(self, n, element):
self.num = n
self.ele = element
self.data = [self.ele] * (self.num + 1)
def calc(self, x, y):
return x + y
def update(self, idx, x):
while idx <= self.num:
self.data[idx] = self.calc(self.data[idx], x)
idx += idx & -idx
def sum(s... | cntb[x-1] == 0 | [{"input": "8 10\n1 2 4\n3 6 2 7 2\n1 3 2\n3 6 2 7 2\n1 4 3\n3 2 6 4 8\n2 4 3\n3 2 6 4 8\n1 4 8\n3 2 6 4 8", "output": ["No\nYes\nYes\nNo\nYes"]}] | control_completion_005481 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have a square chessboard of size $$$n \times n$$$. Rows are numbered from top to bottom with numbers from $$$1$$$ to $$$n$$$, and columnsΒ β from left to right with numbers from $$$1$$$ to $$$n$$$. So, each cell is denoted with pair of inte... | import sys
def solve():
inp = sys.stdin.readline
n, q = map(int, inp().split())
r = [0] * n
c = [0] * n
rc = [0] * n
cc = [0] * n
for i in range(q):
ii = iter(map(int, inp().split()))
t = next(ii)
if t <= 2:
x, y = ii
vv = 1 if t == 1 else -1
x -= 1
w = int(rc[x] > 0)
rc[x]... | x >= 0 | [{"input": "8 10\n1 2 4\n3 6 2 7 2\n1 3 2\n3 6 2 7 2\n1 4 3\n3 2 6 4 8\n2 4 3\n3 2 6 4 8\n1 4 8\n3 2 6 4 8", "output": ["No\nYes\nYes\nNo\nYes"]}] | control_completion_005482 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have a square chessboard of size $$$n \times n$$$. Rows are numbered from top to bottom with numbers from $$$1$$$ to $$$n$$$, and columnsΒ β from left to right with numbers from $$$1$$$ to $$$n$$$. So, each cell is denoted with pair of inte... | import sys
def solve():
inp = sys.stdin.readline
n, q = map(int, inp().split())
r = [0] * n
c = [0] * n
rc = [0] * n
cc = [0] * n
for i in range(q):
ii = iter(map(int, inp().split()))
t = next(ii)
if t <= 2:
x, y = ii
vv = 1 if t == 1 else -1
x -= 1
w = int(rc[x] > 0)
rc[x]... | v == x2 - x1 + 1 | [{"input": "8 10\n1 2 4\n3 6 2 7 2\n1 3 2\n3 6 2 7 2\n1 4 3\n3 2 6 4 8\n2 4 3\n3 2 6 4 8\n1 4 8\n3 2 6 4 8", "output": ["No\nYes\nYes\nNo\nYes"]}] | control_completion_005483 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have a square chessboard of size $$$n \times n$$$. Rows are numbered from top to bottom with numbers from $$$1$$$ to $$$n$$$, and columnsΒ β from left to right with numbers from $$$1$$$ to $$$n$$$. So, each cell is denoted with pair of inte... | import math
from collections import defaultdict, deque, Counter
from sys import stdin
inf = int(1e18)
input = stdin.readline
#fenwick Tree
#D V ARAVIND
def add(ft, i, v):
while i < len(ft):
ft[i] += v
i += i&(-i)
def get(ft, i):
s = 0
while (i > 0):
s = s + ft[i]
... | visr[a[1]] == 1 | [{"input": "8 10\n1 2 4\n3 6 2 7 2\n1 3 2\n3 6 2 7 2\n1 4 3\n3 2 6 4 8\n2 4 3\n3 2 6 4 8\n1 4 8\n3 2 6 4 8", "output": ["No\nYes\nYes\nNo\nYes"]}] | control_completion_005484 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have a square chessboard of size $$$n \times n$$$. Rows are numbered from top to bottom with numbers from $$$1$$$ to $$$n$$$, and columnsΒ β from left to right with numbers from $$$1$$$ to $$$n$$$. So, each cell is denoted with pair of inte... | import math
from collections import defaultdict, deque, Counter
from sys import stdin
inf = int(1e18)
input = stdin.readline
#fenwick Tree
#D V ARAVIND
def add(ft, i, v):
while i < len(ft):
ft[i] += v
i += i&(-i)
def get(ft, i):
s = 0
while (i > 0):
s = s + ft[i]
... | (sr == a[3] - a[1] + 1) or (sc == a[4]-a[2]+1) | [{"input": "8 10\n1 2 4\n3 6 2 7 2\n1 3 2\n3 6 2 7 2\n1 4 3\n3 2 6 4 8\n2 4 3\n3 2 6 4 8\n1 4 8\n3 2 6 4 8", "output": ["No\nYes\nYes\nNo\nYes"]}] | control_completion_005485 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have a square chessboard of size $$$n \times n$$$. Rows are numbered from top to bottom with numbers from $$$1$$$ to $$$n$$$, and columnsΒ β from left to right with numbers from $$$1$$$ to $$$n$$$. So, each cell is denoted with pair of inte... | import sys
def update(ind, val, tree, n):
while ind <= n:
tree[ind] += val
ind += (ind & -ind)
def read(ind, tree):
ans = 0
while(ind > 0):
ans += tree[ind]
ind -= (ind & -ind)
return ans
def query(l, r, tree):
return read(r, tree) - read(l-1, tree)
... | row[x] == 0 | [{"input": "8 10\n1 2 4\n3 6 2 7 2\n1 3 2\n3 6 2 7 2\n1 4 3\n3 2 6 4 8\n2 4 3\n3 2 6 4 8\n1 4 8\n3 2 6 4 8", "output": ["No\nYes\nYes\nNo\nYes"]}] | control_completion_005486 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have a square chessboard of size $$$n \times n$$$. Rows are numbered from top to bottom with numbers from $$$1$$$ to $$$n$$$, and columnsΒ β from left to right with numbers from $$$1$$$ to $$$n$$$. So, each cell is denoted with pair of inte... | import sys
def update(ind, val, tree, n):
while ind <= n:
tree[ind] += val
ind += (ind & -ind)
def read(ind, tree):
ans = 0
while(ind > 0):
ans += tree[ind]
ind -= (ind & -ind)
return ans
def query(l, r, tree):
return read(r, tree) - read(l-1, tree)
... | query(x1, x2, rtree) < x2 - x1 + 1 | [{"input": "8 10\n1 2 4\n3 6 2 7 2\n1 3 2\n3 6 2 7 2\n1 4 3\n3 2 6 4 8\n2 4 3\n3 2 6 4 8\n1 4 8\n3 2 6 4 8", "output": ["No\nYes\nYes\nNo\nYes"]}] | control_completion_005487 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have a square chessboard of size $$$n \times n$$$. Rows are numbered from top to bottom with numbers from $$$1$$$ to $$$n$$$, and columnsΒ β from left to right with numbers from $$$1$$$ to $$$n$$$. So, each cell is denoted with pair of inte... | import bisect
import collections
import heapq
import io
import math
import os
import sys
LO = 'abcdefghijklmnopqrstuvwxyz'
Mod = 1000000007
def gcd(x, y):
while y:
x, y = y, x % y
return x
# _input = lambda: io.BytesIO(os.read(0, os.fstat(0).st_size)).readline().decode()
_input = lam... | u <= n | [{"input": "8 10\n1 2 4\n3 6 2 7 2\n1 3 2\n3 6 2 7 2\n1 4 3\n3 2 6 4 8\n2 4 3\n3 2 6 4 8\n1 4 8\n3 2 6 4 8", "output": ["No\nYes\nYes\nNo\nYes"]}] | control_completion_005488 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another s... | f = open(0)
def R(): return map(int, next(f).split())
n, q = R()
d = {}
i = v = r = 0
for x in R():
r += x
i += 1
d[i] = x
while q:
q -= 1
t, *x = R()
if {{completion}}:
i, x = x
r += x - d.get(i, v)
d[i] = x
else:
d = {}
v, = x
... | t & 1 | [{"input": "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1", "output": ["19\n50\n51\n42\n5"]}] | control_completion_005511 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another s... | inp = [list(map(int, l.split())) for l in open(0).read().splitlines()]
n, q = inp[0]
a = inp[1]
last = 0
step = [-1] * n
laststep = -2
tot = sum(a)
for i, b in enumerate(inp[2:]):
if b[0] == 1:
if {{completion}}:
tot += b[2] - a[b[1]-1]
a[b[1]-1] = b[2]
else:
... | step[b[1]-1] > laststep | [{"input": "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1", "output": ["19\n50\n51\n42\n5"]}] | control_completion_005512 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another s... | from collections import defaultdict
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
t = dict(enumerate(map(int, input().split())))
ans = sum(t.values())
for i in range(q):
p = list(map(int, input().split()))
if {{completion}}:
k = p[1]
ans = n*p[1]
t = defaultdict(... | p[0] == 2 | [{"input": "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1", "output": ["19\n50\n51\n42\n5"]}] | control_completion_005513 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another s... | n,q = map(int, input().split(' '))
array = list(map(int, input().split(' ')))
d = {i:item for i,item in enumerate(array, start=1)}
tot = sum(array)
default = None
for _ in range(q):
t, *a = map(int, input().split(' '))
if t==1:
i, x = a
tot += (x-d.get(i, default))
d[i] = x
... | t==2 | [{"input": "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1", "output": ["19\n50\n51\n42\n5"]}] | control_completion_005514 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another s... | f=open(0)
s=lambda:map(int,next(f).split())
n,tst=s()
arr={}
i=g=ans=0
for x in s():ans+=x;i+=1;arr[i]=x
while tst:
tst-=1;t,*x=s()
if {{completion}}:i,x=x;ans+=x-arr.get(i,g);arr[i]=x
else:arr={};g,=x;ans=g*n
print(ans)
| t&1 | [{"input": "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1", "output": ["19\n50\n51\n42\n5"]}] | control_completion_005515 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another s... | n, q = list(map(int, input().split()))
a = list(map(int, input().split()))
x, c, s, b = 0, 0, sum(a), [1]*(n)
for i in range(q):
k = list(map(int, input().split()))
if k[0]==1:
j = k[1]-1
if {{completion}}:
s = s-a[j]+k[2]
else:
s = s-x+k[2]
... | b[j]>c | [{"input": "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1", "output": ["19\n50\n51\n42\n5"]}] | control_completion_005516 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another s... | f=open(0)
n,q=map(int,next(f).split())
a = list(map(int,next(f).split()))
c = [-1]*n
X = 0
S = sum(a)
lst=-2
for idx in range(q):
req = list(map(int,next(f).split()))
if {{completion}}:
i = req[1]-1
x = req[2]
current = X if c[i]<lst else a[i]
S += x - ... | (req[0] == 1) | [{"input": "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1", "output": ["19\n50\n51\n42\n5"]}] | control_completion_005517 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another s... | import sys, math
input = sys.stdin.readline
n, q = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
d = {}
for i in range(n):
d[i + 1] = a[i]
type2 = 0
for i in range(q):
t = [int(x) for x in input().split()]
if {{completion}}:
d[t[1]] = t[2]
else:
... | t[0] == 1 | [{"input": "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1", "output": ["19\n50\n51\n42\n5"]}] | control_completion_005518 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: One day Masha was walking in the park and found a graph under a tree... Surprised? Did you think that this problem would have some logical and reasoned story? No way! So, the problem...Masha has an oriented graph which $$$i$$$-th vertex contai... | import sys
input = sys.stdin.readline
def solve():
n, m, k = map(int, input().split())
arr = list(map(int, input().split()))
graph = [[] for _ in range(n)]
for i in range(m):
u, v = map(int, input().split())
graph[u-1].append(v-1)
lo, hi = min(arr), max(arr)+1
while lo < hi:
... | degree[nei] == 0 | [{"input": "6 7 4\n1 10 2 3 4 5\n1 2\n1 3\n3 4\n4 5\n5 6\n6 2\n2 5", "output": ["4"]}, {"input": "6 7 100\n1 10 2 3 4 5\n1 2\n1 3\n3 4\n4 5\n5 6\n6 2\n2 5", "output": ["10"]}, {"input": "2 1 5\n1 1\n1 2", "output": ["-1"]}, {"input": "1 0 1\n1000000000", "output": ["1000000000"]}] | control_completion_005569 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: One day Masha was walking in the park and found a graph under a tree... Surprised? Did you think that this problem would have some logical and reasoned story? No way! So, the problem...Masha has an oriented graph which $$$i$$$-th vertex contai... | import sys
from array import array
from collections import deque
input = lambda: sys.stdin.buffer.readline().decode().strip()
inp = lambda dtype: [dtype(x) for x in input().split()]
inp_2d = lambda dtype, n: [dtype(input()) for _ in range(n)]
inp_2ds = lambda dtype, n: [inp(dtype) for _ in range(n)]
ceil1 = la... | a[i] <= md and not self.deg[i] | [{"input": "6 7 4\n1 10 2 3 4 5\n1 2\n1 3\n3 4\n4 5\n5 6\n6 2\n2 5", "output": ["4"]}, {"input": "6 7 100\n1 10 2 3 4 5\n1 2\n1 3\n3 4\n4 5\n5 6\n6 2\n2 5", "output": ["10"]}, {"input": "2 1 5\n1 1\n1 2", "output": ["-1"]}, {"input": "1 0 1\n1000000000", "output": ["1000000000"]}] | control_completion_005570 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: One day Masha was walking in the park and found a graph under a tree... Surprised? Did you think that this problem would have some logical and reasoned story? No way! So, the problem...Masha has an oriented graph which $$$i$$$-th vertex contai... | from sys import stdin, stdout
n, m, k = [int(x) for x in stdin.readline().split()]
a = [int(x) for x in stdin.readline().split()]
edges = {i:[] for i in range(n)}
for bar in range(m):
u, v = [int(x)-1 for x in stdin.readline().split()]
edges[u].append(v)
a_copy = list(set(a))
a_copy.sort()
def ... | expanded[w] == 1 | [{"input": "6 7 4\n1 10 2 3 4 5\n1 2\n1 3\n3 4\n4 5\n5 6\n6 2\n2 5", "output": ["4"]}, {"input": "6 7 100\n1 10 2 3 4 5\n1 2\n1 3\n3 4\n4 5\n5 6\n6 2\n2 5", "output": ["10"]}, {"input": "2 1 5\n1 1\n1 2", "output": ["-1"]}, {"input": "1 0 1\n1000000000", "output": ["1000000000"]}] | control_completion_005571 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: One day Masha was walking in the park and found a graph under a tree... Surprised? Did you think that this problem would have some logical and reasoned story? No way! So, the problem...Masha has an oriented graph which $$$i$$$-th vertex contai... | import sys
input = sys.stdin.readline
n, m, k = list(map(int,input().split()))
arr = list(map(int,input().split()))
adj = [list() for _ in range(n)]
for i in range(m):
u, v = list(map(int,input().split()))
adj[u-1].append(v-1)
def dfs(u, vis, val, dist, group):
vis[u] = True
grou... | dist[u] >= k | [{"input": "6 7 4\n1 10 2 3 4 5\n1 2\n1 3\n3 4\n4 5\n5 6\n6 2\n2 5", "output": ["4"]}, {"input": "6 7 100\n1 10 2 3 4 5\n1 2\n1 3\n3 4\n4 5\n5 6\n6 2\n2 5", "output": ["10"]}, {"input": "2 1 5\n1 1\n1 2", "output": ["-1"]}, {"input": "1 0 1\n1000000000", "output": ["1000000000"]}] | control_completion_005572 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: One day Masha was walking in the park and found a graph under a tree... Surprised? Did you think that this problem would have some logical and reasoned story? No way! So, the problem...Masha has an oriented graph which $$$i$$$-th vertex contai... | import sys
input = sys.stdin.readline
n, m, k = list(map(int,input().split()))
arr = list(map(int,input().split()))
adj = [list() for _ in range(n)]
for i in range(m):
u, v = list(map(int,input().split()))
adj[u-1].append(v-1)
def dfs(u, vis, val, dist, group):
vis[u] = True
grou... | arr[v] <= val | [{"input": "6 7 4\n1 10 2 3 4 5\n1 2\n1 3\n3 4\n4 5\n5 6\n6 2\n2 5", "output": ["4"]}, {"input": "6 7 100\n1 10 2 3 4 5\n1 2\n1 3\n3 4\n4 5\n5 6\n6 2\n2 5", "output": ["10"]}, {"input": "2 1 5\n1 1\n1 2", "output": ["-1"]}, {"input": "1 0 1\n1000000000", "output": ["1000000000"]}] | control_completion_005573 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | test = int(input())
for i in range(test):
ans = "B"
cnt =0
while cnt < 8 :
t = input()
if t.strip() != '':
cnt +=1
if {{completion}}:
ans = "R"
print(ans)
| t == "RRRRRRRR" | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005702 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | t=int(input())
for p in range(t):
l=[]
c=0
a=['R','R','R','R','R','R','R','R']
while(len(l)<8):
s=input()
if {{completion}}:
l.append([*s])
for i in range(8):
if l[i]==a:
c=1
break
print("B" if c!=1 else "R") | len(s)==8 | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005703 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | t=int(input())
for p in range(t):
l=[]
c=0
a=['R','R','R','R','R','R','R','R']
while(len(l)<8):
s=input()
if len(s)==8:
l.append([*s])
for i in range(8):
if {{completion}}:
c=1
break
print("B" if c!=1 else "R") | l[i]==a | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005704 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | for _ in range(int(input())):
l=[]
ans="B"
while len(l)!=8:
l.append(input())
if {{completion}}:
l.pop()
for row in l:
if row.count('R')==8:
ans='R'
break
print(ans)
| len(l[-1])<8 | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005705 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | for _ in range(int(input())):
l=[]
ans="B"
while len(l)!=8:
l.append(input())
if len(l[-1])<8:
l.pop()
for row in l:
if {{completion}}:
ans='R'
break
print(ans)
| row.count('R')==8 | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005706 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | from sys import stdin
n = int(input())
lines = stdin.read().split()
a = 0
for ele in range(n):
for i in range(8):
if {{completion}}:
print('R')
break
else:
print('B')
a+=8 | lines[i+a].count('R') == 8 | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005707 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | for _ in range(int(input())):
met = []
res = []
judge = True
i = 0
while i < 8:
tmp = input()
met.append(tmp)
if {{completion}}:
i += 1
if tmp == "R" * 8 and judge:
print("R")
judge = False
if judge:
pri... | tmp != '' | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005708 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | for _ in range(int(input())):
met = []
res = []
judge = True
i = 0
while i < 8:
tmp = input()
met.append(tmp)
if tmp != '':
i += 1
if {{completion}}:
print("R")
judge = False
if judge:
print("B")
# f... | tmp == "R" * 8 and judge | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005709 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | n = int(input())
for i in range(n) :
b = []
j = 0
while(j<8) :
a = input()
if(a != '') :
b.append(a)
j += 1
key = 0
for j in range(8) :
ok = True
for k in range(8) :
if{{completion}}:
ok = False
... | (b[j][k] != 'R') | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005710 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | from sys import stdin
t = int(input())
lines = stdin.read().split()
j = 0
for num in range(t):
for i in range(8):
if {{completion}}:
print('R')
break
else:
print('B')
j += 8 | lines[i + j].count('R') == 8 | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005711 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | t = int(input())
for _ in range(t):
count = 0
grid = []
while count < 8:
n = input()
if len(n) != 0:
count+=1
grid.append(n)
ans = False
for i in range(8):
x = False
for j in range(8):
if {{completion}}:
... | grid[i][j]!='R' | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005712 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | n = int(input())
for i in range(n) :
b = []
j = 0
key = '.'
while(j<8) :
a = input()
if{{completion}}:
b.append(a)
j += 1
for j in range(8) :
if(len(set(b[j])) == 1 and b[j][0] == 'R') :
key = 'R'
break
if(key!= ... | (a != '') | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005713 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the ce... | n = int(input())
for i in range(n) :
b = []
j = 0
key = '.'
while(j<8) :
a = input()
if(a != '') :
b.append(a)
j += 1
for j in range(8) :
if{{completion}}:
key = 'R'
break
if(key!= 'R') :
key = 'B'
... | (len(set(b[j])) == 1 and b[j][0] == 'R') | [{"input": "4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\... | control_completion_005714 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Mark has just purchased a rack of $$$n$$$ lightbulbs. The state of the lightbulbs can be described with binary string $$$s = s_1s_2\dots s_n$$$, where $$$s_i=\texttt{1}$$$ means that the $$$i$$$-th lightbulb is turned on, while $$$s_i=\texttt{... | import sys
inp = sys.stdin.read().split()[::-1]
out = []
def compress(s):
lst = None
ret = []
for c in s:
if {{completion}}:
ret.append(0)
lst = c
ret[-1] += 1
return ret
def transform(lns):
st = []
s = 0
for l in lns:
... | lst != c | [{"input": "4\n\n4\n\n0100\n\n0010\n\n4\n\n1010\n\n0100\n\n5\n\n01001\n\n00011\n\n6\n\n000101\n\n010011", "output": ["2\n-1\n-1\n5"]}] | control_completion_005768 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: After watching a certain anime before going to sleep, Mark dreams of standing in an old classroom with a blackboard that has a sequence of $$$n$$$ positive integers $$$a_1, a_2,\dots,a_n$$$ on it.Then, professor Koro comes in. He can perform t... | import sys
import os
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write ... | word != 0 | [{"input": "5 4\n2 2 2 4 5\n2 3\n5 3\n4 1\n1 4", "output": ["6\n5\n4\n5"]}, {"input": "2 1\n200000 1\n2 200000", "output": ["200001"]}] | control_completion_005831 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: After watching a certain anime before going to sleep, Mark dreams of standing in an old classroom with a blackboard that has a sequence of $$$n$$$ positive integers $$$a_1, a_2,\dots,a_n$$$ on it.Then, professor Koro comes in. He can perform t... | import sys
import os
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write ... | word != 0 | [{"input": "5 4\n2 2 2 4 5\n2 3\n5 3\n4 1\n1 4", "output": ["6\n5\n4\n5"]}, {"input": "2 1\n200000 1\n2 200000", "output": ["200001"]}] | control_completion_005832 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: After watching a certain anime before going to sleep, Mark dreams of standing in an old classroom with a blackboard that has a sequence of $$$n$$$ positive integers $$$a_1, a_2,\dots,a_n$$$ on it.Then, professor Koro comes in. He can perform t... | import sys
import os
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write ... | word != 0 | [{"input": "5 4\n2 2 2 4 5\n2 3\n5 3\n4 1\n1 4", "output": ["6\n5\n4\n5"]}, {"input": "2 1\n200000 1\n2 200000", "output": ["200001"]}] | control_completion_005833 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: After watching a certain anime before going to sleep, Mark dreams of standing in an old classroom with a blackboard that has a sequence of $$$n$$$ positive integers $$$a_1, a_2,\dots,a_n$$$ on it.Then, professor Koro comes in. He can perform t... | import sys
import os
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write ... | word != 0 | [{"input": "5 4\n2 2 2 4 5\n2 3\n5 3\n4 1\n1 4", "output": ["6\n5\n4\n5"]}, {"input": "2 1\n200000 1\n2 200000", "output": ["200001"]}] | control_completion_005834 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: After watching a certain anime before going to sleep, Mark dreams of standing in an old classroom with a blackboard that has a sequence of $$$n$$$ positive integers $$$a_1, a_2,\dots,a_n$$$ on it.Then, professor Koro comes in. He can perform t... | import sys
import os
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write ... | word != 0 | [{"input": "5 4\n2 2 2 4 5\n2 3\n5 3\n4 1\n1 4", "output": ["6\n5\n4\n5"]}, {"input": "2 1\n200000 1\n2 200000", "output": ["200001"]}] | control_completion_005835 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: After watching a certain anime before going to sleep, Mark dreams of standing in an old classroom with a blackboard that has a sequence of $$$n$$$ positive integers $$$a_1, a_2,\dots,a_n$$$ on it.Then, professor Koro comes in. He can perform t... | import sys
import os
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write ... | word != 0 | [{"input": "5 4\n2 2 2 4 5\n2 3\n5 3\n4 1\n1 4", "output": ["6\n5\n4\n5"]}, {"input": "2 1\n200000 1\n2 200000", "output": ["200001"]}] | control_completion_005836 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam.They love equilateral triangles and want to create $$$n$$$ equilateral triangles on the grid by adding some straight lines. The triangle... | import sys
ctr = [0, 0, 0]
cnt = [0]
while cnt[-1] < 10**9:
i = ctr.index(min(ctr))
cnt.append(cnt[-1] + 2*(sum(ctr) - ctr[i]))
ctr[i] += 1
def solve(sn):
t = int(sn)
s, e = 0, len(cnt) - 1
while s < e:
m = (s + e) >> 1
if {{completion}}:
e = m
else:
s = m + 1
return str(s)
i... | cnt[m] >= t | [{"input": "4\n\n1\n\n2\n\n3\n\n4567", "output": ["2\n2\n3\n83"]}] | control_completion_005883 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam.They love equilateral triangles and want to create $$$n$$$ equilateral triangles on the grid by adding some straight lines. The triangle... | import sys
ctr = [0, 0, 0]
cnt = [0]
i = 0
tot = 0
s = 0
while tot < 10**9:
tot += 2*(s - ctr[i])
cnt.append(tot)
ctr[i] += 1
s += 1
i += 1
if i == 3: i = 0
def solve(sn):
t = int(sn)
s, e = 0, len(cnt) - 1
while s < e:
m = (s + e) >> 1
if {{completion}}:
e = m
... | cnt[m] >= t | [{"input": "4\n\n1\n\n2\n\n3\n\n4567", "output": ["2\n2\n3\n83"]}] | control_completion_005884 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: While searching for the pizza, baby Hosssam came across two permutations $$$a$$$ and $$$b$$$ of length $$$n$$$.Recall that a permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For exampl... | """
in each circle, there's two options
"""
import sys;input=sys.stdin.readline
I=lambda:int(input())
A=lambda:[*map(int,input().split())]
mod=10**9+7
for _ in range(I()):
n=I()
a,b,c=A(),A(),A()
g={a[i]:[b[i],c[i]] for i in range(n)}
cycles,visi=0,[False]*(n+1)
for u in range(1,n+1):
n... | g[u][1]!=0 | [{"input": "9\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n2 0 1 0 0 0 0\n1\n1\n1\n0\n6\n1 5 2 4 6 3\n6 5 3 1 4 2\n6 0 0 0 0 0\n8\n1 6 4 7 2 3 8 5\n3 2 8 1 4 5 6 7\n1 0 0 7 0 3 0 5\n10\n1 8 6 2 4 7 9 3 10 5\n1 9 2 3 4 10 8 6 7 5\n1 9 2 3 4 10 8 6 7 5\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n0 0 0 0 0 0 0\n5\n1 2 3 4 5\n1 2 3 4 5\n0 0 0 ... | control_completion_005919 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: While searching for the pizza, baby Hosssam came across two permutations $$$a$$$ and $$$b$$$ of length $$$n$$$.Recall that a permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For exampl... | # read interger t from input.txt and then read t lines
import sys
DEBUG = False
def check(a, b, c):
a = [0] + a
b = [0] + b
c = [0] + c
m_ = [0] * len(a)
m = [0] * len(a)
for i in range(1, len(b)):
m_[b[i]] = i
for i in range(1, len(a)):
m[i] = m_[a[i]]
# print(">>>", a... | c[j] != 0 | [{"input": "9\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n2 0 1 0 0 0 0\n1\n1\n1\n0\n6\n1 5 2 4 6 3\n6 5 3 1 4 2\n6 0 0 0 0 0\n8\n1 6 4 7 2 3 8 5\n3 2 8 1 4 5 6 7\n1 0 0 7 0 3 0 5\n10\n1 8 6 2 4 7 9 3 10 5\n1 9 2 3 4 10 8 6 7 5\n1 9 2 3 4 10 8 6 7 5\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n0 0 0 0 0 0 0\n5\n1 2 3 4 5\n1 2 3 4 5\n0 0 0 ... | control_completion_005920 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: While searching for the pizza, baby Hosssam came across two permutations $$$a$$$ and $$$b$$$ of length $$$n$$$.Recall that a permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For exampl... |
import sys
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
a = list(map(int,sys.stdin.readline().split()))
b = list(map(int,sys.stdin.readline().split()))
c = list(map(int,sys.stdin.readline().split()))
count = 0
L = [0] * (n+1)
for i in range(0,n):
... | xcount >= 1 | [{"input": "9\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n2 0 1 0 0 0 0\n1\n1\n1\n0\n6\n1 5 2 4 6 3\n6 5 3 1 4 2\n6 0 0 0 0 0\n8\n1 6 4 7 2 3 8 5\n3 2 8 1 4 5 6 7\n1 0 0 7 0 3 0 5\n10\n1 8 6 2 4 7 9 3 10 5\n1 9 2 3 4 10 8 6 7 5\n1 9 2 3 4 10 8 6 7 5\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n0 0 0 0 0 0 0\n5\n1 2 3 4 5\n1 2 3 4 5\n0 0 0 ... | control_completion_005921 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: While searching for the pizza, baby Hosssam came across two permutations $$$a$$$ and $$$b$$$ of length $$$n$$$.Recall that a permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For exampl... | import sys
input = sys.stdin.readline
class Solver1670C:
def __init__(self):
self.n = int(input())
self.a = list(map(int, input().split(' ')))
self.b = list(map(int, input().split(' ')))
self.d = list(map(int, input().split(' ')))
self.pos_a = [0 for _ in rang... | self.been[j] == 0 | [{"input": "9\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n2 0 1 0 0 0 0\n1\n1\n1\n0\n6\n1 5 2 4 6 3\n6 5 3 1 4 2\n6 0 0 0 0 0\n8\n1 6 4 7 2 3 8 5\n3 2 8 1 4 5 6 7\n1 0 0 7 0 3 0 5\n10\n1 8 6 2 4 7 9 3 10 5\n1 9 2 3 4 10 8 6 7 5\n1 9 2 3 4 10 8 6 7 5\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n0 0 0 0 0 0 0\n5\n1 2 3 4 5\n1 2 3 4 5\n0 0 0 ... | control_completion_005922 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: While searching for the pizza, baby Hosssam came across two permutations $$$a$$$ and $$$b$$$ of length $$$n$$$.Recall that a permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For exampl... | import sys
input = sys.stdin.readline
class Solver1670C:
def __init__(self):
self.n = int(input())
self.a = list(map(int, input().split(' ')))
self.b = list(map(int, input().split(' ')))
self.d = list(map(int, input().split(' ')))
self.pos_a = [0 for _ in rang... | self.been[j] == 0 | [{"input": "9\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n2 0 1 0 0 0 0\n1\n1\n1\n0\n6\n1 5 2 4 6 3\n6 5 3 1 4 2\n6 0 0 0 0 0\n8\n1 6 4 7 2 3 8 5\n3 2 8 1 4 5 6 7\n1 0 0 7 0 3 0 5\n10\n1 8 6 2 4 7 9 3 10 5\n1 9 2 3 4 10 8 6 7 5\n1 9 2 3 4 10 8 6 7 5\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n0 0 0 0 0 0 0\n5\n1 2 3 4 5\n1 2 3 4 5\n0 0 0 ... | control_completion_005923 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: While searching for the pizza, baby Hosssam came across two permutations $$$a$$$ and $$$b$$$ of length $$$n$$$.Recall that a permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For exampl... | m = 10**9+7
for _ in range(int(input())):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
d={i:0 for i in range(1,n+1)}
for i in range(n):
d[c[i]]=1
dd={}
for i in range(n):
dd[a[i]]=i
... | (c[j]!=0) | [{"input": "9\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n2 0 1 0 0 0 0\n1\n1\n1\n0\n6\n1 5 2 4 6 3\n6 5 3 1 4 2\n6 0 0 0 0 0\n8\n1 6 4 7 2 3 8 5\n3 2 8 1 4 5 6 7\n1 0 0 7 0 3 0 5\n10\n1 8 6 2 4 7 9 3 10 5\n1 9 2 3 4 10 8 6 7 5\n1 9 2 3 4 10 8 6 7 5\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n0 0 0 0 0 0 0\n5\n1 2 3 4 5\n1 2 3 4 5\n0 0 0 ... | control_completion_005924 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: While searching for the pizza, baby Hosssam came across two permutations $$$a$$$ and $$$b$$$ of length $$$n$$$.Recall that a permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For exampl... | from sys import stdin, stdout
from functools import reduce
M = int(10**9 + 7)
def solve(a, b, c, n):
vis = [False]*n
ans = []
g = {a[i]:(b[i], c[i]) for i in range(n)}
for i in range(n):
t, ass, j = 0, False, i
while not vis[j]:
vis[j] = True
if {{com... | g[j + 1][1] != 0 | [{"input": "9\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n2 0 1 0 0 0 0\n1\n1\n1\n0\n6\n1 5 2 4 6 3\n6 5 3 1 4 2\n6 0 0 0 0 0\n8\n1 6 4 7 2 3 8 5\n3 2 8 1 4 5 6 7\n1 0 0 7 0 3 0 5\n10\n1 8 6 2 4 7 9 3 10 5\n1 9 2 3 4 10 8 6 7 5\n1 9 2 3 4 10 8 6 7 5\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n0 0 0 0 0 0 0\n5\n1 2 3 4 5\n1 2 3 4 5\n0 0 0 ... | control_completion_005925 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: While searching for the pizza, baby Hosssam came across two permutations $$$a$$$ and $$$b$$$ of length $$$n$$$.Recall that a permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For exampl... | from sys import stdin, setrecursionlimit
input = stdin.readline
from bisect import bisect_left, bisect_right
from collections import deque
from functools import lru_cache, reduce
from heapq import heappush, heappop
from math import sqrt, ceil, floor, log2
T = int(input())
def rl(t = int):
return list(map(t, inpu... | d[i] != 0 | [{"input": "9\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n2 0 1 0 0 0 0\n1\n1\n1\n0\n6\n1 5 2 4 6 3\n6 5 3 1 4 2\n6 0 0 0 0 0\n8\n1 6 4 7 2 3 8 5\n3 2 8 1 4 5 6 7\n1 0 0 7 0 3 0 5\n10\n1 8 6 2 4 7 9 3 10 5\n1 9 2 3 4 10 8 6 7 5\n1 9 2 3 4 10 8 6 7 5\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n0 0 0 0 0 0 0\n5\n1 2 3 4 5\n1 2 3 4 5\n0 0 0 ... | control_completion_005926 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: While searching for the pizza, baby Hosssam came across two permutations $$$a$$$ and $$$b$$$ of length $$$n$$$.Recall that a permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For exampl... | import math,sys;input=sys.stdin.readline;S=lambda:input().rstrip();I=lambda:int(S());M=lambda:map(int,S().split());L=lambda:list(M());mod1=1000000007;mod2=998244353
for _ in range(I()):
n=I();a=L();b=L();d=L();l=[]
for i in range(n):l.append([a[i],b[i],d[i]])
l.sort(key=lambda x:x[0]);s=set();ans=1
... | l[cur][2]!=0 or l[cur][1]==l[cur][0] | [{"input": "9\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n2 0 1 0 0 0 0\n1\n1\n1\n0\n6\n1 5 2 4 6 3\n6 5 3 1 4 2\n6 0 0 0 0 0\n8\n1 6 4 7 2 3 8 5\n3 2 8 1 4 5 6 7\n1 0 0 7 0 3 0 5\n10\n1 8 6 2 4 7 9 3 10 5\n1 9 2 3 4 10 8 6 7 5\n1 9 2 3 4 10 8 6 7 5\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n0 0 0 0 0 0 0\n5\n1 2 3 4 5\n1 2 3 4 5\n0 0 0 ... | control_completion_005927 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: While searching for the pizza, baby Hosssam came across two permutations $$$a$$$ and $$$b$$$ of length $$$n$$$.Recall that a permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For exampl... | import math,sys;input=sys.stdin.readline;S=lambda:input().rstrip();I=lambda:int(S());M=lambda:map(int,S().split());L=lambda:list(M());mod1=1000000007;mod2=998244353
for _ in range(I()):
n=I();a=L();b=L();d=L();l=[]
for i in range(n):l.append([a[i],b[i],d[i]])
l.sort(key=lambda x:x[0]);s=set();ans=1
... | d[l[cur][1]]==2 | [{"input": "9\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n2 0 1 0 0 0 0\n1\n1\n1\n0\n6\n1 5 2 4 6 3\n6 5 3 1 4 2\n6 0 0 0 0 0\n8\n1 6 4 7 2 3 8 5\n3 2 8 1 4 5 6 7\n1 0 0 7 0 3 0 5\n10\n1 8 6 2 4 7 9 3 10 5\n1 9 2 3 4 10 8 6 7 5\n1 9 2 3 4 10 8 6 7 5\n7\n1 2 3 4 5 6 7\n2 3 1 7 6 5 4\n0 0 0 0 0 0 0\n5\n1 2 3 4 5\n1 2 3 4 5\n0 0 0 ... | control_completion_005928 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: One day Prof. Slim decided to leave the kingdom of the GUC to join the kingdom of the GIU. He was given an easy online assessment to solve before joining the GIU. Citizens of the GUC were happy sad to see the prof leaving, so they decided to h... | import sys
ls = []
for l in sys.stdin:
lst = l.rstrip('\n')
if len(lst) > 0:
ls.append(lst)
for l in ls:
sys.stderr.write(l + ('\n'))
sys.stderr.write("-- output --\n")
def solve(n, a):
k = sum([0 if ai > 0 else 1 for ai in a])
b = [abs(a[i]) if i >= k else -abs(a[i]) for ... | b[i] > b[i+1] | [{"input": "4\n\n7\n\n7 3 2 -11 -13 -17 -23\n\n6\n\n4 10 25 47 71 96\n\n6\n\n71 -35 7 -4 -11 -25\n\n6\n\n-45 9 -48 -67 -55 7", "output": ["NO\nYES\nYES\nNO"]}] | control_completion_005942 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: During their training for the ICPC competitions, team "Jee You See" stumbled upon a very basic counting problem. After many "Wrong answer" verdicts, they finally decided to give up and destroy turn-off the PC. Now they want your help in up-sol... |
n,l,r,z=map(int,input().split())
mod=10**9+7
#############################
#############
cnb_max=10**5
#############
kai=[1]*(cnb_max+1)
rkai=[1]*(cnb_max+1)
for i in range(cnb_max):
kai[i+1]=kai[i]*(i+1)%mod
rkai[cnb_max]=pow(kai[cnb_max],mod-2,mod)
for i in range(cnb_max):
rkai[cn... | (r&1)==0 and (j+cnt)%2==1 | [{"input": "3 1 5 1", "output": ["13"]}, {"input": "4 1 3 2", "output": ["4"]}, {"input": "2 1 100000 15629", "output": ["49152"]}, {"input": "100 56 89 66", "output": ["981727503"]}] | control_completion_005959 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: During their training for the ICPC competitions, team "Jee You See" stumbled upon a very basic counting problem. After many "Wrong answer" verdicts, they finally decided to give up and destroy turn-off the PC. Now they want your help in up-sol... | import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7
N = 10000
fact = [0 for _ in range(N)]
invfact = [0 for _ in range(N)]
fact[0] = 1
for i in range(1, N):
fact[i] = fact[i - 1] * i % MOD
invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)
for i in range(N - 2, -1, -1):
invfact[i] = invfact[i + ... | rr < 0 | [{"input": "3 1 5 1", "output": ["13"]}, {"input": "4 1 3 2", "output": ["4"]}, {"input": "2 1 100000 15629", "output": ["49152"]}, {"input": "100 56 89 66", "output": ["981727503"]}] | control_completion_005960 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | a,b=map(int,input().split())
arr=[0]*500001
for {{completion}}:
arr[i]+=1
for i in range(1,500000):
arr[i+1]+=arr[i]//(i+1)
arr[i]%=i+1
if sum(arr[:b])==0:
print('Yes')
else:
print('No') | i in map(int,input().split()) | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005980 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | a,b=map(int,input().split())
arr=[0]*500001
for i in map(int,input().split()):
arr[i]+=1
for {{completion}}:
arr[i+1]+=arr[i]//(i+1)
arr[i]%=i+1
if sum(arr[:b])==0:
print('Yes')
else:
print('No') | i in range(1,500000) | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005981 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | import sys
from collections import Counter
input = sys.stdin.readline
n, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = Counter(a)
rest, base = 0, 1
for t in range(x, 0, -1):
if {{completion}}:
n -= cnt[t]
rest += cnt[t] % base
rest %= base
rest *= t
... | t in cnt | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005982 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | import sys
from collections import Counter
input = sys.stdin.readline
n, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = Counter(a)
rest, base = 0, 1
for t in range(x, 0, -1):
if t in cnt:
n -= cnt[t]
rest += cnt[t] % base
rest %= base
rest *= t
bas... | n == 0 or base - rest > n * t | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005983 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | def rl():
return [int(i) for i in input().split()]
def solve():
[n,x]=rl()
a=rl()
nax=500000+5
ct=[0 for i in range(nax)]
for b in a:
ct[b]+=1
for i in range(x):
if {{completion}}:
return "No"
ct[i+1]+=ct[i]/(i+1)
return "Yes"
print(solve())
| ct[i]%(i+1) | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005984 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | # your code goes here
if __name__ == '__main__':
n, x = map(int, input('').split(' '))
a = list(map(int, input('').split(' ')))
cnt = [0] * (x+2)
for w in a:
cnt[w] += 1
for i in range(x):
while {{completion}}:
cnt[i] -= (i+1)
cnt[i+1] += 1
print('No' if sum(cnt[:x]) else 'Yes')
| cnt[i] > i | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005985 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | def factorial_divisibility(n, x, a: list):
a.sort()
a.reverse()
while True:
k = a[-1]
a.pop()
cnt = 1
while {{completion}}:
cnt += 1
a.pop()
if cnt < k + 1:
return ('Yes' if k >= x else 'No' )
for i in range(cn... | len(a) > 0 and k == a[-1] | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005986 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | def factorial_divisibility(n, x, a: list):
a.sort()
a.reverse()
while True:
k = a[-1]
a.pop()
cnt = 1
while len(a) > 0 and k == a[-1]:
cnt += 1
a.pop()
if {{completion}}:
return ('Yes' if k >= x else 'No' )
for... | cnt < k + 1 | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005987 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | n , x = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
s = [0] * (x+1)
for i in l:
s[i] += 1
for i in range(1,x):
if {{completion}}:
s[i+1] += s[i]//(i+1)
else:
print('NO')
break
else:
print('Yes') | s[i] % (i+1) == 0 | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005988 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... |
ex = [0]
arr = [0]
for i in range(1):
a = list(map(int, input().split()))
ex = a[1]
b = list(map(int, input().split()))
arr = b
for i in range(1):
dp = [0]*ex
for a in arr:
dp[a-1]+=1
for m in range(len(dp)-1):
while {{completion}}:
dp[m] = dp[m] ... | dp[m]>=m+2 | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005989 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | n,x=map(int,input().split())
s={i:0 for i in range(1,x+1)}
def f(x,a):
s[x]=s[x]+a
an=map(int,input().split())
for b in an:
f(b,1)
l=1
i=1
while i < x:
if {{completion}}:
f(i+1,s[i]//(i+1))
i+=1
else:
l=0
break
print(['no','yes'][l])
| s[i]%(i+1)==0 | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005990 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | b=[0]*500001
l=list(map(int,input("").split()))
n=l[0]
m=l[1]
a=list(map(int,input("").split()))
e=1
for i in a:
b[i]+=1
for i in range(1,l[1]):
if {{completion}}:
b[i+1]+=(b[i]//(i+1))
else:
print("No")
e=0
break
if e==1:
if b[m]!=0 :
print("Yes"... | b[i]%(i+1)==0 | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005991 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given an integer $$$x$$$ and an array of integers $$$a_1, a_2, \ldots, a_n$$$. You have to determine if the number $$$a_1! + a_2! + \ldots + a_n!$$$ is divisible by $$$x!$$$.Here $$$k!$$$ is a factorial of $$$k$$$Β β the product of all ... | b=[0]*500001
l=list(map(int,input("").split()))
n=l[0]
m=l[1]
a=list(map(int,input("").split()))
e=1
for i in a:
b[i]+=1
for i in range(1,l[1]):
if b[i]%(i+1)==0:
b[i+1]+=(b[i]//(i+1))
else:
print("No")
e=0
break
if e==1:
if {{completion}}:
print(... | b[m]!=0 | [{"input": "6 4\n3 2 2 2 3 3", "output": ["Yes"]}, {"input": "8 3\n3 2 2 2 2 2 1 1", "output": ["Yes"]}, {"input": "7 8\n7 7 7 7 7 7 7", "output": ["No"]}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4", "output": ["No"]}, {"input": "2 500000\n499999 499999", "output": ["No"]}] | control_completion_005992 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have been invited as a production process optimization specialist to some very large company. The company has $$$n$$$ machines at its factory, standing one behind another in the production chain. Each machine can be described in one of the... | from bisect import bisect
import sys
input = sys.stdin.readline
n, b, p, m = map(int, input().split())
adds = []
curr = []
mults = []
i = 0
for _ in range(n):
t, v = input().split()
v = int(v)
if t == '*':
if v == 1:
continue
curr.sort()
a... | exc[j] == 0 | [{"input": "3 2 1 3\n* 2\n+ 1\n+ 1", "output": ["6"]}, {"input": "4 2 2 2\n* 2\n+ 1\n* 3\n+ 2", "output": ["21"]}, {"input": "8 2 1 1\n* 2\n+ 1\n* 4\n+ 1\n+ 1\n+ 1\n* 5\n+ 3", "output": ["240"]}] | control_completion_006010 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have been invited as a production process optimization specialist to some very large company. The company has $$$n$$$ machines at its factory, standing one behind another in the production chain. Each machine can be described in one of the... | from bisect import bisect
import sys
input = sys.stdin.readline
n, b, p, m = map(int, input().split())
adds = []
curr = []
mults = []
i = 0
for _ in range(n):
t, v = input().split()
v = int(v)
if t == '*':
if v == 1:
continue
curr.sort()
a... | un_m[i] == v | [{"input": "3 2 1 3\n* 2\n+ 1\n+ 1", "output": ["6"]}, {"input": "4 2 2 2\n* 2\n+ 1\n* 3\n+ 2", "output": ["21"]}, {"input": "8 2 1 1\n* 2\n+ 1\n* 4\n+ 1\n+ 1\n+ 1\n* 5\n+ 3", "output": ["240"]}] | control_completion_006011 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: We call an array $$$a$$$ of length $$$n$$$ fancy if for each $$$1 < i \le n$$$ it holds that $$$a_i = a_{i-1} + 1$$$.Let's call $$$f(p)$$$ applied to a permutation$$$^\dagger$$$ of length $$$n$$$ as the minimum number of subarrays it can be... | n, m = map(int, input().split())
def modmul(a, b, c = 0):
return (a * b + c) % m
comb = [[1]]
for i in range(2010):
prev = comb[-1]
nex = [1]
for i in range(i):
nex.append((prev[i] + prev[i + 1]) % m)
nex.append(1)
comb.append(nex)
fact = [1]
for i in range(1, 3000):
... | spec[d] | [{"input": "4 666012\n1 3 4 2", "output": ["1 0 1 1"]}, {"input": "3 10\n3 2 1", "output": ["1 2 2"]}, {"input": "7 1000000000\n7 2 1 3 5 4 6", "output": ["1 6 40 201 705 1635 1854"]}, {"input": "10 11\n10 9 8 7 6 5 4 3 2 1", "output": ["1 9 9 0 1 5 5 0 1 0"]}] | control_completion_006355 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: We call an array $$$a$$$ of length $$$n$$$ fancy if for each $$$1 < i \le n$$$ it holds that $$$a_i = a_{i-1} + 1$$$.Let's call $$$f(p)$$$ applied to a permutation$$$^\dagger$$$ of length $$$n$$$ as the minimum number of subarrays it can be... | n, m = map(int, input().split())
def modmul(a, b, c = 0):
return (a * b + c) % m
comb = [[1]]
for i in range(2010):
prev = comb[-1]
nex = [1]
for i in range(i):
nex.append((prev[i] + prev[i + 1]) % m)
nex.append(1)
comb.append(nex)
fact = [1]
for i in range(1, 3000):
... | rem[j] == 0 | [{"input": "4 666012\n1 3 4 2", "output": ["1 0 1 1"]}, {"input": "3 10\n3 2 1", "output": ["1 2 2"]}, {"input": "7 1000000000\n7 2 1 3 5 4 6", "output": ["1 6 40 201 705 1635 1854"]}, {"input": "10 11\n10 9 8 7 6 5 4 3 2 1", "output": ["1 9 9 0 1 5 5 0 1 0"]}] | control_completion_006356 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given a connected undirected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. The weight of the $$$i$$$-th edge is $$$i$$$.Here is a wrong algorithm of finding a minimum spanning tree (MST) of a graph:vis := an array of length n... | input = __import__('sys').stdin.readline
class DisjointSetUnion(object):
def __init__(self, n):
self.n = n
self.par = [i for i in range(n)]
def find(self, x):
toupdate = []
while {{completion}}:
toupdate.append(x)
x = self.par[x]
... | x != self.par[x] | [{"input": "5 5\n1 2\n3 5\n1 3\n3 2\n4 2", "output": ["01111"]}, {"input": "10 11\n1 2\n2 5\n3 4\n4 2\n8 1\n4 5\n10 5\n9 5\n8 2\n5 7\n4 6", "output": ["0011111011"]}] | control_completion_006662 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You are given a connected undirected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. The weight of the $$$i$$$-th edge is $$$i$$$.Here is a wrong algorithm of finding a minimum spanning tree (MST) of a graph:vis := an array of length n... | input = __import__('sys').stdin.readline
class DisjointSetUnion(object):
def __init__(self, n):
self.n = n
self.par = [i for i in range(n)]
def find(self, x):
toupdate = []
while x != self.par[x]:
toupdate.append(x)
x = self.par[x]
... | u != v | [{"input": "5 5\n1 2\n3 5\n1 3\n3 2\n4 2", "output": ["01111"]}, {"input": "10 11\n1 2\n2 5\n3 4\n4 2\n8 1\n4 5\n10 5\n9 5\n8 2\n5 7\n4 6", "output": ["0011111011"]}] | control_completion_006663 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have an array $$$a$$$ of size $$$n$$$ consisting only of zeroes and ones. You can do the following operation: choose two indices $$$1 \le i , j \le n$$$, $$$i \ne j$$$, add $$$a_{i}$$$ to $$$a_{j}$$$, remove $$$a_{i}$$$ from $$$a$$$. No... | import sys
tokens = (token for token in sys.stdin.read().split())
N = int(next(tokens))
for i in range(N):
Q = int(next(tokens))
arr = []
count = 0
for i in range(Q):
arr.append(int(next(tokens)))
i = 0
j = len(arr) - 1
while True:
while True:
if {{completion}}:
break
else:
... | arr[i] == 1 or i == j | [{"input": "4\n\n8\n\n0 0 1 1 1 1 1 1\n\n5\n\n1 0 0 1 1\n\n2\n\n1 0\n\n11\n\n1 1 0 0 1 0 0 1 1 1 0", "output": ["0\n1\n1\n3"]}] | control_completion_006839 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have an array $$$a$$$ of size $$$n$$$ consisting only of zeroes and ones. You can do the following operation: choose two indices $$$1 \le i , j \le n$$$, $$$i \ne j$$$, add $$$a_{i}$$$ to $$$a_{j}$$$, remove $$$a_{i}$$$ from $$$a$$$. No... | import sys
tokens = (token for token in sys.stdin.read().split())
N = int(next(tokens))
for i in range(N):
Q = int(next(tokens))
arr = []
count = 0
for i in range(Q):
arr.append(int(next(tokens)))
i = 0
j = len(arr) - 1
while True:
while True:
if arr[i] == 1 or i == j:
break
e... | arr[j] == 0 or j == i | [{"input": "4\n\n8\n\n0 0 1 1 1 1 1 1\n\n5\n\n1 0 0 1 1\n\n2\n\n1 0\n\n11\n\n1 1 0 0 1 0 0 1 1 1 0", "output": ["0\n1\n1\n3"]}] | control_completion_006840 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have an array $$$a$$$ of size $$$n$$$ consisting only of zeroes and ones. You can do the following operation: choose two indices $$$1 \le i , j \le n$$$, $$$i \ne j$$$, add $$$a_{i}$$$ to $$$a_{j}$$$, remove $$$a_{i}$$$ from $$$a$$$. No... | import sys
tokens = (token for token in sys.stdin.read().split())
N = int(next(tokens))
for i in range(N):
Q = int(next(tokens))
arr = []
count = 0
for i in range(Q):
arr.append(int(next(tokens)))
i = 0
j = len(arr) - 1
while True:
while True:
if {{completion}}:
break
else:
... | arr[i] == 1 or i == j | [{"input": "4\n\n8\n\n0 0 1 1 1 1 1 1\n\n5\n\n1 0 0 1 1\n\n2\n\n1 0\n\n11\n\n1 1 0 0 1 0 0 1 1 1 0", "output": ["0\n1\n1\n3"]}] | control_completion_006841 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have an array $$$a$$$ of size $$$n$$$ consisting only of zeroes and ones. You can do the following operation: choose two indices $$$1 \le i , j \le n$$$, $$$i \ne j$$$, add $$$a_{i}$$$ to $$$a_{j}$$$, remove $$$a_{i}$$$ from $$$a$$$. No... | import sys
tokens = (token for token in sys.stdin.read().split())
N = int(next(tokens))
for i in range(N):
Q = int(next(tokens))
arr = []
count = 0
for i in range(Q):
arr.append(int(next(tokens)))
i = 0
j = len(arr) - 1
while True:
while True:
if arr[i] == 1 or i == j:
break
e... | arr[j] == 0 or j == i | [{"input": "4\n\n8\n\n0 0 1 1 1 1 1 1\n\n5\n\n1 0 0 1 1\n\n2\n\n1 0\n\n11\n\n1 1 0 0 1 0 0 1 1 1 0", "output": ["0\n1\n1\n3"]}] | control_completion_006842 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You have an array $$$a$$$ of size $$$n$$$ consisting only of zeroes and ones and an integer $$$k$$$. In one operation you can do one of the following: Select $$$2$$$ consecutive elements of $$$a$$$ and replace them with their minimum (that is... | from sys import stdin
from collections import deque
lst = list(map(int, stdin.read().split()))
_s = 0
def inp(n=1):
global _s
ret = lst[_s:_s + n]
_s += n
return ret
def inp1():
return inp()[0]
t = inp1()
for {{completion}}:
n = inp1()
k = inp1()
a = set(inp(n))
print("YES"... | _ in range(t) | [{"input": "7\n\n3 2\n\n0 1 0\n\n5 3\n\n1 0 1 1 0\n\n2 2\n\n1 1\n\n4 4\n\n0 0 0 0\n\n6 3\n\n0 0 1 0 0 1\n\n7 5\n\n1 1 1 1 1 1 1\n\n5 3\n\n0 0 1 0 0", "output": ["YES\nYES\nYES\nNO\nYES\nYES\nYES"]}] | control_completion_006875 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: This is the hard version of this problem. In this version, we have queries. Note that we do not have multiple test cases in this version. You can make hacks only if both versions of the problem are solved.An array $$$b$$$ of length $$$m$$$ is ... | import sys
input = sys.stdin.readline
inf = float('inf')
def getInt():
return int(input())
def getStr():
return input().strip()
def getList(split=True):
s = getStr()
if split:
s = s.split()
return map(int, s)
# t = getInt()
t = 1
def solve():
n = getInt()
a = list(getList(... | it and keys[it-1] + 1 == u | [{"input": "4\n2 4 1 4\n3\n2 4\n3 3\n2 1", "output": ["6\n10\n5"]}, {"input": "5\n1 1 3 2 1\n3\n1 3\n2 5\n4 5", "output": ["7\n9\n8"]}] | control_completion_006945 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: This is the hard version of this problem. In this version, we have queries. Note that we do not have multiple test cases in this version. You can make hacks only if both versions of the problem are solved.An array $$$b$$$ of length $$$m$$$ is ... | import sys
input = sys.stdin.readline
inf = float('inf')
def getInt():
return int(input())
def getStr():
return input().strip()
def getList(split=True):
s = getStr()
if split:
s = s.split()
return map(int, s)
# t = getInt()
t = 1
def solve():
n = getInt()
a = list(getList(... | v > a[u] | [{"input": "4\n2 4 1 4\n3\n2 4\n3 3\n2 1", "output": ["6\n10\n5"]}, {"input": "5\n1 1 3 2 1\n3\n1 3\n2 5\n4 5", "output": ["7\n9\n8"]}] | control_completion_006946 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: This is the hard version of this problem. In this version, we have queries. Note that we do not have multiple test cases in this version. You can make hacks only if both versions of the problem are solved.An array $$$b$$$ of length $$$m$$$ is ... | from sys import stdin, stdout
from collections import defaultdict
n = int(stdin.readline())
a = [int(x) for x in stdin.readline().split()]
left = 0
right = 0
right_array = []
right_prefix = [0]
answer = 0
second_right = 0
second_right_array = []
second_right_prefix = [0]
while left < n:
if righ... | right_array[candidate] > p | [{"input": "4\n2 4 1 4\n3\n2 4\n3 3\n2 1", "output": ["6\n10\n5"]}, {"input": "5\n1 1 3 2 1\n3\n1 3\n2 5\n4 5", "output": ["7\n9\n8"]}] | control_completion_006947 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: This is the hard version of this problem. In this version, we have queries. Note that we do not have multiple test cases in this version. You can make hacks only if both versions of the problem are solved.An array $$$b$$$ of length $$$m$$$ is ... | from sys import stdin, stdout
from collections import defaultdict
n = int(stdin.readline())
a = [int(x) for x in stdin.readline().split()]
left = 0
right = 0
right_array = []
right_prefix = [0]
answer = 0
second_right = 0
second_right_array = []
second_right_prefix = [0]
while left < n:
if righ... | upper - lower > 1 | [{"input": "4\n2 4 1 4\n3\n2 4\n3 3\n2 1", "output": ["6\n10\n5"]}, {"input": "5\n1 1 3 2 1\n3\n1 3\n2 5\n4 5", "output": ["7\n9\n8"]}] | control_completion_006948 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Madoka decided to participate in an underground sports programming competition. And there was exactly one task in it:A square table of size $$$n \times n$$$, where $$$n$$$ is a multiple of $$$k$$$, is called good if only the characters '.' and... | import sys
if __name__ == "__main__":
input_arr = sys.stdin.read().split()
tc = int(input_arr[0])
pos = 1
for case in range(tc):
n, k, r, c = list(map(int, input_arr[pos:pos + 4]))
pos += 4
mat = [["." for _ in range(n)] for j in range(n)]
r = r - 1
c ... | ll in range(l) | [{"input": "3\n\n3 3 3 2\n\n2 1 1 2\n\n6 3 4 2", "output": ["X..\n..X\n.X.\nXX\nXX\n.X..X.\nX..X..\n..X..X\n.X..X.\nX..X..\n..X..X"]}] | control_completion_007042 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: Madoka decided to participate in an underground sports programming competition. And there was exactly one task in it:A square table of size $$$n \times n$$$, where $$$n$$$ is a multiple of $$$k$$$, is called good if only the characters '.' and... | import sys
if __name__ == "__main__":
input_arr = sys.stdin.read().split()
tc = int(input_arr[0])
pos = 1
for case in range(tc):
n, k, r, c = list(map(int, input_arr[pos:pos + 4]))
pos += 4
mat = [["." for _ in range(n)] for j in range(n)]
r = r - 1
c ... | j in i | [{"input": "3\n\n3 3 3 2\n\n2 1 1 2\n\n6 3 4 2", "output": ["X..\n..X\n.X.\nXX\nXX\n.X..X.\nX..X..\n..X..X\n.X..X.\nX..X..\n..X..X"]}] | control_completion_007043 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: You work in the quality control department of technical support for a large company. Your job is to make sure all client issues have been resolved.Today you need to check a copy of a dialog between a client and a technical support manager. Acc... | import fileinput
def f(n):
i = 0
while i<len(n):
if n[i] == "Q":
found = False
for j in range(i,len(n)):
if {{completion}}:
n = n[:j] + n[j+1:]
found = True
break
if not found:
... | n[j] == "A" | [{"input": "5\n\n4\n\nQQAA\n\n4\n\nQQAQ\n\n3\n\nQAA\n\n1\n\nQ\n\n14\n\nQAQQAQAAQQQAAA", "output": ["Yes\nNo\nYes\nNo\nYes"]}] | control_completion_007194 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: We say an infinite sequence $$$a_{0}, a_{1}, a_2, \ldots$$$ is non-increasing if and only if for all $$$i\ge 0$$$, $$$a_i \ge a_{i+1}$$$.There is an infinite right and down grid. The upper-left cell has coordinates $$$(0,0)$$$. Rows are number... | n,x,d,m,f=int(input()),0,0,10**9+7,[1]
for {{completion}}:f.append(f[-1]*i%m)
for z in map(int,input().split()):d+=f[z+x]*pow(f[x+1]*f[z-1],-1,m)*(z>0);x+=1
print(d%m) | i in range(1,9**6) | [{"input": "2\n2 2 0", "output": ["5"]}, {"input": "10\n12 11 8 8 6 6 6 5 3 2 1", "output": ["2596"]}] | control_completion_007307 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: We say an infinite sequence $$$a_{0}, a_{1}, a_2, \ldots$$$ is non-increasing if and only if for all $$$i\ge 0$$$, $$$a_i \ge a_{i+1}$$$.There is an infinite right and down grid. The upper-left cell has coordinates $$$(0,0)$$$. Rows are number... | n,x,d,m,f=int(input()),0,0,10**9+7,[1]
for i in range(1,9**6):f.append(f[-1]*i%m)
for {{completion}}:d+=f[z+x]*pow(f[x+1]*f[z-1],-1,m)*(z>0);x+=1
print(d%m) | z in map(int,input().split()) | [{"input": "2\n2 2 0", "output": ["5"]}, {"input": "10\n12 11 8 8 6 6 6 5 3 2 1", "output": ["2596"]}] | control_completion_007308 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: We say an infinite sequence $$$a_{0}, a_{1}, a_2, \ldots$$$ is non-increasing if and only if for all $$$i\ge 0$$$, $$$a_i \ge a_{i+1}$$$.There is an infinite right and down grid. The upper-left cell has coordinates $$$(0,0)$$$. Rows are number... | from math import gcd
mod=1_000_000_007
maxn=400_100
fac=[1]*maxn
for i in range(2,maxn):
fac[i]=(fac[i-1]*i)%mod
def inv(b,m):
return pow(b, m - 2, m)
n=int(input())
a=list(map(int,input().split()))
o=0
for i in range(n+1):
if {{completion}}: break
c=fac[a[i]+i]*inv(fac[i+1]*fac[a[i]-1],mod)
... | a[i]==0 | [{"input": "2\n2 2 0", "output": ["5"]}, {"input": "10\n12 11 8 8 6 6 6 5 3 2 1", "output": ["2596"]}] | control_completion_007309 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: We say an infinite sequence $$$a_{0}, a_{1}, a_2, \ldots$$$ is non-increasing if and only if for all $$$i\ge 0$$$, $$$a_i \ge a_{i+1}$$$.There is an infinite right and down grid. The upper-left cell has coordinates $$$(0,0)$$$. Rows are number... | N = 4 * 10**5 + 5
MOD = 10**9 + 7
fact = [1]
invf = [1]
for i in range(1, N):
fact.append(fact[i-1] * i % MOD)
invf.append(pow(fact[-1], MOD-2, MOD))
def C(m, n):
if {{completion}}:
return 0
return fact[m] * invf[n] % MOD * invf[m-n] % MOD
n = int(input())
a = list(map(in... | n < 0 or m < n | [{"input": "2\n2 2 0", "output": ["5"]}, {"input": "10\n12 11 8 8 6 6 6 5 3 2 1", "output": ["2596"]}] | control_completion_007310 | control_fixed |
python | Complete the code in python to solve this programming problem:
Description: We say an infinite sequence $$$a_{0}, a_{1}, a_2, \ldots$$$ is non-increasing if and only if for all $$$i\ge 0$$$, $$$a_i \ge a_{i+1}$$$.There is an infinite right and down grid. The upper-left cell has coordinates $$$(0,0)$$$. Rows are number... | import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7
n = int(input())
a = [int(x) for x in input().split()]
fac = [1]
for i in range(8 * 10 ** 5 - 1):
fac.append((fac[-1] * (i + 1)) % MOD)
ans = 0
for i in range(n + 1):
if {{completion}}:
ans = (ans + fac[a[i] + i] * pow((fac[i + 1] * fac[... | a[i] != 0 | [{"input": "2\n2 2 0", "output": ["5"]}, {"input": "10\n12 11 8 8 6 6 6 5 3 2 1", "output": ["2596"]}] | control_completion_007311 | control_fixed |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.