Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    N = II()
    l_list = LI()

    # 短い順
    l_list = sorted(l_list)
    ind_list = list(range(len(l_list)))

    from bisect import bisect_left, bisect_right
    from itertools import combinations
    dprint(l_list)
    cnt = 0
    for a, b in combinations(ind_list, 2):
        # 2つえらぶ
        # 残りでできたl_listを作る
        cand_list = []
        for c in range(len(l_list)):
            if c != a and c!= b:
                cand_list.append(l_list[c])

        # cのmax, min
        la = l_list[a]
        lb = l_list[b]

        mx = la + lb
        mn = max(la, lb) - min(la, lb)

        # cand_listをbisectする
        right_ind_plus1 = bisect_left(cand_list, mx)
        left_ind = bisect_right(cand_list, mn)

        dprint(la, lb, mn, mx, cand_list, left_ind, right_ind_plus1, cnt)
        cnt += right_ind_plus1 - left_ind

    print(cnt//3)

solve()

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    N = II()
    l_list = LI()

    # 短い順
    l_list = sorted(l_list)
    ind_list = list(range(len(l_list)))

    from bisect import bisect_left, bisect_right
    from itertools import combinations
    dprint(l_list)
    cnt = 0
    for a, b in combinations(ind_list, 2):
        # 2つえらぶ

        # 残りでできたl_listを作る
        # cand_list = []
        # for c in range(len(l_list)):
        #     if c != a and c!= b:
        #         cand_list.append(l_list[c])

        # cのmax, min
        la = l_list[a]
        lb = l_list[b]

        mx = la + lb
        mn = max(la, lb) - min(la, lb)

        # cand_listをbisectする
        right_ind_plus1 = bisect_left(l_list, mx)
        left_ind = bisect_right(l_list, mn)

        # dprint(la, lb, mn, mx, l_list, left_ind, right_ind_plus1, cnt)

        cnt += right_ind_plus1 - left_ind

        if left_ind <= a and a < right_ind_plus1:
            cnt -= 1

        if left_ind <= b and b < right_ind_plus1:
            cnt -= 1

    print(cnt//3)

solve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10 ** 7)
debug = True

debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()

INF = 10 ** 18
MOD = 10 ** 9 + 7

def main():
    N = II()
    S = SI()

    mark = [-1 for i in range(N)]

    from collections import defaultdict
    posd = defaultdict(list)

    for i, c in enumerate(S):
        posd[c].append(i)

    for i in range(N):
        si = S[i]

        # headの文字の位置のリスト
        pos_list = posd[si]

        for pos in pos_list:
            if pos >= i:
                # 自分より前のところだけを探す
                continue

            # どこまであうかをやっていく
            for j in range(N):
                # 自分のところまで来てたらやめる
                if pos+j == i:
                    break
                # 突き抜けたらやめる
                if i+j == N:
                    break

                you = pos + j
                me = i + j

                # 違ったらやめる
                if S[you] != S[me]:
                    break

                # 同じなら、マークする
                mark[you] = max(mark[you], j)

    print(max(mark)+1)



main()

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
debug = True

debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()

INF = 10 ** 18
MOD = 10 ** 9 + 7

def main():
    N = II()
    S = SI()

    mark = [-1 for i in range(N)]

    from collections import defaultdict
    posd = defaultdict(list)

    for i, c in enumerate(S):
        posd[c].append(i)

    for i in range(N):
        si = S[i]

        # headの文字の位置のリスト
        pos_list = posd[si]

        for pos in pos_list:
            if pos >= i:
                # 自分より前のところだけを探す
                continue

            # この場合は直前により長いシーケンスを見ているので見なくていい
            if pos > 0 and S[pos - 1] == S[i - 1]:
                continue

            # どこまであうかをやっていく
            for j in range(N):
                # 前回見たシーケンスは見ない
                # 自分のところまで来てたらやめる
                if pos+j == i:
                    break
                # 突き抜けたらやめる
                if i+j == N:
                    break

                you = pos + j
                me = i + j

                # 違ったらやめる
                if S[you] != S[me]:
                    break

                # 同じなら、マークする
                mark[you] = max(mark[you], j)

    dprint(mark)
    print(max(mark)+1)



main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

mx = 10**9 + 7

from math import factorial
# def npr(n, r):
#     ans = math.factorial(n+r) // (math.factorial(n) * math.factorial(r))
#     return ans

def ncr(n, r):
    a = factorial(n) // (factorial(r) * factorial(n - r))
    return a

def solve():
    N, K = map(int, input().split())
    M = N - K

    for i in range(1, K+1):
        # まず、赤がM個あるので、両端を含む隙間 M+1 から、i個選ぶ
        agroup = ncr(M+1, i)

        # そのあと、青iこの箱にKをを分ける
        bagroup = ncr(K-1, i-1)

        print((agroup * bagroup) % mx)

solve()

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

mx = 10**9 + 7

from math import factorial
# def npr(n, r):
#     ans = math.factorial(n+r) // (math.factorial(n) * math.factorial(r))
#     return ans

def ncr(n, r):
    a = factorial(n) // (factorial(r) * factorial(n - r))
    return a

def solve():
    N, K = map(int, input().split())
    M = N - K

    for i in range(1, K+1):
        if M+1 < i:
            print(0)
            continue
        # まず、赤がM個あるので、両端を含む隙間 M+1 から、i個選ぶ
        agroup = ncr(M+1, i)

        # そのあと、青iこの箱にKをを分ける
        bagroup = ncr(K-1, i-1)

        print((agroup * bagroup) % mx)

solve()
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = input()

blk_list = []
for i in range(len(s)):
  if i==0:
    blk = {'n':0, 's':s[i]}
  if i > 1 and s[i-1]!=s[i]:
    blk_list.append(blk)
    blk = {'n':0, 's':s[i]}

  blk['n'] += 1
blk_list.append(blk)

# iblkの始点を1が連続する箇所の始点とするときの数を見る

mx = 0
for i, blk in enumerate(blk_list):
  if blk['s'] == '0':
    if i == 0:
      endi = i + 2*k - 1
    else:
      continue
  if blk['s'] == '1':
    endi = i + 2*k
    
  sm = blk['n']
  for j in range(i+1, min(len(blk_list), endi+1)):
    sm += blk_list[j]['n']
      
  if sm > mx:
    mx = sm
print(mx)
      





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

blk_num = []
blk_sum = []
for i in range(len(s)):
  if i == 0 or s[i-1]!=s[i]:
    if i!= 0:
      blk_sum.append(n)
    blk_num.append(s[i])
    n = 0
  n += 1

blk_sum.append(n)

def cumsum(x):
    y = []
    current = 0
    for i in x:
        y.append(current + i)
        current += i
    return y

blk_csum = cumsum(blk_sum)
# iblkの始点を1が連続する箇所の始点とするときの数を見る

mx = 0
for i, n in enumerate(blk_num):
  if n == '0':
    endi = i + 2*k - 1
    endi = min(len(blk_num)-1, endi)
    if i == 0:
      sm = blk_csum[endi]
    else:
      continue
  else:
    endi = i + 2*k
    endi = min(len(blk_num)-1, endi)
    if i == 0:
      sm = blk_csum[endi]
    else:
      sm = blk_csum[endi] - blk_csum[i-1]
  if sm > mx:
    mx = sm
print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

class UnionFind:

    def __init__(self, n):
        self.parents = [i for i in range(n)]

    def merge(self, i, j):
        rooti = self.findroot(i)
        rootj = self.findroot(j)
        self.parents[rooti] = rootj

    def issame(self, i, j):
        rooti = self.findroot(i)
        rootj = self.findroot(j)
        return rooti == rootj

    def findroot(self, i, followed_indices=None):

        if i == self.parents[i]:
            return i
        else:
            root = self.findroot(self.parents[i])
            self.parents[i] = root # 経路圧縮
            return root
          
n, m = LI()
edge_list = []
for i in range(m):
  a, b = LI()
  edge_list.append((a-1, b-1))
  
ans = []

uf = UnionFind(n)
import collections

for e in edge_list[::-1]:
  p = [uf.findroot(i) for i in range(n)]
  c = collections.Counter(p)
  fuben = 0
  for k in c.keys():
    fuben += c[k] * (n-c[k])
  ans.append(fuben//2)
  uf.merge(e[0], e[1])

for a in ans[::-1]:
  print(a)


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

class UnionFind:

    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.size_dict = {i:1 for i in range(n)}
        self.fuben = n * (n-1) / 2

    def merge(self, i, j):
        rooti = self.findroot(i)
        rootj = self.findroot(j)
        if rooti == rootj:
          return
        self.parents[rooti] = rootj
        sj = self.size_dict[rootj]
        si = self.size_dict[rooti]
        self.fuben -= sj*(n-sj)/2
        self.fuben -= si*(n-si)/2
        self.fuben += (sj+si)*(n-(sj+si))/2
        self.size_dict[rootj] += self.size_dict[rooti]
        self.size_dict[rooti] = 0

    def issame(self, i, j):
        rooti = self.findroot(i)
        rootj = self.findroot(j)
        return rooti == rootj

    def findroot(self, i, followed_indices=None):

        if i == self.parents[i]:
            return i
        else:
            root = self.findroot(self.parents[i])
            self.parents[i] = root # 経路圧縮
            return root
          
n, m = LI()
edge_list = []
for i in range(m):
  a, b = LI()
  edge_list.append((a-1, b-1))
  
ans = []

uf = UnionFind(n)
import collections

for e in edge_list[::-1]:
  ans.append(int(uf.fuben))
  uf.merge(e[0], e[1])

for a in ans[::-1]:
  print(a)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def calcans(ans, a_list):  
  sm = 0
  for a in a_list:
    sm += a^ans
  print(sm)

def solve():
  N, K = LI()
  a_list = LI()
  if K == 0:
    calcans(0, a_list)
    return
  # Kの可能な最大桁（1オリジン）
  import math
  nk = math.floor(math.log2(K)) + 1
  bink = '{0:030b}'.format(K)
  bin_list = []
  for a in a_list:
    bin_list.append('{0:030b}'.format(a))

  # 最大の桁から順に決める nk桁目～1桁目
  bind = True
  ans = ''
  for i in range(nk, 0, -1):
    n1 = 0
    for b in bin_list:
      # i桁目の数字は string の index で見て -i
      if b[-i] == '1':
        n1 += 1

    if n1 > N // 2:
      optimal = '0'
    else:
      optimal = '1'

    if bink[-i] == '1':
      ans += optimal
      if optimal == '0':
        bind = False
    else:
      if bind == True:
        ans += '0'
      else:
        ans += optimal

  ansint = int(ans, 2)
  calcans(ansint, a_list)
  
solve()

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def calcans(ans, a_list):  
  sm = 0
  for a in a_list:
    sm += a^ans
  print(sm)

def solve():
  N, K = LI()
  a_list = LI()
  if K == 0:
    calcans(0, a_list)
    return
  # Kの可能な最大桁（1オリジン）
  import math
  nk = math.floor(math.log2(K)) + 1
  bink = '{0:050b}'.format(K)
  bin_list = []
  for a in a_list:
    bin_list.append('{0:050b}'.format(a))

  # 最大の桁から順に決める nk桁目～1桁目
  bind = True
  ans = ''
  for i in range(nk, 0, -1):
    n1 = 0
    for b in bin_list:
      # i桁目の数字は string の index で見て -i
      if b[-i] == '1':
        n1 += 1

    if n1 > N // 2:
      optimal = '0'
    else:
      optimal = '1'

    if bink[-i] == '1':
      ans += optimal
      if optimal == '0':
        bind = False
    else:
      if bind == True:
        ans += '0'
      else:
        ans += optimal

  ansint = int(ans, 2)
  calcans(ansint, a_list)
  
solve()
Buggy python submission (verdict: Runtime Error):
def solve():
    c = []
    c.append(map(int, input().split()))
    c.append(map(int, input().split()))
    c.append(map(int, input().split()))

    a1_list = range(c[0][0]+1)
    for a1 in a1_list:
        b1 = c[0][0] - a1
        b2 = c[0][1] - a1
        b3 = c[0][2] - a1

        a2 = c[1][0] - b1
        a3 = c[2][0] - b2

        if c[1][1] != a2 + b2:
            continue
        if c[1][2] != a2 + b3:
            continue
        if c[2][1] != a3 + b2:
            continue
        if c[2][2] != a3 + b3:
            continue
        print("Yes")
        return

    print("No")
    return

solve()

Fixed submission:
def solve():
    c = []
    c.append(list(map(int, input().split())))
    c.append(list(map(int, input().split())))
    c.append(list(map(int, input().split())))

    a0_list = range(c[0][0]+1)

    for a0 in a0_list:
        b0 = c[0][0] - a0
        b1 = c[0][1] - a0
        b2 = c[0][2] - a0

        a1 = c[1][0] - b0
        a2 = c[2][0] - b0

        if c[1][1] != a1 + b1:
            continue
        if c[1][2] != a1 + b2:
            continue
        if c[2][1] != a2 + b1:
            continue
        if c[2][2] != a2 + b2:
            continue
        print("Yes")
        return

    print("No")
    return

solve()
Buggy python submission (verdict: Runtime Error):
def solve():
    h, w = map(int, input().split())
    maze = []
    for i in range(h):
        maze.append(list(map(int, input().split())))

    nwall = 0
    for i in range(h):
        for j in range(w):
            if maze[i][j] == '#':
                nwall += 1

    q = []
    q.insert(0, (0,0))
    hist = [[0 for i in range(w)] for j in range(h)]


    while(len(q) > 0):
        x, y = q.pop()

        if x == w-1 and y == h-1:
            break

        for i in range(0, 4):
            nx, ny = x+[1,0,-1,0][i], y+[1,0,-1,0][i]

            if nx<0 or nx>=w or ny<0 or ny>=h:
                continue
            if maze[ny][nx] == '#':
                continue
            if hist[ny][nx] == 1:
                continue

            q.insert(0, (nx,ny))
            hist[nx][ny] = hist[x][y] + 1

    print(h*w - nwall - hist[h-1][w-1])

solve()

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

    # for i in range(h):
    #     print(maze[i])

    nwall = 0
    for i in range(h):
        for j in range(w):
            if maze[i][j] == '#':
                nwall += 1

    q = []
    q.insert(0, (0,0))
    hist = [[0 for i in range(w)] for j in range(h)]
    hist[0][0] = 1


    while(len(q) > 0):
        x, y = q.pop()

        if x == w-1 and y == h-1:
            return h*w - nwall - hist[h-1][w-1]

        for i in range(0, 4):
            nx, ny = x+[1,0,-1,0][i], y+[0,1,0,-1][i]

            if nx<0 or nx>=w or ny<0 or ny>=h:
                continue
            if maze[ny][nx] == '#':
                continue
            if hist[ny][nx] >= 1:
                continue
            # print("x,y", x,y)
            # print("nx,ny", nx,ny)

            q.insert(0, (nx,ny))
            hist[ny][nx] = hist[y][x] + 1

    return -1


print(solve())
Buggy python submission (verdict: Runtime Error):
n, h = input().split()
n = int(n)
h = int(h)

a = []
b = []
for i in range(n):
    a_, b_ = input().split()
    a.append(int(a_))
    b.append(int(b_))

import numpy as np
a = np.array(a)
b = np.array(b)

to_throw = b[b>max(a)]
sum_throw = sum(to_throw)

d = h - sum_throw

if d <= 0:
    cum = np.cumsum(np.sort(b)[::-1])
    print(len(to_throw) - len(cum[cum>=h])) + 1
else:
    import math
    print(len(to_throw) + math.ceil(d/max(a)))


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

a = []
b = []
for i in range(n):
    a_, b_ = input().split()
    a.append(int(a_))
    b.append(int(b_))

import numpy as np
a = np.array(a)
b = np.array(b)

to_throw = b[b>max(a)]
sum_throw = sum(to_throw)

d = h - sum_throw

if d <= 0:
    cum = np.cumsum(np.sort(to_throw)[::-1])
    print(len(to_throw) - len(cum[cum>=h]) + 1)
else:
    import math
    print(len(to_throw) + math.ceil(d/max(a)))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
a = list(map(int, input().split()))
a = np.array(a)

def solve():
    u, c = np.unique(a, return_counts=True)
    k = len(u) - K
    if len(u) > K:
        print(np.sum(np.sort(c)[:k]))
    else:
        print(0)

solve()

Fixed submission:
import numpy as np
N, K = map(int, input().split())
a = list(map(int, input().split()))

def uniq(a):
    d = {}
    for a_ in a:
        if a_ not in d:
            d[a_] = 1
        else:
            d[a_] += 1
    return d.keys(), d.values()

def solve():
    u, c = uniq(a)
    k = len(u) - K
    if len(u) > K:
        print(sum(sorted(c)[:k]))
    else:
        print(0)

solve()
Buggy python submission (verdict: Runtime Error):

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

    one = n*(n+1)/2

    if sum(a) % one != 0:
        print("NO")
    else:
        nop = sum(a) / one

    d = [0 for i in range(n)]
    for i in range(n):
        d[i] = a[(i+1)%n] - a[i]
        d[i] = d[i] - nop

    count = 0

    for i in range(n):
        if d[i] != 0:
            if d[i] % n != 0:
                print("NO")
                return
            count = count + (-1*d[i]) / n
            d[i] = 0
            if count > nop:
                print("NO")
                return

    if sum(d) == 0 and count == nop:
        print("YES")
    else:
        print("NO")

solve()

Fixed submission:

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

    one = n*(n+1)/2

    if sum(a) % one != 0:
        print("NO")
        return
    else:
        nop = sum(a) / one

    d = [0 for i in range(n)]
    for i in range(n):
        d[i] = a[(i+1)%n] - a[i]
        d[i] = d[i] - nop

    count = 0

    for i in range(n):
        if d[i] != 0:
            if d[i] % n != 0 or d[i] > 0:
                print("NO")
                return
            count = count + (-1*d[i]) / n
            d[i] = 0
            if count > nop:
                print("NO")
                return

    if sum(d) == 0 and count == nop:
        print("YES")
    else:
        print("NO")

solve()
Buggy python submission (verdict: Runtime Error):
import fraction

def lcm(x, y):
    return (x * y) // fraction.gcd(x, y)

N = int(input())
T = [int(input()) for i in range(N)]

ans = 1
for value in range(0, N):
    ans = lcm(ans, T[value])

print(ans)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
T = [int(input()) for i in range(N)]

ans = 1
for value in range(0, N):
    ans = lcm(ans, T[value])

print(ans)

Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N = int(input())
T = []
for i in range(0, N):
    T.append(input())

ans = 1
for value in range(0, N):
    ans = lcm(ans, int(T[value]))

print(str(ans))

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
T = [int(input()) for i in range(N)]

ans = 1
for value in range(0, N):
    ans = lcm(ans, T[value])

print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
a = [input() for i in range(N)]

d = [a[0],a[1]]
b = [a[2],a[3]]

s = min(d) + min(b)
print(s)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
import os

d = [int(input()), int(input())]
b = [int(input()), int(input())]

s = min(d) + min(b)
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
ans=1000000000000
N=int(input())
for i in range(1,N+1):
    if (N%i==0):
        j=N//i
        move=(i-1)+(j-1)
        ans=min(ans,move)
print(ans)

Fixed submission:
import numpy as np
ans=1000000000000
N=int(input())
for i in range(1,int(np.sqrt(N)+1)):
    if (N%i==0):
        j=N//i
        move=(i-1)+(j-1)
        ans=min(ans,move)
print(ans)