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: Runtime Error

Solution code:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    static bool fr_f; static char fr_ch;
    fr_f=0; x=0; fr_ch=getchar();
    while(fr_ch<'0' || '9'<fr_ch) {if(fr_ch=='-') fr_f=1; fr_ch=getchar();}
    while('0'<=fr_ch && fr_ch<='9') {x=(x<<1)+(x<<3)+fr_ch-'0'; fr_ch=getchar();}
    if(fr_f) x=-x;
}

template< typename T > inline void Max (T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min (T &a, T b) {if(b<a) a=b;}
template< typename T > inline void Swap(T &a, T &b) {T c=a;a=b;b=c;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double   pi = acos(-1.0) ;
const int     MOD = (int)1e9+7 ;
const int     INF = (int)0x3f3f3f3f ;
const LL     LINF = (LL)INF<<32|INF ;
const int    SINF = (uint)(-1)>>1 ;
const LL    SLINF = (ULL)(-1)>>1 ;
const double DINF = 1e50 ;
const double  eps = 1e-5 ;
const int    maxn = (int) 1e5+20 ;
const int    maxm = (int) 1e6+20 ;
const int    maxk = (int) 1000+20 ;

inline int sig(double x) {return x<-eps?-1:x>eps;}
inline LL fp(LL a,LL n,LL p) {LL res=1; for(;n;n>>=1,a=a*a%p) if(n&1) res=res*a%p; return res;}
template<typename T>inline T gcd(T a,T b) {for(T c;b;c=a%b,a=b,b=c); return a;}

//--------------------start--------------------

int func(int x)
{
    int res = 0;
    while(x)
    {
        res += x % 10;
        x /= 10;
    }
    return res;
}

void work()
{
    int n; read(n);
    int ans = n;
    for(int i = 0; i <= n; i++)
    {
        Min(ans, func(i) + func(n - i));
    }
    cout <<ans <<endl;
}


//---------------------end---------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())

def func(x) :
    res = 0
    while x :
        res += x % 10
        x = x // 10
    return res

ans = n

for i range(n + 1) :
    min(ans, func(i) + func(n - i))

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

def func(x) :
    res = 0
    while x :
        x, res = x/10, res + x % 10
    return res

ans = n

for i range(n + 1) :
    min(ans, func(i) + func(n - i))

print(ans)

Submission status: Runtime Error

Solution code:
N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)
v = 1
for i in range(N):
	v = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod
	ncr[i+1] = v%mod

pat = 0
for a in range(N):
	if (K - (a * A)) % B == 0:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)

Submission status: Runtime Error

Solution code:
import itertools


if __name__ == '__main__':
    N, A, B, K = map(int, input().split())
    li = [i for i in range(N)]
    ans = 0
    for ai in range(N):
        tmp = K-(ai*A)
        if tmp / B <= N and tmp % B == 0:
            bi = tmp // B
            a = len(list(itertools.combinations(li, ai)))
            b = len(list(itertools.combinations(li, bi)))
            ans += a*b
    print(ans)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
import copy

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

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

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, A, B, K] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2]), long(input_raw[3])]
    cnt = 0
    li = []
    for t in range(N + 1):
        if (K - t * A)%B == 0:
            u = (K - t * A)/B
            if t >= 0 and u >= 0 and t <= N and u <= N:
                li.append((t, u))


    frac_N = [0 for i in range(N + 1)]
    power_N = [0 for i in range(N + 1)]
    frac_N[0] = 1
    power_N[0] = 1
    p = 998244353L
    for i in range(1, N + 1):
        frac_N[i] = (frac_N[i - 1] * i ) % p
        power_N[i] = -1

    s = 0L
    for i in range(len(li)):
        t = li[i][0]
        u = li[i][1]
        if power_N[t] == -1:
            power_N[t] = power_func(frac_N[t], p - 2, p)
        if power_N[N - t] == -1:
            power_N[N - t] = power_func(frac_N[N - t], p - 2, p)
        if power_N[u] == -1:
            power_N[u] = power_func(frac_N[u], p - 2, p)
        if power_N[N - u] == -1:
            power_N[N - u] = power_func(frac_N[N - u], p - 2, p)

        s = (s + ((frac_N[N] * power_N[t] * power_N[N - t]) % p) * ((frac_N[N] * power_N[u] * power_N[N - u]) % p)) % p
    print s


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from functools import lru_cache

