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: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())

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

Submission status: Runtime Error

Solution code:
import sys
from collections import *
import heapq
import math

import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())

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

Submission status: Runtime Error

Solution code:
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())

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

Submission status: Runtime Error

Solution code:
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())

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

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

total = 0
for i in range(ceil(n ** 0.5) + 1):
  if n % (i + 1) == 0:
    a = n // (i + 1) - 1
    if n // a == n % a:
      total += a

print(total)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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))
print((tank-1).sum() - 1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import floor, sqrt
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)
max_div = floor(sqrt(N))
ans = 0

for d in div:
    if N % 
    if d <= max_div:
        ans += (N-d)//d
        print(d, (N-d)//d, ans)
print(ans+1)

Submission status: Runtime Error

Solution code:
n=int(input())
s=[input() for i in range(n)]
count=0
A=0
B=0
BA=0
for i in range(n):
    for j in range(len(s[i])-1):
        if j==0:
            if s[i][j]=='B':
                B+=1
        if j==len(s[i])-2:
            if s[i][j+1]=='A':
                A+=1
        if s[i][j:j+2]=='AB':
            count+=1
    if s[i][0]=='B' and s[i][-1]=='A':
        BA+=1
        A-=1
        B-=1
        
if BA==0:
    print(count+min(A,B))
else:
    ans=count+BA-1
    if A>=1 and B>=1:
        print(ans+2)
    elif A>=1 or B>=1:
        print(ans+1)
    else:
        print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
ans=0
for i in range(n):
    if i**2>=n:
        x=i
        break

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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 n // num == n % num:
            ans += num
print(ans)

Submission status: Runtime Error

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)
#print(divisors)
ds = set(divisors)
ans = 0
for div in ds:

    if N//(div-1) == N%(div-1):
        ans += div-1
print(ans)

Submission status: Runtime Error

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]:
    q, r = divmod(N, i - 1)
    if q == r:
        answer += i - 1
    else:
        break

print(answer)

Submission status: Runtime Error

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

n=int(input())
fct =[]

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

print(ans)

Submission status: Runtime Error

Solution code:

N = int(input())

ans = 0

now = 1

while now ** 2 <= N:

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

        ans += N // now - 1

    now += 1

print (ans)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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)
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: Runtime Error

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()
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: Runtime Error

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

Submission status: Runtime Error

Solution code:
# div2019D - DivRem Number
def divisors(n: int) -> set:
    # Compute divisors of a number.
    divs = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i)
            div.add(n // i)
    return divs


def main():
    N = int(input())
    divs = divisors(N)
    ans = 0
    for m in divs:
        if m == 1:
            continue
        m -= 1
        if N // m == N % m:
            ans += m
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

n_list = [0]
for i in range(1,20):
    p = divrem(i)
    q = 0
    for i in p:
        q += i[0]
    n_list.append(q)

n = int(input())

if n <= 20:
    print(n_list[n])
else:
    ans = 0
    p = n**0.5
    for i in divisors(n):
        x, y = i
        if y < p:
            ans += (x-1)
    print(ans)

Submission status: Runtime Error

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

n_list = [0]
for i in range(1,20):
    p = divrem(i)
    q = 0
    for i in p:
        q += i[0]
    n_list.append(q)
    
n = int(input())

if n <= 20:
    print(n_list[i])
else:
    ans = 0
    p = n**0.5
    for i in divisors(n):
        x, y = i
        if y < p:
            ans += (x-1)
    print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())

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

Submission status: Runtime Error

