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(i) for i in list(input())]
s=sum(n)
if s==1 and min(n)==0:
  print(10)
else:
  print(s)

Submission status: Accepted

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

for i in range(1,N//2):
    A = str(i)
    B = str(N-i)
    AB_sum = 0
    for j in A:
        AB_sum += int(j)
    for j in B:
        AB_sum += int(j)
    if AB_sum < ans:
        ans = AB_sum

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
m = 10000000000000000
for i in range (1,N):
    a = i
    b = N-i
    s1,s2=str(a),str(b) #int型をstr型に
    d1,d2 = list(s1),list(s2) #一文字ずつリストに格納
    x1,x2 = list(map(int, d1)),list(map(int, d2)) #int型に直して格納
    sum1,sum2 = sum(x1),sum(x2)
    m = min(m,sum1+sum2)
print(m)

Submission status: Accepted

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


def main():
    N = int(input())
    if len(str(N)) >= 2 and int(str(N)[1:]) == 0 and str(N)[0] == '1':
        print(10)
    else:
        print(sum(map(int, str(N))))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# Meet

def digitSum(a):
	s=0
	while a!=0:
		s+=a%10
		a//=10

	return s

n = int(input())
a = 1
b = n-1

m = 100000000000
while a<=b:
	s1 = digitSum(a)
	s2 = digitSum(b)

	if s1+s2 < m:
		m = s1+s2

	a+=1
	b-=1

print(m)

Submission status: Accepted

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

N = int(input())

ans = 9999999
j = N - 1
for i in range(1, N):
    di = sum([int(d) for d in list(str(i))])
    dj = sum([int(d) for d in list(str(j))])
    ans = min(ans, di + dj)
    j -= 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N = ri()
ret = N
for A in range(1,N):
  B = N-A
  ret = min(ret, sum(int(e) for e in str(A)) + sum(int(e) for e in str(B)))
print(ret)

Submission status: Accepted

Solution code:
n = input()
flag = False
for i in range(len(n)):
    if 2 <= int(n[i]) <= 9:
        flag = True
        break
if int(n[-1]) == 1:
    flag = True

if flag == True:
    ans = 0
    for i in range(len(n)):
        ans += int(n[i])
else:
    ans = 9
    for i in range(len(n)):
        ans += int(n[i])
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 10*5
for i in range(1,N//2+1):
    L=[]
    for x in range(len(str(i))):
        L.append(int(str(i)[x]))
    for y in range(len(str(N-i))):
        L.append(int(str(N-i)[y]))
    ans = min(ans,sum(L))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = float("inf")
for i in range(1,n//2+1):
	x,num = str(i)+str(n-i),0
	for j in x: num += int(j)
	ans = min(ans,num)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=float("inf")
for i in range(1,n):
    sum=0
    j=n-i
    ii=str(i)
    jj=str(j)
    for k in range(len(ii)):
        sum+=int(str(i)[k])
    for k in range(len(jj)):
        sum+=int(str(j)[k])
    ans=min(ans,sum)
print(ans)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
  N = int(input())
  min = 1000000000000
  for i in range(1, N):
    A = i
    A_sum = sum([int(x) for x in list(str(A))])
    B = N - i
    B_sum = sum([int(x) for x in list(str(B))])
    buf = A_sum + B_sum
    if buf < min:
      min = buf
  print(min)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
# cook your dish here
def sum_dig(n):
    sum = 0 
    n=str(n)
    for ele in n:
        sum+=int(ele)
    return sum

ans = 328932998329823983298

n = int(input())

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    ans = 99999999
    for i in range(1, n):
        total = list(str(n-i)) + list(str(i))
        tmp = 0
        for t in total:
            tmp += int(t)
        ans = min(ans, tmp)
    print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans = 100000000
for i in range(1,n):
    ankari = 0
    for j in range (1,6):
        ankari += (i%pow(10,j))//pow(10,j-1)+((n-i)%pow(10,j))//pow(10,j-1)
    ans = min(ans,ankari)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
N = int(input())

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

ans = float('inf')
for i in range(1, N):
    a = digit_sum(i)
    if a > ans:
        continue
    ans = min(ans, a + digit_sum(N-i))
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
minT=pow(10,5)
for i in range(1,N):
  tmp = 0
  for x in range(len(str(i))):
    tmp += int(str(i)[x])
  for y in range(len(str(N-i))):
    tmp += int(str(N-i)[y])
  minT = min(minT,tmp)
print(minT)

Submission status: Accepted

Solution code:
n = int(input())

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

    sum_a = sum(list(map(int, str(a))))
    sum_b = sum(list(map(int, str(b))))
    
    ans = min(ans, sum_a+sum_b)

print(ans)

Submission status: Accepted

Solution code:
def findDigits(num):
	l = []
	while(num > 0):
		l.append(num % 10)
		num = num / 10
	return l	


n = input()
i = 1
sum1 = 1000000000
while(i <= n/2):
	l1 = findDigits(i)
	l2 = findDigits(n - i)
	s1 = sum(l1)
	s2 = sum(l2)
	if(s1 + s2 < sum1):
		sum1 = s1 + s2
	i = i + 1
print(sum1)

Submission status: Accepted

Solution code:
N = int(input())
res = float('INF')
for a in range(1, N//2+1):
    b = N - a
    res = min(res, sum([int(i) for i in list(str(a))]) + sum([int(i) for i in list(str(b))]))

print(res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    ans = sys.maxsize
    for a in range(1, N):
        b = N - a
        ta = 0
        while a:
            ta += a % 10
            a //= 10
        while b:
            ta += b % 10
            b //= 10

        ans = min(ta, ans)

    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = input()
n = int(a)
if n%10==0 or n%100==0 or n%1000==0 or n%10000==0 or n%100000==0:
    print(10)
else:
    b = 0
    for i in a:
        b += int(i)
    print(b)

Submission status: Accepted

Solution code:
n=raw_input()
tn0=[k for k in n if k!="0"]
if len(tn0)>1 or tn0[0]!="1":
    print sum([int(k) for k in tn0])
else:
    print 10

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
#n = int(input())
#x,y = map(int,input().split())	
#list=[int(input()) for i in range(n)]


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

n = int(input())

ans = 1<<20
for i in range(1,n):
    ans = min(ans,digitsum(i)+digitsum(n-i))

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 100000
for a in range(1, N):
    b = N - a
    s = sum(list(map(int, list(str(a))))) + sum(list(map(int, list(str(b)))))
    if s < ans:
        ans = s
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
ans=float("inf")
for i in range(1,n):
  a=0
  for j in range(len(str(i))):
    a+=int(str(i)[j])
  for j in range(len(str(n-i))):
    a+=int(str(n-i)[j])
  ans=min(ans,a)
print(ans)

Submission status: Accepted

Solution code:
N = input()
count = 0
for i in N:
    count += int(i)
if (count == 1):
    count = 10
print(count)

Submission status: Accepted

Solution code:
def sum_digits(n):

    n = str(n)
    summ = 0

    for d in n:
        summ += int(d)

    return summ

n = int(input())
min_summ = 1000000

for a in range(1, n):

    min_summ = min(min_summ, sum_digits(a) + sum_digits(n-a))

print(min_summ)

Submission status: Accepted

Solution code:
x = int(input())
if x==10 or x==100 or x==1000 or x==10000 or x==100000:
    print(10)
else:
    s = 0
    for i in str(x):
        s += int(i)
    print(s)

Submission status: Accepted

Solution code:
N = int(input())
res = int(1e18)

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

if N == 2:
    res = 2

print(res)

Submission status: Accepted

Solution code:
N = int(input())

def dig_sum(n):
    res = 0
    while(not n<10):
        res += n % 10
        n = n//10
    res += n
    return res

ans = 100000000000000
for A in range(2, 2+N//2):
    B = N - A
    tmp = dig_sum(A) + dig_sum(B)
    ans = min(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
def asu(a,b):
    a,b=str(a),str(b)
    a=sum(map(int,list(a)))
    b=sum(map(int,list(b)))
    return a+b

n=int(input())
mins=999999999
for i in range(1,n):
    asun=asu(i,n-i)
    if mins>asun:
        mins=asun
print(mins)

Submission status: Accepted

Solution code:

N = int(input())

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

else:
    t = list(str(N))
    print(sum(map(int, t)))

Submission status: Accepted

Solution code:
N = int(input())

ans = float('inf')
for i in range(1, N):
    a = str(i)
    b = str(N - i)
    if ans > sum(map(int, list(a))) + sum(map(int, list(b))):
        ans = min(ans, sum(map(int, list(a))) + sum(map(int, list(b))))

print(ans)

Submission status: Accepted

Solution code:

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

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

n=int(input())
ans=10**9
for i in range(1,n):
    s=get(i)+get(n-i)
    if ans>s: ans=s
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

digsum = lambda x: sum(map(int, str(x)))
ans = 100
for a in range(1, n):
    b = n - a
    ans = min(ans, digsum(a) + digsum(b))
print(ans)

Submission status: Accepted

Solution code:
n = int(raw_input())
a = 1
best = 999999999999999
def score(a, b):
    return sum([int(c) for c in str(a) + str(b)])
while a <= n/2:
    b = n - a
    best = min(best, score(a, b))
    a += 1
print best

Submission status: Accepted

Solution code:
N = input()
if N[0] == '1' and all(n == '0' for n in N[1:]):
  print(10)
else:
  print(sum(int(n) for n in N))

Submission status: Accepted

Solution code:
x=raw_input()
if x[0]=="1" and set(x[1:])=={"0"}: print 10
else: print sum(int(y) for y in x)

Submission status: Accepted

Solution code:
import math
from copy import deepcopy
import bisect
import itertools
from collections import deque
import numpy as np


def read():
    return int(input())


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


def readmap():
    return map(int, input().split())


N = read()


def is_10(n):
    while n > 1:
        if n % 10:
            return False
        else:
            n = n // 10

    return True


if is_10(N):
    print(10)
else:
    strN = str(N)
    ans = 0
    for num in strN:
        ans += int(num)
    print(ans)

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

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

setrecursionlimit(100000)

def digsum(x):
  result = 0
  while x != 0:
    result += x % 10
    x //= 10
  return result

ans = 10**6
N = read()
for A in range(1, N):
  B = N - A
  ans = min(ans, digsum(A) + digsum(B))

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 100000
for i in range(1,n):
    count = 0
    a = str(i)
    b = str(n-i)
    for j in a:
        count += int(j)
    for k in b:
        count += int(k)
    ans = min(ans,count)
print(ans)

Submission status: Accepted

Solution code:

n = int(input())

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

ans = 10 ** 9
for i in range(1, n):
    ans = min(ans, d(i) + d(n - i))

print(ans)

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 9999
for i in range(1,N):
    A = sum([int(s) for s in str(i)])
    B = sum([int(s) for s in str(N-i)])
    if A+B<ans:
        ans = A+B
        
print(ans)

Submission status: Accepted

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

N = int(input())
m = N
for A in range(1,N):
	B = N - A
	m = min(m, digitsum(A) + digitsum(B))

print(m)

Submission status: Accepted

Solution code:
def kuraiwa(M):
    S=str(M)
    ans=0
    for i in S:
        ans+=int(i)
    return ans
N=int(input())
res=N
for i in range(1,N):
    A=i
    B=N-i
    tmp=kuraiwa(A)+kuraiwa(B)
    if tmp<res:
        res=tmp
print(res)

Submission status: Accepted

Solution code:
n = int(input())

def dig_sum(n):
  return sum([int(i) for i in str(n)])

res = 10**9
for a in range(1, n):
  b = n - a
  res = min(res, dig_sum(a) + dig_sum(b))
  
print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()

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

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n = I()
    if n in [10,100,1000,10000,100000]:
        return 10

    s = [c for c in str(n)]
    return sum(map(int, s))


print(main())

Submission status: Accepted

Solution code:
ans = 10 ** 20
n = int(input())
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)

Submission status: Accepted

Solution code:
N = int(input())

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

r = 100000
for a in range(1, N):
    b = N - a
    r = min(cal(a) + cal(b), r)

print(r)

Submission status: Accepted

Solution code:
n = int(input())
ans = 1234567890
def c(x):
    ers = 0
    for i in str(x):
        ers += ord(i) - ord('0')
    return ers
for a in range(1, n):
    ans = min(ans, c(a) + c(n - a))
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = input()
    best = float('inf')
    for a in range(1, n//2 + 1):
        b = n - a
        s = sum(map(int, '%i%i' % (a, b)))
        best = min(best, s)
    print best

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
mi=10**5
for a in range(1,n//2+1):
    b=n-a
    sa=str(a)
    sb=str(b)
    aa=list(map(int,list(sa)))
    ab=list(map(int,list(sb)))
    mi=min(mi,sum(aa)+sum(ab))
print(mi)

Submission status: Accepted

Solution code:
import sys

N = int(input())

a = 10 ** 23

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

print(a)

Submission status: Accepted

Solution code:
n = int(input())
num = float("inf")
for i in range(1, n):
    rec = 0
    a, b = i, n - i
    while a > 0:
        rec += a % 10
        a //= 10
    while b > 0:
        rec += b % 10
        b //= 10
    num = min(rec, num)

print(num)

Submission status: Accepted

Solution code:
N = int(input())
ans = 9999999
for a in range(1,N):
    b = N-a
    tmp = 0
    for ac in str(a):
        tmp += int(ac)
    for bc in str(b):
        tmp += int(bc)
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
def digit_sum(s):
    return sum(int(x) for x in str(s))
ans = 10 ** 9
for i in range(1, N):
    ans = min(ans, digit_sum(i) + digit_sum(N - i))
print(ans)

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())

def get_sum(n):
    n_str = str(n)
    ret = 0
    for ch in n_str:
        ret += int(ch)
    return ret

A = 1
B = N - A
ans = 1e10
while B >= 1:
    ans = min(ans, get_sum(A) + get_sum(B))
    A += 1
    B -= 1
print(ans)

Submission status: Accepted

Solution code:
def read_ints():
    return [int(c) for c in input().split()]


def dsum(i):
    return sum(int(c) for c in str(i))


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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

ans = 2000000000
for a in range(1, n):
	b = n-a
	X = str(a)
	Y = str(b)
	s = sum([int(a) for a in X])
	s += sum([int(a) for a in Y])
	ans = min(ans, s)
print (ans)

Submission status: Runtime Error

Solution code:
N=int(input())

M=10**9
for i in range(1,N//2+10):
    a=list(str(i))
    b=list(str(N-i))
    #print(a,b)
    k=0
    for q in range(len(a)):
        k+=int(a[q])
    for p in range(len(b)):
        k+=int(b[p])
    M=min(M,k)
print(M)

Submission status: Runtime Error

Solution code:
N=int(input())
N_sum=[]
for A in range(1,int((N+1)/2)):
  B=N-A
  N_sum.append(sum(map(int,str(A)+str(B))))
print(min(N_sum))

Submission status: Runtime Error

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

def get_digits_sum(val_str):
    digits_sum = 0
    for i in range(len(val_str)):
        digits_sum += int(val_str[i])

    return digits_sum

N = int(input())


for i in range(2, N, 1):
    A = i
    B = N - i
    a_sum = get_digits_sum(str(A))
    b_sum = get_digits_sum(str(B))
    if i==2:
        sum_min = a_sum + b_sum
    elif sum_min > a_sum + b_sum:
        sum_min = a_sum + b_sum
        
print(sum_min)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

min_v = 100000

for i in range(2, n - 2):
    b = n - i
    s = sum(list(map(int, str(i)))) + sum(list(map(int, str(b))))
    min_v = min(ans,s)

print(min_v)

Submission status: Runtime Error

Solution code:
N = int(input())

def sum_of(num): 
    list_b = []
    k = 0
    while num > 0:
        list_b.append(num%10)
        num //= 10
    for i in range(len(list_b)):
        k += list_b[i]
    return k 

list_a =[]
for i in range(2,N-1):
    A = i
    B = N - i
    list_a.append(sum_of(A) + sum_of(B))
    
print(min(list_a))

Submission status: Runtime Error

Solution code:
N = int(input())

def sum_of(num): 
    list_b = []
    k = 0
    if num > 0:
        while num > 0:
            list_b.append(num % 10)
            num = num // 10
        for i in range(len(list_b)):
            k += list_b[i]
        return k 

list_a =[]
for i in range(N-2):
    A = i + 2
    B = N - i - 2   
    list_a.append(sum_of(A) + sum_of(B))
    
print(min(list_a))

Submission status: Runtime Error

Solution code:
# AGC 025 A - Digits Sum
N = int(input())

def sum_of(num): #各位の合計値を返す
    list_b = []
    k = 0
    if num > 0:
        while num > 0:
            list_b.append(num % 10)
            num = num // 10
        for i in range(len(list_b)):
            k += list_b[i]
        return k 
    if num == 0:
        return 0 

list_a =[]
for i in range(N-2):
    A = i + 2
    B = N - i - 2   
    list_a.append(sum_of(A) + sum_of(B))
    
print(min(list_a))

Submission status: Runtime Error

Solution code:
# AGC 025 A - Digits Sum
N = int(input())

def sum_of(num): #各位の合計値を返す
    list_b = []
    k = 0
    if num > 0:
        while num > 0:
            list_b.append(num % 10)
            num = num // 10
        for i in range(len(list_b)):
            k += list_b[i]
        return k 
    if num <= 0:
        next
        

list_a =[]
for i in range(N-2):
    A = i + 2
    B = N - i - 2   
    list_a.append(sum_of(A) + sum_of(B))
    
print(min(list_a))

Submission status: Runtime Error

Solution code:
# AGC 025 A - Digits Sum
N = int(input())

def sum_of(num): #各位の合計値を返す
    list_b = []
    k = 0
    while num > 0:
        list_b.append(num % 10)
        num = num // 10
    for i in range(len(list_b)):
        k += list_b[i]
    return k 

list_a =[]
for i in range(N-2):
    A = i + 2
    B = N - i - 2   
    list_a.append(sum_of(A) + sum_of(B))
    
print(min(list_a))

Submission status: Runtime Error

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

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

cmb = []
for i in range(1,k):
  cmb.append([i , N-i])

def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

ans = []
for i in range(k-2):
  X = digitSum(cmb[i][0])
  Y = digitSum(cmb[i][1])
  ans.append(X+Y)

print(min(ans))

Submission status: Runtime Error

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

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

cmb = []
for i in range(1,k):
  cmb.append([i , N-i])

def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

ans = []
for i in range(k-1):
  X = digitSum(cmb[i][0])
  Y = digitSum(cmb[i][1])
  ans.append(X+Y)

print(min(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
if n % 10 == 0:
  print(10)
else:
  a = str(n)
  b = sum(a)
  print(b)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def digitSum(number):
    sum = 0
    while number > 0:
        sum += number % 10
        number //= 10
    return sum

for i in range(2, n + 1):
    a = i
    b = n - a
    if b < a:
        break
    total.append(digitSum(a) + digitSum(b))
print(min(total))

Submission status: Runtime Error

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

def digitSum(number):
    sum = 0
    while number > 0:
        sum += number % 10
        number //= 10
    return sum

for i in range(3, n + 1):
    a = i
    b = n - a
    if b < a:
        break
    total.append(digitSum(a) + digitSum(b))
print(min(total))

Submission status: Runtime Error

Solution code:
n = int(input())
def f(x):
    x%10+f(x//10) if x else 0
print(min([f(i)+f(n-i) for i in range(0,n+1)]))

Submission status: Runtime Error

Solution code:
def f(x):
    sum = 0
    for i in str(x):
        sum += int(i)
    return sum
n = int(input())
data = []
for i in range(2,n):
    sum = f(i)+f(n-i)
    data.append(sum)
print(min(data))

Submission status: Runtime Error

Solution code:
num=int(input())
ans_list=[]
for i in range(2,num-1): 
	ls_list=list(map(int,str(num-i)))  
	ls_list.append(i) 
	ans_list.append(sum(ls_list))
print(min(ans_list))

Submission status: Runtime Error

Solution code:
num=int(input())
min=num
 for i in range(2,a-1): 
	ls_list=list(map(int,str(a-i)))  
	ls_list.append(i) 
	ans=max(min,sum(ls_list))

Submission status: Runtime Error

Solution code:
def soma(a):
    res=0
    for i in range(0, len(a)):
        res+=int(a[i])

    if(res>=10):
        return soma(str(res))

    return res

def main():
    n = int(input())
    menor = soma("1")+soma(str(n-1))
    
    for i in range(1,10):
        if(soma(str(i))+soma(str(n-i))<menor):
            menor = soma(str(i))+soma(str(n-i))

    print(menor,"\n")
    
main()

Submission status: Runtime Error

Solution code:
def soma(a):
    res=0
    for i in range(0, len(a)):
        res+=int(a[i])

    if(res>=10):
        return soma(str(res))

    return res

def main():
    n = int(input())
    menor = soma("1")+soma(str(n-1))
    
    for i in range(1,10):
        if(soma(str(i))+soma(str(n-i))<menor):
            menor = soma(str(i))+soma(str(n-i))

    print(menor)
    
main()

Submission status: Runtime Error

Solution code:
a = int(input())
lim = a // 2
soma_lista = []
for i in range(a - 1, lim, -1):
    b = str(a - abs(i)) + str(abs(i))
    soma = 0
    for digit in b:
        soma += int(digit)
    soma_lista.append(soma)
print(min(soma_lista))

Submission status: Runtime Error

Solution code:
n = int(input())


x = n - 2
y = n - x

if n < 10:
    print(n)
if n = 10:
    print(1)
else:
    resulty, resultx = 0, 0

    while(x > 0):
        resultx += x % 10
        x = x // 10

    while(y > 0):
        resulty += y % 10
        y = y // 10

    #print(resulty+resultx)
    z = n//2

    result = 0
    while(z > 0):
        result += z % 10
        z = z // 10

    if result*2 < resulty+resultx:
        print(result*2)
    else:
        print(resulty+resultx)

Submission status: Runtime Error

Solution code:
N = int(input())

def wa(x):
    s = 0
    while x > 0:
        s += x % 10
        x = int(x / 10)
    return s
L = []
for i in range(2,N):
    A = i
    B = N - i
    x = wa(A) + wa(B)
    L.append(x)
    
L = sorted(L)
    
print(L[0])

Submission status: Runtime Error

Solution code:
N = int(input())
ans = 10**5
for a in range(N//2):
  b = N - a
  while a > 0:
    suma += a % 10
    a //= 10
  while b > 0:
    sumb += b % 10
    b //= 10
  if (suma + sumb) < ans:
    ans = suma + sumb
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

s = []
for i in range(2, n + 1):
    j = n - i
    if j >= 2 and i + j == n:
        a = sum(map(int, str(i)))
        b = sum(map(int, str(j)))
        s.append(a + b)
print(min(s))

Submission status: Runtime Error

Solution code:
A = list(map(int,input().split()))
A.sort()
ret = 0
ret += A[2]-A[1]
A[1] += ret
A[0] += ret
ret += (A[1]-A[0])//2
if (A[1]-A[0])%2==1:
  ret += 2
print(ret)

Submission status: Runtime Error

Solution code:
N = list(int(input()))
if N.count(0) == len(N) - 1:
  print(10)
else:
  sum(N)

Submission status: Runtime Error

Solution code:
n = int(input())
c = n
for i in range(1, n//2+1):
  a = digitsum(i)
  b = digitsum(n-i)
  if c > a + b:
    c = a + b
print(c)

Submission status: Runtime Error

Solution code:
digit(num):
    sum = 0
    while(num > 0):
        sum += num % 10
        num = int(num / 10)
    return sum
 
 
for a in range(2,n):
    sum_A =sum_digit(a)
    sum_B =sum_digit(n-a)
    all=min(all,(sum_A + sum_B))

print(all)

Submission status: Runtime Error

Solution code:
n = input().split()
if n[0] == 1 and sum(n):
    print(10)
else:
    print(sum(n))