qyliang/CodeNanoFix huggingface dataset:
Buggy 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)

Fixed code:
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)
Buggy code:
N = int(input())

t = N
SUM_N = 0
non_list = [10,100,1000,10000]
if N not in non_list:
    while t!=0:
        SUM_N  += t%10
        t //= 10
    print(SUM_N)
else:
    print(10)

Fixed code:
N = int(input())

t = N
SUM_N = 0
non_list = [10,100,1000,10000,100000]
if N not in non_list:
    while t!=0:
        SUM_N  += t%10
        t //= 10
    print(SUM_N)
else:
    print(10)
Buggy code:
s=input()
res=0
flag=s[0]=="1"
for c in s[1:]:
 res+=int(c)
 if c!="0":
  flag=False
if flag:
 print(10)
else:
 print(res)

Fixed code:
s=input()
res=int(s[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)
Buggy code:
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(N):
    B = N - A
    val = digit_sum(A) + digit_sum(B)
    min_ = min(min_, val)

print(min_)


Fixed code:
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_)
Buggy code:
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))

Fixed code:
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)
Buggy code:
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)

Fixed code:
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)
Buggy code:
def wa(t):
    sum=0
    while t>0:
       sum+=t%10
       t//=10
    return sum

n=int(input())
ans=[]
for i in range(1,n+1):
    ans.append(wa(i)+wa(n-i)) 
print(min(ans))

Fixed code:
def wa(t):
    sum=0
    while t>0:
       sum+=t%10
       t//=10
    return sum

n=int(input())
ans=[]
for i in range(1,n):
    ans.append(wa(i)+wa(n-i)) 
    if wa(i)+wa(n-i)==1:
        print(i)
print(min(ans))
Buggy code:
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)]))

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

min_=100000

for i in range(1, N):
    for j in range(1, N):
        sum_i=0
        sum_j=0
        if i + j == N:
            tmp_i=i
            tmp_j=j
            while tmp_i > 0:
                sum_i += tmp_i % 10
                tmp_i = tmp_i // 10
            while tmp_j > 0:
                sum_j += tmp_j % 10
                tmp_j = tmp_j // 10
            min_=min(min_, sum_i+sum_j)



print(min_)

Fixed code:
N=int(input())

min_=100000

for i in range(1, N//2+1):
    j=N-i
    sum_i=0
    sum_j=0
    tmp_i=i
    tmp_j=j
    while tmp_i  > 0:
        sum_i += tmp_i % 10
        tmp_i = tmp_i // 10
    while tmp_j > 0:
        sum_j += tmp_j % 10
        tmp_j = tmp_j // 10
    min_=min(min_, sum_i+sum_j)

print(min_)
Buggy 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)
        

Fixed code:
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)
Buggy 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)

Fixed 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
        res = min(res, sum_)
print(res)
Buggy code:
#!/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()


Fixed code:
#!/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()
Buggy code:
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)

Fixed code:
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)
Buggy code:
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)

Fixed code:
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)
Buggy code:
N=int(input())

M=10**9
for i in range(1,N//2+10):
    a=list(str(i))
    b=list(str(N-i))
    #print(a,b)
    k=0
    for q in range(len(a)):
        k+=int(a[q])
    for p in range(len(b)):
        k+=int(b[p])
    M=min(M,k)
print(M)

Fixed code:
N=int(input())

M=10**9
for i in range(1,N//2+1):
    a=list(str(i))
    b=list(str(N-i))
    #print(a,b)
    k=0
    for q in range(len(a)):
        k+=int(a[q])
    for p in range(len(b)):
        k+=int(b[p])
    M=min(M,k)
print(M)
Buggy code:
n = input()
num = 0
for num in n:
    ans += int(num)
if ans == 1:
    ans = 10
print(ans)

Fixed code:
n = input()
ans = 0
for num in n:
    ans += int(num)
if ans == 1:
    ans = 10
print(ans)
Buggy code:
# A - Digits Sum

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

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

print(ans)

Fixed code:
# A - Digits Sum

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

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

print(ans)
Buggy code:
n = int(input())
ans = inf
def f(x):
    cur = 0
    while x >0:
        cur += x % 10
        x = x //10
    return cur
for a in range(1,n):
    b = n-a
    ans = min(ans,f(a)+f(b))
print(ans)


Fixed code:
inf = 10**10

n = int(input())
ans = inf
def f(x):
    cur = 0
    while x >0:
        cur += x % 10
        x = x //10
    return cur
for a in range(1,n):
    b = n-a
    ans = min(ans,f(a)+f(b))
print(ans)
Buggy code:
import math

def ten_sum(n):
    s = 0
    while n > 0:
        s += n % 10
        n = math.floor(n / 10)
    return s

lst = []
N = int(input())
for A in range(0, N + 1):
    lst.append(ten_sum(A) + ten_sum(N - A))


print(min(lst))

Fixed code:
import math

def ten_sum(n):
    s = 0
    while n > 0:
        s += n % 10
        n = math.floor(n / 10)
    return s

lst = []
N = int(input())
for A in range(1, N):
    lst.append(ten_sum(A) + ten_sum(N - A))


print(min(lst))
Buggy 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)

Fixed code:
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)
Buggy code:
N = int(input())

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

min_num = 100000
for A in range(1, N):
  for B in range(1, N):
    if A + B != N:
      continue
    digit_num = digit_sum(A)
    digit_num += digit_sum(B)
    if digit_num < min_num:
      min_num = digit_num

print(min_num)

Fixed code:
N = int(input())

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

