description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | t = int(input())
ans = [None for _ in range(t)]
for q in range(t):
s = input()
P, S, R = 0, 0, 0
for i in range(len(s)):
if s[i] == "P":
P += 1
elif s[i] == "S":
S += 1
else:
R += 1
if S == P == R:
ans[q] = "P" * R + "S" * P + "R" * S
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | def solve(s):
ans = ""
r = "R" * len(s)
S = "S" * len(s)
p = "P" * len(s)
cnt1, cnt2, cnt3 = s.count("R"), s.count("S"), s.count("P")
if cnt1 >= cnt2 and cnt1 >= cnt3:
print(p)
elif cnt2 >= cnt1 and cnt2 >= cnt3:
print(r)
else:
print(S)
def main():
t = int(i... | FUNC_DEF ASSIGN VAR STRING ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VA... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | for _ in range(int(input())):
string = input()
r, p, s = 0, 0, 0
for i in string:
if i == "R":
r += 1
elif i == "P":
p += 1
else:
s += 1
ar = [r, p, s]
max_in = None
max_no = 0
for i, j in enumerate(ar):
if j >= max_no:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR NONE ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | t = int(input())
while t > 0:
t = t - 1
s = input()
n = len(s)
x = s.count("R")
y = s.count("P")
z = s.count("S")
if x >= y and x >= z:
c = "P" * n
elif y >= x and y >= z:
c = "S" * n
elif z >= y and z >= x:
c = "R" * n
print(c) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR VAR ASSIGN VAR BIN_OP STRING VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP ... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | t = int(input())
cases = []
for _ in range(t):
cases.append(list(input()))
for c in cases:
m = {"R": 0, "P": 0, "S": 0}
for i in range(len(c)):
m[c[i]] += 1
maxi = max(m, key=m.get)
if maxi == "R":
print("P" * len(c))
elif maxi == "P":
print("S" * len(c))
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING EXPR FUNC_CALL V... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | t = int(input())
for i in range(t):
s1 = input()
s = list(s1)
l = len(s1)
hm = {}
hm["R"] = 0
hm["S"] = 0
hm["P"] = 0
for j in s:
hm[j] += 1
if hm["R"] == hm["S"] and hm["R"] == hm["P"]:
print(s1)
continue
q = max(hm, key=hm.get)
if q == "R":
p... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER FOR VAR VAR VAR VAR NUMBER IF VAR STRING VAR STRING VAR STRING VAR STRING EXPR FU... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | import sys
input = sys.stdin.readline
def int_array():
return list(map(int, input().strip().split()))
def str_array():
return input().strip().split()
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
for _ in range(int(input())):
arr = list(input())
n = len(arr)
r, p, ... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASS... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | tests = int(input())
for _ in range(tests):
s = input()
n = len(s)
cnt = {"R": 0, "P": 0, "S": 0}
for c in s:
cnt[c] += 1
target = max(cnt.values())
ans = "R"
for u, v in cnt.items():
if v == target:
if u == "R":
ans = "P"
if u == "P":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR VAR FUNC_CALL VAR IF VAR VAR IF VAR STRING ASSIGN V... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | for kek in range(int(input())):
x = input()
R = 0
S = 0
P = 0
for i in x:
if i == "R":
R += 1
if i == "S":
S += 1
if i == "P":
P += 1
ans = ""
if max(S, R, P) == P:
ans = "S"
elif max(S, R, P) == S:
ans = "R"
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR VAR VAR AS... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | for i in range(int(input())):
di = dict()
n = input()
for i in n:
di[i] = di.get(i, 0) + 1
b = max(di.values())
if len(di) == 1:
for i, j in di.items():
if i == "R":
x = ["P"] * j
print(*x, sep="")
elif i == "S":
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR IF VAR STRING ASSIGN VAR BIN_OP LIST STRING VAR EXPR FUNC_CAL... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | def universalsol(s):
rock = s.count("R")
paper = s.count("P")
scissor = s.count("S")
if rock == paper == scissor:
print("R" * scissor + "P" * rock + "S" * paper)
else:
maximum = max(rock, paper, scissor)
if rock == maximum:
print("P" * len(s))
elif paper =... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR EXP... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | for i in range(int(input())):
s = input()
n = len(s)
x, y, z = 0, 0, 0
for i in range(n):
if s[i] == "R":
y += 1
elif s[i] == "P":
z += 1
else:
x += 1
if y == max(x, y, z):
for i in range(n):
print("P", end="")
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STR... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | def counter(s):
if s == "R":
return "P"
elif s == "P":
return "S"
elif s == "S":
return "R"
for t in range(int(input())):
bot = input()
n = len(bot)
if len(set(bot)) == 1:
print(counter(bot[0]) * n)
else:
d = {}
l = ["R", "P", "S"]
fo... | FUNC_DEF IF VAR STRING RETURN STRING IF VAR STRING RETURN STRING IF VAR STRING RETURN STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR DICT ASSIGN VAR... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | def get_beating(x):
if x == "R":
return "P"
elif x == "P":
return "S"
else:
return "R"
for _ in range(int(input())):
play = input()
output = ""
R = play.count("R")
S = play.count("S")
P = play.count("P")
if R >= S and R >= P:
print(len(play) * get_be... | FUNC_DEF IF VAR STRING RETURN STRING IF VAR STRING RETURN STRING RETURN STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CA... |
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can ... | t = int(input())
while t:
dict1 = {"R": "P", "P": "S", "S": "R"}
dict2 = {}
s = input()
for i in s:
if i in dict2:
dict2[i] += 1
else:
dict2[i] = 1
max1 = 0
ans = ""
for i in dict2:
if max1 < dict2[i]:
ans = i
max1 = dic... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR STRI... |
Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).
Vasya wants to add either a "+" or a "-" before each number of array. Thus,... | def invert(s):
t = ""
for i in s:
if i == "+":
t += "-"
else:
t += "+"
return t
n = int(input())
if n == 1:
print("+")
exit()
a = list(map(int, input().split()))
cur = a[-1]
s = "+"
for i in range(n - 2, 0, -1):
if cur > 0:
cur -= a[i]
s ... | FUNC_DEF ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR STRING VAR STRING RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP ... |
Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).
Vasya wants to add either a "+" or a "-" before each number of array. Thus,... | n = int(input())
arr = list(map(int, input().split()))
if n == 1:
print("+")
elif n == 2:
print("-+")
else:
ans = ["+"]
cur = arr[-1]
for i in range(n - 2, -1, -1):
if cur > 0:
cur -= arr[i]
ans.append("-")
else:
cur += arr[i]
ans.appen... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST STRING ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR VAR VAR EXPR FUNC... |
Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).
Vasya wants to add either a "+" or a "-" before each number of array. Thus,... | n = int(input())
b = list(map(int, input().split()))
s = 0
res = []
j = n - 1
while j >= 0:
if s <= 0:
s += b[j]
res.append(1)
else:
s -= b[j]
res.append(0)
j += -1
res.reverse()
if s >= 0:
for j in res:
if j:
print("+", end="")
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER ... |
Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).
Vasya wants to add either a "+" or a "-" before each number of array. Thus,... | n = int(input())
a = list(map(int, input().split(" ")))
temp_sgn = 1
sgns = []
curr_sum = 0
for i in range(n):
if curr_sum >= a[n - i - 1]:
sgns.append(1)
sgns.append(-1)
curr_sum -= a[n - i - 1]
else:
sgns.append(-1)
sgns.append(1)
curr_sum -= a[n - i - 1]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ... |
Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).
Vasya wants to add either a "+" or a "-" before each number of array. Thus,... | n = int(input())
a = list(map(int, input().split()))
r = [0] * n
s = 0
for i in range(n - 1, -1, -1):
if abs(s + a[i]) <= a[i]:
s += a[i]
else:
s -= a[i]
r[i] = 1
if s < 0:
print("".join(["-", "+"][i] for i in r))
else:
print("".join(["+", "-"][i] for i in r)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER EXPR... |
Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).
Vasya wants to add either a "+" or a "-" before each number of array. Thus,... | n = int(input())
t = list(map(int, input().split()))
t.reverse()
s, p = 0, [0] * n
for i, j in enumerate(t):
if s > 0:
p[i] = 1
s -= j
else:
s += j
p.reverse()
if s < 0:
print("".join("-+"[i] for i in p))
else:
print("".join("+-"[i] for i in p)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING... |
Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).
Vasya wants to add either a "+" or a "-" before each number of array. Thus,... | n = int(input())
a = list(map(int, input().split()))
s = a[-1]
ans = ["+"]
for v in reversed(a[:-1]):
if s > 0:
s -= v
ans.append("-")
else:
s += v
ans.append("+")
if 0 <= s <= a[-1]:
print("".join(reversed(ans)))
else:
s = -a[-1]
ans = ["-"]
for v in reversed(a[:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST STRING FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR STRING VAR VAR EXPR FUNC_CALL VAR STRING IF NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL ... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def main():
for t in range(int(input())):
n, m, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
x, y = 0, 0
flag1, flag2 = False, False
for i in range(k):
if a[i] // n > 2:
flag1 = True
if a[i] //... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | try:
for _ in range(int(input())):
n, m, k = map(int, input().split(" "))
l = list(map(int, input().split(" ")))
l.sort()
mul = m * n
mn = 10000000
f = 0
mx = 0
g = 0
for i in range(k):
if l[i] // n > 1 and f == 0:
m... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUN... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | t = int(input())
def solve(n, m):
res = 0
for i in piles:
u = i // n
if u > 1:
res += u
if res >= m:
if res - u == m - 1:
return piles[0] // n > 2
return True
return False
for _ in range(t):
n, m, k = map(int, input().split(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR IF VAR VAR IF BIN_OP VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL ... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | for _ in range(int(input())):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
cols, rows = [], []
for count in a:
if count // n >= 2:
cols.append(count // n)
if count // m >= 2:
rows.append(count // m)
ans = "No"
if m <= sum(cols):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BI... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def resi():
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
mDK = [0] * k
for i in range(k):
mDK[i] = a[i] // n
if mDK[i] == 1:
mDK[i] = 0
mDV = [0] * k
for i in range(k):
mDV[i] = a[i] // m
if mDV[i] == 1:
mDV[i] = ... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CA... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def solve(n, m):
s = 0
cut = False
for i in a:
t = i // n
if t >= 2:
s += t
if t > 2 and not cut:
cut = True
return s >= m and (m % 2 == 0 or cut)
for _ in range(int(input())):
n, m, k = map(int, input().split())
a = list(map(int, input()... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR IF VAR NUMBER VAR ASSIGN VAR NUMBER RETURN VAR VAR BIN_OP VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | t = int(input())
for _ in range(t):
n, m, k = map(int, input().split())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
i = 0
ans = 0
flag = False
while i < k:
x = l[i] // m
if x > 2:
flag = True
if x >= 2:
ans += x
i += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | for _ in range(int(input())):
n, m, k = list(map(int, input().split()))
color = list(map(int, input().split()))
row_cost = m
col_cost = n
tot = 0
flag = False
for i in color:
if i // row_cost > 2:
flag = True
if i // row_cost >= 2:
tot += i // row_cost... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF BIN_... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | t = int(input())
while t > 0:
t -= 1
n, m, k = map(int, input().split())
numH, numV = 0, 0
ntH, ntV = False, False
a = list(map(int, input().split()))
for i in a:
if int(i / n) > 1:
numH += int(i / n)
if int(i / n) > 2:
ntH = True
if int(i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR FUNC_CALL VA... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def possible(xs, m, n):
ys = [(x // m) for x in xs]
ys = [y for y in ys if y > 1]
if len(ys) == 0 or sum(ys) < n:
return False
return max(ys) >= 3 or n % 2 == 0
def solve():
n, m, k = map(int, input().split())
xs = [int(x) for x in input().split()]
if possible(xs, m, n) or possible... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
valid = 0
an = a[:]
ans = 0
for i in range(len(an)):
an[i] //= n
if an[i] >= 2 and ans + 2 <= m:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_C... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | t = int(input())
while t > 0:
t -= 1
n, m, k = [int(x) for x in input().split(" ")]
quantities = [int(x) for x in input().split(" ")]
row_count = 0
flag = False
for num in quantities:
if num // m >= 2:
row_count += num // m
if num // m >= 3:
flag = True
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER ... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def solve(m, n, arr):
res = 0
flag = 0
for i in arr:
if i // n <= 1:
continue
res += i // n
if i // n >= 3:
flag = 1
if res >= m and (m % 2 == 1 and flag or m % 2 == 0):
return 1
else:
return 0
t = int(input())
while t:
n, m, k = ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR FUNC_CALL VAR V... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | t = int(input())
for _ in range(t):
n, m, k = map(int, input().split())
arr = list(map(int, input().split()))
arr1 = []
arr2 = []
for i in arr:
if i // n > 1:
arr1.append(i // n)
if i // m > 1:
arr2.append(i // m)
arr1.sort(reverse=True)
arr2.sort(reve... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def iin():
return list(map(int, input().split(" ")))
def solve(n, m, p):
pigments = p.copy()
for pigment in pigments:
cols = pigment // n
if cols >= m:
return "Yes"
elif cols > 1 and m > 3:
m = max(2, m - cols)
return "No"
[t] = iin()
for _ in range(t)... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR RETURN STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR RETURN STRING ASSIGN LIST VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR AS... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | t = int(input())
for x in range(t):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
cols = 0
for num in a:
if num // n > 1:
cols += num // n
ans = "No"
if m % 2 == 0 and cols >= m:
ans = "Yes"
elif cols >= m:
for num in a:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR STRING IF BIN_OP VAR NUMBER NUMBER VAR VAR... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | t = int(input())
for _ in range(t):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
ok = False
for _ in range(2):
n, m = m, n
s = 0
o = 0
for i in range(k):
x = a[i] // n
if x > 1:
s += x
if x > 2... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def ss(t, l):
if sum(l) < t:
return False
x = sum(l)
twos = 0
odd = 0
even = 0
for i in l:
if i == 2:
twos += 1
elif i % 2 == 0:
even += 1
else:
odd += 1
if t % 2 == 0:
return True
xxx = 0
for i in l:
... | FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER IF VA... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def solve(n, m):
b = [(x // n) for x in a]
b = list(filter(lambda x: x >= 2, b))
return sum(b) >= m and (m % 2 == 0 or any(x >= 3 for x in b))
for _ in range(int(input())):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
print("Yes" if solve(n, m) or solve(m, n) else "N... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | for i in range(int(input())):
n, m, k = [int(x) for x in input().split()]
colors = [int(x) for x in input().split()]
col, row = [], []
for i in range(k):
cell = colors[i]
if cell // n >= 2:
col.append(cell // n)
else:
col.append(0)
if cell // m >= ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def solve(n, m, k, K):
Q = [x for x in K]
P = [(0) for x in K]
idx = 0
z = n
for i in range(k):
if Q[i] >= 2 * m and z >= 2:
Q[i] -= 2 * m
P[i] = 2
z -= 2
if z == 0:
return True
for i in range(k):
if P[i] > 0:
z -= Q[i] ... | FUNC_DEF ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP NUMBER VAR VAR NUMBER VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR BIN_OP VAR VAR VAR IF VAR NU... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def column(a, n, m, k):
sumi = 0
if n % 2:
if a[-1] >= 3 * m:
a[-1] -= 3 * m
n -= 3
sumi += a[-1] // m
a[-1] = 0
else:
return -1
r = 2 * m
for i in range(k):
if a[i] >= r:
sumi += a[i] // m
if sumi >= n:
... | FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER IF VAR NUMBER BIN_OP NUMBER VAR VAR NUMBER BIN_OP NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASS... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | from sys import stdin, stdout
def get_ints():
return map(int, stdin.readline().split())
def PRINT(s):
stdout.write(s + "\n")
def f(a, b, arr):
evens = []
odds = []
s = 0
t = False
for v in arr:
x = v // a
if x >= 2:
s += x
if x % 2 == 0:
... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP VAR STRING FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VA... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | for i in range(int(input())):
n, m, k = map(int, input().split())
m1 = []
n1 = []
m01 = 0
n01 = 0
for j in map(int, input().split()):
m1 += [j // n]
n1 += [j // m]
if j // n > 1:
m01 += j // n
if j // m > 1:
n01 += j // m
maxm1 = max(m1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST BIN_OP VAR VAR VAR LIST BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def test(n, m, a):
x = [(i // m) for i in a]
enough = sum(i for i in x if i >= 2) >= n
if n % 2 == 1:
enough = enough and any(i >= 3 for i in x)
return enough
T = int(input())
for cc in range(T):
n, m, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]
ans ... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN V... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def canColor(n, m, colors):
colors.sort(reverse=True)
n, m = _n, _m = sorted([n, m])
cando = 0
mfirst = colors[0] // n
nfirst = colors[0] // m
for c in colors:
if c // n > 1:
if _m == 1:
if mfirst > 2:
_m = 0
else:
... | FUNC_DEF EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FOR VAR VAR IF BIN_OP VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER IF VAR NUMBER IF VAR NUM... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | R = lambda: map(int, input().split())
G = range
(t,) = R()
def f(n, m):
b = [(v // n) for v in a if v >= 2 * n]
return not (m & 1 and all(v == 2 for v in b)) and sum(b) >= m
for _ in G(t):
n, m, k = R()
a = [*R()]
print(["No", "Yes"][f(n, m) or f(m, n)]) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CA... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, m, k = map(int, input().split())
(*a,) = map(int, input().split())
b = []
c = []
bodd = 0
codd = 0
for e in a:
bi = e // n
bi = bi * (bi >= 2)
ci = e // m
ci = ci * (ci >= 2)
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BI... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def solve(n, m, arr):
p = m
curr = 0
flag = False
for i in arr:
k = i // p
if k > 1:
curr += k
if k > 2:
flag = True
if n % 2 == 0:
if curr >= n:
return True
else:
return False
elif curr >= n and flag:
... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER IF VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VA... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def rr(a, n, m):
if m % 2 == 1:
count = 0
if a[0] >= 3 * n:
pass
else:
return False
for i in a:
if i // n >= 2:
count += i // n
if count >= m:
return True
else:
return False
else:
... | FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER BIN_OP NUMBER VAR RETURN NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR FUN... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | def solve(a, n, m):
b = []
flag = False
for i in a:
curr = i // n
if curr >= 3:
flag = True
if curr >= 2:
b.append(curr)
if m % 2 == 1:
if not flag:
return False
return sum(b) >= m
for t in range(int(input())):
n, m, k = map(i... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR RETURN NUMBER RETURN FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_... |
A picture can be represented as an $n\times m$ grid ($n$ rows and $m$ columns) so that each of the $n \cdot m$ cells is colored with one color. You have $k$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $a_i$ cells with the $i$-th pigment.
A picture is co... | import sys
def solve1(n, m, a):
s = 0
ok = False
for i in a:
v = i // m
if v >= 2:
s += v
if v > 2:
ok = True
if ok:
return s >= n
else:
return s >= n and n % 2 == 0
def solve():
inp = sys.stdin.readline
n, m, k = ma... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR RETURN VAR VAR RETURN VAR VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | T = int(input())
for t in range(T):
N = int(input()) + 2
s = "1" + input() + "1"
A = [-10000000000] + [int(x) for x in input().split()] + [10000000000]
ss = 0
mm = 0
ans = 0
for i in range(1, N):
ss += A[i] - A[i - 1]
mm = max(mm, A[i] - A[i - 1])
if s[i] == "1":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
for z in range(t):
n = int(input())
s = input()
d, v = [], []
d = list(map(int, input().split()))
for i in range(len(s)):
if s[i] == "1":
v.append(i)
if n == 1:
print(0)
continue
a, ans = len(v), 0
for i in range(v[0] - 1, -1, -1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
while t > 0:
n = int(input())
a = input()
y = input().split()
d = []
for i in range(n):
d.append(int(y[i]))
s = 0
i = 0
while a[i] == "0":
s = s + (d[i + 1] - d[i])
i = i + 1
loc1 = i
i = n - 1
while a[i] == "0":
s = s + (d[i] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR STRING ASSIGN VAR BIN_OP VAR BIN... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | MAX = 1 + 10**9
T = int(input())
for t in range(T):
N = int(input())
E = input()
X = list(map(int, input().strip().split()))
ans = 0
if E[0] == "0":
E = E.lstrip("0")
i = N - len(E)
ans = ans + X[i] - X[0]
X = X[i:]
N -= i
if E[-1] == "0":
E = E.rs... | ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR STRI... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | def test(n, y, x):
v = x[-1] - x[0]
w = False
record = 0
for i in range(n):
if i:
delta = x[i] - x[i - 1]
if delta > record:
record = delta
if y[i]:
if w:
v -= record
else:
w = True
... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR IF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CAL... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
for i in range(t):
n = int(input())
elec = input()
coord = list(map(int, input().split()))
sum1 = 0
sum = 0
temp1 = elec.index("1")
for j in range(0, temp1):
x = coord[j + 1] - coord[j]
sum1 += x
max = 0
for j in range(temp1, n - 1):
if elec[j... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR B... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | T = int(input())
while T > 0:
N = int(input())
mystr = input()
user_input = input().split()
ind = 1
t = 1
firstNum = mystr[0]
mysum = 0
if firstNum == "0":
while mystr[t] != "1":
t += 1
mysum = int(user_input[t]) - int(user_input[0])
while t < N:
m... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR STRING WHILE VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUN... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
while t > 0:
n = int(input())
s = input()
x_coords = [int(x) for x in input().split()]
min_len = 0
left_index = s.find("1")
for i in range(left_index):
min_len += x_coords[i + 1] - x_coords[i]
right_index = s.rfind("1")
for i in range(right_index + 1, n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR S... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | T = int(input())
while T > 0:
T -= 1
N = int(input())
light = [int(x) for x in input()]
x = [int(x) for x in input().split()]
i = 0
while light[i] != 1:
i += 1
cost = x[i] - x[0]
prev = i
i += 1
while i < N:
Flag = True
while light[i] != 1:
if ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMB... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
for _ in range(t):
n = int(input())
e = [(True if i == "1" else False) for i in input().strip()]
X = [int(i) for i in input().split()]
ans = X[-1] - X[0]
p, q = None, None
for i in range(n):
if e[i]:
p = q
q = i
m = 0
if p ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR STRING NUMBER NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NONE NONE FOR VAR FUNC_CALL VAR VAR IF V... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | import sys
f = sys.stdin
big = 10**15
def solve(ee, x):
ret = 0
x0 = 0
for i in range(len(ee)):
if ee[i] == 0 or x0 > 0:
dx = x[i] - x[i - 1] if i > 0 else big
x0 = max(x0, dx)
ret += dx
if ee[i] == 1:
ret -= x0
x0 = 0
return... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER RETU... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | import sys
T = int(sys.stdin.readline())
for i in range(T):
N = int(sys.stdin.readline())
A = sys.stdin.readline()
B = list(map(int, sys.stdin.readline().split(" ")))
Node = []
for j in range(N):
Node.append([int(A[j]), B[j]])
wire = 0
start = 0
for j in range(len(Node)):
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUM... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
for i in range(t):
n = int(input())
s = input()
x = list(map(int, input().split()))
p = []
cum = 0
l = 0
for j in range(n):
if s[j] == "1":
p += [j]
l += 1
j = 0
k = 0
if p[k] == j:
k += 1
else:
while j < p[k]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR LIST VAR VAR NUMBER ASSI... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | def func1():
n = int(input())
vs = list(input())
ds = list(map(int, input().split()))
wireLength = 0
l = []
found1 = False
if vs[0] == "1":
found1 = True
for i in range(1, n):
if vs[i] == "0":
l.append(ds[i] - ds[i - 1])
if i == n - 1:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_O... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | for _ in range(int(input())):
n = int(input())
s = list(input())
coord = list(map(int, input().split()))
p = 0
i = 0
h = []
for i in range(0, n):
if s[i] == "1":
h.append(i)
if h[0] != 0:
p = p + coord[h[0]] - coord[0]
if h[len(h) - 1] != n - 1:
p ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
while t != 0:
t -= 1
n = int(input())
s = input()
l = list(map(int, input().split()))
l1 = []
i = 1
while i < n:
l1 += [l[i] - l[i - 1]]
i += 1
k1 = s.index("1")
c = s.count("1")
ans = l[n - 1] - l[0]
while c > 1:
k2 = s.index("1", k1 ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR VAR LIST BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_C... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | T = int(input())
for t in range(T):
n = int(input())
a = [int(v) for v in input()]
x = [int(v) for v in input().split()]
f = s = 0
while f < n - 1:
m = 0
f1 = n - 1
for i in range(f + 1, n):
m = max(m, x[i] - x[i - 1])
if a[i]:
f1 = i
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CA... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | for t in range(int(input())):
n = int(input())
cin = [int(i) for i in list(input())]
pos = [int(i) for i in input().split()]
dist = [(pos[i + 1] - pos[i]) for i in range(n - 1)]
charged = [cin.index(1)]
while True:
try:
charged.append(cin.index(1, charged[-1] + 1))
ex... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | for _ in range(int(input())):
n = int(input())
s = input()
arr = [int(i) for i in input().split()]
ans = 0
i = 0
if s[0] == "0":
while i < len(s) - 1 and s[i] != "1":
ans += arr[i + 1] - arr[i]
i += 1
if i == len(s) - 1:
print(ans)
continue
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR STRING VAR BIN_OP VAR BIN_OP VAR NUMBER VA... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
ans = []
for i in range(t):
n = int(input())
marker = input()
a = list(map(int, input().split()))
sum = 0
count = 0
if marker[0] == "0":
count += 1
while marker[count] == "0":
count += 1
sum += a[count] - a[0]
count += 1
max = 0
h1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER WHILE VAR VAR STRING VAR NUMBER VAR BIN_... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | from sys import stdin
def calcWire(L, D):
i = 0
wire = 0
while i < len(L):
if L[i] == 0:
leftPole = i
while i < len(L) and L[i] == 0:
i += 1
rightPole = i
if leftPole == 0:
wire += D[rightPole] - D[0]
elif ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN ... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
ans = []
for i in range(t):
n = int(input())
s = input()
l = list(map(int, input().split()))
c = 0
t1 = 0
t2 = 0
while c < n:
if s[c] == "1":
j = c + 1
m = -float("inf")
while j < n and s[j] == "0":
t2 += l[j] - l[j... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR ... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
for _ in range(0, t):
n = int(input())
e = input()
v = list(map(int, input().split()))
sum = 0
first = 0
last = 0
i = 0
flag = False
for i in range(0, n):
if e[i] == "1":
if flag == False:
first = i
flag = True
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | T = int(input())
answers = []
for i in range(T):
N = int(input())
electricity = input()
coordinates = list(map(int, input().split()))
oneIndexes = []
for j in range(0, len(electricity)):
if electricity[j] == "1":
oneIndexes.append(j)
oneCount = len(oneIndexes)
if oneCount... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSI... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | T = int(input())
while T:
N = int(input())
valid = input()
arr = input().split(" ")
e = []
for i in range(0, len(arr)):
arr[i] = int(arr[i])
if valid[i] == "1":
e.append(i)
ans = arr[e[0]] - arr[0]
ans = ans + arr[N - 1] - arr[e[len(e) - 1]]
for i in range(0, ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VA... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | for _ in range(int(input())):
n = int(input())
s = input()
arr = list(map(int, input().split()))
ans = start = 0
end = n - 1
while s[end] == "0":
end -= 1
while s[start] == "0":
start += 1
i = start
while i < end:
j = i + 1
while j <= end and s[j] == "... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR NUMBER WHILE VAR VAR STRING VAR NUMBER ASSIGN VAR VAR WHILE VAR... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | INT_MAX = 10**18
def get_ans(start, end, maps):
ans = INT_MAX
for i in range(start, end):
temp = maps[end] - maps[i + 1] + maps[i] - maps[start]
if temp < ans:
ans = temp
return ans
t = int(input())
while t:
n = int(input())
status = input()
maps = [int(loc) for l... | ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
for z in range(t):
n = int(input().strip())
s = input().strip()
x = [int(i) for i in input().strip().split()]
lit = [int(s[i]) for i in range(n)]
lm, rm = -1, -1
for i in range(n):
if s[i] == "1":
lm = i
break
for i in range(n - 1, -1, -1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VA... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
ans = []
for i in range(t):
d = []
light = []
xcor = []
n = int(input())
ele = input()
xcor.extend(map(int, input().split()))
l = 0
for j in range(n):
if j != n - 1:
d.append(xcor[j + 1] - xcor[j])
if ele[j] == "1":
light.append(j)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMB... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | import sys
t = int(sys.stdin.readline())
for _ in range(t):
N = int(sys.stdin.readline())
B = [True] + [bool(int(x)) for x in sys.stdin.readline().strip()] + [True]
X = [-(10**18)] + [int(x) for x in sys.stdin.readline().split()] + [10**18]
s = 0
mx = -1
o = 0
for i in range(1, N + 2):
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBER ASSIGN VAR BIN_OP BIN_OP LIST BIN_OP NUMBER NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIS... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | T = int(input())
for t in range(T):
n = int(input())
s = input()
x = [int(xi) for xi in input().split(" ")]
res = 0
first = False
i = 0
while i < n:
if not first:
if s[i] == "1":
first = True
else:
res += x[i + 1] - x[i]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR IF VAR VAR STRING ASSIGN VAR NUMBER VAR BIN_OP VAR B... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | def minDist(start, end, a):
temp = 0
for i in range(start, end):
temp = max(temp, a[i + 1] - a[i])
return a[end] - a[start] - temp
t = int(input().strip())
for __ in range(t):
n = int(input().strip())
s = input().strip()
a = [int(i) for i in input().strip().split()]
l = []
for ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL V... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | for test in range(int(input())):
n = int(input())
s = str(input())
ip = list(map(int, input().split()))
a = []
for i in range(n):
if s[i] == "1":
a.append(i)
if len(a) == 1:
ans = ip[-1] - ip[0]
else:
ans = ip[a[0]] - ip[0] + ip[-1] - ip[a[-1]]
for... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
for i in range(t):
n = int(input())
s = input()
x = list(map(int, input().split()))
ans = 0
start = 0
end = n - 1
while s[start] == "0":
start += 1
while s[end] == "0":
end -= 1
ans += x[start] - x[0]
ans += x[n - 1] - x[end]
while start < end... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR NUMBER WHILE VAR VAR STRING VAR NU... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
x = [int(i) for i in input().split()]
y = 0
z = 0
l = 0
k = 0
d = {}
for i in range(len(s)):
if s[i] == "1":
d[y] = i
y = y + 1
ln = y
if d[0] != 0:
i = d[0]
l = x... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | t = int(input())
ret = []
while t > 0:
t -= 1
n = int(input())
s = input()
arr = list(map(int, input().split(" ")))
l = []
f = True
for i in range(len(arr)):
if s[i] == "1":
if f:
fr = i
f = False
l.append(i)
r = []
for ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR ... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | T = int(input())
for tt in range(T):
x, N = 0, int(input())
S = input() + "$"
A = [int(y) for y in input().split(" ")]
cost = 0
while x < N:
if S[x] == "0":
start, end = x, x
while S[end] == "0":
end += 1
if start == 0:
cost... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR VAR WHILE VAR VAR STRING VAR NUMB... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | test_cases = int(input())
for i in range(test_cases):
n = int(input())
vil = input()
dis = input()
dist = dis.split()
length, ind_zero = 0, 0
if vil[0] == "0":
zero = True
else:
zero = False
for j in range(1, n):
if vil[j] == "1":
if zero == True:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF V... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | for _ in range(int(input())):
n = int(input())
s = input()
a = [int(temp) for temp in input().strip().split(" ")]
f = 0
l = 0
sm = 0
for b in range(len(s)):
if s[b] == "1":
f = l = b
sm += a[f] - a[0]
break
for i in range(f + 1, len(s)):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR V... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | tests = int(input())
for _ in range(tests):
n = int(input())
s = input()
d = list(map(int, input().split()))
mdiff = -1
r, l, ans = int(), 0, 0
if s[0] == "0":
while s[l] == "0":
l += 1
ans += d[l] - d[0]
r = n - 1
if s[n - 1] == "0":
r = n - 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER STRING WHILE VAR VAR STRING VAR NUMBER VAR BI... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | for t in range(int(input())):
N = int(input())
s = input()
elec = list(map(int, list(s)))
villages = list(map(int, input().split()))
power = [i for i, v in enumerate(elec) if v == 1]
ans = 0
if len(power) == 1:
idx = elec.index(1)
if idx == 0 or idx == N - 1:
ans ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_... |
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | for t in range(int(input())):
n = int(input())
elec = list(input().strip())
elec += ["0"]
city = i = 0
x = [int(x) for x in input().split()]
city = elec.count("1") - 1
length = x[n - 1] - x[0]
while elec[i] == "0":
i += 1
while city != 0:
mx = 0
i += 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR LIST STRING ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER V... |
Problem Statement
It is 2042 and we are surrounded by cyborgs everywhere. Geneo is one such cyborg with a human body and an electronic brain. To monitor skills and health of Geneo he is posed with questions everyday. On one fine day Geneo was asked the following question.
You are given a string S of size N containing ... | def gcd(a, b):
while b:
a, b = b, a % b
return a
def sol():
charcount, k = map(int, input().split())
intcount, sum1 = 0, 0
s = input()
for a in s:
if (ord(a) - 96) / k > 2:
intcount += 1
charcount -= 1
sum1 += ord(a) - 96
if sum1 % k == 0... | FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR... |
Problem Statement
It is 2042 and we are surrounded by cyborgs everywhere. Geneo is one such cyborg with a human body and an electronic brain. To monitor skills and health of Geneo he is posed with questions everyday. On one fine day Geneo was asked the following question.
You are given a string S of size N containing ... | from sys import setrecursionlimit as limits
limits(10**5)
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
t = int(input())
while t > 0:
n, k = [int(x) for x in input().split()]
string = [x for x in input().strip()]
string.sort(reverse=True)
m, s, nums, letters, sumNumbers, w... | EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR V... |
Problem Statement
It is 2042 and we are surrounded by cyborgs everywhere. Geneo is one such cyborg with a human body and an electronic brain. To monitor skills and health of Geneo he is posed with questions everyday. On one fine day Geneo was asked the following question.
You are given a string S of size N containing ... | t = int(input())
for it in range(t):
n, k = map(int, input().split())
clst = list(input())
clst.sort()
num = 0
den = k
pure_int = n
index = n - 1
while index >= 0 and (ord(clst[index]) - 96) / den > 2:
num += ord(clst[index]) - 96
pure_int -= 2
index -= 1
num ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR... |
Problem Statement
It is 2042 and we are surrounded by cyborgs everywhere. Geneo is one such cyborg with a human body and an electronic brain. To monitor skills and health of Geneo he is posed with questions everyday. On one fine day Geneo was asked the following question.
You are given a string S of size N containing ... | def gcd(a, b):
while b:
a, b = b, a % b
return a
t = int(input())
for j in range(t):
n, k = map(int, input().split(" ", 2)[:2])
s = input()
sum1 = 0
icnt = 0
ccnt = n
for a in s:
if (ord(a) - 96) / k > 2:
icnt += 1
ccnt -= 1
sum1 += o... | FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR VAR IF BIN_OP BIN_OP FUNC_CAL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.