Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
a = list(map(int, input().split()))
for i in range(N - 1):
    a[i + 1] = math.gcd(a[i], a[i+1])
print(a[N-1])

Fixed submission:
import fractions

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

for i in range(N - 1):
    a[i + 1] = fractions.gcd(a[i], a[i+1])

print(a[N-1])

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
a = list(map(int, input().split()))

for i in range(N - 1):
    a[i + 1] = math.gcd(a[i], a[i+1])

print(a[N-1])

Fixed submission:
import fractions

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

for i in range(N - 1):
    a[i + 1] = fractions.gcd(a[i], a[i+1])

print(a[N-1])

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
a = list(map(int, input().split()))

for i in range(N - 1):
    a[i + 1] = int(math.gcd(a[i], a[i+1]))

print(a[N-1])

Fixed submission:
import fractions

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

for i in range(N - 1):
    a[i + 1] = fractions.gcd(a[i], a[i+1])

print(a[N-1])

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
a = list(map(int, input().split()))

for i in range(N - 1):
    a[i + 1] = int(math.gcd(a[i], a[i+1]))
    print(a)

print(a[N-1])

Fixed submission:
import fractions

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

for i in range(N - 1):
    a[i + 1] = fractions.gcd(a[i], a[i+1])

print(a[N-1])
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list()
ans = list()

for i in range(n):
    h.append(int(input()))
h.sort()

for i in range(n-k+1):
    ans.append(h[i+k-1] - h[i])

print(min(ans))

Fixed submission:
print('Christmas' + ' Eve' * (25 - int(input())))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
city = []
p_list = []
for i in range(m):
    p, y = map(int, input().split())
    city.append([p, y, i])
city.sort(key=lambda x: x[1])
city.sort()
n = 0
for i in range(m):
    p_list.append(city[i][0])
max_p = max(p_list)

for i in range(max_p + 1):
    for j in range(p_list.count(i)):
        city[n].append(str(p_list[n]).zfill(6) + (str(j + 1)).zfill(6))
        n += 1

city.sort(key=lambda x: x[2])
for i in range(m):
    print(city[i][3])


Fixed submission:
n, m = map(int, input().split())
tmp = [list(map(int, input().split())) for i in range(m)]
city = [[] for i in range(n+1)]
answers = [''] * m

for i, (pref, year) in enumerate(tmp):
    city[pref].append([year, i])

for i in range(n+1):
    for j, (year, index) in enumerate(sorted(city[i])):
        ans = str(i).zfill(6) + str(j+1).zfill(6)
        answers[index] = ans

print(*answers, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
city = []
p_list = []
for i in range(m):
    p, y = map(int, input().split())
    p_list.append(p)
    city.append([p, y, i])
p_list.sort()
city.sort(key=lambda x: x[1])
city.sort()

n = 0
max_p = max(p_list)

for i in range(max_p + 1):
    for j in range(p_list.count(i)):
        city[n].append(str(p_list[n]).zfill(6) + (str(j + 1)).zfill(6))
        n += 1

city.sort(key=lambda x: x[2])
for i in range(m):
    print(city[i][3])


Fixed submission:
n, m = map(int, input().split())
tmp = [list(map(int, input().split())) for i in range(m)]
city = [[] for i in range(n+1)]
answers = [''] * m

for i, (pref, year) in enumerate(tmp):
    city[pref].append([year, i])

for i in range(n+1):
    for j, (year, index) in enumerate(sorted(city[i])):
        ans = str(i).zfill(6) + str(j+1).zfill(6)
        answers[index] = ans

print(*answers, sep='\n')
Buggy python submission (verdict: Runtime Error):
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

Fixed submission:
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0) for xi, yi, hi in xyh if hi == 0)):
                print(cx, cy, H)
                exit()

Buggy python submission (verdict: Runtime Error):
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]


for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
      
        if len(height) == 1:
            H = max(height)
            if all(set(hi=max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

Fixed submission:
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0) for xi, yi, hi in xyh if hi == 0)):
                print(cx, cy, H)
                exit()

