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: Wrong Answer

Solution code:
N = int(input())
ans = 100
i = 1
while i * 2 < N:
  ans = min(ans, sum(map(int, list(str(i)))) + sum(map(int, list(str(N-i)))))
  i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())

M=10**9
for i in range(1,N//2):
    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: Wrong Answer

Solution code:
n = input()
print(sum([int(n[i]) for i in range(len(n))]))

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 1001001001
for i in range(1,n-1):
    j = n-i
    i_sum, j_sum = 0, 0

    si, sj = list(str(i)), list(str(j))
    for s1 in si:
        i_sum += int(s1)
    for s2 in sj:
        j_sum += int(s2)

    ans = min(ans, i_sum+j_sum)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=10e6
for a in range(2,n+1):
    b=n-a
    ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=10e5
for a in range(2,n):
    b=n-a
    ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = 10000

for i in range(1,n//2):
  d_n = n-i
  count_a = 0
  count_b = 0
  
  while i > 0:
    count_a += i % 10
    i //= 10
  
  while d_n >0:
    count_b += d_n % 10
    d_n //= 10
  
  if ans >= count_a + count_b:
    ans = count_a + count_b
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 10**14
for i in range(1, N//2):
    a = sum(map(int, str(i)))
    b = sum(map(int, str(N-i)))
    ans = min(a+b, ans)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# vim: fileencoding=utf-8


def main():
    n = int(input())
    ans = float("inf")
    for i in range(2, n // 2 + 1):
        a = i
        b = n - a
        na = sum(map(int, list(str(a))))
        nb = sum(map(int, list(str(b))))
        if ans > na + nb:
            ans = na + nb
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def SumReturn(num):
    total=0
    while num!=0:
        total += num%10
        num //= 10
        
    return total

if __name__ == '__main__':
    
    n = int(input())
    min = 10000
    
    for i in range(n+1):
        if(min > SumReturn(i)+SumReturn(n-i)):
            min = SumReturn(i)+SumReturn(n-i)
        
        
    print(min)

Submission status: Wrong Answer

Solution code:
def SumReturn(num):
    total=0
    while num!=0:
        total += num%10
        num //= 10
        
    return total

if __name__ == '__main__':
    
    n = int(input())
    min = 1000
    
    for i in range(n):
        if(min > SumReturn(i)+SumReturn(n-i)):
            min = SumReturn(i)+SumReturn(n-i)
        
        
    print(min)

Submission status: Wrong Answer

Solution code:
N = int(input())
n = N - 1
A = list(str(n))
A = list(int(n) for n in A)
ans1 = sum(A) + 1

n = N // 2
A = list(str(n))
A = list(int(n) for n in A)
ans2 = 2 * sum(A)

ans = min(ans1, ans2)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
n = N // 2
A = list(str(n))
A = list(int(n) for n in A)
ans = 2 * sum(A)
if N % 2 == 1:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

def digit_sum(A):
    S = 0
    while A > 0:
        S += A % 10
        A //= 10
    return S

ans = 10e+6
for A in range(N):
    cand = digit_sum(A) + digit_sum(N - A)
    ans = min(ans, cand)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

def digit_sum(A):
    S = 0
    while A > 0:
        S += A % 10
        A //= 10
    return S

ans = N
for A in range(N):
    cand = digit_sum(A) + digit_sum(N - A)
    ans = min(ans, cand)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
gou=0
goub=0
ke = n
for i in range(n):
  b=n-i
  while i:
    gou += i%10
    i= i//10
  while b:
    goub += b%10
    b= b//10
  kei=gou+goub
  if ke > kei:
    ke=kei
print(ke)

Submission status: Wrong Answer

Solution code:
N=int(input())
t=10000000
for A in range(1,N):
    B=N-A
    ans=0
    for i in range(len(str(A))+1):
        ans+=A%10
        A=A//10
        ans+=B%10
        B=B//10
    if ans<t:
        t=ans
print(t)

Submission status: Wrong Answer

Solution code:
n = int(input())

min_v = 100000

for i in range(2, n - 1):
    b = n - i
    s = sum([int(i) for i in str(i)]) + sum([int(i) for i in str(b)])
    if s <= min_v:
        min_v = s

print(min_v)

Submission status: Wrong Answer

Solution code:
n = int(input())

min_v = 100000

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

print(min_v)

Submission status: Wrong Answer

Solution code:
n = int(input())

min_v = 100000

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

print(min_v)

Submission status: Wrong Answer

Solution code:
N = int(input())

n = 1
ans = 10**5

def calucurate(M):
    n = 0
    while M > 0:
        n += M%10
        M //= 10
    return n

while n < N:
    t = N - n
    m = calucurate(t) + calucurate(n)
    ans = min(ans,m)
    n += 1

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = float("inf")
for i in range(N):
    if sum(map(int, str(i))) + sum(map(int, str(N-i))) < ans:
        ans = sum(map(int, str(i))) + sum(map(int, str(N-i)))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = 0
b = 0
ans = 1000000000
for i in range(1, n-1):
    a = n - i
    b = n - a
    a = list(map(int,str(a)))
    b = list(map(int,str(b)))
    if sum(a) + sum(b) <= ans:
        ans = sum(a) + sum(b)
print(ans)

Submission status: Wrong Answer

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+1):
    A = i
    B = N - i 
    list_a.append(sum_of(A) + sum_of(B))
    
print(str(min(list_a)))

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=n
for i in range(1,n):
    a=str(i*10000)
    b=int(a[0])+int(a[1])+int(a[2])+int(a[3])
    c=str((n-i)*10000)
    d=int(c[0])+int(c[1])+int(c[2])+int(c[3])
    ans=min(ans,b+d)
print(ans)

Submission status: Wrong Answer

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

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

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

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


if ans == []:
  print("2")
else:
  print(min(ans))

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
ans = 10**18
for i in range(1,n-1):
    j = n-i
    s = str(i).rjust(6,"0")[::-1]
    t = str(j).rjust(6,"0")[::-1]
    res = 0
    for i,j in zip(s,t):
        res += int(i)+int(j)
    ans = min(res,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
cnt = 0
while n != 0:
    cnt += n%10
    n //= 10
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
min_k = 10000000000
for i in range(1,n//2):
    sum_k = 0
    a = str(i)
    b = str(n-i)
    for j in a:
        sum_k += int(j)
    for j in b:
        sum_k += int(j)
    min_k = min(min_k,sum_k)
print(min_k)

Submission status: Wrong Answer

Solution code:
n = int(input())

def Digits_sum(a):
    a_s = str(a)
    s = 0
    for i in a_s:
        s += int(i)
    return s

ans = 10000

for i in range(n+1):
    A = i
    B = n-A
    s = Digits_sum(A)+Digits_sum(B)
    ans = min(ans,s)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

mn = 10**10
for a in range(1, n // 2):
    mn = min(mn, sum(int(i) for i in str(a)) + sum(int(i) for i in str(n-a)))
print(mn)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n <=10:
    print(n)
elif n % 10 == 0:
    print(min(10,n//10+n%10))
else:
    print(n//10+n%10)

Submission status: Wrong Answer

Solution code:
n = input()

mask = 10 ** (len(n)-1)
n = int(n)

if n //mask == 1:
    print(10)
else:
    print(n//mask + n%10)

Submission status: Wrong Answer

Solution code:
n = int(input())
min_sum = 99999999999999
for i in range (1, n - 1):
  first = i
  second = n - i
  first_sum = 0
  second_sum = 0
  while first > 0 :
    last_digit_first = first % 10
    first = first // 10
    first_sum += last_digit_first
    
  while second > 0 :
    last_digit_second = second % 10
    second = second // 10
    second_sum += last_digit_second
  
  if first_sum + second_sum <= min_sum :
    min_sum = first_sum + second_sum
print(min_sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
min_sum = 99999999999999
for i in range (n):
  first = i
  second = n - i
  first_sum = 0
  second_sum = 0
  while first > 0 :
    last_digit_first = first % 10
    first = first // 10
    first_sum += last_digit_first
    
  while second > 0 :
    last_digit_second = second % 10
    second = second // 10
    second_sum += last_digit_second
  
  if first_sum + second_sum <= min_sum :
    min_sum = first_sum + second_sum
print(min_sum)

Submission status: Wrong Answer

Solution code:
N = int(input())

MIN = 100000000000000
for i in range(N+1):
  A = sum(map(int,list(str(i))))
  B = sum(map(int,list(str(N-i))))
  MIN = min(A+B,MIN)
  
print(MIN)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
l = len(str(n)) - 1
if n % 10**l == 0:
    if str(n)[0] == '1':
        print(10)
else:
    ans = 0
    for i in str(n):
        ans += int(i)
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
min = 10000000000000
for i in range(1, N//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: Wrong Answer

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: Wrong Answer

Solution code:
def getter(i):
  res=0
  while True:
    res+=i%10
    i//=10
    if i==0:
      break
  return res
n=int(input())
digit=n//10
a=10**digit
if n-a>0:
  res=1+getter(n-a)
  print(res)
  exit()
else:
  print("10")

Submission status: Wrong Answer

Solution code:
ans=999999999
n = int(input())
for i in range(1,n//2):
    x=str(i)
    y=str(n-i)
    ans=min(ans, sum(map(int, x))+sum(map(int, y)))
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
if(not N % 10): print(N)
ans = 0
while(N > 0):
    ans += N % 10
    N //= 10
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 0
while(N > 0):
    ans += N % 10
    N //= 10
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# A - Digits Sum

N = input()
N_int = int(N)
mylist = ['10','100','1000','10000','100000']
ans = 0

if N in mylist:
    ans = 0
else:
    for i in range(len(N)):
        ans += (N_int % 10)
        N_int = N_int // 10

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
M = float('inf')
for i in range(N):
    M = min(M,sum(list(map(int,str(i)))+list(map(int,str(N-i)))))
print(M)

Submission status: Wrong Answer

Solution code:
n = int(input())
candi = []
for i in range(2,int(n/2+1)):
  j = n - i
  candi.append([i,j])

#candi = [[2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8]]

ans = 0
for a,b in candi:
  count = 0
  a = str(a)
  b = str(b)
  for i in a:
    count += int(i)
  for i in b:
    count += int(i)
  if ans == 0 :
    ans = count
  ans = min(ans,count)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
N = int(input())
result = 10 ** 5
for i in range(1, floor(N / 2)):
  a = str(i)
  b = str(N - i)
  result = min(result, sum(map(int, a)) + sum(map(int, b)))
print(result)

Submission status: Wrong Answer

Solution code:
from math import floor
N = int(input())
result = 10 ** 5
for i in range(floor(N / 2)):
  a = str(i)
  b = str(N - i)
  result = min(result, sum(map(int, a)) + sum(map(int, b)))
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
results = []
for i in range(N+1):
    for j in range(N+1):
        if i+j == N:
            si = str(i)
            sj = str(j)
            count1 = 0
            for x in si:
                count1 += int(x)
            for y in sj:
                count1 += int(y)
            results.append(count1)
print(min(results))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    ans = float("inf")
    for A in range(1, N - 2):
        B = N - A
        total = sum(int(s) for s in str(A)) + sum(int(s) for s in str(B))
        if total < ans:
            ans = total

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

N = input()

print(sum(map(int, N)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    re = 1000
    for a in range(((10**5) //2)+1):
        b = n - a
        sumnum = 0
        while a >= 1:
            sumnum += a % 10
            a = a //10
        while b >= 1:
            sumnum += b % 10
            b = b //10
        if re > sumnum:
            re = sumnum

    print(re)


resolve()

Submission status: Wrong Answer

Solution code:
from sys import stdin


def find_sum_of_digits(n, base=10):
    _sum = 0
    while n>0:
        _sum += n%base
        n //= base
    return _sum


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = float('inf')
    for A in range(1,N-1):
        B = N-A
        sum_ = find_sum_of_digits(A)+find_sum_of_digits(B)
        cnt = min(cnt,sum_)
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Wrong Answer

Solution code:
ans=float("INF")
n=int(input())
l=[]
s=0
for i in range(n//2+1):
  ans=min(sum(list(map(int,list(str(i)))))+sum(list(map(int,list(str(n-i))))),ans)
print(ans)

Submission status: Wrong Answer

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

for i in range(1,N+1):
  j = N-i
  ist = str(i)
  jst = str(j)
  iarray = list(map(int ,ist))
  jarray = list(map(int ,jst))
  isum = sum(iarray)
  jsum = sum(jarray)
  if isum + jsum < ans:
    ans = isum + jsum
print(ans)

Submission status: Wrong Answer

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

for i in range(N+1):
  j = N-i
  ist = str(i)
  jst = str(j)
  iarray = list(map(int ,ist))
  jarray = list(map(int ,jst))
  isum = sum(iarray)
  jsum = sum(jarray)
  if isum + jsum < ans:
    ans = isum + jsum
print(ans)

Submission status: Wrong Answer

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

for i in range(N):
  j = N-i
  ist = str(i)
  jst = str(j)
  iarray = list(map(int ,ist))
  jarray = list(map(int ,jst))
  isum = sum(iarray)
  jsum = sum(jarray)
  if isum + jsum < ans:
    ans = isum + jsum
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def somaD(numero):
    soma=0
    for i in str(numero):
        soma+=int(i)
    return soma

numero= int(input())
minimo=numero

for i in range(1,numero+1):
    # i // numero-i
    soma = somaD(i)+somaD(numero-i)
    if soma < minimo:
        minimo=soma
print(minimo)

Submission status: Wrong Answer

Solution code:
def somaD(numero):
    soma=0
    for i in str(numero):
        soma+=int(i)
    return soma

numero= int(input())
minimo=numero

for i in range(numero):
    # i // numero-i
    soma = somaD(i)+somaD(numero-i)
    if soma < minimo:
        minimo=soma
print(minimo)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

# A - Digits Sum
def digits_sum(num):
	sum = 0
	
	for s in str(num):
		sum += int(s)
	
	return sum


N = int(input())
ans = sys.maxsize

for A in range(1, N//2):
	B = N - A
	sum = digits_sum(A) + digits_sum(B)
	ans = min(ans, sum)
	
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

def digit_sum(a, b):
    ab_sum = 0
    for i in range(1, len(str(a))+1):
        ab_sum += a % (10*i)
        a = a // (10*i)
    
    for i in range(1, len(str(b))+1):
        ab_sum += b % (10*i)
        b = b // (10*i)
    
    return ab_sum

max_sum = float("inf")
for i in range(1, N//2+1):
    a = i
    b = N - i
    if digit_sum(a, b) < max_sum:
        max_sum = digit_sum(a, b)

print(max_sum)

Submission status: Wrong Answer

Solution code:
def readInt():
    return list(map(int,input().split()))
n = int(input())
ans = 0
while n > 0:
    ans += int(n%10)
    n = int(n/10)
print(ans)

Submission status: Wrong Answer

Solution code:

import sys  
import numpy as np

input = sys.stdin.readline

N = input()
sum_ = 0

for i in list(N)[:-1]:
    
    sum_+=int(i)

print(sum_)

Submission status: Wrong Answer

Solution code:
def f(x):
    sum = 0
    for i in str(x):
        sum += int(i)
    return sum
n = int(input())
aim = 1000000000
for i in range(2,n-1):
    sum = f(i)+f(n-i)
    aim = min(aim,sum)
print(aim)

Submission status: Wrong Answer

Solution code:
def f(x):
    sum = 0
    for i in str(x):
        sum += int(i)
    return sum
n = int(input())
aim = 1000000000
for i in range(2,n):
    sum = f(i)+f(n-i)
    aim = min(aim,sum)
print(aim)

Submission status: Wrong Answer

Solution code:
N = int(input())

def  DigitsSum(n):
    s = 0
    while True:
        if n // 10 != 0:
            s += n % 10
            n = n // 10
        else:
            s += n
            break
    return s

S = 0

for i in range(1,int(N/2)):
    A = i
    B = N - i
    if S == 0 :
        S = DigitsSum(A)+DigitsSum(B)
    else:
        if S > DigitsSum(A)+DigitsSum(B):
            S = DigitsSum(A)+DigitsSum(B)
        else:
            continue

print(S)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=0
m=0
for i in range(n+1):
    for j in range(n+1):
        if i+j!=n:
            continue
        l=([x for x in str(i)])
        m=([y for y in str(j)])
print(min(l+m))

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 1000000
for i in range(1, N+1):
    A = i
    B = N - i
    Asum = sum(map(int, str(A)))
    Bsum = sum(map(int, str(B)))
    if ans > (Asum + Bsum):
        ans = Asum + Bsum
print(ans)

Submission status: Wrong Answer

Solution code:
n=input()
nn=int(n)
min_n=9999999999999
for i in range(len(n)-1):
    a=10**i
    b=nn-a
    s=1
    for j in range(5):
        s+=b%10
        b=b//10
    min_n=min(min_n,s)
for i in range(len(n)-1):
    b=10**i
    a=nn-b
    s=1
    for j in range(5):
        s+=a%10
        a=a//10
    min_n=min(min_n,s)
print(min_n)

Submission status: Wrong Answer

Solution code:
n=input()
nn=int(n)
min_n=9999999999999
for i in range(len(n)-1):
    a=10**i
    b=nn-a
    s=1
    for j in range(5):
        s+=b%10
        b=b//10
    min_n=min(min_n,s)
print(min_n)

Submission status: Wrong Answer

Solution code:
def soma(n):
    if(n<10):
        return n
    somaf=0
    for i in range(0,len(str(n))):
        somaf+=int(str(n)[i])
        
    return soma(somaf)

def main():
    n = int(input())
    if n<10:
        print(n)
        return
    menor=soma(n-1)+1
    if(n<200):
        for i in range(2, n-1):
            if(soma(i)+soma(n-i)<menor):
                menor=soma(i)+soma(n-i)
        print(menor)
    else:
        for i in range(2, 100):
            if(soma(i)+soma(n-i)<menor):
                menor=soma(i)+soma(n-i)
        print(menor)

main()

Submission status: Wrong Answer

Solution code:
N = int(input())

v = float("inf")
for a in range(1, N - 1):
    b = N - a
    c = sum(map(int, str(a))) + sum(map(int, str(b)))
    if c < v:
        v = c
print(v)

Submission status: Wrong Answer

Solution code:
def soma(n):
    somaf=0
    if(n<10):
        return n
    
    for i in range(0, len(str(n))):
        somaf+=int(str(n)[i])

    if(somaf<10):
        return somaf
    else:
        return soma(somaf)

def main():
    n = int(input())
    menor=soma(n-1)+1
    if(n<10):
        print(n)
        return
    
    lim=150
    if(n<lim):
        lim=n
    for i in range(1,lim):
        if(soma(i)+soma(n-i)<menor):
            print(i, (n-i),  soma(i),soma(n-i))
            menor = soma(i)+soma(n-i)
    print(menor)

main()

Submission status: Wrong Answer

Solution code:
def soma(n):
    somaf=0
    if(n<10):
        return n
    
    for i in range(0, len(str(n))):
        somaf+=int(str(n)[i])

    if(somaf<10):
        return somaf
    else:
        return soma(somaf)

def main():
    n = int(input())
    menor=soma(n-1)+1

    lim=150
    if(n<lim):
        lim=n
    for i in range(1,lim):
        if(soma(i)+soma(n-i)<menor):
            print(i, (n-i),  soma(i),soma(n-i))
            menor = soma(i)+soma(n-i)
    print(menor)

main()

Submission status: Wrong Answer

Solution code:
def soma(n):
    somaf=0
    if(n<10):
        return n
    
    for i in range(0, len(str(n))):
        somaf+=int(str(n)[i])

    if(somaf<10):
        return somaf
    else:
        return soma(somaf)

def main():
    n = int(input())
    menor=soma(n-1)+1

    lim=12
    if(n<lim):
        lim=n
    for i in range(1,lim):
        if(soma(i)+soma(n-i)<menor):
            print(i, (n-i),  soma(i),soma(n-i))
            menor = soma(i)+soma(n-i)
    print(menor)

main()

Submission status: Wrong Answer

Solution code:
num=int(input())
ans_list=[]
ans=400000
for i in range(2,num-1): 
	max_list=list(map(int,str(num-i)))  
	min_list=list(map(int,str(i)))
	tot=sum(max_list)+sum(min_list)
	ans=min(tot,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
num=int(input())
ans_list=[]
ans=40000
for i in range(2,num-1): 
	max_list=list(map(int,str(num-i)))  
	min_list=list(map(int,str(i)))
	tot=sum(max_list)+sum(min_list)
	ans=min(tot,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())
lim = a // 2
soma_lista = []
menor = 100000
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)
    if soma < menor:
        menor = soma
if a == 2:
    print(a)
print(menor)

Submission status: Wrong Answer

Solution code:
def soma(a):
    res=0
    if(int(a)<10):
        return int(a)
        
    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(str(n-1))+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: Wrong Answer

Solution code:
def soma(a):
    res=0
    if(int(a)<10):
        return int(a)
        
    for i in range(0, len(a)-1):
        res+=int(a[i])

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

    return res

def main():
    n = int(input())
    menor = soma(str(n-1))+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: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = n - 1
    b = 1
    menor = soma_digitos(a) + soma_digitos(b)
    temp = 0
    for i in range(n-2):
        a -= 1
        b += 1
        temp = soma_digitos(a) + soma_digitos(b)
        if menor > temp:
            menor = temp
            print('A=', a,'B=', b)
    print(menor)

def soma_digitos(n):
    soma = 0
    while n >= 1:
        soma += n%10
        n = n//10
    return soma
main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = n - 1
    b = 1
    menor = soma_digitos(a) + soma_digitos(b)
    temp = 0
    for i in range(n-1):
        a -= 1
        b += 1
        temp = soma_digitos(a) + soma_digitos(b)
        if menor > temp:
            menor = temp
    print(menor)

def soma_digitos(n):
    soma = 0
    while n >= 1:
        soma += n%10
        n = n//10
    return soma
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a,b, sA, sB, result= 1, 0,0,0,0
soma = []
while a<=n:
    b=n-a
    for i in str(a):
         sA+=int(i)
    for j in str(b):
        sB+=int(j)
    soma.append(sA+sB)
    a=a+1
for k in str(min(soma)):
    result += int(k)
print(result)

Submission status: Wrong Answer

Solution code:
numero = int(input())
soma = 0
minimo = 100000
for aux in range(numero - 1,2,-1):
    prim = str(aux)
    seg = str(numero - aux)
    for x in range(len(prim)):
        soma += int(prim[x])
    for x in range(len(seg)):
        soma += int(seg[x])
    if soma < minimo :
        minimo = soma
    soma = 0
print(minimo)

Submission status: Wrong Answer

Solution code:
n = int(input())


x = n - 2
y = n - x

if n <= 10:
    print(n)
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: Wrong Answer

Solution code:
n = int(input())


x = n - 2
y = n - x

if n < 10:
    print(n)
elif n == 10 or n == 1000 or n == 100000 or n == 10000 or n == 100:
    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: Wrong Answer

Solution code:
n = int(input())

a = 2
b = n - 2

def sum_dig(dig):
    dig = str(dig)
    soma = 0
    for d in dig:
        soma += int(d)

    return soma

st = 0
if(n != 2):
    menor_s = 10^5
else:
    menor_s = 2
while(a < b):
    st = sum_dig(a) + sum_dig(b)
    if(st < menor_s):
        menor_s = st

    a += 1
    b -= 1

print(menor_s)

Submission status: Wrong Answer

Solution code:
n = int(input())

a,b = 1,0
sA, sB= 0,0
soma = []

while a<=n:
    b=n-a

    for i in str(a):
        sA+=int(i)
    for j in str(b):
        sB+=int(j)
    soma.append(sA+sB)
    
    a=a+1
print(min(soma))

Submission status: Wrong Answer

Solution code:
n = int(input())

a = 1
b = n - 1

def sum_dig(dig):
    dig = str(dig)
    soma = 0
    for d in dig:
        soma += int(d)

    return soma

st = 0
menor_s = 10^5
while(a < b):
    st = sum_dig(a) + sum_dig(b)
    if(st < menor_s):
        menor_s = st

    a += 1
    b -= 1

print(menor_s)

Submission status: Wrong Answer

Solution code:
def soma(n):
    x = sum(int(digit) for digit in str(n))
    if x < 10:
        return x
    else:
        return soma(x)

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

    somad = soma(n) # soma(n)+soma(0)

    n-=n%10
    
    while(n>=1):
        somaf=soma(n-1)+1
        
        if(somaf>somad):
            somad=somaf
        
        n=n//10
    
    print(somad,"\n")
       
main()

Submission status: Wrong Answer

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)