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

div = make_divisors(n)
print(div)
if len(div)%2 == 0:
    print(div[len(div)//2 - 1]+div[(len(div)//2)]-2)
else:
    print(div[(len(div)//2)]*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())

div = make_divisors(n)
if len(div)%2 == 0:
    print(div[len(div)//2 - 1]+div[(len(div)//2)]-2)
else:
    print(div[(len(div)//2)]*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())
k = 0
while k ** 2 < N:
  k++
for i in range(k, 0, -1):
  if N % i:
    continue
  print(N // i + i - 2)
  break

N = int(input())
k = 0
while k ** 2 < N:
  k += 1
for i in range(k, 0, -1):
  if N % i:
    continue
  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):
N = int(input())

ans = 1

for i in range(1,int(N**0.5)+1):
    if N % i == 0:
        ans = i

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

N = int(input())

ans = 1

for i in range(1,int(N**0.5)+1):
    if N % i == 0:
        ans = i

print(ans+int(N/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())
num = 1
for i in range(1, int(np.sqrt(n))):
    if n % i == 0:
        num = i
ans = int(num -1 + (n / num) -1)
print(ans)

n = int(input())
num = 1
for i in range(1, 11):
    if n % i == 0:
        num = i
ans = int(num -1 + (n / num) -1)
print(ans)

import math
n = int(input())
 
for i in range(int(math.sqrt(n)), 0, -1):
    if n % i == 0:
        num = i
        break
        
ans = int(num -1 + (n / num) -1)
print(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
n = int(input())
m = n-1
for i in range(1,int(math.sqrt(n))):
  if n%i==0:
    m = min(m,i+n/i-2)
print(m)

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

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

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

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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

l = np.empty(n)
l[:] = np.nan
k = 0
for i in range(1,n):
  if n % i == 0:
    l[k] = i + (n / i)
    k += 1
print(int(np.nanmin(l)))

import numpy as np

n = int(input())

l = np.empty(n)
l[:] = np.nan

k = 0
i = 1

while i <= n ** 0.5:
  if n % i == 0:
    l[k] = i + (n / i) - 2
   　k += 1
  i += 1
print(int(np.nanmin(l)))

import numpy as np
import math
n = int(input())
l = np.empty(n)
l = np.nan

k = 0
i = 1
while i <= n ** 0.5:
  if n % i == 0:
    l[k] = i + (n / i) - 2
  i += 1
print(int(np.nanmin(l)))

import numpy as np
import math
n = int(input())
l = np.empty(floor(n ** 0.5))
l = np.nan

k = 0
for i in range(1,floor(n ** 0.5)):
  if n % i == 0:
    l[k] = i + n // i - 2
    k += 1
print(int(np.nanmin(l)))

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

l = np.empty(n)
l[:] = np.nan
k = 0
for i in range(1,n):
  if n % i == 0:
    l[k] = int(i + (n / i))
    k += 1
print(np.nanmin(l))

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

l = np.empty(n)
l[:] = np.nan

for i in range(n):
  if n % i == 0:
    l[i] = int(i + (n / i))
print(np.min(l))

import numpy as np
import math
n = int(input())
l = np.empty(n)
l = np.nan

k = 0
i = 1
while i <= n ** 0.5:
  if n % i == 0:
    l[k] = i + (n / i) - 2
   　k += 1
  i += 1
print(int(np.nanmin(l)))

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

l = np.empty(n)
l[:] = np.nan
k = 0
for i in range(n):
  if n % i == 0:
    l[k] = int(i + (n / i))
    k += 1
print(np.min(l))

import numpy as np
import math
n = int(input())
l = np.empty(floor(n ** 0.5))
l = np.nan

k = 0
for i in range(floor(n ** 0.5)):
  if n % i == 0:
    l[k] = i + n // i - 2
    k += 1
print(int(np.nanmin(l)))

import numpy as np
import math
n = int(input())
l = np.empty(n)
l = np.nan

k = 0
while i <= n ** 0.5:
  if n % i == 0:
    l[k] = i + n / i - 2
  i += 1
print(int(np.nanmin(l)))

n = int(input())

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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 = int(input())
a = int(N**0.5)
ans = 10**6
for x in range(0,a+1):
    b = N / x
    if b == int(b):
        if a + b - 2 < ans:
            ans = a+b-2
print(ans)

N = int(input())
a = int(N**0.5)
ans = 10 ** 12
for x in range(1,a+1):
    b = N / x
    if b == int(b):
        if x + b - 2 < ans:
            ans = x+b-2
print(int(ans))

Verdicts: Runtime Error

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

Submission attempts (in order):
n = int(input())
l = []
for i in range(1,n):
    sur = n%i
    ans = n/i
   # print(i,ans,sur)
    if ans < i:
        break
    elif sur == 0:
        l.append(i)
l.sort(reverse=True)
max = l[0]
max_op = n/max
ite = max-1+max_op-1
print(ite)

n = int(input())
l = []
for i in range(1,n):
    sur = n%i
    ans = n/i
   # print(i,ans,sur)
    if ans < i:
        break
    elif sur == 0:
        l.append(i)
l.sort(reverse=True)
max = l[0]
max_op = n/max
ite = max-1+max_op-1
print(int(ite))

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

def factortwo(N):
    factors = []
    for i in range(1, int(math.sqrt(N))+1):
        if N % i == 0:
            factors.append((i, N // i))
    return factors

print(sum(factortwo(N)[-1]))

import math

N = int(input())

def factortwo(N):
    factors = []
    for i in range(1, int(math.sqrt(N))+1):
        if N % i == 0:
            factors.append((i, N // i))
    return factors

print(sum(factortwo(N)[-1]) - 2)

Verdicts: Wrong Answer

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

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


def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        for n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors
div = make_divisors(N)
a = div[0]
b = N // a
ans = (a - 1) + (b - 1)
print(ans)

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(reverse=True)
    return divisors
div = make_divisors(N)
l = len(div) // 2
a = div[l]
b = N // a
ans = (a - 1) + (b - 1)
print(ans)

Verdicts: Runtime Error

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

Submission attempts (in order):
import math

def f(n):
    divisor = [1]
    limit = math.ceil(math.sqrt(n))
    for n2 in range(2, limit+1):
        if n % n2 == 0:
            divisor.append(n2)
    n1 = max(divisor)
    n2 = n // n1
    return n1 + n2 - 2

n = int(input())
f(n)


import math

def f(n):
    divisor = [1]
    limit = math.ceil(math.sqrt(n))
    for n2 in range(2, limit+1):
        if n % n2 == 0:
            divisor.append(n2)
    n1 = max(divisor)
    n2 = n // n1
    print(n1 + n2 - 2)

n = int(input())
f(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())
ans = []
for i in range(N):
	if i**2 > N:
		left = (i-1)
		break

for i in reversed(range(N)):
	if i**2 <N:
		right = (i-1)
		break
print(left,right)
left,right=right,left

for i in range(left**2,right**2+1):
	if N%i==0:
		ans.append(i+N//i-2)

print(min(ans))

N = int(input())
a,b = 0,0
t = 10**13
for i in range(1,int(N**0.5)+1):
	if N%i == 0:
		if t >= N//i + i:
			t = N//i + i
			


print(t-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())
result = []
for i in tqdm(range(1, N+1)):
    if N % i == 0:
        result.append(i+int(N/i)-2)
print(min(result))

import numpy as np
N = int(input())
result = []
for i in range(1, np.sqrt(N).astype(int)+1):
    if N % i == 0:
        result.append(i+int(N/i)-2)
print(min(result))

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())
i,j=1,1
C=[(i,j)]
while True:
    p=C.pop(0)
    if p[0]*p[1]==N:
      print(p[0]+p[1]-2)
      break
    else:
      C.append((i+1,j))
      C.append((i,j+1))
      i+=1
      j+=1

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

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

Verdicts: Time Limit Exceeded

Wrong Answer

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

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


m = 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)


x=1

for i in a[::-1]:
  x *= i
  if x*x > m:
    x //= i
    break

y = m // x
ans = x + y -2

print(ans)



n = int(input())

ans = 0
for i in range(1,n):
    if n % i == 0:
      if ans == 0:
        ans = i + n//i
      else:
        ans = min(ans, i + n//i)
    if i**2 >= n:
      break

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())
dp = []
dp[0] = 0
i = 1
j = 1
for k in range(1,N):
  dp[k] = max(i+1*j,i*j+1)
  if max(i+1*j,i*j+1) == i+1*j:
    i += 1
  elif max(i+1*j,i*j+1) == i*j+1:
    j += 1
  if N == dp[k]:
    print(k)
    break


N = int(input())
ans = 10**12
for i in range(1,10**6+1):
  j = N//i
  if i*j == N:
    ans = min(i+j-2,ans)
  if i == 10**6 and ans == 10**12:
    ans = N-1
    break
print(ans)

Verdicts: Runtime Error

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

Submission attempts (in order):
import numpy as np

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

print(N-1)

import numpy as np

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

print(N-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 sys
n = int(input())
ans = 10**12

for k in range(1,(n+1)**0.5):
    if n%k == 0 :
        m = n//k + k - 2
        if ans > m:
            ans = m
        else:
            print(ans)
            sys.exit()
print(ans)

n = int(input())
ans = 10**12

for k in range(1,int((n)**0.5)+2):
    if n%k == 0 :
        m = n//k + k - 2
        if ans > m:
            ans = m
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());print(min(x+n/x-2for x in range(1,int(n**.5)+1)if n%x<0))

def main():
  n=int(input())
  t=0
  for x in range(1,int(n**0.5)+1):
    if n%x==0:
      return x+n//x-2
  return n-1
if __name__ == '__main__':
  print(main())

n=int(input());print(min(x+n//x-2for x in range(1,int(n**.5)+1)if n%x<1))

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())
check = []
k = int()
for i in range(int( N ** (1/2) ) + 1 , 2 , -1 ):
    if N % i == 0:
        k = int( N / i )
        check.append(i + k - 2)
        
print(min(check))

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

print( min(check_list) )

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

import math

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

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

k = math.floor(math.sqrt(n))

import math

n = int(input())

k = math.ceil(math.sqrt(n))

for i in reversed(range(k+1)):
  if n/i == n//i:
    print(int(n/i + i -2))
    exit()
    

Verdicts: Wrong Answer

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

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
#
# abc144 c
#
import unittest
from io import StringIO
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    N = int(input())

    S = round(math.sqrt(N))

    for i in range(S):
        for j in range(i, S):
            if i*j == N:
                print(i+j-2)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[: -1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """10"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """50"""
        output = """13"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10000000019"""
        output = """10000000018"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


#
# abc144 c
#
import unittest
from io import StringIO
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    N = int(input())

    S = math.ceil(math.sqrt(N))
    ans = N - 1

    for i in range(1, S+1):
        if N % i == 0:
            j = N // i
            ans = min(ans, i+j-2)
    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[: -1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """10"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """50"""
        output = """13"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10000000019"""
        output = """10000000018"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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())
sn=int(math.sqrt(n))
tl=list(range(1,sn+1))
ans=0
for i in range(1,sn+1):
    a=n/tl[-i]
    if a.is_integer():
        ans=int(a)
        break
b=int(n/ans)
print(n,ans,b)
print(ans-1+b-1)

import math
n=int(input())
sn=int(math.sqrt(n))
tl=list(range(1,sn+1))
ans=0
for i in range(1,sn+1):
    a=n/tl[-i]
    if a.is_integer():
        ans=int(a)
        break
b=int(n/ans)
print(ans-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):
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

BIG_NUM = 200000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
ans = BIG_NUM

for i in range(0,int(np.sqrt(N))):
    if N % i == 0:
        j = N//i
        ans = min(ans, i+j-2)

print(ans)


from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

BIG_NUM = 200000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
ans = N

for i in range(1,int(np.sqrt(N))+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())
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)
i = 0
div = make_divisors(n)
div.sort()
while True:
    if div[i]*div[i+1] == n:
        print(div[i]+div[i+1]-2)
        break
    elif div[i]*div[i] == n:
        print(div[i]+div[i]-2)
        break     
    else:
        i += 1

n = int(input())
div = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        div.append(i)
        if i != n // i:
            div.append(n//i)
i = 0
div.sort()
while True:
    if div[i]*div[i+1] == n:
        print(div[i]+div[i+1]-2)
        break
    elif div[i]*div[i] == n:
        print(div[i]+div[i]-2)
        break     
    else:
        i += 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 sys
import math
N = int(input())
for i in range(math.ceil(math.sqrt(N)),2,-1):
    if N % i ==0:
        print(N//i + i-2)
        sys.exit()
print(N-1)

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

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

import math 
def get_prime(n):
    
    if n <=1:
        return []
    prime = [2]
    limit = int(math.sqrt(n))
    
    
    data = [i+1 for i in range(2,n,2)]
    while limit > data[0]:
        prime.append(data[0])
        data = [j for j in data if j % data[0] !=0]
    return prime + data
from itertools import combinations
import functools
import operator
P = get_prime(N)
m = N+1
memo = []
for i in range(1,len(P)+1):
    L1 = list(combinations(P,i))
    L1 = [list(l) for l in L1]
    for l in L1:
        if l not in memo:
            memo.append(l)
            s1 = functools.reduce(operator.mul,l)
            s2 = N/s1
            if s1+s2 <=m:
                m = s1+s2
print(int(m-2))

N = int(input())
ans = N*3
for i in range(1,int(N**0.5)+1):
    if N%i==0:
        s1 = i
        s2 =N/i
        
        if ans > s1+s2:
            ans =int(s1+s2)
print(ans-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 math
import sys
a = int(input())
n = int(math.sqrt(a))
print(n)

result = sys.maxsize

for i in range(1,n):
  if a%i==0:
    b=a/i
    m = i+b-2
    print(i,b,m)
    if result>m:
      result = m
      
print(result)

from math import sqrt
from sys import exit

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: 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
sys.setrecursionlimit(100000)

N = int(input())

min = float('inf')

def dfs(x, y, count):
    global min

    if x<0 or y<0 or (((x+1)*(y+1))>N):
        return

    if (x+1)*(y+1)==N:
        
        if min > count:
            min = count
            return
        return

    dfs(x+1, y, count+1)
    dfs(x, y+1, count+1)

    return

dfs(0,0,0)

while 

print(min)

N = int(input())

ans_list = []
for a in range(1, int(N**0.5)+1, 1):
    if N%a==0:
        ans_list.append([a,N//a])

ans = float('inf')
for a,b in ans_list:
    ans = min(ans, a+b-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):
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())

d=make_divisors(n)


count=0
ans=[]
for i in d:
    pair=n/i
    count=(pair-1)+(i-1)
    ans.append(count)

print(min(ans))


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

d=make_divisors(n)


count=0
ans=[]
for i in d:
    pair=n//i
    count=(pair-1)+(i-1)
    ans.append(count)

print(min(ans))

Verdicts: Wrong Answer

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

Submission attempts (in order):
import math
N = int(input())
Min = float('inf')
Max = math.ceil(math.sqrt(N))
for i in range(1,Max+1):
    if N%i==0:
        b = N//i
        Min = min(Min,i+b-2)
print(Min

import math
N = int(input())
Min = float('inf')
Max = math.ceil(math.sqrt(N))
for i in range(1,Max+1):
    if N%i==0:
        b = N//i
        Min = min(Min,i+b-2)
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):
N = int(input())

ans=N
for i in range(1, int(N**0.5+1)):
    if N%i==0:
        a = N/i
        b = N/a
        up_ans = a + b -2
        print(up_ans)
        ans = min(ans, up_ans)
    else:
        continue
print(int(ans))

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

list=[]

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

n=int(input())

list=[]

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

import math

n = int(input())

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

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 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())
lst = make_divisors(N)
lst.sort()
for i in range(N):
    if lst[i]*lst[i+1] >= N:
        break
print(lst[i+1]-lst[i])

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())
lst = make_divisors(N)
lst.sort()
for i in range(N):
    if lst[i] * lst[i+1] >= N:
        break
if lst[i] ** 2 == N:
    print(lst[i] * 2 - 2)
else:
    print(lst[i+1]-1+lst[i]-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())

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

total=sorted(make_divisors(N))
print(total[1]-1+total[len(total)-2]-1)

n=int(input())

d=[]
for h in range(1, int(n**0.5)+1):
	if n%h == 0:
		j=n//h
		d.append(j)
		i=n//j

print(i-1+j-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())
m = n**0.5
ans = 0
#print(n)
#print(m)
for i in range(1,math.floor(m+1)):
    if m%i==0:
        ans = i
    else :
        ans = 1
print(math.floor(ans+ n/ans -2))

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

import math
n = int(input())
m = n**0.5
ans = 1
x = 0 
#print(n)
#print(m)
for i in range(1,math.floor(m)+1):
    x += 1 
    if n%i==0:
        ans = i

print(math.floor(ans+ n/ans -2))

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

N = int(input())
A = []
for p in range(2,int(math.sqrt(N))+1):
    if N%p != 0:
        print(N-1)
        break
    else:
        for i in range(N//2+1):
            for j in range((N-i)//2+1):
                if N == i*j:
                    A.append(i+j-2)
    print(min(A))

C:\pycharm\code_atcoder\venv\Scripts\python.exe C:/pycharm/code_atcoder/144C.py
100019
100018

プロセスは終了コード 0 で完了しました


import math

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

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):
# coding:utf8
from collections import  Counter

n=int(input())

ans=10**12+1

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

t=divisor(n)
for i in range(0,len(t)//2):
    if i%2==0:
        tmp=t[i]+(n//t[i])-2
        ans=min(ans,tmp)

print(ans)

# coding:utf8
from collections import  Counter

n=int(input())

ans=10**12+1

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(table)
    table.sort()
    return table

t=divisor(n)
for i in range(0,len(t)//2):
    tmp=t[i]+(n//t[i])-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):
n = int(input())
for i in range(-int(-n**0.5//1),0,-1):
  if n%i==0:
    a=i
    b=n//i
print(a+b-2)

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

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

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

def prime_factorize(n):
    a = []
    time = 0
    while n % 2 == 0:
        a.append(2)
        n //= 2
    ff = 3
    while ff * ff <= n:
        if n % ff == 0:
            a.append(ff)
            n //= ff
        else:
            ff += 2

    if len(a) == 0 and time == 0:
        a.append(1)
        time = 1
    if n != 1:
        a.append(n)
    return a

print(prime_factorize(N))

f = []
serch_mini = []


for i in range(len(prime_factorize(N))):
    f = prime_factorize(N)
    b = f[0:i+1]
    c = f[i+1:]
    bb = 1
    cc = 1
    for j in range(len(b)):
        bb *= b[j]
    for k in range(len(c)):
        cc *= c[k]
    serch_mini.append(bb+cc)

print(min(serch_mini)-2)


N = int(input())
n = int((N ** 0.5)//1 + 1)

ans = 1000000
ans_list = []

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

print(int(min(ans_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):
if __name__ == '__main__':

	n = int(input())
	m = int(n//2)

	end = n - 1
	for x in range(2,int(n**0.5)+1):
		if n % x == 0:
			y = n // x
			end = min(n+m-2,end)

	print(end)


if __name__ == '__main__':

	n = int(input())
	m = int(n//2)

   	end = n - 1
	for x in range(2,int(n**0.5)+1):
		if n % x == 0:
			y = n // x
			end = min(x+y-2,end)

	print(end)


if __name__ == '__main__':

	n = int(input())
	m = int(n//2)

	end = n - 1
	for x in range(2,int(n**0.5)+1):
		if n % x == 0:
			y = n // x
			end = min(x+y-2,end)

	print(end)

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):
N = int(input())
yakusuu_list = []
for i in range (1,N+1):
  if N % i == 0:
    yakusuu_list.append([i,N/i])
kyori_list =[]
for a in yakusuu_list:
  [i,j] = a
  kyori_list.append(i+j-2)
print(min(kyori_list))
  

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

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

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

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

Verdicts: Wrong Answer

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):
abc = input()
abc_int = int(abc)
prolist = []
chk = abc_int
print(chk)
for c1 in range(chk):
    for c2 in range(chk):
        if (c1+1)*(c2+1) == abc_int:
            prolist.append(c1+c2)
print(min(prolist))

abc = input()
abc_int = int(abc)
prolist = []
chk = int(abc_int**0.5)
print(chk)
for c1 in range(chk):
    for c2 in range(chk):
        if (c1+1)*(c2+1) == abc_int:
            prolist.append(c1+c2)
print(min(prolist))

abc = input()
abc_int = int(abc)
prolist = []
chk = int(abc_int**0.5)+2
for c1 in range(chk):
	if abc_int % (c1+1) == 0:
		prolist.append(c1+1+abc_int//(c1+1)-2)
print(min(prolist))

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

n=int(input())
import math
l= n-1
for i in range (1,int(math.sqrt(n))+1):
  if n % i ==0 and i+ n/i -2<l:
    l = i + n/i -2
print(int(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):
from operator import itemgetter
n = int(input())

list_p = []
for i in range(n):
    for j in range(n - i):
        if i*j == 100:
            list_p.append([i, j, i+j])
list_sorted = sorted(list_p, key=itemgetter(2))
print(list_sorted[0][0] + list_sorted[0][1] - 2)

from operator import itemgetter
n = int(input())

list_p = []
for i in range(1, int(n**0.5)+1):

    j = n / i

    if j.is_integer():
        list_p.append([i, j, i+j])

list_sorted = sorted(list_p, key=itemgetter(2))
print(int(list_sorted[0][0] + list_sorted[0][1] - 2))


Verdicts: Runtime Error

Accepted