Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):

import sys
input = sys.stdin.readline
#-------------------------------------

n,x = map(int,input().split())
l = list(map(int,input().split()))

cnt = 1
d = 0

for _ in range(n+1):
    if n is 1:
        d = d+l[0]
        break

    if d+l[cnt-1] <= x:
        d = d+l[cnt-1]
        cnt += 1
        # print(d)
    else:
        break

print(cnt)

Fixed submission:

n,x = map(int,input().split())
l = list(map(int,input().split()))

cnt = 1
d = 0

for _ in range(n):

    if d+l[cnt-1] <= x:
        d = d+l[cnt-1]
        cnt += 1
        # print(d)
    else:
        break

print(cnt)

Buggy python submission (verdict: Runtime Error):

import sys
input = sys.stdin.readline
#-------------------------------------

n,x = map(int,input().split())
l = list(map(int,input().split()))

cnt = 1
d = 0

for _ in range(n+1):
    if d+l[cnt-1] <= x:
        d = d+l[cnt-1]
        cnt += 1
        # print(d)
    else:
        break

print(cnt)

Fixed submission:

n,x = map(int,input().split())
l = list(map(int,input().split()))

cnt = 1
d = 0

for _ in range(n):

    if d+l[cnt-1] <= x:
        d = d+l[cnt-1]
        cnt += 1
        # print(d)
    else:
        break

print(cnt)
Buggy python submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abcXXX
import __input
#-------------------------以下を提出-------------------------

p,q,r = map(int,input().split())
ans = 999
ans = min(p+q,ans)
ans = min(p+r,ans)
ans = min(q+r,ans)

print(ans)

Fixed submission:

