Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n ,m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
while k > 0:
  i, j = 0
  if a[i] <= b[j]:
    k -= a[i]
    if k >= 0
      i += 1
      ans += 1
      if i >= n:
        for o in range(j, m):
          if k >= b[o]:
            k -= b[o]
            ans += 1
          else:
            k -= b[o]
            break
  else:
    k -= b[j]
    if k >= 0
      j += 1
      ans += 1
      if j >= m:
        for p in range(i, n):
          if k >= a[p]:
            k -= a[p]
            ans += 1
          else:
            k -= a[p]
            break
print(ans)

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

a_cs, b_cs = [0], [0]
for i in range(n):
  a_cs.append(a_cs[i] + a[i])
for i in range(m):
  b_cs.append(b_cs[i] + b[i])

ans, j = 0, m
for i in range(n+1):
  if a_cs[i] > k:
    break
  while b_cs[j] > k - a_cs[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
n ,m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
while k > 0:
  i, j = 0
  if a[i] <= b[j]:
    k -= a[i]
    if k >= 0
      i += 1
      ans += 1
  else:
    k -= b[j]
    if k >= 0
      j += 1
      ans += 1
print(ans)

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

a_cs, b_cs = [0], [0]
for i in range(n):
  a_cs.append(a_cs[i] + a[i])
for i in range(m):
  b_cs.append(b_cs[i] + b[i])

ans, j = 0, m
for i in range(n+1):
  if a_cs[i] > k:
    break
  while b_cs[j] > k - a_cs[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = ''
while n > 0:
  n -= 1
  ans += chr(ord('a')+ans%26)
  n //= 26
print(ans[::-1])

Fixed submission:
n = int(input())
ans = ''
while n > 0:
  n -= 1
  ans += chr(ord('a')+n%26)
  n //= 26
print(ans[::-1])
Buggy python submission (verdict: Runtime Error):
ans = 'No'
x ,y = map(int, input().split())
for i in range(x+1):
  if 2 ＊ x + 4 ＊ (x-i) == y:
    ans = 'Yes'
    break
print(ans)

Fixed submission:
ans = 'No'
x, y = map(int, input().split())
for i in range(x+1):
  if (2 * i) + (4 * (x-i)) == y:
    ans = 'Yes'
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
l = list(map(int, input().split()))
flg = false
t = x
while flg == False:
  if t in l:
    t -= 1
  else:
    ans = t
    flg = True
flg = False
t = x
while flg == False:
  if t in l:
    t += 1
  else:
    if abs(x-ans) > abs(x-t):
      ans = t
    flg = True
print(ans)


Fixed submission:
x, n = map(int, input().split())
l = list(map(int, input().split()))
flg = False
t = x
while flg == False:
  if t in l:
    t -= 1
  else:
    ans = t
    flg = True
flg = False
t = x
while flg == False:
  if t in l:
    t += 1
  else:
    if abs(x-ans) > abs(x-t):
      ans = t
    flg = True
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
    a = 'ABC'
    r = 'ARC'
    s = input()
    if s == a:
        print(r)
    else:
        print(a)
    
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    a = 'ABC'
    r = 'ARC'
    s = input()
    if s == a:
        print(r)
    else:
        print(a)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    ans = 0
    n,k = map(int, input(.split()))
    l = [0]*n
    for i in range(k):
        d = int(input())
        s = list(map(int, input().split()))
        for j in s:
            l[j-1] += 1
    for i in range(n):
        if l[i] == 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    ans = 0
    n,k = map(int, input().split())
    l = [0]*n
    for i in range(k):
        d = int(input())
        s = list(map(int, input().split()))
        for j in s:
            l[j-1] += 1
    for i in range(n):
        if l[i] == 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
3 3
1
3
1
3
1
3

Fixed submission:
def main():
    ans = 0
    n,k = map(int, input().split())
    l = [0]*n
    for i in range(k):
        d = int(input())
        s = list(map(int, input().split()))
        for j in s:
            l[j-1] += 1
    for i in range(n):
        if l[i] == 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
d = 0
ans = 0
while d < x:
  d += d//100
  ans += 1
print(ans)

Fixed submission:
def main():
    ans = 0
    m = 100
    x = int(input())
    while m < x:
        m += m//100
        ans += 1 
    
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    input = stdin.readline
    n = int(input())
    l = []
    for i in range(n):
        s = input()
        if not s in l:
            l.append(s)

    print(len(l))

if __name__ == '__main__':
    main()

Fixed submission:
from sys import stdin

def main():
    input = stdin.readline
    n = int(input())
    l = []
    for i in range(n):
        s = input()
        l.append(s)

    print(len(set(l)))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math

def main():
  r = int(input())
  print('{:.16}'.format(2*r*math.pi)

if __name__ == '__main__':
  main()

Fixed submission:
import math

def main():
  r = int(input())
  print('{:.20}'.format(2*r*math.pi))

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
def main():
  n, m = map(int, input().split())
  l = list(map(int, input(.split())))
  ans = n - sum(l)
  if ans < 0:
      ans = -1
  print(ans)

if __name__ == '__main__':
  main()

Fixed submission:
def main():
  n, m = map(int, input().split())
  l = list(map(int, input().split()))
  ans = n - sum(l)
  if ans < 0:
      ans = -1
  print(ans)

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  n = int(input())
  l = list(map(int, input().split()))
  for i in range(n):
    print(l.count(i+1))

if __name__ == '__main__':
  main()

Fixed submission:
def main():
  n = int(input())
  l = list(map(int, input().split()))
  ans = [0] * n
  for i in range(n-1):
    ans[l[i]-1] += 1
  for i in ans:
    print(i)

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
s = 0
n = int(input())
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      s += gcd(i,j,k)
print(s)

Fixed submission:
import math
n = int(input())
sum = 0
for i in range(1,n+1):
  for j in range(1,n+1):
    g = math.gcd(i,j)
    for k in range(1,n+1):
      sum += math.gcd(g,k)
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
import math
def main():
  n = int(input())
  s = input()
  ans = 0
  for i in range(n-2):
    for j in range(i,n-1):
      for k in range(j,n):
        if 2*j!=i+k and s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
          ans += 1
  print(ans)

if __name__ == "__main__":
  main()

Fixed submission:
def main():
  n = int(input())
  s = input()
  r = g = b = d =0
  for i in range(n):
    if s[i] == "R":
      r += 1
    elif s[i] == "G":
      g += 1
    else:
      b += 1
  a = r * g * b
  for i in range(n):
    for j in range(i+1,n):
      if s[i] == s[j]:
        continue
      k = 2*j - i
      if k >= n or s[k] == s[i] or s[k] == s[j]:
        continue
      d += 1
  print(a - d)
  
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
for i in range(n-2):
  for j in range(i,n-1):
    for k in range(j,n):
      if 2*j!=i+k and s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
        ans += 1
print(ans)

Fixed submission:
def main():
  n = int(input())
  s = input()
  r = g = b = d =0
  for i in range(n):
    if s[i] == "R":
      r += 1
    elif s[i] == "G":
      g += 1
    else:
      b += 1
  a = r * g * b
  for i in range(n):
    for j in range(i+1,n):
      if s[i] == s[j]:
        continue
      k = 2*j - i
      if k >= n or s[k] == s[i] or s[k] == s[j]:
        continue
      d += 1
  print(a - d)
  
if __name__ == "__main__":
  main()
Buggy python submission (verdict: Runtime Error):
x,y,z = mpa(int, input().split())
print("{} {} {}".format(z,x,y))


Fixed submission:
x,y,z = map(int, input().split())
print("{} {} {}".format(z,x,y))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n,k = map(int, input().split())
if n == 0 or k == 1:
  print(0)
  sys.exit()
while True:
  ans = abs(n-k)
  if ans >= n:
    break
  elif n > ans:
    n = ans
print(n)

Fixed submission:
n, k = map(int, input().split())
ans = min(n%k, k-(n%k))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

n,k = map(int, input().split())
if n == 0 or k == 1:
  print(0)
  sys.exit()

while True:
  ans = abs(n-k)
  if n > ans:
    n = ans
  else:
    print(n)
    break

Fixed submission:
n, k = map(int, input().split())
ans = min(n%k, k-(n%k))
print(ans)
Buggy python submission (verdict: Runtime Error):
k, n = map(int, input().split())
l = list(map(int, input().split()))
d = []
for i in range(n):
  if i+1<n:
    d.append(abs(l[i+1]-l[i]))
  else:
    if 0 in l:
      d.append(abs(k - l[i]))
    else:
      d.append(abs(k - l[i] + l[0])
print(sum(d)-max(d))

Fixed submission:
k,n = map(int, input().split())
l = list(map(int, input().split()))
d = []
for i in range(n):
  if i + 1 < n:
    d.append(l[i+1]-l[i])
  else:
    if 0 in l:
      d.append(k - l[i])
    else:
      d.append(k - l[i] + l[0])
sum = sum(d)
a = []
for i in range(n):
  a.append(sum - d[i])
print(min(a))

Buggy python submission (verdict: Time Limit Exceeded):
k, n = map(int, input().split())
l = list(map(int, input().split()))
c = n*(n-1)//(n-1)
s = [0 for _ in range(c)]
for i in range(c):
  for j in range(n-1):
    if l[j+1] == 0:
      s[i] += abs(k-l[j])
    else:
      s[i] += abs(l[j+1]-l[j])
  temp = l.pop(0)
  l.append(temp)
print(min(s))

Fixed submission:
k,n = map(int, input().split())
l = list(map(int, input().split()))
d = []
for i in range(n):
  if i + 1 < n:
    d.append(l[i+1]-l[i])
  else:
    if 0 in l:
      d.append(k - l[i])
    else:
      d.append(k - l[i] + l[0])
sum = sum(d)
a = []
for i in range(n):
  a.append(sum - d[i])
print(min(a))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
from operator import mul
from functools import reduce
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
  ans = 0
  temp = l.copy()
  temp.pop(i)
  c = collections.Counter(temp)
  for j in c.most_common():
    if j[1] > 1:
      r = min(2, j[1] - 2)
      numer = reduce(mul, range(j[1], j[1] - r, -1), 1)
      denom = reduce(mul, range(1, r + 1), 1)
      ans += numer // denom
  print(ans)


Fixed submission:
n = int(input())
b = list(map(int, input().split()))
l = [0]*n
for i in range(n):
  l[b[i]-1] += 1
l2 = sum([i*(i-1)//2 for i in l])
for i in b:
  print(l2-(l[i-1]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
  ans = 0
  temp = l.copy()
  temp.pop(i)
  c = collections.Counter(temp)
  for j in c.most_common():
    if j[1] > 1:
      ans += math.factorial(j[1]) // (math.factorial(j[1] - 2) * math.factorial(2))
  print(ans)

Fixed submission:
n = int(input())
b = list(map(int, input().split()))
l = [0]*n
for i in range(n):
  l[b[i]-1] += 1
l2 = sum([i*(i-1)//2 for i in l])
for i in b:
  print(l2-(l[i-1]-1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[n+1])

Fixed submission:
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(l[n-1])
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
if h == 1 or w == 1:
  print(1)
else:
  if a*w%2 != 0:
    print(a*w//2 + 1)
  else:
    print(a*w//2)

Fixed submission:
import sys
h, w = map(int, input().split())
if h == 1 or w == 1:
  print(1)
  sys.exit()
ans = h//2*w
if h%2 != 0:
  if w%2 != 0:
    ans += w//2+1
  else:
    ans += w/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
if a + b + 4*a*b < c:
  print("Yes")
else:
  print("No)

Fixed submission:
a,b,c = map(int, input().split())
d = c-a-b
if d > 0 and d**2 > 4*a*b:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
a,b,c = map(decimal, input().split())
if abs((a**0.5) + (b**0.5)) < abs(c**0.5):
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c = map(int, input().split())
d = c-a-b
if d > 0 and d**2 > 4*a*b:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline

def main():
    ans = 10**5 * 2
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    for i in range(A):
        for j in range(B):
            cost = a[i] + b[i]
            ans = min(ans, cost)

    for i in range(M):
        x, y, c =  map(int, input().split())
        cost = a[x-1] + b[y-1] - c
        ans = min(ans, cost)

    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys

input = sys.stdin.readline

def main():
    ans = 10**5 * 2
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = sorted(a)[0] + sorted(b)[0]
    
    for i in range(M):
        x, y, c =  map(int, input().split())
        cost = a[x-1] + b[y-1] - c
        ans = min(ans, cost)

    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n,b,r = map(int, input().split())
s = n // (b+r)
a = n % (b+r)
ans = s * b
ans += min(a, b)
print({}.format(ans))

Fixed submission:
n,b,r = map(int, input().split())
s = n // (b+r)
a = n % (b+r)
ans = s * b
ans += min(a, b)
print("{}".format(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
l = list(map(int, input().split()))
s = 0
l2 = [0 for _ in range(k)]
for i in range(n-k+1):
  if s < sum(l[i:i+k]):
    s = sum(l[i:i+k])
    for j in range(k):
      l2[j] = i + j
ans = 0
for i in range(k):
  ans += (1+l[l2[i]])/2
print("{:.8}".format(ans))

Fixed submission:
n,k = map(int, input().split())
l = list(map(int, input().split()))
l2 = [0 for _ in range(n+1)]
for i in range(n):
  l[i] = 1+l[i]
for i in range(n):
  l2[i + 1] = l2[i]+l[i]
l3 = []
for i in range(n-k+1):
  l3.append(l2[i+k]-l2[i])
print("{:.8}".format(max(l3)/2))
Buggy python submission (verdict: Runtime Error):
n = int(input)
h = n//100
if 100*h <= n <= 105*h:
  print(1)
else:
  print(0)

Fixed submission:
n = int(input())
h = n//100
if 100*h <= n <= 105*h:
  print(1)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
n = int(input)
h = n//100
if 100*n <= n <= 105*n:
  print(1)
else:
  print(0)

Fixed submission:
n = int(input())
h = n//100
if 100*h <= n <= 105*h:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    for i in range(1, n):
        ans += i%(i+1)
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys

input = sys.stdin.readline

def main():
    n = int(input())-1
    ans = (1+n)*(n//2)
    if n%2 != 0:
        ans += n//2+1
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
l, r = map(int, input().split())
for i in range(l, r-1):
  for j in range(i+1, r):
    if i*j%2019 == 0:
      print(0)
      sys.exit()
    elif ans > i*j%2019:
      ans = i*j%2019
print(ans)

Fixed submission:
import sys
l, r = map(int, input().split())
ans = l*r%2019
for i in range(l, r):
  for j in range(i+1, r+1):
    if i*j%2019 == 0:
      print(0)
      sys.exit()
    elif ans > i*j%2019:
      ans = i*j%2019
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

def main():
    li = []
    ans = 0
    n,m = map(int,input().split())
    for _ in range(m):
        l,r = map(int, input().split())
        for i in range(l,r+1):
            li.append(i)
    c = collections.Counter(li)
    for i,v in c.items():
        if v >= m:
            ans += 1
    print(ans)

if __name__ == '__main__':
  main()

Fixed submission:
def main():
    ll = []
    rl = []
    n,m = map(int,input().split())
    for _ in range(m):
        l,r = map(int, input().split())
        ll.append(l)
        rl.append(r)
    l = max(ll)
    r = min(rl)
    print(max(0,r-l+1))

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
ans = 0
R, G, B, N = map(int, input().split())
for r in range(N//R + 1):
  for g in range(N//G + 1):
    rg = r*R + g*G
    if rg <= N and (N-rg)%B == 0:
      ans += 1
print(ans)

Fixed submission:
ans = 0
R, G, B, N = map(int, input().split())
rl = (N+R-1)//R+1
gl = (N+G-1)//G+1
bl = (N+B-1)//B
for r in range(rl):
  for g in range(gl):
    tmp = N - (r*R) - (g*G)
    if tmp < 0:
      break
    if tmp == 0:
      ans += 1
    elif tmp%B == 0 and tmp%B <= bl:
      ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import fraction
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
n = int(input())
l = list(map(int, input().split()))
print(gcd_list(l))


Fixed submission:
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
n = int(input())
l = list(map(int, input().split()))
print(gcd_list(l))
Buggy python submission (verdict: Time Limit Exceeded):
ans = 0
ans2 = 0
s = input()
l = len(s)
t = 1
for i in range(l):
  print(f'a={t}')
  same = True
  while same:
    if s[i] != s[t]:
      i = t
      print(f'b={t}')
      same = False
    else:
      ans += 1
print(max(ans, ans2))


Fixed submission:
import sys

input = sys.stdin.readline

def main():
    ans = 0
    S = input().rstrip('\n')
    w = 0
    for s in S[::-1]:
        if s == 'W':
            w += 1
        else:
            ans += w
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
ans = ''
if s[1] == '1':
  ans = 1
else:
  ans = s[1]
print(ans)

Fixed submission:
import sys

input = sys.stdin.readline

def main():
    ans = ''
    index = 0
    s = input().rstrip('\n')
    k = int(input())
    for i in range(len(s)):
        if s[i] != '1':
            ans = s[i]
            index = i
            break
    if ans == '' or k < index+1:
        ans = '1'
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
d = b - a
bh = 0
for i in range(n+1):
  bh += bh + i
print(bh - b)

Fixed submission:
a,b = map(int, input().split())
bh = 0
for i in range(b-a+1):
  bh += i
print(bh-b)
Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

d = '.'
dn = '#'

def isPaintable(h, w, x, y, canvas):
    ret = False
    if x > 0:
        if canvas[x-1, y] == dn:
            ret = True
    elif x < w:
        if canvas[x+1, y] == dn:
            ret = True
    elif y > 0:
        if canvas[x, y-1] == dn:
            ret = True
    elif y < h:
        if canvas[x, y+1] == dn:
            ret = True
    return ret

def main():
    ans = 'Yes'
    h, w = map(int, input().split())
    canavs = []
    for _ in range(h):
        s = list(input().split().rstrip('\n'))
        canvas.append(s)
    for i in h:
        if ans == 'No':
            break
        for j in w:
            if not isPaintable(h, w, j, i, canvas):
                ans = 'No'
                break
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys

input = sys.stdin.readline

d = '.'
dn = '#'

def isPaintable(h, w, x, y, canvas):
    if x > 0:
        if canvas[y][x-1] == dn:
            return True
    if x < w-1:
        if canvas[y][x+1] == dn:
            return True
    if y > 0:
        if canvas[y-1][x] == dn:
            return True
    if y < h-1:
        if canvas[y+1][x] == dn:
            return True
    return False

def main():
    ans = 'Yes'
    h, w = map(int, input().split())
    canvas = []
    for _ in range(h):
        s = list(input().rstrip('\n'))
        canvas.append(s)
    for y in range(h):
        if ans == 'No':
            break
        for x in range(w):
            if canvas[y][x] == dn and not isPaintable(h, w, x, y, canvas):
                ans = 'No'
                break
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())
for i in range(n+1):
  for g in range(n-i):
    s = n-i-g
    if 10000*i + 5000*g 1000*s == y:
      print(i, g, s)
      exit()
print('-1 -1 -1')

Fixed submission:
n, y = map(int, input().split())
for i in range(n+1):
  for g in range(n-i+1):
    s = n-i-g
    if 10000*i + 5000*g + 1000*s == y:
      print(i, g, s)
      exit()
print('-1 -1 -1')
Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

def main():
    ans = ""
    nums = list(map(int, list(input())))
    for i in range(8):
        ts = sum(nums)
        ops = ['+']*3
        for j in range(3):
            if i>>j&1:
                ts -= nums[j+1]*2
                ops[j]='-'
        if ts == 7:
            for i in range(3):
                ans += str(nums[i])+ops[i]
            ans += str(nums[3])+"=7"
            break
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys

input = sys.stdin.readline

def main():
    ans = ""
    nums = list(map(int, list(input().rstrip("\n"))))
    
    for i in range(2**3):
        ts = sum(nums)
        ops = ['+']*3
        for j in range(3):
            if i>>j&1:
                ts -= nums[j+1]*2
                ops[j]='-'
        if ts == 7:
            for i in range(3):
                ans += str(nums[i])+ops[i]
            ans += str(nums[3])+"=7"
            break
    print(ans)

if __name__ == '__main__':
    main()

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

input = sys.stdin.readline

def main():
    ans = ""
    nums = list(map(int, list(input())))
    for i in range(8):
        ts = sum(nums)
        ops = ['+']*3
        for j in range(3):
            if i>>j&1:
                ts -= nums[j+1]*2
                ops[j]='-'
        if ts == 7:
            for i in range(3):
                ans += str(nums[i])+ops[i]
            ans += str(nums[3])+"=7"
            break
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys

input = sys.stdin.readline

def main():
    ans = ""
    nums = list(map(int, list(input().rstrip("\n"))))
    
    for i in range(2**3):
        ts = sum(nums)
        ops = ['+']*3
        for j in range(3):
            if i>>j&1:
                ts -= nums[j+1]*2
                ops[j]='-'
        if ts == 7:
            for i in range(3):
                ans += str(nums[i])+ops[i]
            ans += str(nums[3])+"=7"
            break
    print(ans)

if __name__ == '__main__':
    main()