Problem:


Score : 200 points

Problem Statement

Takahashi has two positive integers A and B.

It is known that A plus B equals N.
Find the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B" (in base 10).

Constraints

2 ≤ N ≤ 10^5

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B".

Sample Input 1

15

Sample Output 1

6

When A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.

Sample Input 2

100000

Sample Output 2

10



Sample input:
15


Sample output:
6

Submission status: Accepted

Solution code:
a=input()
if int(a)%10==0:
    print(10)
else:
    print(sum(list(map(int,list(a)))))

Submission status: Accepted

Solution code:
N = int(input())

# 各桁の和
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

min_sum = 1000000
for i in range(N - 1):
    A = i + 1
    B = N - A
    tmp = digitSum(A) + digitSum(B)
    if tmp < min_sum:
        min_sum = tmp

ans = min_sum
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=2148483647
for i in range(1,n):
    a,b=i,n-i
    t=0
    for j in range(len(str(a))):
        t+=int(str(a)[j])
    for j in range(len(str(b))):
        t+=int(str(b)[j])
    if t<ans:
        ans=t
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
while n % 10 == 0 and n != 10:
    n //= 10
if n % 10:
    print(sum(list(map(int, list(str(n))))))
else:
    print(10)

Submission status: Accepted

Solution code:
import math

n = int(input())
index=1
minS=10**5
while index < n//2+1:
    a = str(index)
    b = str(n-index)
    listA= list(a)
    listB= list(b)
    sum =0
    index2 =0
    while index2 < len(listA):
        sum+=int(listA[index2])
        index2+=1
    index3 =0
    while index3 < len(listB):
        sum+=int(listB[index3])
        index3+=1
    if sum < minS:
        minS = sum
    index+=1
print(minS)

Submission status: Accepted

Solution code:
N=int(input())
a=1
ls=[]
while a<N:
    b=list(str(N-a))
    sum=0
    for i in range(len(b)):
        sum+=int(b[i])
    ls.append(sum+1)
    a*=10
print(min(ls))

Submission status: Accepted

Solution code:
n = int(input())
if n%10 == 0:
    print(10)
else:
    nums = list(map(int,[x for x in str(n)]))
    print(sum(nums))

Submission status: Accepted

Solution code:
N = int(input())

if N%10 == 0:
    print(10)
else:
    sumN = map(int, list(str(N)))
    print(sum(sumN))

Submission status: Accepted

Solution code:
n=input()
l=[10,100,1000,10000,100000]
if int(n) in l:print(10)
else:
  L=list(n)
  c=0
  for i in range(len(L)):
    c+=int(L[i])
  print(c)

Submission status: Accepted

Solution code:
N = int(input())
r = float("inf")
for i in range(1, N):
    A = i
    B = N - i
    a = 0
    b = 0

    while A >= 1:
        a += A % 10
        A /= 10

    while B >= 1:
        b += B % 10
        B /= 10

    if a + b <= r:
        r = a + b

print(int(r))

Submission status: Accepted

Solution code:
N = int(input())

def digit_sum(x):
  num = x
  total = 0
  while num > 0:
    total += num%10
    num //= 10
  return(total)

total_list = []
for i in range(1, N):
  A, B = i, N - i
  total_list.append(sum([digit_sum(i) for i in [A, B]]))
print(min(total_list))

Submission status: Accepted

Solution code:
def digit_sum(x):
    sum = 0
    while x :
        sum += x % 10
        x = int(x / 10)
    return sum

N = int(input())
l = [ digit_sum(x) for x in range(1, N+1)]

sum_a_b = []
if N % 2 == 0:
    sum_a_b.append(l[int(N/2)-1]*2)

for i in range(1, int(N/2)):
    sum_a_b.append(l[i-1] + l[N-i-1])

print(min(sum_a_b))

Submission status: Accepted

Solution code:
def sumOfDegits(n, p=10): #p進法での各位の和
	sum = 0
	while n > 0:
		sum += n % 10
		n //= 10
	return sum

n = int(input())

