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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    return divisors

n=int(input())
d=div(n)
ans=0
for i in d:
    x=i-1
    if x!=0 and n//x==n%x: ans+=x

print(ans)

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

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_d
import itertools
from collections import Counter
from collections import defaultdict
import bisect

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

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

        i += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

result = 0

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

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

print(result)

Submission status: Accepted

Solution code:
import math

l = raw_input().split()
N = int(l[0])

def calc(N):
    sum = 0
    for i in range(int(math.sqrt(N))):
        r = i + 1
        q = r
        m = (N - r)/q
        if N - m*q == r and m > q:
            sum += m
            # print(m, q)
    return sum

#for i in range(100):
#    print('N={}'.format(i + 1))
#    calc(i + 1)

print(calc(N))

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
n = int(input())
n_div_list = []
for i in range(1, int(n**0.5)+1):
    if n%i == 0:
        if int(n/i) == i:
            n_div_list.append(i)
        else:
            n_div_list.append(i)
            n_div_list.append(int(n/i))
check = 0
cnt = 0
for n_div in n_div_list:
    if n_div - 1 > check:
        cnt += n_div - 1
    check = n_div
print(cnt)

Submission status: Accepted

Solution code:
import math
N = int(input())
ans = 0
k = round(math.sqrt(N))
for i in range(1, k):
    if (N - i) % i == 0:
        ans += (N - i) // i
