Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input()) 
A = list(map(int, input().split())) 

M = 1000
X = 0

for i in range(N-1):
    if A[i] < A[i+1]:
        X = int(M/A[i])
        M = int(M - X * A[i])
    
	M = M + X * A[i+1]
    X = 0

print(int(M))


Fixed submission:
N = int(input()) 
A = list(map(int, input().split())) 

M = 1000
X = 0

for i in range(N-1):
    if A[i] < A[i+1]:
        X = int(M/A[i])
        M = int(M - X * A[i])
    
    M = M + X * A[i+1]
    X = 0

print(int(M))

Buggy python submission (verdict: Runtime Error):
N = int(input()) 
A = list(map(int, input().split())) 

M = 1000
X = 0

for i in range(N-1):
    if A[i] < A[i+1]:
        X = int(M/A[i])
        M = int(M - X * A[i])
    
	M = M + X * A[i+1]

print(int(M))


Fixed submission:
N = int(input()) 
A = list(map(int, input().split())) 

M = 1000
X = 0

for i in range(N-1):
    if A[i] < A[i+1]:
        X = int(M/A[i])
        M = int(M - X * A[i])
    
    M = M + X * A[i+1]
    X = 0

print(int(M))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = [int(_) for _ in input().split()]

d = sum(P)
min_i = 0
S_left = 0
S_right= 0

for i in range(N):
    S_left = sum(P[:i])
    S_right = sum(P[-(N-i):])
    d_temp = S_left - S_right
    
    if d >= abs(d_temp):
        d = abs(d_temp)
    
    else:
        break

    if d == 0:
        break

print(abs(d))


Fixed submission:
N = int(input())
P = [int(_) for _ in input().split()]

d = sum(P)
L = sum(P)
S_left = 0
S_right= 0

for i in range(N):
    S_left += P[i]
    S_right = L - S_left
    d_temp = S_left - S_right
    
    if d >= abs(d_temp):
        d = abs(d_temp)
    
    else:
        break

    if d == 0:
        break

print(abs(d))
Buggy python submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)] 

p = Q - K
for i in range(N):
    j = A.count(i+1)
    if j > p:
        print('Yes')
    else:
        print('No')
    j = 0


Fixed submission:
S = str(input())

A = ['Sunny','Cloudy','Rainy']
i = 0

if S == 'Sunny':
    i = 1
elif S == 'Cloudy':
    i = 2
else:
    i =0

print(A[i])
Buggy python submission (verdict: Runtime Error):
N = int(input())
primeNum = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999]

pow = 1
time = 0
while True:
    for p in primeNum:
        z = p**pow
        if p <= N:
            if N % z == 0:
                N = int(N / (z))
                time+=1
        else:
            break
    pow+=1
    if pow >= N:
        break

print(time)


Fixed submission:
A,B = input().split()
print(int(A)*int(B))
Buggy python submission (verdict: Runtime Error):
A, B, K = input().split()
A = int(A)
B = int(B)
K = int(K)
if (A + B) - K <= 0:
    Ta = 0
    Ao = 0
else:
    if A > B:
        Ta = (A + B) - K
        Ao = 0
    else:
        Ao = (A + B) - K
        Ta = 0
print(f"{Ta} {Ao}")

Fixed submission:
cookies = [int(x) for x in input().split()]
leftOver = cookies[0] - cookies[2]
takahashi = max(0, leftOver)
print(str(takahashi)+ ' ' + (str(cookies[1]) if takahashi > 0  else str(max(0,cookies[1] - abs(leftOver)))))

Buggy python submission (verdict: Runtime Error):
A, B, K = input().split()
A = int(A)
B = int(B)
K = int(K)

if (A+B) - K <= 0:
    Ta=0
    Ao=0
else:
    if A < B:
        Ta = (A+B) - K
        Ao = 0
    else:
        Ao = (A+B) - K
        Ta = 0

    
print(f"{Ta} {Ao}")

Fixed submission:
cookies = [int(x) for x in input().split()]
leftOver = cookies[0] - cookies[2]
takahashi = max(0, leftOver)
print(str(takahashi)+ ' ' + (str(cookies[1]) if takahashi > 0  else str(max(0,cookies[1] - abs(leftOver)))))

