TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.  These squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.  We say the grid is a _good_ grid when the following condition is met for all i,j,x,y satisfying 1 \leq i,j,x,y \leq N:    * If (i+j) \% 3=(x+y) \% 3, the color of (i,j) and the color of (x,y) are the same.   * If (i+j) \% 3 \neq (x+y) \% 3, the color of (i,j) and the color of (x,y) are different.  Here, X \% Y represents X modulo Y.  We will repaint zero or more squares so that the grid will be a good grid.  For a square, the _wrongness_ when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.  Find the minimum possible sum of the wrongness of all the squares.

Submission attempts (in order):
import itertools
N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
grid = [list(map(int,input().split())) for i in range(N)]
color = list(range(1,C+1))
ans = float('inf')
for x,y,z in itertools.permutations(color,3):
    print(x,y,z)
    res = 0
    for i in range(1,N+1):
        for j in range(1,N+1):
            if (i+j) % 3 == 0:
                res += D[grid[i-1][j-1]-1][x-1]
            elif (i+j) % 3 == 1:
                res += D[grid[i-1][j-1]-1][y-1]
            elif (i+j) % 3 == 2:
                res += D[grid[i-1][j-1]-1][z-1]
    if res < ans:
        ans = res
print(ans)

import itertools
N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
grid = [list(map(int,input().split())) for i in range(N)]
l1 = [0]*C
l2 = [0]*C
l3 = [0]*C
for i in range(1,N+1):
    for j in range(1,N+1):
        if (i+j) % 3 == 0:
            l1[grid[i-1][j-1]-1] += 1
        elif (i+j) % 3 == 1:
            l2[grid[i-1][j-1]-1] += 1
        elif (i+j) % 3 == 2:
            l3[grid[i-1][j-1]-1] += 1
color = list(range(1,C+1))
ans = float('inf')
for x,y,z in itertools.permutations(color,3):
    res = 0
    for i in range(C):
        res += D[i][x-1]*l1[i]
    for i in range(C):
        res += D[i][y-1]*l2[i]
    for i in range(C):
        res += D[i][z-1]*l3[i]
    if res < ans:
        ans = res
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.  These squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.  We say the grid is a _good_ grid when the following condition is met for all i,j,x,y satisfying 1 \leq i,j,x,y \leq N:    * If (i+j) \% 3=(x+y) \% 3, the color of (i,j) and the color of (x,y) are the same.   * If (i+j) \% 3 \neq (x+y) \% 3, the color of (i,j) and the color of (x,y) are different.  Here, X \% Y represents X modulo Y.  We will repaint zero or more squares so that the grid will be a good grid.  For a square, the _wrongness_ when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.  Find the minimum possible sum of the wrongness of all the squares.

Submission attempts (in order):
def main():
    N, Ma, Mb = map(int, input().split())
    yakuhin = []
    sa = 0
    sb = 0
    for i in range(N):
        yakuhin.append(list(map(int, input().split())))
        sa += yakuhin[i][0]
        sb += yakuhin[i][1]
    
    INF = 10**15
    DP = [[[INF for _ in range(sb+1)] for _ in range(sa+1)] for _ in range(N+1)]
    
    for i in range(N):
        DP[i][0][0] = 0
    
    for i in range(N):
        for j in range(sa+1):
            for k in range(sb+1):
                if(j >= yakuhin[i][0] and k >= yakuhin[i][1]):
                    DP[i+1][j][k] = min(DP[i][j][k], DP[i][j-yakuhin[i][0]][k-yakuhin[i][1]]+yakuhin[i][2])
                else:
                    DP[i+1][j][k] = min(DP[i+1][j][k], DP[i][j][k])
        
    ans = INF
    for i in range(1, N):
        for j in range(1, sa+1):
            for k in range(1, sb+1):
                if(j*Mb == k*Ma):
                    ans = min(ans, DP[i][j][k])    
        
    print(ans if ans != INF else -1)
    
main()

N, C = map(int, input().split())

D = []
for i in range(C):
    D.append(list(map(int, input().split())))

cc = [[0]*C for i in range(3)]
for i in range(N):
    color = list(map(int, input().split()))
    for j in range(len(color)):
        cc[(i+j)%3][color[j]-1] += 1
    
iwakan = [[[0, 0] for _ in range(C)] for _ in range(3)]

