Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

flags = [True] * (A[-1] + 1)

for a in A:
    if A.count(a) > 1:
        flags[a] = False
    for mul in range(2, A[-1] // a + 1):
        flags[a * mul] = False
print(sum([flags[a] for a in A]))

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
c = Counter(A)

flags = [True] * (A[-1] + 1)

for a in A:
    for mul in range(2, A[-1] // a + 1):
        flags[a * mul] = False
print(sum([flags[a] and c[a] == 1 for a in A]))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
c = 0
for i, ai in enumerate(A):
    for j, aj in enumerate(A):
        if i == j:
            continue
        if ai % aj == 0:
            break
    else:
        c += 1
print(c)


Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
c = Counter(A)

flags = [True] * (A[-1] + 1)

for a in A:
    for mul in range(2, A[-1] // a + 1):
        flags[a * mul] = False
print(sum([flags[a] and c[a] == 1 for a in A]))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

dp = [0] * (N + 1)
for k in range(K):
    sta = [max(i-A[i], 0) for i in range(N)]
    end = [min(i+A[i]+1, N) for i in range(N)]
    for s in sta:
        dp[s] += 1
    for e in end:
        dp[e] -= 1
    for i in range(1, len(dp)-1):
        dp[i] += dp[i-1]
    B = dp[:-1]
    if A == B:
        break
    A = B
    dp = [0] * (N + 1)
 
print(' '.join(map(str, A)))


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

dp = [0] * (N + 1)
for k in range(K):
    sta = [max(i-A[i], 0) for i in range(N)]
    end = [min(i+A[i]+1, N) for i in range(N)]
    for s in sta:
        dp[s] += 1
    for e in end:
        dp[e] -= 1
    for i in range(1, len(dp)-1):
        dp[i] += dp[i-1]
    B = dp[:-1]
    if A == B:
        break
    A = B
    dp = [0] * (N + 1)
 
print(' '.join(map(str, A)))

Buggy python submission (verdict: Time Limit Exceeded):
import math
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))

for _ in range(k):
    B = [0] * n
    for i, a in enumerate(A):
        sta = math.ceil(i-a-0.5)
        end = math.floor(i+a+0.5)
        for j in range(max(0, sta), min(end+1, n)):
            B[j] += 1
    if A == B:
        A = B
        break
    A = B
print(' '.join(map(str, A)))

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

dp = [0] * (N + 1)
for k in range(K):
    sta = [max(i-A[i], 0) for i in range(N)]
    end = [min(i+A[i]+1, N) for i in range(N)]
    for s in sta:
        dp[s] += 1
    for e in end:
        dp[e] -= 1
    for i in range(1, len(dp)-1):
        dp[i] += dp[i-1]
    B = dp[:-1]
    if A == B:
        break
    A = B
    dp = [0] * (N + 1)
 
print(' '.join(map(str, A)))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))

for _ in range(k):
    ranges = [(i-a-0.5, i+a+0.5) for i, a in enumerate(A, start=1)]
    B = []
    for i in range(n):
        count = 0 
        for r in ranges[:i]:
            if r[1] >= i+1:
                count += 1
        for r in ranges[i:]:
            if r[0] <= i+1:
                count += 1
        B.append(count)
    if A == B:
        A = B
        break
    A = B
print(' '.join(map(str, A)))

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

dp = [0] * (N + 1)
for k in range(K):
    sta = [max(i-A[i], 0) for i in range(N)]
    end = [min(i+A[i]+1, N) for i in range(N)]
    for s in sta:
        dp[s] += 1
    for e in end:
        dp[e] -= 1
    for i in range(1, len(dp)-1):
        dp[i] += dp[i-1]
    B = dp[:-1]
    if A == B:
        break
    A = B
    dp = [0] * (N + 1)
 
print(' '.join(map(str, A)))
Buggy python submission (verdict: Runtime Error):
, y = map(int, input().split())
 
a = [0, 300000, 200000, 100000, 0]
ans = 0
 
