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:
# 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)
    if ((n - i_fav) // i_fav) == ((n - i_fav) / i_fav):
        return (n - i_fav) // i_fav
    else:
        return -1


N = int(input())
ans = 0


for i in range(1, 1000000):
    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())

x = math.floor(math.sqrt(n))

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

if n / math.sqrt(n) == math.sqrt(n):
    print(int(ans - math.sqrt(n)) + 1)
else:
    print(int(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 += N//i -1
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
k = 2
ans = 0
while True:
    if N % k == 0:
        k += 1
        continue
    for i in range(N):
        if N == (k * i + i):
            ans += k
        if N < (k * i + i):
            break
    k += 1
    if k > N :
        break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = [m for m in range(2, int(n/2)) if n // m == n % m]
print(sum(ans)+ n-1)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

i = 2
N_ = N
ans = 0

divisor = {}
for i in range(2,N):
    if N_ % i == 0:
        divisor[i] = 0
        while(N_ % i == 0):
            divisor[i] += 1
            N_  //= i
#            print(N_,i)
    if i *i  > N_:
        break

ans += 0
def solve(dic,keys,n,i):
    if i == len(keys):
 #       print(n)
        if n-1 != 0 and N == (N % (n-1))*n:
            global ans
            ans += n-1

    else:
        for j in range(dic[keys[i]]+1):
            solve(dic,keys,n*keys[i]**j,i+1)

#print(divisor)
ans = 0 
solve(divisor,list(divisor.keys()),1,0)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import itertools
from functools import reduce
N = int(input())
copyN = N
sqrtN = int(math.sqrt(N))
fac = []
for i in range(2, sqrtN+1):
    while copyN != 1:
        if copyN % i == 0:
            copyN //= i
            fac.append(i)
        else:
            break
    if copyN == 1:
        break
ans = 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:
            ans += div
print(ans)

Submission status: Wrong Answer

Solution code:
pf={}
m=int(input())
n=m
for i in range(2,int(n**0.5)+1):
    while n%i==0:
        pf[i]=pf.get(i,0)+1
        n//=i
if n>1:
    pf[n]=1
#print(pf)
summ=1
count=1
a=0
error=0
for j in range(2,int(m**0.5)+1):
    #print('A')
    a=pf.get(j,0)
    #print(j)
    if(a>0):
        count=count*(a+1)
        summ=summ*((j**(a+1)-1)/(j-1))

for i in range(2,int(m**0.5)+1):
    if m%i==0 and i*(i-1)<m:
        #print('A')
        error+=i
        count-=1
#print(error)
print(int(summ-count-error))

Submission status: Wrong Answer

Solution code:
a = int(input())
x = 0
last = 0
p = list(range(int(a**0.5)+1))
ok = 0
p.pop(0)

for i in p:
    if a % i == 0:
        ok += 1
        last = i
if a / last - last < 2:
    x = 1

print(ok-x)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/diverta2019/tasks/diverta2019_d

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


num = 0
div = make_divisors(N)

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

print(num)

Submission status: Wrong Answer

Solution code:
import math
import sys
input = sys.stdin.readline
N = int(input())


max_n = int(math.sqrt(N)-1e-6)
ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

s = 0
m = 1
while True:
    n = N - m
    x = n//m
    if n % m == 0:
        s += x
    m += 1
    if m >= x:
        break

print(s)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
sqrt_N = int(math.sqrt(float(N)))

ans = N-1

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
sqrt_N = int(math.sqrt(float(N)))

ans = N-1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline

N = int(readline())

sqrtN = int(N ** 0.5)

i = 1
total = 0
while True:
    if N % i == 0:
        if i < (N / i) - 1:
            total += N / i - 1
        else:
            break
    i += 1

print(total)

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

Submission status: Wrong Answer

Solution code:
import math
import itertools
from functools import reduce
N = int(input())
copyN = N
sqrtN = int(math.sqrt(N))
fac = []
for i in range(2, sqrtN+1):
    while copyN != 1:
        if copyN % i == 0:
            copyN //= i
            fac.append(i)
        else:
            break
    if copyN == 1:
        break

ans = 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:
            ans += div
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
m=math.ceil(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())

sum = 0

b = 0
for i in range(1,N):
    N2 = int(N/i)
    if N2 == 1:
        break
    if int(N/(N2-1)) != i:
        b += 1
        if b > 25000:
            break
    else:
        if N%(N2-1) == i:
            sum += N2-1

print(sum)

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 x*prime[i] < r+1:
            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:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
def main():
	#R, G, B, N = map(int, input().split(" "))
	N = int(input())

	if N <= 2:
		print(0)
		sys.exit()

	ansans = N - 1
	if N < 8:
		print(ansans)
		sys.exit()

	flg = True
	if N % 2 != 0:
		flg = False
		
	ans = 0
	for i in range(N+1):
		if i == 0:
			continue
		if N // i == N % i:
			print(i)
			ans += i
	
	print(ans)
		



	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

N = int(input())

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import sqrt 

n = int(input())

x = int(sqrt(n))
ans = n-1
for i in range(2, x):
    y = dt = n//i
    while n//dt == n//y and n%y <= n//y:
        if n//y == n%y:
            ans += y
            break
        y -= 1
        if y == 1:
            break
        # print x,y,ans
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0

for m in range(3,N+1):
    if(N%m==0):
            if(N%(m-1)>0):
                    ans += m-1

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:
  c=0
print(c+n-1)

Submission status: Wrong Answer

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


def yakusuu(num):
    l = []
    for i in range(1, math.ceil(math.sqrt(num))):
        if num % i == 0:
            l.append(i)
    return l


sum = 0
for yak in yakusuu(n):
    sum += n / yak - 1

print(int(sum))

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

m_total = 0
l = make_divisors(n)

for x in l:
    m_plus1 = n//x
    if x < m_plus1:
        m_total += m_plus1 - 1

print(m_total)

Submission status: Wrong Answer

Solution code:
import math

n=int(input())
sum=0
for x in range(1,10**6):
    if n%x==0:
        sum+=(n//x)-1
print(sum)

Submission status: Wrong Answer

Solution code:
import sys
def sample_code():
    n = int(input())
    if n == 1 or n == 2:
        print(0)
        sys.exit(0)
    # print('# 素因数')
    fct = factorize(n)
    # print(fct, num(fct))
    answer = 0
    # print('# 約数')
    for div in divisorize(fct):
        if num(div) > n//num(div):
            answer += num(div) - 1
    print(answer)


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    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 = []  # prime factor
    b, e = 2, 0  # base, exponent
    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
    return a


if __name__ == '__main__':
    sample_code()

Submission status: Wrong Answer

Solution code:
from math import sqrt 

n = int(input())

x = int(sqrt(n)+1)
ans = n-1
for i in range(2, x):
    y = dt = n//i
    while n//dt == n//y and n%y <= n//y:
        if n//y == n%y:
            ans += y
            break
        y -= 1
        if y == 1:
            break
        # print x,y,ans
print(ans)

Submission status: Wrong Answer

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

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

print(result)

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	sqrt_n = int(N**0.5)
	ans = 0
	for i in range(1, sqrt_n+1):
		mod = N % i
		if mod == 0 and i != N//i:
			ans += max(i, N//i) - 1

	print(ans)


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
#D
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
div = sorted(make_divisors(N))[::-1]
if len(div) % 2 == 0:
    div =  div[:int(len(div)/2)]
else:
    div = div[:len(div)//2]
print(sum(div)-len(div)) if N != 2 else print(0)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(raw_input())
    ret = 0
    for i in range(2, int(N**0.5 + 1)):
        if N % i == 0:
            inv_i = N//i
            if N % (inv_i - 1) == N / (inv_i - 1):
                ret += inv_i - 1
    ret += N -1
    print str(ret)

if __name__ == '__main__':
    solve()

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 and i != (n // i + 1) :
                divisors.append(n//i - 1)
    return divisors

n = int(input())
print(sum(make_divisors(n)))

Submission status: Wrong Answer

Solution code:
n = int(input())

sum = 0
for i in range(1, int(n**0.5) + 1):
    if n == 1:
        break
    if n % i == 0 and i != n // i:
        sum = sum + n // i - 1

print(sum)

Submission status: Wrong Answer

Solution code:
import math

n=int(input())
sum=0
y=((1+4*n)**(1/2)-1)/2
z=math.floor(y)
print(z)

for x in range(1,z+1):
    if n%x==0:
        m=(n//x)-1
        if x<m:
            sum+=(n//x)-1
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def zzz(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

x=int(input())
list=zzz(x)
kotae=0
for l in list:
    if l>=2:
        if x%(l-1)!=0:
            kotae+=(l-1)
print(kotae)

Submission status: Wrong Answer

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

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

print(result)

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
for i in range(1,sqrtN+1):
  if N%i == 0:
    ans += N//i -1
    
print(ans)

Submission status: Wrong Answer

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

x = math.floor(math.sqrt(n))
ans = 0
for i in range(x):
    if n % (i+1) == 0:
        a = n / (i+1)
        if (a-1) * (i+1) + (i+1) == n:
            ans += a-1

print(int(ans))

Submission status: Wrong Answer

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

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

print(result)

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)

    divisors.sort()
    return divisors

N =int(input())

div = make_divisors(N)
L = len(div)

if L % 2 == 0:
    print(sum(div[L//2:])-L//2)
else:
    print(sum(div[L//2+1:])-L//2)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

n = int(input())

output = 0
# n = (m+1)*x = y*x (y>=2)
for x in range(1, int(pow(n, 0.5))):
    if n % x == 0:
        output += n // x - 1

print(output)

Submission status: Wrong Answer

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

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

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:
import math

n = int(input())

###商及び余りをsとすると、n=m*s+s=s(m+1)、ただし0<s<m
sum_fav = 0
for s in range(1,int(math.sqrt(n))):
  if n%s == 0:
    m = n//s-1
    if s < m:
      #print(m)
      sum_fav += m
    else:
      break
  
print(sum_fav)

Submission status: Wrong Answer

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

import numpy as np

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())
if N == 1 or N == 2:
    print("0")
    sys.exit()

N_divisors = make_divisors(N)

N_length = len(N_divisors)
N_length_half = N_length // 2
N_length_mod = N_length % 2

N_length_half_temp = 0

if N_length_mod == 1:
    N_length_half_temp = N_length_half + 1
else:
    N_length_half_temp = N_length_half

print(sum(N_divisors[N_length_half_temp:]) - (N_length - N_length_half_temp))

Submission status: Wrong Answer

Solution code:
from math import sqrt 

n = int(raw_input())

x = int(sqrt(n)+1)
ans = n-1
for i in xrange(2, x):
    y = dt = n/i
    while n/dt == n/y and n%y <= n/y:
        if n/y == n%y:
            ans += y
            break
        y -= 1
        if y == 1:
            break
        # print x,y,ans
print ans

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0

for m in range(3,N+1):
    if(N%m==0 and N%(m-1)>0):
        ans += m-1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


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

    divisors.sort()
    return divisors


def solve():
    N = ii()
    ans = 0
    divisors = make_divisors(N)
    print(divisors)
    sqrt_n = N ** 0.5
    for m in divisors:
        if m == 1 or m - 1 < sqrt_n:
            continue
        ans += m - 1
    return ans


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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())
x = 0
p = list(range(int(a**0.5)+1))
ok = 0
p.pop(0)

for i in p:
    if a % i == 0:
        ok += 1
if a**0.5 == int(a**0.5):
    x = 1
print(ok*2-1-x)

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)

    # divisors.sort()
    return divisors


n = int(input())
# N = some * fav + some
# 1 ... n-1
# 2 ... n/2 - 1　整数の場合
# 3 ... n/3 - 1　整数の場合

sum_val = 0
divisor_list = make_divisors(n)

# print(divisor_list)
for divisor in divisor_list:
    quot = n // divisor
    if quot < divisor:
        diff = (n - quot) // quot
        if diff != 1:
            sum_val = sum_val + (n - quot) // quot
print(sum_val)

Submission status: Wrong Answer

Solution code:
N=int(input())

sum_m=0

for a in range(1,int(N/2)):
    if (N-a)%a==0:
        sum_m+=int((N-a)/a)
print(sum_m)

Submission status: Wrong Answer

Solution code:


def main():
    n = input()
    if n <= 2:
        print 0
        return
    s = 0
    i = 1
    while i * i < n:
        if n % i == 0:
            s += n // i - 1
        i += 1
    print s


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())


def divisor(n):
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass

ds = divisor(N)
# print(ds)

ds = [x - 1 for x in ds if x > 2]

# 1000000000000
# 2499686339916  # True answer
# 2499694822001
# 2499686339916
# print(ds)
print(sum(ds))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
cnt = 0
for i in range(1, int(np.ceil(round(np.sqrt(N),1)))):
    if (N-i)%i ==0:
        cnt += int((N-i)/i)
print(cnt)

Submission status: Wrong Answer

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

ans = N - 1

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

cond = []
for i in range(1, N):
    if i*i >= N:
        break
    if N % i == 0:
         cond.append((i, N//i))
# print(cond)

ans = set()
for a,b in cond:
    m = a+1
    if N//m == N%m:
        ans.add(m)
    m = b+1
    if N//m == N%m:
        ans.add(m)

    x = a
    if N%x == 0 and N//x > 1 and x < N//x:
        ans.add(N//x - 1)
    x = b
    if N%x == 0 and N//x > 1 and x < N//x:
        ans.add(N//x - 1)
    # print(a,b,ans)
# print(ans)
a = sum(list(ans))
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())

sum = 0
N2c = 0
for i in range(1,N):
    N2 = int(N/i)
    if int(N/(N2-1)) == i:
        if N%(N2-1) == i:
            sum += N2-1
    else:
        break

print(sum)

Submission status: Wrong Answer

Solution code:
n=int(input())
c=0
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:
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())
A=sorted(make_divisors(N))
b=[]
for i in range(1,len(A)):
    if A[i]-1!=A[i-1]:
        b.append(A[i]-1)
    else:
        pass
ans=sum(b)
print(ans)

Submission status: Wrong Answer

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

max_m = max(math.ceil(math.sqrt(N) - 1), 1)

count = 0
for i in range(1, max_m+1):
  if (N - i) % i == 0:
    count += (N - i) // i
print(count)

Submission status: Wrong Answer

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

    # divisors.sort()
    return divisors

n = int(input())
div = make_divisors(n)
ans = 0
for i in range(len(div)): #約数列挙
    if div[i] < math.sqrt(n):
        ans += (n//div[i])-1
print(ans)

Submission status: Wrong Answer

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

import math

n = ni()
a = 0
b = math.ceil(math.sqrt(n))

for i in range(1,b):
    if n%i == 0:
        c = n//i-1
        a = 0 if c == i else a+c

print(a)

Submission status: Wrong Answer

Solution code:
import math

n=int(input())
sum=0
y=((1+4*n)**(1/2)-1)/2
z=math.floor(y)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
if N%2 == 1:
    print(N-1)
    exit()

ans = N-1
p = N//2
q = N-1
while True:
    print(q)
    ans = ans + q-p
    q = q-p
    if q == 1:
        print(int(ans-1))
        exit()
    p /= 2
    if p%2:
        print(int(ans+q-p))
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())

sqrt_N = N**0.5

list_D=[]
list_A=[]

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

for d in list_D:
    list_A.append(N//d-1)

if N==1 or N==2:
    print()
else:
    print(sum(list_A))

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
N = int(input())
m_list = []
for p in range(1, math.floor(-0.5+math.sqrt((1+4*N))/2)+1):
   if N % p == 0:
       m = N//p -1
       m_list.append(m)
print(int(np.sum(m_list)))

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

a = make_divisors(n)
a = a[len(a)//2:]
if n//a[0] == a[0]:
     a = a[1:]
print(sum(a)-len(a))

Submission status: Wrong Answer

Solution code:
# for i in range(1,101):
#   for j in range(1,i):
#     a=i//j
#     b=i%j
#     if a==b:
#       print(str(i)+'を'+str(j)+'で割った商は'+str(a)+'、余りは'+str(b))

n=int(input())
if n==2:
  print(0)
  exit()
elif n==6:
  print(5)
  exit()
c=0
for i in range(1,n):
  x=(n-i)%i
  y=(n-i)//i
  if y<i:
    break
  if x==0:
    c+=y
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
# 素数リスト生成
def sieve(x):
    if x < 2: return []
    primes = [i for i in range(x)]
    primes[1] = 0
    for p in primes:
        if p > x ** (1/2): break
        if p == 0: continue
        for np in range(2 * p, x, p): primes[np] = 0
    return [p for p in primes if p != 0]

PS = sieve(10**1)

# 素因数分解
def factorint(x):
  d = {}
  for k in PS:
    if(x % k== 0):
      m = 1
      while(x % (k**m) == 0):
        m += 1
      d[k] = m - 1
      x = x / (k ** (m - 1))
      if x == 1:
        break
  return d

f = factorint(n)
# 10^6より大きい素因数があったときの処理
re = 1
for k, v in f.items():
  re *= k**v
if n // re != 1:
  f[n // re] = 1

# print(f)
s = 1
num = 1
for k, v in f.items():
  s *= (k ** (v + 1) - 1) // (k - 1)
  num *= (v + 1)
loss = 0
for i in range(1, int((-1 + (1 + 4 * n) ** (1/2)) / 2) + 1):
  if n % (i + 1) == 0:
    loss += i
print(s - num - loss)