Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
a, b, n = map(int, input().split())
arr = []
ans = 0
for i in range(min(b, n)):
  x = i + 1
  arr.append(math.floor(a * x / b) - a * math.floor(x / b))
ans = max(arr)
print(ans)

Fixed submission:
import math
a, b, n = map(int, input().split())
x = min(b - 1, n)
ans = math.floor(a * x / b) - a * math.floor(x / b)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
a, b, n = map(int, input().split())
arr = [math.floor(a * 1 / b) - a * math.floor(1 / b)]
ans = 0
for i in range(n):
  x = i + 1
  if math.floor(a * x / b) - a * math.floor(x / b) < arr[-1]:
    ans = arr[-1]
    break
  else:
    arr.append(math.floor(a * x / b) - a * math.floor(x / b))
    ans = arr[-1]
ans = max(arr)
print(ans)

Fixed submission:
import math
a, b, n = map(int, input().split())
x = min(b - 1, n)
ans = math.floor(a * x / b) - a * math.floor(x / b)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
a, b, n = map(int, input().split())
arr = [0]
ans = 0
for i in range(n):
  x = i + 1
  if math.floor(a * x / b) - a * math.floor(x / b) < arr[-1]:
    ans = arr[-1]
    break
  else:
    arr.append(math.floor(a * x / b) - a * math.floor(x / b))
    ans = arr[-1]
ans = max(arr)
print(ans)

Fixed submission:
import math
a, b, n = map(int, input().split())
x = min(b - 1, n)
ans = math.floor(a * x / b) - a * math.floor(x / b)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
a, b, n = map(int, input().split())
arr = []
for i in range(n):
  x = i + 1
  arr.append(math.floor(a * x / b) - a * math.floor(x / b))
ans = max(arr)
print(ans)

