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

Fixed submission:
a,b = map(int, input().split())
if a <= 9 and b <= 9:
    print(a*b)
else:
    print('-1')

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
if x / a >= (a*b/2):
    print(math.degrees(math.atan((2*b/a)-2*x/(a**3))))
else:
    if a < b:
        print(math.degrees(math.atan(a*b*b/(2*x))))
    else:
        print(math.degrees(math.atan(2*x/(a*b*b))))
Problem p03286 (python)

Fixed submission:
n = int(input())
if n == 0:
    print(0)
    exit()
flag = True
ans_str = ''
while True:
    if n == 1:
        ans_str = '1' + ans_str
        print(int(ans_str))
        exit()
    if n < 0 and (-n)%2 == 1:
        ans_str = '1' + ans_str
        n = -(n-1)//2
    elif n < 0 and (-n)%2 == 0:
        ans_str = '0' + ans_str
        n = -n//2
    elif n > 0 and n%2 ==1:
        ans_str = '1' + ans_str
        n = -(n//2)
    elif n > 0 and n%2 ==0:
        ans_str = '0' + ans_str
        n = -(n//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n == 0:
    print(0)
    exit()
flag = True
ans_str = ''
while True:
    if n // (-2) == 0:
        ans_str = '1' + ans_str
        print(int(ans_str))
        exit()
    else:
        ans_str = n%(-2) + ans_str
Problem p03723 (python)

Fixed submission:
import sys
a,b,c = map(int,input().split())
if a == b == c and a%2 == b%2 == c%2== 0:
    print(-1)
    sys.exit()
count = 0
while a%2 == 0 and b%2 == 0 and c%2 == 0:
    x = (b+c)//2
    y = (a+c)//2
    z = (a+b)//2
    a,b,c = x,y,z
    count+=1
    #print(a,b,c)
print(count)

Buggy submission (verdict: Runtime Error):
import sys
a,b,c = map(int,input().split())
if a == b == c:
    print(-1)
    sys.eixt()
count = 0
while a%2 == 0 and b%2 == 0 and c%2 == 0:
    x = (b+c)//2
    y = (a+c)//2
    z = (a+b)//2
    a,b,c = x,y,z
    count+=1
    #print(a,b,c)
print(count)
Problem p02629 (python)

Fixed submission:
import math

alphabets = [chr(i) for i in range(97, 97+26)]

N = int(input())

def run(n):
    a = 0
    for i in range(1, 12):
        if math.pow(26, i) >= n:
            break
        n -= int(math.pow(26, i))

    ans = ''
    for j in range(i-1):
        b = n // int(math.pow(26, i-j-1))
        amari = n % int(math.pow(26, i-j-1))
        if amari == 0:
            b -= 1
        ans += alphabets[b]
        n = n % int(math.pow(26, i-j-1))
    ans += alphabets[n-1]
    return ans
    
print(run(N))

Buggy submission (verdict: Runtime Error):

import math

alphabets = [chr(i) for i in range(97, 97+26)]

N = int(input())

a = 0
for i in range(1, 12):
    if math.pow(26, i) >= N:
        break
    N -= int(math.pow(26, i))

ans = ''
for j in range(i):
    b = N // int(math.pow(26, i-j-1))
    if i-j != 1:
        ans += alphabets[b]
    else:
        ans += alphabets[b-1]
    N = N % int(math.pow(26, i-j-1))
print(ans)
Problem p02659 (python)

Fixed submission:

import math

A, B = input().split()

A = int(A)
if '.' in B:
    B_a = int(B.split('.')[0])
    B_b_size = len(B.split('.')[1])
    B_b =  int(B.split('.')[1])
else:
    B_a = int(B)
    B_b_size = 0
    B_b = 0
if B_b_size == 0:
    ans = A * B_a
elif B_b_size == 1:
    ans_a = A * B_a
    ans_b = A * B_b 
    ans_b = ans_b // 10
    ans = ans_a + ans_b
else:
    ans_a = A * B_a
    ans_b = A * B_b 
    ans_b = ans_b // 100
    ans = ans_a + ans_b
print(ans)

Buggy submission (verdict: Runtime Error):
input_count = 0

A, B = input().split()

A = int(A)
if '.' in B:
    B_a = int(B.split('.')[0])
    B_b_size = len(B.split('.')[1])
    B_b =  int(B.split('.')[1])
else:
    B_a = int(B)
    B_b_size = 0
    B_b = 1
ans_a = A * B_a
ans_b = A * math.pow(10, -1*B_b_size) * B_b
ans = ans_a + int(ans_b)
print(ans)
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())

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

Buggy submission (verdict: Runtime Error):
s = int(input())
w = int(input())

if w >= s:
    print('unsafe')
else:
    print('safe')
Problem p02831 (python)

Fixed submission:
import fractions
A, B = map(int, input().split())
lcm = int(A/fractions.gcd(A,B) * B)
print(lcm)

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
lcm = int(A/math.gcd(A,B) * B)
print(lcm)
Problem p02711 (python)

Fixed submission:
N=input()
N=N.replace('7','')
print('Yes' if len(N)<3 else 'No')

Buggy submission (verdict: Runtime Error):
N=input()
N=N.replace('7')
print('Yes' if len(N)<3 else 'No')
Problem p02729 (python)

Fixed submission:
N,M=map(int,input().split())
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

if N>=2:
    a=combinations_count(N,2)
else:
    a=0
if M>=2:
    b=combinations_count(M,2)
else:
    b=0
print(a+b)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(combinations_count(N,2)+combinations_count(M,2))
Problem p03186 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a + b >=  c:
  print(b + c)
else:
  print(a + b * 2 + 1)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a + b >=  c:
  print(b + c)
else:
  print(c + b - 1)
a, b, c = map(int, input().split())
if a + b >=  c:
  print(b + c)
else:
  print(b + 2 * c + 1)
Problem p03803 (python)

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

if a == b:
    print("Draw")
elif a == 1:
    print("Alice")
elif b == 1:
    print("Bob")
elif a > b:
    print("Alice")
else:
    print("Bob")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
    if a == b:
        print("Draw")
    elif a == 1:
        print("Alice")
    elif b == 1:
        print("Bob")
    elif a > b:
        print("Alice")
    else:
        print("Bob")
Problem p03834 (python)

Fixed submission:
print(input().replace(',', ' '))

Buggy submission (verdict: Runtime Error):
s = input()
print(s.replace(',', ' ')
Problem p02833 (python)

Fixed submission:
N = int(input())

if N%2 != 0:
    print(0)
    exit()

ans = 0

denom = 10
while True:
    if denom > N:
        break

    ans += N//denom
    denom = denom*5

print(ans)

Buggy submission (verdict: Runtime Error):

N = int(input())

def func(num):
    if num < 2:
        return 1
    else:
        return num * func(num-2)

res = func(N)

ans = 0
while True:
    if res % 10 == 0:
        ans += 1
        res = res//10
    else:
        break
print(ans)
Problem p03041 (python)

Fixed submission:
X = input().split()
N = int(X[0])
K = int(X[1]) - 1
S = list(str(input()))

if S[K]=="A":
    S[K] = "a"
elif S[K]=="B":
    S[K] = "b"
elif S[K]=="C":
    S[K] = "c"
for i in S:
  print(i, end ="")

Buggy submission (verdict: Runtime Error):
X = int(input().split())
N = int(X[0])
K = int(X[1])
S = list(str(input()))

if S[K]=="A":
    S[K] = "a"
elif S[K]=="B":
    S[K] = "b"
elif S[K]=="C":
    S[K] = "c"
for i in S:
  print(i, end ="")
Problem p02891 (python)

Fixed submission:
S=list(input())
k=int(input())

cnt,ans=0,0
T=S+S
for i in range(1,len(T)):
  if T[i-1]==T[i]:
    cnt+=1
  else:
    ans+=(cnt+1)//2
    cnt=0
  if i==len(S)-1:
    ans+=(cnt+1)//2
    tmp=ans

if len(S)==1:
  print(k//2)
  exit()
if len(S)==2:
  if S[0]==S[1]:
    print(k)
  else:
    print(0)
  exit()
  
if len(set(T))==1:
  if len(S)%2==0:
    print(len(S)//2*k)
  else:
    out=(len(S)//2)*(k-(k//2))+(len(S)//2+1)*(k//2)
    print(out)
  exit()
      
print(tmp+(ans-tmp)*(k-1))

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

cnt,ans=0,0
for i in range(1,len(S)):
  if S[i-1]==S[i]:
    cnt+=1
  else:
    cnt+=1
    ans+=cnt//2
    cnt=0
ans+=cnt//2
if S[0]==S[-1] and S[-1]!=S[-2]:
  print(ans*k+k-1)
else:
  print(ans*k)

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

cnt,ans=0,0
for i in range(1,len(S)):
  if S[i-1]==S[i]:
    cnt+=1
  else:
    cnt+=1
    ans+=cnt//2
    cnt=0
ans+=cnt//2
if S[0]==S[-1] and S[-1]==S[-2]:
  print(ans*k+k)
else:
  print(ans*k)
Problem p02912 (python)

Fixed submission:
import heapq
n,m=map(int,input().split())
A=list(map(int,input().split()))

q=[]
for a in A:
  heapq.heappush(q,-a)
  
for _ in range(m):
  p=-heapq.heappop(q)//2
  heapq.heappush(q,-p)
print(-sum(q))

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

while m>0:
  A.sort(reverse=True)
  A[0]=A[0]//2
  m-=1
  print(A,m)
print(sum(A))
Problem p02990 (python)

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

mod=10**9+7
ans=n-k+1
print(ans)
for i in range(2,k+1):
  ans=(ans*(n-k-i+2)*(k-i+1)*pow(i*(i-1),mod-2,mod))%mod
  print(ans)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
n,k=map(int,input().split())

def comb(n,r):
  r = min(n-r,r)
  if r == 0: return 1
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1,r + 1))
  return over // under

blue,red=k,n-k
if red==0:
  print(0)
else:
  mod=10**9+7
  for i in range(1,k+1):
    print((comb(red+1,i)*comb(blue-1,i-1))%mod)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
n,k=map(int,input().split())

def comb(n,r):
  r = min(n-r,r)
  if r == 0: return 1
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1,r + 1))
  return over // under

blue,red=k,n-k
mod=10**9+7
for i in range(1,k+1):
  print((comb(red+1,i)*comb(blue-1,i-1))%mod)
Problem p03013 (python)

Fixed submission:
import sys
mod = 10**9+7

def main():
    n, m = map(int, input().split(' '))
    if m > 0:
        aaa = set(map(int, sys.stdin))
    else:
        aaa = set()
 
    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in aaa else 0
    
    for i in range(2, n+1):
        if i in aaa:
            continue
        dp[i] = (dp[i-1]+dp[i-2])%mod
 
    print(dp[n])
 
main()

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split(' '))
if m > 0:
    aaa = set(map(int, sys.stdin))