Buggy python submission (verdict: Runtime Error):
A,B,K = input().split()
print(f"{0 if A <= K else A - k} {0 if B <= K else B-k}")


Fixed submission:
cookies = [int(x) for x in input().split()]
leftOver = cookies[0] - cookies[2]
takahashi = max(0, leftOver)
print(str(takahashi)+ ' ' + (str(cookies[1]) if takahashi > 0  else str(max(0,cookies[1] - abs(leftOver)))))
Buggy python submission (verdict: Runtime Error):
N=int(input())
k=0
for i in range(N):
  j=i+1
  if (j%3!=0)&&(j%5!=0):
    k=k+j
print(k)


Fixed submission:
N=int(input())
k=0
for i in range(N):
  j=i+1
  if (j%3!=0)and(j%5!=0):
    k=k+j
print(k)

Buggy python submission (verdict: Runtime Error):
N=int(input())
k=0
for i in range(N):
  if (i%3!=0)&&(i%5!=0):
    k=k+i
print(k)

Fixed submission:
N=int(input())
k=0
for i in range(N):
  j=i+1
  if (j%3!=0)and(j%5!=0):
    k=k+j
print(k)

Buggy python submission (verdict: Runtime Error):
N=int(input())
k=0
for i in range(N):
  if ((i+1)%3!=0)&&((i+1)%5!=0):
    k=k+i
print(k)
  

Fixed submission:
N=int(input())
k=0
for i in range(N):
  j=i+1
  if (j%3!=0)and(j%5!=0):
    k=k+j
print(k)
Buggy python submission (verdict: Runtime Error):
import random
list = []
for i in range(31):
  list.append(random.randint(0,10000))
K = int(input())
print(list[K-1])


Fixed submission:
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(list[K-1])

Buggy python submission (verdict: Runtime Error):
import random
list = []
for i in range(31):
  list.append(random.randint(0,10000))
print(list)
K = int(input())
print(list[K-1])


Fixed submission:
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(list[K-1])

Buggy python submission (verdict: Runtime Error):
import random
list = []
for i in range(31):
  list.append(random.randint(0,100))
K = int(input())
print(list[K-1])


Fixed submission:
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(list[K-1])

Buggy python submission (verdict: Runtime Error):
import random
list = []
for i in range(32):
  list.append(random.randint(0,100))
K = int(input())
print(list[K])


Fixed submission:
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(list[K-1])
Buggy python submission (verdict: Runtime Error):
x = input()
print(x)

if x >=30:
  print('Yes')
else:
  print('No')

Fixed submission:
x = int(input())
# print(x)

if x >=30:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N,K = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

#print(N)
#print(K)
#print(A)

preX = 0
nowX = 1

for i in range(K,N+1):
#  print(str(i)+'学期')
  if i == K:
    for x in range(K):
      nowX *= A[x]
  else:
    nowX = int(preX / A[i-K-1]) * A[i-1]
#    print(str(preX) +', '+ str(nowX))
    if preX < nowX:
      print('Yes')
    else:
      print('No')
  preX = nowX
  

Fixed submission:
N,K = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

#print(N)
#print(K)
#print(A)

preX = 0
nowX = 1

for i in range(K+1,N+1):
#  print(str(i)+'学期')
#  if i == K:
#    for x in range(K):
#      nowX *= A[x]
#  else:
#    nowX = int(preX / A[i-K-1]) * A[i-1]
#    print(str(preX) +', '+ str(nowX))
#    if preX < nowX:
#      print('Yes')
#    else:
#      print('No')
#  preX = nowX

  if A[i-K-1] < A[i-1]:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N,K = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

#print(N)
#print(K)
#print(A)

preX = -1
nowX = 1

for i in range(K,N+1):
#  print(str(i)+'学期')
  if i == K:
    for x in range(K):
      nowX *= A[x]
  else:
    nowX = int(preX / A[i-K-1] * A[i-1])
#    print(str(preX) +', '+ str(nowX))
    if preX < nowX:
      print('Yes')
    else:
      print('No')
  preX = nowX
  

Fixed submission:
N,K = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

#print(N)
#print(K)
#print(A)

preX = 0
nowX = 1

