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())
min = float("inf")
for i in range(2,n-1):
    j = n - i
    if min > sum(map(int,str(i))) + sum(map(int,str(j))):
        min = sum(map(int,str(i))) + sum(map(int,str(j)))
print(min)

Submission status: Wrong Answer

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

if iszero(N):
    ans = int(N[0])+9
else:
    ans = digit(N)
    
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

from math import *

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

from math import *

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
min = float("inf")
m = int(n/2)
for i in range(1,m):
    a = np.array([int(j) for j in list(str(i))])
    b = np.array([int(j) for j in list(str(n-i))])
    tmp = np.sum(a) + np.sum(b)
    if(tmp < min):
        min = tmp

print(min)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
min = float("inf")
m = int((n+1)/2)
for i in range(1,m):
    a = np.array([int(j) for j in list(str(i))])
    b = np.array([int(j) for j in list(str(n-i))])
    tmp = np.sum(a) + np.sum(b)
    if(tmp < min):
        min = tmp

print(min)

Submission status: Wrong Answer

Solution code:
import math


def count(n):
    return sum(map(lambda x: int(x), str(n)))


N = int(input())
ret = float('inf')
for i in range(1, int(math.ceil(N / 2))):
    A = i
    B = N - i

    ret = min(ret, count(A) + count(B))

print(ret)

Submission status: Wrong Answer

Solution code:
#encoding: utf-8

N = int(input())

def sum_digit(num):
    list_num = [int(x) for x in list(str(num))]
    sum = 0
    for i in range(len(list_num)):
        sum += list_num[i]

    return sum

def expect(N):
    digit = len(str(N))

    l_num = [int(x) for x in list(str(N))]
    sum_a = l_num[0]
    # print(l_num)
    # print(l_num[digit-1])
    b = (N-int(l_num[0])*10**(digit-1))
    if digit == 1:
        sum = N
    elif N == 100:
        sum =10
    elif N == (10 or 1000 or 10**5):
        sum = 10

    elif b==0:
        sum_a = int(N/2)
        sum = sum_digit(sum_a)
        sum = sum*2
        for i in range(digit):
            # print("goaho",i)
            # print("hi")
            if sum > (sum_digit(N-10**i)+1):
                # print("hi")
                sum = sum_digit(N-10**i)+1
    else:
        sum_b = sum_digit(b)
        sum = sum_a+sum_b

    return sum

print(expect(N))

Submission status: Wrong Answer

Solution code:
#encoding: utf-8

N = int(input())

def sum_digit(num):
    list_num = [int(x) for x in list(str(num))]
    sum = 0
    for i in range(len(list_num)):
        sum += list_num[i]

    return sum

digit = len(str(N))

l_num = [int(x) for x in list(str(N))]
sum_a = l_num[0]
# print(l_num)
# print(l_num[digit-1])
b = (N-int(l_num[0])*10**(digit-1))

if b==0:
    sum_a = int(N/2)
    sum = sum_digit(sum_a)
    sum1 = sum*2
    sum2 = sum_digit(10**(digit-1))+sum_digit(N-10**(digit-1))

    sum = min(sum1,sum2)
else:
    sum_b = sum_digit(b)
    sum = sum_a+sum_b


print(sum)

Submission status: Wrong Answer

Solution code:
#encoding: utf-8

N = int(input())

def sum_digit(num):
    list_num = [int(x) for x in list(str(num))]
    sum = 0
    for i in range(len(list_num)):
        sum += list_num[i]

    return sum

digit = len(str(N))

l_num = [int(x) for x in list(str(N))]
sum_a = l_num[0]
# print(l_num)
# print(l_num[digit-1])
b = (N-int(l_num[0])*10**(digit-1))

if b==0:
    sum_a = int(N/2)
    sum = sum_digit(sum_a)
    sum = sum*2
else:
    sum_b = sum_digit(b)
    sum = sum_a+sum_b

sum2=sum_digit(N)
print(min(sum2,sum))

Submission status: Wrong Answer

Solution code:
#encoding: utf-8

N = int(input())

def sum_digit(num):
    list_num = [int(x) for x in list(str(num))]
    sum = 0
    for i in range(len(list_num)):
        sum += list_num[i]

    return sum

digit = len(str(N))

l_num = [int(x) for x in list(str(N))]
sum_a = l_num[0]
# print(l_num)
# print(l_num[digit-1])
b = (N-int(l_num[0])*10**(digit-1))

if b==0:
    sum_a = int(N/2)
    sum = sum_digit(sum_a)
    sum = sum*2
else:
    sum_b = sum_digit(b)
    sum = sum_a+sum_b

print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
for i in range(N):
	a = list(str(i + 1))
	b = list(str(N - i - 1))
	asum = sum(list(map(int, a)))
	bsum = sum(list(map(int, b)))
	
	L.append(asum + bsum)
print(min(L))

Submission status: Wrong Answer

Solution code:
n=int(input())
def a(a):
    return a//100000 + (a//10000)%10+(a//1000)%10 + (a//100)%10 + (a//10)%10 + a%10
b=[]
if n == 100000:
    print(10)
else:    
    for i in range(0,n//2 +2):
        b.append(a(i)+a(n-i))
    print(min(b))

Submission status: Wrong Answer

Solution code:
n=int(input())
def a(a):
    return a//100000 + (a//10000)%10+(a//1000)%10 + (a//100)%10 + (a//10)%10 + a%10
b=[]
if n == 100000:
    print(10)
else:    
    for i in range(0,n//2 +1):
        b.append(a(i)+a(n-i))
    print(min(b))

Submission status: Wrong Answer

Solution code:
n = int(input())
res = 101010101
for a in range(n):
  b = n - a
  res = min(res, sum(map(int, str(a))) + sum(map(int, str(b))))
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
res = 0
for a in range(n):
  b = n - a
  res = max(res, sum(map(int, str(a))) + sum(map(int, str(b))))
print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
res=100000
for i in range(1,n-1):
    j=n-i
    s=0
    for c in str(i):
        s+=int(c)
    for c in str(j):
        s+=int(c)
    res=min(res,s)
print(res)

Submission status: Wrong Answer

Solution code:
n = input()
lines = len(n)
result = 0
for i in range(lines):
  result += int(n[i])
if result % 10 == 0:
  print("10")
else:
  print(result)

Submission status: Wrong Answer

Solution code:
n = input()
lines = len(n)
result = 0
for i in range(lines):
  result += int(n[i])
print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())

ansli=[]
for i in range(1, n):
    mn=n-i
    s1=str(i)
    s2=str(mn)
    dli=[]
    for j in s1:
        dli.append(int(j))
    for k in s2:
        dli.append(int(k))
    ans=0
    for l in dli:
        ans+=l
    #print(ans)
    ansli.append(ans)
print("min",min(ansli))

Submission status: Wrong Answer

Solution code:
'''
問題
高橋君は 2 つの正の整数 A と B を持っています。

それらの和が N であると分かっているとき、 A の各位の和と B の各位の和の合計として考えられる最小の値を求めてください。

'''

# 入力して
n=int(input())
# 後半を端折るために2で割る
n2=int(n/2)

# n2回繰り返す 奇数の場合+1しておかないと計算されない
for a in range(n2+1):
    b=int(n)-a-1
    sa = list(str(a))
    sb = list(str(b))
    suma=0
    for isa in sa:
        suma += int(isa)
    sumb=0
    for isb in sb:
        sumb += int(isb)
    #print("turn a, b: ", a, b, suma+sumb)
    if a>0:
        if minsum > suma + sumb:
            minsum = suma +sumb
    else:
        minsum=suma+sumb
print(minsum)

Submission status: Wrong Answer

Solution code:
n = input()
a = ["100","1000","10000","100000"]
if n in a:
    print(10)
else:
    ans = 0
    for i in n:
        ans += int(i)
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [100,1000,10000,100000]
if n in a:
    print(10)
else:
    ans = 0
    r = 1
    while r:
        r = n % 10
        ans += r
        n = n // 10
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sum(list(map(int, list(str(N)))))
if A == 1:
    print(5)
else:
    print(A)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
i=2
digitSum=pow(10,5)
A=int(2)
while i<=int(N/2):
    A=i
    B=N-A
    if A<B:
        break
    A_digitsum=0
    while A>=10:
        A_digitsum += A%10
        A = A//10
    if A<10:
        A_digitsum+=A
    B_digitsum=0
    while B>=10:
        B_digitsum += B%10
        B = B//10
    if B<10:
        B_digitsum+= B
    if digitSum > A_digitsum+B_digitsum:
        digitSum = A_digitsum+B_digitsum
    i+=1
print(digitSum)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
i=2
digitSum=pow(10,5)
A=int(2)
while i<=int(N/2):
    A=i
    B=N-A
    if B>A:
        break
    A_digitsum=0
    while A>=10:
        A_digitsum += A%10
        A = A//10
    if A<10:
        A_digitsum+=A
    B_digitsum=0
    while B>=10:
        B_digitsum += B%10
        B = B//10
    if B<10:
        B_digitsum+= B
    if digitSum > A_digitsum+B_digitsum:
        digitSum = A_digitsum+B_digitsum
    i+=1
print(digitSum)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
i=2
digitSum=pow(10,5)
A=int(2)
while i<=N/2:
    A=i
    B=N-A
    A_digitsum=0
    while A>=10:
        A_digitsum += A%10
        A = A//10
    if A<10:
        A_digitsum+=A
    B_digitsum=0
    while B>=10:
        B_digitsum += B%10
        B = B//10
    if B<10:
        B_digitsum+= B
    if digitSum > A_digitsum+B_digitsum:
        digitSum = A_digitsum+B_digitsum
    i+=1
print(digitSum)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
i=2
digitSum=pow(10,5)
A=int(2)
while i<=N/2:
    A=i
    B=N-A
    print(A,B)
    A_digitsum=0
    while A>=10:
        A_digitsum += A%10
        A = A//10
    if A<10:
        A_digitsum+=A
    B_digitsum=0
    while B>=10:
        B_digitsum += B%10
        B = B//10
    if B<10:
        B_digitsum+= B
    if digitSum > A_digitsum+B_digitsum:
        digitSum = A_digitsum+B_digitsum
    i+=1
print(digitSum)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    inputNum = int(input())
    result = 10000000000

    for num in range(2, inputNum):
        numA = num
        numB = inputNum - num
        _result = 0

        if numA > numB:
            break

        for num1 in str(numA):
            _result += int(num1)
        for num1 in str(numB):
            _result += int(num1)

        if result > _result:
            result = _result

    print(result)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    inputNum = int(input())
    result = 100000

    for num in range(2, inputNum):
        numA = num
        numB = inputNum - num
        _result = 0

        if numA > numB:
            break

        for num1 in str(numA):
            _result += int(num1)
        for num1 in str(numB):
            _result += int(num1)

        if result > _result:
            result = _result

    print(result)

Submission status: Wrong Answer

Solution code:
def num(x):
	sum = 0
	while (x > 0):
		sum += x % 10
		x //= 10
	return sum

n = int(input())
ans = 1 << 30

for i in range(1, n + 1):
	j = n - i
	ans = min(ans, num(i) + num(j))

print(ans)

Submission status: Wrong Answer

Solution code:
n = str(input())
res = 0
for i in range(len(n)):
  res = res + int(n[i])
  
print(res)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
inf = pow(10, 5)

def sum_digits(n):
    answer = 0
    for d in reversed(range(7)):
        shou, amari = divmod(n, pow(10, d))
        if shou == 0:
            continue
        answer += shou
        n = amari
    return answer

answer = inf
for a in range(1, math.floor(N/2)):
    b = N-a
    answer = min([sum_digits(a) + sum_digits(b), answer])

print(str(answer))

Submission status: Wrong Answer

Solution code:
N = int(input())
M = N
for i in range(len(str(M)) - 1):
    if M % 10 == 0:
        M = int(M / 10)
if len(str(M)) == 1:
    print(10)
else:
    print(sum(map(int, list(str(N)))))

Submission status: Wrong Answer

Solution code:
s=input()
res=0
flag=s[0]=="1"
for c in s[1:]:
 res+=int(c)
 if c!="0":
  flag=False
if flag:
 print(10)
else:
 print(res)

Submission status: Wrong Answer

Solution code:
#coding : utf8

def digitSum(number):
    s = str(number)
    li = list(map(int,list(s)))
    return sum(li)

if __name__ == '__main__':
    inputNum = int(input())
    minimum = inputNum

    for i in range(int(inputNum/2)):
        temp = digitSum(i) + digitSum(inputNum-i)
        if(minimum > temp):
            minimum = temp

    print(minimum)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
max = 0
for i in range(1,int(N/2)+1):
   part = sum([int(j) for j in list(str(i))]) + sum([int(j) for j in list(str(N-i))])
   if max < part:
      max = part
print(max)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
max = 0
for i in range(1,int(N/2)+1):
   part = sum([int(i) for j in list(str(i))]) + sum([int(i) for j in list(str(N-i))])
   if max < part:
      max = part
print(max)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
max = 0
for i in range(int(N/2)):
   part = sum([int(i) for j in str(i)]) + sum([int(i) for j in str(N-i)])
   if max < part:
      max = part
print(max)

Submission status: Wrong Answer

Solution code:
def sumOfEach(x):
    array = list(str(x))
    ret = 0
    for z in array:
        ret += int(z)
    return ret

n = int(input())
a = 1
b = sumOfEach(n - a)
print(a + b)

#minOfsum = 10 ** 5
#for a in range(1, int(n / 2) + 1):
#    b = n - a
#    #print(a, b)
#    sumOfEachA = sumOfEach(a)
#    sumOfEachB = sumOfEach(b)
#    sumOfTwo = sumOfEachA + sumOfEachB
#    #sumOfTwo = sumOfEach(a) + sumOfEach(b)
#    if sumOfTwo < minOfsum:
#        minOfsum = sumOfTwo
#print(minOfsum)
#

Submission status: Wrong Answer

Solution code:
a=[]
aint=[]
a=list(str(input()))
aint=map(int,a)
if sum(aint)==1:
    print(10)
else:
    print(sum(aint))

Submission status: Wrong Answer

Solution code:
N = int(input("input integer:"))
hoge = [(A,B) for A in range(N) for B in range(N) if A+B==N]
hogehoge = []
for C in range(len(hoge)):
    ini0 = 0
    ini1 = 0
    for i0 in (list(str(hoge[C][0]))):
        ini0 += int(i0)
    for i1 in (list(str(hoge[C][1]))):
        ini1 += int(i1)
    hoho  = ini0+ini1
    hogehoge.append(hoho)
print(min(hogehoge))

Submission status: Wrong Answer

Solution code:
N = int(input())
r = 0
if N == 10 or N == 100 or N == 1000 or N == 10000:
	r = 10
else:
	for i in range(5):
		r = r + int(N/(10**i))%10
print(r)

Submission status: Wrong Answer

Solution code:
n = int(input())
sumn = 0
data = 10
check = False
for i in range(5):
	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: Wrong Answer

Solution code:
n = int(input())
sumn = 0
data = 10
check = False
for i in range(5):
	if(10**i==n):
		check = True

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

Submission status: Wrong Answer

Solution code:
n = int(input())
sumn = 0
data = 10
for i in range(1,6):
	data = data**i
	if(data == n):
		print(10)
		break
	else:
		while n>10:
			sumn += n%10
			n /= 10
		sumn += n
		print(int(sumn))
		break

Submission status: Wrong Answer

Solution code:
import math


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


n =  int(input())

# 0が多くなるようにする
rank = int(math.log10(n)) 
div =  n % 10**rank
if div == 0:
    print(10)
else :
    print(digitSum(n))

Submission status: Wrong Answer

Solution code:
import math


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


n =  int(input())

# 0が多くなるようにする
rank = int(math.log10(n)) 
div =  n % 10**rank
if div == 0:
    print(10)
else :
    print(digitSum(int(n)))

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
m = 99999
for A in range(1, N-1):
  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: Wrong Answer

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))))
print(a,b)

Submission status: Wrong Answer

Solution code:
n = input()

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

Submission status: Wrong Answer

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//2):
        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: Wrong Answer

Solution code:
import sys
from functools import reduce
 
n = int(input())

def count(i):
	n = 0
	j = i
	while 0 < j:
		n = n + j % 10
		j = j // 10

	return n

s = 91

for i in range(2,n):
	s2 = count(i) + count(n - i)

	if s2 < s:
		s = s2
print(s)

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())

def count(i):
	n = 0
	j = i
	while 0 < j:
		n = n + j % 10
		j = j // 10

	return n

s = 46

for i in range(2,n):
	s2 = count(i) + count(n - i)

	if s2 < s:
		s = s2
print(s)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce
 
n = int(input())

def count(i):
	n = 0
	j = i
	while 0 < j:
		n = n + j % 10
		j = j // 10

	return n

s = 46

for i in range(n):
	s2 = count(i) + count(n - i)

	if s2 < s:
		s = s2
print(s)

Submission status: Wrong Answer

Solution code:
a=[]
aint=[]
a=list(str(input()))
aint=map(int,a)
if sum(aint)==1:
    print(10)
else:
    print(sum(aint))

Submission status: Wrong Answer

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):
        B = N - A
        tmp = sum_digits(A) + sum_digits(B)
        ans = min(ans, tmp)

    return ans


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
aa=[]
aint=[]
a=list(input())
aint=map(int,a)
if sum(aint)==1:
    print(10)
else:
    print(sum(aint))

Submission status: Wrong Answer

Solution code:
a=[]
aint=[]
a=list(input())
aint=map(int,a)
print(sum(aint))

Submission status: Wrong Answer

Solution code:
n = int(input())

def count(x):
    ans = 0
    while x > 0:
        ans += x%10
        x //= 10
    return ans

ans = 10**9+7
for i in range(1, n//2):
    ans = min(ans, count(i)+count(n-i))

print(ans)

Submission status: Wrong Answer

Solution code:
ans = 0
NMAX = 500000
MOD = 998244353
fac = [0] * (NMAX+1)
ifac = [0]* (NMAX+1)
fac[0] = 1
for i in range(1,NMAX+1):
    fac[i] = fac[i-1] * i % MOD

tmp = 1
e = MOD-2
for i in range(62,-1,-1):
    tmp = tmp*tmp %MOD
    if (1<<i)&e > 0:
        tmp = tmp * fac[NMAX] % MOD
    

#print(fac[NMAX], tmp ,  fac[NMAX]*tmp%MOD)
ifac[NMAX] = tmp
for i in range(NMAX,0,-1):
    ifac[i-1] = ifac[i] * i % MOD

#n,a,b,k = map(int,input().split())
#for i in range(0,n+1):
#    if k-a*i>=0 and (k-a*i) %b == 0:
#        x = i
#        y = (k-a*i)//b
#        if y>n:
#            continue
#        ans = (ans + fac[n]*ifac[x] % MOD *ifac[n-x] %MOD *fac[n] %MOD * ifac[y] %MOD* ifac[n-y] %MOD ) % MOD;

print(ans)

Submission status: Wrong Answer

Solution code:
ans = 0
NMAX = 500000
MOD = 998244353
fac = [0] * (NMAX+1)
ifac = [0]* (NMAX+1)
fac[0] = 1
for i in range(1,NMAX+1):
    fac[i] = fac[i-1] * i % MOD

tmp = 1
e = MOD-2
for i in range(62,-1,-1):
    tmp = tmp*tmp %MOD
    if (1<<i)&e > 0:
        tmp = tmp * fac[NMAX] % MOD
    

#print(fac[NMAX], tmp ,  fac[NMAX]*tmp%MOD)
#ifac[NMAX] = tmp
#for i in range(NMAX,0,-1):
#    ifac[i-1] = ifac[i] * i % MOD
#
#n,a,b,k = map(int,input().split())
#for i in range(0,n+1):
#    if k-a*i>=0 and (k-a*i) %b == 0:
#        x = i
#        y = (k-a*i)//b
#        if y>n:
#            continue
#        ans = (ans + fac[n]*ifac[x] % MOD *ifac[n-x] %MOD *fac[n] %MOD * ifac[y] %MOD* ifac[n-y] %MOD ) % MOD;

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
score = 9999999

n = int(raw_input())

for a in xrange(1, n + 1):
    b = n - a

    sum_a = 0
    while True:
        quo  = a %10
        sum_a += quo
        a = int(a/10)
        if a  == 0:
            break
    sum_b = 0
    while True:
        quo2  = b %10
        sum_b += quo2
        b = int(b/10)
        if b  == 0:
            break
    
    summand = sum_a + sum_b
    
    if summand < score:
        score = summand
        
print score

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

N_str = str(N)
n_digit = len(N_str)

div = int(math.pow(10, n_digit-1))

i1 = N // div
i2 = N % div

sum2 = sum([int(s) for s in str(i2)])

print(i1 + sum2)

Submission status: Wrong Answer

Solution code:
import sys

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

def solve(n):
    ans = sys.maxsize
    for a in range(2, n//2):
        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: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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!=0:
    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: Wrong Answer

Solution code:
# Q_A

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(1, int(N/2)):
    c = arr[i] + arr[N - i]
#    print(i, "-", N-i, "  ", arr[i], "-", arr[N-i])
    if re > c or re == 0:
        re = c
        
print(re)

Submission status: Wrong Answer

Solution code:
import math


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


n =  int(input())

# 0が多くなるようにする

rank = int(math.log10(n)) 


div =  n % 10**rank
if rank < 1:
    a = 2
    b = n %2

elif div == 0:
    a = n / 2
    b = n / 2
else :
    a = 10**rank
    b = div

#print("{} : {}".format(a, b))


count = 0
count += digitSum(int(a))
count += digitSum(int(b))

print(count)

Submission status: Wrong Answer

Solution code:
sum = int(input())
len = len(str(sum))
res = sum%(10**(len-1))
if(res==0):
    print('10')
else:
    sum_list = [int(x) for x in list(str(sum))]
    min_sum = 0
    for y in sum_list:
         min_sum = min_sum + y
    print(min_sum)

Submission status: Wrong Answer

Solution code:
import math


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


n =  int(input())

# 0が多くなるようにする

rank = int(math.log10(n)) 
print(rank)


div =  n % 10**rank
if rank < 1:
    a = 2
    b = n %2

elif div == 0:
    a = n / 2
    b = n / 2
else :
    a = 10**rank
    b = div

#print("{} : {}".format(a, b))


count = 0
count += digitSum(int(a))
count += digitSum(int(b))

print(count)

Submission status: Wrong Answer

Solution code:
import sys


def sum_digits(n):
    return sum(int(a) for a in str(n))


def solve(n):
    min_sum = sys.maxsize

    for a in range((n + 1) // 2):
        b = n - a
        sum_ = sum_digits(a) + sum_digits(b)

        if sum_ < min_sum:
            min_sum = sum_

    return min_sum


print(solve(int(input())))

Submission status: Wrong Answer

Solution code:
N = int(input())

SUM = 1000000

for i in range(int(N/2)):
    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: Wrong Answer

Solution code:
n = int(input())
n4 = 0
n3 = 0
n2 = 0
n1 = 0
if n >= 10**4:
    n4 = n // 10 ** 4
    n = n - n4*10**4
if n >= 10**3:
    n3 = n // 10 ** 3
    n = n - n3*10**3
if n >= 10**2:
    n2 = n // 10 ** 2
    n = n - n2*10**2
if n >= 10:
    n1 = n // 10
    n = n - n1*10
n0 = n
print(n0 + n1 + n2 + n3 + n4)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

@author: ashida
"""

N = input()

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

Submission status: Wrong Answer

Solution code:
import math


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


n =  int(input())

# 0が多くなるようにする

rank = int(math.log10(n)) 

div =  n % 10**rank
if div == 0:
    a = n / 2
    b = n / 2
else :
    a = 10**rank
    b = div

#print("{} : {}".format(a, b))


count = 0
count += digitSum(int(a))
count += digitSum(int(b))

print(count)

Submission status: Wrong Answer

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

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!=0:
    if str(N)[0]=='1':
        print(10)
        sys.exit()
    else:
        print(str(N)[0])
        sys.exit()
count=0
for j in range(len(str(N))):
    count+=int((str(N))[j])
    
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())

sums = int(1e5)
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 sums>a_sum+b_sum: sums = a_sum+b_sum

print(sums)

Submission status: Wrong Answer

Solution code:
N = input()
ls=[]
for i in range(int(N)):
    a = i
    b = int(N)-i
    numa = map(int,str(a))
    numb = map(int,str(b))
    ls.append(sum(list(numa))+sum(list(numb)))

print (min(ls))

Submission status: Wrong Answer

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(int(N/2)+1) : 
	A = i
	B = N - i

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

print(summin)

Submission status: Wrong Answer

Solution code:
k = int(input())
 
while k // 10 < 10:
  if k != 10:
    k /= 10
  else:
    break
 
p = list(str(k).split("."))
 
al = 0
if k != 10: 
  for i in range(len(p)):
    al += int(p[i])
else:
  al = 10
print(al)

Submission status: Wrong Answer

Solution code:
N = int(input())

min_val = 1000000000000000000
for i in range(1, int(N / 2)):
    A = i
    B = N - i
    val = sum(map(int, str(A))) + sum(map(int, str(B)))
    if val < min_val:
        min_val = val
print(min_val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

min_val = 100000000000
for i in range(1, int(N / 2)):
    A = i
    B = N - i
    val = sum(map(int, str(A))) + sum(map(int, str(B)))
    if val < min_val:
        min_val = val
print(min_val)

Submission status: Wrong Answer

Solution code:
k = int(input())

while k // 10 != 0:
  if k != 10:
    k /= 10
  else:
    break

p = list(str(k).split("."))

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

Submission status: Wrong Answer

Solution code:
n = int(input())
dp = [0 for i in range(n)]
min = float("inf")
for i in range(1, n//2):
    a_sum = sum(map(int, list(str(i))))
    b_sum = sum(map(int, list(str(n - i))))
    c = a_sum + b_sum
    if(min > c):
        min = c
print(min)

Submission status: Wrong Answer

Solution code:
n=int(input())
nl=[]
for i in range(5):
    nl.append(int((n/10**(4-i))%10))

if sum(nl)>2:
    print(sum(nl))
elif sum(nl)==2 and n/10>1:
    print(sum(nl))
else:
    print(sum(nl)+9)

Submission status: Wrong Answer

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]:
    s = 9
s += sum(l)
print(s)

Submission status: Wrong Answer

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