print("{}".format(ans))

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の約数
        # m = N/k-1
        ans += ((N//k)-1)

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

print(ans)

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

if __name__=="__main__":
    lis = make_divisors(N)
    for i in lis:
        if i!= 1:
            if N // (i-1) == N % (i-1):
                count += i-1
    print(count)

Submission status: Accepted

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
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

ls = make_divisors(N)
count =0
for i in ls:
    if N/i -1 >= 1 and i < N/i-1:
        count+= N/i -1 
    

print(int(count))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


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


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def eratosthenes(n):
    p = []
    t = [True] * n

    t[1] = True
    for i in range(2, int(math.ceil(math.sqrt(n)))):
        if t[i]:
            p.append(i)
            for j in range(2*i, n, i):
                t[j] = False

    for j in range(i+1, n):
        if t[j]:
            p.append(j)

    return p


def divisor(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            yield i
            if i != n // i:
                yield n // i


@mt
def slv(N):
    ans = 0
    for i in divisor(N):
        m = i-1
        if m == 0:
            continue
        if N//m == N % m:
            ans += m
    return ans


def slv2(N):
    ans = 0
    for m in range(1, N+1):

        if N//m == N % m:
            # print(m)
            print(m, N//m, N % m)
            ans += m
    return ans


def main():
    N = read_int()
    # print(slv2(N))
    print(slv(N))


if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

Solution code:
import numpy as np
def eratosthenes(n):
    is_prime = np.ones((n+1,), dtype=bool)
    is_prime[:2] = False
    for i in range(2,n+1):
        if is_prime[i]:
            is_prime[i*2::i]=False
    return np.arange(n+1)[is_prime]
Ps = eratosthenes(1000007)
def divisor(n):
    for p in Ps:
        if p*p>n:return -1
        if n%p==0:return p
def prime_division(n):
    d={}
    while n>1:
        p=divisor(n)
        if p==-1:d[n]=d.get(n,0)+1;break
        else:d[p]=d.get(p,0)+1;n//=p
    return d

def z(n,k,v):
    if len(k)==1:
        return [n*k[0]**i for i in range(v[0]+1)]
    else:
        r=[]
        for i in range(v[0]+1):
             r+=z(n*k[0]**i,k[1:],v[1:])
        return r
def y(n):
    pd=prime_division(n)
    KV=[[k,v] for k,v in pd.items()]
    K=[k for k,v in KV]; V=[v for k,v in KV]
    return z(1,K,V)

N=int(input())
if N==1:print(0);exit()
r=0
#print(y(N))
for yk in y(N):
    if yk>1 and N//(yk-1) == N%(yk-1):
        r+=yk-1
print(r)

Submission status: Accepted

Solution code:
a = 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


test_list = make_divisors(a)
test_list_modify = [i-1 for i in test_list if i > 2 and a//(i-1) == a%(i-1)]
print(sum(test_list_modify))

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1,int(n**(1/2))+1):
    s = i
    a = i
    if (n-a)%s==0:
        if (n-a)//s > a:
            ans += (n-a)//s
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import math

N = int(input())

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

m = int(math.sqrt(N))+1

s, a = divmod(N,m)

sum_of_m = 0
for i in range(s, 0, -1):
    m = N/i - 1
    if m > 0 and m.is_integer() and divmod(N, m) == (i, i):
        sum_of_m += int(m)

print(sum_of_m)

Submission status: Accepted

Solution code:
N = long(raw_input())

prime_factor = []

all_sum = 0

for i in range(1, long(N ** 0.5)+1):
    if N % i == 0:
        if i > 2 and N % (i-1) == int(N /(i-1)): all_sum += i-1
        if i != N // i:
            if N // i > 2 and N % (N//i-1) == int(N/(N//i-1)): all_sum += N // i -1

print all_sum

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)
                # print(f"{N} = {m} * {N // m} + {N % m}")

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


assert (solve(8) == 3 + 7)
assert (solve(10) == 4 + 9)
assert (solve(1000000000000) == 2499686339916)
if __name__ == "__main__":
    N = int(input())
    print(solve(N))

Submission status: Accepted

Solution code:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())

n = ni()
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

lis = make_divisors(n)
ans = 0
for i in lis:
    if i - 1 == 0:
        continue
    if i - 1 > n // i:
        ans += i - 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
i=0
while True:
    i+=1
    if (n-i)//i<i:
        break
    elif n%((n-i)//i)==i:
        ans+=(n-i)//i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N > 2:
    ans = N - 1
else:
    ans = 0

x = 2
while x*x <= N:
    if N % x == 0:
        m = N // x - 1
        if N % m == x:
            ans += m
    x += 1
print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
ans = 0
n_max = int(math.sqrt(N))
for n in range(1,n_max+1):
	if N%n == 0:
		a = N//n
		if a+1 < n:
			ans += n-1
		elif n+1 < a:
			ans += a-1
print(ans)

Submission status: Accepted

Solution code:
# coding:utf-8

import math
import re

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(params):
    n = params
    a = make_divisors(n)
    total = 0
    for i in a:
        if i - 1 >= 2 and i -1 > n  / i:
            total += i - 1
    print total

if __name__ == "__main__":
    params = int(raw_input())
    #cnt = 1 # TODO: edit here
#    params = []
#    for i in range(n):
#        param = raw_input()
#        params.append(param)
    main(params)

Submission status: Accepted

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


def prime_decomposition(n):
    i = 2
    ret = collections.defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            ret[i] += 1
        i += 1
    if n > 1:
        ret[n] = 1
    return ret


factors_dict = prime_decomposition(N)
factors_values = list(factors_dict.values())
factors_keys = list(factors_dict.keys())
factors = []
import itertools
for K in itertools.product(*[range(_ + 1) for _ in factors_values]):
    f = 1
    for i in range(len(factors_keys)):
        f *= factors_keys[i]**K[i]
    factors += [f]
ans = 0
for f in factors:
    if N < f * (f - 1):
        ans += f - 1
print(ans)

Submission status: Accepted

Solution code:
import math
N=int(input())
rt = int(math.sqrt(N))
# print(rt)

res = 0
for a in range(1, rt+1):
    if N % a == 0:
        b1 = N // a
        b = b1-1 
        if b > a and b > 0:
            res += b

print(res)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    res = 0
    if n<=8:
        for i in range(1,n):
            if n//i == n%i:
                res += i
    else:
        for i in range(1,int(n**(1/2))):
            if (n-i)/i == (n-i)//i and (n-i)//i>0:
                res += (n-i)//i
    print(res)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
if N <= 2:
    print(0)
    exit()
for i in range(1, 10**6):
    if (N - i) % i == 0:
        tmp = (N - i) // i
        if tmp > 1 and tmp > i:
            ans += tmp
print(ans)

Submission status: Accepted

Solution code:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())

n = ni()
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

lis = make_divisors(n)
ans = 0
for i in lis:
    if i - 1 == 0:
        continue
    if i - 1 > n // (i - 1):
        ans += i - 1
print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())

###商及び余りをsとすると、n=m*s+s=s(m+1)、ただし0<s<m
sum_fav = 0
for s in range(1,int(math.sqrt(n))+1):
  if n%s == 0:
    m = n//s-1
    if s < m:
      #print(m)
      sum_fav += m
    else:
      break
  
print(sum_fav)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
if N <= 2:
    print(0)
    exit()
for i in range(1, 10**7):
    if (N - i) % i == 0:
        tmp = (N - i) // i
        if tmp > 1 and tmp > i:
            ans += tmp
print(ans)

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/diverta2019/tasks/diverta2019_d

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


num = 0
div = make_divisors(N)
#print(div)
'''
for i in range(0,len(div)-1,2): #k
    if div[i+1]+1-div[i] >= 2 and div[i+1]+1-div[i] <= div[i+1]:
        num += div[i+1]-1
'''
for i in range(0,len(div)-1,2): #k
    if div[i] <= div[i+1]-2:
        num += div[i+1]-1
        #print(div[i+1]-1)


print(num)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())

