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

Fixed submission:
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

Q, H, S, D, N = map(int, read().split())
H = min(Q * 2, H)
S = min(H *2 , S)

if S * 2 < D:
    print(N * S)
else:
    print(N // 2 * D + N % 2 * S)

Buggy submission (verdict: Runtime Error):
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

Q, H, S, D, N = map(int, read().split())

dp = [1<<60] * (N + 2)

dp[0] = 0

for i in range(1, N+1):
    dp[i] = min([dp[i-1] + Q * 4, dp[i-1] + Q*2 + H, dp[i-1] + H*2, dp[i-1] + S])
    if i >= 2:
        dp[i] = min(dp[i], dp[i-2] + D)

print(dp[N])
Problem p03767 (python)

Fixed submission:
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, *A = map(int, read().split())

A = sorted(A)[::-1]
A = A[1:-N:2]

print(sum(A))

Buggy submission (verdict: Runtime Error):
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, *A =  map(int, read().split())

A = sorted(A)
A = A[N:-N]

print(sum(A))
Problem p04005 (python)

Fixed submission:
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B, C = map(int, readline().split())

if (A % 2 == 0) or (B % 2 == 0) or (C % 2 == 0):
    print(0)
else:
    tmp = [A, B, C]
    tmp = sorted(tmp)
    print(tmp[0] * tmp[1])

Buggy submission (verdict: Runtime Error):
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B, C = map(int, readline().split())

if (A % 2 == 0) or (B % 2 == 0) or (C % 2 == 0):
    print(0)
else:
    tmp = [A, B, C]
    tmp = sorted(tmp)
    print(tmp[0] * tmp[1])
Problem p02623 (python)

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

a_, b_ = [0], [0]

for i in range(n):
    a_.append(a_[i] + a[i])
for i in range(m):
    b_.append(b_[i] + b[i])

ans, j = 0, 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)

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

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

a_, b_ = [0], [0]

for i in range(n):
    a_.append(a_[i] + a[i])
for j in range(m):
    b_.append(b_[j] + b[j])

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)

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

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

a_, b_ = [0], [0]

for i in range(n):
    a_.append(a_[i] + a[i])
for j in range(m):
    b_.append(b_[j] + b[j])

ans = 0
for i in range(n+1):
    
    idx2 = m
    while a_[i] + b_[idx2] > k:
        idx2 -= 1
    
    ans = max(ans, i + idx2)
print(ans)

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

a_, b_ = [0], [0]

for i in range(n):
    a_.append(a_[i] + a[i])
for i in range(n):
    b_.append(b_[i] + b[i])

ans, j = 0, m - 1

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)
Problem p02570 (python)

Fixed submission:
D,T,S=map(int,input().split())
if D/S <= T:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
D,T,S=map(int,input().split())
if D/S <= T:
    print("Yes")
else:
    prnit("No")
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
A,B = input().split()
b = Decimal(B)
print(int(int(A)*b))

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
A,B = input().split()
b = Decimal(B)
print(int(A*b))

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int, input().split())
c = A*B
print(math.floor(c))
Problem p02693 (python)

Fixed submission:
K = int(input())
A,B = map(int, input().split())
p = 0
for i in range(1000):
    if A <= K*i and K*i <= B:
        p = 1
        break
if p == 1:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A,B = map(int, input().split())
p = 0
for i in range(1000):
    if A <= K*i and k*i <= B:
        p = 1
        break
if p == 1:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A,B = map(int, input().split())
p = 0
for i in range(1000):
    if A <= K*i and k*i <= B:
        p = 1
        break
if p = 1:
    print("OK")
else:
    print("NG")
Problem p02701 (python)

Fixed submission:
import collections

n = int(input())
a = [input() for i in range(n)]
b = collections.Counter(a)
print(len(b))

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
a = [list(input() for i in range(n))]
b = collections.Counter(a)
print(len(b))
Problem p02773 (python)

Fixed submission:

n = int(input())
dic = {}
b = []
for i in range(n):
    a = input()
    b.append(a)
for o in b:
    if o in dic:
        dic[o] += 1
    else:
        dic[o] = 1
M = max(dic.values())
for j,k in sorted(dic.items()):
    if k == M:
        print(j)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
