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

def make_divisors(n):
    from collections import deque
    divisors = deque([])
    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)
    lst_divisors = list(divisors)
    lst_divisors.sort()
    return lst_divisors

lst = make_divisors(n)




ans = 0
for y in lst:
    if y > 1 and n//(y-1) == n%(y-1):
        ans += y-1
        
print(ans)

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	n = int(input())
	return maa(n)
	
	
	for i in range(1,10000):
		if maa(i)!=mab(i):
			pa(maa(i), mab(i))
			return i
	print('ok')
	
def maa(n):
	ret = 0
	rr=[]
	for i in range(1, n+1):
		if n//i <= i:
			break
			
		if (n-i) % i == 0:
			if i == (n-i)//i:
				return ret
			
			ret += (n-i)//i
			
			
	return ret
	
def mab(n):
	ret = 0
	for i in range(1, n+1):
		if n // i == n%i:
			ret += i
	return ret
	
	

isTest=False

def pa(*vl):
	if not isTest:
		return
	print(*vl)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

total = 0

for i in range(1, int(n**0.5)+1):
    if n%i == 0:
        a = i
        b = n//i

        if a != 1 and (n//(a-1))*a == n:
            total += a-1
        if b != a and (n//(b-1))*b == n:
            total += b-1

print(total)

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

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

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


def read():
    N = int(input().strip())
    return N,


def solve(N):
    
    ans = 0
    p = 1
    while p * p <= N:
        if N % p == 0:
            m = N // p - 1
            if p < m:
                ans += m
            else:
                break
        p += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

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

t1=2
comb=set()
while t1*t1<=n:
    if n%t1==0:
        t2=n//t1

        m=t1-1
        if t2==n%m:
            comb.add(m)
        m=t2-1
        if t1==n%m:
            comb.add(m)
    t1+=1

if n>2:
    print(sum(comb)+n-1)
else:
    print(sum(comb))

Solution (Python):
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())
divs = make_divisors(n)

def judge(d):
  if n // (d-1) == n % (d-1):
    return True
  else:
    return False

ans = 0
for d in divs:
  if d > 1 and judge(d):
    ans += d-1
print(ans)

Solution (Python):
import sys, math, re
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

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

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

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 main():
    N = ii()
    d = make_divisors(N)
    ans = 0

    for a in d:
        m = (N-a)//a
        if a < m:
            ans += m

    print(ans)


if __name__ == "__main__":
    main()

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

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

from functools import reduce
import operator
int_product = lambda it: reduce(operator.mul,it,1)


def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i
    if n > 1:
        yield n

def divisors(n):
    factors = prime_factors(n)
    factors = Counter(factors)
    pows = tuple(factors.values())
    factors = tuple(factors.keys())
    for pp in product(*(range(p+1) for p in pows)):
        yield int_product(f**p for f,p in zip(factors,pp))


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

print(res)

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

Solution (Python):

def resolve():
    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 k in div[1:]:  
        m = k - 1
        if m <= 0:
            continue
        if N // m == N % m:
            ans += m

    print(ans)


if __name__ == "__main__":
    resolve()

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

ans = 0
if N > 3:
    ans += N-1

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

print(ans)

Solution (Python):
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

N=intput()
ans=0
for x in range(1,int(N**0.5)+1000):
    if (N-x)%x==0:
        m=(N-x)//x
        if m<=x:
            break
        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]

arr = make_divisors(n)
total=0
for m in arr:
    r = n//m

    if r<m-1:
        total +=m-1


print(total)

Solution (Python):
def 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())
div = divisors(n)

ans = 0
for d in div:
    if d-1 == 0:
        continue
    if n%(d-1) == n//(d-1):
        ans += d-1
print(ans)

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

ans = 0
for i in range(1, N):
  if ((N-i)%i==0) and (i<(N-i)//i):
    ans += (N-i)//i
  elif i > (N-i)//i:
    break
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]





if N < 3:
    print(0)
else:
    mylist = make_divisors(N)
    idx = len(mylist)//2
    ans = 0
    for x in mylist[idx:]:
        if N//(x-1) == N%(x-1):
            ans += x-1
    print(ans)

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

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