x = min(x, 4)
y = min(y, 4)
 
ans = a[x] + a[y]
if x == 1 and y == 1:
    ans += 400000
 
print(ans)

Fixed submission:
x, y = map(int, input().split())
 
a = [0, 300000, 200000, 100000, 0]
ans = 0
 
x = min(x, 4)
y = min(y, 4)
 
ans = a[x] + a[y]
if x == 1 and y == 1:
    ans += 400000
 
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd

x, y = map(int, input().split())

a = [0, 300000, 200000, 100000, 0]
ans = 0

x = min(x, 4)
y = min(y, 4)

ans = a[x] + a[y]
if x == 1 and y == 1:
    ans += 400000

print(ans)

Fixed submission:
x, y = map(int, input().split())
 
a = [0, 300000, 200000, 100000, 0]
ans = 0
 
x = min(x, 4)
y = min(y, 4)
 
ans = a[x] + a[y]
if x == 1 and y == 1:
    ans += 400000
 
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd

a, b, c, d = map(int, input().split())

A = (a-1) // c + (a-1) // d - (a-1) // ((c * d) // gcd(c, d))
B = b // c + b // d - b // ((c * d ) // gcd(c, d))

print (b - B - (a - 1 - A))

Fixed submission:
from fractions import gcd

a, b, c, d = map(int, input().split())

A = (a-1) // c + (a-1) // d - (a-1) // ((c * d) // gcd(c, d))
B = b // c + b // d - b // ((c * d ) // gcd(c, d))

print (b - B - (a - 1 - A))
Buggy python submission (verdict: Runtime Error):
	K, A, B = map(int, raw_input().split())

if B - A <= 2:
    print K + 1
    exit()

S = 1

M = min(K, A-1)
K -= M
S += M

S += K / 2 * (B - A)
K %= 2
S += K

print S


Fixed submission:
K, A, B = map(int, raw_input().split())

if B - A <= 2:
    print K + 1
    exit()

S = 1

M = min(K, A-1)
K -= M
S += M

S += K / 2 * (B - A)
K %= 2
S += K

print S
Buggy python submission (verdict: Runtime Error):
T, A, B, C, D = map(int, raw_input().split())

if A + C <= T:
    print B + D
elif C <= T:
    print D
elif A <= T:
    print B
else:
    print 0


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

NA = sum(A)
mv = float('inf')
mi = -1

for i in xrange(N):
    v = abs(NA - A[i] * N)
    if v < mv:
        mv = v
        mi = i

print mi
Buggy python submission (verdict: Runtime Error):
from fractions import Fraction
from collections import Counter

K = input()
A = range(1, 10) + range(19, 100, 10)
N = K - len(A)
diff = 100
target = 19
count = 0

while N > 0:
    N -= 1
    A.append(A[-1]+diff)
    count += 1
    if count == target:
        diff *= 10
        target += 9
        count = 0

for i in xrange(K):
    print A[i]


Fixed submission:
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
print (N-2)/(K-1)+1
Buggy python submission (verdict: Runtime Error):
from fractions import Fraction
from collections import Counter

K = input()
A = range(1, 10) + range(19, 100, 10)
N = K - len(A)
diff = 100
target = 19
count = 0

while N > 0:
    N -= 1
    A.append(A[i]+diff)
    count += 1
    if count == target:
        diff *= 10
        target += 9
        count = 0

for i in xrange(K):
    print A[i]


Fixed submission:
from fractions import Fraction

def calc(a):
    return sum(map(int, list(str(a))))

def comp(a, b):
    return a * calc(b) <= b * calc(a)

MAX = 10**17
K = input()
A = set()
base = 0
front = 1
ok = True
while base < MAX:
    for i in xrange(1, 999):
        tmp = i * front + base
        if tmp <= MAX:
            A.add(tmp)
    base = base * 10 + 9
    front *= 10

A = sorted(list(A), key=lambda x: -x)
m = A[0]
ans = []

