Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
import sys
sys.setrecursionlimit(50000)

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

@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1]-h[0])
    return min(abs(h[n]-h[n-1]) + rec(n-1), abs(h[n]-h[n-2]) + rec(n-2))

print(rec(n-1))


Fixed submission:
n = int(input())
h = list(map(int, input().split()))
res = [0] * n

res[1] = abs(h[1] - h[0])
for i in range(2, n):
    res[i] = min(res[i-2] + abs(h[i] - h[i-2]),
                 res[i-1] + abs(h[i] - h[i-1]))

print(res[-1])

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)

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

@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1]-h[0])
    return min(abs(h[n]-h[n-1]) + rec(n-1), abs(h[n]-h[n-2]) + rec(n-2))

print(rec(n-1))


Fixed submission:
n = int(input())
h = list(map(int, input().split()))
res = [0] * n

res[1] = abs(h[1] - h[0])
for i in range(2, n):
    res[i] = min(res[i-2] + abs(h[i] - h[i-2]),
                 res[i-1] + abs(h[i] - h[i-1]))

print(res[-1])

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
import sys
sys.setrecursionlimit(2000)

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

@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1]-h[0])
    return min(abs(h[n]-h[n-1]) + rec(n-1), abs(h[n]-h[n-2]) + rec(n-2))

print(rec(n-1))


Fixed submission:
n = int(input())
h = list(map(int, input().split()))
res = [0] * n

res[1] = abs(h[1] - h[0])
for i in range(2, n):
    res[i] = min(res[i-2] + abs(h[i] - h[i-2]),
                 res[i-1] + abs(h[i] - h[i-1]))

print(res[-1])

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache

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

@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1]-h[0])
    return min(abs(h[n]-h[n-1]) + rec(n-1), abs(h[n]-h[n-2]) + rec(n-2))

print(rec(n-1))

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
res = [0] * n

res[1] = abs(h[1] - h[0])
for i in range(2, n):
    res[i] = min(res[i-2] + abs(h[i] - h[i-2]),
                 res[i-1] + abs(h[i] - h[i-1]))

print(res[-1])
Buggy python submission (verdict: Runtime Error):
x = map(int, input().split(' '))
for i in range(0, len(x)):
  if x[i] == 0:
    print(i+1)
    break

Fixed submission:
x = [x for x in map(int, input().split(' '))]
for i in range(0, len(x)):
  if x[i] == 0:
    print(i+1)
    break
Buggy python submission (verdict: Runtime Error):
[x, y] = [x forx in map(int, input().split(' '))]
flg = -1
if y % 2 == 1:
  flg = 1
else:
  for i in range(0, x):
    if i * 2 + (x - i) * 4 == y:
      flg = 0
      break
if flg == 1 or flg == -1:
  print('No')
else:
  print('Yes')

Fixed submission:
[x, y] = [x for x in map(int, input().split(' '))]
flg = -1
if y % 2 == 1:
  flg = 1
else:
  for i in range(0, x):
    if i * 2 + (x - i) * 4 == y or (x - i) * 2 + i * 4 == y:
      flg = 0
      break