dic = {}
b = []
for i in range(n):
    a = input()
    b.append(a)
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
M = max(dic.values())
for j, k in sorted(dic.items):
    if k == M:
        print(j)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
dic = {}
b = []
for i in range(n):
    a = input()
    b.append(a)
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

for j, k in sorted(dic.items):
    if k == max(dic):
        print(j)
Problem p02659 (python)

Fixed submission:
q = input().split(" ")
A = int(q[0])
B = q[1].split(".")
#print(B)
b0 = B[0]
b1 = B[1]
if b1[0]=="0":
  b1 = b1[1]

s = str(A*int(b1)//100)
#print(s)
print(A*int(b0) + int(s))

Buggy submission (verdict: Runtime Error):
import math
q = input().split(" ")
A = int(q[0])
B = q[1].split(".")
b0 = B[0]
b1 = B[1]
if b1[0]=="0":
  b1 = b1[1]


print(A*int(b0) + math.floor(((A*int(b1))/100)
Problem p02699 (python)

Fixed submission:
a = input().split(" ")
s = int(a[0])
w = int(a[1])

if w >= s:
  print("unsafe")
else:
  print("safe")

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

for i in range(N):
  a.append(input())
  
b = set(a)
print(len(b))

Buggy submission (verdict: Runtime Error):
N = input().split(" ")
TL = int(N[0])
TA = int(N[1])
AL = int(N[2])
AA = int(N[3])
a = 0

while a == 0:
  AL = AL - TA
  if AL <= 0:
    a = 1
    break
  TL = TL - AA
  if TL <= 0:
    a = 2
    break
if a == 1:
  print("Yes")
elif a == 2:
  print("No")
Problem p02771 (python)

Fixed submission:
def kawaiso(a, b, c):
  if (a == b and b != c) or (b == c and c != a) or (c == a and a != b):
    return 'Yes'
  else:
    return 'No'
 
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
 
print(kawaiso(a, b, c))

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

if A = B = C :
    print("No")
else:
    print("Yes")
Problem p02777 (python)

Fixed submission:
S,T = map(str,input().split())
A,B = map(int,input().split())
s = input()

if s == S:
    A -=1
elif s == T:
    B -=1
print(A,B)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
res = "YES"
A.sort()
for i in range(len(A)):
    if i == 0:
        continue
    if A[i-1] == A[i]:
        res = "NO"
        break
    else:
        continue
print(res)

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

if s == S:
    A -=1
else:
    B -=1
print(A,B)
Problem p02831 (python)

Fixed submission:
import fractions

a,b=(int(x) for x in input().split())
  
print(a*b // fractions.gcd(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))

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 p02897 (python)

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

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
c = 2
for i in (2,A):
    for j in range(2, B):
        if i % j == 0:
            if i == j:
                c +=1
            else:
                break
print(c)
Problem p02916 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b= list(map(int,input().split()))
c = list(map(int,input().split()))
 
m=0
 
for i in range (0,n):
  m += b[a[i]-1]
  if i !=0 and a[i]==a[i-1]+1:
    m += c[a[i-1]-1]
print(m)

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

listD = [ListA,ListB,ListC]
sorted(listD)
print(sum(listD[1])+sum(list[2]))

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

listD = [ListA,ListB]
sorted(listD)
print(sum(listD[1]))
Problem p03208 (python)

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

tree = []
for _ in range(N):
    tree.append(int(input()))

tree.sort()
ans = 10**9
for i in range(N-K+1):
    ans = min(ans, tree[i+K-1]-tree[i])
print(ans)

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

tree = []
for _ in range(n):
    tree.append(int(input()))

tree.sort()
ans = 10**9
for i in range(N-K+1):
    ans = min(ans, tree[i+K-1]-tree[i])
print(ans)
Problem p03315 (python)

Fixed submission:
S = list(input())
ans = 0
for i in range(len(S)):
    if S[i] =="+":
        ans += 1
    elif S[i] == "-":
        ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
s = input()
#print(n-1,k-1)
print(math.ceil((n-1)/(k-1)))
Problem p03327 (python)

Fixed submission:
N = int(input())
if N<1000:
    print("ABC")
elif N>=1000:
    print("ABD")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
k=b-a
print(((1+k)*k)//2-b)
Problem p03834 (python)

Fixed submission:
s = input()
print(s.replace(",", " "))

Buggy submission (verdict: Runtime Error):
t=str(s)
print(t.replace(",", " "))
Problem p02571 (python)

Fixed submission:
s = input()
t = input()

ans = 10000

for i in range(len(s) - len(t) + 1):
    score = 0
    U = s[i:i + len(t)]
    for j in range(len(t)):
        if U[j] != t[j]:
            score += 1
    ans = min(ans, score)

print(ans)

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

ans = 10000

for i in range(len(s) - len(t) + 1):
    score = 0
    U = [i:i + len(t)]
    for j in range(len(t)):
        if U[j] != t[j]:
            score += 1
    ans = min(ans, score)

print(ans)
Problem p02572 (python)

Fixed submission:

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

MOD = 10 ** 9 + 7

sum = sum(a) % MOD
ans = 0

for i in range(len(a)):
    sum -= a[i]
    sum %= MOD
    ans += a[i] * sum
    ans %= MOD

print(ans)

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

n = int(input())
a = list(map(int, input().split()))
sum = 0
k = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        k += a[j]

    
    sum += a[i] * k

    k = 0
        
ans = np.mod(sum,10**9+7)

print(ans)

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

n = int(input())
a = list(map(int, input().split()))
sum = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        sum += a[i]*a[j]
        
ans = np.mod(sum,10**9+7)

print(ans)

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

def product(list):
    p = 1
    for i in list:
        p *= i
    return p


n = int(input())
a = list(map(int, input().split()))
sum = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        sum += a[i]*a[j]
        
ans = np.mod(sum,10**9+7)

print(ans)
Problem p02948 (python)

Fixed submission:
from heapq import heappush, heappop

def solve():
    N, M = map(int , input().split())
    arbeit_A_B = list(list(map(int , input().split())) for _ in range(N))
    arbeit_A_B = sorted(arbeit_A_B, key=lambda x: (x[0], -x[1]))
    # print(arbeit_A_B)
    day = 1
    result = 0
    index_arbeit = 0
    heap_q = []
    while day <= M:
        while index_arbeit < N:
            A,B = arbeit_A_B[index_arbeit]
            if A <= day:
                heappush(heap_q, (-1)*B)
            else: break
            index_arbeit += 1
            
        if heap_q:
            result -= heappop(heap_q)
        day += 1
            
    print(result)
    
solve()

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

def solve():
    N, M = map(int , input().split())
    arbeit_A_B = list(list(map(int , input().split())) for _ in range(N))
    arbeit_A_B = sorted(arbeit_A_B, key=lambda x: (x[0], -x[1]))
    # print(arbeit_A_B)
    day = 1
    result = 0
    index_arbeit = 0
    heap_q = []
    while day <= M:
        while index_arbeit < N:
            A,B = arbeit_A_B[index_arbeit]
            if A <= day:
                heappush(heap_q, (-1)*B)
            else: break
            index_arbeit += 1
            
        result -= heappop(heap_q)
        day += 1
            
    print(result)
    
solve()
Problem p03038 (python)

Fixed submission:
import heapq

def solve():
  N,M = map(int, input().split())
  A = list(map(int, input().split()))
  A.sort()
  ret = sum(A)
  CB = {}
  C_heap = []
  for _ in range(M):
    b,c  = map(int, input().split())
    if c in CB:
      CB[c] += b
    else:
      CB[c] = b
      heapq.heappush(C_heap, -c)

  c = (-1)*heapq.heappop(C_heap)
  for a in A:
    if CB[c] == 0:
      if not C_heap: break

      c = (-1)*heapq.heappop(C_heap)
    
    if c <= a:
      break

    ret += c-a
    CB[c] -= 1

  print(ret)
  
solve()

Buggy submission (verdict: Runtime Error):
def solve():
  N,M = map(int, input().split())
  A = list(map(int, input().split()))
  A.sort()
  ret = sum(A)
  CB = {}
  C_heap = []
  for _ in range(M):
    b,c  = map(int, input().split())
    if c in CB:
      CB[c] += b
    else:
      CB[c] = b
      heapq.heappush(C_heap, -c)

  c = (-1)*heapq.heappop(C_heap)
  for a in A:
    if CB[c] == 0:
      if not C_heap: break

      c = (-1)*heapq.heappop(C_heap)
    
    if c <= a:
      break

    ret += c-a
    CB[c] -= 1

  print(ret)
  
solve()
Problem p03077 (python)

Fixed submission:
import math

def solve():
    N = int(input())
    ABCDE = []
    for _ in range(5):
        ABCDE.append(int(input()))
        
    min_ = min(ABCDE)
    
    print(math.ceil(N/min_)+4)
    
solve()

Buggy submission (verdict: Runtime Error):
def solve():
    N = int(input())
    ABCDE = []
    for _ in range(5):
        ABCDE.append(int(input()))
        
    min_ = min(ABCDE)
    
    print(math.floor(N/min_)+4)
    
solve()
Problem p03209 (python)

Fixed submission:
def len_burger(L):
    return 2**(L+2)-3
def num_ban(L):
    return 2**(L+1)-1

def eat(L,X):
    if L == 0: return 1
    if X == 1: return 0
    elif X <= len_burger(L-1)+1: return eat(L-1,X-1)
    elif X == len_burger(L-1)+2: return num_ban(L-1)+1
    elif X < 2*len_burger(L-1)+3: return num_ban(L-1)+1+eat(L-1,X-len_burger(L-1)-2)
    elif X == len_burger(L): return num_ban(L)

def solve():
    N,X = [int(s) for s in input().split() if s]
    
    print(eat(N,X))
    
solve()

Buggy submission (verdict: Runtime Error):
def eat(L,X):
    if L == 0: return 1
    if X == 1: return 0
    elif X <= len_burger(L-1)+1: return eat(L-1,X-1)
    elif X == len_burger(L-1)+2: return num_ban(L-1)+1
    elif X < 2*len_burger(L-1)+3: return num_ban(L-1)+1+eat(L-1,X-len_burger(L-1)-2)
    elif X == len_burger(L): return num_ban(L)

def solve():
    N,X = [int(s) for s in input().split() if s]
    
    print(eat(N,X))

solve()
Problem p03804 (python)

Fixed submission:
def find_indices(a, b, L):
    # aからbのパターンをみつける
    return [i for i in range(L) if a[i:].startswith(b)]

def solve():
    N,M = map(int, input().split())
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]
    idx = 0
    start_pos = {}
    for S_a in A:
        indices = set(find_indices(S_a, B[idx], N))
        if not start_pos:
            start_pos = indices
        else:
            start_pos = start_pos&indices
        
        if start_pos:
            idx += 1
        else:
            start_pos = {}
            idx = 0
            
        if idx == M:
            break
    
    print('Yes' if start_pos else 'No')
    
solve()

Buggy submission (verdict: Runtime Error):
def solve():
    N,M = map(int, input().split())
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]
    idx = 0
    start_pos = {}
    for S_a in A:
        indices = set(find_indices(S_a, B[idx], N))
        if not start_pos:
            start_pos = indices
        else:
            start_pos &= indices
        
        if start_pos:
            idx += 1
        else:
            start_pos = {}
            idx = 0
            
        if idx == M:
            break
    
    print('Yes' if start_pos else 'No')
    
solve()
Problem p02711 (python)

Fixed submission:
n=input()
if n[0]=='7' or n[1]=='7' or n[2]=='7':
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%10==7:
	print('Yes')
	exit()
else:
	n=n//10
	if n%10==7:
		print('Yes')
		exit()
	else:
		n=n//10:
		if n%10==7:
			print('Yes')
			exit()
print('No')
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
a=

Buggy submission (verdict: Runtime Error):
a = int(input())
2 s = input()
3 print(s if a >= 3200 else 'red')

Buggy submission (verdict: Runtime Error):
a = int(input())
2 s = input()
3 print(s if a >= 3200 else 'red')
Problem p02951 (python)

Fixed submission:
a,b,c=map(int,input().split())
s=c-min(c,a-b)
print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(1, N + 1):
	if len(str(i)) % 2 == 1:
		ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(1, N + 1):
	if len(int(i)) % 2 == 1:
		ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(1, N + 1):
	if len(i) % 2 == 1:
		ans += 1
print(ans)
Problem p02623 (python)

Fixed submission:
def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])

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

    ans, j = 0, 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)
