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())
a=int(n**(1/2))
for i in range(a):
    if n%(a-i)==0:
        print(int((a-i)+(n/(a-i))-1))
        break

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

ans = 1000000000000

a = 1
while a * a <= n:
  if n % a != 0:
    a += 1
    continue
  b = n % a
  ans = min(ans, a + b - 2)
  a += 1

print(ans)

n = int(input())

ans = 1000000000000

a = 1
while a * a <= n:
	if n % a != 0:
      continue
    b = n % a
    ans = min(ans, a + b - 2)
    a += 1

print(ans)

n = int(input())

ans = 1000000000000

a = 1
while a * a <= n:
  if n % a != 0:
    a += 1
    continue
  b = n / a
  ans = min(ans, a + b - 2)
  a += 1

print(ans)

n = int(input())

ans = 1000000000000

a = 1
while a * a <= n:
  if n % a != 0:
    a += 1
    continue
  b = n // a
  ans = min(ans, a + b - 2)
  a += 1

print(ans)

Verdicts: 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):
import math

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


import math

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


import math

N = int(input())
for i in range(1, int(math.sqrt(N) + 1))[::-1]:
    if N % i == 0:
        print(N // i + i - 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):
# -*- coding: utf-8 -*-
"""
Created on Wed Nov  6 21:49:38 2019

@author: over-
"""

N=int(input())

ans=N
for i in range(1,10**12):
    if i > N: break
    if N%i == 0:
        A=(N/i-1)+(i-1)
        if A < ans:
            ans = A
            
print(int(A))

# -*- coding: utf-8 -*-
"""
Created on Wed Nov  6 21:49:38 2019

@author: over-
"""

N=int(input())

ans=N
for i in range(1,10**6):
    if i > N: break
    if N%i == 0:
        A=(N/i-1)+(i-1)
        if A < ans:
            ans = A
            
print(int(A))

# -*- coding: utf-8 -*-
"""
Created on Wed Nov  6 21:49:38 2019

@author: over-
"""

N=int(input())

ans=N
for i in range(1,10**12):
    if i**2 > N: break
    if N%i == 0:
        A=(N/i-1)+(i-1)
        if A < ans:
            ans = A
            
print(int(A))

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 = input()
N_sqrt = int(np.sqrt(N))+1
N_ = [i for i in range(2, N_sqrt) if N % i == 0]

if len(N_) == 0:
    print(N-1)
else:
    pair = [(i, int(N/i)) for i in N_]
    my_lambda = lambda x : sum(x)
    x = list(map(my_lambda, pair))
    print(min(x)-2)

import numpy as np

N = int(input())
N_sqrt = int(np.sqrt(N))+1
N_ = [i for i in range(2, N_sqrt) if N % i == 0]

if len(N_) == 0:
    print(N-1)
else:
    pair = [(i, int(N/i)) for i in N_]
    my_lambda = lambda x : sum(x)
    x = list(map(my_lambda, pair))
    print(min(x)-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())
ans=10**18
for i in range(10**6+1):
  if n%i==0:
    j=n//i
  ans=min(ans,i+j-2)
print(ans)

n=int(input())
ans=10**18
for i in range(1,10**6+1):
  if n%i==0:
    j=n//i
  ans=min(ans,i+j-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):
N=int(input())
minn=N-1
for i in range(2,round((N)**0.5+1)):
    if N%(i+1)==0 and minn>N//(i+1)-1+i:
        minn=N//(i+1)-1+i
print(minn)


N=int(input())
minn=N-1
for i in range(2,round((N-1)**0.5)):
    if N%(i+1)==0 and minn>N//(i+1)-1+i:
        minn=N//(i+1)-1+i
if minn<=(N-1):
    print(minn)
else:
    print(N-1)

N=int(input())
minn=N-1
for i in range(2,round((N)**0.5+1)):
    if N%i==0 and minn>N//(i)-2+i:
        minn=N//(i)-2+i
print(minn)



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 ceil, sqrt
N = int(input())

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

from math import ceil, sqrt
N = int(input())

for i in range(ceil(sqrt(N)), 0, -1):
    if N % i == 0:
        print((N//i) + i - 2)
        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):
tall = int(input())
bit = round(tall**(1/2))
while (bit/tall%1 != 0):
  bit -= 1
print(bit+tall/b-2)

tall = int(input())
bit = int(tall**(1/2))
while ((tall/bit)%1 != 0):
  bit -= 1
print(bit+tall/bit-2)

tall = int(input())
bit = int(tall**(1/2))
while ((tall/bit)%1 != 0):
  bit -= 1
print(int(bit+tall/bit-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

N = int(input())

a = pow(10,12)

is_not_prime = False
#for k in range(2, int(math.sqrt(N)) + 1):

#        is_not_prime = True
#        break
#if is_not_prime:
for i in range(1, int(math.sqrt(N))):
    print(i)
    j = N/i
    if j.is_integer():

        if (i+int(j)) < a:
            a = i+int(j)
    #if j < 2:
    #    break

print(a - 2)
#else:
#    print(N - 1)

import math

N = int(input())

a = pow(10,12)

is_not_prime = False
for k in range(2, int(math.sqrt(N)) + 1):
    if N % k == 0:
        is_not_prime = True
        break
if is_not_prime:
    for i in range(1, int(N/3)):
        print(i)
        j = N/i
        if j.is_integer():

            if (i+int(j)) < a:
                a = i+int(j)
        if j < 2:
            break

    print(a - 2)
else:
    print(N - 1)

import math

N = int(input())

a = pow(10,12)

is_not_prime = False
for k in range(2, int(math.sqrt(N)) + 1):
    if N % k == 0:
        is_not_prime = True
        break
if is_not_prime:
    for i in range(1, int(math.sqrt(N)) + 1):
        print(i)
        j = N/i
        if j.is_integer():

            if (i+int(j)) < a:
                a = i+int(j)
        if j < 2:
            break

    print(a - 2)
else:
    print(N - 1)

import math

N = int(input())

a = pow(10,12)

is_not_prime = False
#for k in range(2, int(math.sqrt(N)) + 1):

#        is_not_prime = True
#        break
#if is_not_prime:
for i in range(1, int(math.sqrt(N))+1):
    #print(i)
    j = N/i
    if j.is_integer():

        if (i+int(j)) < a:
            a = i+int(j)
    #if j < 2:
    #    break

print(a - 2)
#else:
#    print(N - 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):
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

def main():
    Min = 2000000000000
    divisors = make_divisors(int(input()))
    if len(divisors)%2==1:
        divisors.append(divisors[len(divisors)-1])
    print(divisors)
    for i in range(0,len(divisors)-1,2):
        Min = min(divisors[i]+divisors[i+1],Min)
    print(Min-2)

main()

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

def main():
    Min = 2000000000000
    divisors = make_divisors(int(input()))
    if len(divisors)%2==1:
        divisors.append(divisors[len(divisors)-1])
    
    for i in range(0,len(divisors)-1,2):
        Min = min(divisors[i]+divisors[i+1],Min)
    print(Min-2)

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):
import sys
import math

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

ls = []
for i in range(1, int(sqrt) + 1):
  if N % i == 0:
    ls.append((i, int(N/i)))

print(ls)

print(min(a[0] + a[1] -2 for a in ls))


import sys
import math

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

ls = []
for i in range(1, int(sqrt) + 1):
  if N % i == 0:
    ls.append((i, int(N/i)))


print(min(a[0] + a[1] -2 for a in ls))


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())
ans=n
i=1
while(i<math.sqrt(n)):
    if n%i==0:
        d=i+n/i-2
        ans=min(ans,d)
    i+=1
print(int(ans))

from math import floor
from math import sqrt
n=int(input())
nn=floor(sqrt(n))
rest=n%nn
while rest!=0:
    nn-=1
    rest=n%nn
nnn=n/nn
print(int(nn+nnn-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())

for i in range(math.floor(N**0.5),0,-1):
    if N % i == 0:
        x,y = i, N//i
        break
print(x+y-2)

import math

N = int(input())
for i in range(math.floor(N**0.5),0,-1):
    if N % i == 0:
        x,y = i, N//i
        break
print(x+y-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())
temp=10**13
for i in range(1,int(n**(1/2))+1):
    if n%i==0:temp=min(temp,i+n/i)
print(temp-2)

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

n=int(input())
temp=10**13
for i in range(1,int(n**(1/2))+1):
    if n%i==0:temp=min(temp,i+n/i)
print(int(temp-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):
a = []


def dis(n):
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            a.append(int(i))


num = int(input())
dis(num)
ans = 0


print(ans)


a = []


def dis(n):
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            a.append(int(i))


num = int(input())
dis(num)
ans = 0
for e in a:
    continue
    
print(ans)


def solve(n):
    ans = int(1e12)
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0 and i + n // i - 2 < ans:
            ans = i + n // i - 2
    return int(ans)


num = int(input())
print(solve(num))


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 numpy as np
n = int(input())
MIN = n
for x in range(1,int(np.sqrt(n)+100)):
    if n % x == 0:
        MIN = min([MIN,x + n/x - 2])
    print(x)
print(int(MIN))

import numpy as np
n = int(input())
MIN = n
for x in range(1,int(np.sqrt(n))):
    if n % x == 0:
        MIN = min([MIN,x + n/x - 2])
    print(x)
    x += 1
print(int(MIN))

import numpy as np
n = int(input())
MIN = n
for x in range(1,int(np.sqrt(n))):
    if n % x == 0:
        MIN = min([MIN,x + n/x - 2])
    print(x)
print(int(MIN))

import numpy as np
n = int(input())
MIN = n
for x in range(1,int(np.sqrt(n)+1)):
    if n % x == 0:
        MIN = min([MIN,x + n/x - 2])
print(int(MIN))

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

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

div = make_divisors(N)
if len(div) % 2 == 0:
	ind_2 = len(div) // 2
	ind_1 = ind_2 - 1
	print(div[ind_1] + div[ind_2])
else:
	ind = len(div) // 2
	print(div[ind] * 2)

N = 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)
	
	divisors.sort()
	return divisors

div = make_divisors(N)
if len(div) % 2 == 0:
	ind_2 = len(div) // 2
	ind_1 = ind_2 - 1
	print(div[ind_1] + div[ind_2] -2)
else:
	ind = len(div) // 2
	print(div[ind] * 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):
def get_divisors(n):
    res = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n//i)
    return sorted(res)
    
N = int(input())
ds = get_divisors(N)

res = 10**12

print('len(ds) = ', len(ds))

if len(ds) % 2 != 0:
    
    for i in range((len(ds)+1) // 2):
        res = min(res, ds[i] + ds[-(i+1)])
else:
    
    for i in range(len(ds) // 2):
        print(ds[i], ds[-(i+1)])
        res = min(res , ds[i] + ds[-(i+1)])
        
print(res - 2)

def get_divisors(n):
    res = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n//i)
    return sorted(res)
    
N = int(input())
ds = get_divisors(N)

res = 10**12

if len(ds) % 2 != 0:
    
    for i in range((len(ds)+1) // 2):
        res = min(res, ds[i] + ds[-(i+1)])
else:
    
    for i in range(len(ds) // 2):
        res = min(res , ds[i] + ds[-(i+1)])
        
print(res - 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):
    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())
div=make_divisors(N)

from math import sqrt

tmpmin=10*10
for i in range(len(div)):
  if tmpmin>abs(sqrt(N)-div[i]):
    tmpmin=abs(sqrt(N)-div[i])
    minidx=i

a=div[i]
b=N//a

print(a-1+b-1)



from math import sqrt

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

ans = N/s + s - 2
print(ans)

N = int(input())
s = N
i = 1
while i**2 <= N:
    if N % i == 0:
        s = i
    i += 1

ans = N//s + s - 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

n = int(input())

sqrt_n = int(math.sqrt(n))

for i in reversed(range(sqrt_n)):
  if(n%i == 0):
    print(i + n%i -2)

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

n=int(input())

min=-1
for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
        j=int(n/i)
        print("divide",i,j)
        calc=j+i-2
        if min==-1 or min>calc:
            min=calc

print(min)


import math

n=int(input())

min=-1
for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
        j=int(n/i)
        calc=j+i-2
        if min==-1 or min>calc:
            min=calc

print(min)


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())
result=100000000000000000000000000
for i in range(n):
  nn=n/i
  if (nn.is_integer() and result>nn+i-2):
	result=nn+i-2
print(result)
    
    

n = int(input())
list=[]
for i in range(1,int(n**0.5+1)):
  if n%i == 0:
    list.append(int(i+n/i))
print(min(list)-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):
# -*- coding: utf-8 -*-
import math
a = int(input())
b = round(math.sqrt(a))
while a % b != 0:
    print(a,b)
    b+=1
c = int(a / b)
print(b+c-2)

# -*- coding: utf-8 -*-
import math
a = int(input())
b = round(math.sqrt(a))
while a % b != 0:
    b -= 1
c = int(a / b)
print(b + c - 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 sys
import os
import math
import itertools

def factorize(n):
    b = 2
    fct = []
    fct.append(1)
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

N = int(input())
listN = factorize(N)
x = 0
y = 0

mini = 10**12
if len(listN) == 1:
    x = N
    y = 1
else:
    for i in range(1,len(listN)):
        tmp = list(itertools.combinations(listN,i))
        for j in range(len(tmp)):
            x0,y0 = 1,1
            for k in range(len(tmp[j])):
                x0 *= tmp[j][k]
                y0 = N//x0
                print(x0,y0)
                if mini > abs(x0+y0):
                    mini = abs(x0+y0)
                    x = x0
                    y = y0

print(x-1+y-1)


import sys
import os
import math
import itertools

def factorize(n):
    b = 2
    fct = []
    fct.append(1)
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

N = int(input())
listN = factorize(N)
x = 0
y = 0

mini = 10**12
if len(listN) == 1:
    x = N
    y = 1
else:
    for i in range(1,len(listN)):
        tmp = list(itertools.combinations(listN,i))
        for j in range(len(tmp)):
            x0,y0 = 1,1
            for k in range(len(tmp[j])):
                x0 *= tmp[j][k]
                y0 = N//x0
                print(x0,y0)
                if mini > abs(x0-y0):
                    mini = abs(x0-y0)
                    x = x0
                    y = y0

print(x-1+y-1)


import sys
import os

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())
listN = make_divisors(N)
mini = 10**12
if len(listN) == 1:
    x = N
    y = 1
else:
    for i in range(len(listN)):
        x = listN[i]
        y = N//x
        mini = min(x+y,mini)
print(x-1+y-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):
n = int(input())
factor = []
tmp = n
for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
    while tmp % i == 0:
        factor.append(i)
        tmp //= i
if tmp != 1:
    factor.append(tmp)
if len(factor) == 0:
    factor.append(n)

from collections import defaultdict


def factorize(n):
    f = defaultdict(int)
    tmp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        while tmp % i == 0:
            f[i] += 1
            tmp //= i
    if tmp != 1:
        f[tmp] += 1
    if not f:
        f[n] += 1
    return f


def distance(s, d):
    a, b = 1, 1
    for i, si in enumerate(s):
        if si == "0":
            a *= factors[i]
            if a > d:
                return inf
        else:
            b *= factors[i]
            if b > d:
                return inf
    return a + b - 2


def answer(f, d):
    a = 1
    for i in f:
        a *= i
        if a > d:
            return inf
    return a + N // a - 2


def sa(f):
    d = inf
    for fi in f:
        d = min(d, answer(fi, d))
    return d


def comb(f):
    c = [[]]
    for k in f:
        ct = [[k] * i for i in range(1, f[k] + 1)]
        ci = c.copy()
        for cti in ct:
            for cii in ci:
                c.append(cii + cti)
    return [[1]] + c[1:]


# CONST = 1099511627776
N = int(input())
inf = 999999999999
factors = factorize(N)
print(sa(comb(factors)))

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=0
b=0
for i in range(int(math.sqrt(n)),2,-1):
  if n%i==0:
    a=i
    b=n//i
if a==0:
  print(n-1)
else:
  print(a+b-2)

import math
n=int(input())

a=0
b=0
for i in range(int(math.sqrt(n)),1,-1):
  if n%i==0:
    a=i
    b=n//i
    break
if a==0:
  print(n-1)
else:
  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):
N=int(input())
x=[]
min=10000000
ans=0
for i in range(1,N+1):
  for j in range(1,N-i+1):
    if i*j==50:
      a=[i,j]
      x.append(a)
for i,j in x:
  if i+j<=min:
    ans=i+j-2
    min=i+j
print(ans)

import math
N=int(input())
x=[]
min=10000000000000000
ans=0
sqN=math.ceil(math.sqrt(N))
for i in range(1,sqN+1):
  if N%i==0:
    j=int(N/i)
    a=[i,j]
    x.append(a)
for i,j in x:
  if i+j<=min:
    ans=i+j-2
    min=i+j
print(ans)
print(x)

import math
N=int(input())
sqN=math.ceil(math.sqrt(N))
ans=10**15
for i in range(1,sqN+1):
  if N%i==0:
    b=int(N/i)
    if ans>=(i+b-2):
      ans=i+b-2
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):
import sys

def divisor(n):
    i = 1
    l = []
    while i * i <= n:
        if n%i == 0:
            l.append(i)
            l.append(n//i)
        i += 1
    l = list(set(l))
    l.sort()
    return l

stdin = sys.stdin

ni = lambda: int(ns())
ns = lambda: stdin.readline()

N = ni()
ans = 0
if N > 1:
    div = divisor(N)
    print(div, div[len(div)//2 - 1])
    if len(div) > 1:
        i = div[len(div)//2 - 1] - 1
        j = (N // (div[(len(div)//2) - 1]))  - 1
        ans = i + j
    else:
        ans = 1
elif N == 1:
    ans = 0
else:
    ans = 1

print(ans)

import sys

def divisor(n):
    i = 1
    l = []
    while i * i <= n:
        if n%i == 0:
            l.append(i)
            l.append(n//i)
        i += 1
    l.sort()
    return l

stdin = sys.stdin

ni = lambda: int(ns())
ns = lambda: stdin.readline()

N = ni()
ans = 0
if N > 1:
    div = divisor(N)
    #print(div, div[len(div)//2 - 1])
    if len(div) > 1:
        i = div[len(div)//2 - 1] - 1
        j = (N // (div[(len(div)//2) - 1]))  - 1
        ans = i + j
    else:
        ans = 1
elif N == 1:
    ans = 0
else:
    ans = 1

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


n = int(input())
a = math.sqrt(n)//1
while a > 0:
  if n%a == 0:
    s = a
    t = n//a    
    break
  a -= 1
print(s+t-2)

import math


n = int(input())
a = int(math.sqrt(n))
while a > 0:
  if n%a == 0:
    s = a
    t = n//a    
    break
  a -= 1
print(s+t-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
n = int(input())
root = int(math.sqrt(n))
ans = 0
flag = 0
for i in range(1, root+1):
    if n % i == 0:
        flag = 1
        ans = int((n/i)) + i - 2
        break
print(ans)

import math
n = int(input())
root = int(math.sqrt(n))
ans = 0
flag = 0
for i in range(root, 10**6+1):
    if n % i == 0:
        flag = 1
        print('i='.format(i))
        ans = int((n/i)) + i - 2
        break
if flag==1: pass
else: 
  ans = n + 1 - 2
print(ans)

import math
n = int(input())
root = int(math.sqrt(n))
ans = 0
flag = 0
for i in range(root, 10**6+1):
    if n % i == 0:
        flag = 1
        ans = min(int((n/i)) + i - 2, ans)
        break
if flag==1: pass
else: 
  ans = n + 1 - 2
print(ans)

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

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

b=n
a=[]
N=math.sqrt(n)

for i in range(1,10):
  for j in range(1,10):
      if(i*j==n):
          print ("Yes")
          sys.exit()

print ("No")


import sys
import math
n=int(input())

b=n
a=[]
N=int(math.sqrt(n))

for i in range(1,N+1):
 q, mod=divmod(n,i)
 a=q+i-2

 if(mod==0 and a<b):
     b=a

print(b)


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())
sqN = int(math.sqrt(N))
for i in range(sqN):
  if N % (sqN-i) == 0:
    print(int(N/(sqN-i)+sqN-i))
    break

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

move =[]
for i in range(1, int(n**0.5)+1):
    if n % i == 0:

        move.append(i+n//i)
        if i != n // i:
            divisors.append(n//i)
        


# print(move)
print(min(move)-2)

n = int(input())
move =[]
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        move.append(i+n//i)
# print(move)
print(min(move)-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):
from fractions import gcd
import itertools
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
x_max = 0
y_min = float('inf')
for it in itertools.combinations(divisor(n),2):
    if it[0] * it[1] == n:
        x_max = max(x_max,it[0])
        y_min = min(y_min,it[1])
print(x_max-1+y_min-1) 

import itertools
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
d = divisor(n)
l = float('inf')
for i in range(len(d)):
    l = min(n // d[i] + d[i] - 2,l)
print(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):
import math

n = int(input())

ans  = 10 ** 7 
for i in range(1, math.sqrt(n) + 1):
    if n%i != 0:
        continue
    j = n/i
    ans = min(ans, i+j-2)

print(ans)

import math

n = int(input())

ans  = 10 ** 12 
for i in range(1, math.floor(math.sqrt(n)) + 1):
    if n%i != 0:
        continue
    j = n/i
    ans = min(ans, i+j-2)

print(ans)

import math

n = int(input())

ans  = 10 ** 7 
for i in range(1, math.floor(math.sqrt(n)) + 1):
    if n%i != 0:
        continue
    j = n/i
    ans = min(ans, i+j-2)

print(ans)

import sys

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

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

def main():
    res = divisors(n)
    print(res[-1] + res[-2] - 2)

if __name__ ==  '__main__':
    main()

Verdicts: Runtime Error

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

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

N = int(input())

n = make_divisors(N)
n.sort()
mannaka_ = int(len(n)/2)
mannaka = mannaka_ - 1
#print(n)
if len(n)%2 == 0:
    print((n[mannaka_]-1)+ (n[mannaka]-1))
else:
    print(n[mannaka_] * 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):
n = int(input())
d = 1000000000000000000000
for i in range(1, int(sqrt(n))+1):
  if n % i == 0:
    d = min(d, i + n // i - 2)
print(d)

from math import sqrt
n = int(input())
d = 1000000000000000000000
for i in range(1, sqrt(n)+1):
  if n % i == 0:
    d = min(d, i + n // i - 2)
print(d)


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


from math import sqrt
n = int(input())
d = 1000000000000000000000
for i in range(1, int(sqrt(n))+1):
  if n % i == 0:
    d = min(d, i + n // i - 2)
print(d)


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):
from operator import mul
from functools import reduce

N = int(input())


# (i, j)


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

prime_list = prime_factorize(N)


fact1 = [1]
fact2 = [1]




for i in range(len(prime_list)//2):
    left = i
    right = len(prime_list) - i - 1
    if i % 2 == 0:
        fact1.append(prime_list[left])
        fact1.append(prime_list[right])
    else:
        fact2.append(prime_list[left])
        fact2.append(prime_list[right])
if len(prime_list)%2 == 1:
    if reduce(mul, fact1) > reduce(mul, fact2):
        fact2.append(prime_list[len(prime_list)//2])
    else:
        fact1.append(prime_list[len(prime_list)//2])

#print(fact1, fact2)
print(reduce(mul, fact1) + reduce(mul, fact2) - 2)


import math
N = int(input())
result = N
for i in range(1, int(math.sqrt(N))+2):
    if N % i == 0:
        result = min(result, i - 1 + N//i - 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):
import numpy as np
n=int(input())
l=[n]
for i in range(int(np.sqrt(n))):
  for j in range(i,int(np.sqrt(n))+1):
    if i*j==n:
      l+=[i+j-2]
print(min(l))

import numpy as np
n=int(input())
ans = n-1
for i in range(int(np.sqrt(n))+1):
  if n % i == 0:
    ans = min(ans, i + n/i -2)
print(ans)

import numpy as np
n=int(input())
ans = n-1
for i in range(1,int(np.sqrt(n))+1):
  if n % i == 0:
    ans = min(ans, i + n/i -2)
print(ans)

import numpy as np
n=int(input())
ans = n-1
for i in range(1,int(np.sqrt(n))+1):
  if n % i == 0:
    ans = min(ans, i + n/i -2)
print(int(ans))

Verdicts: 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):
import math
n = int(input())
move = n-1
m = math.ceil(n ** (1/2))
for i in range(1, (m+1)):
    for j in range(1, (m+1)):
        if n == i*j and move > i+j-2:
            move = i+j-2
        else:
            move += 0
print(move)

import math
n = int(input())
move = 0
m = math.ceil(n ** (1/2))
for i in range(1, (m+1)):
    if n %  i == 0:
        move = i + (n/i) - 2
    else:
        pass
print(int(move))

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 divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            tmp = []
            tmp.append(i)
            tmp.append(n//i)
            divisors.append(tmp)
    return divisors

L = divisors(N)
ans = float('inf')
print(L)
for l in L:
    tmp = sum(l) - 2
    ans = min(ans,tmp)
print(ans)

N = int(input())

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

L = divisors(N)
ans = float('inf')

for l in L:
    tmp = sum(l) - 2
    ans = min(ans,tmp)
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):
def solve():
    N = int(input())
    
    r = 0
    for i in range(N - 1, 0, -1):
        if N % i == 0:
            r = (N / i - 1) + (i - 1) 
            break
    
    print(r)

solve()

def solve():
    N = int(input())
    
    r = 0
    for i in range(1, N):
        if N % i == 0:
            r = (N / i - 1) + (i - 1) 
            break
    
    print(r)

solve()

import numpy as np

def solve():
    N = int(input())
    
    r = 1e12
    for i in range(1, int(np.sqrt(N)) + 1):
        if N % i == 0:
            r = min(r, (N / i - 1) + (i - 1))
            
    
    print(int(r))

solve()

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

ans = n

i = 1

while i*i<=n :
  if n%i == 0 :
    d = n/i
    if ans > i*d-2 : ans = i*d-2
  i++
      
print(ans)

n = int(input())
ans = n
i = 1
while i*i<=n :
  if n%i == 0 :
    d = n/i
    if ans > i*d-2 : ans = i+d-2
  i+=1
print(ans)


n = int(input())
ans = n
i = 1
while i*i<=n :
  if n%i == 0 :
    d = n/i
    if ans > i+d-2 : ans = i+d-2
  i+=1
print(ans)


n = int(input())
ans = n
i = 1
while i*i<=n :
  if n%i == 0 :
    d = n//i
    if ans > i+d-2 : ans = i+d-2
  i+=1
print(ans)


Verdicts: Runtime Error

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())
c = n - 1
for i in (1, int(math.sqrt(n)) + 1):
    if n % i == 0:
        c = min(c, i + n // i - 2)
print(c)

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


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

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())
keep=10**100
for i in range(1,10**6+1):
  if n%i==0:
    temp=i+n//i
    if temp<keep:
      keep=temp
print(temp-2)

n=int(input())
keep=10**100
for i in range(1,10**6+1):
  if n%i==0:
    temp=i+n//i
    if temp<keep:
      keep=temp
print(keep-2)

Verdicts: Wrong Answer

Accepted