else:
    aaa = set()

dp = [0] * (n+1)
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0

mod=10**9+7
for i in range(2, n+1):
    if i in aaa:
        continue
    dp[i] = (dp[i-1]+dp[i-2])%mod

print(dp[n])

Buggy submission (verdict: Runtime Error):
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

out=0
for i in range(0,N,1):
  if i in A:
    continue
  if i==N-1:
    out+=1
  for j in range(i,N,2):
    if j in A:
      continue
    if j==N-1:
      out+=1
  
print(out%1000000007)

Buggy submission (verdict: Runtime Error):
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

out=0
for i in range(0,N,1):
  if i in A:
    continue
  if i==N:
    out+=1
  for j in range(i,N,2):
    if j in A:
      continue
    if j==N:
      out+=1
  
print(out%1000000007)
Problem p03077 (python)

Fixed submission:
import math
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

print(math.ceil(n/min(a,b,c,d,e)+4))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

print(ceil(n/min(a,b,c,d,e)+4))
Problem p02712 (python)

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

allsum = int( (N + 1) * N / 2 )
#print(allsum)

f = int(N / 3)
b = int(N / 5)
fb = int(N / 15)


#print(f)
#print(b)
#print(fb)

fsum = int((f+1)*f/2)*3
bsum = int((b+1)*b/2)*5
fbsum = int((fb+1)*fb/2)*15

