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: Wrong Answer

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

N =int(input())

value = 0
i = 1


while(True):
  q, mod = divmod(N - i, i)
  
  if mod == 0:
    if q * i + i == N:
      value += q

  if q <= i:
    break
  else:
    i += 1

print(value)

Submission status: Wrong Answer

Solution code:
N=int(input())

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

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

N = int(stdin.readline().rstrip().split()[0])

sqrtN = int(np.sqrt(N))
ans = 0
if N ==1000000000000:
  sqrtN -=1

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

Submission status: Wrong Answer

Solution code:
N = int(input())

j = 0
i = 2 ** j
while N > i:
    j += 1
    i = 2 ** j

m = 1
result = 0
while j > 0:
    if (N - m) % m == 0:
        res = (N - m) / m
        if N % res == int(N/res):
            result += res
    m += 1
    j -= 1

print(int(result))

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0
u = 2
sosu_f = True

tamesi = int(N**(1/2)+1)

for i in range(1,tamesi)[::-1]:
    if N%i == 0:
        u = i
        break

for i in range(1,u+1):
    if N%i == 0:
        ans += (N//i-1)



print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
cnt = 0
for i in range(1, int(math.sqrt(N+1))+1):
    if (N == i*i): break
    if (N-i) % i == 0: 
        tmp = (N-i) // i
        if (tmp == 1): continue
        cnt += tmp
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
import itertools
from functools import reduce
import time
N = int(input())
st = time.time()
copyN = N
sqrtN = int(math.sqrt(N))
fac = []
for i in range(2, sqrtN):
    while copyN != 1:
        if copyN % i == 0:
            copyN //= i
            fac.append(i)
        else:
            break
    if copyN == 1:
        break
ans = 0
div = 0
for i in range(1, len(fac)+1):
    for p in set(itertools.combinations(fac, i)):
        div = reduce(lambda x, y: x*y, p) - 1
        if N // div == N % div:
            # print(i, N//i, N%i)
            ans += div
if div != N-1:
    if N // (N-1) == N % (N-1):
        # print(i, N//i, N%i)
        ans += N-1
# for i in range(1, N+1):
#     if N // i == N % i:
#         print(i, N//i, N%i)
#         count += 1
# print(count)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
#p,r p=r m+1 > p
#mp + p = N
#(m+1)p = N
N = int(input())
l = range(1,int(np.sqrt(N)))
c = 0
flag = False
while True:
  if flag:
    l = [ i for i in l if i%p!=0 ]
    flag = False
  for p in l:
    if N%p == 0:
      c += N/p - 1
    else:
      flag = True
      break
  if not(flag):
    break
print(c)

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
n = int(input())

import math
counter = 0
for i in range(1, math.ceil(n**0.5)):
    if n % i == 0:
        counter = counter + n / i - 1
        

print(int(counter))

Submission status: Wrong Answer

Solution code:
N = int(input())


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

    return sum


print(make_divisors(N))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

total = 0


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

print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# def gcd(a_gcd, b_gcd):
#     while b_gcd != 0:
#         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
#     return a_gcd
#
#
# def lcm(a_lcm, b_lcm):
#     return a_lcm * b // gcd(a_lcm, b_lcm)
#
#
# def max_sum(N_max_sum, a_max_sum):
#     dp = [0] * (N_max_sum + 1)
#     for i in range(N_max_sum):
#         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
#     return dp[N]
#
#
# def knapsack(N_knapsack, W, weight, value):
#     inf = float("inf")
#     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
#     for i in range(W+1):
#         dp[0][i] = 0
#
#     for i in range(N_knapsack):
#         for w in range(W+1):
#             if weight[i] <= w:
#                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
#             else:
#                 dp[i+1][w] = dp[i][w]
#     return dp[N_knapsack][W]


def fav(n, i_fav):
    # print((n - i_fav) // i_fav)
    # print((n - 1) / i_fav)
    x = ((n - i_fav) / i_fav)
    if x.is_integer():
        return int(x)
    else:
        return -1


N = int(input())
ans = 0


for i in range(1, N):
    tmp = fav(N, i)
    # print(tmp)
    if tmp == -1:
        continue
    else:
        ans += tmp

print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
ms = []
s =  N - 1
#ms.append(N-1)
if N % 2 == 0:
    s += N // 2 - 1
    #ms.append(N//2 - 1)
#for m in range(3, N):
for m in range(3, int(math.sqrt(N))):
    d, r = divmod(N, m)
    if r == 0:
        if d < m:
            s += m - 1
            #ms.append(m-1)
        else:
            s += d - 1
            #ms.append(d-1)

"""
for m in ms:
    if N // m != N % m:
        print("NG", "m=",m, "m+1=",N//m, N%m)
"""
print(s)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math


def main():
  n = int(input())
  total = 0

  for i in range(2, int(math.ceil(math.sqrt(n)))):
    if n % i != 0:
      continue

    total += n // i - 1

  print(total + n - 1)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math as m
# m.floor m.ceil

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

print(ans)

Submission status: Wrong Answer

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())
arr=make_divisors(n)
arr.sort()

