Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
numbers=[str(i).zfill(3) for i in range(1000)]
 
count=0
for num in numbers:
  j=0
  for i in range(N):
    if num[j]==S[i]:
      j+=1
      if j==3:
        count+=1
        break

print(count)

Fixed submission:
N = int(input())
S = input()
numbers=[str(i).zfill(3) for i in range(1000)]
 
count=0
for num in numbers:
  j=0
  for i in range(N):
    if num[j]==S[i]:
      j+=1
      if j==3:
        count+=1
        break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
 
lis = [0 for _ in range(1000)]
 
usiro_lis = [[0 for _ in range(10)] for _ in range(N)]
for i in range(N)[::-1]:
  for j in range(0, i):
    usiro_lis[j][int(S[i])] = 1

for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(10):
      if usiro_lis[j][k] == 1:
      	lis[100*int(S[i])+10*int(S[j])+k] = 1
      
print(sum(lis))

Fixed submission:
N = int(input())
S = input()
numbers=[str(i).zfill(3) for i in range(1000)]
 
count=0
for num in numbers:
  j=0
  for i in range(N):
    if num[j]==S[i]:
      j+=1
      if j==3:
        count+=1
        break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
 
lis = [0 for _ in range(1000)]
 
for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      lis[100*int(S[i])+10*int(S[j])+int(S[k])] = 1
      
print(sum(lis))

Fixed submission:
N = int(input())
S = input()
numbers=[str(i).zfill(3) for i in range(1000)]
 
count=0
for num in numbers:
  j=0
  for i in range(N):
    if num[j]==S[i]:
      j+=1
      if j==3:
        count+=1
        break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

lis = [0 for _ in range(1000)]

usiro_lis = [[0 for _ in range(10)] for _ in range(N)]
for i in range(N)[::-1]:
  for j in range(0, i):
    usiro_lis[j][int(S[i])] = 1

for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(10):
      if usiro_lis[j][k] == 1:
      	lis[100*int(S[i])+10*int(S[j])+k] = 1
      
print(sum(lis))

Fixed submission:
N = int(input())
S = input()
numbers=[str(i).zfill(3) for i in range(1000)]
 
count=0
for num in numbers:
  j=0
  for i in range(N):
    if num[j]==S[i]:
      j+=1
      if j==3:
        count+=1
        break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

lis = [0 for _ in range(1000)]

for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      lis[100*int(S[i])+10*int(S[j])+int(S[k])] = 1
      
print(sum(lis))

Fixed submission:
N = int(input())
S = input()
numbers=[str(i).zfill(3) for i in range(1000)]
 
count=0
for num in numbers:
  j=0
  for i in range(N):
    if num[j]==S[i]:
      j+=1
      if j==3:
        count+=1
        break
print(count)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split()))

count = 0
for i in range(N):
  if h[i] >= K:
    count += 1
print(count)

Fixed submission:
N = int(input())

if N % 2 == 0:
  print(0.5)