Solution code:
import math
N = int(input())
num = 0
i = 1
while i <= math.sqrt(N):
    if N % i == 0:
        a = i - 1
        b = (N // i) - 1
        if a == b:
            if N // a == N % a:
                num += a
        else:
            if a > 0 and N // a == N % a:
                num += a
            if b > 0 and N // b == N % b:
                num += b
    i += 1

print(num)

Submission status: Runtime Error

Solution code:
N = int(input())

S = []
for i in range(N):
    s = str(input())
    S.append(s)
    
count_AB = 0
for s in S:
    count_AB += s.count("AB")
# print(count_AB)

count_BA = 0
count_A = 0
count_B = 0
for s in S:
    if s[0] == 'B' and s[-1] == 'A':
        count_BA += 1
    if s[0] != 'B' and s[-1] == 'A':
        count_A += 1
    if s[0] == 'B' and s[-1] != 'A':
        count_B += 1
# print(count_BA, count_A, count_B)

if count_BA >= 1:
    count_AB += count_BA -1
if count_BA >= 2:
    if count_A >= 1:
        count_A -= 1
        count_AB += 1
    if count_B >= 1:
        count_B -= 1
        count_AB += 1
count_AB += min(count_A, count_B)
print(count_AB)

Submission status: Runtime Error

Solution code:
import math
ans=0
m=[]
N=int(input())
rN=math.floor(math.sqrt(N))
for i in range(1,rN+1):
    if N%i==0:
        m.append(i)
        m.append(int(N/i))
    else:
        pass
m.sort()
m2=list(map(lambda x: x-1,m))
m2.pop(0)
for i in m2:
    a,b=divmod(N,i)
    if a==b:
        ans+=i
    else:
        pass
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
res = n-1 if n%(n-1) == int(n/(n-1)) else 0
i = 2
while i*i <= n:
  if n%i == 0:
    if n%(i-1) == int(n/(i-1)):
      res += i-1
    if i*i != n:
      if n%(int(n/i)-1) == int(n/(int(n/i)-1)):
        res += int(n/i) - 1
  else:
    pass
  i += 1
print(res)

Submission status: Runtime Error

Solution code:
def main():
    n = int(input().rstrip())
    sqrt_n = int(sqrt(n))

    total = 0
    for number in range(1,sqrt_n + 1):
        if n % number > 0:
            continue
        remain = n - number
        x, y = divmod(remain, number)
        #print(x, y, remain, number)
        if y == 0 and x > number:
            #print("○",number)
            total += x
        #elif y == 0:
        #    print("×",number)

    print(total)

if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
from copy import copy
def main():
    n = int(input().rstrip())
    sqrt_n = int(sqrt(n))
    primes = get_primes(sqrt_n)
    
    candidates = [1]
    for prime in primes:
        count = 0
        remain = n
        while remain % prime == 0:
            count += 1
            remain = remain // prime
        if count > 0:
        
            next_candidates = copy(candidates)
            for candidate in candidates:
                temp_candidate = candidate
                for i in range(count):
                    temp_candidate *= prime
                    #if temp_candidate > sqrt_n:
                    #    break
                    next_candidates.append(temp_candidate)
            candidates = next_candidates
    
    total = 0
    for number in candidates:

        remain = n - number
        x, y = divmod(remain, number)
        #print(x, y, remain, number)
        if y == 0 and x > number:
            #print("○",number)
            total += x
        #elif y == 0:
        #    print("×",number)

    print(total)

if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
import sys

N = int(sys.stdin.readline())

i = 0
count = 0

while i ** 2 <= N:
  if N // i == N % i:
    count += 1

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if n > 2:
  ans += n-1

for i in range(2,math.ceil(n**0.5)+1):

  if n % i == 0:
    j = n // i
    if n % (i-1) == n // (i-1):
      ans += i-1
    if n % (j-1) == n // (j-1) and i != j:
      ans += j-1
  
print(ans)

Submission status: Runtime Error

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

if n > 2:
  ans += n-1

for i in range(2,math.ceil(n**0.5)+1):

  if n % i == 0:
    j = n // i
    if n % (i-1) == n // (i-1):
      ans += n-1
    if n % (j-1) == n // (j-1) and i != j:
      ans += j-1
  
print(ans)

Submission status: Runtime Error

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

root = math.ceil(math.sqrt(N))
for i in range(root):
    if N % i  == 0:
        result += (N // i)  - 1

print(result)

Submission status: Runtime Error

Solution code:

import math
N = int(input())
result = 0

root = math.ceil(math.sqrt(N))
for i in range(root):
    if N % i  == 0:
        result += N // i  - 1

print(result)

Submission status: Runtime Error

Solution code:
import math
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
q = int(math.sqrt(n))+1
sum = 0
for i in range(1,q):
    ddprint("i {}".format(i))
    if n%i==0:
        m = n//i - 1
        ddprint("divides m {}".format(m))
        if n%m == n//m:
            sum += m
print(sum)

Submission status: Runtime Error

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

"""解説
http://drken1215.hatenablog.com/entry/2019/05/12/004500

N//m = N%m = k （kは約数。かつ余り）とすると、

N = mk + k ...(1)
N = k(m+1)

k は MOD m の余りなので、m > k である。
よって、

N = k*(m+1) > k*k

よって、

N > k**2
√N > k

これに気づけばOK。あとはkについて全探索。O(√N)


(例)
・N=8, m=3のとき
3*2 + 2 = 8
m*k + k = N

・N=8, m=7のとき
7*1 + 1 = 8
m*k + k = N

"""
import math

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

    ans = 0
    for k in range(1, math.floor(math.sqrt(N))+1):
        if N%k != 0: continue # kはNの約数より
        # N = k(m+1)
        # m = (N/k) - 1
        m = (N/k) - 1
        if N//m == N%m:
            ans += m
    print(int(ans))


if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
import math

n = int(input())

factors = set((n, ))
for factor in range(2, math.ceil(math.sqrt(n))):
    if n % factor == 0:
        factors.add(factor)
        factors.add(n // factor)

total = 0
for factor in factors:
    k = factor - 1
    div = n // k
    mod = n % k
    if div == mod:
        total += k

print(total)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import sys
import sympy
def input(): return sys.stdin.readline().strip()

i  = lambda: int(input())

N = i()

pfd = sympy.factorint(N)

check_num = []

for pf in pfd.keys():
    tmp_num = []
    for i in range(1, pfd[pf] + 1):
        tmp_num.append(pf ** i)
        for n in check_num:
            tmp_num.append(n * (pf ** i))
    check_num += tmp_num

count = 0
for n in check_num:
    if N / n < n:
        count += n-1

print(count)

Submission status: Runtime Error

Solution code:
import math
n=int(input())
sqn=math.sqrt(n)
ch=n-sqn
nums=[]
su=0
stage=2
while(su<n):
    n_ = math.ceil(n*(stage-1)/stage)
    if n_ == su:
        nums.append(1)
        nums.append(n-su-1)
        break
    nums.append(n_-su)
    su+=n_-su
    if su>=ch:
        nums.append(n-su)
        break
    stage += 1
ans=[]
next_div_num = 0
k=len(nums)
for i in range(k):
    next_div_num += nums[k-1-i]
    if nums[k-1-i] == 1:
        continue
    sho = n//next_div_num
    d = next_div_num-1
    if d==0 or sho>d:
        continue
    if sho == n%d:
        ans.append(d)
print(sum(ans))

Submission status: Runtime Error

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

import sys
from math import sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()

# for i in range(N, 0, -1):
#     print(i, N//i, N%i)

m=N
ans=set()
while m>=sqrt(N):
    i=N//m
    j=N%m
    if (i-j)%i==0 and N//m==N//(m-1):
        ans.add(m-1)
    m=N//(i+1)

for m in range(1, int(sqrt(N))+1):
    if N//m==N%m:
        ans.add(m)

print(sum(ans))

Submission status: Runtime Error

Solution code:
import math

N=int(input())
result=0

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

Submission status: Runtime Error

Solution code:
import math

N = int(input())

total = 0
   
for i in range(1,int(math.sqrt(N)+1)):
    amari = i
    if N % amari == 0:
        k = N // amari - 1
        if amari == N % k:
            total += N//amari - 1
        #print(amari)

print(total)

Submission status: Runtime Error

Solution code:
from math import floor

def divisor(n):
    left = []
    right = [n]
    sup = floor(pow(n,1/2))
    for p in range(2,sup+1):
        if n % p == 0:
            left.append(p)
            right.append(n//p)
    res = left + right[::-1]
    return res
        
N = int(input())

div = divisor(N)
ans = 0

for d in div:
    if N // (d-1) == N % (d-1):
        ans += (d-1)

print(ans)

Submission status: Runtime Error

Solution code:
import math
n,a=int(input()),0
for i in range(1,int(math.sqrt(n))+1):
  if n%i==0:
    m=n//i-1
    if n//m==n%m:a+=n//i-1
print(a)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
import numpy as np
N = int(input())
G = []
for n in range(1, int(np.sqrt(N))+1):
    if N % n == 0:
        if n != 1:
            G.append(n)
        G.append(int(N/n))

cnt = 0
for g in G:
    m = g-1
    if N // m == N % m:
        cnt += m
print(cnt)

Submission status: Runtime Error

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

res = make_divisors(N)
#print(res)

Submission status: Runtime Error

Solution code:
def sample_code(N):

 #   print('Prime factor')
    fct = factorize(N)
 #   print(fct,num(fct))

 #   print('divisor')
    for div in divisorize(fct):
        b = num(div)


def divisorize(fct):
    b,e = fct.pop()
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b,k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def factorize(N):
    fct = []
    b,e = 2, 0
    while b * b <= N:
        while N % b == 0:
            N = N // b
            e = e + 1
        if e > 0:
            fct.append((b,e))
        b,e = b + 1,0
    if N > 1:
        fct.append((N,1))
    return fct

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base ** exponent
        divisor_list.append(a)
    return a

N = int(input())
sum_m = 0
divisor_list = []
sample_code(N)
divisor_list = list(set(divisor_list))

for c in divisor_list:
    if c != 1 and c!= 2:
        if N // (c-1) >= (c-1):
            continue
        else:
            sum_m += c - 1

print(sum_m)

Submission status: Runtime Error

Solution code:
def sample_code(N):

 #   print('Prime factor')
    fct = factorize(N)
 #   print(fct,num(fct))

 #   print('divisor')
    for div in divisorize(fct):
        continue
 #       print(div,num(div))


def divisorize(fct):
    b,e = fct.pop()
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b,k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def factorize(N):
    fct = []
    b,e = 2, 0
    while b * b <= N:
        while N % b == 0:
            N = N // b
            e = e + 1
        if e > 0:
            fct.append((b,e))
        b,e = b + 1,0
    if N > 1:
        fct.append((N,1))
    return fct

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base ** exponent
        divisor_list.append(a)
    return a

N = int(input())
sum_m = 0
divisor_list = []
sample_code(N)
divisor_list = list(set(divisor_list))

for c in divisor_list:
    if c != 1 and c!= 2:
        if N // (c-1) >= (c-1):
            continue
        else:
            sum_m += c - 1

print(sum_m)

Submission status: Runtime Error

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

from math import sqrt
ans = 0
for k in range(1,int(sqrt(N)+1)):
    if N%k == 0:
        m = N//k-1
        if k == N%m: ans += m

print(ans)

Submission status: Runtime Error

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

def yakusu(n):
    l = []
    for i in range(1,int(math.sqrt(n))+1):
 #       print(i)
        if n%i == 0:
            l.append(i)
            l.append(n//i)
    return(l)

l = yakusu(n)

ans = 0
for m in l[1:]:
    if n == int(n/(m-1))*m:
        ans += m-1
    
#print(l)
print(ans)

Submission status: Runtime Error

Solution code:
import math

N = int(input())
ans = 0
for i in range(1, math.ceil(math.sqrt(N)) + 1):
    if N % i:
        continue
    n = N // i - 1
    if N % n == N // n:
        ans += n
print(ans)

Submission status: Runtime Error

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 n // m == n % m:
            ans += m

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
ans = 0
l = list()
for i in range(1, int(N**0.5)+1):
  if N % i == 0:  # i is a divisor of N
    if i > 1:
      m = i-1
      if N//m == N % m:ans += m
    m = N//i-1
    if N//m == N % m:ans += m
print(ans)

Submission status: Runtime Error

Solution code:
#DivRem number
N  = int(input())
ans = 0
def divisor(N):
    div_lst = [N]
    for n in range(2, int(N ** 0.5 + 1)):
        if N % n == 0:
            if  n == int(N / n):
                div_lst.append(n)
            else:
                div_lst.append(n)
                div_lst.append(int(N / n))

    return div_lst

div_lst = divisor(N)
for m in div_lst:
    m = m - 1
    if int(N / m) == N % m:
        ans += m
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
N=int(input())

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

ans=0
divisors=make_divisors(N)

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

print(ans)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
from math import sqrt
n=int(input())
s=0
for i in range(int(sqrt(n))):
    d,m=divmod(n,i+1)
    if m == 0:
        if len(set(divmod(n,d-1))) == 1:
            s += d-1
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(int(result))

Submission status: Runtime Error

Solution code:
N = int(input())

BA = 0
BX = 0
XA = 0

ans = 0

for i in range(N):
    S = input()
    if S[0] == 'B' and S[-1] == 'A':
        BA += 1
    elif S[0] == 'B':
        BX += 1
    elif S[-1] == 'A':
        XA += 1

    for a, b in zip(S, S[1:]):
        # print(a, b)
        if a == 'A' and b == 'B':
            ans += 1

# print(BA, BX, XA, ans)

if BA == 0:
    ans += min(BX, XA)
else:
    if BX == 0 and XA == 0:
        ans += BA - 1
    else:
        ans += BA + min(BX, XA)

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())

import math

kmax1 = (N+1/4)**(1/2)-1/2


kmax = min(kmax1, kmax2)

acc = 0
for k in range(1, int(kmax+1)):
    if((N-k)%k==0&N>k):
        acc+=(N-k)/k
print(int(acc))

Submission status: Runtime Error

Solution code:
import math
 
N = int(input())
d_list = []
 
for i in range(3, int(math.sqrt(N))):
  if N % i == 0:
    d_list.append(i)
    if i != math.sqrt(N):
      d_lsit.append(N / i)
 
output = sum(d_list) - (len(d_list) - 2) - 3
print(output)

Submission status: Runtime Error

Solution code:
import math

N = int(input())
d_list = []

for i in range(3, int(math.sqrt(N))):
  if N % i == 0:
    d_list.append(i)
    if i != math.sqrt(N):
      d_lsit.append(N / i)

output = sum(d_list) - len(d_list)
print(output)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

    divisors.sort()
    return divisors
N_divs = make_divisors(N)


for i in range(len(N_divs)): 
    k = N//N_divs[i] - 1
    if k != 0 or N//k == N%k:
        ans += k

print(ans)

Submission status: Runtime Error

Solution code:
m=int(input())
pf={m:1}
a=[0]
for i in range(2,int(m**0.5)+1):
    pf[i]=pf.get(i,0)+1
    if i!=m//i:
        pf[m//i]=pf.get(m//i,0)+1
for i in pf:
    if m//(i-1)==m%(i-1):
        a.append(a[-1]+i-1)
print(a[-1])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math

N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1)
    d = N - i
    if d%i==0:
        k = int(d/i)
        count+=k
print(count)

Submission status: Runtime Error

Solution code:
import math

N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1:
    d = N - i
    if d%i==0:
        k = int(d/i)
        count+=k
print(count)