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):


import itertools
import collections
import bisect

def main():
    N = int(input())
    if N % 10 == 0:
        print(10)
    else:
        print(sum(map(int, list(str(N)))))


if __name__ == '__main__':
    main()

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

Solution (Python):
N=int(input())
p=100
for i in range(1,N,1):
    s=i
    t=0
    while s>0:
        t+=s%10
        s=(s-s%10)//10
    u=N-i
    v=0
    while u>0:
        v+=u%10
        u=(u-u%10)//10
    n=t+v
    if p>n:
        p=n
print(p)

Solution (Python):
n=int(input())
mini=999
def digisum(nn):
  return sum(map(int, nn))
for a in range(1, n):
  val = digisum(str(a)) + digisum(str(n-a))
  if mini > val:
    mini = val
print(mini)

Solution (Python):
N = int(input())
p = N
sums = 0
if N == 10 or N == 100 or N == 1000 or N == 10000 or N == 100000:
    print(10)
else:
    while p >= 1:
        sums += p%10
        p //= 10
    print(sums)

Solution (Python):
from sys import stdin
N=int(stdin.readline().rstrip())
tmp=float("inf")
for A in range(1,N):
    B=N-A
    a=sum(list(map(int,list(str(A)))))
    b=sum(list(map(int,list(str(B)))))
    if a+b < tmp:
        tmp=a+b
print(tmp)

Solution (Python):
def digit_sum(x):
    a = range(1, x)
    min_n = x
    for i in a:
        b = x - i
        p = sum(list(map(int, list(str(i)))))
        q = sum(list(map(int, list(str(b)))))
        if min_n > (p+q):
            min_n = p+q
        if a == b:
            break
    return min_n
N = int(input())
print(digit_sum(N))

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

Solution (Python):

n=int(input())


for i in range(1,n):
	A=i
	B=n-i
	
	count_a=0
	count_b=0
	while(A!=0):
		count_a+=A%10
		A=int(A/10)

	while(B!=0):
		count_b+=B%10
		B=int(B/10)
	count=count_a+count_b
	if(i==1):
		ans=count

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