print('Yes' if flg == 0 else 'No')
Buggy python submission (verdict: Runtime Error):
k = int(input())
s = str(input())
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(''.join([str(x) for x in [s[:k+1], '...']])

Fixed submission:
k = int(input())
s = str(input())
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(s[:k] + '...')

Buggy python submission (verdict: Runtime Error):
k = int(input())
s = input()
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(''.join([str(x) for x in [s[:k], '...']])

Fixed submission:
k = int(input())
s = str(input())
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(s[:k] + '...')

Buggy python submission (verdict: Runtime Error):
k = int(input())
s = input()
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(''.join([str(x) for x in [s[:k+1], '...']])

Fixed submission:
k = int(input())
s = str(input())
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(s[:k] + '...')

Buggy python submission (verdict: Runtime Error):
k = input()
s = int(input())
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(''.join([str(x) for x in [s[:k], '...']])

Fixed submission:
k = int(input())
s = str(input())
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(s[:k] + '...')

Buggy python submission (verdict: Runtime Error):
k = input()
s = int(input())
len_s = len(s)

if len_s <= k:
  print(s)
else:
  print(''.join([str(x) for x in [s[:k+1], '...']])
  

Fixed submission:
k = int(input())
s = str(input())
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(s[:k] + '...')
Buggy python submission (verdict: Runtime Error):
[a, b, h, m] = map(int, input())
 
import math
 
long_n = math.radians((h*60 + m) / (12 * 60))
short_n = math.radians((m) / 60)
 
y1 = a * math.sin(long_n)
x1 = a * math.cos(long_n)
 
y2 = b * math.sin(short_n)
x2 = b * math.cos(short_n)
 
print(math.sqrt((x2 - x1) **2+ (y2 - y1) **2))

Fixed submission:
[a, b, h, m] = map(int, input().split(' '))
 
import math

long_n = math.radians(h * 30 + 30 * (m / 60))
short_n = math.radians(360 / 60 * m)
 
y1 = a * math.sin(long_n)
x1 = a * math.cos(long_n)
 
y2 = b * math.sin(short_n)
x2 = b * math.cos(short_n)
 
print(math.sqrt((x2 - x1) **2+ (y2 - y1) **2))

Buggy python submission (verdict: Runtime Error):
[a, b, h, m] = map(int, input())

import math

long_n = math.radians((h*60 + m) / (12 * 6o))
short_n = math.radians((m) / 60)

y1 = a * math.sin(long_n)
x1 = a * math.cos(long_n)

y2 = b * math.sin(short_n)
x2 = b * math.cos(short_n)

print(math.sqrt((x2 - x1) **2+ (y2 - y1) **2))

Fixed submission:
[a, b, h, m] = map(int, input().split(' '))
 
import math

long_n = math.radians(h * 30 + 30 * (m / 60))
short_n = math.radians(360 / 60 * m)
 
y1 = a * math.sin(long_n)
x1 = a * math.cos(long_n)
 
y2 = b * math.sin(short_n)
x2 = b * math.cos(short_n)
 
print(math.sqrt((x2 - x1) **2+ (y2 - y1) **2))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
n*n*n
# 出力
print("{}".format(n**3))

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# 出力
print("{}".format(n**3))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a_s = map(int, input().split(' '))
b_s = map(int, input().split(' '))
c_s = map(int, input().split(' '))

i = 0
a = a_s[i]
b = b_s[a]

before_a = a
sas = b
for i in range(1, n):
  a = a_s[i]
  b = b_s[a]
  sas += b
  if before_a + 1 == a:
    sas += c_s[i-1]
  before_a = a
print(sas)

Fixed submission:
n = int(input())
a_s = list(map(int, input().split(' ')))
b_s = list(map(int, input().split(' ')))
c_s = list(map(int, input().split(' ')))

sat = 0
for a_i in range(0, n):
    i = a_s[a_i] - 1
    b = b_s[i]
    sat += b
    if a_i < n-1 and a_s[a_i] +1 == a_s[a_i+1]:
        if i >= 0:
            sat += c_s[i]
print(sat)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_s = map(int, input().split(' '))
b_s = map(int, input().split(' '))
c_s = map(int, input().split(' '))

i = 0
a = a_s[i]
b = b_s[a]

before_a = a
sas = b
for i in range(1, n):
  a = a_s[i]
  b = b_s[a]
  sas += b
  if before_a + 1 = a:
    sas += c_s[i-1]
  before_a = a

Fixed submission:
n = int(input())
a_s = list(map(int, input().split(' ')))
b_s = list(map(int, input().split(' ')))
c_s = list(map(int, input().split(' ')))

sat = 0
for a_i in range(0, n):
    i = a_s[a_i] - 1
    b = b_s[i]
    sat += b
    if a_i < n-1 and a_s[a_i] +1 == a_s[a_i+1]:
        if i >= 0:
            sat += c_s[i]
print(sat)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input().split())
b = int(input().split())
c = int(input().split())

Fixed submission:
n = int(input())
a_s = list(map(int, input().split(' ')))
b_s = list(map(int, input().split(' ')))
c_s = list(map(int, input().split(' ')))

sat = 0
for a_i in range(0, n):
    i = a_s[a_i] - 1
    b = b_s[i]
    sat += b
    if a_i < n-1 and a_s[a_i] +1 == a_s[a_i+1]:
        if i >= 0:
            sat += c_s[i]
print(sat)
Buggy python submission (verdict: Runtime Error):
import sys
for e in sys.stdin.readline():
    X, A = map(int, e.split())
    print(0 if X < A else 10)

Fixed submission:
X,A = map(int,input().split())
 
print(0 if X<A else 10)

Buggy python submission (verdict: Runtime Error):
X, A = map(int, input.split())
print(0 if X < A else 0)

Fixed submission:
X,A = map(int,input().split())
 
print(0 if X<A else 10)

Buggy python submission (verdict: Runtime Error):
N = int(input())
return 0 if N[0] < N[1] else 10

Fixed submission:
X,A = map(int,input().split())
 
print(0 if X<A else 10)

Buggy python submission (verdict: Runtime Error):
return (0 if  X < A else 10)

Fixed submission:
X,A = map(int,input().split())
 
print(0 if X<A else 10)

Buggy python submission (verdict: Runtime Error):
0 if X < A else 10

Fixed submission:
X,A = map(int,input().split())
 
print(0 if X<A else 10)
Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())
Ln = list(map(int,input().split()))
 
cnt = 1
sum = 0
 
for i in range(1, N+1):
  sum += Ln[i]
  if sum > X:
    break
  cnt += 1
 
print(cnt)

Fixed submission:
N, X = map(int,input().split())
Ln = list(map(int,input().split()))
 
cnt = 1
sum = 0
 
for i in range(0, N):
  sum += Ln[i]
  if sum > X:
    break
  cnt += 1
 
print(cnt)

Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())
Ln = list(map(int,input().split()))
cnt = 1
sum = 0
 for i in range(1, N):
  sum += Ln[i]
  if sum > X:
    break
  cnt += 1
print(cnt)

Fixed submission:
N, X = map(int,input().split())
Ln = list(map(int,input().split()))
 
cnt = 1
sum = 0
 
for i in range(0, N):
  sum += Ln[i]
  if sum > X:
    break
  cnt += 1
 
print(cnt)

Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())
Ln = map(int,input().split())
cnt = 1
sum = 0
 for i in range(1, N):
  sum += Ln[i]
  if sum > X:
    break
  cnt += 1
print(cnt)

Fixed submission:
N, X = map(int,input().split())
Ln = list(map(int,input().split()))
 
cnt = 1
sum = 0
 
for i in range(0, N):
  sum += Ln[i]
  if sum > X:
    break
  cnt += 1
 
print(cnt)

Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())
Ln = map(int,input().split())
cnt = 1
sum = 0
 for i in range(1, N):
    sum += Ln[i]
    if sum > X:
        break
    cnt += 1
