Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
ans = 5
cnt = 0
N = int(input())
for i in range(5):
    c = int(input())
    if N <= c:
        continue
    else:
        if i == 0:
            ans += N // c
            minn = c
        else:
            if minn - c > 0:
                cnt += 1
                minn = c
for i in range(cnt):
    ans += 2 ** i
print(ans)

Fixed submission:
import math
C = []
N = int(input())
for i in range(5):
    c = int(input())
    C.append(c)
print(math.ceil(N / min(C)) + 4)

Buggy python submission (verdict: Runtime Error):
ans = 5
cnt = 0
N = int(input())
for i in range(5):
    c = int(input())
    if N < c:
        continue
    else:
        if i == 0:
            ans += N // c
            minn = c
        else:
            if minn - c > 0:
                cnt += 1
                minn = c
for i in range(cnt):
    ans += 2 ** i
print(ans)

Fixed submission:
import math
C = []
N = int(input())
for i in range(5):
    c = int(input())
    C.append(c)
print(math.ceil(N / min(C)) + 4)
Buggy python submission (verdict: Runtime Error):
N = input()
A = set(list("ACGT"))
ans = []
for i in range(len(N)):
    cnt = 0
    for n in N[i:]:
        if n in A:
            cnt += 1
        else:
            ans.append(cnt)
            break
print(max(ans))

Fixed submission:
N = list(input())
A = set(list("ACGT"))
ans = [0]
for i in range(len(N)):
    cnt = 0
    for n in N[i:]:
        if n in A:
            cnt += 1
        else:
            break
        ans.append(cnt)
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
A = "AC"
N, Q = map(int, input().split())
S = list(input())
ans = [0] * (N - 1)
ind = 0
for i in range(N):
    try:
        ind = S.index('A', ind)
        if S[ind + 1] == 'C':
            ans[ind] = 1
        ind = ind + 1
    except:
        break


for i in range(Q):
    l, r = map(int, input().split())
    print(sum(ans[l-1:r-1]))



Fixed submission:
A = "AC"
N, Q = map(int, input().split())
S = list(input())
ans = [0]
cnt = 0
for j in range(N - 1):
    tmp1 = S[j] + S[j + 1]
    if tmp1 == A:
        cnt += 1
    ans.append(cnt)

for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
A = "AC"
N, Q = map(int, input().split())
S = list(input())
ans = []
for j in range(N - 1):
    tmp1 = S[j] + S[j + 1]
    if tmp1 == A:
        ans.append(1)
    else:
        ans.append(0)

for i in range(Q):
    l, r = map(int, input().split())
    print(sum(ans[l-1:r-1]))



Fixed submission:
A = "AC"
N, Q = map(int, input().split())
S = list(input())
ans = [0]
cnt = 0
for j in range(N - 1):
    tmp1 = S[j] + S[j + 1]
    if tmp1 == A:
        cnt += 1
    ans.append(cnt)

for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
A = "AC"
N, Q = map(int, input().split())
S = list(input())
for i in range(Q):
    l, r = map(int, input().split())
    tmp = S[l-1:r]
    cnt = 0
    for j in range(len(tmp) -1):
        tmp1 = tmp[j] + tmp[j+1]
        if tmp1 == A:
            cnt += 1
    print(cnt)



Fixed submission:
A = "AC"
N, Q = map(int, input().split())
S = list(input())
ans = [0]
cnt = 0
for j in range(N - 1):
    tmp1 = S[j] + S[j + 1]
    if tmp1 == A:
        cnt += 1
    ans.append(cnt)

for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())
ans = 0
for i, a in enumerate(range(A, B+1)):
    if i == 0:
        ans = a
    else:
        ans = ans ^ a
print(ans)

Fixed submission:
A, B = map(int, input().split())
res = B - A
res = res % 4
if A % 2 == 0:
    ans = B
    for i in range(1, res+1):
        ans = ans ^ (B - i)
    print(ans)
    exit()
else:
    ans = A
    for i in range(0, res):
        ans = ans ^ (B - i)
    print(ans)
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
import collections as co
S = co.deque(input())
prev = 0
cnt = 0
while prev != len(S):
    prev = len(S)
    for i, s in enumerate(S):
        if i == 0:
            continue
        if s != S[i-1]:
            del(S[i-1])
            del(S[i-1])
            cnt += 2
            break
