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

divs = make_divisors(N)
ans = 0
for div in divs:
    x = N//div-1
    if x > 0 and N // x == div:
        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())
t=make_divisors(n)
for i in range(len(t)):
    t[i]-=1
    if t[i]!=0:
        if n/t[i]>=t[i]:
            t[i]=0
print(sum(t))

Solution (Python):
n=int(input())
ans=0
def divisor(n):
    d0=[]
    d1=[]
    for i in range(1,int(n**.5)+1):
        x,y=divmod(n,i)
        if y==0:
            d0.append(i)
            d1.append(x)
    if d1[-1]==d0[-1]:
        d1=d1[:-1]
    return d0+d1[::-1]
d=divisor(n)
for i in d:
    if i>2 and n//i<i-1:
        ans+=i-1
print(ans)

Solution (Python):
import math
def num_divisors(n):
    ans = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            if i > 2 and i-1 > n // i: ans.append(i-1)
            if n != i**2 and n//i-1 > n // (n//i):
                ans.append(n//i-1)
    
    return ans

N = int(input())
lst = num_divisors(N)

print(sum(lst))

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

plist = make_divisors(N)

ans = 0
for p in plist:
    if p == N : continue
    m = N//p - 1
    if m > p:
        ans += m
        
print(ans)

Solution (Python):
from math import sqrt

def simple(N):
    c = 0
    for r in range(1, int(sqrt(N)) + 100):
        if N % r == 0:
            x = N // r - 1
            if x > r:
                c += x
    print(c)
    
simple(int(input()))

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

Solution (Python):
n = int(input())
s = set()
l = []
for i in range(1, int(n**(0.5))+1):
    p = (n-i) // i
    if (n-i) % i == 0 and i < p :
         l.append(p)
print(sum(l))

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

Solution (Python):
import math
val = int(input())
res = 0
current = 1
while True:
    rest = val - current
    plus = math.floor(rest / current)
    if plus == 0:
        break

    if math.floor(val / plus) == val % plus:
        res += plus
    if current * current + current >= val:
        break
    current += 1
print(str(res))

Solution (Python):
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())

def divisor(n): 
    f=[]
    d=[1]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    for i in range(len(f)):
        t=[]
        for j in range(1,f[i][1]+1):
            t.append(f[i][0]**j)
        for j in range(len(d)):
            for k in range(len(t)):
                d.append(d[j]*t[k])
    return sorted(d)

