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



Sample input:
15


Sample output:
6

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import collections
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

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

if ans == 1:
    ans = 10

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N_list = list(map(int, list(input())))
s = sum(N_list)
# 求める値は、Nの各桁の和、ただし和が1となるときは10のべき乗ということなので10を返す。
if s == 1:
  print(10)
else:
  print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/agc025/tasks/agc025_a

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#025B
n=int(input())
#A>0 B>0

for i in range(1,n):
	A=i
	B=n-i
	#print(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)

Submission status: Accepted

Solution code:
def solve(n):
    # 1-origin
    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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# AGC 025 A - Digits Sum
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Digits Sum
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))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# python template for atcoder1
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# A
NL = list(map(int, list(input())))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = list(input())

m = set(n)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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):
    # print(i)
    m = N-i
    l = digits_sum(i) + digits_sum(m)
    min_num = min(l, min_num)

print(min_num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
#print(n)
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = 1
B = 1
listA = []
listB = []
for i in range(N):
    # N = A + B
    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))

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest025-A
#  https://atcoder.jp/contests/agc025/tasks/agc025_a
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
#           MinSum chenged OutPut
#			print("{} = {} + {} =>{}".format(givenNumber,nowNumber,anotherNumber,minSum))

	return minSum

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

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding: utf-8
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

minCount = 10 ** 6
for i in range(1, n):
    # a = i, b = n - i として各位の和を計算
    _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)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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_)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 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))
NL = list(map(int, list(input())))
 
if NL[0] == 1 and sum(NL) == 1:
    print(10)
else:
    print(sum(NL))

Submission status: Accepted

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