min_num = 100000
for A in range(1, N):
  B = N - A
  digit_num = digit_sum(A)
  digit_num += digit_sum(B)
  if digit_num < min_num:
    min_num = digit_num

print(min_num)
Buggy 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)

Fixed code:
n = int(input())
res = float('inf')
for a in range(1, 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)
Buggy code:
# -*- 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])

Fixed code:
# -*- 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
    # 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])
Buggy code:
n = int(input())
print(min([sum(map(int, str(i) + str(n - i))) for i in range((n + 1) // 2)]))


Fixed code:
n = int(input())
print(min([sum(map(int, str(i) + str(n - i))) for i in range(1, n // 2 + 1)]))
Buggy code:
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)


Fixed code:
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(1,N//2+1):
  minsum = min(minsum,sumof(i) + sumof(N-i))
print(minsum)
Buggy code:
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)
  

Fixed code:
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)
Buggy code:
def num(x):
	sum = 0
	while (x > 0):
		sum += x % 10
		x //= 10
	return sum

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

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

print(ans)

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

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

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

print(ans)
Buggy code:
# coding: utf-8
import math
n=int(input())-1
a=10**int(math.log10(n))
b=n-a+1
print(sum(map(int,str(a)))+sum(map(int,str(b))))
print(a,b)

Fixed code:
# coding: utf-8
import math
n=int(input())-1
a=10**int(math.log10(n))
b=n-a+1
print(sum(map(int,str(a)))+sum(map(int,str(b))))
Buggy code:
def SumReturn(num):
    total=0
    while num!=0:
        total += num%10
        num //= 10
        
    return total

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

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

if __name__ == '__main__':
    
    n = int(input())
    min = 10000
    
    for i in range(1,n):
        if(min > SumReturn(i)+SumReturn(n-i)):
            min = SumReturn(i)+SumReturn(n-i)
        
        
    print(min)
Buggy 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()
  

Fixed code:
def main():
  n = int(input())
  ans = 100000
  for i in range(1, (n+2)//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()
Buggy code:
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))


Fixed code:
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))
Buggy code:
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)

Fixed code:
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)
Buggy code:
N = int(input())
prev = 1000000
for i in range(1, N+1):
    ans = 0
    for j in str(i):
        ans += int(j)
    for j in str(N - i):
        ans += int(j)
    if prev > ans:
        prev = ans
print(prev)

Fixed code:
N = int(input())
prev = 1000000
for i in range(1, N):
    ans = 0
    for j in str(i):
        ans += int(j)
    for j in str(N - i):
        ans += int(j)
    if prev > ans:
        prev = ans
print(prev)
Buggy code:
n=int(input())

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


Fixed code:
n=int(input())

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

n = 1
ans = 10**5

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

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

Fixed code:
N = int(input())

n = 1
ans = 10**5

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

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

print(ans)
Buggy code:
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)

Fixed code:
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)
Buggy 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):
    for k in range(1, N - i + 1):
        if N == i + k:
            m = min(m, sumDigits(i) + sumDigits(k))

print(m)

Fixed 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
    m = min(m, sumDigits(i) + sumDigits(k))

print(m)
Buggy 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)

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

N = int(input())

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

print(m)
Buggy code:
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)

Fixed code:
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)
Buggy 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)


Fixed 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):
    B = N - A
    num = F(A) + F(B)
    if num < min_num:
        min_num = num
print(min_num)
Buggy code:
n = int(input())

minsum = 900000
for i in range(n):
    count = 0
    a = i
    b = n - i
    for c in str(a):
        count += int(c)
    for c in str(b):
        count += int(c)
    if count < minsum:
        minsum = count
print(count)

Fixed code:
n = int(input())

minsum = 900000

for i in range(n - 1):
    count = 0
    a = i +1
    b = n -i -1
    for c in str(a):
        count += int(c)
    for c in str(b):
        count += int(c)
    if count < minsum:
        minsum = count
print(minsum)
Buggy code:
N = int(input())

def sum_10(n):
  return sum[int(l) for l in str(n)]

li=[]
for i in range(1,N//2 +1):
  for k in range(N-N//2,N+1):
    if i + k == N:
      li.append(sum_10(i)+sum_10(k))
print(min(li))      

Fixed code:
N = int(input())

def sum_10(n):
  return sum([int(l) for l in str(n)])

li=[]
for i in range(1,N//2 +1):
    if N - N//2 <= N - i <= N:
      li.append(sum_10(i)+sum_10(N - i))
print(min(li))
Buggy code:
N = int(input())

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

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

print(ans)

Fixed code:
N = int(input())

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

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

print(ans)
Buggy 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))

Fixed code:
N=int(input())
li=[sum(list(map(int,str(a))))+sum(list(map(int,str(N-a)))) for a in range(1,N)]
print(min(li))
Buggy code:
x=int(input())
count=10000
suma=0
sumb=0
for a in range(1, x):
    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) 

Fixed code:
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)
Buggy code:
n = int(input())
l = []
for a in range(2,n+1):
        sum = 0
        sum1 = 0
        b = n - a
        for i in range(len(str(a))):
                sum += int(str(a)[i])
        for i in range(len(str(b))):
                sum1 += int(str(b)[i])
        l.append(sum+sum1)
print(min(l))

Fixed code:
n = int(input())
l = []
for a in range(1,n):
        sum = 0
        sum1 = 0
        b = n - a
        for i in range(len(str(a))):
                sum += int(str(a)[i])
        for i in range(len(str(b))):
                sum1 += int(str(b)[i])
        l.append(sum+sum1)
print(min(l))
Buggy code:
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))

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