Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
if A ==0 :
    print(0)
elif B==0:
    print(N)
else:
    m = N % (A+B)
    n = N // (A+B)
    ans = A * n
    if m > A:
        print(ans+A)n
    else:
        print(ans+m)


Fixed submission:
N,A,B = map(int,input().split())
if A ==0 :
    print(0)
elif B==0:
    print(N)
else:
    m = N % (A+B)
    n = N // (A+B)
    ans = A * n
    if m > A:
        print(ans+A)
    else:
        print(ans+m)

Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
if A ==0 :
    print(0)
elif B==0:
    print(N)
else:
    n = N // (A+B)
    ans = A * n
    m = N % n
    if m > A:
        print(ans+A)
    else:
        print(ans+m)

Fixed submission:
N,A,B = map(int,input().split())
if A ==0 :
    print(0)
elif B==0:
    print(N)
else:
    m = N % (A+B)
    n = N // (A+B)
    ans = A * n
    if m > A:
        print(ans+A)
    else:
        print(ans+m)

Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
if A+B != 0:
    n = N // (A+B)
    ans = A * n
    m = N % n
    if m > A:
        print(ans+A)
    else:
        print(ans+m)
else:
    print(0)


Fixed submission:
N,A,B = map(int,input().split())
if A ==0 :
    print(0)
elif B==0:
    print(N)
else:
    m = N % (A+B)
    n = N // (A+B)
    ans = A * n
    if m > A:
        print(ans+A)
    else:
        print(ans+m)

Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
n = N // (A+B)
ans = A * n
m = N % n
if m > A:
    print(ans+A)
else:
    print(ans+m)


Fixed submission:
N,A,B = map(int,input().split())
if A ==0 :
    print(0)
elif B==0:
    print(N)
else:
    m = N % (A+B)
    n = N // (A+B)
    ans = A * n
    if m > A:
        print(ans+A)
    else:
        print(ans+m)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % 2 = 0:
  a = N / 2
else:
  a = (N+1)/2
print(a)

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

else:
  print(int((N+1)/2))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
S = [list(map(int,input().split())) for _ in range(M)]
ans = [0 for _ in range(N)]
check = [0 for _ in range(N)]
for i in range(M):
    s = S[i][0]
    c = S[i][1]
    if check[s-1] == 0:
        check[s-1] = 1
        ans[s-1] = c
    else:
        if ans[s-1] != c:
            e = 1
            break
if e == 1:
    print(-1)
elif e != 1:
    if ans[0] == 0:
        if N == 1:
            print(0)
        else:
            print(-1)
    else:
        d = 0
        for i in range(N):
            d += ans[i] * (10 ** (N-1-i))
            print(d)

Fixed submission:
N,M = map(int,input().split())
S = [list(map(int,input().split())) for _ in range(M)]
ans = [0 for _ in range(N)]
check = [0 for _ in range(N)]
e = 0
for i in range(M):
    s = S[i][0]
    c = S[i][1]
    if check[s-1] == 0:
        check[s-1] = 1
        ans[s-1] = c
    else:
        if ans[s-1] != c:
            e = 1
            break
if e == 1:
    print(-1)
else:
    if ans[0] == 0:
        if N == 1:
            print(0)
        else:
            if check[0] == 0:
                ans[0] = 1
                d = 0
                for i in range(N):
                    d += ans[i] * (10 ** (N-1-i))
                print(d)
            else:
                print(-1)

    else:
        d = 0
        for i in range(N):
            d += ans[i] * (10 ** (N-1-i))
        print(d)
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.buffer.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
N,R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(R+100*(10-K))
    



Fixed submission:
import sys
input=sys.stdin.buffer.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
N,R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(R+100*(10-N))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
c = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] %3 != 0 :
            if A[i] %5 != 0:
                c = 1
                break
if c == 0:
    print(APPROVED)
else:
    print(DENIED)
            
    



Fixed submission:
N = int(input())
A = list(map(int,input().split()))
c = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] %3 != 0 :
            if A[i] %5 != 0:
                c = 1
                break
if c == 0:
    print("APPROVED")
else:
    print("DENIED")
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
n = len(c)
max = c.most_common()[0][1]
d = 0
for j in range(n):
  if c.most_common()[j][1] == max:
    d += 1
  else:
    d = j
    break
ans = [c.most_common()[i][0] for i in range(d)]
ans.sort()
for i in range(d):
  print(ans[i])


Fixed submission:
from collections import defaultdict
N = int(input())
S = [input() for _ in range(N)]
dic = defaultdict(int)
for i in range(N):
        dic[S[i]] += 1
dic = dict(dic)
dic = sorted(dic.items(),key = lambda x:-x[1])
n = len(dic)
max = dic[0][1]
d = 0
for i in range(n):
  if dic[i][1] == max:
    d += 1
  else:
    d = i
    break
dic = sorted(dic[0:d],key = lambda x:x[0])
for i in range(len(dic)):
  print(dic[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
n = len(c)
max = c.most_common()[0][1]
ans = [c.most_common()[i][0] for i in range(n) if c.most_common()[i][1] == max]
ans.sort()
m = len(ans)
for i in range(m):
  print(ans[i])

Fixed submission:
from collections import defaultdict
N = int(input())
S = [input() for _ in range(N)]
dic = defaultdict(int)
for i in range(N):
        dic[S[i]] += 1
dic = dict(dic)
dic = sorted(dic.items(),key = lambda x:-x[1])
n = len(dic)
max = dic[0][1]
d = 0
for i in range(n):
  if dic[i][1] == max:
    d += 1
  else:
    d = i
    break
dic = sorted(dic[0:d],key = lambda x:x[0])
for i in range(len(dic)):
  print(dic[i][0])
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
p = list(map(int,input().split()))
max = 0
for i in range(N-K+1):
    s = 0
    for j in range(i,i+K):
        s += p[j]
    if s > max:
        max = s
print((max+K)/2)

Fixed submission:
N = int(input())
c = 0
A = list(map(int,input().split()))
ans = {}
for i in range(N):
    a = A[i]
    if a not in ans:
        ans[a] = 1
    else:
        c = 1
        break
if c == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
p = list(map(int,input().split()))
max = 0
for i in range(N-K+1):
    s = 0
    for j in range(i,i+K):
        s += p[j]
    if s > max:
        max = s
print((max+K)/2)


Fixed submission:
N,K = map(int,input().split())
p = list(map(int,input().split()))
S = [0]
s = 0
Max = 0
for i in range(N):
    s += (p[i]+1)/2
    S.append(s)
for i in range(N-K+1):
    s = S[i+K] - S[i]
    if s > Max:
        Max = s
print(Max)
Buggy python submission (verdict: Runtime Error):
H,A = map(int,input().split())
a = H // A
if  H % ! != 0:
	print(a+1)
else:
  print(a)

Fixed submission:
H,A = map(int,input().split())
a = H // A
if  H % A != 0:
	print(a+1)
else:
  print(a)
Buggy python submission (verdict: Runtime Error):
h,n=int(input().split())
a = list(map(int,input().split()))
for i in range(n):
  h -= a[i]
if h>0 :
  print("n↨o")
else:
  print("y↨es")
  

Fixed submission:
h,n=map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
  h -= a[i]
if h>0 :
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N,K= map(int,input().split())
H = list(map(int,input().split()))
H.sort()
s = 0
for i in range(K):
  s += H[i]
print(s+K) 


Fixed submission:
N,K= map(int,input().split())
H = list(map(int,input().split()))
H.sort()
s = 0
for i in range(N-K):
  s += H[i]
print(s)

Buggy python submission (verdict: Runtime Error):
N,K= map(int,input().split())
H = list(map(int,input().split()))
H = sort(H)
s = 0
for i in range(N-K):
  s += H[i]
print(s+K)
  


Fixed submission:
N,K= map(int,input().split())
H = list(map(int,input().split()))
H.sort()
s = 0
for i in range(N-K):
  s += H[i]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.buffer.readline
H,N = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]
dp = [10000000000]*(H+1)
dp[0] = 0
for i in range(1,H+1):
    for j in range(N):
        A = ab[j][0]
        B = ab[j][1]
        if i - A < 0:
            dp[i] = min(dp[i],dp[0]+B)
        else:
            dp[i] = min(dp[i],dp[i-A]+B)
print(dp[H])

Fixed submission:
import sys
input=sys.stdin.buffer.readline
H,N = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]
dp = [10000000000]*(H+1)
dp[0] = 0
for i in range(1,H+1):
    for j in range(N):
        A = ab[j][0]
        B = ab[j][1]
        if i - A < 0:
            dp[i] = min(dp[i],dp[0]+B)
        else:
            dp[i] = min(dp[i],dp[i-A]+B)
