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

Fixed submission:
n = int(input()) 

import math
def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

if(is_prime(n)):
    print(n)
else:
    while(is_prime(n) == False):
        n = n + 1
        is_prime(n)
    print(n)

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

if(is_prime(n)):
    print(n)
else:
    while(is_prime(n) == False):
        n = n + 1
        is_prime(n)
    print(n)

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

if(is_prime(n)):
    print(n)
else:
    while(is_prime(n) == False):
        n = n + 1;
        is_prime(n)
    print(n)
Problem p02836 (python)

Fixed submission:
str1 = input()
str2 = list(str1)
n = (int(len(str1)/2))
count = 0
for i in range(1, n+1):
    if(str2[i-1]!=str2[-1*i]):
        count = count+1        
print(count)

Buggy submission (verdict: Runtime Error):
str1 = input()
str2 = list(str1)
n = (int(len(str1)/2))
count = 0
for i in range(1, n+1):
    if(str2[i-1]!=str2[-1*i]):
    count = count+1        
print(count)
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())

list = [1,2,3]

list.remove(a)
list.remove(b)

print(list[0])

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


list = [1,2,3]

list.pop(a)
list.pop(b)

print(list[0])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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


truelist = [1,2,3]

truelist.pop(a)
truelist.pop(b)

print(truelist[0])
Problem p02835 (python)

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

result = a + b + c

if result >= 22:
    print('bust')
else:
    print('win')

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

result = a + b + c

if result => 22:
    print('bust')
else:
    print('win')
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())

if a==1 :
    if b==2:
        print(3)
    elif b==3:
        print(2)
elif a ==2 :
    if b==1:
        print(3)
    elif b==3:
        print(1)
else:
    if b==1:
        print(2)
    elif b==2:
        print(1)

Buggy submission (verdict: Runtime Error):
if a==1 :
    if b==2:
        print(3)
    elif b==3:
        print(2)
elif a ==2 :
    if b==1:
        print(3)
    elif b==3:
        print(1)
else:
    if b==1:
        print(2)
    elif b==2:
        print(1)
Problem p02831 (python)

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

x = a * b;

if a<b:
    tmp = a
    a = b
    b = tmp

r = a % b
while r!=0:
    a = b
    b = r
    r = a % b
 
