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=float("inf")
for i in range(1,n):
    j=n-i
    tmp=0
    I=str(i)
    J=str(j)
    for ii in range(len(I)):
        tmp+=int(I[ii])
    for jj in range(len(J)):
        tmp+=int(J[jj])
    if tmp<ans:
        ans=tmp
print(ans)

Solution (Python):
def dig(x):
	return sum([int(i) for i in str(x)])

n = int(input())
ans = 1e20
for a in range(1, n):
	b = n - a
	ans = min(ans, dig(a)+dig(b))
print(ans)

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

a = list(str(N))
a = [int(s) for s in a]


Z = 10 ** (len(a) - 1)

Y = N - Z

X = list(str(Y))
X = [int(s) for s in X]
SUM = 0
for i in range(len(X)):
    SUM = SUM + X[i]

if Y != 0:
    print(SUM + 1)
else:
    print(10)

Solution (Python):
N=int(input())
N_sum=[]
for A in range(1,int(N/2)+1):
  B=N-A
  N_sum.append(sum(map(int,str(A)+str(B))))
print(min(N_sum))

Solution (Python):
n = int(input())
l1 = []
l2 = []
b = 0
ans = float('inf')

def keta(x):
    l = []
    while(x > 0):
        l.append(x%10)
        x //= 10
    return l

for a in range(1, n):
    b = n - a
    l1 = keta(a)
    l2 = keta(b)
    ans = min(ans, sum(l1, sum(l2)))

print(ans)

Solution (Python):
N = int(input())
ans = 100
i = 1
while i * 2 <= N:
  ans = min(ans, sum(map(int, list(str(i)))) + sum(map(int, list(str(N-i)))))
  i += 1
print(ans)

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