for i in range(K+1,N+1):
#  print(str(i)+'学期')
#  if i == K:
#    for x in range(K):
#      nowX *= A[x]
#  else:
#    nowX = int(preX / A[i-K-1]) * A[i-1]
#    print(str(preX) +', '+ str(nowX))
#    if preX < nowX:
#      print('Yes')
#    else:
#      print('No')
#  preX = nowX

  if A[i-K-1] < A[i-1]:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N,K = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

#print(N)
#print(K)
#print(A)

preX = 0
nowX = 1

for i in range(K,N+1):
#  print(str(i)+'学期')
  for x in range(K):
    nowX *= A[i-x-1]
#  print(nowX)
  if preX != 0:
    if preX < nowX:
      print('Yes')
    else:
      print('No')
  preX = nowX
  nowX = 1
  

Fixed submission:
N,K = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

#print(N)
#print(K)
#print(A)

preX = 0
nowX = 1

for i in range(K+1,N+1):
#  print(str(i)+'学期')
#  if i == K:
#    for x in range(K):
#      nowX *= A[x]
#  else:
#    nowX = int(preX / A[i-K-1]) * A[i-1]
#    print(str(preX) +', '+ str(nowX))
#    if preX < nowX:
#      print('Yes')
#    else:
#      print('No')
#  preX = nowX

  if A[i-K-1] < A[i-1]:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())

#print(N)
#print(A)

syozi = 1000
kabu = 0

for i in range(N-1):
#  print(str(i)+': '+ str(A[i]) + ', ' + str(kabu) + ', ' + str(syozi) )
  if A[i] < A[i+1]:
    kabu = syozi // A[i] 
    syozi = int( syozi % A[i] )
  elif A[i] > A[i+1]:
    syozi += A[i] * kabu
    kabu = 0
  else:
    pass
#  print( str(i)+': '+str(A[i]) + ', ' + str(kabu) + ', ' + str(syozi) )

if A[N-2] < A[N-1]:
  syozi += A[N-1] * kabu
  kabu = 0

print(syozi)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

money = 1000
ticket = 0
for i in range(N - 1):
    # buy
    if A[i] < A[i + 1]:
        ticket += money // A[i]
        money -= (money // A[i]) * A[i]
    elif A[i] == A[i + 1]:
        pass
    # sell
    else:
        money += A[i] * ticket
        ticket = 0

money += A[-1] * ticket

print(money)
Buggy python submission (verdict: Runtime Error):
s=input()
flag = True
for i in range(len(s)):
  if (i % 2 == 0 and s[i] == 'L') or (i % 2 == 1 and s[i] == 'R')
    flag = False
if flag:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
flag = True
for i in range(len(s)):
    if (i % 2 == 0 and s[i] == 'L') or (i % 2 == 1 and s[i] == 'R'):
        flag = False
if flag:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s=input()
flag = True
for i in range(n):
  if (i % 2 == 0 and s[i] == 'L') or (i % 2 == 1 and s[i] == 'R')
    flag = False
if flag:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
flag = True
for i in range(len(s)):
    if (i % 2 == 0 and s[i] == 'L') or (i % 2 == 1 and s[i] == 'R'):
        flag = False
if flag:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
k, x = map(int, input().split())
i = max(−1000000, x - k + 1)
while i <= min(1000000, x + k - 1):
  print(i, end=" ")
  i += 1

Fixed submission:
k, x = map(int, input().split())
i = max(-1000000, x - k + 1)
while i <= min(1000000, x + k - 1):
  print(i, end=" ")
  i += 1
Buggy python submission (verdict: Runtime Error):
s=input()
print "Yes" if s.count("AC") else "No"


Fixed submission:
print "Yes" if raw_input().count("AC") else "No"
Buggy python submission (verdict: Time Limit Exceeded):
from random import random, randint

K = 26
d = int(input())

c = list(map(int, input().split()))

s = []
for i in range(d):
    q = list(map(int, input().split()))
    s.append(q)

ans = []
last = [-1 for i in range(K)]
for i in range(d):
    x = []
    for j in range(K):
        x.append(pow(s[i][j] * c[j] * (i - last[j]), 3))

    sum = 0
    for j in range(K):
        sum += x[j]

    for j in range(K):
        x[j] /= sum

    prob = random()
    cur = 0
    for j in range(K):
        if cur + x[j] <= prob:
            cur += x[j]
            continue
        ans.append(j)
        last[j] = i
        break


def get_result():
    res = 0
    last = [-1 for i in range(K)]
    for i in range(d):
        res += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(K):
            res -= c[j] * (i - last[j])
    return res


# print(get_result())
for qq in range(1000):
    i = randint(0, d - 1)
    nw = randint(0, K - 1)

    old = ans[i]
    old_res = get_result()

    ans[i] = nw
    res = get_result()

    if res < old_res:
        ans[i] = old

    # print(get_result())

for u in ans:
    print(u + 1)

Fixed submission:
from random import random

K = 26
d = int(input())

c = list(map(int, input().split()))

s = []
for i in range(d):
    q = list(map(int, input().split()))
    s.append(q)

ans = []
last = [-1 for i in range(K)]
for i in range(d):
    x = []
    for j in range(K):
        x.append(pow(s[i][j] * s[i][j] * s[i][j] * c[j] * (i - last[j]) * c[j] * (i - last[j]), 2))

    sum = 0
    for j in range(K):
        sum += x[j]

    for j in range(K):
        x[j] /= sum

    prob = random()
    cur = 0
    for j in range(K):
        if cur + x[j] <= prob:
            cur += x[j]
            continue
        ans.append(j)
        last[j] = i
        break


def get_result():
    res = 0
    last = [-1 for i in range(K)]
    for i in range(d):
        res += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(K):
            res -= c[j] * (i - last[j])
    return res


# print(get_result())
for u in ans:
    print(u + 1)
Buggy python submission (verdict: Runtime Error):
N=int(input());R,d,f,s,x=sorted(list(map(int,input().split()))for i in range(N))+[(2e9,0)],[0]*N+[1],[0]*N,1,N
for i in range(N-1,-1,-1):
	while R[x][0]<sum(R[i]):x=f[x]
	d[i]=s=(s+d[x])%998244353;f[i],x=x,i
print(s)

Fixed submission:
print("YNeos"[2-len(set(input()))::2])
Buggy python submission (verdict: Runtime Error):
N,A,B=map(int,input().split());print(N/B*A+min(N%B,A))

Fixed submission:
N,A,B=map(int,input().split());B+=A;print(N//B*A+min(N%B,A))
Buggy python submission (verdict: Runtime Error):
S,f=__import__('collections').deque(input()),0
for _ in range(int(input())):
	T=input()
	if'2'>T:f=1-f
	else:S.insert(0 if(T[2]<'2')^f else len(S),T[4])
if f:S.reverse()
print(*S,sep='')

Fixed submission:
S,f=__import__('collections').deque(input()),0
for _ in range(int(input())):
	T=input()
	if T<'2':f=1-f
	else:(S.appendleft if (T[2]<'2')^f else S.append)(T[4])
if f:S.reverse()
print(*S,sep='')

Buggy python submission (verdict: Runtime Error):
S,f=__import__('collections').deque(input()),0
for _ in range(int(input())):
	T=input()
	if'2'>T:f=1-f
	else:S.insert(0if(T[2]<'2')^f else len(S),T[4])
if f:S.reverse()
print(*S,sep='')

Fixed submission:
S,f=__import__('collections').deque(input()),0
for _ in range(int(input())):
	T=input()
	if T<'2':f=1-f
	else:(S.appendleft if (T[2]<'2')^f else S.append)(T[4])
if f:S.reverse()
print(*S,sep='')

Buggy python submission (verdict: Time Limit Exceeded):
S=__import__('collections').deque(input())
for _ in range(int(input())):
	T=input()
	if T<'2':S.reverse()
	else:(S.appendleft if T[2]<'2'else S.append)(T[4])
print(*S,sep='')

Fixed submission:
S,f=__import__('collections').deque(input()),0
for _ in range(int(input())):
	T=input()
	if T<'2':f=1-f
	else:(S.appendleft if (T[2]<'2')^f else S.append)(T[4])
if f:S.reverse()
print(*S,sep='')

Buggy python submission (verdict: Time Limit Exceeded):
S=__import__('collections').deque(input())
for _ in range(int(input())):
	T=input()
	if T<'2':S.reverse()
	else:(S.appendleft if T[2]<'2' else S.append)(T[4])
print(*S,sep='')

Fixed submission:
S,f=__import__('collections').deque(input()),0
for _ in range(int(input())):
	T=input()
	if T<'2':f=1-f
	else:(S.appendleft if (T[2]<'2')^f else S.append)(T[4])
if f:S.reverse()
print(*S,sep='')
Buggy python submission (verdict: Runtime Error):
N,P=map(int,input().split());S,a,i,j,c=[*map(int,input())],0,0,1,[1]+[0]*P
if 10%P:
	for v in S[::-1]:i=(i+v*j)%P;j=j*10%P;a+=c[i];c[i]+=1
else:
	for i,v in enumerate(S):
		if v%P<1:a+=i+1
print(a)

Fixed submission:
N,P=map(int,input().split());S,a,i,j,c=list(map(int,input())),0,0,1,[1]+[0]*P
if 10%P:
	for v in S[::-1]:i=(i+v*j)%P;j=j*10%P;a+=c[i];c[i]+=1
else:
	for i,v in enumerate(S):
		if v%P<1:a+=i+1
print(a)
Buggy python submission (verdict: Runtime Error):
(s,t),(a,b),u=input().split(),map(int,input().split()),input();print(a-(s==u),b-(t--u))

Fixed submission:
(s,t),(a,b),u=input().split(),map(int,input().split()),input();print(a-(s==u),b-(t==u))
Buggy python submission (verdict: Runtime Error):
input();a=list(map(int,input().split()));print("YNEOS"[len(A)>len(set(A))::2])

Fixed submission:
input();A=list(map(int,input().split()));print("YNEOS"[len(A)>len(set(A))::2])
Buggy python submission (verdict: Runtime Error):
i=lambda:map(int,input().split())
N,Q=i()
adj=[[] for _ in range(N)]
for _ in range(N-1):
  a,b=i()
  adj[a-1].append(b-1)
  adj[b-1].append(a-1)
V = [0 for _ in range(N)]
for _ in range(Q):
  p,x=i()
  V[p-1]+=x
def dfs(cur, prv):
  for nxt in adj[cur]:
    if nxt == prv: continue
    V[nxt] += V[cur]
    dfs(nxt, cur)
dfs(0,-1)
print(' '.join(map(str, V)))

Fixed submission:
i=lambda:map(int,input().split())
N,Q=i()
adj=[[] for _ in range(N)]
for _ in range(N-1):
  a,b=i()
  adj[a-1].append(b-1)
  adj[b-1].append(a-1)
V = [0 for _ in range(N)]
for _ in range(Q):
  p,x=i()
  V[p-1]+=x
par = [-1 for _ in range(N)]
q = [0]
for cur in q:
  if par[cur] != -1: V[cur] += V[par[cur]]
  for nxt in adj[cur]:
    if nxt == par[cur]: continue
    par[nxt] = cur
    q.append(nxt)
print(' '.join(map(str, V)))
Buggy python submission (verdict: Runtime Error):
s,t=([chr(c)-chr('a') for c in input()]for _ in'xx')
if set(t)-set(s):
  print(-1)
else:
  u=s+s
  nxt = [None for _ in range(len(u)+1)]
  nxt[len(u)]=[0 for _ in range(26)]
  for i in range(len(u)-1,-1,-1):
    nxt[i] = [v+1 for v in nxt[i+1]]
    nxt[i][u[i]]=0
  p = 0
  for c in t:
    p += nxt[p%len(s)][c]+1
  print(p)

Fixed submission:
s,t=([ord(c)-ord('a') for c in input()]for _ in'xx')
if set(t)-set(s):
  print(-1)
else:
  u=s+s
  nxt = [None for _ in range(len(u)+1)]
  nxt[len(u)]=[0 for _ in range(26)]
  for i in range(len(u)-1,-1,-1):
    nxt[i] = [v+1 for v in nxt[i+1]]
    nxt[i][u[i]]=0
  p = 0
  for c in t:
    p += nxt[p%len(s)][c]+1
  print(p)
Buggy python submission (verdict: Runtime Error):
input()
def f(a):
  a = int(a)
  r = 0
  while a % 2 == 0:
    a /= 2
    r += 1
  return r
print(sum(map(f,input.split())))

Fixed submission:
input()
def f(a):
  a = int(a)
  r = 0
  while a % 2 == 0:
    a /= 2
    r += 1
  return r
print(sum(map(f, input().split())))
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
x = [tuple(map(int, input().split())) for _ in range(n)]
from itertools import *
res = 0
for a in product([-1, 1], [-1, 1], [-1, 1]):
  res = max(res, sum(sorted(((sum(i*j for i,j in zip(a,t)) for t in x),reverse=True)[:m]))
print(res)

Fixed submission:
n,m = map(int, input().split())
x = [tuple(map(int, input().split())) for _ in range(n)]
from itertools import *
res = 0
for a in product([-1, 1], [-1, 1], [-1, 1]):
  res = max(res, sum(sorted((sum(i*j for i,j in zip(a,t)) for t in x),reverse=True)[:m]))
print(res)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = []
na = ["a","b", "c", "d", "e", "f", "g",
        "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
        "r", "s", "t", "u", "v", "w", "x", "y", "z"]
name = ""

if n < 26:
    h.append(n)
else:
    while n >= 27:
        tmp = n%26
        n //= 26
        h.append(tmp)
        print(n)

    print(n)
    if n != 0:
        h.append(n)

h = h[::-1]
if h[-1] == 0:
    h.pop(-1)
    for i in h:
        name += na[-i]
else:
    for i in h:
        name += na[-i-1]

print(name)

Fixed submission:
n = int(input())
h = []
tmp = ["a", "b", "c", "d", "e", "f", "g",
       "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
        "r", "s", "t", "u", "v", "w", "x", "y", "z"]
name = ""

while n != 0:
    mod = n % 26
    h.append(mod)
    n //= 26
    if mod == 0:
        n -= 1
h.reverse()
for i in h:
    name += tmp[i - 1]
print(name)
Buggy python submission (verdict: Runtime Error):
n, a, b = list(map(int, input().split(' ')))
tmp = 0
count = 0
if a == 0:
    print(0)
while count < 10**100:
    n -= a
    tmp += a
    if n <= 0:
        print(tmp + n)
        break
    n -= b
    if n <= 0:
        print(tmp)
        break
    

Fixed submission:
s = list(input())
if s[0] == s[1] == s[2]:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = list(map(int, input().split(' ')))
tmp = 0
count = 0
if a == 0:
    print(0)
elif n % (a+b) == 0:
    print(a*(n // (a+b)))
elif n % (a+b) == a:
    print(a*(n // (a+b)+1))
else:
    while count < 10**100:
        n -= a
        tmp += a
        if n <= 0:
            print(tmp + n)
            break
        n -= b
        if n <= 0:
            print(tmp)
            break
    

Fixed submission:
n, a, b = list(map(int, input().split(' ')))
if a == 0:
    print(0)
elif n % (a+b) <= a:
    print(a*(n // (a+b))+ n % (a+b))
else:
    print( a*(n // (a+b))+a)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = list(map(int, input().split(' ')))
tmp = 0
count = 0
if a == 0:
    print(0)
else:
    while count < 10**100:
        n -= a
        tmp += a
        if n <= 0:
            print(tmp + n)
            break
        n -= b
        if n <= 0:
            print(tmp)
            break
    

Fixed submission:
n, a, b = list(map(int, input().split(' ')))
if a == 0:
    print(0)
elif n % (a+b) <= a:
    print(a*(n // (a+b))+ n % (a+b))
else:
    print( a*(n // (a+b))+a)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = list(map(int, input().split(' ')))
tmp = 0
count = 0
if a == 0:
    print(0)
    exit(0)
while count < 10**100:
    n -= a
    tmp += a
    if n <= 0:
        print(tmp + n)
        break
    n -= b
    if n <= 0:
        print(tmp)
        break
    

Fixed submission:
n, a, b = list(map(int, input().split(' ')))
if a == 0:
    print(0)
elif n % (a+b) <= a:
    print(a*(n // (a+b))+ n % (a+b))
else:
    print( a*(n // (a+b))+a)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = list(map(int, input().split(' ')))
tmp = 0
count = 0
while count < 10**100:
    n -= a
    tmp += a
    if n <= 0:
        print(tmp + n)
        break
    n -= b
    if n <= 0:
        print(tmp)
        break
    

Fixed submission:
n, a, b = list(map(int, input().split(' ')))
if a == 0:
    print(0)
elif n % (a+b) <= a:
    print(a*(n // (a+b))+ n % (a+b))
else:
    print( a*(n // (a+b))+a)