description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | i_speed, f_speed = input().split(" ")
time, transition = input().split(" ")
i_speed = int(i_speed)
f_speed = int(f_speed)
time = int(time)
transition = int(transition)
path = [i_speed] * time
for i in range(1, len(path)):
path[i] += transition * i
while path[i] > f_speed + transition * (len(path) - i - 1):
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR WHILE VAR V... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | def solve(v1, v2, t, d):
cache = {}
def calc_max(cur_v, remain_t):
if remain_t == 0:
return 0
cur_dist = float("-inf")
if remain_t == 1 and cur_v != v2:
return cur_dist
cache_key = cur_v, remain_t
if cache_key in cache:
return cache[ca... | FUNC_DEF ASSIGN VAR DICT FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR VAR VAR IF VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | v1, v2 = list(map(int, input().split()))
t, d = list(map(int, input().split()))
if v1 > v2:
v1, v2 = v2, v1
if d == 0:
print(t * v1)
else:
a = [i for i in range(v1, v1 + t * d, d)]
b = [i for i in range(v2, v2 + t * d, d)]
b.reverse()
i = 0
answer = 0
while i < t - 1:
if abs(a[i]... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL ... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | v1, v2 = list(map(int, input().split()))
t, d = list(map(int, input().split()))
ans = [0] * t
ans[0] = v1
ans[-1] = v2
n = t
for i in range(1, n - 1):
if ans[-1] < ans[i - 1] + d:
if ans[i - 1] + d - ans[-1] <= d * (n - 1 - i):
ans[i] = ans[i - 1] + d
else:
ans[i] = ans[-1] +... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER BIN_OP VAR BIN_OP VAR NU... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | def main():
v1, v2 = (int(i) for i in input().split())
t, d = (int(i) for i in input().split())
res = 0
for i in range(t):
res += min(v1 + d * i, v2 + d * (t - i - 1))
print(res)
main() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | v1, v2 = map(int, input().split())
t, d = map(int, input().split())
dst = v1
for i in range(2, t + 1):
for x in range(d):
if abs(v1 + 1 - v2) <= d * (t - i):
v1 += 1
elif abs(v1 - v2) > d * (t - i):
if v1 > v2:
v1 -= 1
else:
v1 += 1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR BIN... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | from sys import stdin, stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int, stdin.readline().split()))
for _ in range(1):
v1, v2 = lst()
n, d = lst()
N = 1001
dp = [[(0) for _ in range(N)] for _ in range(n)]
dp[0][v1] = v1
for i in range(1, n - 1):
for j in range(N):
... | ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | a, b = map(int, input().split())
t, d = map(int, input().split())
first = [0] * t
first[0] = a
for i in range(1, t):
first[i] = first[i - 1] + d
second = [0] * t
second[0] = b
for i in range(1, t):
second[i] = second[i - 1] + d
second = second[::-1]
final = [0] * t
for i in range(t):
final[i] = min(first[i]... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR FOR VAR FUNC_... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | v1, v2 = map(int, input().split(" "))
a, b = map(int, input().split(" "))
ans = 0
z = [v1]
x = [v2]
for i in range(a - 2):
z.append(z[-1] + b)
x.append(x[-1] + b)
x.append(v1)
z.append(v2)
x.reverse()
for i in range(a):
ans += min(x[i], z[i])
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CA... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | v1, v2 = [int(x) for x in input().split()]
t, d = [int(x) for x in input().split()]
pre1 = [v1]
pre2 = [v2]
for i in range(1, t):
pre1.append(pre1[i - 1] + d)
for i in range(1, t):
pre2.append(pre2[i - 1] + d)
pre2 = pre2[::-1]
ans = 0
for i in range(t):
ans += min(pre1[i], pre2[i])
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | vs = input().split()
v1 = int(vs[0])
v2 = int(vs[1])
vals = input().split()
t = int(vals[0])
d = int(vals[1])
a = [(0) for i in range(t + 1)]
index = t
maxspeed = v2
while index > 0:
a[index] = maxspeed
index = index - 1
maxspeed += d
answer = v1
current = v1
index = 2
done = False
while index <= t and not ... | 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 NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER ASSIG... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | v1, v2 = map(int, input().split())
t, d = map(int, input().split())
res = 0
for i in range(1, t + 1):
r1 = v1 + (i - 1) * d
r2 = v2 + (t - i) * d
res += min(r1, r2)
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL V... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | v1, v2 = map(int, input().split())
t, d = map(int, input().split())
v = v1
ans = v1
for i in range(1, t):
delta = v2 - v + (t - i - 1) * d
v += min(d, delta)
ans += v
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | def main():
v1, v2 = map(int, input().split())
t, d = map(int, input().split())
print(
sum(
min(vv)
for vv in zip(range(v1, v1 + t * d, d), range(v2 + (t - 1) * d, v2 - 1, -d))
)
if d
else v1 * t
)
main() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ... |
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.
Assuming that at each of the seconds the speed is constant, a... | a, b = map(int, input().split())
v1, v2 = min(a, b), max(a, b)
t, d = map(int, input().split())
dist = 0
vn = v1
t -= 1
j = 0
a = 0
r1 = 0
while j < t and vn - (t - j) * d <= v2:
vn += d
j += 1
a = 1
r1 += 1
vd = vn
r1 -= a
x = 0
b = t > r1 + 1
while x < d and vd - (t - j) * d > v2:
vd -= 1
x +=... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VA... |
Ziota found a video game called "Monster Invaders".
Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns.
For the sake of simplicity, we only consider two different types of monsters and three different types of guns.
Namely, the two types of monsters are:
*... | import sys
def solve(lst, r1, r2, r3, d):
console("----- solving ------")
const_r2_r1_d = r2 + r1 + d
const_2r1_d = 2 * r1 + d
m1_cost = [(r1 * x + r3) for x in lst]
m4_cost = [min(r1 * x + const_2r1_d, const_r2_r1_d) for x in lst]
baseline = sum(m1_cost) + (len(lst) - 1) * d
cost_diff = [... | IMPORT FUNC_DEF EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR BIN... |
Ziota found a video game called "Monster Invaders".
Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns.
For the sake of simplicity, we only consider two different types of monsters and three different types of guns.
Namely, the two types of monsters are:
*... | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
n, r1, r2, r3, d = map(int, input().split())
a = list(map(int, input().split()))
dp = [0, float("inf")]
for i in range(1, n + 1):
na = a[i - 1]
ndp = [float("inf"), float("inf")]
c1 = r1 * na + r3
c2 = min(r1 * (na + 2), r2 + r... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIG... |
Ziota found a video game called "Monster Invaders".
Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns.
For the sake of simplicity, we only consider two different types of monsters and three different types of guns.
Namely, the two types of monsters are:
*... | N, R1, R2, R3, D = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0, 0] for _ in A]
dp[0][0] = R1 * A[0] + R3
dp[0][1] = min(R2, R1 * A[0] + R1)
for i, a in enumerate(A[1:-1], 1):
dp[i][0] = min(
dp[i - 1][0] + D + R1 * A[i] + R3,
dp[i - 1][1]
+ D
+ min(
... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR VAR ASSIGN VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FOR VAR VAR ... |
Ziota found a video game called "Monster Invaders".
Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns.
For the sake of simplicity, we only consider two different types of monsters and three different types of guns.
Namely, the two types of monsters are:
*... | import sys
input = sys.stdin.readline
def snipe(i):
global r1, r2, r3, arr
return r1 * arr[i] + r3
def laser(i):
global r1, r2, r3, arr
return min(r1 * (arr[i] + 1), r2)
n, r1, r2, r3, d = list(map(int, input().split()))
arr = list(map(int, input().split()))
dp = [[sys.maxsize for j in range(2)] ... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NU... |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a = int(input())
b = int(input())
if (a + b) % 2 != 0:
print(-1)
else:
print((a - b) // 2, (a + b) // 2) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | A = int(input())
B = int(input())
if B > A or (A + B) % 2 != 0:
print(-1)
else:
C = A - B
C //= 2
if B & C == 0:
print(C, A - C)
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | x = int(input())
y = int(input())
if (x - y) % 2 == 0:
print((x - y) // 2, (x + y) // 2, sep=" ", end="\n")
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER STRING STRING EXPR FUNC_CALL VAR NUMBER |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a = int(input())
b = int(input())
if a >= b:
if (a - b) % 2 == 1:
print(-1)
exit(0)
f = b
s = (a - b) // 2
t = s
if f ^ s == f + s:
print(t, end=" ")
print(f + s)
exit(0)
if f ^ t == f + t:
print(s, end=" ")
print(f + t)
exit(0)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FU... |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | A = int(input())
B = int(input())
x = (A - B) // 2
y = x ^ B
if x + y == A and x ^ y == B:
print(x, y)
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a, b = int(input()), int(input())
x, y = a - b >> 1, (a - b) // 2 + b
if a < b or a + b & 1 or x & a - x != x:
print("-1")
else:
print(x, y) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a = int(input())
b = int(input())
if a < b or (a - b) % 2 != 0:
print(-1)
else:
v = (a - b) // 2
x = 0
y = 0
for i in range(64):
if v & 1 << i != 0:
x += 1 << i
y += 1 << i
ok = 1
for i in range(64):
if b & 1 << i:
if y & 1 << i:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR VAR... |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | S = int(input())
X = int(input())
A = (S - X) // 2
a = 0
b = 0
ok = 1
for i in range(64):
xnow = X & 1 << i
anow = A & 1 << i
if xnow == 0 and anow == 0:
pass
elif xnow > 0 and anow == 0:
a = 1 << i | a
elif xnow == 0 and anow > 0:
a = 1 << i | a
b = 1 << i | b
el... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER ... |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | A = int(input())
B = int(input())
if A < B:
T = A
A = B
B = T
X = A - B
if X % 2 == 1:
print(-1)
else:
X //= 2
print("{0} {1}".format(int(X), int(A - X))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a = int(input())
b = int(input())
A = a
x = 0
y = 0
for i in range(64):
if b & 1 << i != 0:
y |= 1 << i
elif a & 1 << i + 1 != b & 1 << i + 1:
a ^= 1 << i + 1
x |= 1 << i
y |= 1 << i
if x ^ y == b and x + y == A:
print(x, y)
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR IF BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP N... |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | _a = int(input())
_b = int(input())
A = bin(_a)[2:]
B = bin(_b)[2:]
if len(A) < len(B):
A, B = B, A
B = "0" * (len(A) - len(B)) + B
X = ""
Y = ""
need_carry = False
for a, b in zip(A, B):
if a + b == "11":
X += "0"
Y += "1"
elif a + b == "10":
if need_carry:
X += "1"
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR ... |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | A, B = int(input()), int(input())
if A < B:
print(-1)
X = (A - B) // 2
Y = X + B
if X + Y != A or X ^ Y != B:
print(-1)
else:
print(X, Y) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | A = int(input())
B = int(input())
if (A - B) % 2 != 0:
print(-1)
exit()
XAY = A - B >> 1
res = 0
r1 = XAY
r2 = A - r1
if r1 < 0 or r2 < 0:
print(-1)
exit()
if A != r1 + r2 or B != r1 ^ r2:
print(-1)
exit()
print(r1, r2) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUN... |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | import sys
def solve():
(a,) = rv()
(b,) = rv()
bbin = bin(b)[::-1]
bl, x, y = [0] * 64, [0] * 64, [0] * 64
for i in range(len(bbin) - 2):
bl[i] = 1 if bbin[i] == "1" else 0
for i in range(64):
count = 0
if bl[i] == 1:
count += 1
if count == 1:
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR STRING NUMBER NUMBER FOR VAR FUNC_CALL VAR N... |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a = int(input())
b = int(input())
q = a - b
if q >= 0 and q % 2 == 0:
q = (a - b) // 2
x = bin(b)[2:][::-1]
y = bin(q)[2:][::-1]
if len(x) > len(y):
s = ["0"] * (len(x) - len(y))
y += "".join(s)
else:
s = ["0"] * (len(y) - len(x))
x += "".join(s)
j = 0
f = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR B... |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a = int(input())
b = int(input())
if a < b:
print(-1)
else:
nda = a - b >> 1
xrr = b
num1 = 0
num2 = 0
flag = True
for i in range(0, 64):
bit1 = nda >> i & 1
bit2 = xrr >> i & 1
if bit1 == 0 and bit2 == 0:
num1 += 0
num2 += 0
elif bit1 ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BI... |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a = int(input())
b = int(input())
if (a - b) % 2 == 1:
print("-1")
exit(0)
x = (a - b) // 2
y = a - x
print(x, y) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a = int(input())
b = int(input())
c = (a - b) // 2
if a < b:
print(-1)
elif c & a - c != c:
print(-1)
else:
print(str(c) + " " + str(a - c)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR BIN_OP VAR VAR |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | S = int(input())
X = int(input())
if S < X or (S - X) % 2 == 1:
print("-1")
else:
print((S - X) // 2, end=" ")
print(X ^ (S - X) // 2) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | A = int(input())
B = int(input())
if A < B:
print(-1)
else:
v = A - B
if v % 2:
print(-1)
else:
v //= 2
if B & v:
print(-1)
else:
print(f"{v} {v + B}") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR STRING BIN_OP VAR VAR |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a = int(input())
b = int(input())
x = int((a - b) / 2)
y = a - x
if 2 * x + b == a:
print("{} {}".format(x, y))
else:
print("-1") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR VAR EXPR FUNC_CALL VAR STRING |
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions ... | a = int(input())
b = int(input())
k = a - b
if k % 2:
print(-1)
exit(0)
k >>= 1
if k < 0:
print(-1)
exit(0)
print(k, a - k) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def solve_simple(source, target):
if not set(source) >= set(target):
return -1
operations = 0
target_index = 0
while target_index < len(target):
operations += 1
source_index = 0
while source_index < len(source) and target_index < len(target):
if source[source_... | FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER A... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | from sys import stdin, stdout
def bs(nums, target):
low = 0
high = len(nums) - 1
while low < high:
m = (high + low) // 2
if nums[m] <= target:
low = m + 1
else:
high = m
if low == len(nums):
return -1
if nums[low] <= target:
return -1... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR VAR RETURN NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VA... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
input = sys.stdin.readline
def main():
d = {}
for i in range(26):
d[chr(i + ord("a"))] = i
for _ in range(int(input())):
s = input().strip()
t = input().strip()
s1 = set(s)
s2 = set(t)
if not s2.issubset(s1):
print(-1)
con... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FU... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
s = input().rstrip()
t = input().rstrip()
L = len(s)
dp = []
cur_min = [-1] * 26
for i in range(L):
x = s[L - 1 - i]
xx = ord(x) - 97
cur_min[xx] = L - 1 - i
dp.append(cur_min[:])
dp.re... | IMPORT ASSIGN VAR VAR 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR ... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
input = sys.stdin.readline
t = int(input())
for test in range(t):
s = input().strip()
t = input().strip()
LEN = len(s)
NEXT = [([-1] * 26) for i in range(LEN + 1)]
for i in range(LEN - 1, -1, -1):
for j in range(26):
NEXT[i][j] = NEXT[i + 1][j]
NEXT[i][ord(s[i... | IMPORT ASSIGN VAR VAR 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
def main():
import sys
input = sys.stdin.readline
for _ in range(int(input())):
S = input().rstrip("\n")
T = input().rstrip("\n")
N = len(S)
nxt = [([N + 1] * 26) for _ in range(N + 1)]
for i in range(N, 0, -1):
s = S[i - 1]
for j... | IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NU... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | ALPHA = 26
def offset(c):
return ord(c) - ord("a")
T = int(input())
for cs in range(T):
s = list(map(offset, list(input())))
t = list(map(offset, list(input())))
ls = len(s)
nxt = [[(-1) for j in range(ALPHA)] for i in range(ls)]
nxt[ls - 1][s[ls - 1]] = ls - 1
for i in range(ls - 2, -1,... | ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING 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 VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSI... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for _ in range(int(input())):
s = list(input())
t = list(input())
n = len(s)
pos = [[(-1) for i in range(26)] for i in range(n)]
for i in range(n - 1, -1, -1):
if i + 1 < n:
pos[i] = pos[i + 1].copy()
pos[i][ord(s[i]) - ord("a")] = i
ans = 1
prev = 0
n1 = len(... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | T = int(input())
for i in range(T):
s = input()
t = input()
n = len(s)
m = len(t)
d = []
for _ in range(26):
d.append([])
if set(s).intersection(set(t)) != set(t):
print(-1)
else:
for j in range(n):
while len(d[ord(s[j]) - 97]) < j + 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST IF FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_C... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for _ in range(int(input())):
s = input()
t = input()
nxt = [([-1] * 26) for _ in range(len(s))]
exist = [False] * 26
get_code = lambda c: ord(c) - ord("a")
last = [-1] * 26
first = [-1] * 26
for i in range(len(s)):
c = s[i]
code = get_code(c)
exist[code] = True
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_O... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | from sys import stdin
input = stdin.readline
def printTable(u):
for _ in u:
print(*_)
def getAns(s, t):
l = len(s)
l2 = len(t)
rows, cols = l, 26
u = [[(-1) for i in range(cols)] for j in range(rows)]
currLetterIndices = [-1] * 26
for j in range(26):
if j in s:
... | ASSIGN VAR VAR FUNC_DEF FOR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for i in range(int(input())):
s = input()
inf = 10**12
x = input()
dp = [[inf for i in range(26)] for j in range(len(s))]
d = {}
n = len(s)
for i in range(n - 1, -1, -1):
for j in range(26):
if j == ord(s[i]) - ord("a"):
dp[i][j] = i
elif i + 1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
readline = sys.stdin.readline
Qu = int(readline())
Ans = [None] * Qu
for qu in range(Qu):
T = list(map(lambda x: ord(x) - 97, readline().strip()))
S = list(map(lambda x: ord(x) - 97, readline().strip()))
N = len(S)
M = len(T)
inf = 10**9 + 7
table = [([inf] * 26) for _ in range(M + 1... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR ASSIGN VAR ... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def solve(s, t):
dp = [[float("inf") for i in range(26)] for j in range(len(s))]
for i in range(len(s) - 1, -1, -1):
dp[i][ord(s[i]) - ord("a")] = i
if i + 1 < len(s):
for j in range(26):
dp[i][j] = min(dp[i][j], dp[i + 1][j])
moves = 0
i = 0
j = 0
whi... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VA... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for nt in range(int(input())):
s = input()
t = input()
n = len(s)
d = set(s)
flag = 0
for i in t:
if i not in d:
print(-1)
flag = 1
break
if flag:
continue
dp = [[(-1) for i in range(n)] for j in range(26)]
for i in range(n - 1, -1,... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER FOR V... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | n = int(input())
for _ in range(n):
str1 = input()
str2 = input()
n = len(str1)
m = len(str2)
next_char = [([-1] * n) for _ in range(26)]
for i in range(n - 1, -1, -1):
c = ord(str1[i]) - ord("a")
if i < n - 1:
for j in range(26):
next_char[j][i] = nex... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VA... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def find(x, a):
b = 0
e = len(a) - 1
while b <= e:
m = (b + e) // 2
if 0 < m < n - 1 and a[m] < x < a[m + 1]:
return a[m + 1]
elif a[m] > x:
e = m - 1
else:
b = m + 1
if 0 <= b <= len(a) - 1:
return a[b]
elif 0 <= e <= len(a... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF NUMBER VAR BIN_OP FUNC_CA... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | T = int(input())
for _ in range(T):
s = input()
t = input()
order = {}
for i, char in enumerate(s):
if char in order:
order[char].append(i)
else:
order[char] = [i]
answer = 1
prev = -1
for char in t:
if char not in order:
answer = -... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER AS... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | alphabet = "abcdefghijklmnopqrstuvwxyz"
T = int(input())
for t in range(T):
s = input()
t = input()
ls = len(s)
lt = len(t)
bs = [(0) for _ in range(26)]
bt = [(0) for _ in range(26)]
check = 0
for e in t:
bt[ord(e) - 97] = 1
for e in s:
bs[ord(e) - 97] = 1
for i ... | ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BI... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def search_just_greater(arr, target):
if target >= arr[-1]:
return -1
low = 0
high = len(arr) - 1
while low < high:
mid = low + (high - low) // 2
if arr[mid] <= target:
low = mid + 1
else:
high = mid
return low
for _ in range(int(input())):
... | FUNC_DEF IF VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CAL... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def upperBound(array, k):
low = 0
high = len(array)
while low < high:
mid = (low + high) // 2
if array[mid] < k:
low = mid + 1
else:
high = mid
return low
for _ in range(int(input())):
s = input().strip()
t = input().strip()
array = [[] for _... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR ... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for _ in range(int(input())):
s, t = input(), input()
ss = set(list(s))
flag = False
for i in t:
if i not in ss:
flag = True
break
if flag:
print(-1)
continue
n = len(s)
dp = [list([float("inf")] * 26) for _ in range(n)]
for i in range(n - ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP LIST FUNC_CALL VAR STRING NUMBE... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
input = sys.stdin.readline
def search(arr, x):
if arr[0] >= x:
return arr[0]
if arr[-1] < x:
return -1
lo = 0
hi = len(arr) - 1
ans = hi
while lo <= hi:
m = (lo + hi) // 2
if arr[m] >= x:
hi = m - 1
ans = m
else:
... | IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER VAR RETURN VAR NUMBER IF VAR NUMBER VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RET... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def binary(alpha, k):
global dic, dicle
n = dicle[alpha]
ar = dic[alpha]
if k >= ar[-1]:
ans = n
elif k < ar[0]:
ans = 0
else:
l = 0
r = n - 1
while not (k >= ar[l] and k < ar[l + 1]):
mid = (l + r) // 2
if ar[mid] <= k:
... | FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BI... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for _ in range(int(input())):
s = input()
t = input()
if set(t).difference(set(s)):
print(-1)
else:
nxt_s = [{"a": 0} for _ in range(-1, len(s))]
cur = {}
for i in range(len(s) - 1, -2, -1):
nxt_s[i] = cur.copy()
cur[s[i]] = i
ans = 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR DICT STRING NUMBER VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NU... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
s, t = input()[:-1], input()[:-1]
n, m = len(s), len(t)
nxt = [[(0) for j in range(26)] for i in range(n + 1)]
nxt[-1] = [-1] * 26
for i in range(n - 1, -1, -1):
for j in range(26):
if s[i] == chr... | ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR BI... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for t in range(int(input())):
s = input()
z = input()
c = []
a = []
plus = 0
for i in z:
c.append(i)
plus += 1
count = 0
for i in s:
a.append(i)
count += 1
b = [[(0) for i in range(26)] for j in range(count + 1)]
alpha = [(9999999) for i in range(2... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
input = sys.stdin.readline
t = int(input())
def binary(ar, l, r, pos, n):
m = (l + r) // 2
if m == 0 and ar[m] > pos:
return ar[m]
elif m > 0 and ar[m] > pos and ar[m - 1] <= pos:
return ar[m]
if l < r:
if m > 0 and ar[m - 1] > pos:
return binary(ar, l, ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR VAR VAR RETURN VAR VAR IF VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR VAR IF VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR VAR... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | tt = int(input())
for i in range(tt):
s = input()
t = input()
sm = [[] for i in range(len(s))]
sa = [(-1) for i in range(26)]
cind = 0
start = 0
cnt = 1
s0 = s[0]
for i in range(len(s) - 1, -1, -1):
sm[i] = sa.copy()
sa[int(s[i], base=36) - 10] = i
sa = sm[0].copy... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | t = int(input())
def find(letter, after):
global pos
if letter not in pos.keys():
return -2
if pos[letter][0] > after:
return pos[letter][0]
elif pos[letter][-1] <= after:
return -1
lower = 0
upper = len(pos[letter]) - 1
while upper - lower > 1:
mid = (lower... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR FUNC_CALL VAR RETURN NUMBER IF VAR VAR NUMBER VAR RETURN VAR VAR NUMBER IF VAR VAR NUMBER VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR ASSIG... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | LETTERS = set(list("abcdefghijklmnopqrstuvwxyz"))
def PrepareLettersIndices(s):
s_letters = dict()
for letters in LETTERS:
s_letters[letters] = []
for i in range(len(s)):
s_letters[s[i]].append(i)
return s_letters
def BinSearch(num, numbers):
if num >= numbers[-1]:
return... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF IF VAR VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | tt = int(input())
def find(c, i):
l = 0
r = len(mp[c]) - 1
ret = -1
while l <= r:
m = (l + r) // 2
if mp[c][m] > i:
ret = mp[c][m]
r = m - 1
else:
l = m + 1
return ret
for _ in range(tt):
s = input()
t = input()
mp = [[] for... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VA... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | t = int(input())
for i in range(t):
s = input()
k = input()
b = []
a = []
for j in s:
b.append(j)
for j in k:
a.append(j)
b1 = [[] for j in range(26)]
for j in range(len(b)):
b1[ord(b[j]) - 97].append(j)
dp = [([-1] * 26) for j in range(len(b) + 1)]
for j ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for _ in range(int(input())):
s = input()
t = input()
d = {}
for x in s:
d[x] = 1
for x in t:
if d.get(x, 0) == 0:
print(-1)
break
else:
dp = [([-1] * 26) for i in range(len(s))]
p = [-1] * 26
for i in range(len(s) - 1, -1, -1):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST N... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def next(arr, target):
start = 0
end = len(arr) - 1
ans = -1
while start <= end:
mid = (start + end) // 2
if arr[mid] <= target:
start = mid + 1
else:
ans = mid
end = mid - 1
return ans
def sol():
s = list(input())
t = list(input(... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_C... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def countGreater(arr, k):
l = 0
r = len(arr) - 1
n = len(arr)
leftGreater = n
while l <= r:
m = int(l + (r - l) // 2)
if arr[m] > k:
leftGreater = m
r = m - 1
else:
l = m + 1
return n - leftGreater
T = int(input())
while T:
s = in... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_C... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for _ in range(int(input())):
s = input()
t = input()
d = {}
for i in range(len(s)):
d[s[i]] = 1
flag = True
for i in range(len(t)):
if d.get(t[i]) == None:
flag = False
break
if not flag:
print(-1)
continue
dp = []
ll = [float(... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NONE ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR NUMBER... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | T = int(input().strip())
for _ in range(T):
s = input().strip()
t = input().strip()
lt = len(t)
if lt == 0:
print(0)
continue
s_letters = set(el for el in s)
impossible = False
for el in t:
if el not in s_letters:
impossible = True
break
if... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR EXP... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | T = int(input())
def solve():
S = input()
T = input()
char_to_index = {}
for i, t in enumerate(S):
if t not in char_to_index:
char_to_index[t] = []
char_to_index[t].append(i)
ans = 0, len(S) + 1
for t in T:
if t not in char_to_index:
return -1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR ASSIGN VAR F... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | INF = 1000000.0
def main():
def solve():
ss = input()
tt = input()
ls = len(ss)
nxt = [[INF] * 26]
for i, s in enumerate(ss[::-1]):
nxt.append(nxt[-1].copy())
nxt[-1][ord(s) - ord("a")] = ls - i - 1
nxt.reverse()
ans = 1
pos ... | ASSIGN VAR NUMBER FUNC_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST BIN_OP LIST VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR NUM... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for _ in range(int(input())):
s = [(ord(c) - 97) for c in list(input())]
t = [(ord(c) - 97) for c in list(input())]
pl = [[] for i in range(26)]
for i in range(len(s)):
pl[s[i]].append(i)
pos = -1
j = 0
ans = 1
while j < len(t):
i = t[j]
if pl[i] == []:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN V... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def binarySearch(seq, a):
if not seq:
return -2
n = len(seq)
l = 0
r = len(seq)
while l < r:
m = (l + r) // 2
if seq[m] > a:
r = m
if seq[m] < a:
l = m + 1
if seq[m] == a:
if m == n - 1:
return -1
... | FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR IF VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN VAR BIN_OP VAR NUMBER IF ... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def main():
T = int(input().strip())
for _ in range(T):
s = input().strip()
t = input().strip()
charset = set(s)
if any(c not in charset for c in t):
print(-1)
continue
d = {c: len(s) for c in charset}
jump = [0] * len(s)
for i in r... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CA... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
input = sys.stdin.readline
def solve():
s = [(ord(i) - 97) for i in input().strip()]
t = [(ord(i) - 97) for i in input().strip()]
ss = set(s)
tt = set(t)
for i in tt:
if i not in ss:
print(-1)
return
nxt = [[(-1) for _ in range(26)] for _ in range(le... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER VAR FUNC_CALL V... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for _ in range(int(input())):
s = list(map(lambda x: ord(x) - 97, input()))
t = list(map(lambda x: ord(x) - 97, input()))
if len(set(t) - set(s)) > 0:
print(-1)
continue
dp = [([-1] * 26) for i in range(len(s))]
nextt = [-1] * 26
for i in range(len(s) - 1, -1, -1):
nextt[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR IF FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN ... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | T = int(input())
for _ in range(T):
s = input()
t = input()
n = len(s)
pos = [[] for _ in range(26)]
for i in range(n):
pos[ord(s[i]) - 97].append(i)
val = -1
ans = 1
for x in t:
p = pos[ord(x) - 97]
if not p:
ans = -1
break
l, r = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR AS... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | tests = int(input())
while tests > 0:
s = input()
t = input()
dpList = []
i = len(s) - 1
cd = {}
while i >= 0:
cd[s[i]] = i
dpList.append(cd.copy())
i -= 1
dpList = dpList[::-1]
dpList.append({})
ans = 1
i = 0
ci = 0
while i < len(t):
val =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT WHILE VAR NUMBER ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR DICT ASSIGN VA... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def f(s, t):
dp = [([float("inf")] * 26) for i in range(len(s) + 10)]
for i in reversed(range(len(s))):
dp[i] = dp[i + 1].copy()
dp[i][ord(s[i]) - 97] = i
res = 1
pos = 0
for i in range(len(t)):
if pos == len(s):
pos = 0
res += 1
if dp[pos][ord... | FUNC_DEF ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL ... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | T = int(input())
while T:
T -= 1
s = input()
n = len(s)
t = input()
f = [[n] * 26] * n
for i in range(n - 1, -1, -1):
if i < n - 1:
f[i] = f[i + 1].copy()
f[i][ord(s[i]) - ord("a")] = i
i = 0
res = 1
ok = True
for c in t:
j = ord(c) - ord("a")
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP LIST VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIG... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for _ in range(int(input())):
s1 = input()
s2 = input()
if not set(s2).issubset(set(s1)):
print(-1)
continue
n = len(s1)
l = [([10**9 + 7] * 26) for _ in range(n)]
for i in range(n - 1, 0, -1):
for j in range(26):
l[i - 1][j] = l[i][j]
l[i - 1][ord(s1[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP ... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
input = sys.stdin.readline
def bnsearch(L, x):
start = 0
end = len(L) - 1
while start <= end:
mid = (start + end) // 2
if L[mid] == x:
return mid
if L[mid] > x:
end = mid - 1
else:
start = mid + 1
return start
for i in "... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUN... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for h in range(int(input())):
s = input()
t = input()
dp = [[float("inf") for i in range(26)] for i in range(len(s) + 1)]
dp[-2][ord(s[-1]) - ord("a")] = len(s) - 1
for i in range(len(s) - 2, -1, -1):
for j in range(26):
dp[i][j] = dp[i + 1][j]
dp[i][ord(s[i]) - ord("a")]... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FU... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
def input():
return sys.stdin.readline().rstrip()
DXY = [(0, -1), (1, 0), (0, 1), (-1, 0)]
def slv():
s = input()
n = len(s)
s *= 2
t = input()
m = len(t)
dp = []
for char in range(26):
a = [2 * n] * (2 * n)
for i in range(2 * n):
if s[i] == c... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST BIN_O... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def alpha(x):
return ord(x) - 97
for _ in range(int(input())):
s = input()
t = input()
curi = 0
iters = 1
nexts = [[(-1) for _ in range(len(s) + 1)] for _ in range(26)]
for i in range(26):
for j in range(len(s) - 1, -1, -1):
if alpha(s[j]) == i:
nexts[i]... | FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_C... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def bi_search(a, x):
l, r = 0, len(a) - 1
if a[r] <= x:
return -1
while l < r:
m = (l + r) // 2
if a[m] <= x:
l = m + 1
else:
r = m
return a[r]
def solve(s, t):
pos = [[] for _ in range(26)]
for i, c in enumerate(s):
x = ord(c) - ... | FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR RETURN NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FU... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
input = lambda: sys.stdin.readline().rstrip()
Q = int(input())
for _ in range(Q):
S = [(ord(a) - 97) for a in input()]
T = [(ord(a) - 97) for a in input()]
N = len(S)
S += S
X = [([-1] * 26) for _ in range(N)]
Y = [-1] * 26
for _ in range(2):
for i in range(N)[::-1]:
... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def s_map(s):
m = [[None] * 26] + [([None] * 26) for _ in s]
for prev_i, (prev_x, prev_col, cur_col) in reversed(
list(enumerate(zip(s, m[1:], m), 1))
):
cur_col[:] = prev_col
cur_col[prev_x] = prev_i
return m
def solve(s, t):
if not set(t).issubset(set(s)):
return ... | FUNC_DEF ASSIGN VAR BIN_OP LIST BIN_OP LIST NONE NUMBER BIN_OP LIST NONE NUMBER VAR VAR FOR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF IF FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR BI... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | n = int(input())
for i in range(0, n):
s = input().rstrip()
t = input().rstrip()
L = []
x = list(s)
y = list(t)
for j in range(0, 26):
D = []
L.append(D)
for j in range(0, len(x)):
L[ord(x[j]) - 97].append(j)
M = list(L)
j = 0
tot = 0
G = 0
while j... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | t = int(input())
for _ in range(t):
s = str(input())
t = str(input())
INF = 10**18
n = len(s)
m = len(t)
X = [([INF] * 26) for i in range(n + 5)]
for i in reversed(range(n)):
for j in range(26):
X[i][j] = X[i + 1][j]
X[i][ord(s[i]) - ord("a")] = i
ans = 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.