print(cnt)

Fixed submission:
N, X = map(int,input().split())
Ln = list(map(int,input().split()))
 
cnt = 1
sum = 0
 
for i in range(0, N):
  sum += Ln[i]
  if sum > X:
    break
  cnt += 1
 
print(cnt)
Buggy python submission (verdict: Runtime Error):
S, T = input().split()
A, B = map(int, input().split())
U = input()
if S == U:
    A -= 1
else if T == U:
    B -= 1
print(f'{str(A)} {str(B)}')

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()
if S == U:
    A -= 1
elif T == U:
    B -= 1
print('{} {}'.format(A, B))
Buggy python submission (verdict: Runtime Error):
H, A = input().split()
import math
print(math.ceil(H/A))

Fixed submission:
import math
H, A = input().split()
H = int(H)
A = int(A)
print(math.ceil(H/A))
Buggy python submission (verdict: Runtime Error):
H, N = input().split()
A = list(int(input().split()))
A = [int(a) for a in A]
if H > sum(A):
    print('No')
else:
    print('Yes')

Fixed submission:
H, N = input().split()
A = list(input().split())
H = int(H)
N = int(N)
A = [int(a) for a in A]
if H > sum(A):
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = []
for q in range(Q):
    a = int(input())
    A.append(a)
import numpy as np
points = np.array([K for i in range(N)])
for a in A:
    points -= 1
    points[a-1] += 1
for p in points:
    if p > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
import numpy as np
N, K, Q = map(int, input().split())
A = []
for q in range(Q):
    a = int(input())
    A.append(a)
points2 = np.zeros(N)
for a in A:
    points2[a-1] += 1
results = []
for p in points2:
    if K - (Q - p) > 0:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = []
for q in range(Q):
    a = int(input())
    A.append(a)
points = np.array([K for i in range(N)])
for a in A:
    points -= 1
    points[a-1] += 1
for p in points:
    if p > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
import numpy as np
N, K, Q = map(int, input().split())
A = []
for q in range(Q):
    a = int(input())
    A.append(a)
points2 = np.zeros(N)
for a in A:
    points2[a-1] += 1
results = []
for p in points2:
    if K - (Q - p) > 0:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = []
for q in range(Q):
    a = int(input())
    A.append(a)
points = np.array([K for i in range(N)])
for a in A:
    points -= 1
    points[a-1] += 1
print(points)
for p in points:
    if p > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
import numpy as np
N, K, Q = map(int, input().split())
A = []
for q in range(Q):
    a = int(input())
    A.append(a)
points2 = np.zeros(N)
for a in A:
    points2[a-1] += 1
results = []
for p in points2:
    if K - (Q - p) > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
import heapq
A = list(map(int, input().split()))
A = [(-x,x) for x in A]
heapq.heapify(A)
def conf(A, M):
    if M > 0:
        a = heapq.heappop(A)[1]
        heapq.heappush(A, (-int(a/2), int(a/2)))
    else:
        return A
    return conf(A, M-1)
conf(A, M)
B = [a[1] for a in A]
print(sum(B))


Fixed submission:
N,M = map(int, input().split())
import heapq
A = list(map(int, input().split()))
A = [(-x,x) for x in A]
heapq.heapify(A)
for _ in range(M):
    a = heapq.heappop(A)[1]
    heapq.heappush(A, (-int(a/2), int(a/2)))
B = [a[1] for a in A]
print(sum(B))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S=[]
for n in range(N):
    S.append(input())
Slist = []
for s in S:
    lists = list(s)
    listss = sorted(lists)
    Slist.append(listss)
def isAna2(Sl,sl):
    boolcount = True
    for i,Sli in enumerate(Sl):
        if Sli != sl[i]:
            boolcount = False
            break
    return boolcount
count = 0
for i,Sl in enumerate(Slist):
    for sl in Slist[i+1:]:
        if isAna2(Sl,sl) == True:
            count+=1
print(count)

