Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03072 (python)

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

ans = 1
for i in range(0, N):
  for j in range(0, i):
    if H[j] > H[i]:
      break
    if  j + 1 == i:
      ans += 1
    
print (ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

ans = 0
for i in range(0, N):
  for j in range(0, i):
    if N[i] < N[j]:
      break
    if  i == j:
      ans += 1
    
print (ans)
Problem p03073 (python)

Fixed submission:
S = input()
wb = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
bw = ["1" if i % 2 == 0 else "0" for i in range(len(S))]

cnt_wb = 0
cnt_bw = 0
for i in range((len(S))):
  if wb[i] != S[i]:
    cnt_wb += 1
  if bw[i] != S[i]:
    cnt_bw += 1
    
print (min(cnt_wb, cnt_bw))

Buggy submission (verdict: Runtime Error):
S = input()
wb = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
bw = ["1" if i % 2 == 0 else "0" for i in range(len(S))]

cnt_wb = 0
cnt_bw = 0
for i in range((len(S))):
  if wb[i] != S[i]:
    cnt_wb += 1
  if bw[i] != S[i]:
    cnt_bw += 1
    
print (min(cnt_eb, cnt_bw))

Buggy submission (verdict: Runtime Error):
S = input()
wb = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
bw = ["1" if i % 2 == 0 else "0" for i in range(len(S))]

cnt_wb = 0
cnt_bw = 0
for i in range((len(S))):
  if w_b[i] != S[i]:
    cnt_wb += 1
  if bw[i] != S[i]:
    cnt_bw += 1
    
print (min(cnt_eb, cnt_bw))
Problem p03075 (python)

Fixed submission:
import sys
 
antennas = [int(input()) for _ in range(5)]
k = int(input())
 
for p in range(5):
  for q in range(p+1,5):
    if antennas[q] - antennas[p] > k:
      print (':(')
      sys.exit()

print ('Yay!')

Buggy submission (verdict: Runtime Error):
import sys
 
antennas = [int(input()) for _ in range(5)]
k = int(input())
 
for p in range(5):
  for q in range(p+1,5):
    if antennas[q] - antennas[p] > k:
      print ':('
      sys.exit()

print 'Yay!'

Buggy submission (verdict: Runtime Error):
import sys

antennas = [int(input()) for _ in range(5)]
k = int(input())

for p in range(5):
  for q in range(p+1,5):
    if antennas[q] - antennas[p] > k:
      print ':('
      sys.exit()

print 'Yay!'
Problem p02792 (python)

Fixed submission:
from collections import defaultdict
n = int(input())

def f(x):
    a1 = int(str(x)[0])
    a2 = x%10
    return (a1, a2)

count = defaultdict(int)
for x in range(1, n+1):
    key = f(x)
    count[key] += 1

ans = 0
for x in range(1, n+1):
    a0, a1 = f(x)
    if a1 != 0:        # !
        key = (a1, a0) # swap
        ans += count[key]

print(ans)

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

def f(x):
    a1 = int(str(x)[0])
    a2 = x%10
    return (a1, a2)

count = {}
for x in range(1, n+1):
    key = f(x)
    if key in count:
        count[key] += 1
    else:
        count[key] = 1

ans = 0
for x in range(1, n+1):
    a0, a1 = f(x)
    if a1 != 0:        # !
        key = (a1, a0) # swap
        ans += count[key]

print(ans)
Problem p03835 (python)

Fixed submission:
def count(k, s):
    answer = 0

    for a in range(s + 1):
        if a > k:
            # aは増える一方なので
            break

        if s - a > 2*k:
            continue

        for b in range(a, s + 1):
            x = a - 0
            y = b - a
            z = s - b

            if y > k:
                break

            if z <= k and x + y + z == s:
                answer += 1

    return answer

k, s = map(int, input().split())
print(count(k, s))

Buggy submission (verdict: Runtime Error):
def count(k, s):
    answer = 0

    for a in range(s + 1):
        if a > k:
            break

        if s - a > 2*k:
            continue

        for b in range(a, s + 1):
            x = a - 0
            y = b - a
            z = s - b

            if y > k:
                break

            if z <= k and x + y + z == s:
                answer += 1

    return answer

if __name__ == '__main__':
    k, s = ' '.split(input())
    k = int(k)
    s = int(s)

    print(count(k, s))
Problem p02829 (python)

Fixed submission:
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(a, b):
    return 1 + 2 + 3 - a - b
    #if a + b + c <= 21: return 'win'
    #else: return 'bust'



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    S = parsed_lines[1][0]
    return n, k, S


if not do_submit:
    a, b, c = input_parse("""
    3 1
    ABC
    """)
    print(sol(a, b, c))

    a, b, c = input_parse("""
    4 3
    CABA
    """)
    print(sol(a, b, c))

else:
    #a, b, c = list(map(int, input().split()))
    # S = input().split()
    a = int(input())
    b = int(input())
    # T = input()
    print(sol(a, b))
    # S = input().strip()
    # print(sol(S))

Buggy submission (verdict: Runtime Error):
#-*- coding: utf-8 -*-
import math

a, b = [int(x.strip()) for x in input().split()]
#print((a * b) // math.gcd(a, b))
print(6)
Problem p02831 (python)

Fixed submission:
#-*- coding: utf-8 -*-


def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
def lcm(x, y):
    return (x * y) // gcd(x, y)

def sol(a, b):
    return (a * b) // gcd(a, b)


a, b = list(map(int, input().split()))
print(sol(a, b))

Buggy submission (verdict: Runtime Error):
import math

a, b = [int(x.strip()) for x in input().split()]
print((a * b) // math.gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def sol(a, b):
    return (a * b) // math.gcd(a, b)


a, b = list(map(int, input().split()))
print(sol(a, b))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys
import math
from datetime import datetime
import re
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def sol(a, b):
    return lcm(a, b)


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    #print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    #S = parsed_lines[0][0]
    return n, k


if not do_submit:
    n, k = input_parse("""
    5
10 4 8 7 3
    """)
    print(sol(n, k))

    n, k = input_parse("""
    100000 5
    """)
    print(sol(n, k))


else:
    #n = int(input())
    a, b = list(map(int, input().split()))
    print(sol(a, b))

    # S = input().strip()
    # print(sol(S))

Buggy submission (verdict: Runtime Error):
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime
import re
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def sol(a, b):
    return lcm(a, b)


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    #print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    #S = parsed_lines[0][0]
    return n, k


if not do_submit:
    n, k = input_parse("""
    5
10 4 8 7 3
    """)
    print(sol(n, k))

    n, k = input_parse("""
    100000 5
    """)
    print(sol(n, k))


else:
    #n = int(input())
    a, b = list(map(int, input().split()))
    print(sol(a, b))

    # S = input().strip()
    # print(sol(S))
Problem p03012 (python)

Fixed submission:
#-*- coding: utf-8
#  -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(n, W):
    # oxoxoxoxoxoxox
    mini = sys.maxsize
    #print(n, W)
    for i in range(len(W)):
        #print(i)
        mini = min(abs(sum(W[0:i]) - sum(W[i:len(W)])), mini)
    #print("end")
    return mini


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    #print(parsed_lines)
    n = int(parsed_lines[0][0])
    W = [int(x) for x in parsed_lines[1]]
    # k = int(parsed_lines[0][1])
    # S = parsed_lines[1][0]
    # return n, k, S
    return n, W


if not do_submit:
    n, W = input_parse("""
    3
    1 2 3
    """)
    print(sol(n, W))

    n, W = input_parse("""
    4
    1 3 1 1
    """)
    print(sol(n, W))

else:
    n = int(input())
    W = list(map(int, input().split()))
    # print(sol(n, k, S))
    #S = input().strip()
    # S = input().strip()
    print(sol(n, W))

Buggy submission (verdict: Runtime Error):
#-*- coding: utf-8
#  -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(n, W):
    # oxoxoxoxoxoxox
    mini = sys.maxsize
    #print(n, W)
    for i in range(len(W)):
        #print(i)
        mini = min(abs(sum(W[0:i]) - sum(W[i:len(W)])), mini)
    #print("end")
    return mini


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    #print(parsed_lines)
    n = int(parsed_lines[0][0])
    W = [int(x) for x in parsed_lines[1]]
    # k = int(parsed_lines[0][1])
    # S = parsed_lines[1][0]
    # return n, k, S
    return n, W


if not do_submit:
    n, W = input_parse("""
    3
    1 2 3
    """)
    print(sol(n, W))

    n, W = input_parse("""
    4
    1 3 1 1
    """)
    print(sol(n, W))

else:
    n = int(input().split())
    W = list(map(int, input().split()))
    # print(sol(n, k, S))
    #S = input().strip()
    # S = input().strip()
    print(sol(n, W))
Problem p03041 (python)

Fixed submission:
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(n, k, S):
    return S[:k-1]+S[k-1].lower()+S[k:]


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    S = parsed_lines[1][0]
    return n, k, S


if not do_submit:
    a, b, c = input_parse("""
    3 1
    ABC
    """)
    print(sol(a, b, c))

    a, b, c = input_parse("""
    4 3
    CABA
    """)
    print(sol(a, b, c))

else:
    n, k = list(map(int, input().split()))
    S = input().split()
    print(sol(n, k, S[0]))

    # S = input().strip()
    # print(sol(S))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(n, k, S):
    return S[:k-1]+S[k-1].lower()+S[k:]


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    S = parsed_lines[1][0]
    return n, k, S


if not do_submit:
    a, b, c = input_parse("""
    3 1
    ABC
    """)
    print(sol(a, b, c))

    a, b, c = input_parse("""
    4 3
    CABA
    """)
    print(sol(a, b, c))

else:
    n, k = list(map(int, input().split()))
    S = input().split()
    print(sol(n, k, S))
    # S = input().strip()
    # print(sol(S))
Problem p02829 (python)

Fixed submission:
A = int(input())
B = int(input())
 
Answer = [1, 2, 3]
 
Answer.remove(A)
Answer.remove(B)
 
print(Answer[0])

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()
Answer = []
 
for i in range(N):
  Answer.append(S[i])
  Answer.append(T[i])
  
print(''.join(Answer))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

Answer = [1, 2, 3]

remove.Answer(A)
remove.Answer(B)

print(Answer[0])
Problem p02836 (python)

Fixed submission:
n = input()
number = len(n)
change = 0
for i in range(number//2):
  if n[i] != n[number - i -1]:
    change += 1
    
print(change)

Buggy submission (verdict: Runtime Error):
n = input()
number = len(n)
change = 0
for i in range(number//2):
  if n[i] != n[number - i]:
    change += 1
    
print(change)
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
key = 0
 
if N%2 == 1:
  key += 1
else:
  for i in range(N//2):
    if S[i] != S[(N//2)+i]:
      key += 1
    
if key >= 1:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
r = input()
print(r**2)
Problem p02860 (python)

Fixed submission:
N = int(input())
S = input()
key = 0
 
if N%2 == 1:
  key += 1
else:
  for i in range(N//2):
    if S[i] != S[(N//2)+i]:
      key += 1
    
if key >= 1:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
key = 0

if N = 1:
  key += 1
else:
  for i in range(N//2):
  if S[i] != S[(N//2)+i]:
    key += 1
    
if key >= 1:
  print('No')
else:
  print('Yes')

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

for i in range(N//2):
  if S[i] != S[-i-1]:
    key += 1
    
if key >= 1:
  print('No')
else:
  print('Yes')
Problem p02880 (python)

Fixed submission:
n = int(input())
ans = 0

for s in range(1,10):
    for t in range(1,10):
        if n == s*t:
            ans += 1
    
if ans == 0:
  print('No')
else:
  print('Yes')

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

for s, t in range(8):
  if n == s*t:
    ans += 1
    
if ans == 0:
  print('No')
else:
  print('Yes')
Problem p02915 (python)

Fixed submission:
i = int(input())
print(i**3)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
 
happy = 0
 
for i in range(N):
  happy += B[A[i]]
  if A[i]+1 == A[i+1]:
    happy += C[i]
 
print(happy)
Problem p03803 (python)

Fixed submission:
A, B = map(int, input().split())
if A == 1:
    A += 13
if B == 1:
    B += 13
win_Alice = A - B
if win_Alice == 0:
    print('Draw')
else:
    print('Alice' if win_Alice > 0 else 'Bob')

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
if A == 1:
    A += 13
if B == 1:
    B += 13
win_Alice = A - B
if win_Alice = 0:
    print('Draw')
else:
    print('Alice' if win_Alice > 0 else 'Bob')
Problem p02831 (python)

Fixed submission:
A,B=map(int,input().split())
C=1
D=A
E=B
if A<=B:
    if B%A==0:
        print(B)
    else:
        for k in range(2,int(B**(1/2)+2)):
            if A%k==0 and B%k==0:
                A=A/k
                B=B/k
                C=int(A*E)
                while True:
                    if A%k==0 and B%k==0:
                        A=A/k
                        B=B/k
                        C=int(A*E)
                    else:
                        break
        if C==1:
            C=int(A*B)
        print(C)
else:
    if A%B==0:
        print(A)
    else:
        for k in range(2,int(A**(1/2)+2)):
            if A%k==0 and B%k==0:
                A=A/k
                B=B/k
                C=int(D*B)
                while True:
                    if A%k==0 and B%k==0:
                        A=A/k
                        B=B/k
                        C=int(D*B)
                    else:
                        break
        if C==1:
            C=int(A*B)
        print(C)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
if A<=B:
    if B%A==0:
        print(B)
    else:
        for k in range(2,int(B**(1/2)+2)):
            if A%k==0 and B%k==0:
                A=A/k
                B=B/k
                C=int(A*B*k)
        print(C)
else:
    if A%B==0:
        print(A)
    else:
        for k in range(2,int(A**(1/2)+2)):
            if A%k==0 and B%k==0:
                A=A/k
                B=B/k
                C=int(A*B*k)
        print(C)
Problem p02833 (python)

Fixed submission:
count=0
k=10
n=int(input())
if n%2==1:
    print(0)
else:
    for i in range(1,100):
        count+=n//(k)
        k*=5
    print(count)

Buggy submission (verdict: Runtime Error):
k=10
n=int(input())
if n%2==1:
    print(0)
else:
    for i in range(1,100):
        count+=n//(k)
        k*=5
    print(count)
Problem p02836 (python)

Fixed submission:
S=input()
n=0
if len(S)%2==0:
    for i in range (0,int((len(S))/2)):
        if S[i]!=S[-i-1]:
            n+=1
else:
    for i in range (0,int(((len(S))+1)/2)):
        if S[i]!=S[-i-1]:
            n+=1
print(n)

Buggy submission (verdict: Runtime Error):
S=input()
n=0
if len(S)%2==0:
    for i in range (0,int(len(S))/2):
        if S[i]!=S[-i-1]:
            n+=1
else:
    for i in range (0,int(((len(S))+1)/2)):
        if S[i]!=S[-i-1]:
            n+=1
print(n)
Problem p02859 (python)

Fixed submission:
r=int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
r=int(input())
print(r＊＊2)

Buggy submission (verdict: Runtime Error):
r=input()
print(int(r＊＊2))
Problem p02862 (python)

Fixed submission:
import math

MOD = 10**9 + 7

# nCk
def comb(n, r):
    r = min(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
  
# nCk mod
def comb_mod(n, r, mod):
  r = min(r, n-r)
  
  g1 = [1, 1] # 元
  g2 = [1, 1] # 逆元
  inverse = [0, 1] # 逆元計算用
  
  for i in range(2, n+1):
    g1.append( (g1[-1] * i) % mod )
    inverse.append( (-inverse[mod % i] * (mod // i)) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

  return g1[n] * g2[r] * g2[n-r] % mod

X, Y = map(int, input().split())
  
if (X+Y)%3!=0:
  print(0)
  quit()

# (+1,+2):n, (+2,+1):m
m = (X*2 - Y) // 3
n = X - m*2

if m < 0 or n < 0:
  print(0)
  quit()

ans = comb_mod(n+m, n, MOD)

print(ans)

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
X, Y = map(int, input().split())
  
if (X+Y)%3!=0:
  print(0)
  quit()
  
if X < Y:
  X, Y = Y, X

sub = X - Y
tan = Y - sub

X = sub + tan//3 + 3
Y = tan//3 + 3
dp = [[0]*X for _ in range(Y)]

dp[1][0] = 1
for i in range(1, Y):
  for j in range(1, X):
    if dp[j][i]:
      dp[i][j] = dp[j][i]
      continue
    dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD

print(dp[Y-1][X-1])

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
X, Y = map(int, input().split())
  
if (X+Y)%3!=0:
  print(0)
  quit()
  
if X < Y:
  X, Y = Y, X

sub = X - Y
tan = Y - sub

X = sub + tan//3 + 3
Y = tan//3 + 3
dp = [[0]*X for _ in range(Y)]

dp[2][1] = 1
for i in range(2, Y):
  for j in range(2, X):
    dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD

print(dp[Y-1][X-1])

Buggy submission (verdict: Runtime Error):
def solve():
  MOD = 10**9 + 7
  X, Y = map(int, input().split())
  
  if (X+Y)%3!=0:
    print(0)
    quit()
  
  if X < Y:
    X, Y = Y, X

  sub = X - Y
  tan = X - sub

  X = sub + tan + 1
  Y = tan + 1
  dp = [[0]*X for _ in range(Y)]

  dp[2][1] = 1
  for i in range(2, Y):
    for j in range(2, X):
      dp[i][j] = dp[i][j-1] + dp[i-1][j]

  dp[i][j] %= MOD

  #print(*dp, sep='\n')
  print(dp[Y-1][X-1])

if __name__ == '__main__':
  solve()
Problem p02916 (python)

Fixed submission:
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

  n = int(input())
  *a, = map(int,input().split())
  *b, = map(int,input().split())
  *c, = map(int,input().split())
  
  ans = sum(b)
  for i in range(1,n):
    if a[i]-a[i-1]==1:
      ans += c[a[i-1]-1]

  print(ans)


if __name__ == '__main__':
  solve()

Buggy submission (verdict: Runtime Error):
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

  n = int(input())
  *a, = map(int,input().split())
  *b, = map(int,input().split())
  *c, = map(int,input().split())
  
  ans = b[a[0]]
  for i in range(1,n):
    ans += b[a[i]]
    if a[i]-a[i-1]==1:
      ans += c[a[i-1]]

  print(ans)


if __name__ == '__main__':
  solve()
Problem p02948 (python)

Fixed submission:
import sys
from heapq import heappush, heappop
from operator import itemgetter

na = lambda: map(int, sys.stdin.readline().split())

n, m = na()
ab = [list(na()) for _ in range(n)]
ab.sort(key=itemgetter(0))

ans = 0
p = 0
h = []
for day in range(1, m+1):
  for i in range(p, len(ab)):
    if ab[i][0] <= day:
      heappush(h, -ab[i][1])
      p += 1
    else:
      break
  if h:
    ans += -heappop(h)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from heapq import heappush, heappop

na = lambda: map(int, sys.stdin.readline().split())

n, m = na()
ab = [list(na()) for _ in range(n)]

ans = 0
h = []
for day in range(1, m+1):
  d = 0
  for i in range(len(ab)):
    if ab[i-d][0] <= day:
      heappush(h, -ab.pop(i-d)[1])
      d += 1
  ans += -heappop(h)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from heapq import heappush, heappop

na = lambda: map(int, sys.stdin.readline().split())

n, m = na()
ab = [list(na()) for _ in range(n)]

ans = 0
h = []
for day in range(1, m+1):
  d = 0
  for i in range(len(ab)):
    if ab[i-d][0] <= day:
      heappush(h, -ab.pop(i-d)[1])
      d += 1
  ans += -heappop(h)

print(ans)
Problem p02790 (python)

Fixed submission:
a,b = map(int, input().split())
if a>b:
    print(str(b)*a)
else:
    print(str(a)*b)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a>b:
  print(str(b)*a)
 else:
  print(str(a)*b)
Problem p03038 (python)

Fixed submission:
n,m = map(int,input().split())
aa = list(map(int, input().split()))
aa.sort()
bc_list = [list(map(int, input().split())) for i in range(m)]
bc_list = sorted(bc_list, key=lambda x:x[1])

p = 0
for bc in bc_list[::-1]:
    for i in range(bc[0]):
        if aa[p] < bc[1]:
            aa[p] = bc[1]
            p += 1
            if p > len(aa) - 1:
                break
        else:
            break
    else:
        continue
    break

print(sum(aa))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
aa = list(map(int, input().split()))
aa.sort()
bc_list = [list(map(int, input().split())) for i in range(m)]
bc_list = sorted(bc_list, key=lambda x:x[1])

p = 0
for bc in bc_list[::-1]:
    for i in range(bc[0]):
        if aa[p] < bc[1]:
            aa[p] = bc[1]
            p += 1
        else:
            break
    else:
        continue
    break

print(sum(aa))
Problem p03127 (python)

Fixed submission:
N = int(input())
Mons = list(map(int, input().split()))
Mons = list(set(Mons))
Mons.sort()

minHP = Mons[0]

if minHP == 1 or len(Mons) == 1:
    print(minHP)
    exit()
    
minSA = minHP

for a,b in zip(Mons[:],Mons[1:]):
    sa = b % a
    if sa and sa < minSA:
        minSA = sa

ans = minSA

while 1:
    hoge = [val % ans for val in Mons if val % ans]

    if hoge:
        if ans == min(hoge):
            break
        else:
            ans = min(hoge)
    else:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
# C Monsters Battle Royale
N = int(input())
Monsters = list(map(int, input().split()))
Monsters.sort()

ans = Monsters[0]
for i in range(len(Monsters) - 1):
    tempList = [val % Monsters[i] for val in Monsters[i+1:] if not val % Monsters[i] == 0]
    if tempList:
        if min(tempList) < ans:
            ans = a
        
print(ans)