print(int(x/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 p02820 (python)

Fixed submission:
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
l = {'r':'p','s':'r','p':'s'}
L = ['' for i in range(n)]
tmp = ['r','s','p']
for i in range(n):
    x = t[i]
    if (i - k) >= 0 and L[i-k] == l[x]:
        tmp.remove(L[i-k])
        if (i + k) <= (n-1) and l[t[i+k]] != l[x]:
            tmp.remove(l[t[i+k]])
        L[i] = tmp[0]
        tmp = ['r','s','p']
    else:
        L[i] = l[x]

score = 0
sc = {'r':r,'s':s,'p':p}
for i in range(n):
    if l[t[i]] == L[i]:
        score += sc[L[i]]

print(score)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
l = {'r':'p','s':'r','p':'s'}
L = ['' for i in range(n)]
tmp = ['r','s','p']
for i in range(n):
    x = t[i]
    if (i - k) >= 0 and L[i-k] == l[x]:
        tmp.remove(L[i-k])
        if (i + k) <= n and l[t[i+k]] != l[x]:
            tmp.remove(l[t[i+k]])
        L[i] = tmp[0]
        tmp = ['r','s','p']
    else:
        L[i] = l[x]

score = 0
sc = {'r':r,'s':s,'p':p}
for i in range(n):
    if l[t[i]] == L[i]:
        score += sc[L[i]]

print(score)
Problem p02831 (python)

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

c = fractions.gcd(a,b)
ans = int(a*b/c)
print(ans)

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

c = math.gcd(a,b)
ans = int(a*b/c)
print(ans)

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

c = math.gcd(a,b)
ans = int(a*b/c)
print(ans)
Problem p02835 (python)

Fixed submission:
a,b,c = map(int,input().split())
if a+b+c >= 22:
    print('bust')
else:
    print('win')

Buggy submission (verdict: Runtime Error):
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a,b,c = map(int,input().split())\n",
    "if a+b+c >= 22:\n",
    "    print('bust')\n",
    "else:\n",
    "    print('win')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
Problem p02847 (python)

Fixed submission:
s = input()

m = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1}

print(m[s])

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

ans = 0
for i in range(1,10):
 n = (x - b*i)//a
 if 10**(i-1) <= n < 10**i:
  ans = n
 elif n>=10**i:
  ans=10**i-1
  
if x>=a*10**9+b*10:
 ans=10**9
print(ans)

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

ans = 0
for i in range(1,10):
　　n = (x - b*i)//a
　　if 10**(i-1) <= n < 10**i:
　　　　ans = n
　　elif n >= 10**i:
　　　  ans = 10**i - 1
  
if x >= a*10**9+b*10:
       ans =10**9
print(ans)
Problem p02915 (python)

Fixed submission:
n = int(input())
print(n**3)

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

l = 0
r = 0
count = 0
hcount = 0
score = 0
def sccount(s):
    l = 0
    r = 0
    count = 0
    score = 0
    for i in range(n):
        if s[i] == 'R':
            if r == 1:
                score += 1
            l = 0
            r = 1
        else:
            if l == 1:
                score += 1
            l = 1
            r = 0
    l = 0
    r = 0
    return score

if s[0] == 'L':
    for i in range(n):
        if s[i] == 'L':
            if r == 1 :
                count += 1
            l = 1
            r = 0
        else:
            l = 0
            r = 1
    if s[-1] == 'R':
        hcount = 1
else:
    for i in range(n):
        if s[i] == 'R':
            if l == 1 :
                count += 1
            l = 0
            r = 1
        else:
            l = 1
            r = 0
    if s[-1] == 'L':
        hcount = 1
score = sccount(s)
if count >= k:
    ans = score + k*2
elif count < k:
    ans = score + count*2 + hcount
print(ans)
# print(score,count,hcount)
Problem p03038 (python)

Fixed submission:
n,m = map(int,input().split())
alis = [int(i) for i in input().split()]
bclis = []
for i in range(m):
    bclis.append(list(map(int,input().split())))
bclis.sort(key=lambda x:x[1],reverse=True)
alis.sort()
def ans(bclis,alis):
    count=0
    for i in bclis:
        for j in range(i[0]):
            if alis[count] >= i[1]:
                return alis
            else :
                alis[count] = i[1]
            count += 1
            if count == n:
                return alis
    return alis
# print(alis)
# print(bclis)
# print(ans(bclis,alis))
print(sum(ans(bclis,alis)))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = [int(i) for i in input().split()]
bclis = []
for i in range(m):
    bclis.append(list(map(int,input().split())))
bclis.sort(key=lambda x:x[1],reverse=True)
alis.sort()
def ans(bclis,alis):
    count=0
    for i in bclis:
        for j in range(i[0]):
            if alis[count] >= i[1]:
                return alis
            else :
                alis[count] = i[1]
            count += 1
    return alis
# print(alis)
# print(bclis)
# print(ans(bclis,alis))
print(sum(ans(bclis,alis)))
Problem p03013 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
n,m = list(map(int, input().split()))
s = [0 for i in range(n+1)]
t = [-1 for i in range(n+1)]
for i in range(m):
    x = int(input())
    s[x] = 1

def dx(r):
    global t
    if t[r]>=0:
        return t[r]
    x=0
    y=0
    #print(i)
    if s[r+1]==0 and r==n-2:
        return 2
    if s[r+1]==1 and r==n-2:
        return 1
    if r==n-1:
        return 1
    if r==n:
        return 0
    if s[r+1] == 0:
        x=dx(r+1)
    if s[r+2] == 0:
        y=dx(r+2)
    #print([i,x,y])
    t[r]=(x+y)%1000000007
    return (x+y)%1000000007

ans=dx(0)

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = list(map(int, input().split()))
s = [0 for i in range(n+1)]
t = [-1 for i in range(n+1)]
for i in range(m):
    x = int(input())
    s[x] = 1

def dx(r):
    global t
    if t[r]>=0:
        return t[r]
    x=0
    y=0
    #print(i)
    if s[r+1]==0 and r==n-2:
        return 2
    if s[r+1]==1 and r==n-2:
        return 1
    if r==n-1:
        return 1
    if r==n:
        return 0
    if s[r+1] == 0:
        x=dx(r+1)
    if s[r+2] == 0:
        y=dx(r+2)
    #print([i,x,y])
    t[r]=(x+y)%1000000007
    return (x+y)%1000000007

ans=dx(0)

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = list(map(int, input().split()))
s = [0 for i in range(n+1)]
t = [-1 for i in range(n+1)]
for i in range(m):
    x = int(input())
    s[x] = 1

def dx(r):
    global t
    if t[r]>=0:
        return t[r]
    x=0
    y=0
    #print(i)
    if r==n-2:
        return 2
    if r==n-1:
        return 1
    if r==n:
        return 0
    if s[r+1] == 0:
        x=dx(r+1)
    if s[r+2] == 0:
        y=dx(r+2)
    #print([i,x,y])
    t[r]=(x+y)%1000000007
    return (x+y)%1000000007

ans=dx(0)

print(ans)
Problem p02759 (python)

Fixed submission:
N = int(input())
print(int(N/2)+N%2)

Buggy submission (verdict: Runtime Error):
x = input()
print(int(x/2)+1)

Buggy submission (verdict: Runtime Error):
x = input()
print(int(x/2))
Problem p03631 (python)

Fixed submission:
a=(input())

if a[0]==a[2]:
    print("Yes")
else:
    print("No")

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

print("Yes" if a[0]==a[2] else "No")
Problem p02831 (python)

Fixed submission:
n=list(map(int,input().split(' ')))
import fractions
ans=(n[0]*n[1]) // fractions.gcd(n[0],n[1])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=list(map(int,input().split(' ')))
ans=(n[0]*n[1])//math.gcd(n[0],n[1])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=list(map(int,input().split()))
ans=(n[0]*n[1])//math.gcd(n[0],n[1])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=list(map(int,input().split(' ')))
ans=(n[0]*n[1])//math.gcd(n[0],n[1])
print(ans)
Problem p02771 (python)

Fixed submission:
A, B, C = map(int, input().split())
if A == B and A == C:
    print("No")
elif A == B or A == C or B == C:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import itertools
N, K = map(int, input().split())
pair = itertools.combinations(list(map(int, input().split())), 2)
res = [i[0] * i[1] for i in pair]
res.sort()
if len(res) != 0:
    print(res[K-1])

Buggy submission (verdict: Runtime Error):
import itertools
N, K = map(int, input().split())
pair = itertools.combinations(map(int, input().split()), 2)
res = [i[0] * i[1] for i in pair]
res.sort()
if len(res) != 0:
    print(res[K-1])

Buggy submission (verdict: Runtime Error):
import itertools
N, K = map(int, input().split())
input_n = list(map(int, input().split()))
pair = itertools.combinations(input_n, 2)
res = [i[0] * i[1] for i in pair]
res.sort()
print(res[K-1])

Buggy submission (verdict: Runtime Error):
from collections import  Counter
N = int(input())
votes = [input() for i in range(N)]
count = dict(Counter(votes))
max_vote = max(count.values())
res = []
for i in count:
    if count[i] == max_vote:
        res.append(i)
        continue
res.sort()
for i in res:
    print(i)
Problem p03127 (python)

Fixed submission:
import functools

def gcd(num1, num2):
    r = num1 % num2
    while (r > 0):
        num1 = num2
        num2 = r
        r = num1 % num2
    return num2

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

max_koyaku_num = functools.reduce(gcd, a)

print(max_koyaku_num)

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

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

max_koyaku_num = functools.reduce(math.gcd, a)

print(max_koyaku_num)

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

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

max_koyaku_num = functools.reduce(math.gcd, a)  #最大公約数って英語でなんて言うん？

print(max_koyaku_num)
Problem p02754 (python)

Fixed submission:
N,A,B = map(int,input().split())
set_cnt=N//(A+B)
amari=N%(A+B)
if amari > A:
    amari_A = A
else:
    amari_A = amari
print(A*set_cnt+amari_A)

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
ball_str=""
for i in range(10**100):
    if len(ball_str)<=N:
        ball_str+="b"*A+"r"*B
    else:
        break
print(ball_str[:N].count("b"))
Problem p02879 (python)

Fixed submission:
A,B = input().split()
A = int(A)
B = int(B)
if A > 9 or B > 9:
  print(-1)
else:
  print(A*B)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A > 9 or B > 9:
  print(-1)
else:
  print(A*B)
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
value_list = input().split()
value_list.sort()
i = 0

for i in range(N):
	if i == 0:
		new_value = int(value_list[i])
	else:
		new_value = (new_value + int(value_list[i])) / 2
    i += 1

print(new_value)

Buggy submission (verdict: Runtime Error):
N = int(input())
value_list = input().split()
value_list.sort()
i = 0
#value_list.reverse()
#print(value_list)
for i in range(N):
	if i == 0:
		new_value = int(value_list[i])
	else:
		new_value = (new_value + int(value_list[i])) / 2

print(new_value)
Problem p03207 (python)

Fixed submission:
N = int(input())
price_list = []
append = price_list.append
for i in range(N):
    p = int(input())
    append(p)
price_list.sort(reverse=True)
price_list[0] = price_list[0] // 2
print(sum(price_list))

Buggy submission (verdict: Runtime Error):
N = int(input())
price_list = []
append = pricelist.append
for i in range(N):
	p = int(input)
    append(p)
pricelist.sort(reverse=True)
pricelist[0] = pricelist[0] / 2
print(sum(pricelist))
Problem p02785 (python)

Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
del h[0:k]


print(sum(h))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
for i in range(k):
  h.pop(0)


print(sum(h))
Problem p02835 (python)

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

if a+b+c>=22:
  print('bust')
else:
  print('win')

Buggy submission (verdict: Runtime Error):
a = int(input())
b=[]
b=list(map(int,input().split()))
sum1=0
num = []
for i in range(a-1):
  for j in range(i+1,a):
    num.append(b[i]^b[j])
sum1=sum(num)
 
if sum1>=1000000007:
  sum1=sum1%1000000007
print(sum1)
Problem p02785 (python)

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

N, K = map(int, input().split())
H = list(map(int, input().split()))

if K >= N:
    print(0)
else:
    H.sort(reverse=True)
    print(sum(H[K:]))

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

N, K = map(int, input().split())
H = list(map(int, input().split()))

if K >= N:
    print(0)
else:
    H.sort(reverse=True)
    for i in range(0, K):
        H.pop(i)

    print(sum(H))

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

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]

