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:
import collections as c
ip = lambda : map(int, input().split())

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

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

Submission status: Accepted

Solution code:
def hersCode(l, r, mod):
  if N % r == mod:
    return r
  if N % l == mod:
    return l
  ok = r
  ng = l
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if N % mid == mod:
      return mid
    if N % mid < mod:
      ok = mid
    else:
      ng = mid
  return -1


def first(l, r):
  ok = r
  ng = l
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if N // mid < mid:
      ok = mid
    else:
      ng = mid
  return ok

N = int(input())

l = first(0, N)
f = N // l
Ans = 0
for i in range(f, 0, -1):
  r = N // i
  x = hersCode(l, r, i)
  if x != -1:
    Ans += x
  l = r + 1

print(Ans)

Submission status: Accepted

Solution code:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


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


def main():
    n = intin()

    ans = 0

    for div in set(get_divisors(n)):
        m = div - 1
        a = n // div
        if m <= a:
            continue
        ans += m

    print(ans)


if __name__ == '__main__':
    main()

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())
#print(make_divisors(N))
A=sorted( make_divisors(N))
ans=0
for a in A:
    m=((N//a)-1)
    if m!=0:
        if N//m ==N%m:
            ans+=m
#    if N%((N//a)-1) !=0:
#        ans+=((N//a)-1)
print (ans)


#223092870000

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    ret = 0
    i = 1
    used = set()
    while (i - 1) ** 2 <= N:
        #print(i)
        tmp = N - i
        if tmp % i == 0:
            val = tmp // i
            if val > 0 and N // val == N % val and not val in used:
                ret += val
                used.add(val)
        if N % (i + 1):
            val = N // (i + 1) != i
            if val > 0 and N // val == N % val and not val in used:
                ret += val
                used.add(val)
        i += 1
    print(ret)
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

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

Submission status: Accepted

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

for i in range(1,math.floor(N**0.5)+1):
    if N%i == 0:
        if N/i > i+1:
            Ans += int(N/i)-1
print(Ans)

Submission status: Accepted

Solution code:
import math


def main():
    N = int(input())
    sqrt = math.ceil(math.sqrt(N))
    ans = 0
    for x in range(1, sqrt):
        if N % x == 0:
            y = N // x - 1
            if N // y == N % y:
                ans += y
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

N = int(input())

# primes = []
# N_tmp = N
# for p in range(2, int(math.sqrt(N) + 1)):
#     if N_tmp % p > 0: continue
#     for i_p in range(1, 64):
#         if N % (p ** (i_p + 1)) > 0: break
#     primes.append((p, i_p))
#     N_tmp /= (p ** i_p)

divisors = []
for i in range(1, int(math.sqrt(N) + 1)):
    if N % i > 0: continue
    if (N // i) - i < 2: continue
    divisors.append(N // i)
    
print(sum(divisors) - len(divisors))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import math
n = int(input())
ans = 0
for k in range(1, math.floor(math.sqrt(n))+ 1):
    if (n-k) % k == 0 and k**2 + k < n :
        ans += (n-k)//k
print(ans)

Submission status: Accepted

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

    divisors.sort()
    return divisors
def main():
    N = int(input())
    div = make_divisors(N)
    res = 0
    for p in div:
        m = (N // p) - 1
        if p == m:
            continue
        if p >= m:
            break
        res += m
    print(res)
main()

Submission status: Accepted

Solution code:
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b
  
def solve():
    N = int(single_input())
    ans = 0
    c = 1
    while N - c > pow(c, 2):
        if (N - c) % c == 0: ans += (N - c) // c
        c += 1
    print(ans)
    return 0
  
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import math

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())

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

root_n = int(math.sqrt(n))

ans = 0
for mod in range(1, root_n+1):
    if (n - mod) % mod == 0:
        a = (n - mod) // mod
        #if a != 1 and a < n:
        if n % a == mod:
            #print(a)
            ans += a

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    buf = input()
    N = int(buf)
    # N / m = i % i
    # m * i + i = N
    total = 0
    i = 1
    while i * i < N:
        if N % i == 0:
            div = N // i - 1
            if N // div == N % div:
                total += div
        i += 1
    print(total)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd

#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint
#from sympy import divisors

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

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


def is_prime(n):
    if n == 1:
        return False
    if n % 2 == 0:
        return False
    i = 3
    while i * i <= n:
        if n % i == 0:
            return False
        i += 2
    return True


def prime_factors(n):
    prime_factor_list = []
    while not n % 2:
        prime_factor_list.append(2)
        n //= 2
    while not n % 3:
        prime_factor_list.append(3)
        n //= 3
    i = 5
    while n != 1:
        if is_prime(i):
            while not n % i:
                prime_factor_list.append(i)
                n //= i
        i += 2

    return prime_factor_list

def divisors2(factors) :
    """
    Generates all divisors, unordered, from the prime factorization.
    """
    ps = sorted(set(factors))
    omega = len(ps)

    def rec_gen(n = 0) :
        if n == omega :
            yield 1
        else :
            pows = [1]
        for j in range(factors.count(ps[n])) :
            pows += [pows[-1] * ps[n]]
        for q in rec_gen(n + 1) :
            for p in pows :
                yield p * q

    for p in rec_gen() :
        yield p

def divisors(N):
    l = []
    for i in range(1,int(sqrt(N))+1):
        if N % i == 0:
            l.append(i)
    return l

N = int(input())

cnt = 0
#for p in divisors(prime_factors(N)):
for p in divisors(N):
    m = N // p
    if not p < m-1:
        break
    #print(m-1)
    cnt += m-1

print(cnt)

Submission status: Accepted

Solution code:
import math
n = int(input())
res = 0
for i in range(int(math.sqrt(n))+2):
    if i >= 1 and i <= n and n%i==0:
        if i>2 and n//i==n%(i-1):
            res+=(i-1)
        j = n//i
        if j>2 and j!=i and n//j==n%(j-1):
            res+=(j-1)
print(res)

Submission status: Accepted

Solution code:
import math
n=int(input())
def yakusu(n):
    yaku=[]
    for i in range(1, math.ceil(n**(1/2))+1):
        if n%i==0:
            yaku.append((i, n//i))
    return yaku
yakusu=yakusu(n)
ans=0
for yaku in yakusu:
    if yaku[1]-yaku[0]>=2:
        ans+=(yaku[1]-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(reverse = True)
	return divisors

N = int(input())
div = make_divisors(N)
i = 0
ans = 0
m = div[0]
while m >= 1:
	q = N // m
	r = N % m
	if q == r:
		ans += m
		i += 1
		m = div[i]
	else:
		m -= 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
i = 1
while(True):
    if N//i <=i+1:
        break
    if N%i == 0:
        ans += N//i - 1
    i += 1
        
print(ans)

Submission status: Accepted

Solution code:
# floor(N/m) = N % m

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

def solve(n):
    s = 0

    for d in divisors(n):
        m = d - 1
        if m and (m+1)*(n//m) == n:
            s += m
    return s


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

Submission status: Accepted

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


div = make_divisors(N)

score = 0
for i in div:
    if N // i - 1 > i:
        score += N // i - 1


print(score)

Submission status: Accepted

Solution code:
from math import sqrt

n = int(input())

def factorize(n):    
    A = set()
    
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            A.add(i)
            A.add(n // i)

    return A

A = factorize(n)
ans = 0

for a in A:
    q = n // a
    m = a - 1
    if q < m:
        ans += m

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

ans = 0

for d in div:
    if d - 1 <= 0:
        continue
    if N // (d - 1) != (N % (d - 1)):
        continue

    if (d - 1) ** 2 <= N:
        continue
    ans += (d - 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())
a = make_divisors(N)
b = []
for i in range(len(a)):
  k = a[i]
  if k > N**0.5:
    if N//(k-1) == N%(k-1):
      b.append(k)
#print(a)
print(sum(b)-len(b))

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 in divs[1:]:
    m = div - 1
    if N % m == N // m:
        ans += m

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def all_factors(n):
    """returns a sorted list of all distinct factors of n"""
    small, large = [], []
    for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):
        if not n % i:
            small.append(i)
            large.append(n // i)
    if small[-1] == large[-1]:
        large.pop()
    large.reverse()
    small.extend(large)
    return small


def main():
    n = int(input())
    cnt = 0
    for f in all_factors(n)[1:]:
        if n // (f - 1) == n % (f - 1):
            cnt += f - 1
    print(cnt)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

if n == 1:
  print(0)
else:
  divl = [n]
  i = 2
  while i * i <= n:
    if n % i == 0:
      divl.append(i)
      divl.append(n // i)
    i += 1

  ans = 0
  for d in divl:
    if n == d * (n // (d - 1)):
      ans += d - 1
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

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



for i in range(1, int(n**0.5)+1):
    n2 = n - i

    if n2 % i == 0:
        #print(i, n2 / i)
        #print(n2+i , n//(n2//i), i)

        try:
            if n//(n2//i) == i:
                ans += math.ceil(n2 / i)
        except:
            pass

print(ans)

Submission status: Accepted

Solution code:
from math import floor

N = int(input())
ans = 0
sup = floor(pow(N,1/2))
for r in range(1,sup+1):
    if N % r == 0:
        m = N // r - 1
        if 0 <= r <= m-1:
            ans += m
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
N = input()
dlist = []
n2 = int(round(math.sqrt(N)))
for i in range(2,n2+1):
	if(N % i == 0):
		if(N/i - 1 > i):
			dlist.append(N/i -1)
if(N!=2):
	dlist.append(N-1)
print(sum(dlist))

Submission status: Accepted

Solution code:
n = int(input())
n_1 = int(n ** (1/2))
s = 0
 
for i in range(1,n_1+10000):
    if n % i == 0:
        if i < n // i -1:
            s += (n // i) - 1

print(s)

Submission status: Accepted

Solution code:
def calc_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 = calc_divisors(N)

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

Submission status: Accepted

Solution code:
n = int(input())
sqrt_n = int(n ** 0.5)
count = 0
com = []
for i in range(sqrt_n):
    if n % (i+1) == 0:
        a, b = i+1, int(n/(i+1))
        if b-a >= 2:
            com.append([a,b])
for i in range(len(com)):
    count += (com[i][1]-1)
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(1, math.ceil(N**(1/2))):
    if N % i == 0:
        if N % (N//i - 1) != 0:
            ans += N//i - 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
k = 1
while True:
  m = (N//k) - 1
  if m <= k:
    break
  if N % k == 0:
    ans += m
  k += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(1,N):
    if N//i < i:
        break
    if N%i:
        continue
    m = (N//i) - 1
    if N//m == N%m:
        ans += m
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

res = 0
for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        if i<n//i-1:
            res += n//i-1
        if i**2 == n:
            continue
        if n//i<i-1:
            res += i-1
print(res)

Submission status: Accepted

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

x=int(input())

import math
xr=math.ceil(math.sqrt(x))

LIST=[]
for i in range(1,xr+1):
    if x%i==0:
        LIST.append(i)
        LIST.append(x//i)

SET=set(LIST)
SET.remove(x)
ANS=0
for i in SET:
    y=x//i-1
    if x//y==x%y:
        ANS+=y

print(ANS)

Submission status: Accepted

Solution code:
n = int(input())

if n == 0:
    print(0)

else:

    lim = int((n**0.5))

    ans = 0
    for i in range(1,lim+1):
        if n%i == 0 and i*i != n and i*(i+1) != n:
            ans += (n//i)-1

    print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys
from collections import deque, Counter
import bisect
import math
from itertools import accumulate, product, permutations, combinations, groupby
from fractions import gcd 
import heapq
sys.setrecursionlimit(10**6)
#input = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
#s = input()
#a = [int(i) for i in input().split()]
#m = [[int(i) for i in input().split()] for j in range(n)] # 縦「n」行

n = int(input())

ans = 0
for x in range(1,10**6+1):
    if n%x != 0: continue
    m=n//x-1
    if x >= m: continue
    ans += m
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
rN=int(N**(1/2))
ans=0
for i in range(1,rN+1):
  N-=1
  if i>=N/i:
    break
  if N%i==0:
    ans+=N//i
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

divs = make_divisors(N)

check = lambda x: x if N/x < x-1 else 1
divs_ok = list(map(check, divs))

print(sum(divs_ok) - len(divs_ok))

Submission status: Accepted

Solution code:
N = int(input())
s = 0
A = 1
while A*A <= N:
    if N%A == 0:
        B = int((N+0.5)//A)
        if A+1 < B:
            s += B-1
    A += 1
print(s)

Submission status: Accepted

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

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:
        continue
    if N//(N//i-1)!=N%((N//i-1)):
        continue
    else:
        #print(i,N//i-1,N//(N//i-1),N%((N//i-1)))
        ans+=N//i-1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
import math

N = int(input())
rootN = int(math.sqrt(N))
sum = 0

for q in range(1, rootN + 1):
    if N % q == 0:
        m = N // q - 1
        if q < m:
            sum += m

print(sum)

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)%i==0 and (n-i)//i>i): 
        ans+=(n-i)//i
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
ans = 0
N = int(input())
for a in make_divisors(N):
    b = N//a
    m = a -1
    if m < 1:
        continue
    if N%m == b:
        ans += m
print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
S = 0
for k in range(1, math.floor(math.sqrt(N)) + 1):
  if N % k == 0 and N // k > k + 1:
    S += N // k - 1
print(S)

Submission status: Accepted

Solution code:
n=int(input())
d=[]
c=[]
for i in range(1,int(n**.5)+1):
  if n%i==0:
    for p in [i-1,n//i-1]:
      if p==0:continue
      if n%p==n//p:
        c.append(p)
print(sum(c))

Submission status: Accepted

Solution code:
n = int(input())

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

    i += 1

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
from copy import deepcopy
def factors(N):
    ret = []
    for i in range(2, int(N**(1/2))+1):
        if N%i == 0:
            ret.append([])
            t = 1
            while N%i == 0:
                N //= i
                ret[-1].append(i**t)
                t += 1
    return ret
N = int( input())
F = factors(N)
C = deque([1])

for d in F:
    T = deepcopy(C)
    for t in T:
        for s in d:
            C.append(t*s)

ans = 0
for c in C:
    m = N//c -1
    if m == 0:
        continue
    if N//m == N%m:
        ans += m

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = int(n**(1/2))+1
ans = 0
for a in range(1,p):
    if n%a == 0:
        m = n//a-1
        if m>a:
            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())
if N <= 2:
    print(0)
    exit()
array = make_divisors(N)
len_array = len(array)
# print(array)
if len_array % 2 == 1:
    print(sum(array[1::2]) - len_array // 2)
else:
    if array[-1] - array[-2] == 1:
        print(sum(array[1:-2:2]) - (len_array // 2 - 1))
    else:
        print(sum(array[1::2]) - len_array // 2)

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

ans = 0
for i in make_divisors(n):
    if i == 1:
        continue
    k = n//i
    m = i-1
    if k < m:
        ans += m
print(ans)

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7


N = int(input())
s = round(math.sqrt(N))

ans = 0
for i in range(1,s+1):
    if N % i == 0:
        m = N//i-1
        # print(m)

        if m > 0 and i < m:
            ans += m

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
i = 1
while i*i < N:
    d, m = divmod((N-i), i)
    if m == 0:
        if d==i:
            i+=1
            continue
        ans += d
        #print(d, i)
    i += 1
print(ans)

Submission status: Accepted

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

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)

    # divisors.sort()
    return divisors

n = int(input())
div = make_divisors(n)

ans = 0
for i in range(len(div)):
    if div[i] == 1:
        continue
    if n // (div[i] - 1) == n % (div[i] - 1):
        ans += div[i] - 1

print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())

sqrtN = int(math.sqrt(n))

ans = 0
for i in range(sqrtN):
    m = i+1
    tmp = n - m
    if(tmp%m==0):
        tmpAns = tmp / m
        if(tmpAns > m):
            ans += tmpAns

print(int(ans))