m_sum = 0
for i in range(1, n):
    m = n / i - 1
    if i >= m:
        break

    int_m = int(m)
    if m == int_m:
        m_sum += int_m

print(m_sum)

Submission status: Accepted

Solution code:
# お気に入りの数である条件
# N = am + bとおくと、a=b ∴ > N = a(m+1)
# ただし、a=b<m
# よってaはNの約数でなければならず、N>0よりa>0、a>0よりN / a = m + 1 
# 整理して m = N / a - 1.

N = int(input())
answer = 0

for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        m = N // i - 1
        if m > i:
            answer += m 
        if i != N // i:
            m = N // (N // i) - 1 
            if m > i:
                answer += m

print(answer)

Submission status: Accepted

Solution code:
N = int(input())

i = 2
N_ = N
ans = 0

divisor = {}
for i in range(2,N):
    if N_ % i == 0:
        divisor[i] = 0
        while(N_ % i == 0):
            divisor[i] += 1
            N_  //= i
#;            print(N_,i)
    if i *i > N_:
        if N_ != 1:
            if N_ in divisor.keys():
                divisor[N_] += 1
            else:
                divisor[N_] = 1
        break

ans += 0
def solve(dic,keys,n,i):
    if i == len(keys):
#        print(n)
        if n-1 != 0 and N == (N % (n-1))*n:
            global ans
            ans += n-1

    else:
        for j in range(dic[keys[i]]+1):
            solve(dic,keys,n*keys[i]**j,i+1)

#print(divisor)
ans = 0 
solve(divisor,list(divisor.keys()),1,0)
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
ans = 0

# cnt = 0
# for i in range(1, N+1):
# 	if N%i == N//i:
# 		# print(i)
# 		cnt += i
	# print(i, "N%i=", N%i, "N//i=", N//i)

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

yaku = make_divisors(N)
if int(N**(1/2))*(int(N**(1/2))+1) == N:
	for i, num in enumerate(sorted(yaku)):
		if i == len(yaku)//2-1:
			break
		ans += N//num-1
	print(ans)
else:
	for i, num in enumerate(sorted(yaku)):
		if i == len(yaku)//2:
			break
		ans += N//num-1
	print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from heapq import heappush, heapreplace
from itertools import count, chain, cycle
from functools import partial
from math import floor, ceil, sqrt
from fractions import gcd
from collections import defaultdict, deque

