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: Let's call a string $$$s$$$ perfectly balanced if for all possible triplets $$$(t,u,v)$$$ such that $$$t$$$ is a non-empty substring of $$$s$$$ and $$$u$$$ and $$$v$$$ are characters present in $$$s$$$, the difference between the frequencies o...
for _ in range(int(input())): {{completion}}
s = input() c = len(set(s)) print("Yes" if all(len(set(s[i::c])) == 1 for i in range(c)) else "No")
[{"input": "5\naba\nabb\nabc\naaaaa\nabcba", "output": ["YES\nNO\nYES\nYES\nNO"]}]
block_completion_004801
block
python
Complete the code in python to solve this programming problem: Description: Let's call a string $$$s$$$ perfectly balanced if for all possible triplets $$$(t,u,v)$$$ such that $$$t$$$ is a non-empty substring of $$$s$$$ and $$$u$$$ and $$$v$$$ are characters present in $$$s$$$, the difference between the frequencies o...
import sys input = sys.stdin.readline n = int(input()) for _ in range(n): s = input()[:-1] a = len(s) b = len(set(s)) if b == 1 or a == b: print('YES') else: for i in range(1, a): if s[i] in s[:i]: w = (s[:i]*a)[:a] if s == w...
print("NO")
[{"input": "5\naba\nabb\nabc\naaaaa\nabcba", "output": ["YES\nNO\nYES\nYES\nNO"]}]
block_completion_004802
block
python
Complete the code in python to solve this programming problem: Description: Let's call a string $$$s$$$ perfectly balanced if for all possible triplets $$$(t,u,v)$$$ such that $$$t$$$ is a non-empty substring of $$$s$$$ and $$$u$$$ and $$$v$$$ are characters present in $$$s$$$, the difference between the frequencies o...
t = int(input()) while (t > 0): t -= 1 s = str(input()) var = set(s) ans = "YES" for i in range(len(s)-len(var)+1): if len(set(s[i:i+len(var)])) != len(var): {{completion}} print(ans)
ans = "NO" break
[{"input": "5\naba\nabb\nabc\naaaaa\nabcba", "output": ["YES\nNO\nYES\nYES\nNO"]}]
block_completion_004803
block
python
Complete the code in python to solve this programming problem: Description: Let's call a string $$$s$$$ perfectly balanced if for all possible triplets $$$(t,u,v)$$$ such that $$$t$$$ is a non-empty substring of $$$s$$$ and $$$u$$$ and $$$v$$$ are characters present in $$$s$$$, the difference between the frequencies o...
def solve(s): st=set(s) a=len(st) f=1 for i in range(len(s)): if s[i]!=s[i%a] : {{completion}} if not f: return "NO" else: return "YES" for i in range(int(input())): s=input() print(solve(s))
f=0
[{"input": "5\naba\nabb\nabc\naaaaa\nabcba", "output": ["YES\nNO\nYES\nYES\nNO"]}]
block_completion_004804
block
python
Complete the code in python to solve this programming problem: Description: Let's call a string $$$s$$$ perfectly balanced if for all possible triplets $$$(t,u,v)$$$ such that $$$t$$$ is a non-empty substring of $$$s$$$ and $$$u$$$ and $$$v$$$ are characters present in $$$s$$$, the difference between the frequencies o...
for _ in range(int(input())): n=input() s=len(set(n)) for i in range(len(n)-s): if n[i]!=n[i+s]:{{completion}} else:print("YES")
print("NO");break
[{"input": "5\naba\nabb\nabc\naaaaa\nabcba", "output": ["YES\nNO\nYES\nYES\nNO"]}]
block_completion_004805
block
python
Complete the code in python to solve this programming problem: Description: Let's call a string $$$s$$$ perfectly balanced if for all possible triplets $$$(t,u,v)$$$ such that $$$t$$$ is a non-empty substring of $$$s$$$ and $$$u$$$ and $$$v$$$ are characters present in $$$s$$$, the difference between the frequencies o...
for i in range(int(input())): count={} str = input() for char in str: count[char] = 0 res = True for i in range(len(str) - len(count.keys())): if (str[i]!=str[i + len(count.keys())]): {{completion}} print("YES" if res else "NO")
res = False
[{"input": "5\naba\nabb\nabc\naaaaa\nabcba", "output": ["YES\nNO\nYES\nYES\nNO"]}]
block_completion_004806
block
python
Complete the code in python to solve this programming problem: Description: Let's call a string $$$s$$$ perfectly balanced if for all possible triplets $$$(t,u,v)$$$ such that $$$t$$$ is a non-empty substring of $$$s$$$ and $$$u$$$ and $$$v$$$ are characters present in $$$s$$$, the difference between the frequencies o...
t = int(input()) while(t): s = input() d = len(set(s)) for i in range(d, len(s)): if(s[i] != s[i - d]): {{completion}} else: print("Yes") t -= 1
print("No") break
[{"input": "5\naba\nabb\nabc\naaaaa\nabcba", "output": ["YES\nNO\nYES\nYES\nNO"]}]
block_completion_004807
block
python
Complete the code in python to solve this programming problem: Description: Let's call a string $$$s$$$ perfectly balanced if for all possible triplets $$$(t,u,v)$$$ such that $$$t$$$ is a non-empty substring of $$$s$$$ and $$$u$$$ and $$$v$$$ are characters present in $$$s$$$, the difference between the frequencies o...
n = int(input()) for i in range(n): str1 = input() set_char = set(str1) req = len(set_char) prev = dict() truth = True ind = 0 for i1 in str1: if( i1 in prev and ind - prev[i1] != req): {{completion}} prev[i1] = ind ind += 1 print(truth and 'YES' or 'NO')
truth = False break
[{"input": "5\naba\nabb\nabc\naaaaa\nabcba", "output": ["YES\nNO\nYES\nYES\nNO"]}]
block_completion_004808
block
python
Complete the code in python to solve this programming problem: Description: Alice and Bob are playing a game with strings. There will be $$$t$$$ rounds in the game. In each round, there will be a string $$$s$$$ consisting of lowercase English letters. Alice moves first and both the players take alternate turns. Alice ...
from sys import stdin from collections import deque lst = 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 = int(inp1()) for _ in range(t): alph = "abcdefghijklmnopqrstuvwxyz" a = list(map(lambda c: alph.ind...
print(f"Alice {o2}")
[{"input": "5\n\naba\n\nabc\n\ncba\n\nn\n\ncodeforces", "output": ["Alice 2\nAlice 4\nAlice 4\nBob 14\nAlice 93"]}]
block_completion_004850
block
python
Complete the code in python to solve this programming problem: Description: Consider every tree (connected undirected acyclic graph) with $$$n$$$ vertices ($$$n$$$ is odd, vertices numbered from $$$1$$$ to $$$n$$$), and for each $$$2 \le i \le n$$$ the $$$i$$$-th vertex is adjacent to exactly one vertex with a smaller...
MOD = 998244353 def modmul(x, y, c = 0): {{completion}} def inv(x): return pow(x, MOD - 2, MOD) MAX = 10 ** 6 fact = [1] for i in range(1, MAX): fact.append(modmul(i, fact[i-1])) invfact = [1] * (MAX) invfact[MAX - 1] = inv(fact[MAX - 1]) for i in range(MAX - 2, -1, -1): invfact[i]...
return (x * y + c) % MOD
[{"input": "3", "output": ["1 1 0"]}, {"input": "5", "output": ["10 10 4 0 0"]}, {"input": "7", "output": ["276 276 132 36 0 0 0"]}]
block_completion_005082
block
python
Complete the code in python to solve this programming problem: Description: Consider every tree (connected undirected acyclic graph) with $$$n$$$ vertices ($$$n$$$ is odd, vertices numbered from $$$1$$$ to $$$n$$$), and for each $$$2 \le i \le n$$$ the $$$i$$$-th vertex is adjacent to exactly one vertex with a smaller...
MOD = 998244353 def modmul(x, y, c = 0): return (x * y + c) % MOD def inv(x): {{completion}} MAX = 10 ** 6 fact = [1] for i in range(1, MAX): fact.append(modmul(i, fact[i-1])) invfact = [1] * (MAX) invfact[MAX - 1] = inv(fact[MAX - 1]) for i in range(MAX - 2, -1, -1): invfact[i] = ...
return pow(x, MOD - 2, MOD)
[{"input": "3", "output": ["1 1 0"]}, {"input": "5", "output": ["10 10 4 0 0"]}, {"input": "7", "output": ["276 276 132 36 0 0 0"]}]
block_completion_005083
block
python
Complete the code in python to solve this programming problem: Description: A triple of points $$$i$$$, $$$j$$$ and $$$k$$$ on a coordinate line is called beautiful if $$$i < j < k$$$ and $$$k - i \le d$$$.You are given a set of points on a coordinate line, initially empty. You have to process queries of three t...
import sys # https://codeforces.com/contest/1701/problem/F MAXN = 200000 class SegmentTree: def __init__(self): self.lazy = [] self.v0 = [] self.v1 = [] self.v2 = [] self.active = [] for _ in range(4 * MAXN + 1): self.lazy.append(0) ...
self.v2[x] = self.v2[x] - 2 * self.v1[x] + self.v0[x] self.v1[x] -= self.v0[x] self.lazy[x] -= 1
[{"input": "7 5\n8 5 3 2 1 5 6", "output": ["0\n0\n1\n2\n5\n1\n5"]}]
block_completion_005215
block
python
Complete the code in python to solve this programming problem: Description: A triple of points $$$i$$$, $$$j$$$ and $$$k$$$ on a coordinate line is called beautiful if $$$i < j < k$$$ and $$$k - i \le d$$$.You are given a set of points on a coordinate line, initially empty. You have to process queries of three t...
import sys # https://codeforces.com/contest/1701/problem/F MAXN = 200000 class SegmentTree: def __init__(self): self.lazy = [] self.v0 = [] self.v1 = [] self.v2 = [] self.active = [] for _ in range(4 * MAXN + 1): self.lazy.append(0) ...
self.v2[x] = self.v2[x] + 2 * self.v1[x] + self.v0[x] self.v1[x] += self.v0[x] self.lazy[x] += 1
[{"input": "7 5\n8 5 3 2 1 5 6", "output": ["0\n0\n1\n2\n5\n1\n5"]}]
block_completion_005216
block
python
Complete the code in python to solve this programming problem: Description: A triple of points $$$i$$$, $$$j$$$ and $$$k$$$ on a coordinate line is called beautiful if $$$i < j < k$$$ and $$$k - i \le d$$$.You are given a set of points on a coordinate line, initially empty. You have to process queries of three t...
import os import sys from io import BytesIO, IOBase 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 = self.buffer...
break
[{"input": "7 5\n8 5 3 2 1 5 6", "output": ["0\n0\n1\n2\n5\n1\n5"]}]
block_completion_005217
block
python
Complete the code in python to solve this programming problem: Description: A triple of points $$$i$$$, $$$j$$$ and $$$k$$$ on a coordinate line is called beautiful if $$$i < j < k$$$ and $$$k - i \le d$$$.You are given a set of points on a coordinate line, initially empty. You have to process queries of three t...
import os import sys from io import BytesIO, IOBase 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 = self.buffer...
self.push(l >> i)
[{"input": "7 5\n8 5 3 2 1 5 6", "output": ["0\n0\n1\n2\n5\n1\n5"]}]
block_completion_005218
block
python
Complete the code in python to solve this programming problem: Description: You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total....
n,k = map(int,input().split()) ns = set() for _ in range(n): {{completion}} arr = [[tuple((6-v1[i]-v2[i])%3 for i in range(k)) in ns for v1 in ns] for v2 in ns] ans = 0 for i in range(n): s = sum(arr[i])-2 ans += s*s//8 print(ans)
s = tuple(int(v) for v in input().split()) ns.add(s)
[{"input": "8 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n1 0 0 0\n2 2 0 0", "output": ["1"]}, {"input": "7 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n0 2 0 0", "output": ["3"]}, {"input": "9 2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2", "output": ["54"]}, {"input": "20 4\n0 2 0 0\n0 2 2 2...
block_completion_005312
block
python
Complete the code in python to solve this programming problem: Description: You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total....
n,k = map(int,input().split()) ns = set() for _ in range(n): s = tuple(int(v) for v in input().split()) ns.add(s) arr = [[tuple((6-v1[i]-v2[i])%3 for i in range(k)) in ns for v1 in ns] for v2 in ns] ans = 0 for i in range(n): {{completion}} print(ans)
s = sum(arr[i])-2 ans += s*s//8
[{"input": "8 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n1 0 0 0\n2 2 0 0", "output": ["1"]}, {"input": "7 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n0 2 0 0", "output": ["3"]}, {"input": "9 2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2", "output": ["54"]}, {"input": "20 4\n0 2 0 0\n0 2 2 2...
block_completion_005313
block
python
Complete the code in python to solve this programming problem: Description: You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total....
from sys import stdin def missing(c1, c2): c3 = [] for i in range(len(c1)): if c1[i] == c2[i]: c3.append(c1[i]) else: c3.append(next(iter({"0", "1", "2"}.difference({c1[i], c2[i]})))) return "".join(c3) def solve(): n, k = map(int, stdin.readline()...
off1[m] += 1
[{"input": "8 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n1 0 0 0\n2 2 0 0", "output": ["1"]}, {"input": "7 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n0 2 0 0", "output": ["3"]}, {"input": "9 2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2", "output": ["54"]}, {"input": "20 4\n0 2 0 0\n0 2 2 2...
block_completion_005314
block
python
Complete the code in python to solve this programming problem: Description: You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total....
ndfeagbb, dfeagbbk = map(int, input().split()) cards = [tuple(map(int, input().split())) for _ in range(ndfeagbb)] cards_lookup, counter = {card: i for i, card in enumerate(cards)}, [0] * (ndfeagbb + 1) for i in range(len(cards) - 1): for j in range(i + 1, len(cards)): {{completion}} print(sum(x * (x ...
counter[cards_lookup.get(tuple(x if x == y else ((x + 1) ^ (y + 1)) - 1 for x, y in zip(cards[i], cards[j])), -1)] += 1
[{"input": "8 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n1 0 0 0\n2 2 0 0", "output": ["1"]}, {"input": "7 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n0 2 0 0", "output": ["3"]}, {"input": "9 2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2", "output": ["54"]}, {"input": "20 4\n0 2 0 0\n0 2 2 2...
block_completion_005315
block
python
Complete the code in python to solve this programming problem: Description: You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total....
from sys import stdin, stdout n, k = [int(x) for x in stdin.readline().split()] cards = set() for i in range(n): cards.add(tuple([int(x) for x in stdin.readline().split()])) answer = 0 for card in cards: yes_v = 0 for v in cards: w = [] for i in range(k): {{complet...
w.append((3-card[i]-v[i])%3)
[{"input": "8 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n1 0 0 0\n2 2 0 0", "output": ["1"]}, {"input": "7 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n0 2 0 0", "output": ["3"]}, {"input": "9 2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2", "output": ["54"]}, {"input": "20 4\n0 2 0 0\n0 2 2 2...
block_completion_005316
block
python
Complete the code in python to solve this programming problem: Description: You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total....
from sys import stdin, stdout n, k = [int(x) for x in stdin.readline().split()] cards = set() for i in range(n): cards.add(tuple([int(x) for x in stdin.readline().split()])) answer = 0 for card in cards: yes_v = 0 for v in cards: w = [] for i in range(k): w.append(...
yes_v += 1
[{"input": "8 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n1 0 0 0\n2 2 0 0", "output": ["1"]}, {"input": "7 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n0 2 0 0", "output": ["3"]}, {"input": "9 2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2", "output": ["54"]}, {"input": "20 4\n0 2 0 0\n0 2 2 2...
block_completion_005317
block
python
Complete the code in python to solve this programming problem: Description: You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total....
import sys; R = sys.stdin.readline n,k = map(int,R().split()) deck = [tuple(map(int,R().split())) for _ in range(n)] dic = {} for i in range(n): dic[deck[i]] = i res = [0]*n for p in range(n-2): for q in range(p+1,n-1): last = [0]*k for j in range(k): {{completion}} la...
last[j] = deck[p][j] if deck[p][j]==deck[q][j] else 3-deck[p][j]-deck[q][j]
[{"input": "8 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n1 0 0 0\n2 2 0 0", "output": ["1"]}, {"input": "7 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n0 2 0 0", "output": ["3"]}, {"input": "9 2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2", "output": ["54"]}, {"input": "20 4\n0 2 0 0\n0 2 2 2...
block_completion_005318
block
python
Complete the code in python to solve this programming problem: Description: You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total....
import sys; R = sys.stdin.readline n,k = map(int,R().split()) deck = [tuple(map(int,R().split())) for _ in range(n)] dic = {} for i in range(n): dic[deck[i]] = i res = [0]*n for p in range(n-2): for q in range(p+1,n-1): last = [0]*k for j in range(k): last[j] = deck[p][j] if de...
res[p] += 1; res[q] += 1; res[dic[last]] += 1
[{"input": "8 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n1 0 0 0\n2 2 0 0", "output": ["1"]}, {"input": "7 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n0 2 0 0", "output": ["3"]}, {"input": "9 2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2", "output": ["54"]}, {"input": "20 4\n0 2 0 0\n0 2 2 2...
block_completion_005319
block
python
Complete the code in python to solve this programming problem: Description: You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total....
n,k=map(int,input().split()) a=[] d={} for i in range(n): a+=[''.join(input().split())] d[a[-1]]=0 def cal(s,t): res="" for i in range(k): res+=str((9-int(s[i])-int(t[i]))%3) return res for i in range(n): for j in range(i): try: d[cal(a[i],a[...
pass
[{"input": "8 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n1 0 0 0\n2 2 0 0", "output": ["1"]}, {"input": "7 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n0 2 0 0", "output": ["3"]}, {"input": "9 2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2", "output": ["54"]}, {"input": "20 4\n0 2 0 0\n0 2 2 2...
block_completion_005320
block
python
Complete the code in python to solve this programming problem: Description: You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total....
n, k = [int(i) for i in input().split()] a = [] for _ in range(n): a.append(tuple([int(i) for i in input().split()])) a = tuple(a) sus = set(a) cs = [0 for i in range(n)] for i in range(n): p = a[i] for j in set(range(n)) - set(tuple([i])): q = a[j] r = [] for o in rang...
r.append(3-p[o]-q[o])
[{"input": "8 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n1 0 0 0\n2 2 0 0", "output": ["1"]}, {"input": "7 4\n0 0 0 0\n0 0 0 1\n0 0 0 2\n0 0 1 0\n0 0 2 0\n0 1 0 0\n0 2 0 0", "output": ["3"]}, {"input": "9 2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2", "output": ["54"]}, {"input": "20 4\n0 2 0 0\n0 2 2 2...
block_completion_005321
block
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 _ in range(int(input())): {{completion}}
n = input() a = sorted(map(int, input().split())) print(a[-1] + a[-2] - a[0] - a[1])
[{"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"]}]
block_completion_005384
block
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 s in[*open(0)][2::2]:{{completion}}
a,b,*_,c,d=sorted(map(int,s.split()));print(c+d-a-b)
[{"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"]}]
block_completion_005385
block
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 t in range(int(input())):{{completion}}
input();a,b,*_,c,d=sorted(map(int,input().split()));print(c+d-a-b)
[{"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"]}]
block_completion_005386
block
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 sdr in[*open(0)][2::2]:{{completion}}
p,q,*_,r,s=sorted(map(int,sdr.split()));print(r+s-p-q)
[{"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"]}]
block_completion_005387
block
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 _ in range(int(input())): {{completion}}
input() a, b, *_, c, d = sorted(map(int, input().split())) print(c+d-a-b)
[{"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"]}]
block_completion_005388
block
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 _ in range(int(input())): {{completion}}
input() a = sorted(map(int, input().split())) print(a[-1] + a[-2] - a[0] - a[1])
[{"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"]}]
block_completion_005389
block
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...
ma=max(ma,s[i])
[{"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"]}]
block_completion_005534
block
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...
from collections import * from itertools import * from functools import * import math,sys input = sys.stdin.buffer.readline n = int(input()) AB = [tuple(map(int,input().split())) for _ in range(n)] M = int(input()) XY = [tuple(map(int,input().split())) for _ in range(M)] ans = [] from math import gcd d...
ng = mid
[{"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"]}]
block_completion_005535
block
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...
from collections import * from itertools import * from functools import * import math,sys input = sys.stdin.buffer.readline n = int(input()) AB = [tuple(map(int,input().split())) for _ in range(n)] M = int(input()) XY = [tuple(map(int,input().split())) for _ in range(M)] ans = [] from math import gcd d...
ng = mid
[{"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"]}]
block_completion_005536
block
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 math import sys input = sys.stdin.readline class Dish: def __init__(self): self.a=0 self.b=0 def exgcd(a,b): if b: x,y=exgcd(b,a%b) return y,x-a//b*y return 1,0 n=int(input()) dish=[Dish() for i in range(n)] val=[0 for i in range(n+5)] for i in range(n): dish[i].a,dish[i].b=...
print(val[a*gcdAB*(x1+kmin*b)])
[{"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"]}]
block_completion_005537
block
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 math import sys input = sys.stdin.readline class Dish: def __init__(self): self.a=0 self.b=0 def exgcd(a,b): if b: x,y=exgcd(b,a%b) return y,x-a//b*y return 1,0 n=int(input()) dish=[Dish() for i in range(n)] val=[0 for i in range(n+5)] for i in range(n): dish[i].a,dish[i].b=...
k=(maxW/a/gcdAB-x1)/b print(max(val[a*gcdAB*(x1+math.ceil(k)*b)],val[a*gcdAB*(x1+math.floor(k)*b)]))
[{"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"]}]
block_completion_005538
block
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_p = points[prev_idx] mid = (prev_p + p) // 2 keys.append((0, prev_idx, posmap[mid])) q = q * queryL[prev_idx][posmap[mid]] % MOD keys.append((1, i, posmap[mid+1])) q = q * queryR[i][posmap[mid+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"]}]
block_completion_005549
block
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...
keys.append((1, i, 0)) q = q * queryR[i][0] % MOD
[{"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"]}]
block_completion_005550
block
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 ...
A(tr,x,-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"]}]
block_completion_005571
block
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 ...
A(tc,y,-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"]}]
block_completion_005572
block
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...
bitb.update(x, -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"]}]
block_completion_005573
block
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...
bitv.update(y, -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"]}]
block_completion_005574
block
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]...
print('No')
[{"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"]}]
block_completion_005575
block
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 += r[x] x = (x & (x + 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"]}]
block_completion_005576
block
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] ...
print("NO")
[{"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"]}]
block_completion_005577
block
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) ...
sys.stdout.write("No\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"]}]
block_completion_005578
block
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) ...
update(x, -1, rtree, 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"]}]
block_completion_005579
block
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 = lambda: sys.stdin.readline().rstrip() class SegTree: def __init__(self, n): self.size = n self.tree = [0]*(n*2) def update(self,p,v): self.tree[p+self.size] = v p+=self.size i = p while i>1: self.tree[i>>1] = self.tree[i] + self.tree[i^1] i>>=1 def query(se...
ans += self.tree[l] l+=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"]}]
block_completion_005580
block
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 = lambda: sys.stdin.readline().rstrip() class SegTree: def __init__(self, n): self.size = n self.tree = [0]*(n*2) def update(self,p,v): self.tree[p+self.size] = v p+=self.size i = p while i>1: self.tree[i>>1] = self.tree[i] + self.tree[i^1] i>>=1 def query(se...
r-=1 ans += self.tree[r]
[{"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"]}]
block_completion_005581
block
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...
x[u] -= 1 u += u & -u
[{"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"]}]
block_completion_005582
block
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...
y[v] -= 1 v += v & -v
[{"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"]}]
block_completion_005583
block
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 t & 1: i, x = x r += x - d.get(i, v) d[i] = x else: {{completion}} print(r)
d = {} v, = x r = v * n
[{"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"]}]
block_completion_005606
block
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 step[b[1]-1] > laststep: tot += b[2] - a[b[1]-1] a[b[1]-1] = b[2] ...
tot += b[2] - last a[b[1]-1] = b[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"]}]
block_completion_005607
block
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...
def inpList(): return [int(i) for i in input().split()] def solve(): n, q = inpList() a = inpList() t1 = {} t2 = 0 sm = sum(a) for qi in range(q): inp = inpList() if len(inp) == 3: _, i, x = inp if t1.get(i): sm += x - t1[i] ...
sm += x - (t2 or a[i-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"]}]
block_completion_005608
block
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 p[0] == 2: k = p[1] ans = n*p[1] t = defaultdict(lambd...
ans += p[2] - t[p[1] - 1] t[p[1] - 1] = p[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"]}]
block_completion_005609
block
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 ...
default, = a tot = default*n d = {}
[{"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"]}]
block_completion_005610
block
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 t&1:i,x=x;ans+=x-arr.get(i,g);arr[i]=x else:{{completion}} print(ans)
arr={};g,=x;ans=g*n
[{"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"]}]
block_completion_005611
block
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 b[j]>c: s = s-a[j]+k[2] else: {{completion}} a[j] ...
s = s-x+k[2] b[j] = c+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"]}]
block_completion_005612
block
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 (req[0] == 1): i = req[1]-1 x = req[2] current = X if c[i]<lst else a[i] S += x - c...
X = req[1] S = X * n lst = idx
[{"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"]}]
block_completion_005613
block
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 t[0] == 1: d[t[1]] = t[2] else: {{c...
d.clear() type2 = 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"]}]
block_completion_005614
block
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: ...
continue
[{"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"]}]
block_completion_005667
block
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: ...
continue
[{"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"]}]
block_completion_005668
block
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...
que.append((i, lev + 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"]}]
block_completion_005669
block
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 ...
return True
[{"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"]}]
block_completion_005670
block
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...
return True
[{"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"]}]
block_completion_005671
block
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...
stk.append(v)
[{"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"]}]
block_completion_005672
block
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 t == "RRRRRRRR": {{completion}} print(ans)
ans = "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\...
block_completion_005800
block
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: {{completion}} for i in range(8): if l[i]==a: c=1 break print("B" if c!=1 else "R")
l.append([*s])
[{"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\...
block_completion_005801
block
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 l[i]==a: {{completion}} print("B" if c!=1 else "R")
c=1 break
[{"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\...
block_completion_005802
block
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: {{completion}} for row in l: if row.count('R')==8: ans='R' break print(ans)
l.pop()
[{"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\...
block_completion_005803
block
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 row.count('R')==8: {{completion}} print(ans)
ans='R' break
[{"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\...
block_completion_005804
block
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 lines[i+a].count('R') == 8: {{completion}} else: print('B') a+=8
print('R') break
[{"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\...
block_completion_005805
block
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 != '': {{completion}} if tmp == "R" * 8 and judge: print("R") judge = False if judge: ...
i += 1
[{"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\...
block_completion_005806
block
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 tmp == "R" * 8 and judge: {{completion}} if judge: print("B") # for i in met: ...
print("R") judge = False
[{"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\...
block_completion_005807
block
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(b[j][k] != 'R') : {{completion}} ...
ok = False
[{"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\...
block_completion_005808
block
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 lines[i + j].count('R') == 8: {{completion}} else: print('B') j += 8
print('R') break
[{"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\...
block_completion_005809
block
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 grid[i][j]!='R': ...
x = True
[{"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\...
block_completion_005810
block
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 != '') : {{completion}} for j in range(8) : if(len(set(b[j])) == 1 and b[j][0] == 'R') : key = 'R' break if(key!= 'R') : key =...
b.append(a) j += 1
[{"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\...
block_completion_005811
block
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(len(set(b[j])) == 1 and b[j][0] == 'R') : {{completion}} if(key!= 'R') : k...
key = 'R' break
[{"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\...
block_completion_005812
block
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 lst != c: {{completion}} ret[-1] += 1 return ret def transform(lns): st = [] s = 0 for l in lns: st.append(s) ...
ret.append(0) 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"]}]
block_completion_005866
block
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 ...
res += [1] * (self.sz - i) break
[{"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"]}]
block_completion_005931
block
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 ...
res += [1] * (j-i) st = j
[{"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"]}]
block_completion_005932
block
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 ...
res += [1] * (self.sz - i) break
[{"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"]}]
block_completion_005933
block
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 ...
res += [1] * (j-i) st = j
[{"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"]}]
block_completion_005934
block
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 ...
res += [1] * (self.sz - i) break
[{"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"]}]
block_completion_005935
block
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 ...
res += [1] * (j-i) st = j
[{"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"]}]
block_completion_005936
block
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 cnt[m] >= t: e = m else: {{completion}} return str(s) ...
s = m + 1
[{"input": "4\n\n1\n\n2\n\n3\n\n4567", "output": ["2\n2\n3\n83"]}]
block_completion_005986
block
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 cnt[m] >= t: e = m e...
s = m + 1
[{"input": "4\n\n1\n\n2\n\n3\n\n4567", "output": ["2\n2\n3\n83"]}]
block_completion_005987
block
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...
need=False
[{"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 ...
block_completion_006024
block
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_zeros = False
[{"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 ...
block_completion_006025
block
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): ...
count += 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 ...
block_completion_006026
block
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] = 1 j = self.pos_b[self.a[j]]
[{"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 ...
block_completion_006027
block
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 ...
f=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 ...
block_completion_006028
block
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 g[j +...
ass = True
[{"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 ...
block_completion_006029
block
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...
mul = 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 ...
block_completion_006030
block
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 ...
f=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 ...
block_completion_006031
block
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 ...
break
[{"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 ...
block_completion_006032
block
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 ...
return "NO"
[{"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"]}]
block_completion_006045
block
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...
break
[{"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"]}]
block_completion_006063
block
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...
d=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"]}]
block_completion_006064
block