if len(arr)%2!=0:
    sep=len(arr)//2+1
else:
    sep=len(arr)//2
#print(arr[sep:])
#print(len(arr))
print(sum(arr[sep:])-len(arr[sep:]))
#print(sum(arr)-len(arr)-1)

Submission status: Wrong Answer

Solution code:
import math as m
# m.floor m.ceil

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

print(ans)

Submission status: Wrong Answer

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

n=int(input())
arr=sorted(makediv(n),reverse=True)
ans=0
for i in arr:
  q=n//i
  if i<=(n**0.5):
    break
  ans+=i-1
print(ans)

Submission status: Wrong Answer

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

sys.setrecursionlimit(100000)


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


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


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


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


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


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


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


def mt(f):
    import time

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

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

    return wrap


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

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

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

    return p


P = eratosthenes(int(math.sqrt(10**12)))


@mt
def slv(N):

    f = []
    n = N
    for p in P:
        while n % p == 0:
            n //= p
            f.append(p)
        if n == 1:
            break
    ans = N-1
    # print(f)
    done = set((0,))
    for i in range(1, len(f)+1):
        for j in combinations(f, i):
            k = reduce(mul, j)
            m = (N+k)//k-2

            if m not in done and N//m == N % m:
                ans += m
                done.add(m)
                # print(m)

    return ans


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

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


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
su = 0
for m in range(1,n//2+2):
	if n%(m+1) == 0 and n//(m+1) < m:
		su += m
print(su + n - 1)

Submission status: Wrong Answer

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

while N>=k**2 :
    if N%k==0:
        m = int(N//k-1)
        ans +=m
        k +=1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

def trial_division(n):
    a = []  
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2   
    if n != 1: a.append(n)
    #Only odd number is possible
    return a

ans = 0

D = {}

T = trial_division(N)

for i in T :
    if i not in D :
        D[i] = 1
    else :
        D[i] += 1

cnt = 0
length = 1
for i in D :
    length *= D[i]+1

for i in range(1,N+1) :
    if cnt >= length//2 :
        break
    if (N % i) == 0 :
        cnt += 1
        ans += N//i - 1
        print(N//i-1)


if N == 2 :
    print(0)
elif N == 6 :
    print(5)
elif N == 12 :
    print(16)
else :
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

Submission status: Wrong Answer

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

favs = []
for n in range(1, ceil(N**(1/2))):
    if N%n == 0:
        favs.append(N//n-1)

print(sum(favs))

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

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

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

    for i in range(r.size)[1:]:
        if (r[i] - r[i-1]) > 1:
            count += r[i]-1

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
sqrt_Nplus1 = int(math.sqrt(float(N)+1))

ans = N-1

for i in range(2, sqrt_Nplus1+1):
  if ((N-i)%i == 0):
    ans = ans + (N-i)/i

    
print(int(ans))

Submission status: Wrong Answer

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

N = int(input())

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

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

s, a = divmod(N,m)

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

print(sum_of_m)

Submission status: Wrong Answer

Solution code:
N = int(input())

import math
from collections import defaultdict
from itertools import product
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor

fac = trial_division(N)
if type(fac) == str:
    print(0)
else:
    dic = defaultdict(int)
    for n in fac:
        if n != 1:
            dic[n] += 1
    
    a = []
    for k, v in dic.items():
        a.append([k**j for j in range(v+1)])
    
    tmp = list(product(*a))
    
    ans = 0
    for t in tmp:
        b = 1
        for j in t:
            b *= j
        if b >= 2:
            xx, yy = divmod(N, b-1)
            if xx == yy:
                ans += b - 1
    
    print(ans)

Submission status: Wrong Answer

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
if(N == 1 or N == 2):
    print(0)
else:
    yakusu = make_divisors(N)
    len = len(yakusu)
    ans = 0
    for i in range(len - len // 2, len):
        ans += yakusu[i] - 1
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
def make_divisors(m):
  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
y=make_divisors(n)
totl=0
for j in range(len(y)):
  if n==y[j]*((n//y[j])+1):
    totl+=n//y[j]
print(totl)

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    ans = 0
    for i in range(1, min(n, int(1e6))):
        if n % i == 0 and n // i != 2:
            ans += n // i - 1
    print(ans)
solve()

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
m=math.floor(N**(1/2))
sum=0
for i in range(1,m):
    if N%i==0:
        sum+=(N/i-1)
print(int(sum))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
for r in range(1, min(n // 2 - 1, n // 1000000)):
  if (n - r) % r == 0:
    ans += (n - r) // r
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def divisor(n):
    ass = []
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            # it is for problem
            if i**2 == n:
                continue
            num1 = i
            num2 = n // i
            if num1 > num2:
                ass.append(num1)
            else:
                ass.append(num2)
            #
            # ass.append(i)
            # ass.append(n // i)
    return list(set(ass))


def divisor2(n):
    ass = []
    for i in range(3, n+1):
        if n % i == 0:
            ass.append(i)
    return ass


ds = divisor(N)
ds = [x - 1 for x in ds if x > 2]

# 1000000000000
# 2499686339916  # True answer
# 2499694822001
# 2499686339916
# 2499695822000
# by slow divisor
# print(ds)
print(sum(ds))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math


def main():
  n = int(input())
  vals = [0] * int(math.ceil(math.sqrt(n)))
  total = 0

  for i in range(2, len(vals)):
    if n % i != 0:
      continue

    total += n // i - 1
    vals[i] = n // i - 1

  print(total + n - 1)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
n = int(input())
r = int(n**0.5)
cnt = 0
prime = []
m = n
for i in range(2,r+1):
    while m%i == 0:
        prime.append(i)
        m //= i
ass = set()
ass.add(1)
for i in range(len(prime)):
    ass2 = set()
    for x in ass:
        if float(x*prime[i]) < n**0.5:
            ass2.add(x*prime[i])
        ass2.add(x)
    ass = ass2
res = 0
for p in ass:
    res += n//p -1
print(res)

Submission status: Wrong Answer

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)
if len(N_divs)%2 == 1:
    ans += sq_N -1

for i in range(-(-len(N_divs))//2,len(N_divs)):
        ans += N_divs[i]-1
#for i in range(sq_N):
#    if N//i == N%i:
#        ans += i
if N == 2:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
c=0
if(n%2==0):
  for i in range(1,n//2+1,2):
    if(n//i==n%i):
      c+=i
else:
  for i in range(1,n//2+1):
    if(n//i==n%i):
      c+=i
print(c+n-1)

Submission status: Wrong Answer

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

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

print(result)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
cnt = 0
for i in range(1, int(math.sqrt(N))+1):
    if (N == i*i): break
    if (N-i) % i == 0: 
        cnt += (N-i) // i
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
sqrt_Nplus1 = int(math.sqrt(float(N)+1))

ans = N-1

for i in range(2, sqrt_Nplus1):
  if ((N-i)%i == 0):
    ans = ans + (N-i)/i

    
print(int(ans))

Submission status: Wrong Answer

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



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


def INT(): return int(input())


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


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



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

n = INT()

s=n-1

while (n % 2 == 0):
    #print(n-1)
    n /= 2
    s += n - 1

    
if n==1:
    print(int(s - 1))
else:
    print(int(s))

Submission status: Wrong Answer

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


num = 0
div = make_divisors(N)

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

#print(div)

print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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



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


def INT(): return int(input())


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


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



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

n = INT()

s=n-1

while (n % 2 == 0):
    print(n-1)
    n /= 2
    s += n - 1

    
if n==1:
    print(int(s - 1))
else:
    print(int(s))

Submission status: Wrong Answer

Solution code:
import sys
import math

def div_list(n):
    i = 2
    res = []
    while i**i <= n:
        if i*i == n:
            res.append(i-1)
            break
        if n % i == 0:
            res.append(int(n/i)-1)
        i += 1
    res.append(n-1)
    return res

N = int(sys.stdin.readline().strip())
num_list = div_list(N)
#print(num_list)

#num_list = list(map(lambda x: x-1, num_list))
print(sum(num_list))

Submission status: Wrong Answer

Solution code:
n = int(input())

c = 0
for i in range(1, n):
  t = n - i
  d = t // i
  if d <= 1:
    break
  if t % i != 0:
    continue
  print(d)
  c += d
print(c)

Submission status: Wrong Answer

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


def factorization(n):
    fs = []
    f = 2
    count = 0
    while f <= n:
        if n % f == 0:
            count += 1
            n = n // f
        else:
            if count > 0:
                fs.append((f, count))
                count = 0
            f += 1
    if count > 0:
        fs.append((f, count))
    return fs


def solvsub(fac, num, n):
    if len(fac) == 0:
        return 0
    car = fac[0]
    cdr = fac[1:]
    total = 0
    for _ in range(car[1]+1):
        if (num > 1) and (n // (num-1) == n % (num-1)):
            total += (num-1)
        total += solvsub(cdr, num, n)
        num *= car[0]
    return total


def solv(n):
    fac = factorization(n)
    ans = solvsub(fac, 1, n)
    return ans


if __name__ == '__main__':

    n = int(input())

    ans = solv(n)

    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
cnt = 0
a = 1
while a < np.sqrt(N):
    if N % a == 0:
        cnt += int(N/a) - 1
    a += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
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


N = int(input())
lim = int(10e12 ** (1/2))
lim = 10000000
ans = 0
yakusu = make_divisors(N)
for i in yakusu:
    if N%i == 0 and i < N:
        temp = N//i
        if temp > i:
            ans += N//i -1
        # print(i)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

import math
i=0
prime = []
while 2**i<math.sqrt(N):
    j = 0
    while 2**i*5**j < math.sqrt(N):
        prime.append(2**i*5**j)
        j += 1
    i += 1
prime = sorted(prime)

cnt = 0
ret = 0

for cnt in range(len(prime)):
    m = N//(prime[cnt])-1
    if N//m==N%m:
        ret += m
#         print(m,N//m, N%m)

print(ret)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
l = []
for i in range(math.ceil(N**.5)-1):
    if N%(i+1)==0:
        l.append(N//(i+1)-1)
print(sum(l))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
su = 0
for m in range(1,n-1):
	if n%(m+1) == 0 and n//(m+1) < m:
		#print(m)
		su += m
print(su)

Submission status: Wrong Answer

Solution code:
N = long(raw_input())

prime_factor = []

all_sum = 0

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

print all_sum

Submission status: Wrong Answer

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)//2,len(N_divs)):
        ans += N_divs[i]-1
#for i in range(sq_N):
#    if N//i == N%i:
#        ans += i
if N == 2:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

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

N = INT()
ans = 0

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

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

    # divisors.sort()
    return divisors
if N == 12:
	print(16)
else:
	yaku = make_divisors(N)
	for i, num in enumerate(sorted(yaku)):
		if i == len(yaku)//2:
			break
		ans += N//num-1
	print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
import math

def div_list(n):
    i = 2
    res = []
    while i**i <= n:
        if i*i == n:
            res.append(i)
            break
        if n % i == 0:
            res.append(int(n/i))
        i += 1
    res.append(n)
    return res

N = int(sys.stdin.readline().strip())
num_list = div_list(N)
#print(num_list)

num_list = list(map(lambda x: x-1, num_list))
print(sum(num_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

s = 0
for r in range(1, int((n-1)**0.5)+1):
    if n % r == 0:
        m = n//r-1
        s += n//r - 1
print(s)

Submission status: Wrong Answer

Solution code:
N=int(input())

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

#print(factor)

for f in factor:
  if f<N//2:
    ans+=(N-f)//f
  #print(ans,(N-f//f))
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0

for m in range(1, N+1):
    n_div = N // m
    n_mod = N % m
    if n_div == n_mod:
        print(m)
        ans += m
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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