Problem:
 Score : 200 points    Problem Statement Takahashi has two positive integers A and B .  It is known that A plus B equals N .
Find the minimum possible value of "the sum of the digits of A " plus "the sum of the digits of B " (in base 10 ).      Constraints  2 ≤ N ≤ 10^5  N is an integer.         Input Input is given from Standard Input in the following format:  N       Output Print the minimum possible value of "the sum of the digits of A " plus "the sum of the digits of B ".        Sample Input 1 15      Sample Output 1 6  When A=2 and B=13 , the sums of their digits are 2 and 4 , which minimizes the value in question.       Sample Input 2 100000      Sample Output 2 10

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

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

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


def f(x):
    ret = 0
    while x:
        x, r = divmod(x, 10)
        ret += r
    return ret


ret = 10 ** 9
for a in range(1, N):
    b = N - a
    ret = min(ret, f(a) + f(b))
print(ret)

Solution (Python):
N=input()
import re
if re.match('10+',N):
    print(10)
else:
    ans=0
    for n in N:
        ans+=int(n)
    print(ans)

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

ans=10**10

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

    X = sum(A) + sum(B)

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

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

def f(n):
    ans = 0
    for s in str(n):
        ans += int(s)
    return ans

ans = float("INF")
for i in range(1, N):
    j = N-i
    ans = min(ans, f(i) + f(j))
    
print(ans)

Solution (Python):
N = int(input())
ans = float('inf')
for i in range(1, N):
    j = N-i
    i_str = str(i)
    j_str = str(j)
    i_sum, j_sum = 0, 0
    for p in range(len(i_str)):
        i_sum += int(i_str[p])
    for q in range(len(j_str)):
        j_sum += int(j_str[q])
    ans = min(ans, i_sum+j_sum)

print(ans)

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

def f(k):
    s = str(k)
    n = len(s)
    ans = 0
    for i in range(n):
        ans += int(s[i])
    return ans

ans = float("INF")
for i in range(1, N):
    j = N-i
    t = f(i) + f(j)
    ans = min(ans, t)

print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
MIN = 10**18
for i in range(1, N):
    val = 0
    a, b = i, N-i
    while a or b:
        x = a%10
        y = b%10
        val += (x+y)
        a //=10
        b //= 10
    MIN = min(MIN, val)

print(MIN)

Solution (Python):
n=int(input())
ans=10**18
for a in range(1,n):
  b=n-a
  tmp=0
  for aa in str(a):
    tmp+=int(aa)
  for bb in str(b):
    tmp+=int(bb)
  ans=min(ans,tmp)
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):
def calc(a):
  ret = 0
  while a != 0:
    ret += a % 10
    a //= 10
  return ret

def resolve():
  n = int(input())
  ans = 1000000000
  for a in range(1, n):
    b = n - a
    ans = min(ans, calc(a) + calc(b))
  print(ans)
  return

if __name__ == "__main__":
  resolve()

Solution (Python):
n=int(input())
while n%10==0 and n!=10:
  n=n//10
if n==10:
  print(10)
else:
  s=str(n)
  ans=0
  for i in range(len(s)):
    ans+=int(s[i])
  print(ans)

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

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

def f(n):
    n = str(n)
    res = 0
    for i in range(len(n)):
        res += int(n[i])
    return res

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()


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


def solve():
    ans = 1 << 60
    for a in range(1, N // 2 + 2):
        b = N - a
        ans = min(ans, dsum(a) + dsum(b))
    return ans


print(solve())

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    ans = INF

    for x in range(1, n):
        score = 0
        a = x
        b = n - a
        while a > 0:
            score += a % 10
            a //= 10
        while b > 0:
            score += b % 10
            b //= 10
        ans = min(ans, score)

    print(ans)


if __name__ == '__main__':
    main()

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())
s = 0
while True:
    s += n % 10
    n = n // 10
    if n == 0:
        break

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