Fixed submission:
A,B = map(int,input().split())
a = max(A+B, A-B, A*B)
print(a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S=[]
for n in range(N):
    S.append(input())
Slist = []
for s in S:
    lists = list(s)
    listss = sorted(lists)
    Slist.append(listss)
def isAna2(Sl,sl):
    boolcount = True
    for i,Sli in enumerate(Sl):
        if Sli != sl[i]:
            boolcount = False
            break
    return boolcount
import copy
def countAna(Slist):
    if len(Slist) == 1:
        return 0
    else:
        groupcount = 1
        Sl = Slist[0]
        del Slist[0]
        newSlist = copy.deepcopy(Slist)
        for i,sl in enumerate(Slist):
            if isAna2(Sl, sl) == True:
                groupcount += 1
                del newSlist[i]
        if groupcount == 1:
            count = 0
        else:
            count = int(groupcount*(groupcount-1)/2)
        return count + countAna(newSlist)
print(countAna(Slist))

Fixed submission:
N = int(input())
S=[]
for n in range(N):
    S.append(input())
Sdict = {}
for s in S:
    lists = list(s)
    listss = sorted(lists)
    listsss = ''.join(listss)
    if Sdict.get(listsss) == None:
        Sdict[listsss] = 1
    else:
        Sdict[listsss] += 1
count = 0
for value in Sdict.values():
    count += int(value*(value-1)/2)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S=[]
for n in range(N):
    S.append(input())
Slist = []
for s in S:
    lists = list(s)
    listss = sorted(lists)
    Slist.append(listss)
def isAna2(Sl,sl):
    boolcount = True
    for i,Sli in enumerate(Sl):
        if Sli != sl[i]:
            boolcount = False
            break
    return boolcount
count = 0
for i,Sl in enumerate(Slist):
    for sl in Slist[i+1:]:
        if isAna2(Sl,sl) == True:
            count+=1
print(count)

Fixed submission:
N = int(input())
S=[]
for n in range(N):
    S.append(input())
Sdict = {}
for s in S:
    lists = list(s)
    listss = sorted(lists)
    listsss = ''.join(listss)
    if Sdict.get(listsss) == None:
        Sdict[listsss] = 1
    else:
        Sdict[listsss] += 1
count = 0
for value in Sdict.values():
    count += int(value*(value-1)/2)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S=[]
for n in range(N):
    S.append(input())
def isAna(a,b):
    boolcount = True
    listb = list(b)
    for ai in list(a):
        if ai in listb:
            listb.remove(ai)
        else:
            boolcount = False
            break
    return boolcount
count = 0
for i,s in enumerate(S):
    for ss in S[i+1:]:
        if isAna(s,ss) == True:
            count += 1
print(count)

Fixed submission:
N = int(input())
S=[]
for n in range(N):
    S.append(input())
Sdict = {}
for s in S:
    lists = list(s)
    listss = sorted(lists)
    listsss = ''.join(listss)
    if Sdict.get(listsss) == None:
        Sdict[listsss] = 1
    else:
        Sdict[listsss] += 1
count = 0
for value in Sdict.values():
    count += int(value*(value-1)/2)
print(count)
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

 #最小公倍数
def lcm(a,b):
    return a*b/gcd(a,b)
  
A,B,C,D=map(int,input().split())

if A%C == 0:
    AC = int(A/C) - 1
else:
    AC = int(A/C)
if A%D == 0:
    AD = int(A/D) - 1
else:
    AD = int(A/D)
    
lcmCD = lcm(C,D)
if A%(lcmCD) == 0:
    ACD = int(A/(lcmCD)) - 1
else:
    ACD = int(A/(lcmCD))
    
print((B - A + 1) - (int(B/C) - AC + int(B/D) - AD - int(B/(lcmCD) + ACD)))

Fixed submission:
a = input()
lena = len(a)
bad = False
aft = 0

for i in a:
    bef = i
    if bef==aft:
        bad = True
        break
    else:
        aft=bef
if bad==True:
    print('Bad')
else:
    print('Good')
Buggy python submission (verdict: Runtime Error):
n = input()
print(int((int(n[0]) * 3 + int(n[2])) / 2))

Fixed submission:
a, p = map(int, input().split())

print(int((a * 3 + p)/ 2))
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = (input())
a = S.split('1')
a = [len(i) for i in a if len(i)!=0]

b = S.split('0')
b = [len(i) for i in b if len(i)!=0]
m = 0
c = [0]
for i in range(len(a)+len(b)):
    if S[0] == '0':
        if i%2==0:
            m+=a[int(i/2)]
        else:
            m+=b[int(i/2)]
        c.append(m)
    else:
        if i%2==0:
            m+=b[int(i/2)]
        else:
            m+=a[int(i/2)]
        c.append(m)
mc=0
try:
    if S[0]=='0':
        if 1+2*K-1 >len(c) -1:
            mc = 1
    else:
        if 1+2*K > len(c) -1:
            mc =1
    for i in range(1,len(c)):
        d=0
        if S[0]=='0':
            if i%2!=0:
                d=c[i+2*K-1] - c[i-1]
            else:
                d=c[i+2*K] - c[i-1]
        else:
            if i%2==0:
                d=c[i+2*K-1] - c[i-1]
            else:
                d=c[i+2*K] - c[i-1]
        if mc < d:
            mc = d
except:        
    print(mc)
else:
   
    print(mc)

Fixed submission:
A,B = map(int, input().split())
count=0
for i in range(2):
    if A >= B:
        count+=A
        A-=1
    else:
        count+=B
        B-=1
print(count)
Buggy python submission (verdict: Runtime Error):
N = input()
Hlist = list(map(int, input().split()))
import numpy
a = numpy.argsort(Hlist)
count=0
while True:
    if a[-1]==0:
        count+=1
        break
    else:
        m = a.pop(-1)
        a = [i for i in a if a[-1] >= i]
        count+=1
print(count)

Fixed submission:
N = int(input())
Hlist = list(map(int, input().split()))
count=0
maxHi=1
for i in range(N):
    if Hlist[0] >= maxHi:
        count+=1
        maxHi=Hlist.pop(0)
    else:
        del Hlist[0]
print(count)
Buggy python submission (verdict: Runtime Error):
N,Y = map(int,input().split())
count=0
for x in range(N+1):
    for y in range(N+1):
        if x+y >N:
            break
        else:
            money = 10000*x + 5000*y + 1000*(N-x-y)
            if money == Y:
                count=1
                print('{} {} {}'.format(x,y,N-x-y)
                break
    else:
        continue
    break
if count == 0:
    print('-1 -1 -1')

Fixed submission:
N,Y = map(int,input().split())
count=0
for x in range(N+1):
    for y in range(N+1):
        if x+y >N:
            break
        else:
            money = 10000*x + 5000*y + 1000*(N-x-y)
            if money == Y:
                count=1
                print('{} {} {}'.format(x,y,N-x-y))
                break
    if count == 1:
        break
if count == 0:
    print('-1 -1 -1')

Buggy python submission (verdict: Runtime Error):
N,Y = map(int,input().split())
count=0
for x in range(N+1):
    for y in range(N+1):
        if x+y >N:
            break
        else:
            money = 10000*x + 5000*y + 1000*(N-x-y)
            if money == Y:
                count=1
                print(f'{x} {y} {N-x-y}')
                break
    else:
        continue
    break
if count == 0:
    print('-1 -1 -1')

Fixed submission:
N,Y = map(int,input().split())
count=0
for x in range(N+1):
    for y in range(N+1):
        if x+y >N:
            break
        else:
            money = 10000*x + 5000*y + 1000*(N-x-y)
            if money == Y:
                count=1
                print('{} {} {}'.format(x,y,N-x-y))
                break
    if count == 1:
        break
if count == 0:
    print('-1 -1 -1')
Buggy python submission (verdict: Runtime Error):
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))