main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M, K = map(int, input().split())
    bookA = list(map(int, input().split()))
    bookB = list(map(int, input().split()))
    Ai = 0
    Bi = 0
    C = 0

    while K > 0:
        if Ai - N == 0 and Bi - M == 0:
            break
        if Ai - N == 0:
            K = K - bookB[Bi]
            if K == 0:
                C = C + 1
                break
            elif K < 0:
                break
            C = C + 1
            Bi = Bi + 1
        elif Bi - M == 0:
            K = K - bookB[Bi]
            if K == 0:
                C = C + 1
                break
            elif K < 0:
                break
            C = C + 1
            Ai = Ai + 1
        else:
            if bookA[Ai] < bookB[Bi]:
                K = K - bookA[Ai]
                if K == 0:
                    C = C + 1
                    break
                elif K < 0:
                    break
                C = C + 1
                Ai = Ai + 1
            else:
                K = K - bookB[Bi]
                if K == 0:
                    C = C + 1
                    break
                elif K < 0:
                    break
                C = C + 1
                Bi = Bi + 1
    
    print(C)
    
    

main()

Buggy submission (verdict: Runtime Error):
def main():
    A, M, K = map(int, input().split())
    bookA = list(map(int, input().split()))
    bookB = list(map(int, input().split()))

    if len(bookA) != len(bookB):
        if len(bookA) > len(bookB):
            diff = len(bookA) - len(bookB)
            for i in range(diff + 1):
                bookB.append(1000000000)
            bookA.append(1000000000)
        else:
            diff = len(bookB) - len(bookA)
            for j in range(diff + 1):
                bookA.append(1000000000)
            bookB.append(1000000000)
    
    C = 0
    Ai = 0
    Bi = 0

    while K > -1:
        if bookA[Ai] < bookB[Bi]:
            K = K - bookA[Ai]
            if K == 0:
                C = C + 1
                break
            elif K < 1:
                break
            Ai = Ai + 1
            C = C + 1
        else:
            K = K - bookB[Bi]
            if K == 0:
                C = C + 1
                break
            elif K < 1:
                break
            Bi = Bi + 1
            C = C + 1
    print(C)
    

