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):
s = input()
n = int(s)
ans = 0
for i in s:
    ans += int(i)
if s.count('0') == len(s)-1 and s[0]=='1':
    ans += 9
print(ans)

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

Solution (Python):
N=int(input())
result=[]
for i in range(1,N):
  A=str(i)
  B=str(N-int(A))
  goukei=[]
  for j in range(len(A)):
    goukei.append(int(A[j]))
  for k in range(len(B)):
    goukei.append(int(B[k]))
  result.append(sum(goukei))

print(min(result))

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

if not N % 10:
    print(10)
else:
    ans = [int(x) for x in list(str(N))]
    print(sum(ans))

Solution (Python):
n=input()
if int(n)==10**(len(n)-1):
  print(10)
else:
  print(sum(int(i) for i in n))

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

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

min_d = 10 ** 12

for a in range(1, N):
	b = N - a
	min_d = min(min_d, solve(a) + solve(b))
print(min_d)

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

out = 1000000

for a in range(1,n):
    b = n-a
    a = [int(i) for i in list(str(a))]
    sum_a = sum(a)
    b = [int(i) for i in list(str(b))]
    sum_b = sum(b)
    
    if sum_a + sum_b < out:
        out = sum_a + sum_b
        
print(out)

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

Solution (Python):
n = int(input())
def sumNum(i):
    if i//10 == 0:
        s = i
    else:
        s = 0
    while i//10 > 0:
        s += i%10
        if i//10 < 10:
            s += i//10
        i = i//10
    return s

sumab = float('inf')
for i in range(1,n):
    j = n - i
    tmp = sumNum(i) + sumNum(j)
    if tmp < sumab:
        sumab = tmp
print(sumab)