print(cnt)

Fixed submission:
S = input()
cnt = 0
prev = 0
while prev != len(S):
    prev = len(S)
    ans = []
    for i, n in enumerate(S):
        if i == 0:
            ans.append(n)
            continue
        if len(ans) > 0 and ans[-1] != n:
            ans.pop()
            cnt += 2
        else:
            ans.append(n)
    S = ''.join(ans)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
prev = 0
cnt = 0
while prev != len(S):
    prev = len(S)
    for i, s in enumerate(S):
        if i == 0:
            continue
        if s != S[i-1]:
            del(S[i-1])
            del(S[i-1])
            cnt += 2
print(cnt)

Fixed submission:
S = input()
cnt = 0
prev = 0
while prev != len(S):
    prev = len(S)
    ans = []
    for i, n in enumerate(S):
        if i == 0:
            ans.append(n)
            continue
        if len(ans) > 0 and ans[-1] != n:
            ans.pop()
            cnt += 2
        else:
            ans.append(n)
    S = ''.join(ans)
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [input() for i in range(3)]
ans = [0] * N.
tmp = []
for i in range(N):.
  for j in range(3):
      tmp.append(L[j][i])
  ans[i] = len(set(tmp)) - 1
  tmp = []
print(sum(ans))

Fixed submission:
N = int(input())
L = [input() for i in range(3)]
ans = [0] * N
tmp = []
for i in range(N):
  for j in range(3):
      tmp.append(L[j][i])
  ans[i] = len(set(tmp)) - 1
  tmp = []
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
L = list(input())
A = list("keyence")

prev = -1
for i, a in A:
  curr = L.index(a)
  if prev < current:
    continue
  else:
    print("NO")
    exit()
print("YES")

Fixed submission:
L = input()
A = 'keyence'

for i in range(len(L)):
    for j in range(i, len(L)):
        if L[:i] + L[j:] == A:
            print("YES")
            exit()
print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

def minStep(num, prev, cost):
  if num <= 0:
    cost += abs(prev - H[0])
    return cost
  a1 = abs(prev - H[num-1])
  a2 = abs(prev - H[num-2])
  if a1 < a2:
    cost += a1
    return minStep(num-1, H[num-1], cost)
  cost += a2
  return minStep(num-2, H[num-2], cost)

print(minStep(N-1, H[N-1], 0))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [0] * N
for i in range(1, N):
    dp[i] = min(dp[i-j] + abs(H[i] - H[i-j]) for j in range(1, min(i, K) + 1))
print(dp[-1])

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [0] * N
for i in range(1, N):
    dp[i] = min(dp[i-j] + abs(H[i] - H[i-j]) for j in range(1, min(i, K) + 1))
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [0] * N
for i in range(1, N):
    dp[i] = min(dp[i-j] + abs(H[i] - H[i-j]) for j in range(1, K+1) if i-j >= 0)
print(dp[-1])

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [0] * N
for i in range(1, N):
    dp[i] = min(dp[i-j] + abs(H[i] - H[i-j]) for j in range(1, min(i, K) + 1))
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())
dp = [[0] * (W + 1) for i in range(N+1)]
for i in range(N):
  w, v = map(int, input().split())
  for j in range(W+1):
      if j - w >= 0:
        dp[i+1][j] = max(dp[i][j], dp[i][j-w] + v)
      else:
        dp[i+1][j] = dp[i][j]
print(max(dp[N]))

Fixed submission:
n,w=map(int, input().split())
m=10**5+1
x=[list(map(int, input().split())) for i in range(n)]
dp=[[float('inf')]*m for i in range(n+1)]
dp[0][0]=0
for i in range(n):
    for j in range(m):
        if j>=x[i][1]:
            dp[i+1][j]=min(dp[i][j],dp[i][j-x[i][1]]+x[i][0])
        else:
            dp[i+1][j]=dp[i][j]