main()
Problem p02659 (python)

Fixed submission:
from decimal import Decimal as dec
import math

def main():
    a,b = map(dec, input().split())
    ans = (a * b)
    print(int(ans))
main()

Buggy submission (verdict: Runtime Error):
from decimal import * as dec
import math

def main():
    a,b = map(dec, input().split())
    if b < 1:
        print(0)
        return
    ans = (a * b)
    print(math.floor(ans))
main()
Problem p02572 (python)

Fixed submission:
N = int(input())

A = list(map(int, input().split()))
S = sum(A)
ans = 0
for i in range(N):
    S -= A[i]
    ans += A[i] * S
    

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

print(ans)

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

A = list(map(int, input().split()))
S = sum(A)

for i in range(N-1):
    S -= A[i]
    ans += A[i] * S
    

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

print(ans)
Problem p02693 (python)

Fixed submission:
import sys
k = int(input())
a, b = map(int, input().split())

for i in range(1,1000):
  kk=k*i
  if (kk >= a and kk <= b):
    print ('OK')
    sys.exit()
  if (kk > b):
    print ('NG')
    sys.exit()

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


if (n >=b):
  x=int(n/b)*b-1
  print (int(a*x/b)-a*int(x/b))
else:
  xmax=0
  for x in range(1,n+1):
    atai=int(a*x/b)-a*int(x/b)
    if (atai >= xmax): xmax=atai
  print (xmax)
Problem p02711 (python)

Fixed submission:
i = input()

if (i[0] == '7' or i[1] == '7' or i[2] == '7'):
    print ('Yes')
else:
    print ('No')

Buggy submission (verdict: Runtime Error):
i = input()
i1=int(i/100)
i2=int((i-i1*100)/10)
i3=i-i1*100-i2*10

if (i1 == 7 or i2 == 7 or i3 == 7):
    print ('Yes')
else:
    print ('No')