n=I()
div=divisor(n)
if len(div)%2==1:
    ddiv=div[len(div)//2+1:]
    ans=sum(ddiv)-len(ddiv)
else:
    if div[max(0,len(div)//2-1)]+1==div[len(div)//2]:
        if len(div)>=4:
            ddiv=div[len(div)//2+1:]
            ans=sum(ddiv)-len(ddiv)
        else:
            ans=0
    else:
        ddiv=div[len(div)//2:]
        ans=sum(ddiv)-len(ddiv)
print(ans)

Solution (Python):
import math
n=int(input())
n_root=math.ceil(n**(0.5))

sum=0
for i in range(1, n_root+1):
    if n%i==0 and (i+1)<int(n/i):
        sum=sum+int(n/i)-1
print(int(sum))

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

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

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

divs = get_divs(N)

ans = 0
for d in divs:
    l = d - 1
    if 0 < l > N//d:
        ans += (d-1)

print(ans)

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

Solution (Python):
import math
N = int(input())
ans = []
for i in range(1,math.ceil(N**0.5)):
    if N%i == 0:
        if int(N/i)-1 > i:
            ans.append(math.floor(N/i)-1)
print(sum(ans))

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

answer=0
import math
for m in range(1,math.ceil(math.sqrt(N+1/4)-1/2)):
    if N%m==0:
       answer+=N/m-1
print(int(answer))

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

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

Solution (Python):
words = lambda t : list(map(t, input().split()))
n = int(input())

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

print(total)

Solution (Python):
words = lambda t : list(map(t, input().split()))
n = int(input())

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

print(total)

Solution (Python):
import math
def num_divisors(n):
    ans = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            if i > 2 and i-1 > n // i: ans.append(i-1)
            if n != i**2 and n//i-1 > n // (n//i):
                ans.append(n//i-1)
    
    return ans

N = int(input())
lst = num_divisors(N)

print(sum(lst))

Solution (Python):
import math

N=int(input())
ans=0
M=math.ceil(N**0.5+2)
for i in range(1,M):
    if N%i==0 and N//i-i>1: ans+=N//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:
        if N // i - i > 1:
            ans += N // i - 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)

    return divisors

N = int(input())
l = make_divisors(N)
l.sort()

ans = sum(l)-len(l)
for i in l:
    if i <= 1:
        continue
    if N%(i-1) == N//(i-1):
        break
    else:
        ans -= i-1

print(ans)

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

div=set()
for x in range(1, int(N**0.5)+1):
	if N % x == 0:
		div.add(x)
		div.add(N//x)

print(sum(d-1 for d in div if d-1 > 0 and N//(d-1) == N%(d-1)))

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

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

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=[]
l=make_divisors(n)
ans=0

for i in range(len(l)):
    if l[i]-1 > n//l[i]:
        ans+=l[i]-1
print(ans)

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

Solution (Python):
import math
N = int(input())
if N == 2:
    print("0")
    exit(0)

P = [1]
for k in range(2,math.floor(math.sqrt(N))+1):
    if N % k == 0:
        if N//k-1 > k:
            P.append(min(k,N//k))
ans = 0
for p in P:
    ans += N//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:
    if n/i-1 > i:
      ans+=(n//i)-1
print(ans)

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

Solution (Python):
import math
N = int(input())
mn = int(math.sqrt(N) + 1)
 
res = 0
 
for i in range(1, mn):
    if (N - i) % i == 0:
        val = (N - i) // i
        if i < val:
            res += val
 
print(res)

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

while True:
    N = int(input())
    ans_list = sorted(make_divisors(N))
    ans = 0
    
    for i in ans_list:
        m = N // i - 1
        if N < m * m:
            
            
            ans += (N // i - 1)

    print(ans)
    break

Solution (Python):
import math

N = int(input())

ans = 0
for Q in range(1, int(math.sqrt(N)) + 2):
    M = N // Q
    if M * Q != N or M - Q < 2:
        continue
    ans += M - 1
print(ans)

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

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

div = make_divisor(n)
print(sum([s - 1 for s in div if (s - 1) ** 2 > n]))

Solution (Python):


import sys
import math


def solve(n):
  ret = 0
  for i in range(1,math.ceil(math.sqrt(n))):
    s,t = divmod(n, n//i-1)
    if s==t:
      ret += n//i-1
  return ret


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

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

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

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

print(sum(anss))

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

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

ans = 0

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


print(ans)

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

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

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



s=0
for t in range(1,1+int((N-1)**0.5)):
  if N%t==0:
    m=N//t-1
    if N<m*(m+1):
      s+=m
print(s)

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

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

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


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


ans = 0
divisors = enumerate_divisors(N)

for divisor in divisors:
    num = N // divisor - 1
    if N - divisor * num < num:
        ans += N // divisor - 1
print(ans)

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

Solution (Python):
import math

m = int(input())


s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		if (i+1) not in s:
			s.append(i+1)
		if m//(i+1) not in s:
			s.append(m//(i+1))
s.sort()
x =0
for i in range(len(s)):
    if m//s[i]>s[i]+1:
        x += m//s[i]-1
print(x)

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

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

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

ans = 0
mina = int((-1 + math.sqrt(1 + 4 * N)) / 2)
if (mina * 2 + 1) * (mina * 2 + 1) != 1 + 4 * N:
    mina += 1

for a in range(1, mina):
    if (N - a) % a == 0:
        ans += int((N - a) / a)
print(ans)

Solution (Python):
def find_factor(N):
    factors=[]
    factors2=[]
    S=int(N**0.5)
    for i in xrange(2,S+1):
        if N%i==0:
            factors+=[i]
            factors2+=[N//i]
    if S**2!=N:
        all_factor= factors+factors2[::-1]   
    else:
        all_factor= factors[:-1]+factors2[::-1] 

    return [1]+all_factor+[N]

def find_ans(N):
    ans=0
    factors=find_factor(N)
    for i in xrange(len(factors)):
        x=factors[i]
    
        m=x-1
        k=N//x
        if m==0:
            continue
        if k==N%m:
            ans+=m
    return ans

N=input()
print(find_ans(N))

Solution (Python):

def find_factor(N):
    factors=[]
    factors2=[]
    S=int(N**0.5)
    for i in xrange(2,S+1):
        if N%i==0:
            factors+=[i]
            factors2+=[N//i]
    if S**2!=N:
        all_factor= factors+factors2[::-1]   
    else:
        all_factor= factors[:-1]+factors2[::-1] 

    return [1]+all_factor+[N]

def find_ans(N):
    ans=0
    factors=find_factor(N)
    for i in xrange(len(factors)):
        x=factors[i]
    
        m=x-1
        k=N//x
        if m==0:
            continue
        if k==N%m:
            ans+=m
    return ans

N=input()
print(find_ans(N))

Solution (Python):



from collections import deque
import heapq
import math
import bisect


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

    p = 1
    while p * p <= N:
        if N % p == 0:
            d = N // p
            if p + 1 < d:
                ans += d - 1
        p += 1

    print(ans)


if __name__ == '__main__':
    main()

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

i = 1
s = 0
while(i * i < n):
    if n % i == 0:
        m = n // i
        if m - 1 > i:
            s += m - 1
    i += 1
print(s)

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

ans = 0
for r in range(1,int(N**0.5)+2):
  if (N-r)%r != 0:
    continue
  else:
    m = (N-r)//r
    if m <= r:
      break
    else:
      ans += m
      
print(ans)

Solution (Python):
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n = int(input())

    ans = 0
    root = int(n**0.5)

    for i in range(1,root+1):
        if n%i == 0:
            ans += (n/i-1)

    if root*(root+1) == n:
        ans -= root
    if root**2 == n:
        ans -= (root-1)
    print(int(ans))

Solution (Python):
n = int(input())
ans = 0
if n==1 or n==2:
  print(0)
  exit()
elif n<6:
  print(n-1)
  exit()
for i in range(1, int(n**(1/2))+2):
  k = (n-i)//i
  if n%k == n//k:
    ans += k
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

while True:
    N = int(input())
    ans_list = sorted(make_divisors(N))
    ans = 0
    
    for i in ans_list:
        m = N // i - 1
        if N < m * m:
            
            
            ans += (N // i - 1)

    print(ans)
    break

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

Solution (Python):
def main():
    from sys import stdin, stdout

    def read():
        return stdin.readline().rstrip('\n')

    def read_array(sep=None, maxsplit=-1):
        return read().split(sep, maxsplit)

    def read_int():
        return int(read())

    def read_int_array(sep=None, maxsplit=-1):
        return [int(a) for a in read_array(sep, maxsplit)]

    def write(*args, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in args) + end)

    def write_array(array, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in array) + end)

    n = read_int()
    if n == 1:
        write(0)
        return

    top = int(n**0.5)
    out = 0
    for c in range(1, top+1):
        c2 = n // c - 1
        if n // c2 == n % c2:
            out += c2
    write(out)

main()

Solution (Python):
N = int(input())
n = int((N ** 0.5) // 1)

ans = 0

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

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

ans = 0
for i in range(1, 10**6+1):
    if n % i == n//i:
        ans += i

if n <= 10**6:
    print(ans)
    exit()
  
syou = n // 10**6

i = 10**6 + 1
while True:
    if syou != n//i or i >= n:
        break
    else:
        if n % i == n//i:
            ans += i
    i += 1

syou = n//i

for i in range(1, syou+1):
    if (n-i) % i != 0:
        continue
    else:
        okiniiri = (n-i) // i
        if n % okiniiri == i:
            ans += okiniiri 

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

ans=0
n=int(input())

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

Solution (Python):

"""
AtCoder D
"""








def main():
    
    N = int(input())
    tmp=0
    i=1
    o=min(N,2000000)
    for i in range(1,o):
        mod=(N-i)%i
        if mod==0:
            if (i>=(N-i)/i):
                break
            tmp+=int((N-i)/i)
        i+=1
    print(int(tmp))
    
if __name__ == "__main__":
    main()

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

ans = 0


i = 1
while i * i < n:
    if n % i == 0:
        m = n // i - 1
        if m > i:
            ans += m
    i += 1

print(ans)

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

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

Solution (Python):
from collections import defaultdict, deque, Counter
from math import sqrt
def inpl(): return list(map(int, input().split()))

N = int(input())
yaku = []
ans = 0
S = int(sqrt(N))

for d in range(1, S+(S*S!=N)):
    a, b = divmod(N-d, d)
    if b == 0 and a >= 0:
      j, k = divmod(N, a)
      ans += a*(j==k)
print(ans)

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

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

lists = make_divisors(N)
print(sum(lists)-len(lists))

Solution (Python):
import math

n = int(input())

upper = int(math.sqrt(n)) + 1
sum = 0
for r in range(1, upper+1):
  if n % r == 0:
    m = n // r - 1
    if m > r:
      sum += m

print(sum)

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

ls = make_divisors(N)
rst = 0
for i in range(len(ls)) : 
    k = ls[i]
    m = (N / ls[i] - 1) 
    if k < m : rst += m
print(int(rst))

Solution (Python):
from sys import stdin

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

n = int(stdin.readline().rstrip())
ds = make_divisors(n)



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

   if(int(n/m) == n%m):
     sum += m

print(sum)

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

s = 0
for i in range(1,int(N**0.5)+1):
    q = N//i
    if q*i==N:
        m = q-1
        if i < m:
            s += m

print(s)

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

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

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

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

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

ans = 0

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

print(ans)

Solution (Python):


import sys
from collections import deque, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return 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


def main():
    n = II()
    pf = make_divisors(n)
    res = 0
    for x in pf[1:]:
        q, mod = divmod(n, x - 1)
        if q == mod:
            
            res += x - 1

    print(res)


if __name__ == '__main__':
    main()

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

def solve0(N):
    result = 0
    for i in range(2, N):
        if N % i == N // i:
            print("!", N // i, i, N % i)
            result += i
    return result

def solve(N):
    import math
    r = math.ceil(math.sqrt(N))
    result = 0
    for i in range(1, r + 1):
        d, m = divmod(N - i, i)
        if m == 0 and d > i:
            
            result += d
    return result


result = solve(N)


print(result)

Solution (Python):
n = int(input())
i=1
a=[]
while i*i<n:
    if n%i ==0 and not i+1==n//i:
        a.append(n//i)
    i+=1
print(sum(a)-len(a))

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

count = 0
divisors = make_divisors(N)
for i in divisors[1:]:
    tmp = i - 1 
    if N // tmp == N % tmp:
        count += tmp
        
print(count)

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

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





ans = 0
debuglist = []

for a in range(1, 10**6 + 2):
    m = (N // a) - 1
    if (N % a) == 0 and m > a :
        debuglist.append(m)
        ans += m

print(ans)

Solution (Python):

N = int(input())





import math

sqnc = int(math.sqrt(N))

print(sum(N // b - 1 for b in range(1, sqnc+1) if N % b == 0 and b < N // b -1))

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

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

ans = 0
for i in range(1, math.ceil(math.sqrt(N))):
  if N % i == 0:
    x = (N // i) - 1
    if x > i:
      ans += x
print(ans)

Solution (Python):
import math  
def div(a) :
    for i in range(1, int(math.sqrt(n) + 1)) : 
        if (n % i == 0) :
            a.append(i)
            if (n / i != i) :
                a.append(int(n / i))

n = int(input())
a = []
div(a)
s = 0
for i in a:
    if n//i<(i-1):
        s+=i-1

print(s)

Solution (Python):


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

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

    ans = 0
    for y in yakusu:
        x = N//y - 1
        if x == 0: continue
        if N//x == N % x:
            ans += N // y - 1

    print(ans)
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    

if __name__ == "__main__":
    solve()

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

Solution (Python):
N = int(input())
ans = 0
l = [N,0]
a = 1

while l[0] != 0:
    if l[1] == 0:
        a += 1
        l = [N//a, N%a]
    elif l[0] == l[1]:
        ans += a
        a += 2 
        l = [N//a, N%a]
    else:
        if l[1] % l[0] == 0:
            a += l[1] // l[0] - 1
            ans += a
            a += 2
            l = [N//a, N%a]
        else:
            a += l[1] // l[0] + 1
            l = [N//a, N%a]

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

div=make_divisors(n)
sum=0
for i in div:
    if i!=1 and n//(i-1)==n%(i-1):
        sum+=i-1
print(sum)

Solution (Python):
N = int(input())
sum = 0
half_N = int((N ** (1/2)) // 1)
for i in range(half_N):
	if 0 == (N - (i+1)) % (i+1):
		if ((N-(i+1)) / (i+1)) > (i+1):
			sum += ((N - (i+1)) / (i+1))
		
print(int(sum))

Solution (Python):
def f(n):
    x = 1
    ans = 0
    while x ** 2 + x < n:
        if n % x == 0:
            ans += n // x - 1
        x += 1
    print(ans)

n = int(input())
f(n)

Solution (Python):


import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    divisors = make_divisors(N)
    
    c = 0
    for x in divisors:
        m = int(N / x) - 1
        if m <= x:
            continue
        c += m
    print(c)

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

main()

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)

ans = 0
for d in divisors:
    if N // d < d - 1:
        ans += d - 1
print(ans)

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

def 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 item in divisors(n):
    if item < n**0.5 + 1:
        continue
    ans += item - 1

print(ans)

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

for i in divisors:
    if i == 1:
        continue
    if n//(i-1) == n%(i-1):
        ans += i-1
print(ans)

Solution (Python):
import math

def divisor(num):
    if num < 0:
        return 0
    if num == 1:
        return [1, ]

    divisor_list = [1, ]
    divisor_list_r = [num, ]

    i = 2
    while i * i <= num:
        if num % i == 0:
            divisor_list.append(i)
        i += 1

    return divisor_list

N = int(input())
divisor_list = divisor(N)
ans = 0
for i in divisor_list:
    tmp = (N - i) // i
    if tmp == 0:
        continue
    if i // tmp > 0:
        continue
    ans += tmp

print(ans)

Solution (Python):


import math
N=int(input())
n=int(math.sqrt(N))
plist=[]
for i in range(1,n+1):
    if N%i == 0:
        plist.append(i)
        if i != int(N/i):
            plist.append(int(N/i))
ans=0
for i in range(len(plist)):
    x=plist[i]
    kari=int(N/x)-1
    if kari == 0:
        pass
    else:
        q=int(N/kari)
        r=N%kari
        if q == r:
            ans+=kari
print(ans)

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

Solution (Python):
import collections as c
ip = lambda : map(int, input().split())



ans = 0
N = int(input())
n = int(N**0.5)+2

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