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())
a = 0
b = 0
s = 10 ** 5
for i in range(1, N):
	a = sum(int(j) for j in str(i))
	b = sum(int(k) for k in str(N - i))
	if s >= a + b:
		s = a + b
print(s)

Solution (Python):
n = input()
f = 0
for i in list(n[1:]):
    if i == "0":
        continue
    else:
        f = 1
        break
if f == 0 and n[0] == "1":
    print(10)
else:
    print(sum([int(x) for x in list(n)]))

Solution (Python):
n = int(input())
a = 0
num = []
from functools import reduce
num = [int(x) for x in list(str(n))]
if n != 100000 and n != 10000 and n != 1000 and n != 100 and n != 10:
  for i in num:
    a = a + i
else:
    a = 10
print(a)

Solution (Python):
def each_digit_sum(num):
    sum_list = [int(x) for x in list(str(num))]
    min_sum = 0
    for y in sum_list:
         min_sum = min_sum + y
    return min_sum


sum = int(input())
ans = 0
for i in range(1,sum):
    A = i
    B = sum - i
    tmp_ans = each_digit_sum(A)+each_digit_sum(B)
    if(ans == 0 or tmp_ans<ans):
        ans = tmp_ans
print(ans)

Solution (Python):
def getSum(n):
    sum1 = 0
    while(n > 0):
        sum1 += int(n%10)
        n = int(n/10)
    return sum1
n = int(input())
dig_sum = getSum(n)
if (dig_sum) == 1:
    if n == 1:
        print(1)
    else:
        print(10)
else:
    print(dig_sum)

Solution (Python):
score = 9999999

n = int(raw_input())

sum_a = 0
while True:
    quo  = n %10
    sum_a += quo
    n = int(n/10)
    if n  == 0:
        break

if sum_a == 1:
    sum_a  =10

print sum_a

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

A = 0
B = 0

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

for i in range(1, N/2+1):
    a = i
    b = N - i

    if min > digitSum(a) + digitSum(b):
        min = digitSum(a) + digitSum(b)   

print(min)

Solution (Python):
 


N = int(input())

ans = 0

if N == 10 ** 1 or N == 10 ** 2 or N == 10 ** 3 or N == 10 ** 4 or N == 10 ** 5:
	ans = 10

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

Solution (Python):
import math

n = int(input())
minresult = 0

def gen(num):
   if num < 10:
      return(num)
   else:
      data_size = int(math.log10(num) + 1)
      sum = 0
      for i in range(data_size):
         digit = num // 10**(data_size - i - 1)
         sum += digit
         num -= digit * 10**(data_size - i - 1)
      return(sum)

for j in range(n - 1):
   A = gen(j + 1)
   B = gen(n - j - 1)
   result = A + B
   if minresult == 0 or result < minresult:
      minresult = result

print(minresult)

Solution (Python):
import sys

N=int(input())
non_zero=0

for i in range (1,len(str(N))):
    if str(N)[i]=='0':
        non_zero+=1
    
if non_zero==len(str(N))-1:
    if str(N)[0]=='1':
        print(10)
        sys.exit()
    else:
        print(int(str(N)[0]))
        sys.exit()

count=0
for j in range(len(str(N))):
    count+=int((str(N))[j])
    
print(count)

Solution (Python):
def DSum(n):
    s = list(str(n))
    i = list(map(int, s))
    return sum(i)

if __name__ == "__main__":
    a = int(input())
    hoge = DSum(a)
    if hoge == 1:
        hoge = 10
    print("{}".format(hoge))

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

ans = 0

while True:
	ans += N%10
	if N // 10 == 0:
		break
	N = N//10

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

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