if K >= N:
    print(0)
else:
    H.sort(reverse=True)
    for i in range(0, K):
        H.pop(i)

    print(sum(H))

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

if K >= N:
    print(0)
else:
    H.sort(reverse=True)
    for i in range(0, K):
        H.pop(i)
    
    print(sum(H))
Problem p02897 (python)

Fixed submission:
n=int(input())
odd=0
for i in range(1, n+1):
  if i%2!=0:
    odd+=1
 
print(odd/n)

Buggy submission (verdict: Runtime Error):
n=int(input())
for i in range(n):
  if i%2!=0:
    odd+=1
 
print(odd/n)
Problem p03137 (python)

Fixed submission:
from collections import deque
N, M = map(int, input().split())
X = list(map(int, input().split()))
sortX = sorted(X)
dist = []
if N-M>=0:
    print(0)
else:
    for i in range(M-1):
        dist.append(sortX[i + 1] - sortX[i])
    dist.sort()
    print(sum(dist[:M-N]))

Buggy submission (verdict: Runtime Error):
from collections import deque
N, M = map(int, input().split())
X = list(map(int, input().split()))
sortX = sorted(X)
dist = []
if M == 1:
    print(0)
else:
    for i in range(M-1):
        dist.append(sortX[i + 1] - sortX[i])
    for i in range(N - 1):
        dist.pop(dist.index(max(dist)))
    print(sum(dist))