p,q,r = map(int,input().split())
ans = 999
ans = min(p+q,ans)
ans = min(p+r,ans)
ans = min(q+r,ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc128
# -*- coding: utf-8 -*-

n,m = map(int,input().split())

k = []
s = []
for i in range(m):
    x = list(map(int,input().split()))
    k.append(x[0])
    y = []
    for j in range(x[0]):
        y.append(x[j+1])
    s.append(y)

p = list(map(int,input().split()))

cnt = 0
for i in range(1024):
    x = format(i,"08b")[::-1]
    if x[n] == "1":
        break

    for j in range(m):
        tmpSum = 0
        for k in s[j]:
            tmpSum += int(x[k-1])
        if tmpSum%2 is not p[j]:
            break
    else:
        cnt += 1
        
print(cnt)

Fixed submission:
#https://atcoder.jp/contests/abc128
# -*- coding: utf-8 -*-

n,m = map(int,input().split())

k = []
s = []
for i in range(m):
    x = list(map(int,input().split()))
    k.append(x[0])
    y = []
    for j in range(x[0]):
        y.append(x[j+1])
    s.append(y)

p = list(map(int,input().split()))

cnt = 0
for i in range(1024):
    x = format(i,"010b")[::-1]
    if n < 10 and x[n] == "1":
        break
    
    for j in range(m):
        tmpSum = 0
        for k in s[j]:
            tmpSum += int(x[k-1])
        if tmpSum%2 is not p[j]:
            break
    else:
        cnt += 1

print(cnt)

Buggy python submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc128
# -*- coding: utf-8 -*-

n,m = map(int,input().split())

k = []
s = []
for i in range(m):
    x = list(map(int,input().split()))
    k.append(x[0])
    y = []
    for j in range(x[0]):
        y.append(x[j+1])
    s.append(y)

p = list(map(int,input().split()))

cnt = 0
for i in range(1024):
    x = format(i,"08b")[::-1]
    if x[n] == "1":
        break

    for j in range(m):
        tmpSum = 0
        for k in s[j]:
            tmpSum += int(x[k-1])
        if tmpSum%2 is not p[j]:
            break
    else:
        cnt += 1

print(cnt)


    

Fixed submission:
#https://atcoder.jp/contests/abc128
# -*- coding: utf-8 -*-

n,m = map(int,input().split())

k = []
s = []
for i in range(m):
    x = list(map(int,input().split()))
    k.append(x[0])
    y = []
    for j in range(x[0]):
        y.append(x[j+1])
    s.append(y)

p = list(map(int,input().split()))

cnt = 0
for i in range(1024):
    x = format(i,"010b")[::-1]
    if n < 10 and x[n] == "1":
        break
    
    for j in range(m):
        tmpSum = 0
        for k in s[j]:
            tmpSum += int(x[k-1])
        if tmpSum%2 is not p[j]:
            break
    else:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

a,b = map(int,input().split())
c = max(a,b)
if a<b:
    a--
    else:
        b--
c += max(a,b)
print(c)


Fixed submission:
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

a,b = map(int,input().split())
c = max(a,b)
if a>b:
    a-=1
else:
    b-=1
c += max(a,b)
print(c)

Buggy python submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

a,b = map(int,input().split())
c = max(a,b)
if a<b:
    a--
    else:
        b--
c += max(a,b)
print(c)


Fixed submission:
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

a,b = map(int,input().split())
c = max(a,b)
if a>b:
    a-=1
else:
    b-=1
c += max(a,b)
print(c)

Buggy python submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

a,b = map(int,input().split())
c += max(a,b)
c += max(a,b)-1
print(c)


Fixed submission:
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

a,b = map(int,input().split())
c = max(a,b)
if a>b:
    a-=1
else:
    b-=1
c += max(a,b)
print(c)
Buggy python submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

n = int(input())
h = list(map(int,input().split()))

current=0
cnt=0
for i in h:
    if i >= current:
        current = i
        cunt += 1

print(cnt)

Fixed submission:
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

n = int(input())
h = list(map(int,input().split()))

current=0
cnt=0
for i in h:
    if i >= current:
        current = i
        cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc123
# -*- coding: utf-8 -*-

n=int(input())
v = [int(input()) for i in range(5)]
city = [ n, 0, 0, 0, 0, 0]

counter = 0
while city[5] is not n:
    counter += 1

    for i in range(5)[::-1]:
        if city[i] >= v[i]:
            city[i+1] += v[i]
            city[i] -= v[i]
        else:
            city[i+1] += city[i]
            city[i] = 0

print(counter)

Fixed submission:
# https://atcoder.jp/contests/abc123
# -*- coding: utf-8 -*-

n=int(input())
v = [int(input()) for i in range(5)]

minimum = min(v)
if n % minimum is 0:
    print((n // minimum)+4)
else:
    print((n // minimum)+5)
Buggy python submission (verdict: Runtime Error):
if d is 0:
    print(n + n//100)
if d is 1:
    if n is 100:
        print(100*100+100)
    else:
        print(n*100)
if d is 2:
    if n is 100:
        print(100*10000+10000)
    else:
        print(n*10000)

Fixed submission:
d,n = map(int,input().split())

if d is 0:
    print(n + n//100)
if d is 1:
    if n is 100:
        print(100*100+100)
    else:
        print(n*100)
if d is 2:
    if n is 100:
        print(100*10000+10000)
    else:
        print(n*10000)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = 0
for v in a:
    while a%2 is 0:
        ans += 1
        a /= 2
print(ans)

Fixed submission:
#!/usr/bin/env python
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
for a in A:
    while a % 2 != 1:
        ans += 1
        a /= 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy

n = int(input())
a = list(map(int,input().split()))

counter = 0
while(True):
    b = deepcopy(a)
    undivided = True
    for i,v in enumerate(b):
        if v%2 is 0 and undivided:
            a[i] = v//2
            undivided = False
        else:
            a[i] = v*3
    if undivided:
        break
    else:
        counter += 1
print(counter)

Fixed submission:
#!/usr/bin/env python
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
for a in A:
    while a % 2 != 1:
        ans += 1
        a /= 2
print(ans)
Buggy python submission (verdict: Runtime Error):
#http://abc081.contest.atcoder.jp/
# -*- coding: utf-8 -*-

a,b,c = map(int,input().split())
print(a+b+c)


Fixed submission:
#http://abc081.contest.atcoder.jp/
# -*- coding: utf-8 -*-

a,b,c = map(int,list(input()))
print(a+b+c)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
for k in range(5):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])
print(sum([sum(map(lambda a: 0 if a == -1 else C[a][1], row)) for row in A])

Fixed submission:
#http://abc079.contest.atcoder.jp/
# -*- coding: utf-8 -*-

n = list(input())

if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
#http://abc078.contest.atcoder.jp/
# -*- coding: utf-8 -*-
n, z, w = map(int,input().split())
a = list(map(int,input().split()))

ans = []
ans.append( abs( a[-1] - w ) )
ans.append( abs( a[-1] - a[-2] ) )
print(max(ans))

Fixed submission:
#http://abc078.contest.atcoder.jp/
# -*- coding: utf-8 -*-
n, z, w = map(int,input().split())
a = list(map(int,input().split()))

ans = []
ans.append( abs( a[-1] - w ) )
if len(a) > 1: ans.append( abs( a[-1] - a[-2] ) )

print(max(ans))
Buggy python submission (verdict: Runtime Error):
#https://beta.atcoder.jp/contests/abc075
# -*- coding: utf-8 -*-
from collections import Counter
import sys

n,m = map(int,input().split())
line = []
for _ in range(m):
    line.append(list(map(int,input().split())))

line_count = []
for i in line:
    line_count.append(i[0])
    line_count.append(i[1])
line_count = Counter(line_count)

start_point = []
for k,v in line_count.items():
    if v == 1: start_point.append(k)
if len(start_point) == 0:
    print(0)
    sys.exit()

counter = 0
while(True):
    start_point_bu = start_point
    start_point = []
    for i in start_point_bu:
        for index,j in enumerate(line):
            if i in j:
                if j[0] == i : start_point.append(j[1])
                if j[1] == i : start_point.append(j[0])
                line.pop(index)
                counter+=1
            break
    if len(start_point)==0: break
print(counter)


Fixed submission:
#https://beta.atcoder.jp/contests/abc075
# -*- coding: utf-8 -*-
a,b,c = map(int,input().split())

if a == b : print(c)
if b == c : print(a)
if c == a : print(b)

Buggy python submission (verdict: Runtime Error):
#https://beta.atcoder.jp/contests/abc075
# -*- coding: utf-8 -*-
from collections import Counter
import sys

n,m = map(int,input().split())
line = []
for _ in range(m):
    line.append(list(map(int,input().split())))

line_count = []
for i in line:
    line_count.append(i[0])
    line_count.append(i[1])
line_count = Counter(line_count)

start_point = []
for k,v in line_count.items():
    if v == 1: start_point.append(k)
if len(start_point) == 0:
    print(0)
    sys.exit()

counter = 0
while(True):
    start_point_bu = start_point
    start_point = []
    for i in start_point_bu:
        for index,j in enumerate(line):
            if i in j:
                if j[0] == i : start_point.append(j[1])
                if j[1] == i : start_point.append(j[0])
                line.pop(index)
                counter+=1
            break
    if len(start_point)==0: break
print(counter)


Fixed submission:
#https://beta.atcoder.jp/contests/abc075
# -*- coding: utf-8 -*-
a,b,c = map(int,input().split())

if a == b : print(c)
if b == c : print(a)
if c == a : print(b)
Buggy python submission (verdict: Runtime Error):
def demon():
  N = int(input())
  A = list(map(int,input().split()))
  A = sort(A)
  if A[0] == 0:
    print(0)
    return

  X = 1
  for i in A:
    X *= A
    if X > 10 ** 18:
      print("-1")
      return

  print(X)

demon()

Fixed submission:
def demon():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  if A[0] == 0:
    print(0)
    return

  X = 1
  for i in A:
    X *= i
    if X > 10 ** 18:
      print("-1")
      return

  print(X)

demon()

Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator
N = int(input())
A = list(map(int,input().split()))
result = functools.reduce(operator.mul, A)
if result > 10 ** 18:
  print("-1")
else:
  print(result)

Fixed submission:
def demon():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  if A[0] == 0:
    print(0)
    return

  X = 1
  for i in A:
    X *= i
    if X > 10 ** 18:
      print("-1")
      return

  print(X)

demon()

Buggy python submission (verdict: Time Limit Exceeded):
X = 1
N = int(input())
A = list(map(int,input().split()))
for i in A:
  X *= i
if X > 10 ** 18:
  print("-1")
else:
  print(X)


Fixed submission:
def demon():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  if A[0] == 0:
    print(0)
    return

  X = 1
  for i in A:
    X *= i
    if X > 10 ** 18:
      print("-1")
      return

  print(X)

demon()
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = N[-1]
if X == 2 or X == 4 or X == 5 or X == 7 or X == 9:
  print("hon")
if X == 3:
  print("bon")
else:
  print("pon")

Fixed submission:
N = input()
X = int(N[-1])
if X == 2 or X == 4 or X == 5 or X == 7 or X == 9:
  print("hon")
elif X == 3:
  print("bon")
else:
  print("pon")
Buggy python submission (verdict: Time Limit Exceeded):
X = list(map(int, input().split()))
N = X[0]
K = X[1]
if N % K == 0:
  print(0)
else:
  while True:
    A = abs(N - K)
    if N > A:
      N = A
    else:
      break
  print(N)

Fixed submission:
X = list(map(int, input().split()))
N = X[0]
K = X[1]
t = N % K
s = K - t
if t <= s:
  print(t)
else:
  print(s)

Buggy python submission (verdict: Time Limit Exceeded):
X = list(map(int, input().split()))
N = X[0]
K = X[1]
if K == 1:
  print(0)
else:
  if K == 2:
    if N % 2 == 0:
      print(0)
    else:
      print(1)
  else: 
    while True:
      A = abs(N - K)
      if N > A:
        N = A
      else:
        break
    print(N)

Fixed submission:
X = list(map(int, input().split()))
N = X[0]
K = X[1]
t = N % K
s = K - t
if t <= s:
  print(t)
else:
  print(s)

Buggy python submission (verdict: Time Limit Exceeded):
X = list(map(int, input().split()))
N = X[0]
K = X[1]
if K == 1:
  print(0)
else:  
  while True:
    A = abs(N - K)
    if N > A:
      N = A
    else:
      break
  print(N)

Fixed submission:
X = list(map(int, input().split()))
N = X[0]
K = X[1]
t = N % K
s = K - t
if t <= s:
  print(t)
else:
  print(s)

Buggy python submission (verdict: Runtime Error):
import math
X = list(map(int, input().split()))
N = X[0]
K = X[1]
A = math.inf
if K == 1:
  print(0)
else:  
  while True:
    A = abs(N - K)
    if N > A:
      N = A
    else:
      break
  print(N)

Fixed submission:
X = list(map(int, input().split()))
N = X[0]
K = X[1]
t = N % K
s = K - t
if t <= s:
  print(t)
else:
  print(s)
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)
A = int((N - 1) / 2)
B = int((A - 1) / 2)
X = 0

for i in range(A):
  if S[i] != S[-i-1]:
    X += 1

if N == 5:
  if S[0] != S[1]:
    X += 1

if N >= 7:
  for i in range(B):
  	if S[i] != S[A-1]:
    	X += 1
      
if X == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
S = input()
N = len(S)
A = int((N - 1) / 2)
if A % 2 == 0:
  B = int(A / 2)
else:
  B = int((A - 1) / 2)
X = 0
 
for i in range(A):
  if S[i] != S[-i-1]:
    X += 1
 
if N >= 5:
  for i in range(B):
  	if S[i] != S[A-1-i]:
  	    X += 1
      
if X == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
S = input()
A = 0
for i in range(n-3):
  clipped_S = S[i:i+2]
  if clipped_S == "ABC"
    A += 1
print(A)

Fixed submission:
n = int(input())
S = input()
A = 0
for i in range(n-2):
  clipped_S = S[i:i+3]
  if clipped_S == "ABC":
    A += 1
print(A)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = input()
ans = []
for i in range(10):
  for j in range(10):
    for k in range(10):
      for x in range(n-2):
        if int(S[x]) == i:
          for y in range(x+1,n):
            if int(S[y]) == j:
              for z in range(y+1,n):
                if int(S[z]) == k:
                  ans.append(100*i+10*j+k)
print(len(set(ans)))

Fixed submission:
n = int(input())
S = input()
ans = 0
for i in range(10):
  x = S.find(str(i))
  if x == -1:
    continue
  for j in range(10):
    y = S.find(str(j),x+1)
    if y == -1:
      continue
    for k in range(10):
      z = S.find(str(k),y+1)
      if z != -1:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = 0
for i in range(1,10):
  for j in range(1,10):
    x = i * j
      if x == n:
        A += 1
if A >= 1:
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
A = 0
for i in range(1,10):
  for j in range(1,10):
    x = i * j
    if x == n:
      A += 1
if A >= 1:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
l = list("ACGT")
A = 0
for i in range(n):
  for j in range(i+1,n+1):
    x = s[i,j]
    if all(k in l for k in x):
      A = max(A,len(x))
print(A)

Fixed submission:
s = input()
n = len(s)
l = list("ACGT")
A = 0
for i in range(n):
  for j in range(i+1,n+1):
    x = s[i:j]
    if all(k in l for k in x):
      A = max(A,len(x))
print(A)
Buggy python submission (verdict: Runtime Error):
a,b,c = input()
A = 0
if a == o:
  A += 1
if b == o:
  A += 1
if c == o:
  A += 1

if A == 3:
  print(1000)
if A == 2:
  print(900)
if A == 1:
  print(800)
if A == 0:
  print(700)

Fixed submission:
a,b,c = input()
A = 0
if a == "o":
  A += 1
if b == "o":
  A += 1
if c == "o":
  A += 1
 
if A == 3:
  print(1000)
if A == 2:
  print(900)
if A == 1:
  print(800)
if A == 0:
  print(700)
Buggy python submission (verdict: Runtime Error):
h, w, k = map(int, input().split())
grid = []
for i in range(h):
    grid.append(input())

count = 0
for i in range(2**h):
    row = []
    while i:
        if i & 1:
            row.append(i & 1)
        i >>= 1
        
        for j in range(2**w):
            col = []
            while j:
                if j & 1:
                    row.append(j & 1)
                j >>= 1
            
            black = 0
            for r, c in row, col:
                if grid[r][c] == "#":
                    black += 1
            
            if black == k:
                count += 1
            
print(count)


Fixed submission:
h, w, k = map(int, input().split())
grid = []
for i in range(h):
    grid.append(input())

count = 0
for i in range(2**h):
    row = []
    r = 0
    while i:
        if i & 1:
            row.append(r)
        i >>= 1
        r += 1

    for j in range(2**w):
        col = []
        c = 0
        while j:
            if j & 1:
                col.append(c)
            j >>= 1
            c += 1

        black = 0
        for r in row:
            for c in col:
                if grid[r][c] == "#":
                    black += 1

        if black == k:
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
friendliness = [int(s) for s in input().split()]

res = friendliness[0] + 2 * sum(friendliness[1:n//2+1]) + (n%2) * friendliness[n//2+1]


Fixed submission:
n = int(input())
friendliness = [int(s) for s in input().split()]

friendliness.sort(reverse=True)
print(friendliness[0] + 2 * sum(friendliness[1:n//2]) + (n%2) * friendliness[n//2])
Buggy python submission (verdict: Runtime Error):
N = int(input())
Dictionary = {}
for i in range(N):
    S = input()
    if S not in Dictionary :
        Dictionary[S] = 1
    else :
        Dictionary[S] = Dictionary[S]+1
sorted_Dic = sorted(Dictionary.items(), key=lambda x: x[1],reverse=True)

ans_list = []
for i in range(N):
    if sorted_Dic[i][1]==sorted_Dic[0][1]:
        ans_list.append(sorted_Dic[i][0])
    else:
        break;
for item in sorted(ans_list):
  print(item)
    

Fixed submission:
N = int(input())
Dictionary = {}
for i in range(N):
    S = input()
    if S not in Dictionary :
        Dictionary[S] = 1
    else :
        Dictionary[S] = Dictionary[S]+1

sorted_Dic = sorted(Dictionary.items(), key=lambda x: x[1],reverse=True)

if len(sorted_Dic)==1:
  print(sorted_Dic[0][0])
else:
  ans_list = []
  for i in range(N):
      if sorted_Dic[i][1]==sorted_Dic[0][1]:
          ans_list.append(sorted_Dic[i][0])
      else:
          break;
  for item in sorted(ans_list):
    print(item)
Buggy python submission (verdict: Runtime Error):
import math
def lcm(a, b):
  return a * b / gcd(a, b)

A, B = map(int,input().split())
print(lcm(A,B))

Fixed submission:
from fractions import gcd
def lcm(a, b):
  return a * b / gcd(a, b)
 
A, B = map(int,input().split())
print(int(lcm(A,B)))
Buggy python submission (verdict: Runtime Error):

N= int(input())
X1 = N / 1.08
X = int(X1)
N_calc = int(X*1.08)
N_calc2 = int((X+1)*1.08)
if N_calc == N :
    print(X)
elif: N_calc2==N:
    print(X+1)
else :
    print(":(")

Fixed submission:
N= int(input())
X1 = N / 1.08
X = int(X1)
N_calc = int(X*1.08)
N_calc2 = int((X+1)*1.08)
if N_calc == N :
    print(X)
elif N_calc2==N:
    print(X+1)
else :
    print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
#C問題
#考え方：平方根に近いところを探す。
#平方根を切り上げた値からスタート。割り切れた時点で終了。
#TLEになった。原因として考えられるのは何か？ものすごい大きな数の時にうまくいかない？
import math
N = int(input())
sq_N = int(math.sqrt(N))
i = 0
while True:
    if N ==1:
        A = 1
        B = 1
        break;
    elif N% (sq_N+i) ==0:
        A = sq_N+i
        B = int(N/A)
        break;
    else:
        i = i+1
print(A-1+B-1)
    

Fixed submission:
#C問題
#考え方：平方根に近いところを探す。
#平方根を切り上げた値からスタート。割り切れた時点で終了。
#TLEになった。原因として考えられるのは何か？ものすごい大きな数の時にうまくいかない？
#素数の時に厳しい。
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
import numpy as np


def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

N = int(input())
lis_1 = make_divisors(N)
A = getNearestValue(lis_1,math.sqrt(N))
B = int(N/A)

print(A+B-2)

Buggy python submission (verdict: Time Limit Exceeded):
#C問題
#考え方：平方根に近いところを探す。
#平方根を切り上げた値からスタート。割り切れた時点で終了。
import math
N = int(input())
sq_N = int(math.sqrt(N))
i = 0
while True:
    if N% (sq_N+i) ==0:
        A = sq_N+i
        B = int(N/A)
        break;
    else:
        i = i+1
print(A-1+B-1)
    
    

Fixed submission:
#C問題
#考え方：平方根に近いところを探す。
#平方根を切り上げた値からスタート。割り切れた時点で終了。
#TLEになった。原因として考えられるのは何か？ものすごい大きな数の時にうまくいかない？
#素数の時に厳しい。
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
import numpy as np


def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

N = int(input())
lis_1 = make_divisors(N)
A = getNearestValue(lis_1,math.sqrt(N))
B = int(N/A)

print(A+B-2)