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):
from collections import defaultdict
import math


def kari():
    map(int, input().split())
    list(map(int, input().split()))
    math.ceil()

def main():
    num = int(input())
    ans = 0

    for i in range(1, num):
        if i *(i + 1) + i > num:
            break

        kari_num = num
        kari_num -= i
        if kari_num % i != 0:
            continue

        kari_waru = kari_num // i

        
        if kari_waru == 0 or kari_waru == 1:
            continue

        if kari_num % kari_waru == 0:
            
            ans += kari_waru

    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):





import sys


N = int(input())




sum_ = 0



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

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)

count = 0
for divisor in divisors:
    m = divisor-1
    if m and (N//m == N%m):
        count += m
print(count)

Solution (Python):
N = int(input())
ans = 0
l = list()
for i in range(1, int(N**0.5)+1):
  if N % i == 0:  
    if i > 1:
      m = i-1
      if N//m == N % m:ans += m
    if i != N//i:
      m = N//i-1
      if 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)
    return divisors



N = int(input())
candidate = make_divisors(N)
ans = 0

for j in candidate:
    if j == 1:
        continue
    if N % (j - 1) == N // (j - 1):
        ans += (j -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)

    
    return divisors
c=0
for i in make_divisors(n):
    if i!=1 and n//(i-1)==n%(i-1):
        c+=(i-1)
print(c)

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

for i in range(1,int(math.sqrt(n)) + 1):
    if n % i == 0:
        if (n-i) // i > 0 and n // ((n-i) // i) == n % ((n-i) // i):
            cnt += (n-i) // i
print(cnt)

Solution (Python):