Solution (Python):
import sys



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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def make_divisors(n: int):
    lower_divs = []
    upper_divs = []
    i = 1
    while i**2 <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n // i)
        i += 1
    return lower_divs + upper_divs[::-1]


def main():
    n = input_int()
    divs = make_divisors(n)
    ans = 0
    for div in divs:
        m = (n // div) - 1
        if m == 0:
            continue
        if n // m == n % m:
            ans += m
    print(ans)

    return


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
ans = 0
q = 1
while(q ** 2 + q < N):
  m = (N - q) / q
  if(m.is_integer()):
    ans += int(m)
  q += 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

ans=0
n = int(input())
divisors = make_divisors(n)
for i in divisors[1:]:
    i -= 1
    if n % i == n//i:
        ans += i

print(ans)

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




def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))




def main():
	n=II()

	ans=0
	for i in range(1,10**6+10):
		a=n-i
		if a%i==0:
			b=a//i
			if b>i:
				ans+=b
			else:
				break
	print(ans)



	
	
	



	
	
	









if __name__ == "__main__":
	main()

Solution (Python):
import math

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

Solution (Python):
import math

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

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

from collections import defaultdict
sys.setrecursionlimit(10**7)
import math








INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

class factorials:
    '''
    args:
      n : max val when exploring factorials
    '''
    def __init__(self, n):
        self.n = 1
        self.factorials = []
        self.update_factorials(n)

    def update_factorials(self, n):
        if self.n >= n:
            return None
        for i in range(self.n+1, n+1):
            done = False
            limit = int(i ** 0.5)
            for j in self.factorials:
                if j > limit: break
                if not i % j:
                    done = True
                    break
            if not done:
                self.factorials.append(i)
        self.n = n
        return None

    def factorials_list(self):
        return self.factorials

    def check_fact(self, x):
        if x > self.n**2:
            self.update_factorials(int(x ** 0.5)+1)
        MAX = int(math.sqrt(x))
        for f in self.factorials:
            if f > MAX:break
            if not x % f:
                return False
        return True

    def prime_factorization(self, val, divisors=None):
        
        max_n = int(math.sqrt(val))
        if self.n < max_n:
            self.update_factorials(max_n)
        if divisors == None:
            divisors = defaultdict(lambda: 0)
        for f in self.factorials:
            if f > val: break
            while True:
                if not val % f:
                    divisors[f] += 1
                    val //= f
                else:
                    break
        if val > 1:
            divisors[val] += 1
        return divisors



def run():
    N = int(input())
    if N == 1:
        print(0)
        return
    facts = factorials(int(N ** 0.5))
    dic = facts.prime_factorization(N)
    
    ret = 0

    def dfs(x, l, v):
        nonlocal ret
        
        xx, ll = x[0], l[0]
        if len(x) == 1:
            for i in range(ll+1):
                tmp = v * (xx ** i)
                
                if tmp == 1:continue
                if N % (tmp-1) == N // (tmp-1):
                    
                    ret += tmp-1

        else:
            for i in range(ll + 1):
                tmp = v * xx ** i
                dfs(x[1:], l[1:], tmp)

    dfs(list(dic.keys()), list(dic.values()), 1)

    print(ret)

if __name__ == "__main__":
    run()

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

if N == 1:
  print(0)
  exit()

ans = 0
i = 1
while True:
  m = N//i-1
  q,r = divmod(N,m)
  if q == r:
    ans += m
  if m<N**.5:
    break
  i += 1
  
print(ans)