L = input().split()
sprime = 998244353 # approx 10**9
N = int(L[0])
A = int(L[1])
B = int(L[2])
K = int(L[3])

if (A+B) * N < K:
	print(0)
	exit()

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

memo = [0] * (N+1)
memo[0] = memo[N] = 1
for i in range(1,N//2+1):
	v = memo[i-1] * (N-i+1) * modinv(i,sprime)
	v = v % sprime
	memo[i] = memo[N-i] = v

# max is A*N + B*N
sum = 0
for i in range(0,N):
	if (K - A*i) % B == 0:
		j = (K-A*i)//B
		if 0 <= j <= N:
			sum += memo[i] * memo[j]
			sum %= sprime

print(sum)

Submission status: Runtime Error

Solution code:
N, C, D = map(int, input().split())
check = [i*i for i in range(N+1)]
time = 0
stop = N * N
 
print(check)
if C * D % 2 ==1:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 0:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break
elif (C+D) % 2 == 0:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 1:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break
else:
 for i in range(2*N):
  tt = i * i
  if C - tt in check or D - tt in check:
   continue
  else:
   for j in range(2*N):
    print(i,j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break

Submission status: Runtime Error

Solution code:
def digitSum(n):
    l=int(log10(n))
    r=0
    while(l>0):
        r=r+n%10
        n=n/10
        l=l-1
    return r
#int main
n=int(input())
hb=[]
hb.append(digitSum(n))
if n%2==0:
    hb.append(2*digitSum(n/2))
else :
    hb.append(digitSum(int(n/2))+digitSum(int(n/2)+1))
print(min(hb))

Submission status: Runtime Error

Solution code:
def digitSum(n):
    l=int(log10(n))
    r=0
    while(l>0):
        r=r+n%10
        n=n/10
        l=l-1
    return r
#int main
n=int(input())
print(digitSum(n))

Submission status: Runtime Error

Solution code:
N, C, D = map(int, input().split())
check = [i*i for i in range(N)]
time = 0
stop = N * N

if C * D % 2 ==1:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 0:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break
elif (C+D) % 2 == 0:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 1:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break
else:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 0:
    if C % 2 == 1:
     if D - j * j not in check:
      print(i, j)
      time += 1
      if stop == time:
       break
    else:
     if C - j * j not in check:
      print(i, j)
      time += 1
      if stop == time:
       break
   if stop == time:
    break

Submission status: Runtime Error

Solution code:
N, C, D = map(int, input().split())
check = [i*i for i in range(N)]
time = 0
stop = N * N

if C * D % 2 ==1:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 0:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break
elif (C+D) % 2 == 0:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 1:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break

Submission status: Runtime Error

Solution code:
n,a,b,k = map(int,input().split())

Submission status: Runtime Error

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: Runtime Error

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: Runtime Error

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: Runtime Error

Solution code:
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())
#ans = 0
#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: Runtime Error

Solution code:
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())
ans = 0
#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: Runtime Error

Solution code:
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())
ans = 0
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: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)

n, a, b, k = map(int, input().split())

nmemo = [0 for i in range(n+1)]
def permutation(n):
    if nmemo[n] != 0:
        return nmemo[n]
    if n == 0:
        return 1
    nmemo[n] = n * permutation(n-1)
    return nmemo[n]


memo = []
ans = 0

for i in range(n + 1):
    knum = k - b * i
    if k < 0:
        break
    if knum % a == 0:
        if knum//a + i <= 2 * n:
            memo.append([knum // a, i])

for i in memo:
    nmin = min(i[0], i[1])
    jmin = 0
    if i[0] + i[1] > n:
        jmin = i[0] + i[1] - n
    for j in range(jmin, nmin+1):
        if (i[0] + i[1] - j) <= n:
            ans += permutation(n) // (permutation(i[0] - j) * permutation(i[1] - j)
                                      * permutation(j) * (permutation(n - (i[0] - j + i[1]))))

if k == 0:
    print(1)
else:
    print(ans % 998244353)

Submission status: Runtime Error

Solution code:
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())
ans = 0
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: Runtime Error

Solution code:
N = int(input())

min = 999999

A = 0
B = 0

for i in range(1, N/2):
    a = i
    b = N - i
    
    s = str(a)
    array = list(map(int, list(s)))
    suma = sum(array)
    
    s = str(b)
    array = list(map(int, list(s)))
    sumb = sum(array)

    aaa = suma + sumb
    if min > aaa:
        min = aaa   

print(min)

Submission status: Runtime Error

Solution code:
a=int(input())
s=0
while True:
    if 10**s < a:
        s +=1
    else:
        break
a1=a-10**s
alist=list(str(a1))
aintlist=map(int,alist)
aa=sum(aintlist)
print(s+aa)

Submission status: Runtime Error

Solution code:
N = int(input())
min = 999999
A = 0
B = 0
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

for i in range(1, N/2):
    a = i
    b = N - i
    if min > digitSum(a) + digitSum(b):
        min = digitSum(a) + digitSum(b)   

print(min)

Submission status: Runtime Error

Solution code:
N = int(input())

min = 999999

A = 0
B = 0

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



for i in range(1, N/2):
    a = i
    b = N - i

    if min > digitSum(a) + digitSum(b):
        min = digitSum(a) + digitSum(b)   

print(min)

Submission status: Runtime Error

Solution code:
min = 999999

A = 0
B = 0

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



for i in range(1, N/2):
    a = i
    b = N - i

    if min > digitSum(a) + digitSum(b):
        min = digitSum(a) + digitSum(b)   

print(min)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
import sys

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

def solve(n):
    ans = sys.maxint
    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: Runtime Error

Solution code:
import numpy as np
N =int(input())
ku = np.zeros((N, 2),dtype=int)

for i in range(N):
    l=list(map(int, input().split()))
    ku[i][0] = l[0]
    ku[i][1] = l[1]
    

K = 0
now=0
for i in range(N):
    a = np.zeros(len(ku))
    flag=np.zeros(len(ku))
    for j in range(len(ku)):
        if now > ku[j][0] and now < ku[j][1]:
            a[j] = 0
            flag[j]=0
        elif now < ku[j][0]:
            a[j] = abs(now - ku[j][0])
            flag[j]=1
        else:
            a[j] = abs(now - ku[j][1])
            flag[j]=2
    idx = a.argmax()
    K += a[idx]

    if flag[idx] == 1:
        now = ku[idx][0]
    elif flag[idx] == 2:
        now = ku[idx][1]
    ku= np.delete(ku, 0, 0)

K+=abs(now)
print(int(K))

Submission status: Runtime Error

Solution code:
N=int(input())

a=N//100000
A=N-a*100000

b=A//10000
B=A-b*10000

c=B//1000
C=B-c*1000

d=C//100
D=C-d*100

e=D//10
f=D-e*10

sum01=a+b+c+d+e+f

if sum01=>2:
    print(sum01)
else:
    print(10)

Submission status: Runtime Error

Solution code:

N=int(input())

a=N//100000
b=(N-a*100000)//10000
c=(N-a*100000-b*10000)//1000
d=(N-a*100000-b*10000-c*1000)//100
e=(N-a*100000-b*10000-c*1000-d*100)//10
f=(N-a*100000-b*10000-c*1000-d*100-e*10)

sum01=a+b+c+d+e+f

if sum01=>2:
    print(sum01)
else:
    print(10)

Submission status: Runtime Error

Solution code:
N = int(input())
c_list = []
if N % 2 ==0:
    for i in range(1, int(N/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
else:
    for i in range(1, int((N+1)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
print(min(c_list))

Submission status: Runtime Error

Solution code:
N = int(input())
c_list = []
if N % 2 ==0:
    for i in range(1, int(N/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
else:
    for i in range(1, int((N-1)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
print(min(c_list))

Submission status: Runtime Error

Solution code:
N = int(raw_input())
ans = 1000000
for A in range(1, 1+N/2):
  B = N - A
  a = 0
  b = 0
  for i in range(6)[::-1]:
    ta = tA/10**i
    tb = tB/10**i
    a += ta
    b += tb
    A -= ta*(10**i)
    B -= tb*(10**i)
  ans = min(ans, a+b)
print ans

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
N = int(input())

sums =[]
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)))))
    sums.append(a_sum+b_sum)

print(min(sums))

Submission status: Runtime Error

Solution code:
n = int(input())

ans = list()

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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n;
    cin >> n;
    li res = INF;
    repp(i, 1, n) {
        li tres = 0;
        li j = n - i;
        stringstream ssi;
        ssi << i;
        stringstream ssj;
        ssj << j;
        for (char c : ssi.str()) {
            tres += c - '0';
        }
        for (char c : ssj.str()) {
            tres += c - '0';
        }
        res = min(res, tres);
    }
    cout << res << endl;

    return 0;
}