for i in range(3):
    for j in range(C):
        tmp = 0
        for k in range(len(cc[i])):
            tmp += cc[i][k]*D[k][j]
        iwakan[i][j][0] = tmp
        iwakan[i][j][1] = j

ans = 10**15
for i in range(len(iwakan)):
    iwakan[i] = sorted(iwakan[i], key=lambda x:x[0])
    
for i in range(3):
    for j in range(3):
        if(iwakan[0][i][1] == iwakan[1][j][1]):
            continue
        for k in range(3):
            if(iwakan[0][i][1] == iwakan[2][k][1]):
                continue
            if(iwakan[1][j][1] == iwakan[2][k][1]):
                continue
            ans = min(ans, iwakan[0][i][0]+iwakan[1][j][0]+iwakan[2][k][0])
            
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n=int(input())
def num(x):
  rec=0
  while x>0:
    rec+=x%10
    rec//=10
ans=10**18
for i in range(1,n//2):
  ans=min(ans,num(i)+num(n-i))
print(ans)

n=int(input())
def num(x):
  rec=0
  while x>0:
    rec+=x%10
    rec//=10
  return rec
ans=10**18
for i in range(1,n//2):
  ans=min(ans,num(i)+num(n-i))
print(ans)

n=int(input())
def num(x):
  rec=0
  while x>0:
    rec+=x%10
    x//=10
  return rec
ans=10**18
for i in range(1,(n+3)//2):
  ans=min(ans,num(i)+num(n-i))
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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()


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

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

    return res

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

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


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

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
a = 0
for i in range(len(n)):
    a += n[i]
if a == 1:
    print(10)
else:
    print(a)

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


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
N=int(input())
if N%10==0:
    print(10)
else:
    ans = 0
    for i in range(len(N)):
        ans+= int(N[i])
        print(ans)

N=int(input())
ans=[]

if N%10==0:
    print(10)
else:
    for i in range(1,N+1):
        ls=list(map(int,list(str(i))))
        x=sum(ls)
        lst=list(map(int,list(str(N-i))))
        y=sum(lst)
        ans.append(x+y)
        print(min(ans))

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


N=int(input())
ans=[]

if N%10==0:
    print(10)
else:
    ans = 0
    for i in range(len(N)):
        ans+= int(N[i])
        print(ans)


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


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())

ans = float("inf")

A = 0
B = N
for i in range(N//2):

    A += 1
    B -= 1

    if A + B > N:
        break

    else:

        s_a = str(A)
        s_b = list(str(B))

        a = [int(i) for i in s_a]
        b = [int(i) for i in s_b]

        ans = min(ans, sum(a)+sum(b)

print(ans)


N = int(input())

ans = float("inf")

A = 0
B = N
for i in range(N//2):

    A += 1
    B -= 1

    if A + B > N:
        break

    else:

        s_a = str(A)
        s_b = list(str(B))

        a = [int(i) for i in s_a]
        b = [int(i) for i in s_b]

        ans = min(ans, sum(a)+sum(BytesWarning))

print(ans)


N = int(input())

ans = float("inf")

A = 0
B = N
for i in range(N//2):

    A += 1
    B -= 1

    if A + B > N:
        break

    else:

        s_a = str(A)
        s_b = list(str(B))

        a = [int(i) for i in s_a]
        b = [int(i) for i in s_b]

        ans = min(ans, sum(a)+sum(b))

print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
A = int(input())
s=0
while (A > 0):

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


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) 

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


n = input()

powers10 = [10**i for i in range(1, 6)]
print(10 if int(n) in powers10 else sum(int(d) for d in n))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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

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

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)

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)

N=int(input())
m=[]
for A in range(1,N):
  s=0
  B=N-A
  a="".join(str(A))
  b="".join(str(B))
  for x in range(0,len(a)):
    s+=int(a[x])
  for y in range(0,len(b)):
    s+=int(b[y])
  m.append(s)
print(min(m))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)

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+1):
  minn=min(f(i)+f(N-i),minn)
print(minn)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n = input()

m = len(n)
f = 0
ans = 0

for i in range(m):
    ans += n[i]
    
    
if m>1 and n[0] == 1:
    if n[1] == 0:
        ans += 9
print(ans)

n = input()

m = len(n)
f = 0
ans = 0

for i in range(m):
    ans += int(n[i])
    
    
if m>1 and n[0] == '1':
    if n[1] == '0':
        ans += 9
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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).

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

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)

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)

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)