smallest = 9999999999
for i in range(1,n//2+1):
	a = i
	b = n - i
	if sumOfDegits(a) + sumOfDegits(b) < smallest:
		smallest = sumOfDegits(a) + sumOfDegits(b)
print(smallest)

Submission status: Accepted

Solution code:
n=int(input())
c=10**18
for a in range(1,n):
    b=n-a
    c=min(c,sum(map(int,str(a)))+sum(map(int,str(b))))
print(c)

Submission status: Accepted

Solution code:
n = list(map(int, list(input())))
if sum(n) == 1:
    print(10)
else:
    print(sum(n))

Submission status: Accepted

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

def main():
    n = int(input())
    ans = float('inf')
    for a in range(1, n):
        b = n - a
        ans = min(ans, sum(map(int, list(str(a)))) + sum(map(int, list(str(b)))))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = str(input())
len = len(n)
list = list(n)
ans = 0
if len == 1:
  ans = int(n)
elif n.count("0") != len - 1:
  for element in list:
    ans += int(element)
else:
  ans = 10
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())

def dsum(x):
    return sum(map(int,list(str(x))))

ans = INF
for a in range(1,N):
    b = N-a
    ans = min(ans,dsum(a)+dsum(b))

print(ans)

Submission status: Accepted

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


string = list(input())
line=[]

for i in range(len(string)):
    if string[i]!="0":
        line.append(string[i])
        

num = int(''.join(line))
Sum = 0

if num==1:
    print("10")
else:
    for i in range(len(line)):
        Sum += int(line[i])
    print(Sum)

Submission status: Accepted

Solution code:
N = int(input())
if N % 10 == 0:
     print(10)
else:
    a = [int(x) for x in str(N)]
    print(sum(a))

Submission status: Accepted

Solution code:
n = int(input())
if n % 10 == 0:
    print(10)
