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())
sumn = 0
data = 10
check = False
for i in range(1,6):
	if(10**i==n):
		check = True

if(check):
	print(10)
else:
	while n>=10:
		sumn += n%10
		n //= 10
	sumn += n
	print(sumn)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans = 10**6
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

arr = [(i, N-i) for i in range(1, int(N/2))]
minn = N
for i, j in arr:
    temp = sum(list(map(int, list(str(i))))) + sum(list(map(int, list(str(j)))))
    minn = min(temp, minn)

print(minn)

Submission status: Accepted

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

n = int(raw_input())
mn = 100
for a in range(1, n/2+1):
    mn = min(mn, calc(a) + calc(n-a))
print mn

Submission status: Accepted

Solution code:
n = input()


if int(n) % 10 != 0:
    print(sum([int(i) for i in list(n)]))
else:
    a = int(int(n)/10)
    b = int(n)-a

    a_sum = sum([int(i) for i in list(str(a))])
    b_sum = sum([int(i) for i in list(str(b))])
    print(a_sum+b_sum)

Submission status: Accepted

Solution code:
N = int(input())
ls = [0]*6
count = 0
for i in range(6):
    k = int(N % pow(10,i+1)) 
    ls[i] = int(k / pow(10,i))
    count += ls[i]
if count == 1:
    count = 10

print(count)

Submission status: Accepted

Solution code:
n=int(input())
ans=10**9

for i in range(1,n):
    suma,sumb=0,0
    ii,jj=i,n-i
    while ii>0:
        suma+=ii%10
        ii//=10
    while jj>0:
        sumb+=jj%10
        jj//=10
    ans=min(ans,suma+sumb)
print(ans)

Submission status: Accepted

Solution code:
n = input()

sum = 0
for i in n:
    sum += int(i)

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

Submission status: Accepted

Solution code:
import math
 
 
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)
 
 
n =  int(input())
 
# 0が多くなるようにする
rank = math.ceil(math.log10(n)) 
div =  n % 10**rank
if div == 0:
    print(10)
else :
    print(digitSum(int(n)))

Submission status: Accepted

Solution code:
N = int(input())
digitsum = lambda n: sum(map(int, str(n)))
ans = 36
for A in range(1, N//2 + 1):
    dig = digitsum(A) + digitsum(N - A)
    if dig < ans:
        ans = dig
print(ans)

Submission status: Accepted

Solution code:
import math


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


n =  int(input())


# 0が多くなるようにする
ans = digitSum(n)
if ans == 1:
    print(10)
else :
    print(ans)

Submission status: Accepted

Solution code:
N = int(raw_input())
m = 99999
for A in range(1, N):
  B = N - A
  s = sum([int(x) for x in str(A)] + [int(x) for x in str(B)])
  m = min(m, s)
print m

Submission status: Accepted

Solution code:
N = raw_input()
sum = sum(map(int, list(N)))
if sum == 1:
  print(10)
else:
  print(sum)

Submission status: Accepted

Solution code:
N=int(input())

import numpy as np

a=np.arange(N)
a=np.delete(a,0)

b=N-a

num_arr=[]

for i in range(len(a)):
	factor_a=[int(x) for x in list(str(a[i]))]
	factor_b=[int(x) for x in list(str(b[i]))]
	num_arr.append(sum(factor_a)+sum(factor_b))

print(min(num_arr))

Submission status: Accepted

Solution code:
n = map(int,list(input()))
s = 0
for i in n:
    s += i

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

Submission status: Accepted

Solution code:
# coding: utf-8
import math
n=int(input())-1
a=10**int(math.log10(n))
b=n-a+1
print(sum(map(int,str(a)))+sum(map(int,str(b))))

Submission status: Accepted

Solution code:
N = int(input())

min_num = float('inf')
for i in range(1, N):
    j = N - i
    A_sum = sum(map(int, list(str(i))))
    B_sum = sum(map(int, list(str(j))))
    if A_sum + B_sum < min_num:
        min_num = A_sum + B_sum
print(min_num)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Grand Contest
# Problem A


def sum_digit(number):
    string = str(number)
    array = list(map(int, list(string)))
    return sum(array)


if __name__ == '__main__':
    n = int(input())
    a = 0
    digit_sum_min = 1000000

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

        sum_a = sum_digit(a)
        sum_b = sum_digit(b)
        digit_sum_min = min(digit_sum_min, sum_a + sum_b)

    print(digit_sum_min)

Submission status: Accepted

Solution code:
n = input()

if int(n) % 10 == 0:
  print(10)
else:
  res = 0
  for i in n:
  	res += int(i)
  print(res)

Submission status: Accepted

Solution code:
def eachdigitsum(n):
	x = len(str(n))
	sum = 0
	for i in range(x):
		t = n//10**(x-i-1)
		n = n - t*10**(x-i-1)
		sum += t
	return sum
	
n = int(input())
min = 1000000
for i in range(1,n//2 + 2):
	x = eachdigitsum(i) + eachdigitsum(n-i)
	if min > x:
		min = x
print(min)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#agc025a

n=raw_input()
s=0
for i in xrange(len(n)):
 s+=int(n[i])
if s==1:
 print 10
else:
 print s

Submission status: Accepted

Solution code:
import sys

def digits_sum(x):
    return sum(map(int, str(x)))

def solve(n):
    ans = sys.maxsize
    for a in range(1, n):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))

    return ans

