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):
n = int(input())
r = int(n**0.5)
while r>0:
    if n % r == 0:
        print(int(r + n/r - 2))
        break
    else:
        r =- 1

n = int(input())
r = int(n**0.5)
while r>0:
    if n % r == 0:
        print(int(r + n/r - 2))
        break
    r = r - 1

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 itertools
import functools
import operator
import math

N = int(input())

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


#     # print(a, p)
#     if p * n >= sqr:
#         # print(a, p, n, sqr)
#         return p
#     tmp = 0

#     for i, next_ in enumerate(a):

#             continue

#         tmp = max(prod_dfs(a[:i] + a[i+1:], p * n, next_), tmp)
#     return tmp


#     tmp = 0

#     for i, next_ in enumerate(a):

#             continue

#         tmp = max(prod_dfs(a[:i] + a[i+1:], 1, next_), tmp)
#     return tmp

# prod = functools.partial(functools.reduce, operator.mul)

a = prime_factorize(N)
sqr = math.sqrt(N)

t = a.pop()

if len(a) == 1:
    print(N - 1)
elif len(a) == 2:
    print(a[0] + a[1] - 2)
else:
    ans = 10 * 6
    for i in range(2 ** len(a)):
        tmp = t
        for j in range(len(a)):
            if ((i >> j) & 1):
                tmp *= a[j]
        if abs(ans) > abs(sqr - tmp):
            ans = tmp - sqr

    print(int(ans + sqr + N // (ans + sqr) - 2))


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

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=int(N**0.5);

while i>0:
    if N%i==0:
        i,j=(i,N/i)
        break
    i-=1

print(i+j-2)

N=int(input())

i=int(N**0.5);

while i>0:
    if N%i==0:
        i,j=(i,N/i)
        break
    i-=1

print(int(i+j-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
A = int(input())
B = int(math.sqrt(A))
count = 0
for i in reversed(range(1,B)):
	if count == 0:
    	if A % i == 0:
			print(i+A/i-2)
        	count += 1

import math 

N=int(input())
A=math.sqrt(N)
tmp=float("inf")
for i in range(1,int(A)+1):
	if N%i==0:
		tmp=min(tmp,N//i+i)
print(tmp-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 sqrt from math
N=int(input())
for i in range(int(sqrt)+1,-1,-1):
    if N%i==0:
        print(i-1+N//i-1)
        exit()


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


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


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):
def devide2two(n):
    arr=[]
    arr.append((n-1))
    for i in range(2, int(-(-n**0.5//1))+1):
        if n%i==0:
            a = n/i
            arr.append(i-1+ a-1)
    
    return min(arr)
n = input()
print(devide2two(n))

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

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

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):

N = int(input())
L = []

for i in range(1,1000000000001):
  for j in range(1,1000000000001):
    if i * j == N: 
      L.append(i + j - 2)
print(min(L))


import math
N = int(input())
L = []

def f(x):
  n = int(math.sqrt(x))
  for i in range(n,0,-1):
    if x % i == 0:
       return i
result = f(N) + N // f(N) - 2
print(result)

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):
N = int(input())
i = 1
min = 1000000000000
for _ in range(N):
  if N % i == 0:
    j = N/i
    sum = j + i
    if sum < min:
      min = sum
      ans = i-1+j-1
    else:
      break
  i += 1
print(ans)

import math
N = int(input())
i = 1
min = 9000000000000
for _ in range(1, int(math.sqrt(N)+1)):
  if N % i == 0:
    j = N/i
    sum = j + i
    if sum < min:
      min = sum
      ans = i-1+j-1
    else:
      break
  i += 1
print(ans)

import math
N = int(input())
i = 1
min = 9000000000000
for _ in range(1, int(math.sqrt(N)+1)):
  if N % i == 0:
    j = N/i
    sum = j + i
    if sum < min:
      min = sum
      ans = i-1+j-1
    else:
      break
  i += 1
print(int(ans))

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
from functools import reduce

def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def prime(n1):
	for i in range(2, int(math.sqrt(n1))):
		if n1%i == 0:
			return False
	return True

n = int(input())
if prime(n):
	print(n - 1)
else:
	k = sorted(list(factors(n)))
	#print(k)
	s = k[len(k)//2] + k[len(k)//2 + 1]
	print(s - 2)


def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def prime(n1):
	for i in range(2, n1//2):
		if n1%i == 0:
			return False
	return True

n = int(input())
if prime(n):
	print(n - 1)
else:
	k = sorted(list(factors(n)))
	#print(k)
	s = k[len(k)//2 - 1] + k[len(k)//2]
	print(s - 2)


def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def prime(n1):
	for i in range(2, int(math.sqrt(n1))+1):
		if n1%i == 0:
			return False
	return True

n = int(input())
if prime(n):
	print(n - 1)
else:
	k = sorted(list(factors(n)))
	#print(k)
	if len(k) %2 != 0:
		if k[len(k)//2]*k[len(k)//2] == n:
			print(2*k[len(k)//2] - 2)
		#else:

	else:
		s = k[len(k)//2 - 1] + k[len(k)//2]
		print(s - 2)


import math
from functools import reduce

def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def prime(n1):
	for i in range(2, int(math.sqrt(n1))+1):
		if n1%i == 0:
			return False
	return True

n = int(input())
if prime(n):
	print(n - 1)
else:
	k = sorted(list(factors(n)))
	#print(k)
	if len(k) % 2 != 0:
		if k[len(k)//2]*k[len(k)//2] == n:
			print(2*k[len(k)//2] - 2)
		#else:

	else:
		s = k[len(k)//2 - 1] + k[len(k)//2]
		print(s - 2)


Verdicts: Wrong Answer

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 numpy as np

def isPrime(n):
  s = int(np.sqrt(n))
  for i in range(2, s+1):
    if n % i == 0:
      return False
  return True

def sum_devisor(n):
  s = int(np.sqrt(n))
  while(n % s != 0):
    s -= 1
  return s + n/s

n = int(input())
if isPrime(n) == True:
  print(n-1)
else:
  print(sum_devisor(n)-2)
  

import numpy as np

def isPrime(n):
  s = int(np.sqrt(n))
  for i in range(2, s+1):
    if n % i == 0:
      return False
  return True

def sum_devisor(n):
  s = int(np.sqrt(n))
  while(n % s != 0):
    s -= 1
  return s + n/s

n = int(input())
if isPrime(n) == True:
  print(n-1)
else:
  print(int(sum_devisor(n)-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):

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

if __name__ == "__main__":
    n = int(input())
    ret = make_divisors(n)
    print(ret)
    ans = 10**18
    for a,b in ret:
        ans = min(a+b, ans)
    print(ans-2)


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

if __name__ == "__main__":
    n = int(input())
    ret = make_divisors(n)
    # print(ret)
    ans = 10**18
    for a,b in ret:
        ans = min(a+b, ans)
    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):
N=int(input())

li=[]
l=0
m=0

for i in range(N):
  if N%(i+1)==0:
    l=i+1
    m=N/(i+1)
    li.append(l+m-1)
    l=0
    m=0
  else:
    pass

print(min(li))



N=int(input())

li=[]
l=0
m=0

for i in range(N):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
    l=0
    m=0
  else:
    pass

print(min(li))



N=int(input())

answer=0

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


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):
    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())
Nlist = make_divisions(N)
L = len(Nlist)
if L%2==0:
    print(Nlist[int(L/2)]+Nlist[int(L/2)-1]-2)
else:
    print(int(math.sqrt(N)*2-2)

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())
Nlist = make_divisions(N)
L = len(Nlist)
if L%2==0:
    print(Nlist[int(L/2)]+Nlist[int(L/2)-1]-2)
else:
    print(int(math.sqrt(N)*2-2)

import math

N = int(input())

k = int(math.sqrt(N))

for i in range(1,k)[-1]:
  if N%i==0:
      print(int(N%i)+i)

import math
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())
Nlist = make_divisors(N)
L = len(Nlist)
if L%2==0:
    print(Nlist[int(L/2)]+Nlist[int(L/2)-1]-2)
else:
    print(int(math.sqrt(N)*2-2))

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):
n = 50
ans = 10**12
for i in range(2,int(n**0.5)+1):
    if n%i == 0:
        if (i+n/i)<ans:
            ans = i+n/i
print(ans-2)

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

n = int(input())
ans = 10**12
for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        if (i+n/i)<ans:
            ans = i+n/i
print(int(ans-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())

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


ans=0
if prime(n)==True:
    ans=n-1
else:
    for k in range(n-int(math.sqrt(n)+1)):
        print('k',k)
        if n%(n-k)==0:
            ans=(n-k-1)+(n//(n-k)-1)
            
print(ans)

import math
n=int(input())
r=math.ceil(math.sqrt(n))

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


ans=0
if prime(n)==True:
    ans=n-1
else:
    for k in range(r):
        if n%(r-k)==0:
            ans=(r-k)+(n//(r-k))-2
            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):
s = int(input())
if s%2 == 0:
	ss = int(s/2)
else:
	ss = int(s/2)+1
a=0
b=0
dir = 1000000000000000000000
for i in range(1,ss):
	if s%i == 0:
		a = i
		b = s/i
		if a+b-2 < dir:
			dir = a+b-2
print(dir)


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


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=input()
N=int(N)
A=10**12
I=((N**(1/2))//1)

for a in range(1,round(I+1)):
    for b in range(a,(10**12)+1):
        if N==a*b:
            if a+b-2<A:
                A=a+b-2
            else:
                pass
        else:
            pass

print(A)


N=input()
N=int(N)
A=10**12

for a in range(1,(10**12)+1):
    for b in range(1,(10**12)+1):
        if N==a*b:
            if a+b-2<A:
                A=a+b-2
            else:
                pass
        else:
            pass

print(A)


N=int(input())
ans=1000000000000
import math

for i in range(int(math.sqrt(N))):
    j=N/(i+1)
    if j%1==0:
        if i+int(j)-1<ans:
            ans=i+int(j)-1

print(ans)


Verdicts: Time Limit Exceeded

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):
N = int(input())
s = N + 1
t = 0
for i in range(1,N**0.5):
    if N % i == 0:
        a = i + (N//i)
        if s > a:
            t = a
print(a-2)
    


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

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


N = int(input())
import math
n = math.floor(N**0.5)
s = N + 1
for i in range(1,n + 1):
    if N % i == 0:
        a = i + (N/i)
        s = a
print(int(s-2))

Verdicts: 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())

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

import math
n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i:
    next
  else:
    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
list=[ ]
for i in range(1,math.floor(n*0.5)+2):
  if float(n/i).is_integer()==True:
    j=n/i
    list.append(i+j)
print(list)
print(min(list)-2)
  

n=int(input())
import math
list=[ ]

for i in range(1,math.floor(n**0.5)+1):
  if (n/i)%1==0:
    j=n/i
    list.append(i+j)

print(int(min(list)-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):
n = int(input())
flag = True
ans = n -1
for i in range(2, int(n ** 0.5), -1):
  if (n%i == 0):
    ans = i + n//i - 2
    break
print(ans)


import math
n = int(input())
flag = True
ans = n - 1
for i in reversed(range(2, int(math.sqrt(n))+1)):
  if (n%i == 0):
    ans = i + n//i - 2
    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):
N = int(input())
tmp = []
for i in range(1,N+1):
  if N % i == 0:
    tmp.append(i + N/i)
print(min(tmp) - 2)

import math
n = int(input())
tmp = round(math.sqrt(n))
for i in range(tmp):
  if (n % (tmp - i) == 0):
      print(int((tmp - i) + (n / (tmp - 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):
i = 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


l = []
for x, y in zip(make_divisors(i), reversed(make_divisors(i))):
	l.append(x + y - 2)
print(min(l))


i = 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

l = []
for x, y in zip(sorted(make_divisors(i)), sorted(make_divisors(i),reverse=True)):
	l.append(x + y - 2)
print(min(l))


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())
 
def make_divisors(n):
    divisors = []
    for i in range(int(n**0.5)+1, 0, -1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
            return divisors
 
    
    return divisors
 
 
k = make_divisors(n)
print(k)
if len(k) == 2:
    print(sum(k)-2)
else:
    print(k.pop()*2-2)

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 = int(input())

prime_N = factorization(N)
prime_N = sorted(prime_N, reverse=True, key=lambda x: x[0])
A = 1
B = 1
for i in range(len(prime_N)):
    for j in range(prime_N[i][1]):
        if A*prime_N[i][0] < B*prime_N[i][0]:
            A *= prime_N[i][0]
        else:
            B *= prime_N[i][0]
print(A, B)
print(A + B - 2)

n=int(input())
 
def make_divisors(n):
    divisors = []
    for i in range(int(n**0.5)+1, 0, -1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
            return divisors
 
    
    return divisors
 
 
k = make_divisors(n)
if len(k) == 2:
    print(sum(k)-2)
else:
    print(k.pop()*2-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):

class Solution:
    def solve(self, n: int) -> int:

        maxDivisor = int(math.sqrt(n) + 0.5)

        for i in range(1, maxDivisor + 1):
            if n % i == 0:
                p = i

        q = n // p

        return p+q-2


if __name__ == '__main__':

    # standard input
    n = int(input())

    # solve
    solution = Solution()
    print(solution.solve(n))


import math


class Solution:
    def solve(self, n: int) -> int:

        maxDivisor = int(math.sqrt(n) + 0.5)

        for i in range(1, maxDivisor + 1):
            if n % i == 0:
                p = i

        q = n // p

        return p+q-2


if __name__ == '__main__':

    # standard input
    n = int(input())

    # solve
    solution = Solution()
    print(solution.solve(n))


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):
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

from math import sqrt
N = int(input())
a = make_divisors(N)
print(a)

l = len(a)
if (l%2 == 0):
    print(a[-1] + a[-2] - 2)
else:
    print(a[-1]*2 - 2)

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

from math import sqrt
N = int(input())
a = make_divisors(N)

l = len(a)
if (l%2 == 0):
    print(a[-1] + a[-2] - 2)
else:
    print(a[-1]*2 - 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 sys import stdin
import math
N = int(input())

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

from sys import stdin
import math
N = int(input())
a,b = 0,0
for i in range(int(math.sqrt(N)),0,-1):
    if N % i == 0:
        a = i
        b = N // a
        break
print(a+b-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):
a = int(input())
b = 0
count = 0
for i in range(9):
  for j in range(9):
    if (i+1)*(j+1) == a:
      count += 1
      if count>0:
        if (c+d)>(i+1)+(j+1):
		  c = i+1
          d = j+1
      else :
        c = i+1
        d = j+1
ans = c+d-2
print 

a = int(input())
b = 0
count = 0
for i in range(9):
  for j in range(9):
    if (i+1)*(j+1) == a:
      count += 1
      if count>0:
        if (c+d)>(i+1)+(j+1):
		  c = i+1
          d = j+1
      else :
        c = i+1
        d = j+1
ans = c+d-2
print(ans)

a = int(input())
b = 0
l = int(a**0.5)+1
count = 0
for i in range(l):
    i = i+1
    if a%i == 0:
        j = a//i
    if i*j == a:
        if count == 0:
            count += 1
            c = i
            d = j
        if count>0:
            if (c+d)>(i+j):
                c = i
                d = j
ans = c+d-2
print(ans)

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 numpy as np
n = int(input())

mean = int(np.sqrt(n))

for i in range(mean):
    div = mean - i
    if n % div == 0:
        print(div + n/div - 2)
        break

import numpy as np
n = int(input())

mean = int(np.sqrt(n))

for i in range(mean):
    div = mean - i
    if n % div == 0:
        print(int(div + n/div - 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 = 10000000019  # int(input())


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


def solve(N):
    list_N = prime_decomposition(N)
    ans = N - 1
    for i in list_N:
        ans_tmp = ((N / i) - 1) + (i - 1)
        if ans > ans_tmp:
            ans = ans_tmp

    return ans


print(solve(N))


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


def solve(N):
    list_N = divisor(N)
    ans = N - 1
    for i in list_N:
        ans_tmp = ((N / i) - 1) + (i - 1)
        if ans > ans_tmp:
            ans = ans_tmp

    return ans


print(solve(N))


N = int(input())


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


def solve(N):
    list_N = prime_decomposition(N)
    ans = N - 1
    for i in list_N:
        ans_tmp = ((N / i) - 1) + (i - 1)
        if ans > ans_tmp:
            ans = ans_tmp

    return ans


print(solve(N))


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


def solve(N):
    list_N = divisor(N)
    ans = N - 1
    print(list_N)
    for i in list_N:
        ans_tmp = ((N / i) - 1) + (i - 1)
        if ans > ans_tmp:
            ans = ans_tmp

    return ans


print(solve(N))


N = int(input())


def solve(n):
    i = 1
    ans = N - 1
    while i * i <= n:
        if n % i == 0:
            ans_tmp = ((N // i) - 1) + (i - 1)
            if ans > ans_tmp:
                ans = ans_tmp
        i += 1
    return ans


print(solve(N))


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):
import math
n=int(input())
p=math.sqrt(n)
def x(g):
  a=g
  c=0
  while a>=0:
    a-=1
    c+=1
  return c-1

m=x(p)
for i in range(m):
  if n%(m-i)==0:
    print(m-i+(n//(m-i)))
    break



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

import math
n=int(input())
p=math.sqrt(n)
def x(g):
  a=g
  c=0
  while a>=0:
    a-=1
    c+=1
  return c-1

m=x(p)
for i in range(m):
  if n%(m-i)==0:
    print(m-2-i+(n//(m-i)))
    break



Verdicts: Wrong Answer

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 
num = int(input())

a = int(math.sqrt(num))
b = num // a

for i in range(1, a +1):
    b = num // i
    if i * b == num:
        print(i + b - 2)


import math 
num = int(input())

def mk_factor(num):
    factor = 2
    factor_list = []

    while num > 1 and factor < int(math.sqrt(num)):
        if num % factor == 0:
            factor_list.append(factor)
            num //= factor
        else:
            factor += 1
        if factor_list == []:
            factor_list.append(num)
    return factor_list

def nearest_path(factor_list):
    if len(factor_list) == 1:
        return [0, factor_list[0]-1]
    else:
        half = len(factor_list) // 2 +1

        move_i_list = factor_list[:half]
        move_i = 1
        for i in move_i_list:
            move_i *= i

        move_j_list = factor_list[half:]
        move_j = 1
        for j in move_j_list:
            move_j *= j

    return [move_i -1, move_j -1]

factor_list = mk_factor(num)
print(sum(nearest_path(factor_list)))

import math 
num = int(input())

a = int(math.sqrt(num))
b = num // a

res_list = []

for i in range(1, a+1)[::-1]:
    b = num // i
    if i * b == num:
        print(i + b -2)
        break

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
x=int(input())
s=set()
y=int(math.sqrt(x))
for i in range(y,0,-1):
  print(i)
  if x%i == 0:
    a=i+x//i-2
    s.add(a)
    if min(s)-a <0:
      break
print(min(s))

import math
x=int(input())
s=set()
y=int(math.sqrt(x))
for i in range(y,0,-1):
  if x%i == 0:
    a=i+x//i-2
    s.add(a)
    if min(s)-a <0:
      break
print(min(s))

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())
min_ = n -1 
for i in range(1, n**0.5+10):
  if n % i != 0:
    continue
  else:
    min_ = min(min_, i-1+n//i-1)
    
print(min_)

n = int(input())
min_ = n -1 
for i in range(1, int(n**0.5)+10):
    if n % i != 0:
        continue
    else:
        min_ = min(min_, i-1+(n//i)-1)
    
print(min_)

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())
x = math.floor(math.sqrt(N))
y = 0
for i in range(1, x+1):
    if N % i == 0:
        y = i
        break
    else:
        continue
ans = y + (N/y) - 2
print(int(ans))


import math
N = int(input())
x = math.floor(math.sqrt(N))
y = 0
for i in reversed(range(1, x+1)):
    if N % i == 0:
        y = i
        break
    else:
        continue
ans = y + (N/y) - 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):
import sys,math
def input():
    return sys.stdin.readline()[:-1]


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

t = x/(a**2)
half = b/2
if t<half:
    a_2 = x/b
    b_2 = b
else:
    a_2 = a
    b_2 = (b-t)*2
c = (a_2**2+b_2**2)**0.5
cos1 = ((a_2**2)+(c**2)-(b_2**2))/(2*a_2*c)
print(math.degrees(math.acos(cos1)))

import sys
def input():
    return sys.stdin.readline()[:-1]


N = int(input())
cnt = 0
n = N//2+1
k = int(N**0.5)+1
b = 0
for i in range(k,1,-1):
    if N%i==0:
        b = N//i
        a = i
        print(a+b-2)
        exit()
else:
    print(N-1)

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())
sq_n = int(math.sqrt(n))
s_lis = []
e_lis = []
for i in range(1, sq_n + 1):
    if n % i == 0:
        s_lis.append(i)
        e_lis.append(n // i)
min_len = n + 1 - 2
for s, e in zip(s_lis, e_lis):
    print(s, e)
    min_len = min(min_len, s + e - 2)
print(min_len)

import math
n = int(input())
sq_n = int(math.sqrt(n))
s_lis = []
e_lis = []
for i in range(1, sq_n + 1):
    if n % i == 0:
        s_lis.append(i)
        e_lis.append(n // i)
min_len = n + 1 - 2
for s, e in zip(s_lis, e_lis):
    min_len = min(min_len, s + e - 2)
print(min_len)

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())
p=math.floor(math.sqrt(N))
while N % p > 0:
    p-=1
q=N//p
print(p+q)

import math
N=int(input())
p=math.floor(math.sqrt(N))
while N % p > 0:
    p-=1
q=N//p
print(p+q-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):
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

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

    
    return divisors

n = int(input())

if is_prime(n) == True:
    print(n-1)
else:
    ls = (make_divisors(n))
    print(ls)
    if (n / ls[-1]) == ls[-1]:
        print(ls[-1]+ls[-1]-2)
    else:
        print(ls[-1]+ls[-2]-2)
    

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

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

    
    return divisors

n = int(input())

if is_prime(n) == True:
    print(n-1)
else:
    ls = (make_divisors(n))
    if (n / ls[-1]) == ls[-1]:
        print(ls[-1]+ls[-1]-2)
    else:
        print(ls[-1]+ls[-2]-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
import fractions
import sys
import itertools
import numpy as np
from collections import Counter

def input1():
	return int(input())


def input2():
	return map(int,input().split())


def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))



n=input1()

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









import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter

def input1():
	return int(input())


def input2():
	return map(int,input().split())


def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))



n=input1()

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









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):
input_num = int(input())

min_count = 1 + input_num
for i in range(input_num//2 + 1, 1, -1):
  if(input_num % i == 0) and (min_count >= input_num//i + i):
    min_count = input_num//i + i
print(min_count)

import math
input_num = int(input())
sqrt_num = math.floor(math.sqrt(input_num))

min_count = 1 + input_num
for i in range(sqrt_num + 1, 1, -1):
  if(input_num % i == 0) and (min_count >= input_num//i + i):
    min_count = input_num//i + i
print(min_count)


import math
N = int(input())

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

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):
from math import sqrt
n=int(input())

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

print(ans)

from math import sqrt
n=int(input())

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

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 solv(N):
    x = N-1
    for i in range(1, int(math.sqrt(N))):
        if N % i == 0:
            x = min(x, i + N / i -2)
    return x

N = int(input())
print(solv(N))


import math

def solv(N):
    x = N-1
    for i in range(1, int(math.sqrt(N)) + 1):
        if N % i == 0:
            x = min(x, i + N / i -2)
    return x

N = int(input())
print(int(solv(N)))


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())
m = []
for i in n:
  for j in n:
    if i*j==n:
      m.append(i+j-2)
print(min(m))

n = int(input())
b = 10**12
a = int(n**0.5)
for i in range(1,a+1):
  if n%i==0:
    b = min(b,i+(n/i)-2)
print(b)

n = int(input())
m = 10**12
for i in n:
  for j in n:
    if i*j==n:
      m=min(m,i+j-2)
print(m)

n = int(input())
m = 10**12
for i in n:
  for j in n:
    if i*j=n:
      m=min(m,i+j-2)
print(m)

n = int(input())
m = 10**12
a = (n**0.5)//1
for i in a:
  if n%i==0:
    m=min(m,i+(n/i)-2)
print(m)

n = int(input())
m = 10**12
a = int((n**0.5)//1)
for i in a:
  if n%i==0:
    m=min(m,i+(n/i)-2)
print(m)

n = int(input())

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

n = int(input())
m = 10**12
for i in int(n**0.5//1):
  if n%i==0:
    m=min(m,i+(n/i)-2)
print(m)

n = int(input())
m = 10**12
for i in n:
  for j in n:
    if i*j==n:
      m=min(m,(i+j-2))
print(m)

n = int(input())
 
b = 10**12
a = int((n**0.5)//1)
for i in range(1,a+1):
  if n%i==0:
    b = min(b,int(i+(n//i)-2))
print(b)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

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):
N=int(input())
p=0
for i in range(1,N):
  if i**2<=N:
    p=p+1
  else:
    break
    
q=p   
for i in range(p,N):
  if N%i!=0:
    q=q+1
  else:
    break
    
print(q+(N//q))

N=int(input())
p=0
for i in range(1,N):
  if i**2<=N:
    p=p+1
  else:
    break
    
q=p   
for i in reversed(range(p+1)):
  if N%i!=0:
    q=q-1
  else:
    break
    
print((q+(N//q))-2)

Verdicts: Wrong Answer

Accepted