def Primes_fnct():
    def b_search(L,t):
        #増大列LについてL[:+1]の要素すべてがt以下であるような最大のi<len(L)を返す。
        search_range = [-1, len(L)]
        update_range = lambda mid: search_range.__setitem__(t<L[mid], mid)
        for _ in [0]*search_range[1].bit_length():
            update_range(sum(search_range)//2)
        return search_range[0]
    
    P = [2,]
    Pappend = P.append
    Q = deque([])
    Qappend = Q.append
    Qpopleft = Q.popleft
    hq = [] 
    integer = count(3,2)
    current_i = 1
    valid_range = 1
    def Primes(*, max_int=None):
        nonlocal valid_range, current_i
        if max_int is None:
            return P[:]

        if  max_int - current_i <= 1:
            return P[:b_search(P,max_int)+1]

        for i in integer:
            if i >= valid_range:
                if Q:
                    q = Qpopleft()
                    heappush(hq, (q**2,q))
                valid_range = Q[0]**2 if Q else i**2

            m,r = hq[0] if hq else (0,0)
            if i != m:
                Pappend(i)
                Qappend(i)

            while m == i:
                heapreplace(hq, (m+2*r, r))
                m,r = hq[0]

            current_i = i
            if max_int - current_i <=1:
                break 
        return P[:]
    return Primes

def factorization(m, Primes=None):
    F = defaultdict(int)
    if m < 2:
        return F

    while not m&1:
        F[2] += 1
        m >>= 1

    if Primes is None:
        Primes = Primes_fnct()

    Primes = deque(Primes(max_int=ceil(sqrt(m))+1))
    Primespopleft = Primes.popleft

    while m > 1 and Primes:
        p = Primespopleft()
        while not m%p:
            m //= p
            F[p] += 1

    if m > 1:
        F[m] += 1
    return F

def solve():
    N = int(input())
    F = factorization(N)
    Q = sorted(F.items())
    P = [q[0] for q in Q]
    I = [q[1] for q in Q]
    i = [0 for _ in range(len(P)+1)]
    m = 1
    res = 0
    while any(a<b for a,b in zip(i,I)):
        if i[0] < I[0]:
            i[0] += 1
            m *= P[0]
        else:
            for j in range(0, len(P)):
                if i[j] < I[j]:
                    i[j] += 1
                    m *= P[j]
                    break
                else:
                    m //= P[j]**i[j]
                    i[j] = 0
        if N%(m-1) == N//(m-1):
            res += (m-1)

    return str(res)

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

Submission status: Accepted

Solution code:
from itertools import product

N = int(input())

sqrt = int(N ** 0.5)

factorize_result = {}
n = N
for i in range(2, sqrt + 1):
    if n % i == 0:
        factorize_result[i] = 1
        n = n // i
        while n % i == 0:
            factorize_result[i] += 1
            n = n // i
if n > 1:
    factorize_result[n] = 1

ans = 0
vs = [list(range(v+1)) for v in factorize_result.values()]
for indices in product(*vs, repeat=1):

    tmp = 1
    for i, (k, v) in enumerate(factorize_result.items()):
       tmp *= k ** indices[i]

    tmp -= 1
    if tmp == 0:
        continue

    if N % tmp == N // tmp:
        ans += tmp

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())

Number_to_divide = []
for i in range(1,int(np.sqrt(N))+1):
    if (N % i == 0)and((N / i) > (i + 1)):
        Number_to_divide.append((N / i) - 1)
print(int(sum(Number_to_divide)))

Submission status: Accepted

Solution code:
# coding: utf-8
import numpy as np
from functools import lru_cache
import time
import math