akari = [0]*(n+1)
bkari = [0]*(m+1)
for i in range(n):
	akari[i+1] = akari[i] + a[i]

for i in range(m):
	bkari[i+1] = bkari[i] + b[i]

def bin(ls,s,e,sikii):
	if e - s <= 1:
		return s
	mid = (s+e)//2
	if sikii < ls[mid]:return bin(ls,s,mid,sikii)
	else:return bin(ls,mid,e,sikii)

ans = 0
for i in range(n+1):
	time = akari[i]
	if k - time <= 0:break
	ref = bin(bkari,0,m+2,k-time)
	ans = max(ans,ref+i)

print(ans)


Fixed submission:
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
import random
import bisect

#n,m,k = random.randint(1,1000),random.randint(1,1000),random.randint(1,10**8)
##a = [random.randint(1,10**5) for i in range(n)]
#b = [random.randint(1,10**5) for i in range(m)]

def solv():
	global a,b,n,m,k
	akari = [0]*(n+1)
	bkari = [0]*(m+1)
	for i in range(n):
		akari[i+1] = akari[i] + a[i]

	for i in range(m):
		bkari[i+1] = bkari[i] + b[i]

	def bin(ls,s,e,sikii):
		if e - s <= 1:
			return s
		mid = (s+e)//2
		if sikii < ls[mid]:return bin(ls,s,mid,sikii)
		else:return bin(ls,mid,e,sikii)

	ans = 0
	for i in range(n+1):
		time = akari[i]
		if k - time < 0:break
		#ref = bin(bkari,0,m+1,k-time)
		ref = bisect.bisect_right(bkari,k-time)
		ans = max(ans,ref+i)
	return ans

def karisolv():
	global a,b,n,m,k
	akari = [0]*(n+1)
	bkari = [0]*(m+1)
	for i in range(n):
		akari[i+1] = akari[i] + a[i]

	for i in range(m):
		bkari[i+1] = bkari[i] + b[i]

	ans = 0
	for i in range(n+1):
		time = akari[i]
		ref = 0
		if k - time <= 0:break
		cost = 0
		for j in range(m+1):
			if k - time - bkari[j] >= 0:
				ans = max(ans,j+i)
		
	return ans

def makedata():
	global a,b,n,m,k
	n,m,k = random.randint(1,10000),random.randint(1,10000),random.randint(1,1000000)
	a = [random.randint(1,10**5) for i in range(n)]
	b = [random.randint(1,10**5) for i in range(m)]
import sys
def main():
	for i in range(1000000):
		makedata()
		kari = karisolv()
		kotae = solv()
		if kari != kotae:
			print(n,m,k,a,b)
			sys.exit()
print(solv()-1)