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: There are $$$n$$$ candies put from left to right on a table. The candies are numbered from left to right. The $$$i$$$-th candy has weight $$$w_i$$$. Alice and Bob eat candies. Alice can eat any number of candies from the left (she can't skip c...
for _ in range(int(input())): n = int(input()) a = [*map(int, input().split())] x = sum(a) // 2 s, d = 0, {} for idx, i in enumerate(a): s += i if s > x: break d[s] = idx + 1 s, r = 0, 0 for idx, i in enumerate(a[::-1]): s += i if {{complet...
s in d
[{"input": "4\n3\n10 20 10\n6\n2 1 4 2 4 1\n5\n1 2 4 8 16\n9\n7 3 20 5 15 1 11 8 10", "output": ["2\n6\n0\n7"]}]
control_completion_000791
control_fixed
python
Complete the code in python to solve this programming problem: Description: There are $$$n$$$ candies put from left to right on a table. The candies are numbered from left to right. The $$$i$$$-th candy has weight $$$w_i$$$. Alice and Bob eat candies. Alice can eat any number of candies from the left (she can't skip c...
n = int(input()) for i in range(n): h = 1 g = 1 counter = 0 m = int(input()) lst = list(map(int, input().split())) index =0 e= 0 r =m-1 highest = lst[m-1] lowest = lst[0] while h+g <= m: if lowest<highest: lowest+=lst[e+1] e+=1 ...
highest<lowest
[{"input": "4\n3\n10 20 10\n6\n2 1 4 2 4 1\n5\n1 2 4 8 16\n9\n7 3 20 5 15 1 11 8 10", "output": ["2\n6\n0\n7"]}]
control_completion_000792
control_fixed
python
Complete the code in python to solve this programming problem: Description: There are $$$n$$$ candies put from left to right on a table. The candies are numbered from left to right. The $$$i$$$-th candy has weight $$$w_i$$$. Alice and Bob eat candies. Alice can eat any number of candies from the left (she can't skip c...
n = int(input()) for i in range(n): h = 1 g = 1 counter = 0 m = int(input()) lst = list(map(int, input().split())) index =0 e= 0 r =m-1 highest = lst[m-1] lowest = lst[0] while h+g <= m: if lowest<highest: lowest+=lst[e+1] e+=1 ...
highest == lowest
[{"input": "4\n3\n10 20 10\n6\n2 1 4 2 4 1\n5\n1 2 4 8 16\n9\n7 3 20 5 15 1 11 8 10", "output": ["2\n6\n0\n7"]}]
control_completion_000793
control_fixed
python
Complete the code in python to solve this programming problem: Description: There are $$$n$$$ candies put from left to right on a table. The candies are numbered from left to right. The $$$i$$$-th candy has weight $$$w_i$$$. Alice and Bob eat candies. Alice can eat any number of candies from the left (she can't skip c...
def read(): return int(input()) def readline(): return list(map(int,input().split())) def solve(): n=read() arr=readline() ans,cur=0,0 a,suma=-1,0 b,sumb=n,0 while True: if a>=b: break elif {{completion}}: b-=1 sumb+=arr[b] ...
suma>sumb
[{"input": "4\n3\n10 20 10\n6\n2 1 4 2 4 1\n5\n1 2 4 8 16\n9\n7 3 20 5 15 1 11 8 10", "output": ["2\n6\n0\n7"]}]
control_completion_000794
control_fixed
python
Complete the code in python to solve this programming problem: Description: There are $$$n$$$ candies put from left to right on a table. The candies are numbered from left to right. The $$$i$$$-th candy has weight $$$w_i$$$. Alice and Bob eat candies. Alice can eat any number of candies from the left (she can't skip c...
def read(): return int(input()) def readline(): return list(map(int,input().split())) def solve(): n=read() arr=readline() ans,cur=0,0 a,suma=-1,0 b,sumb=n,0 while True: if a>=b: break elif suma>sumb: b-=1 sumb+=arr[b] ...
suma<sumb
[{"input": "4\n3\n10 20 10\n6\n2 1 4 2 4 1\n5\n1 2 4 8 16\n9\n7 3 20 5 15 1 11 8 10", "output": ["2\n6\n0\n7"]}]
control_completion_000795
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid with $$$n$$$ rows and $$$m$$$ columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall down until they meet the...
for _ in range(int(input())): n, _ = map(int, input().split()) a = map("".join, zip(*(input() for _ in range(n)))) a = ("o".join("".join(sorted(y, reverse=True)) for y in x.split("o")) for x in a) for {{completion}}: print("".join(x))
x in zip(*a)
[{"input": "3\n6 10\n.*.*....*.\n.*.......*\n...o....o.\n.*.*....*.\n..........\n.o......o*\n2 9\n...***ooo\n.*o.*o.*o\n5 5\n*****\n*....\n*****\n....*\n*****", "output": ["..........\n...*....*.\n.*.o....o.\n.*........\n.*......**\n.o.*....o*\n\n....**ooo\n.*o**o.*o\n\n.....\n*...*\n*****\n*****\n*****"]}]
control_completion_000829
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid with $$$n$$$ rows and $$$m$$$ columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall down until they meet the...
# Write your code here :-) # Fall Down def solution(): n, m = [int(i) for i in input().split()] grid = [list(input()) for _ in range(n)] for i in range(m): for j in range(n - 1, -1, -1): if grid[j][i] == "*": grid[j][i] = "." pos = j while ...
pos < n - 1 and grid[pos + 1][i] == "."
[{"input": "3\n6 10\n.*.*....*.\n.*.......*\n...o....o.\n.*.*....*.\n..........\n.o......o*\n2 9\n...***ooo\n.*o.*o.*o\n5 5\n*****\n*....\n*****\n....*\n*****", "output": ["..........\n...*....*.\n.*.o....o.\n.*........\n.*......**\n.o.*....o*\n\n....**ooo\n.*o**o.*o\n\n.....\n*...*\n*****\n*****\n*****"]}]
control_completion_000830
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid with $$$n$$$ rows and $$$m$$$ columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall down until they meet the...
def res(s): a=s.split('o');t='' for i in a:t+=i.count('*')*'*'+i.count('.')*'.'+'o' return t[:-1] for _ in[0]*int(input()): n,m=map(int,input().split()) a=[[*input()] for x in[0]*n] b=[] for i in range(m):b+=res(''.join([a[~j][i] for j in range(n)])), for i in range(n): for {{completion}}:print(b[...
j in range(m)
[{"input": "3\n6 10\n.*.*....*.\n.*.......*\n...o....o.\n.*.*....*.\n..........\n.o......o*\n2 9\n...***ooo\n.*o.*o.*o\n5 5\n*****\n*....\n*****\n....*\n*****", "output": ["..........\n...*....*.\n.*.o....o.\n.*........\n.*......**\n.o.*....o*\n\n....**ooo\n.*o**o.*o\n\n.....\n*...*\n*****\n*****\n*****"]}]
control_completion_000831
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid with $$$n$$$ rows and $$$m$$$ columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall down until they meet the...
c=input() for _ in range(int(c)): b=input().split() a=[] for i in range(int(b[0])): a.append(list(input())) for i in range(int(b[1])): count=0 row=int(b[0])-1 for j in range(int(b[0])): if a[row][i]=='.': count+=1 elif {...
a[row][i]=='o'
[{"input": "3\n6 10\n.*.*....*.\n.*.......*\n...o....o.\n.*.*....*.\n..........\n.o......o*\n2 9\n...***ooo\n.*o.*o.*o\n5 5\n*****\n*....\n*****\n....*\n*****", "output": ["..........\n...*....*.\n.*.o....o.\n.*........\n.*......**\n.o.*....o*\n\n....**ooo\n.*o**o.*o\n\n.....\n*...*\n*****\n*****\n*****"]}]
control_completion_000832
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid with $$$n$$$ rows and $$$m$$$ columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall down until they meet the...
import sys input = sys.stdin.readline for _ in [0]*int(input()): n,m=map(int,input().split()) s=['']*m for _ in [0]*n: s=[s[i]+j for i,j in zip(range(m),input())] col=['']*n k=0 for i in s: bl=0 x='' for j in i[::-1]: if j=='o': ...
j=='*'
[{"input": "3\n6 10\n.*.*....*.\n.*.......*\n...o....o.\n.*.*....*.\n..........\n.o......o*\n2 9\n...***ooo\n.*o.*o.*o\n5 5\n*****\n*....\n*****\n....*\n*****", "output": ["..........\n...*....*.\n.*.o....o.\n.*........\n.*......**\n.o.*....o*\n\n....**ooo\n.*o**o.*o\n\n.....\n*...*\n*****\n*****\n*****"]}]
control_completion_000833
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid with $$$n$$$ rows and $$$m$$$ columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall down until they meet the...
for i in range(int(input())): n,m=map(int,input().split()) s=[list(input()) for j in range(n)] for _ in range(n): for a in reversed(range(n-1)): for b in range(m): if s[a][b]=='*': if {{completion}}: continue ...
s[a+1][b]=='o' or s[a+1][b]=='*'
[{"input": "3\n6 10\n.*.*....*.\n.*.......*\n...o....o.\n.*.*....*.\n..........\n.o......o*\n2 9\n...***ooo\n.*o.*o.*o\n5 5\n*****\n*....\n*****\n....*\n*****", "output": ["..........\n...*....*.\n.*.o....o.\n.*........\n.*......**\n.o.*....o*\n\n....**ooo\n.*o**o.*o\n\n.....\n*...*\n*****\n*****\n*****"]}]
control_completion_000834
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid with $$$n$$$ rows and $$$m$$$ columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall down until they meet the...
I=lambda:map(int,input().split()) for _ in range(int(input())): n,m=I() a=[input() for _ in range(n)] at=[''.join(col).split('o') for col in zip(*a)] f=lambda s:''.join(sorted(s,reverse=True)) at=['o'.join(map(f, col)) for col in at] for {{completion}}: print(''.join(ro...
row in zip(*at)
[{"input": "3\n6 10\n.*.*....*.\n.*.......*\n...o....o.\n.*.*....*.\n..........\n.o......o*\n2 9\n...***ooo\n.*o.*o.*o\n5 5\n*****\n*....\n*****\n....*\n*****", "output": ["..........\n...*....*.\n.*.o....o.\n.*........\n.*......**\n.o.*....o*\n\n....**ooo\n.*o**o.*o\n\n.....\n*...*\n*****\n*****\n*****"]}]
control_completion_000835
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid with $$$n$$$ rows and $$$m$$$ columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall down until they meet the...
I = input for _ in range(int(I())): n,m = map(int,I().split()) grid = [I().strip() for __ in range(n)] res = [] for col in range(m): newcol = '' for {{completion}}: newcol += '.'*seg.count('.')+'*'*seg.count('*')+'o' res.append(newcol[0:-1]) for row in r...
seg in (''.join(grid[row][col] for row in range(n))).split('o')
[{"input": "3\n6 10\n.*.*....*.\n.*.......*\n...o....o.\n.*.*....*.\n..........\n.o......o*\n2 9\n...***ooo\n.*o.*o.*o\n5 5\n*****\n*....\n*****\n....*\n*****", "output": ["..........\n...*....*.\n.*.o....o.\n.*........\n.*......**\n.o.*....o*\n\n....**ooo\n.*o**o.*o\n\n.....\n*...*\n*****\n*****\n*****"]}]
control_completion_000836
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid with $$$n$$$ rows and $$$m$$$ columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall down until they meet the...
for ii in range(int(input())): n,m = map(int, input().split()) mat=[] r=[0]*m for jj in range(n): a=list(input()) for kk in range(m): if a[kk]=="*": r[kk]+=1 a[kk]="." elif a[kk]=="o": while {{completion}}: mat[jj-r[kk]][kk]="*" r[kk]-=1 mat.append(a) for jj in rang...
r[kk]
[{"input": "3\n6 10\n.*.*....*.\n.*.......*\n...o....o.\n.*.*....*.\n..........\n.o......o*\n2 9\n...***ooo\n.*o.*o.*o\n5 5\n*****\n*....\n*****\n....*\n*****", "output": ["..........\n...*....*.\n.*.o....o.\n.*........\n.*......**\n.o.*....o*\n\n....**ooo\n.*o**o.*o\n\n.....\n*...*\n*****\n*****\n*****"]}]
control_completion_000837
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid with $$$n$$$ rows and $$$m$$$ columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall down until they meet the...
t = int(input()) for i in range (t): n, m = map(int,input().split()) arr = [[0]*m]*n for j in range(n): arr[j] = list(input()) # for h in range(m): # print(arr[j][h]) for k in range(m): for l in range(n-1, -1, -1): if arr[l][k]=='.': ...
arr[f][k]=='*'
[{"input": "3\n6 10\n.*.*....*.\n.*.......*\n...o....o.\n.*.*....*.\n..........\n.o......o*\n2 9\n...***ooo\n.*o.*o.*o\n5 5\n*****\n*....\n*****\n....*\n*****", "output": ["..........\n...*....*.\n.*.o....o.\n.*........\n.*......**\n.o.*....o*\n\n....**ooo\n.*o**o.*o\n\n.....\n*...*\n*****\n*****\n*****"]}]
control_completion_000838
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
from collections import Counter for _ in range(int(input())): n = int(input()) num = Counter(input() for x in [1]*n) cnt = 0 for x in num: for y in num: if {{completion}}: cnt+=num[x]*num[y] print(cnt//2)
x!=y and (x[0] == y[0] or x[1] == y[1])
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000864
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
from collections import Counter from itertools import islice from sys import stdin LETTERS = 'abcdefghijk' data = (line.strip() for line in stdin.readlines()[1:]) res = [] for line in data: n = int(line) s = 0 ctr = Counter() for ab in islice(data, n): a, b = ab ctr[ab] += 1 f...
l != a
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000865
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
from collections import Counter from itertools import islice from sys import stdin LETTERS = 'abcdefghijk' data = (line.strip() for line in stdin.readlines()[1:]) res = [] for line in data: n = int(line) s = 0 ctr = Counter() for ab in islice(data, n): a, b = ab ctr[ab] += 1 f...
l != b
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000866
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
for i in range(int(input())): data = [[0 for l in range(11)] for k in range(11)] for j in range(int(input())): first, second = input() data[ord(first)-ord('a')][ord(second)-ord('a')] += 1 answer = 0 for j in range(11): for k in range(11): for l in range(11...
j != l
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000867
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
for i in range(int(input())): data = [[0 for l in range(11)] for k in range(11)] for j in range(int(input())): first, second = input() data[ord(first)-ord('a')][ord(second)-ord('a')] += 1 answer = 0 for j in range(11): for k in range(11): for l in range(11...
k != l
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000868
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
from collections import defaultdict ak = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"] t = int(input()) for _ in range(t): count = 0 d = defaultdict(int) n = int(input()) for i in range(n): s = input() for c in ak: if c != s[0]: if {{com...
d[c + s[1]] > 0
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000869
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
from collections import defaultdict ak = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"] t = int(input()) for _ in range(t): count = 0 d = defaultdict(int) n = int(input()) for i in range(n): s = input() for c in ak: if c != s[0]: if d[c +...
d[s[0] + c] > 0
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000870
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
for ii in range(int(input())): n=int(input()) a=[] co=0 x=set() for jj in range(n): a.append(input()) for jj in range(n): mul=1 if jj not in x: for kk in range(jj+1,n): if a[jj][0]!=a[kk][0] and a[jj][1]==a[kk][1]: co+=mul elif {{completion}}: co+=mul elif a[jj][0]==a...
a[jj][0]==a[kk][0] and a[jj][1]!=a[kk][1]
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000871
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
t=int(input()) for i in range(t): n=int(input()) result=0 dic1={} dic2={} dic3={} for i in range(n): S=input() if {{completion}}: result+=dic1[S[0]] dic1[S[0]]+=1 else: dic1[S[0]]=1 if S[1] in dic2: result+=dic2[S[1]] dic2[S[1]]+=1 else: ...
S[0] in dic1
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000872
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
t=int(input()) for i in range(t): n=int(input()) result=0 dic1={} dic2={} dic3={} for i in range(n): S=input() if S[0] in dic1: result+=dic1[S[0]] dic1[S[0]]+=1 else: dic1[S[0]]=1 if {{completion}}: result+=dic2[S[1]] dic2[S[1]]+=1 else: ...
S[1] in dic2
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000873
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
for i in range(int(input())): n= int(input()) a = dict() b = dict() c = dict() ans = 0 for j in range(n): d,e = str(input()) try: ans += a[d] a[d] += 1 except KeyError: a[d] = 1 try: ans += b[e] ...
d+e not in c
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000874
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
from collections import Counter t=int(input()) while(t!=0): n=int(input()) s = Counter(input() for x in [1]*n) cnt = 0 for x in s: for y in s: if{{completion}}: cnt += s[x]*s[y] print(cnt//2) t-=1
(x!=y and (x[1]==y[1] or x[0]==y[0]))
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000875
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
t = int(input()) for x in range(t): n = int(input()) d1 = {} for i in range(97,109): for j in range(97,109): d1[chr(i)+chr(j)] = 0 ans1 = 0 for y in range(n): s = input() for l in range(2): for m in range(97,109): a = list(s...
a == s
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000876
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given $$$n$$$ strings, each of length $$$2$$$, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices $$$(i, j)$$$ such that $$$i &lt; j$$$ and the $$$i$$$-th string and the $$$j$$$-th string diff...
for n in range(int(input())): a = {} for j in range(int(input())): c = input() if c not in a: a[c] = 1 elif c in a: a[c] += 1 count = 0 for i in a.keys(): for j in a.keys(): if {{completion}}: count += a[i] *...
i != j and (i[0] == j[0] or i[1] == j[1])
[{"input": "4\n6\nab\ncb\ndb\naa\ncc\nef\n7\naa\nbb\ncc\nac\nca\nbb\naa\n4\nkk\nkk\nab\nab\n5\njf\njf\njk\njk\njk", "output": ["5\n6\n0\n6"]}]
control_completion_000877
control_fixed
python
Complete the code in python to solve this programming problem: Description: A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\color{blue}{\te...
for {{completion}}:print('YNEOS'[1in map(len,map(set,s[:-1].split('W')))::2])
s in[*open(0)][2::2]
[{"input": "12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW", "output": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"]}]
control_completion_000905
control_fixed
python
Complete the code in python to solve this programming problem: Description: A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\color{blue}{\te...
for {{completion}}: l = int(input()) print("NO" if any (len(set(x)) == 1 for x in input().split('W') ) else "YES")
_ in range(int(input()))
[{"input": "12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW", "output": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"]}]
control_completion_000906
control_fixed
python
Complete the code in python to solve this programming problem: Description: A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\color{blue}{\te...
def solve(): n = int(input()) s = input().split('W') for i in s: bs = 'B' in i rs = 'R' in i if {{completion}}: print('NO') return print('YES') for t in range(int(input())): solve()
bs ^ rs
[{"input": "12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW", "output": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"]}]
control_completion_000907
control_fixed
python
Complete the code in python to solve this programming problem: Description: A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\color{blue}{\te...
for {{completion}}:print('YNEOS'[1in[len({*x})for x in s[:-1].split('W')]::2])
s in[*open(0)][2::2]
[{"input": "12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW", "output": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"]}]
control_completion_000908
control_fixed
python
Complete the code in python to solve this programming problem: Description: A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\color{blue}{\te...
g = input() for i in range(int(g)): input() numb = input().split('W') ans = 'yes' for z in numb: if z == '': pass else: if {{completion}}: pass else: ans = 'no' print(ans)
('R' in z) and ('B' in z)
[{"input": "12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW", "output": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"]}]
control_completion_000909
control_fixed
python
Complete the code in python to solve this programming problem: Description: A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\color{blue}{\te...
for s in[*open(0)][2::2]: b=0 for {{completion}}:b|=len({*i})%2 print('YNEOS'[b::2])
i in s[:-1].split('W')
[{"input": "12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW", "output": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"]}]
control_completion_000910
control_fixed
python
Complete the code in python to solve this programming problem: Description: A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\color{blue}{\te...
t=int(input()) for i in range(t): n=int(input()) s=input() s=s.strip("W") temp=list(s.split('W')) for i in temp: if i: if {{completion}}: print("NO") break else: print("YES")
'B' not in i or 'R' not in i
[{"input": "12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW", "output": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"]}]
control_completion_000911
control_fixed
python
Complete the code in python to solve this programming problem: Description: A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\color{blue}{\te...
for {{completion}}: num = int(input()) line = [elem for elem in input().split("W") if elem != ""] print("YES" if all(["B" in elem and "R" in elem for elem in line]) else "NO")
i in range(int(input()))
[{"input": "12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW", "output": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"]}]
control_completion_000912
control_fixed
python
Complete the code in python to solve this programming problem: Description: A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\color{blue}{\te...
for s in[*open(0)][2::2]: b = 0 for {{completion}}: b|=(len(set(i))==1) print('YNEOS '[b::2])
i in s[:-1].split("W")
[{"input": "12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW", "output": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"]}]
control_completion_000913
control_fixed
python
Complete the code in python to solve this programming problem: Description: A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\color{blue}{\te...
t = int(input()) Ans = [-1]*t for z in range(t): n = int(input()) l = input().split('W') bad = False for s in l: b1 = 'R' in s b2 = 'B' in s if {{completion}}: bad = True print("NO" if bad else "YES")
(b1 ^ b2)
[{"input": "12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW", "output": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"]}]
control_completion_000914
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
n=int(input()) l=[int(i) for i in input().split()] def f(l): cur = 0 n = 0 for {{completion}}: n += cur // i + 1 cur = i * (cur // i + 1) return n print(min(f(l[i+1:])+f(l[:i][::-1]) for i in range(n)))
i in l
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000959
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
n = int(input().strip()) a = list(map(int, input().strip().split())) ans = None for i in range(n): acc, p = 0, 0 for {{completion}}: x = (p - 1) // a[j] acc += -x p = x * a[j] p = 0 for j in range(i+1, n): x = (p + a[j]) // a[j] acc += x p =...
j in range(i-1, -1, -1)
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000960
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
n = int(input().strip()) a = list(map(int, input().strip().split())) ans = None for i in range(n): acc, p = 0, 0 for j in range(i-1, -1, -1): x = (p - 1) // a[j] acc += -x p = x * a[j] p = 0 for {{completion}}: x = (p + a[j]) // a[j] acc += x ...
j in range(i+1, n)
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000961
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
from math import ceil n=int(input()) a=list(map(int,input().split())) ans=float("inf") for i in range(len(a)): t=[0]*n temp=0 j=i-1 prev =0 while {{completion}}: x=(ceil((prev+1)/a[j])) temp+=x prev=(a[j]*x) j-=1 k=i+1 prev=0 while k<...
j>=0
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000962
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
from math import ceil n=int(input()) a=list(map(int,input().split())) ans=float("inf") for i in range(len(a)): t=[0]*n temp=0 j=i-1 prev =0 while j>=0: x=(ceil((prev+1)/a[j])) temp+=x prev=(a[j]*x) j-=1 k=i+1 prev=0 while {{completion...
k<len(a)
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000963
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
for _ in range(1): n = int(input()) a = list(map(int, input().split())) Min = 1e18 for l in range(n): m = a[l] answer = 1 for i in range(l-1, -1, -1): answer += (m + a[i]) // a[i] m = a[i] * ((m + a[i]) // a[i]) if l + 1 < n: ...
i in range(l + 2, n)
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000964
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
m=int(input()) a=[int(i)for i in input().split()] t1,min=0,10**20 while(t1<m): t2=t1 k,t=0,0 while{{completion}}: t+=(k//a[t2+1]+1) k=a[t2+1]*(k//a[t2+1]+1) t2+=1 t2=t1 k=0 while(t2>0): t+=(k//a[t2-1]+1) k=a[t2-1]*(k//a[t2-1]+1) t2-=...
(t2<m-1)
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000965
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
m=int(input()) a=[int(i)for i in input().split()] t1,min=0,10**20 while(t1<m): t2=t1 k,t=0,0 while(t2<m-1): t+=(k//a[t2+1]+1) k=a[t2+1]*(k//a[t2+1]+1) t2+=1 t2=t1 k=0 while{{completion}}: t+=(k//a[t2-1]+1) k=a[t2-1]*(k//a[t2-1]+1) t2...
(t2>0)
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000966
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
import math n = int(input()) a = list(map(int, input().split(' '))) # numbers w/ ws c = None d = 0 for i in range(len(a)): p = 0 t = 0 for {{completion}}: d = math.ceil((t+1)/k) t = k*d p += d t = 0 for k in reversed(a[:i]): d = math.ceil((t+1)/k) t = k*d p += d if c == None or p < ...
k in a[i+1:]
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000967
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
import math n = int(input()) a = list(map(int, input().split(' '))) # numbers w/ ws c = None d = 0 for i in range(len(a)): p = 0 t = 0 for k in a[i+1:]: d = math.ceil((t+1)/k) t = k*d p += d t = 0 for {{completion}}: d = math.ceil((t+1)/k) t = k*d p += d if c == None or p < c: c ...
k in reversed(a[:i])
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000968
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
def f(b, i): return e(b[::-1], i) def e(b, i): if b == []: return 0 count = 0 ggg = [0] * len(b) for {{completion}}: ggg[i] = (b[i - 1] * ggg[i - 1]) // b[i] + 1 count += ggg[i] return count def c(b, i): return e(b[i + 1:], 0) + f(b[:i], 0) a = int(...
i in range(len(b))
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000969
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
n=int(input()) a=list(map(int,input().split())) b=[int(0) for _ in range(n)] m=1e18 for i in range(n): c=0 p=0 for {{completion}}: p+=a[j]-p%a[j] c+=p//a[j] p=0 for j in range(i-1,-1,-1): p+=a[j]-p%a[j] c+=p//a[j] m=min(m,c) print(m)
j in range(i+1,len(b))
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000970
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and an array $$$b$$$, with length $$$n$$$. Initially $$$b_i=0$$$ for each $$$1 \leq i \leq n$$$.In one move you can choose an integer $$$i$$$ ($$$1 \leq i \leq n$$$), and ...
n=int(input()) a=list(map(int,input().split())) b=[int(0) for _ in range(n)] m=1e18 for i in range(n): c=0 p=0 for j in range(i+1,len(b)): p+=a[j]-p%a[j] c+=p//a[j] p=0 for {{completion}}: p+=a[j]-p%a[j] c+=p//a[j] m=min(m,c) print(m) ...
j in range(i-1,-1,-1)
[{"input": "5\n1 2 3 4 5", "output": ["4"]}, {"input": "7\n1 2 1 2 1 2 1", "output": ["10"]}, {"input": "8\n1 8 2 7 3 6 4 5", "output": ["16"]}]
control_completion_000971
control_fixed
python
Complete the code in python to solve this programming problem: Description: $$$m$$$ chairs are arranged in a circle sequentially. The chairs are numbered from $$$0$$$ to $$$m-1$$$. $$$n$$$ people want to sit in these chairs. The $$$i$$$-th of them wants at least $$$a[i]$$$ empty chairs both on his right and left side....
t=lambda:map(int,input().split()) for {{completion}}:n,m=t();a=[*t()];print("YNEOS"[sum(a)+max(a)-min(a)+n>m::2])
_ in range(int(input()))
[{"input": "6\n3 2\n1 1 1\n2 4\n1 1\n2 5\n2 1\n3 8\n1 2 1\n4 12\n1 2 1 3\n4 19\n1 2 1 3", "output": ["NO\nYES\nNO\nYES\nNO\nYES"]}]
control_completion_000997
control_fixed
python
Complete the code in python to solve this programming problem: Description: $$$m$$$ chairs are arranged in a circle sequentially. The chairs are numbered from $$$0$$$ to $$$m-1$$$. $$$n$$$ people want to sit in these chairs. The $$$i$$$-th of them wants at least $$$a[i]$$$ empty chairs both on his right and left side....
for _t in range(int(input())): n,m = map(int, input().split(' ')) # numbers w/ ws a = sorted(map(int, input().split(' '))) tot = 0 dis = 0 p_i = a[-1] for i in a: tot += 2*i+1 if {{completion}}: dis += p_i else: dis += i p_i = i if tot-dis <= m: print("YES") else: print("NO...
p_i < i
[{"input": "6\n3 2\n1 1 1\n2 4\n1 1\n2 5\n2 1\n3 8\n1 2 1\n4 12\n1 2 1 3\n4 19\n1 2 1 3", "output": ["NO\nYES\nNO\nYES\nNO\nYES"]}]
control_completion_000998
control_fixed
python
Complete the code in python to solve this programming problem: Description: $$$m$$$ chairs are arranged in a circle sequentially. The chairs are numbered from $$$0$$$ to $$$m-1$$$. $$$n$$$ people want to sit in these chairs. The $$$i$$$-th of them wants at least $$$a[i]$$$ empty chairs both on his right and left side....
import sys def solve(): n, m = map(int, input().split()) num = list(map(int , input().split())) num.sort() s = sum(num[1:]) + num[-1] + n print("YES" if s <= m else "NO") for {{completion}}: solve()
_ in range(int(input()))
[{"input": "6\n3 2\n1 1 1\n2 4\n1 1\n2 5\n2 1\n3 8\n1 2 1\n4 12\n1 2 1 3\n4 19\n1 2 1 3", "output": ["NO\nYES\nNO\nYES\nNO\nYES"]}]
control_completion_000999
control_fixed
python
Complete the code in python to solve this programming problem: Description: $$$m$$$ chairs are arranged in a circle sequentially. The chairs are numbered from $$$0$$$ to $$$m-1$$$. $$$n$$$ people want to sit in these chairs. The $$$i$$$-th of them wants at least $$$a[i]$$$ empty chairs both on his right and left side....
import sys for t in range(int(sys.stdin.readline())): n,m = map(int, sys.stdin.readline().strip().split()) a = list(map(int, sys.stdin.readline().strip().split())) if {{completion}}:print('yes') else:print('no')
sum(a)-min(a)+max(a) + n <= m
[{"input": "6\n3 2\n1 1 1\n2 4\n1 1\n2 5\n2 1\n3 8\n1 2 1\n4 12\n1 2 1 3\n4 19\n1 2 1 3", "output": ["NO\nYES\nNO\nYES\nNO\nYES"]}]
control_completion_001000
control_fixed
python
Complete the code in python to solve this programming problem: Description: $$$m$$$ chairs are arranged in a circle sequentially. The chairs are numbered from $$$0$$$ to $$$m-1$$$. $$$n$$$ people want to sit in these chairs. The $$$i$$$-th of them wants at least $$$a[i]$$$ empty chairs both on his right and left side....
x = lambda: map(int,input().split()) t,= x() for {{completion}}: p,n = x() a = [*x()] s = sum(a) + (p-1) - min(a) print("YNEOS"[n-1-s<max(a)::2])
_ in [1]*t
[{"input": "6\n3 2\n1 1 1\n2 4\n1 1\n2 5\n2 1\n3 8\n1 2 1\n4 12\n1 2 1 3\n4 19\n1 2 1 3", "output": ["NO\nYES\nNO\nYES\nNO\nYES"]}]
control_completion_001001
control_fixed
python
Complete the code in python to solve this programming problem: Description: $$$m$$$ chairs are arranged in a circle sequentially. The chairs are numbered from $$$0$$$ to $$$m-1$$$. $$$n$$$ people want to sit in these chairs. The $$$i$$$-th of them wants at least $$$a[i]$$$ empty chairs both on his right and left side....
def Dist(): num_nm = input().split() m = int(num_nm[1]) n = int(num_nm[0]) a = input().split() a = list(map(int, a)) wish = n + sum(a) - min(a) + max(a) print("NO" if wish >m else "YES") num_iter = int(input()) for {{completion}}: Dist()
_ in range(num_iter)
[{"input": "6\n3 2\n1 1 1\n2 4\n1 1\n2 5\n2 1\n3 8\n1 2 1\n4 12\n1 2 1 3\n4 19\n1 2 1 3", "output": ["NO\nYES\nNO\nYES\nNO\nYES"]}]
control_completion_001002
control_fixed
python
Complete the code in python to solve this programming problem: Description: $$$m$$$ chairs are arranged in a circle sequentially. The chairs are numbered from $$$0$$$ to $$$m-1$$$. $$$n$$$ people want to sit in these chairs. The $$$i$$$-th of them wants at least $$$a[i]$$$ empty chairs both on his right and left side....
for T in range (int(input())) : n,m = map(int, input().strip().split()) a = sorted(list(map(int,input().strip().split())),reverse=True) m -= 2*a[0] + 1 cont = 0 for i in range(1,n) : if {{completion}}: break m -= a[i] + 1 cont +=1 if cont == n-1 : print('YES') ...
m <= 0
[{"input": "6\n3 2\n1 1 1\n2 4\n1 1\n2 5\n2 1\n3 8\n1 2 1\n4 12\n1 2 1 3\n4 19\n1 2 1 3", "output": ["NO\nYES\nNO\nYES\nNO\nYES"]}]
control_completion_001003
control_fixed
python
Complete the code in python to solve this programming problem: Description: $$$m$$$ chairs are arranged in a circle sequentially. The chairs are numbered from $$$0$$$ to $$$m-1$$$. $$$n$$$ people want to sit in these chairs. The $$$i$$$-th of them wants at least $$$a[i]$$$ empty chairs both on his right and left side....
I=lambda:[*map(int,input().split())] t,=I() while {{completion}}:t-=1;n,m=I();a=sorted(I());print('YNEOS'[sum(max(a[i-1],a[i])for i in range(n))+n>m::2])
t
[{"input": "6\n3 2\n1 1 1\n2 4\n1 1\n2 5\n2 1\n3 8\n1 2 1\n4 12\n1 2 1 3\n4 19\n1 2 1 3", "output": ["NO\nYES\nNO\nYES\nNO\nYES"]}]
control_completion_001004
control_fixed
python
Complete the code in python to solve this programming problem: Description: $$$m$$$ chairs are arranged in a circle sequentially. The chairs are numbered from $$$0$$$ to $$$m-1$$$. $$$n$$$ people want to sit in these chairs. The $$$i$$$-th of them wants at least $$$a[i]$$$ empty chairs both on his right and left side....
for i in range(int(input())): n,m=map(int,input().split()) a=list(map(int,input().split())) if {{completion}}: print("no") else: print("yes")
n+sum(a)+max(a)-min(a)>m
[{"input": "6\n3 2\n1 1 1\n2 4\n1 1\n2 5\n2 1\n3 8\n1 2 1\n4 12\n1 2 1 3\n4 19\n1 2 1 3", "output": ["NO\nYES\nNO\nYES\nNO\nYES"]}]
control_completion_001005
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ integers. You should divide $$$a$$$ into continuous non-empty subarrays (there are $$$2^{n-1}$$$ ways to do that).Let $$$s=a_l+a_{l+1}+\ldots+a_r$$$. The value of a subarray $$$a_l, a_{l+1},...
from collections import Counter, defaultdict, deque import bisect from sys import stdin, stdout from itertools import repeat import math MOD = 998244353 input = stdin.readline finp = [int(x) for x in stdin.buffer.read().split()] def inp(force_list=False): re = list(map(int, input().split())) if ...
x>0
[{"input": "5\n\n3\n\n1 2 -3\n\n4\n\n0 -2 3 -4\n\n5\n\n-1 -2 3 -1 -1\n\n6\n\n-1 2 -3 4 -5 6\n\n7\n\n1 -1 -1 1 -1 -1 1", "output": ["1\n2\n1\n6\n-1"]}]
control_completion_001028
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array $$$a$$$ consisting of $$$n$$$ integers. You should divide $$$a$$$ into continuous non-empty subarrays (there are $$$2^{n-1}$$$ ways to do that).Let $$$s=a_l+a_{l+1}+\ldots+a_r$$$. The value of a subarray $$$a_l, a_{l+1},...
from collections import Counter, defaultdict, deque import bisect from sys import stdin, stdout from itertools import repeat import math MOD = 998244353 input = stdin.readline finp = [int(x) for x in stdin.buffer.read().split()] def inp(force_list=False): re = list(map(int, input().split())) if ...
p < self._mx
[{"input": "5\n\n3\n\n1 2 -3\n\n4\n\n0 -2 3 -4\n\n5\n\n-1 -2 3 -1 -1\n\n6\n\n-1 2 -3 4 -5 6\n\n7\n\n1 -1 -1 1 -1 -1 1", "output": ["1\n2\n1\n6\n-1"]}]
control_completion_001029
control_fixed
python
Complete the code in python to solve this programming problem: Description: Today, like every year at SWERC, the $$$n^2$$$ contestants have gathered outside the venue to take a drone photo. Jennifer, the social media manager for the event, has arranged them into an $$$n\times n$$$ square. Being very good at her job, s...
import sys input = sys.stdin.readline n = int(input()) o1 = [0] * (n * n) o2 = [0] * (n * n) for i in range(n): curr = (list(map(int, input().split()))) for {{completion}}: o1[curr[j] - 1] = i o2[curr[j] - 1] = j row_count = [0] * n col_count = [0] * n ct = 0 f...
j in range(n)
[{"input": "2\n1 3\n4 2", "output": ["0"]}, {"input": "2\n3 2\n4 1", "output": ["1"]}, {"input": "3\n9 2 4\n1 5 3\n7 8 6", "output": ["6"]}]
control_completion_001071
control_fixed
python
Complete the code in python to solve this programming problem: Description: Today, like every year at SWERC, the $$$n^2$$$ contestants have gathered outside the venue to take a drone photo. Jennifer, the social media manager for the event, has arranged them into an $$$n\times n$$$ square. Being very good at her job, s...
import sys import random input = sys.stdin.buffer.readline read = sys.stdin.buffer.read N = int(input()) As = [list(map(int, input().split())) for _ in range(N)] # N = 1500 # As = list(range(1, N ** 2 + 1)) # random.shuffle(As) # As = [As[i * N:(i + 1) * N] for i in range(N)] ijs = [0] * (N ** 2) for i in range(N):...
j in range(N)
[{"input": "2\n1 3\n4 2", "output": ["0"]}, {"input": "2\n3 2\n4 1", "output": ["1"]}, {"input": "3\n9 2 4\n1 5 3\n7 8 6", "output": ["6"]}]
control_completion_001072
control_fixed
python
Complete the code in python to solve this programming problem: Description: The derby between Milan and Inter is happening soon, and you have been chosen as the assistant referee for the match, also known as linesman. Your task is to move along the touch-line, namely the side of the field, always looking very carefull...
import sys import bisect input = sys.stdin.buffer.readline read = sys.stdin.buffer.read N, V = map(int, input().split()) Ts = list(map(int, input().split())) As = list(map(int, input().split())) points = [] for T, A in zip(Ts, As): B = T * V x = B - A y = B + A if {{completion}}: continue ...
x < 0 or y < 0
[{"input": "3 2\n5 10 15\n7 17 29", "output": ["2"]}, {"input": "5 1\n5 7 8 11 13\n3 3 -2 -2 4", "output": ["3"]}, {"input": "1 2\n3\n7", "output": ["0"]}]
control_completion_001081
control_fixed
python
Complete the code in python to solve this programming problem: Description: The derby between Milan and Inter is happening soon, and you have been chosen as the assistant referee for the match, also known as linesman. Your task is to move along the touch-line, namely the side of the field, always looking very carefull...
import sys import bisect input = sys.stdin.buffer.readline read = sys.stdin.buffer.read N, V = map(int, input().split()) Ts = list(map(int, input().split())) As = list(map(int, input().split())) points = [] for T, A in zip(Ts, As): B = T * V x = B - A y = B + A if x < 0 or y < 0: continue ...
index < len(lis)
[{"input": "3 2\n5 10 15\n7 17 29", "output": ["2"]}, {"input": "5 1\n5 7 8 11 13\n3 3 -2 -2 4", "output": ["3"]}, {"input": "1 2\n3\n7", "output": ["0"]}]
control_completion_001082
control_fixed
python
Complete the code in python to solve this programming problem: Description: The derby between Milan and Inter is happening soon, and you have been chosen as the assistant referee for the match, also known as linesman. Your task is to move along the touch-line, namely the side of the field, always looking very carefull...
from bisect import bisect_right,bisect_left n,v = map(int,input().split()) t = [*map(int,input().split())] a = [*map(int,input().split())] res = [] for i in range(n): xi,yi = t[i]*v+a[i],t[i]*v-a[i] if{{completion}}: res.append((xi,yi)) res.sort() dp = [float("inf")]*(n+3) dp[0] = 0 dp[n+2] ...
(xi>=0 and yi>=0)
[{"input": "3 2\n5 10 15\n7 17 29", "output": ["2"]}, {"input": "5 1\n5 7 8 11 13\n3 3 -2 -2 4", "output": ["3"]}, {"input": "1 2\n3\n7", "output": ["0"]}]
control_completion_001083
control_fixed
python
Complete the code in python to solve this programming problem: Description: The derby between Milan and Inter is happening soon, and you have been chosen as the assistant referee for the match, also known as linesman. Your task is to move along the touch-line, namely the side of the field, always looking very carefull...
from bisect import bisect_right,bisect_left n,v = map(int,input().split()) t = [*map(int,input().split())] a = [*map(int,input().split())] res = [] for i in range(n): xi,yi = t[i]*v+a[i],t[i]*v-a[i] if(xi>=0 and yi>=0): res.append((xi,yi)) res.sort() dp = [float("inf")]*(n+3) dp[0] = 0 dp[n+...
(dp[i]!=float("inf"))
[{"input": "3 2\n5 10 15\n7 17 29", "output": ["2"]}, {"input": "5 1\n5 7 8 11 13\n3 3 -2 -2 4", "output": ["3"]}, {"input": "1 2\n3\n7", "output": ["0"]}]
control_completion_001084
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a circular maze such as the ones shown in the figures. Determine if it can be solved, i.e., if there is a path which goes from the center to the outside of the maze which does not touch any wall. The maze is described by $$$n$...
t = int(input()) for _ in range(t): field = [[0 for _ in range(2*360)] for _ in range(42)] vis = [[False for _ in range(2*360)] for _ in range(42)] n = int(input()) for _ in range(n): line = input().split() a, b, c = map(int, line[1:]) if line[0] == "C": y = 2...
nx in range(x-1, x+1+1)
[{"input": "2\n5\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\n6\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\nS 5 10 0", "output": ["YES\nNO"]}]
control_completion_001093
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a circular maze such as the ones shown in the figures. Determine if it can be solved, i.e., if there is a path which goes from the center to the outside of the maze which does not touch any wall. The maze is described by $$$n$...
t = int(input()) for _ in range(t): field = [[0 for _ in range(2*360)] for _ in range(42)] vis = [[False for _ in range(2*360)] for _ in range(42)] n = int(input()) for _ in range(n): line = input().split() a, b, c = map(int, line[1:]) if line[0] == "C": y = 2...
y in range(2*a, 2*b+1)
[{"input": "2\n5\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\n6\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\nS 5 10 0", "output": ["YES\nNO"]}]
control_completion_001094
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a circular maze such as the ones shown in the figures. Determine if it can be solved, i.e., if there is a path which goes from the center to the outside of the maze which does not touch any wall. The maze is described by $$$n$...
from collections import deque def bfs(graph, start): visited = set() queue = deque([start]) while queue: vertex = queue.popleft() if vertex not in visited: visited.add(vertex) queue.extend(graph[vertex] - visited) return visited for tc in range(int(i...
rad in range(r1, r2)
[{"input": "2\n5\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\n6\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\nS 5 10 0", "output": ["YES\nNO"]}]
control_completion_001095
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a circular maze such as the ones shown in the figures. Determine if it can be solved, i.e., if there is a path which goes from the center to the outside of the maze which does not touch any wall. The maze is described by $$$n$...
from collections import deque def bfs(graph, start): visited = set() queue = deque([start]) while queue: vertex = queue.popleft() if vertex not in visited: visited.add(vertex) queue.extend(graph[vertex] - visited) return visited for tc in range(int(i...
r < 21
[{"input": "2\n5\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\n6\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\nS 5 10 0", "output": ["YES\nNO"]}]
control_completion_001096
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a circular maze such as the ones shown in the figures. Determine if it can be solved, i.e., if there is a path which goes from the center to the outside of the maze which does not touch any wall. The maze is described by $$$n$...
from itertools import islice, chain from sys import stdin MAX_RADIUS = 20 lines = iter(stdin.readlines()[1:]) for line in lines: n = int(line) circular_wall, straight_wall = ([[False] * 360 for _ in range(MAX_RADIUS)] for _ in range(2)) for shape, *params in map(str.split, islice(lines, n)): para...
r in range(r1, r2)
[{"input": "2\n5\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\n6\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\nS 5 10 0", "output": ["YES\nNO"]}]
control_completion_001097
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a circular maze such as the ones shown in the figures. Determine if it can be solved, i.e., if there is a path which goes from the center to the outside of the maze which does not touch any wall. The maze is described by $$$n$...
from itertools import islice, chain from sys import stdin MAX_RADIUS = 20 lines = iter(stdin.readlines()[1:]) for line in lines: n = int(line) circular_wall, straight_wall = ([[False] * 360 for _ in range(MAX_RADIUS)] for _ in range(2)) for shape, *params in map(str.split, islice(lines, n)): para...
theta in theta_range
[{"input": "2\n5\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\n6\nC 1 180 90\nC 5 250 230\nC 10 150 140\nC 20 185 180\nS 1 20 180\nS 5 10 0", "output": ["YES\nNO"]}]
control_completion_001098
control_fixed
python
Complete the code in python to solve this programming problem: Description: On a beach there are $$$n$$$ huts in a perfect line, hut $$$1$$$ being at the left and hut $$$i+1$$$ being $$$100$$$ meters to the right of hut $$$i$$$, for all $$$1 \le i \le n - 1$$$. In hut $$$i$$$ there are $$$p_i$$$ people.There are $$$m$...
from itertools import chain from sys import stdin (n, m), population, shops = [[int(x) for x in line.split()] for line in stdin.readlines()] shops.sort() shops = chain([float('-inf')], (v / 100 for v in shops), [float('inf')]) shop_left, shop_right = next(shops), next(shops) hut_left_idx = max_score = score = 0 for h...
shop_right <= hut_right_idx
[{"input": "3 1\n2 5 6\n169", "output": ["7"]}, {"input": "4 2\n1 2 7 8\n35 157", "output": ["15"]}, {"input": "4 1\n272203905 348354708 848256926 939404176\n20", "output": ["2136015810"]}, {"input": "3 2\n1 1 1\n300 99", "output": ["2"]}]
control_completion_001125
control_fixed
python
Complete the code in python to solve this programming problem: Description: On a beach there are $$$n$$$ huts in a perfect line, hut $$$1$$$ being at the left and hut $$$i+1$$$ being $$$100$$$ meters to the right of hut $$$i$$$, for all $$$1 \le i \le n - 1$$$. In hut $$$i$$$ there are $$$p_i$$$ people.There are $$$m$...
from itertools import chain from sys import stdin (n, m), population, shops = [[int(x) for x in line.split()] for line in stdin.readlines()] shops.sort() shops = chain([float('-inf')], (v / 100 for v in shops), [float('inf')]) shop_left, shop_right = next(shops), next(shops) hut_left_idx = max_score = score = 0 for h...
shop_left >= hut_left_idx or 2 * (hut_right_idx - hut_left_idx) >= shop_delta
[{"input": "3 1\n2 5 6\n169", "output": ["7"]}, {"input": "4 2\n1 2 7 8\n35 157", "output": ["15"]}, {"input": "4 1\n272203905 348354708 848256926 939404176\n20", "output": ["2136015810"]}, {"input": "3 2\n1 1 1\n300 99", "output": ["2"]}]
control_completion_001126
control_fixed
python
Complete the code in python to solve this programming problem: Description: On a beach there are $$$n$$$ huts in a perfect line, hut $$$1$$$ being at the left and hut $$$i+1$$$ being $$$100$$$ meters to the right of hut $$$i$$$, for all $$$1 \le i \le n - 1$$$. In hut $$$i$$$ there are $$$p_i$$$ people.There are $$$m$...
n,m=map(int,input().split()) p=list(map(int,input().split())) x=sorted(list(map(int,input().split()))) s=sum(p[:-(-(x[0])//100)]) for i in range(len(x)-1): if x[i]//100+1>=n: break num=int(((x[i+1]-x[i])/2)//(100)+1) l=x[i]//100+1 r=-(-(x[i+1])//100) r=min(r,n) prefs=0 if ...
l+num<=r
[{"input": "3 1\n2 5 6\n169", "output": ["7"]}, {"input": "4 2\n1 2 7 8\n35 157", "output": ["15"]}, {"input": "4 1\n272203905 348354708 848256926 939404176\n20", "output": ["2136015810"]}, {"input": "3 2\n1 1 1\n300 99", "output": ["2"]}]
control_completion_001127
control_fixed
python
Complete the code in python to solve this programming problem: Description: On a beach there are $$$n$$$ huts in a perfect line, hut $$$1$$$ being at the left and hut $$$i+1$$$ being $$$100$$$ meters to the right of hut $$$i$$$, for all $$$1 \le i \le n - 1$$$. In hut $$$i$$$ there are $$$p_i$$$ people.There are $$$m$...
N, M = [int(x) for x in input().split()] hut = [int(x) for x in input().split()] shop = [int(x) for x in input().split()] shop = sorted([-1e9] + shop + [1e9]) events = [] j = 0 for i in range(N): while {{completion}}: j += 1 if shop[j] != 100 * i: d = min(100*i - shop[j-1], shop[j] - 100*i) e...
shop[j] < 100*i
[{"input": "3 1\n2 5 6\n169", "output": ["7"]}, {"input": "4 2\n1 2 7 8\n35 157", "output": ["15"]}, {"input": "4 1\n272203905 348354708 848256926 939404176\n20", "output": ["2136015810"]}, {"input": "3 2\n1 1 1\n300 99", "output": ["2"]}]
control_completion_001128
control_fixed
python
Complete the code in python to solve this programming problem: Description: On a beach there are $$$n$$$ huts in a perfect line, hut $$$1$$$ being at the left and hut $$$i+1$$$ being $$$100$$$ meters to the right of hut $$$i$$$, for all $$$1 \le i \le n - 1$$$. In hut $$$i$$$ there are $$$p_i$$$ people.There are $$$m$...
N, M = [int(x) for x in input().split()] hut = [int(x) for x in input().split()] shop = [int(x) for x in input().split()] shop = sorted([-1e9] + shop + [1e9]) events = [] j = 0 for i in range(N): while shop[j] < 100*i: j += 1 if {{completion}}: d = min(100*i - shop[j-1], shop[j] - 100*i) even...
shop[j] != 100 * i
[{"input": "3 1\n2 5 6\n169", "output": ["7"]}, {"input": "4 2\n1 2 7 8\n35 157", "output": ["15"]}, {"input": "4 1\n272203905 348354708 848256926 939404176\n20", "output": ["2136015810"]}, {"input": "3 2\n1 1 1\n300 99", "output": ["2"]}]
control_completion_001129
control_fixed
python
Complete the code in python to solve this programming problem: Description: Bethany would like to tile her bathroom. The bathroom has width $$$w$$$ centimeters and length $$$l$$$ centimeters. If Bethany simply used the basic tiles of size $$$1 \times 1$$$ centimeters, she would use $$$w \cdot l$$$ of them. However, sh...
from math import sqrt, floor from sys import stdin data = [int(x) for x in stdin.read().split()[1:]] res = [] for w, l in zip(data[::2], data[1::2]): half_perimeter = w + l - 2 solutions = {1, 2} for i in range(2, floor(sqrt(half_perimeter)) + 1): div, mod_i = divmod(half_perimeter, i) if m...
mod_a <= 2
[{"input": "3\n\n3 5\n\n12 12\n\n314159265 358979323", "output": ["3 1 2 3\n3 1 2 11\n2 1 2"]}]
control_completion_001138
control_fixed
python
Complete the code in python to solve this programming problem: Description: Alina has discovered a weird language, which contains only $$$4$$$ words: $$$\texttt{A}$$$, $$$\texttt{B}$$$, $$$\texttt{AB}$$$, $$$\texttt{BA}$$$. It also turned out that there are no spaces in this language: a sentence is written by just con...
t = int(input()) for _ in range(t): a, b, c, d = [int(i) for i in input().split()] s = input() if s.count('A') != a+c+d: print("NO") continue ult = 'X' k = 0 z = [] for x in s: if x == ult: z.append((k, ult)) k = 1 else: ...
v == 'B' and c >= k//2
[{"input": "8\n1 0 0 0\nB\n0 0 1 0\nAB\n1 1 0 1\nABAB\n1 0 1 1\nABAAB\n1 1 2 2\nBAABBABBAA\n1 1 2 3\nABABABBAABAB\n2 3 5 4\nAABAABBABAAABABBABBBABB\n1 3 3 10\nBBABABABABBBABABABABABABAABABA", "output": ["NO\nYES\nYES\nYES\nYES\nYES\nNO\nYES"]}]
control_completion_001182
control_fixed
python
Complete the code in python to solve this programming problem: Description: Alina has discovered a weird language, which contains only $$$4$$$ words: $$$\texttt{A}$$$, $$$\texttt{B}$$$, $$$\texttt{AB}$$$, $$$\texttt{BA}$$$. It also turned out that there are no spaces in this language: a sentence is written by just con...
def canmake(s,a,b,c,d): anum = s.count('A') bnum = s.count('B') cnum = s.count('AB') dnum = s.count('BA') if cnum < c or dnum < d or anum != a + c + d or bnum != b + c + d: return False n=len(s) ans=0 abls=[] bals=[] l=0 while l<n: while...
r<n-1 and s[r]!=s[r+1]
[{"input": "8\n1 0 0 0\nB\n0 0 1 0\nAB\n1 1 0 1\nABAB\n1 0 1 1\nABAAB\n1 1 2 2\nBAABBABBAA\n1 1 2 3\nABABABBAABAB\n2 3 5 4\nAABAABBABAAABABBABBBABB\n1 3 3 10\nBBABABABABBBABABABABABABAABABA", "output": ["NO\nYES\nYES\nYES\nYES\nYES\nNO\nYES"]}]
control_completion_001183
control_fixed
python
Complete the code in python to solve this programming problem: Description: Alina has discovered a weird language, which contains only $$$4$$$ words: $$$\texttt{A}$$$, $$$\texttt{B}$$$, $$$\texttt{AB}$$$, $$$\texttt{BA}$$$. It also turned out that there are no spaces in this language: a sentence is written by just con...
def canmake(s,a,b,c,d): anum = s.count('A') bnum = s.count('B') cnum = s.count('AB') dnum = s.count('BA') if cnum < c or dnum < d or anum != a + c + d or bnum != b + c + d: return False n=len(s) ans=0 abls=[] bals=[] l=0 while l<n: while...
s[l]== s[r]=='B'
[{"input": "8\n1 0 0 0\nB\n0 0 1 0\nAB\n1 1 0 1\nABAB\n1 0 1 1\nABAAB\n1 1 2 2\nBAABBABBAA\n1 1 2 3\nABABABBAABAB\n2 3 5 4\nAABAABBABAAABABBABBBABB\n1 3 3 10\nBBABABABABBBABABABABABABAABABA", "output": ["NO\nYES\nYES\nYES\nYES\nYES\nNO\nYES"]}]
control_completion_001184
control_fixed
python
Complete the code in python to solve this programming problem: Description: Alina has discovered a weird language, which contains only $$$4$$$ words: $$$\texttt{A}$$$, $$$\texttt{B}$$$, $$$\texttt{AB}$$$, $$$\texttt{BA}$$$. It also turned out that there are no spaces in this language: a sentence is written by just con...
for _ in range(int(input())): a,b,ab,ba=map(int,input().split());s=input() if s.count('A')!=a+ab+ba:print('NO');continue stack=[[1,s[0]]] for i in range(1,len(s)): if stack[-1][1]!=s[i]: x=stack.pop() stack.append([x[0]+1,s[i]]) else: stack.append([1,s[i]]...
ele=='B' and ab>=val//2
[{"input": "8\n1 0 0 0\nB\n0 0 1 0\nAB\n1 1 0 1\nABAB\n1 0 1 1\nABAAB\n1 1 2 2\nBAABBABBAA\n1 1 2 3\nABABABBAABAB\n2 3 5 4\nAABAABBABAAABABBABBBABB\n1 3 3 10\nBBABABABABBBABABABABABABAABABA", "output": ["NO\nYES\nYES\nYES\nYES\nYES\nNO\nYES"]}]
control_completion_001185
control_fixed
python
Complete the code in python to solve this programming problem: Description: Alina has discovered a weird language, which contains only $$$4$$$ words: $$$\texttt{A}$$$, $$$\texttt{B}$$$, $$$\texttt{AB}$$$, $$$\texttt{BA}$$$. It also turned out that there are no spaces in this language: a sentence is written by just con...
import sys,os,io # input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline input = sys.stdin.readline for _ in range (int(input())): c = [int(i) for i in input().split()] s = list(input().strip()) if s.count('A') != c[0] + c[2] + c[3] or s.count('B') != c[1] + c[2] + c[3]: print("NO") ...
cnt <= c[2 + ord(i[0])-ord('A')]
[{"input": "8\n1 0 0 0\nB\n0 0 1 0\nAB\n1 1 0 1\nABAB\n1 0 1 1\nABAAB\n1 1 2 2\nBAABBABBAA\n1 1 2 3\nABABABBAABAB\n2 3 5 4\nAABAABBABAAABABBABBBABB\n1 3 3 10\nBBABABABABBBABABABABABABAABABA", "output": ["NO\nYES\nYES\nYES\nYES\nYES\nNO\nYES"]}]
control_completion_001186
control_fixed
python
Complete the code in python to solve this programming problem: Description: Alina has discovered a weird language, which contains only $$$4$$$ words: $$$\texttt{A}$$$, $$$\texttt{B}$$$, $$$\texttt{AB}$$$, $$$\texttt{BA}$$$. It also turned out that there are no spaces in this language: a sentence is written by just con...
import sys import math def do_test(): a,b,ab,ba = map(int, input().split()) S = input().strip() n = len(S) ac = 0 for i in S: if i == 'A': ac += 1 if (ac != a + ab + ba): return "NO" a_parts = [] b_parts = [] ab_total = ...
f == 'A'
[{"input": "8\n1 0 0 0\nB\n0 0 1 0\nAB\n1 1 0 1\nABAB\n1 0 1 1\nABAAB\n1 1 2 2\nBAABBABBAA\n1 1 2 3\nABABABBAABAB\n2 3 5 4\nAABAABBABAAABABBABBBABB\n1 3 3 10\nBBABABABABBBABABABABABABAABABA", "output": ["NO\nYES\nYES\nYES\nYES\nYES\nNO\nYES"]}]
control_completion_001187
control_fixed
python
Complete the code in python to solve this programming problem: Description: Alina has discovered a weird language, which contains only $$$4$$$ words: $$$\texttt{A}$$$, $$$\texttt{B}$$$, $$$\texttt{AB}$$$, $$$\texttt{BA}$$$. It also turned out that there are no spaces in this language: a sentence is written by just con...
import sys import math def do_test(): a,b,ab,ba = map(int, input().split()) S = input().strip() n = len(S) ac = 0 for i in S: if i == 'A': ac += 1 if (ac != a + ab + ba): return "NO" a_parts = [] b_parts = [] ab_total = ...
l % 2 == 1
[{"input": "8\n1 0 0 0\nB\n0 0 1 0\nAB\n1 1 0 1\nABAB\n1 0 1 1\nABAAB\n1 1 2 2\nBAABBABBAA\n1 1 2 3\nABABABBAABAB\n2 3 5 4\nAABAABBABAAABABBABBBABB\n1 3 3 10\nBBABABABABBBABABABABABABAABABA", "output": ["NO\nYES\nYES\nYES\nYES\nYES\nNO\nYES"]}]
control_completion_001188
control_fixed
python
Complete the code in python to solve this programming problem: Description: Alina has discovered a weird language, which contains only $$$4$$$ words: $$$\texttt{A}$$$, $$$\texttt{B}$$$, $$$\texttt{AB}$$$, $$$\texttt{BA}$$$. It also turned out that there are no spaces in this language: a sentence is written by just con...
def solve(): cnt_a, cnt_b, cnt_ab, cnt_ba = map(int, input().strip().split()) # print(cntA, cntB, cntAB, cntBA) s = input() if s.count('A') != cnt_a + cnt_ba + cnt_ab: print("NO") return stk = [[1, s[0]]] for i in range(1, len(s)): if i == 0: conti...
last == 'B' and cnt_ab >= (cnt >> 1)
[{"input": "8\n1 0 0 0\nB\n0 0 1 0\nAB\n1 1 0 1\nABAB\n1 0 1 1\nABAAB\n1 1 2 2\nBAABBABBAA\n1 1 2 3\nABABABBAABAB\n2 3 5 4\nAABAABBABAAABABBABBBABB\n1 3 3 10\nBBABABABABBBABABABABABABAABABA", "output": ["NO\nYES\nYES\nYES\nYES\nYES\nNO\nYES"]}]
control_completion_001189
control_fixed
python
Complete the code in python to solve this programming problem: Description: Alina has discovered a weird language, which contains only $$$4$$$ words: $$$\texttt{A}$$$, $$$\texttt{B}$$$, $$$\texttt{AB}$$$, $$$\texttt{BA}$$$. It also turned out that there are no spaces in this language: a sentence is written by just con...
def solve(): cnt_a, cnt_b, cnt_ab, cnt_ba = map(int, input().strip().split()) # print(cntA, cntB, cntAB, cntBA) s = input() if s.count('A') != cnt_a + cnt_ba + cnt_ab: print("NO") return stk = [[1, s[0]]] for i in range(1, len(s)): if i == 0: conti...
last == 'A' and cnt_ba >= (cnt >> 1)
[{"input": "8\n1 0 0 0\nB\n0 0 1 0\nAB\n1 1 0 1\nABAB\n1 0 1 1\nABAAB\n1 1 2 2\nBAABBABBAA\n1 1 2 3\nABABABBAABAB\n2 3 5 4\nAABAABBABAAABABBABBBABB\n1 3 3 10\nBBABABABABBBABABABABABABAABABA", "output": ["NO\nYES\nYES\nYES\nYES\nYES\nNO\nYES"]}]
control_completion_001190
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array of $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$. After you watched the amazing film "Everything Everywhere All At Once", you came up with the following operation.In one operation, you choose $$$n-1$$$ elements of the arr...
import fileinput lines = [] for line in fileinput.input(): line_f = [int(x) for x in line.split()] if len(line_f) > 0: lines.append(line_f) # print ffs for i in range(1, len(lines), 2): n = lines[i][0] a = lines[i+1] b = 123 + 23 c= b + 1 sm = 0 ...
lhs == rhs
[{"input": "4\n\n3\n\n42 42 42\n\n5\n\n1 2 3 4 5\n\n4\n\n4 3 2 1\n\n3\n\n24 2 22", "output": ["YES\nYES\nNO\nNO"]}]
control_completion_001218
control_fixed
python
Complete the code in python to solve this programming problem: Description: For an array $$$[b_1, b_2, \ldots, b_m]$$$ define its number of inversions as the number of pairs $$$(i, j)$$$ of integers such that $$$1 \le i &lt; j \le m$$$ and $$$b_i&gt;b_j$$$. Let's call array $$$b$$$ odd if its number of inversions is o...
import fileinput lines = [] for line in fileinput.input(): line_f = [int(x) for x in line.split()] if len(line_f) > 0: lines.append(line_f) # print ffs for i in range(1, len(lines), 2): n = lines[i][0] a = lines[i+1] numoddseg = 0 prev = -1 i = 0 whil...
a[i] < prev
[{"input": "5\n\n3\n\n1 2 3\n\n4\n\n4 3 2 1\n\n2\n\n1 2\n\n2\n\n2 1\n\n6\n\n4 5 6 1 2 3", "output": ["0\n2\n0\n1\n1"]}]
control_completion_001260
control_fixed
python
Complete the code in python to solve this programming problem: Description: Inflation has occurred in Berlandia, so the store needs to change the price of goods.The current price of good $$$n$$$ is given. It is allowed to increase the price of the good by $$$k$$$ times, with $$$1 \le k \le m$$$, k is an integer. Outpu...
from sys import stdin, stderr data = [int(x) for x in stdin.read().split()[1:]] ns, ms = data[::2], data[1::2] output = [] for n, m in zip(ns, ms): # n = 2 ** a * 5 ** b * c a = b = 0 c = n while c % 2 == 0: a += 1 c //= 2 while c % 5 == 0: b += 1 c //= 5 t = 1...
b > a and 2 * t <= m
[{"input": "10\n\n6 11\n\n5 43\n\n13 5\n\n4 16\n\n10050 12345\n\n2 6\n\n4 30\n\n25 10\n\n2 81\n\n1 7", "output": ["60\n200\n65\n60\n120600000\n10\n100\n200\n100\n7"]}]
control_completion_001308
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a string $$$s$$$. You have to determine whether it is possible to build the string $$$s$$$ out of strings aa, aaa, bb and/or bbb by concatenating them. You can use the strings aa, aaa, bb and/or bbb any number of times and in any...
t=int(input()) while(t): i=0 s=input() if(len(s)==1): print("NO") t=t-1 continue while(i<len(s)): if(i==0): if(s[0:2]=="ab" or s[0:2]=="ba"): print("NO") t=t-1 break if(i>0 and i<len(s)-1): ...
(s[i-1:]=="ba" or s[i-1:]=="ab")
[{"input": "8\n\naaaabbb\n\nbbaaaaabbb\n\naaaaaa\n\nabab\n\na\n\nb\n\naaaab\n\nbbaaa", "output": ["YES\nYES\nYES\nNO\nNO\nNO\nNO\nYES"]}]
control_completion_001643
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a rooted tree of $$$2^n - 1$$$ vertices. Every vertex of this tree has either $$$0$$$ children, or $$$2$$$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children...
n = int(input()) s = input() c = 1 def dfs(i): if {{completion}}: return s[i] global c l = dfs(2*i + 1) r = dfs(2*i + 2) if l != r: c *= 2 if l > r: l, r = r, l return s[i] + l + r dfs(0) print(c % 998244353)
i >= 2**(n-1)-1
[{"input": "4\nBAAAAAAAABBABAB", "output": ["16"]}, {"input": "2\nBAA", "output": ["1"]}, {"input": "2\nABA", "output": ["2"]}, {"input": "2\nAAB", "output": ["2"]}, {"input": "2\nAAA", "output": ["1"]}]
control_completion_001661
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a rooted tree of $$$2^n - 1$$$ vertices. Every vertex of this tree has either $$$0$$$ children, or $$$2$$$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children...
n = int(input()) s = input() c = 1 def dfs(i): if i >= 2**(n-1)-1: return s[i] global c l = dfs(2*i + 1) r = dfs(2*i + 2) if {{completion}}: c *= 2 if l > r: l, r = r, l return s[i] + l + r dfs(0) print(c % 998244353)
l != r
[{"input": "4\nBAAAAAAAABBABAB", "output": ["16"]}, {"input": "2\nBAA", "output": ["1"]}, {"input": "2\nABA", "output": ["2"]}, {"input": "2\nAAB", "output": ["2"]}, {"input": "2\nAAA", "output": ["1"]}]
control_completion_001662
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a rooted tree of $$$2^n - 1$$$ vertices. Every vertex of this tree has either $$$0$$$ children, or $$$2$$$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children...
mod=998244353 cnt=0 n=int(input()) s=input() import random q=random.randint(10**9,2*10**9) p=random.randint(10**9,2*10**9) r=10**9+7 a=[-1] for i in s: if {{completion}}: a.append(p) else: a.append(q) for i in range(2**(n-1)-1,0,-1): if a[2*i]!=a[2*i+1]: cnt+=1 a[i]=a[i]^(2*a[2*i]+2*a[2*i+1]) a...
i=='A'
[{"input": "4\nBAAAAAAAABBABAB", "output": ["16"]}, {"input": "2\nBAA", "output": ["1"]}, {"input": "2\nABA", "output": ["2"]}, {"input": "2\nAAB", "output": ["2"]}, {"input": "2\nAAA", "output": ["1"]}]
control_completion_001663
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a rooted tree of $$$2^n - 1$$$ vertices. Every vertex of this tree has either $$$0$$$ children, or $$$2$$$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children...
mod=998244353 cnt=0 n=int(input()) s=input() import random q=random.randint(10**9,2*10**9) p=random.randint(10**9,2*10**9) r=10**9+7 a=[-1] for i in s: if i=='A': a.append(p) else: a.append(q) for i in range(2**(n-1)-1,0,-1): if {{completion}}: cnt+=1 a[i]=a[i]^(2*a[2*i]+2*a[2*i+1]) a[i]%=r ...
a[2*i]!=a[2*i+1]
[{"input": "4\nBAAAAAAAABBABAB", "output": ["16"]}, {"input": "2\nBAA", "output": ["1"]}, {"input": "2\nABA", "output": ["2"]}, {"input": "2\nAAB", "output": ["2"]}, {"input": "2\nAAA", "output": ["1"]}]
control_completion_001664
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a rooted tree of $$$2^n - 1$$$ vertices. Every vertex of this tree has either $$$0$$$ children, or $$$2$$$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children...
MOD = 998244353 n, s = int(input()), input() def calc(u: int) -> tuple: if {{completion}}: return (0, 0) t1, t2 = calc(u * 2), calc(u * 2 + 1) return (t1[0] + t2[0] + (t1[1] != t2[1]), hash((min(t1[1], t2[1]), max(t1[1], t2[1]), s[u - 1]))) print(pow(2, calc(1)[0],...
u >= (1 << n)
[{"input": "4\nBAAAAAAAABBABAB", "output": ["16"]}, {"input": "2\nBAA", "output": ["1"]}, {"input": "2\nABA", "output": ["2"]}, {"input": "2\nAAB", "output": ["2"]}, {"input": "2\nAAA", "output": ["1"]}]
control_completion_001665
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given a rooted tree of $$$2^n - 1$$$ vertices. Every vertex of this tree has either $$$0$$$ children, or $$$2$$$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children...
def dfs(tree,i,h): if {{completion}}: return [tree[i],1] ls,li=dfs(tree,i*2+1,h) rs,ri=dfs(tree,i*2+2,h) res=li*ri if ls!=rs: res*=2 if ls>rs: return [tree[i]+rs+ls,res] else: return [tree[i]+ls+rs,res] h=int(input()) tree=input() print(dfs(t...
i>=2**(h-1)-1
[{"input": "4\nBAAAAAAAABBABAB", "output": ["16"]}, {"input": "2\nBAA", "output": ["1"]}, {"input": "2\nABA", "output": ["2"]}, {"input": "2\nAAB", "output": ["2"]}, {"input": "2\nAAA", "output": ["1"]}]
control_completion_001666
control_fixed