def main(): 
    if True:
        N = int(input())
        #H,W = list(map(int, input().split()))
        #A = np.asarray([str(input()) for i in range(H)])
    else:
        pass

    sN = int(math.sqrt(N))
    r = np.asarray([],dtype=int)
    count = 0
    for i in range(sN+1):
        #print(i)
        if N % (i+1) == 0 :
            r = np.append(r,i+1)
            if i+1 != N//(i+1):
                r = np.append(r,N//(i+1))
    r = np.sort(r)

    for i in range(r.size)[1:]:
        if N//(r[i]-1) == N%(r[i]-1):
            count += r[i]-1
        else:
            pass
            #print(r[i])

    print(int(count))#,r)
if __name__ =='__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum)

Submission status: Accepted

Solution code:
def makeDiv(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)
    div.sort()
    return div

N = int(input())
L = makeDiv(N)
ans = 0
shou = 0
for i in L:
    shou = (N-i)//i
    if shou > i and N == shou*i+i and shou != 1:
        ans += shou
print(ans)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
N = int(input())
yakusuu = []

for i in range(1, int(N**0.5) + 1):
    if N % i == 0:
        yakusuu.append(i - 1)
        yakusuu.append(N // i - 1)
retval = 0
for y in yakusuu:
    if y == 0:
        continue
    if N // y == N % y:
        retval += y

print(retval)

Submission status: Accepted

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

while x**2+x < N:
    x += 1
    m = (N-x)/x
    if m % 1 == 0:
        if x < m <= N:
            ans += m
        else:
            break

print(int(ans))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for r in range(1, int(1e6) + 1):
    if n <= r * r:
        break
    m = (n - r) // r
    if n % m == n // m:
        ans += m
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
i = 1
r = []
while((n-i)/i>i):
  if (n-i)%i==0:
    r.append(i)
  i+=1
print(sum([int((n-j)/j) for j in r]))

Submission status: Accepted

Solution code:
n = int(input())

co = 0
i = 1
while True:
	if (n - i) // i <= i:
		break
	if (n - i) % i == 0:
		co += (n - i) // i
	i += 1
print(co)

Submission status: Accepted

Solution code:
import math

N = int(input())

ans = 0
for i in range(1, int(math.sqrt(N)) + 1):
  if i > N / 2:
    continue
  tmp = int((N - i) / i)
  if (N - i) % i == 0 and N % tmp != 0 and tmp >= math.sqrt(N):
    ans += tmp

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print(s)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(1,n):
    if (n-i)/i > i:
        if (n-i)%i == 0:
            ans += (n-i)/i
    else:
        break
print(int(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)

    divisors.sort()
    return divisors

N = int(input())
l = make_divisors(N)
g = 0
for c in l:
    rc = N//c - 1
    if (rc != 0):
        if (N % rc) == (N//rc):
            g+=rc
print(g)

Submission status: Accepted

Solution code:
N = int(input())
num = 0
for i in range(1,int(N**0.5)+1):
  m = N//i-1
  if m!=0 :
#  print(i,m)
    if (N//m) == (N % m):num += m
print(num)

Submission status: Accepted

Solution code:
import math
N = int(input())
ans = 0
s = math.sqrt(N)
for i in range(1, math.ceil(s)):
  if N%i == 0:
    a = N/i - 1
    if a > i:
      ans += a
    else:
      break;
print(int(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)

    divisors.sort()
    return divisors

N = int(input())
l = make_divisors(N)
#print('try to:',len(l))
g = 0
for c in l:
    rc = N//c - 1
    if (rc != 0):
        if (N % rc) == (N//rc):
            g+=rc
            #print(rc)
print(g)

Submission status: Accepted

Solution code:
def make_divisors(n: int) -> list:
    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 sorted(divisors)


N = int(input())

ans = 0
divisors = make_divisors(N)

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

Submission status: Accepted

Solution code:
# km + k = N
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())
i = 1
ans = 0
for i in make_divisors(N)[:-1]:
    m = ((N - i) // i)
    if N // m != N % m:
        break
    ans += m
print(ans)

Submission status: Accepted

Solution code:
from io import StringIO
from collections import *
from functools import *
from math import sqrt
import sys


def main(inputs):
    n = int(next(inputs))
    # xs = list(map(int, next(inputs).split()))
    x_max = int(sqrt(n))
    ans=0
    
    for i in range(1, x_max+1):
        if n % i == 0 and (n // i) - 1 > i:
            ans += (n // i) - 1
            pass
        pass

    # n // m = x 
    # n % m = x (0 < x < m < m+1 < x*m < n), (x*x < n)
    # m * x + x = x * (m + 1) = n
    # m = n / x - 1

    return ans


def gen_inputs(str_=None):
    inputs = StringIO(str_) if str_ else sys.stdin
    while True:
        a = inputs.readline().rstrip()
        yield a
        pass
    pass


if __name__ == "__main__":
    print(main(gen_inputs()))
    pass

Submission status: Accepted

Solution code:
N=input()

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

    # divisors.sort()
    return divisors


L=make_divisors(N)
L.sort()

ans=0

for x in L:
	if x==1: continue
	if N%(x-1)==N/(x-1):
		ans+=(x-1)

print ans

Submission status: Accepted

Solution code:
# coding: utf-8
import math

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

    total = 0

    for i in range(1, int(math.sqrt(N))+1):
        if N % i == 0:
             k = i - 1
             m = N // i
             if k > 1 and N % k != 0 and k > m:
                 total += k
             k2 = (N // i - 1)
             m2 = i
             if k2 != k and k2 > 1 and N % k2 != 0 and k2 > m2:
                 total += k2
    print(total)

if __name__ == "__main__":
    main()