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

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

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

Solution (Python):


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

Solution (Python):
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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):

N = int(input())

min=-1

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)

Solution (Python):
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)

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

Solution (Python):
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()

Solution (Python):
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))

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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):
        
        ans = Digitsum(N)
        break
    elif (n % 10 == 1 and n >= 10):
        
        ans = Digitsum(N)
        break
    n = int(n / 10)
    if (n == 1):
        ans = 10
        break

print(ans)

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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
    
    ansli.append(ans)
print(min(ansli))

Solution (Python):
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)

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

Solution (Python):
n = input()

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

Solution (Python):
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))

Solution (Python):
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)

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

Solution (Python):
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))

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

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

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

Solution (Python):
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)

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

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

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

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)

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

s = sum(N)

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

Solution (Python):


import sys, math, copy





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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)))))

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


n = int(input())


ans=1145141919810


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

Solution (Python):


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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
n = int(input())

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

Solution (Python):
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
    
    sumOfEachA = sumOfEach(a)
    sumOfEachB = sumOfEach(b)
    sumOfTwo = sumOfEachA + sumOfEachB
    
    if sumOfTwo < minOfsum:
        minOfsum = sumOfTwo
print(minOfsum)

Solution (Python):
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)

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):






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

    
    
    
    if n[0] == 1 and sum(n) == 1:
        print(10)
    else:
        print(sum(n))

Solution (Python):






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

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

Solution (Python):
n = int(input())
sumn = 0
data = 10
check = False
for i in range(1,6):
	if(10**i==n):
		check = True

if(check):
	print(10)
else:
	while n>=10:
		sumn += n%10
		n //= 10
	sumn += n
	print(sumn)

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

Solution (Python):
ans = 10**6
N = int(input())

for a in range(1, N//2+1):
    b = N - a
    ans = min(ans, sum(map(int, str(a))) + sum(map(int, str(b))))

print(ans)

Solution (Python):
N = int(input())

arr = [(i, N-i) for i in range(1, int(N/2))]
minn = N
for i, j in arr:
    temp = sum(list(map(int, list(str(i))))) + sum(list(map(int, list(str(j)))))
    minn = min(temp, minn)

print(minn)

Solution (Python):
def calc(n):
    ans = 0
    while n > 0:
        ans += n % 10
        n /= 10
    return ans

n = int(raw_input())
mn = 100
for a in range(1, n/2+1):
    mn = min(mn, calc(a) + calc(n-a))
print mn

Solution (Python):
n = input()


if int(n) % 10 != 0:
    print(sum([int(i) for i in list(n)]))
else:
    a = int(int(n)/10)
    b = int(n)-a

    a_sum = sum([int(i) for i in list(str(a))])
    b_sum = sum([int(i) for i in list(str(b))])
    print(a_sum+b_sum)

Solution (Python):
N = int(input())
ls = [0]*6
count = 0
for i in range(6):
    k = int(N % pow(10,i+1)) 
    ls[i] = int(k / pow(10,i))
    count += ls[i]
if count == 1:
    count = 10

print(count)

Solution (Python):
n=int(input())
ans=10**9

for i in range(1,n):
    suma,sumb=0,0
    ii,jj=i,n-i
    while ii>0:
        suma+=ii%10
        ii//=10
    while jj>0:
        sumb+=jj%10
        jj//=10
    ans=min(ans,suma+sumb)
print(ans)

Solution (Python):
n = input()

sum = 0
for i in n:
    sum += int(i)

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

Solution (Python):
import math
 
 
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)
 
 
n =  int(input())
 

rank = math.ceil(math.log10(n)) 
div =  n % 10**rank
if div == 0:
    print(10)
else :
    print(digitSum(int(n)))

