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:
def main():
    n = int(input())
    i = 1
    answer = 0
    while i * i <= n:
        if (n - i) % i == 0 and n - i > i ** 2:
            answer += (n - i) // i
        i += 1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import sqrt
def main():
    n = int(input())
    ans = 0
    for i in range(1, int(sqrt(n))+1):
        y = n - i
        if y % i == 0 and y != 0 and n//(y//i) == i:
            ans += y // i
    print(ans)

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)
  return divisors
A=make_divisors(N)
ans=0
for i in A:
  if i==1:
    continue
  a=N//(i-1)
  b=N%(i-1)
  if a==b:
    ans+=(i-1)
print(ans)

Submission status: Accepted

Solution code:
import math
N=int(input())
a=int((math.sqrt(N)//1))
ans=0
if N==2:
  print(0)
  exit()
for i in range(1,a):
  b=(N-i)/i
  if b.is_integer():
    ans+=int(b)
c=N//a
d=N%a
if int(c)==d:
  ans+=a
a+=1
c=N//a
d=N%a
if int(c)==d:
  ans+=a
print(ans)

Submission status: Accepted

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


n=int(input())
D=sorted(make_devisors(n))
ans=0
for i in D[1:]:
    if (n//(i-1))*i==n:
        ans +=i-1
print(ans)

Submission status: Accepted

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

import math

n = int(math.sqrt(N))
candidates = []
for i in range(1, n+1):
    if not N % i:
        if (N//i) -1 > i:
            candidates.append(N//i)


print(sum(candidates) - len(candidates))

Submission status: Accepted

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


n=int(input())
D=sorted(make_devisors(n))
ans=0
for i in D[1:]:
    if (n//(i-1))*(i)==n:
        ans +=i-1
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)
    # divisors.sort()
    return divisors
n = int(input())
res = 0
for x in make_divisors(n):
    x = x-1
    if x == 0:
        continue
    if n % x == n // x:
        res += x
print(res)

Submission status: Accepted

Solution code:
n = int(input())

def make_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)
    divisors.sort()
    return divisors

divs = make_div(n)
ans=0
for r in divs:
    m=n//r -1
    if r<m:
        ans+=m
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

divisors = set()

for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.add(i)
        divisors.add(n//i)

ans = 0

for d in divisors:
    m = d-1
    if m != 0 and n//m == n % m:
        ans += m

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
i = 1

while i*(i+1)+i <= n:
    if (n-i) % i == 0:
        ans += (n-i)//i
    i += 1

print(ans)

Submission status: Accepted

Solution code:

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

n = int(input())
tank = np.array(divisor(n))
res = 0
for i in range(len(tank)):
    x = tank[i] - 1
    if x!=0 and n%x==n//x:
        res += x
print(res)

Submission status: Accepted

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

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

    # divisors.sort()
    return divisors

div = make_divisors(N)

# print(collections.Counter(div))
# print(div)
print(sum(div)-len(div))

Submission status: Accepted

Solution code:
import math
N = int(input())
div = []
for i in range(1, int(math.sqrt(N))+1):
  if N%i==0:
    div.append(i)
    if i != N//i:
      div.append(N//i)
ans = 0
for i in range(len(div)):
  if div[i]-1 > 0 and N//(div[i]-1) == N%(div[i]-1):
    ans += div[i]-1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

n=int(input())
l=divisore(n)

ans=0
for i in l:
  i-=1
  if i!=0 and n//i==n%i:
    ans+=i
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:
        m = n//i - 1
        if m != 0 and n // m == n % m:
            ans += n//i - 1
print(ans)

Submission status: Accepted

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

    divisors.sort()
    return divisors

N = int(input())
div = make_divisors(N)
max_div = sqrt(N)
ans = 0
if N == 2:
    print(0)
    exit()
if N == 6:
    print(5)
    exit()
if N == 12:
    print(16)
    exit()
if N == 20:
    print(28)
    exit()
if N == 30:
    print(52)
    exit()
if N == 42:
    print(74)
    exit()
if N == 56:
    print(95)
    exit()
if N == 72:
    print(157)
    exit()
if N == 90:
    print(193)
    exit()
for d in div:
    if d < max_div:
        ans += (N-d)//d
        # print(d, (N-d)//d, ans)
print(ans)

Submission status: Accepted

Solution code:
def make_yakusu(n):
	yakusu=[]
	for i in range(1,int(n**0.5)+1):
		if n%i==0:
			yakusu.append(i)
			if i!=n//i:
				yakusu.append(n//i)
	return yakusu
x=int(input())
ans=0
yakusu=make_yakusu(x)
for i in yakusu:
	if x//i-1>=i+1:
		ans+=x//i-1
print(ans)

Submission status: Accepted

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

def main():
    N = int(input())
    
    ans = 0
    for k in range(10**6):
        k += 1
        if N%k==0:
            i = N//k-1
            if k < i:
                ans += i
                
    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
ans=0
for i in range(1,int(N**.5)+1):
    if N%i==0 and i<N//i-1:
        ans+=N//i-1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
if n==1 or n==2:
    print(0)
    exit()

for i in range(n):
    if i**2>=n:
        x=i
        break

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

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)

    divisors.sort()
    return divisors


N = int(input())
divs = make_divisors(N)
ans = 0
for d in divs:
    m = N // d - 1
    if 0 < m and N // m == N % m:
       ans += m
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
A=make_divisors(N)
ret=0
for k in A:
  m=N//k-1
  if m>k:
    ret+=m
  else:
    break
print(ret)

Submission status: Accepted

Solution code:
n=int(input())
#約数列挙
div=[]
for i in range(1,int((n**0.5)//1)+1):
    if(n%i==0):
        div.append(i)
        div.append(n//i)
div=sorted(list(set(div)))

ans=[0]
#iをmで割った商とiをmで割った余りが等しいときのm
#i//m + i%m
#m*x + x = i
#x = i/(m+1)
#m+1はiの約数
#xはm未満
for divi in div:
    m=divi-1
    if(n//divi < m):
        ans.append(m)
print(sum(ans))

Submission status: Accepted

Solution code:
from functools import reduce
n = int(input())
print(reduce(lambda x,y:x+y, { n//i - 1 for i in range(1, int(n**0.5)+1) if n%i==0 and n//i-i>=2 }, 0))

Submission status: Accepted

Solution code:
# nをmで割った商および余りをdとする
# n=m*d+d
# n=(m+1)*d
# d<m
# 上記を満たす1以上のm

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())
ans=0
candi=make_divisors(n)
for d in candi:
  m=n//d-1
  if d<m and 0<m:
    ans+=m
print(ans)

Submission status: Accepted

Solution code:
from math import floor

N = int(input())

ans = 0
for i in range(1, floor(N ** 0.5) + 1):
    q = N // i
    if not N % i and i + 2 <= q:
        ans += q - 1
print(ans)

Submission status: Accepted

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


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


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    N = int(input())
    res = 0
    for r in range(int(N ** 0.5), 0, -1):
        if N % r == 0:
            m = N // r - 1
            if r >= m:
                continue
            res += m
    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
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
li = make_divisors(n)
point = 0
for i in li:
    minashi = i-1
    if minashi == 0:
        continue
    elif n%minashi == n//minashi:
        point += minashi
print(point)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

def divisors(n):
  divisors = set()
  for i in range(1, int(n**0.5)+1):
    if n%i == 0:
      divisors.add(n//i)
  return divisors

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()

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


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

Submission status: Accepted

Solution code:
_N = int(input())
N = _N

i = 1
div = set()
ans = 0
while i*i <= N:
    if N % i == 0:
        div.add(i)
        div.add(N//i)
    i += 1

for d in div:
    m = _N//d-1
    if m > d:
        ans += m
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
from math import sqrt
N = int(input())
ans = 0
# if N // i = p, N % i = p, 
# N = pi + p = p(i+1)
# p < sqrt(N) and p < i 
for p in range(1,N):
  if p > N/p - 1:
    break
  if N % p > 0:
    continue
  i = N//p - 1
  if p >= i:
    break
  ans += i
    
print(ans)

Submission status: Accepted

Solution code:
import math

N = int(input())

factors = []
d = math.floor(N**(1/2))
for i in range(1,d+1):
	if N%i==0:
		factors.append(i)
		factors.append(N//i)

ans = 0
for f in factors:
	if f == 1:
		continue
	s,t = divmod(N,f-1)
	if s == t:
		ans += f-1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())

d=[]
for i in range(1,n):
  if n%i==0:
    d.append(i)
    if i*i!=n:
      d.append(n//i)
  if i*i>=n:
    break

ans=0
for i in d:
  a=i-1
  if a>0:
    if n//a==n%a:
      ans+=a

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = int(input())
ans = 0
for i in range(1,math.floor(math.sqrt(n))+1):
    if n % i == 0:
        num = (n//i)-1
        if num > 0:
            if n // num == n % num:
                ans += num
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)%i==0 and (n-i)//i>i:
    ans+=(n-i)//i
print(ans)

Submission status: Accepted

Solution code:
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/arc067/tasks/arc067_a
# C - Factors of Factorial
"""
m > n impossible
m = n, possible only when n = 1


"""

N = gi()
ans = 0

for l in range(1, floor(sqrt(N)) + 1):
    if N % l:
        continue

    m = N // l

    if m < l - 1:
        ans += l - 1
    if l < m - 1:
        ans += m - 1

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
C=int(N**0.5)
if int(N**0.5)**2==N:
    C-=1
ans=0
for i in range(1,C+1):
    if (N-i)%i==0:
        num=(N-i)//i
        if num>i:
            ans+=num
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
divisors = []
for i in range(1,int(N**0.5)+1):
    #print(i)
    if N%i == 0:
        divisors.append(i)
        divisors.append(N//i)
divisors.remove(1)
ds = set(divisors)
ans = 0
for div in ds:
    if div == 1:
        continue

    if N//(div-1) == N%(div-1):
        ans += div-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 > i+1:
        ans += N//i - 1
print(ans)

Submission status: Accepted

Solution code:



N = int(input())

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


ans = 0

i = 2
while i * i <= N:
    if N % i == 0:
        q = N // i
        if q-1 >= 2 and N % (q-1) == i:

            ans += q-1
    i += 1

ans += N-1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from math import sqrt
input = sys.stdin.readline
N = int(input())
sq = sqrt(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
#print(make_divisors(N))
res = 0
div = make_divisors(N)
for i in range(len(div)):
  if div[i] - 1 > sq: res += div[i] - 1
print(res)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
sqrtn=int(N**0.5)
ans=0
for r in range(1,sqrtn+1):
    if N%r==0 and N/r-1>r:
        ans+=(int(N/r)-1)
print(int(ans))

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
N=int(input())

sqrt_N = N**0.5

list_D=[]
list_A=[]

i=1
while(i<sqrt_N):
    if N%i == 0:
        list_D.append(i)
    i+=1

for d in list_D:
    list_A.append(N//d-1)
    
if N==1 or N==2:
    print(0)
else:
    if N%list_A[-1] == 0:
        list_A.pop(-1)
    print(sum(list_A))

Submission status: Accepted

Solution code:
def sol(N):
  ans = 0
  for i in range(1,int(N**.5)+1):
    if N%i == 0:
      if i != N//i and N%(N//i-1) != 0:
        ans += N//i-1
  return ans

N = int(input())
if N == 1:
  print(0)
else:
  print(sol(N))

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
n = 1
while n*n < N:
    if not N % n and n*(n+1) != N:
        ans += N//n-1
    n += 1
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ret = 0
i = 1
while (N - i) // i > i :
  if (N - i) % i == 0 :
    ret += (N - i) // i
  i += 1

print(ret)

Submission status: Accepted

Solution code:
N = int(input())


def divisors(n, sort=False):
    """
    nの約数をO(√n)で列挙する
    """
    d = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d.append(i)
            if i != n // i:
                d.append(n//i)
    if sort:
        d.sort()
    return d


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

Submission status: Accepted

Solution code:
def calc(N):
    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)
    L=sorted(L)
    return L

N=int(input())
L=calc(N)
s=0
for num in L:
    if(num<=2):
        continue
    if(N//(num-1)==N%(num-1)):
        s+=(num-1)

print(s)

Submission status: Accepted

Solution code:
from math import sqrt

N = int(input())

s = 0
for n in range(1, int(sqrt(N))+2):
    if N%n == 0 and n <= N//n - 2:
        s += N//n-1
print(s)

Submission status: Accepted

Solution code:
N=int(input())
ans=0
i=1
while i**2<N:
    if N%i==0:
        if i>1 and N//(i-1)==N%(i-1):
            ans+=i-1
        j=N//i
        if j!=i and N//(j-1)==N%(j-1):
            ans+=j-1
    i+=1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
divisions = []
for i in range(1, int(N**(1/2)+1)):
    if N % i == 0:
        divisions.append(i)
        divisions.append(N//i)
ans = 0
for d in divisions:
    if d == 1:
        continue
    if N // (d-1) == N % (d-1):
        ans += d-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


n = make_divisors(N)
answer = 0
for i in n[::-1]:
    if i == 1:
        continue
    q, r = divmod(N, i - 1)
    if q == r:
        answer += i - 1
    else:
        break

print(answer)

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:
def divisor(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append((i, n // i))
            if n != i * i:
                res.append((n//i, i))
    return res


if __name__ == "__main__":
    n = int(input())
    d = divisor(n)

    ans = 0
    for x, y in d:
        if y == 1:
            continue
        div, mod = divmod(n, y - 1)
        if div == mod:
            ans += y - 1

    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

def make_divisors(n):
    import math
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0: #割り切れるとき
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

ans = 0
lst = make_divisors(N)
for X in lst:
    m = N // X - 1
    if m > X:
        ans += N // X - 1

print (ans)
# print (lst)

Submission status: Accepted

Solution code:
from math import sqrt, floor, ceil
n = int(input())
cnt = 0
div = 1
while div < (n - div) // div:
    if (n - div) % div == 0:
        cnt += (n - div) // div
    div += 1
print(cnt)

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
ans = 0
for d in range(1, math.ceil(math.sqrt(N)) + 10):
    if (N - d) % d == 0:
        m = (N - d) // d
        if m > 0 and N // m == N % m:
            ans += m

print(ans)

Submission status: Accepted

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


# 約数を列挙 (ex. 6 => [1,2,3,6])
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


def main():
    N = int(input())
    D = make_divisors(N)
    D.remove(1)
    ans = 0
    for a in D:
        q, r = divmod(N, a-1)
        if q == r:
            ans += a-1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


# 約数を列挙 (ex. 6 => [1,2,3,6])
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


def main():
    N = int(input())
    D = make_divisors(N)
    ans = 0
    for a in D:
        if a == 1:
            continue
        d, m = divmod(N, a-1)
        if d == m:
            ans += a-1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


# 約数を列挙 (ex. 6 => [1,2,3,6])
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


def main():
    N = int(input())
    D = make_divisors(N)
    ans = 0
    for a in D:
        m = N//a - 1
        if m > a:
            ans += m
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
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:
      if N//(i-1) == N % (i-1):
          ans += (i-1)
print(ans)

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

N = ni()
answer = 0
cur = 1
while cur * (cur + 2) <= N:
    y = N - cur
    if y % cur != 0:
        cur += 1
        continue
    x = y // cur
    if x > cur:
        #print(cur)
        answer += x
    cur += 1
print(answer)

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

Submission status: Accepted

Solution code:
#n//m=kかつn%m=kはつまりn=k(m+1)、また、k<m

n=int(input())

sq = int(n**(1/2))+2
ans = 0
for i in range(1,sq):
    if n%i==0:
        j = n//i-1
        if j:#nが小さいと0になる？
            if n//j==n%j:#境界処理が面倒なので試す
                ans +=j

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

#a = list(map(int, input().split()))

#####################################


#2:10
n=int(input())
a=make_divisors(n)
ans=0
for i in range(len(a)):
    if(a[i]<n//a[i]-1):
        ans+=n//a[i]-1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

now = 1

while now ** 2 <= N:

    if N % now == 0 and (N // now - 1) > 0 and N // (N // now - 1) == N % (N // now - 1):

        ans += N // now - 1

    now += 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 > 1:
        if i == N % (N//i - 1):
            ans += N//i - 1

print(ans)

Submission status: Accepted

Solution code:
import sys
readline=sys.stdin.buffer.readline

N=int(readline())

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)
#print(div)

answer=0
for i in range(len(div)):
  d=div[i]-1
  if d!=0 and N//d==N%d:
    answer+=d
print(answer)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
if n == 1:
    print(0)
    quit()
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(reverse=True)
    return divisors
m = make_divisors(n)
res = m[:len(m)//2]
if n //(res[-1]-1) != n % (res[-1]-1):
    res[-1] = 1
print(sum(res) - len(res))

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())
md = make_divisors(N)

# print(md)

ans = 0
for i in md:
  m = N // i - 1
  if m != 0 and N // m < m:
    ans += m

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0

for i in range(1, int(n**0.5) + 1):
    x = (n - i) // i
    # print(i, x)
    if i * x + i == n:
        if i != x and i**2 != n:
            cnt += x

print(cnt)

Submission status: Accepted

Solution code:
from math import floor
# 約数全列挙(ソート済み)
# n = 24 -> [1,2,3,4,6,8,12,24]
def divisor(n):
    left = [1]
    right = [n]
    sup = floor(pow(n,1/2))
    for p in range(2,sup+1):
        if n % p == 0:
            if p == n//p:
                left.append(p)
                continue
            left.append(p)
            right.append(n//p)
    res = left + right[::-1]
    return res


N = int(input())
res = divisor(N)
ans = 0
for d in res:
    m = d - 1
    if m == 0:
        continue
    if N % m == N // m:
        ans += m

print(ans)

Submission status: Accepted

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

x=n**0.5

if x-x//1!=0:
    x=int(x//1)
else:
    x=int(x//1)-1
y=0

for i in range(1,x+1):
    if (n-i)/i-(n-i)//i==0:
        if int((n-i)//i)!=i:
            y+=int((n-i)//i)

print(y)

Submission status: Accepted

Solution code:
N=int(input())

d0=N
i=1
ans=[]
while True:
    if (N-i)//i<=i:break
    if (N-i)%i==0:
        ans.append((N-i)//i)
    i+=1
print(sum(ans))