Solution (Python):
def solve(n):
    
    dp = [None] * n
    ans = n
    for i in range(1, n // 2):
        rest = n - i
        if dp[i] is None:
            dp[i] = value_sum(i)
        if dp[rest] is None:
            dp[rest] = value_sum(rest)
        ans = min(ans, dp[i] + dp[rest])
    return ans


def value_sum(i):
    value = 0
    for v in str(i):
        value += int(v)
    return value


def main():
    n = int(input())
    ans = solve(n)
    print(ans)


main()

Solution (Python):
n = int(input())
ans = 10 ** 12
for i in range(1, n):
    a = str(i)
    b = str(n - i)
    C = []
    for j in a:
        C.append(int(j))
    for k in b:
        C.append(int(k))
    ans = min(ans, sum(C))
print(ans)

Solution (Python):
import math

def ten_sum(n):
    s = 0
    while n > 0:
        s += n % 10
        n = math.floor(n / 10)
    return s

lst = []
N = int(input())
for A in range(1, N):
    lst.append(ten_sum(A) + ten_sum(N - A))


print(min(lst))

Solution (Python):
n = int(input())
half_n = int(n//2)
ans = []

if n == 2:
    print(2)
    exit()
else:
    for i in range(1, half_n):
        a = str(i)
        b = str(n-i)
        count_a = 0
        count_b = 0
        for ai in a:
            count_a += int(ai)
        for bi in b:
            count_b += int(bi)
        ans.append(count_a + count_b)

print(min(ans))

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

Solution (Python):
n=int(input())
count = sum([int(j) for j in str(1)]) + sum([int(j) for j in str(n-1)])
for i in range(1,-(-n//2)+1):
    a = sum([int(j) for j in str(i)])
    b = sum([int(j) for j in str(n-i)])
    if count > a + b:
        count = a + b
print(count)

Solution (Python):
N = int(input())
prev = 1000000
for i in range(1, N):
    ans = 0
    for j in str(i):
        ans += int(j)
    for j in str(N - i):
        ans += int(j)
    if prev > ans:
        prev = ans
print(prev)

Solution (Python):
n=int(input())
if n%2==0:
    a=n//2+1
else:
    a=n//2+2
def wa(k):
    kai=0
    while k>0:
        kai+=round(k%10)
        k=round((k-round(k%10))/10)
    return kai
ans=10000000000
for i in range(1,a+1):
    b=i
    c=n-i
    if ans>(wa(b)+wa(c)):
        ans=wa(b)+wa(c)
print(ans)

Solution (Python):

n = int(input())
cnt=0
sum_of_min = 999999999999999999
for a in range(1,n):
    b = n - a
    sum_of_a = sum([int(c) for c in str(a)])
    sum_of_b = sum([int(c) for c in str(b)])
    sum_of_n = sum_of_a + sum_of_b

    if sum_of_n < sum_of_min:
        sum_of_min = sum_of_n
        
print(sum_of_min)

Solution (Python):
n = int(input())
ans = 10**6
for i in range(1,n):

  tmp = 0
  a = str(i)
  b = str(n-i)
  for j in a:
   tmp+= int(j)
  for k in b:
   tmp+= int(k)
  ans = min(ans,tmp)
print(ans)

Solution (Python):

import sys
import math
N = int(input())

def getValue(wk) :
    ret = 0
    while wk > 0 :
        ret = ret + wk % 10
        wk = wk // 10
    return ret

def getAns(n) :
    minV = 999999
    B = n
    l = math.log10(n)
    if int(l) == l :
        return 10
    for A in range(1, n + 1) :
        B = B - 1
        if A + B == n :
            waA = getValue(A)
            waB = getValue(B)
            if minV > waA + waB :
                minV = waA + waB
    return minV

print(getAns(N))

Solution (Python):
def sumDigit(i):
  if i > 0:
    return sumDigit(i // 10) + i % 10
  else:
    return 0

n = int(input())
ans = n
for a in range(1, n):
  tmp = sumDigit(a) + sumDigit(n - a)
  ans = min(ans, tmp)
print(ans)

Solution (Python):

from math import log10
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

Solution (Python):
a = input()
if a.count("0") == len(a)-1 and a[0] == "1":
    print(10)
else:
    count = 0
    for i in range(len(a)):
        if a[i] != "0":
            count += int(a[i])
    print(count)

Solution (Python):

NL = list(map(int, list(input())))

if NL[0] == 1 and sum(NL) == 1:
    print(10)
else:
    print(sum(NL))

Solution (Python):
n=int(input())
ans=n
for i in range(1,n):
  l=[int(j) for j in list(str(i))]
  m=[int(k) for k in list(str(abs(n-i)))]
  if ans>sum(l)+sum(m):
    ans=sum(l)+sum(m)
print(ans)

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

m = set(n)

ans = 0
if m != {'1','0'}:
    for i in n:
        ans += int(i)
else:
    ans = 10
print(ans)

Solution (Python):
import math
N = float(input())
ans = 0
if math.log10(N).is_integer():
  print(10)
else:
  N = int(N)
  for i in range(len(str(N))):
    ans += N%10
    N = N//10
  print(ans)

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


n = int(input())

m = float('inf')
for a in range(1, n):
    b = n - a
    v = func(a) + func(b)
    if v < m:
        m = v

print(m)

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

digits_sum = lambda x: sum(map(int, str(x)))

min_num = 10**18
for i in range(1, (N+1)//2+1):
    
    m = N-i
    l = digits_sum(i) + digits_sum(m)
    min_num = min(l, min_num)

print(min_num)

Solution (Python):
n = int(input())
ans = float("INF")
for i in range(1, n):
    t = list(str(n - i))
    t = [int(m) for m in t]
    u = list(str(i))
    u = [int(m) for m in u]
    if ans > int(sum(t) + sum(u)):
        ans = int(sum(t) + sum(u))
print(ans)

Solution (Python):
N = int(input())
ans = float('inf')
for i in range(N//2):
    a = i+1
    b = N-a
    sa,sb = 0,0
    for j in range(max(len(str(a)),len(str(b)))):
        sa += a%10
        a //= 10
        sb += b%10
        b //= 10
    ans = min(sa+sb,ans)
print(ans)

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

sum_min = 10000000
for i in range(1,N):
	A = i
	B = N-i
	sum_A = sum(list(map(int,list(str(A)))))
	sum_B = sum(list(map(int,list(str(B)))))
	if sum_min > sum_A+sum_B:
		sum_min = sum_A+sum_B

print(sum_min)

Solution (Python):
import sys


def sum_of(i):
    sum = 0
    for digit in str(i):
        sum += int(digit)
    return sum


n = int(input())
min = sys.maxsize
for i in range(1, n):
    sum_a = sum_of(i)
    sum_b = sum_of(n - i)
    total = sum_a + sum_b
    if min > total:
        min = total
print(min)

Solution (Python):
n=list(input())
n=[int(i) for i in n]
if len(n)<=2 and n!=[1,0]:
    print(sum(n))
else:
    d=sum(n[2:])
    if n[:2]==[1,0]:
        print(d+10)
    else:
        print(d+sum(n[:2]))

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

Solution (Python):
a = input()
s = 0
for i in a:
    s+=int(i)
if s == 1 and len(a)>1:
    print(10)
else:print(s)

Solution (Python):
n=input()

ans=9*len(n)*2

n=int(n)
for i in range(1,n):
  j=n-i
  sumi=sum([int(i) for i in str(i)])
  sumj=sum([int(j) for j in str(j)])
  tmpans=sumi+sumj
  if tmpans < ans:
    ans=tmpans

print(ans)

Solution (Python):
n = input()
res = 1<<10
def ds(x):
    return sum(map(int,list(str(x))))

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

print res

Solution (Python):
def digsum(x):
    sum = 0
    while(x != 0):
        sum += x%10
        x //= 10
    return sum
N = int(input())
while(1):
    if N == 10 or N%10 != 0:
        break
    N //= 10
print(digsum(N) if N!= 10 else 10)

Solution (Python):
import sys

input = sys.stdin.readline


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


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


def sum_digits(n: int, base: int) -> int:
    if n < base:
        return n
    else:
        return sum_digits(n // base, base) + (n % base)


N = int(input())
m = float("inf")
for n in range(1, N):
    s = sum_digits(n, 10) + sum_digits(N - n, 10)
    if s < m:
        m = s
print(m)

Solution (Python):
import sys

def sumdigit(val):
  res = 0
  for v in str(val):
    res += int(v)
  return res

N = int(sys.stdin.readlines()[0].strip())
min_val = sys.maxsize
for a in range(1, N):
  b = N - a
  cur_val = sumdigit(a) + sumdigit(b)
  if min_val > cur_val:
    min_val = cur_val
print(min_val)

Solution (Python):
N = int(input())
A = 1
B = 1
listA = []
listB = []
for i in range(N):
    
    A = i+1
    B = N - i -1
    listA.append(A)
    listB.append(B)
ans = []
for i in range(N-1):
    A = str(listA[i])
    if len(str(A)) == 1:
        sumA = int(A)
    elif len(str(A)) == 2:
        sumA = int(A[0]) + int(A[1])
    elif len(str(A)) == 3:
        sumA = int(A[0]) + int(A[1]) + int(A[2])
    elif len(str(A)) == 4:
        sumA = int(A[0]) + int(A[1]) + int(A[2]) + int(A[3])
    elif len(str(A)) == 5:
        sumA = int(A[0]) + int(A[1]) + int(A[2]) + int(A[3]) +int(A[4])
    elif len(str(A)) == 6:
        sumA = int(A[0]) + int(A[1]) + int(A[2]) + int(A[3]) +int(A[4]) + int(A[5])

    B = str(listB[i])
    if len(str(B)) == 1:
        sumB = int(B)
    elif len(str(B)) == 2:
        sumB = int(B[0])+ int(B[1])
    elif len(str(B)) == 3:
        sumB = int(B[0])+ int(B[1]) + int(B[2])
    elif len(str(B)) == 4:
        sumB = int(B[0])+ int(B[1]) + int(B[2]) + int(B[3])
    elif len(str(B)) == 5:
        sumB = int(B[0])+ int(B[1]) + int(B[2]) + int(B[3]) +int(B[4])
    elif len(str(B)) == 6:
        sumB = int(B[0])+ int(B[1]) + int(B[2]) + int(B[3]) +int(B[4])+ int(B[5])

    ans.append(sumA + sumB)

print(min(ans))

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def digit_sum(x):
    S = str(x)
    dig_sum = 0
    for s in S:
        dig_sum += int(s)

    return dig_sum

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]

    min_sum = sys.maxint
    for A in range(1, N):
        B = N - A
        min_sum = min(min_sum, digit_sum(A) + digit_sum(B))

    print min_sum



if __name__ == '__main__':
    main()

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

ans = 10 ** 15

for a in range(1, N // 2 + 1):
    A, B = a, N - a
    total = sum(map(int, list(str(A)))) + sum(map(int, list(str(B))))
    ans = min(ans, total)

print(ans)

Solution (Python):



def digitEachDigitSum(number):
	numberStr=str(number)
	numberLength = len(numberStr)
	numberRange = range(0,numberLength,1)
	numberDigitSum = 0
	for eachNumberPosition in numberRange:
		eachNumberInt = int(numberStr[eachNumberPosition])
		numberDigitSum = numberDigitSum+eachNumberInt
	return numberDigitSum

def minDigitSum(givenNumber):
	minSum = 100000000
	checkNumberRange = range(1,givenNumber,1)
	for nowNumber in checkNumberRange:
		anotherNumber = givenNumber-nowNumber
		twoNumberSum = digitEachDigitSum(nowNumber)+digitEachDigitSum(anotherNumber)
		if twoNumberSum < minSum:
			minSum = twoNumberSum



	return minSum

if __name__ == '__main__':
	N = int(input())
	solution=minDigitSum(N)
	print("{}".format(solution))

Solution (Python):
N = input()

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

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

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

t = N
SUM_N = 0
non_list = [10,100,1000,10000,100000]
if N not in non_list:
    while t!=0:
        SUM_N  += t%10
        t //= 10
    print(SUM_N)
else:
    print(10)

Solution (Python):

N = int(input())

ans = 10 ** 9 + 7

for A in range(1, N):
    B = N - A
    ans_tmp = 0
    for i in range(6):
        if A < 1: break
        ans_tmp += A % 10
        A = A // 10
    for i in range(6):
        if B < 1: break
        ans_tmp += B % 10
        B = B // 10
    if ans_tmp < ans: ans = ans_tmp

print(ans)

Solution (Python):
n=str(int(input())*10000)
a=int(n[0])+int(n[1])+int(n[2])+int(n[3])+int(n[4])
if a==1:
    print(10)
else:
    print(a)

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


N = int(input())

t = float('inf')
for a in range(1, N // 2 + 1):
    b = N - a
    t = min(t, digit_sum(a) + digit_sum(b))
print(t)

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

N = int(input())

mi = 999999999
for a in range(1, N):
    b = N - a
    mi = min(mi, sum_digit(a)+sum_digit(b))

print(mi)

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

Solution (Python):
N=int(input())
ans=float("inf")
for i in range(1,N):
  A,B=str(i),str(N-i)
  S=0
  for a in range(len(A)):
    S+=int(A[a])
  for b in range(len(B)):
    S+=int(B[b])
  ans=min(ans,S)
print(ans)

Solution (Python):
def calc_digit_sum(n):
    return sum(list(map(int, list(str(n)))))

n = int(input())
ans = 10000000
for i in range(1, int(n/2) + 1):
    ans = min(calc_digit_sum(i) + calc_digit_sum(n-i), ans)
print(ans)

Solution (Python):
def calc_digit_sum(n):
    return sum(list(map(int, list(str(n)))))

n = int(input())
ans = 10000000
for i in range(1, int(n/2) + 1):
    ans = min(calc_digit_sum(i) + calc_digit_sum(n-i), ans)
print(ans)

Solution (Python):
N=int(input())
ans=1000000
for i in range(1,N):
    ans=min((i%10)+((i//10)%10)+((i//100)%10)+((i//1000)%10)+((i//10000)%10)+((i//100000)%10)+((i//1000000)%10)+((N-i)%10)+(((N-i)//10)%10)+(((N-i)//100)%10)+(((N-i)//1000)%10)+(((N-i)//10000)%10)+(((N-i)//100000)%10)+(((N-i)//1000000)%10),ans)
print(ans)

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

minCount = 10 ** 6
for i in range(1, n):
    
    _a = str(i)
    _b = str(n - i)
    count = 0
    for j in range(len(_a)):
        count += int(_a[j])
    for j in range(len(_b)):
        count += int(_b[j])
    minCount = min(minCount, count)
print(minCount)

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

Solution (Python):
n = sum([int(x) for x in input().strip()])

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

Solution (Python):
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def digits_sum(x: int) -> int:
    result = 0
    while x != 0:
        result += x % 10
        x //= 10
    return result


def main() -> None:
    n = next_int()
    ans = sys.maxsize

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n = sum(map(int,list(input())))
print((n,10)[n==1])

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

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


def sum_digits(n):
    result = 0
    while True:
        result += (n % 10)
        n //= 10
        if n == 0:
            break

    return result


min_of_sum = 10 ** 5
for a in range(1, n):
    b = n - a
    digits_sum_of_a = sum_digits(a)
    digits_sum_of_b = sum_digits(b)
    digits_sum = digits_sum_of_a + digits_sum_of_b
    if digits_sum < min_of_sum:
        min_of_sum = digits_sum

print(min_of_sum)

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

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


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


ans = 10**5
for i in range(1, N):
    ans = min(ans, digits_sum(i) + digits_sum(N - i))
print(ans)

Solution (Python):
n=int(input())
tips=[10,100,1000,10000,100000]
if n in tips:
    print(10)
else:
    ans_h=[int(x) for x in list(str(n))]
    print(sum(ans_h))

Solution (Python):
N = int(input())
digit_sums = []
for i in range(1, N // 2 + 1):
    A_sum = sum([int(c) for c in str(i)])
    B_sum = sum([int(c) for c in str(N - i)])
    digit_sums.append(A_sum + B_sum)
print(min(digit_sums))

Solution (Python):
n=input()
l=len(n)
m=int(n)
sum=0
for i in range(l-1,-1,-1):
  x=m//10**i
  m-=x*10**i
  sum+=x
if sum==1:
  print(10)
else:
  print(sum)

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

ans = 9999
for a in range(1,N):
    b = N-a
    x = sum(map(int,str(a)))
    y = sum(map(int,str(b)))
    ans = min(ans, x+y)
print(ans)

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

ans = float('inf')
a = 1

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

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

if N % 10 == 0:
    print(10)
    exit()
    
wa=0
ans=N
for A in range(N):
    wa=sum(map(int, list(str(A))))+sum(map(int, list(str(N-A))))
    if wa <= ans:
        ans = wa

print(ans)

Solution (Python):
def digit(a):
    tmp = list(str(a))
    x = 0
    for j in tmp:
        x += int(j)
    return x
n=int(input())
min_ = n
for i in range(1,n//2):
    y = digit(i)+digit(n-i)
    min_ = min(min_,y)
print(min_)

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


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


min_sum = float('inf')
for a in range(1, n):
    min_sum = min(min_sum, dsum(a) + dsum(n - a))
print(min_sum)

Solution (Python):
def digit_sum(x):
  if x < 10:
    return x
  return x % 10 + digit_sum(int(x / 10))
N = int(input())
ans = N
for i in range(1, int(N / 2) + 1):
  d = digit_sum(i) + digit_sum(N - i)
  if d < ans:
    ans = d
print(ans)

Solution (Python):
N = int(input())
ans = N
for i in range(1,N):
    A,B = 0,0
    A_str = list(str(i))
    B_str = list(str(N-i))
    for e in A_str:
        A += int(e)
    for e in B_str:
        B += int(e)
    if A + B < ans:
        ans = A + B       
print(ans)

Solution (Python):
n=int(raw_input())
ret=[]
for y in range(n/2):
	a=y+1
	b=n-a
	r1 = 0
	r2 = 0
	for i in str(a):
		r1 += int(i)
	for x in str(b):
		r2 += int(x)
	r=r1+r2
	ret.append(r)
print min(ret)

Solution (Python):
l = list(input())
s = sum([int(x) for x in l])
if s == 1:
  s = 10
print(s)

Solution (Python):



n=int(raw_input())
maxv=n
for a in xrange(1,n):
  b=n-a
  if a>b: break
  sa=sum([int(x) for x in str(a)])
  sb=sum([int(x) for x in str(b)])
  maxv=min(maxv, sa+sb)
print(maxv)

Solution (Python):



n=int(raw_input())
maxv=n
for a in xrange(1,n):
  b=n-a
  if a>b: break
  sa=sum([int(x) for x in str(a)])
  sb=sum([int(x) for x in str(b)])
  maxv=min(maxv, sa+sb)
print(maxv)

Solution (Python):
def sumDigit(x):
	total = 0
	while x > 0:
		total += x % 10
		x = x // 10

	return total

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

for a in range(1, N):
	sum_A = sumDigit(a)
	sum_B = sumDigit(N - a)
	ans.append(sum_A + sum_B)

print(min(ans))

Solution (Python):
def kakuketa(p):
    s=0
    while p>0:
       s+=p%10
       p=p//10
    return s

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

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

N = int(input())
ans = 1<<30
for i in range(1, N):
    j = N - i
    ans = min(ans, wa(i)+wa(j))
print(ans)

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

sol = 21312321
for i in range(1, n):
    sol = min(sol, sum([ord(x) - 48 for x in str(i)]) + sum([ord(x) - 48 for x in str(n-i)]))

print (sol)

Solution (Python):







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

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

dsum = [digitsum(a)+digitsum(n-a) for a in range(1,int(n/2)+1)]
print(min(dsum))

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

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


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

min_sum = 1000000
for i in range(N - 1):
    A = i + 1
    B = N - A
    tmp = digitSum(A) + digitSum(B)
    if tmp < min_sum:
        min_sum = tmp

ans = min_sum
print(ans)

Solution (Python):
n=int(input())
ans=2148483647
for i in range(1,n):
    a,b=i,n-i
    t=0
    for j in range(len(str(a))):
        t+=int(str(a)[j])
    for j in range(len(str(b))):
        t+=int(str(b)[j])
    if t<ans:
        ans=t
print(ans)

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

Solution (Python):
import math

n = int(input())
index=1
minS=10**5
while index < n//2+1:
    a = str(index)
    b = str(n-index)
    listA= list(a)
    listB= list(b)
    sum =0
    index2 =0
    while index2 < len(listA):
        sum+=int(listA[index2])
        index2+=1
    index3 =0
    while index3 < len(listB):
        sum+=int(listB[index3])
        index3+=1
    if sum < minS:
        minS = sum
    index+=1
print(minS)

Solution (Python):
N=int(input())
a=1
ls=[]
while a<N:
    b=list(str(N-a))
    sum=0
    for i in range(len(b)):
        sum+=int(b[i])
    ls.append(sum+1)
    a*=10
print(min(ls))

Solution (Python):
n = int(input())
if n%10 == 0:
    print(10)
else:
    nums = list(map(int,[x for x in str(n)]))
    print(sum(nums))

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

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

Solution (Python):
n=input()
l=[10,100,1000,10000,100000]
if int(n) in l:print(10)
else:
  L=list(n)
  c=0
  for i in range(len(L)):
    c+=int(L[i])
  print(c)

Solution (Python):
N = int(input())
r = float("inf")
for i in range(1, N):
    A = i
    B = N - i
    a = 0
    b = 0

    while A >= 1:
        a += A % 10
        A /= 10

    while B >= 1:
        b += B % 10
        B /= 10

    if a + b <= r:
        r = a + b

print(int(r))

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

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

total_list = []
for i in range(1, N):
  A, B = i, N - i
  total_list.append(sum([digit_sum(i) for i in [A, B]]))
print(min(total_list))

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

N = int(input())
l = [ digit_sum(x) for x in range(1, N+1)]

sum_a_b = []
if N % 2 == 0:
    sum_a_b.append(l[int(N/2)-1]*2)

for i in range(1, int(N/2)):
    sum_a_b.append(l[i-1] + l[N-i-1])

print(min(sum_a_b))

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

n = int(input())

smallest = 9999999999
for i in range(1,n//2+1):
	a = i
	b = n - i
	if sumOfDegits(a) + sumOfDegits(b) < smallest:
		smallest = sumOfDegits(a) + sumOfDegits(b)
print(smallest)

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

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

Solution (Python):


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

if __name__ == '__main__':
    main()

Solution (Python):
n = str(input())
len = len(n)
list = list(n)
ans = 0
if len == 1:
  ans = int(n)
elif n.count("0") != len - 1:
  for element in list:
    ans += int(element)
else:
  ans = 10
print(ans)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())

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

ans = INF
for a in range(1,N):
    b = N-a
    ans = min(ans,dsum(a)+dsum(b))

print(ans)

Solution (Python):




string = list(input())
line=[]

for i in range(len(string)):
    if string[i]!="0":
        line.append(string[i])
        

num = int(''.join(line))
Sum = 0

if num==1:
    print("10")
else:
    for i in range(len(line)):
        Sum += int(line[i])
    print(Sum)

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

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

Solution (Python):

from sys import stdin

in_strings = lambda: stdin.readline()[:-1] 
in_int = lambda: int(stdin.readline()) 
in_intlist = lambda: list(map(int, stdin.readline().split())) 

N = in_int()

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

ans = 10**3
for i in range(1, N//2 + 1):
    temp = OrderSum(i) + OrderSum(N-i)
    if ans > temp:
        ans = temp
print(ans)

Solution (Python):
n = input()

m = len(n)
f = 0
ans = 0

for i in range(m):
    ans += int(n[i])
    
    
if m>1 and n[0] == '1':
    if n[1] == '0':
        ans += 9
print(ans)

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

Solution (Python):
def digit(n):
    ans=0
    for i in n:
        ans += int(i)
    return ans
    
def iszero(n):
    if n[0]!='1': return False
    for i in n[1:]:
        if i!='0': return False
    return True
    
N=input()

if iszero(N):
    ans = 10
else:
    ans = digit(N)
    
print(ans)

Solution (Python):


INF = float('inf')


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


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


N = int(input())

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

print(ans)

Solution (Python):
N = int(input())
L = []
flag = True
k = str(N)
if (N == 10**(len(k)-1)):
  flag = True    
else:
  flag = False
if flag:
  print('10')
else:
  for i in range(len(k)):
    L.append(int(k[i]))
  print(sum(L))

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

cand = []
def func(a):
    return sum([int(i) for i in str(a)])
for i in range(1, N//2 + 1):
    a = i
    b = N - i
    cand.append(func(a) + func(b))
print(min(cand))

Solution (Python):
from math import log
n = int(input())

if log(n, 10) % 1 == 0:
    ans = 10
else:
    ans = sum(map(int, list(str(n))))
print(ans)

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

n = int(input())

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

print(ans)

Solution (Python):
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    min_s = sys.maxint
    for i in range(1, N):
        A = str(i)
        A = A.zfill(6)
        B = str(N - i)
        B = B.zfill(6)
        s = 0
        for j in range(6):
            s += int(A[j]) + int(B[j])
        min_s = min(s, min_s)

    print min_s
if __name__ == '__main__':
    main()

Solution (Python):
f = lambda x: sum(map(int, str(x)))
N = int(input())
print(min(f(i) + f(N - i) for i in range(1, N // 2 + 1)))

Solution (Python):
def digitSum(num):
    s = str(num)
    res = 0
    for c in s:
        res += int(c)
    return res

n = int(input())
r = float('inf')
for i in range(1,n):
    j = n - i
    r = min(r,digitSum(i)+digitSum(j))
print(r)

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

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


N = int(input())
ans = 10 ** 18
for i in range(1, N):
    A = i
    B = N - A
    if A > B:
        break
    ans = min(ans, calc_dig_sum(A)+calc_dig_sum(B))
print(ans)

Solution (Python):
n=int(input())
f=lambda x:sum(map(int,str(x)))
v=1e9
for i in range(1,n//2+1):
  a=i
  b=n-i
  v=min(v,f(a)+f(b))
print(v)

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

Solution (Python):
def count(n):
    cnt = 0
    for i in str(n):
        cnt += int(i)
    return cnt

n = int(input())
if n % 10 == 0:
    print(count(n//2)*2)
else:
    print(count(n))

Solution (Python):

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