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

Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap



@mt
def slv(H, W, D, A, Q, LR):
    S = [0] * (H * W + 1)
    A_ = {}
    for i, r in enumerate(A):
        for j, c in enumerate(r):
            A_[c] = (i, j)
    
    for i in range(D+1, H*W+1):
        S[i] = S[i-D] + abs(A_[i][0]-A_[i-D][0]) + abs(A_[i][1]-A_[i-D][1])
    
    for l, r in LR:
        # print(H, W, r, l)
        print(S[r]-S[l])
    



def main():
    H, W, D = read_int_n()
    A = [read_int_n() for _ in range(H)]
    Q = read_int()
    LR = [read_int_n() for _ in range(Q)]
    slv(H, W, D, A, Q, LR)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap



@mt
def slv(H, W, D, A, Q, LR):
    A_ = {}
    for i, r in enumerate(A):
        for j, c in enumerate(r):
            A_[c] = (i, j)
    
    @lru_cache(maxsize=None)
    def f(l, r):
        if l == r:
            return 0
        ans = 0
        i, j = A_[l]
        x, y = A_[l+D]
        l += D
        ans += abs(x-i)
        ans += abs(y-j)
        ans += f(l, r)
        return ans
    
    for l, r in LR:
        print(f(l, r))
    



def main():
    H, W, D = read_int_n()
    A = [read_int_n() for _ in range(H)]
    Q = read_int()
    LR = [read_int_n() for _ in range(Q)]
    slv(H, W, D, A, Q, LR)


if __name__ == '__main__':
    main()
Problem p03803 (python)

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

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

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

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


def f(i, j):
  for k in range(M):
    for l in range(M):
      if A[i+k][j+l] != B[k][l]:
        return False
  return True

def slv():
  for i in range(N-M+1):
    for j in range(N-M+1):
      if f(i, j):
        return 'Yes'
  return 'No'
print(slv())

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

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


def f(i, j):
  for k in range(i, i+M):
    for l in range(j, j+M):
      if A[i+k][j+l] != B[k][l]:
        return False
  return True

def slv():
  for i in range(N-M+1):
    for j in range(N-M+1):
      if f(i, j):
        return 'Yes'
  return 'No'
print(slv())
Problem p03805 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, AB):
    g = defaultdict(set)

    for a, b in AB:
        g[a].add(b)
        g[b].add(a)

    ans = 0
    for ns in permutations(range(2, N+1), N-1):
        ns = list(ns)
        ns.insert(0, 1)
        for i in range(N-1):
            if ns[i+1] not in g[ns[i]]:
                break
        else:
            ans += 1
    return ans


def main():
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    print(slv(N, M, AB))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, AB):
    g = defaultdict(set)

    for a, b in AB:
        g[a].add(b)
        g[b].add(a)

    ans = 0
    for ns in permutations(range(2, N+1), N-1):
        ns = list(ns)
        ns.insert(0, 1)
        for i in range(N-1):
            if ns[i+1] not in g[ns[i]]:
                break
        else:
            ans += 1
    return ans


def main():
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(N)]
    print(slv(N, M, AB))


if __name__ == '__main__':
    main()
Problem p02729 (python)

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

ans = (N * (N - 1) + M * (M - 1)) / 2

print(int(ans))

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

input_1 = input()
input_2 = input_1.split()

for k in range(N):
    A = map(int, input_2)

    def equal(num):
        return num / 1
    A = [equal(x) for x in A]

    ans = 0

    A.remove(A[k])

    for l in range(N - 1):
        for m in range(N - 1):
            if A[l] == A[m]:
                ans += 1
        
        ans -= 1

    ans = ans / 2

    print(int(ans))

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

input_1 = input()
input_2 = input_1.split()

A = map(int, input_2)

def equal(num):
    return num
A = [equal(x) for x in A]

ans = 0

for l in range(N):
    ans += A.count(A[l]) - 1

ans = ans / 2
re = ans

for k in range(N):
    ans -= A.count(A[k]) - 1

    print(int(ans))

    ans = re
Problem p02753 (python)

Fixed submission:
s = input()
if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
s = sys.stdin.readline().rstrip()
q = int(sys.stdin.readline().rstrip())

for _ in range(q):
    t = sys.stdin.readline().rstrip()
    if t == '1':
        s = s[::-1]
    else:
        t, f, c = t.split()
        if f == '1':
            s = c + s
        else:
            s = s + c

print(s)
Problem p02793 (python)

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

lcm = 1
from fractions import gcd
for i in range(n):
    lcm *= a[i] // gcd(a[i], lcm)

ans = 0
for i in a:
    ans += lcm // i

print(ans % (10**9+7))

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