for i in xrange(1, len(A)):
    if comp(A[i], m):
        m = A[i]
        ans.append(A[i])

ans.sort()
for i in xrange(K):
    print ans[i]
Buggy python submission (verdict: Runtime Error):
def grundy(N, K):
    if N < K:
        return 0
    while N % K:
        m = N / K + 1
        N -= m
    return N / K

N = input()
ans = 0
for i in xrange(N):
    a, k = map(int, raw_input().split())
    ans ^= grundy(a, k)
print "Takahashi" if ans else "Aoki"


Fixed submission:
H, W = map(int, raw_input().split())

if H > W:
    H, W = W, H

if H == 1 and W == 1:
    print 1
elif H == 1:
    print W - 2
else:
    print (H - 2) * (W - 2)
Buggy python submission (verdict: Runtime Error):
    A = [0 for _ in xrange(10**5+10)]
    N, K = map(int, raw_input().split())
    for i in xrange(N):
        a, b = map(int, raw_input().split())
        A[a] += b
     
    k = 0
    for i in xrange(10**5+10):
        k += A[i]
        if k >= K:
            print i
            break

Fixed submission:
A = [0 for _ in xrange(10**5+10)]
N, K = map(int, raw_input().split())
for i in xrange(N):
    a, b = map(int, raw_input().split())
    A[a] += b

k = 0
for i in xrange(10**5+10):
    k += A[i]
    if k >= K:
        print i
        break
Buggy python submission (verdict: Runtime Error):
a,b,c=input(),input(),input()
print ["NO","YES"][b-a==c-b]