Problem p03317 (python)

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

if N == K:
    print(1)
else:
    N = N - K
    count = 1
    while N>0:
        N -= K - 1
        count += 1
    print(count)

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

def minus(N, K,count):
    if N>K:
        N=N - (K - 1)
        count += 1
        return minus(N, K, count)
        
    elif N <= K:
        count += 1
        return count

print(minus(N,K,0))
Problem p02773 (python)

Fixed submission:
import collections
def resolve_c():
    n = input()
    s_l = [input() for i in range(int(n))]
    c = collections.Counter(s_l)
    values, counts = zip(*c.most_common())
    results = sorted(list(values[:collections.Counter(counts)[max(counts)]]))
    fin = [print(r) for r in results]
resolve_c()

Buggy submission (verdict: Runtime Error):
import collections
def resolve_c():
    n = input()
    s_l = [input() for i in range(int(n))]
    c = collections.Counter(s_l)
    for k, v in c.items():
        if v == c.most_common()[0][1]:
            results.append(v)
        else:
            break
    results = sorted(results)
    for r in results:
        print(r)
resolve_c()
Problem p02819 (python)

Fixed submission:
x = int(input())
b_flg = True
try_n = x - 1
roop_c = 0
if x == 2:
    print(x)
else:
    while b_flg:
        try_n += 1
        for n in range(2, try_n):
            roop_c += 1
            if try_n % n == 0: # 素数でないことが確定した場合
                break
            else:
                if roop_c == try_n - 2:
                    b_flg = False
    print(try_n)

