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

Fixed submission:
s = input()
t = input()
 
count = 0
 
for i in range(len(s)):
  if s[i] != t[i]:
    count = count + 1
    
print(count)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

count = 0

for i in ronge(len(s)):
  if s[i] != t[i]:
    count = count + 1
    
print(count)
Problem p02729 (python)

Fixed submission:
import math
import sys

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

if n == 1 and m == 1:
  print('0')
  sys.exit()
  
if n <= 1:
  print(comb(m, 2))
  sys.exit()
  
if m <=1:
  print(comb(n, 2))
  sys.exit()

print(comb(n, 2) + comb(m, 2))

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

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

if n <= 1:
  print(comb(m, 2))
  sys.exit()
  
if m <=1:
  print(comb(n, 2))
  sys.exit()

if n == 1 and m == 1:
  print('0')
  sys.exit()

print(comb(n, 2) + comb(m, 2))

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

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

if n <= 1
  print(comb(m, 2))
  sys.exit()
  
if m <=1
  print(comb(n, 2))
  sys.exit()

if n == 1 and m == 1:
  print('0')
  sys.exit()

print(comb(n, 2) + comb(m, 2))

Buggy submission (verdict: Runtime Error):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

if n < 1:
  print(comb(m, 2))
elif m < 1:
  print(comb(n, 2))
else:
  print(comb(n, 2) + comb(m, 2))

Buggy submission (verdict: Runtime Error):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

print(comb(n, 2) + comb(m, 2))
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
 
N, A, B = map(int,input().split())
 
ans = 0
 
if N < A:
  print(N)
  sys.exit()
 
if N < A+B:
  print(A)
  sys.exit()