N  = int(input())
ans = 0
def divisor(N):
    div_lst = [N] if N != 1 else []
    for n in range(2, int(N ** 0.5 + 1)):
        if N % n == 0:
            if  n == N // n:
                div_lst.append(n)
            else:
                div_lst.append(n)
                div_lst.append(N // n)

    return div_lst

div_lst = divisor(N)
for m in div_lst:
    m = m - 1
    if N // m == N % m:
        ans += m
print(ans)

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

Solution (Python):


import sys
import copy

sys.setrecursionlimit(1000000)






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


N = int(input())

divisors = DIVISORS(N)

ans = 0
for x in divisors:
    m = x - 1
    if m <= 0:
        continue
    if N // x == N % m:
        ans += m


print(ans)

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

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










N = int(stdin.readline().rstrip().split()[0])

sqrtN = int(np.sqrt(N))
ans = 0
for i in range(1,sqrtN+1):
  if N%i == 0:
    if N//i - 1 > i:
      ans += N//i -1
    
print(ans)

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

import numpy as np

sum = 0

for n in range(1, int(np.sqrt(N)+1)):
    x = (N - n ) // n
    if ((N - n) % n == 0) and (x > n):
        sum += x

print(sum)

Solution (Python):
a = int(input())
def d(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
s = 0
t = d(a)

for i in range(len(t)):
    if t[i] == 1:
        continue
    m = t[i]-1
    if(a//m) == (a%m):
        s+=m
print(s)

Solution (Python):
def solve(x):
    if(x<2):
        return 0
    k=1
    s=0
    while True:
        if(x%k==0):
            i=(x//k)-1
            if (x//i==x%i):
                s+=i
        k+=1
        if k*k>x:
            break
    return s
        

x=int(input())
print(solve(x))

Solution (Python):
from math import ceil
n = int(input())
res = 0
for i in range(1,ceil(n**0.5)):
    if n%i == 0 and i < n//i -1:
        res += n//i -1
print(res)

Solution (Python):
a = int(input())
def d(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
s = 0
t = d(a)

res = 0
for k in t:
    if k==1:
        continue
    m=k-1
    if (a//m)==(a%m):
        res+=m
print(res)

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


common = make_divisors(N)
summer = 0
for i in common:
    cd = N // i - 1
    if cd != 0:
        if N % cd == N // cd:
            summer += cd

print(summer)

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

Solution (Python):
def solve(N):
    s = 1
    e = int(pow(N, 0.5)) + 1
    ds = []
    for k in range(s, e):
        if N % k == 0:
            m = (N // k) - 1
            if m and N // m == N % m:
                ds.append(m)

    return sum(ds)

if __name__ == "__main__":
    N = int(input())
    print(solve(N))

Solution (Python):
import math
 
n = int(input())
s = 0
if n > 2:
  for p in range(1, int(math.sqrt(n)) + 1):
    t = (n - p) / p
    if t.is_integer():
      if (n // int(t)) == (n % int(t)):
        s += int(t)
  print(s)

else:
  print(0)

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

ans = N - 1 if N != 2 else 0
for i in range(2, int(N ** 0.5) + 1):
    if N % i == 0:
        a = N // i
        b = i
        if N // (a-1) == N % (a-1):
            ans += a-1
        if N // (b-1) == N % (b-1):
            ans += b-1

print(ans)

Solution (Python):

from math import sqrt
n = int(input())

selected = set()
res = 0
for w in range(1,int(sqrt(n))+10):
    if n%w==0:
        m = (n-w)//w
        if m>0 and m not in selected and n//m == n%m:
            res += m
            selected.add(m)

        w2 = n//w
        m2 = (n-w2)//w2
        if m2>0 and m2 not in selected and n//m2 == n%m2:
            res += m2
            selected.add(m2)
print(res)

Solution (Python):

from math import sqrt
n = int(input())

res = 0
for w in range(1,int(sqrt(n))+10):
    if n%w==0:
        m = (n-w)//w
        if m>0 and n//m == n%m:
            res += m
print(res)

Solution (Python):
n,i,a=int(input()),1,0
while-~i*i<n:a+=n%i<1and n//i-1;i+=1
print(a)

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

ans=0
divisors=make_divisors(N)

for d in divisors:
    m=(d-1)
    if m and (N//m==N%m):
        ans+=m

print(ans)

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

for i in range(2, int(N ** 0.5) + 1):
    if N % i == 0:
        m1 = i - 1
        m2 = N // i - 1
        if N // m1 == N % m1:
            ans += m1
        elif m1 != m2 and N // m2 == N % m2:
            ans += m2

ans += N - 1
if N == 2:
    ans = 0

print(ans)

Solution (Python):
import math

N = int(input())
ans = 0
sqi = math.sqrt(N)
for i in range(1, int(sqi)+1):
    if (N-i)%i == 0:
        m = (N-i)//i
        if m > 0:
        	if N//m == N%m:
        		ans += (N-i)//i
print(ans)

Solution (Python):
from math import sqrt
n=int(input())
s=0
for i in range(int(sqrt(n))):
    d,m=divmod(n,i+1)
    if m == 0:
        if d>1 and len(set(divmod(n,d-1))) == 1:
            s += d-1
print(s)

Solution (Python):
import math

N = int(input())
ans = 0
ms = set()
sqi = math.sqrt(N)
for i in range(1, int(sqi)+1):
    if N % i == 0:
        ms.add(i-1)
        ms.add(N//i-1)
for m in ms:
    if m <= 0:
        continue
    if N//m == N%m:
        ans += m
print(ans)

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

def gen_div(n):
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            yield i
            if n // i != i:
                yield n // i

sum = 0
for i in gen_div(N):
    if i == 1:
        continue
    a = i - 1
    q, m = N // a, N % a
    if q == m:
        sum += a

print(sum)

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

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

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

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

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

s = 0
x = 1
while True:
    n = N - x
    m = n//x
    if m <= x:
        break
    if n % m == 0:
        s += m
    x += 1

print(s)

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

Solution (Python):
def dv(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.remove(1)
    return divisors
n=int(input())
x=dv(n)
ans=0
for i in x:
    if n//(i-1)==n%(i-1):
        ans+=i-1

print(ans)

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

result = 0
for i in range(1, math.ceil(((1+4*N)**0.5-1)/2)):
  if (N - i) % i == 0:
    result += (N - i) // i
      
print(int(result))

Solution (Python):
n=int(input())
cnt=0
k=1
l=[]
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        l.append(i)
        if n//i!=i:l.append(n//i)
for k in l:
    x=(n-k)/k
    intx=int(x)
    if x==intx and intx>k:cnt+=intx
print(cnt)

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

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

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 += n//i-1
print(ans)

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

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())
ans,i = 0,1
while i*i<=n:
    if n % i == 0:
        if 1<i and n//(i-1) == n%(i-1):
            ans += i-1
        j = n//i
        if 1<j and n//(j-1) == n%(j-1):
            ans += j-1
    i+=1
print(ans)

Solution (Python):
import math
 
N = int(input())
d_list = []
 
for i in range(1, int(math.sqrt(N)) + 1):
  if N % i == 0:
    if i != 1:
      if (N // (i - 1)) == (N % (i - 1)):
        d_list.append(i)
    if i != math.sqrt(N):
      if (N // (N / i - 1)) == (N % (N / i - 1)):
        d_list.append(N / i)
 
output = sum(d_list) - len(d_list)
print(int(output))

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

kmax = (N+1/4)**(1/2)-1/2

acc = 0
for k in range(1, int(kmax+1)):
    m = (N-k)//k
    if(((N-k)%k==0)&(k<m)):
        acc+=m
print(int(acc))

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

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)

m_list = []
for k in divisors:
    if N % k == 0 and N > k:
        m = int((N / k) - 1)
        if k == N%m:
            A = N / (m + 1)
            m_list.append(m)

print(sum(m_list))

Solution (Python):
n = int(input())
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** .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:
    m = d - 1
    if m == 0:
        continue
    if n // m == n % m:
        ans += m
print(ans)

Solution (Python):
n = int(input())
ans = 0
x_max = (n+1/4)**(1/2) - 1/2
for x in range(1, int(x_max + 1)):

    m = (n-x) // x
    if (n-x) % x == 0 and x < m:
        ans += m


print(ans)

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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 - 1)
    
    return divisors

l = make_divisors(n)
ans = 0
for i in l:
    a = int(n / i)
    q = n % i
    if a == q:
        ans += i
print(ans)

Solution (Python):
from collections import defaultdict
from itertools import product

n = int(input())
if n < 3:
    print(0)
else:
    rt = int(n ** 0.5)
    factors = defaultdict(int)
    N = n
    n_div = 2
    while n > 1:
        if n_div == int(n ** 0.5) + 2:
            factors[n] += 1
            break
        while not n % n_div:
            factors[n_div] += 1
            n = n // n_div
        n_div += 1
    lis = [1]
    for k, v in factors.items():
        facts = [k ** i for i in range(v + 1)]
        it = product(lis, facts)
        lis = [a * b for a, b in it]
    nums = [l - 1 for l in lis if l - 1]
    nums = [i for i in nums if (N //i) == (N % i)]
    print(sum(nums))

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

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

result = 0
for i in range(1, int(N**0.5)+1):
  if N % i == 0:
    for j in set([i, N//i]):
      num = j - 1
      if num != 0 and N // num == N % num:
        result += num

print(int(result))

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


ans = 0
divisors = make_divisors(N)

for d in divisors:
    m = (d - 1)
    if m and (N//m == N % m):
        ans += m

print(ans)

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

Solution (Python):
import math

N = int(input())

rootN = int(math.sqrt(N))

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

Solution (Python):
N = int(input())
import math
sq_N = int(math.sqrt(N))
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)

    divisors.sort()
    return divisors
N_divs = make_divisors(N)


for i in range(len(N_divs)): 
    k = N//N_divs[i] - 1
    if k != 0:
        if N//k == N%k:
            ans += k

print(ans)

Solution (Python):
m=int(input())
pf={m:1}
a=[0]
for i in range(2,int(m**0.5)+1):
    if m ==1:
        break
    pf[i]=pf.get(i,0)+1
    if i!=m//i:
        pf[m//i]=pf.get(m//i,0)+1
for i in pf:
    if m!=1and m//(i-1)==m%(i-1):
        a.append(a[-1]+i-1)
print(a[-1])

Solution (Python):
n = int(input())
count = 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 i in range(len(l)):
  if l[i]-1 > 0 and n // (l[i]-1) == n % (l[i]-1):
    count += l[i]-1
print(count)

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

output = 0
divisors = make_divisors(N)
for div in divisors:
    if N/div < (div - 1):
        output += div - 1

print(output)

Solution (Python):
import math

N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1):
    d = N - i
    if d%i==0 and i < (N // i) -1:
        k = d//i
        count+=k
print(count)

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    
    
    
    
    ans = 0
    for k in range(1, int(N**0.5)+1):
        if N % k == 0:
            m = N // k - 1
            if k >= m:
                break
            ans += m

    return ans


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

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

n=int(input())
l=[]

md=make_divisors(n)
if 1 in md:
    md.remove(1)
for i in md:
    k=i-1
    if n//k==n%k:
        
        l.append(k)

print(sum(l))

Solution (Python):
import math

N = int(input())

rootN = int(math.sqrt(N))

ans = 0
for i in range(1,rootN+1):
    if N%i==0:
        j = (N//i) - 1
        if i < j:
            ans += j
        
print(ans)

Solution (Python):
N = int(input())
count = 0 
X = 0
q = 1
while N >= X:
    if N%q==0 and N/q-1<N and N/q-1!=1:
        count += N/q-1
    q += 1
    X = (q+1)*q+q
print(int(count))

Solution (Python):
def main():
    n = input()
    s = 0
    i = 1
    while i * i < n:
        if n % i == 0:
            a = n // i - 1
            if i < a:
                s += a
        i += 1
    print s


if __name__ == '__main__':
    main()

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

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

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

c = 0

def check(a, n):
  if a == 0:
    return False
  d = n // a
  m = n % a
  return d == m

for i in range(1, n):
  ii = i*i
  if ii > n:
    break
  if n % i == 0:
    r = i - 1
    if check(r, n):
      c += i
    if ii != n:
      r = n // i - 1
      if check(r, n):
        c += r

print(c)

Solution (Python):
import numpy as np
N = int(input())
cnt = 0
for i in range(1, int(np.ceil(np.sqrt(N)))):
    if (N-i)%i ==0 and (N-i)/i >i:
        cnt += int((N-i)/i)
print(cnt)

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

divisors = gen_divisors(N)
divisors.remove(1)
ans = sum([d-1 for d in divisors if N//(d-1) == N%(d-1)])

print(ans)

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

m = math.floor(n/2)
if n>2:
    q = int( n / m )
    lm= m
    s = n - 1
else:
    s = 0

while( m>1 ):
    m = math.floor(n/(q+1))
    r0 = n % ( m + 1 )
    if r0>=q:
        d= r0  - q
        if d%q==0:
            s+= ( m+1+int(d/q) )
    
    
    q = int( n/m )
    lm= m

print( s )

Solution (Python):

import math

N = int(input())

m = math.floor(N ** 0.5) + 1

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

print(ans)

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

divisors = gen_divisors(N)
divisors.remove(1)
ans = 0
for d in divisors:
    m = d-1
    if N//m == N%m:
        ans += m

print(ans)

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

Solution (Python):
import math

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

n = int(input())

div = findDivisor(n)

c = 0
for d in set(div)-{1}:
    if n//(d-1) == n%(d-1):
        c += d-1

print(c)

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


div = make_divisors(N)
total = 0

for num in div:
    if num == 1:
        continue

    if N // (num - 1) == N % (num - 1):
        total += (num - 1)

print(total)

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

Solution (Python):
import math
n=int(input())
r=int(math.sqrt(n))
ctr=0
for i in range(1,r+1):
    if n%i==0 and n//i-1>i:
        ctr+=n//i-1
print(ctr)

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

tmp = []
for i in range(1,int(N **(0.5)) + 2):
    if N % i == 0:
        tmp.append(i -1)
        tmp.append(N // i - 1)

res = 0

for t in tmp:
    if t > 0 and N // t == N % t:
        res += t

print(res)

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

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

for j in range(len(div)):
	if div[j] == 1:  
		pass
	else:
		m = div[j] - 1
		if N // m == N % m:
			ans += m

print(ans)

Solution (Python):
import math
N = int(input())
cnt = 0
for i in range(1,int(math.sqrt(N))+1):
    if N % i == 0:
        m = N/i-1
        if m > i:
            cnt += m
print(int(cnt))

Solution (Python):
def solve(N):
    s = 1
    e = int(pow(N, 0.5)) + 1
    ds = []
    for i in range(s, e):
        if N % i == 0:
            m = (N // i) - 1
            if m and N // m == N % m:
                ds.append(N // i)

    return sum([i - 1 for i in ds])

if __name__ == "__main__":
    N = int(input())
    print(solve(N))

Solution (Python):
from math import sqrt

def factorization(n):
    l = set()
    for i in range(1, int(sqrt(n))+1):
        if not n % i:
            l.add(i)
            l.add(n//i)
    return l

N = int(input())
ans = 0
for m in factorization(N):
    m -= 1
    if m > 0 and N == (N//m)*(m + 1):
        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)
    return divisors

n=int(input())
arr=make_divisors(n)


count=0
for i in arr:
    if i==1:
        continue
    if n//(i-1) == n%(i-1):
        count+=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)
  return divisors

div = make_divisors(N)
ans = 0
for d in div:
  if d != 1 and N // (d - 1) == N % (d - 1):
    ans += d - 1

print(ans)

Solution (Python):
def makediv(n):
  ret=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      if i!=n//i:
        ret.append(n//i)
  return ret
 
n=int(input())
arr=sorted(makediv(n),reverse=True)
ans=0
for i in arr:
  q=n//i
  if i-1<=q:
    break
  ans+=i-1
print(ans)

Solution (Python):
n=int(input())
a=0
for i in range(1,int(n**.5+1)):t=n//i-1;a+=t*(t and i==n%t)
print(a)

Solution (Python):
n=int(input())
res=0
for i in range(1,min(n,1000000)):
    if((n-i)%i==0):
        if(i>=(n-i)//i):
            break
        res+=(n-i)//i
print(res)

Solution (Python):
n=int(input())
a=0
for i in range(1,int(n**.5+1)):t=n//i-1;a+=t*(t and i==n%t)
print(a)

Solution (Python):

n = int(input())

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)

total = 0
for divisor in divisors:
    if divisor == 1:
        continue
    fav = divisor - 1
    x = n // fav
    y = n % fav
    if x == y:
        total += fav

print(total)

Solution (Python):

import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int):
    ret = 0

    for i in range(1, int(sqrt(N)) + 1):
        m = (N-1) // i
        if m == 0:
            continue
        if (N // m) == (N % m):
            ret += m
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    result = solve(N)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
sqrtN = int(N ** 0.5)
fac = []
for i in range(1, sqrtN+1):
    if N % i == 0:
        fac.append(i)
        if i ** 2 != N:
            fac.append(N//i)
ans = 0
div = 0
for p in fac[1:]:
    div = p - 1
    if N // div == N % div:
        
        ans += div
print(ans)

Solution (Python):
def dv(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.remove(1)
    return divisors


n=int(input())
x=dv(n)

y=[]
for i in x:
    if n//(i-1)==n%(i-1):
        y.append(i-1)

print(sum(y))

Solution (Python):
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N = int(stdin.readline().rstrip())


ans = 0
for k in range(1, int(math.sqrt(N+1))):
    if N % k == 0:
        
        
        ans += ((N//k)-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

ans = 0
for i in make_divisors(N):
    if i > 1 and N // (i - 1)  == N % (i - 1):
        ans += i - 1

print(ans)

Solution (Python):
n=int(input())
li=[]
ans=0
for x in range(1,int(n**0.5)+1):
    if n%x == 0:
        li.append(x)
        if x != n//x:
            li.append(n//x)
li.pop(0)
for x in li:
    if n//(x-1) == n%(x-1):
        ans+=x-1
print(ans)

Solution (Python):
def div(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())
d=div(n)
ans=0
for i in d:
    x=i-1
    if x!=0 and n//x==n%x: ans+=x

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
  
ans=0
count=1
factor=make_divisors(N)


factor.remove(N)
for f in factor:
  if f==N%((N-f)//f):
    ans+=(N-f)//f
  
print(ans)

Solution (Python):

import itertools
from collections import Counter
from collections import defaultdict
import bisect

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

    ans = 0
    i = 1
    while i * i <= N:
        if N % i == 0:
            opo1 = i - 1
            if opo1 > 0 and N // opo1 == N % opo1:
                ans += opo1
            opo2 = N // i - 1
            if opo2 > 0 and N // opo2 == N % opo2:
                ans += opo2

        i += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
y,f=[],[]
for i in range(1,int(N**0.5+1)):
	if N%i==0:
		y.append(i-1)
		if not i**2==N:
			y.append((N//i)-1)
del y[0]
for i in y:
	if (N//i)==(N%i):
		f.append(i)
print(sum(f))

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

result = 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

for i in make_divisors(n):
    x = n//i - 1
    if x!=0:
        if n%x == n//x:
            result+=x

print(result)

Solution (Python):
n = int(input())
ans = 0
x_max = (n+1/4)**(1/2) - 1/2
for x in range(1, int(x_max + 1)):

    m = (n-x) // x
    if (n-x) % x == 0 and x < m:
        ans += m


print(ans)