Buggy python submission (verdict: Runtime Error):
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]
print(xyh)

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        print(height)
        if len(height) == 1:
            H = max(height)
            if all(set(hi=max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

Fixed submission:
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0) for xi, yi, hi in xyh if hi == 0)):
                print(cx, cy, H)
                exit()
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(map(str, input().split()))
gu_row = [] * (int(n/2))
ki_row = [] * (int(n/2))

for i in range(n):
    if i % 2 == 0:
        gu_row.append(v[i])
    elif i % 2 == 1:
        ki_row.append(v[i])

gu_count = collections.Counter(gu_row).most_common()
ki_count = collections.Counter(ki_row).most_common()


if gu_count[0][0] != ki_count[0][0]:
    ans = n - gu_count[0][1] - ki_count[0][1]
else:
    ans = n - max(gu_count[0][1] + ki_count[1][1], gu_count[1][1] + ki_count[0][1])

print(ans)

Fixed submission:
import collections
n = int(input())
v = list(map(str, input().split()))
gu_row = []
ki_row = []

for i in range(n):
    if i % 2 == 0:
        gu_row.append(v[i])
    elif i % 2 == 1:
        ki_row.append(v[i])

gu_count = collections.Counter(gu_row).most_common()
ki_count = collections.Counter(ki_row).most_common()

if len(gu_count) > 1 and len(ki_count) > 1:
    if gu_count[0][0] != ki_count[0][0]:
        ans = n - gu_count[0][1] - ki_count[0][1]
    elif gu_count[0][0] == ki_count[0][0] and len(gu_count) == 1:
        ans = n - gu_count[0][1] - ki_count[1][1]
    elif gu_count[0][0] == ki_count[0][0] and len(ki_count) == 1:
        ans = n - gu_count[1][1] - ki_count[0][1]
    else:
        ans = n - max(gu_count[0][1] + ki_count[1][1], gu_count[1][1] + ki_count[0][1])