if N%(A+B) <A:
  print((A*(N//(A+B))) + (N%(A+B)))
else:
  print((A*(N//(A+B))) + A)
Problem p02723 (python)

Fixed submission:
a=list(input())
if a[2] == a[3] and a[4] == a[5]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
x=int(input())
cnt = 0
q = x // 500
cnt += (q * 1000)
w = x % 500
e = w // 5
cnt += (e * 5)
print(cnt)
Problem p02771 (python)

Fixed submission:
a,b,c = map(int,input().split())
if a == b:
  if a != c and b !=c:
    print('Yes')
  else:
    print('No')
elif a == c:
  if a != b and c != b:
    print('Yes')
  else:
    print('No')
elif b == c:
  if b != a and c != a:
    print('Yes')
  else:
    print('No')
elif a == b == c:
  print('No')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c = map(input().split())
if a == b or a == c:
    if b != c:
        print('Yes')
    else:
        print('No')
elif b == c:
    print('Yes')
Problem p02831 (python)

Fixed submission:
import math
from fractions import gcd

A, B = map(int, input().split())

print((A * B)//gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math
from fractions import gcd

A, B = map(int, input().split())

print((A * B)//math.gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())

print((A * B)//math.gcd(A, B))
Problem p02916 (python)

Fixed submission:
N = int(input())

A_list = list(input().split())
A_list_int = [int(s) for s in A_list]

B_list = list(input().split())
B_list_int = [int(s) for s in B_list]

C_list = list(input().split())
C_list_int = [int(s) for s in C_list]

Answer = []

for i in range(0, N):
  Answer.append(B_list_int[A_list_int[i] - 1])
  if i != N and i != 0:
      if A_list_int[i - 1] == A_list_int[i] - 1:
          Answer.append(C_list_int[A_list_int[i] - 2])

print(sum(Answer))

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

A_list = list(input().split())
A_list_int = [int(s) for s in A_list]

B_list = list(input().split())
B_list_int = [int(s) for s in B_list]

C_list = list(input().split())
C_list_int = [int(s) for s in C_list]

Answer = []

for i in range(0, N):
  Answer.append(B_list_int[A_list_int[i] - 1])
  if i != N and i != 0:
      if A_list_int[i - 1] == A_list_int[i] - 1:
          Answer.append(C_list_int[i])

print(sum(Answer))
Problem p02951 (python)

Fixed submission:
A, B, C = [int(x) for x in input().split()]

if A - B >= C:
  print(0)
elif C > A - B:
  print(C - (A - B))

Buggy submission (verdict: Runtime Error):
A, B, C = [int(x) for x in input()]

if A - B > C:
  print(C)
elif C > A - B:
  print(A - B)
Problem p02688 (python)

Fixed submission:
# coding: utf-8
import numpy as np

hairetsu = input().split(' ')
sunuke = int(hairetsu[0])
okashi = int(hairetsu[1])
books = [[0]*sunuke]*okashi

for i in range(0, okashi):
  kaisu = int(input())
  whohas = list(map(int, input().split(' ')))
  for j in range(0, kaisu):
    k = int(whohas[j])-1
    books[i][k] = 1


result = np.sum(books,axis=0)
a = np.count_nonzero(result)
print(sunuke - a)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import numpy as np

hairetsu = input().split(' ')
sunuke = int(hairetsu[0])
okashi = int(hairetsu[1])
books = [[0]*sunuke]*okashi

for i in range(0, okashi):
  kaisu = int(input())
  whohas = list(map(int, input().split(' ')))
  for j in range(0, kaisu):
    k = int(whohas[j])-1
    books[i][k] = 1


result = np.sum(books,axis=0)
a = np.count_nonzero(result)
print(sunuke - a)
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
k,n = map(int,input().split())
A = list(map(int,input().split()))
A.append(k)
A.sort()
m = max(y-x for x,y in zip(A,A[1:]))
ans = k-m
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
k,n = map(int,input().split())
A = list(map(int,input().split()))
A.append(k)
A.sort()
dist = np.diff(A)
ans = k-max(dist)
print(ans)
Problem p02754 (python)

Fixed submission:
n,a,b = map(int,input().split())
ans = n // (a+b) * a
rem = n % (a+b)
ans += min(rem,a)
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
l = ('b'*a+'r'*b)*10**100
print(l[:n].count('b'))

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
l = ('b'*a+'r'*b)*100
print(l[:n].count('b'))
Problem p02829 (python)

Fixed submission:
A = input()
B = input()
ans = '123'
ans = ans.replace(A,'').replace(B,'')
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
a,b = map(int,input().split())
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)
print(lcm(a,b))
Problem p02831 (python)

Fixed submission:
import fractions
a,b = map(int,input().split())
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)
print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
def lcm(x,y):
    return (x*y)//math.gcd(x,y)
print(lcm(a,b))
Problem p02723 (python)

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

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

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
count = 0
for i in A:
  count += 1
  if count != N:
    B[i]=A[i+1]-A[i]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
count = 0
for i in A:
  count += 1
  if count < N:
    B[i]=A[i+1]-A[i]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
for i in range[0, N-1]:
  if i < N-1:
    B[i]=A[i+1]-A[i]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
for i in A if i < N-1:
  B[i]=A[i+1]-A[i]

B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
for i in A:
  B[i]=A[i+1]-A[i]
  
B[N-1]=A[0]+K-A[N-1]

print(K-max(B))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [A[i+1]-A[i] for i in A if i < N]
B[N-1]=A[0]+K-A[N-1]

print(K-max(B))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = []
while all(a< N-1 for a in A):
  B.append(A[a+1]-A[a])

B.append(A[1]+K-A[a])

print(K-max(B))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = []
for a in A:
  if a < N:
    B.append(A[a+1]-A[a])
  else:
    B.append(A[1]+K-A[a])

print(K-max(B))
Problem p02881 (python)

Fixed submission:
import numpy as np

N = int(input())

U = 10**6 + 100
x = np.arange(1,U, dtype=np.int64)
div = x[N%x==0]
ans = (div + N//div).min() - 2
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
A = prime_factorize(N)

n = len(A)
ans = []
for i in range(1,2**n-1):
    a = [1]
    b = [1]
    for j in range(n):
        if (i >> j) & 1:
            a.append(A[j])
        else:
            b.append(A[j])
    ap, bp = np.prod(a), np.prod(b)
    ans.append(bp+ap)
print(min(ans)-2)
Problem p02970 (python)

Fixed submission:
N,D = map(int, input().split())
count = 0
i = 0
while i < N:
  i += 2*D+1
  count +=1
print(count)

Buggy submission (verdict: Runtime Error):
N,D = map(int, input().split())
d = 2D+1
print(N//d+1)

Buggy submission (verdict: Runtime Error):
N,D = map(int, input().split())
print(N//(2D+1)+1)
Problem p02622 (python)

Fixed submission:
s = str(input())
t = str(input())
c = 0
for i in range(len(s)):
  if(s[i] != t[i]):
    c+=1
 
print(c)

Buggy submission (verdict: Runtime Error):
s = str(input())
t = str(input())
c = 0
for i in len(s):
  if(s[i] != t[i]):
    c+=1

print(c)
Problem p02624 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
    k = n//i
    m = k*(k+1)//2
    ans += m*i
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
n = int(input())
ans = 0
for i in range(1,n+1):
    k = n//i
    m = k*(k+1)//2
    ans += m*i
print(ans)
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().rstrip().split())
if A == 0:
    ret = 0
elif A + B == 0:
    ret = 0
else:
    tmp1 = int(N / (A + B)) * A
    tmp2 = 0
    if A > N % (A + B):
        tmp2 = N % (A + B)
    else:
        tmp2 = A
    ret = tmp1 + tmp2
print(ret)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().rstrip().split())
if A + B == 0:
    ret = 0
else:
    ret = int(N / (A + B)) * A + ('b'*A + 'r'*B)[:(N % (A + B))].count('b')
print(ret)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().rstrip().split())
if A + B == 0:
    ret = 0
else:
    ret = (N // (A + B) * A + ('b'*A + 'r'*B)[:(N % (A + B))].count('b'))
print(ret)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().rstrip().split())
if A == B == 0:
    print(0)
else:
    print((N//(A+B) * A + ('b'*A+'r'*B)[:(N % (A+B))].count('b')))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().rstrip().split())
print((N//(A+B) * A + ('b'*A+'r'*B)[:(N % (A+B))].count('b')))
Problem p02829 (python)

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

Buggy submission (verdict: Runtime Error):
l = [1, 2, 3]
A = int(stdin.readline().rstrip())
B = int(stdin.readline().rstrip())
l.remove(A)
l.remove(B)
print(l[0])
Problem p02682 (python)

Fixed submission:
A,B,C,K=map(int,input().split())
ans=0
if A>=K:
  ans=K
elif A<K and K<=A+B:
  ans=A
else :
  ans=A-(K-A-B)
print(ans)

Buggy submission (verdict: Runtime Error):
,B,C,K=map(int,input().split())
ans=0
if A>=K:
  ans=K
elif A<K and K<=A+B:
  ans=A
else :
  ans=A-(K-A-B)
print(ans)
Problem p02725 (python)

Fixed submission:
K,N=map(int,input().split())
A=list(map(int,input().split()))
sa=[]
sa.append(int(K-A[-1]+A[0]))
for i in range(1,N):
  tmp=A[i]-A[i-1]
  sa.append(tmp)
ans=K-max(sa)
print(ans)

Buggy submission (verdict: Runtime Error):
K,N=map(int,input().split())
A=list(map(int,input().split()))
x=[]
y=[]
for i in A:
  if i>10:
    a=20-i
    y.append(a)
  else:
    x.append(i)
if len(A)==1:
  if A[0]>=10:
    print(20-A[0])
  else:
    print(A[0])
else:
  ans=max(x)+max(y)
  print(ans)
Problem p02773 (python)

Fixed submission:
import collections
N=int(input())
S=list(input() for i in range(N))
S=collections.Counter(S)
S=S.most_common()
if len(S)==1:
  print(S[0][0])
elif S[0][1]>S[1][1]:
  print(S[0][0])
else:
  s=[i for i in S if i[1]==S[0][1]]
  s=dict(s)
  s=list(s.keys())
  s=sorted(s)
  for i in s:
    print(i)

Buggy submission (verdict: Runtime Error):
import collections
N=int(input())
S=list(input() for i in range(N))
S=collections.Counter(S)
S=S.most_common()
if S[0][1]>S[1][1]:
  print(S[0][0])
else:
  s=[i for i in S if i[1]==S[0][1]]
  s=dict(s)
  s=list(s.keys())
  s=sorted(s)
  for i in s:
    print(i)
Problem p02735 (python)

Fixed submission:
H, W = map(int, input().split())
grid = [list(input().strip()) for _ in range(H)]

ans = [[0] * W for _ in range(H)]

if grid[0][0] == "#":
    ans[0][0] = 1

for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            continue

        r = H*W
        d = H*W
        if j > 0 and grid[i][j] != grid[i][j-1] and grid[i][j-1] == ".":
            r = 1 + ans[i][j-1]
        elif j > 0:
            r = ans[i][j-1]

        if i > 0 and grid[i][j] != grid[i-1][j] and grid[i-1][j] == ".":
            d = 1 + ans[i-1][j]
        elif i > 0:
            d = ans[i-1][j]
        ans[i][j] = min(r, d)

print(ans[H-1][W-1])

Buggy submission (verdict: Runtime Error):
def flip_sq(sy, sx):
    gy = sy
    gx = sx
    while True:
        if sx == W - 1:
            if tiles[sy+1][sx] == "#":
                sy += 1
            else:
                break
        elif tiles[sy][sx+1] == "#":
            sx += 1
            if sy == H - 1:
                break
            if tiles[sy+1][sx] == "#":
                sy += 1
        else:
            break
    for y in range(gy, sy+1):
        for x in range(gx, sx+1):
            tiles[y][x] = flip[tiles[y][x]]

    print(tiles)

H, W = [int(i) for i in input().strip().split(" ")]
tiles = []
for i in range(H):
    tiles.append([i for i in input().strip()])

tile = {"#":1, ".":0}
flip = {"#":".", ".":"#"}
count = []
for i in range(H):
    count.append([])
    for j in range(W):
        count[i].append(0)

count[0][0] = tile[tiles[0][0]]
if tile[tiles[0][0]]:
    flip_sq(0, 0)

for y in range(H):
    for x in range(W):
        if y == 0:
            if x == 0:
                continue
            count[y][x] = count[y][x-1] + tile[tiles[y][x]]
        else:
            if x == 0:
                count[y][x] = count[y-1][x] + tile[tiles[y][x]]
            else:
                count[y][x] = min(count[y-1][x], count[y][x-1]) + tile[tiles[y][x]]
        if tile[tiles[y][x]]:
            flip_sq(y, x)

print(count[H-1][W-1])
Problem p02763 (python)

Fixed submission:
class SegTree:
    def __init__(self, N, S):
        self.N = 2 ** ((N-1).bit_length())
        self.tree = [0 for i in range(self.N * 2 - 1)]
        for i in range(len(S)):
            self.tree[self.N - 1 + i] = 1 << (ord(S[i]) - ord("a"))

        for i in range(self.N - 2, -1, -1):
            self.tree[i] = self.tree[i*2 + 1] | self.tree[i*2 + 2]

    def update(self, index, char):
        i = self.N - 1 + index
        # アルファベットがある = bitが立っている
        self.tree[i] = 1 << (ord(char) - ord("a"))
        while i > 0:
            i = (i-1) // 2
            self.tree[i] = self.tree[i*2 + 1] | self.tree[i*2 + 2]

    def get(self, a, b):
        return self.query(a, b, 0, 0, self.N)

    # k : ノードの番号
    # l : ノードkの受け持つ区間
    # r : ノードkの受け持つ区間
    def query(self, a, b, k, l, r):
        if r <= a or b <= l: # 区間外
            return 0
        elif a <= l and r <= b: # 受け持ち区間は完全に含まれている
            return self.tree[k]
        else: # 一部含まれてる
            left = self.query(a, b, 2 * k + 1, l, (l+r)//2)
            right = self.query(a, b, 2 * k + 2, (l+r)//2, r)
            return left | right

def solve():
    N = int(input())
    S = list(input().strip())
    tree = SegTree(N, S)

    Q = int(input())
    for _ in range(Q):
        t_q, in_1, in_2 = input().split()
        if t_q == "1":
            i_q = int(in_1)
            c_q = in_2
            tree.update(i_q-1, c_q)
        else:
            l_q = int(in_1)
            r_q = int(in_2)
            print(bin(tree.get(l_q-1, r_q)).count("1"))

solve()

Buggy submission (verdict: Runtime Error):
class SegTree:
    def __init__(self, N, S):
        self.N = 2 ** ((N-1).bit_length())
        self.tree = [0 for i in range(self.N * 2 - 1)]
        for i in range(len(S)):
            self.tree[self.N - 1 + i] = 1 << (ord(S[i] - ord("a")))

        for i in range(self.N - 2, -1, -1):
            self.tree[i] = self.tree[i*2 + 1] | self.tree[i*2 + 2]

    def update(self, index, char):
        i = self.N - 1 + index
        # アルファベットがある = bitが立っている
        self.tree[i] = 1 << (ord(char) - ord("a"))
        while i > 0:
            i = (i-1) // 2
            self.tree[i] = self.tree[i*2 + 1] | self.tree[i*2 + 2]

    def get(self, a, b):
        return self.query(a, b, 0, 0, self.N)

    # k : ノードの番号
    # l : ノードkの受け持つ区間
    # r : ノードkの受け持つ区間
    def query(self, a, b, k, l, r):
        if r <= a or b <= l: # 区間外
            return 0
        elif a <= l and r <= b: # 受け持ち区間は完全に含まれている
            return self.tree[k]
        else: # 一部含まれてる
            left = self.query(a, b, 2 * k + 1, l, (l+r)//2)
            right = self.query(a, b, 2 * k + 2, (l+r)//2, r)
            return left | right

def solve():
    N = int(input())
    S = list(input().strip())
    tree = SegTree(N, S)

    Q = int(input())
    for _ in range(Q):
        t_q, in_1, in_2 = input().split()
        if t_q == "1":
            i_q = int(in_1)
            c_q = in_2
            tree.update(i_q-1, c_q)
        else:
            l_q = int(in_1)
            r_q = int(in_2)
            print(bin(tree.get(l_q-1, r_q)).count(1))

solve()
Problem p03785 (python)

Fixed submission:
N, C, K = map(int, input().strip().split(" "))
t = sorted([int(input().strip()) for _ in range(N)])

bus = 0
idx = 0
while idx < N:
    bus_go = t[idx] + K
    tmp = 0
    while idx < N:
        if t[idx] <= bus_go:
            tmp += 1
            idx += 1
            if idx == N:
                break
            if tmp == C:
                bus += 1
                tmp = 0
                bus_go = t[idx] + K
        else:
            break
    if tmp > 0:
        bus += 1

print(bus)

Buggy submission (verdict: Runtime Error):
N, C, K = map(int, input().strip().split(" "))
t = sorted([int(input().strip()) for _ in range(N)])

bus = 0
idx = 0
while idx < N:
    bus_go = t[idx] + K
    tmp = 0
    while idx < N:
        if t[idx] <= bus_go:
            tmp += 1
            idx += 1
            if tmp == C:
                bus += 1
                bus_go = t[idx] + K
                tmp = 0
        else:
            break

    if tmp > 0:
        bus += 1

print(bus)
Problem p02623 (python)

Fixed submission:
import logging

logging.basicConfig(level=logging.INFO)
logging.info('info')


def main():
    N, M, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    B_list = list(map(int, input().split()))
    logging.info("hello")

    a = [0]
    b = [0]

    for i in range(N):
        a.append(a[i] + A_list[i])

    for i in range(M):
        b.append(b[i] + B_list[i])

    ans = 0
    j = M
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i + j)

    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import logging

logging.basicConfig(level=logging.INFO)
logging.info('info')


def main():
    N, M, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    B_list = list(map(int, input().split()))
    logging.info("hello")

    a = [0]
    b = [0]

    for i in range(N):
        a.append(a[i] + A_list[i])

    for i in range(M):
        b.append(b[i] + B_list[i])

    ans = 0
    j = M
    for i in range(N + 1):
        if a[i] > K:
            break
        for j in range(M):
            if b[j] > K - a[i]:
            else:
                ans = max(ans, i + j)
                break
    print(ans)

if __name__ == "__main__":
    main()
Problem p02948 (python)

Fixed submission:
import logging
import heapq

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, M = map(int, input().split())
    A_B = [list(map(int, input().split())) for _ in range(N)]
    logging.info("Hello!")

    A_B.sort()
    logging.info(A_B)


    heap_Q = []
    curr = 0
    total = 0
    for i in range(1, M + 1):
        while curr < N and  A_B[curr][0] <= i:
            heapq.heappush(heap_Q, A_B[curr][1] * (-1))
            curr += 1

        if heap_Q:
            total += (-1) * heapq.heappop(heap_Q)

    print(total)
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

dp = [0 for _ in range(100000)]

def main():
    N, M = map(int, input().split())
    A_B = [list(map(int, input().split()))[::-1] for _ in range(N)]
    logging.info("Hello!")

    sorted_A_B = sorted(A_B, reverse=True)
    logging.info(sorted_A_B)


    total = 0
    for i in range(M):
        if sorted_A_B[i][1] + i <= M:
            total += sorted_A_B[i][0]


    print(total)
    
if __name__ == "__main__":
    main()