lcm = 1
from math import gcd
for i in range(n):
    lcm *= a[i] // gcd(a[i], lcm)

ans = 0
for i in a:
    ans += lcm // i

print(ans % (10**9+7))
Problem p03253 (python)

Fixed submission:
class Factorials:
    def __init__(self, n=10**6, mod=10**9 + 7):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        self.fac = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            self.fac.append(num)

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        self.rec = [1 for i in range(n+1)]
        self.rec[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            self.rec[i] = num

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod
    
    # perm(n, r) ≡ nPr
    def perm(self, n, r):
        return self.fac[n] * self.rec[n-r] % self.mod

    # fact(n) ≡ n!
    def fact(self, n):
        return self.fac[n]

def main():
    mod = 10**9 + 7
    n, m = map(int, input().split())

    if m == 1:
        print(1)
        exit()

    factors = []
    for i in range(2, m+1):
        if i * i > m:
            if m > 1:
                factors.append(1)
            break

        if m % i == 0:
            num = 1
            m //= i
            while m % i == 0:
                num += 1
                m //= i
            factors.append(num)

    fct = Factorials(n=n+max(factors), mod=mod)

    ans = 1
    for i in factors:
        ans *= fct.comb(n+i-1, i)
        ans %= mod

    print(ans)

main()

Buggy submission (verdict: Runtime Error):
class Factorials:
    def __init__(self, n=10**6, mod=10**9 + 7):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        self.fac = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            self.fac.append(num)

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        self.rec = [1 for i in range(n+1)]
        self.rec[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            self.rec[i] = num

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod
    
    # perm(n, r) ≡ nPr
    def perm(self, n, r):
        return self.fac[n] * self.rec[n-r] % self.mod

    # fact(n) ≡ n!
    def fact(self, n):
        return self.fac[n]

def main():
    mod = 10**9 + 7
    n, m = map(int, input().split())

    factors = []
    for i in range(2, m+1):
        if i * i > m:
            if m > 1:
                factors.append(1)
            break

        if m % i == 0:
            num = 1
            m //= i
            while m % i == 0:
                num += 1
                m //= i
            factors.append(num)

    fct = Factorials(n=n+max(factors), mod=mod)

    ans = 1
    for i in factors:
        ans *= fct.comb(n+i-1, i)
        ans %= mod

    print(ans)

main()
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split())
ans = 0
amari = N % (A + B)
o = N // (A + B)
if amari > A:
    amari = A

print(amari + A * o)

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

AB = "b" * A + "r" * B

o = N // len(AB) + 1
l = AB * o

print(l[:N].count("b"))
Problem p02759 (python)

Fixed submission:
N = int(input())
print(int(N / 2 if not N % 2 else N // 2 + 1))

Buggy submission (verdict: Runtime Error):
let n = read_int ()

let () = n / 2 + (n mod 2) |> print_int; print_string "\n"
Problem p02766 (python)

Fixed submission:
import numpy as np
n, r = map(int, input().split())
print(len(str(np.base_repr(n,r))))

Buggy submission (verdict: Runtime Error):
n, k = input().split()
print(len(str(int(n, int(k)))))
Problem p02773 (python)

Fixed submission:
N = int(input())

value_dict = {}

for x in range(N):
    value = input()
    if value not in value_dict.keys():
        value_dict[value] = 1
        continue
    value_dict[value] += 1

max_count = max(value_dict.values())
max_values = [k for k, v in value_dict.items() if v == max_count]
max_values.sort()


print("\n".join(max_values))

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
S_list = [input() for i in range(N)]
c = collections.Counter(S_list)
l = {}
m = c[0][0]
for x, y in zip(*c):
  if x in l.keys():
    l[x] = [y]
  else:
    l[x].append(y)

  
for y in sorted(l[m]):
  print(y)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
S_list = [input() for i in range(N)]
c = collections.Counter(S_list)
l = {}
for x, y in zip(*c):
  if x in l.keys():
    l[x] = [y]
  else:
    l[x].append(y)

for x in sorted(l.keys(), reverse=True):
  for y in sorted(l[x]):
    print(y)
Problem p02693 (python)

Fixed submission:
K = int(input())
a,b = map(int, input().split())
kekka = ("NG")
for i in range(a,b+1):
    if i % K == 0:
        kekka = ("OK")
print(kekka)

Buggy submission (verdict: Runtime Error):
K = int(input())
a,b = map(int, input().split())
if a < K and K < B:
    print("OK")
elif (b - a) > K:
    print("OK")
elif (b-a)== 0 and K == 1:
    print("OK")
else :
    print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
a,b = map(int, input().split())
if a < K and K < B:
    print("OK")
elif (b - a)/K >= 1:
    print("OK")
elif (b-a)== 0 and K == 1:
    print("OK")
else :
    print("NG")
Problem p02723 (python)

Fixed submission:
s = input()
print("Yes" if s[2] == s[3] and s[4] == s[5] else "No")

Buggy submission (verdict: Runtime Error):
s = input()
print("Yes" if s[2] == s[3] and s[4] == s[5] else "No)
Problem p02777 (python)

Fixed submission:
s,t = map(str, input().split())
a,b = map(int, input().split())
u = input()
if u == s:
    print(a-1, b)
else :
    print(a, b-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b), else "NO")
Problem p02779 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b), else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if len(a) == len(b), else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
res = "YES"
for i in range(n):
  if i.count(a[i])>=2:
    res="NO"
    break
print(res)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
res = "YES"
for i in range(n):
  if i.count(a[i])>=2:
    res="NO"
print(res)
Problem p02829 (python)

Fixed submission:
a =sorted( [int(input()) for i in range(2)])
print("1" if a == [2,3] else "2" if a == [1,3] else "3")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
ls = [1,2,3]
del ls[a-1]
del ls[b-1]
print(max(ls))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
ls = [1,2,3]
del ls[a-1]
del ls[b-1]
print(ls)
Problem p02881 (python)

Fixed submission:
n=int(input())
a=1
ans=n
while a*a<=n:
    if n%a==0:
        ans=min(a+n//a-2,ans)
    a+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
def eratos(n):
   prime_list =set ()
   num_list=set()
   for i in range(2, int(n**0.5)+1):
       if i not in num_list:
           prime_list.add(i)
           for j in range(i*i, n+1, i):
               num_list.add(j)
   return(prime_list)
print(s)
x=int(n**0.5)
while 1:
    if x in s and n%x==0:
        break
    x-=1
print(x+(n//x)-2)
Problem p03041 (python)

Fixed submission:
n,k = map(int, input().split())
s = input()
ans = [s[:k-1],s[k-1].lower(),s[k:]]
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = input()
ans = [s[:k],s[k].lower(),s[k+1:]]
print(''.join(ans))
Problem p03075 (python)

Fixed submission:
a,b,c,d,e,k= int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
print("Yay!" if e-a<= k else ":(")

Buggy submission (verdict: Runtime Error):
a,b,c,d,e = map(int,input().split())
k = int(input())
print("Yay!" if e-a<= k else ":(")

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]
k = int(input())
print("Yay!" if e-a<= k else ":(")

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]
k = int(input())
print("Yey!" if e-a<= k else ":(")
Problem p02695 (python)

Fixed submission:
from itertools import combinations_with_replacement as c
n, m, q = [int(i) for i in input().split()]
abc = [[int(i) for i in input().split()] for _ in range(q)]
aa = list(range(1,m+1))
ans = 0
for bb in c(aa, n):
    cc = 0
    for a, b, c, d in abc:
        if bb[b-1] - bb[a-1] == c:
            cc += d
    ans = max(ans, cc)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import combinations_with_replacement as c
n, m, q = [int(i) for i in input().split()]
abc = [[int(i) for i in input().split()] for _ in range(q)]
aa = list(range(1,m+1))
ans = 0
for bb in c(aa,m):
    cc = 0
    for a, b, c, d in abc:
        if bb[b-1] - bb[a-1] == c:
            cc += d
    ans = max(ans, cc)
print(ans)
Problem p02771 (python)

Fixed submission:
if len(set([int(i) for i in input().split()])) == 2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=1<<1000000000
b = 1<<a
print(b)
Problem p02781 (python)

Fixed submission:
n = input()
k = len(n) - int(input())
if k < 0:
    print(0)
    exit()

dp = [[[0] * 2 for _ in range(k + 1)] for _ in range(len(n)+1)]

dp[0][0][1] = 1

for i in range(len(n)):
    if n[i] == "0":
        for j in range(k):
            dp[i + 1][j + 1][0] = dp[i][j][0]
            dp[i + 1][j + 1][1] = dp[i][j][1]
        for j in range(k+1):
            dp[i + 1][j][0] += dp[i][j][0] * 9
    else:
        for j in range(k):
            dp[i + 1][j + 1][0] = dp[i][j][0] + dp[i][j][1]
        for j in range(k+1):
            dp[i + 1][j][0] += dp[i][j][0] * 9+dp[i][j][1] * (int(n[i])-1)
            dp[i + 1][j][1] += dp[i][j][1]
print(sum(dp[-1][-1]))

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

dp = [[[0] * 2 for _ in range(k + 1)] for _ in range(len(n)+1)]

dp[0][0][1] = 1

for i in range(len(n)):
    if n[i] == "0":
        for j in range(k):
            dp[i + 1][j + 1][0] = dp[i][j][0]
            dp[i + 1][j + 1][1] = dp[i][j][1]
        for j in range(k+1):
            dp[i + 1][j][0] += dp[i][j][0] * 9
    else:
        for j in range(k):
            dp[i + 1][j + 1][0] = dp[i][j][0] + dp[i][j][1]
        for j in range(k+1):
            dp[i + 1][j][0] += dp[i][j][0] * 9+dp[i][j][1] * (int(n[i])-1)
            dp[i + 1][j][1] += dp[i][j][1]
print(sum(dp[-1][-1]))

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

dp = [[[0] * 2 for _ in range(k + 1)] for _ in range(len(n)+1)]

dp[0][0][1] = 1

for i in range(len(n)):
    if n[i] == "0":
        for j in range(k):
            dp[i + 1][j + 1][0] = dp[i][j][0]
            dp[i + 1][j + 1][1] = dp[i][j][1]
        for j in range(k+1):
            dp[i + 1][j][0] += dp[i][j][0] * 9
    else:
        for j in range(k):
            dp[i + 1][j + 1][0] = dp[i][j][0] + dp[i][j][1]
        for j in range(k+1):
            dp[i + 1][j][0] += dp[i][j][0] * 9+dp[i][j][1] * (int(n[i])-1)
            dp[i + 1][j][1] += dp[i][j][1]
print(sum(dp[-1][-1]))
Problem p02793 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
p = 10 ** 9 + 7

def pr(x):
    a=[]
    i=2
    while True:
        if x % i == 0:
            j=0
            while x % i == 0:
                x //= i
                j += 1
            a.append((i, j))
        if i * i > x:
            break
        i += 1
    if x != 1:
        a.append((x,1))
    return a
c = {}
for i in a:
    d = pr(i)
    for j in d:
        if j[0] in c:
            c[j[0]] = max(c[j[0]], j[1])
        else:
            c[j[0]] = j[1]

b = 1
for i in c:
    b *= pow(i, c[i], p)
    b %= p
ans = 0
for i in a:
    ans += b * pow(i, p - 2, p)
    ans %= p
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n = int(input())
a = [int(i) for i in input().split()]

b = 1
for i in a:
    b = b * i // gcd(b, i)

ans = 0
for i in a:
    ans += b // i
    ans %= 10**9+7

print(ans
Problem p02863 (python)

Fixed submission:
n, t = [int(i) for i in input().split()]
ab = []
for _ in range(n):
    ab.append([int(i) for i in input().split()])
ab.sort(key=lambda x:x[0])
aa = t+max([i[0] for i in ab])+1
c = [0] * aa
for i in ab:
    d = c[:]
    for j in range(t):
        k = d[j]
        l = i[0] + j
        if l >= aa:
            continue
        c[l] = max(c[l], d[j] + i[1])
print(max(c))

Buggy submission (verdict: Runtime Error):
n, t = [int(i) for i in input().split()]
ab = []
for _ in range(n):
    ab.append([int(i) for i in input().split()])
sb.sort(key=lambda x:x[0])
aa = t+max([i[0] for i in ab])+1
c = [0] * aa
for i in ab:
    d = c[:]
    for j in range(t):
        k = d[j]
        l = i[0] + j
        if l >= aa:
            continue
        c[l] = max(c[l], d[j] + i[1])
print(max(c))
Problem p02933 (python)

Fixed submission:
a=int(input())
b=input()
if int(a)>=3200:
  print(b)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
a,b=input().split()
if int(a)>=3200:
  print(b)
else:
  print('red')
Problem p02948 (python)

Fixed submission:
import heapq
n, m = [int(i) for i in input().split()]
ab = []
for _ in range(n):
    a, b = [int(i) for i in input().split()]
    ab.append([a, -b])
ab.sort()
j = 0
ans=0
h = []
for i in range(1, m + 1):
    while j<n and ab[j][0] <= i:
        heapq.heappush(h, ab[j][1])
        j += 1
    if h:
        ans += heapq.heappop(h)
print(-ans)

Buggy submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
c={}
for _ in range(n):
  a,b=[int(i) for i in input().split()]
  if a in c:
    c[a].append(b)
  else:
    c[a]=[b]
k=0
l=[]
for i in range(m+1):
  if i in c:
    j=sorted(c[i],reverse=True)
    if l:
      if max(j)>l[0]:
        k+=max(j)
        if len(j)>1:
          l=l+j[1:]
      else:
        k+=max(l)
        del l.index(max(l))
        l=l+j
    else:
      k+=j[0]
      l=j[1:]
  else:
    if l:
      k+=l[0]
      del l.index(max(l))
  if len(l)>m:
    l=l[:m]
print(k)