else:
    str_n = str(n)
    res = 0
    for i in range(len(str_n)):
        res += int(str_n[i])
    print(res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

in_strings = lambda: stdin.readline()[:-1] # s = in_strings()
in_int = lambda: int(stdin.readline()) # N = in_int()
in_intlist = lambda: list(map(int, stdin.readline().split())) # List = in_intlist()

N = in_int()

def OrderSum(x):
    res = 0
    while (x//10) > 0:
        res += x % 10
        x = x // 10
    res += x % 10
    return res

ans = 10**3
for i in range(1, N//2 + 1):
    temp = OrderSum(i) + OrderSum(N-i)
    if ans > temp:
        ans = temp
print(ans)

Submission status: Accepted

Solution code:
n = input()

m = len(n)
f = 0
ans = 0

for i in range(m):
    ans += int(n[i])
    
    
if m>1 and n[0] == '1':
    if n[1] == '0':
        ans += 9
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = float("inf")
for i in range(1, n // 2 + 1):
    a = i
    b = n - i
    ans = min(ans, sum(map(int, str(a))) + sum(map(int, str(b))))
print(ans)

Submission status: Accepted

Solution code:
def digit(n):
    ans=0
    for i in n:
        ans += int(i)
    return ans
    
def iszero(n):
    if n[0]!='1': return False
    for i in n[1:]:
        if i!='0': return False
    return True
    
N=input()

if iszero(N):
    ans = 10
else:
    ans = digit(N)
    
print(ans)

Submission status: Accepted

Solution code:
# coding:utf-8

INF = float('inf')


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


def sum_digit(n):
    return sum(list(map(int, list(str(n)))))


N = int(input())

ans = INF
for i in range(1, N // 2 + 1):
    ans = min(ans, sum_digit(i) + sum_digit(N - i))

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = []
flag = True
k = str(N)
if (N == 10**(len(k)-1)):
  flag = True    
else:
  flag = False
if flag:
  print('10')
else:
  for i in range(len(k)):
    L.append(int(k[i]))
  print(sum(L))

Submission status: Accepted

Solution code:
N = int(input())
# N = int('15')
cand = []
def func(a):
    return sum([int(i) for i in str(a)])
for i in range(1, N//2 + 1):
    a = i
    b = N - i
    cand.append(func(a) + func(b))
print(min(cand))

Submission status: Accepted

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

if log(n, 10) % 1 == 0:
    ans = 10
else:
    ans = sum(map(int, list(str(n))))
print(ans)

Submission status: Accepted

Solution code:
def d_sum(x):
    res = 0
    while x > 0:
        res += x % 10
        x //= 10
    return res

n = int(input())

ans = float('inf')
for a in range(1, n // 2 + 1):
    b = n - a
    ans = min(ans, d_sum(a) + d_sum(b))

print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    min_s = sys.maxint
    for i in range(1, N):
        A = str(i)
        A = A.zfill(6)
        B = str(N - i)
        B = B.zfill(6)
        s = 0
        for j in range(6):
            s += int(A[j]) + int(B[j])
        min_s = min(s, min_s)

    print min_s
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
f = lambda x: sum(map(int, str(x)))
N = int(input())
print(min(f(i) + f(N - i) for i in range(1, N // 2 + 1)))

Submission status: Accepted

Solution code:
def digitSum(num):
    s = str(num)
    res = 0
    for c in s:
        res += int(c)
    return res

n = int(input())
r = float('inf')
for i in range(1,n):
    j = n - i
    r = min(r,digitSum(i)+digitSum(j))
print(r)

Submission status: Accepted

Solution code:
n,ans = input(),0
for i in range(len(n)):
    ans += int(n[i])
if ans == 1:
    print("10")
else:
    print(ans)

Submission status: Accepted

Solution code:
def calc_dig_sum(x):
    ret = 0
    while x > 0:
        ret += x % 10
        x //= 10
    return ret


N = int(input())
ans = 10 ** 18
for i in range(1, N):
    A = i
    B = N - A
    if A > B:
        break
    ans = min(ans, calc_dig_sum(A)+calc_dig_sum(B))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
f=lambda x:sum(map(int,str(x)))
v=1e9
for i in range(1,n//2+1):
  a=i
  b=n-i
  v=min(v,f(a)+f(b))
print(v)

Submission status: Accepted

Solution code:
from numpy import inf
n=int(input())
ans=inf
for i in range(n-1):
    ans=min(ans,sum(list(map(int, list(str(n-i-1)))))+sum(list(map(int, list(str(i+1))))))
print(ans)

Submission status: Accepted

Solution code:
def count(n):
    cnt = 0
    for i in str(n):
        cnt += int(i)
    return cnt

n = int(input())
if n % 10 == 0:
    print(count(n//2)*2)
else:
    print(count(n))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
ans = float('inf')
for a in range(1, n):
    b = n - a
    ans = min(ans, sum(map(int, str(a))) + sum(map(int, str(b))))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ANS = []
for i in range(N) :
    if i != 0 and i != N :
        a = str(i)
        b = str(N-i)
        L = []
        K = []
        for j in range(len(a)) :
            c = int(a[j])
            L.append(c)
        for k in range(len(b)) :
            d = int(b[k])
            K.append(d)
        ans = sum(L)+sum(K)
        ANS.append(ans)
print(min(ANS))

Submission status: Accepted

Solution code:
def getinputdata():

    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

cnt=1

mindata = float('inf') 

while cnt<n:
    
    mysum=0
    
    for v in str(cnt):
        
        mysum+=int(v)
        
    for v in str(n-cnt):
        
        mysum+=int(v)
    
    
    mindata=min(mindata,mysum)
    
    cnt+=1
    
    
print(mindata)

Submission status: Accepted

Solution code:
n = int(input())
def sum(X):
	c = 0
	while(X>0):
		c += X%10
		X//=10
	return c
ans = (1<<30)
for i in range(1, n):
	ans = min(ans, sum(i) + sum(n-i))
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
min = float("inf")
m = int(n/2 + 1)
for i in range(1,m):
    a = np.array([int(j) for j in list(str(i))])
    b = np.array([int(j) for j in list(str(n-i))])
    tmp = np.sum(a) + np.sum(b)
    if(tmp < min):
        min = tmp

print(min)

Submission status: Accepted

Solution code:
a=sum(int(i)for i in input());print([a,10][a<2])

Submission status: Accepted

Solution code:
#coding: utf-8

from math import log10

def getLS(N):
    small = N//2
    large = N//2 + N%2
    return large, small

def getDigit(num):
    n_sum = 0
    for i in range(int(log10(num))+1):
        n_sum += num % 10
        num //= 10
    return n_sum

def getDigitSum(n1, n2):
    return getDigit(n1) + getDigit(n2)

def main(N):
    n_min = pow(10, 5)
    large, small = getLS(N)
    while small >= 1:
        tmp = getDigitSum(large, small)
        if n_min > tmp:
            n_min = tmp
        large += 1
        small -= 1
    return n_min

if __name__ == "__main__":
    N = int(input())
    print(main(N))

Submission status: Accepted

Solution code:
n = int(input())

def digitsum(x):
	tmp = x
	ans = 0
	while tmp > 0:
		ans += tmp % 10
		tmp /= 10

	return ans

ans = float("inf")
for i in range(1,(n/2)+1):
	ans = min(ans,digitsum(i) + digitsum(n-i))

print ans

Submission status: Accepted

Solution code:
def func(x):
    if x // 10 == 0:
        return x
    else:
        return x % 10 + func(x // 10)

n = int(input())
ans = float('inf')
for a in range(1, (n // 2) + 1):
    ans = min(ans, func(a) + func(n - a))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = 1
maxx = 9999999999
while a < N:
  su = 0
  A = str(a)+str(N-a)
  for charas in A:
    su += int(charas)
  maxx = min(maxx,su)
  a += 1
print(maxx)

Submission status: Accepted

Solution code:
N = int(input())
ans = 100001
for A in range(1, N):
    B = str(N - A)
    A = str(A)
    ttl = sum(list(int(digit) for digit in A))
    ttl += sum(list(int(digit) for digit in B))
    ans = min(ans, ttl)
print(ans)

Submission status: Accepted

Solution code:
def count(n):
    return sum(map(lambda x: int(x), str(n)))


N = int(input())
ret = float('inf')
for i in range(1, N + 1):
    A = i
    B = N - i
    if A > B:
        break

    ret = min(ret, count(A) + count(B))

print(ret)

Submission status: Accepted

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

min=-1
#最大値=N/2
for a in range(1, int(N/2)+1):
	b=N-a
	#各位の和は・・・
	sum=0
	for i in range(5):
		sum+=a%10
		sum+=b%10
		a=int(a/10)
		b=int(b/10)
	
	if min==-1 or min>sum:
		min=sum

print(min)

Submission status: Accepted

Solution code:
n = int(input())

def digitsum(a):
    s = 0
    while True:
        if a <= 0:
            break
        s += a % 10
        a //= 10
    return s

min = 1e6

for a in range(1, (n + 1) - 1):
    b = n - a
    s = digitsum(a) + digitsum(b)
    if s < min:
        min = s

print(min)

Submission status: Accepted

Solution code:
ans=sum(list(map(int,input())))
if ans==1:
	ans=10
print(ans)

Submission status: Accepted

Solution code:
import math


def run(n):
    ret = 0
    if n == 1:
        return n
    while True:
        ret += n % 10
        n = math.floor(n / 10)
        if n == 0:
            if ret == 1:
                return 10
            else:
                return ret


def read_line():
    n, = input().split()
    n = int(n)
    return n


def main():
    n = read_line()
    print(run(n))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = []
for i in range(N - 1):
	a = list(str(i + 1))
	b = list(str(N - i - 1))
	asum = sum(list(map(int, a)))
	bsum = sum(list(map(int, b)))
	
	L.append(asum + bsum)
print(min(L))

Submission status: Accepted

Solution code:
n=int(input())
def a(a):
    return a//100000 + (a//10000)%10+(a//1000)%10 + (a//100)%10 + (a//10)%10 + a%10
b=[]

if n == 100000:
    print(10)
else:    
    for i in range(1,n//2 +1):
        b.append(a(i)+a(n-i))
    print(min(b))

Submission status: Accepted

Solution code:
N = input()
zero_flag = False
one_flag = False
for i in N[::-1]:
    if i == "0" :
        zero_flag = True
    elif i == "1" and zero_flag:
        one_flag = True
        break
    else:
        break
ans = sum([ int(i) for i in N])
if one_flag:
    ans += 9
print(ans)

Submission status: Accepted

Solution code:
def Digitsum(n):
    sum = 0
    while(n > 0):
        sum += (n % 10)
        n = int(n / 10)
    return sum

N = int(input())
n = N
ans = 0
while(True):
    if (n % 10 >= 2):
        #10のべき乗ではない
        ans = Digitsum(N)
        break
    elif (n % 10 == 1 and n >= 10):
        #10のべき乗ではない
        ans = Digitsum(N)
        break
    n = int(n / 10)
    if (n == 1):
        ans = 10
        break

print(ans)

Submission status: Accepted

Solution code:
def DigitsSum(n):
    sum = 0
    while (n != 0):
        sum += (n % 10)
        n = int(n / 10)
    return sum

N = int(input())

min_sum = 10**5
for i in range(1, N):
    sum = DigitsSum(i) + DigitsSum(N-i)
    if (sum < min_sum):
        min_sum = sum

print(min_sum)

Submission status: Accepted

Solution code:
n=int(input())
s=0
while n>0:
  s+=n%10
  n//=10
if s==1:
  print(10)
else:
  print(s)

Submission status: Accepted

Solution code:
n=int(input())
res=100000
for i in range(1,n):
    j=n-i
    s=0
    for c in str(i):
        s+=int(c)
    for c in str(j):
        s+=int(c)
    res=min(res,s)
print(res)

Submission status: Accepted

Solution code:
def s(i):
    return sum([int(k) for k in str(i)])

n = int(input())
ans = 10**18
for i in range(1,n):
    ans = min(ans, s(i) + s(n-i))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

def Digit_Sum(n):
	s = str(n)
	sum = 0
	for i in s:
		sum += int(i)
	return sum

ans = 100000000000000

for i in range(1, n):
	ans = min(Digit_Sum(i) + Digit_Sum(n - i), ans)

print(ans)

Submission status: Accepted

Solution code:
def kakuwa(S):
    A = list(str(S))
    B = [int(x) for x in A]
    return sum(B)
    
N = int(input())
for i in range(1,5):
    if N%(10**i) == 0:
        ans = 10
        break
else:
    ans = kakuwa(N)
print(ans)

Submission status: Accepted

Solution code:
def kakuwa(S):
    A = list(str(S))
    B = [int(x) for x in A]
    return sum(B)
    
N = int(input())
ans = 50
for i in range(1,N):
    ans = min(ans, kakuwa(i) + kakuwa(N-i))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

ansli=[]
for i in range(1, n):
    mn=n-i
    s1=str(i)
    s2=str(mn)
    dli=[]
    for j in s1:
        dli.append(int(j))
    for k in s2:
        dli.append(int(k))
    ans=0
    for l in dli:
        ans+=l
    #print(ans)
    ansli.append(ans)
print(min(ansli))

Submission status: Accepted

Solution code:
n = input()
a = ["10","100","1000","10000","100000"]
if n in a:
    print(10)
else:
    ans = 0
    for i in n:
        ans += int(i)
    print(ans)

Submission status: Accepted

Solution code:
N = input()
sum = 0
for c in N:
    sum += int(c)
if sum == 1:
    sum = 10
print(sum)

Submission status: Accepted

Solution code:
n = input()

num = sum([int(i) for i in n])
if num == 1:
    print(10)
else:
    print(num)

Submission status: Accepted

Solution code:
n = int(input())
def sumdigits(n):
    n = str(n)
    a = 0
    while(n != ""):
        a += int(n[0])
        n = n[1:]
    return a
ans = sumdigits(1)+sumdigits(n-1)
for i in range(2,n//2):
    p = sumdigits(i)
    q = sumdigits(n-i)
    if(p+q < ans):
        ans = p + q
print(str(ans))

Submission status: Accepted

Solution code:
N = int(input())
ans = float('inf')
for A in range(1, N):
    B = N - A
    a = sum([int(i) for i in str(A)])
    b = sum([int(i) for i in str(B)])
    ans = min(ans, a+b)
print(ans)

Submission status: Accepted

Solution code:
a=input()
x=0
for c in a:
    x+=int(c)
if x==1:
    x=10
print(x)

Submission status: Accepted

Solution code:
n = int(input())
def sum_keta(m):
	sum_wa = 0
	while m>0:
		sum_wa = sum_wa + m%10
		m = int(m/10)

	return sum_wa

if sum_keta(n) == 1:
	print(10)
else:
	print(sum_keta(n))

Submission status: Accepted

Solution code:
n = input()
ans = 0
for ele in n:
  ans+=int(ele)
if ans==1:
  print(10)
else:
  print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = sum(list(map(int, list(str(N)))))
if A == 1:
    print(10)
else:
    print(A)

Submission status: Accepted

Solution code:
def s(n):
    p=0
    for i in str(n):
        p+=int(i)
    return p
ans=10**5    
N=int(input())
for i in range(1,(N//2)+1):
    p=s(i)+s(N-i)
    ans=min(ans,p)
print(ans)

Submission status: Accepted

Solution code:
import math
N=int(input())
i=2
digitSum=pow(10,5)
A=int(2)
while i<=int(N/2)+1:
    A=i
    B=N-A
    A_digitsum=0
    while A>=10:
        A_digitsum += A%10
        A = A//10
    if A<10:
        A_digitsum+=A
    B_digitsum=0
    while B>=10:
        B_digitsum += B%10
        B = B//10
    if B<10:
        B_digitsum+= B
    if digitSum > A_digitsum+B_digitsum:
        digitSum = A_digitsum+B_digitsum
    i+=1
print(digitSum)

Submission status: Accepted

Solution code:
a = input()
ans = 0
for i in a:
  ans += int(i)
 
if ans == 1:
  print(10)
else:
  print(ans)

Submission status: Accepted

Solution code:
def digSum(i):
    dig = str(i)
    array = list(map(int, list(dig)))
    return sum(array)

N = int(input())
minSum = float("inf")

for a in range(1, (N//2) + 1):
    b = N-a
    sumAB = digSum(a) + digSum(b)
    if sumAB < minSum:
        minSum = sumAB

print(minSum)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    inputNum = int(input())
    result = 100000

    for num in range(2, inputNum):
        numA = num
        numB = inputNum - num
        _result = 0

        if numA > numB:
            break

        for num1 in str(numA):
            _result += int(num1)
        for num1 in str(numB):
            _result += int(num1)

        if result > _result:
            result = _result

    if inputNum == 2:
        result = 2
    print(result)

Submission status: Accepted

Solution code:
def num(x):
	sum = 0
	while (x > 0):
		sum += x % 10
		x //= 10
	return sum

n = int(input())
ans = 1 << 30

for i in range(1, n):
	j = n - i
	ans = min(ans, num(i) + num(j))

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

def digit(a):
  a = list(str(a))
  a = [int(i) for i in a]
  return(sum(a))

ans = 9*8
for i in range(1, N//2+1):
  tmp = digit(i) + digit(N-i)
  ans = min(ans,tmp)

print(ans)

Submission status: Accepted

Solution code:
def digit_sum(i):
    return sum([int(digit) for digit in list(str(i))])

N = int(input())
ret = 10000
for A in range(1, N):
    ret = min(ret, digit_sum(A) + digit_sum(N-A))
print(ret)

Submission status: Accepted

Solution code:
n = input()
a = 0
for i in range(len(n)):
    a += int(n[i])
if a == 1:
    print(10)
else:
    print(a)

Submission status: Accepted

Solution code:
s = sum(int(i)for i in raw_input())
print [10, s][s > 1]

Submission status: Accepted

Solution code:
b = int(input())
a = []
while b >= 1:
    a.append(b %10)
    b /= 10
    b = int(b)
if sum(a) == 1:
    print(10)
else: 
    print(sum(a))

Submission status: Accepted

Solution code:
n = int(input())

ans = 99999999999999999999
for i in range(1, n) :
    j = n-i

    a = str(i)
    b = str(j)

    sum = int(0)
    for k in a : 
        sum += int(k)
    for k in b :
        sum += int(k)

    ans = min(ans, sum)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
m = str(n)
res = 0
for i in range(len(m)):
  res = res + int(m[i])
if res == 1:
    res *= 10
print(res)

Submission status: Accepted

Solution code:
import math
N = int(input())
inf = pow(10, 7)

def sum_digits(n):
    answer = 0
    for d in reversed(range(7)):
        shou, amari = divmod(n, pow(10, d))
        if shou == 0:
            continue
        answer += shou
        n = amari
    return answer

answer = inf
answer_v = (0,0)
for a in range(1, math.ceil(N/2)+1):
    b = N-a
    if sum_digits(a) + sum_digits(b) < answer:
        answer = sum_digits(a) + sum_digits(b)
        answer_v = (a, b)

print(str(answer))
# print(str(answer_v))

Submission status: Accepted

Solution code:
N = int(input())

N2 = N // 2

def sum_all_digits(n):
    return sum([int(x) for x in str(n)])

rtn = N
for A in range(2, N2+1):
    B = N - A
    c = sum_all_digits(A) + sum_all_digits(B)
    if c < rtn:
        rtn = c

print(rtn)

Submission status: Accepted

Solution code:
def sumdigits(n):
    result=0
    while n!=0:
        result+=n%10
        n=int(n/10)
    return result

N=int(input())

result=10**10
for i in range(1,int(N/2)+1):
    result=min(sumdigits(i)+sumdigits(N-i),result)


print(result)

Submission status: Accepted

Solution code:
N = int(input())
def f(c):
    if len(str(c)) == 1:
        return c
    p = 10 ** len(str(c)) - 1
    for i in range(len(str(c))):
        if c - (10 ** i) > 0:
            q = sum(map(int, list(str(c - (10 ** i))))) + 1
            if q < p:
                p = q
    return p
print(f(N))

Submission status: Accepted

Solution code:
N=int(input())

answer=999999999999

def digit(N):
 total=0
 listN=list(str(N))
 for i in range(len(listN)):
  total+=int(listN[i])
 return total

for i in range(1,N):
 A=i
 B=N-i
 answer=min(digit(A)+digit(B),answer)

print(answer)

Submission status: Accepted

Solution code:
s = sum(map(int,raw_input()))
if s == 1:
  print 10
else:
  print s

Submission status: Accepted

Solution code:
N=int(input())

ans=99999999999999999

def digit(N):
    total=0
    listN=list(str(N))
    for i in listN:
        total+=int(i)
    return total


for i in range(1,int(N/2)+1):
    A=i
    B=N-i
    ans=min(digit(A)+digit(B),ans)

print(ans)

Submission status: Accepted

Solution code:
s=input()
res=int(s[0])
flag=s[0]=="1"
for c in s[1:]:
 res+=int(c)
 if c!="0":
  flag=False
if flag:
 print(10)
else:
 print(res)

Submission status: Accepted

Solution code:
N = list(map(int, list(input())))

s = sum(N)

if s is 1:
  print(10)
else:
  print(s)

Submission status: Accepted

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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy
# sys.setrecursionlimit(1000000)

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def sumdig(a):
    assert a > 0
    sa = str(a)
    re = 0
    for c in sa:
        re += int(c)
    return re

def main():
    n = int(input())
    res = HUGE
    for a in range(1, n // 2 + 1):
        b = n - a
        res = min(res, sumdig(a) + sumdig(b))
    print(res)

main()

Submission status: Accepted

Solution code:
n = int(input())

a = 1
b = n - 1
sum_b = 0
while b > 10:
    sum_b += b % 10
    b //= 10
sum_b += b

result = sum_b + 1

for i in range(2, n):
    a = i
    b = n - i
    sum_a = 0
    while a > 10:
        sum_a += a % 10
        a //= 10
    sum_a += a
    sum_b = 0
    while b > 10:
        sum_b += b % 10
        b //= 10
    sum_b += b
    if sum_a + sum_b < result:
        result = sum_a + sum_b

print(result)

Submission status: Accepted

Solution code:
N = int(input())
ans = 100000
for j in range(1,N):
    p = str(j)+str(N-j)
    t = 0
    for k in p:
        t += int(k)
    ans = min(t,ans)
print(ans)

Submission status: Accepted

Solution code:
N = input()

if int(N) % 10 == 0:
    if N[0] == "1":  
        print("10")
    else:
        print(N[0])
else:
    print(sum(list(map(int, list(N)))))

Submission status: Accepted

Solution code:
def wa(a):
    ans = 0
    while(1):
        if a==0 :
            break;
        ans += a%10
        a = a//10
    
    return ans


n = int(input())
# print(wa(n))

ans=1145141919810


for a in range(1,n):
    b=n-a
    tmp=wa(a)+wa(b)
    if tmp < ans:
        ans=tmp
    
print(ans)

Submission status: Accepted

Solution code:
#coding : utf8

def digitSum(number):
    s = str(number)
    li = list(map(int,list(s)))
    return sum(li)

if __name__ == '__main__':
    inputNum = int(input())
    minimum = inputNum

    for i in range(1,int(inputNum/2+1)):
        temp = digitSum(i) + digitSum(inputNum-i)
        if(minimum > temp):
            minimum = temp

    print(minimum)

Submission status: Accepted

Solution code:
N = input()
mod = 10
while mod * 10 < int(N):
    mod *= 10
if int(N)%mod == 0:
    print(10)
else:
    ans = 0
    for N_i in N:
        ans += int(N_i)
    print(ans)

Submission status: Accepted

Solution code:
def f(x):
	return sum(map(int,list(str(x))))

n = int(input())

ans = 10**9

for i in range(1,n):
	x = i
	y = n-i
	ans = min(ans,f(x)+f(y))

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=str(N)
ans=0
non=0
for x in A:
  ans+=int(x)
if ans==1:
  ans=10*ans
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

sum = 0
while(n>0):
    sum+=n%10
    n//=10
if sum == 1:
    print(10)
else:
    print(sum)

Submission status: Accepted

Solution code:
def sumOfEach(x):
    array = list(str(x))
    ret = 0
    for z in array:
        ret += int(z)
    return ret

n = int(input())
minOfsum = 10 ** 5
for a in range(1, int(n / 2) + 1):
    b = n - a
    #print(a, b)
    sumOfEachA = sumOfEach(a)
    sumOfEachB = sumOfEach(b)
    sumOfTwo = sumOfEachA + sumOfEachB
    #sumOfTwo = sumOfEach(a) + sumOfEach(b)
    if sumOfTwo < minOfsum:
        minOfsum = sumOfTwo
print(minOfsum)

Submission status: Accepted

Solution code:
import math

n = int(input())
sum = 0
length = int(math.log10(n) + 1)

for i in range(length):
	sum += n % 10
	n = int(n / 10)

if sum == 1:
	print(10)
else:
	print(sum)

Submission status: Accepted

Solution code:
import math

n = int(input())
sum = 0
length = int(math.log10(n) + 1)

for i in range(length):
	sum += n % 10
	n = int(n / 10)

if sum == 1:
	print(10)
else:
	print(sum)

Submission status: Accepted

Solution code:
n = [int(x) for x in list(input())]
print(sum(n) + (9 if n[-1] == 0 else 0))

Submission status: Accepted

Solution code:
def sum_digit(n):
	sum = 0
	for s in str(n):
		sum += int(s)
	return sum

N = int(input())
min = N
for i in range(N)[1:]:
	m = sum_digit(i) + sum_digit(N-i)
	if m <= min:
		min = m


print(min)

Submission status: Accepted

Solution code:
def f(x):
    res = 0
    while x > 0:
        res += x % 10
        x /= 10
    return res

def solve(n):
    return min([f(a) + f(n-a) for a in range(1,n)])

assert solve(15) == 6
assert solve(100000) == 10, solve(100000)
n = input()
print solve(n)

Submission status: Accepted

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

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    n = list(map(int, list(input())))

    # See:
    # https://www.youtube.com/watch?v=Ommfmx2wtuY
    # https://beta.atcoder.jp/contests/agc025/submissions/2607113
    if n[0] == 1 and sum(n) == 1:
        print(10)
    else:
        print(sum(n))

Submission status: Accepted

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

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    n = int(input())

    # See:
    # https://www.youtube.com/watch?v=Ommfmx2wtuY
    if (n == 10) or (n == 100) or (n == 1000) or (n == 10000) or (n == 100000):
        print(10)
    else:
        print(sum(list(map(int, list(str(n))))))