description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | import sys
rline = lambda: sys.stdin.readline()
def secondScore(alst, i, num):
if i == 1:
return num
return secondScore(alst, i - 1, num - alst[i - 1])
def annSet(score, alst, i):
ans = {score}
x = score
y = score
for j in range(i - 1, 0, -1):
x -= alst[j]
ans.add(x)... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | I = lambda: list(map(int, input().split()))
k, n = I()
a, b = list(I()), list(I())
s = 0
for i in range(k):
s += a[i]
a[i] = s
ans = [set() for x in range(n)]
for i, y in enumerate(b):
ans[i] = [(y - x) for x in a]
ans2 = set(ans[0])
for x in ans:
ans2.intersection_update(x)
print(len(ans2)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR A... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | def read():
return [int(x) for x in input().split()]
k, n = read()
a = read()
b = read()
c = []
for x in a:
c.append((c[-1] if c else 0) + x)
c = set(c)
z = set()
s = 0
for x in a:
s += x
i = b[0] - s
for y in b[1:]:
if y - i not in c:
break
else:
z.add(i)
print(len... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN ... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | import sys
K, N = [int(x) for x in sys.stdin.readline().split()]
a_s = [int(x) for x in sys.stdin.readline().split()]
b_s = [int(x) for x in sys.stdin.readline().split()]
poss = set([])
start = 1
for b in b_s:
locls = set([])
for a in a_s:
b -= a
locls.add(b)
if start == 1:
poss = l... | IMPORT ASSIGN 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR LIST FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VA... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | import sys
def solve():
k, n = list(map(int, sys.stdin.readline().split()))
mks = list(map(int, sys.stdin.readline().split()))
pts = list(map(int, sys.stdin.readline().split()))
for i in range(1, k):
mks[i] = mks[i - 1] + mks[i]
mks = sorted(mks)
pts = sorted(pts)
vals = set()
... | IMPORT FUNC_DEF ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUN... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | o = lambda: [int(f) for f in input().split()]
k, n = o()
a = o()
b = o()
s = []
for x in b:
t = x
t1 = set()
for y in a:
t -= y
t1.add(t)
s += [t1]
print(len(set.intersection(*s))) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR LIST VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | def list_input():
return list(map(int, input().split()))
def map_input():
return map(int, input().split())
def map_string():
return input().split()
n, k = map_input()
a = list_input()
b = list_input()
pos = set()
pref = []
cur = 0
for i in a:
cur += i
pref.append(cur)
for j in pref:
pos.ad... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR ... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | k, n = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
dic = dict()
for i in B:
if i not in dic:
dic[i] = 1
pref = [0] * len(A)
pref[0] = A[0]
for i in range(1, k):
pref[i] = A[i] + pref[i - 1]
ans = set()
for i in range(k):
x = B[0] - pr... | ASSIGN 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBE... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | k, n = list(map(int, input().split()))
j = list(map(int, input().split()))
b = list(map(int, input().split()))
b_set = set(b)
my_sum = [(0) for i in range(k)]
my_sum[0] = j[0]
for i in range(1, k):
my_sum[i] = my_sum[i - 1] + j[i]
pos_val = set()
for score in my_sum:
pos_val.add(b[0] - score)
ans = 0
for start_... | ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | k, n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = []
ans = 0
test = set()
for i in a:
c.append(i if c == [] else c[-1] + i)
def howMany(a1):
nonlocal ans
for i in b:
if not i in a1:
return
if a1[0] in test:
... | ASSIGN 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR LIST VAR BIN_OP VAR NUMBER VAR FUNC_DEF FOR VAR VAR... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | k, n = (int(i) for i in input().split())
a = []
prev = 0
for i in input().split():
prev = prev + int(i)
a.append(prev)
b = [int(i) for i in input().split()]
kands = set()
for i in a:
kands.add(b[0] - i)
b = set(b)
cnt = 0
for i in kands:
cur = set()
for j in a:
cur.add(i + j)
if b <= cur... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | import sys
inp = [int(x) for x in sys.stdin.read().split()]
ii = 0
k = inp[ii]
ii += 1
n = inp[ii]
ii += 1
marks = inp[ii : ii + k]
ii += k
scores = inp[ii : ii + n]
pre = [0]
for x in marks:
pre.append(pre[-1] + x)
ans = set()
for b in pre[1:]:
ans.add(scores[0] - b)
for a in scores[1:]:
scset = set()
... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR F... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | def read():
return [int(x) for x in input().split()]
k, n = read()
a = read()
b = read()
sum = set()
tmp = [0]
for e in a:
tmp.append(tmp[-1] + e)
sum.add(tmp[-1])
ans = set()
for e in tmp[1:]:
init = b[0] - e
for bb in b[1:]:
if bb - init not in sum:
break
else:
an... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR NUMBER ASSI... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | mark_num, remember_num = [int(i) for i in input().split()]
marks = [int(i) for i in input().split()]
after_scores = {int(i) for i in input().split()}
assert mark_num == len(marks) and len(after_scores) == remember_num
template = []
score = 0
for m in marks:
score += m
template.append(score)
poss_starts = set()
... | ASSIGN 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
all_maybe_all_b = []
for mast_b in b:
all_maybe_for_b_i = set()
for slog in a:
mast_b -= slog
all_maybe_for_b_i.add(mast_b)
all_maybe_all_b += [all_maybe_for_b_i]
pack_ans_intersect... | ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR LIST VAR ASSIGN... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | import sys
input = sys.stdin.readline
n, k = map(int, input().split())
A = list(map(int, input().split()))
B = sorted(list(set(list(map(int, input().split())))))
for i in range(1, len(B)):
B[i] -= B[0]
B[0] = 0
cur = 0
A_s = set()
for x in A:
cur += x
A_s.add(cur)
A = sorted(list(A_s))
ans = 0
for i, delta... | IMPORT ASSIGN VAR VAR ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR NUMBER... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | import sys
k, n = [int(i) for i in sys.stdin.readline().split()]
rate = [int(i) for i in sys.stdin.readline().split()]
rem = dict()
for i in sys.stdin.readline().split():
v = int(i)
if v in rem:
rem[v] += 1
else:
rem[v] = 1
for i in range(len(rate)):
if i > 0:
rate[i] += rate[i ... | IMPORT ASSIGN 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 FUNC_CALL VAR FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | n, k = [int(x) for x in input().split()]
marks = [int(x) for x in input().split()]
scores = set([int(x) for x in input().split()])
possible = set()
for i in [(min(scores) - sum(marks[: i + 1])) for i in range(len(marks))]:
j = i
values = set()
for mark in marks:
j += mark
values.add(j)
i... | ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR A... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | from sys import stdin
def main():
from sys import stdin
k, n = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
res = set()
for i in range(k):
our = set()
curr = b[0]
for j in range(i, -1, -1):... | FUNC_DEF ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR ... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | from sys import stdin
input = lambda: stdin.readline().strip()
k, n = map(int, input().split())
a = [*map(int, input().split())]
b = sorted([*map(int, input().split())])
c = [(0) for i in range(k)]
c[0] = a[0]
for i in range(1, k):
c[i] = c[i - 1] + a[i]
c.sort()
if n == 1:
print(len(set(c)))
exit()
start_... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | k, n = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = set()
sums = [0]
for i in range(k):
sums.append(sums[-1] + a[i])
sums.pop(0)
for i in range(k):
x.add(b[0] - sums[i])
count = 0
for s in x:
points = []
for i in range(k):
points.append(s ... | ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | n, k = map(int, input().split())
jury = []
remember = []
ans = []
for i in list(map(int, input().split())):
jury.append(i)
for i in list(map(int, input().split())):
remember.append(i)
juryPrefix = len(jury) * [jury[0]]
for i in range(1, len(jury)):
juryPrefix[i] = jury[i] + juryPrefix[i - 1]
for i in range(... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR LIST ... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | k, n = map(int, input().split())
a = []
b = []
temp = input().split()
s = 0
for i in range(k):
s += int(temp[i])
a.append(s)
list.sort(a)
temp = input().split()
for i in range(n):
b.append(int(temp[i]))
list.sort(b)
count = 0
visit = set()
for i in range(k - n + 1):
dif = b[0] - a[0]
if dif not in v... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | n, k = map(int, input().strip().split())
t = input()
a = list(map(int, t.strip().split()))
t = input()
b = list(map(int, t.strip().split()))
sum = []
ans = {}
for i in range(n):
if i == 0:
sum.append(a[0])
else:
sum.append(sum[i - 1] + a[i])
sum.sort()
vis = {}
i = 1
while i < n:
if sum[i] =... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL 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 DICT FOR VAR FUNC_CALL VAR VAR IF VAR NUMB... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | k, n = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
st = set()
zn = b[0]
sums = [a[0]]
for j in range(1, len(a)):
sums.append(sums[-1] + a[j])
for j in sums:
st.add(b[0] - j)
for i in b:
tmp = set()
for j in sums:
tmp.add(i - j)
st = st.in... | ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUN... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | n, k = (int(x) for x in input().split())
n += 1
scores = [0]
for diff in input().split():
scores.append(scores[-1] + int(diff))
idxs = sorted(range(n), key=lambda x: scores[x])
rems = sorted(int(x) for x in input().split())
ans = set()
for base in range(n):
if idxs[base] == 0:
continue
i = 1
for... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | k, n = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
b = [int(x) for x in input().strip().split()]
sb = set(b)
sm = [0] * k
for i in range(k):
sm[i] = sm[i - 1] + a[i]
answers = set()
for i in range(k):
beg = b[0] - sm[i]
t = set([(beg + sm[j]) for j in range(k)])
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL 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 FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR ... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | import sys
fin = sys.stdin
fout = sys.stdout
k, n = list(map(int, fin.readline().split()))
a = list(map(int, fin.readline().split()))
b = list(map(int, fin.readline().split()))
b.sort()
for i in range(1, k):
a[i] += a[i - 1]
a = sorted(set(a))
cnt = 0
set_b = set(b)
for i in range(len(a) - len(b) + 1):
x = b[0... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUM... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | k, n = map(int, input().split())
scores = [int(x) for x in input().split()]
remembered = [int(x) for x in input().split()]
temp = 0
possibility = []
for x in scores:
temp += x
if -1 * temp not in possibility:
possibility.append(-1 * temp)
lol = []
for x in remembered:
temp = []
for y in possibil... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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 NUMBER ASSIGN VAR LIST FOR VAR VAR VAR VAR IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR VAR ASSIG... |
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave a_{i} points.... | R = lambda: map(int, input().split())
k, n = R()
a, b = list(R()), list(R())
c = [a[0]]
for i in range(1, k):
c.append(c[-1] + a[i])
c = set(c)
s, cur = set(), 0
for x in a:
cur += x
new = b[0] - cur
for y in b[1:]:
if y - new not in c:
break
else:
s.add(new)
print(len(s)... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMB... |
There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using movement of instruction pointer (IP) which consists of two parts. Current character pointer (CP); Directi... | n, q = list(map(int, input().split()))
s = input()
for _ in range(q):
l, r = list(map(int, input().split()))
t = list(s[l - 1 : r])
p, d = 0, 1
res = [0] * 10
while 0 <= p < len(t):
if "0" <= t[p] <= "9":
k = int(t[p])
res[k] += 1
if k > 0:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER WHILE NUMB... |
There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using movement of instruction pointer (IP) which consists of two parts. Current character pointer (CP); Directi... | n, Q = map(int, input().strip().split())
s = input()
d = 1
for q in range(Q):
arr = [0] * 10
l, r = map(int, input().strip().split())
su = ""
for i in range(l - 1, r):
su += s[i]
su = list(su)
i = 0
d = 1
ll = 0
while i < len(su) and i >= 0:
if su[i].isdigit():
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN... |
Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating."
The class can be represented as a matrix with n rows and m col... | def get_answer(m, n):
if (m, n) in [(1, 2), (2, 1), (1, 3), (3, 1), (2, 2), (2, 3), (3, 2)]:
return "NO", []
elif n == 1:
mat = [[i] for i in range(2, m + 1, 2)] + [[i] for i in range(1, m + 1, 2)]
return "YES", mat
elif n == 2:
bs = [[2, 3], [7, 6], [4, 1], [8, 5]]
m... | FUNC_DEF IF VAR VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RETURN STRING LIST IF VAR NUMBER ASSIGN VAR BIN_OP LIST VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER LIST VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER RETURN STRING VAR IF VAR NUM... |
Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating."
The class can be represented as a matrix with n rows and m col... | import itertools
import sys
f = sys.stdin
def near(i, n, m):
x = i // m
y = i % m
d = [[0, -1], [0, 1], [-1, 0], [1, 0]]
ns = []
for dx, dy in d:
nx = x + dx
ny = y + dy
if nx >= 0 and nx < n and ny >= 0 and ny < m:
ns.append(nx * m + ny)
return ns
def ch... | IMPORT IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER ASSIGN VAR LIST FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CAL... |
Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating."
The class can be represented as a matrix with n rows and m col... | def transpos(a, n, m):
b = []
for i in range(m):
b.append([a[j][i] for j in range(n)])
return b
def printarr(a):
for i in range(len(a)):
for j in range(len(a[i])):
print(a[i][j], end=" ")
print("")
n, m = [int(i) for i in input().split()]
a = []
for i in range(n):... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL F... |
Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating."
The class can be represented as a matrix with n rows and m col... | n, m = map(int, input().strip().split(" "))
arr = []
cnt = 1
if n * m == 1:
print("YES")
print(1)
elif (
n == 1
and (m == 2 or m == 3)
or n == 2
and (m == 1 or m == 2 or m == 3)
or n == 3
and (m == 1 or m == 2)
):
print("NO")
elif n == 3 and m == 3:
print("YES")
print(6, 1, 8... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STR... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | __author__ = "Think"
word = input()
found = False
for i in range(2, 27):
if word[i] in word[: i - 1]:
place2 = i
place1 = word[: i - 1].index(word[i])
found = True
break
if not found:
print("Impossible")
else:
rows = [[""] * 13, [""] * 13]
start = (place1 + place2 + 1) //... | ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST BIN_OP LIST STRING NUMBER BIN_OP LIST STRING NUMBER ASSIG... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | P = print
S = input()
for i in range(26):
if S.count(chr(i + 65)) == 2:
x = chr(i + 65)
a = S.find(x)
b = S.rfind(x)
s = S[a + 1 : b]
w = q = ""
if s == "":
P("Impossible")
exit()
while len(s) > 1:
t = len(s) // 2 - 1
q += s[t]
w += s[t + 1]
s = s[:t] + s[t + 2 :]
q += s + S[:a][::-1... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR STRING IF VAR STRING EXPR FUNC_CALL VAR ST... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | import sys
s = input()
n = 27
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
pos = [-1] * 26
first = 0
second = 0
for i in range(n):
x = alphabet.index(s[i])
if pos[x] != -1:
second = i
first = pos[x]
break
pos[x] = i
if second - first == 1:
print("Impossible")
sys.exit()
middle = ... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRIN... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
for c in s:
if s.count(c) == 2:
break
i = s.index(c)
j = i + 1 + s[i + 1 :].index(c)
if i + 1 == j:
print("Impossible")
exit(0)
s = s.replace(c, "", 1) * 3
mid = 13 + (i + j) // 2
print(s[mid - 13 : mid])
print(s[mid : mid + 13][::-1]) | ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR STRING NUMBER NUMBER ASSIGN VAR BIN_OP NU... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | def main():
l, d = [], {}
for i, c in enumerate(input()):
if c in d:
u, v = d[c], i
else:
d[c] = i
l.append(c)
if v - u == 1:
print("Impossible")
return
l *= 2
w = (u + v + 1) // 2
print("".join(l[w : w + 13]))
print("".join... | FUNC_DEF ASSIGN VAR VAR LIST DICT FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR VAR... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | def main():
s = input()
flag = False
st = -1
fn = -1
for i in range(27):
for j in range(i + 2, 27):
if s[i] == s[j]:
flag = True
st = i
fn = j
break
if not flag:
print("Impossible")
return
s =... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR ... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
s1 = s
our = dict()
f = ""
for i in s:
our[i] = our.get(i, 0) + 1
if our[i] == 2:
f = i
i1 = s.find(f)
i2 = s.rfind(f)
if abs(i1 - i2) == 1:
print("Impossible")
l = [list()] * 26
l[0] = [1, 24, 25]
l[12] = [11, 13, 14]
l[13] = [11, 12, 14]
l[25] = [0, 1, 24]
for i in range(1, 25):
if... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | def find_duplicate(s):
for i in range(len(s)):
for j in range(i + 1, len(s)):
if s[i] == s[j]:
return i, j, s[i]
def main():
s = input()
l, r, ch = find_duplicate(s)
if r - l == 1:
print("Impossible")
return
ans = [["#" for i in range(13)] for j ... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR STRING VAR FUNC_CALL VAR NUMBER... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
arr = [0] * 26
for i in s:
arr[ord(i) - 65] += 1
l = chr(arr.index(2) + 65)
a = s.find(l)
b = s.rfind(l)
ans = b - a - 1
x = 27 + a + ans // 2
if ans == 0:
print("Impossible")
else:
s = 3 * s
print(s[x - 12 : x + 1])
s1 = s[x + 1 : x + 15][::-1]
s1 = s1[: s1.find(l)] + s1[s1.find(l) ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VA... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | checky = [-1] * 26
rowOne = [None] * 13
rowTwo = [None] * 13
firstr = None
secondr = None
listy = [x for x in input()]
for i, c in enumerate(listy):
if checky[ord(c) - 65] > -1:
secondr = i
firstr = checky[ord(c) - 65]
else:
checky[ord(c) - 65] = i
if firstr + 1 == secondr:
print("im... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR VAR VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | d = {}
di = {}
ct = 0
x = input()
bad = []
for i in x:
if i not in d:
ct += 1
d[i] = ct
di[ct] = i
else:
bad = [ct, d[i]]
if bad[0] == bad[1]:
print("Impossible")
quit()
def gen(x):
bot = []
for i in range(x + 13, x, -1):
bot.append(i)
top = []
f... | ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR N... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input().strip()
length = 27
d = {}
firsti, secondi = -1, -1
for i in range(length):
if s[i] in d:
firsti = d[s[i]]
secondi = i
break
d[s[i]] = i
if secondi - firsti > 1:
table = [[0] * 13, [0] * 13]
blen = secondi - firsti
midindx = 13 - (blen // 2 + blen % 2)
for i i... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR LIST BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR A... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | def lanjut(last):
if last[0] == 1:
if last[1] == 0:
last[0] = 0
else:
last[1] -= 1
elif last[1] == 12:
last[0] = 1
else:
last[1] += 1
hasil = []
hasil.append(list(13 * "1"))
hasil.append(list(13 * "1"))
s = input()
pos1 = -1
pos2 = -1
for i in range(... | FUNC_DEF IF VAR NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER VAR NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NU... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | l, d = [], {}
for i, c in enumerate(input()):
if c in d:
u, v = (d[c] + i + 1) // 2, i
else:
l.append(c)
d[c] = i
s = "".join(l * 2)
print(s[u : u + 13] + "\n" + s[u + 25 : u + 12 : -1] if u < v else "Impossible") | ASSIGN VAR VAR LIST DICT FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR N... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input().strip()
pos = [[] for i in range(26)]
for i in range(len(s)):
pos[ord(s[i]) - ord("A")].append(i)
p = -1
for i in range(26):
if pos[i][-1] - pos[i][0] > 1:
p = i
break
else:
print("Impossible")
exit(0)
a = pos[p][0]
b = pos[p][-1]
pos[p] = pos[p][1:-1]
res = ["", ""]
inner = ... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR STR... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
gx = None
for i in range(26):
x = chr(ord("A") + i)
if s.count(x) == 2:
gx = x
x = gx
sz = s.rindex(x) - s.index(x) - 1
ss = s[s.index(x) + 1 : s.rindex(x)]
if sz == 0:
print("Impossible")
else:
cols = sz // 2
ans = [[None for _ in range(13)], [None for _ in range(13)]]
st = ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR IF... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | import sys
s = input()
possible = False
d = {}
l, r = -1, -1
for i in range(len(s)):
if not s[i] in d:
d[s[i]] = []
d[s[i]].append(i)
for i, v in d.items():
if max(v) - min(v) > 1:
l, r = min(v), max(v)
possible = True
if not possible:
print("Impossible")
sys.exit(0)
g = [["... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUN... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
cnt = dict()
f = 0
for elem in s:
if elem in cnt:
cnt[elem].append(f)
else:
cnt[elem] = [f]
f += 1
t = sorted([(len(cnt[elem]), cnt[elem], elem) for elem in cnt])[-1]
if t[1][1] - t[1][0] == 1:
print("Impossible")
near = [list()] * 26
near[0] = [1, 24, 25]
for i in range(1, 1... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | def solve(s):
for i0 in range(27):
for i1 in range(i0 + 1, 27):
if s[i0] == s[i1]:
break
if s[i0] == s[i1]:
break
assert s[i0] == s[i1]
d = i1 - i0
if d == 1:
return "Impossible"
res = [None] * 26
def set(idx, ch):
nonlocal... | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN STRING ASSIGN VAR BIN_OP LIST NONE NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR FUNC_DEF FOR VAR VAR FUNC_CALL VAR B... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s1 = ["" for j in range(13)]
s2 = ["" for j in range(13)]
s = input()
f = 0
for i in range(27):
if f == 0 and s.count(s[i]) == 2:
f = 1
sp1 = i
elif f == 1 and s[i] == s[sp1]:
sp2 = i
break
if sp2 - sp1 == 1:
print("Impossible")
else:
tp = 12 - (sp2 - sp1 - 1) // 2
fo... | ASSIGN VAR STRING VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL V... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
n = len(s)
left, right = -1, -1
for i in range(n):
j = s[i + 1 :].find(s[i])
if j == -1:
continue
left = i
right = i + 1 + j
break
if left == right - 1:
print("Impossible")
else:
a = left
b = n - right - 1
d = n - 2 - a - b
if a > b:
left, right = n - ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP ... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = str(input())
A = [[] for _ in range(26)]
Al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
i = 0
while i < 27:
A[Al.index(s[i])] += [i]
i += 1
T = [len(A[i]) for i in range(26)]
ok = 0
for i in range(26):
if T[i] > 1:
for k in range(T[i] - 1):
for l in range(k + 1, T[i]):
if abs(A[i]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR NUMBER VAR FUNC_CALL VAR VAR VAR LIST VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL ... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = str(input())
l = list(s)
lr = l[::-1]
for i in range(27):
if s[i] in l[:i]:
c = s[i]
flag = True
for i in range(27):
if s[i] == c and flag:
a1 = i
flag = False
elif s[i] == c and flag == False:
a2 = i
d = a2 - a1 - 1
if d == 0:
print("Impossible")
exit()
s1 = l[: ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_O... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | a = input()
for i in range(1, 27):
if a[i] == a[i - 1]:
print("Impossible")
break
else:
b = [[] for i in range(26)]
for i in range(27):
b["ABCDEFGHIJKLMNOPQRSTUVWXYZ".find(a[i])].append(i)
c = [[" " for i in range(13)] for j in range(2)]
j = 0
for i in range(26):
... | ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUM... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
for i in range(65, 91):
if s.index(chr(i)) != s.rindex(chr(i)):
k = chr(i)
l = s.index(chr(i))
r = s.rindex(chr(i))
if r - l == 1:
print("Impossible")
else:
p = s[:l]
q = s[l + 1 : r]
t = s[r + 1 :]
s1 = ""
s2 = ""
s1 += q[: len(q) // 2][::-1] + k
... | ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN ... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | 3
s = input()
n = len(s)
a, b = 0, 0
d = dict()
for i in range(len(s)):
if s[i] in d:
a = d[s[i]]
b = i
d[s[i]] = i
if a == b - 1:
print("Impossible")
else:
ans = [([" "] * 13) for i in range(2)]
if (b - a) % 2 == 1:
for i in range((b - a) // 2):
ans[0][-(b - a) /... | EXPR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST STRING NUM... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
seen_letters = set()
doubled_letter = None
for l in s:
if l in seen_letters:
doubled_letter = l
break
seen_letters.add(l)
indices = []
for i, l in enumerate(s):
if l == doubled_letter:
indices.append(i)
idx_fst, idx_snd = indices
delta = idx_snd - idx_fst - 1
grid = [["*"... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE FOR VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR STRING VAR FUNC_CALL VAR NUMBER VAR LIST NU... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | def main():
s = input()
poss = {}
lst = [[" "] * 13]
lst.append([" "] * 13)
for i in range(27):
if s[i] in poss:
poss[s[i]].append(i)
D = s[i]
else:
poss[s[i]] = [i]
loop1 = s[poss[D][0] : poss[D][1]]
if len(loop1) <= 1:
print("Impo... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST BIN_OP LIST STRING NUMBER EXPR FUNC_CALL VAR BIN_OP LIST STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR ASSIGN VAR VAR VAR VAR NUMBER VAR VAR NUMBER IF FUNC_CALL VAR... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | import sys
debug = False
def print_debug(*args, **kwargs):
if debug:
print(*args, **kwargs, file=sys.stderr)
s = input()
double = ""
for c in range(ord("A"), ord("Z") + 1):
if s.count(chr(c)) == 2:
double = chr(c)
i1, i2 = [i for i, c in enumerate(s) if c == double]
print_debug(double, i1, ... | IMPORT ASSIGN VAR NUMBER FUNC_DEF IF VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR EXP... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
l, r = -1, -1
for c in "QWERTYUIOPLKJHGFDSAZXCVBNM":
if s.count(c) == 2:
l, r = s.find(c), s.rfind(c)
break
if r - l < 2:
print("Impossible")
else:
res = [(["_"] * 13) for x in range(2)]
i, j = 0, -1 - (r - l - 1) // 2
s = s[l:r] + s[r + 1 :] + s[:l]
for c in s:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR STRING IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST STRING NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP NUMBER BIN_OP BIN_OP BIN_OP VA... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
m = dict()
c = "?"
for i in range(27):
if s[i] in m:
left = m[s[i]]
right = i
c = s[i]
else:
m[s[i]] = i
mid = right - left - 1
if mid == 0:
print("Impossible")
exit()
a = [["?", "?"] for i in range(13)]
if mid % 2 == 1:
a[mid // 2][0] = c
cur = mid //... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | s = input()
a = []
for i in range(27):
if s[i] in a:
letter = s[i]
break
a.append(s[i])
p1 = s.find(letter)
p2 = s.rfind(letter)
if p1 + 1 == p2:
print("Impossible")
else:
str1 = ""
str2 = ""
dist = p2 - p1
if dist % 2:
new_s = s[p2 + 1 :] + s[:p1]
len1 = 13 -... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMB... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | def is_path_in(G, s):
cur_x, cur_y = -1, -1
for y in range(2):
for x in range(13):
if G[y][x] == s[0]:
cur_y, cur_x = y, x
if cur_x == -1:
return False
for c in s[1:]:
for d in range(8):
nx, ny = cur_x + dx[d], cur_y + dy[d]
if ... | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR NUMBER RETURN NUMBER FOR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER... |
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM
NOPQRSTUVWXYZ
We say that two tiles are adjacent ... | l, d = [], {}
for i, c in enumerate(input()):
if c in d:
d1, len = d[c], (i - d[c] - 1) // 2 + 1
d2 = i
else:
l.append(c)
d[c] = i
s = "".join(l * 2)
if d2 - d1 <= 1:
print("Impossible")
else:
print(
s[d1 + 26 - 13 + len : d1 + 26]
+ s[d1 : d1 + len]
+... | ASSIGN VAR VAR LIST DICT FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL STRING BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR F... |
Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one... | n = int(input())
a = []
area = 0
for i in range(n):
a.append([int(i) for i in input().split(" ")])
def get_s(p1, p2, p3):
return ((p2[0] - p1[0]) * (p3[1] - p1[1]) - (p2[1] - p1[1]) * (p3[0] - p1[0])) / 2.0
for i in range(len(a) - 1):
for j in range(i + 1, len(a)):
positive = 0
negative ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER ... |
Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one... | def convex(v, eps=1e-08):
v.sort(key=lambda x: (x.real, x.imag))
v = v[0:1] + sorted(v[1:], key=lambda x: (x - v[0]).imag / abs(x - v[0]))
n = 1
for i in range(2, len(v)):
while n > 1 and ((v[n] - v[n - 1]) * (v[i] - v[n]).conjugate()).imag > -eps:
n -= 1
else:
n ... | FUNC_DEF NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR WHILE VAR NUMBER BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FUNC_CALL BIN_OP VAR VAR ... |
Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one... | import sys
s, n = 0, int(input())
t = list(map(int, sys.stdin.read().split()))
p = [(t[2 * i], t[2 * i + 1]) for i in range(n)]
for x, i in enumerate(p, 1):
for j in p[x:]:
a = b = 0
for k in p:
d = (i[0] - k[0]) * (j[1] - k[1]) - (i[1] - k[1]) * (j[0] - k[0])
a, b = min(d, ... | IMPORT ASSIGN VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP ... |
Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one... | def cross(x1, y1, x2, y2):
return x1 * y2 - x2 * y1
def gao():
n = int(input())
x, y = [], []
for i in range(n):
x1, y1 = input().split(" ")
x.append(int(x1))
y.append(int(y1))
max_area = 0
for i in range(n):
for j in range(i + 1, n):
max_left, max_r... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR ... |
Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one... | n = int(input())
l = []
def cross(x1, y1, x2, y2):
area = x1 * y2 - y1 * x2
return area
for i in range(n):
x, y = list(map(int, input().split()))
l.append([x, y])
max_upper = 0
max_lower = 0
ans = 0
for i in range(n - 1):
for j in range(i + 1, n):
max_upper = 0
max_lower = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_C... |
Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one... | import sys
c, n = 0, int(input())
t = list(map(int, sys.stdin.read().split()))
p = [complex(t[i], t[i + 1]) for i in range(0, 2 * n, 2)]
for x, i in enumerate(p, 1):
for j in p[x:]:
a = b = 0
for k in p:
if k == i or k == j:
continue
d = (i.real - k.real) * (... | IMPORT ASSIGN VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR IF V... |
Since Sonya has just learned the basics of matrices, she decided to play with them a little bit.
Sonya imagined a new type of matrices that she called rhombic matrices. These matrices have exactly one zero, while all other cells have the Manhattan distance to the cell containing the zero. The cells with equal numbers ... | def get(n, m, a, b, t):
freq = [0] * (t + 1)
for i in range(n):
for j in range(m):
val = abs(i - a) + abs(j - b)
freq[val] += 1
return freq
t = int(input())
a = list(map(int, input().split()))
mx = max(a)
f = [0] * (t + 1)
for i in a:
f[i] += 1
b = 1
for i in range(1, m... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASS... |
There are $n$ cities in Berland. Some pairs of cities are connected by roads. All roads are bidirectional. Each road connects two different cities. There is at most one road between a pair of cities. The cities are numbered from $1$ to $n$.
It is known that, from the capital (the city with the number $1$), you can rea... | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(200001)
n, m, k = map(int, input().split())
edge = [[] for _ in range(n)]
di = {}
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
if a > b:
a, b = b, a
di[a, b] = i
edge[a].append(b)
edg... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VA... |
There are $n$ cities in Berland. Some pairs of cities are connected by roads. All roads are bidirectional. Each road connects two different cities. There is at most one road between a pair of cities. The cities are numbered from $1$ to $n$.
It is known that, from the capital (the city with the number $1$), you can rea... | n, m, k = [int(x) for x in input().split()]
E = [[] for _ in range(n)]
for i in range(m):
a, b = [int(x) for x in input().split()]
E[a - 1].append((b - 1, i))
E[b - 1].append((a - 1, i))
Q = [0]
INFTY = n + 1
levels = [INFTY] * n
levels[0] = 0
E_min = [[] for _ in range(n)]
while len(Q) > 0:
city = Q.po... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR L... |
In the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Overall the game has n mandatory quests. To perform each of them, you need to take exactly two companions.
The attitude of each of the companions to the hero is an integer. Initially, the attitude of each o... | n = int(input())
ans = -(10**8), ["Impossible"]
s = []
d = {}
fl = True
a = [list(map(int, input().split())) for i in range(n)]
def job(nom, l, m, w):
global s, ans
if nom == n // 2 and fl:
su, ss = d.get((m - l, w - l), (-(10**10), []))
if l > su:
d[m - l, w - l] = l, s[:]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER LIST STRING ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR B... |
In the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Overall the game has n mandatory quests. To perform each of them, you need to take exactly two companions.
The attitude of each of the companions to the hero is an integer. Initially, the attitude of each o... | import itertools
import sys
n = int(input())
data = [list(map(int, input().split())) for __ in range(n)]
if n == 1:
if data[0].count(0) < 2:
print("Impossible")
else:
print("".join([i for i, a in zip("LMW", data[0]) if a == 0][:2]))
sys.exit()
pre = n // 2
dat1 = data[:pre]
dat2 = data[pre:... | IMPORT IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR VAR VAR FUNC_CALL VAR STRING VAR NUMBER VAR NUMBER NUMBER EX... |
In the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Overall the game has n mandatory quests. To perform each of them, you need to take exactly two companions.
The attitude of each of the companions to the hero is an integer. Initially, the attitude of each o... | n = int(input())
a = [0] * n
b = [0] * n
c = [0] * n
for i in range(n):
a[i], b[i], c[i] = map(int, input().split())
middle = {}
stack = []
result = -10000000000.0, ()
phase = 1
def search(pos, l, m, w):
global result
if pos == n >> 1 if phase == 1 else pos < n >> 1:
if phase == 1:
mid... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF IF ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | read = lambda: map(int, input().split())
c = [0] * 100001
n, x = read()
a = list(read())
for v in a:
c[v] += 1
ans = 0
for v in a:
y = x ^ v
if y <= 100000:
ans += c[y]
if y == v:
ans -= 1
print(ans // 2) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR N... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | def answer(n, x, A):
count = 0
d = {A[0]: 1}
for i in range(1, n):
if A[i] ^ x in d:
count += d[A[i] ^ x]
if A[i] in d:
d[A[i]] += 1
else:
d[A[i]] = 1
return count
n, x = map(int, input().split())
arr = list(map(int, input().split()))
print(a... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR DICT VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FU... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = list(map(int, input().split()))
a = [int(x) for x in input().split()]
ad = {}
count = 0
for i in a:
count += ad.get(i ^ x, 0)
ad[i] = ad.get(i, 0) + 1
print(count) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
lis = list(map(int, input().split()))
ans = 0
has = [0] * 1000000
for i in lis:
has[i] += 1
ans = 0
if x == 0:
for i in range(1000000):
ans += has[i] * (has[i] - 1) // 2
else:
for i in range(n):
a = lis[i] ^ x
ans += has[lis[i]] * has[a]
has[l... | ASSIGN 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 ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER NUMBE... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
d = dict()
a = [int(x) for x in input().split()]
for i in a:
if i in d:
d[i] += 1
else:
d[i] = 1
k = 0
for i in a:
c = d.get(i ^ x, 0)
if i == i ^ x:
k += (c - 1) / 2
else:
k += c / 2
print(int(k)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
arr = list(map(int, input().split()))
dp = [0] * (10**6 + 1)
for i in arr:
dp[i] += 1
ans = 0
for i in arr:
ans += dp[i ^ x]
if x == 0:
ans -= 1
print(ans // 2) | ASSIGN 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 BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
a, c, ct = list(map(int, input().split())), [(0) for x in range(1 << 18)], 0
for u in a:
ct += c[x ^ u]
c[u] += 1
print(ct) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | N = 1000000
[n, x] = list(map(int, input().split()))
a = list(map(int, input().split()))
h = [(0) for i in range(N)]
for i in range(n):
h[a[i]] += 1
res = 0
for i in range(n):
cnt = h[a[i] ^ x]
if a[i] ^ x == a[i]:
cnt -= 1
res += cnt
res //= 2
print(res) | ASSIGN VAR NUMBER ASSIGN LIST 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 NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = list(map(int, input().split()))
A = list(map(int, input().split()))
cnt = 2**17 * [0]
ans = 0
for i in range(n - 1, -1, -1):
ans += cnt[x ^ A[i]]
cnt[A[i]] += 1
print(ans) | ASSIGN 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 BIN_OP BIN_OP NUMBER NUMBER LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CAL... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | def process(A, x):
d = {}
answer = 0
for c in A:
if c not in d:
d[c] = 0
d[c] += 1
c2 = c ^ x
if c2 in d:
if c != c2:
answer += d[c2]
else:
answer += d[c] - 1
return answer
n, x = [int(x) for x in input... | FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR IF VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EX... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
d = dict()
for i in range(len(a)):
d[a[i]] = d.get(a[i], 0) + 1
res = 0
def search(num):
l = -1
r = len(a)
while r - l > 1:
m = (l + r) // 2
if a[m] > k:
r = m
else:
l = m
... | ASSIGN 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 ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIG... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
for i in arr:
if i in d.keys():
d[i] += 1
else:
d[i] = 1
count = 0
for i in arr:
if i ^ x in d.keys():
if x == 0:
if d[i ^ x] > 1:
count += d[i] - 1
else:
cou... | ASSIGN 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 DICT FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR FUNC_CALL VAR IF VAR NUMBER IF VAR BIN_OP VAR VAR NUMBER VAR B... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | import sys
args = sys.stdin.readline()
n, x = [int(a) for a in args.split()]
args = sys.stdin.readline()
arr = [int(a) for a in args.split()]
met = {}
amount = 0
for a in arr:
val = a ^ x
old = met.get(val, None)
if not old is None:
amount += old
old = met.get(a, 0)
met[a] = old + 1
sys.std... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NONE IF VAR NONE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASS... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, k = map(int, input().split())
num = list(map(int, input().split()))
ans = 0
map = dict()
for x in num:
y = x ^ k
if y in map:
ans += map[y]
if x not in map:
map[x] = 0
map[x] += 1
print(ans) | ASSIGN 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 ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
A = list(map(int, input().split()))
d = dict()
for j in range(n):
if A[j] in d:
d[A[j]] += 1
else:
d[A[j]] = 1
ans = 0
for j in range(n):
per = x ^ A[j]
if A[j] != per:
if per in d:
ans += d[per]
elif per in d:
ans += d[per... | ASSIGN 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 FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | def __starting_point():
n, x = map(int, input().split())
a = list(map(int, input().split()))
freq = {}
for v in a:
freq[v] = freq.get(v, 0) + 1
res = 0
cfreq = {}
for v in a:
y = v ^ x
cfreq[v] = cfreq.get(v, 0) + 1
if y in freq:
res += freq[y] - c... | FUNC_DEF ASSIGN 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 DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL V... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
M = max(a) + 1
cnt = [(0) for _ in range(M)]
for num in a:
cnt[num] += 1
res = 0
for num in range(1, M):
if cnt[num] > 0:
s = num ^ x
if M > s >= num:
res += cnt[s] * cnt[num] if s != num else (cnt[s] - 1) * c... | ASSIGN 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 BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASS... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * (10**6 + 1)
for i in A:
B[i] += 1
ans = 0
if x:
for i in range(10**5 + 1):
ans += B[i] * B[i ^ x]
print(ans // 2)
else:
for i in B:
ans += i * (i - 1) // 2
print(ans) | ASSIGN 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 BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER VAR BIN_OP VAR VAR VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.