Fixed submission:
import math
a, b, n = map(int, input().split())
x = min(b - 1, n)
ans = math.floor(a * x / b) - a * math.floor(x / b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  print(a.count(i + 1))

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
c = dict(c)
for i in range(n):
  if i + 1 in c.keys():
    print(c[i + 1])
  else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for x in range(1, k + 1):
  for y in range(1, k + 1):
    for z in range(1, k + 1):
      ans += math.gcd(math.gcd(x, y), z)
print(ans)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
for x in range(1, k + 1):
  for y in range(1, k + 1):
    for z in range(1, k + 1):
      ans += gcd(gcd(x, y), z)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
k = int(input())
ans = 0
for x in range(1, k + 1):
  for y in range(1, k + 1):
    for z in range(1, k + 1):
      ans += reduce(math.gcd, (x, y, z))
print(ans)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
for x in range(1, k + 1):
  for y in range(1, k + 1):
    for z in range(1, k + 1):
      ans += gcd(gcd(x, y), z)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
a = [i for i in range(1, k + 1)]
b = [i for i in range(1, k + 1)]
c = [i for i in range(1, k + 1)]

ans = 0
for x, y, z in itertools.product(a, b, c):
  ans += gcd(x, y, z)
print(ans)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
for x in range(1, k + 1):
  for y in range(1, k + 1):
    for z in range(1, k + 1):
      ans += gcd(gcd(x, y), z)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
s = ''
while len(s) < n:
  s += 'b' * a + 'r' * b
print(s[:n].count('b'))

Fixed submission:
n, a, b = map(int, input().split())
ans = 0
ans += n // (a + b) * a
k = n % (a + b)
if k >= a:
  ans += a
else:
  ans += k
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
e = []
m = 0
arr = []
ans = 0
for i in range(n):
  m += (p[i] + 1) / 2
  e.append(m)
for i in range(n - k):
  arr.append(e[i + k] - e[i])
ans = max(arr)
print(ans)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
e = []
m = 0
arr = []
ans = 0
for i in range(n):
  m += (p[i] + 1) / 2
  e.append(m)
arr.append(e[k - 1])
for i in range(n - k):
  arr.append(e[i + k] - e[i])
ans = max(arr)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
ans = 0
d = {}
m = {}
for i in range(n):
  d[i] = p[i]
  m[i] = min(p[:i + 1])
for i in range(n):
  if p[i] == m[i]:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
ans = 1
pmin = p[0]
for i in range(1, n):
  if pmin >= p[i]:
    ans += 1
    pmin = p[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
ans = 0
m = []
for i in range(n):
  m.append(min(p[:i + 1]))
for i in range(n):
  if p[i] == m[i]:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
ans = 1
pmin = p[0]
for i in range(1, n):
  if pmin >= p[i]:
    ans += 1
    pmin = p[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
ans = 1
for i in range(1, n):
  a = 1
  if p[i] <= min(p[:i]):
    ans += 1
print(ans)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
ans = 1
pmin = p[0]
for i in range(1, n):
  if pmin >= p[i]:
    ans += 1
    pmin = p[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
  a = 1
  for j in range(i + 1):
    if p[i] <= p[j]:
      next
    else:
      a = 0
      break
  ans += a
print(ans)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
ans = 1
pmin = p[0]
for i in range(1, n):
  if pmin >= p[i]:
    ans += 1
    pmin = p[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ac = set()
pn = 0
l = []
for i in range(m):
  p, s = map(str, input().split())
  if s == 'AC':
    ac.add(p)
  l.append([p, s])


for a in ac:
  for p in l:
    if p[0] == a and p[1] == 'WA':
      pn += 1
    elif p[0] == a and p[1] == 'AC':
      break
print(len(list(ac)), pn)

Fixed submission:
from collections import defaultdict
d = defaultdict(int)
n, m = map(int, input().split())
ac = set()
for i in range(m):
  p, s = map(str, input().split())
  if s == 'AC':
    ac.add(p)
  elif s == 'WA' and p not in ac:
    d[p] += 1
for e in d.keys():
  if e not in ac:
    d[e] = 0
pn = d.values()
print(len(list(ac)), sum(pn))
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a, b = map(int, input().split())
print(lcm(a, b))

Fixed submission:
a, b = map(int, input().split())
ans = 0
if a > b:
  for i in range(1, a + 1):
    if b * i % a == 0:
      ans = b * i
      break
else:
  for i in range(1, b + 1):
    if a * i % b == 0:
      ans = a * i
      break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
for i in range(1, n // 2 + 1):
  if n % i == 0:
    a = i
    b = n // i
    l.append(a + b - 2)
print(min(l))

Fixed submission:
import math
n = int(input())
l = []
for i in range(1, int(math.sqrt(n)) + 1):
  if n % i == 0:
    a = i
    b = n // i
    l.append(a + b - 2)
print(min(l))

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(1, n // 2):
  if n % i == 0:
    l.append(i + n // i - 2)
print(min(l))

Fixed submission:
import math
n = int(input())
l = []
for i in range(1, int(math.sqrt(n)) + 1):
  if n % i == 0:
    a = i
    b = n // i
    l.append(a + b - 2)
print(min(l))
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
p = [k] * n
for i in range(q):
  a = int(input())
  for j in range(n):
    if j != a - 1:
      p[j] -= 1
for i in range(n):
  if p[i] <= 0:
    print('No')
  else:
    print('Yes')

Fixed submission:
from collections import defaultdict
d = defaultdict(int)
n, k, q = map(int, input().split())
for i in range(q):
  d[int(input())] += 1

for i in range(n):
  p = k - q
  if i + 1 in d:
    p += d[i + 1]
  if p <= 0:
    print('No')
  else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
a = []
i = 0
while i < n - 1:
  k = 0
  p = h[i]
  for j in range(i + 1, n):
    if p >= h[j]:
      p = h[j]
      k += 1
    else:
      break
  i = j
  a.append(k)
print(max(a))

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
a = [0]
i = 0
while i < n - 1:
  k = 0
  p = h[i]
  for j in range(i + 1, n):
    if p >= h[j]:
      p = h[j]
      k += 1
    else:
      break
  i = j
  a.append(k)
print(max(a))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int, input().split()))
a = []
for i in range(n):
  k = 0
  p = h[i]
  for j in range(i + 1, n):
    if p >= h[j]:     
      k += 1
      p = h[j]
    else:
      break
  a.append(k)
print(max(a))

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
a = [0]
i = 0
while i < n - 1:
  k = 0
  p = h[i]
  for j in range(i + 1, n):
    if p >= h[j]:
      p = h[j]
      k += 1
    else:
      break
  i = j
  a.append(k)
print(max(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [i for i in range(n)]
print(sum(a))

Fixed submission:
n = int(input())
ans = (n - 1) * n // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
a = []
for i in range(n):
  s = input()
  c = collections.Counter(list(s))
  a.append(c)
ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    if a[i] == a[j]:
      ans += 1
print(ans)

Fixed submission:
import collections
n = int(input())
a = []
for i in range(n):
  s = input()
  b = list(s)
  b.sort()
  b = ''.join(b)
  a.append(b)
c = collections.Counter(a)
ans = 0
for e in c:
  ans += c[e] * (c[e] - 1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
a = len(n)  # 桁数
if a % 2 == 0:  # 桁数が偶数
  ans = "90" * (a // 2)
  ans = int(ans[:-1])
else:
  ans = "90" * ((a - 1) // 2)
  ans = int(ans[:-1])
  ans += int(n) - 10 ** (a - 1) + 1
print(ans)

Fixed submission:
n = input()
a = len(n)  # 桁数
if a % 2 == 0:  # 桁数が偶数
  ans = "90" * (a // 2)
  ans = int(ans[:-1])
else:
  if a == 1:
    ans = int(n)
  else:
    ans = "90" * ((a - 1) // 2)
    ans = int(ans[:-1])
    ans += int(n) - 10 ** (a - 1) + 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
a = set()
for i in range(l, r):
  for j in range(i + 1, r + 1):
    a.add((i * j) % 2019)
a = list(a)
print(min(a))

Fixed submission:
l, r = map(int, input().split())
a = []
if r - l > 2019:
  for i in range(l, l + 2019):
    for j in range(i + 1, min(r + 1, l + 2020)):
      a.append((i * j) % 2019)
else:
  for i in range(l, r):
    for j in range(i + 1, r + 1):
      a.append((i * j) % 2019)
ans = min(a)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
ans = 0
def notdiv(n, m):
  return n // m

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a -= 1
e = b - notdiv(b, c) - notdiv(b, d) + notdiv(b, lcm(c, d))
f = a - notdiv(a, c) - notdiv(a, d) + notdiv(a, lcm(c, d))
ans = e - f
print(ans)

Fixed submission:
import math
a, b, c, d = map(int, input().split())
e = b - ((b // c) + (b // d) - (b // (c * d // math.gcd(c, d))))
f = (a - 1) - (((a - 1) // c) + ((a - 1) // d) - ((a - 1) // (c * d // math.gcd(c, d))))
ans = e - f
print(ans)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
ans = 1
for i in range(n):
  d += l[i]
  if d <= x:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
w = list(map(int, input().split()))
arr = []
for i in range(n):
  a = w[:i]
  b = w[i:]
  arr.append(abs(sum(a) - sum(b)))
print(min(arr))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
arr = [0] * n
for i in range(m):
  l, r = map(int, input().split())
  arr[l - 1] += 1
  arr[l] += 1
  arr[r - 1] += 1
ans = 0
for i in range(n):
  if arr[i] == m:
    ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
max_l = 0
min_r = n
ans = n
for i in range(m):
  l, r = map(int, input().split())
  if ans != 0:
    if l <= min_r or r <= max_l:
      max_l = max(max_l, l)
      min_r = min(min_r, r)
    else:
      ans = 0
if ans != 0:
  ans = min_r - max_l + 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
  for j in range((n - i * r) // g + 1):
    if (n - r * i - g * j) / b == abs(int((n - r * i - g * j) / b)):
      ans += 1
print(ans)

Fixed submission:
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
  for j in range((n - r * i) // g + 1):
    if (n - r * i - g * j) % b == 0 and (n - r * i - g * j) // b >= 0:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
  for j in range(n // g + 1):
    if (n - r * i - g * j) / b == int((n - r * i - g * j) / b) and (n - r * i - g * j) / b >= 0:
      ans += 1
print(ans)

Fixed submission:
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
  for j in range((n - r * i) // g + 1):
    if (n - r * i - g * j) % b == 0 and (n - r * i - g * j) // b >= 0:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
  for j in range(n // g + 1):
    if (n - (i * r + j * g)) % b == 0 and (n - (i * r + j * g)) // b >= 0 :
      ans += 1
print(ans)

Fixed submission:
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
  for j in range((n - r * i) // g + 1):
    if (n - r * i - g * j) % b == 0 and (n - r * i - g * j) // b >= 0:
      ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
a = ['A', 'C', 'G', 'T']
ans = []
k = 0
for i in range(len(s)):
  if s[i] in a:
    k += 1
  else:
    ans.append(k)
    k = 0
print(max(ans))

Fixed submission:
s = input()
a = ['A', 'C', 'G', 'T']
ans = []
k = 0
for i in range(len(s)):
  if s[i] in a:
    k += 1
  else:
    ans.append(k)
    k = 0
ans.append(k)
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = len(s)
f = 0
while f == 0: 
  s = s.replace('01', '').replace('10', '')
  if s.count('0') == 0 or s.count('1') == 0:
    f = 1 
    break
print(k - len(s))

Fixed submission:
s = input()
k = len(s)
a = s.count('0')
b = s.count('1')
ans = 0
if a >= b:
  ans = k - a + b
else:
  ans = k + a - b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = len(s)
f = 0
while f == 0: 
  s = s.replace('01', '')
  s = s.replace('10', '')
  if s.count('0') == 0 or s.count('1') == 0:
    f =1 
    break
print(k - len(s))

Fixed submission:
s = input()
k = len(s)
a = s.count('0')
b = s.count('1')
ans = 0
if a >= b:
  ans = k - a + b
else:
  ans = k + a - b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
f = 0
while f == 0:
  for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
      next
    else:
      ans += 2
      s = s[:i] + s[i + 2:]
      break
  if s.count('0') == 0 or s.count('1') == 0:
    f =1 
    break
print(ans)    

Fixed submission:
s = input()
k = len(s)
a = s.count('0')
b = s.count('1')
ans = 0
if a >= b:
  ans = k - a + b
else:
  ans = k + a - b
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
H = [h]
ans = 0
while len(H) > 0:
  if [] in H:
    H.remove([])
    if len(H) == 0:
      break
  for i in range(len(H)):
    if len(H[i]) == 0:
      H.pop(i)
    elif 0 in H[i]:
      a = H[i][:H[i].index(0)]
      b = H[i][H[i].index(0) + 1:]
      H.append(a)
      H.append(b)
      H.pop(i)
      if [] in H:
        H.remove([])
        if len(H) == 0:
          break
    else:
      ans += min(H[i])
      H[i] = [H[i][j] - min(H[i]) for j in range(len(H[i]))]
      a = H[i][:H[i].index(0)]
      b = H[i][H[i].index(0) + 1:]
      H.append(a)
      H.append(b)
      H.pop(i)
      if [] in H:
        H.remove([])
        if len(H) == 0:
          break
print(ans)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
H = [h]
ans = 0
while len(H) > 0:
  for e in H:
    if len(e) == 0:
      H.remove(e)
    elif 0 in e:
      a = e[:e.index(0)]
      b = e[e.index(0) + 1:]
      H.append(a)
      H.append(b)
      H.remove(e)
      if [] in H:
        H.remove([])
        if len(H) == 0:
          break
    else:
      ans += min(e)
      c = [e[j] - min(e) for j in range(len(e))]
      a = c[:c.index(0)]
      b = c[c.index(0) + 1:]
      H.append(a)
      H.append(b)
      H.remove(e)
      if [] in H:
        H.remove([])
        if len(H) == 0:
          break
    if [] in H:
      H.remove([])
      if len(H) == 0:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
f = 0
while f == 0:
  if 'BW' in s:
    a = s.index('BW')
    s = s[:a] + 'WB' + s[a + 2:]
    ans += 1
  else:
    f == 1
    break
print(ans)

Fixed submission:
s = input()
ans = 0
w = 0
for i in range(len(s)):
  if s[i] == 'W':
    ans += i - w
    w += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
ans =  [i for i in range(a, b + 1) if a <= i < a + k or b - k < i <=b]
for e in ans:
  print(e)

Fixed submission:
a, b, k = map(int, input().split())
ans = []
for i in range(k):
  if a + i <= b:
    ans.append(a + i)
  if b - i >= a:
    ans.append(b - i) 
for i in sorted(set(ans)):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
l = [i for i in range(a, b + 1)]
ans = l[:k] + l[-k:]
ans = list(set(ans))
ans.sort()
for e in ans:
  print(e)

Fixed submission:
a, b, k = map(int, input().split())
ans = []
for i in range(k):
  if a + i <= b:
    ans.append(a + i)
  if b - i >= a:
    ans.append(b - i) 
for i in sorted(set(ans)):
    print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
k = len(str(n))
a = 9 * (k - 1)
b = 0
for i in range(k):
  b += int(str(n)[i])
c = 0
if k > 2:
  m = str(int(n))[:k - 2] + str(int(int(str(n)[-2]) - 1)) + '9'
  for i in range(k):
    c += int(m[i])
ans = max(a, b, c)
print(ans)

Fixed submission:
n = input()
k = len(n)
a = 9 * (k - 1) + int(n[0]) - 1
b = 0
for i in range(k):
  b += int(n[i])
c = 0
m = ''
if k > 2 and n[-2] != '0':
  m = str(int(n))[:k - 2] + str(int(n[-2]) - 1) + '9'
elif k > 2 and n[-2] == '0':
  m = str(int(n) - (int(n[-1]) + 1))
for i in range(len(m)):
  c += int(m[i])
ans = max(a, b, c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, y = map(int, input().split())
a = [i for i in range(y // 10000 + 1)]
b = [i for i in range(y // 5000 + 1)]
m = list(itertools.product(a, b))
m = m[::-1]
ans = 0
for i in range(len(m)):
  if n - m[i][0] - m[i][1] >= 0 and m[i][0] * 10000 + m[i][1] * 5000 + (n - m[i][0] - m[i][1]) * 1000 == y:
    print(m[i][0], m[i][1], n - m[i][0] - m[i][1])
    ans = 1
    break
if ans == 0:
  print('-1 -1 -1')

Fixed submission:
import itertools
n, y = map(int, input().split())
k = [i for i in range(n + 1)]
ans = 0
for a, b in itertools.product(k, k):
  if n >= a + b and a * 10000 + b * 5000 + (n - a - b) * 1000 == y:
    print(a, b, n - a - b)
    ans = 1
    break
if ans == 0:
  print('-1 -1 -1')

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, y = map(int, input().split())
a = [i for i in range(y // 10000 + 1)]
b = [i for i in range(y // 5000 + 1)]
m = list(itertools.product(a, b))
ans = 0
for i in range(len(m)):
  if n - m[i][0] - m[i][1] >= 0 and m[i][0] * 10000 + m[i][1] * 5000 + (n - m[i][0] - m[i][1]) * 1000 == y:
    print(m[i][0], m[i][1], n - m[i][0] - m[i][1])
    ans = 1
    break
if ans == 0:
  print('-1 -1 -1')

Fixed submission:
import itertools
n, y = map(int, input().split())
k = [i for i in range(n + 1)]
ans = 0
for a, b in itertools.product(k, k):
  if n >= a + b and a * 10000 + b * 5000 + (n - a - b) * 1000 == y:
    print(a, b, n - a - b)
    ans = 1
    break
if ans == 0:
  print('-1 -1 -1')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
ans = ''
for i in range(m):
  if t[i] in d:
    d.pop(d.index(t[i]))
  else:
    ans = 'NO'
    break
if ans == '':
  ans = 'YES'
print(ans)

Fixed submission:
import collections
n = int(input())
d = list(map(str, input().split()))
m = int(input())
t = list(map(str, input().split()))
c_d = collections.Counter(d)
c_t = collections.Counter(t)
ans = ''
for e in c_t:
  if c_t[e] <= c_d[e]:
    next
  else:
    ans = 'NO'
if ans == '':
  ans = 'YES'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
for i in range(n):
  a = int(input())
  if a not in l:
    l.append(a)
  elif a in l:
    l.remove(a)
print(len(l))

Fixed submission:
import collections
n = int(input())
l = []
for i in range(n):
  l.append(int(input()))
d = collections.Counter(l)
ans = 0
for v in d.values():
  if v % 2 == 1:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
  b.append(a[i])
  b = b[::-1]
s = ' '.join([str(e) for e in b])
print(s)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [a[i] for i in range(n) if i % 2 == 0]
c = [a[i] for i in range(n) if i % 2 == 1]
if n % 2 == 0:
  d = c[::-1] + b
elif n % 2 == 1:
  d = b[::-1] + c
s = ' '.join([str(e) for e in d])
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
  for y in range(k + 1):
    if x + y > s:
      break
    for z in range(k + 1):
      if x + y + z == s:
        ans += 1
        break
      
print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
  for y in range(k + 1):
    if x + y > s:
      break
    z = s - x - y
    if 0 <= z <= k:
      ans += 1
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
  for y in range(k + 1):
    for z in range(k + 1):
      if x + y + z == s:
        ans += 1
print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
  for y in range(k + 1):
    if x + y > s:
      break
    z = s - x - y
    if 0 <= z <= k:
      ans += 1
      
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
c = a
d = b
while c % x != 0:
  c += 1
while d % x != 0:
  d -= 1
print((d - c) // x +1)

Fixed submission:
a, b, x = map(int, input().split())
c = b // x + 1
d = 0
if a - 1 > -1:
  d = (a - 1) // x + 1
else:
  d = 0
print(c - d)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
l = []
ans = 0
for i in range(n):
  x = i + 1
  y = a[i]
  p = [x, y]
  p.sort()
  if p in l:
    ans += 1
  else:
    l.append(p)
print(ans)

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
d = {}
ans = 0
for i in range(n):
  d[i + 1] = a[i]
for i in range(n):
  if d[d[i + 1]] == i + 1:
    ans += 1
ans //= 2
print(ans)