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.



Sample input:
8


Sample output:
10

Submission status: Accepted

Solution code:
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)

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
l = list()
for i in range(1, int(N**0.5)+1):
  if N % i == 0:  # i is a divisor of N
    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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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
c=0
for i in make_divisors(n):
    if i!=1 and n//(i-1)==n%(i-1):
        c+=(i-1)
print(c)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#DivRem number
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)


# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)
#print(t)
for i in range(len(t)):
    if t[i] == 1:
        continue
    m = t[i]-1
    if(a//m) == (a%m):
        s+=m
print(s)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)
#print(t)
res = 0
for k in t:
    if k==1:
        continue
    m=k-1
    if (a//m)==(a%m):
        res+=m
print(res)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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(i, N // (i - 1), N % (i - 1))
        
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
N = int(input())
 
result = 0
for i in range(1, int(N**0.5)+1):
  # 偽物が通ってしまう．sample 2 の時，999999ずれる
  if (N - i) % i == 0:
    temp = (N - i) // i
    if temp != 0 and N // temp == N % temp:
      result += temp
      
print(int(result))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
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)
    # divisors.sort()
    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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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)

    # divisors.sort()
    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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    # From the problem statement, the quotient and remainder of N is the
    # the same k when m is the favorite number.
    #   N = k*m + k = k*(m+1)
    # Here, k is the remainder when N is divided by m, so k < m.
    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())

Submission status: Accepted

Solution code:
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)
    # divisors.sort()
    return divisors

n=int(input())
l=[]
# print(make_divisors(n))
md=make_divisors(n)
if 1 in md:
    md.remove(1)
for i in md:
    k=i-1
    if n//k==n%k:
        # print(k+1,n//k,n%k)
        l.append(k)
# print(l)
print(sum(l))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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) )
    #
    # for next
    q = int( n/m )
    lm= m
#
print( s )

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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 x,y,ans
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

div = []  # Nの約数を全列挙して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:  # m=0はskip
		pass
	else:
		m = div[j] - 1
		if N // m == N % m:
			ans += m

print(ans)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)
#arr.sort()

count=0
for i in arr:
    if i==1:
        continue
    if n//(i-1) == n%(i-1):
        count+=i-1
print(count)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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))  # type: int
    result = solve(N)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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:
        # print(i, N//i, N%i)
        ans += div
print(ans)

Submission status: Accepted

Solution code:
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)
#print(x)
y=[]
for i in x:
    if n//(i-1)==n%(i-1):
        y.append(i-1)
#print(y)
print(sum(y))

Submission status: Accepted

Solution code:
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:
        # N = k(m+1) で表すことができる ...よってkはNの約数で、N^0.5以下のもの
        # m = N/k-1
        ans += ((N//k)-1)

print(ans)