if __name__ == '__main__':
    n = int(input())
    print(solve(n))

Submission status: Accepted

Solution code:
import sys

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

def solve(n):
    ans = sys.maxsize
    for a in range(1, n):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))

    return ans

if __name__ == '__main__':
    n = int(input())
    print(solve(n))

Submission status: Accepted

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

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

main()

Submission status: Accepted

Solution code:
# cook your dish here

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

n = int(input())
ans = 1000000
l = 1
r = n - 1
while l <= r:
    ans = min(ans , digSum(l) + digSum(r))
    l += 1
    r -= 1

print(ans)

Submission status: Accepted

Solution code:
n=sum(map(int,input()));print(n+9*(n<2))

Submission status: Accepted

Solution code:
n=sum(map(int,input()));print([n,10][n<2])

Submission status: Accepted

Solution code:
def a_digits_sum(N):
    # A+B のk桁目を c_k、Nのk桁目をn_kとおくと、筆算の考え方より、
    # c_k=n_k となるようにすればいい。つまり解はNの各桁の和に等しい。
    # ただし、Nが10の冪乗のときは、上の考え方では片方がNに等しくなってしまう。
    # この場合、 N=10^k とすると、 A=a*10^(k-1), B=b*10^(k-1) (ただし a+b=10)
    # の形にするしかない。よってA+Bの各桁の和は常に10。
    ans = 0
    n = str(N)
    for c in n:
        ans += int(c)
    if ans == 1:
        # 最上位桁に1が出て、その後0しか出ていない。Nは10の冪乗だった
        ans = 10
    return ans

N = int(input())
print(a_digits_sum(N))

Submission status: Accepted

Solution code:
n = int(input())

a = 1
while a * 10 <= n:
    a *= 10

if a != n:
    b = n - a
else:
    b = n - a//10

print(1 + sum([int(digit) for digit in str(b)]))

Submission status: Accepted

Solution code:
def a_digits_sum(N):
    def digit_sum(n):  # 非負整数nの各桁の和
        str_n = str(n)
        ret = 0
        for c in str_n:
            ret += int(c)
        return ret

    ans = float('inf')
    for A in range(1, N):
        B = N - A
        ans = min(ans, digit_sum(A) + digit_sum(B))
    return ans

N = int(input())
print(a_digits_sum(N))

Submission status: Accepted

Solution code:
def s(a):
 if a:
  return(s(a//10) + a%10)
 else:
  return(0)
n = int(input())
ans = 10000000000000
for i in range(1,n//2+1):
 k = s(i) + s(n-i)
 if k < ans:
  ans = k
print(ans)

Submission status: Accepted

Solution code:
N=int(input());print(min(sum(map(int,str(i)+str(N-i)))for i in range(1,N)))

Submission status: Accepted

Solution code:
#! /usr/bin/env python3

N = int(input())
ans = 10000000
for i in range(1, N):
    s = sum(map(int, str(i))) + sum(map(int, str(N - i)))
    ans = min(ans, s)
print(ans)

Submission status: Accepted

Solution code:
a=sum(map(int,input()));print(a if a>1 else 10)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
ans = float('Inf')
for i in range(1, n//2+1):
  if sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i)))) < ans:
    ans = sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i))))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
