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

d=divisore(n)

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

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


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


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


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

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



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

Submission status: Accepted

Solution code:
from math import sqrt

n = int(input())

ans = 0


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


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

print(ans)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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_list = list()
divisors = make_divisors(N)

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

Submission status: Accepted

Solution code:
n = int(input())
def make_divisors(n):
    divisors = []
    # 試し割りで、かつ積でnを作るときの相方も同時に追加してる
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
divisors = make_divisors(n)
ans = 0
for div in divisors:
    if div != 1:
        q,r = divmod(n,div-1)
        if q == r:
            ans += div-1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

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

Submission status: Accepted

Solution code:
N = int(input())

# t = []
# for i in range(1, N+1):
#     if N // i == N % i:
#         print("→ :", i)
#         t.append(i)
#     else:
#         print("  :", i)

# print("G:", sum(t))

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#--約数のリスト--#

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

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

Submission status: Accepted

Solution code:
N=int(input())

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

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

print(answer)

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

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

Solution code:
import sys

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

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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


def main():
    N = int(readline())
    div = divisors(N)
    ans = 0
    for m in div:
        if m!=1:
            if N//(m-1) == N%(m-1):
                ans += m-1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(sum(l)-len(l))

Submission status: Accepted

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

n = int(input())
ans = 0

yakusu = make_divisors(n)