Solution (Python):
N = int(input())
digitsum = lambda n: sum(map(int, str(n)))
ans = 36
for A in range(1, N//2 + 1):
    dig = digitsum(A) + digitsum(N - A)
    if dig < ans:
        ans = dig
print(ans)

Solution (Python):
import math


def digitSum(n):
    count = 0
    while n != 0:
        count += n % 10
        n //= 10
    return count


n =  int(input())



ans = digitSum(n)
if ans == 1:
    print(10)
else :
    print(ans)

Solution (Python):
N = int(raw_input())
m = 99999
for A in range(1, N):
  B = N - A
  s = sum([int(x) for x in str(A)] + [int(x) for x in str(B)])
  m = min(m, s)
print m

Solution (Python):
N = raw_input()
sum = sum(map(int, list(N)))
if sum == 1:
  print(10)
else:
  print(sum)

Solution (Python):
N=int(input())

import numpy as np

a=np.arange(N)
a=np.delete(a,0)

b=N-a

num_arr=[]

for i in range(len(a)):
	factor_a=[int(x) for x in list(str(a[i]))]
	factor_b=[int(x) for x in list(str(b[i]))]
	num_arr.append(sum(factor_a)+sum(factor_b))

print(min(num_arr))

Solution (Python):
n = map(int,list(input()))
s = 0
for i in n:
    s += i

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

Solution (Python):

import math
n=int(input())-1
a=10**int(math.log10(n))
b=n-a+1
print(sum(map(int,str(a)))+sum(map(int,str(b))))

Solution (Python):
N = int(input())

min_num = float('inf')
for i in range(1, N):
    j = N - i
    A_sum = sum(map(int, list(str(i))))
    B_sum = sum(map(int, list(str(j))))
    if A_sum + B_sum < min_num:
        min_num = A_sum + B_sum
print(min_num)

Solution (Python):






def sum_digit(number):
    string = str(number)
    array = list(map(int, list(string)))
    return sum(array)


if __name__ == '__main__':
    n = int(input())
    a = 0
    digit_sum_min = 1000000

    for i in range(1, n):
        a = i
        b = n - a

        sum_a = sum_digit(a)
        sum_b = sum_digit(b)
        digit_sum_min = min(digit_sum_min, sum_a + sum_b)

    print(digit_sum_min)

Solution (Python):
n = input()

if int(n) % 10 == 0:
  print(10)
else:
  res = 0
  for i in n:
  	res += int(i)
  print(res)

Solution (Python):
def eachdigitsum(n):
	x = len(str(n))
	sum = 0
	for i in range(x):
		t = n//10**(x-i-1)
		n = n - t*10**(x-i-1)
		sum += t
	return sum
	
n = int(input())
min = 1000000
for i in range(1,n//2 + 2):
	x = eachdigitsum(i) + eachdigitsum(n-i)
	if min > x:
		min = x
print(min)

Solution (Python):
n=int(input())
ans=[]
for i in range(1,n//2+1):
    a=i
    b=n-i
    a=list(map(int,str(a)))
    b=list(map(int,str(b)))
    ans.append(sum(a)+sum(b))
print(min(ans))

Solution (Python):
n=int(input())
ans=[]
for i in range(1,n//2+1):
    a=i
    b=n-i
    a=str(a)
    b=str(b)
    a=list(map(int,a))
    b=list(map(int,b))
    ans.append(sum(a)+sum(b))
print(min(ans))

Solution (Python):


n=raw_input()
s=0
for i in xrange(len(n)):
 s+=int(n[i])
if s==1:
 print 10
else:
 print s

Solution (Python):
import sys

def digits_sum(x):
    return sum(map(int, str(x)))

def solve(n):
    ans = sys.maxsize
    for a in range(1, n):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))

    return ans

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

Solution (Python):
import sys

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

def solve(n):
    ans = sys.maxsize
    for a in range(1, n):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))

    return ans

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

Solution (Python):
def main():
    N = int(input())

    ans = 0
    while N > 0:
        ans += N % 10
        N //= 10
    if ans == 1:
        print(10)
    else:
        print(ans)

main()

Solution (Python):


def digSum(n):
    s = 0
    while n != 0:
        s += (n % 10)
        n //= 10
    return s

n = int(input())
ans = 1000000
l = 1
r = n - 1
while l <= r:
    ans = min(ans , digSum(l) + digSum(r))
    l += 1
    r -= 1

print(ans)