Buggy submission (verdict: Runtime Error):
x = int(input())
try_n = x - 1
b_flg = True
roop_c = 0
while b_flg:
    try_n += 1
    for n in range(2, try_n):
        roop_c += 1
        if try_b == 2: # 2の場合は特別
            b_flg =False
            break
        if try_n % n == 0: # 素数でないことが確定した場合
            break
        else:
            if roop_c == try_n - 2:
                b_flg = False
print(try_n)

Buggy submission (verdict: Runtime Error):
x = int(input())
try_n = x - 1
b_flg = True
roop_c = 0
while b_flg:
    try_n += 1
    for n in range(2, try_n):
        roop_c += 1
        if try_b == 2: # 2の場合は特別
            b_flg =False
            break
        if try_n % n == 0: # 素数でないことが確定した場合
            break
        else:
            if roop_c == try_n - 2:
                b_flg = False
print(try_n)
Problem p02831 (python)

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

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

Fixed submission:
# coding: utf-8
# Your code here!

N,A=map(int,input().split())
print(N-A+1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

N,A=map(int,input()split())
print(N-A+1)
Problem p03013 (python)

Fixed submission:
n, m = list(map(int, input().split()))
a = []
for i in range(m):
	a.append(int(input()))
a.sort()
f0 = 1
if len(a) > 0 and a[0] == 1:
	f1 = 0
else:
	f1 = 1
k = 0
for i in range(2, n + 1):
	while k < len(a) and a[k] < i:
		k += 1
	if k == len(a) or a[k] != i:
		f = (f0 + f1) % 1000000007
	else:
		f = 0
	f0 = f1
	f1 = f
	if f0 == f1 == 0:
		break
print(f1)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a = []
for i in range(m):
	a.append(int(input()))
a.sort()
f0 = 1
if a[0] == 1:
	f1 = 0
else:
	f1 = 1
k = 0
for i in range(2, n + 1):
	while k < len(a) and a[k] < i:
		k += 1
	if k == len(a) or a[k] != i:
		f = (f0 + f1) % 1000000007
	else:
		f = 0
	f0 = f1
	f1 = f
	if f0 == f1 == 0:
		break
print(f1)
Problem p02879 (python)

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

Buggy submission (verdict: Runtime Error):
N=int(input())
n=N-1
for i in range(1,int(N**(1/2))+1):
    if N%i==0:
      n=min(n,i+N/i-2)
print(int(n))
Problem p03201 (python)

Fixed submission:
import math
N = int(input())
A = sorted([int(_) for _ in input().split()], reverse=True)
dp = {}
for a in A:
    dp[a] = dp.get(a, 0) + 1
ans = 0
for a in A:
    if dp[a]:
        dp[a] -= 1
        if dp.get(2**int(math.log2(a) + 1) - a, 0) > 0:
            dp[2**int(math.log2(a) + 1) - a] -= 1
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(N);
  for(int &a:A)cin>>a;
  sort(A.begin(),A.end(),greater<int>());
  map<int,int>m;
  int ans=0;
  for(int a:A){
    if(m.count(a)&&m[a]>0)m[a]--,ans++;
    else m[(1<<(32-__builtin_clz(a)))-a]++;
  }
  cout<<ans<<endl;
}
Problem p02754 (python)

Fixed submission:
n,a,b = list(map(int,input().split()))
if(a != 0):
    kurikaeshi = n // (a + b)
    mod = n % (a + b)
    ans = a*kurikaeshi
    if(mod - a > 0):
        ans += a
    else:
        ans += mod
if(a == 0):
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int,input().split()))
kurikaeshi = n // (a + b)
amari = n - (kurikaeshi * (a+b))
ball_list = []
ans = 0
blue = 'b' * a
red = 'r' * b
if(amari - len(blue) < 0):
    ans = 0
if(amari - len(blue) == 0):
    ans = len(blue)
else:
    ans = len(blue) - amari
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int,input().split()))
kurikaeshi = n // (a + b)
amari = n - (kurikaeshi * (a+b))
ball_list = []
ans = 0
blue = 'b' * a
red = 'r' * b
if(amari - len(blue) < 0):
    ans = 0
else:
    ans = len(blue) - amari
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int,input().split()))
kurikaeshi = n // (a + b)
ans = kurikaeshi * a
amari = n - (kurikaeshi * (a+b))
ball_list = []
ans = 0
blue = 'b' * a
red = 'r' * b
for i in range(1,kurikaeshi+2):
    ball_list.append(blue)
    ball_list.append(red)
for l in range(0,a+1):
    if(list(ball_list)[amari] == 'b'):
        ans += 1
print(ans)