else:
  print((N//2+1) / N)
Buggy python submission (verdict: Runtime Error):
import itertools
 
N, K = map(int, input().split())
S = input()
 
lis = [len(list(g)) for _, g in itertools.groupby(S)]
 
if len(lis) < 2*K + 1:
  print(N-1)
else:
  print(max(sum(lis[:2*K+1]), sum(lis[len(lis)-2*K-2:])))


Fixed submission:
N = int(input())

print(N ** 3)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

count = 0
for i in range(1, N):
  count += i % (i + 1)
print(count)

Fixed submission:
N = int(input())
 
print(N * (N - 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

count = 0
for i in range(1, N):
  count += i % (i + 1)
print(count)

Fixed submission:
N = int(input())
 
print(N * (N - 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

count = 0
for i in range(1, N):
  count += i % (i + 1)
print(count)

Fixed submission:
N = int(input())
 
print(N * (N - 1) // 2)
Buggy python submission (verdict: Runtime Error):
import math
 
N = int(input())
 
count = 0
for i in range(1, N+1):
  if math.floor(math.log10(i)) % 2 == 0:
    count += 1
print(count)

Fixed submission:
A, B, C = map(int, input().split())

if A - B <= C:
  print(C - A + B)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = []
a = list(map(int,input().split()))
 
b = [0]*N
for i in reversed(range(N)):
    j = i + 1
    buf = b[i::j]
    if (sum(buf) % 2) != a[i]:
        b[i] = 1
print(sum(b))
bb = [i+1 for i in range(N) if b[i] == 1]
if sum(b) != 0:
    print(' '.join(map(str, bb)))

Fixed submission:
r = int(input())

print(3 * r ** 2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input) for _ in range(N)]
B = sorted(A, reverse=True)

for i in range(N):
    if A[i] <= B[0]:
        print(B[0])
    else:
        print(B[1])

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A, reverse=True)

for i in range(N):
    if A[i] < B[0]:
        print(B[0])
    else:
        print(B[1])
Buggy python submission (verdict: Runtime Error):
from math import factorial

N, K = map(int, input().split())

for i in range(1, K+1):
  print(int(factorial(N-K+1)*factorial(K-1)/factorial(N-K+1-i)/factorial(i)/factorial(i-1)/factorial(K-i) % (10**9+7)))

Fixed submission:
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n, r = map(int, input().split())

for i in range(1, r+1):
  if n-r+1 < i:
    print(0)
  else:
    print(cmb(n-r+1,i)*cmb(r-1,i-1)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
a = list(map(int, input().split()))

i = 0
count = 0
while i < N:
  for j in range(N-i):
    if sum(a[j:j+1+i]) >= K:
      count += 1
  i += 1
  
print(count)

Fixed submission:
N, K = map(int, input().split())

if N < K:
  print(0)
else:
  print(10)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
  
count = 0
for i in range(1, N+1):
  flag = 0
  for j in range(M-1, -1, -1):
    if not (LR[j][0] <= i <= LR[j][1]):
      break
    else:
      flag += 1
    if flag == M:
      count += 1

print(count)

Fixed submission:
N, M = map(int, input().split())

LR = [list(map(int, input().split())) for _ in range(M)]

L = []
R = []
for i in LR:
  L.append(i[0])
  R.append(i[1])
  
if min(R) - max(L) < 0:
  print(0)
else:
  print(min(R) - max(L) + 1)

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

L = []
R = []
for i in range(M):
  L.append(LR[i][0])
  R.append(LR[i][1])
  
count = 0
flag = 0
for i in range(1, N+1):
  flag = 0
  for j in range(M-1, -1, -1):
    if not (L[j] <= i <= R[j]):
      break
    else:
      flag += 1
    if flag == M:
      count += 1

print(count)

Fixed submission:
N, M = map(int, input().split())

LR = [list(map(int, input().split())) for _ in range(M)]

L = []
R = []
for i in LR:
  L.append(i[0])
  R.append(i[1])
  
if min(R) - max(L) < 0:
  print(0)
else:
  print(min(R) - max(L) + 1)

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

L = []
R = []
for i in range(M):
  L.append(LR[i][0])
  R.append(LR[i][1])
  
count = 0
flag = 0
for i in range(1, N+1):
  flag = 0
  for j in range(M):
    if not (L[j] <= i <= R[j]):
      break
    else:
      flag += 1
    if flag == M:
      count += 1

print(count)

Fixed submission:
N, M = map(int, input().split())

LR = [list(map(int, input().split())) for _ in range(M)]

L = []
R = []
for i in LR:
  L.append(i[0])
  R.append(i[1])
  
if min(R) - max(L) < 0:
  print(0)
else:
  print(min(R) - max(L) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

org_list = [R, G, B]
org_list.sort()
first_num = org_list[2]
second_num = org_list[1]
third_num = org_list[0]

count = 0

for i in range(N // first_num + 1):
  if i*first_num > N:
    break
  for j in range((N-i*first_num) // second_num + 1):
    if i*first_num + j*second_num > N:
      break
    if (N - i*first_num - j*second_num) % third_num == 0:
      count += 1
 
print(count)

Fixed submission:
R, G, B, N = map(int, input().split())

org_list = [R, G, B]
org_list.sort()
first_num = org_list[2]
second_num = org_list[1]
third_num = org_list[0]

count = 0

for i in range(N // first_num + 1):
  for j in range((N-i*first_num) // second_num + 1):
    if (N - i*first_num - j*second_num) % third_num == 0:
      count += 1
 
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

org_list = [R, G, B]
org_list.sort()
first_num = org_list[2]
second_num = org_list[1]
third_num = org_list[0]

count = 0

for i in range(N // first_num + 1):
  if i*first_num > N:
    break
  for j in range(N // second_num + 1):
    if i*first_num + j*second_num > N:
      break
    if (N - i*first_num - j*second_num) % third_num == 0:
      count += 1
 
print(count)

Fixed submission:
R, G, B, N = map(int, input().split())

org_list = [R, G, B]
org_list.sort()
first_num = org_list[2]
second_num = org_list[1]
third_num = org_list[0]

count = 0

for i in range(N // first_num + 1):
  for j in range((N-i*first_num) // second_num + 1):
    if (N - i*first_num - j*second_num) % third_num == 0:
      count += 1
 
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

n = 1000
count = 0
for i in range(N // R + 1):
  if i*R > N:
    break
  for j in range(N // G + 1):
    if i*R + j*G > N:
      break
    if (N - i*R - j*G) % B == 0:
      count += 1
 
print(count)

Fixed submission:
R, G, B, N = map(int, input().split())

org_list = [R, G, B]
org_list.sort()
first_num = org_list[2]
second_num = org_list[1]
third_num = org_list[0]

count = 0

for i in range(N // first_num + 1):
  for j in range((N-i*first_num) // second_num + 1):
    if (N - i*first_num - j*second_num) % third_num == 0:
      count += 1
 
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]

c = [[10**9 for _ in range(W)] for _ in range(H)]
que = deque()

for i in range(H):
  for j in range(W):
    if maze[i][j] == "#":
      c[i][j] = 0
      que.append([i, j])

dxy = [[-1, 0], [1, 0], [0, -1], [0, 1]]      
      
while len(que) != 0:
  p = que.popleft()
  for i in dxy:
    nx = p[0] + i[0]
    ny = p[1] + i[1]
    if 0 <= nx < H and 0 <= ny < W and c[nx][ny] == 10**9 and maze[nx][ny] ==".":
      maze[nx][ny] = "#"
      c[nx][ny] = c[p[0]][p[1]] + 1
      que.append([nx, ny])
max = 0
for i in range(H):
  for j in range(W):
    if max < c[i][j]:
      max = c[i][j]
print(max)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]

c = [[10**9 for _ in range(W)] for _ in range(H)]
que = deque()

for i in range(H):
  for j in range(W):
    if maze[i][j] == "#":
      c[i][j] = 0
      que.append([i, j])

dxy = [[-1, 0], [1, 0], [0, -1], [0, 1]]      
      
while len(que) != 0:
  p = que.popleft()
  for i in dxy:
    nx = p[0] + i[0]
    ny = p[1] + i[1]
    if 0 <= nx < H and 0 <= ny < W and c[nx][ny] == 10**9 and maze[nx][ny] ==".":
      maze[nx][ny] = "#"
      c[nx][ny] = c[p[0]][p[1]] + 1
      que.append([nx, ny])
max = 0
for i in range(H):
  for j in range(W):
    if max < c[i][j]:
      max = c[i][j]
print(max)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())

count_1 = 0
count_2 = 0
for i in range(N-1):
  if S[i] == "#" and S[i+1] == ".":
    count_1 += 1
for i in range(N-1):
  if S[N - i - 1] == "." and S[N - i - 2] == "#":
    count_2 += 1
    
print(min(count_1, count_2))

Fixed submission:
A, B, C = list(map(int, input().split()))

D = max([A, B])
E = min([A, B])
if E <= C <= D:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())

print(180*(N-2))

Fixed submission:
a,b=(int(x) for x in input().split())

if a >= b:
    count = a
    a -= 1
else:
    count = b
    b -= 1

if a >= b:
    count += a
else:
    count += b
    
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = int(input().split())
count = 0
max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
count = 0
max = 0
for i in range(N):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = input().split()
count = 0
max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
count = 0
max = 0
for i in range(N):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = []
count = 0
for i in range(N):
    h.append(int(input()))
max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
count = 0
max = 0
for i in range(N):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = []
for i in range(N):
    h.append(int(input()))
max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
count = 0
max = 0
for i in range(N):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = [0]
for i in range(N):
    h = list.append(int(input()))
max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
count = 0
max = 0
for i in range(N):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())

h = []
for i in range(N):
    h = list.append(int(input()))

max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1

print(count)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
count = 0
max = 0
for i in range(N):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())

h = [int(x) for x in input().split()]

max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1

print(count)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
count = 0
max = 0
for i in range(N):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())

h = [int(x) for x in input().split()]

max = 0
for i in n:
    if max <= h[i]:
        max = h[i]
        count += 1

print(count)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
count = 0
max = 0
for i in range(N):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
ab = sorted(ab, key=lambda x:x[1], reverse=True)

dellist = lambda items,indices: [item for idx,item in enumerate(items) if idx not in indices]

count = 0
while len(ab) != 0:
  p = ab.pop()
  count += 1
  del_idx = []
  for i in range(len(ab)):
    if ab[i][0] < p[1]:
      del_idx.append(i)
  ab = dellist(ab, del_idx) # ['japanese','!!']
print(count)

Fixed submission:
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
ab = sorted(ab, key=lambda x:x[1])
count = 0

del_num = 0
for i in range(M):
  if ab[i][0] >= del_num:
    count += 1
    del_num = ab[i][1]
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

alice_count = 0
bob_count = 0
for i in range(N//2):
  alice_count += max(a)
  a.pop(a.index(max(a)))
  bob_count += max(a)
  a.pop(a.index(max(a)))

if a:
  alice_count += a[0]
  
count = alice_count - bob_count

print(count)

Fixed submission:
N = int(input())
A = int(input())

if (N % 500) <= A:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
def threeArea(w, h, ans):
  for i in range(1, h):
    recA = w * i
    width = w//2
    recB = (h-i) * width
    recC = w * h - recA - recB
    diff = max(recA, recB, recC) - min(recA, recB, recC)
 
	height = (h - i) //2
    recB = w * height
    recC = w * h - recA - recB
    diff = min(diff, max(recA, recB, recC) - min(recA, recB, recC))
    if ans > diff:
      ans = diff
  return ans

H, W = (int(i) for i in input().split())
 
ans = float('inf')
ans = threeArea(W, H, ans)
ans = threeArea(H, W, ans)
 
print(ans)

Fixed submission:
def threeArea(w, h, ans):
  for i in range(1, h):
    recA = w * i
    width = w//2
    recB = (h-i) * width
    recC = w * h - recA - recB
    diff = max(recA, recB, recC) - min(recA, recB, recC)
    
    height = (h - i) //2
    recB = w * height
    recC = w * h - recA - recB
    diff = min(diff, max(recA, recB, recC) - min(recA, recB, recC))
    if ans > diff:
      ans = diff
  return ans

H, W = (int(i) for i in input().split())
 
ans = float('inf')
ans = threeArea(W, H, ans)
ans = threeArea(H, W, ans)
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

for i in range(Q):
  l, r = map(int, input().split())
  deleted = S[l-1:r]
  print(deleted.count('AC'))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(1, N+1):
  t[i] = t[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)
  
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

for i in range(Q):
  l, r = map(int, input().split())
  deleted = S[l-1:r]
  print(len(deleted.split('AC'))-1)

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(1, N+1):
  t[i] = t[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)
  
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

for i in range(Q):
  l, r = map(int, input().split())
  deleted = S[l-1:r]
  
  print(len(''.join(deleted).split('AC'))-1)

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(1, N+1):
  t[i] = t[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)
  
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1]-t[l-1])

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

for i in range(Q):
  tmp = input().split()
  l = int(tmp[0])
  r = int(tmp[1])
  
  deleted = S[l-1:r]
  print(len(''.join(deleted).split('AC'))-1)

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(1, N+1):
  t[i] = t[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)
  
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1]-t[l-1])

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

for i in range(Q):
  ans = 0
  tmp = input().split()
  l = int(tmp[0])
  r = int(tmp[1])
  
  deleted = S[l-1:r]

  for j in range(len(deleted)-1):  
    if deleted[j] == 'A' and deleted[j+1] == 'C':
      ans += 1
  
  print(ans)
  ans = 0

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(1, N+1):
  t[i] = t[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)
  
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1]-t[l-1])
Buggy python submission (verdict: Runtime Error):
h_all, w_all = map(int, input().split)
h_b, w_b = map(int, input().split)

print((h_all - h_b) * (w_all - w_b))

Fixed submission:
h_all, w_all = map(int, input().split())
h_b, w_b = map(int, input().split())
 
print((h_all - h_b) * (w_all - w_b))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
data = []

for i in range(N):
  tmp_a, tmp_b = map(int, input().split())
  data.append((tmp_a, tmp_b))

sorted_data = sorted(data, key=lambda x: x[0])
  
buy_count = 0
money_count = 0

while buy_count < M:
  tmp_a = sorted_data[0][0]
  tmp_b = sorted_data[0][1]

  if buy_count + tmp_b < M:
    buy_count += tmp_b
    money_count += tmp_b * tmp_a
    sorted_data.pop(0)
  else:
    while buy_count < M:
      buy_count += 1
      money_count += tmp_a
      
print(money_count)

Fixed submission:
N, M = map(int, input().split())
data = []

for i in range(N):
  tmp_a, tmp_b = map(int, input().split())
  data.append((tmp_a, tmp_b))

sorted_data = sorted(data, key=lambda x: x[0])
  
buy_count = 0
money_count = 0

while buy_count < M:
  tmp_a = sorted_data[0][0]
  tmp_b = sorted_data[0][1]

  if buy_count + tmp_b < M:
    buy_count += tmp_b
    money_count += tmp_b * tmp_a
    sorted_data.pop(0)
  else:
    while buy_count < M:
      buy_count += 1
      money_count += tmp_a
      
print(money_count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = []
B = []

for i in range(N):
  tmp_a, tmp_b = map(int, input().split())
  A.append(tmp_a)
  B.append(tmp_b)
  
buy_count = 0
money_count = 0

while True:
  min_a = min(A)
  index_a = A.index(min_a)
  value_b = B[index_a]
  
  while buy_count < M:
    if value_b == 0:  
      A.pop(index_a)
      B.pop(index_a)
      break
    value_b -= 1
    buy_count += 1
    money_count += A[index_a]
  
  if buy_count == M:
    break
  
print(money_count)

Fixed submission:
N, M = map(int, input().split())
data = []

for i in range(N):
  tmp_a, tmp_b = map(int, input().split())
  data.append((tmp_a, tmp_b))

sorted_data = sorted(data, key=lambda x: x[0])
  
buy_count = 0
money_count = 0

while buy_count < M:
  tmp_a = sorted_data[0][0]
  tmp_b = sorted_data[0][1]

  if buy_count + tmp_b < M:
    buy_count += tmp_b
    money_count += tmp_b * tmp_a
    sorted_data.pop(0)
  else:
    while buy_count < M:
      buy_count += 1
      money_count += tmp_a
      
print(money_count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
list_c = list(map(int,input().split()))
list_d = []

for i in range(n):
  list_d.append(list(map(int,input().split())))

now = [0]*26

max_happy = 0
index_max = -1

for day in range(1,n+1):
  max_happy = 0
  index_max = -1
  for i in range(n):
    score = list_d[day-1][i] - (day - now[i]) * list_c[i]
    if score > max_happy:
      index_max = i
      max_happy = score
  
  print(index_max+1)
    
    


Fixed submission:
from random import randint

n = int(input())

for i in range(n):
  print(randint(1,26))
Buggy python submission (verdict: Runtime Error):
m,d = map(int(input().split()))
count = 0
for month in range(1,m+1):
  for day in range(1,d):
    if (day%10) >= 2 and (day//10) >= 2:
      if (day%10)*(day//10) == m:
        count += 1
print(count)

Fixed submission:
m,d = map(int,input().split())
count = 0
for month in range(1,m+1):
  for day in range(1,d+1):
    if (day%10) >= 2 and (day//10) >= 2:
      if (day%10)*(day//10) == month:
        #print(month,day)
        count += 1
print(count)