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

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a.sort()
if N%2==0:
  print(a[int(N/2)]-a[int(N/2-1)])
else:
  print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
if N%2==0:
  print(a[N/2]-a[N/2-1])
else:
  print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
ans = 0
if N%2==0:
  print(a[N]-a[N-1])
else:
  print(0)
Problem p02990 (python)

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

from operator import mul
from functools import reduce

def cmb(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

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    if n-k+1 < i :
      print("0")
    else:
      out(cmb(k-1,i-1)*cmb(n-k+1,i))

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

from operator import mul
from functools import reduce

def cmb(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

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    
      out(cmb(k-1,i-1)*cmb(n-k+1,i))

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

from operator import mul
from functools import reduce

def cmb(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

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    if n-k+1 < i :
       return print('0')
    else out(cmb(k-1,i-1)*cmb(n-k+1,i))

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

from operator import mul
from functools import reduce

def cmb(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

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    if n-k+1 < 1 :
       return 0
    else out(cmb(k-1,i-1)*cmb(n-k+1,i))
Problem p02785 (python)

Fixed submission:
n,k=map(int,input().split())
h=sorted(list(map(int,input().split())))
ans=0
if k>=n:
  print(0)
else:
  for i in range(n-k):
    ans+=h[i]
  print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=sorted(list(map(int,input().split())))
ans=0
for i in range(k):
  ans+=h[i]
print(ans)
Problem p02819 (python)

Fixed submission:
x=int(input())
import math

def is_prime(n):
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
for i in range(x,10**6):
  if is_prime(i)==True:
    print(i)
    exit()

Buggy submission (verdict: Runtime Error):
from sympy import nextprime
x=int(input())
print(nextprime(x))
Problem p02912 (python)

Fixed submission:
def main():
  import heapq
  n,m = map(int,input().split())
  a =sorted(list(map(lambda x: int(x)*(-1),input().split())))
  heapq.heapify(a)
  for _ in range(m):
    x=heapq.heappop(a)/2
    heapq.heappush(a,x) 
  print(int(sum((-1)*i//1 for i in a)))
if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = a.sort()
for i in range(m):
  a[-1] = a[-1]*0.5
  a = a.sort()
sum( i//1 for i in a)
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
a,b = [],[]
for i in range(n-1):
    a1,b1=[int(i) for i in input().split()]
    a.append(a1)
    b.append(b1)
p,x = [],[]
for j in range(q):
    p1,x1=[int(j) for j in input().split()]
    p.append(p1)
    x.append(x1)
    
z = [0]*n
for k in range(q):
  z[p[k]-1] = z[p[k]-1] + x[k]
for l in range(n-1):
  z[b[l]-1] = z[b[l]-1] + z[a[l]-1]    
print(*z)
Problem p02959 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.append(0)
count = 0
for i in range(n+1):
  if a[i] >= b[i]:
    count += b[i]
  else:
    if a[i] + a[i+1] > b[i]:
      count += b[i]
      a[i+1] = a[i+1] - b[i] + a[i]
    else:
      count += a[i] + a[i+1]
      a[i+1] = 0
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.append(0)
count = 0
for i in range(n+1):
  if a[i] >= b[i]:
    count += b[i]
  else:
    count += b[i]
    a[i+1] = a[i+1] - b[i] + a[i]
print(count)
Problem p02990 (python)

Fixed submission:
n,k=map(int,input().split())
mod=pow(10,9)+7

fact,inv,factinv=[0]*(n+1),[0]*(n+1),[0]*(n+1)
fact[0],fact[1],inv[1]=1,1,1
factinv[0],factinv[1]=1,1

for i in range(2,n+1):
  fact[i]=(fact[i-1]*i)%mod
  inv[i]=mod-(inv[mod%i]*(mod//i))%mod               
  factinv[i]=(factinv[i-1]*inv[i])%mod      
    
def comb(n,r,mod):
  if r<0 or n<r:
    return 0
  r=r if r<=n-r else n-r
  return fact[n]*factinv[r]*factinv[n-r]%mod
  
for i in range(1,k+1):
  ans=comb(n-k+1,i,mod)*comb(k-1,i-1,mod)%mod
  print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
n,mod=n-k+1,pow(10,9)+7

fact,inv,factinv=[0]*(n+1),[0]*(n+1),[0]*(n+1)
fact[0],fact[1]=1,1
inv[1]=1
factinv[0],factinv[1]=1,1

for i in range(2,n+1):
  fact[i]=(fact[i-1]*i)%mod
  inv[i]=mod-(inv[mod%i]*(mod//i))%mod               
  factinv[i]=(factinv[i-1]*inv[i])%mod      
    
def comb(n,r,mod):
  r = min(r,n-r)
  return fact[n] * factinv[r] * factinv[n-r] % mod
  
for i in range(1,k+1):
  ans=comb(n,i,mod)*comb(k-1,i-1,mod)%mod
  print(ans)
Problem p03011 (python)

Fixed submission:
import sys
input = sys.stdin.readline
p,q,r = map(int,input().split())
print(min(p+q,q+r,r+p))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
p,q,r = map(int,input().split())
print(min[p+q,q+r,r+p])
Problem p03013 (python)

Fixed submission:
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  mod=pow(10,9)+7
  ans=[1]*(n+1)
  for _ in [0]*m:
    ans[int(input())]=0
  for i in range(n+1):
    ans[i]=ans[i] if ans[i]==0 or i<2 else (ans[i-1]+ans[i-2])%mod
  print(ans[-1])
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  mod=pow(10,9)+7
  ans=[1]*(n+1)
  for _ in [0]*m:
    ans[int(input())]=0
  ans[2]=ans[1]+1 if ans[2]!=0 else 0
  for i in range(3,n+1):
    if ans[i]>0:
      ans[i]=(ans[i-1]+ans[i-2])%mod
  print(ans[-1])
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  a=[int(input()) for _ in [0]*m]
  mod=pow(10,9)+7
  ans=[0]*n
  ans[0]=1
  for i in range(n):
    if a.count(i+1)==1:
      ans[i]=0
    else:
      if i==1:
        ans[i]=ans[0]+1
      else:
        ans[i]=(ans[i-1]%mod+ans[i-2]%mod)%mod
  print(ans[-1])
if __name__ == '__main__':
    main()
Problem p03073 (python)

Fixed submission:
def main():
  s=list(input())
  count1,count2,l=0,0,len(s)
  for i in range(l):
    count1=count1+1 if (i%2==0 and int(s[i])==1) or (i%2==1 and int(s[i])==0) else count1
    count2=count2+1 if (i%2==1 and int(s[i])==1) or (i%2==0 and int(s[i])==0) else count2
  print(min(count1,count2))

if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  import sys
  input = sys.stdin.readline
  s=list(input())
  count1,count2,l=0,0,len(s)
  for i in range(l):
    count1=count1+1 if (i%2==0 and int(s[i])==1) or (i%2==1 and int(s[i])==0) else count1
    count2=count2+1 if (i%2==1 and int(s[i])==1) or (i%2==0 and int(s[i])==0) else count2
  print(min(count1,count2))

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

Fixed submission:
A, B = input().split()
   
A = int(A)
B = int(float(B) * 100 + .5)
   
A *= B
print(A // 100)

Buggy submission (verdict: Runtime Error):
import math

a, b = map(float, input().split())
if a = 0 or b = 0:
    print(0)
else:
    print(int(a*b))
Problem p02725 (python)

Fixed submission:
#!/usr/bin/env python3
 
K, N = map(int, input().split())
A = list(map(int, input().split()))
A += [A[0] + K]
max_gap = max(y - x for x, y in zip(A, A[1:]))
print(K - max_gap)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
 
k, n = map(int, input().split())
A = list(map(int, input().split()))
A += [A[0] + K]
max_gap = max(y - x for x, y in zip(A, A[1:]))
print(K - max_gap)
Problem p02771 (python)

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

if a==b==c:
    print('No')
elif a==b or b==c or c==a:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>

using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    if(a == b == c){
        puts("No");
    }else{
        puts("Yes");
    }

}
Problem p02831 (python)

Fixed submission:
from fractions import gcd

A,B = map(int,input().split())
answer = A * B // gcd(A,B)
print(answer)

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())
ans = A * B // math.gcd(A,B)

print(ans)
Problem p02897 (python)

Fixed submission:
N = int(input())

odd = (N+1)//2
print(odd/N)

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

if N % 2 != 0:
  print('0.6000000000')
else:
  if N == 1:
    print('1.0000000000')
    break
  else:
  	print('0.5000000000')
Problem p03036 (python)

Fixed submission:
r, d, x = map(int,input().split())
for _ in range(10):
    x = x * r - d
    print(x)

Buggy submission (verdict: Runtime Error):
r, d, x = map(int,input().split())
print(x = x * r - d  for _ in range(10))

Buggy submission (verdict: Runtime Error):
r, d, x = map(int,input().split())
print((x = x * r - k ) for _ in range(10))
Problem p03042 (python)

Fixed submission:
s = int(input())
l = s / 100
r = s % 100

if(1 <= l and l <= 12):
    if(1 <= r and r <= 12):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if(1 <= r and r <= 12):
        print('YYMM')
    else:
        print('NA')

Buggy submission (verdict: Runtime Error):
s = int(input())
l = s / 100
r = s % 100

if(1 <= l && l <= 12):
    if(1 <= r && r <= 12):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if(1 <= r && r <= 12):
        print('YYMM')
    else:
        print('NA')

Buggy submission (verdict: Runtime Error):
s = int(input())
l = s / 100
r = s % 100

if(1 <= l && <= 12):
    if(1 <= r && r <= 12):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if(1 <= r && r <= 12):
        print('YYMM')
    else:
        print('NA')

Buggy submission (verdict: Runtime Error):
s = int(input())
l = s / 100
r = s % 100

if(1 <= l && <= 12):
    if(1 <= r && r <= 12):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if(1 <= r && r <= 12):
        print('YYMM')
    else:
      print('NA')
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()))

    SUMA = [0]
    for a in A:
        if SUMA[-1] + a > K: break
        SUMA.append(SUMA[-1] + a)
    SUMB = [0]
    for b in B:
        if SUMB[-1] + b > K: break
        SUMB.append(SUMB[-1] + b)

    if len(SUMA) == 1:
        ans = len(SUMB) - 1
    elif len(SUMB) == 1:
        ans = len(SUMA) - 1
    else:
        ans = 0
        i = len(SUMA)
        j = 1
        while i:
            i -= 1
            while SUMA[i] + SUMB[j] <= K:
                j += 1
                if j == len(SUMB): break
            j -= 1
            ans = max(ans, i + j)

    print(ans)


if __name__ == '__main__':
    main()

exit()

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

    DP = [[0] * (M + 1) for _ in range(N + 1)]

    for i in range(N):
        DP[i + 1][0] = DP[i][0] + A[i]
        if DP[i + 1][0] > K:
            DP[i + 1][0] = 0
            break
    for j in range(M):
        DP[0][j + 1] = DP[0][j] + B[j]
        if DP[0][j + 1] > K:
            DP[0][j + 1] = 0
            break

    for i in range(N):
        if DP[i + 1][0] == 0: break
        for j in range(M):
            if DP[i + 1][j] == 0: break
            DP[i + 1][j + 1] = DP[i + 1][j] + B[j]
            if DP[i + 1][j + 1] > K:
                DP[i + 1][j + 1] = 0
                break

    ans = 0
    for i in range(N + 1):
        MX = max(DP[i])
        if MX == 0: break
        j = DP[i].index(MX)
        ans = max(ans, i + j)

    print(ans)


if __name__ == '__main__':
    main()

exit()
Problem p02831 (python)

Fixed submission:
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

A, B = map(int, input().split())
def okasi(x, y):
    return (x * y) // gcd(x, y)

print(okasi(A,B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
def okasi(x, y):
    return (x * y) // math.gcd(x, y)

print(okasi(A,B))
Problem p02688 (python)

Fixed submission:
N,K = map(int,input().split(" "))
trickSum = 0
result = list()
for i in range(K):
    d = input()
    result = result + (list(map(int, input().split(" "))))
print(N - len(set(result)))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split(" "))
trickSum = 0
result = list()
while True :
    d = input()
    if d == "":
        break
    result = result + (list(map(int, input().split(" "))))
print(N - len(set(result)))
Problem p02771 (python)

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

if (a!=b and a!=c and b!=c) or (a==b and a==c):
  print("No")
else :
  print("Yes")

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

if (a!=b && a!=c && b!=c) || (a==b && a==c):
  print("No")
else :
  print("Yes")
Problem p02682 (python)

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

if(k<=a):
    print(k)
elif(k>a and k<=a+b):
    print(a)
else:
    print(a-(k-(a+b)))

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
k = input()

if(k<a):
    print(k)
elif(k>a and k<a+b):
    print(a)
elif(k>a+b and k<a+b+c):
    print(a-(k-(a+b)))
Problem p02711 (python)

Fixed submission:
N=input()
n=list(N)
x= '7' in n
if x is True:
  print("Yes")
else:
  print("No")

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

if N in 7:
  print("yes")
else:
  print("no")

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

if N in 7:
  print("yes")
else:
  print("no")
Problem p02629 (python)

Fixed submission:
num = int(input())
k=0
ans=[]
while k<1:
    if num<=26:
        ans.append((chr(96+num)))
        k=1
    elif num%26==0:
        num=(num//26-1)
        ans.append((chr(96+26)))
    else:
        ans.append((chr(96+num%26)))
        num=(num//26)

for i in range(len(ans)-1,-1,-1):
    if i ==0:
        print(ans[i])
    else:
        print(ans[i], end="")

Buggy submission (verdict: Runtime Error):

 k=0
ans=[]
while k<1:
    if num<=26:
        ans.append((chr(96+num)))
        k=1
    elif num%26==0:
        num=(num//26-1)
        ans.append((chr(96+26)))
    else:
        ans.append((chr(96+num%26)))
        num=(num//26)

for i in range(len(ans)-1,-1,-1):
    if i ==0:
        print(ans[i])
    else:
        print(ans[i], end="")
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B = map(int, input().split())
mul = 0
for i in range(A, B + 1):
    if i % K == 0:
        mul += 1
print("OK" if mul > 0 else "NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1):
  if(i%K==0):
    print("ok")
    break
  if(i==B and i%K !=0)
    print("NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
for i in range(A,B):
  if(i%K==0):
    print("ok")
    break
  if(i==B and i%K not ==0)
    print("NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
for i in range(A,B):
  if(i%K==0):
    print("ok")
  if(i==B and i%K!=0)
    print("NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
for i in range(A,B):
  if(i%K==0):
    print("ok")
  if(i==B and i%K not ==0)
    print("NG")
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):
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else : 
    print("No")

Buggy submission (verdict: Runtime Error):

S1=list(S)
if S1[2]==S1[3] and S1[4]==S1[5]:
    print("Yes")
else : 
    print("No")

Buggy submission (verdict: Runtime Error):

S1=list(S)
print(S1)
if S1[2]==S1[3] and S1[4]==S1[5]:
    print("Yes")
else : 
    print("No")
Problem p02753 (python)

Fixed submission:




s = input()

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

Buggy submission (verdict: Runtime Error):
S=map(str,input())
if "A" in S:
    print("Yes")
elif :
    S="AAA"
    print("No")
else :
    print("No")

Buggy submission (verdict: Runtime Error):
S=map(str,input())
if "A" in S:
    print("Yes")
elif :
    S="AAA"
else :
    print("No")
Problem p02819 (python)

Fixed submission:
def isPrime(x):
  if x < 2:
    return False
  for i in range(2,x):
    if x%i == 0:
      return False
  return True

num = int(input())

for i in range(num,100004):
  if isPrime(i):
    print(i)
    break

Buggy submission (verdict: Runtime Error):
X=int(input())
for i in range(2,X+2):
  if(X%i==0):
    X+=1
    continue
  else:
    if(i<X):
      continue
    else if(i<=X):
      print(X)

Buggy submission (verdict: Runtime Error):
X=int(input())
for i in range(2,X):
  if(X%i==0):
    X+=1
    break
  else:
    if(i<X):
      continue
    else
      print(X)

Buggy submission (verdict: Runtime Error):
Source Code 

Copy
Copy
X=int(input())
for i in range(2,X):
  if(X%i==0):
    X+=1
    break
  else :
  	print(X)

Buggy submission (verdict: Runtime Error):

X=int(input())
for i in range(2,X):
  if(X%i==0):
    X+=1
    break
  else :
  	print X

Buggy submission (verdict: Runtime Error):
X=int(input())
for i in rage(2,X):
  if(X%i==0):
    X+=1
    break
  else :
  	print X
Problem p02676 (python)

Fixed submission:
n=int(input())
s=input()
if len(s)>n:
  print(s[:n]+"...")
else:
  print(s)

Buggy submission (verdict: Runtime Error):
40
ferelibenterhominesidquodvoluntcredunt
Problem p02711 (python)

Fixed submission:
numbers = str(input())
ans = 0
for i in range(3):
	if numbers[i] == "7":
  		ans =1
if ans == 0:
	print("No")
else :
	print("Yes")

Buggy submission (verdict: Runtime Error):
numbers = str(input())
ans = 0
for(i = 0;i<3;i++){
	if(numbers[i] == "7")
  		ans =1
}
if(ans == 0){
	print("No")
}else{
	print("Yes")
}
Problem p02688 (python)

Fixed submission:
n, k = map(int, input().split())
s = set()
for _ in range(k):
    input()
    a = list(map(int, input().split()))
    for i in a:
        s.add(i)
print(n - len(s))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = set()
for _ in range(k):
    input()
    s.add(*list(map(int, input().split())))
print(n - len(s))
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):
from itertools import zip_longest
import sys

sys.maxsize
N, M, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
# iter_A = iter(A)
# iter_B = iter(B)
S = sum(A) + sum(B)
S_len = len(A) + len(B)
if K >= S:
    print(S_len)
else:
    ans = 0
    a_index = 0
    b_index = 0
    while K >= 0:
        for i in range(max(len(A), len(B))):
            if K < 0:
                break
            if A[a_index] <= B[b_index]:
                if K < 0:
                    break
                K -= A[a_index]
                a_index += 1
                ans += 1
            elif A[a_index] > B[b_index]:
                if K < 0:
                    break
                K -= B[b_index]
                b_index += 1
                ans += 1
    print(ans - 1)
Problem p02881 (python)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors


n = int(input())
a = make_divisors(n)
b = []

if len(a) % 2 == 0:
    for i in range(0,len(a),2):
        sum = a[i] + a[i+1]
        b.append(sum)
else:
    b.append(a[len(a)-1]*2)
    for i in range(0,len(a)-1,2):
        sum = a[i] + a[i+1]
        b.append(sum)

b.sort()
print(b[0]-2)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

n = int(input())
a = make_divisors(n)
b = []
for i in range(0,len(a),2):
    sum = a[i] + a[i+1]
    b.append(sum)
b.sort()
print(b[0]-2)
Problem p02990 (python)

Fixed submission:
n, k = map(int, input().split())
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, 3000):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for i in range(1,k+1):
    print((cmb(n-k+1,i,p)%p * cmb(k-1,i-1,p)%p))

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, 2001):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for i in range(1,k+1):
    print(cmb(n-k+1,i,p) * cmb(k-1,i-1,p))
Problem p02627 (python)

Fixed submission:
a = input()

s=int(ord(a))

if  65<=s and s<=90:
 print("A")
elif 97<=s and s<=122:
 print("a")

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

if  65<=s and s<=90:
 print("A")
elif 97<=s and s<=122:
 print("B")
Problem p02676 (python)

Fixed submission:
k = int(input())
s  = input()
if  len(s)<=k:
 print(s)
else:
 print(s[:k]+'...')

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

if  len(s)<=k:
 print(s)
else:
print(s[:k]+'...')