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):
def resolve():
    N=int(input())
    s=str(N)
    val=0
    for i in s:
        val+=int(i)
    print(10 if N in [10, 100, 1000,1000,10000,100000] else val)
    


resolve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    ans=10**18
    for i in range(1,n):
        x=sum([int(j) for j in str(i)])+sum([int(j) for j in str(n-i)])
        ans=min(ans,x)
    print(ans)
resolve()

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

Solution (Python):

N = int(input())
results = []
for i in range(1,N):
    results.append(sum(map(int,str(i))) + sum(map(int,str(N-i))))
print(min(results))

Solution (Python):
N = int(input())
results = ''
for A in range(N + 1):
    if A == 0:
        continue

    BBB = []
    AAA = []

    B = N - A
    if B >= 1:
        for b in range(len(str(B))):
            BBB.append(int(str(B)[b]))

        for a in range(len(str(A))):
            AAA.append(int(str(A)[a]))
        sums = sum(BBB) + sum(AAA)
        if sums == 1:
            print(A)
            print(B)
            print(AAA)
            print(BBB)

        if not results:
            results = sums
        else:
            if results > sums:
                results = sums
print(results)

Solution (Python):
N = int(input())
results = []
for i in range(1,N):
    results.append(sum(map(int,str(i))) + sum(map(int,str(N-i))))
print(min(results))

Solution (Python):
n = int(input())
N = n//2
ans = float("INF")
for i in range(1,N+1):
  a,b = list(str(i)), list(str(n-i))
  A,B = sum(list(map(int, a))), sum(list(map(int, b)))
  if ans > A+B: ans = A+B
print(ans)

Solution (Python):
n=int(input())
ans=100000
for a in range(1,n):
    b=n-a
    suma=sum(list(map(int, list(str(a)))))
    sumb=sum(list(map(int, list(str(b)))))
    
    ans=min(ans,sumb+suma)
print(ans)

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

ans = 10000000