for i in yakusu:
    if i != 1 and (n//(i-1) == n%(i-1)):
        ans += i-1

print(ans)

Submission status: Accepted

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

import math  
  
# Method to print the divisors 
def printDivisors(n) : 
	list = []  
	for i in range(1, int(math.sqrt(n) + 1)) : 
		if (n % i == 0) : 
			if (n / i == i) : 
				list.append(i) 
			else : 
				list.append(i) 
				list.append(int(n / i)) 
	return(list)

A = printDivisors(N)

for i in range (1, len(A)):
	if N//(A[i]-1) == N/A[i]:
		count+=(A[i]-1)

print(count)

Submission status: Accepted

Solution code:
def main():
    import sys

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

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




    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def enum_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(readline())
    divs = enum_divisors(n)
    ans = 0

    for x in divs:
        m = n // x - 1
        if n - m * x < m:
            ans += m

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
c = 1
li = []
while True:
    k = n-c
    if k//c <= c:
        break
    if k % c == 0:
        li.append(k//c)
    c += 1
print(sum(li))

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    ans = 0
    # N//m=N%m=i => N=m*i, i<m => i<N**0.5
    for i in range(1, int(N ** 0.5) + 1):
        # N//m = N%m = i <=> (N-i)//i = m
        if (N - i) % i == 0:
            m = (N - i) // i
            ## 誤差のため、i==mはループで除外しきれない
            if i < m:
                ans += m

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
def calc(x):
    x -= 1
    if x <= 0:
        return 0
    elif n // x == n % x:
        return x
    return 0

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

Submission status: Accepted

Solution code:
# mのとりうる範囲を考える 最小値はまあ2だろう 最大値はN-1になる（modなので）

# こんがらがったので小さい数で考える
# N = 65
# まずN-1は商1余り1を達成できる 64
# 商2の範囲 21 < x <= 32 （N//3 < x <= N//2)
# 32では余り1, 31では余り3になり、以降xを少なくしてもあまりが増えるだけなので達成できない
# 商3の範囲 16 < x <= 21
# 21では余り2, 20では余り5 達成できない
# 商4 13 <= x <16
# 16では余り1, 15では5 達成できない
# 商5の範囲 10 < x <= 13
# 13では余り0, 12では5 達成できる 64+12 = 76
# 商6の範囲 9 < x <= 10
# 10では余り5, 9は無理
# 商7はどうなる？ いちおう8 < x<= 9
# 9では余り2 達成できない
# 商8 7< x <= 8
# 8では余り1で達成できない
# 商9 6 < x <= 7だが、商>余りの最大値 になってしまい、コレ以上は無意味
# 答えは76

# N = 329
# で考える まずはN-1で 328
# 商2 109 < x <= 164
# 164では1 163では3 達成できない
# 商3 82 < x <= 109
# 109では2 108では5 達成できない
# 商4 65 < x <= 82
# 82では1 81では5 達成できない
# 商5 54 < x <= 65
# 65では4 64では9 達成できない
# 商6 47 < x <= 54
# 54では5 53では11 達成できない
# 商7 41 < x <= 47
# 47では0 46で7になり、達成できる 328+46 = 374
# 商8 36 < x <= 41
# 41では1 40では9 達成できない
# 商9 32 < x <= 36
# 36では5 35では14 達成できない
# 商10 29 < x <= 32
# 32では9 31では19 達成できない
# 商11 27 < x <= 29
# 29では10 28では21 達成できない
# 商12 25 < x <= 27
# 27では5 27では17 達成できない
# 商13 23 < x <= 25
# 25では4 25では17 達成できない
# 商14 21 < x <= 23
# 23では7 22では21 達成できない
# 商15 20 < x <= 21
# 21では14 達成できない
# 商16 19 < x <= 20
# 20では9 達成できない
# 商17 18 < x <= 19
# 19では6 達成できない
# 商18 17 < x <= 18
# 18では5 達成できない8
# これ以降は無意味
# 答えは374

# というのを愚直に実装してみる...
N = int(input())
if N <= 2:
    print(0)
    exit()
ans = N - 1
div = 2
limit = N // div
while div <= limit:
    tmp = limit
    # ここ明らかに無駄っぽい気がするんだよなー
    while True:
        if N % tmp > div or tmp <= N // (div + 1):
            break
        if N % tmp == div:
            ans += tmp
            break
        tmp -= 1
    div += 1
    limit = N // div
print(ans)

Submission status: Accepted

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

if n == 1:
  print(0)
  quit()

for i in range(1, n):
  #余り、商がiになるmを求める。mが整数で、余りより大きければ答えに加える。
  #iは単調増加、mは単調減少だから、mが余りより小さくなったら打ち切る。
  temp=n-i
  syou=temp/i
  if syou>i:
    if syou.is_integer():
      ans+=int(syou)
  else:
    break
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans=0
if n == 1:
  print(0)
  quit()

#test = 0
#for i in range(1, n):
#  if n//i == n%i:
#    test+=i
#print(test)
  
for i in range(1, n):
  #余り、商がi
  temp=n-i
  syou=temp/i
  #print(syou)
  if syou>i:
    if syou.is_integer():
      ans+=int(syou)
  else:
    break
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
x=10**12
i=1
c=0
while x>i+1:
  x=(n-i)//i
  if (n-i)%i==0 and n-i!=i:c+=x
  i+=1
print(c)

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

n = INT()
a = divisor(n)
ans = 0
for x in a:
    if n // x <= x - 2:
        ans += x - 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
print(sum([n//x-1 for x in range(1,int(n**.5)+1) if n%x==0 and n//x-1>x]))

Submission status: Accepted

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

n = int(input())
lis = list(set(div(n)))
ans = 0
for b in lis:
    c = b - 1
    if c != 0:
        
        if n//c == n%c:
            ans += c
print(ans)

Submission status: Accepted

Solution code:
def solve(n):
    res = 0
    p = 1
    while p**2 <= n:
        if n % p == 0:
            m = n // p - 1
            if m > p:
                res += m
        p += 1
    return res

n = int(input())
print(solve(n))

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

divs=make_divisors(n)
ans=0
for div_i in divs:
    k=div_i
    m=(n-k)//k
    if m>k:
        ans+=m
print(ans)

Submission status: Accepted

Solution code:
def make_divisors(n):
    ret = []
    d = 1
    while d * d <= n:
        if n % d == 0:
            ret.append(d)
            if d != n // d:
                ret.append(n // d)
        d += 1
    return ret

# n = int(input())
def test(n):
    ret = 0
    for i in range(1, n + 1):
        if n // i == n % i:
            ret += i
    return ret


def main(n):
    d = make_divisors(n)
    # print("d =", d)
    ans = 0
    for i in d:
        m = i - 1
        if 1 <= n // (m + 1) < m:
            ans += m
    return ans
    # print(ans)

n = int(input())
print(main(n))

# for i in range(1, 1000):
#     ans_main = main(i)
#     ans_test = test(i)
#     if ans_main != ans_test:
#         print(i)        
#         print("ans_main =", ans_main)
#         print("ans_test =", ans_test)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

Submission status: Accepted

Solution code:
N = int(input())
x,r = 1,0

while x*x < N:
	if N%x==0:
		if x>1 and N//(x-1)==N%(x-1):
			r += x-1
		t = N//x-1
		if N//t==N%t:
			r += t
	x += 1

print(r)

Submission status: Accepted

Solution code:
def make_divisors(n):
    # from qiita.com/LorseKudos
    l, u = [], []
    i = 1
    while i*i<=n:
        if n%i==0:
            l.append(i)
            if i!=n//i:
                u.append(n//i)
        i+=1
    return l+u[::-1]

n = int(input())
Ns = make_divisors(n)
Ns = [_ns-1 for _ns in Ns if _ns!=1]
ans = 0
for _ns in Ns:
    if n//_ns==n%_ns:
        ans += _ns
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

i = 1
rlt = 0
while N > i**2 + i:
  if (N-i)%i == 0:
    rlt += (N-i)//i
  i += 1
    
print(rlt)

Submission status: Accepted

Solution code:
def make_divisors(n):
    lw, up = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lw.append(i)
        if i * i != n:
            up.append(n//i)
        i += 1
    return lw + up[::-1]

N = int(input())
ans = 0
li = make_divisors(N)
if N == 1 or N==2:
    print(0)
    exit()

for x in li:
    if x * (x+2) > N:
        break
    ans += N//x - 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
i = 1
ans = 0
while i*i<N:
    temp = N//i-1
    if  N == i*temp+i and (N-i)/i > i:
        ans += temp
    i+=1
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, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()

ans = 0
m = INF
r = 1

while r < m:
	m = (N-r)/r
	if (N-r)%r == 0 and r < m:
		ans += m
	r += 1

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

N = int(input())
divisors = make_divisors(N)
ans = 0
divisors.sort(reverse=True)
for x in divisors:
    if x > 1:
        temp = x - 1
        d,m = divmod(N,temp)
        if d != m:
            break
        else:
            ans += temp
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())


ans = 0

for i in range(1, 1000000):
    if N <= i:
        break
    # if (N-i) == i:
    #    break

    if (N - i) % i == 0:
        a = (N-i) // i
        if a <= i:
            break
        ans += a
        #print(i, (N-i) // i)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
from math import gcd
cou = 0
for i in range(1,int(n**0.5)+1):
  if n%i==0:
    b = n//i-1
    if b>=2 and n//b==n%b:
      cou += b
    
    if i>2:
      c = i-1
      if n//c==n%c:
        cou += c
print(cou)

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(reverse=True)
    return divisors

D = make_divisors(n)
ans = 0
for d in D:
    m = d-1
    q = n//d
    if m > 0 and 0 <= q < m:
        ans += m
print(ans)

Submission status: Accepted

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
ans=0
for i in range(1,n+1):
    #print(n-i,i)
    if (n-i)%i==0 and i<(n-i)//i:
        ans+=((n-i)//i)
        #print(i)
    if (n-i)+100<i**2:
        #print(i)
        break
    #print(i)
print(ans)

Submission status: Accepted

Solution code:
def divisor(n):
  cd = []
  i = 1
  while i*i <= n:
    if n%i==0:
      if i*(i-1)>N:
        cd.append(i-1)
      if i != n//i and (n//i)*(n//i-1)>N:
        cd.append(n//i-1)
    i += 1
  return cd

N = int(input())
print(sum(divisor(N)))

Submission status: Accepted

Solution code:
N = int(input())
A = []
for i in range(1,int(N**0.5)+1):
    if N%i==0:
        a = i
        b = N//i
        if a>b:
            a,b = b,a
        if 0<a<b-1:
            A.append(b-1)
print(sum(A))

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
if n==1:
    print(0)
    exit()
elif n==2:
  print(0)
  exit()
m=math.ceil(n/((n-1)**0.5+1))
ans=0
for i in range(1,m):
    if n%i==0:
        ans+=(n//i-1)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
lim = int(N ** 0.5)
ans = 0
for i in range(1, lim + 1):
    m = N // i
    quotient = N // m
    while m != 0:
        remainder = N % m
        if N // m != quotient or remainder > i:
            break
        if quotient == remainder:
            ans += m
            break
        m -= 1
print(ans)

Submission status: Accepted

Solution code:
import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


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


def main():
    N = in_n()
    yaku = make_divisors(N)

    ans = 0
    for n in yaku:
        if n < N // n - 1:
            ans += N // n - 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def divisor_dif_2_over(n):
    if n == 1:
        return []
    res = []
    i = 1
    while i * i <= n:
        if n % i == 0 and (n // i) - i >= 2:
            res.append(n // i - 1)
        i += 1
    return res


n = int(input())
# print(divisor_dif_2_over(n))
print(sum(divisor_dif_2_over(n)))

Submission status: Accepted

Solution code:
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
            if(N//i!=i):
                arr.append(N//i)
    return arr
N=int(input())
arr=factor(N)
ans=0
for x in arr:
    m=N//x-1
    if m<=x:
        continue
    ans+=m
print(ans)

Submission status: Accepted

Solution code:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    sum = 0
    for i in range(1,10**6):
        if i**2 >= n:
            break
        if n%i == 0:
            if i < n//i-1:
                sum += n//i-1
            else:
                break
    print(sum)
    return None

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def cal_divisors(N):
    divisors = []
    i = 1
    while i*i < N:
        if N % i == 0:
            divisors.append(i)
        i += 1
    divisors.sort()
    return divisors

def main():
    N = int(input())
    l = cal_divisors(N)
    ans = 0
    for i in l:
        if N//i - i > 1:
            ans += N//i - 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    N2=int(N**0.5)+5
    
    ans=0
    for i in range(1,N2):
        m=(N-i)//i
        if m*i+i==N:
            if i<m:
                ans+=m
                
    print(ans)

main()

Submission status: Accepted

Solution code:
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    ass.sort()
    return ass #sortされていない


def main():
    N = int(input())
    if N <= 2:
        print(0)
        exit()
    ans = 0
    for i in divisor(N):
        if i == 1:
            continue
        if N // (i-1) == N % (i-1):
            ans += (i-1)

    print(ans)

if __name__ == "__main__":
    main()