M=10**9
for i in range(1,N//2+1):
    a=list(str(i))
    b=list(str(N-i))
    
    k=0
    for q in range(len(a)):
        k+=int(a[q])
    for p in range(len(b)):
        k+=int(b[p])
    M=min(M,k)
print(M)

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

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

Solution (Python):
N=int(input())
N_sum=[]
for A in range(1,int(N/2)+1):
  B=N-A
  N_sum.append(sum(map(int,str(A)+str(B))))
print(min(N_sum))

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

if (N%10 == 0):
    print(10)
    exit()
a = []
while N > 0:
    a.append(N%10)
    N //= 10

print(sum(a))

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

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

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

Solution (Python):



from math import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq














import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7


INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
i = 1
def keta(v):
    a = 0
    while v:
        a += v%10
        v //= 10
    return a
ans = INF
while 2*i <= n:
    ans = min(ans, keta(i) + keta(n-i))
    i += 1
print(ans)

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

count = 10000000

for i in range (1, N//2+2):
	A = str(i)
	B = str(N-i)
	temp = 0
	for j in range (0, len(A)):
		temp+=int(A[j])
	for j in range (0, len(B)):
		temp+=int(B[j])
	count = min(count, temp)

print(count)

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

Solution (Python):
n = int(input())
ans = 1001001001
for i in range(1,n):
    j = n-i
    i_sum, j_sum = 0, 0

    si, sj = list(str(i)), list(str(j))
    for s1 in si:
        i_sum += int(s1)
    for s2 in sj:
        j_sum += int(s2)

    ans = min(ans, i_sum+j_sum)

print(ans)

Solution (Python):
N = int(input())
ans = 10**9+7
for i in range(1,N):
  A = i
  B = N-i
  ans = min(ans, sum(list(map(int,str(A))))+sum(list(map(int,str(B)))))
print(ans)

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


N = int(input())
ans = N
for i in range(1, N):
    A = i
    B = N - i
    ans = min(ans, digit_sum(A) + digit_sum(B))
print(ans)

Solution (Python):
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float('inf')

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float('inf')
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float('inf')
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(' ')
        elif type(ls[0])==str:
            print(' '.join(ls))
        elif type(ls[0])==int:
            print(' '.join(map(str,ls)))
        else:
            print('Output Error')
    else:
        if len(ls)==0:
            print('')
        elif type(ls[0])==str:
            print(''.join(ls))
        elif type(ls[0])==int:
            print(''.join(map(str,ls)))
        else:
            print('Output Error')

def I():
    return int(input())

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

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]







mod = 10**9 + 7

n = I()

m = INF
for i in range(n//2):
    a = i + 1
    b = n - a
    a = str(a)
    b = str(b)
    a = list(a)
    b = list(b)
    a = sum(list(map(int,a)))
    b = sum(list(map(int,b)))
    m = min(m,a+b)
print(m)

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

Solution (Python):
N = int(input())
cmin = N
for i in range(1,N):
    j = N-i
    a = str(i)
    b = str(j)
    cnt = 0
    for k in range(len(a)):
        cnt += int(a[k])
    for k in range(len(b)):
        cnt += int(b[k])
    cmin = min(cmin,cnt)
print(cmin)

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

min_sum = 100000

for A in range(1, N):
    Sum = 0
    sum_A = 0
    sum_B = 0
    B = N - A
    str_A = str(A)
    str_B = str(B)
    for i in str_A:
        sum_A += int(i)
    for j in str_B:
        sum_B += int(j)
    Sum = sum_A + sum_B
    if Sum < min_sum:
        min_sum = Sum
    
print("{}".format(min_sum))

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

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

for a in range(1,n):
  l_a=str(a)
  l_b=str(n-a)
  
  sum_a=0
  sum_b=0
  for e_a in l_a:
    sum_a+=int(e_a)
  for e_b in l_b:
    sum_b+=int(e_b)
  sum_ab = sum_a+sum_b
  
  if sum_ab<min_sum:
    min_sum=sum_ab
    
print(min_sum)

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

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

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

Solution (Python):
n = int(input())
l = [0] * (n // 2)
for i in range(1, n // 2 + 1):
    sum1 = sum([int(d) for d in str(i)])
    sum2 = sum([int(d) for d in str(n - i)])
    l[i - 1] = sum1 + sum2
print(min(l))

Solution (Python):
def func(i):
  ret_val=0
  while 0<i:
    ret_val+=i%10
    i//=10
  return ret_val

N=int(input())
ans=10**9
for i in range(1,N):
  j=N-i
  ans=min(ans,func(i)+func(j))
print(ans)

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

minno = 10 ** 5
for i in range(1, N):
    str_list_a = list(str(i))
    int_list_a = [int(x) for x in str_list_a]
    str_list_b = list(str(N - i))
    int_list_b = [int(y) for y in str_list_b]

    sum_a_b = sum(int_list_a) + sum(int_list_b)
    if sum_a_b < minno:
        minno = sum_a_b
print(minno)

Solution (Python):
N=int(input())
ans=float("inf")
for i in range(1,N):
   a,b=map(int,list(str(i))),map(int,list(str(N-i)))
   ans=min(ans,sum(a)+sum(b))
print(ans)

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

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

Solution (Python):
import sys
n = int(sys.stdin.readline().rstrip("\n"))
INF = float('inf')
ans = INF
for a in range(1,(n+2)//2):
    b = n-a
    s = 0
    while a != 0:
        a,p = divmod(a, 10)
        s += p
    while b != 0:
        b,p = divmod(b, 10)
        s += p
    ans = min(ans,s)
print(ans)

Solution (Python):
s = input()
l = len(s)
a = [int(x) for x in s]
 
if int(s) == 10 ** (l - 1):
  print(10)
else:
  print(sum(a))

Solution (Python):
'''
Created on 2020/09/03

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  A=1
  B=N-A
  m=10**9
  for i in range(N-1):
    f=0
    for j in str(A):
      f+=int(j)
    for k in str(B):
      f+=int(k)
    m=min(m,f)
    A+=1
    B-=1
  print(m)
  return 
main()

Solution (Python):
n=int(input())
a=[]
for i in range(1,n):
  s=str(i)+str(n-i)
  c=0
  for j in s:
    c+=int(j)
  a.append(c)
    
print(min(a))

Solution (Python):


def get_digits_sum(val_str):
    digits_sum = 0
    for i in range(len(val_str)):
        digits_sum += int(val_str[i])

    return digits_sum

N = int(input())

if N==2:
    sum_min = 2

for i in range(2, N, 1):
    A = i
    B = N - i
    a_sum = get_digits_sum(str(A))
    b_sum = get_digits_sum(str(B))
    if i==2:
        sum_min = a_sum + b_sum
    elif sum_min > a_sum + b_sum:
        sum_min = a_sum + b_sum
        
print(sum_min)

Solution (Python):
N = int(input())
ans = 10**14
for i in range(1, N//2+1):
    a = sum(map(int, str(i)))
    b = sum(map(int, str(N-i)))
    ans = min(a+b, ans)
print(ans)

Solution (Python):



def main():
    n = int(input())
    ans = float("inf")
    for i in range(2, n // 2 + 2):
        a = i
        b = n - a
        na = sum(map(int, list(str(a))))
        nb = sum(map(int, list(str(b))))
        if ans > na + nb:
            ans = na + nb
    print(ans)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
N = int(input())
ans = float("inf")

for i in range(1, N):
    A = i
    B = N - i
    A_sum = 0
    B_sum = 0
    while True:
        if A // 10 > 0:
            A_sum += A % 10
            A  //= 10
        else:
            A_sum += A % 10
            break
    while True:
        if B // 10 > 0:
            B_sum += B % 10
            B  //= 10
        else:
            B_sum += B % 10
            break
    if ans > (A_sum + B_sum):
        ans = A_sum + B_sum
print(ans)

Solution (Python):
def SumReturn(num):
    total=0
    while num!=0:
        total += num%10
        num //= 10
        
    return total

if __name__ == '__main__':
    
    n = int(input())
    min = 10000
    
    for i in range(1,n):
        if(min > SumReturn(i)+SumReturn(n-i)):
            min = SumReturn(i)+SumReturn(n-i)
        
        
    print(min)

Solution (Python):
s = input()
l = len(s)
a = [int(x) for x in s]

if int(s) == 10 ** (l - 1):
  print(10)
else:
  print(sum(a))

Solution (Python):



def main():
    N = int(input())
    print(
        min(
            [
                sum(list(map(int, str(i)))) + sum(list(map(int, str(N - i))))
                for i in range(1, N)
            ]
        )
    )


main()

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

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

min_num = 100000
for A in range(1, N):
  B = N - A
  digit_num = digit_sum(A)
  digit_num += digit_sum(B)
  if digit_num < min_num:
    min_num = digit_num

print(min_num)

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

ans=[]

for i in range(1,N):
    B=N-i
    ans.append(sum(map(int,str(i)))+sum(map(int,str(B))))

print(min(ans))

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

ans=10**9+7
for i in range(1,n):
    tmp=list(str(i)) + list(str(n-i))
    tmp=[int(i) for i in tmp]
    ans=min(ans, sum(tmp))

print(ans)

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

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

def sss(s):
    return sum(map(int, list(str(s))))

ans = 10**7
for a in range(1, n):
    b = n-a
    ans = min(ans, sss(a)+sss(b))
print(ans)

Solution (Python):
n = int(input())
absum = []
for a in range(1,n//2+1):
    b = n-a
    asum = 0
    bsum = 0
    astr = str(a)
    bstr = str(b)
    for j in range(len(astr)):
        asum = asum + int(astr[j])
    for k in range(len(bstr)):
        bsum = bsum + int(bstr[k])
    absum.append(asum+bsum)
print(min(absum))

Solution (Python):
n = int(input())
absum = []
for a in range(1,n):
    b = n-a
    asum = 0
    bsum = 0
    astr = str(a)
    bstr = str(b)
    for j in range(len(astr)):
        asum = asum + int(astr[j])
    for k in range(len(bstr)):
        bsum = bsum + int(bstr[k])
    absum.append(asum+bsum)
print(min(absum))

Solution (Python):
n = int(input())
absum = []
for a in range(1,n//2+1):
    b = n-a
    asum = 0
    bsum = 0
    alen = len(str(a))
    blen = len(str(b))
    for j in range(alen):
        a0 = (a//(10**j)) % 10
        asum = asum + a0
    for k in range(blen):
        b0 = (b//(10**k)) % 10
        bsum = bsum + b0
    absum.append(asum+bsum)
print(min(absum))

Solution (Python):
n = int(input())
absum = []
for a in range(1,n):
    b = n-a
    asum = 0
    bsum = 0
    alen = len(str(a))
    blen = len(str(b))
    for j in range(alen):
        a0 = (a//(10**j)) % 10
        asum = asum + a0
    for k in range(blen):
        b0 = (b//(10**k)) % 10
        bsum = bsum + b0
    absum.append(asum+bsum)
print(min(absum))

Solution (Python):
N = int(input())
n = N - 1
A = list(str(n))
A = list(int(n) for n in A)
ans1 = sum(A) + 1

n = N // 2
A = list(str(n))
A = list(int(n) for n in A)
ans2 = 2 * sum(A)

if N % 2 == 0:
    ans = min(ans1, ans2)
else:
    ans = min(ans1, ans2 + 1)

print(ans)

Solution (Python):
import sys
input = sys.stdin.buffer.readline




def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))




def main():
	n=II()

	ans=10**10


	for i in range(1,n):
		a=str(i)
		b=str(n-i)
		cnt=0
		for aa in a:
			cnt+=int(aa)
		for bb in b:
			cnt+=int(bb)
		ans=min(ans,cnt)
	print(ans)









if __name__ == "__main__":
	main()

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

def digit_sum(A):
    S = 0
    while A > 0:
        S += A % 10
        A //= 10
    return S

ans = 10e+5
for A in range(1, N):
    cand = digit_sum(A) + digit_sum(N - A)
    ans = min(ans, cand)

print(ans)

Solution (Python):
def digits_sum(n):
    return sum(int(c) for c in str(n))


N = int(input())
ans = float("inf")
for i in range(1, N):
    A = i
    B = N - i
    ans = min(ans, digits_sum(A) + digits_sum(B))
print(ans)

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

Solution (Python):
N = int(input())
ans = float('inf')
for i in range(N//2):
  A = i+1
  B = N-A
  ans = min(ans, sum(list(map(int,str(A)))) + sum(list(map(int,str(B))) ))

print(ans)

Solution (Python):
S = input()
ansA = 0
ansB = 0
for i in range(len(S)):
    N = int(S[i])
    if N == 1:
        ansA += 1
    elif N % 2 == 0:
        ansA += N//2
        ansB += N//2
    else:
        N -= 1
        ansA += N//2+1
        ansB += N//2
if ansA == 1 and ansB == 0:
    ans = 10
else:
    ans = ansA+ansB
print(ans)

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

Solution (Python):
import sys
n=int(input())
ans=0
flag=0
while n%10==0:
  n=n//10
if n==1:
  print(10)
  sys.exit()
s=str(n)
for i in range(len(s)):
  ans+=int(s[i])
print(ans)

Solution (Python):
N = int(input())
cmin = N
for i in range(1,N//2):
    j = N-i
    a = str(i)
    b = str(j)
    cnt = 0
    for k in range(len(a)):
        cnt += int(a[k])
    for k in range(len(b)):
        cnt += int(b[k])
    cmin = min(cmin,cnt)
print(cmin)

Solution (Python):
n = int(input())
ans = 10**9
for a in range(1,n):
    b = n - a
    a_sum = 0
    b_sum = 0
    for ai in str(a):
        a_sum += int(ai)
    for bi in str(b):
        b_sum += int(bi)
    v = a_sum+b_sum
    ans = min(ans,v)

print(ans)

Solution (Python):
N = int(input())
if N == 10 or N == 100 or N == 1000 or N == 10000 or N == 100000:
    print(10)
else:
    ans = sum(list(map(int, str(N))))
    print(ans)

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

if n == 10 or n == 100 or n == 1000 or n == 10000 or n == 100000:
    ans = 10
else:
    n = str(n)
    ans = 0
    for l in n:
        ans += int(l)

print(ans)

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


N = int(input())
m = 10**5+1
for i in range(1, N//2+1):
    A = digitsum(i)
    B = digitsum(N-i)
    m = min(m, A+B)
print(str(m))

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

n = int(input())
minTotal = float('inf')
for i in range(1,n+1):
    if 0 < n - i < n:
        a = findSumOfDigits(i)
        b = findSumOfDigits(n-i)
        if a + b < minTotal:
            minTotal = a + b
print(minTotal)

Solution (Python):
N=int(input())
A=[]
for i in range(1,(N//2)+1):
    A.append(list(str(i))+list(str(N-i)))
for i in range(len(A)):
    for j in range(len(A[i])):
        A[i][j]=int(A[i][j])
B=[]
for i in range(len(A)):
    B.append(sum(A[i]))
print(min(B))

Solution (Python):
def digit_sum(x): 
    y = str(x) 
    y_len = len(y) 
    ans = 0
    for j in range(y_len):
        ans += int(y[j]) 

    return ans

answer = 10**8 
n = int(input()) 
for i in range(1,n):
    a = i 
    b = n - a 
    answer = min(answer, digit_sum(a)+ digit_sum(b))

print(answer)

Solution (Python):
n = int(input())
ans = 10 ** 9
for a in range(1, n):
  b = n - a
  total = sum([int(digit_a) for digit_a in str(a)]) + sum([int(digit_b) for digit_b in str(b)])
  if total < ans:
    ans = total
print(ans)

Solution (Python):
N = int(input())
ans  = 10**5+1
for i in range(1,N//2 + 1):
    A = i
    B = N - i
    tmp = 0
    while(A > 0):
        tmp += A % 10
        A //= 10
    while(B > 0):
        tmp += B % 10
        B //= 10
    ans = min(ans,tmp)
print(str(ans))

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """15"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100000"""
        output = """10"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    ans = float('inf')
    for a in range(1, N):
        b = N - a
        A = str(a)
        B = str(b)
        t = 0
        for i in range(len(A)):
            t += int(A[i])
        for i in range(len(B)):
            t += int(B[i])
        ans = min(ans, t)
    print(ans)


if __name__ == "__main__":
    
    resolve()

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

n = 1
ans = 10**5

def calucurate(M):
    n = 0
    while M > 0:
        n += M%10
        M //= 10
    return n

while n < N:
    t = N - n
    m = calucurate(t) + calucurate(n)
    ans = min(ans,m)
    n += 1

print(ans)

Solution (Python):
N = int(input())
ans = float("inf")
for i in range(1,N):
    if sum(map(int, str(i))) + sum(map(int, str(N-i))) < ans:
        ans = sum(map(int, str(i))) + sum(map(int, str(N-i)))
print(ans)

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

print(ans)

Solution (Python):
def calc_sum_of_digits(num):
	ans = 0

	while True:
		if num // 10 == 0:
			ans += num
			break

		ans += num % 10
		num //= 10

	return ans


def main():
	N = int(input())
	min_sum = 1000

	for A in range(1, N):
		B = N - A

		A_sum = calc_sum_of_digits(A)
		B_sum = calc_sum_of_digits(B)

		if A_sum + B_sum < min_sum:
			min_sum = A_sum + B_sum

	print(min_sum)

  
if __name__ == "__main__":
  	main()

Solution (Python):
def digitsum(N):
    return sum(map(int,list(str(N))))
N = int(input())
m = 100000
for A in range(1,N//2+1):
    B = N-A
    m = min(m,digitsum(A)+digitsum(B))
print(m)

Solution (Python):
N = int(input())
if N%10 ==0:
  ans = 10
else:
  NN = list(str(N))
  ans = 0
  for i in NN:
    ans += int(i)
print(ans)

Solution (Python):
n = int(input())
if n == 10 or n == 10 ** 2 or n == 10 ** 3 or n == 10 ** 4 or n == 10 ** 5:
    print(10)
else:
    ans = 0
    a = str(n)
    for i in range(len(a)):
        ans += int(a[i])
    print(ans)

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

def d_sum(n):
    ret = 0
    while(n>0):
        ret += n%10
        n //= 10
    return ret

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

print(ans)

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


def digit_sum(x):
    return sum(int(si) for si in str(x))


ans = 10**5
for a in range(1, n):
    b = n - a
    ans = min(ans, digit_sum(a) + digit_sum(b))

print(ans)

Solution (Python):
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

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

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    m = 10**100
    for i in range(1, N//2+1):
        A = i
        B = N-i
        Da = sum(int(a) for a in str(A))
        Db = sum(int(b) for b in str(B))
        m = min(m, Da+Db)
    print(m)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = 0
b = 0
ans = 1000000000
for i in range(1, n):
    a = n - i
    b = n - a
    a = list(map(int,str(a)))
    b = list(map(int,str(b)))
    if sum(a) + sum(b) <= ans:
        ans = sum(a) + sum(b)
print(ans)

Solution (Python):
N = int(input())
ans = float('inf')
for i in range(1,N):
    A = i
    B = N - i
    Sum = 0
    for power in range(4,-1,-1):
        q_a,r_a = divmod(A,10**power)
        A = r_a
        q_b,r_b = divmod(B,10**power)
        B = r_b
        Sum += q_a + q_b
    ans = min(Sum, ans)
print(ans)

Solution (Python):
def digitsum(s):
    su = 0
    for i in range(len(s)):
        su += int(s[i])

    return su

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

    ans = 10**10
    for a in range(1, N):
        b = N - a
        tmp = digitsum(str(a)) + digitsum(str(b))

        ans = min(ans, tmp)

    print(ans)

if __name__ == "__main__":
    main()

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

ans = 2 * 10**5

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

Solution (Python):
import sys
import collections
import bisect
import math
import time


def main():
    n = input()
    if len(n) == 1:
        print(int(n))
        return

    if len(n) - list(n).count("0") >= 2:
        print(sum(list(map(lambda x: int(x), list(n)))))
        return

    if n[0:2] == "10":
        print(10)
        return

    print(n[0])


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = 0
b = n
ans = 1e9
while (1 < b):
    a += 1
    b -= 1
    sa = str(a)
    sb = str(b)
    sum = 0
    for i in range(len(sa)):
        sum += int(sa[i])
    for i in range(len(sb)):
        sum += int(sb[i])
    ans = min(ans, sum)
print(ans)

Solution (Python):

N = int(input())

def sum_of(num): 
    list_b = []
    k = 0
    while num > 0:
        list_b.append(num%10)
        num //= 10
    for i in range(len(list_b)):
        k += list_b[i]
    return k 

list_a =[]
if N <= 10:
    print(str(N))
if N > 10:
    for i in range(2,(N-1)//2+1):
        A = i
        B = N - i
        list_a.append(sum_of(A) + sum_of(B))
    print(min(list_a))

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

ans = 10**10
for i in range(1,n):
    a = i
    b = n-i
    s = sum([int(i) for i in str(a)]) + sum([int(i) for i in str(b)])
    ans = min(ans,s)
print(ans)

Solution (Python):

N = int(input())

def sum_of(num): 
    list_b = []
    k = 0
    while num > 0:
        list_b.append(num%10)
        num //= 10
    for i in range(len(list_b)):
        k += list_b[i]
    return k 

list_a =[]
if N <= 10:
    print(str(N))
if N > 10:
    for i in range(2,N-1):
        A = i
        B = N - i
        list_a.append(sum_of(A) + sum_of(B))
    print(min(list_a))

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

def sum_of(num): 
    list_b = []
    k = 0
    while num > 0:
        list_b.append(num%10)
        num //= 10
    for i in range(len(list_b)):
        k += list_b[i]
    return k 

list_a =[]
if N == 2:
    print(str(2))
if N == 3:
    print(str(3))
if N >= 4:
    for i in range(2,N-1):
        A = i
        B = N - i
        list_a.append(sum_of(A) + sum_of(B))
    print(min(list_a))

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

for a in range(1,N):
  sum = 0
  A = a
  B = N-a
  while A > 0:
    sum += A%10
    A = int(A/10)
  while B > 0:
    sum += B%10
    B = int(B/10)
  if minval > sum:
    minval = sum

print(minval)

Solution (Python):

import math

n = int(input())
m = math.log10(n)
if int(m) == m:
    print(10)
    exit()

ans = sum(map(int, list(str(n))))
print(ans)

Solution (Python):


n = int(input())

def sumdigits(n):
    ret = 0 
    s = list(str(n))
    for i in range(len(s)):
        ret += int(s[i])
    return ret 

a = 1 
ans = 1000000
while n-a > 0:
    tmp = sumdigits(a) + sumdigits(n-a)
    if ans >= tmp:
        ans = tmp 
    a += 1

print(ans)

Solution (Python):
def solve(x):
  n = len(str(x))
  res = 0
  for i in str(x):
    res += int(i)
  return res

n=int(input())
ans = 10**20
for a in range(1,n):
  ans = min(ans,solve(a)+solve(n-a))
print(ans)

Solution (Python):
N = int(input())
mn=10**8
for A in range(1,N):
    B=N-A
    sm=0
    while A!=0:
        sm+=A%10
        A//=10
    while B!=0:
        sm+=B%10
        B//=10
    if mn>sm:
        mn=sm
print(mn)

Solution (Python):
N=int(input())
if N==10 or N==10**2 or N==10**3 or N==10**4 or N==10**5:
  print(10)
else:
  a=list(str(N))
  b=sum([int(i) for i in a])
  print(b)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    ans = INF
    for a in range(1,N//2+1):
        b = N-a
        res = 0
        for i in str(a):
            res += int(i)
        for i in str(b):
            res += int(i)
        ans = min(ans, res)
    print(ans)




if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
ans=100000000000
for a in range(1,N):
    b=N-a
    tempa=0
    tempb=0
    for i in range(len(str(a))):
        tempa+=a%10
        a=a//10
    for j in range(len(str(b))):
        tempb+=b%10
        b=b//10
    if tempa+tempb<ans:
        ans=tempa+tempb

print(ans)

Solution (Python):

N = int(input())


if N%2 == 0:
  k = N//2
else:
  k = (N+1)//2

cmb = []
for i in range(1,k+1):
  cmb.append([i , N-i])
  
def digitSum(n):
    
    s = str(n)
    
    array = list(map(int, s))
    
    return sum(array)

ans = []
for i in range(k-1):
  X = digitSum(cmb[i][0])
  Y = digitSum(cmb[i][1])
  ans.append(X+Y)


if ans == []:
  print("2")
else:
  print(min(ans))

Solution (Python):
Max = 1000000
def digit_sum(n):
	res = 0
	while n>0:
		res += int(n%10)
		n /= 10
	return res

N = int(input())
if N==10 or N==100 or N==1000 or N==10000 or N==100000:
	print(10)
else:
	print(digit_sum(N))

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

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

counter=90
for A in range(1,N):
    if digitsum(A)+digitsum(N-A)<counter:
        counter=digitsum(A)+digitsum(N-A)

print(counter)

Solution (Python):
INF = 1 << 60
n = int(input())
ans = INF
for a in range(1, n):
    b = str(n - a)
    a = str(a)
    total_a = 0
    total_b = 0
    for i in a:
        total_a += int(i)
    for i in b:
        total_b += int(i)
    ans = min(ans, total_a + total_b)
print(ans)

Solution (Python):
def resolve():
    N = int(input())
    if 10**(len(str(N))-1) == N:
        print("10")
    else:
        print(sum(map(int, str(N))))
resolve()

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
ans = 10**18
for i in range(1,n):
    j = n-i
    s = str(i).rjust(6,"0")[::-1]
    t = str(j).rjust(6,"0")[::-1]
    res = 0
    for i,j in zip(s,t):
        res += int(i)+int(j)
    ans = min(res,ans)

print(ans)

Solution (Python):
n = int(input())
if n%10 == 0:
    print(10)
else:
    cnt = 0
    while n != 0:
        cnt += n%10
        n //= 10
    print(cnt)