n=int(input())
m=100000
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)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n = input()

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


n = input()

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


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n = input()

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

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

n = int(input())

res = 0

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

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)

n = int(input())
result =10**10
for i in range(1, n):
    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)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())
ret = 10000
for A in range(1, N):
    ret = min(ret, digit_sum(A) + digit_sum(N-A))
print(ret)

def digit_sum(i):
    return sum([int(digit) for digit in list(str(i))])

N = int(input())
ret = 10000
for A in range(1, N):
    ret = min(ret, digit_sum(A) + digit_sum(N-A))
print(ret)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n = input().split()
if n[0] == 1 and sum(n):
    print(10)
else:
    print(sum(n))


n = list(map(int, list(input())))

if n[0] == 1 and sum(n)  == 1:
    print(10)
else:
    print(sum(n))


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n=int(input())
if a%2==0:
    a=n//2+1
else:
    a=n//2+2
def wa(k):
    kai=0
    while k>0:
        kai+=round(k%10)
        k=round((k-round(k%10))/10)
    return kai
ans=10000000000
for i in range(1,a+1):
    b=i
    c=n-i
    if ans>(wa(b)+wa(c)):
        ans=wa(b)+wa(c)
print(ans)

n=int(input())
if n%2==0:
    a=n//2+1
else:
    a=n//2+2
def wa(k):
    kai=0
    while k>0:
        kai+=round(k%10)
        k=round((k-round(k%10))/10)
    return kai
ans=10000000000
for i in range(1,a+1):
    b=i
    c=n-i
    if ans>(wa(b)+wa(c)):
        ans=wa(b)+wa(c)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n=int(input());minn=100
def digit_sum(x):
  a,b=0,str(x)
  for i in range(len(b)):a+=int(b[i])
  return a
for i in range(1,n//2+1):
  a=digit_sum(i)+digit_sum(n-i)
  minn=min(100,a)
print(minn)

n=int(input());minn=100
def digit_sum(x):
  a,b=0,str(x)
  for i in range(len(b)):a+=int(b[i])
  return a
for i in range(1,n//2+1):
  a=digit_sum(i),digit_sum(n-i)
  minn=min(100,a)
print(minn)

n=int(input());minn=100
def digit_sum(x):
  a,b=0,str(x)
  for i in range(len(b)):a+=int(b[i])
  return a
for i in range(1,n//2+1):a=digit_sum(i)+digit_sum(n-i);minn=min(minn,a)
print(minn)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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).

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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).

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

N = int(input())
ans = 10**5
for a in range(1, N//2 + 1):
    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)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n = input()
sum = 0
if n[0] == "1" and n[1:-1]=="0"*(len(n)-1):
  print("10")
else:
  for i in range(len(n)):
    sum +=int(i)
  print(sum)

n = input()
sum = 0
if n[0] == "1" and n[1:len(n)]=="0"*(len(n)-1):
  print("10")
else:
  for i in range(len(n)):
    sum +=int(n[i])
  print(sum)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())
LR = [tuple(map(int,input().split()))for i in [None] * N]
Lmin = sorted(LR,key=lambda x:x[0])
Rmax = sorted(LR,key=lambda x:x[1],reverse=True)

T = 0
def t_len(lr):
    a = lr[1] - T
    b = T - lr[0]
    return  a if a > b else b

def select(l):
    return sorted(l,key=t_len,reverse=True)[0]

def select2(l):
    a = abs(Lmin[0][0] - T)
    b = abs(Rmax[0][1] - T)
    return Lmin[0] if a > b else Rmax[0]

def selectT(lr):
    if lr[0] <= T <= lr[1]:
        return T
    a = lr[1] - T
    b = T - lr[0]
    return  lr[0] if a > b else lr[1]
K = 0
for i in [None]*N:
    s = select2(LR)
    nextT = selectT(s)
    K += abs(nextT-T)
    T = nextT
    LR.remove(s)
    Lmin.remove(s)
    Rmax.remove(s)
K += abs(T)
print(K)

N = sum([int(i) for i in input()])
print('10' if N == 1 else N)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
# -*- coding: utf-8 -*-

def sum_digits(val):
    work = 0
    while True:
        work += val % 10
        val //= 10
        if val == 0:
            break
    return work
   
n = int(input())

values = []
for a in range(2, n + 1):
    b = n - a
    if b < 2:
        continue
    print("{}, {} / {}, {}".format(a, sum_digits(a), b, sum_digits(b)))
    values.append(sum_digits(a) + sum_digits(b))