else:
    if gu_count[0][0] != ki_count[0][0]:
        ans = n - gu_count[0][1] - ki_count[0][1]
    else:
        ans = gu_count[0][1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, k = map(int, input().split())
a = []
x = k/2
count = 0
while x <= n:
    if x % 1 == 0:
        a.append(int(x))
    x += k/2
ori_list = list(itertools.product(a, repeat=3))
for i in range(len(ori_list)):
    if (ori_list[i][0] + ori_list[i][1]) % k == 0:
    	if (ori_list[i][1] + ori_list[i][2]) % k == 0:
    		if (ori_list[i][0] + ori_list[i][2]) % k == 0:
        		count += 1

print(count)

Fixed submission:
n, k = map(int, input().split())
cnt = 0

if k % 2 == 1:
    for i in range(1, n+1):
        if i % k == 0:
            cnt += 1
    ans = cnt ** 3
elif k % 2 == 0:
    cnt1 = 0
    cnt2 = 0
    for i in range(1, n+1):
        if i % k == 0:
            cnt1 += 1
        elif i % k == k/2:
            cnt2 += 1
    ans = cnt1 ** 3 + cnt2 ** 3
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, k = map(int, input().split())
a = []
x = k/2
while x <= n:
    if x % 1 == 0:
        a.append(int(x))
    x += k/2
ori_list = list(itertools.product(a, repeat=3))
for i in range(len(ori_list)):
    if (ori_list[i][0] + ori_list[i][1]) % k != 0:
        ori_list[i] = 'none'
    elif (ori_list[i][1] + ori_list[i][2]) % k != 0:
        ori_list[i] = 'none'
    elif (ori_list[i][0] + ori_list[i][2]) % k != 0:
        ori_list[i] = 'none'

while 'none' in ori_list:
    ori_list.remove('none')

print(len(ori_list))

Fixed submission:
n, k = map(int, input().split())
cnt = 0

if k % 2 == 1:
    for i in range(1, n+1):
        if i % k == 0:
            cnt += 1
    ans = cnt ** 3
elif k % 2 == 0:
    cnt1 = 0
    cnt2 = 0
    for i in range(1, n+1):
        if i % k == 0:
            cnt1 += 1
        elif i % k == k/2:
            cnt2 += 1
    ans = cnt1 ** 3 + cnt2 ** 3
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = list(map(int, input().split()))
minus = []
minus.append(0)
plus = []
plus.append(0)

for n in x:
    if n < 0:
        minus.append(n)
    else:
        plus.append(n)
minus.sort(reverse=True)
totals = []

for i in range(len(minus)):
    if k-i < len(plus):
        if i == 0:
            totals.append(plus[k-i])
        else:
            totals.append(2 * abs(minus[i]) + plus[k-i])
            # print(i)
            # print(abs(minus[i]))
            # print(plus[k-i])
for i in range(len(plus)):
    if k-i < len(minus):
        if i == 0:
            totals.append(abs(minus[k-i]))
        else:
            totals.append(2 * plus[i] + abs(minus[k-i]))
# print(totals)
print(min(totals))


Fixed submission:
n, k = map(int, input().split())
x = list(map(int, input().split()))
minus = []
minus.append(0)
plus = []
plus.append(0)

for n in x:
    if n < 0:
        minus.append(n)
    else:
        plus.append(n)
minus.sort(reverse=True)
totals = []

for i in range(len(minus)):
    if (k-i < len(plus)) and (k-i >= 0):
        if i == 0:
            totals.append(plus[k-i])
        else:
            totals.append(2 * abs(minus[i]) + plus[k-i])
            # print(i)
            # print(abs(minus[i]))
            # print(plus[k-i])
for i in range(len(plus)):
    if (k-i < len(minus)) and (k-i >= 0):
        if i == 0:
            totals.append(abs(minus[k-i]))
        else:
            totals.append(2 * plus[i] + abs(minus[k-i]))
# print(totals)
print(min(totals))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, y = map(int, input().split())

sihei = [1000, 5000, 10000]
money = list(itertools.combinations_with_replacement(sihei, n))
flag = False

for i in range(len(money)):
    if sum(money[i]) == y:
        # print(money[i])
        print(str(money[i].count(10000)) + ' ' + str(money[i].count(5000)) + ' ' + str(money[i].count(1000)))
        flag = True
        break

if flag is False:
    print('-1 -1 -1')

Fixed submission:
n, t = map(int, input().split())
flag = False
for x in range(n+1):
    if flag is True:
        break
    for y in range(n-x+1):
        # print(10000 * x + 5000 * y + 1000 * (n-x-y))
        if (10000 * x + 5000 * y + 1000 * (n-x-y)) == t:
            print(str(x) + ' ' + str(y) + ' ' + str(n-x-y))
            flag = True
            break

if flag is False:
    print('-1 ' * 3)
Buggy python submission (verdict: Runtime Error):
n = input()
for i in range(len(n)//2){
  if n[i] != n[-(i+1)]:
  	print('No')
  	exit(0)
print('Yes')

Fixed submission:
import sys
n = input()
for i in range(len(n)//2):
  if n[i] != n[-(i+1)]:
  	print('No')
  	sys.exit(0)
print('Yes')
Buggy python submission (verdict: Runtime Error):
S=list(input())
N=int(input())
P=list()
jia= N%26
for i in range(len(S)):
  xin= ord(S[i])+jia
  if xin > ord("Z"):
   xin-=26
  zimu=chr(xin)
  P+=zimu
p=''.join(P)
print(p)


Fixed submission:
N=int(input())
S=list(input())
P=list()
jia= N%26
for i in range(len(S)):
  xin= ord(S[i])+jia
  if xin > ord("Z"):
   xin-=26
  zimu=chr(xin)
  P+=zimu
p=''.join(P)
print(p)
Buggy python submission (verdict: Runtime Error):
a = [0] * 100
for i in range(1, 10):
    for j in range(1, 10):
        a[i * j] = 1
num = int(input())
if a[num] == 1:
    print('Yes')
else:
    print('No')



Fixed submission:
a = [0] * 100
for i in range(1, 10):
    for j in range(1, 10):
        a[i * j] = 1
num = int(input())
if num < 100 and a[num] == 1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(50):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if x == 1:
  ans = 1

print(ans)

Fixed submission:
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if H == 1:
  ans = 1

print(ans)

Buggy python submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(42):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if x == 1:
  ans = 1

print(ans)

Fixed submission:
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if H == 1:
  ans = 1

print(ans)

Buggy python submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if x == 1:
  ans = 1

print(ans)

Fixed submission:
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if H == 1:
  ans = 1

print(ans)

Buggy python submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(40):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if x == 1:
  ans = 1

print(ans)

Fixed submission:
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if H == 1:
  ans = 1

print(ans)

Buggy python submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(40):
  if x < H and x*2 >= H:
    ans = x*2 - 1
    break
  x = x*2

print(ans)

Fixed submission:
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if H == 1:
  ans = 1

print(ans)

Buggy python submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(40):
  if x < H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
    
print(ans)

Fixed submission:
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if H == 1:
  ans = 1

print(ans)
Buggy python submission (verdict: Runtime Error):
tmp = list(map(int,input().split()))
L = tmp[0] % 2019
R = tmp[1] % 2019
l = tmp[0]//2019
r = tmp[1]//2019
if l == r:
  num_list = []
  for i in range(tmp[0],tmp[1]+1,1):
    for k in range(i+1,tmp[1],1):
      num_list.append((i*k) % 2019)
  print(min(num_list))
else:
  print(0)

Fixed submission:
tmp = list(map(int,input().split()))
L = tmp[0] % 2019
R = tmp[1] % 2019
l = tmp[0]//2019
r = tmp[1]//2019
if l == r:
  if tmp[1] - tmp[0] > 673:
    print(0)
  else:
    num_list = []
    for i in range(tmp[0],tmp[1]+1,1):
      for k in range(i+1,tmp[1]+1,1):
        num_list.append((i*k) % 2019)
    print(min(num_list))
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = map(int,input().split(' '))

countsum = 0
countC = 0
countD = 0
countC_D = 0
for i in range(A,B+1,1):
  countsum += 1
  if i % C == 0:
    countC += 1
  if i % D == 0:
    countD += 1
  if i % C == 0 and i % D == 0:
    countC_D += 1

print(countsum-countC-countD+countC_D)

Fixed submission:
import fractions as frac
A,B,C,D = map(int,input().split(' '))

countC = (B // C) - (A // C)
countD = (B // D) - (A // D)
def lcm(x, y):
    return (x * y) // frac.gcd(x, y)
lcmCD = lcm(C, D)

countlcm = (B // lcmCD) - (A // lcmCD) 

num = B - A + 1
if A % C == 0:
  countC += 1
if A % D == 0:
  countD += 1
if A % lcmCD == 0:
  countlcm += 1

print(num - countC - countD + countlcm)
Buggy python submission (verdict: Runtime Error):
N,K = input().split(' ')
N = int(N)
K = int(K)
num_list = list(map(int,input().split(' ')))
pivot = 0
ans = 0
while (pivot < len(num_list)):
  flag = 0
  tmp_num = 0
  for i in range(pivot, len(num_list), 1):
    tmp_num += num_list[i]
    if tmp_num >= K:
      ans += (N - i)
      pivot += 1
      break
    elif tmp_num < K and i == len(num_list)-1:
      flag = 1
      break
      
  if flag == 1:
    break
    
for i in range(pivot, len(num_list), 1):
  sum_num = sum(num_list[pivot + 1:])
  if sum_num < K:
    break
  ans += 1
      
print(ans)

Fixed submission:
X,A = map(int,input().split(' '))
if X < A:
  print('0')
else:
  print('10')
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
S = input()

if S[K] = 'A':
  S[K] = 'a'
if S[K] = 'B':
  S[K] = 'b'
if S[K] = 'C':
  S[K] = 'c'

print(S)

Fixed submission:
N,K = map(int, input().split())
S = input()
newS = ''
for i in range(N):
  if i == K-1:
    if S[i] == 'A':
      newS += 'a'
    if S[i] == 'B':
      newS += 'b'
    if S[i] == 'C':
      newS += 'c'
  else:
    newS += '{}'.format(S[i])

print(newS)
Buggy python submission (verdict: Runtime Error):
[N,X] = list(map(int,input().split(' ')))

def paty(n,x):
  if n == 0:
    if x == 1:
      return 1
    elif x == 0:
      return 0
  elif int((2**(n+2)-3 - 1) / 2) >= x:
    return paty(n-1,x-2)
  elif int((2**(n+2)-3 + 1) / 2) == x:
    return paty(n-1,x-2) + 1
  else:
    return 2**n + paty(n-1, x-(2**(n+1)-3) -3)
  
ans = paty(N,X)
print(ans)

Fixed submission:
[N,X] = list(map(int,input().split(' ')))

def paty(n,x):
  #print('n:{}'.format(n))
  #print('x:{}'.format(x))
  if x == 0:
    return 0
  if n == 0:
    return x
  elif ((2**(n+2))-3 - 1) / 2 >= x:
    return paty(n-1,x-1)
  elif ((2**(n+2))-3 + 1) / 2 == x:
    return 2**n
  elif ((2**(n+2))-3) - 1 <= x:
    return 2**(n+1) - 1
  else:
    return 2**n + paty(n-1, x-((2**(n+1))-3) -2)
  
ans = paty(N,X)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
card = list(map(int,input().split(' ')))

sum_card = sum(card)
dif_list = []
min_value = 1000000000
for i in range(1,N,1):
  sunuke = sum(card[:i])
  if abs(sum_card/2 - sunuke) < min_value:
    min_value = abs(sum_card/2 - sunuke)
  
print(int(2*min_value))

Fixed submission:
N = int(input())
card = list(map(int,input().split(' ')))

sum_card = sum(card)
min_value = 10000000000
sunuke = 0
for i in range(0,N-1,1):
  sunuke += card[i]
  if abs(sum_card - 2*sunuke) < min_value:
    min_value = abs(sum_card - 2*sunuke)
  
print(int(min_value))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
card = list(map(int,input().split(' ')))

dif_list = []
for i in range(1,N,1):
  sunuke = sum(card[:i])
  arai = sum(card[i:])
  dif = abs(sunuke-arai)
  dif_list.append(dif)
  
print(min(dif_list))

Fixed submission:
N = int(input())
card = list(map(int,input().split(' ')))

sum_card = sum(card)
min_value = 10000000000
sunuke = 0
for i in range(0,N-1,1):
  sunuke += card[i]
  if abs(sum_card - 2*sunuke) < min_value:
    min_value = abs(sum_card - 2*sunuke)
  
print(int(min_value))
Buggy python submission (verdict: Runtime Error):
def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    dp = [0] + [0] * h
    for i in range(1, h + 1):
        dp[i] = min(dp[i - a] + b for a, b in ab)
    print(dp[h])


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    amax = max(a for a, b in ab)
    dp = [0] + [0] * (h + amax)
    for i in range(1, h + 1):
        dp[i] = min(dp[i - a] + b for a, b in ab)
    print(dp[h])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    dp = [0] + [0] * h
    for i in range(1, h + 1):
        dp[i] = min(dp[i - a] + b for a, b in ab)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    amax = max(a for a, b in ab)
    dp = [0] + [0] * (h + amax)
    for i in range(1, h + 1):
        dp[i] = min(dp[i - a] + b for a, b in ab)
    print(dp[h])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
"""
6 1
3
"""

n, m = list(map(int, input().split()))
aaa = list(int(input()) for i in range(m))

dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0
MOD = 10 ** 9 + 7

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

print(dp[n])


Fixed submission:
n, m = list(map(int, input().split()))
broken = [False] * (n + 1)
for _ in range(m):
    broken[int(input())] = True

dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if not broken[1] else 0
MOD = 10 ** 9 + 7

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

print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):

n, m = list(map(int, input().split()))
aaa = list(int(input()) for i in range(m))

dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0
MOD = 10 ** 9 + 7

for i in range(2, n + 1):
    if i in aaa:
        continue
    dp[i] = (dp[i - 2] + dp[i - 1])
print(dp[n] % MOD)


Fixed submission:
n, m = list(map(int, input().split()))
broken = [False] * (n + 1)
for _ in range(m):
    broken[int(input())] = True

dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if not broken[1] else 0
MOD = 10 ** 9 + 7

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

print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))
aaa = [int(input()) for _ in range(m)]

dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0
MOD = 10 ** 9 + 7

for i in range(2, n + 1):
    if i in aaa:
        continue
    dp[i] = (dp[i - 2] + dp[i - 1])
print(dp[n] % MOD)


Fixed submission:
n, m = list(map(int, input().split()))
broken = [False] * (n + 1)
for _ in range(m):
    broken[int(input())] = True

dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if not broken[1] else 0
MOD = 10 ** 9 + 7

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

print(dp[n])