Solution (Python):
n=sum(map(int,input()));print(n+9*(n<2))

Solution (Python):
n=sum(map(int,input()));print([n,10][n<2])

Solution (Python):
def a_digits_sum(N):
    
    
    
    
    
    ans = 0
    n = str(N)
    for c in n:
        ans += int(c)
    if ans == 1:
        
        ans = 10
    return ans

N = int(input())
print(a_digits_sum(N))

Solution (Python):
n = int(input())

a = 1
while a * 10 <= n:
    a *= 10

if a != n:
    b = n - a
else:
    b = n - a//10

print(1 + sum([int(digit) for digit in str(b)]))

Solution (Python):
def a_digits_sum(N):
    def digit_sum(n):  
        str_n = str(n)
        ret = 0
        for c in str_n:
            ret += int(c)
        return ret

    ans = float('inf')
    for A in range(1, N):
        B = N - A
        ans = min(ans, digit_sum(A) + digit_sum(B))
    return ans

N = int(input())
print(a_digits_sum(N))

Solution (Python):
def s(a):
 if a:
  return(s(a//10) + a%10)
 else:
  return(0)
n = int(input())
ans = 10000000000000
for i in range(1,n//2+1):
 k = s(i) + s(n-i)
 if k < ans:
  ans = k
print(ans)

Solution (Python):
N=int(input());print(min(sum(map(int,str(i)+str(N-i)))for i in range(1,N)))

Solution (Python):


N = int(input())
ans = 10000000
for i in range(1, N):
    s = sum(map(int, str(i))) + sum(map(int, str(N - i)))
    ans = min(ans, s)
print(ans)

Solution (Python):
a=sum(map(int,input()));print(a if a>1 else 10)

Solution (Python):
N = int(input())

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

Solution (Python):
n = int(input())
ans = float('Inf')
for i in range(1, n//2+1):
  if sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i)))) < ans:
    ans = sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i))))
print(ans)