Solution (Python):
n = int(input())
min_k = 10000000000
for i in range(1,n//2+1):
    sum_k = 0
    a = str(i)
    b = str(n-i)
    for j in a:
        sum_k += int(j)
    for j in b:
        sum_k += int(j)
    min_k = min(min_k,sum_k)
print(min_k)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

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

def Digits_sum(a):
    a_s = str(a)
    sum_ = 0
    for i in a_s:
        sum_ += int(i)
    return sum_

ans = 10000

for i in range(1,(n//2)+1):
    A = i
    B = n-A
    sum_ = Digits_sum(A)+Digits_sum(B)
    ans = min(ans,sum_)
print(ans)

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

mn = 10**10
for a in range(1, n // 2+1):
    mn = min(mn, sum(int(i) for i in str(a)) + sum(int(i) for i in str(n-a)))
print(mn)

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

for A in range(1,1+int(N/2)):
  tmp = 0
  B = N - A
  A = str(A)
  B = str(B)
  for i in range(0,len(A)):
    tmp += int(A[i])
  for i in range(0,len(B)):
    tmp += int(B[i])
  ans.append(tmp)

print(min(ans))

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

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

ans = 1000000
for i in range(1,n):
  if ans > digit(i) + digit(n-i):
    ans = digit(i) + digit(n-i)
print(ans)

Solution (Python):
n = int(input())
a = [10 ** 1,10 ** 2,10 ** 3,10 ** 4,10 ** 5]
if n in a:
    print(10)
    exit(0)

l = 10 ** 5
for i in range(1,n):
    m = n
    p = i
    q = m - 1
    z = 0
    while p > 0:
        z += p % 10
        p = p // 10
    while q > 0:
        z += q % 10
        q = q // 10
    l = min(l,z)

print(l)

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

res = 0

while n:
    res += n % 10
    n //= 10
if res == 1:
    print(10)
else:
    print(res)

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

m=[]
for i in range(1,n//2+2):
    a=0
    k=i
    l=n-i
    while k>0 or l>0:
        a=a+k%10+l%10
        k=k//10
        l=l//10

    m.append(a)

print(min(m))

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

Solution (Python):
n = int(input())
res = 10000
for i in range(1, n // 2 + 1):
  s = str(i)
  t = str(n - i)
  cnt = 0
  for j in s + t:
    cnt += int(j)
  res = min(res, cnt)
print(res)

Solution (Python):

n = int(input())

ans = 999999

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

    k = sum(a) + sum(b)

    if k < ans:
        ans = k

print(ans)

Solution (Python):
N = int(input())
a = 0
b = 0
ans = 0
s = 10000
for i in range(1,int(N/2) + 1):
    a = i
    b = N - i
    ans = 0
    while 1:
        ans += a % 10 + b % 10
        a = a // 10
        b = b // 10
        if a == 0 and b == 0:
            if ans < s:
                s = ans
            break
print(s)

Solution (Python):
n = int(input())
ans = 46
for i in range(1, n):
    tmp = 0
    j = n - i
    while i > 0:
        tmp += i % 10
        i //= 10
    while j > 0:
        tmp += j % 10
        j //= 10
    ans = min(tmp, ans)
print(ans)

Solution (Python):
N = int(input())
N_half = N//2

min_sum = N

for A in range(1,N_half+1):
  digit_a = 0
  digit_b = 0
  B = N-A
  while A!=0:
    num = A%10
    digit_a += num
    A = A//10
  while B!=0:
    num = B%10
    digit_b += num
    B = B//10
  digit = digit_a + digit_b
  if digit<min_sum:
    min_sum = digit

print(min_sum)

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

def sum0f(n):
    sum=0
    while n>0:
        sum+=n%10
        n//=10
    return sum

list=[]    
for a in range(1,n):
    list.append(sum0f(a)+sum0f(n-a))
    
print(min(list))

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

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

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

Solution (Python):
N=int(input())
ans=100000000000
for A in range(1,N):
    B=N-A
    sa=0
    sb=0
    for i in range(len(str(A))):
        sa+=A%10
        A=(A-A%10)//10
    for j in range(len(str(B))):
        sb+=B%10
        B=(B-B%10)//10
    if sa+sb<ans:
        ans=sa+sb

print(ans)

Solution (Python):
n = int(input())
rt = n
def sums(st: str):
  return sums(st[:-1])+int(st[-1]) if len(st) >1 else int(st)
for a in range(1,n//2):
  b = n - a
  tmp = sums(str(b)) + sums(str(a))
  if tmp < rt:
    rt = tmp
print(rt)

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

Solution (Python):
import numpy as np


def sum_of_digits(x):
  res = np.zeros_like(x)
  for i in range(len(x)):
    s = 0
    while x[i] > 0:
      s += x[i] % 10
      x[i] = int(x[i] / 10)
    res[i] = s
  return res


n = int(input())
a = np.arange(1, n)
b = a[::-1].copy()
print(np.min(sum_of_digits(a) + sum_of_digits(b)))

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

Solution (Python):
n=int(input())
if n in [10,100,1000,10000,100000]:
  print(10)
else:
  x=str(n)
  ans=0
  for i in x:
    ans+=int(i)
  print(ans)

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

Solution (Python):
n = int(input())
ans = 1e18
for i in range(1, n):
    a = i
    b = n-i
    tmp = 0
    while a:
        tmp += a%10
        a //= 10
    while b:
        tmp += b%10
        b //= 10
    ans = min(ans, tmp)
print(ans)

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

Solution (Python):
n = int(input())
sum = float('inf')

for i in range(1, n):
    k = 0
    for j in range(len(str(i))):
        k += float(str(i)[j])
    for l in range(len(str(n-i))):
        k += float(str(n-i)[l])
    sum = min(sum, k)

print(int(sum))

Solution (Python):
N = int(input())
L = [10, 10**2, 10**3, 10**4, 10**5]
if N in L:
  print(10)
else:
  X = list(str(N))
  Y = sum([int(i) for i in X])
  print(Y)

Solution (Python):
n = int(input())
for i in range(1,6):
    if n%(10*i) == 0:
        print(10)
        exit()
print(sum(list(map(int, str(n)))))

Solution (Python):
n = int(input())
ans = 100000
for i in range(1, n):
    a, b = str(i), str(n-i)
    A, B = 0, 0
    for x in a:
        A += int(x)
    for y in b:
        B += int(y)
    ans = min(ans, A+B)
print(ans)

Solution (Python):
n = int(input())
min_sum = 99999999999999
if n == 2 :
  print (2)
  exit()
for i in range (1, n - 1):
  first = i
  second = n - i
  first_sum = 0
  second_sum = 0
  while first > 0 :
    last_digit_first = first % 10
    first = first // 10
    first_sum += last_digit_first
    
  while second > 0 :
    last_digit_second = second % 10
    second = second // 10
    second_sum += last_digit_second
  
  if first_sum + second_sum <= min_sum :
    min_sum = first_sum + second_sum
print(min_sum)

Solution (Python):
N = int(input())
temp_min = sum(map(int, str(1))) + sum(map(int, str(N - 1)))
for A in range (2, N):
    x = sum(map(int, str(A))) + sum(map(int, str(N - A)))
    if x < temp_min:
        temp_min = x
print(temp_min)

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

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

N=int(input())
ans=100
for i in range(1,N):
    tmp=dig_sum(i)+dig_sum(N-i)
    if tmp<ans:
        ans=tmp
print(ans)

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

    ans = 100000

    for i in range(1, N):
        tmp = sum(map(int, str(i)))
        tmp += sum(map(int, str(N-i)))
        if tmp < ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
def f(x):
    a = 0
    while x != 0:
        a += x % 10
        x //= 10
    return a

N = int(input())

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

print(Min)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_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())
ans = 0
while N > 0:
    ans += N%10
    N //= 10
if ans == 1:
    print(10)
else:
    print(ans)

Solution (Python):
n = int(input())
ans = n
for i in range(n // 2):
  j = i + 1
  k = n - j
  sumj = []
  sumk = []
  for l in range(len(str(j))):
    strj = str(j)
    sumj.append(int(strj[l]))
    
  for l in range(len(str(k))):
    strk = str(k)
    sumk.append(int(strk[l]))
  if sum(sumj) + sum(sumk) < ans:
    ans = sum(sumj) + sum(sumk)
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:
    x = str(n)
    a = list(x)
    b = sum([int(i) for i in a])
    print(b)

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

print(ans)

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

Solution (Python):
N = int(input())
list_candi = []
for A in range(1, N):
  B = N - A
  list_A = list(map(int, list(str(A))))
  list_B = list(map(int, list(str(B))))
  sum_list= sum(list_A) + sum(list_B)
  list_candi.append(sum_list)
print(min(list_candi))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_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()

ans = INF
for i in range(1, N//2 + 1):
	j = N - i
	tmp = sum([int(x) for x in list(str(i))]) + sum([int(x) for x in list(str(j))])
	ans = min(ans, tmp)

print(ans)

Solution (Python):



def main():
    N = int(input())
    ret = 10**9
    for a in range(1,N):
        b = N-a
        ret = min(ret,sum(map(int,list(str(a))))+sum(map(int,list(str(b)))))

    print(ret)

if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
ans=float('inf')
for i in range(1,n//2+1):
    tmp=0
    a=i
    b=n-i
    while a>0:
        tmp+=a%10
        a//=10
    while b>0:
        tmp+=b%10
        b//=10
    ans=min(ans,tmp)
print(ans)

Solution (Python):
import math
N = int(input())
if math.log10(N)%1 != 0:
  K = str(N)
  ans = 0
  for i in range(len(K)):
    ans += int(K[i])
  print(ans)
else:
  print(10)

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

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

ans = 0

for i in range(1, N):
    j = SumOfDigits(i) + SumOfDigits(N-i)
    if ans > j:
        ans = j
    elif ans == 0:
        ans = j
    else:
        pass

print(ans)

Solution (Python):
N = list(input())
if int(''.join(N))%10 != 0:
    res = 0
    for i in range(len(N)):
        res += int(N[i])
else:
    res = 10
print(res)

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


N = int(input())

answer = None

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

    C = calc(A) + calc(B)

    if answer is None or answer > C:
        answer = C

print(answer)

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

MIN = 100000000000000
for i in range(1,N):
  A = sum(map(int,list(str(i))))
  B = sum(map(int,list(str(N-i))))
  MIN = min(A+B,MIN)
  
print(MIN)

Solution (Python):
n = int(input())
ans = 10 ** 5
for a in range(1, n):
    ak = sum([int(a) for a in str(a)])
    bk = sum([int(b) for b in str(n - a)])
    if ans > ak + bk:
        ans = ak + bk
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    ans = float("inf")

    for a in range(1, N):
        b = N - a
        tmp = 0
        for s in str(a):
            tmp += int(s)
        for s in str(b):
            tmp += int(s)

        ans = min(ans, tmp)

    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
l = len(str(n)) - 1
if n % 10**l == 0:
    if str(n)[0] == '1':
        print(10)
    else:
        ans = 0
        for i in str(n):
            ans += int(i)
        print(ans) 
else:
    ans = 0
    for i in str(n):
        ans += int(i)
    print(ans)

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

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

for i in range(n//2):
    x = i+1
    y = str(n-x)
    x = str(x)
    z = 0

    for c in x:
        z += int(c)
    for c in y:
        z += int(c)
    
    if z < ans:
        ans = z

print(ans)

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

Solution (Python):
n=int(input())
ans=9999999999999
for i in range(1,int(n/2)+1):
  tempa=list(str(i))
  tempb=list(str(n-i))
  s=0
  for j in range(len(tempa)):
    s=s+int(tempa[j])
  for j in range(len(tempb)):
    s=s+int(tempb[j])
  ans=min(ans,s)
print(ans)

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

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())
def f(i):
  return sum([int(j) for j in str(i)])
ans = float('inf')
for A in range(1, N):
  B = N - A
  ans = min(ans, f(A) + f(B))
print(ans)

Solution (Python):
import math
import string
import collections
from collections import Counter
from collections import deque


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())


def func(n):
    x = 0
    while(n > 0):
        x += n % 10
        n //= 10
    return x


a = 10**5
for i in range(1, n):
    j = n-i
    tmp = func(i)+func(j)
    a = min(tmp, a)
print(a)

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

digis_sum = 10 ** 2

def cal_digit(num):
    tmp = 0
    q = num
    while q:
        q, r = divmod(q, 10)
        tmp += r
        if q == 0:
            break
    return tmp

for x in range(1, int(n/2)+1):
    y = n - x
    t = cal_digit(x) + cal_digit(y)
    if t < digis_sum:
        digis_sum = t

print(digis_sum)

Solution (Python):
n = input()
n_ = n.replace('0','')
if n_ == '1':
  print(10)
else:
  a = 0
  for s in n:
    a += int(s)
  print(a)

Solution (Python):
N = int(input())
min = 100000000000000
for i in range(1, N):
  A = str(i)
  B = str(N - i)
  ref = 0
  for a in A:
    ref += int(a)
  for b in B:
    ref += int(b)
  if ref < min:
    min = ref
print(min)

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
ans = float('inf')
for i in range(1, N):
    x = sum(int(c) for c in str(i))
    y = sum(int(c) for c in str(N-i))
    tmp = x + y
    ans = min(ans, tmp)
print(ans)

Solution (Python):
n = int(input())
l = []

def each_sum(x):
    y = str(x)
    ans = 0
    for i in range(len(y)):
        ans += int(y[i])
    return ans

for a in range(1, n):
    b = n - a
    l.append(each_sum(a) + each_sum(b))

print(min(l))

Solution (Python):

def sum_N(a:int):
    sum = 0
    while a > 0:
        sum += a % 10
        a = a // 10
    return sum

N = int(input())
ans = []
for i in range(1, N):
    j = N - i
    ans.append(sum_N(i) + sum_N(j))
print(min(ans))

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

for x in range(1, N // 2 + 1):
    SUM = 0
    A = x
    B = N - x
    while A > 0 or B > 0:
        SUM += A % 10 + B % 10
        A //= 10
        B //= 10
    if ans > SUM:
        ans = SUM

print(ans)

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

min = n

def digits_sum(x):
    _x = 0
    while x > 0:
        _x += x % 10
        x //= 10
    
    return _x


for i in range(2, n):
    a = i
    b = n - i
    if digits_sum(a) + digits_sum(b) < min:
        min = digits_sum(a) + digits_sum(b)

print(min)

Solution (Python):
n = int(input())
ans = 10**9
for i in range(1,n//2+1):
    dum1 = n - i
    a = str(i)
    b = str(dum1)
    dum2 = 0
    for j in a:
        dum2 += int(j)
    for j in b:
        dum2 += int(j)
    ans = min(dum2,ans)
print(ans)

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

Solution (Python):
def getter(i):
  res=0
  while True:
    res+=i%10
    i//=10
    if i==0:
      break
  return res
n=int(input())
digit=0
hoge=n
while True:
  hoge//=10
  if hoge==0:
  	break
  digit+=1
a=10**digit
if n-a>0:
  res=1+getter(n-a)
  print(res)
  exit()
else:
  print("10")

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

def dig(num):
    ans = 0
    while num>0:
        ans += num%10
        num//=10
    return ans

mi = float('inf')
for i in range(1,n//2+1):
    a = dig(i)+dig(n-i)
    mi = min(a,mi)
print(mi)

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

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

Solution (Python):
N = int(input())
if N % 10 == 0:
  print(10)
else:
  ls = list(str(N))
  for i in range(len(ls)):
    ls[i] = int(ls[i])
  print(sum(ls))

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

n = int(input())

ans = 10 ** 6
for i in range(1, n):
    a, b = i, n - i
    ans = min(ans, ranksum(a) + ranksum(b))

print(ans)

Solution (Python):
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N = int(input().rstrip())
    ANS = INF
    for i in range(1,N):
        ANS = min(ANS,sum(list(map(int, str(i)))) + sum(list(map(int, str(N - i)))))
    print(ANS)    

if __name__ == '__main__':
    solve()

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

A = str(N//2)
B = str(N-int(A))

ans1,ans2 = 0,1
for i in range(len(A)):
  ans1 += int(A[i])
for i in range(len(B)):
  ans1 += int(B[i])

B = str(N-1)

for i in range(len(B)):
  ans2 += int(B[i])

ans = min(ans1,ans2)

print(ans)

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

ans=10**5
for a in range(1,n):
  b=n-a
  aa=list(str(a))
  bb=list(str(b))
  tmp=0
  for k in (aa+bb):
    tmp+=int(k)
  ans=min(ans,tmp)
print(ans)

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

Solution (Python):
ans=999999999
n = int(input())
for i in range(1,n//2+1):
    x=str(i)
    y=str(n-i)
    ans=min(ans, sum(map(int, x))+sum(map(int, y)))
    
print(ans)

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

Solution (Python):

N = int(input())
min = 1000000000

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

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


N = int(input())
ans = float('inf')
for A in range(1, N):
    B = N - A
    if A > B:
        break
    ans = min(ans, split_sum(A) + split_sum(B))
print(ans)

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

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

def keta(num):
    s = str(num)
    sm=0
    for i in range(len(s)):
        sm+=int(s[i])
    return sm

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

print(ans)

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

Solution (Python):


N = input()
N_int = int(N)
mylist = ['10','100','1000','10000','100000']
ans = 0

if N in mylist:
    ans = 10
else:
    for i in range(len(N)):
        ans += (N_int % 10)
        N_int = N_int // 10

print(ans)

Solution (Python):
def calc(x) -> int:
  sum = 0
  while x//10!=0:
    sum += x%10
    x = x//10
  sum+=x
  return sum


n = int(input())
best_score = float('inf')
for a in range(1,n):
  b = n-a
  score = calc(a)+calc(b)
  if score < best_score:
    best_score = score
print(best_score)

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

l = []
for i in range(1, n):
    a = i
    b = n - i
    ra = 0
    rb = 0

    flg = True
    while flg:
        aa = a % 10
        a //= 10
        ra += aa
        if a == 0:
            flg = False
    flg = True
    while flg:
        bb = b % 10
        b //= 10
        rb += bb
        if b == 0:
            flg = False
    l.append(ra+rb)
print(min(l))

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

Solution (Python):
n = int(input())
candi = []
for i in range(1,int(n/2+1)):
  j = n - i
  candi.append([i,j])



ans = 0
for a,b in candi:
  count = 0
  a = str(a)
  b = str(b)
  for i in a:
    count += int(i)
  for i in b:
    count += int(i)
  if ans == 0 :
    ans = count
  ans = min(ans,count)

print(ans)

Solution (Python):
from math import ceil
N = int(input())
result = 10 ** 6
for i in range(1, ceil(N / 2) + 1):
  a = str(i)
  b = str(N - i)
  result = min(result, sum(map(int, a)) + sum(map(int, b)))
print(result)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def digit_sum(n):
    res = 0
    while n > 0:
        res += n % 10
        n //= 10
    return res


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

    res = f_inf
    for a in range(1, n):
        b = n - a
        cnt = digit_sum(a) + digit_sum(b)
        res = min(res, cnt)

    print(res)


if __name__ == '__main__':
    resolve()

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

Solution (Python):
N = int(input())
n = 1e5
for i in range(1, N):
    A = i
    B = N - A
    s = 0
    while A > 0:
        s += A % 10
        A = int(A / 10)
    while B > 0:
        s += B % 10
        B = int(B / 10)
    n = min(n, s)
print(n)

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

    minSum = 10**18

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

        sumA = 0
        sumB = 0

        for digit in str(a):
            sumA += int(digit)
        
        for digit in str(b):
            sumB += int(digit)
        
        total = sumA + sumB
        
        if total < minSum:
            minSum = total
    
    print(minSum)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    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))
    


resolve()