Problem:
 Score : 500 points    Problem Statement Snuke received a positive integer N from Takahashi.
A positive integer m is called a favorite number when the following condition is satisfied:   The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds.   Find all favorite numbers and print the sum of those.      Constraints  All values in input are integers.  1 \leq N \leq 10^{12}         Input Input is given from Standard Input in the following format:  N       Output Print the answer.        Sample Input 1 8      Sample Output 1 10  There are two favorite numbers: 3 and 7 . Print the sum of these, 10 .       Sample Input 2 1000000000000      Sample Output 2 2499686339916  Watch out for overflow.

Solution (Python):
def make_divisors(n: int) -> list:
    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 sorted(divisors)


N = int(input())

ans = 0
divisors = make_divisors(N)

for x in divisors:
    m = N // x - 1
    if (m > 0) and (N // m == N % m):
        ans += m
print(ans)

Solution (Python):
import math

n = int(input())


sum_fav = 0
for s in range(1,int(math.sqrt(n))+1):
  if n%s == 0:
    m = n//s-1
    if s < m:
      
      sum_fav += m
    else:
      break
  
print(sum_fav)

Solution (Python):

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())
i = 1
ans = 0
for i in make_divisors(N)[:-1]:
    m = ((N - i) // i)
    if N // m != N % m:
        break
    ans += m
print(ans)

Solution (Python):
from io import StringIO
from collections import *
from functools import *
from math import sqrt
import sys


def main(inputs):
    n = int(next(inputs))
    
    x_max = int(sqrt(n))
    ans=0
    
    for i in range(1, x_max+1):
        if n % i == 0 and (n // i) - 1 > i:
            ans += (n // i) - 1
            pass
        pass

    
    
    
    

    return ans


def gen_inputs(str_=None):
    inputs = StringIO(str_) if str_ else sys.stdin
    while True:
        a = inputs.readline().rstrip()
        yield a
        pass
    pass


if __name__ == "__main__":
    print(main(gen_inputs()))
    pass

Solution (Python):
N=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


L=make_divisors(N)
L.sort()

ans=0

for x in L:
	if x==1: continue
	if N%(x-1)==N/(x-1):
		ans+=(x-1)

print ans

Solution (Python):

import math

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

    total = 0

    for i in range(1, int(math.sqrt(N))+1):
        if N % i == 0:
             k = i - 1
             m = N // i
             if k > 1 and N % k != 0 and k > m:
                 total += k
             k2 = (N // i - 1)
             m2 = i
             if k2 != k and k2 > 1 and N % k2 != 0 and k2 > m2:
                 total += k2
    print(total)

if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]


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

div = sorted(divisor(N))
def solve():
    ans = 0
    for d in div:
        if d == N: continue
        x = (N - d) // d
        if N % x == d:
            
            ans += (N - d) // d
    return ans

if __name__ == "__main__":
    res = solve()
    print(res)

Solution (Python):
n = int(input())
x = 1
ans = 0
while x < n:
    m = (n - x) // x
    if m <= x:
        break
    if ((n-x) % x) == 0:
        ans += m
    x += 1
print(ans)

Solution (Python):
def main():
	N = int(input())
	sqrt_n = int(N**0.5)
	ans = 0
	for i in range(1, sqrt_n+1):
		mod = N % i
		if mod == 0 and not(i == N//i or i+1 == N//i):
			ans += N//i - 1

	print(ans)


if __name__ == '__main__':
	main()

Solution (Python):

n = int(input())

m_sum = 0
for i in range(1, n):
    m = n / i - 1
    if i >= m:
        break

    int_m = int(m)
    if m == int_m:
        m_sum += int_m

print(m_sum)

Solution (Python):
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)
L = len(div)

if L % 2 == 0:
    if div[L//2] - div[L//2-1] == 1:
        print(sum(div[L//2+1:])-L//2+1)
    else:
        print(sum(div[L//2:])-L//2)
else:
    print(sum(div[L//2+1:])-L//2)

Solution (Python):
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)
L = len(div)

if L % 2 == 0:
    if div[L//2] - div[L//2-1] == 1:
        print(sum(div[L//2+1:])-L//2+1)
    else:
        print(sum(div[L//2:])-L//2)
else:
    print(sum(div[L//2+1:])-L//2)

Solution (Python):
n = int(input())
ans = 0
if n >= 3:
    i = 1
    while n // i >= i + 2:
        if n % i == 0:
            ans += n // i - 1
        i += 1
print(ans)

Solution (Python):
N = int(input())
ans = 0

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

    return divisors

if N > 1:
	divisors = make_div1(N)
	for i in divisors[1:]:
		if N // i == (N % i):
			ans += i
	print(ans)
else:
	print(0)

Solution (Python):
import sys
input = sys.stdin.readline

import numpy as np

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())
if N == 1 or N == 2:
    print("0")
else:
    N_divisors = make_divisors(N)

    N_length = len(N_divisors)
    N_length_half = N_length // 2
    N_length_mod = N_length % 2

    N_length_half_temp = 0

    if N_length_mod == 1:
        N_length_half_temp = N_length_half + 1
    else:
        N_length_half_temp = N_length_half
    if N_divisors[N_length_half_temp]-1 == N_divisors[N_length_half_temp-1]:
        N_length_half_temp += 1
    print(sum(N_divisors[N_length_half_temp:]) - (N_length - N_length_half_temp))

Solution (Python):
N = int(input())

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

Solution (Python):
import math

N = int(input())

ans = 0
for i in range(1, int(math.sqrt(N)) + 1):
  if i > N / 2:
    continue
  tmp = int((N - i) / i)
  if (N - i) % i == 0 and N % tmp != 0 and tmp >= math.sqrt(N):
    ans += tmp

print(ans)

Solution (Python):
N=int(input())
ans=0
for i in range(1,N+1):
    if i*i>=N:
        break
    if N%i==0 and (i+1!=N//i):
        ans+=N//i-1

print(ans)

Solution (Python):
n=int(input())
c=0
i=1
while i**2<=n:
    if ((n-i)/i)%1==0 and n/(i+1)<(n-i)/i and (n-i)/i<=n/i:
        c=c+(n-i)/i
    i+=1
print(int(c))

Solution (Python):
import math
N = int(input())
r = math.sqrt(N)
p = math.floor(r)
ans = 0
for k in range(1, p + 1):
  if N % k == 0:
    if (N//k - 1) > k:
      ans += (N//k - 1)
print(ans)

Solution (Python):


def read_input():
    n = int(input())
    return n

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


def submit():
    n = read_input()
    divisors = make_divisors(n)
    
    s = 0
    for d in divisors:
        m = (n - d) // d
        if d >= m:
            break
        s += m

    print(s)

if __name__ == '__main__':
    submit()

Solution (Python):


def get_divisors(num):
    """
    指定した整数のすべての約数を配列にして返す.

    :param num:
    :return:
    """
    import math
    max_num = math.floor(math.sqrt(num))
    re = set()
    for i in range(1, max_num + 1):
        if num % i == 0:
            re.add(i)
            re.add(num // i)
    return sorted(re)


def solve():
    N = int(input())
    result = 0

    ls = get_divisors(N)

    
    
    
    
    for m in ls[1:]:
        m -= 1
        if N // m == N % m:
            result += m
    print(result)


if __name__ == '__main__':
    solve()

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

m_total = 0
l = make_divisors(n)

for x in l:
    m = n//x - 1
    if x < m:
        m_total += m

print(m_total)

Solution (Python):
import math
import numpy as np
N = int(input())
m_list = []
max_p = math.floor(-1+math.sqrt(1+N))
for p in range(1, max_p+1):
   if N % p == 0:
       m = N//p -1
       m_list.append(m)
print(int(np.sum(m_list)))

Solution (Python):
import sys
def sample_code():
    n = int(input())
    if n == 1 or n == 2:
        print(0)
        sys.exit(0)
    
    fct = factorize(n)
    
    answer = 0
    
    for div in divisorize(fct):
        if num(div)-1 > n//num(div):
            answer += num(div) - 1
    print(answer)


def divisorize(fct):
    b, e = fct.pop()  
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


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


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


if __name__ == '__main__':
    sample_code()

Solution (Python):
N = int(input())
answer = 0
divi=[]
for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        divi.append(i)
        if i != N // i:
            divi.append(N//i)

divi.sort()
divi.pop(0)
for i in reversed(range(len(divi))):
    if N % (divi[i]-1) != N // (divi[i]-1):
        divi.pop(i)
        i = i-1



for i in  range(len(divi)):
    answer = answer + divi[i]-1
print(answer)

Solution (Python):
import sys
def sample_code():
    n = int(input())
    if n == 1 or n == 2:
        print(0)
        sys.exit(0)
    
    fct = factorize(n)
    
    answer = 0
    
    for div in divisorize(fct):
        if num(div)-1 > n//num(div):
            answer += num(div) - 1
    print(answer)


def divisorize(fct):
    b, e = fct.pop()  
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


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


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


if __name__ == '__main__':
    sample_code()

Solution (Python):


n = int(input())

output = 0

limit = pow(n+0.25, 0.5)-0.5
x = 1
while x < limit:
    if n % x == 0:
        output += n // x - 1
    x += 1

print(output)

Solution (Python):
def solve():
    N = int(raw_input())
    ret = 0
    for i in range(2, int(N**0.5 + 1)):
        if N % i == 0:
            inv_i = N//i
            if N % (inv_i - 1) == N / (inv_i - 1):
                ret += inv_i - 1
    if N > 2:
        ret += N -1
    print str(ret)

if __name__ == '__main__':
    solve()

Solution (Python):
n = int(input())

def make_divisors(n):
    global 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 = []

make_divisors(n)

ans = 0

for i in range(len(divisors)):
    k = divisors[i]
    if n / k < k -1:
        ans += k -1

print(ans)

Solution (Python):
import math
import numpy as np
N = int(input())
m_list = []
max_p = math.floor(-1+math.sqrt(1+N))
for p in range(1, max_p+1):
   if N % p == 0:
       m = N//p -1
       m_list.append(m)
print(int(np.sum(m_list)))

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

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 = ni()
li = make_divisors(n)
l = len(li)
result = 0
for i in range(l):
    if i >= l // 2:
        break
    else:
        if li[-(i+1)] - li[i] > 1:
            result += (li[-(i+1)] - 1)
print(result)

Solution (Python):
N=int(input())

sqrt_N = N**0.5

list_D=[]
list_A=[]

i=1
while(i<sqrt_N):
    if N%i == 0:
        list_D.append(i)
    i+=1

for d in list_D:
    list_A.append(N//d-1)
    
if N==1 or N==2:
    print(0)
else:
    if N%list_A[-1] == 0:
        list_A.pop(-1)
    print(sum(list_A))

Solution (Python):
n = int(input())
i = 1
r = []
while((n-i)/i>i):
  if (n-i)%i==0:
    r.append(i)
  i+=1
print(sum([int((n-j)/j) for j in r]))

Solution (Python):
n=int(input())
sum=0
for x in range(1,10**6+1):
    if n%x==0:
        m=(n//x)-1
        if x<m:
            sum+=m
print(sum)

Solution (Python):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import math

n = ni()
a = 0
b = math.ceil(math.sqrt(n))

for i in range(1,b+1):
    if n%i == 0:
        c = n//i-1
        a = a if c <= i else a+c

print(a)

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

Solution (Python):
N = int(input())
i, ans = 1, 0
while (i + 1) * i + i <= N:
  if (N - i) % i == 0:
    ans += (N - i) // i
  i += 1
print(ans)

Solution (Python):
import math
import sys
def II(): return int(sys.stdin.readline())

n = II()
sum = 0

    
    
        
            


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

Solution (Python):
def zzz(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

x=int(input())
list=zzz(x)
kotae=0
for l in list:
    if l>=2:
        if x%(l-1)==int(x/(l-1)):
            kotae+=(l-1)
            
print(kotae)

Solution (Python):
import numpy as np
import re

N=int(input())
"""
count = 0
for a in range(1,n):
  if n%(a+1) == 0:
    count += a
print(count)
"""
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 np.array(divisors)
 


divs = make_divisors(N)-1
print(np.sum(divs[np.where(divs>N**0.5)[0]]))

Solution (Python):
import math
import sys
def II(): return int(sys.stdin.readline())

n = II()
sum = 0

    
    
        
            


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

Solution (Python):
n = int(input())













def main():
    p = prime_factor(n)
    ans = f([(i,j) for i, j in p.items()], 0, 1)
    print(ans)

def f(p, i, x):
    if i == len(p):
        tmp = n // x - 1
        if (tmp + 1) * x != n:
            return 0
        return tmp
    ans = 0
    tmp = 1
    for j in range(p[i][1]+1):
        ans += f(p, i+1, x*tmp)
        tmp *= p[i][0]
    return ans

def main():
    import math
    ans = 0
    for i in range(1, int(math.pow(n, 0.5)) + 2):
        if (n - i) % i == 0 and (n - i) // i > i:
            if n <= i:
                break
            ans += (n - i) // i

    print(ans)

def prime_factor(n):
    ret = {}
    i = 2
    while i * i <= n:
        while n % i == 0:
            ret[i] = ret.get(i, 0) + 1
            n /= i
        i += 1
    if n != 1:
        ret[n] = 1
    return ret


if __name__ == '__main__':
    main()
    2499694822001

Solution (Python):
N = int(input())

min_m = int(N**0.5)
max_m = N
ans = 0
for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        if(min_m<i-1 and i-1<max_m):
            ans += i-1
        if i != N // i:
            a = N//i-1
            if(min_m<a and a<max_m):
                ans += a
print(ans)

Solution (Python):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            
            if i != n // i and i != (n // i - 1) :
                divisors.append(n//i - 1)
    return divisors

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

Solution (Python):
import math

n = int(input())


sum_fav = 0
for s in range(1,int(math.sqrt(n))+1):
  if n%s == 0:
    m = n//s-1
    if s < m:
      
      sum_fav += m
    else:
      break
  
print(sum_fav)

Solution (Python):
import math
import numpy as np
N = int(input())
m_list = []
max_p = math.floor(-1+math.sqrt(1+N))
for p in range(1, max_p+1):
   if N % p == 0:
       m = N//p -1
       m_list.append(m)
print(int(np.sum(m_list)))

Solution (Python):
import math
n=int(input())
rt=int(math.sqrt(n+1))-1
r=1
ans=0
while r<=rt:
    if n%r==0: ans+=n//r-1
    r+=1
print(ans)

Solution (Python):
N = int(input())
ans = 0
yakusu = []

for i in range(1,int(N**0.5)+1):
    if N%i == 0:
        yakusu.append(i)
        if i != N//i:
            yakusu.append(N//i)
yakusu.sort()

for i in range(len(yakusu)-1):
    if yakusu[i+1] - yakusu[i] > 1:
        for m in range(yakusu[i+1], yakusu[i], -1):
           if N//m == N%m:
               ans += m 
               break

print(ans)

Solution (Python):
N = int(input())

i = 1
sum_value = 0
while (i+1) * i + i <= N:
    n = N - i
    d, m = divmod(n, i)
    if m == 0:
        sum_value += d
    i += 1

print(sum_value)

Solution (Python):
n = int(input())
cnt = 0

for i in range(1, n):
    m = n - i
    mm = m // i
    if mm <= i:
        break
    
    if m % i == 0:
        cnt += mm

print(cnt)

Solution (Python):
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
divisors = make_divisors(N)
ans = 0
for d in divisors:
    t = d - 1
    if t != 0 and N % t == N // t:
        ans += t
print(ans)

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

Solution (Python):

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

Solution (Python):
import math
N = int(input())
 
count = 0
m = 1
while m**2 < N:
  if (N - m) % m == 0:
    fav_num = (N - m) // m
    if fav_num > m:
      count += fav_num
  m += 1
    
print(count)

Solution (Python):
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
divisors = make_divisors(N)
ans = 0
for d in divisors:
    t = d - 1
    if t != 0 and N % t == N // t:
        ans += t
print(ans)

Solution (Python):
N = int(input())


def make_divisors(n):
    divisors = []
    s = n ** (1/2)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i > s:
                divisors.append(i-1)
            if i != n // i and n//i-1 > s:
                divisors.append(n//i - 1)
    return divisors
S = make_divisors(N)
print(sum(S))

Solution (Python):
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            
            divisors.append(n//i)
    
    return divisors
divisors = make_divisors(N)
if N // divisors[-1]  < (divisors[-1] - 1):
    print(sum(divisors) - len(divisors))
else:
    print(sum(divisors[:-1]) - len(divisors[:-1]))

Solution (Python):
N = int(input())

ans = int()

for i in range(1, int(N ** 0.5) + 1):

    if N % i == 0 and i < int(N / i - 1):

        ans += int(N / i) - 1

print(ans)

Solution (Python):
N = int(input())
a = int(((4*N+1)**(1/2)-1)/2)
ans = []

for i in range(1, int(N**(1/2))+1):
    if N%i == 0 and a < N//i-1:
        ans.append(N//i-1)
print(sum(ans))

Solution (Python):
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 sorted(divisors,reverse=True)

N = int(input())
div = make_divisors(N)
ans = [(a - 1) for a in div if a > 1 and N % (a - 1) == N // (a - 1)]
print(sum(ans))

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

Solution (Python):
n = int(input())

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

    divisors.sort()
    return divisors


a = make_divisors(n)

b = []
for i in a:
     if i-1 in a:
          b.append(i)

a = a[len(a)//2:]
if n//a[0] == a[0]:
     a = a[1:]

for i in b:
     if i in a:
          a.remove(i)

print(sum(a)-len(a))

Solution (Python):
N = int(input())

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

print(ans)

Solution (Python):
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
    
divisors = make_divisors(N)

total = 0
for divisor in divisors:
    m = N//divisor-1
    if m > divisor:
        total += m
print(total)

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

    
    return divisors

n = int(input())
div = make_divisors(n)
ans = 0
for i in range(len(div)): 
    m = (n//div[i])-1
    if m != 0 and n%m == n//m:
        ans += m
print(ans)

Solution (Python):
n = int(input())
ans = 0
p = int(n ** 0.5) + 5
for i in range(1, p):
  if (n - i) % i == 0:
    q = (n - i) // i
    if q > i:
      ans+= q
print(ans)

Solution (Python):
n = int(input())

wa = 0
end = int(n**0.5)+1
for r in range(1,end):
  if n%r is 0 and n//r > r+1:
    wa += n//r-1
    

print(wa)

Solution (Python):
N = int(input())

anss = set()
for X in range(1, int(N**0.5)+2):
    if (N-X) % X == 0:
        m = (N-X) // X
        if m <= 0: continue
        if N//m == N%m:
            anss.add(m)

for m in range(1, int(N**0.5)+2):
    if N//m == N%m:
        anss.add(m)

print(sum(anss))

Solution (Python):
N = int(input())

cond = []
for i in range(1, N):
    if i*i >= N:
        break
    if N % i == 0:
         cond.append((i, N//i))


ans = set()
for a,b in cond:
    m = a+1
    if N//m == N%m:
        ans.add(m)
    m = b+1
    if N//m == N%m:
        ans.add(m)

    x = a
    if N%x == 0 and N//x > 1 and x < N//x-1:
        ans.add(N//x - 1)
    x = b
    if N%x == 0 and N//x > 1 and x < N//x-1:
        ans.add(N//x - 1)
    

a = sum(list(ans))
print(a)

Solution (Python):
from sys import stdin
import numpy as np

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

lst_div = make_divisors(N)




ans = 0
for i in range(len(lst_div)):
  if (lst_div[i]-1 not in lst_div) and (lst_div[i]*(lst_div[i]-1) > N):
    ans += lst_div[i]-1

print(ans)

Solution (Python):
n = int(input())
ans = 0
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
d = make_divisors(n)
for x in d:
    if x > 1 and n // (x-1) < (x-1):
        ans += x-1
print(ans)

Solution (Python):
N = int(input())

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

Solution (Python):
t = 0
N = int(input().strip())
for i in range(pow(10, 6)):
    i = i+1
    x = (N // i)
    if i == N:
        break
    if N % i == 0:
        x -= 1
    if N//x == N%x:
        t += x
print(t)

Solution (Python):
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


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


def solve():
    N = ii()
    ans = 0
    divisors = make_divisors(N)
    sqrt_n = N ** 0.5
    for m in divisors:
        if m == 1 or m - 1 < sqrt_n:
            continue
        ans += m - 1
    return ans


if __name__ == "__main__":
    print(solve())

Solution (Python):

import sys
import math
import bisect
INF = float("inf")


def solve(N: int):

    if N == 1:
        print(0)
        return
    count = 0
    for r in range(1, int(math.sqrt(N))+1):  
        
        lower = -(-N//r+1)
        upper = N//r
        while lower + 1 < upper:
            mid = (lower+upper)//2
            if N % mid >= r:
                lower = mid
            else:
                upper = mid
        if N % lower == r:
            count += lower
    print(count)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())

def sieve(x):
    if x < 2: return []
    primes = [i for i in range(x)]
    primes[1] = 0
    for p in primes:
        if p > x ** (1/2): break
        if p == 0: continue
        for np in range(2 * p, x, p): primes[np] = 0
    return [p for p in primes if p != 0]

PS = sieve(10**6)


def factorint(x):
  d = {}
  for k in PS:
    if(x % k== 0):
      m = 1
      while(x % (k**m) == 0):
        m += 1
      d[k] = m - 1
      x = x / (k ** (m - 1))
      if x == 1:
        break
  return d

f = factorint(n)

re = 1
for k, v in f.items():
  re *= k**v
if n // re != 1:
  f[n // re] = 1


s = 1
num = 1
for k, v in f.items():
  s *= (k ** (v + 1) - 1) // (k - 1)
  num *= (v + 1)
loss = 0
for i in range(1, int((-1 + (1 + 4 * n) ** (1/2)) / 2) + 1):
  if n % (i + 1) == 0:
    loss += i
print(s - num - loss)

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

Solution (Python):
from math import sqrt
N = int(input())
kMaxBound = sqrt(N+1/4) - 1/2
kMax = int(kMaxBound)
if kMax == kMaxBound:
    kMax -= 1
ans = 0
for k in range(1,kMax+1):
    if N % k == 0:
        ans += N//k - 1
print(ans)

Solution (Python):

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())
a = make_divisors(N)
if N < 100000:
    ans = 0
    for n in range(1, N):
        a = N%n
        b = N//n

    
        if a == b:
            ans += n

    print(ans)
else:
    if len(a)%2 == 0:
        print(sum(a[len(a)//2:]) - len(a)//2)
    else:
        print(sum(a[len(a)//2 + 1:]) - len(a)//2)

Solution (Python):
from collections import defaultdict
N=int(input())
if N==1 or N==2:
    print(0)
    quit()
def prime_factor(n):
    i = 2
    table = defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table
table=prime_factor(N)
list=[1]
for fact,num in table.items():
    list_=[]
    for k in range(num+1):
        list_.extend([i*fact**k for i in list])
    list=list_
list.sort()
ans=0
for i in range(len(list)):
    if i==0:
        continue
    if list[i-1]+1==list[i]:
        continue
    m=list[i]-1
    if N//m==N%m:
        ans+=list[i]-1
print(ans)

Solution (Python):







n=int(input())

c=0
for i in range(1,n):
  x=(n-i)%i
  y=(n-i)//i
  if y<=i:
    break
  if x==0:
    c+=y
print(c)

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

Solution (Python):
N = int(input())







def divisor_list(n):
    ret = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
        i += 1
    return ret

ans = 0
L = divisor_list(N)
for l in L:
    oki = l-1
    if oki > 0 and N // oki == N % oki:
       ans += oki

print(ans)

Solution (Python):
n = int(input())
x = 0
for i in range(1,n+1):
  if (n-i)//i<=i:
    break
  if (n-i)%i == 0:
    if (n-i)//i != i:
      x += (n-i)//i
print(int(x))

Solution (Python):
n=int(input())
if(n==2):
  print(0)
  quit()
ans=0
p=[]
for i in range(2,1000001):
  if(i*i>=n):
    break
  if(n%i==0):
    p.append(n//i)
for i in p:
  if(n%(i-1)==n//(i-1)):
    ans+=i-1
print(ans+n-1)

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

Solution (Python):
def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

N = int_raw()

def main():
    ans = 0 
    for idx in range(1,N+1):
        if(idx*idx)+idx>=N:
            break
        if (N-idx)%idx == 0:
            ans += (N-idx)//idx
    return ans


print(main())