print(dp[H])
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a == b:
    print("Yes")
else :
    print("No")

Fixed submission:
a,b = map(int,input().split())
if a==b:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a == b:
    
    print("Yes")
else :
    print("No")

Fixed submission:
a,b = map(int,input().split())
if a==b:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a == b:
    
    print(Yes)
else :
    print(No)

Fixed submission:
a,b = map(int,input().split())
if a==b:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a == b:
    
    print(Yes)
else :
    print(No)

Fixed submission:
a,b = map(int,input().split())
if a==b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a<b:
  min = a
  max = b
else:
  min = b
  max = a
c =[min for i in range(max)]
l = "".join(c)
print(l)

Fixed submission:
a,b = map(int,input().split())
if a<b:
  min = a
  max = b
else:
  min = b
  max = a
c =[min for i in range(max)]
d = map(str,c)
l = "".join(d)
print(l)
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
t = [i for i in range(n)]
li = list(itertools.permutations(t))
p = list(map(int,input().split())
q = list(map(int,input().split())
p = tuple(p)
q = tuple(q)
pp = li.index(p)
qq = li.index(q)
print(abs(pp-qq))     

Fixed submission:
import sys
input=sys.stdin.buffer.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
import itertools
n = int(input())
t = [i+1 for i in range(n)]
li = list(itertools.permutations(t))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
p = tuple(p)
q = tuple(q)
pp = li.index(p)
qq = li.index(q)
print(abs(pp-qq))
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,M = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
flag = 0
order = 0
while True:
    for i in range(N):
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
        else:
            cnt += 1
    if cnt == 0:
        order += 1
        continue
    elif cnt == N:
        break
    else:
        print(0)
        flag = 1
        break
if flag == 0:
    S = a[0]
    for i in range(1,N):
        p = math.gcd(S,a[i])
        S = (S*a[i]) // p
    q = S*(2**(order-1))
    loc = M // q
    if loc % 2 == 1:
        loc += 1
    print(loc // 2)

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,M = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
flag = 0
order = 0
while True:
    for i in range(N):
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
        else:
            cnt += 1
    if cnt == 0:
        order += 1
        continue
    elif cnt == N:
        break
    else:
        print(0)
        flag = 1
        break
if flag == 0:
    S = a[0]
    for i in range(1,N):
        p = fractions.gcd(S,a[i])
        S = (S*a[i]) // p
    q = S*(2**(order-1))
    loc = M // q
    if loc % 2 == 1:
        loc += 1
    print(loc // 2)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
for i in range(K):
    if A > 0:
        A -= 1
    elif B > 0:
        B -= 1
    else:
        break
print(A,B)

Fixed submission:
A,B,K = map(int,input().split())
if K <= A:
    print(A-K,B)
elif A < K and K <= B + A:
    print(0,A+B-K)
else:
    print(0,0)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
X = int(input())
prime = [2]
if X == 2:
    print(2)
else:
    for i in range(2,X):
        c = 0
        for j in prime:
            if i % j == 0:
                c = 1
                break
        if c == 0:
            prime.append(i)
    for i in range(X,X + 1000):
        c = 0
        for j in prime:
            if i % j == 0:
                c = 1
                break
        if c == 0:
            print(i)
            break

Fixed submission:
import sys
input=sys.stdin.readline
import math
X = int(input())
if X == 2:
    print(2)
else:
  x = math.ceil(math.sqrt(X))
  for i in range(X,X+1000):
      c = 0
      for j in range(2,x+1):
          if i % j == 0:
              c = 1
              break
      if c == 0:
          print(i)
          break
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
MOD = pow(10,9)+7
N = int(input())
d = [[N,0] for _ in range(60)]
A = list(map(int,input().split()))
for k in A:
    c = 0
    while k > 0:
        if k % 2 == 1:
            d[c][0] -= 1
            d[c][1] += 1
        k = k // 2
        c += 1
s = 0
for i in range(60):
    li = d[i]
    s += (li[0]*li[1]*pow(2,i,MOD))%MOD
print(s%MOD)

Fixed submission:
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
from collections import defaultdict
MOD = pow(10,9)+7
N = int(input())
d = [[N,0] for _ in range(60)]
A = list(map(int,input().split()))
for k in A:
    c = 0
    while k > 0:
        if k % 2 == 1:
            d[c][0] -= 1
            d[c][1] += 1
        k = k // 2
        c += 1
s = 0
for i in range(60):
    li = d[i]
    s += (li[0]*li[1]*pow(2,i,MOD))%MOD
print(s%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
S = input()
c = 0
for i in range(1000):
    if 0 <= i and i <= 9:
        s0 = "0"
        s1 = "0"
        s2 = str(i)
    elif 10 <= i and i <= 99:
        s0 = "0"
        s = str(i)
        s1 = s[0]
        s2 = s[1]
    else:
        s = str(i)
        s0 = s[0]
        s1 = s[1]
        s2 = s[2]
    i0 = -1
    i1 = -1
    i2 = -1
    for k in range(N-2):
        if S[k] == s0:
            i0 = k
            break
    if i0 == -1:
        continue
    for j in range(i0+1,N-1):
        if S[j] == s1:
            i1 = j
            break
    if i1 == -1:
        continue
    for l in range(i1+1,N):
        if S[l] == s2:
            i2 = l
            break
    if i2 != -1:
        c +=1
print(c)


    
    








Fixed submission:
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
S = input()
c = 0
for i in range(1000):
    if 0 <= i and i <= 9:
        s0 = "0"
        s1 = "0"
        s2 = str(i)
    elif 10 <= i and i <= 99:
        s0 = "0"
        s = str(i)
        s1 = s[0]
        s2 = s[1]
    else:
        s = str(i)
        s0 = s[0]
        s1 = s[1]
        s2 = s[2]
    i0 = -1
    i1 = -1
    i2 = -1
    for k in range(N-2):
        if S[k] == s0:
            i0 = k
            break
    if i0 == -1:
        continue
    for j in range(i0+1,N-1):
        if S[j] == s1:
            i1 = j
            break
    if i1 == -1:
        continue
    for l in range(i1+1,N):
        if S[l] == s2:
            i2 = l
            break
    if i2 != -1:
        c +=1
print(c)
Buggy python submission (verdict: Runtime Error):
MOD = 998244353
N = int(input())
D = list(map(int,input().split()))
d = defaultdict(int)
for i in D:
    d[i] += 1
ans = 1
if d[0] != 1 or D[0] != 0:
    print(0)
else:
    for i in range(1,N):
        ans = ans*pow(d[i-1],d[i],MOD)
    print(ans%MOD)

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
MOD = 998244353
N = int(input())
D = list(map(int,input().split()))
d = defaultdict(int)
for i in D:
    d[i] += 1
ans = 1
if d[0] != 1 or D[0] != 0:
    print(0)
else:
    for i in range(1,N):
        ans = ans*pow(d[i-1],d[i],MOD)
    print(ans%MOD)
Buggy python submission (verdict: Runtime Error):
N = int(input())
n = int(n**(0.5))
for i in range(n):
  c = n-i
  if N % c == 0:
    a = N/c
print(a+c-2)

Fixed submission:
import sys
input=sys.stdin.buffer.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
N = int(input())
n = int(N**(0.5))
for i in range(n):
  c = n-i
  if N % c == 0:
    a = N/c
    break;
print(int(a+c-2))