Solution (Python):
n=int(input())
sum=0
a=1
b=n-1
ans=100000000
while(a<=b):
	ans1=0
	i=a
	j=b
	while(i//10!=0):
		ans1+=i%10
		i=i//10
	ans1+=i%10
	while(j//10!=0):
		ans1+=j%10
		j=j//10
	ans1+=j%10
	a+=1
	b-=1
	if(ans1<ans):
		ans=ans1
print(ans)

Solution (Python):
a=sum(int(i)for i in input());print([a,10][a==1])

Solution (Python):
a=sum(int(i)for i in input());print(10if a==1else a)

Solution (Python):
 


N = int(input())

ans = 0

for i in range(1, 6):
	if N == 10 ** i:
		ans = 10

if ans == 0:
	
	strN_list = list(str(N))
	
	for strN in strN_list:
		ans += int(strN)
print(ans)

Solution (Python):
def main():
    N = int(input())

    ans = f(N)
    print(ans)


def sum_digits(x):
    ans = 0
    while x > 0:
        x, a = divmod(x, 10)
        ans += a
    return ans


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


def f(N):
    ans = float("inf")
    
    for A in range(1, N//2 + 1):
        B = N - A
        tmp = sum_digits(A) + sum_digits(B)
        ans = min(ans, tmp)

    return ans


if __name__ == '__main__':
    main()

Solution (Python):
def digsum(a):
	sum=0
	A=str(a)
	for i in range(0,len(A)):
		sum=sum+int(A[i])
	return sum
n=int(input())

mini=n
a=0
b=0
for i in range(1,n):
	A=i
	B=n-i
	suma=digsum(A)+digsum(B)
	if(suma<mini):
		mini=suma
		a=A
		b=B
print(mini)

Solution (Python):
a=sum(int(i)for i in input());print(a if a!=1else 10)

Solution (Python):
n = int(input())
ans = float('Inf')
for i in range(1, n):
  if i > n//2:
    break
  if eval('+'.join(str(i))) + eval('+'.join(str(n - i))) < ans:
    ans = eval('+'.join(str(i))) + eval('+'.join(str(n - i)))
print(ans)

Solution (Python):
n=int(input());print(min([sum(list(map(int,str(i)))+list(map(int,str(n-i))))for i in range(1, n)]))

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

Solution (Python):
N = int(input())

if N < 10:
    print(N)
    exit()

N_list = list(map(int, list(str(N))))

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

Solution (Python):
def k(n):return sum(int(i)for i in str(n))
m=n=int(input())
for i in range(1,n):m=min(m,k(i)+k(n-i))
print(m)

Solution (Python):
n = int(input())


def sum_digit(n):
    s = 0
    while n > 0:
        s += n % 10
        n //= 10
    return s


res = 10000000000
for a in range(1,n):
    b = n - a
    res = min(res, sum_digit(a) + sum_digit(b))
print(res)

Solution (Python):
N = input()
A = max(1,10**(len(N)-2))
B = int(N) - A
print(sum(list(map(int,str(A)))) + sum(list(map(int,str(B)))))

Solution (Python):
N = int(input())
Ans = 0
while N >=1:
    Ans += N%10
    N //= 10
print(Ans if Ans != 1 else 10)

Solution (Python):
N = int(input())

res = 2 * 32


def g(a):
    if a < 10:
        return a
    return a % 10 + g(a // 10)


def f(a, b):
    return g(a) + g(b)


for a in range(1, N):
    b = N - a
    res = min(res, f(a, b))

print(res)

Solution (Python):
n = int(input())
ans = 0
lis = []
for i in range(1,n):
    r = n - i
    ti = list(str(i))
    tr = list(str(r))
    for k in range(len(ti)):
        ti[k] = int(ti[k])
    for k in range(len(tr)):
        tr[k] = int(tr[k])
    lis.append(sum(ti)+sum(tr))
print(min(lis))

Solution (Python):


input_str = input()
input_num = int(input_str)

input_num_digits = len(input_str) - 1

if input_num == 10 ** input_num_digits:
    min_digit_sums = [10]

else:
    former_num = 10 ** input_num_digits
    latter_num = input_num - former_num

    digit_sum = 0
    for char in str(former_num):
        digit_sum += int(char)
    for char in str(latter_num):
        digit_sum += int(char)
    min_digit_sums = [digit_sum]

for i in range(1, input_num // 2):
    former_num = i
    latter_num = input_num - i

    digit_sum = 0
    for char in str(former_num):
        digit_sum += int(char)
    if digit_sum >= min(min_digit_sums):
        continue
    for char in str(latter_num):
        digit_sum += int(char)
    if digit_sum < min(min_digit_sums):
        min_digit_sums.append(digit_sum)

print(str(min(min_digit_sums)))

Solution (Python):
N = int(input())
ans = float('inf')
for i in range(1,N):
	num = i
	j = N - num
	d = 0
	while num != 0:
		d += (num % 10)
		num //= 10
	while j != 0:
		d += (j % 10)
		j //= 10

	ans = min(d,ans)

print(ans)

Solution (Python):
import math

A=0
N=int(input())
for i in range(5,10):
  X = N / i
  if X == int(X):
    A += math.floor(N / i)
    break
  else:
    continue
  
B = N - A
anum=[]
bnum=[]
a=0
b=0

while A > 0:
    anum.append(A%10)
    A //= 10 
anum.reverse()

while B > 0:
    bnum.append(B%10)
    B //= 10 
bnum.reverse()

for q in anum:
  a += q
for w in bnum:
  b += w

print(a+b)

Solution (Python):
n = int(input().strip())
ans = int(1e9)
for a in range(1, n):
  b = n-a
  ans = min(ans, sum(map(int,str(a)))+sum(map(int,str(b))))
print(ans)

Solution (Python):
n = int(raw_input())
dp = range(100010)
for i in xrange(1, n + 1):
    dp[i] = dp[i/10] + i % 10
print min(dp[x] + dp[n-x] for x in xrange(1, n))

Solution (Python):
N = input()
 
l = [int(x) for x in list(str(N))]
 
s = 0
if (sum(l[1:-1])is 0) and l[-1] in [0,1,2] and l[0] == 1:
    s = 9
s += sum(l)
print(s)