for i in range(1,n//2+2):
    memo = 0
    first = str(i)
    second = str(n-i)
    for j in first:
        memo += int(j)
    for j in second:
        memo += int(j)
    ans = min(memo,ans)

print(ans)

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

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

total = []
for i in range(1, N):
    x = sum(list(map(int, str(i)))) + sum(list(map(int, str(N - i))))
    total.append(x)

print(min(total))

Solution (Python):
N = int(input())
result = []

for A in range(1, N):
    B = N - A
    A = str(A)
    B = str(B)
    A_sum = sum(list(map(int, A)))
    B_sum = sum(list(map(int, B)))
    result.append(A_sum + B_sum)

print(min(result))

Solution (Python):
import sys

input = sys.stdin.readline


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

    ans = float("inf")
    for A in range(1, N):
        B = N - A
        total = sum(int(s) for s in str(A)) + sum(int(s) for s in str(B))
        if total < ans:
            ans = total

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

N = int(input())

if N in [10**i for i in range(1, 6)] :
    print("10")
else :
    print(sum(map(int, str(N))))

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

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

cdt = None
for a in range(1, N):
    b = N - a
    x = sum([int(c) for c in str(a)]) + sum([int(c) for c in str(b)])
    if cdt is None or cdt > x:
        cdt = x
print(cdt)

Solution (Python):
n = int(input())
if n % 10 == 0:
  print(10)
else:
  result = sum(list(map(int, str(n))))
  print(result)

Solution (Python):
import math
def digsum(A):
  n = math.floor(math.log10(A))
  tmp = 0
  for i in range(n,0,-1):
    tmp += A // (10**i)
    A = A % (10**i)
  return tmp + A
  
N = int(input())
ans = 10**9
for i in range(1,N//2+1):
  ans = min(ans, digsum(i) + digsum(N-i))
print(ans)

Solution (Python):
N = int(input())
ans = 100
for A in range(1, N):
    B = N - A
    tmp = sum(list(map(int, str(A)))) + sum(list(map(int, str(B))))
    if ans > tmp:
        ans = tmp
print(ans)

Solution (Python):
n = int(input())
sum_min = 100000
for i in range(1,n):
    i_sum = 0; j_sum = 0
    j = n-i
    i = str(i); j = str(j)
    for k in range(len(i)):
        i_sum += int(i[k])
    for k in range(len(j)):
        j_sum += int(j[k])
    tmp_sum  = i_sum + j_sum
    if sum_min >tmp_sum :
        sum_min = tmp_sum
print(sum_min)

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

    re = 1000
    for a in range(1, (n//2)+1):
        b = n - a
        sumnum = 0
        while a >= 1:
            sumnum += a % 10
            a = a //10
        while b >= 1:
            sumnum += b % 10
            b = b //10
        if re > sumnum:
            re = sumnum

    print(re)
resolve()

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

Solution (Python):
from sys import stdin


def find_sum_of_digits(n, base=10):
    _sum = 0
    while n>0:
        _sum += n%base
        n //= base
    return _sum


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  
    
    cnt = float('inf')
    for A in range(1,N):
        B = N-A
        sum_ = find_sum_of_digits(A)+find_sum_of_digits(B)
        cnt = min(cnt,sum_)
    
    print(cnt)

Solution (Python):
ans=float("INF")
n=int(input())

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

Solution (Python):
N = int(input())
ans = 100
for i in range(1, N // 2 + 1):
  A = str(i)
  B = str(N - i)
  t = 0
  for j in A:
    t += int(j)
  for j in B:
    t += int(j)
  ans = min(ans, t)
print(ans)

Solution (Python):
n = int(input())
total=10*100

def sum_digits(num):
    sum = 0
    while True:
        if num == 0:
            break
        sum += num%10
        num //= 10
    return sum

for a in range(1, n):
    b = n - a
    total = min(total, sum_digits(a)+sum_digits(b))

print(total)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=input()
    ans=0
    if int(n)%10!=0:
        for i in range(len(n)):
            ans+=int(n[i])
    else:
        ans=10
    print(ans)
resolve()

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

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

def digitSum(number):
    sum = 0
    while number > 0:
        sum += number % 10
        number //= 10
    return sum

for i in range(1, n + 1):
    a = i
    b = n - a
    if b < a:
        break
    total.append(digitSum(a) + digitSum(b))
print(min(total))

Solution (Python):
def digitsum(N): 
    return sum(int(s) for s in str(N))
ans=INF=9*10
N=int(input())
for a in range(1,N):
    b=N-a
    ans=min(digitsum(a)+digitsum(b),ans)
print(ans)

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

for i in range(1,N):
  j = N-i
  ist = str(i)
  jst = str(j)
  iarray = list(map(int ,ist))
  jarray = list(map(int ,jst))
  isum = sum(iarray)
  jsum = sum(jarray)
  if isum + jsum < ans:
    ans = isum + jsum
print(ans)

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

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

minv = 1 << 30

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

for i in range(1, n//2 + 1):
	a = i
	b = n - i
	minv = min(digit_sum(a) + digit_sum(b), minv)

print(minv)

Solution (Python):

N = int(input())
n = N // 2 if N % 2 == 0 else N // 2 + 1
min_sum = 9999

for i in range(1, n + 1):
    sum_digits = 0
    A = i
    B = N - i

    while A != 0:
        sum_digits += A % 10
        A //= 10
    
    while B != 0:
        sum_digits += B % 10
        B //= 10
        
    min_sum = min(min_sum, sum_digits)

print(min_sum)

Solution (Python):
n = int(input())
mn = float("inf")
for i in range(1,n):
  count = 0
  for s in str(i):
    count += int(s)
  for p in str(n-i):
    count += int(p)
  if count < mn:
    mn = count
print(mn)

Solution (Python):
def f(x):
    return x%10+f(x//10) if x else 0
n = int(input())
print(min([f(i)+f(n-i) for i in range(1,n)]))

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

ans = 10**3
for a in range(1,n):
    b = n-a
    tmp = 0
    for j in reversed(range(len(str(a)))):
        tmpa = (a//(10**j))
        a -= tmpa*(10**j)
        tmp += tmpa
    for j in reversed(range(len(str(b)))):
        tmpb = (b//(10**j))
        b -= tmpb*(10**j)
        tmp += tmpb

    ans = min(ans,tmp)

print(ans)

Solution (Python):
num = int(input())
if num % 10 == 0:
    ans = 10
else:   
    s = str(num)
    array = list(map(int, s))
    ans = sum(array)
print (ans)

Solution (Python):
n = int(input())
if n % 10 == 0:
    print(10)
else:
    print(sum([int(i) for i in str(n)]))

Solution (Python):
n = int(input())
if n % 10 == 0:
    print(10)
else:
    ans = 0
    for s in str(n):
        ans += int(s)
    print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n=ii()
ans=10**10
for i in range(1,n):
    a=sum(list(map(int,list(str(i)))))
    b=sum(list(map(int,list(str(n-i)))))
    ans =min(ans,a+b)
print(ans)

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

Solution (Python):
def sum_of_digits(n):
	mod=0
	num=[]
	while n !=0:
		mod=n%10
		n=n//10
		num.append(mod)
	return (sum(num))

N=int(input())
sum_of_all =0
for i in range(1,N//2+2):
	sum1=sum_of_digits(i)
	sum2=sum_of_digits(N-i)
	sum_of_all=sum1+sum2
	if i ==1:
		ans=sum_of_all
	elif ans>sum_of_all:
		ans=sum_of_all
print(ans)

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


def digits_sum(num):
	sum = 0
	
	for s in str(num):
		sum += int(s)
	
	return sum


N = int(input())
ans = sys.maxsize

if N < 10:
	max_index = N
else:
	max_index = N // 2

for A in range(1, max_index):
	B = N - A
	sum = digits_sum(A) + digits_sum(B)
	ans = min(ans, sum)
	
print(ans)

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

f_x=sum(map(int,str(N-1)))
count=int((f_x)+1)
for a in range(1,N):
    f_x_a=sum(map(int,str(a)))
    b=N-a
    f_x_b=sum(map(int,str(b)))
    ans=int((f_x_a)+(f_x_b))

    if count>=ans:
        count=ans
print(count)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    n = int(input())
    def digsum(n):
        res = 0
        while n:
            res += n%10
            n //= 10
        return res
    res = 1000000
    for i in range(1, n):
        a = i
        b = n-i
        res = min(res, digsum(a)+digsum(b))
    print(res)

if __name__ == '__main__':
    main()

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

def digit_sum(a, b):
    ab_sum = 0
    for i in range(1, len(str(a))+1):
        ab_sum += a % 10
        a = a // 10
    
    for i in range(1, len(str(b))+1):
        ab_sum += b % 10
        b = b // 10
    
    return ab_sum

min_sum = float("inf")
for i in range(1, (N//2)+1):
    a = i
    b = N - i
    if digit_sum(a, b) < min_sum:
        min_sum = digit_sum(a, b)

print(min_sum)

Solution (Python):
from sys import stdin
import math


N = int(stdin.readline().rstrip())

A=0
B=N-A


def sum_of_digit(n):
    total = 0
    s = str(n)
    for i in range(len(s)):
        total = total + int(s[i:i+1])

    return total


minimum = 9999999999

for a in range(1,N):
    a_total = sum_of_digit(a)
    b = N - a
    b_total = sum_of_digit(b)
    minimum = min(minimum, a_total + b_total)

print(minimum)

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

ans = float('inf')
a, b = 1, N-1
while a <= b:
  sum_d_a = sum(map(int, str(a)))
  sum_d_b = sum(map(int, str(b)))
  ans = min(ans, sum_d_a + sum_d_b)
  a += 1
  b -= 1

print(ans)

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

ans=9999999999999
for a in range(1,n):
    b=n-a
    a_sum=sum(list(map(int,list(str(a)))))
    b_sum=sum(list(map(int,list(str(b)))))
    ab_sum=a_sum+b_sum
    if(ans>ab_sum):
        ans=ab_sum

print(ans)

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

Solution (Python):



import sys





def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(inputNum):
    result = 0
    
    totalDigit = 0
    inputStr = str(inputNum)
    for j in range(0, len(inputStr)):
        totalDigit = totalDigit + int(inputStr[j])
    if totalDigit == 1:
        result = 10
    else:
        result = totalDigit
    return result


if __name__ == "__main__":
    print("{}".format(solver(II())))

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

    return ans

n = int(input())
ans = 100
for a in range(1,int(n/2)+1):
    ans = min(ans, digit_sum(a)+digit_sum(n-a))

print(ans)

Solution (Python):
def readInt():
    return list(map(int,input().split()))
n = int(input())
l = []
for i in range(1,n):
    ans = 0
    j = i
    k = n-i
    while j>0:
        ans += int(j%10)
        j = int(j/10)
    while k>0:
        ans += int(k%10)
        k = int(k/10)
    l.append(ans)

print(min(l))

Solution (Python):
n = input()
print(10 if len(set(n)) == 2 and n[:2] == "10" else sum(int(i) for i in n))

Solution (Python):

import sys  
import numpy as np

input = sys.stdin.readline

N = input()
sum_ = 0

for i in list(N)[:-1]:
    
    sum_+=int(i)

if sum_ != 1:
    print(sum_)
else :
    print(10)

Solution (Python):



import sys





def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(inputNo):
    result = 36
    for a in range(1, inputNo, +1):
        strA = str(a)
        strB = str(inputNo-a)
        checkDigitAdd = 0
        for j in range(0, len(strA)):
            checkDigitAdd = checkDigitAdd + int(strA[j])
        for j in range(0, len(strB)):
            checkDigitAdd = checkDigitAdd + int(strB[j])
        if checkDigitAdd < result:
            result = checkDigitAdd

    
    return result


if __name__ == "__main__":
    print("{}".format(solver(II())))

Solution (Python):
def calc(n):
    return sum(ord(c) - ord('0') for c in str(n))

def solve():
    n = int(input())
    ans = 1 << 60
    for i in range(1, n):
        a = n - i
        ans = min(ans, calc(a) + calc(i))
    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):



import sys





def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def digitSum(inputNum):
    result = 0
    inputNumStr = str(inputNum)
    for j in range(0, len(inputNumStr)):
        result = result + int(inputNumStr[j])
    return result


def solver(inputNum):
    result = 10**5
    
    for j in range(1, inputNum):
        total = digitSum(j)+digitSum(inputNum-j)
        if total <= result:
            result = total
    return result


if __name__ == "__main__":
    print("{}".format(solver(II())))

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

def  DigitsSum(n):
    s = 0
    while True:
        if n // 10 != 0:
            s += n % 10
            n = n // 10
        else:
            s += n
            break
    return s

S = 0

for i in range(1,int(N/2)+1):
    A = i
    B = N - i
    if S == 0 :
        S = DigitsSum(A)+DigitsSum(B)
    else:
        if S > DigitsSum(A)+DigitsSum(B):
            S = DigitsSum(A)+DigitsSum(B)
        else:
            continue

print(S)

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

A = 0
B = 0

result = 0
judg = 100000

for i in range(N-1):
    A = i + 1
    B = N - A
    for ii in range(len(str(A))):
        A_re = A % 10
        A = int(A / 10)
        result += A_re
    for iii in range(len(str(B))):    
        B_re = B % 10
        B = int(B / 10)
        result += B_re
    if judg>result:
        judg = result
    result = 0

print(judg)

Solution (Python):
n=int(input())
a=10*5
def k(n):
    s=tuple(map(int,tuple(str(n))))
    return sum(s)

for i in range(1,n):
    s=k(i)+k(n-i)
    if a>s:
        a=s
print(a)

Solution (Python):
n=int(input())
ans=10**6
for i in range(1,n+1):
    a=i
    b=n-i
    if a<=b:
        asum=sum(map(int,str(a)))
        bsum=sum(map(int,str(b)))
        if ans>(asum+bsum):
            ans=asum+bsum
print(ans)

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

Solution (Python):
N = int(input())
ans = 1000000
for i in range(1, N+1):
    A = i
    B = N - i
    if A <= B:
        Asum = sum(map(int, str(A)))
        Bsum = sum(map(int, str(B)))
        if ans > (Asum + Bsum):
            ans = Asum + Bsum
print(ans)

Solution (Python):
from collections import Counter
 
n = input()
c = Counter(n)
c.pop('0', None)
 
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())
a=100
def k(n):
    s=tuple(map(int,tuple(str(n))))
    return sum(s)
for i in range(1,N):
    s=k(i)+k(N-i)
    if s<a:
        a=s
print(a)

Solution (Python):
n=int(input())
if n in [10,100,1000,10000,100000]:
    print(10)
else:
    sum=0
    for i in range(len(str(n))):
        sum+=n%10
        n=n//10
    print(sum)

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

v = float("inf")
for a in range(1, N):
    b = N - a
    c = sum(map(int, str(a))) + sum(map(int, str(b)))
    if c < v:
        v = c
print(v)

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

def digsum(n):
    total = 0
    while n > 0:
        total += n%10
        n /= 10
        n = int(n)
    return total

ans = float('inf')
for i in range(2, N//2+2):
    A = i
    B = N-A
    s = digsum(A)+digsum(B)
    ans = min(ans, s)

print(ans)

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul, add
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

N = INT()

ans = INF

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

Solution (Python):

n = int(input())

def DegitSum(x):
    ans = 0
    while x > 0:
        ans += x%10
        x = x // 10
    return ans
    
res = 10**8
for a in range(1, n//2+1):
    b = n - a
    if DegitSum(a) + DegitSum(b) < res:
        res = DegitSum(a) + DegitSum(b)
        
print(res)

Solution (Python):
a = int(input())
lim = a // 2
soma_lista = []
menor = 100000
for i in range(a - 1, lim, -1):
    b = str(a - abs(i)) + str(abs(i))
    soma = 0
    for digit in b:
        soma += int(digit)
    if soma < menor:
        menor = soma
if a == 2:
    print(a)
else:
    print(menor)

Solution (Python):
n = int(input())
ans = 114514
for i in range(1, n):
    a = list(map(int, list(str(i))))
    b = list(map(int, list(str(n - i))))
    c = sum(a) + sum(b)
    ans = min(ans, c)
print(ans)

Solution (Python):
def main():
    n = int(input())
    a = n - 1
    b = 1
    menor = soma_digitos(a) + soma_digitos(b)
    temp = 0
    for i in range(n-2):
        a -= 1
        b += 1
        temp = soma_digitos(a) + soma_digitos(b)
        if menor > temp:
            menor = temp
    print(menor)

def soma_digitos(n):
    soma = 0
    while n >= 1:
        soma += n%10
        n = n//10
    return soma
main()

Solution (Python):
numero = int(input())
soma = 0
minimo = 100000
for aux in range(numero-1,1,-1):
    prim = str(aux)
    seg = str(numero - aux)
    for x in range(len(prim)):
        soma += int(prim[x])
    for x in range(len(seg)):
        soma += int(seg[x])
    if soma < minimo :
        minimo = soma
    soma = 0
if numero == 2:
    print(numero)
else:
    print(minimo)

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

if n%10 == 0 and n != 10:
    print(10)
else:
    a,b = 1,0
    sA, sB= 0,0
    soma = []

    while a<=n:
        b=n-a

        for i in str(a):
            sA+=int(i)
        for j in str(b):
            sB+=int(j)
        soma.append(sA+sB)
    
        a=a+1
    print(min(soma))

Solution (Python):
n = input()

powers10 = [10**i for i in range(1, 6)]
print(10 if int(n) in powers10 else sum(int(d) for d in n))

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


x = n / 2
result = 0

if n <= 10:
    result = n
elif (n <= 100 and not n % 10) or not x % 10:
    result = 0

    while(x > 0):
        result += int(x % 10)
        x = x // 10
    result = result* 2
else:
    if n % 10:
        x = n % 10
    elif n % 10: 
        x = n % 100
    elif n % 1000: 
        x = n % 1000
    elif n % 10000: 
        x = n % 10000
    n = n - x
    while(x > 0):
        result += x % 10
        x = x // 10

    while(n > 0):
        result += n % 10
        n = n // 10
print(result)

Solution (Python):
line = input()
num = [int(n) for n in line.split()][0]
number_of_sums = num//2 + 1 + 1*num % 2
smallest_sum = 100000
for i in range(1, number_of_sums):
    first_number = i
    second_number = num-i
    summation = 0
    while first_number and summation < smallest_sum:
        summation += first_number % 10
        first_number //= 10
    while second_number and summation < smallest_sum:
        summation += second_number % 10
        second_number //= 10
    if smallest_sum > summation:
        smallest_sum = summation
print(smallest_sum)

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

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


arr = []
rev_arr = []
for n in range(1,num):
    arr.append(n)
rev_arr = arr[::-1]

final_arr = []
for n in range(num-1):
    val = digitSum(arr[n]) + digitSum(rev_arr[n])
    final_arr.append(val)

print(min(final_arr))

Solution (Python):
def sum_value(n):
    n = str(n)
    sum = 0
    for i in range(len(n)):
        sum+=int(n[i])
    return sum

N = int(input())
A = int(N/2)
B = int(N/2) if N%2 == 0 else int(N/2)+1
menor = -1
for i in range(int(N/2)):
    menor = sum_value(A+i)+sum_value(B-i) if menor < 0 else min(sum_value(A+i)+sum_value(B-i), menor) 
print(menor)

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

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

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

print(min(lis))

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

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

def wa(x):
    s = 0
    while x > 0:
        s += x % 10
        x = int(x / 10)
    return s
L = []
for i in range(1,N):
    A = i
    B = N - i
    x = wa(A) + wa(B)
    L.append(x)
    
L = sorted(L)
    
print(L[0])

Solution (Python):

import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s

n=int(input())
if is_power(n,10):
    print(10)
else:
    n=str(n)
    n=list(n)
    n=list(map(int,n))
    print(sum(n))

Solution (Python):
n = int(input())
A = []
for i in range(1, n // 2 + 1):
    a = str(i)
    b = str(n - i)
    t = 0
    for j in a:
        t += int(j)
    for k in b:
        t += int(k)
    A.append(t)
print(min(A))

Solution (Python):
n = int(input())
def func(x):
  answer = list(map(int,str(x)))
  return sum(answer)
nums = []
for a in range(1,n):
  b = n - a
  num = func(a) + func(b)
  nums.append(num)
print(min(nums))

Solution (Python):
n = int(input())
def digsum(x):
  ret = 0
  while x > 0:
    ret += x % 10
    x //= 10
  return ret
ans = 10**5
for i in range(1, (n+1)//2+1):
  ans = min(ans, digsum(i) + digsum(n-i))
print(ans)

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
ans = 100
def colsum(s):
    ret = 0
    for i in s:
        ret += int(i)
    return ret

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

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

mini=float("inf")
for A in range(1,N):
  B=N-A
  sa=str(A)
  sb=str(B)
  sum_a=0
  sum_b=0
  for st in sa:
    sum_a += int(st)
  for st in sb:
    sum_b += int(st)
  mini= min(mini, sum_a+sum_b)  
  
print(mini)

Solution (Python):
from math import log10
N=input()

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

Solution (Python):

def inputlist(): return [int(j) for j in input().split()]


N = int(input())
def wa(N) : 
    S = str(N)
    array = list(map(int,S))
    return sum(array)
ans = 10**9+7
for i in range(1,N):
    l = i
    r = N-i
    suma = wa(l) + wa(r)
    ans = min(ans,suma)
print(ans)

Solution (Python):

n=int(input())

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

min=9999999

for a in range(1,n):
    b=n-a
    sum_a=digitSum(a)
    sum_b=digitSum(b)
    sum_ab=int(sum_a)+int(sum_b)
   
    if sum_ab < min:
        min=sum_ab

print(min)