qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import math
N = int(input())

a = math.ceil(N**0.5)

cnt=0
for i in range(1,a+1):
    if N%i == 0:
        cnt += (N//i)-1
print(cnt)

Fixed code:
import math
N = int(input())

a = math.ceil(N**0.5)-1

cnt=0
for i in range(1,a+1):
    if N%i == 0:
        if i < (N//i)-1:
            cnt += (N//i)-1
print(cnt)
Buggy code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()

ans = 0


for j in range(1, int(n ** 0.5) + 1):
    if not (n - j) % j:
        ans += (n - j) // j


print(ans)


Fixed code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()

ans = 0
for j in range(1, int(n ** 0.5) + 1):
    if not (n - j) % j and (n - j) // j > j:
        ans += (n - j) // j


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



Fixed code:
N = int(input())

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

print(ans)
Buggy code:
n = int(input())
c = 0
for i in range(1, int(n**0.5)+1):
    if n % i == 0 and n / i + 1 >= i:
        c += int(n / i) - 1
print(c)

Fixed code:
n = int(input())
cnt = 0
for i in range(1, int(n**0.5)+1):
    if n % i == 0 and n / i - 1 > i:
        cnt += int(n / i) - 1
print(cnt)
Buggy code:
N=int(input())
def divisor(n):
	divs=[]
	for i in range(1,int(n**0.5)+1):
		if n%i==0:
			divs.append(i)
			if i!=n//i:
				divs.append(n//i)
	divs.sort()
	return divs
d=divisor(N)
s=0
for i in range(1,len(d)):
	if d[i-1]+1!=d[i]:
		s=s+d[i]-1
print(s)

Fixed code:
N=int(input())
def divisor(n):
	divs=[]
	for i in range(1,int(n**0.5)+1):
		if n%i==0:
			divs.append(i)
			if i!=n//i:
				divs.append(n//i)
	divs.sort()
	return divs
d=divisor(N)
s=0
for i in range(1,len(d)):
	if d[i-1]+1!=d[i] and d[i]-1>d[-(i+1)]:
		s=s+d[i]-1
print(s)
Buggy code:
import sys
 
stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

N = ni()
answer = 0
cur = 1
while cur * (cur + 2) <= N:
    x = (N-cur) // cur
    if x > cur:
        #print(cur)
        answer += x
    cur += 1
print(answer)

Fixed code:
import sys
 
stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

N = ni()
answer = 0
cur = 1
while cur * (cur + 2) <= N:
    y = N - cur
    if y % cur != 0:
        cur += 1
        continue
    x = y // cur
    if x > cur:
        #print(cur)
        answer += x
    cur += 1
print(answer)
Buggy code:
import sys

N = int(input())
sum = 0

for i in range(1, N+1):
    if (N-i) % i == 0:
        m = int((N-i) / i)
        if(m <= i):
            print(sum)
            sys.exit()
        
        sum += m
    if((N-i)/i <= i):
        sys.exit()

Fixed code:
import sys

N = int(input())
sum = 0

for i in range(1, N+1):
    if (N-i) % i == 0:
        m = int((N-i) / i)
        if(m <= i):
            print(sum)
            sys.exit()
        
        sum += m
    if((N-i)/i < i):
        print(sum)
        sys.exit()
Buggy code:
n=int(input())
i,ans=1,0
while i*i<=n:
    if (n-i)%i==0: ans+=(n-i)//i
    i+=1
print(ans)

Fixed code:
n=int(input())
i,ans=1,0
while i*i+i<n:
    if (n-i)%i==0: ans+=(n-i)//i
    i+=1
print(ans)
Buggy code:
N = int(input())
ans = 0

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


Fixed code:
N = int(input())
ans = 0
for x in range(1, int(N**(1/2)+2)):
    if (N-x) % x == 0:
        if (N-x)//x > x:
            ans += (N-x)//x

print(ans)
Buggy code:
import math
def main():
    n = int(input())
    a = []
    for i in range(1,(int)(math.sqrt(n)) + 1):
        if n % i == 0:
            if i != 1:
                a.append(i - 1)
            a.append(n // i - 1)
    a.sort()
    print(a)
    ans = 0
    for i in a:
        if i != 1 and n // i == n % i:
            ans += i
    print(ans)
main()


Fixed code:
import math


def main():
    n = int(input())
    a = []
    for i in range(1, (int)(math.sqrt(n)) + 1):
        if n % i == 0:
            if i != 1:
                a.append(i - 1)
            if n // i - 1 != 0:
                a.append((n // i) - 1)
    ans = 0
    for i in range(len(a)):
        if a[i] != 1 and (n // a[i] == n % a[i]):
            ans += a[i]
    print(ans)


main()
Buggy code:
import math
N = int(input())
ans = 0
n_max = int(math.sqrt(N))
for n in range(1,n_max):
	if N%n == 0:
		a = N//n
		if a+1 < n:
			ans += n-1
		elif n+1 < a:
			ans += a-1
print(ans)


Fixed code:
import math
N = int(input())
ans = 0
n_max = int(math.sqrt(N))
for n in range(1,n_max+1):
	if N%n == 0:
		a = N//n
		if a+1 < n:
			ans += n-1
		elif n+1 < a:
			ans += a-1
print(ans)
Buggy code:
n = int(input())
ans = 0
for i in range(1, int(n ** 0.5)):
    if (n - i) % i == 0:
        ans += (n - i) // i
print(ans)


Fixed code:
n = int(input())
ans = 0
for i in range(1, int(n ** 0.5) + 1):
    if i * (i + 1) >= n:
        break
    if (n - i) % i == 0:
        ans += (n - i) // i
print(ans)
Buggy code:
n = int(input())

ans = 0
for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0 and n // (i - 1) == n % (i - 1):
        ans += i - 1
    m = n // i - 1
    if m > 0 and n % i == 0 and n // m == n % m:
        ans += m
print(ans)


Fixed code:
n = int(input())

ans = 0
for i in range(1, int(n ** 0.5) + 1):
    m = n // i - 1
    if m > 0 and n % i == 0 and n // m == n % m:
        ans += m
print(ans)
Buggy code:
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
fav = make_divisors(n)
result = 0
for x in fav:
    result += n/x-1
print(result-1)

Fixed code:
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
fav = make_divisors(n)
result = 0
for x in fav:
    if x == n:
        continue
    m = int(n/x)-1
    if int(n/m)==n%m:
        result += m
print(result)
Buggy code:
n = int(input())

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

print(sum)        


Fixed code:
n = int(input())

a = int(n ** (1 / 2))
sum = 0
for i in range(1, a + 1):
    if (n % i == 0):
        j = n // i
        if j - 1 > i:
            sum += j - 1

print(sum)
Buggy code:
N = int(input())
ans = 0
for i in range(1,1250000):
    if(((N-i)/i).is_integer() and N//((N-i)/i) == N%((N-i)/i)):
        # print((N-i)//i,i)
        ans += ((N-i)//i)
        # if(i == 800000):
        #     print(ans)
    # print(i)
print(ans)

Fixed code:
N = int(input())
ans = 0
for i in range(1,min(N,1250000)):
    if(((N-i)/i).is_integer() and N//((N-i)/i) == N%((N-i)/i)):
        # print((N-i)//i,i)
        ans += ((N-i)//i)
        # if(i == 800000):
        #     print(ans)
    # print(i)
print(ans)
Buggy code:
import math

def all_divisor(n):
  small = [1]
  large = [n]
  for i in range(2, int(math.sqrt(n))):
    if n % i == 0:
      small.append(i)
      large.append(n//i)
  large.reverse()
  divisor = small + large
  return divisor


n = int(input())
n_divisor = all_divisor(n)
ans = 0
for i in n_divisor:
  mini_ans = (n - i) // i
  if i >= mini_ans:
    break
  ans += mini_ans 
print(ans)


Fixed code:
import math

def all_divisor(n):
  small = [1]
  large = [n]
  for i in range(2, int(math.sqrt(n))+1):
    if n % i == 0:
      small.append(i)
      large.append(n//i)
  large.reverse()
  divisor = small + large
  return divisor


n = int(input())
n_divisor = all_divisor(n)
ans = 0
for i in n_divisor:
  mini_ans = (n - i) // i
  if i >= mini_ans:
    break
  ans += mini_ans 
print(ans)
Buggy code:
limit = 0
n = int(input())
for v in range(1,n):
    if v*v >n:
        limit= v-1
        break
ans =0
for i in range(1,limit):
    a = n // i - 1
    if i * a + i == n:
        ans += a
print(ans)

Fixed code:
limit = 0
n = int(input())
for v in range(1,n):
    if v*v >n:
        limit= v-1
        break
ans =0
for i in range(1,limit+1):
    a = n // i - 1
    if n//a == n%a:
        ans += a
print(ans)
Buggy code:
n = int(input())
m = 1
ans = 0
"""
for m in range(1, int(n**0.5)+1):
    if n%m == 0 and m < n//m:
        ans += n//m -1
"""
while m <= int(sqrt(n)):
    if n % m == 0 and m < n // m:
        ans += n // m - 1
    m += 1
print(ans)


Fixed code:
n = int(input())
ans = 0
for m in range(1, int(n**0.5)+1):
    if n%m == 0 and m < n//m-1:
        ans += n//m -1
print(ans)
"""
while m <= int(n**0.5):
    if n % m == 0 and m < n // m:
        ans += n // m - 1
    m += 1
print(ans)
"""
Buggy code:
import math

N = int(input())

ans = 0

for i in range(math.floor((math.sqrt(N)))-1):
    if N % (i+1) == 0:
        if  ( N / (i+1) ) -1 > (i+1):
            ans = ans + ( N / (i+1) ) -1
            #break
        #print( N / (i+1)-1)
        
        
print(int(ans))

Fixed code:
import math

N = int(input())

ans = 0

for i in range(int((math.sqrt(N)))+1):
    if N % (i+1) == 0:
        if  ( N / (i+1) ) -1 > (i+1):
            ans = ans + ( N / (i+1) ) -1
        else:
            break
            #break
        #print( N / (i+1)-1)
        #ans = ans + ( N / (i+1) ) -1
        
        
print(int(ans))
Buggy code:
N = int(input())

from math import sqrt
ans = 0
if N != 1:
    for k in range(2,int(sqrt(N)+1)):
        if N%k == 0:
            m = N//k-1
            if k == N%m: ans += m

print(ans)

Fixed code:
N = int(input())

from math import sqrt
ans = 0
if N != 1:
    for k in range(1,int(sqrt(N)+1)):
        if N%k == 0:
            m = N//k-1
            if k == N%m: ans += m

print(ans)
Buggy code:
n=int(input())
y=[]
for i in range(1,round(n**0.5)+1):
    if n%i==0:
        y.append(i)
ans=0
for i in y:
    if n//(i-1)==n%(i-1):
        ans+=(i-1)
print(ans)

Fixed code:
n=int(input())
y=[]
for i in range(1,round(n**0.5)+1):
    if n%i==0:
        y.append(i)
        y.append(n//i)
ans=0
for i in y: 
    if i>1 and n//(i-1)==n%(i-1):
        ans+=(i-1)
print(ans)
Buggy code:
N = int(input())

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


Fixed code:
N = int(input())

ans = 0
for i in range(1, int(N**0.5)+1):
  if (N-i)%i == 0:
    tmp = (N-i)/i
    if tmp != 0 and N%tmp == i:
      ans += int(tmp)
print(ans)
Buggy code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    res = 0
    x = 1
    while x * x <= N:
        mp1, r = divmod(N, x)
        x += 1
        if r > 0:
            continue
        m = mp1 - 1
        if x >= m:
            break
        res += m
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Fixed code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    res = 0
    x = 1
    while x * x <= N:
        mp1, r = divmod(N, x)
        m = mp1 - 1
        if x >= m:
            break
        x += 1
        if r > 0:
            continue
        res += m
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
Buggy code:
n=int(input())
if int(n**(1/2))!=n**(1/2):
    a=int(n**(1/2))+1
else:
    a=int(n**(1/2))
print(a)
ans=0
for i in range(1,a):
    if (n-i)%i==0 and n-i>=i:
        ans+=(n-i)//i
print(ans)

Fixed code:
n=int(input())
if int(n**(1/2))!=n**(1/2):
    a=int(n**(1/2))+1
else:
    a=int(n**(1/2))
ans=0
for i in range(1,a):
    if (n-i)%i==0 and n-i>=i and (n-i)//i>i:
        ans+=(n-i)//i
print(ans)
Buggy code:
from sys import stdin

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(stdin.readline().rstrip())
ds = make_divisors(n)

#print(ds)

sum = 0
for x in ds:
   if x==n:
     continue
   m = int(n/x-1)
#   print(x,m)
   sum += m

print(sum)


Fixed code:
from sys import stdin

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(stdin.readline().rstrip())
ds = make_divisors(n)

#print(ds)

sum = 0
for x in ds:
   if x==n:
     continue
   m = int(n/x-1)
   if m==1:
     continue
#   print(x,m, int(n/m), n%m)
   if(int(n/m) == n%m):
     sum += m

print(sum)
Buggy code:
def main():
    import sys

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

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




    
if __name__ == '__main__':
    main()

Fixed code:
def main():
    import sys

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

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




    
if __name__ == '__main__':
    main()
Buggy code:
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
A=make_divisors(N)
ans=0
for i in A:
  if i==1:
    continue
  a=N//(i-1)
  b=N%(i-1)
  if a==b:
    ans+=(i-1)
print(ans)

Fixed code:
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
A=make_divisors(N)
ans=0
for i in A:
  if i==1:
    continue
  a=N//(i-1)
  b=N%(i-1)
  if a==b:
    ans+=(i-1)
print(ans)
Buggy code:
import math
N=int(input())
a=(math.sqrt(N)//1)
ans=0
if N==2:
  print(0)
  exit()
for i in range(1,int(a)):
  b=(N-i)/i
  if b.is_integer():
    ans+=int(b)
print(ans)

Fixed code:
import math
N=int(input())
a=int((math.sqrt(N)//1))
ans=0
if N==2:
  print(0)
  exit()
for i in range(1,a):
  b=(N-i)/i
  if b.is_integer():
    ans+=int(b)
c=N//a
d=N%a
if int(c)==d:
  ans+=a
a+=1
c=N//a
d=N%a
if int(c)==d:
  ans+=a
print(ans)
Buggy code:
N=int(input())
sqrtn=int(N**0.5)
ans=0
for r in range(1,sqrtn):
    if N%r==0:
        ans+=(int(N/r)-1)
print(int(ans))


Fixed code:
N=int(input())
sqrtn=int(N**0.5)
ans=0
for r in range(1,sqrtn+1):
    if N%r==0 and N/r-1>r:
        ans+=(int(N/r)-1)
print(int(ans))
Buggy code:
import sys
def input(): return sys.stdin.readline().strip()
def prime_factors(n):
    i = 2
    factors = {}
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            if i in factors.keys():
                factors[i] += 1
            else:
                factors[i] = 1
    if n > 1:
        if n in factors.keys():
            factors[n] += 1
        else:
            factors[n] = 1
    return factors

i  = lambda: int(input())

N = i()

pfd = prime_factors(N)

check_num = []

for pf in pfd.keys():
    tmp_num = []
    for i in range(1, pfd[pf] + 1):
        tmp_num.append(pf ** i)
        for n in check_num:
            tmp_num.append(n * (pf ** i))
    check_num += tmp_num

count = 0
for n in check_num:
    if N / n < n  and N != n:
        count += n-1

print(count)

Fixed code:
import sys
def input(): return sys.stdin.readline().strip()
def prime_factors(n):
    i = 2
    factors = {}
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            if i in factors.keys():
                factors[i] += 1
            else:
                factors[i] = 1
    if n > 1:
        if n in factors.keys():
            factors[n] += 1
        else:
            factors[n] = 1
    return factors

i  = lambda: int(input())

N = i()

pfd = prime_factors(N)

check_num = []

for pf in pfd.keys():
    tmp_num = []
    for i in range(1, pfd[pf] + 1):
        tmp_num.append(pf ** i)
        for n in check_num:
            tmp_num.append(n * (pf ** i))
    check_num += tmp_num

count = 0
for n in check_num:
    if N // (n-1) == N % (n-1):
        count += n-1

print(count)
Buggy code:
n = int(input())

ans = 0
for i in range(1,n):
    if (n-i)/i > i:
        if (n-i)%i == 0:
            ans += (n-i)/i
    else:
        break
print(int(ans)

Fixed code:
n = int(input())

ans = 0
for i in range(1,n):
    if (n-i)/i > i:
        if (n-i)%i == 0:
            ans += (n-i)/i
    else:
        break
print(int(ans))
Buggy code:
import math
N=int(input())
root=math.ceil(math.sqrt(N)+1)
ans=0
for i in range(root,N+1):
    if not N%i:
        ans+=i-1
print(ans)

Fixed code:
import math
N=int(input())
root=math.ceil(math.sqrt(N))
ans=0
for i in range(1,root):
    if not N%i:
        if N//i>i+1:
            ans+=N//i-1
print(ans)
Buggy code:
import math
def prime_divisor(n):
    ls = []
    i = 2
    while i <= math.floor(n**0.5):
        if n%i == 0:
            ls.append(i)
            ls.append(n//i)
            i += 1
        else:
            i += 1
    if n > 1:
        ls.append(n)
    return ls
N = int(input())
ls1 = prime_divisor(N)
ls2 = [x-1 for x in list(set(ls1)) if x >= 2]
ls2.sort()
ls2.reverse()
print(ls2)
ans = 0
for i in range(len(ls1)):
    if N // ls2[i] == N % ls2[i]:
        ans += ls2[i]
print(ans)

Fixed code:
import math
def prime_divisor(n):
    ls = []
    i = 2
    while i <= math.floor(n**0.5):
        if n%i == 0:
            ls.append(i)
            ls.append(n//i)
            i += 1
        else:
            i += 1
    if n > 1:
        ls.append(n)
    return ls
N = int(input())
ls1 = prime_divisor(N)
ls2 = [x-1 for x in list(set(ls1)) if x >= 2]
ls2.sort()
ls2.reverse()
ans = 0
for i in range(len(ls2)):
    if N // ls2[i] == N % ls2[i]:
        ans += ls2[i]
print(ans)
Buggy code:
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())
md = make_divisors(N)

# print(md)

ans = 0
for i in md:
  m = N // i - 1
  if m != 0 and N % m != 0:
    ans += m

print(ans)

Fixed code:
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())
md = make_divisors(N)

# print(md)

ans = 0
for i in md:
  m = N // i - 1
  if m != 0 and N // m < m:
    ans += m

print(ans)
Buggy code:
n = int(input())
l = int(-(-(n ** (1/2)) // 1))
print(l)
total = 0
for i in range(1, l):
	if n % i == 0:
		total += (n - i) // i
print(int(total))

Fixed code:
n = int(input())
l = int(-(-(n ** (1/2)) // 1))
total = 0
for i in range(1, l):
	if n % i == 0 and n != i * (i+1):
		total += (n - i) // i
print(int(total))
Buggy code:
from math import sqrt 

n = int(input())

x = int(sqrt(n))
ans = n-1
for i in range(2, x):
    y = dt = n//i
    while n//dt == n//y and n%y <= n//y:
        if n//y == n%y:
            ans += y
            break
        y -= 1
        if y == 1:
            break
        # print x,y,ans
print(ans)

Fixed code:
from math import sqrt 

n = int(input())

x = int(sqrt(n))
if n == 2:
    print(0)
    exit()
ans = n-1
for i in range(2, x+1):
    y = dt = n//i
    while n//dt == n//y and n%y <= n//y:
        if n//y == n%y:
            ans += y
            break
        y -= 1
        if y == 1:
            break
        # print x,y,ans
print(ans)
Buggy code:
_N = int(input())
N = _N

i = 2
div = set()
ans = 0
while N > 1:
    if N % i == 0:
        while N % i == 0:
            div.add(i)
            div.add(N//i)
            N //= i
    i += 1

for d in div:
    m = _N//d-1
    if m > d:
        ans += m
print(ans)


Fixed code:
_N = int(input())
N = _N

i = 1
div = set()
ans = 0
while i*i <= N:
    if N % i == 0:
        div.add(i)
        div.add(N//i)
    i += 1

for d in div:
    m = _N//d-1
    if m > d:
        ans += m
print(ans)
Buggy code:
def make_divisors(n):
    ans=0
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            if i>2:
                ans+=i-1
            if i!=n//i:
                ans+=n//i-1
    return ans

n=int(input())
print(make_divisors(n))

Fixed code:
def make_divisors(n):
    ans=0
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            if i>2:
                if n//i < i-1:
                    ans+=i-1
            if i!=n//i:
                if i < n//i-1:
                    ans+=n//i-1
    return ans

n=int(input())
print(make_divisors(n))