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 = input()
s = int(n)
min = 100000
for i in range(1,s):
  a = str(s - i)
  array1 = list(map(int, list(a)))
  array2 = list(map(int, list(str(i))))
  b = sum(array1) + sum(array2)
  if b < min:
    min = b
print(min)

Solution (Python):
M = list(input())
result = 0
if set(M[1:]) == {'0'}:
    result = 10
else:
    for i in M:
        result = result + int(i)
print(result)
print()

Solution (Python):
import math


def kk(d):
    if d == 0:
        return 0
    else:
        return kk(int(d / 10)) + (d % 10)


n = int(input())
logs = math.log10(n)
if int(logs) == logs:
    print(10)
else:
    print(kk(n))

Solution (Python):
N=int(input())
ans=10**5
for A in range(1,(N//2)+1):
  B=N-A
  ans=min(ans,sum([int(x) for x in list(str(A)+str(B))]))
print(ans)

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

m = (N // 100000) + (N // 10000) % 10 + (N // 1000) % 10 + (N // 100) % 10 + (N // 10) % 10 + (N) % 10
if m < 2:
	m += 9

print(m)

Solution (Python):
N = int(input())
import math
n = 10*N
for i in range(1,math.ceil(N/2)+1):
    m = 0
    j = str(N-i)
    i = str(i)
    for k in range(len(i)):
        m += int(i[k])
    for k in range(len(j)):
        m += int(j[k])
    if m < n:
        n = m
print(n)

Solution (Python):
N = input()
if int(N) == 10 ** (len(N) - 1) and len(N) > 1:
    print(10)
else:
    res = 0
    for c in N:
        res += int(c)
    print(res)

Solution (Python):
from collections import Counter

n = input()
c = Counter(n)
if '0' in c:
    del c['0']

if len(c) == 1 and '1' in c and c['1'] == 1:
    print(10)
else:
    print(sum(int(f) * m for f, m in c.items()))

Solution (Python):


n = int(input())

lst = []

for i in range(1,int(n/2)+1):
    a = n-i

    s1 = str(a)
    s2 = str(i)
    
    
    ans = 0
    for j in range(len(s1)):
        ans += int(s1[j])
    
    for j in range(len(s2)):
        ans += int(s2[j])
    
    lst.append(ans)
lst.sort()
print(lst[0])

Solution (Python):


cs = lambda a: sum(map(int, "{}".format(a)))

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

Solution (Python):
def total(a):
    sumnum = 0
    for i in range(len(str(a))):
        sumnum += int(str(a)[i])
    return sumnum

N = int(input())

S = []
for i in range(int(N / 2)):
    num = N - i - 1
    S.append(total(i + 1) + total(num))
print(min(S))

Solution (Python):



import sys  
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools


sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]

def local_input():
    from pcm.utils import set_stdin
    import sys
    if len(sys.argv) == 1:
        set_stdin(os.path.dirname(__file__) + '/test/' + 'sample-1.in')

def solve():
    N = int(input())
    res = float('inf')
    for n in range(1, N):
        a = n
        b = N - n
        res = min(res, calc(a) + calc(b))
    print(res)

def calc(a):
    res = 0
    for i in range(0, 6):
        b = dcopy(a)
        t = 10**i
        b = int(b/t)
        b %= 10
        res += b
    return res


if __name__ == "__main__":
    try:
        local_input()
    except:
        pass
    solve()

Solution (Python):
N = input()
ans = 0
t = False
if N[0] == "1":
    for i in N[1:]:
        if i != "0":
            break
    else:
        t = True
        print(10)
if not t:
    for n in N:
        ans += int(n)
    print(ans)

Solution (Python):
N = int(input())
if N < 10:
    print(N)
    exit()

while N%10 == 0:
    N = N//10

if N == 1:
    print(10)
    exit()

str_n = str(N)
int_n = map(int, str_n)
ans = sum(int_n)
print(ans)

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

ans = 100000

for i in range(1, n):
    a = n - i
    temp = sum(map(int, str(a))) + sum(map(int, str(i)))
    if temp < ans:
        ans = temp

print(ans)

Solution (Python):
N=input()

ans=float("inf")

for A in range(1,N):
	B=N-A
	A2=list(str(A))
	B2=list(str(B))
	ans=min( ans, sum( map(int,A2) )+ sum( map(int,B2) ) )

print ans

Solution (Python):

p = [10, 100, 1000, 10000, 100000]
N = int(input())
if N in p:
    print(10)

else:
    N = str(N)
    total = 0
    for ch in N:
        total += int(ch)
    print(total)

Solution (Python):
n = input()
ans = 0
for i in n:
    ans += int(i)

if ans == 1:
    ans = 10

print(ans)

Solution (Python):
from sys import stdin

n = stdin.readline().strip()

l = 0
r = 0
for i in range(len(n)):
    l += int(n[i]) // 2
    r += int(n[i]) - (int(n[i])//2)

if l==0:
    l = 0
    r = 0
    ls = str(int(n) // 2)
    rs = str(int(n) - (int(n)//2))
    for i in range(len(ls)):
        l += int(ls[i])
    for i in range(len(rs)):
        r += int(rs[i])

print(l+r)

Solution (Python):
n = int(raw_input())
while n%10==0: n /= 10
if n == 1: print 10
else:
    print sum(list(map(int,str(n))))

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

def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

while( N>=0 ) :
  if N % 10 == 0:
    N = int(N / 10)
    if N == 1:
      print(10)
      break
    continue
  else:
    print(digitSum(N))
    break

Solution (Python):
n = int(input())
number = 0
for i in str(n):
    number += int(i)
if number == 1:
    number += 9
print(number)

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 = int(input())
while(N%10 == 0):
 N /= 10
if N == 1:
 print(10)
else:
 s = str(N)
 array = list(map(int, list(s)))
 print(sum(array))

Solution (Python):
n = int(input())
ans = 0
for i in range(1, 6):
    if n == 10 ** i:
        ans = 1

if ans == 1:
    print(10)
else:
    num = 0
    for i in range(1, 6):
        num += n % 10
        n = n // 10
    print(num)

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

    min_s = 100001
    for i in range(1, n//2+2):
        b = n - i

        a_s, b_s = i % 10, b % 10
        while i // 10 != 0:
            i //= 10
            a_s += i % 10

        while b // 10 != 0:
            b //= 10
            b_s += b % 10

        if a_s + b_s < min_s:
            min_s = a_s + b_s

    print(min_s)


if __name__ == '__main__':
    main()

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

def c(n):
  digit_sum = 0
  length = n
  for i in range(length):
    digit = n % 10
    digit_sum += digit
    n = n // 10
    if n == 0:
      break
      
  return digit_sum

min_sum = n
for a in range(1, n):
  b = n - a
  digit_sum = c(a) + c(b)
  if digit_sum < min_sum:
    min_sum = digit_sum

print(min_sum)

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

result = 10 ** 10

for a in range(1, N):
    b = N - a
    A = 0
    while a != 0:
        A += a % 10
        a = a // 10
    B = 0
    while b != 0:
        B += b % 10
        b = b // 10

    result = min(result, A + B)

print(result)

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

def f(N):
    ll = list(str(N))
    min_num = sum([int(i) for i in ll])
    return min_num

min_num = f(N-1) + f(1)

if N % 2 == 0:
    for i in range(1, int(N/2)):
        counter = N-i
        sum_num = f(i) + f(counter)
        if min_num > sum_num:
            min_num = sum_num

else:
    for i in range(1, int((N+1)/2)):
        counter = N-i
        sum_num = f(i) + f(counter)
        if min_num > sum_num:
            min_num = sum_num

print(min_num)

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

ans = float('inf')
for i in range(1, N//2+1):
  a = i
  b = N - a
  digitSumA = digitSumB = 0
  for i in range(6):
    digitSumA += a % 10
    a //= 10
    digitSumB += b % 10
    b //= 10
  ans = min(ans, digitSumA + digitSumB)
print(ans)

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

def digit_sum(X):
    s = 0
    while(X > 0):
        s += X % 10
        X = int(X / 10)
    return s

min_ = 10 ** 5
for A in range(1, int(N/2)+1):
    B = N - A
    val = digit_sum(A) + digit_sum(B)
    min_ = min(min_, val)

print(min_)

Solution (Python):

import sys
import math
import numpy as np




n = int(input())
min_sum=9999999
for a in range(1,n):
    aa=a
    bb=n-a
    sumab = 0
    while aa > 0:
        sumab += (aa % 10)
        aa = aa // 10
    while bb > 0:
        sumab += (bb % 10)
        bb = bb // 10
    min_sum = min(min_sum,sumab)
print(min_sum)

Solution (Python):
n = input()
minsofar = 100000000

def sumofdigits(a):
    ans = 0
    for i in `a`:
        ans += int(i)
    return ans

for i in range(1, n):
    a = i
    b = n - a
    minsofar = min(minsofar, sumofdigits(a) + sumofdigits(b))

print minsofar

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

def func(i):
    s=str(i)
    return sum([int(c) for c in s])

minimum=1000000
for i in range(1,N):
    tmp=sum([func(i),func(N-i)])
    if tmp<minimum:
        minimum=tmp

print(minimum)

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

ans = N
for A in range(1,N):
    B = N - A
    A_str = str(A)
    B_str = str(B)
    A_li = [int(A_str[i]) for i in range(len(A_str))]
    B_li = [int(B_str[i]) for i in range(len(B_str))]
    s = sum(A_li) + sum(B_li)
    if s < ans:
        ans = s

print(ans)

Solution (Python):
n=[int(i) for i in list(input())]
s=sum(n)
if s==1 and min(n)==0:
  print(10)
else:
  print(s)

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

for i in range(1,N//2):
    A = str(i)
    B = str(N-i)
    AB_sum = 0
    for j in A:
        AB_sum += int(j)
    for j in B:
        AB_sum += int(j)
    if AB_sum < ans:
        ans = AB_sum

print(ans)

Solution (Python):
N=list(input())
ans=0
for i in range(len(N)):
  ans+=int(N[i])

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

Solution (Python):
N = int(input())
m = 10000000000000000
for i in range (1,N):
    a = i
    b = N-i
    s1,s2=str(a),str(b) 
    d1,d2 = list(s1),list(s2) 
    x1,x2 = list(map(int, d1)),list(map(int, d2)) 
    sum1,sum2 = sum(x1),sum(x2)
    m = min(m,sum1+sum2)
print(m)

Solution (Python):




def main():
    N = int(input())
    if len(str(N)) >= 2 and int(str(N)[1:]) == 0 and str(N)[0] == '1':
        print(10)
    else:
        print(sum(map(int, str(N))))

if __name__ == '__main__':
    main()

Solution (Python):


def digitSum(a):
	s=0
	while a!=0:
		s+=a%10
		a//=10

	return s

n = int(input())
a = 1
b = n-1

m = 100000000000
while a<=b:
	s1 = digitSum(a)
	s2 = digitSum(b)

	if s1+s2 < m:
		m = s1+s2

	a+=1
	b-=1

print(m)

Solution (Python):


N = int(input())

ans = 9999999
j = N - 1
for i in range(1, N):
    di = sum([int(d) for d in list(str(i))])
    dj = sum([int(d) for d in list(str(j))])
    ans = min(ans, di + dj)
    j -= 1
print(ans)

Solution (Python):
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N = ri()
ret = N
for A in range(1,N):
  B = N-A
  ret = min(ret, sum(int(e) for e in str(A)) + sum(int(e) for e in str(B)))
print(ret)

Solution (Python):
n = input()
flag = False
for i in range(len(n)):
    if 2 <= int(n[i]) <= 9:
        flag = True
        break
if int(n[-1]) == 1:
    flag = True

if flag == True:
    ans = 0
    for i in range(len(n)):
        ans += int(n[i])
else:
    ans = 9
    for i in range(len(n)):
        ans += int(n[i])
print(ans)

Solution (Python):
N = int(input())
ans = 10*5
for i in range(1,N//2+1):
    L=[]
    for x in range(len(str(i))):
        L.append(int(str(i)[x]))
    for y in range(len(str(N-i))):
        L.append(int(str(N-i)[y]))
    ans = min(ans,sum(L))
print(ans)

Solution (Python):
n = int(input())
ans = float("inf")
for i in range(1,n//2+1):
	x,num = str(i)+str(n-i),0
	for j in x: num += int(j)
	ans = min(ans,num)
print(ans)

Solution (Python):
n=int(input())
ans=float("inf")
for i in range(1,n):
    sum=0
    j=n-i
    ii=str(i)
    jj=str(j)
    for k in range(len(ii)):
        sum+=int(str(i)[k])
    for k in range(len(jj)):
        sum+=int(str(j)[k])
    ans=min(ans,sum)
print(ans)

Solution (Python):
if __name__ == "__main__":
  N = int(input())
  min = 1000000000000
  for i in range(1, N):
    A = i
    A_sum = sum([int(x) for x in list(str(A))])
    B = N - i
    B_sum = sum([int(x) for x in list(str(B))])
    buf = A_sum + B_sum
    if buf < min:
      min = buf
  print(min)

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

ans = 10e10
for A in range(1, N//2+2):
    B = N - A
    S = sum(list(map(int, str(A)))) + sum(list(map(int, str(B))))
    ans = min(ans, S)

print(ans)

Solution (Python):

def sum_dig(n):
    sum = 0 
    n=str(n)
    for ele in n:
        sum+=int(ele)
    return sum

ans = 328932998329823983298

n = int(input())

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

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    ans = 99999999
    for i in range(1, n):
        total = list(str(n-i)) + list(str(i))
        tmp = 0
        for t in total:
            tmp += int(t)
        ans = min(ans, tmp)
    print(ans)

Solution (Python):
n=int(input())
ans = 100000000
for i in range(1,n):
    ankari = 0
    for j in range (1,6):
        ankari += (i%pow(10,j))//pow(10,j-1)+((n-i)%pow(10,j))//pow(10,j-1)
    ans = min(ans,ankari)
print(ans)

Solution (Python):

N = int(input())

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

ans = float('inf')
for i in range(1, N):
    a = digit_sum(i)
    if a > ans:
        continue
    ans = min(ans, a + digit_sum(N-i))
print(ans)

Solution (Python):
N=int(input())
minT=pow(10,5)
for i in range(1,N):
  tmp = 0
  for x in range(len(str(i))):
    tmp += int(str(i)[x])
  for y in range(len(str(N-i))):
    tmp += int(str(N-i)[y])
  minT = min(minT,tmp)
print(minT)

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

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

    sum_a = sum(list(map(int, str(a))))
    sum_b = sum(list(map(int, str(b))))
    
    ans = min(ans, sum_a+sum_b)

print(ans)

Solution (Python):
def findDigits(num):
	l = []
	while(num > 0):
		l.append(num % 10)
		num = num / 10
	return l	


n = input()
i = 1
sum1 = 1000000000
while(i <= n/2):
	l1 = findDigits(i)
	l2 = findDigits(n - i)
	s1 = sum(l1)
	s2 = sum(l2)
	if(s1 + s2 < sum1):
		sum1 = s1 + s2
	i = i + 1
print(sum1)

Solution (Python):
N = int(input())
res = float('INF')
for a in range(1, N//2+1):
    b = N - a
    res = min(res, sum([int(i) for i in list(str(a))]) + sum([int(i) for i in list(str(b))]))

print(res)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product


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


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


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


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


def read_str():
    return input()


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


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


def mt(f):
    import time

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

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

    return wrap


@mt
def slv(N):
    ans = sys.maxsize
    for a in range(1, N):
        b = N - a
        ta = 0
        while a:
            ta += a % 10
            a //= 10
        while b:
            ta += b % 10
            b //= 10

        ans = min(ta, ans)

    return ans


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


if __name__ == '__main__':
    main()

Solution (Python):
a = input()
n = int(a)
if n%10==0 or n%100==0 or n%1000==0 or n%10000==0 or n%100000==0:
    print(10)
else:
    b = 0
    for i in a:
        b += int(i)
    print(b)

Solution (Python):
n=raw_input()
tn0=[k for k in n if k!="0"]
if len(tn0)>1 or tn0[0]!="1":
    print sum([int(k) for k in tn0])
else:
    print 10

Solution (Python):







def digitsum(x):
    s=0
    while(x > 0):
        a = x%10
        x = x//10
        s+= a
    return(s)

n = int(input())

ans = 1<<20
for i in range(1,n):
    ans = min(ans,digitsum(i)+digitsum(n-i))

print(ans)

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

ans = 100000
for a in range(1, N):
    b = N - a
    s = sum(list(map(int, list(str(a))))) + sum(list(map(int, list(str(b)))))
    if s < ans:
        ans = s
print(ans)

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

Solution (Python):
n=int(input())
ans=float("inf")
for i in range(1,n):
  a=0
  for j in range(len(str(i))):
    a+=int(str(i)[j])
  for j in range(len(str(n-i))):
    a+=int(str(n-i)[j])
  ans=min(ans,a)
print(ans)

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

Solution (Python):
def sum_digits(n):

    n = str(n)
    summ = 0

    for d in n:
        summ += int(d)

    return summ

n = int(input())
min_summ = 1000000

for a in range(1, n):

    min_summ = min(min_summ, sum_digits(a) + sum_digits(n-a))

print(min_summ)

Solution (Python):
x = int(input())
if x==10 or x==100 or x==1000 or x==10000 or x==100000:
    print(10)
else:
    s = 0
    for i in str(x):
        s += int(i)
    print(s)

Solution (Python):
N = int(input())
res = int(1e18)

for i in range(1, (N+1)//2):
    A = map(int, list(str(i)))
    B = map(int, list(str(N-i)))
    res = min(res, sum(A)+sum(B))

if N == 2:
    res = 2

print(res)

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

def dig_sum(n):
    res = 0
    while(not n<10):
        res += n % 10
        n = n//10
    res += n
    return res

ans = 100000000000000
for A in range(2, 2+N//2):
    B = N - A
    tmp = dig_sum(A) + dig_sum(B)
    ans = min(ans, tmp)

print(ans)

Solution (Python):
def asu(a,b):
    a,b=str(a),str(b)
    a=sum(map(int,list(a)))
    b=sum(map(int,list(b)))
    return a+b

n=int(input())
mins=999999999
for i in range(1,n):
    asun=asu(i,n-i)
    if mins>asun:
        mins=asun
print(mins)

Solution (Python):

N = int(input())

if N == 10 or N == 100 or N == 1000 or N == 10000 or N == 100000:
    print(10)

else:
    t = list(str(N))
    print(sum(map(int, t)))

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

ans = float('inf')
for i in range(1, N):
    a = str(i)
    b = str(N - i)
    if ans > sum(map(int, list(a))) + sum(map(int, list(b))):
        ans = min(ans, sum(map(int, list(a))) + sum(map(int, list(b))))

print(ans)

Solution (Python):

import sys

input=sys.stdin.readline

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

n=int(input())
ans=10**9
for i in range(1,n):
    s=get(i)+get(n-i)
    if ans>s: ans=s
print(ans)

Solution (Python):
n=int(input())
x=n
for i in range(1,n):
    t=sum(map(int, list(str(i))))+sum(map(int, list(str(n-i))))
    if t<x:
        x=t
print(x)

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

digsum = lambda x: sum(map(int, str(x)))
ans = 100
for a in range(1, n):
    b = n - a
    ans = min(ans, digsum(a) + digsum(b))
print(ans)

Solution (Python):
n = int(raw_input())
a = 1
best = 999999999999999
def score(a, b):
    return sum([int(c) for c in str(a) + str(b)])
while a <= n/2:
    b = n - a
    best = min(best, score(a, b))
    a += 1
print best

Solution (Python):
N = input()
if N[0] == '1' and all(n == '0' for n in N[1:]):
  print(10)
else:
  print(sum(int(n) for n in N))

Solution (Python):
x=raw_input()
if x[0]=="1" and set(x[1:])=={"0"}: print 10
else: print sum(int(y) for y in x)

Solution (Python):
import math
from copy import deepcopy
import bisect
import itertools
from collections import deque
import numpy as np


def read():
    return int(input())


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


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


N = read()


def is_10(n):
    while n > 1:
        if n % 10:
            return False
        else:
            n = n // 10

    return True


if is_10(N):
    print(10)
else:
    strN = str(N)
    ans = 0
    for num in strN:
        ans += int(num)
    print(ans)

Solution (Python):
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(100000)

def digsum(x):
  result = 0
  while x != 0:
    result += x % 10
    x //= 10
  return result

ans = 10**6
N = read()
for A in range(1, N):
  B = N - A
  ans = min(ans, digsum(A) + digsum(B))

print(ans)

Solution (Python):
n = int(input())
ans = 100000
for i in range(1,n):
    count = 0
    a = str(i)
    b = str(n-i)
    for j in a:
        count += int(j)
    for k in b:
        count += int(k)
    ans = min(ans,count)
print(ans)

Solution (Python):

n = int(input())

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

ans = 10 ** 9
for i in range(1, n):
    ans = min(ans, d(i) + d(n - i))

print(ans)

Solution (Python):

NL = list(map(int, list(input())))

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

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

ans = 9999
for i in range(1,N):
    A = sum([int(s) for s in str(i)])
    B = sum([int(s) for s in str(N-i)])
    if A+B<ans:
        ans = A+B
        
print(ans)

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

N = int(input())
m = N
for A in range(1,N):
	B = N - A
	m = min(m, digitsum(A) + digitsum(B))

print(m)

Solution (Python):
def kuraiwa(M):
    S=str(M)
    ans=0
    for i in S:
        ans+=int(i)
    return ans
N=int(input())
res=N
for i in range(1,N):
    A=i
    B=N-i
    tmp=kuraiwa(A)+kuraiwa(B)
    if tmp<res:
        res=tmp
print(res)

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

def dig_sum(n):
  return sum([int(i) for i in str(n)])

res = 10**9
for a in range(1, n):
  b = n - a
  res = min(res, dig_sum(a) + dig_sum(b))
  
print(res)

Solution (Python):


import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq





def solve(f):
    n = f.read_int()

    ans = n
    for a in xrange(1,n):
        b = n-a
        ans = min(ans, sum(map(int, list(str(a)+str(b)))))

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case 
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n = I()
    if n in [10,100,1000,10000,100000]:
        return 10

    s = [c for c in str(n)]
    return sum(map(int, s))


print(main())

Solution (Python):
ans = 10 ** 20
n = int(input())
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)

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

def cal(x):
    r = 0
    while x:
        r += x % 10
        x //= 10
    return r

r = 100000
for a in range(1, N):
    b = N - a
    r = min(cal(a) + cal(b), r)

print(r)

Solution (Python):
n = int(input())
ans = 1234567890
def c(x):
    ers = 0
    for i in str(x):
        ers += ord(i) - ord('0')
    return ers
for a in range(1, n):
    ans = min(ans, c(a) + c(n - a))
print(ans)

Solution (Python):
def main():
    n = input()
    best = float('inf')
    for a in range(1, n//2 + 1):
        b = n - a
        s = sum(map(int, '%i%i' % (a, b)))
        best = min(best, s)
    print best

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
mi=10**5
for a in range(1,n//2+1):
    b=n-a
    sa=str(a)
    sb=str(b)
    aa=list(map(int,list(sa)))
    ab=list(map(int,list(sb)))
    mi=min(mi,sum(aa)+sum(ab))
print(mi)

Solution (Python):
import sys

N = int(input())

a = 10 ** 23

for i in range(1, N):
    a = min(a, sum(map(int, list(str(i)))) + sum(map(int, list(str(N - i)))))

print(a)

Solution (Python):
n = int(input())
num = float("inf")
for i in range(1, n):
    rec = 0
    a, b = i, n - i
    while a > 0:
        rec += a % 10
        a //= 10
    while b > 0:
        rec += b % 10
        b //= 10
    num = min(rec, num)

print(num)

Solution (Python):
N = int(input())
ans = 9999999
for a in range(1,N):
    b = N-a
    tmp = 0
    for ac in str(a):
        tmp += int(ac)
    for bc in str(b):
        tmp += int(bc)
    ans = min(ans, tmp)
print(ans)

Solution (Python):
N = int(input())
def digit_sum(s):
    return sum(int(x) for x in str(s))
ans = 10 ** 9
for i in range(1, N):
    ans = min(ans, digit_sum(i) + digit_sum(N - i))
print(ans)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())

def get_sum(n):
    n_str = str(n)
    ret = 0
    for ch in n_str:
        ret += int(ch)
    return ret

A = 1
B = N - A
ans = 1e10
while B >= 1:
    ans = min(ans, get_sum(A) + get_sum(B))
    A += 1
    B -= 1
print(ans)

Solution (Python):
def read_ints():
    return [int(c) for c in input().split()]


def dsum(i):
    return sum(int(c) for c in str(i))


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

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

    print(ans)


if __name__ == '__main__':
    main()

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

ans = 2000000000
for a in range(1, n):
	b = n-a
	X = str(a)
	Y = str(b)
	s = sum([int(a) for a in X])
	s += sum([int(a) for a in Y])
	ans = min(ans, s)
print (ans)