print(allsum - fsum - bsum + fbsum)

Buggy submission (verdict: Runtime Error):
N = input()
N = int(N)
 
allsum = (N+1)*int(N/2)
 
fum = int(N / 3)
bsum = int(N / 5)
fbsum = int(N / 15)
 
print(allsum-fsum*3-bsum*5+fbsum*15)
Problem p02629 (python)

Fixed submission:
n = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
d = {i+1:s for i, s in enumerate(alp)}
s = ""
while True:
    q, mod = divmod(n, 26)
    if mod == 0:
        s = "z" + s
        n = q-1
    else:
        s = d[mod] + s
        n = q
    if n == 0:
        break
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
d = {i+1:s for i, s in enumerate(alp)}
s = ""
while True:
    q, mod = divmod(n, 26)
    s = d[mod] + s
    if q == 0:
        break
    n = q
print(s)
Problem p02831 (python)

Fixed submission:
import sys
import fractions
def input(): return sys.stdin.readline().rstrip()

def main():
    a, b= map(int, input().split())
    print(a * b // fractions.gcd(a, b))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math
def input(): return sys.stdin.readline().rstrip()

def main():
    a, b= map(int, input().split())
    print(a * b // math.gcd(a, b))

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

Fixed submission:
import math
import sys
input = sys.stdin.readline

def main():
    mod = 10 ** 9 + 7
    x, y = map(int, input().split())
    if (2 * y - x) % 3 != 0:
        print(0)
        return None

    n = (2 * y - x) // 3
    m = y - 2 * n

    if n < 0 or m < 0:
        print(0)
    elif n == 0 and m == 0:
        print(0)
    elif n == 0 or m == 0:
        print(1)
    else:
        s = n + m + 1
        f = [1] * s

        for i in range(1, s):
            f[i] = f[i-1] * i % mod

        ans = f[n+m]
        ans = ans * modinv(f[n]) % mod
        ans = ans * modinv(f[m]) % mod
        print(ans)

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
import sys
input = sys.stdin.readline

def main():
    x, y = map(int, input().split())
    if (2 * y - x) % 3 == 0:
        x_c = (2 * y - x) // 3
        y_c = y - 2 * x_c
        print(x_c, y_c)
        if x_c == 0 or y_c == 0:
            print(1)
        else:
            f = math.factorial
            print(f(x_c+y_c)/(f(x_c) * f(y_c)))
    else:
        print(0)

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

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [[n-1 for n in list(map(int, input().split()))] + [-1] for _ in range(N)]
A = [a[::-1] for a in A]

def main(N, A):
    now = [A[i].pop() for i in range(N)]
    day = 0
    rest = N * (N-1)
    candidate = set(range(N))

    # WCS O(N**2) <- 1日に1試合だけのときN(N-1)/2回while文が繰り返される
    while True:
        # terminal condition
        # O(1)
        if rest == 0:
            return day

        # see if we have match today
        # O(N)
        have_match = False
        # tmp = now.copy()
        # for i in range(N):
        #     if now[now[i]] == i:
        #         tmp[i] = A[i].pop()
        #         rest -= 1
        #         have_match = True
        # now = tmp
        change = []
        next_candidate = set()
        for i in candidate:
            if now[now[i]] == i:
                j = A[i].pop()
                change.append((i, j))
                # あとで(a, b)でnow[a] = bに更新する
                next_candidate.add(i)
                if j != -1:
                    next_candidate.add(j)
                
                rest -= 1
                have_match = True

        if len(change) == 0:
            return -1
        for (a, b) in change:
            now[a] = b
            
        candidate = next_candidate
        
        day += 1

print(main(N, A))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [[n-1 for n in list(map(int, input().split()))] + [-1] for _ in range(N)]
A = [a[::-1] for a in A]

def main(N, A):
    now = [A[i].pop() for i in range(N)]
    day = 0
    rest = N * (N-1)

    # WCS O(N**2) <- 1日に1試合だけのときN(N-1)/2回while文が繰り返される
    while True:
        # terminal condition
        # O(1)
        if rest == 0:
            return day

        # see if we have match today
        have_match = False
        # O(N)
        tmp = now.copy()
        for i in range(N):
            if now[now[i]] == i:
                tmp[i] = A[i].pop()
                rest -= 1
                have_match = True
        now = tmp
        if not have_match:
            return -1
        day += 1

print(main(N, A))
Problem p02984 (python)

Fixed submission:
import sys

input = sys.stdin.readline

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

X = [0 for _ in range(N)]


for i in range(N):
    X[0] += (-1)**i * A[i]
for i in range(1, N):
    X[i] = -X[i-1] + 2*A[i-1]
 
 
print(*X)

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

input = sys.stdin.readline

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

X = [0 for _ in range(N)]



X = np.array(X)
A = np.array(A)
for i in range(N):
    B  = np.hstack((A[i:N+i], A[:i]))
    X = X + (-1)**i * B
 
print(*X)
Problem p02987 (python)

Fixed submission:
from collections import defaultdict
S = input()
D = defaultdict(int)
for s in S:
    D[s] += 1

def main(D):
    if len(D.keys()) != 2:
        return 0
    else:
        for v in D.values():
            if v != 2:
                return 0
    return 1

if main(D):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# xの逆元は、x*y = 1 mod pとなるようなy
N, K = map(int, input().split())
mod = 10**9 + 7
a = N - K + 1
print(a)
for i in range(K-1):
    a = a * (N - K - i) * (K - (i + 1)) // ((i+2) * (i+1))
    a %= mod
    print(a)

Buggy submission (verdict: Runtime Error):
# xの逆元は、x*y = 1 mod pとなるようなy
N, K = map(int, input().split())
mod = 10**9 + 7
a = N - K + 1
print(a)
for i in range(K-1):
    a = (a * (N - K - i) * (K - (i + 1)) // ((i+2) * (i+1))) % mod
    print(a)

Buggy submission (verdict: Runtime Error):
# xの逆元は、x*y = 1 mod pとなるようなy
N, K = map(int, input().split())
mod = 10**9 + 7
a = N - K + 1
print(a)
for i in range(K-1):
    a = a * (N - K - i) * (K - (i + 1)) // ((i+2) * (i+1)) % mod
    print(a)
Problem p02990 (python)

Fixed submission:
# xの逆元は、x*y = 1 mod pとなるようなy
N, K = map(int, input().split())
mod = 10**9 + 7
a = N - K + 1
print(a)
for i in range(K-1):
    a = a * (N - K - i) * (K - (i + 1)) // ((i+2) * (i+1))
    print(a % mod)

Buggy submission (verdict: Runtime Error):
# xの逆元は、x*y = 1 mod pとなるようなy
N, K = map(int, input().split())
mod = 10**9 + 7
a = N - K + 1
print(a)
for i in range(K-1):
    a *= (N - K - i) * (K - (i + 1)) / ((i+2) * (i+1)) % mod
    a = int(a)
    print(a)

Buggy submission (verdict: Runtime Error):
# xの逆元は、x*y = 1 mod pとなるようなy
N, K = map(int, input().split())
mod = 10**9 + 7
a = N - K + 1
print(a)
for i in range(K-1):
    a = a * (N - K - i) * (K - (i + 1)) / ((i+2) * (i+1))
    print(int(a % mod))
Problem p03012 (python)

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

front = W[0]
back = sum(W) - W[0]
diff = abs(front - back)
for i in range(1, N):
  front += W[i]
  back -= W[i]
  diff = min(diff, abs(front - back))

print(diff)

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

front = W[0]
back = sum(W) - W[0]
diff = abs(front, back)
for i in range(1, N):
  front += W[i]
  back -= W[i]
  diff = min(diff, abs(front, back))

print(diff)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
B = [0 for _ in range(N+1)]
for a in A:
  B[a] = 1
mod = 10**9 + 7
dp = [-1 for _ in range(N+1)]
dp[0] = 1
dp[1] = 1
for i in range(2, N+1):
  if B[i-2] == 0 and B[i-1] == 1:
    dp[i] = dp[i-2]
  elif B[i-2] == 1 and B[i-1] == 0:
    dp[i] = dp[i-1]
  elif B[i-2] == 0 and B[i-1] == 0:
    dp[i] = dp[i-1] + dp[i-2]
  else:
    dp[i] = 0
  dp[i] %= mod
 
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
B = [0 for _ in range(N+1)]
for a in A:
  B[a] = 1

dp = [-1 for _ in range(N+1)]
dp[0] = 1
dp[1] = 1
for i in range(2, N+1):
  if B[i-2] == 0 and B[i-1] == 1:
    dp[i] = dp[i-2]
  elif B[i-2] == 1 and B[i-1] == 0:
    dp[i] = dp[i-1]
  elif:
    dp[i] = dp[i-1] + dp[i-2]
  else:
    dp[i] = 0

print(dp[-1])
Problem p03038 (python)

Fixed submission:
from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))

d = defaultdict(int)
for i in range(N):
    d[A[i]] += 1
for i in range(M):
    b, c = map(int, input().split())
    d[c] += b
    

key = sorted(list(d.keys()))

num = N
i = 0
S = 0
while num > 0:
    i -= 1
    n = d[key[i]]
    num -= n
    S += key[i] * n
    
S += key[i] * num

print(S)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


import numpy as np
import bisect

N, M = map(int, input().split())
A = np.array(list(map(int, input().split())), dtype=np.int64)
A.sort()
for _ in range(M):
    b, c = map(int, input().split())
    index = bisect.bisect_left(A, c)
    edge = max(0, index - b)
    A[:edge] = A[index-edge:index]
    A[edge:index] = c

print(sum(A))
Problem p03774 (python)

Fixed submission:
import numpy as np

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

for (x, y) in A:
    d = np.array([])
    for (a, b) in B:
        d = np.append(d, abs(x-a) + abs(y-b))
    print(np.argmin(d) + 1)

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

N, M = map(int, input().split())
A = [map(int, input().split()) for _ in range(N)]
B = [map(int, input().split()) for _ in range(M)]

for (x, y) in A:
    d = np.array([])
    for q in B:
        print("q = ", q)
        print("*q=", *q,)
        a, b = q
        d = np.append(d, abs(x-a) + abs(y-b))
    print(np.argmin(d) + 1)
Problem p03835 (python)

Fixed submission:
K, S = map(int, input().split())
number = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - (x + y)
    if 0 <= z <= K:
      number += 1
print(number)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

num = 0
for x in range(K+1):
    tmp = min(S-x, K) - max(0, S-K-x)
    if tmp >= 0:
        num += tmp + 1


print(num)
Problem p02754 (python)

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

print(n//(a+b)*a+min(a,n%(a+b)))

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

print(n//(a+b)*a+mi,min(a,n%(a+b))
Problem p02859 (python)

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

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

Buggy submission (verdict: Runtime Error):
def hankei(x):
  print(x**2)
print(r)
Problem p02881 (python)

Fixed submission:
import math
n=int(input())
li=[]
for x in range(2,int(math.sqrt(n))+1):
    if n%x==0:
        y=n//x
        walk=y+x-2
        li.append(walk)
    
if li==[]:
    print(n-1)
else:
    print(min(li))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
li=[]
for x in range(2,int(math.sqrt(n))+1):
    if n%x==0:
        y=n//x
        walk=y+x-2
        li.append(walk)
    
if li==[]:
    print(n-1)
else:
    print(min(li))
import math
n=int(input())
li=[]
for x in range(2,int(math.sqrt(n))+1):
    if n%x==0:
        y=n//x
        walk=y+x-2
        li.append(walk)
    
if li==[]:
    print(n-1)
else:
    print(min(li))
Problem p02682 (python)

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

sum = 0
if A >= K:
    print(K)
    exit()
else:
    K = K - A
    sum += A

if B >= K:
    print(sum)
    exit()
else:
    K = K - B

print(sum - K)

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

A = [1] * A
B = [0] * B
C = [-1] * C

sum = A + B + C

count = 0
for i in range(K):
    count += sum[i]

print(count)