Solution (Python):
class common_function():
    """
        1. よく使いそうで予め用意してあるものをまとめた
        2. よく使いそうな関数群をまとめた
    """
    def make_divisors(self, n:int):
        """
            試し割り法による約数の列挙を行うメソッド
            ある値 n の約数の列挙を行うのに O(n^(1/2)) かかる.
            e.g.
                input: 96
                output: [1, 96, 2, 48, 3, 32, 4, 24, 6, 16, 8, 12]
        """
        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 main():
    common = common_function()
    N = int(input())
    m = common.make_divisors(N)
    ans = 0
    for i in m:
        if i == 1:
            continue
        ans += (N%(i-1) == N//(i-1)) * (i-1)
    print(ans)

if __name__ == "__main__":
    main()

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

Solution (Python):
N=int(input())
def div(n):
    low,high= [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            low.append(i)
            if i != n // i:
                high.append(n//i)
        i += 1
    return low+high[::-1]
S=div(N)
ans=0
S=S[1:]
for i in S:
   if i==0:
      continue
   if N%(i-1)==N//(i-1):
      ans+=i-1
print(ans)

Solution (Python):
def main():
    N = int(input())
    
    
    
    ans = 0
    r = 0
    while (r + 1) ** 2 <= N:
        r += 1
        if N % r > 0:
            continue
        m = N // r - 1
        if r < m:
            ans += m
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil

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

d = divisor(n)
ans = 0
for num in d:
    if num>1 and n%(num-1)==n//(num-1):
        ans+=num-1
print(ans)

Solution (Python):

c,n = 0,int(raw_input())
def check(v,n):
	return v and n/v == n%v

for d in range(1, (int(n **0.5) +1)):
	if n % d == 0:
		for v in set([d, n/d]):
			if check(v-1,n):
				c += v-1

print c

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

result = 0
for i in range(1, N+1):
    m = N // i - 1
    if m == 0:
        continue
    if N // m == N % m:
        result += m
    elif m < i:
        break

print(result)

Solution (Python):
import sys

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

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

Solution (Python):


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

ans=0
for M in arr:
    m=M-1
    if m==0:continue
    if N%m==N//m:
        ans+=m
print(ans)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math















import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7


from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
def yaku(m):
    ans = []
    i = 1
    while i*i <= m:
        if m % i == 0:
            j = m // i
            ans.append(i)
            if j != i:
                ans.append(j)
        i += 1
    ans = sorted(ans)
    return ans
dic = yaku(n)
dic = Counter(dic[1:])
ans = 0
for k,v in dic.items():
    m = k-1
    if n//m == n%m:
        ans += m
print(ans)

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


def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


A = divisor(N)
A = [i - 1 for i in A]

ans = 0
for a in A:
    if a == 0:
        continue
    if N // a == N % a:
        ans += a

print(ans)

Solution (Python):
import math
from collections import Counter
N = int(input())
Nyakusu = []
Nruto = math.sqrt(N)
Nruto = math.ceil(Nruto)

for i in range(1, Nruto+1):
    if N % i == 0:
        Nyakusu.append(N//i-1)
        Nyakusu.append((N//(N//i))-1)
ans = 0
Nyakusu = Counter(Nyakusu)
for m in Nyakusu.keys():
    if m == 0:
        continue
    if N//m != N % m:
        continue
    ans += m
print(ans)

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())

N = I()



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

ans = 0
for d in divisor:
    m = d-1
    if N//d < m:
        ans += m

print(ans)

Solution (Python):
N = int(input())
ans = 0
for i in range(1,min(N,1250000)):
    if(((N-i)/i).is_integer() and N//((N-i)/i) == N%((N-i)/i)):
        
        ans += ((N-i)//i)
        
        
    
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
x = 1
ans = 0
while x**2<=N:
    if N%x==0:
        div = N//x
        if div-1>x:
            ans += div-1
    x += 1

print(ans)

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

Solution (Python):
n = int(input())
ans = 0
sqrt = int(n ** 0.5)
for i in range(1, sqrt+1):
    if n % i == 0:
        m = n // i - 1
        if m != 0 and n // m == n % m:
            ans += m
        if n // i == i: continue
        m = i - 1
        if m != 0 and n // m == n % m:
            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]



arr = make_divisors(n)
arr = [x - 1 for x in arr if x >= 2]


ans = 0
for x in arr[::-1]:
    if n // x != n % x:
        break
    ans += x

print(ans)

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

Solution (Python):
import math


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


main()

Solution (Python):
def prime(p):
    memo = [p]
    for i in range(2,(int(p**0.5)+1)):
        if p%i == 0:
            memo.append(i)
            memo.append(p//i)
    return memo

x = int(input())

if x== 1:
    print(0)
    exit()

memo = prime(x)

ans = 0

for i in memo:
    if x%(i-1)==x//(i-1):
        ans += i-1
print(ans)

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

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

print(ans)

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

def divisore(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

d=divisore(n)

ans=0
for i in d[1:]:
  cand=i-1
  if n//cand==n%cand:
    ans+=cand

print(ans)

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

def divisore(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

d=divisore(n)

ans=0
for i in d[1:]:
  cand=i-1
  if n//cand==n%cand:
    ans+=cand

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  

N = I()

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

ans = 0
for d in divisor:
    m = d-1
    if N//d < 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:
        k = (n // i) - 1
        if k > i:
            ans += k
print(ans)

Solution (Python):
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    N = m*p+q = m*q+q = q*(m+1)   q < m
    N%m = (m*p+q)%m = q%m = q = N/m = (m*p+q)/m = p

    3*2+2
    7*1+1
    """
    N = read_int()
    answer = 0
    for q in range(1, math.ceil(math.sqrt(N))):
        if N%q == 0 and q < N//q-1:
            answer += N//q-1
    return answer



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

Solution (Python):
from math import sqrt

n = int(input())

ans = 0


def judge(x):
    global n
    if x == 0:
        return False
    return n // x == n % x


for i in range(1, int(sqrt(n)) + 1):
    if n % i == 0:
        if judge(i-1):
            ans += i-1
        if judge(n // i - 1):
            ans += n // 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)
    divisors.sort()
    return divisors

divs = make_divisors(n)

for div in divs[::-1]:
    if div - 1 >= 2 and div - 1 > n/div:
        ans += div - 1
print(ans)

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

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

Solution (Python):
n=int(input())
ans=0
for i in range(1,int(n**.5+(n**.5%1!=0))):
  j=(n-i)//i
  if n%j==n//j:
    ans+=j
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

ans_list = list()
divisors = make_divisors(N)

for p in divisors:
    if p!= N:
        m = N//p - 1
        if N//m == N%m:
            ans_list.append(m)
    
print(sum(ans_list))

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)
ans = 0
for div in divisors:
    if div != 1:
        q,r = divmod(n,div-1)
        if q == r:
            ans += div-1
print(ans)

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

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

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



N = int(input())
i = 1
divs = []
while i ** 2 <= N:
    if N % i == 0:
        divs.append((i, N // i))
    i += 1

ans = 0
for p in divs:
    r = p[0]
    m = p[1] - 1
    if m == 0:
        continue
    if N % m == r:
        ans += m
print(ans)

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











ans = (N-1) if N != 2 else 0
cur = 2
while (N-cur)//cur >= cur:

    if (N-cur)%cur == 0:
        a = (N-cur)//cur
        if N%a!=0:
            ans += (N-cur)//cur
    cur += 1

print(ans)

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

Solution (Python):


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


N = int(input())
l,u = make_divisors(N)
ans = 0
for ln,un in zip(l,u):
    if un-1>ln:
        ans += un-1
print(ans)

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

def isSQ(x):
  for i in range(1,10**6+1):
    if i**2==x:
      return i
    elif i**2>x:
      return -1
  else:
    return -1

answer=0
root=isSQ(N)
if root==-1:
  for i in range(1,int(N**0.5)+1):
    if N%i==0:
      ni=N//i-1
      if N//ni==N%ni:
        answer+=ni
else:
  for i in range(1,root):
    if N%i==0:
      ni=N//i-1
      if N//ni==N%ni:
        answer+=ni

print(answer)

Solution (Python):
def get_divisor(n: int) -> list:
    divisor = []
    for i in range(1, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            divisor.append(i)
            if n // i != i:
                divisor.append(n // i)
    
    return divisor


n = int(input())
divisor = get_divisor(n)
ans = 0
for x in divisor:
    if n == x:
        continue
    m = n // x - 1
    if n // m == n % m:
        ans += m

print(ans)