Fixed submission:
a,b,c=map(int,raw_input().split())
print ["NO","YES"][b-a==c-b]
Buggy python submission (verdict: Runtime Error):
print 'No' if sum(map(int, raw_input().split())9 else 'Yes'

Fixed submission:
a,b,c = sorted(map(int, raw_input().split()))
print 'Yes' if a+b==c else 'No'
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
t, a = map(int, raw_input().split())
for i in xrange(N-1):
    new_t, new_a = map(int, raw_input().split())
    dt, da = new_t, new_a
    while new_t < t or new_a < a:
        new_t += dt
        new_a += da
    t, a = new_t, new_a
print t+a


Fixed submission:
N = input()
t, a = map(int, raw_input().split())
for i in xrange(N-1):
    new_t, new_a = map(int, raw_input().split())
    d = max((t-1)/new_t+1, (a-1)/new_a+1, 1)
    t, a = new_t*d, new_a*d
print t+a
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N, K = map(int, raw_input().split())
C = sorted(Counter(raw_input()[0] for _ in xrange(N)).values())
a = C.pop()
b = sum(C)
for i in xrange(a, 0, -1):
    if b/i >= K-1:
        print i
        break
else:
    print 0

Fixed submission:
N, A, B=map(int, raw_input().split())
print sum(not(A<=int(raw_input())<B) for _ in range(N))
Buggy python submission (verdict: Time Limit Exceeded):
S = raw_input()
while True:
    new_S = S.replace('ST', '')
    if len(S) == len(new_S):
        break
    S = new_S
print len(S)


Fixed submission:
S = raw_input()
left = 0
ans = 0
for s in S:
    if s == 'S':
        left += 1
    elif s == 'T' and left > 0:
        left -= 1
        ans += 2
print len(S) - ans

Buggy python submission (verdict: Time Limit Exceeded):
S = raw_input()
while True:
    new_S = S.replace('ST', '')
    if len(S) == len(new_S):
        break
    S = new_S
print len(S)


Fixed submission:
S = raw_input()
left = 0
ans = 0
for s in S:
    if s == 'S':
        left += 1
    elif s == 'T' and left > 0:
        left -= 1
        ans += 2
print len(S) - ans
Buggy python submission (verdict: Runtime Error):
    H, W, N = map(int, raw_input().split())
    dx = [-1, 0, 1, -1, 0, 1, -1, 0, 1]
    dy = [-1, -1, -1, 0, 0, 0, 1, 1, 1]
    board = {}
     
    for i in xrange(N):
        a, b = map(int, raw_input().split())
        for j in xrange(9):
            x, y = a+dx[j], b+dy[j]
            if x <= 1 or x >= H or y <= 1 or y >= W:
                continue
            if (x, y) in board:
                board[(x, y)] += 1
            else:
                board[(x, y)] = 1
    ans = [0] * 10
    for v in board.values():
        ans[v] += 1
    ans[0] = (H-2)*(W-2)-sum(ans)
    for a in ans:
        print a

Fixed submission:
print (input()+input())*input()/2
Buggy python submission (verdict: Runtime Error):
    H, W, N = map(int, raw_input().split())
    dx = [-1, 0, 1, -1, 0, 1, -1, 0, 1]
    dy = [-1, -1, -1, 0, 0, 0, 1, 1, 1]
    board = {}
     
    for i in xrange(N):
        a, b = map(int, raw_input().split())
        for j in xrange(9):
            x, y = a+dx[j], b+dy[j]
            if x <= 1 or x >= H or y <= 1 or y >= W:
                continue
            if (x, y) in board:
                board[(x, y)] += 1
            else:
                board[(x, y)] = 1
    ans = [0] * 10
    for v in board.values():
        ans[v] += 1
    ans[0] = (H-2)*(W-2)-sum(ans)
    for a in ans:
        print a

Fixed submission:
H, W, N = map(int, raw_input().split())
dx = [-1, 0, 1, -1, 0, 1, -1, 0, 1]
dy = [-1, -1, -1, 0, 0, 0, 1, 1, 1]
board = {}

for i in xrange(N):
    a, b = map(int, raw_input().split())
    for j in xrange(9):
        x, y = a+dx[j], b+dy[j]
        if x <= 1 or x >= H or y <= 1 or y >= W:
            continue
        if (x, y) in board:
            board[(x, y)] += 1
        else:
            board[(x, y)] = 1
ans = [0] * 10
for v in board.values():
    ans[v] += 1
ans[0] = (H-2)*(W-2)-sum(ans)
for a in ans:
    print a
Buggy python submission (verdict: Runtime Error):
N, A = map(int, raw_input().split())
a = sorted(map(lambda x:int(x)-A, raw_input().split()))
mem = {}

def rec(p, acm):
    if (p, acm) in mem:
        return mem[(p, acm)]
    if p >= N:
        return 0
    if a[p] > 0 and acm > 0:
        return 0
    mem[(p, acm)] = rec(p+1, acm+a[p]) + rec(p+1, acm)
    if acm+a[p] == 0:
        mem[(p, acm)] += 1
    return mem[(p, acm)]

print rec(0, 0)


Fixed submission:
n, k, x, y = [input() for _ in range(4)]
print x * min(n, k) + y * max(n-k, 0)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
print 'Yes' if all(v % 2 == 0 for v in Counter(raw_input()).values())) else 'No'

Fixed submission:
from collections import Counter
print 'Yes' if all(a%2-1 for a in Counter(raw_input()).values()) else 'No'
Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, raw_input().split())
x = sorted(map(int, raw_input().split()))

def solve(n):
    mem = {}
    def rec(i, a, d):
        if (i, a, d) in mem:
            return mem[(i, a, d)]
        if i >= N:
            return 0
        if a < x[i]:
            return 0
        if d > n:
            return 0
        if x[i] == a and d == n-1:
            mem[(i, a, d)] = rec(i+1, a, d) + 1
        else:
            mem[(i, a, d)] = rec(i+1, a, d) + rec(i+1, a-x[i], d+1)
        return mem[(i, a, d)]
    return rec(0, n*A, 0)

s = 0
for i in xrange(1, N+1):
    s += solve(i)
print s


Fixed submission:
N, A = map(int, raw_input().split())
a = sorted(map(lambda x:int(x)-A, raw_input().split()))
mem = {}

def rec(p, acm):
    if (p, acm) in mem:
        return mem[(p, acm)]
    if p >= N:
        return 0
    if a[p] > 0 and acm > 0:
        return 0
    mem[(p, acm)] = rec(p+1, acm+a[p]) + rec(p+1, acm)
    if acm+a[p] == 0:
        mem[(p, acm)] += 1
    return mem[(p, acm)]

print rec(0, 0)
Buggy python submission (verdict: Runtime Error):
def calc(a, b):
    if a <= 0 or b <= 0:
        return 0
    if a == b:
        return a
    a, b = min(a, b), max(a, b)
    return calc(b-a, a) + 2 * a

N, X = map(int, raw_input().split())
print calc(X, N-X) + N 


Fixed submission:
def calc(a, b):
    if a <= 0 or b <= 0:
        return 0
    if a == b:
        return a
    a, b = min(a, b), max(a, b)
    x = max(1, b / (2 * a))
    return calc(b-x*a, a) + 2 * a * x

N, X = map(int, raw_input().split())
print calc(X, N-X) + N
Buggy python submission (verdict: Runtime Error):
import numpy


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

result = []
past = numpy.array([0] * 26)
ans = 0
for i in range(d):
    past += 1
    t = int(input())
    past[t-1] = 0
    ans += sum(past * -c) + s[i][t-1]
    print(ans)


Fixed submission:
d = int(input())  # 365
c = list(map(int, input().split()))

# 最低限のポイントを確認？
for i in range(d):
    p = list(map(int, input().split()))
    print(p.index(max(p)) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

a.sort()

ma = max(a)
f = [1] * (ma + 1)

ans = 0

for i in a:
    if f[i]:
        if a.count(i) == 1:
            ans += 1
        for j in range(i, min(ma + i, ma + 1), i):
            f[j] = 0

print(ans)

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))

a.sort()

ma = max(a)
f = [1] * (ma + 1)

count = collections.Counter(a)
ans = 0

for i in a:
    if f[i]:
        if count[i] == 1:
            ans += 1
        for j in range(i, min(ma + i, ma + 1), i):
            f[j] = 0

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

a.sort()

ma = max(a)
f = [1] * (ma + 1)

ans = 0

for i in a:
    if f[i]:
        if a.count(i) == 1:
            ans += 1
        for j in range(i, min(ma + i, ma + 1), i):
            f[j] = 0

print(ans)

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))

a.sort()

ma = max(a)
f = [1] * (ma + 1)

count = collections.Counter(a)
ans = 0

for i in a:
    if f[i]:
        if count[i] == 1:
            ans += 1
        for j in range(i, min(ma + i, ma + 1), i):
            f[j] = 0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 8)

n, m = map(int, input().split())

aisles = [[] for _ in range(n)]
michi = [0] * n
num = [float('INF')] * n
loads = []
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if b < a:
        a, b = b, a
    if a == 0:
        loads.append(b)
    aisles[a].append(b)
    aisles[b].append(a)

if len(loads) == 0:
    print("No")
    exit()


def ap(ll, nm, nu):
    for l in ll:
        if num[l] > nu:
            michi[l] = nm
            num[l] = nu
            ap(aisles[l], l, nu + 1)


ap(loads, 0, 1)

print("Yes")
for mi in michi[1:]:
    print(mi + 1)

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(10 ** 8)

n, m = map(int, input().split())

aisles = [[] for _ in range(n)]
visited = [1] + [0] * (n - 1)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    aisles[a].append(b)
    aisles[b].append(a)

q = deque([0])

while q:
    v = q.pop()
    for nex in aisles[v]:
        if visited[nex] != 0:
            continue
        visited[nex] = v + 1
        q.appendleft(nex)

print("Yes")
for point in visited[1:]:
    print(point)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

aisles = [[] for _ in range(n)]
michi = [0] * n
num = [float('INF')] * n
loads = []
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if b < a:
        a, b = b, a
    if a == 0:
        loads.append(b)
    aisles[a].append(b)
    aisles[b].append(a)

if len(loads) == 0:
    print("No")
    exit()


def ap(ll, nm, nu):
    for l in ll:
        if num[l] > nu:
            michi[l] = nm
            num[l] = nu
            ap(aisles[l], l, nu + 1)


ap(loads, 0, 1)

print("Yes")
for mi in michi[1:]:
    print(mi + 1)

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(10 ** 8)

n, m = map(int, input().split())

aisles = [[] for _ in range(n)]
visited = [1] + [0] * (n - 1)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    aisles[a].append(b)
    aisles[b].append(a)

q = deque([0])

while q:
    v = q.pop()
    for nex in aisles[v]:
        if visited[nex] != 0:
            continue
        visited[nex] = v + 1
        q.appendleft(nex)

print("Yes")
for point in visited[1:]:
    print(point)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = [0 for _ in range(n)]
f[0] = 1

v = [0]
s = 0
idx = 0
loop = 0
last = 0

for _ in range(k):
    vi = a[last] - 1
    if not f[vi]:
        f[vi] = 1
        last = vi
        s += 1
        v.append(vi)
    else:
        s += 1
        idx = v.index(vi)
        loop = s - idx
        break

remain = k - s

print(v[idx:][remain % loop] + 1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = [0 for _ in range(n)]
f[0] = 1

v = [1]
s = 0
idx = 0
loop = 0
last = 1
for i in range(k):
    vi = a[last - 1]
    if not f[vi - 1]:
        f[vi - 1] = 1
        last = vi
        s += 1
        v.append(vi)
    else:
        s += 1
        idx = v.index(vi)
        loop = s - idx
        break
else:
    print(vi)
    exit()
remain = k - s
print(v[idx:][remain % loop])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = [0 for _ in range(n)]
f[0] = 1

v = [0]
s = 0
idx = 0
loop = 0
last = 0

for i in range(k):
    vi = a[last] - 1
    if not f[vi]:
        f[vi] = 1
        last = vi
        s += 1
        v.append(vi)
    else:
        s += 1
        idx = v.index(vi)
        loop = s - idx
        break

remain = k - s
print(v[idx:][remain % loop] + 1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = [0 for _ in range(n)]
f[0] = 1

v = [1]
s = 0
idx = 0
loop = 0
last = 1
for i in range(k):
    vi = a[last - 1]
    if not f[vi - 1]:
        f[vi - 1] = 1
        last = vi
        s += 1
        v.append(vi)
    else:
        s += 1
        idx = v.index(vi)
        loop = s - idx
        break
else:
    print(vi)
    exit()
remain = k - s
print(v[idx:][remain % loop])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = [0 for _ in range(n)]
f[0] = 1

v = [1]
s = 0
idx = 0
loop = 0
last = 1
for i in range(k):
    vi = a[last - 1]
    if not f[vi - 1]:
        f[vi - 1] = 1
        last = vi
        s += 1
        v.append(vi)
    else:
        s += 1
        idx = v.index(vi)
        loop = s - idx
        break
remain = k - s
print(v[idx:][remain % loop])

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = [0 for _ in range(n)]
f[0] = 1

v = [1]
s = 0
idx = 0
loop = 0
last = 1
for i in range(k):
    vi = a[last - 1]
    if not f[vi - 1]:
        f[vi - 1] = 1
        last = vi
        s += 1
        v.append(vi)
    else:
        s += 1
        idx = v.index(vi)
        loop = s - idx
        break
else:
    print(vi)
    exit()
remain = k - s
print(v[idx:][remain % loop])
Buggy python submission (verdict: Runtime Error):
for i in range(1010):
    tax8 = int(i * 0.08)
    tax10 = int(i * 0.1)

    if a == tax8 and b == tax10:
        print(i)
        exit()

print(-1)

Fixed submission:
a, b = map(int, input().split())
for i in range(1010):
    tax8 = int(i * 0.08)
    tax10 = int(i * 0.1)

    if a == tax8 and b == tax10:
        print(i)
        exit()

print(-1)