values.sort()
# print(values)
print("0" if len(values) == 0 else values[0])

# -*- coding: utf-8 -*-

def sum_digits(val):
    work = 0
    while True:
        work += val % 10
        val //= 10
        if val == 0:
            break
    return work
   
n = int(input())

values = []
for a in range(1, n + 1):
    b = n - a
    if b < 1:
        continue
    
    values.append(sum_digits(a) + sum_digits(b))

values.sort()
# print(values)
print("0" if len(values) == 0 else values[0])

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
print(sum(map(int,input().split())))

n = int(input())
nmin = 10000000
for n1 in range(1,n):
    n2 = n-n1
    nsum = sum(map(int, list(str(n1))))+sum(map(int, list(str(n2))))

    if nmin > nsum:
        nmin = nsum
print(nmin)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
import math
n,a,b,k = map(int, input().split())
un = 998244353
def combination(n,r):
    return math.factorial(n)//(math.factorial(r) * math.factorial(n-r))

total = 0
for i in range(n+1):
    if((k-a*i)%b==0):
        count_b = (k-a*i)//b
        total += combination(n, i) * combination(n, count_b)

print(str(total % un))


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
if min == float("inf"):
    min = n
print(min)


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
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()


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) 

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


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)
else:
    print(menor)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)

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)

n = list(map(int, list(input())))
 
if n[0] == 1 and sum(n)  == 1:
    print(10)
else:
    print(sum(n))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n=int(input())
ans=0
for i in range(n//2+1):
  l=[int(j) for j in list(str(i))]
  m=[int(k) for k in list(str(n-i))]
  if ans<sum(j)+sum(m):
    ans=sum(j)+sum(m)
print(ans)

# A
NL = list(map(int, list(input())))

if NL[0] == 1 and sum(NL) == 1:
    print(10)
else:
    print(sum(NL))
#copy code

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
N, A, B, K = map(int, input().split())
M = 998244353

X = set()
for n in range(0, K//A+1):
    m = (K - n * A) // B
    if n <= N and m <= N and n * A + m * B == K:
        X.add((n, m))

comb = [0]*(N+1)
comb[0] = 1
comb[N] = 1
for i in range(1, N//2+1):
    comb[i] = comb[i-1]*(N-i+1)//i
    comb[i] = comb[i]
    comb[N-i] = comb[i]

ans = 0
for n, m in X:
    ans += comb[n] * comb[m]
    ans = ans % M
print(ans)


N = int(input())

def digit_sum(X):
    s = 0
    while(X > 0):
        s += X % 10
        X = int(X / 10)
    return s

min_ = 10 ** 5
for A in range(1, int(N/2)+1):
    B = N - A
    val = digit_sum(A) + digit_sum(B)
    min_ = min(min_, val)

print(min_)


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):


import itertools
import collections
import bisect

def main():
    N = int(input())
    if N % 10:
        print(10)
    else:
        print(sum(map(int, list(str(N)))))


if __name__ == '__main__':
    main()
    



import itertools
import collections
import bisect

def main():
    N = int(input())
    if N % 10 == 0:
        print(10)
    else:
        print(sum(map(int, list(str(N)))))


if __name__ == '__main__':
    main()
    

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
ans=0
while n>0:
  n%10+=ans
  n//=10
print(ans)

from math import log10
n = int(input())
ans=0
l = log10(n)
if int(l)==l:
  ans=10
else:
  while n>0:
  ans+=n%10
  n//=10
print(ans)


# python template for atcoder1
from math import log10
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
ans = 0
l = log10(n)
if int(l) == l:
    ans = 10
else:
    while n > 0:
        ans += n % 10
        n //= 10
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())
if N % 10 == 0:
    print(10)
else:
    s = 0
    for i in str(N):
        s += int(i)
	print(s)

N = int(input())
if N % 10 == 0:
    print(10)
else:
    s = 0
    for i in str(N):
        s += int(i)
    print(s)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
res = 0
for i in range(len(n)):
  res = res + n[i]
  
print(res)

n = int(input())
res = n
for i in range(1,n//2+1):
    tmp = 0
    a = str(n-i)
    b = str(i)
    for j in a:
        tmp += int(j)
    for j in b:
        tmp += int(j)
    res = min(res,tmp)
else:
    print(res)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
#!/usr/bin/env python3


def read_h(typ=int):
    return map(typ, input().split())


def read_v(n, typ=int):
    return [typ(input()) for _ in range(n)]


def digit_sum(i):
    return sum([int(d) for d in str(i)])


def main():
    n, = read_h()
    ans = 10000
    for a in range(1, n):
        b = n - a
        s = digit_sum(a) + digit_sum(b)
        if s < ans:
            print(a, b)
            ans = s

    print(ans)


if __name__ == '__main__':
    main()


#!/usr/bin/env python3


def read_h(typ=int):
    return map(typ, input().split())


def read_v(n, typ=int):
    return [typ(input()) for _ in range(n)]


def digit_sum(i):
    return sum([int(d) for d in str(i)])


def main():
    n, = read_h()
    ans = 10000
    for a in range(1, n):
        b = n - a
        s = digit_sum(a) + digit_sum(b)
        if s < ans:
            ans = s

    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
def sumNum(i):
    s = 0
    while i//10 > 0:
        s += i%10
        if i//10 < 10:
            s += i//10
        i = i//10
    return s

sumab = float('inf')
for i in range(1,n):
    j = n - i
    tmp = sumNum(i) + sumNum(j)
    if tmp < sumab:
        sumab = tmp
print(sumab)

n = int(input())
def sumNum(i):
    if i//10 == 0:
        s = i
    else:
        s = 0
    while i//10 > 0:
        s += i%10
        if i//10 < 10:
            s += i//10
        i = i//10
    return s

sumab = float('inf')
for i in range(1,n):
    j = n - i
    tmp = sumNum(i) + sumNum(j)
    if tmp < sumab:
        sumab = tmp
print(sumab)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())

ans = [0]

for i in range(2, n):
    a = sum([int(j) for j in str(i)])
    b = sum([int(j) for j in str(n - i)])
    ans.append(a + b)

print(min(ans))

n = int(input())

ans = list()

for i in range(2, n // 2):
    a = sum([int(j) for j in str(i)])
    b = sum([int(j) for j in str(n - i)])
    ans.append(a + b)

if len(ans) > 0:
    print(min(ans))
else:
    print(2)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)))
        ans = np.flip(ans)
        return ans
                
    else:
        print("too large")
        return N
    