ans=0
for i in range(m):
    if dp[-1][i]<=w:ans=max(ans,i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
N = len(S)
count = 0
for i in range(N):
  if S[i] == 'W':
    count+=S[:i].count('B')
print(count)

Fixed submission:
S = list(input())
N = len(S)
ans = 0
count = 0
for i in range(N):
  if S[i] == 'B':
    count+=1
  if S[i] == 'W':
    ans+=count
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
N = len(S)
count = 0
change=True
while change:
  change = False
  for i in range(N-1):
    if S[i] == 'B' and S[i+1] == 'W':
      S[i] = 'W'
      S[i+1] = 'B'
      count+=1
      change = True
      break
print(count)

Fixed submission:
S = list(input())
N = len(S)
ans = 0
count = 0
for i in range(N):
  if S[i] == 'B':
    count+=1
  if S[i] == 'W':
    ans+=count
print(ans)
Buggy python submission (verdict: Runtime Error):
level,eat = map(int, input().split())
burger = 'BPPPB'
for i in range(1, level):
  burger = 'B' + burger + 'P' + burger + 'B'
count=0
eat -=1
for i in range(len(burger)):
  if i > eat:
    break
  if burger[i] == 'P':
    count+=1
print(count)

Fixed submission:
def f(N, X):
  if N == 0:
    if X >= 1:
      return 1
    return 0
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-a[N-1] - 2)

N, X = map(int, input().split(" "))
a = [1]
p = [1]
for i in range(N):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)

print(f(N,X))

Buggy python submission (verdict: Runtime Error):
level,eat = map(int, input().split())
burger = 'BPPPB'
for i in range(1, level):
  burger = 'B' + burger + 'P' + burger + 'B'
print(burger)
count=0
eat -=1
for i in range(len(burger)):
  if i > eat:
    break
  if burger[i] == 'P':
    count+=1
print(count)

Fixed submission:
def f(N, X):
  if N == 0:
    if X >= 1:
      return 1
    return 0
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-a[N-1] - 2)

N, X = map(int, input().split(" "))
a = [1]
p = [1]
for i in range(N):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)

print(f(N,X))
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input())
print(X + Y // 2)

Fixed submission:
X, Y = map(int, input().split())
print(X + Y // 2)
Buggy python submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split(" "))
S = input()
T = input()
G = gcd(N, M)
L = N * M // G
for i in range(G):
  if S[i*N//G] != T[i*M//G]:
    print(-1)
    exit(0)
print(L)



Fixed submission:
from fractions import gcd
N, M = map(int, input().split(" "))
S = input()
T = input()
G = gcd(N, M)
L = N * M // G
for i in range(G):
  if S[i*N//G] != T[i*M//G]:
    print(-1)
    exit(0)
print(L)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N == 1
  print("Hello World")
  exit()
else:
  A = int(input())
  B = int(input())
  print(A+B)

Fixed submission:
N = int(input())
if N == 1:
  print("Hello World")
  exit()
else:
  A = int(input())
  B = int(input())
  print(A+B)
Buggy python submission (verdict: Runtime Error):
N = input()
ans = []
for i in len(N):
  ans.append(N[0])
if int(''.join(ans) > int(N):
    print(''.join(ans))
    exit()
for i in len(N):
  ans.append(str(int(N[0]) + 1))
print(''.join(ans))


Fixed submission:
N = input()
ans = []
for i in range(len(N)):
  ans.append(N[0])
if int(''.join(ans)) >= int(N):
    print(''.join(ans))
    exit()
ans = []
for i in range(len(N)):
  ans.append(str(int(N[0]) + 1))
print(''.join(ans))
Buggy python submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
minB = min(B)
maxA = max(A)
for i in range(maxA, minB+1):
  if X < i and Y =< i:
    print("No War")
    exit()
  else:
    print("War")
    exit()

Fixed submission:
N, M, X, Y = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
minB = min(B)
maxA = max(A)
for i in range(X, Y+1):
  if maxA < i and minB >= i and X < i and i <= Y:
    print("No War")
    exit()
print("War")
Buggy python submission (verdict: Time Limit Exceeded):
N, X = map(int, input().split())
L = list(map(int, input().split()))
L.append(X)
L.sort()
cand = []
def gcd(x, y):
    if x > y:
        small = y
    else:
        small = x
    for i in range(1, small + 1):
        if ((x % i == 0) and (y % i == 0)):
            gcd = i
    return gcd

for i in range(N):
    cand.append(abs(L[i] - L[i+1]))

for i, can in enumerate(cand):
    if i == 0:
        tmp = can
        continue
    tmp = gcd(tmp, can)
print(tmp)


Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
L.append(X)
L.sort()
cand = []
def gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x

for i in range(N):
    cand.append(abs(L[i] - L[i+1]))

for i, can in enumerate(cand):
    if i == 0:
        tmp = can
        continue
    tmp = gcd(tmp, can)
print(tmp)

Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
L = []
for i in range(N):
    L.append(abs(X - A[i]))
for i in range(N-1)
    L.append(A[i+1] - A[i])
print(min(L))

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
L.append(X)
L.sort()
cand = []
def gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x

for i in range(N):
    cand.append(abs(L[i] - L[i+1]))

for i, can in enumerate(cand):
    if i == 0:
        tmp = can
        continue
    tmp = gcd(tmp, can)
print(tmp)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
print(N * 2 // math.gcd(2, N))

Fixed submission:
import fractions
N = int(input())
print(N * 2 // fractions.gcd(2, N))
Buggy python submission (verdict: Runtime Error):
N = input()
ans = 0
for n in N:
  ans += int(ans)
if int(N) % ans == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
N = input()
ans = 0
for n in N:
  ans += int(n)
if int(N) % ans == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
for i in range(N):
  if S[i] == 'W':
    S[i] = 1
  else:
    S[i] = 0
ans = N
for i in range(N):
  W = sum(S[0:i])
  E = len(S[i+1:N+1]) - sum(S[i+1:N+1])
  if ans > W+E:
    ans = W+E
print(ans)

Fixed submission:
N = int(input())
S = list(input())
E = S.count('E')
ans = []
prev = E
pS = 'E'
for i in range(N):
  if S[i] == 'W':
    current = prev
  elif S[i] == 'E':
    current = prev - 1
  if pS == 'W':
    current += 1
  ans.append(current)
  prev = current
  pS = S[i]
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
for i in range(N):
  if S[i] == 'W':
    S[i] = 1
  else:
    S[i] = 0
ans = []
for i in range(N):
  W = sum(S[0:i])
  E = len(S[i+1:N+1]) - sum(S[i+1:N+1])
  ans.append(W+E)
print(min(ans)) 

Fixed submission:
N = int(input())
S = list(input())
E = S.count('E')
ans = []
prev = E
pS = 'E'
for i in range(N):
  if S[i] == 'W':
    current = prev
  elif S[i] == 'E':
    current = prev - 1
  if pS == 'W':
    current += 1
  ans.append(current)
  prev = current
  pS = S[i]
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
ans = []
for i in range(N):
  cnt = S[0:i].count('W')
  cnt += S[i+1:N+1].count('E')
  ans.append(cnt)
print(min(ans)) 

Fixed submission:
N = int(input())
S = list(input())
E = S.count('E')
ans = []
prev = E
pS = 'E'
for i in range(N):
  if S[i] == 'W':
    current = prev
  elif S[i] == 'E':
    current = prev - 1
  if pS == 'W':
    current += 1
  ans.append(current)
  prev = current
  pS = S[i]
print(min(ans))
Buggy python submission (verdict: Runtime Error):
import copy
A, B, C, K = map(int, input().split())
maxL = 10 ** 18
L = [A, B, C]
for i in xrange(K):
    newL = [L[1] + L[2], L[0] + L[2], L[0] + L[1]]
    L = copy.copy(newL)

ans = L[0] - L[1]
if ans >= maxL:
    print("Unfair")
else:
    print(ans)

Fixed submission:
A, B, C, K = map(int, input().split())
maxL = 10 ** 18
L = [A, B, C]
ans = A - B
if ans >= maxL:
    print("Unfair")
else:
    if K % 2 == 0:
        print(ans)
    else:
        print(ans * (-1))

Buggy python submission (verdict: Time Limit Exceeded):
import copy
A, B, C, K = map(int, input().split())
maxL = 10 ** 18
L = [A, B, C]
for i in range(K):
    newL = [L[1] + L[2], L[0] + L[2], L[0] + L[1]]
    L = copy.copy(newL)

ans = L[0] - L[1]
if ans >= maxL:
    print("Unfair")
else:
    print(ans)

Fixed submission:
A, B, C, K = map(int, input().split())
maxL = 10 ** 18
L = [A, B, C]
ans = A - B
if ans >= maxL:
    print("Unfair")
else:
    if K % 2 == 0:
        print(ans)
    else:
        print(ans * (-1))
Buggy python submission (verdict: Time Limit Exceeded):
A = list(input())
N = int(input())
L = []
for i in range(len(A)):
    tmp = A[i:]
    while tmp:
        L.append(''.join(tmp))
        tmp.pop()
L = list(set(L))
L.sort()
print(L[N-1])

Fixed submission:
A = list(input())
K = int(input())
L = []
for i in range(len(A)):
    for j in range(i+1, i+K+1):
        L.append(''.join(A[i:j]))
L = list(set(L))
L.sort()
print(L[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
A = input()
N = int(input())
L = []
for i in range(len(A)):
    for j in range(i+1, len(A)+1):
        L.append(A[i:j])
L = list(set(L))
L.sort()
print(L[N-1])

Fixed submission:
A = list(input())
K = int(input())
L = []
for i in range(len(A)):
    for j in range(i+1, i+K+1):
        L.append(''.join(A[i:j]))
L = list(set(L))
L.sort()
print(L[K-1])

Buggy python submission (verdict: Runtime Error):
A = input()
N = int(input())
L = []
for i in range(len(A)):
    for j in range(i+1, len(A)):
        L.append(A[i:j])
L = list(set(L))
L.sort()
print(L[N-1])

Fixed submission:
A = list(input())
K = int(input())
L = []
for i in range(len(A)):
    for j in range(i+1, i+K+1):
        L.append(''.join(A[i:j]))
L = list(set(L))
L.sort()
print(L[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = list(map(int, input().split()))
mid = N // 2 - 1
for i in range(N):
    tmp = X[:i]
    tmp.extend(X[i+1:])
    tmp.sort()
    print(tmp[mid])

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
tmp = X[:]
tmp.sort()
mid = N // 2 - 1
low = tmp[mid]
high = tmp[mid + 1]
all = sum(tmp)
for a in X:
    if a <= low:
        print(high)
    else:
        print(low)
Buggy python submission (verdict: Runtime Error):
n = set(list(input()))
n.sort()
if 'abc' == ''.join(n):
  print("Yes")
else:
  print("No")

Fixed submission:
n = list(set(list(input())))
n.sort()
if 'abc' == ''.join(n):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import math

A, B, C = map(int, input().split())
maxN = max([A, B, C])
minN = min([A, B, C])
for n in [A, B, C]:
    if n != maxN and n != minN:
        midN = n
diff1 = maxN - midN
diff2 = maxN - minN

if (diff1 % 2 == 0 and diff2 % 2 == 0) or (diff1 % 2 != 0 and diff2 % 2 != 0):
    print((diff1 + diff2) // 2)
else:
    print(math.ceil((diff1 + diff2) / 2) + 1)

Fixed submission:
A, B, C = map(int, input().split())
N = [A, B, C]
maxN = max(N)
sumN = sum(N)
if (3 * maxN - sumN) % 2 != 0:
    maxN += 1
print((3 * maxN - sumN) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
for i in range(N):
    tmp = [0]
    tmp.extend(L[:i])
    tmp.extend(L[i+1:])
    tmp.append(0)
    ans = 0
    for j, n in enumerate(tmp):
        if j == 0:
            pre = n
            continue
        ans += abs(pre - n)
        pre = n
    print(ans)

Fixed submission:
A = [0]
N = int(input())
A.extend(list(map(int, input().split())))
A.append(0)
ALL = 0
for i in range(1, N+2):
    ALL += abs(A[i-1] - A[i])
for i in range(1, N+1):
    print(ALL - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]))
Buggy python submission (verdict: Runtime Error):
import itertools
L = input()
s = ['+','-']
t = ['+','-']
u = ['+','-']
for a, b, c in itertools.product(s, t, u):
   f = L[0] + a + L[1] + b + L[2] + c + L[3] 
   if eval(f) == 7:
       print(f+'=7')
       exit(0)


Fixed submission:
N, Y = map(int, input().split(" "))
for i in range(N+1):
  for j in range(N+1-i):
    k = N-i-j
    if Y == (10000*k + 5000*j + 1000*i):
      print(k,j,i)
      exit(0)
print('-1 -1 -1')

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split(" "))
for i in range(N+1):
  for j in range(N+1):
    for k in range(N+1):
      if Y == (10000*i + 5000*j + 1000*k) and N == (i+j+k):
        print(i,j,k)
        exit(0)
print('-1 -1 -1')

Fixed submission:
N, Y = map(int, input().split(" "))
for i in range(N+1):
  for j in range(N+1-i):
    k = N-i-j
    if Y == (10000*k + 5000*j + 1000*i):
      print(k,j,i)
      exit(0)
print('-1 -1 -1')
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
S = input()
s1, s2 = S.split("-")
if len(s1) == A and len(s2) == B:
    print("Yes")
else:
    print("No")

Fixed submission:
A, B = map(int, input().split())
S = input()
s = S.split("-")
if len(s) != 2:
    print("No")
    exit()
if len(s[0]) == A and len(s[1]) == B:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())
if X > Y:
  print(">")
elif X < Y:
  print("<")
else:
  print("=")

Fixed submission:
X, Y = input().split()
if X > Y:
  print(">")
elif X < Y:
  print("<")
else:
  print("=")
Buggy python submission (verdict: Time Limit Exceeded):
N, X = map(int, input().split())
A = set(list(map(int, input().split())))
lenA = len(A)
prev = 0
while prev != lenA:
    if X in A:
        print("POSSIBLE")
        exit()
    cand = set()
    for i, a in enumerate(A):
        if i == 0:
            aa = a
            continue
        tmp = abs(aa - a)
        if tmp not in A:
            cand.add(tmp)
        A = set.union(A, cand)
    prev= len(A)
print("IMPOSSIBLE")


Fixed submission:
import fractions
N, K = map(int, input().split())
A = list(map(int, input().split()))
if max(A) >= K:
    for i, a in enumerate(A):
        if i == 0:
            gcd = a
            continue
        gcd = fractions.gcd(gcd, a)
    if K % gcd == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
B = [int(input()) for i in range(N)]
A = [0]
A.extend(B)
past = [1]
next_l = 1
if not 2 in A:
  print(-1)
  exit(0)
for i in range(N):
  next_l = A[next_l]
  if next_l in past or next_l > N:
    print(-1)
    exit(0)
  if next_l == 2:
    print(len(past))
    exit(0)
  past.append(next_l)
print(-1)


Fixed submission:
N = int(input())
B = [int(input()) for i in range(N)]
A = [0]
A.extend(B)
past = [1]
next_l = 1
#if not 2 in A:
#  print(-1)
#  exit(0)
for i in range(N):
  next_l = A[next_l]
  #if next_l in past or next_l > N:
  #  print(-1)
  #  exit(0)
  if next_l == 2:
    print(len(past))
    exit(0)
  past.append(next_l)
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
B = [int(input()) for i in range(N)]
A = [0]
A.extend(B)
past = [1]
next_l = 1
for i in range(N):
  next_l = A[next_l]
  if next_l in past:
    print(-1)
    break
  if next_l == 2:
   print(len(past))
   break
  past.append(next_l)


Fixed submission:
N = int(input())
B = [int(input()) for i in range(N)]
A = [0]
A.extend(B)
past = [1]
next_l = 1
#if not 2 in A:
#  print(-1)
#  exit(0)
for i in range(N):
  next_l = A[next_l]
  #if next_l in past or next_l > N:
  #  print(-1)
  #  exit(0)
  if next_l == 2:
    print(len(past))
    exit(0)
  past.append(next_l)
print(-1)