sum=0
a=1
b=n-1
ans=100000000
while(a<=b):
	ans1=0
	i=a
	j=b
	while(i//10!=0):
		ans1+=i%10
		i=i//10
	ans1+=i%10
	while(j//10!=0):
		ans1+=j%10
		j=j//10
	ans1+=j%10
	a+=1
	b-=1
	if(ans1<ans):
		ans=ans1
print(ans)

Submission status: Accepted

Solution code:
a=sum(int(i)for i in input());print([a,10][a==1])

Submission status: Accepted

Solution code:
a=sum(int(i)for i in input());print(10if a==1else a)

Submission status: Accepted

Solution code:
 # -*- coding: utf-8 -*-

# 入力を各変数に格納
N = int(input())

ans = 0
# 10の〇乗は10になるパターン
for i in range(1, 6):
	if N == 10 ** i:
		ans = 10
# 他は各桁を足した合計
if ans == 0:
	# 数値を文字列にして1文字ずつのリストにする
	strN_list = list(str(N))
	# ループして各桁を足した合計を計算
	for strN in strN_list:
		ans += int(strN)
print(ans)

Submission status: Accepted

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

    ans = f(N)
    print(ans)


def sum_digits(x):
    ans = 0
    while x > 0:
        x, a = divmod(x, 10)
        ans += a
    return ans


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


def f(N):
    ans = float("inf")
    # 正の整数
    for A in range(1, N//2 + 1):
        B = N - A
        tmp = sum_digits(A) + sum_digits(B)
        ans = min(ans, tmp)

    return ans


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def digsum(a):
	sum=0
	A=str(a)
	for i in range(0,len(A)):
		sum=sum+int(A[i])
	return sum
n=int(input())
#print(digsum(n))
mini=n
a=0
b=0
for i in range(1,n):
	A=i
	B=n-i
	suma=digsum(A)+digsum(B)
	if(suma<mini):
		mini=suma
		a=A
		b=B
print(mini)
#print(a,b)

Submission status: Accepted

Solution code:
a=sum(int(i)for i in input());print(a if a!=1else 10)

Submission status: Accepted

Solution code:
n = int(input())
ans = float('Inf')
for i in range(1, n):
  if i > n//2:
    break
  if eval('+'.join(str(i))) + eval('+'.join(str(n - i))) < ans:
    ans = eval('+'.join(str(i))) + eval('+'.join(str(n - i)))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
while n > 0:
    ans += n%10
    n //= 10
print(ans if ans > 1 else 10)

Submission status: Accepted

Solution code:
N = int(input())

if N < 10:
    print(N)
    exit()

N_list = list(map(int, list(str(N))))

if N % 10 == 0:
    if N_list[0] == 1:
        print(10)
    else:
        print(N_list[0])
else:
    print(sum(list(map(int, list(str(N))))))

Submission status: Accepted

Solution code:
def k(n):return sum(int(i)for i in str(n))
m=n=int(input())
for i in range(1,n):m=min(m,k(i)+k(n-i))
print(m)

Submission status: Accepted

Solution code:
n = int(input())


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


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

Submission status: Accepted

Solution code:
N = input()
A = max(1,10**(len(N)-2))
B = int(N) - A
print(sum(list(map(int,str(A)))) + sum(list(map(int,str(B)))))

Submission status: Accepted

Solution code:
N = int(input())
Ans = 0
while N >=1:
    Ans += N%10
    N //= 10
print(Ans if Ans != 1 else 10)

Submission status: Accepted

Solution code:
N = int(input())

res = 2 * 32


def g(a):
    if a < 10:
        return a
    return a % 10 + g(a // 10)


def f(a, b):
    return g(a) + g(b)


for a in range(1, N):
    b = N - a
    res = min(res, f(a, b))

print(res)

# N, D1, D2 = [int(a) for a in input().split()]
# import math
#
# table = [
#     [False for _ in range(N * 2)]
#     for _ in range(N * 2)
# ]
#
# xd1 = [
#     (x, D1 - (x * x)) for x in range(int(math.ceil(math.sqrt(D1))) + 1)
# ]
# xd1_ = [(x, y, int(math.sqrt(y))) for x, y in xd1 if y >= 0]
# xd1 = [(x, yy) for x, y, yy in xd1_ if y == yy * yy]
#
# xd2 = [
#     (x, D2 - (x * x)) for x in range(int(math.ceil(math.sqrt(D2))) + 1)
# ]
# xd2_ = [(x, y, int(math.sqrt(y))) for x, y in xd2 if y >= 0]
# xd2 = [(x, yy) for x, y, yy in xd2_ if y == yy * yy]
#
#
# def check(x, y):
#     return 0 <= x < 2 * N and 0 <= y < 2 * N
#
#
# def solve(skip):
#     res = []
#
#     for i in range(N * 2):
#         for j in range(N * 2):
#             if skip != 0:
#                 skip -= 1
#                 continue
#             if table[i][j]:
#                 continue
#
#             res.append((i, j))
#             if len(res) == N * N:
#                 return res
#
#             for x, y in xd1:
#                 p, q = x + i, y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = -x + i, y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = x + i, -y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = -x + i, -y + j
#                 if check(p, q):
#                     table[p][q] = True
#             for x, y in xd2:
#                 p, q = x + i, y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = -x + i, y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = x + i, -y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = -x + i, -y + j
#                 if check(p, q):
#                     table[p][q] = True
#     return None
#
#
# for s in range(N * N):
#     res = solve(s)
#     if res is None:
#         continue
#     for x, y in res:
#         print(x, y)
#     break

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
lis = []
for i in range(1,n):
    r = n - i
    ti = list(str(i))
    tr = list(str(r))
    for k in range(len(ti)):
        ti[k] = int(ti[k])
    for k in range(len(tr)):
        tr[k] = int(tr[k])
    lis.append(sum(ti)+sum(tr))
print(min(lis))

Submission status: Accepted

Solution code:
# main

input_str = input()
input_num = int(input_str)

input_num_digits = len(input_str) - 1

if input_num == 10 ** input_num_digits:
    min_digit_sums = [10]

else:
    former_num = 10 ** input_num_digits
    latter_num = input_num - former_num

    digit_sum = 0
    for char in str(former_num):
        digit_sum += int(char)
    for char in str(latter_num):
        digit_sum += int(char)
    min_digit_sums = [digit_sum]

for i in range(1, input_num // 2):
    former_num = i
    latter_num = input_num - i

    digit_sum = 0
    for char in str(former_num):
        digit_sum += int(char)
    if digit_sum >= min(min_digit_sums):
        continue
    for char in str(latter_num):
        digit_sum += int(char)
    if digit_sum < min(min_digit_sums):
        min_digit_sums.append(digit_sum)

print(str(min(min_digit_sums)))

Submission status: Accepted

Solution code:
N = int(input())
ans = float('inf')
for i in range(1,N):
	num = i
	j = N - num
	d = 0
	while num != 0:
		d += (num % 10)
		num //= 10
	while j != 0:
		d += (j % 10)
		j //= 10

	ans = min(d,ans)

print(ans)

Submission status: Accepted

Solution code:
import math

A=0
N=int(input())
for i in range(5,10):
  X = N / i
  if X == int(X):
    A += math.floor(N / i)
    break
  else:
    continue
  
B = N - A
anum=[]
bnum=[]
a=0
b=0

while A > 0:
    anum.append(A%10)
    A //= 10 
anum.reverse()

while B > 0:
    bnum.append(B%10)
    B //= 10 
bnum.reverse()

for q in anum:
  a += q
for w in bnum:
  b += w

print(a+b)

Submission status: Accepted

Solution code:
n = int(input().strip())
ans = int(1e9)
for a in range(1, n):
  b = n-a
  ans = min(ans, sum(map(int,str(a)))+sum(map(int,str(b))))
print(ans)

Submission status: Accepted

Solution code:
n = int(raw_input())
dp = range(100010)
for i in xrange(1, n + 1):
    dp[i] = dp[i/10] + i % 10
print min(dp[x] + dp[n-x] for x in xrange(1, n))

Submission status: Accepted

Solution code:
N = input()
 
l = [int(x) for x in list(str(N))]
 
s = 0
if (sum(l[1:-1])is 0) and l[-1] in [0,1,2] and l[0] == 1:
    s = 9
s += sum(l)
print(s)

Submission status: Accepted

Solution code:
N = int(input())
a = 0
b = 0
s = 10 ** 5
for i in range(1, N):
	a = sum(int(j) for j in str(i))
	b = sum(int(k) for k in str(N - i))
	if s >= a + b:
		s = a + b
print(s)

Submission status: Accepted

Solution code:
n = input()
f = 0
for i in list(n[1:]):
    if i == "0":
        continue
    else:
        f = 1
        break
if f == 0 and n[0] == "1":
    print(10)
else:
    print(sum([int(x) for x in list(n)]))

Submission status: Accepted

Solution code:
n = int(input())
a = 0
num = []
from functools import reduce
num = [int(x) for x in list(str(n))]
if n != 100000 and n != 10000 and n != 1000 and n != 100 and n != 10:
  for i in num:
    a = a + i
else:
    a = 10
print(a)

Submission status: Accepted

Solution code:
def each_digit_sum(num):
    sum_list = [int(x) for x in list(str(num))]
    min_sum = 0
    for y in sum_list:
         min_sum = min_sum + y
    return min_sum


sum = int(input())
ans = 0
for i in range(1,sum):
    A = i
    B = sum - i
    tmp_ans = each_digit_sum(A)+each_digit_sum(B)
    if(ans == 0 or tmp_ans<ans):
        ans = tmp_ans
print(ans)

Submission status: Accepted

Solution code:
def getSum(n):
    sum1 = 0
    while(n > 0):
        sum1 += int(n%10)
        n = int(n/10)
    return sum1
n = int(input())
dig_sum = getSum(n)
if (dig_sum) == 1:
    if n == 1:
        print(1)
    else:
        print(10)
else:
    print(dig_sum)

Submission status: Accepted

Solution code:
score = 9999999

n = int(raw_input())

sum_a = 0
while True:
    quo  = n %10
    sum_a += quo
    n = int(n/10)
    if n  == 0:
        break

if sum_a == 1:
    sum_a  =10

print sum_a

Submission status: Accepted

Solution code:
N = int(input())
min = 999999

A = 0
B = 0

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

for i in range(1, N/2+1):
    a = i
    b = N - i

    if min > digitSum(a) + digitSum(b):
        min = digitSum(a) + digitSum(b)   

print(min)

Submission status: Accepted

Solution code:
 # -*- coding: utf-8 -*-

# 入力を各変数に格納
N = int(input())

ans = 0
# 10の〇乗は10になるパターン
if N == 10 ** 1 or N == 10 ** 2 or N == 10 ** 3 or N == 10 ** 4 or N == 10 ** 5:
	ans = 10
# 他は各桁を足した合計
else:
	# 数値を文字列にして1文字ずつのリストにする
	strN_list = list(str(N))
	# ループして各桁を足した合計を計算
	for strN in strN_list:
		ans += int(strN)
print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())
minresult = 0

def gen(num):
   if num < 10:
      return(num)
   else:
      data_size = int(math.log10(num) + 1)
      sum = 0
      for i in range(data_size):
         digit = num // 10**(data_size - i - 1)
         sum += digit
         num -= digit * 10**(data_size - i - 1)
      return(sum)

for j in range(n - 1):
   A = gen(j + 1)
   B = gen(n - j - 1)
   result = A + B
   if minresult == 0 or result < minresult:
      minresult = result

print(minresult)

Submission status: Accepted

Solution code:
import sys

N=int(input())
non_zero=0

for i in range (1,len(str(N))):
    if str(N)[i]=='0':
        non_zero+=1
    
if non_zero==len(str(N))-1:
    if str(N)[0]=='1':
        print(10)
        sys.exit()
    else:
        print(int(str(N)[0]))
        sys.exit()

count=0
for j in range(len(str(N))):
    count+=int((str(N))[j])
    
print(count)

Submission status: Accepted

Solution code:
def DSum(n):
    s = list(str(n))
    i = list(map(int, s))
    return sum(i)

if __name__ == "__main__":
    a = int(input())
    hoge = DSum(a)
    if hoge == 1:
        hoge = 10
    print("{}".format(hoge))

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

while True:
	ans += N%10
	if N // 10 == 0:
		break
	N = N//10

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

Submission status: Accepted

Solution code:
n = int(input())
ans = 100

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

print(ans)

Submission status: Accepted

Solution code:
def count_k(num):
    a = list(str(num))
    a = list(list(map(int, a)))
    return sum(a)

N = int(input())

arr = [0] * N

for i in range(1, N):
    arr[i] = count_k(i)

re = 0
for i in range(0, int(N/2)):
    c = arr[i +1] + arr[N - i - 1]
    if re > c or re == 0:
        re = c
        
print(re)

Submission status: Accepted

Solution code:
N = int(input())

SUM = 10000000

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

print(SUM)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 03 21:23:15 2018

@author: ashida
"""

N = input()

if N == 10 or N == 100 or N == 1000 or N == 10000 or N == 100000:
    print(10)
else:
    ans = 0
    a = N
    while(a > 0):
        ans = ans + a - (a/10)*10
        a = a/10
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
n = list(str(N))
sumN = sum(map(int,n))
lenN = len(n)
lengN = 10 ** (lenN - 1)

if sumN == 1:
    print(10)
elif lenN == 1:
    print(n[0])
else:
    A = N // lengN
    B = sum(map(int,list(str(N % lengN))))
    print(A + B)

Submission status: Accepted

Solution code:
N = int(input())

minsum = int(1e4)

for A in range(1,int(N/2)):
    B = N-A
    a_sum = sum(list(map(int, list(str(A)))))
    b_sum = sum(list(map(int, list(str(B)))))
    if minsum > a_sum+b_sum: minsum = a_sum+b_sum

if int(N/2)==1:
    minsum=N
print(minsum)

Submission status: Accepted

Solution code:
N = int(input())						# 5

ans=0
if N<=9:
	ans=N
	print(ans)
	exit(0)

if N==10 or N==100 or N==1000 or N==10000 or N==100000:
	ans=10
	print(ans)
	exit(0)


s = str(N)
for c in s:
	ans += int(c)


print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N % 10 == 0:
    # print(str(N)[0])
    if str(N)[0] == "1":
        print(10)
    else:
        print(str(N)[0])
else:
    print(sum(list(map(int,list(str(N))))))

Submission status: Accepted

Solution code:
N = int(input())

def digitSum(X):

    ds = 0
    for x in str(X):
        ds += int(x)
    return ds

ans = N

for i in range(1, N):
    dgtSum = digitSum(i) + digitSum(N - i)
    if ans > dgtSum:
        ans = dgtSum

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 ==0:
  NA = int(N/2)
else:
  NA = int(N/2)
  
sum_n = 9*5*2 

for a in range(1,int(N/2+1)):
  summ = 0
  b = N-a
  list_a = list(str(a))
  list_b = list(str(b))
  
  while len(list_a) != len(list_b):
    list_a.insert(0,"0")
  for i in range(len(list_b)):
    summ += int(list_a[i])+ int(list_b[i])
  
  if summ < sum_n:
    sum_n = summ

print(sum_n)

Submission status: Accepted

Solution code:
n=input()
s=0
for i in n:
  t=int(i)/2
  s=int(i)+s
if(s==1):
  print(10)
else:
  print(s)

Submission status: Accepted

Solution code:
k = int(input())
 
while k % 10 == 0:
  if k != 10:
    k /= 10
  else:
    break
l = str(k) 
p = list(l)

al = 0
if k != 10: 
  for i in range(len(p)):
    al += int(p[i])
else:
  al = 10
print(al)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main(a,b):
	count = 0
	
	while(a>0):
		count += a%10
		a = int(a/10)
			
	while(b>0):
		count += b%10
		b = int(b/10)
	return count

n = int(input())

result = main(n-1,1)
for i in range(2,n):
	a  = n - i
	b = i
	result = min(result, main(a,b))
		
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

N=int(input())

A=1
B=N-A
min_val=N
while A < N:
	A_num=[int(i) for i in gen(A)]
	B_num=[int(i) for i in gen(B)]
	#print('A='+str(A),end=' ')
	#print('B='+str(B),end=' ')
	#print(A_num,end=' ')	
	#print(B_num,end=' ')
	val=sum(A_num)+sum(B_num)
	#print(val)
	if val < min_val:
		min_val=val
		#print(val)
	A+=1
	B=N-A

print(min_val)

Submission status: Accepted

Solution code:
n = int(input())
i = 100000
ans = 0
while True:
    ans += n//i
    n -= (n//i)*i
    i //= 10
    if n == 0:
        break
if ans == 1:
    print(10)
else:
    print(ans)

Submission status: Accepted

Solution code:
n = input()
s = len(n)
ans = 0
for i in range(s):
    ans += int(n[i])

if ans == 1:
    ans = 10
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
m = float("inf")
alist = []
blist = []

for i in range(1,N):
    a = i
    b = N - i
    while a > 0:
        alist.append( a % 10 )
        a //= 10
    alist.reverse()
    while b > 0:
        blist.append( b % 10 )
        b //= 10
    blist.reverse()
    A = sum(alist)
    B = sum(blist)
    if A + B < m:
        m = A + B
    alist.clear()
    blist.clear()

print(m)

Submission status: Accepted

Solution code:
#!/usr/bin/env python

N = int(input())

v = 0

def dsum(num):
  d = len(str(num))
  s = 0

  for i in range(d-1, -1, -1):
    n = num // 10**i
    s += n
    num = num % 10**i

  return s


min_s = 54
for A in range(1, N):
  B = N - A
  s = 0
  s += dsum(A)
  s += dsum(B)
  if s < min_s: min_s = s

print(min_s)

Submission status: Accepted

Solution code:
N = int(input())
c_list = []
if N % 2 ==0:
    for i in range(1, int((N+2)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
else:
    for i in range(1, int((N+1)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
print(min(c_list))

Submission status: Accepted

Solution code:
n = int(input())
out=100000
for i in range(1,n):
    a=n-i
    b1=str(a)
    b2=str(i)
    c=list(b1)
    c.extend(b2)
    d=[int(s) for s in c]
    e=sum(d)
    
    if e<out:
        out=e
        
print(out)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = str(n)
    if n % 10 == 0:
        a = 0
        for i in s:
            a += int(i)

        f = True
        for i in range(len(s)):
            if i == 0:
                pass
            else:
                if s[i] != "0":
                    f = False
                    break
        if f:
            if s[0] == "1":
                print(10)
            else:
                print(a)
        else:
            print(a)

    else:
        a = 0
        for i in s:
            a += int(i)
        print(a)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N= int(raw_input())

# print list(str(N))

sum_all = N
sum_tmp = N
tmp_A = 1
tmp_B = N
list_A_i = []
#for A in range(N):
for A in range(1, N/2):
    B = N - A
    list_A = list(str(A))
    list_B = list(str(B))
#    print list_A, list_B
    sum_tmp = sum(map(int, list_A))+ sum(map(int, list_B))
    if sum_tmp < sum_all:
        tmp_A = A
        tmp_B = B
        sum_all = sum_tmp

#print tmp_A, tmp_B
print sum_all

Submission status: Accepted

Solution code:
n=int(input())
res=n
for i in range(1,n):
  j=n-i
  i_=i
  j_=j
  if(i>j):break
  tmp=0
  while(i>0):
    tmp+=i%10
    i//=10
  while(j>0):
    tmp+=j%10
    j//=10
  res=min(res,tmp)
print(res)

Submission status: Accepted

Solution code:
n=int(input())
a,b=0,0
ans=[]

def pl(a,b):
    asum,bsum=0,0
    for i in range(len(a)):
        asum+=int(a[i])
    for i in range(len(b)):
        bsum+=int(b[i])
    return asum+bsum
        
for i in range(1,n):
    a=i ; b=n-i
    a=str(a) ; b=str(b)
    ans.append(pl(a,b))

print(min(ans))

Submission status: Accepted

Solution code:
def digitsum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

N = int(input())
summin = 10**5
for i in range(1,int(N/2)+1) : 
	A = i
	B = N - i

	sumab = digitsum(A) + digitsum(B)
	if (summin > sumab) :
		summin = sumab

print(summin)

Submission status: Accepted

Solution code:
l = list(input())
m = [int(k) for k in l]
s = sum(m)

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

Submission status: Accepted

Solution code:
N = int(input())
sum = 0
ls = [10**i for i in range(6)]
if N in ls:
    sum = 10
else:
    str_N = str(N)
    for i in range(len(str_N)):
        sum += int(str_N[i])

print(sum)

Submission status: Accepted

Solution code:
N = int(input())

min = 10000000000
k = -1
flag = False
for i in range(1,6):
    if N / (10 ** i) == 1:
        print(10)
        flag = True
        break

if flag == False:
    sum = 0
    strN = str(N)
    for i in range(len(strN)):
        sum += int(strN[i])
    print(sum)

Submission status: Accepted

Solution code:
a = int(input())
ans = 1000
for i in range(1, (a//2) + 1):
    num = 0
    for j in str(i):
        num += int(j)
    for j in str(a-i):
        num += int(j)
    ans = min(num, ans)
print(ans)