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):
n=int(input())
if n==1:
    print(0)
else:
    pf={}
    m=n
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    ans=[]
    m=0
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            m=n//i-1
            if n%m==i and n//m==i:
                ans.append(m)

    
    print(sum(ans))

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

Solution (Python):
n=int(input())
p=0
for i in range(1,int(n**0.5)+2):
    j,k=divmod(n-i,i)
    p+=0 if k or j<=i else j
print(p)

Solution (Python):
def div(n):
    lower, upper = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower.append(i)
            if i != n // i:
                upper.append(n // i)
        i += 1
    return lower + upper[::-1]

n = int(input())
ans = 0
for i in div(n):
    if i == 1:
        continue
    elif n // (i - 1) == n % (i - 1):
        ans += i - 1
print(ans)

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


def factori(num):
    l = set()
    for i in range(1, int(num ** 0.5) + 1):
        if not num % i:
            l.add(i)
            l.add(n // i)
    return l


ans = 0
for m in factori(n):
    m -= 1
    if m > 0 and n == (n // m) * (m + 1):
        ans += m
print(ans)

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


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def is_favorite(n, m):
    if x == 0:
        return False
    else:
        return n // m == n % m


li = make_divisors(n)
li = [x - 1 for x in li]


ans = 0
for x in li:
    if is_favorite(n, x):
        ans += x

print(ans)

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

Solution (Python):
def divisor(i):
    s = []
    for j in range(1, int(i ** (1 / 2)) + 1):
        if i % j == 0:
            s.append(i // j)
            s.append(j)
    return sorted(set(s))

n = int(input())
s = divisor(n)
ans = 0
for i in s:
    if n > i * (i + 1):
        ans += n // i - 1
print(ans)

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

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

print(ans)

Solution (Python):
N = int(input())
print(sum(N // n - 1 for n in range(1, int(N ** 0.5) + 1) if not N % n and n < N // n - 1))

Solution (Python):
N = int(input())
print(sum((N // n - 1) for n in range(1, int(N ** 0.5) + 1) if not N % n and n < N // n - 1))

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


s=0
a=1
while a*a+a<n:
    if n%a==0:
        s+=n//a-1
    a+=1

print(s)

Solution (Python):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

from math import floor

N=int(input())
p= floor(N**0.5)

ans=0
for i in range(1,p+1):
  if N%i==0:
    s = i
    t = N//i-1
    
    u = N//i
    v = i-1
    
    if s<t:
      ans += t
    if u<v:
      ans += v
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

divs = make_divisors(N)

ans = 0

for d in divs:
    if d == 1:
        continue
    m = d - 1
    if N // m == N % m:
        ans += m

print(ans)

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





if n==1 or n==2:
    print(0)
    exit()

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

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

ans = 0

for i in range(1, N + 1):
    x =  (N - i) // i
    if x <= i:
        break
    if (N - i) % i == 0:
        ans += x

print(ans)

Solution (Python):
import unittest


def solve(n):
    used = set()
    total = 0
    for i in range(1, int(n ** 0.5)+1):
        if n % i > 0:
            continue
        d = n // i
        cand = [i-1, d-1]
        for c in cand:
            if c not in used and c > 0 and n % c == n // c:
                total += c
                used.add(c)

    return total


def main():
    n = int(input())
    result = solve(n)
    print(result)


if __name__ == "__main__":
    main()


class Test(unittest.TestCase):
    def test_solve_1(self):
        n = 8
        actual = solve(n)
        expected = 10
        self.assertEqual(actual, expected)

    def test_solve_2(self):
        n = 1000000000000
        actual = solve(n)
        expected = 2499686339916
        self.assertEqual(actual, expected)

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

Solution (Python):
def factors(N): 
    from collections import deque
    ret = deque()
    middle = int( N**(1/2))
    for i in range(1, middle):
        if N%i == 0:
            ret.append(i)
            ret.append(N//i)
            
    if N%middle == 0:
        ret.append(middle)
        if middle != N//middle:
            ret.append(N//middle)
    return ret

def main():
    N = int( input())
    ans = 0
    for m in factors(N):
        if m==1:
            continue
        if N//(m-1)*m == N:
            ans += m-1
    print(ans)
    
if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))



def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N=int(input())
if N==1:
    print(0)
    exit()
l=make_divisors(N)
ans=0
for i in range(1,len(l)):
    a,b=divmod(N,l[i]-1)
    if a==b:
        ans+=l[i]-1
print(ans)

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

div = []
i = 1

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

ans = 0  
for i in div:
    if N // (i - 1)== N % (i - 1):
        ans += i - 1
print(ans)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6) 
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque 


from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush




def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    

    N = int(input())
    
    
    
    

    ns=int(N**0.5+1)
    ans=0
    for i in range(1,ns):
        ni=N-i
        d,m=divmod(ni,i)
        if m==0 and d>i:
            ans+=d
    print(ans)





if __name__ == "__main__":
    main()

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]


def main():
    n = II()
    sumv = 0
    divs = enumerate_divs(n)
    for p,q in divs:
        if p!=1:
            if n//(p-1) == n%(p-1):
                sumv += p-1
        if q!=1:
            if n//(q-1) == n%(q-1):
                sumv += q-1
    print(sumv)

if __name__ == '__main__':
    main()

Solution (Python):
from math import sqrt

def cal_dummy(N):
    output = 0
    for m in range(1,N):
        if N // m == N % m:
            output += m
    return output

def cal(N):
    
    
    if N == 1:
        return 0
    else:
        output = 0
        for r in range(1,int(sqrt(N))+1):
            if N % r == 0:
                m = (N // r) - 1
                if (N//m) == r:
                    output += m
        return output

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

    print(cal(N))

if __name__ == "__main__":
    main()

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

ans = 0
for k in range(1, int(n**(1/2))+1):
    m = (n - k) // k
    if m <= 0: continue
    if n // m == n % m:
        ans += m

print(ans)

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

Solution (Python):
n = int(input())
factors = []
for i in range(1, int(n**0.5)+1):
    if n%i==0:
        if n//i*2<(4*n+1)**0.5-1:
            factors.append(i)
        if i*2<(4*n+1)**0.5-1:
            factors.append(n//i)
print(sum(factors)-len(factors))

Solution (Python):

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

Solution (Python):
import sys


import math
import collections

import bisect

import fractions

import copy
import heapq
import decimal

import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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





def main():
    n = ni()

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys


import math
import collections

import bisect

import fractions

import copy
import heapq
import decimal

import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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





def main():
    n = ni()

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


if __name__ == '__main__':
    main()

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

li = make_divisors(n)
ans = 0
for l in li:
    if l == 1:
        continue
    t = l - 1
    if n % t == n//t:
        ans += t
print(ans)

Solution (Python):
import sys
from collections import *
import heapq
import math

import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())

ans=0

if n==1:
    print(0)
    quit()
for i in range(int(n**0.5)):
    x=(n-(i+1))//(i+1)
    if n//x==n%x:
        ans+=x
    
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)
    return divisors
n = int(input())
l = make_divisors(n)
ans = 0
for i in l:
    if (i - 1) != 0 and n // (i - 1) == n % (i - 1):
        ans += i - 1
print(ans)

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

import math
rt = math.floor(math.sqrt(n))
result = 0
for i in range(1,rt + 1):
  if n % i == 0 and i**2 != n:
    if n % (n / i - 1) != 0:
      result += n / i - 1
print(int(result))

Solution (Python):
import math
N = int(input())
ans = 0
for m in range(1,math.ceil(N**(1/2))):
  if (N-m)%m == 0 and m < (N-m)//m:
    ans += int((N-m)/m)

if N == 1:
  ans = 0
if N == 2:
  ans = 0
if N == 3:
  ans = 2
if N == 6:
  ans = 5
print(ans)

Solution (Python):




n=int(input())

def make_divisor(x):
    ret=[]
    for i in range(1,int(x**.5)+1):
        q,m=divmod(x,i)
        if m==0:
            ret.append(i)
            if i==q:continue
            ret.append(q)
    return ret

ans=[]
d=make_divisor(n)

for e in d:
    if e==1:continue
    m=e-1
    k=n%m
    if k*e==n:
        ans.append(m)
print(sum(ans))

Solution (Python):




n=int(input())

def make_divisor(x):
    ret=[]
    for i in range(1,int(x**.5)+1):
        q,m=divmod(x,i)
        if m==0:
            ret.append(i)
            if i==q:continue
            ret.append(q)
    return ret

ans=[]
d=make_divisor(n)

for e in d:
    if e==1:continue
    m=e-1
    k=n%m
    if k*e==n:
        ans.append(m)
print(sum(ans))

Solution (Python):
from math import sqrt
n=int(input())
ans=0
for i in range(1,int(sqrt(n+1))):
    if n%i==0:
        ans+=n//i-1
print(ans)

Solution (Python):
def main():
    import sys
    import time
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N = int(input())
    mod = N
    ans = 0
    c = 1
    while True:
        if N // mod == N % mod:
            ans += mod
            c += 1
            mod = N // c
            continue
        mod -= 1
        if not mod:
            break
        if N % mod > c:
            c += 1
            mod = N // c
            continue
        if N // mod == N // c:
            c += 1

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()

def add(m):
    m -= 1
    if m and n % m == n // m:
        return m
    return 0

i = 1
ans = 0
while i * i <= n:
    ans += add(i)
    if i * i != n:
        ans += add(n // i)
    i += 1
    
print(ans)

Solution (Python):


n = int(input())

i = 1
ans = 0
while i <= n ** 0.5 + 1:
    if (n - i) % i == 0 and (n - i) // i > i:
        ans += (n - i) // i
    i += 1
print(ans)

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

    i = 1
    out = 0
    while i*i <= N:
        if N%i == 0 and i < N//i-1:
            out += (N//i - 1)
        i += 1
    print(out)
    return

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
def input(): return sys.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

def main():
    n=int(input())
    ans=0
    div_n=make_divisors(n)
    for p in div_n:
        m=(n-p)//p
        if m>0 and n%m==p:
            ans+=m
    print(ans)

if __name__=='__main__':
    main()

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

print(ans)

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

print(ans)

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

ans = 0

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

Solution (Python):
import sys

input = sys.stdin.readline


def calc_divisors(n):
    divisors_a = []
    divisors_b = []
    for d in range(1, int(n**0.5) + 1):
        if n % d == 0:
            divisors_a.append(d)
            if n // d != d:
                divisors_b.append(n // d)
    divisors = divisors_a + divisors_b[::-1]
    return divisors


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

    divisors = calc_divisors(N)
    ans = 0
    for divisor in divisors:
        q = divisor
        m = N // q - 1
        if 1 < m and q < m:
            ans += m

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


from math import ceil, floor

def divisors(N):
    ans = []
    i = 1
    while i * i <= N:
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
        i += 1
    ans.sort()
    return ans

N = int(input())
fN = divisors(N)

total = 0
for m in fN[1:]:
    m -= 1
    if floor(N / m) == N % m:
        total += m
print(total)

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)

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

Solution (Python):
import math
x = int(input())
if x == 1:
  print(0)
  exit()
  
d = math.ceil((x+1)**0.5)
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

ans = 0
fct = factorize(x)
for div in divisorize(fct):
    c = num(div)
    if d+1 <= c:
      ans += c-1
      
print(ans)

Solution (Python):
import math
x = int(input())
if x == 1:
  print(0)
  exit()
  
d = math.ceil((x+1)**0.5)
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

ans = 0
fct = factorize(x)
for div in divisorize(fct):
    c = num(div)
    if d+1 <= c:
      ans += c-1
      
print(ans)

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


def calc_divisors(n):
    divisors_a = []
    divisors_b = []
    for d in range(1, int(n**0.5) + 1):
        if n % d == 0:
            divisors_a.append(d)
            if n // d != d:
                divisors_b.append(n // d)
    divisors = divisors_a + divisors_b[::-1]
    return divisors


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

    divisors = calc_divisors(N)

    
    
    

    m_set = set()
    for d in divisors:
        m = N // d - 1
        if d < m and m != 1:
            m_set.add(m)
    ans = sum(m_set)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


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

    div = make_divisors(n)
    res = 0
    for i in div:
        if i != 1:
            x, y = divmod(n, i - 1)
            if x == y:
                res += i - 1

    print(res)


if __name__ == '__main__':
    resolve()

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)

ans=0
for m in A[1:]:
    m -=1
    if int(n/m)==n%m:
        ans +=m
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)

ans=0
for m in A[1:]:
    m -=1
    if int(n/m)==n%m:
        ans +=m
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N=int(input())
    cnt=0
    i=1
    while True:
        M=N
        M-=i
        p=M/i
        if p<=i:
            break
        else:
            if p.is_integer():
                cnt+=p
            i+=1
    print(int(cnt))



resolve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

def divisors(n):
    ret = set()
    m = 1
    while m*m <= n:
        if n%m==0:
            
            if n//m > m+1:
                ret.add(n//m)
        m += 1
    return ret
ndivs = list(divisors(n))

ans = sum(ndivs) - len(ndivs)*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
l=make_divisors(n)
for li in l:
  m=(n-li)//li
  if li <= m-1:
    ans+=m
print(ans)

Solution (Python):



N = int(input())


ans = 0


r = 1
while r**2<=N:
    if (N-r)%r==0 and (N-r)/r>r:
        ans += (N-r)//r
    r += 1


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)

    divisors.sort()
    return divisors

divisors = make_divisors(N)

i = 0
res = 0
while True:
    l = divisors[i]
    r = divisors[-(i+1)]
    if r - 1 > l:
        res += r - 1
        i += 1
    else:
        break

print(res)

Solution (Python):
import math
N=int(input())
ans=[]
for i in range(1,int(math.sqrt(N))+1):
    if N%i==0:
        num1=i
        num2=N//i
        if (num1-1)>num2:
            ans.append(num1-1)
        if (num2-1)>num1:
            ans.append(num2-1)

ans=list(set(ans))
print(sum(ans))

Solution (Python):
from math import sqrt
N = int(input())
M = int((sqrt(4*N+1)-1)/2)
ans = 0
a = 1
while a <= M:
  if N % a == 0:
    m = N // a - 1
    ans += m if m > 0 and N % m == a else 0
  a += 1
print(ans)

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


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

ans = 0
for x in factor(N):
    m = (N//x) - 1
    if x < m:
        ans += m

print(ans)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())

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

div = make_divisors(n)
ans = 0
for i in div:
    res = n//i-1
    if res <= 0:continue
    if n%res==i:
        ans += res

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

d = make_divisors(n)
ans = 0
for a in d:
    if a == 1:
        continue
    else:
        q = n//a
        m = a-1
        if 0 <= q <= m-1:
            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

d = make_divisors(n)
ans = 0
for a in d:
    if a == 1:
        continue
    else:
        q = n//a
        m = a-1
        if 0 <= q <= m-1:
            ans += m
print(ans)

Solution (Python):
n = int(input())
    
def md(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 = md(n)

ans = 0
for i in a:
    b = n // i
    if i < b-1:
        ans += (b-1)
        
print(ans)

Solution (Python):
import sys
import math  
import bisect  
import queue  


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


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


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

    res = 0
    divisors = make_divisors(N)
    for d in divisors:
        m = d - 1
        if m > 0:
            if (N // m) == (N % m):
                res += m

    print(res)


if __name__ == '__main__':
    main()

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

l=make_divisors(N)
ans=0
for i in range(len(l)):
    num=l[i]-1
    if num==0:
        continue
    if num==1:
        continue
    p=N//num
    q=N%num
    if p==q:
        ans+=num 
print(ans)

Solution (Python):
def main():
    def trial_division(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)
        return divs

    N = int(input())
    divs = trial_division(N)
    ans = 0
    for d in divs:
        if d != 1 and N//(d-1) == N % (d-1):
            ans += (d-1)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    def trial_division(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)
        return divs

    N = int(input())
    divs = trial_division(N)
    ans = 0
    for d in divs:
        if d != 1 and N//(d-1) == N % (d-1):
            ans += (d-1)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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


def solve():
    N = int(rl())
    
    divs = make_divisors(N)
    ans = 0
    for div in divs[1:]:
        m = div - 1
        if N // m == N % m:
            ans += m
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
import numpy as np
import math

N = int(input())


lim = math.ceil(np.sqrt(N))

ans = 0

for i in range(lim):
    rem = i+1
    if N <= rem**2 + rem:
        break
    if (N-rem) % rem == 0:
        ans += (N-rem)/rem

print(int(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)
    divisors.sort()
    return divisors
l=make_divisors(n)
ans=0
for i in l:
    if i-1>(n**0.5):
        ans+=i-1
print(ans)

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

Solution (Python):
from collections import defaultdict
import math


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

nums = make_divisors(N)

ans = 0
for num in nums:
    if num != 1:
        if N % (num -1) == N // (num -1):
            ans += num -1
print(ans)

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