description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | gans = []
for _ in range(int(input())):
y, x = list(map(int, input().split()))
c2, c3, c4, c5, c6, c1 = list(map(int, input().split()))
for i in range(6):
c1 = min(c1, c6 + c2)
c2 = min(c2, c1 + c3)
c3 = min(c3, c2 + c4)
c4 = min(c4, c3 + c5)
c5 = min(c5, c4 + c6)
... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VA... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
def gift():
for _ in range(t):
tx, ty = list(map(int, input().split()))
c1, c2, c3, c4, c5, c6 = list(map(int, input().split()))
dic = [[1, 1], [0, 1], [-1, 0], [-1, -1], [0, -1], [1, 0]]
if tx > 0:
... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def sol(a1, a2, b1, b2, c1, c2):
d = -b1 * a2 + b2 * a1
d1 = c1 * b2 - c2 * b1
d2 = -c1 * a2 + c2 * a1
x1 = d1 // d
x2 = d2 // d
return x1, x2
m = [[1, 1], [0, 1], [-1, 0], [-1, -1], [0, -1], [1, 0]]
for qq in range(int(input())):
f = [int(s) for s in input().split()]
cost = [int(s) fo... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR VAR ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUM... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
while t:
t += -1
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
ans, t2 = 999999999999999999999, 0
if y > 0:
t1 = min(c2 * y, (c1 + c3) * y)
if x > 0:
t2 = min(c6 * x, (c5 + c1) * x)
else:
t2 = min(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN ... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | for nt in range(int(input())):
y, x = list(map(int, input().split()))
c1, c2, c3, c4, c5, c6 = list(map(int, input().split()))
for i in range(10):
c2 = min(c2, c1 + c3)
c3 = min(c3, c2 + c4)
c4 = min(c4, c3 + c5)
c5 = min(c5, c4 + c6)
c6 = min(c6, c5 + c1)
c1 ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
x, y = map(int, input().split())
lis = list(map(int, input().split()))
costs = [0] * 6
costs[0] = min(lis[0], lis[1] + lis[5])
costs[1] = min(lis[1], lis[0] + lis[2])
costs[2] = min(lis[2], lis[1] + lis[3])
costs[3] =... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def func(x, c2, c5):
if x < 0:
return -x * c5
else:
return x * c2
def func_2(x, c4, c1):
if x < 0:
return -x * c4
else:
return x * c1
def func_3(x, c6, c3):
if x < 0:
return -x * c3
else:
return x * c6
def main():
y, x = map(int, input().... | FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
for you in range(t):
l = input().split()
x = int(l[0])
y = int(l[1])
l = input().split()
c1 = int(l[0])
c2 = int(l[1])
c3 = int(l[2])
c4 = int(l[3])
c5 = int(l[4])
c6 = int(l[5])
if x >= 0 and y >= 0:
mina = c6 * x + c2 * y
if y <= x:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIG... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
for _ in range(t):
x, y = map(int, input().split())
c = list(map(int, input().split()))
for i in range(6):
c[i] = min(c[i], c[(i - 1) % 6] + c[(i + 1) % 6])
if x > 0 and y > 0:
cnt = min(x, y)
print(cnt * c[0] + (x - cnt) * c[5] + (y - cnt) * c[1])
elif x < 0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR ... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
n, m = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
c1 = min(c1, c2 + c6)
c2 = min(c2, c1 + c3)
c3 = min(c3, c2 + c4)
c4 = min(c4, c3 + c5)
c5 = min(c5, c4 + c6)
c6 = min(c6, c5 + c... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | T = int(input())
for t in range(T):
x, y = tuple(map(int, input().split()))
c1, c2, c3, c4, c5, c6 = tuple(map(int, input().split()))
h_p = min(c2, c1 + c3)
h_n = min(c5, c6 + c4)
v_p = min(c6, c1 + c5)
v_n = min(c3, c2 + c4)
d_p = min(c1, c2 + c6)
d_n = min(c4, c3 + c5)
h = h_p if y... | ASSIGN VAR FUNC_CALL 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 VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VA... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
def process():
x, y = map(int, input().split())
c = list(map(int, input().split()))
ans = 0
if x > 0 and y > 0:
d = min(x, y)
if c[0] < c[5] + c[1]:
ans += d * c[0]
x -= d
y -= d
if x < 0 and y < 0:
d = abs(max(x, y))
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
for _ in range(t):
x, y = map(int, input().split())
cost = list(map(int, input().split()))
truecost = [0] * 6
for i in range(6):
truecost[i] = min(cost[i], cost[(i - 1) % 6] + cost[(i + 1) % 6])
ans = 0
if x > 0 and y > 0:
w = min(x, y)
ans += w * truecos... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
while t > 0:
y, x = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
rh = min(c2, c1 + c3)
lh = min(c5, c4 + c6)
uv = min(c6, c1 + lh)
lv = min(c3, rh + c4)
ud = min(c1, uv + rh)
ld = min(c4, lv + lh)
a = 0
if y > 0:
rs = y * u... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR AS... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
input = sys.stdin.readline
def main():
t = int(input())
for _ in range(t):
X, Y = [int(x) for x in input().split()]
C1, C2, C3, C4, C5, C6 = [int(x) for x in input().split()]
ans = float("inf")
if X == 0 and Y == 0:
print(0)
continue
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF ... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def main():
n = int(input())
for i in range(n):
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
answer = 0
if x > 0:
answer += x * c6
else:
answer += -x * c3
if y > 0:
answer += y * c2
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VA... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
masks = []
dirs = [(1, 1), (0, 1), (-1, 0), (-1, -1), (0, -1), (1, 0)]
for i in range(1 << 6):
bad = False
for j in range(3):
if (i >> j & 1) + (i >>... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR N... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
sys.setrecursionlimit(10**8)
def solve(curx, cury, cost):
if curx == tx and cury == ty:
return cost
elif curx == tx:
if ty > cury:
return cost + c2 * (ty - cury)
else:
return cost + c5 * (cury - ty)
elif cury == ty:
if tx > curx:
... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF IF VAR VAR VAR VAR RETURN VAR IF VAR VAR IF VAR VAR RETURN BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR RETURN BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR IF VAR VAR RETURN BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR RETURN BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR VAR... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | for _ in range(int(input())):
y, x = map(int, input().split())
d = abs(x - y)
ans = 10000000000000000000000000000
c = [0] + list(map(int, input().split()))
if x >= 0 and y >= 0:
path1 = c[2] * x + c[6] * y
path2 = c[1] * x + c[3] * d
path3 = c[1] * y + c[2] * d
if x <... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def fun(x, y):
global c1, c2, c3, c4, c5, c6
val = 0
if x >= 0:
val += c6 * x
else:
val += c3 * abs(x)
if y >= 0:
val += c2 * y
else:
val += c5 * abs(y)
return val
def fun1(x):
global c1, c2, c3, c4, c5, c6
val = 0
if x >= 0:
val += c1 * ... | FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL ... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def calc():
global c1, c2, c3, c4, c5, c6, x1, x2, x3, x4, x5, x6
return x1 * c1 + x2 * c2 + x3 * c3 + x4 * c4 + x5 * c5 + x6 * c6
for _ in range(int(input())):
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
ans = []
if x > 0 and y > 0:
x1, x2, x3, ... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | n = int(input())
for _ in range(n):
y, x = map(int, input().split())
costs = list(map(int, input().split()))
for i in range(36):
costs[i % 6] = min(costs[i % 6], costs[(i + 5) % 6] + costs[(i + 1) % 6])
ans = 0
if x >= 0:
if y >= 0:
if x >= y:
ans = (x - y... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR NUMBER N... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def cost(d, c1, c2):
return d * (c1 if d > 0 else -c2)
for _ in range(int(input())):
x, y = map(int, input().split())
c = [0] + list(map(int, input().split()))
opt = []
opt.append(cost(x - y, c[6], c[3]) + cost(y, c[1], c[4]))
opt.append(cost(x, c[6], c[3]) + cost(y, c[2], c[5]))
opt.appen... | FUNC_DEF RETURN BIN_OP VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
input = sys.stdin.readline
for f in range(int(input())):
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
c2 = min(c2, c1 + c3)
c5 = min(c5, c4 + c6)
c6 = min(c6, c1 + c5)
c3 = min(c3, c2 + c4)
c1 = min(c1, c2 + c6)
c4 = min(c4, c3 + c5)
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR B... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
for _ in range(t):
x, y = map(int, input().split(" "))
c = [int(val) for val in input().split(" ")]
if x == 0 and y == 0:
print(0)
elif x == 0:
if y > 0:
print(min(c[1] * y, (c[0] + c[2]) * y))
else:
print(min(c[4] * -y, (c[3] + c[5]) * -y... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMB... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
for _ in range(0, t):
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
c11 = min(c1, c2 + c6)
c22 = min(c2, c3 + c1)
c33 = min(c3, c4 + c2)
c44 = min(c4, c5 + c3)
c55 = min(c5, c6 + c4)
c66 = min(c6, c1 + c5)
ss = 0
if x >= 0 an... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR B... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | for _ in range(int(input())):
x, y = map(int, input().split())
l = list(map(int, input().split()))
c1, c2, c3, c4, c5, c6 = l[0], l[5], l[4], l[3], l[2], l[1]
if x == 0 and y == 0:
print(0)
elif y == 0:
if x > 0:
if c1 + c3 < c2:
print(x * (c1 + c3))
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBE... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def xyc(x, y):
an1 = 0
if x > 0:
an1 += cos[5] * x
else:
an1 += cos[2] * -x
if y > 0:
an1 += cos[1] * y
else:
an1 += cos[4] * -y
return an1
t = int(input())
for _ in range(t):
p = list(map(int, input().split()))
x, y = p[0], p[1]
cos = list(map(int, ... | FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
def soln(targetxy, costs):
assert len(costs) == 6
finalcost = 999
for _ in range(6):
... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUM... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def find_shortest_route(c1, c2, c3, c4, c5, c6, x, y):
costs = []
n1 = y
n2 = x - n1
if n1 >= 0 and n2 >= 0:
costs.append(c1 * n1 + c2 * n2)
n1 = x
n3 = n1 - y
if n1 >= 0 and n3 >= 0:
costs.append(c1 * n1 + c3 * n3)
n1 = y
n5 = n1 - x
if n1 >= 0 and n5 >= 0:
... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUM... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
input = sys.stdin.readline
def main():
x, y = map(int, input().split())
clst = list(map(int, input().split()))
clst[0] = min(clst[0], clst[5] + clst[1])
clst[1] = min(clst[1], clst[0] + clst[2])
clst[2] = min(clst[2], clst[1] + clst[3])
clst[3] = min(clst[3], clst[2] + clst[4])
... | IMPORT ASSIGN VAR VAR 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 NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUN... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | for _ in range(int(input())):
x, y = map(int, input().split())
c = list(map(int, input().split()))
for i in range(6):
c[i] = min(c[i], c[(i + 1) % 6] + c[(i - 1) % 6])
if x >= 0:
if y >= x:
print(x * c[0] + (y - x) * c[1])
elif y <= 0:
print(x * c[5] + abs... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER I... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
X, Y = map(int, stdin.readline().split())
c = [None] + list(map(int, stdin.readline().split()))
ans = 0
x, y = X, Y
if x >= 0:
ans += x * c[6]
else:
ans += abs(x) * c[3]
if y >= 0:
ans... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR V... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
input = sys.stdin.buffer.readline
def oneLineArrayPrint(arr):
print(" ".join([str(x) for x in arr]))
def multiLineArrayPrint(arr):
print("\n".join([str(x) for x in arr]))
def multiLineArrayOfArraysPrint(arr):
print("\n".join([" ".join([str(x) for x in y]) for y in arr]))
allAns = []
t = ... | IMPORT ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR V... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
input = sys.stdin.readline
I = lambda: list(map(int, input().split()))
(t,) = I()
for _ in range(t):
x, y = I()
l = I()
a = min(l[2], l[3] + l[1])
b = min(l[5], l[4] + l[0])
c = min(l[4], l[3] + l[5])
d = min(l[1], l[0] + l[2])
e = min(l[1] + l[5], l[0])
f = min(l[2] + l[4], ... | IMPORT ASSIGN VAR 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 VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUM... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | for _ in range(int(input())):
repl = True
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
while repl:
repl = False
if c1 + c3 < c2:
c2 = c1 + c3
repl = True
if c2 + c4 < c3:
c3 = c2 + c4
repl = Tr... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR WHILE VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def optimize_costs(c1, c2, c3, c4, c5, c6):
c1 = min(c1, c2 + c6)
c2 = min(c2, c1 + c3)
c3 = min(c3, c2 + c4)
c4 = min(c4, c3 + c5)
c5 = min(c5, c4 + c6)
c6 = min(c6, c5 + c1)
return c1, c2, c3, c4, c5, c6
def main(input_f):
t = int(input_f())
for _ in range(t):
x, y = map(... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETURN VAR VAR VAR VAR VAR VAR FUNC_DEF ASSIGN ... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
for i in range(t):
x, y = list(map(int, input().split()))
c = list(map(int, input().split()))
turns = [(1, 1), (0, 1), (-1, 0), (-1, -1), (0, -1), (1, 0)]
true_paths = [None, None, None, None, None, None]
min_in_c = min(c)
for j in range(6):
if c[j] == min_in_c:
... | ASSIGN VAR FUNC_CALL 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST N... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | for _ in range(int(input())):
x0, y0 = input().split()
x0, y0 = int(x0), int(y0)
c = [0] + list(map(int, input().split()))
c[0] = c[-1]
c.append(c[1])
for i in range(1, 7):
c[i] = min(c[i], c[i - 1] + c[i + 1])
c[7] = c[1]
s = None, [1, 1], [0, 1], [-1, 0], [-1, -1], [0, -1], [1,... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | for _ in range(int(input())):
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
arr = [0] * 7
cost = 0
if x >= 0 and y >= 0:
arr[1] = min(x, y)
x -= arr[1]
y -= arr[1]
cost += arr[1] * min(c2 + c6, c1)
if x:
arr[6]... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR V... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | from sys import stdin
t = int(stdin.readline())
for _ in range(t):
x, y = tuple(int(x) for x in stdin.readline().split())
lst = list(int(x) for x in stdin.readline().split())
flag = True
while flag:
flag = False
for i in range(6):
if lst[i - 1] + lst[(i + 1) % 6] < lst[i]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL 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 NUMBER WHILE VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VA... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
for _ in range(t):
x, y = map(int, input().split())
a, b, c, d, e, f = map(int, input().split())
c = [f, a, b, c, d, e]
m = 0
for i in range(6):
if c[i] < c[m]:
m = i
j = (m + 1) % 6
while j != m:
c[j] = min(c[(j + 1) % 6] + c[(j - 1 + 6) % 6], c[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR ASSI... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
for _ in range(t):
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
if x == y == 0:
print(0)
continue
if x == 0:
one_line = True
l = abs(y)
if y > 0:
cs1, cm, cs2 = c1, c2, c3
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
def neg(i):
return (i + 3) % 6
for case in range(t):
x, y = map(int, input().split())
x *= 1
y *= 1
C = [int(x) for x in input().split()]
steps = [0, 0, 0, 0, 0, 0]
if x < 0:
steps[2] = -x
else:
steps[5] = x
if y < 0:
steps[4] = -y
els... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF VAR NUMBER... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | for _ in range(int(input())):
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
c2 = min(c2, c1 + c3)
c3 = min(c3, c2 + c4)
c4 = min(c4, c3 + c5)
c5 = min(c5, c4 + c6)
c6 = min(c6, c5 + c1)
c1 = min(c1, c6 + c2)
if x * y < 0:
if x < 0:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN V... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
d1 = min(c1, c2 + c6)
d2 = min(c2, c1 + c3)
d3 = min(c3, c2 + c4)
d4 = min(c4, c3 + c5)
d5 = min(c5, c4 + c6)
d6 = min(c6, c5 + c... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d):
return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [
[[[e for l in range(d)] for k... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | n = int(input())
def calc(x, y, z):
if x >= 0:
return x * y
else:
return abs(x) * z
for j in range(n):
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
best = 9223372036854775807
best = min(best, calc(x, c6, c3) + calc(y, c2, c5))
best =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR V... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | from sys import gettrace, stdin
if gettrace():
inputi = input
else:
def input():
return next(stdin)[:-1]
def inputi():
return stdin.buffer.readline()
def solve():
r, c = map(int, inputi().split())
costs = [int(a) for a in inputi().split()]
if r >= 0:
if c <= 0:
... | IF FUNC_CALL VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSI... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def read_int():
return int(input())
def read_ints():
return map(int, input().split(" "))
d = [(1, 1), (0, 1), (-1, 0), (-1, -1), (0, -1), (1, 0)]
t = read_int()
for case_num in range(t):
x, y = read_ints()
c = list(read_ints())
ans = -1
for i in range(6):
dx = d[i][0]
dy = d[... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_C... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | for t in range(int(input())):
x, y = map(int, input().split())
c1, c2, c3, c4, c5, c6 = map(int, input().split())
def cal(x, y):
if x == 0 and y == 0:
return 0
elif x > 0 and y == 0:
return min(c1 + c5, c6) * x
elif x < 0 and y == 0:
return min(c2... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR NUMBER VA... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s)])
def invr():
return map(int, input().split())
n = inp()
for _ in range(n):
target = inlt()
l = inlt()
if target[0] >= 0 and target[1] >= 0:
pa... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CA... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | T = int(input())
for _ in range(T):
r, c = map(int, input().split())
UR, R, D, LD, L, U = map(int, input().split())
UR, R, D, LD, L, U = (
min(UR, U + R),
min(R, UR + D),
min(D, R + LD),
min(LD, L + D),
min(L, U + LD),
min(U, L + UR),
)
cc = 0
if r... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import sys
input = sys.stdin.readline
(T,) = map(int, input().split())
for _ in range(T):
y, x = map(int, input().split())
X = [0] + list(map(int, input().split()))
if x >= 0 and y >= 0:
a, b, c = X[2], X[6], X[1]
a = min(a, c + X[3])
b = min(b, c + X[5])
elif x > 0 and y < 0:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | import itertools
import sys
(*data,) = map(int, sys.stdin.read().split()[::-1])
def inp():
return data.pop()
def app(c, speeds, combi, d):
x = 0
y = 0
cost = 0
for dire, dist in zip(combi, d):
y += speeds[dire][0] * dist
x += speeds[dire][1] * dist
cost += c[dire] * dist... | IMPORT IMPORT ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR LIST F... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
for _ in range(t):
x, y = map(int, input().split())
c = list(map(int, input().split()))
UR = 10**9
UL = 10**9
R = 10**9
L = 10**9
DL = 10**9
DR = 10**9
UR = min(c[0], c[1] + c[5])
UL = min(c[5], c[0] + c[4])
R = min(c[1], c[2] + c[0])
L = min(c[4], c[5] +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASS... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | def det(x, y, z, w):
return x * w - y * z
t = int(input())
for test in range(t):
[x, y] = list(map(int, input().rstrip().split()))
c = list(map(int, input().rstrip().split()))
for j in range(6):
for i in range(6):
c[i] = min(c[i], c[(i - 1) % 6] + c[(i + 1) % 6])
direction = [(... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FU... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
for _ in range(t):
x, y = map(int, input().split())
c = list(map(int, input().split()))
for i in range(6):
c[i] = min(c[i], c[int((i - 1) % 6)] + c[int(i + 1) % 6])
answer = 0
path = []
if x >= 0 and y >= 0:
distance = min(x, y)
answer += distance * c[0]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | for _ in range(int(input())):
x, y = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(50):
c[0] = min(c[0], c[5] + c[1])
c[1] = min(c[1], c[0] + c[2])
c[2] = min(c[2], c[1] + c[3])
c[3] = min(c[3], c[2] + c[4])
c[4] = min(c[4], c[3] +... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR... |
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below. [Image]
Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi... | t = int(input())
while t > 0:
x, y = map(int, input().split())
lst = list(map(int, input().split()))
cost = lst.copy()
for i in range(1, 7):
cost[i % 6] = min(cost[i % 6], cost[(i - 1) % 6] + cost[(i + 1) % 6])
cnt = [0] * 6
if x == 0 and y == 0:
pass
elif x >= 0 and y >= 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER 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 NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN... |
T is playing a game with his friend, HL.
There are n piles of stones, the i-th pile initially has a_i stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in th... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
if n == 1:
print("T")
elif n == 2:
if a[0] == a[1]:
print("HL")
else:
print("T")
elif sum(a) % 2 == 1 or max(a) > sum(a) - max(a):
print("T")
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CAL... |
T is playing a game with his friend, HL.
There are n piles of stones, the i-th pile initially has a_i stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in th... | for _ in range(int(input())):
n = int(input())
l1 = list(map(int, input().split()))
l1.sort()
sum1 = sum(l1) - l1[-1]
if l1[-1] > sum1:
print("T")
else:
sum1 += l1[-1]
if sum1 % 2 == 0:
print("HL")
else:
print("T") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR STRING VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_C... |
T is playing a game with his friend, HL.
There are n piles of stones, the i-th pile initially has a_i stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in th... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
if n == 1:
print("T")
continue
a = sorted(a, key=lambda x: -x)
partialsum = 0
for i in range(1, n):
partialsum += a[i]
totalsum = a[0] + par... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR... |
T is playing a game with his friend, HL.
There are n piles of stones, the i-th pile initially has a_i stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in th... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
m = 0
s = 0
for i in a:
m = max(m, i)
s += i
if m > s // 2:
print("T")
elif s % 2 == 0:
print("HL")
else:
print("T") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUM... |
T is playing a game with his friend, HL.
There are n piles of stones, the i-th pile initially has a_i stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in th... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
if s % 2 != 0:
print("T")
else:
k = s // 2
t = 0
for i in range(n):
if a[i] > k:
t = 1
break
if t == 1:
print(... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR V... |
T is playing a game with his friend, HL.
There are n piles of stones, the i-th pile initially has a_i stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in th... | from sys import stdin, stdout
mp = lambda: map(int, stdin.readline().split())
li = lambda: list(map(int, stdin.readline().split()))
for _ in range(int(input())):
n = int(input())
a = li()
mx, sm = max(a), sum(a)
if mx * 2 > sm or sm & 1:
print("T")
else:
print("HL") | ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR... |
T is playing a game with his friend, HL.
There are n piles of stones, the i-th pile initially has a_i stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in th... | t = int(input())
for q in range(t):
n = int(input())
mas = list(map(int, input().split()))
if max(mas) > sum(mas) - max(mas):
print("T")
elif sum(mas) % 2 == 0:
print("HL")
else:
print("T") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VA... |
T is playing a game with his friend, HL.
There are n piles of stones, the i-th pile initially has a_i stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in th... | for t in range(int(input())):
n = int(input())
a = sorted(list(map(int, input().split())))
if a[-1] > sum(a[:-1]):
print("T")
elif sum(a) % 2 == 0:
print("HL")
else:
print("T") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VA... |
T is playing a game with his friend, HL.
There are n piles of stones, the i-th pile initially has a_i stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in th... | def solve(n, piles):
mx = max(piles)
sm = sum(piles)
if mx > sm - mx:
return "T"
if sm % 2 == 1:
return "T"
return "HL"
t = int(input())
for t in range(t):
n = int(input())
piles = [int(s) for s in input().split()]
result = solve(n, piles)
print(result) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR RETURN STRING IF BIN_OP VAR NUMBER NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ... |
T is playing a game with his friend, HL.
There are n piles of stones, the i-th pile initially has a_i stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in th... | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
l.sort()
c = sum(l)
if l[-1] > c - l[-1]:
print("T")
elif sum(l) % 2 == 1:
print("T")
elif len(l) == 1:
print("T")
else:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CA... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | t = int(input())
ans = list()
for i in range(0, t):
n, k = [int(x) for x in input().split()]
arr = [int(x) for x in input()]
arr_sum = 0
j = n - 1
if k >= n:
d = 0
else:
d = n - k - 1
while j >= d:
if arr[j] == 1:
arr[j] = 0
arr_sum += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for i in range(int(input())):
n, k = map(int, input().split())
s = input()
num = s.count("1")
tot = 0
if num == 1:
i = s.index("1")
j = n - s.rfind("1") - 1
if k >= j:
k -= j
tot += 1
num -= 1
elif k >= i:
k -= i
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR STRING NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR N... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input()
back, front = -1, -1
cnt = -1
s = list(s)
for i in range(n - 1, -1, -1):
cnt += 1
if s[i] == "1":
ind1 = i
front = cnt
break
cnt = -1
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input()
f = 999999999
l = -999999999
ans = 0
for i in range(n):
if s[i] == "1":
f = min(f, i)
l = max(l, i)
ans += 11
l = n - 1 - l
used = 0
if k >= l:
ans -= ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBE... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input()
count = 0
for i in range(n - 1):
count += int(s[i] + s[i + 1])
if count == 0:
print(0)
continue
if s[n - 1] != "1":
right = n - 1
while s[right] != "1":
right -= 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NU... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for h in range(int(input())):
n, k = map(int, input().split())
u = input()
x = []
for i in u:
x.append(i)
c = x.count("1") * 11
if c == 0:
print(c)
continue
if x[-1] == "0":
m = 0
for i in range(n):
if x[i] == "1":
m = i
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CA... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
ans, f, l, o = 0, n, -1, 0
for i in range(n):
if s[i] == "0":
continue
o += 1
if f == n:
f = i
l = i
if o and n - l - 1 <= k:
ans += 1
o -= 1
k -... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = list(input())
tot = 0
f = k
last = first = 0
if s[-1] != "1":
for i in range(n - 2, -1, -1):
if k == 0:
break
if s[i] == "1":
s[i], s[-1] = s[-1], s[i]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER IF VAR VAR STRI... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | t = int(input())
def solve(t):
n, k = map(int, input().split())
s = input()
first, last = 10**10, -(10**10)
num = s.count("1")
sum_ = num * 11
for i in range(n):
if s[i] == "1":
first = i + 1
break
for i in range(n):
if s[n - i - 1] == "1":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | def count(l):
ans = 0
n = len(l)
for i in range(n - 1):
if l[i] == "0" and l[i + 1] == "0":
continue
elif l[i] == "0" and l[i + 1] == "1":
ans += 1
continue
elif l[i] == "1" and l[i + 1] == "0":
ans += 10
continue
el... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBE... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | def fun(l):
n = len(l)
c = 0
for i in range(n - 1):
c += int(l[i] + l[i + 1])
return c
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input().rstrip()
l = [x for x in s]
for i in range(n - 1, -1, -1):
if l[i] == "1":
if k >= n - 1 -... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR A... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
beg = s.find("1")
if beg == -1:
print(0)
continue
endix = s.rfind("1")
end = n - endix - 1
s = list(s)
if k >= end:
if s.count("1") == 1:
print(1)
continue
s... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR IF F... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | from sys import stdin, stdout
I = stdin.readline
O = stdout.write
for _ in range(int(I())):
n, k = list(map(int, I().split()))
st = I()
la = -k
st = list(st)
ans = 0
if st.count("1") == 0:
print(0)
continue
for j in range(n - 1, -1, -1):
if st[j] == "1":
... | ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | x = int(input())
ret = []
for z in range(x):
n, k = input().split()
k = int(k)
a = input()
spl = False
lst = a.split("1")
l, r, x = 0, 0, 0
l = len(lst[0])
r = len(lst[-1])
ones = len(lst) - 1
min = ones * 11
if l == len(a):
ret.append(min)
continue
if k >... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for _ in range(int(input())):
n, k = [int(x) for x in input().split()]
s = list(input())
l = []
ans = 0
t = s.count("1")
if t == 0:
print(0)
continue
for i in range(n):
if s[i] == "1":
l.append(i)
ans += 11
used = 0
if k >= n - l[-1] - ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR V... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for _ in range(int(input())):
a, b = map(int, input().split())
c = input()
c = list(c)
if c.count("1"):
y = c.index("1")
s = c.count("1") * 11
c = c[::-1]
x = c.index("1")
if x <= b:
b = b - x
s -= 10
if y <= b and c.count("1") ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF ... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | def substringSum(s):
sum = 0
for i in range(1, len(s)):
sum += int(s[i - 1] + s[i])
return sum
def solution(n, s, k):
min_idx = s.index("1")
max_idx = -1
for idx, x in enumerate(s):
if s[idx] == "1":
max_idx = idx
sum = substringSum(s)
if k == 0:
pri... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL ... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | tc = int(input())
for t in range(tc):
n, k = map(int, input().split())
st = input()
one = 0
s = n + 100
e = 0
for i in range(n):
if st[i] == "1":
one = one + 1
if s == n + 100:
s = i
e = i
sm = 0
if one > 0 and n - 1 - e <= k:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for _ in range(int(input())):
n, k = [int(x) for x in input().split(" ")]
s = input()
cnt = 0
for c in s:
if c == "1":
cnt += 1
if cnt == 0:
print(0)
continue
ans = cnt * 11
left, right = 0, n - 1
while s[left] == "0":
left += 1
while s[rig... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | def solve():
n, k = map(int, input().split())
s = list(input())
indl = -1
indr = -1
for i in range(n):
if s[i] == "1":
indl = i
break
for i in range(n - 1, -1, -1):
if s[i] == "1":
indr = i
break
ans = 0
if indl != -1:
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER I... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for y in [0] * int(input()):
n, k = map(int, input().split())
s = input()
i, j = (x.find("1") % 8**10 for x in (s, s[::-1]))
print(11 * s.count("1") - (k >= i + j < n - 1 or i <= k < j) - 10 * (j <= k)) | FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR STRING BIN_OP NUMBER NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR STRING VAR BIN_OP VAR VAR BIN_OP VAR NU... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | loopcount = int(input())
for loop in range(loopcount):
x = input()
x = x.split(" ")
x = list(map(int, x))
a = input()
output = 0
first = -1
last = -1
for i in range(x[0]):
if a[i] == "1":
output += 11
last = i
if first == -1:
fi... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | t = int(input())
for _ in range(t):
n, k = (int(number) for number in input().split(" "))
item = 0
zero_count_right = 0
zero_count_left = 0
ones = 0
zeros = 0
for number in input():
if item == 0:
if number == "1":
left = 1
count_left = Fals... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR IF VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for t in range(int(input())):
n, k = [int(i) for i in input().split()]
s = input()
first = -1
last = n
ctr = 0
for i in range(n):
if s[i] == "1":
if first == -1:
first = i
last = i
ctr += 1
if ctr == 0:
print(0)
elif ctr... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR N... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | def task(n, k, s):
total = 0
for i in range(n - 1):
value = int(s[i : i + 2])
total += value
ones = 0
for c in s:
if c == "1":
ones += 1
startzeros = 0
for c in s:
if c == "0":
startzeros += 1
else:
break
endzeros = ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR STRING VAR NUMBER IF VAR NUMBER IF VAR N... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for _ in range(int(input())):
n, k = map(int, input().split())
s = list(map(int, input()))
fs = 0
for i in range(n - 1):
fs += 10 * s[i] + s[i + 1]
if k == 0:
print(fs)
elif s.count(1) == 0:
print(0)
elif s.count(1) == 1:
zf = s.index(1)
s1 = s[:]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUN... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input().strip()
z = sum(11 * int(c) for c in s)
k = min(k, n - 1)
a, b = 0, 0
while a <= k:
if s[-a - 1] == "1":
break
a += 1
while b <= k:
if s[b] == "1":
break
b += 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR IF VAR BIN_OP VAR NUMBE... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | t = int(input())
for e in range(t):
n, k = map(int, input().split())
a = input()
l, r = -1, -1
s = 0
for i in range(n):
if a[i] == "1":
s += 11
r = i
if l == -1:
l = i
if r == -1:
print(s)
continue
f = k
if k >= ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CAL... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
L = list(input())
L = [int(x) for x in L]
if not 1 in L:
print(0)
continue
if L.count(1) == 1:
a = L.index(1)
if k >= n - 1 - a:
print(1)
elif k >= a:
print(10)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP BIN_O... |
You are given a binary string $s$ of length $n$.
Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{i=1}^{n-1} d_i$.
For example, for the string $s = 1011$:
$d_1 = ... | t = int(input())
for k in range(t):
n, k = map(int, input().split(" "))
s1 = input()
s = []
ones = 0
for i in s1:
if i == "1":
ones += 1
s.append(int(i))
fone = 0
for i in range(n):
if s[i] == 1:
fone = i
break
lone = 0
for ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUM... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.