for i in range(1, n // 2 + 1):
    ans = min(ans, sum(map(int, str(i))) + sum(map(int, str(n - i))))

print(ans)

Solution (Python):
def count_k(num):
    a = list(str(num))
    a = list(list(map(int, a)))
    return sum(a)

N = int(input())

arr = [0] * N

for i in range(1, N):
    arr[i] = count_k(i)

re = 0
for i in range(0, int(N/2)):
    c = arr[i +1] + arr[N - i - 1]
    if re > c or re == 0:
        re = c
        
print(re)

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

SUM = 10000000

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

print(SUM)

Solution (Python):

"""
Created on Sun Jun 03 21:23:15 2018

@author: ashida
"""

N = input()

if N == 10 or N == 100 or N == 1000 or N == 10000 or N == 100000:
    print(10)
else:
    ans = 0
    a = N
    while(a > 0):
        ans = ans + a - (a/10)*10
        a = a/10
    print(ans)

Solution (Python):
N = int(input())
n = list(str(N))
sumN = sum(map(int,n))
lenN = len(n)
lengN = 10 ** (lenN - 1)

if sumN == 1:
    print(10)
elif lenN == 1:
    print(n[0])
else:
    A = N // lengN
    B = sum(map(int,list(str(N % lengN))))
    print(A + B)

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

minsum = int(1e4)

for A in range(1,int(N/2)):
    B = N-A
    a_sum = sum(list(map(int, list(str(A)))))
    b_sum = sum(list(map(int, list(str(B)))))
    if minsum > a_sum+b_sum: minsum = a_sum+b_sum

if int(N/2)==1:
    minsum=N
print(minsum)

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

ans=0
if N<=9:
	ans=N
	print(ans)
	exit(0)

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


s = str(N)
for c in s:
	ans += int(c)


print(ans)

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

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

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

def digitSum(X):

    ds = 0
    for x in str(X):
        ds += int(x)
    return ds

ans = N

for i in range(1, N):
    dgtSum = digitSum(i) + digitSum(N - i)
    if ans > dgtSum:
        ans = dgtSum

print(ans)

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

if N % 2 ==0:
  NA = int(N/2)
else:
  NA = int(N/2)
  
sum_n = 9*5*2 

for a in range(1,int(N/2+1)):
  summ = 0
  b = N-a
  list_a = list(str(a))
  list_b = list(str(b))
  
  while len(list_a) != len(list_b):
    list_a.insert(0,"0")
  for i in range(len(list_b)):
    summ += int(list_a[i])+ int(list_b[i])
  
  if summ < sum_n:
    sum_n = summ

print(sum_n)

Solution (Python):
n=input()
s=0
for i in n:
  t=int(i)/2
  s=int(i)+s
if(s==1):
  print(10)
else:
  print(s)

Solution (Python):
k = int(input())
 
while k % 10 == 0:
  if k != 10:
    k /= 10
  else:
    break
l = str(k) 
p = list(l)

al = 0
if k != 10: 
  for i in range(len(p)):
    al += int(p[i])
else:
  al = 10
print(al)

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

Solution (Python):
def main(a,b):
	count = 0
	
	while(a>0):
		count += a%10
		a = int(a/10)
			
	while(b>0):
		count += b%10
		b = int(b/10)
	return count

n = int(input())

result = main(n-1,1)
for i in range(2,n):
	a  = n - i
	b = i
	result = min(result, main(a,b))
		
print(result)

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

Solution (Python):
def gen(n):
  if n < 10:
    yield n
  else:
    for m in gen(n/10):
      yield m
    yield n%10

N=int(input())

A=1
B=N-A
min_val=N
while A < N:
	A_num=[int(i) for i in gen(A)]
	B_num=[int(i) for i in gen(B)]
	
	
	
	
	val=sum(A_num)+sum(B_num)
	
	if val < min_val:
		min_val=val
		
	A+=1
	B=N-A

print(min_val)

Solution (Python):
n = int(input())
i = 100000
ans = 0
while True:
    ans += n//i
    n -= (n//i)*i
    i //= 10
    if n == 0:
        break
if ans == 1:
    print(10)
else:
    print(ans)

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

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

Solution (Python):
N = int(input())
m = float("inf")
alist = []
blist = []

for i in range(1,N):
    a = i
    b = N - i
    while a > 0:
        alist.append( a % 10 )
        a //= 10
    alist.reverse()
    while b > 0:
        blist.append( b % 10 )
        b //= 10
    blist.reverse()
    A = sum(alist)
    B = sum(blist)
    if A + B < m:
        m = A + B
    alist.clear()
    blist.clear()

print(m)

Solution (Python):


N = int(input())

v = 0

def dsum(num):
  d = len(str(num))
  s = 0

  for i in range(d-1, -1, -1):
    n = num // 10**i
    s += n
    num = num % 10**i

  return s


min_s = 54
for A in range(1, N):
  B = N - A
  s = 0
  s += dsum(A)
  s += dsum(B)
  if s < min_s: min_s = s

print(min_s)

Solution (Python):
N = int(input())
a = 0
b = 0
s = 10 ** 5
for i in range(1, N):
	a = sum(int(j) for j in str(i))
	b = sum(int(k) for k in str(N - i))
	if s >= a + b:
		s = a + b
print(s)

Solution (Python):
N = int(input())
c_list = []
if N % 2 ==0:
    for i in range(1, int((N+2)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
else:
    for i in range(1, int((N+1)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
print(min(c_list))

Solution (Python):
n = int(input())
out=100000
for i in range(1,n):
    a=n-i
    b1=str(a)
    b2=str(i)
    c=list(b1)
    c.extend(b2)
    d=[int(s) for s in c]
    e=sum(d)
    
    if e<out:
        out=e
        
print(out)

Solution (Python):
def main():
    n = int(input())
    s = str(n)
    if n % 10 == 0:
        a = 0
        for i in s:
            a += int(i)

        f = True
        for i in range(len(s)):
            if i == 0:
                pass
            else:
                if s[i] != "0":
                    f = False
                    break
        if f:
            if s[0] == "1":
                print(10)
            else:
                print(a)
        else:
            print(a)

    else:
        a = 0
        for i in s:
            a += int(i)
        print(a)

if __name__ == "__main__":
    main()

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



sum_all = N
sum_tmp = N
tmp_A = 1
tmp_B = N
list_A_i = []

for A in range(1, N/2):
    B = N - A
    list_A = list(str(A))
    list_B = list(str(B))

    sum_tmp = sum(map(int, list_A))+ sum(map(int, list_B))
    if sum_tmp < sum_all:
        tmp_A = A
        tmp_B = B
        sum_all = sum_tmp


print sum_all

Solution (Python):
n=int(input())
res=n
for i in range(1,n):
  j=n-i
  i_=i
  j_=j
  if(i>j):break
  tmp=0
  while(i>0):
    tmp+=i%10
    i//=10
  while(j>0):
    tmp+=j%10
    j//=10
  res=min(res,tmp)
print(res)

Solution (Python):
n=int(input())
a,b=0,0
ans=[]

def pl(a,b):
    asum,bsum=0,0
    for i in range(len(a)):
        asum+=int(a[i])
    for i in range(len(b)):
        bsum+=int(b[i])
    return asum+bsum
        
for i in range(1,n):
    a=i ; b=n-i
    a=str(a) ; b=str(b)
    ans.append(pl(a,b))

print(min(ans))

Solution (Python):
def digitsum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

N = int(input())
summin = 10**5
for i in range(1,int(N/2)+1) : 
	A = i
	B = N - i

	sumab = digitsum(A) + digitsum(B)
	if (summin > sumab) :
		summin = sumab

print(summin)

Solution (Python):
l = list(input())
m = [int(k) for k in l]
s = sum(m)

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

Solution (Python):
N = int(input())
sum = 0
ls = [10**i for i in range(6)]
if N in ls:
    sum = 10
else:
    str_N = str(N)
    for i in range(len(str_N)):
        sum += int(str_N[i])

print(sum)

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

min = 10000000000
k = -1
flag = False
for i in range(1,6):
    if N / (10 ** i) == 1:
        print(10)
        flag = True
        break

if flag == False:
    sum = 0
    strN = str(N)
    for i in range(len(strN)):
        sum += int(strN[i])
    print(sum)

Solution (Python):
a = int(input())
ans = 1000
for i in range(1, (a//2) + 1):
    num = 0
    for j in str(i):
        num += int(j)
    for j in str(a-i):
        num += int(j)
    ans = min(num, ans)
print(ans)

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

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

def digit_sums_up(n):
    s = digit_sum(n)
    yield s

    while True:
        n += 1
        s += 1
        x = 10
        while n % x == 0:
            s -= 9
            x *= 10
        yield s

def digit_sums_down(n):
    s = digit_sum(n)
    yield s

    while True:
        x = 10
        while n % x == 0:
            s += 9
            x *= 10
        s -= 1
        n -= 1
        yield s

def solve(n):
    m = float('inf')
    for i, a, b in zip(range(n - 1), digit_sums_up(1), digit_sums_down(n - 1)):
        m = min(m, a + b)
    return m


main()

Solution (Python):
n=int(input())
nl=[]
for i in range(5):
    nl.append(int((n/10**(4-i))%10))

if sum(nl)>1:
    print(sum(nl))
else:
    print(10)

Solution (Python):



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

    ans = 999999
    for a in range(1, -(-n // 2)+1):
        t = digits(a) + digits(n-a)
        if(t < ans):
            ans = t

    print(ans)


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


if __name__ == "__main__":
    solve()

Solution (Python):
N = int(raw_input())
ans = 1000000
for A in range(1, 1+N/2):
  B = N - A
  a = 0
  b = 0
  tA = A
  tB = B
  for i in range(6)[::-1]:
    ta = tA/10**i
    tb = tB/10**i
    a += ta
    b += tb
    tA -= ta*(10**i)
    tB -= tb*(10**i)
  ans = min(ans, a+b)
print ans

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

if(n%10==0):
	print(10)
else:
	mini = 0
	sum1 = 0
	sum2 = 0
	for i in range(1,n):
		a = i
		b = n-i
		a1 = str(a)
		b1 = str(b)
		for j in a1:
			sum1+=(int)(j)
		for k in b1:
			sum2+=(int)(k)

		if(i==1):
			mini = sum1+sum2
		else:
			if((sum1+sum2)<mini):
				mini = sum1+sum2
	print(mini)

Solution (Python):
N = input()
n = [int(i) for i in N] 
if n[0] == 1 and n[1:] == [0 for _ in range(len(n)-1)]:
  print(10)
  exit()
cnt = 0
for i in n:
  cnt += i
print(cnt)

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

def func(a):
    result = 0
    
    while a != 0:
        result += a%10
        a = int(a/10)
        
    if result == 1:
        print('10')
    else:
        print(result)

func(a)

Solution (Python):
def sum_digit(n) :
    max_sum = 999999
    for n1 in range(1, n) :
        n2 = n - n1

        l_n1 = []
        l_n2 = []
        l_n1 = list(map(int, list(str(n1))))
        l_n2 = list(map(int, list(str(n2))))
        l_n1.append(0)
        l_n2.append(0)
       
        res = sum(l_n1) + sum(l_n2)
        if res < max_sum :
            max_sum = res
            tmp_n1 = l_n1
            tmp_n2 = l_n2
            
    return max_sum

n = int(input())
print(sum_digit(n))

Solution (Python):
import math                                                                     

N = int(input())
a_dsum = 0 
b_dsum = 0 
ans = 100000

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


for a in range(N + 1): 
    b = N - a 
    if sum(map(int, str(a))) > 1:
        a_dsum = digitSum(a)
    else:
        a_dsum = a
    if sum(map(int, str(b))) > 1:
        b_dsum = digitSum(b)
    else:
        b_dsum = b 
    tmp_sum = a_dsum + b_dsum
    if tmp_sum < ans:
        ans = tmp_sum

print(ans)

Solution (Python):
n = int(input())
dp = [0 for i in range(n)]
min = float("inf")
for i in range(1, n//2):
    a_sum = sum(map(int, list(str(i))))
    b_sum = sum(map(int, list(str(n - i))))
    c = a_sum + b_sum
    if(min > c):
        min = c
if min == float("inf"):
    min = n
print(min)

Solution (Python):
N=int(input())
ans=0
if N==10 or N==100 or N==1000 or N==10000 or N==100000:
    ans=10
else:    
    while  True:
        ans+=N%10
        N=N//10
        if N==0:
            break


    
        
            
print(ans)

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

for i in str(n):
  ans += int(i)

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

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

min_val = 1000000000
for i in range(1, int(N / 2)+1):
    A = i
    B = N - i
    val = sum(map(int, str(A))) + sum(map(int, str(B)))
    if val < min_val:
        min_val = val
print(min_val)

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

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

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

min_num = []
for n in range(1,int(N/2)+1):
	A = str(n)
	B = str(N-n)

	A_list = list(map(int,A))
	B_list = list(map(int,B))


	min_num.append(sum(A_list)+sum(B_list))

min_num.sort()
print(min_num[0])

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

ans = list()

for i in range(2, n // 2):
    a = sum([int(j) for j in str(i)])
    b = sum([int(j) for j in str(n - i)])
    ans.append(a + b)

if len(ans) > 0:
    print(min(ans))
else:
    print(2)

Solution (Python):
N = input()

ans = sum(map(int, N))
if ans != 1:
    print(ans)
else:
    print(10)

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

min = 99999999
for a in range(1, N):
    b = N - a
    a_sum = sum([int(i) for i in str(a)])
    b_sum = sum([int(i) for i in str(b)])
    if a_sum + b_sum < min:
        a_min = a
        b_min = b
        min = a_sum + b_sum
print(min)

Solution (Python):
n = input()

ans = n

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

	tmp = sum(a) + sum(b)
	if tmp < ans:
		ans = tmp

print ans

Solution (Python):
def digits_sum(n):
    st = str(n)
    ans = 0
    for s in st:
        ans += int(s)

    return ans

N = int(input())

if N % 10 == 0:
    a = N//2
else:
    a = N % 10

b = N - a

print(digits_sum(a) + digits_sum(b))

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

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

ans = 100000

for A in range(1, N):
    B = N - A
    a_sum = 0
    b_sum = 0
    for i in range(0, 5):
        a_sum += (A % (10 ** (i + 1))) // (10 ** i)
        b_sum += (B % (10 ** (i + 1))) // (10 ** i)
    ans = min(ans, a_sum + b_sum)

print(ans)

Solution (Python):
N = int(input())
min_cnt = 1000000
for A in range(1, N):
    cnt = 0
    B = N - A
    for i in str(A):
        cnt += int(i)
    for i in str(B):
        cnt += int(i)
    if min_cnt > cnt:
        min_cnt = cnt
print(min_cnt)

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

MIN_ab = 999999

for a in range(1,N):
    a_sum = 0
    b_sum = 0
    for a_split in str(a):
        a_sum +=  int(a_split)
    for b_split in str(N-a):
        b_sum +=  int(b_split)
    if a_sum + b_sum < MIN_ab:
        MIN_ab = a_sum + b_sum
        
print(MIN_ab)

Solution (Python):
N = input()
ans = 99999999
for A in range(1,N):
  B = N-A
  if A<=B:
    ans = min(ans, sum(map(int, str(A)+str(B))))
print ans

Solution (Python):


n = int(input())

res = 1000000

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

    s = 0

    al = list(str(a))
    for c in al:
        s += int(c)

    bl = list(str(b))
    for c in bl:
        s += int(c)

    if s < res:
        res = s

print(res)

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

    for a in range(1, N//2 + 1):
        
        b = N-a

        
        digits_sum = 0
        
        while a != 0:
            digits_sum += a%10
            a = a//10
            
        while b != 0:
            digits_sum += b%10
            b = b//10
            
        
        if digits_sum < minimum:
            minimum = digits_sum

    print(minimum)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
sum_list = [sum([int(e) for e in str(n - c)])  + sum([int(d) for d in str(c)]) for c in range(1, n)]
print(min(sum_list))

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

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




ANS=N
for a in range(1,N):
    FIRST=a%10+(a%100)//10+(a%1000)//100+(a%10000)//1000+(a%100000)//10000
    x=N-a
    SUB=x%10+(x%100)//10+(x%1000)//100+(x%10000)//1000+(x%100000)//10000

    SUM=FIRST+SUB

    if ANS!= SUM:
        ANS=min(ANS,SUM)

print(ANS)

Solution (Python):


N = int(input())

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


r = str(N)[1:]
if int(r) == 0:
    print(sum(map(int, list(str(N // 2)))) * 2)
    exit(0)


l = sum(map(int, list(str(N))))


print(l)

Solution (Python):
def main():
    N = int(input())
    C = N
    if N%2 == 1:
        n = N//2+1
    else:
        n = N//2
    for i in range(1,n+1):
        A = str(i)
        B = str(N-i)
        c = 0
        for k in range(len(B)):
            if k < len(A):
                c += int(A[-k-1])+int(B[-k-1])
            else:
                c += int(B[-k-1])
        C = min(C, c)
    return C

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

Solution (Python):
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def calc(i):
    s = str(i)
    sums = 0
    for e in s:
        sums += int(e)
    return sums

N = I()
lis = []
for i in range(1,N):
    lis.append(calc(i))
ans = 10**10
for i in range(N//2):
    ans = min(ans,lis[i]+lis[N-2-i])
print(ans)

Solution (Python):
def solve(N):
    digits = [int(d) for d in str(N)]
    tmp_ans = sum(digits)
    if tmp_ans == 1:
        return 10
    else:
        return tmp_ans







N = input()
print(solve(N))

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

ans = 0

if(n[0] == 1 and n.count(0) == len(n) -1):
  ans = 10

else:
  for i in range(len(n)):
    ans += n[i]

print(ans)

Solution (Python):



def main():
	n = int(input())
	nums = [int(x) for x in list(str(n))]
	x = [10 ** i for i in range(7)]
	for i1 in x:
		if n == i1:
			print(10)
			
			break
		else:
			for i2 in range(2, 10):
				if n == x * i2:
					print(i2)
					
					break

	else:
		print(sum(nums))
		

		

if __name__ == '__main__':
	main()

Solution (Python):
N=int(input())
suma=N
for i in range(1,N):
    factor_n1 = [int(x) for x in list(str(i))] 
    s1=sum(factor_n1)
    factor_n2 = [int(y) for y in list(str(N-i)) ]
    s2=sum(factor_n2)
    if(s1+s2<suma):
        suma=s1+s2
print(suma)

Solution (Python):
n = int(input())
ret = 10000000
for i in range(1, n//2 + 1):
    c = 0
    for s in str(i):
        c += int(s)
    for s in str(n - i):
        c += int(s)
    if ret > c:
        ret = c
print(ret)

Solution (Python):
n = int(input())
tmp = n
k = 0
while tmp > 0 :
    tmp = tmp//10
    k += 1 

ans = 1e10
for i in range(1,n) :
    tmp = n - i
    x = 0
    while tmp > 0 :
        x += tmp%10
        tmp = tmp//10
    tmp = i
    while tmp > 0 :
        x += tmp%10
        tmp = tmp//10
    ans = min(ans, x)

print(ans)

Solution (Python):
def wa(x):
  sum = 0
  fuga = str(x)
  a = len(fuga)
  hoge = list(fuga)
  for i in range(a):
    sum+=int(hoge[i])
  return sum



n = int(input())
min = 114514
for i in range(1,int(n/2)):
  po = wa(i) + wa(n - i)
  if(min > po):
    min = po

if n == 2:
  min = 2
print(min)

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

def calc(n):
    ans=0
    for i in range(len(n)):
        ans+=int(n[i])
    return ans

for i in range(1,n):
    a=i
    b=n-i
    m=min([calc(str(a))+calc(str(b)),m])

print(m)

Solution (Python):
import sys
import math
import itertools
from heapq import heapify, heappop, heappush
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque








def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)


def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))






def main():
    N = I()
    mid_N = math.ceil(N / 2) 

    ans = float('inf')
    for a in range(1,mid_N+1):
        b = N-a

        sum_digit_a = sum(map(int,list(str(a))))
        sum_digit_b = sum(map(int,list(str(b))))

        tmp = sum_digit_a + sum_digit_b
        ans = min(ans, tmp)

    print(ans)

   
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
digits = [int(i) for i in list(str(n))]

if n % (10 ** (len(str(n)) - 1)) != 0:
	print(sum(digits))
elif digits[0] != 1:
	print(digits[0])
else:
	print(10)

Solution (Python):
n = int(input())
tmp = n
k = 0
while tmp > 0 :
    tmp = tmp//10
    k += 1 

ans = 1e10
for i in range(1,n) :
    tmp = n - i
    x = 0
    while tmp > 0 :
        x += tmp%10
        tmp = tmp//10
    tmp = i
    while tmp > 0 :
        x += tmp%10
        tmp = tmp//10
    ans = min(ans, x)

print(ans)

Solution (Python):
N = input()
count = 0
if N[:2] == '10':
  count += 10
  N = N[2:]
else:
  count += int(N[0])
  N = N[1:]
while N:
  count += int(N[0])
  N = N[1:]
print(count)

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

ans = 1e5
for i in range(1, int(n/2)+1, 1):
    tmp = 0
    a = i
    b = n - i
    while(a != 0):
        tmp += a % 10
        a -= a % 10
        a /= 10
    while(b != 0):
        tmp += b % 10
        b -= b % 10
        b /= 10
    if(ans > tmp): ans = tmp

print(int(ans))

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

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

minimum = N * 100

def kakuiNoWa(x:int):
    digits = []
    for i in range(5):
        digits.append(int(str(int(x / (10 ** i)))[-1]))
    return sum(digits)

for i in range(1, int(N / 2) + 1):
    result = kakuiNoWa(i) + kakuiNoWa(N-i)
    minimum = min(minimum, result)

print(minimum)

Solution (Python):
from sys import stdin


def a(s):
    result = 0
    for c in s[::-1]:
        result += int(c)
    return result


def main():
    N = int(stdin.readline().rstrip())
    print(min([a(str(x)) + a(str(N - x)) for x in range(1, N // 2 + 1)]))


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
minimum =1000000000
for i in range(1,n//2):
    minimum = min(minimum,sum(list(map(int,list(str(i))))+list(map(int,list(str(n-i))))))
print(minimum if n!=2 and n!=3 else n)

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

m = float("inf")
for i in range(1,N):
    A = i
    B = N - i
    factor_A = [int(x) for x in list(str(A))]
    factor_B = [int(x) for x in list(str(B))]
    tmp = sum(factor_A) + sum(factor_B)
    if m > tmp:
        m = tmp

print(m)

Solution (Python):
n=input()
n2=list(map(int, n))
if sum(n2)==1 and sum(n2[1:])==0:print('10')
else: print(sum(n2))

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

ans = 0

if n % 10 == 0:
    ans = 10

else:
    for i in str(n):
        ans += int(i)

print(ans)

Solution (Python):


def addd(n):
    d = 0
    while n > 0:
        d += n % 10
        n //= 10
    return d


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

    best = 9 * 20
    for i in range(1, N):
        j = N - i
        best = min(best, addd(i) + addd(j))

    print(best)

if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
minmum = 10**5
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

for i in range(1, N):
    j = N - i
    min_sum = digitSum(i) + digitSum(j)
    if min_sum < minmum:
        minmum = min_sum

print(minmum)

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

minsum = 900000

for i in range(n - 1):
    count = 0
    a = i +1
    b = n -i -1
    for c in str(a):
        count += int(c)
    for c in str(b):
        count += int(c)
    if count < minsum:
        minsum = count
print(minsum)

Solution (Python):
n = int(input())
nmin = 10000000
for n1 in range(1,n):
    n2 = n-n1
    nsum = sum(map(int, list(str(n1))))+sum(map(int, list(str(n2))))

    if nmin > nsum:
        nmin = nsum
print(nmin)

Solution (Python):
N=int(input())
m=45
for a in range(1,N):
    b=a//100000
    c=(a-b*100000)//10000
    d=(a-b*100000-c*10000)//1000
    e=(a-b*100000-c*10000-d*1000)//100
    f=(a-b*100000-c*10000-d*1000-e*100)//10
    g=a-b*100000-c*10000-d*1000-e*100-f*10
    h=(N-a)//100000
    i=(N-a-h*100000)//10000
    j=(N-a-h*100000-i*10000)//1000
    k=(N-a-h*100000-i*10000-j*1000)//100
    l=(N-a-h*100000-i*10000-j*1000-k*100)//10
    n=N-a-h*100000-i*10000-j*1000-k*100-l*10
    m=min(m,b+c+d+e+f+g+h+i+j+k+l+n)
    
print(m)

Solution (Python):
N = int(input())
M = 150
for A in range(1,int(round(N/2+2))):
    B = N - A
    AS = sum([int(x) for x in list(str(A))])
    BS = sum([int(x) for x in list(str(B))])
    S = AS+BS
    if(S<M):
        M=S
print(M)

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

def func(a):
    digits = []
    temp = a
    while temp != 0:
        digits.append(temp%10)
        temp = int(temp/10)
    result = sum(digits)
    if result == 1:
        print('10')
    else:
        print(result)

func(a)

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

result = N
for A in range(1, N):
	tmp = sum(list(map(int, list(str(A))))) + sum(list(map(int, list(str(N - A)))))
	if tmp < result:
		result = tmp

print(result)

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

def str2each_num(s):
    li = [int(_) for _ in s]
    return li


ans = min([sum(str2each_num(str(i))) + sum(str2each_num(str(n - i))) for i in range(1, n//2+1)])
print(ans)

Solution (Python):
def main():
    N = input()
    if N%10 != 0:
        print(digitSum(N))
    else:
        print(digitSum(N)*10)

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

if __name__ == '__main__':
    main()

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

    total = float('inf')
    for a in range(1, N):
        b = N - a
        n = 0
        while a > 0:
            n += a % 10
            a //= 10
        while b > 0:
            n += b % 10
            b //= 10
        total = min(total, n)

    print(total)

main()

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

minimum = N

for i in range(1,N):
    total = 0
    A = i
    B = N-i
    a = str(A)
    b = str(B)
    for j in range(len(a)):
        total = total + int(a[j])
    for k in range(len(b)):
        total = total + int(b[k])
    minimum = min(minimum,total)

print(minimum)