Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
 
list=[]
 
for i in range(1,n+1):
    if len(list) == 1 and i>int(n/i):
        ans=(list[-1][0]-1)+(list[-1][1]-1)
        break
    a=n%i

    if a == 0:
        if(i<n/i):
            list.append([i,int(n/i)])
            if list[-1][0] == list[-1][1]:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
        else:
            list.append([int(n/i),i])
            if len(list) == 1:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
                break
            if list[-1]==list[-2]:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
print(ans)

Fixed submission:
import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
 
list=[]
 
for i in range(1,n+1):
    if len(list) == 1 and i>int(n/i):
        ans=(list[-1][0]-1)+(list[-1][1]-1)
        break
    a=n%i
    if a == 0:
        if(i<n/i):
            list.append([i,int(n/i)])
        else:
            list.append([int(n/i),i])
            if len(list) == 1:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
                break
            if list[-1]==list[-2]:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
print(ans)

Fixed submission:
import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break

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

list=[]

for i in range(1,int((n+1)/2)):
    a=n%i
    if(len(list) == 1 and i>n/i):
        ans=(list[-1][0]-1)+(list[-1][1]-1)    
        break
    if a == 0:
        if(i<n/i):
            list.append([i,int(n/i)])
        else:
            list.append([int(n/i),i])
            if len(list) == 1:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
                break
            if list[-1]==list[-2]:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
                break
print(ans)

Fixed submission:
import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break

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

list=[]

for i in range(1,int((n+1)/2)):
    a=n%i
    if(len(list) == 1 and i>n/i):
        ans=(list[-1][0]-1)+(list[-1][1]-1)    
        break
    if a == 0:
        if(i<n/i):
            list.append([i,int(n/i)])
        else:
            list.append([int(n/i),i])
            if len(list) == 1:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
                break
            if list[-1]==list[-2]:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
                break
print(ans)

Fixed submission:
import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break

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

list=[]

for i in range(1,int(n+1/2)):
    a=n%i
    if a == 0:
        if(i<n/i):
            list.append([i,int(n/i)])
        else:
            list.append([int(n/i),i])
            if len(list) == 1:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
                break
            if list[-1]==list[-2]:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
print(ans)


Fixed submission:
import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

list=[]

for i in range(1,n+1):
    a=n%i
    if a == 0:
        if(i<n/i):
            list.append([i,int(n/i)])
        else:
            list.append([int(n/i),i])
            if len(list) == 1:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
                break
            if list[-1]==list[-2]:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
print(ans)

Fixed submission:
import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

list=[]

for i in range(1,n+1):
    a=n%i
    if a == 0:
        if(i<n/i):
            list.append([i,int(n/i)])
        else:
            list.append([int(n/i),i])
            if i>1 :
                if len(list) == 1:
                    ans=(list[-1][0]-1)+(list[-1][1]-1)
                    break
                if list[-1]==list[-2]:
                    ans=(list[-1][0]-1)+(list[-1][1]-1)
                    break
print(ans)

Fixed submission:
import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break

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

list=[]

for i in range(1,12):
    a=n%i
    if a == 0:
        if(i<n/i):
            list.append([i,int(n/i)])
        else:
            list.append([int(n/i),i])

    if i>1 :
        if len(list) == 1:
            ans=(list[-1][0]-1)+(list[-1][1]-1)
            break
        if list[-1]==list[-2] or len(list)==1:
            ans=(list[-1][0]-1)+(list[-1][1]-1)
            break
print(ans)

Fixed submission:
import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break