digit = Num_Each_Digit(N,10)
    
if N == 10**(len(digit)+1):
    print(10)
    
else:
    print(np.sum(digit))

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


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
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)

N = int(input())
min = 100000000000000
for i in range(1, N):
  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)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
def func(a):
    result = 0
    
    while a != 0:
        result += a%10
        a = int(a/10)
        
    if result == 1:
        print '10'
    else:
        print result

a=int(input())
func(a)
        

a = int(input())

def func(a):
    result = 0
    
    while a != 0:
        result += a%10
        a = int(a/10)
        
    if result == 1:
        print('10')
    else:
        print(result)

func(a)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())
def sumof(N):
  sum = 0
  while(N>0):
    sum += N % 10
    N /= 10
  return sum

minsum = 9*10
for i in range(N//2):
  minsum = min(minsum,sumof(i+1) + sumof(N-i-1))
print(minsum)


N = int(input())
def sumof(N):
  sum = 0
  while(N>0):
    sum += N % 10
    N /= 10
  return sum

minsum = 9*10
for i in range(N//2+1):
  minsum = min(minsum,sumof(i) + sumof(N-i))
print(minsum)


NL = [int(x) for x in str(input())]
if NL[0] == 1 and sum(NL) == 1:
    print(10)
else:
    print(sum(NL))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())
A = [i for i in str(N)]
result = 0
for j in range(len(A)):
  result += A[j]
if result == 0 and A[0] == 1:
  print(10)
else:
  print(result)

N = int(input())
A = [i for i in str(N)]
result = 0
for j in range(len(A)):
  result += int(A[j])
if result == 1 and A[0] == "1":
  print(10)
else:
  print(result)


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())

sum_list = []

def findSumOfDigit(n):
    s = 0
    while(n > 0):
        s += n % 10
        n = int(n / 10)N = int(input())

sum_list = []

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

for a in range(1, N-1):
    b = N - a
    sum_list.append(findSumOfDigit(a) + findSumOfDigit(b))

print(min(sum_list))

    return s

for a in range(2, N):
    b = N - a
    sum_list.append(findSumOfDigit(a) + findSumOfDigit(b))

