Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = sorted(map(int, input().split()))[::-1]
q = sorted(map(int, input().split()))[::-1]
r = sorted(map(int, input().split()))[::-1]

z = 0
red, green = 0, 0
ans = 0
while True:
    finish = True
    if p[x] <= q[y]:
        if z < c and p[x] < r[z]:
            x -= 1
            z += 1
            finish = False
    else:
        if z < c and q[y] < r[z]:
            y -= 1
            z += 1
            finish = False
    if finish:
        break
print(sum(p[:x]) + sum(q[:y]) + sum(q[:z]))


Fixed submission:
x, y, a, b, c = map(int, input().split())
p = sorted(map(int, input().split()))[::-1]
q = sorted(map(int, input().split()))[::-1]
r = sorted(map(int, input().split()))[::-1]

x, y = x-1, y-1
z = 0
red, green = 0, 0
ans = 0
while True:
    finish = True
    if p[x] <= q[y] or y < 0:
        if z < c and p[x] < r[z]:
            x -= 1
            z += 1
            finish = False
    elif p[x] >= q[y] or x < 0:
        if z < c and q[y] < r[z]:
            y -= 1
            z += 1
            finish = False
    if finish:
        break
print(sum(p[:x+1]) + sum(q[:y+1]) + sum(r[:z]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
dic = {}
ans = {}
for item in a:
    if item in dic.keys():
        dic[item] += 1
    else:
        dic[item] = 1

all_ans = sum([item * (item - 1) // 2 for item in dic.values()])

for i in range(n):
    print(all_ans - dic[a[i]] + 1)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dic = {}
ans = {}
for item in a:
    if item in dic.keys():
        dic[item] += 1
    else:
        dic[item] = 1

all_ans = sum([item * (item - 1) // 2 for item in dic.values()])

for i in range(n):
    print(all_ans - dic[a[i]] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
dic = {}
ans = {}
for item in a:
    if item in dic.keys():
        dic[item] += 1
    else:
        dic[item] = 1

for key in dic.keys():
    tmp = 0
    for key2 in dic.keys():
        if key == key2:
            tmp += (dic[key2]-1) * (dic[key2]-2) // 2
        else:
            tmp += (dic[key2]) * (dic[key2]-1) // 2
    ans[key] = tmp

for i in range(n):
    print(ans[a[i]])


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dic = {}
ans = {}
for item in a:
    if item in dic.keys():
        dic[item] += 1
    else:
        dic[item] = 1

all_ans = sum([item * (item - 1) // 2 for item in dic.values()])

for i in range(n):
    print(all_ans - dic[a[i]] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n, k = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
arr = np.zeros(n-k+1)

for i in range(k):
    arr += np.array(p[i:n-k+i+1]) / 2

arr += k / 2

print(np.max(arr))


Fixed submission:
def exp(a):
    return (a + 1) / 2

n, k = map(int, input().split())
p = list(map(int, input().split()))

tmp = [0] * (n + 1) 
ans = 0

for i in range(1, n+1):
    if i <= k:
        tmp[i] = tmp[i-1] + exp(p[i-1])
    else:
        tmp[i] = tmp[i-1] - exp(p[i-k-1]) + exp(p[i-1])

print(max(tmp))

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

ans = 0

for i in range(n-k+1):
    tmp = sum(p[i:i+k]) / 2 + k / 2
    if ans < tmp:
        ans = tmp

print(ans)


Fixed submission:
def exp(a):
    return (a + 1) / 2

n, k = map(int, input().split())
p = list(map(int, input().split()))

tmp = [0] * (n + 1) 
ans = 0

for i in range(1, n+1):
    if i <= k:
        tmp[i] = tmp[i-1] + exp(p[i-1])
    else:
        tmp[i] = tmp[i-1] - exp(p[i-k-1]) + exp(p[i-1])

print(max(tmp))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce

CONST = 10 ** 9 + 7

def lcm(list_):
    return reduce(lambda x, y: x * y // gcd(x, y), list_)

n = int(input())
a = list(map(int, input().split()))

l = lcm(a)
total = 0

for a_ in a:
    total += l // a_
    if total >= CONST:
        total %= CONST

print(total)


Fixed submission:
from fractions import gcd
from functools import reduce

MOD = 10 ** 9 + 7

def lcm(list_):
    return reduce(lambda x, y: x // gcd(x, y) * y,
                  list_)

n = int(input())
a = list(map(int, input().split()))

l = lcm(a)
total = 0

for a_ in a:
    total += l // a_

print(total % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
n = h * w
INF = 1 << 30

field = []
for i in range(h):
    field.append(input())

dist = [[INF] * n for _ in range(n)]

for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            continue
        if j + 1 < w and field[i][j+1] != '#':
            dist[i * w + j][i * w + j + 1] = 1
            dist[i * w + j + 1][i * w + j] = 1
        if i + 1 < h and field[i+1][j] != '#':
            dist[i * w + j][(i+1) * w + j] = 1
            dist[(i+1) * w + j][i * w + j] = 1

# Warshall-Floyd 
for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k])

ans = 0

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if dist[i][j] == INF:
            continue
        ans = max(ans, dist[i][j])

print(ans)



Fixed submission:
h, w = map(int, input().split())
n = h * w
INF = 1 << 30

field = []
for i in range(h):
    field.append(input())

dist = [[INF] * n for _ in range(n)]

for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            continue
        if j + 1 < w and field[i][j+1] != '#':
            dist[i * w + j][i * w + j + 1] = 1
            dist[i * w + j + 1][i * w + j] = 1
        if i + 1 < h and field[i+1][j] != '#':
            dist[i * w + j][(i+1) * w + j] = 1
            dist[(i+1) * w + j][i * w + j] = 1

# Warshall-Floyd 
for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k])

ans = 0

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if dist[i][j] == INF:
            continue
        ans = max(ans, dist[i][j])

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
print(s.count('ABC')

Fixed submission:
N = int(input())
S = input()

count = 0
for i in range(len(S) - 2):
    if S[i:i+3] == 'ABC':
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
a = list(map(int, input().split()))

m = int(math.log2(max(a))) + 1

total = 0
num = 1
while True:
    if num == n:
        break
    p, q = 0, 0
    for i in range(0, n - num):
        p += (a[i] << m * (n-num-i-1)) % 1000000007
        q += a[num + i] << m * (n-num-i-1) % 1000000007
    r = p ^ q
    for i in range(0, n - num):
        total += r % (2 ** m)
        r = r >> m
    num += 1

print(total % 1000000007)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
bits = [0] * 60
MOD = 10**9 + 7

for a in A:
    div = a
    i = 0
    while True:
        div, mod = div // 2, div % 2
        bits[i] += mod
        i += 1
        if div == 0:
            break

ans = 0
for i in range(60):
    ans += bits[i] * (n-bits[i]) * 2 ** i % MOD
print(ans % MOD)

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

n = int(input())
a = list(map(int, input().split()))

m = int(math.log2(max(a))) + 1

total = 0
num = 1
while True:
    if num == n:
        break
    p, q = 0, 0
    for i in range(0, n - num):
        p += a[i] << m * (n-num-i-1)
        q += a[num + i] << m * (n-num-i-1)
    r = p ^ q
    for i in range(0, n - num):
        total += (r % (2 ** m)) % 1000000007
        r = r >> m
    num += 1

print(total % 1000000007)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
bits = [0] * 60
MOD = 10**9 + 7

for a in A:
    div = a
    i = 0
    while True:
        div, mod = div // 2, div % 2
        bits[i] += mod
        i += 1
        if div == 0:
            break

ans = 0
for i in range(60):
    ans += bits[i] * (n-bits[i]) * 2 ** i % MOD
print(ans % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

keys = []

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            keys.append(''.join([s[i], s[j], s[k]]))

print(len(set(keys)))


Fixed submission:
n = int(input())
s = input()

keys = []

for i in range(10):
    i_str = str(i)
    if i_str not in s:
        continue
    else:
        t = s[s.index(i_str)+1:]
        for j in range(10):
            j_str = str(j)
            if j_str not in t:
                continue
            else:
                u = t[t.index(j_str)+1:]
                for k in range(10):
                    k_str = str(k)
                    if k_str in u:
                        keys.append(i_str + j_str + k_str)

print(len(keys))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

keys = []

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            keys.append(s[i]+s[j]+s[k])

print(len(set(keys)))


Fixed submission:
n = int(input())
s = input()

keys = []

for i in range(10):
    i_str = str(i)
    if i_str not in s:
        continue
    else:
        t = s[s.index(i_str)+1:]
        for j in range(10):
            j_str = str(j)
            if j_str not in t:
                continue
            else:
                u = t[t.index(j_str)+1:]
                for k in range(10):
                    k_str = str(k)
                    if k_str in u:
                        keys.append(i_str + j_str + k_str)

print(len(keys))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = sorted([int(item) for item in input().split(' ')])
count = 0
 
for i in range(N-2):
    for j in range(i+1, N-1):
        low = j + 1
        high = N - 1
        idx = (low + high + 1) // 2 
        for _ in range(10):
            if low == high:
                if not l[i] + l[j] > l[idx]:
                    idx -= 1
                break
            if l[i] + l[j] > l[idx]:
                low = idx
                idx = (low + high + 1) // 2
            else:
                high = idx - 1
                idx = (low + high + 1) // 2
        count += idx - j
print(count)

Fixed submission:
import bisect
n = int(input())
l = sorted(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i+1, n):
        end = bisect.bisect_left(l, l[i]+l[j])
        ans += end - j - 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = sorted([int(item) for item in input().split(' ')])
count = 0
 
for i in range(N):
    kmax = N
    for j in range(N-1, i, -1):
        for k in range(j+1, kmax):
            if l[i] + l[j] > l[k]:
                count += 1
            else:
                kmax -= 1
                break
print(count)

Fixed submission:
import bisect
n = int(input())
l = sorted(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i+1, n):
        end = bisect.bisect_left(l, l[i]+l[j])
        ans += end - j - 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = sorted([int(item) for item in input().split(' ')])
count = 0

def binary_search(count, a, b, l):
    if len(l) == 0:
        return count
    center = len(l) // 2
    if a + b > l[center]:
        count += center + 1
        return binary_search(count, a, b, l[center+1:])
    else:
        return binary_search(count, a, b, l[:center])


for i in range(N):
    for j in range(i + 1, N):
        l_remained = l[j + 1:]
        count = binary_search(count, l[i], l[j], l_remained)

print(count)


Fixed submission:
import bisect
n = int(input())
l = sorted(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i+1, n):
        end = bisect.bisect_left(l, l[i]+l[j])
        ans += end - j - 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = sorted([int(item) for item in input().split(' ')])
count = 0

for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if l[i] + l[j] > l[k]:
                count += 1
            else:
                break

print(count)


Fixed submission:
import bisect
n = int(input())
l = sorted(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i+1, n):
        end = bisect.bisect_left(l, l[i]+l[j])
        ans += end - j - 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
points = [k] * n

for i in range(q):
    a = int(input()) - 1
    for j in range(n):
        if j != a:
            points[j] -= 1

for i in range(n):
    print('Yes' if points[i] > 0 else 'No')


Fixed submission:
n, k, q = map(int, input().split())
points = [0] * n

for _ in range(q):
    a = int(input()) - 1
    points[a] += 1

for i in range(n):
    print('Yes' if k - q + points[i] > 0 else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for _ in range(n):
    s.append(input())

count = 0
for i in range(n):
    for j in range(i+1, n):
        char_i = [0 for _ in range(26)]
        char_j = [0 for _ in range(26)]
        for c in s[i]:
            char_i[ord(c) - 97] += 1
        for c in s[j]:
            char_j[ord(c) - 97] += 1
        if char_i == char_j:
            count += 1

print(count)


Fixed submission:
n = int(input())
s_list = []
for _ in range(n):
    s_list.append(''.join(sorted(input())))

s_list = sorted(s_list)

count = 0
total = 0
s_prev = s_list[0]
for s in s_list[1:]:
    if s_prev == s:
        count += 1
    else:
        if count > 0:
            total += count * (count + 1) // 2
            count = 0
    s_prev = s

if count > 0:
    total += count * (count + 1) // 2

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for _ in range(n):
    s.append(input())

num_char = [[0 for _ in range(26)] for _ in range(n)]
for i in range(n):
    for c in s[i]:
        num_char[i][ord(c) - 97] += 1

count = 0
for i in range(n):
    for j in range(i+1, n):
        if num_char[i] == num_char[j]:
            count += 1

print(count)


Fixed submission:
n = int(input())
s_list = []
for _ in range(n):
    s_list.append(''.join(sorted(input())))

s_list = sorted(s_list)

count = 0
total = 0
s_prev = s_list[0]
for s in s_list[1:]:
    if s_prev == s:
        count += 1
    else:
        if count > 0:
            total += count * (count + 1) // 2
            count = 0
    s_prev = s

if count > 0:
    total += count * (count + 1) // 2

print(total)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9 + 7

import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = []
for _ in range(m):
    a.append(int(input()))

# i段目にたどり着く方法
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0

for i in range(2, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % MOD if i not in a else 0

print(dp[-1])

Fixed submission:
MOD = 10**9 + 7

import sys
input = sys.stdin.readline

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

# i段目にたどり着く方法
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if a[1] == 0 else 0

for i in range(2, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % MOD if a[i] == 0 else 0

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9 + 7

n, m = map(int, input().split())
a = []
for _ in range(m):
    a.append(int(input()))

# i段目にたどり着く方法
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0

for i in range(2, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % MOD if i not in a else 0

print(dp[-1])

Fixed submission:
MOD = 10**9 + 7

import sys
input = sys.stdin.readline

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

# i段目にたどり着く方法
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if a[1] == 0 else 0

for i in range(2, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % MOD if a[i] == 0 else 0

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

a.append(a[0])
neighbors_gcd = [gcd(a[i], a[i+1]) for i in range(n)]

print(sorted(neighbors_gcd)[2])

Fixed submission:
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

left = [0] * (n + 1)
for i in range(1, n):
    left[i] = gcd(left[i-1], a[i-1])

right = [0] * (n + 1)
for i in range(1, n):
    right[n-i] = gcd(right[n-i+1], a[n-i])

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i+1]))
print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq
x, y, z, k = map(int, input().split())
a = sorted(map(int, input().split()))[::-1]
b = sorted(map(int, input().split()))[::-1]
c = sorted(map(int, input().split()))[::-1]

print(a[0] + b[0] + c[0])
candidates = [(-(a[1] + b[0] + c[0]), 1, 0, 0),
              (-(a[0] + b[1] + c[0]), 0, 1, 0),
              (-(a[0] + b[0] + c[1]), 0, 0, 1)]
heapq.heapify(candidates)
popped = {(1, 0, 0): 1,
          (0, 1, 0): 1,
          (0, 0, 1): 1}

for i in range(1, k):
    value, p, q, r = heapq.heappop(candidates)
    print(-value)
    try:
        popped[(p+1, q, r)]
    except:
        if p+1 < x: 
            heapq.heappush(candidates, (-(a[p+1] + b[q] + c[r]), p+1, q, r))
            popped[(p+1, q, r)] = 1
    try:
        popped[(p, q+1, r)]
    except:
        if q+1 < y: 
            heapq.heappush(candidates, (-(a[p] + b[q+1] + c[r]), p, q+1, r))
            popped[(p, q+1, r)] = 1
    try:
        popped[(p, q, r+1)]
    except:
        if r+1 < z: 
            heapq.heappush(candidates, (-(a[p] + b[q] + c[r+1]), p, q, r+1))
            popped[(p, q, r+1)] = 1


Fixed submission:
import heapq
x, y, z, k = map(int, input().split())
a = sorted(map(int, input().split()))[::-1]
b = sorted(map(int, input().split()))[::-1]
c = sorted(map(int, input().split()))[::-1]

print(a[0] + b[0] + c[0])
candidates = []
if x > 1: candidates.append((-(a[1] + b[0] + c[0]), 1, 0, 0))
if y > 1: candidates.append((-(a[0] + b[1] + c[0]), 0, 1, 0))
if z > 1: candidates.append((-(a[0] + b[0] + c[1]), 0, 0, 1))
heapq.heapify(candidates)
popped = {(1, 0, 0): 1,
          (0, 1, 0): 1,
          (0, 0, 1): 1}

for i in range(1, k):
    value, p, q, r = heapq.heappop(candidates)
    print(-value)
    try:
        popped[(p+1, q, r)]
    except:
        if p+1 < x: 
            heapq.heappush(candidates, (-(a[p+1] + b[q] + c[r]), p+1, q, r))
            popped[(p+1, q, r)] = 1
    try:
        popped[(p, q+1, r)]
    except:
        if q+1 < y: 
            heapq.heappush(candidates, (-(a[p] + b[q+1] + c[r]), p, q+1, r))
            popped[(p, q+1, r)] = 1
    try:
        popped[(p, q, r+1)]
    except:
        if r+1 < z: 
            heapq.heappush(candidates, (-(a[p] + b[q] + c[r+1]), p, q, r+1))
            popped[(p, q, r+1)] = 1
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))

max_diff = max(D)
difficulty = [0] * (max_diff + 1)
for d in D:
    difficulty[d] += 1

for t in T:
    if t > max_diff:
        print('NO')
        sys.exit()
    difficulty[t] -= 1
    if difficulty[t] < 0:
        print('NO')
        sys.exit()
print('YES')


Fixed submission:
import sys
n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))

max_diff = max(D)
difficulty = {}
for d in D:
    try:
        difficulty[d] += 1
    except:
        difficulty[d] = 1

for t in T:
    try:
        difficulty[t] -= 1
    except:
        print('NO')
        sys.exit()
    if difficulty[t] < 0:
        print('NO')
        sys.exit()
print('YES')
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 1
A = list(map(int,input().split()))
for x in A:
  if x == 0:
    print(0)
    exit(0)
  ans *= x
  if ans > 10**18:
    print(-1)
    exit(0)
print(ans)


Fixed submission:
a,b = map(int,input().split())
print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
A = list(map(int,input().split()))
for x in A:
  if x == 0:
    print(0)
    exit(0)
  ans *= x
if ans > 10**18:
  print(-1)
  exit(0)
print(ans)

Fixed submission:
n = int(input())
ans = 1
A = list(map(int,input().split()))
if 0 in A:
  print(0)
  exit(0)
for x in A:
  ans *= x
  if ans > 10**18:
    print(-1)
    exit(0)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 1
A = list(map(int,input().split()))
for x in A:
  if x = 0:
    print(0)
    exit(0)
  ans *= x
if ans > 10**18:
  print(-1)
  exit(0)
print(ans)

Fixed submission:
n = int(input())
ans = 1
A = list(map(int,input().split()))
if 0 in A:
  print(0)
  exit(0)
for x in A:
  ans *= x
  if ans > 10**18:
    print(-1)
    exit(0)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
A = list(map(int,input().split()))
for x in A:
  ans *= x
if ans > 10**18:
  print(-1)
  exit(0)
print(ans)


Fixed submission:
n = int(input())
ans = 1
A = list(map(int,input().split()))
if 0 in A:
  print(0)
  exit(0)
for x in A:
  ans *= x
  if ans > 10**18:
    print(-1)
    exit(0)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
list = map(input().split())
ans = float(list[1])*int(list[0])
print(math.floor(ans))

Fixed submission:
a,b = input().split()
a = int(a)
b = round(100*float(b))
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
import math
a = list(map(input().split()))
ans = float(a[1])*int(a[0])
print(math.floor(ans))

Fixed submission:
a,b = input().split()
a = int(a)
b = round(100*float(b))
print(a*b//100)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
A = list(map(int,input().split()))
sub = [0]*n
ans = 1
cir = 0
a = 0
for i in range(n):
  sub[i] = ans
  if A[ans-1] in sub:
    a = sub.index(A[ans-1])
    cir = i+1 - a
    break
  else:
    ans = A[ans-1]
if sub[-1] != 0:
  print(sub[k%n])
  exit(0)
print(sub[a + (k - a) % cir])

Fixed submission:
S = list(input())
T = list(input())

for i in range(len(S)):
  if T[i] != S[i]:
    print('No')
    exit(0)
print('Yes')

Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())

for i in range(len(s)):
  if T[i] != S[i]:
    print('No')
    exit(0)
print('Yes')

Fixed submission:
S = list(input())
T = list(input())

for i in range(len(S)):
  if T[i] != S[i]:
    print('No')
    exit(0)
print('Yes')
Buggy python submission (verdict: Runtime Error):
import itertools

N,M,X = map(int,input().split())
c = []
d = [0]*4
e = []
for _ in range(N):
  c.append(list(map(int,input().split())))
for r in range(1,N+1):
  for x in itertools.combinations(c,r):
    for y in range(len(x)):
      d[0] += x[y][0]
      d[1] += x[y][1]
      d[2] += x[y][2]
      d[3] += x[y][3]
    if d[1] < X or d[2] < X or d[3] < X:
      d = [0]*4
    else:
      e.append(d[0])
      d = [0]*4
if len(e)>0:
  print(min(e))
else:
  print(-1)

Fixed submission:
import itertools

N,M,X = map(int,input().split())
c = []
d = [0]*(M+1)
e = []
for _ in range(N):
  c.append(list(map(int,input().split())))
for r in range(1,N+1):
  for x in itertools.combinations(c,r):
    for y in range(len(x)):
      for z in range(M+1):
        d[z] += x[y][z]
    for z in range(1,M+1):
      if d[z]<X:
        d = [0]*(M+1)
        break
      elif z == M:
        e.append(d[0])
        d = [0]*(M+1)
if len(e)>0:
  print(min(e))
else:
  print(-1)