TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):

import sys
input = sys.stdin.readline
 
N=int(input())
ans=10**12
for i in range(1,int(N**0.5)+1):
    if N%i==0: 
        ans=min(ans,i+N/i) 
print(ans-2) 



"""
pf={}
n = int(input())
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1
print(pf)
"""


""" TLE
n=int(input())

for i in range(1,10000):
    for j in range(1,i+1):
        seki=i*j
        if seki==n:
            print(i+j-2)
            exit()
"""


import sys
input = sys.stdin.readline
 
N=int(input())
ans=10**12
for i in range(1,int(N**0.5)+1):
    if N%i==0: 
        ans=min(ans,i+N//i) 
print(ans-2) 

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math

x = int(input())

tmp = []

for i in range(1, int(math.sqrt(x)) + 1):
    if x % i == 0:
        tmp.append((i - 1) + (x / i - 1))

print(min(tmp))

import math

x = int(input())

tmp = []

for i in range(1, int(math.sqrt(x)) + 1):
    if x % i == 0:
        tmp.append(int((i - 1) + (x / i - 1)))

print(min(tmp))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
N = int(input())
lst=[]
for i in range(1,int(N**0.5)+1):
    if n%i==0:
        lst.append(i+n//i-1)
print(min(lst))

N = int(input())
lst=[]
for i in range(1,int(N**0.5)+1):
    if n%i==0:
        lst.append(i+n//i-2)
print(min(lst))

N = int(input())
lst=[]
for i in range(1,int(N**0.5)+1):
    if N%i==0:
        lst.append(i+N//i-2)
print(min(lst))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
Input = list(map(int,input().split()))

point =[]
for i in range(Input[0]):
    point.append(0)

for i in range(Input[2]):
    aa = int(input())
    point[aa-1] +=1
gouhi =[]
for i in range(Input[0]):
    bb = 0
    if Input[1]-Input[2]+point[i] > 0 :
        bb = "Yes"
    else:
        bb = "No"
    gouhi.append(bb)
print("\n".join(gouhi))

Input = int(input())

aa = int(Input**0.5)

for i in range(1,aa+1):
  if Input%(aa+1-i) == 0:
    num1 = aa+1-i
    num2 = Input/(aa+1-i)
    break
print(int(num1 + num2 -2))

Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
=int(input())
r=n-1
for i in range(2,int(n**0.5)):
    if (n%i==0):
        s=n//i+i-2
        if s<r:
            r=s
print(r)


n=int(input()) 
r=False
i=2
m=n-1
i=2
while (i<=int(n**0.5)):
	if ((n%i)==0 ):		
        s=i+n//i-2
		if (s<m):
			m=s
	i+=1
print(m)

n=int(input())
r=n-1
for i in range(int(n**0.5)+1):
    if (n%i==0):
        s=(n//i)+i-2
        if s<r:
            r=s
print(r)


n=int(input())
r=n-1
for i in range(1,int(n**0.5)+1):
    if (n%i==0):
        s=(n//i)+i-2
        if s<r:
            r=s
print(r)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import collections
A= int(input())

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
  
primelist=make_divisors(A)
S = primelist[-1]
G = int(A/S)
print(primelist,S,G)
print((G-1)+(S-1))

import collections
A= int(input())

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
  
primelist=make_divisors(A)
S = primelist[-1]
G = int(A/S)
print(primelist,S,G)
print((G-1)+(S-1))

import collections
A= int(input())

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
  
primelist=make_divisors(A)
S = primelist[-1]
G = int(A/S)

print((G-1)+(S-1))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math
import sys

n = int(input())

ans = sys.maxsize

for i in range(1, int(math.sqrt(n)) + 1):
    if n % i == 0:
        tmp = min((i - 1) + (n // i - 1), ans)

print(ans)


import math
import sys

n = int(input())

ans = sys.maxsize

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

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import sys

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

input = sys.stdin.readline
n = int(input())

yaku_list = make_divisors(n)
print(yaku_list)
index = int(len(yaku_list)/2)

result = yaku_list[index-1] - 1 + yaku_list[index] - 1 
print(result)


import sys

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

input = sys.stdin.readline
n = int(input())

yaku_list = make_divisors(n)
index = int(len(yaku_list)/2)


if len(yaku_list) % 2 == 0:
    result = yaku_list[index-1] - 1 + yaku_list[index] - 1 
else:
    result = yaku_list[index] - 1 + yaku_list[index] - 1 

print(result)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
data=int(input())
sum=10**6
 
for i in range(10**6):
  a=i+1
  if data%a==0:
    b=data/a
    if a+b<sum:
      sum=a+b
      
print(sum-2)

data=int(input())
sum=20**6
 
for i in range(10**6):
  a=i+1
  if data%a==0:
    b=data/a
    if a+b<sum:
      sum=a+b
      
print(sum-2)

data=int(input())
sum=10**6

for i in range(10**6):
  a=i+1
  if data%a==0:
    b=data/a
    if a+b<sum:
      sum=a+b
print(sum-2)

data=int(input())

sum=data
for i in range(data):
  a=i+1
  b=data/a
  if data%a==0 and a+b<sum:
    sum=a+b
print(sum-2)

data=int(input())
sum=10**12
 
for i in range(10**6):
  a=i+1
  if data%a==0:
    b=data//a
    if a+b<sum:
      sum=a+b
      
print(sum-2)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
N=int(input())
n=round(N**(1/2))
for i in range(1,n+2):
	if N/i==N//i:
		ans=i+N/i-2
print(ans)

N=int(input())
n=round(N**(1/2))
for i in range(1,n+2):
	if N/i==N//i:
		ans=i+N/i-2
print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = 10**15

def prime_factorize(n, unique=False):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    if unique:
        return set(fct)
    else:
        return fct

n = int(input())
print(n)
fact = prime_factorize(n)
fact.append(1)

ans = INF 
for item in fact:
    ans = min(ans, item + n // item - 2)
print(ans)


n = int(input())
ans = 10**15
for i in range(1, n):
    if n % i == 0:
        ans = min(ans, n // i - 1 + i - 1)
    if i * i > n:
        break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math

def sq(n):
    for i in range(math.floor(math.sqrt(N)), 0, -1):
        print(i)
        if n % i == 0:
            return (i, n//i)

N = int(input())
a, b = sq(N)
print(a + b - 2)

import math

def sq(n):
    for i in range(math.ceil(math.sqrt(N)), -1, -1):
        print(i)
        if n % i == 0:
            return (i, n//i)

N = int(input())
a, b = sq(N)
print(a + b - 2)

import math

def sq(n):
    for i in range(math.ceil(math.sqrt(N)), -1, -1):
        if n % i == 0:
            return (i, n//i)

N = int(input())
a, b = sq(N)
print(a + b - 2)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math

def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


n = int(input())
divisors_list = make_divisors(n)
ans = []
n_sqrt = math.sqrt(n)
print(divisors_list)
if n_sqrt == int(n_sqrt):
    for i in range(len(divisors_list) // 2 + 1):
        move = divisors_list[i] + divisors_list[-1 - i] - 2
        ans.append(move)
else:
    for i in range(len(divisors_list) // 2):
        move = divisors_list[i] + divisors_list[-1 - i] - 2
        ans.append(move)
print(min(ans))


import math

def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


n = int(input())
divisors_list = make_divisors(n)
ans = []
n_sqrt = math.sqrt(n)
if n_sqrt == int(n_sqrt):
    for i in range(len(divisors_list) // 2 + 1):
        move = divisors_list[i] + divisors_list[-1 - i] - 2
        ans.append(move)
else:
    for i in range(len(divisors_list) // 2):
        move = divisors_list[i] + divisors_list[-1 - i] - 2
        ans.append(move)
print(min(ans))


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math

N = int(input())

A = int(math.sqrt(N))

for i in reversed(range(1, A + 1)):
    print(i)
    if N % i == 0:
        print(i + (N // i) - 2)
        exit()

import math

N = int(input())

A = int(math.sqrt(N))

for i in reversed(range(1, A + 1)):
    if N % i == 0:
        print(i + (N // i) - 2)
        exit()

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
a=int(input())
c=a+1
for i in range(10000000000,2,-1):
	if a%i==0:
       b=a/i
       if i+b<c:
       	c=i+b
print(int(c-2))

a=int(input())
c=a+1
for i in range(1,10000000,1):
    if a%i==0:
        b=a/i
        if i+b<=c:
            c=i+b
print(int(c-2))   

Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
inport sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())

U = 10**6 + 100

div = np.arange(1, U, dtype=np.int64)
div = div[N%div==0]

div = np.union1d(div, N//div)

answer = (div + (N//div)).min() - 2
print(answer)

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())

U = 10**6 + 100

div = np.arange(1, U, dtype=np.int64)
div = div[N%div==0]

div = np.union1d(div, N//div)

answer = (div + (N//div)).min() - 2
print(answer)

Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math

N=int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n=factorization(N)

print(n)
x=1
y=1
for i in reversed(range(len(n))) :
    for j in range(n[i][1]):
        if x<y:
            x*=n[i][0]
        else:
            y*=n[i][0]
    print(x,y)
print(x,y)

print(x+y-2)

import math

N=int(input())
n=math.ceil(math.sqrt(N))

ans=1000000000000

for i in range(1,n+1):
    if N%i==0:
        if ans>i+(N/i):
            ans=i+(N/i)

print(ans-2)


import math

N=int(input())
n=math.ceil(math.sqrt(N))

ans=1000000000000

for i in range(1,n+1):
    if N%i==0:
        if ans>i+(N/i):
            ans=i+(N/i)
            print(i,N/i,ans)

print(ans-2)


import math

N=int(input())
n=math.ceil(math.sqrt(N))

ans=1000000000000

for i in range(1,n+1):
    if N%i==0:
        if ans>i+(N/i):
            ans=i+(N/i)

print(int(ans-2))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n = int(input())
ans = 1 + n
if n % 2 == 0:
    max = n / 2 + 1
else:
    max = (n + 1) / 2

for i in range (1, max):
    if n % i == 0 and i + n / i < ans:
        ans = i + n /i

print(int(ans - 2))

n = int(input())
ans = 1 + n
if n % 2 == 0:
    max = n / 2 + 1
else:
    max = (n + 1) / 2

for i in range (1, max):
    if max % i == 0 and i + max / i < ans:
        ans = i + max /i

print(int(ans - 2))


import math
n = int(input())
ans = 1 + n

max = math.ceil(n**0.5)

for i in range (2, max+1):
    if n % i == 0 and i + n / i < ans:
        ans = i + n / i

print(int(ans - 2))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())

U = 10**6 + 100
div = np.arange(1,U,dtype=np.int64)
answer = (div + (N//div)).min() - 2
print(answer)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())

U = 10**6 + 100
x = np.arange(1,U,dtype=np.int64)
div = x[N%x==0]
answer = (div + (N//div)).min() - 2
print(answer)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
from math import sqrt

N = int(input())

it = int(sqrt(N))

for i in range(it, 0, -1):
    remain = N % i
    if remain == 0:
        shou = N / i

        if shou:
            print(i+shou-2)
            break


from math import sqrt

N = int(input())

it = int(sqrt(N))

for i in range(it, 0, -1):
    remain = N % i
    if remain == 0:
        shou = N / i

        print(int(i+shou-2))
        break


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
 N = int(input())
x = N
y = N
ansx = N
ansy = N
n = int(N**0.5)
for i in range(x+1):
    if i+1 > n:
        break
    for j in range(y+1):
        if j+1 > x+1:
            break
        if i*j == N:
            if ansx + ansy >i+j:
                ansx,ansy = i,j

print(ansx + ansy -2)

N = int(input())
x = N
y = N
ansx = N
ansy = N
ans = []
n = int(N**0.5)
if N**0.5 == int(N**0.5):
    print(int(N**0.5)*2-2)
else:
    for i in range(n+1):
        if N%(i+1) == 0:
            ans.append(i+1)
    ans.append(N)
    if(ans[1]==N):
        print(N-1)
    else:
        for i in range(len(ans)):
            if ansx+ansy>ans[i] + int(N//ans[i]):
                ansx = ans[i]
                ansy =int(N//ans[i])
        print(ansx + ansy -2)

Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n = int(input())
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)
divisors.sort()
print(divisors)
if len(divisors) % 2 == 1:
    print(2 * divisors[len(divisors) // 2] -2)
else:
    print(divisors[len(divisors) // 2] + divisors[len(divisors) // 2 - 1] - 2)

n = int(input())
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)
divisors.sort()
if len(divisors) % 2 == 1:
    print(2 * divisors[len(divisors) // 2] -2)
else:
    print(divisors[len(divisors) // 2] + divisors[len(divisors) // 2 - 1] - 2)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
from math import sqrt

N = int(input())

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


from math import sqrt

N = int(input())

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


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n=int(input())
import math
a=math.floor(math.sqrt(n))
while a>0:
  if n%a==0:break
  a-=1

print(a+n//a)


n=int(input())
import math
a=math.floor(math.sqrt(n))
while a>0:
  if n%a==0:break
  a-=1

print(a-2+n//a)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math

N = int(input())

ans = 1e18
for i in range(int(0,math.sqrt(N))):
    if N%i != 0:
        continue
    j = N/i
    ans = min(ans, i+j-2)
print(int(ans))

import math

N = int(input())

ans = 1e18
for i in range(int(math.sqrt(N)), 0, -1):
    if N%i != 0:
        continue
    j = N/i
    ans = min(ans, i+j-2)
print(int(ans))

Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math
n = int(input())
a = 0
b = 0
ans = 0
for i in range(int(math.sqrt(n)),1,-1):
  print(i)
  a = i
  b = n/i
  if b%1 == 0 and b<10:
    ans = a+b-2
    break
print(a,b,ans)

import math
n = int(input())
a = 0
b = 0
ans = 0
for i in range(int(math.sqrt(n)),1,-1):
  print(i)
  a = i
  b = n/i
  if b%1 == 0 and b<10:
    ans = a+b-2
    break
print(ans)

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
N = int(input())
i = 1 
res =N
flag = True
if N ==1:
  print(0)
else:
  k = int(N**0.5)
  for j in range(1,k+1):
    k = N / j
    b = int(k)
    if k-b == 0:
      res = min(res,i+b-2)
print(res)
  

N = int(input())
i = 1 
res =N
flag = True
if N ==1:
  print(0)
else:
  k = int(N**0.5)
  for j in range(1,k+1):
    k = N / j
    b = int(k)
    if k-b == 0:
      res = min(res,j+b-2)
print(res)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n = int(input())

for i in range(int(n**0.5),0,-1):
  if n%i==0:
    print(i+n//i-2)

n = int(input())

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



Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import numpy as np
n=int(input())
m=np.floor(np.sqrt(n))

l=[]
for i in range(1,m+1,1):
    if n%i==0:
        a=i+(n/i)
        l.append(a)
        
c=int(min(l))
print(c-2)


n=int(input())
l=[0]
b=0
for i in range(1,n,1):
  if n%i==0 and n/i>=i:
    a=i+(n/i)
    l.append(a)
  else:
    b+=1
    
c=min(l)  
print(c-2)

    
    
    


n=int(inout())
l=[]
for i in range(1,n,1):
    if n%i==0 and n/i>=i:
        a=i+(n/i)
        l.append(a)
        
c=int(min(l))
print(c-2)

n=int(input())
l=[0]
b=0
for i in range(1,n-1,1):
  if n%i==0:
    a=i+(n/i)
    l.append(a)
  else:
    b+=1
    
c=min(l)  
print(c-2)

    
    
    

import numpy as np
n=int(input())
m=int(np.ceil(np.sqrt(n)))+1
l=[]

for i in range(1,m,1):
    if n%i==0:
        a=i+(n/i)
        l.append(a)
        
c=int(min(l))
print(c-2)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
def prime_factorization(N):
    a = []
    while N%2 == 0:
        a.append(2)
        N//= 2
    f = 3
    while f*f <= N:
        if N%f == 0:
            a.append(f)
            N//= f
        else:
            f+= 2
    if N != 1:
        a.append(N)
    return(a)

N = int(input())

a = prime_factorization(N)
Length = len(a)
if Length%2 == 0:
    for i in range(Length-Length/2):
        x = a[Length/2]*a[Length/2+i]
else:
    for i in range(Length-int(Length/2)):
        x = a[int(Length/2)-1]*a[int(Length/2)+i-1]
y = N//x
print(x+y-2)

N = int(input())
a = []
for i in range(1,int(N**0.5+1)):
    if N%i == 0:
        x = i+N//i
        a.append(x)
print(min(a)-2)

Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
N = int(input())

def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
 
if len(divisor(N)) < 3:
    print(N - 1)
else:
    divisor_list = divisor(N)
    tmp = N
    for i in divisor_list:
        print(i)
        A = i
        B = N / i
        if tmp > (A + B - 2):
            tmp = (A + B - 2)
    print(int(tmp))

N = int(input())

def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
 
if len(divisor(N)) < 3:
    print(N - 1)
else:
    divisor_list = divisor(N)
    tmp = N
    for i in divisor_list:
        A = i
        B = N / i
        if tmp > (A + B - 2):
            tmp = (A + B - 2)
    print(int(tmp))


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
ef div_make(n):
    divisor =[]
    n=int(n)
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisor.append([i,n//i])
    return divisor

a=int(input())

lst=[]
for i in div_make(a):
    lst.append(i[0]+i[1])
ans=0
ans=min(lst)-2
print(ans)

def div_make(n):
    divisor =[]
    n=int(n)
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisor.append([i,n//i])
    return divisor

a=int(input())

lst=[]
for i in div_make(a):
    lst.append(i[0]+i[1])
ans=0
ans=min(lst)-2
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())
    min_s = 10 ** 12

    for i in range(1, int(math.sqrt(N))):
        if N % i == 0:
            if min_s > i+(N/i):
                min_s = i + (N/i)

    print(min_s - 2)


if __name__ == '__main__':
    main()


import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())
    min_s = 10 ** 12

    for i in range(1, int(math.sqrt(N))+1):
        if N % i == 0:
            if min_s > i+(N/i):
                min_s = i + (N/i)

    print(int(min_s - 2))


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n = int(input())

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

n = int(input())

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

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n=int(input())
#i+j-2=cnt & i*j=n
import math
minn=100000000000000000000
i=1
while i**2<n:
    if n%i==0:
        j=n/i
        minn=min(int(i+j-2),minn)
print(minn)

n=int(input())
#i+j-2=cnt & i*j=n
minn=n+2
i=1
while i**2<=n:
    if n%i==0:
        j=n/i
        minn=min(int(i+j-2),minn)
    i+=1
print(minn)

Verdicts: Time Limit Exceeded

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math

N = int(input())
ans = N-1
for i in range(1, math.sqrt(N)+1):
    if N%i==0:
        ans = min(ans, i+(N/i)-2)
print(ans)


import math

N = int(input())
ans = N-1
for i in range(1, int(math.sqrt(N)+1)):
    if N%i==0:
        ans = min(ans, i+(N/i)-2)
print(int(ans))


Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math

N = int(input())
a = N
b = round(math.sqrt(N))

for i in range(b):
  j = i + 1
  if N % j == 0:
    if a > j + N / j:
      a = j + N / j
print(a - 2)

import math
import sys

N = int(input())
a = 0

for i in reversed(range(round(math.sqrt(N)))):
  if N % (i + 1) == 0:
    print(i + N / (i + 1) - 1)
    sys.exit()

import math

c = list(map(float, input().split()))
a = c[0]
b = c[1]
x = c[2]
if x <= a * a * b / 2.0:
  print(90.0 - math.atan((x / a * 2.0 / b) / b) * 180.0 / math.pi)
else:
  print(math.atan(((a * a * b - x) / a * 2.0 / a) / a) * 180.0 / math.pi)

import math

N = int(input())
a = N
b = round(math.sqrt(N))

for i in range(b):
  j = i + 1
  if N % j == 0:
    if a > j + N / j:
      a = j + N / j
print(a - 2)

import math
import sys

N = int(input())

for i in reversed(range(int(math.sqrt(N)))):
  if N % (i + 1) == 0:
    print(i + N / (i + 1) - 1)
    sys.exit()

import math
import sys

N = int(input())

for i in reversed(range(int(math.sqrt(N)))):
  if N % i == 0:
    print(i + N / i)
    sys.exit()

import math
import sys

N = int(input())
a = 0

for i in reversed(range(round(math.sqrt(N)))):
  j = i + 1
  if N % j == 0:
    print(j - 1 + N / j - 1)
    sys.exit()

N = int(input())
a = N

for i in range(N):
  j = i + 1
  if N % j == 0:
    if a > j + N / j:
      a = j + N / j
print(a - 2)

import math
import sys

N = int(input())

for i in reversed(range(int(math.sqrt(N)))):
  if N % (i + 1) == 0:
    print((i + 1) + N / (i + 1))
    sys.exit()

import math

N = int(input())
a = N

for i in range(round(math.sqrt(N))):
  j = i + 1
  if N % j == 0:
    if a > j + N / j:
      a = j + N / j
print(a - 2)

import math
import sys

N = int(input())
a = math.sqrt(N)

for i in range(round(math.sqrt(N))):
  j = i + 1
  if N % j == 0:
    if a > j + N / j:
      a = j + N / j
print(a - 2)

import math

N = int(input())
a = N
b = round(math.sqrt(N))

for i in range(b):
  for j in range(b):
    if (i + 1) * (j + 1) == N:
      if a > (i + 1) * (j + 1):
        a = i + j
print(a)

import math
import sys

N = int(input())
a = math.sqrt(N)

for i in range(round(math.sqrt(N))):
  j = i + 1
  if N % j == 0:
    if a > j - 1 + N / j - 1:
      a = j - 1 + N / j - 1
print(a)

import math

N = int(input())
a = N + 1
b = round(math.sqrt(N))

for i in range(b):
  j = i + 1
  if N % j == 0:
    if a > j + N / j:
      a = j + N / j
print(round(a) - 2)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
# C
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)

    divisors.sort()
    return divisors

N = int(input())
divisors = make_divisors(N)
memo = 0
maX = divisors[0] + divisors[len(divisors) - 1]
for (i, r) in zip(make_divisors, reversed(make_divisors)):
    maX = min(i + r, maX)
    memo = i
    if memo == r:
        break
print(maX)


# C
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)

    divisors.sort()
    return divisors

N = int(input())
divisors = make_divisors(N)
memo = 0
maX = divisors[0] + divisors[len(divisors) - 1]
for (i, r) in zip(divisors, reversed(divisors)):
    maX = min(i + r, maX)
    memo = i
    if memo == r:
        break
print(maX)


# C
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)

    divisors.sort()
    return divisors

N = int(input())
divisors = make_divisors(N)
memo = 0
maX = divisors[0] + divisors[len(divisors) - 1]
for (i, r) in zip(divisors, reversed(divisors)):
    maX = min(i + r, maX)
    memo = i
    if memo == r:
        break
print(maX - 2)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
a = int(input())
b = int(math.sqrt(a))-1
for i in range(b):
    x = a/b
    if x.is_integer():
        break
    else:
        b -= 1
print(int(x + b -2))

import math
a = int(input())
b = int(math.sqrt(a))
for i in range(b):
    x = a/b
    if x.is_integer():
        break
    else:
        b -= 1
print(int(x + b -2))

Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import sys
input = sys.stdin.readline
N = int(input())

List = []
for i in range(1,10**4):
    for j in range(1,10**4):
        if N == i*j:
            List.append(i+j)

print(min(List)-2)

N = int(input())

List = []
for i in range(1,10**5):
    for j in range(1,10**5):
        if N == i*j:
            List.append(i+j)

print(min(List)-2)

#--------------------------------------------

import sys
import math
from math import sqrt
input = sys.stdin.readline

#---------------------------------------------
N = int(input())
for i in range(int(sqrt(N))+1,-1,-1):
    if N % i == 0:
        print(i+(N/i)-2)
        exit()
        


#--------------------------------------------

import sys
import math
from math import sqrt
input = sys.stdin.readline

#---------------------------------------------
N = int(input())
for i in range(int(sqrt(N))+1,-1,-1):
    if N % i == 0:
        print(int(i+(N/i)-2))
        exit()



Verdicts: Time Limit Exceeded

Time Limit Exceeded

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n = int(input())
list = []
for i in range(1, n**0.5+1):
  if n%i == 0:
    list.append(int(i + n/i))
print(min(list)-2)

n = int(input())
list = []
for i in range(1, int(n**0.5 + 1)):
  if n%i == 0:
    list.append(i + n/i)
print(min(list) - 2)

import math
n = int(input())
ans = float('inf')
for i in range(10^6):
  if n%i == 0:
    j = n/i
    ans = min(ans, i+j-2)
print(ans)

import math
n = int(input())
ans = int('inf')
for i in range(10^6):
  if n%(i+1) == 0:
    j = n/(i+1)
    ans = min(ans, (i+1)+j-2)
print(ans)

import math
n = int(input())
ans = float('inf')
for i in range(10^6):
  if n%(i+1) == 0:
    j = n/(i+1)
    ans = min(ans, (i+1)+j-2)
print(ans)

n = int(input())
ans = float('inf')
for i in range(1, int(n**0.5 + 1)):
  if n%i == 0:
    ans = min(ans, i + int(n/i) - 2)
print(ans)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math
n=int(input())
temp=n+1
for i in range(int(math.sqrt(n)),0,-1):
  if n%i==0:
    print(i,n//i,i+n//i-2)
    exit()

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n=int(input())

div = 1
result = 10**12

for i in range(1,int(n**0.5//1)+1):
  if n % i == 0:
    div = div // i
    result = min(result, i+div)

print(int(result-2))


n=int(input())

div = n
result = 10**12

for i in range(1,n):
  if n % i == 0:
    result = min(result, i+div)
    div = div // i

print(int(result-2))

n=int(input())

result = 10**12
for i in range(1,int(n**0.5)+1):
  if n % i == 0:
    result = min(result, i + n//i)

print(int(result-2))



Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math
n=int(input())
lst=[]
up=math.ceiling(math.sqrt(n))-1
for i in range(1,up+1):
    if i**2>n:
        break
    if n%i==0:
        lst.append(i+n//i)
print(min(lst)-2)


n=int(input())
lst=[]
for i in range(1,n):
    if i**2>n:
        break
    if n%i==0:
        lst.append(i+n//i)
print(lst)
print(min(lst)-2)

import math
n=int(input())
lst=[]
down=math.floor(math.sqrt(n))
for i in range(1,down+1):
    #if i**2>n:
    #    break
    if n%i==0:
        lst.append(i+n//i)
print(min(lst)-2)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math
int_n = int(input())
i = (math.sqrt(int_n))
i = math.floor(i)
while i >= 1:
    if int_n % i == 0:
        j = int_n/i
        print((i - 1) + (j -1))
        break
    i = i - 1

import math
int_n = int(input())
i = (math.sqrt(int_n))
i = math.floor(i)
while i > 1:
    if int_n % i == 0:
        j = int_n/i
        print((i - 1) + (j -1))
        break
    i = i - 1

import math
int_n = int(input())
i = (math.sqrt(int_n))
math.floor(i)
while i >= 1:
    if int_n % i == 0:
        j = int_n/i
        print((i - 1) + (j -1))
        break
    i = i - 1

import math
int_n = int(input())
i = (math.sqrt(int_n))
i = math.floor(i)
while i >= 1:
    if int_n % i == 0:
        j = int_n/i
        print(math.floor((i - 1) + (j - 1)))
        break
    i = i - 1

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n = int(input())

for i in range(int(n ** 0.5), 0, -1):
  if n % i == 0:
    j = n / i
    print(i + j - 2)
    break

n = int(input())

for i in range(int(n ** 0.5), 0, -1):
  if n % i == 0:
    j = n // i
    print(i + j - 2)
    break

Verdicts: Wrong Answer

Accepted