print(min(sum_list))


N = int(input())

sum_list = []

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

for a in range(1, N):
    b = N - a
    sum_list.append(findSumOfDigit(a) + findSumOfDigit(b))

print(min(sum_list))


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
a=input()

al=[int(c) for c in list(str(a))]

sal=sum(al)
return sal if sal > 1 else 10

a=input()

al=[int(c) for c in list(str(a))]

sal=sum(al)
ret= sal if sal > 1 else 10
print(ret)


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n=int(input())
c_min=200000
for i in range(1,n):
    a=i
    b=n-i
    a_c=0
    b_c=0
    if(a==0)|(b==0):
        print('Err')
    for j in range(6):
        a_c=a_c+a%10
        a=a//10
    for j in range(6):
        b_c=b_c+b%10
        b=b//10
    if (a_c+b_c<=c_min):
        c_min=a_c+b_c
        print(i,n-i)
    
print(c_min)

n=int(input())
c_min=200000
for i in range(1,n):
    a=i
    b=n-i
    a_c=0
    b_c=0
    if(a==0)|(b==0):
        print('Err')
    for j in range(6):
        a_c=a_c+a%10
        a=a//10
    for j in range(6):
        b_c=b_c+b%10
        b=b//10
    if (a_c+b_c<=c_min):
        c_min=a_c+b_c
        #print(i,n-i)
    
print(c_min)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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))

n=int(input())
a=10*5
def k(n):
    s=tuple(map(int,tuple(str(n))))
    return sum(s)

for i in range(1,n):
    s=k(i)+k(n-i)
    if a>s:
        a=s
print(a)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s=sum(list(input()))
print(10 if s==1 else s)

s=sum(list(map(int,list(input()))));print(10 if s==1 else s)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
s = n
for i in range(n//2+1):
  s = min(s, sum(list(str(i))) + sum(list(str(n-i))))
print(s)
  

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

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())

ans = N
for A in range(1,N):
    B = N - A
    A_str = str(A)
    B_str = str(B)
    A_li = [int(A_str[i]) for i in len(A_str)]
    B_li = [int(B_str[i]) for i in len(B_str)]
    s = sum(A_li) + sum(B_li)
    if s < ans:
        ans = s

print(ans)

N = int(input())

ans = N
for A in range(1,N):
    B = N - A
    A_str = str(A)
    B_str = str(B)
    A_li = [int(A_str[i]) for i in range(len(A_str))]
    B_li = [int(B_str[i]) for i in range(len(B_str))]
    s = sum(A_li) + sum(B_li)
    if s < ans:
        ans = s

print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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).

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

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(1,n)]))

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
N = list(map(int, list(input())))
s = sum(N)

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

N = list(map(int, list(input())))

s = sum(N)

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


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
N = input()

ans = 0
for n in N:
    ans += n

print(ans)


N = input()

ans = 0
for n in N:
    ans += int(n)

if ans == 1:
    ans = 10

print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
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))


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


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
x=int(input())
count=0
for a in range(1, x):
    suma=0
    sumb=0
    b=x-a
    while (a > 0):
        suma += a%10
        a//=10
    while (b > 0):
        sumb += b%10
        b//=10
    count = min(count, suma+sumb)
print(min(S))

x=int(input())
count=10000
for a in range(1, x):
    suma=0
    sumb=0
    b=x-a
    while (a > 0):
        suma += a%10
        a= a//10
    while (b > 0):
        sumb += b%10
        b=b//10
    count = min(count, suma+sumb)
print(count)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())

digits_sum = lambda x: sum(map(int, str(x)))

min_num = 10**18
for i in range(1, (N+1)//2+1):
    print(i)
    m = N-i
    l = digits_sum(i) + digits_sum(m)
    min_num = min(l, min_num)

print(min_num)

N = int(input())

digits_sum = lambda x: sum(map(int, str(x)))

min_num = 10**18
for i in range(1, (N+1)//2+1):
    # print(i)
    m = N-i
    l = digits_sum(i) + digits_sum(m)
    min_num = min(l, min_num)

print(min_num)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())
L = []
for i in range(N):
	a = i + 1
	b = N - i - 1
	s = sum(list(map,(int, list(str(a))))) + sum(list(map,(int, list(str(b)))))
	L.append(s)
print(min(L))

N = int(input())
L = []
for i in range(N - 1):
	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))

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted