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


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

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


if n % 2:
    x = n - 2
    y = n - x

    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)
else:
    x = n//2
    
    result = 0
    while(x > 0):
        result += x % 10
        x = x // 10
    print(result*2)

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)
    
    for i in range(1, n):
        soman = soma(i)+soma(n-i);
        if(soman==somad):
            break
    
    print(soman,"\n")
       
main()

Submission status: Wrong Answer

Solution code:
A = int(input())
s=0
while (A > 0):

    r  = A % 10
    A= (A - r) / 10
    s = s+r
print(s)

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
ans = 100
def colsum(s):
    ret = 0
    for i in s:
        ret += int(i)
    return ret

for i in range(n):
    cand = colsum(str(i))+colsum(str(n-i))
    ans = min(cand,ans)
print(ans)

Submission status: Wrong Answer

Solution code:

n=int(input())

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

min=9999999
#b= n-a
for a in range(0,n):
    b=n-a
    sum_a=digitSum(a)
    sum_b=digitSum(b)
    sum_ab=int(sum_a)+int(sum_b)
   
    if sum_ab < min:
        min=sum_ab

print(min)

Submission status: Wrong Answer

Solution code:
n = int(input())
res = 0
for c in str(n):
  res += int(c)
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
res = float('inf')
for a in range(int(n/2)+1):
    b = n-a
    tmp = 0
    for c in str(a):
        tmp += int(c)
    for c in str(b):
        tmp += int(c)
    res = min(res, tmp)
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []

for i in range(1,n + 1):
    j = n - i
    x = sum(map(int,list(str(i)))) + sum((map(int,list(str(j)))))
    l.append(x)

print(min(l))

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = float('inf')
for i in range(2,N):
    A = i
    B = N - i
    tmp = 0
    for k in str(A):
        tmp += int(k)
    for k in str(B):
        tmp += int(k)
    ans = min(ans,tmp)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 10**5
for a in range(1, N//2):
    suma = 0
    sumb = 0
    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: Wrong Answer

Solution code:
N = int(input())
ans = 10**5
for a in range(N//2):
    suma = 0
    sumb = 0
    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: Wrong Answer

Solution code:
def sumDigits(i):
    s = 0
    while i > 0:
        s += (i % 10)
        i = int(i / 10)
    return s

N = int(input())

m = 9*6
for i in range(1, N + 1):
    k = N - i
    m = min(m, sumDigits(i) + sumDigits(k))

print(m)

Submission status: Wrong Answer

Solution code:
def sumDigits(i):
    s = 0
    while i > 0:
        s += (i % 10)
        i = int(i / 10)
    return s

N = int(input())

m = 9*6
for i in range(1, N+1):
    k = N - i
    m = min(m, sumDigits(i) + sumDigits(k))

print(m)

Submission status: Wrong Answer

Solution code:
def sumDigits(i):
    s = 0
    while i > 0:
        s += (i % 10)
        i = int(i / 10)
    return s

N = int(input())

m = 9 * 6
for i in range(1, N):
    k = N - i
    if k > 1:
        m = min(m, sumDigits(i) + sumDigits(k))

print(m)

Submission status: Wrong Answer

Solution code:
def sumDigits(i):
    s = 0
    while i > 0:
        s += (i % 10)
        i = int(i / 10)
    return s

N = int(input())

m = 9 * 6
for i in range(2, N + 1):
    k = N - i
    if k > 1:
        m = min(m, sumDigits(i) + sumDigits(k))

print(m)

Submission status: Wrong Answer

Solution code:
n = int(input());A = [] ; s = 0 ; t = 0

for i in range(1,n+1):
    for j in range(len(str(i))):
        s += int(str(i)[j])
    for k in range(len(str(n-i))):
        t += int(str(n-i)[k])
    a = s + t
    A.append(a)
    s = 0 ; t = 0
    
print(min(A))

Submission status: Wrong Answer

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


def main():
    ab_sum = int(input())
    answer = float("inf")
    for i in range(1, ab_sum // 2):
        answer = min(answer, get_digit_sum(i) + get_digit_sum(ab_sum - i))
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
min = 100
a_sum = 0
b_sum = 0

for a in range(1, n):
  b = n-a
  while a >= 1:
    a_sum += a%10
    a = a//10
  
  while b >= 1:
    b_sum += b%10
    b = b//10
  
  if a_sum + b_sum < min:
    min = a_sum + b_sum

print(min)

Submission status: Wrong Answer

Solution code:
N=list(input())
ans=0
for x in N:
  x=int(x)
  if x%2==1:
    ans+=1
  ans+=(x//2)*2
print(ans)

Submission status: Wrong Answer

Solution code:
N = list(input())
list1 = [int(x) for x in N]
if N.count("0") == len(N) - 1:
  print(10)
else:
  print(sum(list1))

Submission status: Wrong Answer

Solution code:
N = int(input())
mini = float("inf")
for A in range(1,N-2+1):
  mini = min(mini,sum([int(digit) for digit in str(A)])+sum([int(digit) for digit in str(N-A)]))
print(mini)

Submission status: Wrong Answer

Solution code:
N = int(input())
mini = float("inf")
for A in range(2,N-2+1):
  mini = min(mini,sum([int(digit) for digit in str(A)])+sum([int(digit) for digit in str(N-A)]))
print(mini)

Submission status: Wrong Answer

Solution code:
N = int(input())
mini = float("inf")
for A in range(2,N-2):
  mini = min(mini,sum([int(digit) for digit in str(A)])+sum([int(digit) for digit in str(N-A)]))
print(mini)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
all = 10000
 
def sum_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: Wrong Answer

Solution code:
n = int(input())
all = 0
 
def sum_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: Wrong Answer

Solution code:
n = int(input())

def sum_digit(num):
    sum = 0
    while(num > 0):
        sum += num % 10
        num /= 10
    return sum

all = []

for a in range(n):
    sum_A =sum_digit(a+2)
    sum_B =sum_digit(n-a+2)
    all.append(sum_A + sum_B)

print(min(all))

Submission status: Wrong Answer

Solution code:
N = int(input())

num = 0

for i in range(N+1):
  g = N -i
  a=sum(map(int,list(str(g))))
  b=sum(map(int,list(str(i))))
  ans =  a + b
  if num == 0:
    num += ans
  elif num >= ans:
    num += ans
  else:
    continue

    
print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())

num = 0

for i in range(N+1):
  g = N -i
  a=sum(map(int,list(str(g))))
  b=sum(map(int,list(str(i))))
  ans =  a + b
  if ans == 0:
    num += ans
  elif num >= ans:
    num += ans
  else:
    continue

    
print(num)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())

def Num_Each_Digit(N,limit):
    ans = np.array([])
    
    if N < 10**(limit):
        for i in range(1,limit+1):
            if (10**(i-1) > N):
                break
            if i == 1:
                ans = np.append( ans, (N%(10**i)))
            elif i > 1:
                ans = np.append( ans, (N%(10**i)-N%(10**(i-1)))/(10**(i-1)))

        return ans
                
    else:
        print("too large")
        return N
    
digit = Num_Each_Digit(N,10)
    
if N == 10**(len(digit)+1):
    print(10)
    
else:
    print(int(np.sum(digit)))

Submission status: Wrong Answer

Solution code:
N = int(input())

def SumDigits(num):
    sum = 0
    while True:
        sum += num % 10
        num //= 10
        if num == 0:
            break
    return sum

infinity = float('inf')
min = infinity

for x in range(1, -(-N//2)):
    if SumDigits(x) + SumDigits(N - x) < min:
        min = SumDigits(x) + SumDigits(N - x)
print(min)

Submission status: Wrong Answer

Solution code:
N = int(input())

def SumDigits(num):
    sum = 0
    while True:
        sum += num % 10
        num //= 10
        if num == 0:
            break
    return sum

infinity = float('inf')
min = infinity

for x in range(1, N//2):
    if SumDigits(x) + SumDigits(N - x) < min:
        min = SumDigits(x) + SumDigits(N - x)
print(min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 999999
for i in range(1, N//2):
    ans = min(ans, sum([int(n) for n in list(str(i))]
                       )+sum([int(n) for n in list(str(N-i))]))

print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
li = [int(i) for i in N]

print(sum(li))

Submission status: Wrong Answer

Solution code:
n=int(input())
m=0
for x in range(1,n//2+1):
  y=n-x
  x,y=list(str(x)),list(str(y))
  z=sum(list(map(int,x)))+sum(list(map(int,y)))
  m=min(m,z)
print(m)

Submission status: Wrong Answer

Solution code:
n=int(input())
m=0
for x in range(1,n//2+1):
  y=n-x
  x,y=list(str(x)),list(str(y))
  z=sum(list(map(int,x)))+sum(list(map(int,y)))
  m=max(m,z)
print(m)

Submission status: Wrong Answer

Solution code:
n=int(input())
m=0
for x in range(n//2):
  y=n-x
  x,y=list(str(x)),list(str(y))
  z=sum(list(map(int,x)))+sum(list(map(int,y)))
  m=max(m,z)
print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = float("inf")  
for i in range(n+1):
    a = sum([int(i) for i in list(str(i))])
    b = sum([int(i) for i in list(str(n-i))])
    ans = min(a+b, ans)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = float("inf")  
for i in range(n+1):
    a = sum([int(i) for i in list(str(i))])
    b = sum([int(i) for i in list(str(n-i))])
    ans = min(a+b, ans)

Submission status: Wrong Answer

Solution code:
def sumNum(num, sums):
    if num == 0:
        return sums
    sums += num % 10
    num = num // 10
    return sumNum(num, sums)

N = int(input())
keta = 0

for A in range(2, N):
    B = N - A
    _A = sumNum(A, 0)
    _B = sumNum(B, 0)
    ret = _A + _B
    if keta == 0:
        keta = ret
    if keta <= ret:
        continue
    keta = ret

print(keta)

Submission status: Wrong Answer

Solution code:
def sumNum(num, sums):
    if num == 0:
        return sums
    sums += num % 10
    num = num // 10
    return sumNum(num, sums)

N = int(input())
keta = 100001

for A in range(2, N):
    B = N - A
    _A = sumNum(A, 0)
    _B = sumNum(B, 0)
    ret = _A + _B

    if keta <= ret:
        continue
    keta = ret

print(keta)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
n = N
amari = 0
for i in range (len(str(N))):
  amari += n % 10
  n = math.floor(n / 10)
if amari < 10:
  print(10+amari)
else:
  print(amari)

Submission status: Wrong Answer

Solution code:
N = int(input())

#　Xの格桁の和を求める
def f(X):
  return sum(list(map(int, str(X))))

summedDigit = 0
sumArray = []
for A in range(N+1):
  B = N - A
  summedDigit = f(A) + f(B)
  sumArray.append(summedDigit)

print(min(sumArray))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#agc025 a-digits sum
n=input()
ans=0
for i in range(len(n)):
    ans+=int(n[i])
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import math
N=int(input())
ans=float('inf')
for i in range(1,math.ceil(N/2)):
    a_=str(i)
    b_=str(N-i)
    a=[int(j) for j in a_]
    b=[int(j) for j in b_]
    a=sum(a)
    b=sum(b)
    ans=min(ans,a+b)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
ans=float('inf')
for i in range(1,N//2):
    a_=str(i)
    b_=str(N-i)
    a=[int(j) for j in a_]
    b=[int(j) for j in b_]
    a=sum(a)
    b=sum(b)
    ans=min(ans,a+b)
print(ans)

Submission status: Wrong Answer

Solution code:
def dgsm(n):
    ans=0
    while n>0:
        ans+=n%10
        n//=10
    return(ans)
ans=10**6
n=int(input())
for i in range(1,n//2):
    ans=min(ans,dgsm(i)+dgsm(n-i))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

def sum1(a):
    num = 0
    sn = str(a)
    for i in range(len(sn)):
        num += int(sn[i])
    return num
ans = 10**10
for i in range(1,n+1):
    ans = min(ans,sum1(i)+sum1(n-i))
    #print(ans,i,n-i)#,sum1(i),sum1(n-i))
print(ans)

Submission status: Wrong Answer

Solution code:


def ketatashi(a):
	a = str(a)
	ans = 0
	
	for i in range(len(a)):
		ans = ans + int(a[i])
	
	return ans
	

n = int(input())

min = 100

if n == 2:
	print(1)
	exit()

for i in range(1,n//2):
	if ketatashi(i) + ketatashi(n-i) < min :
		min = ketatashi(i) + ketatashi(n-i)
	

print(min)

Submission status: Wrong Answer

Solution code:

def ketatashi(a):
	a = str(a)
	ans = 0
	
	for i in range(len(a)):
		ans = ans + int(a[i])
	
	return ans
	

n = int(input())

min = 100000

for i in range(1,n//2):
	if ketatashi(i) + ketatashi(n-i) < min :
		min = ketatashi(i) + ketatashi(n-i)
	

print(min)

Submission status: Wrong Answer

Solution code:

def ketatashi(a):
	a = str(a)
	ans = 0
	
	for i in range(len(a)):
		ans = ans + int(a[i])
	
	return ans
	

n = int(input())

min = 100

for i in range(1,n//2):
	if ketatashi(i) + ketatashi(n-i) < min :
		min = ketatashi(i) + ketatashi(n-i)
	

print(min)

Submission status: Wrong Answer

Solution code:
N = int(input())
res = 99999
for a in range(1, N): 
        sum_ = 0 
        b = N - a 
        while (a > 0): 
                sum_ += a % 10
                a //= 10
        while (b > 0): 
                sum_ += b % 10
                b //= 10
        print(sum_)
        res = min(res, sum_)
print(res)

Submission status: Wrong Answer

Solution code:


#　各桁の和を計算する
def findSumOfDigits(n):
    sum_digits = 0
    while n > 0 :
        sum_digits += n % 10
        n //= 10
    return sum_digits


def main()->None:
    N = int(input())
    # AとBの各桁の和を求める。
    range_A = range(2,N+1)
    min_total = 100000
    for a in range_A:
        b = N - a
        if b <= 1 : continue
        sum_a = findSumOfDigits(a)
        sum_b = findSumOfDigits(b)
        total = sum_a + sum_b
        if total < min_total:
            min_total = total
    print(min_total)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:


#　各桁の和を計算する
def findSumOfDigits(n):
    sum_digits = 0
    while n > 0 :
        sum_digits += n % 10
        n //= 10
    return sum_digits


def main()->None:
    N = int(input())
    # AとBの各桁の和を求める。
    range_A = range(2,N+1)
    min_total = 100000
    for a in range_A:
        b = N - a
        sum_a = findSumOfDigits(a)
        sum_b = findSumOfDigits(b)
        total = sum_a + sum_b
        if total < min_total:
            min_total = total
    print(min_total)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:


#　各桁の和を計算する
def findSumOfDigits(n):
    sum_digits = 0
    while n > 0 :
        sum_digits += n % 10
        n //= 10
    return sum_digits


def main()->None:
    N = int(input())
    # AとBの各桁の和を求める。
    range_A = range(2,100001)
    min_total = 100000
    for a in range_A:
        b = N - a
        if b < 1:continue
        sum_a = findSumOfDigits(a)
        sum_b = findSumOfDigits(b)
        total = sum_a + sum_b
        if total < min_total:
            min_total = total
    print(min_total)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:


#　各桁の和を計算する
def findSumOfDigits(n):
    sum_digits = 0
    while n > 0 :
        sum_digits += n % 10
        n //= 10
    return sum_digits


def main()->None:
    N = int(input())
    # AとBの各桁の和を求める。
    range_A = range(2,100001)
    min_total = 1000
    for a in range_A:
        b = N - a
        if b < 1:continue
        sum_a = findSumOfDigits(a)
        sum_b = findSumOfDigits(b)
        total = sum_a + sum_b
        if total < min_total:
            min_total = total
    print(min_total)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def findSumOfDigits(n):
    sum_digits = 0
    while n > 0 :
        sum_digits += n % 10
        n //= 10
    return sum_digits
  
N = int(input())
range_A = range(2,100001)
min_total = 1000
for a in range_A:
	b = abs(N - a)
	sum_a = findSumOfDigits(a)
	sum_b = findSumOfDigits(b)
	total = sum_a + sum_b
	if total < min_total:
		min_total = total
print(min_total)

Submission status: Wrong Answer

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

N = int(input())
range_A = range(2,50)
min_total = 1000
for a in range_A:
	b = abs(N - a)
	sum_a = findSumOfDigits(a)
	sum_b = findSumOfDigits(b)
	total = sum_a + sum_b
	if total < min_total:
		min_total = total
print(min_total)

Submission status: Wrong Answer

Solution code:
s=input()
print(sum(int(i) for i in s))

Submission status: Wrong Answer

Solution code:
def digit_10(n):
    dten = 0
    while(n>0):
        dten+=int(n%10)
        n/=10
    return dten

n = int(input())
l = []
for a in range(2,n+1):
    l.append(digit_10(a)+digit_10(n-a))
print(min(l))

Submission status: Wrong Answer

Solution code:
n = int(input())
result =10**10
for i in range(1, n):
    A = str(i)
    print(A)
    a_sum = 0
    B = str(n - i)
    print(B)
    b_sum = 0
    for j in range(len(A)):
        a_sum += int(A[j])
    for k in range(len(B)):
        b_sum += int(B[k])
    if a_sum + b_sum <= result:
        result = a_sum + b_sum

print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
result =10**10
for i in range(1, n + 1):
    A = str(i) 
    a_sum = 0
    B = str(n - i)
    b_sum = 0
    for j in range(len(A)):
        a_sum += int(A[j])
    for k in range(len(B)):
        b_sum += int(B[k])
    if a_sum + b_sum <= result:
        result = a_sum + b_sum
print(result)

Submission status: Wrong Answer

Solution code:
n = input()
if '0' in n:
  n = int(n.replace('0','') + '0')
else:
  n = int(n)
print(sum([int(num) for num in str(n-1)])+1)

Submission status: Wrong Answer

Solution code:
N=int(input())
def f(x):
  s=0
  while x!=0:
    s+=x%10
    x//=10
  return(s)
minn=50
for i in range(1,N//2):
  minn=min(f(i)+f(N-i),minn)
print(minn)

Submission status: Wrong Answer

Solution code:
N = int(input())


def F(num):
    ans = 0
    for n in str(num):
        ans += int(n)
    return ans


min_num = 10**9
for A in range(1, N + 1):
    B = N - A
    num = F(A) + F(B)
    min_num = min(min_num, num)
print(min_num)

Submission status: Wrong Answer

Solution code:
N = int(input())


def F(num):
    ans = 0
    for n in str(num):
        ans += int(n)
    return ans


min_num = 10**9
for A in range(N + 1):
    B = N - A
    num = F(A) + F(B)
    min_num = min(min_num, num)
print(min_num)

Submission status: Wrong Answer

Solution code:
N = int(input())


def F(num1, num2):
    sum1 = sum(map(int, list(str(num1))))
    sum2 = sum(map(int, list(str(num2))))
    return sum1 + sum2


max_num = 0
for A in range(N + 1):
    B = N - A
    max_num = max(max_num, F(A, B))
print(max_num)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce
from collections import Counter
# from itertools import combinations as comb
# from itertools import permutations as perm
# from copy import copy
# 配列二分法アルゴリズム
# https://docs.python.jp/3/library/bisect.html
# import bisect
# 桁数指定
# print('{:.3f}'.format(X))
# from collections import defaultdict
# dic = defaultdict(lambda: ...)
# 値で辞書をソート
# sorted(dic.items(), key=lambda x:x[1])
# ヒープキュー
# https://docs.python.org/ja/3/library/heapq.html
# import heapq
# 正規表現(regular expression)のためのモジュール
# import re

import sys

sys.setrecursionlimit(2000)


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


# 重複組み合わせは nHr = (n + r - 1)Cn
def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)


N = int(input())

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

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
def calc(a,b):
  res=0
  for i in range(len(str(a))):
    res+=int(str(a)[i])
  for i in range(len(str(b))):
    res+=int(str(b)[i])
  return res
  
for i in range(1,n//2+1):
  a=i
  b=n-a
  ans=min(ans,calc(a,b))
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
for a in range(1,N):
    li=[sum(list(map(int,str(a))))+sum(list(map(int,str(N-a))))]
print(min(li))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a = int(input())
mi=[]
for i in range(1,a+1):
    x=0
    y=0
    j = a - i
    for ii in str(i):
        x+=int(ii)
    for jj in str(j):
        y+=int(jj)
    mi.append(x+y)
print(min(mi))

Submission status: Wrong Answer

Solution code:
n = int(input())

s = n % 10
t = int(n / 10) % 10
u = int(n / 100) % 10
v = int(n / 1000) % 10
w = int(n / 10000) % 10

ans = 0

if s == 0 and t == 0 and u == 0 and v == 0 and w == 0:
    ans = 10
else:
    ans = s + t + u + v + w

print(ans)

Submission status: Wrong Answer

Solution code:
# 各位の和を求める
def sum_each_digit(n):
    total_each_digit = 0
    while n > 0:
        total_each_digit += n % 10
        n //= 10
    return total_each_digit


N = int(input())
min_AandB = -1

for A in range(1, N):
    B = N - A

    A_digit = sum_each_digit(A)
    B_digit = sum_each_digit(B)
    sum_digit = A_digit + B_digit

    if sum_digit < min_AandB or min_AandB < 0:
        min_AandB = sum_digit

print(sum_digit)

Submission status: Wrong Answer

Solution code:
N=int(input())

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

Submission status: Wrong Answer

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

N = int(input())
ret = 10**5
for a in range(1, N):
    b = N - a
    if b < 2:
        continue
    total = find_sum_digits(a) + find_sum_digits(b)
    if ret > total:
        ret = total
print(ret)

Submission status: Wrong Answer

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

def is_power(a, b):
    if a < b:
        return False
    if a == b:
        return True
    else:
        return is_power(a / b, b)

N = int(input())

if is_power(N, 10):
    print(10)
    exit()

ret = 10**5
for a in range(2, N + 1):
    b = N - a
    if b < 2:
        continue
    total = find_sum_digits(a) + find_sum_digits(b)
    if ret > total:
        ret = total
print(ret)

Submission status: Wrong Answer

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

N = int(input())
ret = 10**5
for a in range(2, N + 1):
    b = N - a
    if b == 0:
        continue
    total = find_sum_digits(a) + find_sum_digits(b)
    if ret > total:
        ret = total
print(ret)

Submission status: Wrong Answer

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

N = int(input())
ret = 10**5
for a in range(2, N + 1):
    b = N - a
    if b < 2:
        continue
    total = find_sum_digits(a) + find_sum_digits(b)
    if ret > total:
        ret = total
print(ret)

Submission status: Wrong Answer

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

N = int(input())
ret = 10**5
for a in range(2, N + 1):
    b = N - a
    if b == 0:
        continue
    total = find_sum_digits(a) + find_sum_digits(b)
    print(a, b, total)
    if ret > total:
        ret = total
print(ret)

Submission status: Wrong Answer

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

N = int(input())
ret = 10**5
for a in range(1, N + 1):
    b = N - a
    total = find_sum_digits(a) + find_sum_digits(b)
    if ret > total:
        ret = total
print(ret)

Submission status: Wrong Answer

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

N = int(input())
ret = 10**5
for a in range(1, N + 1):
    b = N - a
    total = find_sum_digits(a) + find_sum_digits(b)
    print(a, b, total)
    if ret > total:
        ret = total
print(ret)

Submission status: Wrong Answer

Solution code:
N = int(input())
def summ(X):
  a = X//10000
  b = (X - a*10000)//1000
  c = (X - a*10000 - b*1000)//100
  d = (X - a*10000 - b*1000 - c*100)//10
  e = X - a*10000 - b*1000 - c*100 - d*10
  return a+b+c+d+e
X = []
for A in range(1,N+1):
  B = N-A
  C = summ(A) + summ(B)
  X.append(C)
print(min(X))

Submission status: Wrong Answer

Solution code:
def ketanowa(num):
  return sum(list(map(int,str(num))))

N = int(input())
ans = 10**5
for i in range(1, N//2):
  goukei = ketanowa(i) + ketanowa(N-i)
  if goukei < ans:
    ans = goukei
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  ans = 100000
  for i in range(1, n+1):
    r = (n-i)//10000 + ((n-i)//1000)%10 + ((n-i)//100)%10 + ((n-i)//10)%10 + (n-i)%10 
    l = i//10000 + (i//1000)%10 + (i//100)%10 + (i//10)%10 + i%10
    ans = min(ans, r + l)
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  ans = 100000
  for i in range(1, (n+1)//2):
    r = (n-i)//10000 + ((n-i)//1000)%10 + ((n-i)//100)%10 + ((n-i)//10)%10 + (n-i)%10 
    l = i//10000 + (i//1000)%10 + (i//100)%10 + (i//10)%10 + i%10
    ans = min(ans, r + l)
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  ans = 100000
  for i in range(1, (n+1)//2):
    ans = min(ans, ((n-i)//100000 + ((n-i)//10000)%10 + ((n-i)//1000)%10 + ((n-i)//100)%10 + ((n-i)//10)%10 + (n-i)%10) + (i//100000 + (i//10000)%10 + (i//1000)%10 + (i//100)%10 + (i//10)%10 + i%10))
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  ans = 100000
  for i in range(2, (n+1)//2):
    ans = min(ans, ((n-i)//100000 + ((n-i)//10000)%10 + ((n-i)//1000)%10 + ((n-i)//100)%10 + ((n-i)//10)%10 + (n-i)%10) + (i//100000 + (i//10000)%10 + (i//1000)%10 + (i//100)%10 + (i//10)%10 + i%10))
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  ans = 100000
  for i in range(n+1):
    ans = min(ans, ((n-i)//100000 + ((n-i)//10000)%10 + ((n-i)//1000)%10 + ((n-i)//100)%10 + ((n-i)//10)%10 + (n-i)%10) + (i//100000 + (i//10000)%10 + (i//1000)%10 + (i//100)%10 + (i//10)%10 + i%10))
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  ans = 1000
  for i in range(n+1):
    ans = min(ans, ((n-i)//100000 + ((n-i)//10000)%10 + ((n-i)//1000)%10 + ((n-i)//100)%10 + ((n-i)//10)%10 + (n-i)%10) + (i//100000 + (i//10000)%10 + (i//1000)%10 + (i//100)%10 + (i//10)%10 + i%10))
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  ans = 1000
  for i in range(n+1):
    ans = min(ans, ((n-i)//10000 + ((n-i)//1000)%10 + ((n-i)//100)%10 + ((n-i)//10)%10 + (n-i)%10) + (i//10000 + (i//1000)%10 + (i//100)%10 + (i//10)%10 + i%10))
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list()
for i in range(n):
	x=str(i+1)
	y=str(n-i-1)
	ans=0
	for j in range(len(x)):
		ans+=int(x[j])
	for j in range(len(y)):
		ans+=int(y[j])
	a.append(ans)
print(min(a))

Submission status: Wrong Answer

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