Solution (Python):
def F(N):
  return N if N < 10 else N % 10 + F(N // 10)

N = int(input())
x = F(N)
if x == 1:
  answer = 10
else:
  answer = x

print(answer)

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


if __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input())
minab=10**20
for i in range(1,n//2+1):
    a = str(i)
    b = str(n-i)
    sumab=0
    for j in range(len(a)):
        sumab += int(a[j])
    for j in range(len(b)):
        sumab += int(b[j])
    minab = min(minab,sumab)
print(minab)

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

for a in range(1, (n // 2) + 1):
  b = n - a
  sum = 0

  while (a > 0) or (b > 0):
    sum += (a % 10)
    a = a // 10
    sum += (b % 10)
    b = b // 10

  if sum < ans:
    ans = sum

print(ans)

Solution (Python):
def SumOfDegit(x):
  sum = 0
  while x > 0:
    sum += x % 10
    x //= 10
  return sum
 
n = int(input())
degits_sum = []
for a in range(1,n):
  degits_sum.append(SumOfDegit(a) + SumOfDegit(n-a))
print(min(degits_sum))

Solution (Python):

"""
A - Digits Sum
https://atcoder.jp/contests/agc025/tasks/agc025_a

"""
import sys


def solve(N):
    def calc_dsum(a, b):
        a_sum = sum([int(ch) for ch in str(a)])
        b_sum = sum([int(ch) for ch in str(b)])
        return a_sum + b_sum

    ans = []
    for a in range(1, (N//2)+1):
        b = N - a
        ans.append(calc_dsum(a, b))
    return min(ans)


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
def findSumOfDigits(num):
  sum = 0
  while num > 0:
    sum += num % 10
    num //= 10
  return sum
  
if __name__ == '__main__':
  N = int(input())
  min_total = 1000
  for i in range(1, N):
    A = i
    B = N - A
    total = findSumOfDigits(A) + findSumOfDigits(B)
    if total < min_total:
      min_total = total
  print(min_total)

Solution (Python):
n = (input())
sai = []
x = list(map(int,list(n)))

if sum(x) == 1:
    n_sum = 10
else:
	n_sum = sum(x)

print(n_sum)

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())


N = int(input())

minsum = 10**9
for i in range(1, N//2+1):
  j = N-i
  tmp = 0
  for s in str(i)+str(j):
    tmp += int(s)
  minsum = min(tmp, minsum)

print(minsum)

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

n = int(input())
degits_sum = []
for a in range(1,n):
  degits_sum.append(SumOfDegit(a) + SumOfDegit(n-a))
print(min(degits_sum))

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

if n % 10 == 0:
    while n > 10:
        n = n // 10
    ans = n
else:
    num = str(n)
    x = 0
    for i in range(len(num)):
        x += int(num[i])
    ans = x

print(ans)

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

N, = map(int, input().split())

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

print(ans)

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

flg = 100
for i in range(1,n):
    a = n- i
    b = i
    sum_a = sum([int(x) for x in list(str(a))])
    sum_b = sum([int(x) for x in list(str(b))])
    if flg > sum_a + sum_b:
        flg = sum_a + sum_b

print(flg)

Solution (Python):
N=int(input())
ans=10**20
for a in range(1,N//2+2):
    b=N-a
    A=a
    B=b
    s=0
    while(A!=0):
        s+=A%10
        A//=10
    while(B!=0):
        s+=B%10
        B//=10
    ans=min(ans,s)
print(ans)

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

sum_list = []
for a in range(1, n):
    b = n - a
    a_str = str(a)
    b_str = str(b)
    tmp = 0
    for a_s in a_str:
        tmp += int(a_s)
    for b_s in b_str:
        tmp += int(b_s)
    sum_list.append(tmp)

print(min(sum_list))

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

ans=10**5
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 = int(input())

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

min_sum = float('inf')

for i in range (1, N):
    a = sumOfDegits(i)
    b = sumOfDegits(N-i)
    if min_sum > a + b:
        min_sum = a + b

print(min_sum)

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

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

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

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

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

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

def getsum(p):
  s=str(p)
  sum=0
  for i in range(len(s)):
    sum+=int(s[i])
  return sum

min=n
for a in range(1,n):
  b=n-a
  w=getsum(a)+getsum(b)
  if min>w:
    min=w
print(min)

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


N = int(input())

ans = float('inf')
for A in range(1, N // 2 + 1):
    B = N - A
    ans = min(ans, f(A) + f(B))
print(ans)

Solution (Python):
n=int(input())
def cal(x):
    y=str(x)
    cnt=0
    for i in range(len(y)):
        cnt+=int(y[i])
    return cnt
min=999999999
for a in range(1,n//2+1):
    b=n-a
    if cal(a)+cal(b)<min:
        min=cal(a)+cal(b)
print(min)

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


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


print(min([fsod(A) + fsod(N-A) for A in range(1, N // 2 + 1)]))

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

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

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

Solution (Python):
N = int(input())
print(10 if N % 10 == 0 else sum(int(s) for s in str(N)))

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

N = int(input())
mi = 1e10
for i in range(1, N):
    mi = min(mi, digit_sum(i) + digit_sum(N - i))
print(mi)

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

Solution (Python):
N = int(input())
  
def digit_sum(N):
  ret = 0
  while N:
    ret += N%10
    N = N//10
  return ret

answer = 1e9
for i in range(1,N):
  answer = min(answer, digit_sum(i)+digit_sum(N-i))
  
print(answer)

Solution (Python):
nl = list(map(int, input()))
if len(nl) == 1:
    print(nl[0])
elif all([e == 0 for e in nl[1:]]):
    print(10)
else:
    print(sum(nl))

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

Solution (Python):
n=int(input())
ans=sum(int(i) for i in str(n))
while n%10==0:
  n//=10
print(10 if n==1 else ans)

Solution (Python):
A = int(input()) - 1
B = 1
o = 100000

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

while A >= 1:
    o = min(digitsum(A)+digitsum(B),o)
    A-=1
    B+=1

print(o)

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

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

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

n=int(input())
ans=[]
for i in range(1,n):
    ans.append(wa(i)+wa(n-i)) 
    if wa(i)+wa(n-i)==1:
        print(i)
print(min(ans))

Solution (Python):
inf = 10**10

n = int(input())
ans = inf
def f(x):
    cur = 0
    while x >0:
        cur += x % 10
        x = x //10
    return cur
for a in range(1,n):
    b = n-a
    ans = min(ans,f(a)+f(b))
print(ans)

Solution (Python):
def digitsum(num):
  s=str(num)
  ret=0
  for i in range(len(s)):
    ret+=int(s[i])
  return ret

n=int(input())
arr=[digitsum(i)+digitsum(n-i) for i in range(1,n//2+1)]
print(min(arr))

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

ns = []
while (N != 0):
    ns.append(N % 10)
    N //= 10
if sum(ns) == 1:
    ans = 10
else:
    ans = sum(ns)

print(ans)

Solution (Python):
a=input()

al=[int(c) for c in list(str(a))]

sal=sum(al)
ret= sal if sal > 1 else 10
print(ret)

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

def digit_sum(n):
    return sum([int(s) for s in str(n)])

digit_sums = []
for a in range(1, N):
    b = N - a
    digit_sums.append(digit_sum(a) + digit_sum(b))

print(min(digit_sums))

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

min_num = 10**9
for a in range(1,n):
    b = n-a
    a_s = sum(list(map(lambda x: int(x), str(a))))
    b_s = sum(list(map(lambda x: int(x), str(b))))
    num = a_s+b_s
    min_num = min(num, min_num)

print(min_num)

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

Solution (Python):
def sumdigit(m):
    s=str(m)
    array=list(map(int,s))
    return sum(array)
ans=9999
N=int(input())
for i in range(1,N):
    r=N-i
    if sumdigit(i)+sumdigit(r)<ans:
        ans=sumdigit(i)+sumdigit(r)
print(ans)

Solution (Python):
N=int(input())
ans=0
for i in range(1,N):
    j=N-i
    i_s=sum(map(int,list(str(i))))
    j_s=sum(map(int,list(str(j))))
    S=i_s+j_s
    if ans==0:
        ans=S
    else:
        if S<ans:
            ans=S
        else:
            continue

print(ans)

Solution (Python):
n = input()
result = 0

if int(n)%10 == 0:
    result = 10
else:
    result = sum(int(i) for i in n)

print(result)

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

Solution (Python):
import math
n = int(input())
ns = list(str(n))
if(math.log10(n) == float(len(ns)-1)) : print(10)
else : print(sum([int(ns[i]) for i in range(len(ns))]))

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



n=int(input())

min=100000

for i in range(n):
    if i==0:
        continue
    sub=n-i
    sub=sum(sub)
    i=sum(i)
    
    if min>sub+i:
        min=sub+i
print(min)

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

min_=100000

for i in range(1, N//2+1):
    j=N-i
    sum_i=0
    sum_j=0
    tmp_i=i
    tmp_j=j
    while tmp_i  > 0:
        sum_i += tmp_i % 10
        tmp_i = tmp_i // 10
    while tmp_j > 0:
        sum_j += tmp_j % 10
        tmp_j = tmp_j // 10
    min_=min(min_, sum_i+sum_j)

print(min_)

Solution (Python):
n=int(input())
ans=10**5
for a in range(1,n//2+1):
  b=n-a
  ans=min(ans,a%10+a//10%10+a//100%10+a//1000%10+a//10000%10+b%10+b//10%10+b//100%10+b//1000%10+b//10000%10)
print(ans)

Solution (Python):
N = int(input())
minimum = 10**5
for i in range(1,-(-N//2)+1):
    A = i
    B = N - i
    total = 0
    for _ in range(6):
        total += A % 10 + B % 10
        A //= 10
        B //= 10
    if total < minimum:
        minimum = total
print(minimum)

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

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

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

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

min_count = 10**10

for i in range(1,N):
    A = i
    B = N-i
    count = 0
    for a in str(A):
        count += int(a)
    for b in str(B):
        count += int(b)
    min_count = min(min_count, count)

print(min_count)

Solution (Python):
NL = [int(x) for x in str(input())]
if NL[0] == 1 and sum(NL) == 1:
    print(10)
else:
    print(sum(NL))

Solution (Python):
N = int(input())
def sumof(N):
  sum = 0
  while(N>0):
    sum += N % 10
    N //= 10
  return sum

minsum = 9*10
for i in range(1,N//2+1):
  minsum = min(minsum,sumof(i) + sumof(N-i))
print(minsum)

Solution (Python):
import numpy as np

n = int(input())
ans = np.Inf

for i in range(1,int(n/2+1)):
    a = str(i)
    b = str(n - i)
    an = 0
    for j in range(len(a)):
        an += int(a[j])
    for k in range(len(b)):
        an += int(b[k])
    if an < ans:
        ans = an
print(ans)

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

Solution (Python):
n = int(input())
c = 100000000000000000
for i in range(1,int(n/2)+2):
    a = list(str(i))
    b = list(str(n-i))
    a1 = [int(s) for s in a]
    b1 = [int(s) for s in b]
    if sum(a1) + sum(b1) < c:
        c = sum(a1) + sum(b1)

print(c)

Solution (Python):
n = int(input())
c = 100000000000000000
for i in range(1,int(n/2)+2):
    a = list(str(i))
    b = list(str(n-i))
    a1 = [int(s) for s in a]
    b1 = [int(s) for s in b]
    if sum(a1) + sum(b1) < c:
        c = sum(a1) + sum(b1)

print(c)

Solution (Python):
n = int(input())
ans = pow(10, 15)
for a in range(1, n):
  b = n - a
  adg, bdg = 0, 0
  while a != 0:
    adg += a % 10
    a //= 10
  while b != 0:
    bdg += b % 10
    b //= 10
  if ans > adg + bdg:
    ans = adg + bdg
print(ans)

Solution (Python):
N = int(input())
best = 10**9
for a in range(1, N):
    b = N - a
    s = sum(int(c) for c in str(a)) + sum(int(c) for c in str(b))
    if s < best:
        best = s
print(best)

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


def simulate(m):
    for a in range(1, m):
        global ans
        sum_a = sum([int(i) for i in str(a)])
        sum_b = sum([int(i) for i in str(N-a)])
        if sum_a + sum_b < ans:
            ans = sum_a + sum_b


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

print(ans)

Solution (Python):
N = int(input())
factor_a = []
factor_b = []
ans = N
for a in range(1, N):
    sum_a = sum([int(i) for i in str(a)])
    sum_b = sum([int(i) for i in str(N-a)])
    if sum_a + sum_b < ans:
        ans = sum_a + sum_b
print(ans)

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

Solution (Python):
N = int(input())
m = float("inf")
 
for A in range(1,N):
  summ = 0
  B = N-A
  
  while A >0:
    summ += A%10
    A //=10
  while B >0:
    summ += B%10
    B//=10
  if summ < m:
    m = summ

print(m)

Solution (Python):
def digits(N):
    num = N
    sum = 0
    while num > 0:
        sum += num%10
        num //= 10
    return sum
    
def main():
    N = int(input())
    min = N
    for A in range(1,(N//2+1)):
        B = N - A
        if min > digits(A)+digits(B):
            min = digits(A)+digits(B)
    print(min)
    
if __name__ == '__main__':
    main()

Solution (Python):
n=int(input());minn=100
def digit_sum(x):
  a,b=0,str(x)
  for i in range(len(b)):a+=int(b[i])
  return a
for i in range(1,n//2+1):a=digit_sum(i)+digit_sum(n-i);minn=min(minn,a)
print(minn)

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

ans = float("inf")

for i in range(1,int(n/2)+1):
    a = format(i,"05d")
    b = format(n-i,"05d")
    sm = 0
    for aa,bb in zip(a,b):
        sm += int(aa) + int(bb)
    if ans  >  sm:
        ans = sm
print(ans)

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

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

def SumOfDigits(n):
	ans=0
	while(True):
		if n==0:
			break
		ans+=n%10
		n=n//10
	return ans

ans=N
for a in range(N):
	if a!=0:
		b=N-a
		if ans>SumOfDigits(a)+SumOfDigits(b):
			ans=SumOfDigits(a)+SumOfDigits(b)
print(ans)

Solution (Python):

N = int(input())
S = []

def kakui(X):
    x = [0] * 6
    for i in [5,4,3,2,1,0]:
        x[i] = X // (10**i)
        X = X % (10**i)
    return(x)
def sum(x):
    sum = 0
    for i in range(6):
        sum += x[i]
    return sum

for A in range(1, N):
    B = N - A
    
    S.append(sum(kakui(A))+sum(kakui(B)))
print(min(S))

Solution (Python):

N = int(input())
S = []

a = [0] * 6
for A in range(1, N):
    realA = A
    for i in [5,4,3,2,1,0]:
       a[i] = A // (10**i)
       A = A % (10**i)
       
    b = [0] * 6
    B = N - realA
    for i in [5,4,3,2,1,0]:
        b[i] = B // (10**i)
        B = B % (10**i)
        
    def sum(x):
        sum = 0
        for i in range(6):
            sum += x[i]
        return sum
    S.append(sum(a)+sum(b))
print(min(S))

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

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

ans = float('inf')
for a in range(1, n):
    num = 0
    b = n - a
    if b < a:
        break
    while a:
        num += a % 10
        a = a // 10
    while b:
        num += b % 10
        b = b // 10
    ans = min(ans, num)

print(ans)

Solution (Python):



def main():
    n = input()
    ans = float('inf')

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

    print(ans)


if __name__ == '__main__':
    main()

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

ans = float('inf')
for a in range(1, n):
    num = 0
    b = n - a
    if b < a:
        break
    while a:
        num += a % 10
        a = a // 10
    while b:
        num += b % 10
        b = b // 10
    ans = min(ans, num)

print(ans)

Solution (Python):
N = int(input())
ans = 999
for a in range(1,N):
    b = N-a
    tmp = sum(int(c) for c in str(a)) + sum(int(c) for c in str(b))
    ans = min(ans,tmp)
print(ans)

Solution (Python):
import numpy as np
N = input()
N = np.array([int(k) for k in N])
if N[-1] == 0:
  print(10)
else:
  print(N.sum())

Solution (Python):

'''
問題
AとBは自然数とする
AとBの各桁の数の和をSA，SBとする
和がNであるとわかっているとき，SA＋SBの最小値は？

Nは2以上10000以下

考察
最大でもループは10000以下なのでしらみつぶせばよい
'''

N = int(input())

def dsum(n):
	return sum([int(x) for x in list(str(n))])

result = []

for i in range(1,(N//2)+1):
	result.append(dsum(i)+dsum(N-i))

print(min(result))

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

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

digit_sum = sum(gen(N))
if(digit_sum==1):
    print(10)
else:
    print(digit_sum)

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

Solution (Python):
n = int(input())
x = 10**9

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

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

min_n = 10**9

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

    a = sum(list(map(int, str(A))))
    b = sum(list(map(int, str(B))))

    min_n = min(min_n, a+b)


print(min_n)

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

def f(x):
    s = 0
    while x != 0:
        s += x % 10
        x = x//10
    return s

n = int(input())
res = 10**9
for i in range(1,n):
    res = min(res,f(i)+f(n-i))
print(res)

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

def digSum(n):
  return sum(map(int, str(n)))

A = list(range(1,N//2+1))
B = list(range(N-1,N//2-1,-1))
ans = 1e9
for a, b in zip(A, B):
  
  ans = min(ans, digSum(a)+digSum(b))
print(ans)

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

Solution (Python):
N = int(input())
ans = 10**9

def ketawa(b):
  if b < 10:
    return b
  return ketawa(b//10) + b%10

for i in range(1, N):
  tmp = ketawa(i) + ketawa(N-i)
  if tmp < ans:
    ans = tmp
print(ans)

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

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

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

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

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

    t = 0
    while a > 0:
        a, r = divmod(a, 10)
        t += r

    while b > 0:
        b, r = divmod(b, 10)
        t += r

    ans = min(t, ans)
print(ans)

Solution (Python):
N=int(input())
a=10e6
for i in range(1,N//2+1):
  A=i;B=N-i
  numA=sum([int(i) for i in list(str(A))])
  numB=sum([int(i) for i in list(str(B))])
  a=min(numA+numB,a)
print(a)

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

print(min)

Solution (Python):
n = int(input())
ans = []
for i in range(1,n):
    j = n-i
    si = 0
    sj = 0
    for s in str(i):
        si += int(s)
    for t in str(j):
        sj += int(t)
    ans.append(si+sj)

print(min(ans))

Solution (Python):
import scipy as sp

def sum_of_digits(n):
    answer = 0
    while True:
        if n == 0:
            break
        else:
            answer += n%10
            n = n // 10
    return answer
     

N = int(input())
answer = N 
for a in sp.arange(1, N//2+1):
  b = N - a
  sum = sum_of_digits(a) + sum_of_digits(b)
  if sum < answer:
    answer = sum
         
     
print(answer)

Solution (Python):

"""
Created on Tue Feb 12 15:50:41 2019

@author: shinjisu
"""



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

def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m)]*n 

def getIntLines(n): return [int(input()) for i in range(n)]

def getIntMat(n, m):  
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18


class Debug():
    def __init__(self):
        self.debug = True

    def off(self):
        self.debug = False

    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


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


def prob():
    d = Debug()
    d.off()
    N = getInt()
    minSum = INF
    for i in range(1, N//2+1):
        minSum = min(minSum, digitSum(i)+digitSum(N-i))

    return minSum


ans = prob()
if ans is None:
    pass
else:
    print(ans)

Solution (Python):
N = int(input())
lf  = [int(x) for x in list(str(N-1))]
count = N//2 + 1
min = 1 + sum(lf)
for i in range(1,count):
    l = [int(j) for j in list(str(i))]+[int(j) for j in list(str(N-i))]
    num =sum(l)
    if num <= min:
        min = num
print(min)

Solution (Python):
N = int(input())
def digitsum(n):
    s = str(n)
    res = 0
    for c in s:
        res += int(c)
    return res
m = float('inf')
digits = [0 for i in range(N)]
for A in range(1,N):
    digits[A] = digitsum(A)
for A in range(1,N):
    m = min(m,digits[A]+digits[N-A])
print(m)

Solution (Python):
def degit_sum(n):
    if len(str(n)) < 2:
        return n
    s = list(str(n))
    s = [int(e) for e in s]
    return sum(s)

N = int(input())
degit = len(str(N))
if N % pow(10,degit-1) == 0 and N >= 10:
    degit -= 1
A = pow(10,degit-1)
B = N - A
ans = degit_sum(A) + degit_sum(B)
print(ans)

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


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


res = 10e5
for a in range(1, N):
    b = N - a
    s = sum_digits(a) + sum_digits(b)
    if s < res:
        res = s
print(res)

Solution (Python):
n=int(input())
ans=10000000000000
for i in range(1,n//2+1):
	a=i 
	b=n-i 
	asum=0
	bsum=0
	for j in str(a):
		asum+=int(j)
	for j in str(b):
		bsum+=int(j)
	ans=min(ans,asum+bsum)
print(ans)

Solution (Python):
N = int(input())
answer = float('inf')
for a in range (1, N):
    b = N - a
    digits = sum(map(int, list(str(a)))) + sum(map(int, list(str(b))))
    if digits < answer:
        answer = digits
print(answer)

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

anss = []
for a in range(1,n):
	aSum = sum(map(int,str(a)))
	bSum = sum(map(int,str(n-a)))
	
	anss.append(aSum+bSum)
	
print(min(anss))

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

for i in range(1,n):
    a = i
    b = n - i
    l = list(str(a)+str(b))
    for j in range(len(l)):
        l[j] = int(l[j])
    ans = min(ans, sum(l))

print(ans)

Solution (Python):
n = int(input())
ans = 10000
for i in range(1, n):
    X = list(str(i))
    Y = list(str(n - i))
    m = 0
    for j in X:
        m+=int(j)
    for k in Y:
        m+=int(k)
    if(m < ans):
        ans = m
print(ans)

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


def calc(num):
    total = 0
    while num > 0:
        total += num % 10
        num = num // 10
    return total

minNum = sys.maxsize


for i in range(1, n):
    currNum = calc(i) + calc(n-i)
    if currNum < minNum:
        minNum = currNum

print(minNum)

Solution (Python):

N = int(input())
res = 1e9
for i in range(1,N//2+1):
    A,B = i,N-i
    r = 0
    a,b=str(A),str(B)
    for mystr in [a,b]:
        for j in mystr:
            r += int(j)
    res = min(r,res)
print(res)

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

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

ans = 0
if N%10==0:
    ans = 10
else:
    lst_N = list(str(N))
    for n in lst_N:
        ans += int(n)

print(ans)

Solution (Python):
def main():
    ans=0
    n=input()
    for i in range(len(n)):
        ans+=int(n[i])
    if(int(n)<=10):
        ans=n
    if(n=="100000" or n=="10000" or n=="1000" or n=="100"):
        ans=10
    print(ans)


if __name__=="__main__":
    main()

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

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

Solution (Python):
N = int(input())
nl = [int(str(N)[i]) for i in range(len(str(N)))]
if N == 10 or N == 100 or N == 1000 or N == 10000 or N == 100000:
    print(10)
else:
    print(sum(nl))

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

for i in range(1,n):
  num1 = i
  num2 = n-i
  keta1 = str(num1)
  keta1 = sum([int(keta1[j]) for j in range(len(keta1))])
  keta2 = str(num2)
  keta2 = sum([int(keta2[j]) for j in range(len(keta2))])
  ans = min(ans,keta1+keta2)

print(ans)

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

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

print(tmp)

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

Solution (Python):
N = input()

ans = 0
for n in N:
    ans += int(n)

if ans == 1:
    ans = 10

print(ans)

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

if n[0] == 1 and n[1:] == [0] * (len(n) - 1):
    ans =  10
else:
    ans = sum(n)
print(ans)

Solution (Python):
N = int(input())
ans = 10e10
for i in range(1,int(N/2)+1):
  a = str(i)
  a_sub = 0
  for j in range(len(a)):
    a_sub += int(a[j])
  b = str(N - i)
  b_sub = 0
  for j in range(len(b)):
    b_sub += int(b[j])
  if ans >= b_sub + a_sub:
    ans = a_sub + b_sub
print(ans)

Solution (Python):
n=int(input())
S=set()
for i in range(1,n//2+1):
  S.add(sum(map(int,str(i)))+sum(map(int,str(n-i))))
print(min(S))

Solution (Python):
N_list = list(map(int, list(input())))
s = sum(N_list)

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

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

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

Solution (Python):
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
l = [pow(10,i) for i in range(1,7)]

if N in l:
    print(10)
else:
    num = 0
    for i in str(N):
        num += int(i)
    print(num)

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

Sum = N[0]

flag = True if Sum == 1 else False

for i in N[1:]:
  Sum += i
  if i != 0:
    flag = False

if flag:
  print(10)
else:
  print(Sum)