Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
for i in range(1,10):
    for j in range(1, 10):
        print i + "x" + j "=" +i*j

Fixed submission:
for i in range(1, 10):
     for j in range(1,10):
         print str(i) + "x" + str(j) + "=" + str(i*j)

Buggy python submission (verdict: Runtime Error):
for i in range(1,10):
    for j in range(1, 10):
        print i + "x" + j "=" + i*j

Fixed submission:
for i in range(1, 10):
     for j in range(1,10):
         print str(i) + "x" + str(j) + "=" + str(i*j)

Buggy python submission (verdict: Runtime Error):
for i in range(1,10):
    for j in range(1, 10):
        print i + "x" + j + "=" + i*j

Fixed submission:
for i in range(1, 10):
     for j in range(1,10):
         print str(i) + "x" + str(j) + "=" + str(i*j)

Buggy python submission (verdict: Runtime Error):
for i in range(1,10):
    for j in range(1, 10):
        print str(i) + "x" + str(j) "=" + str(i*j)

Fixed submission:
for i in range(1, 10):
     for j in range(1,10):
         print str(i) + "x" + str(j) + "=" + str(i*j)
Buggy python submission (verdict: Runtime Error):
while(check):
    line = raw_input()
    s = line.rstrip().split()
    for i in range(6):
        s[i] = int(s[i])
    print (s[2]*s[4] - s[1]*s[5])/(s[0]*s[4] - s[1]*s[3]), (s[1]*s[5] - s[3]*s[2]) / (s[0]*s[4] - s[1]*s[3])

Fixed submission:
# -*- coding: utf-8 -*-

while True:
    try:
        list = [float(x) for x in raw_input().split() ]
        x = (list[2]*list[4]-list[1]*list[5])/(list[0]*list[4]-list[1]*list[3])+0
        y = (list[0]*list[5]-list[2]*list[3])/(list[0]*list[4]-list[1]*list[3])+0

        print("%.3f %.3f" %(x, y))

    except EOFError:
        break

Buggy python submission (verdict: Runtime Error):
while(True):
    line = raw_input()
    s = line.rstrip().split()
    for i in range(6):
        s[i] = int(s[i])
    print (s[2]*s[4] - s[1]*s[5])/(s[0]*s[4] - s[1]*s[3]), (s[1]*s[5] - s[3]*s[2]) / (s[0]*s[4] - s[1]*s[3])

Fixed submission:
# -*- coding: utf-8 -*-

while True:
    try:
        list = [float(x) for x in raw_input().split() ]
        x = (list[2]*list[4]-list[1]*list[5])/(list[0]*list[4]-list[1]*list[3])+0
        y = (list[0]*list[5]-list[2]*list[3])/(list[0]*list[4]-list[1]*list[3])+0

        print("%.3f %.3f" %(x, y))

    except EOFError:
        break

Buggy python submission (verdict: Runtime Error):
while(True):
    line = input()
    s = line.rstrip().split()
    for i in range(6):
        s[i] = int(s[i])
    print (s[2]*s[4] - s[1]*s[5])/(s[0]*s[4] - s[1]*s[3]), (s[1]*s[5] - s[3]*s[2]) / (s[0]*s[4] - s[1]*s[3])

Fixed submission:
# -*- coding: utf-8 -*-

while True:
    try:
        list = [float(x) for x in raw_input().split() ]
        x = (list[2]*list[4]-list[1]*list[5])/(list[0]*list[4]-list[1]*list[3])+0
        y = (list[0]*list[5]-list[2]*list[3])/(list[0]*list[4]-list[1]*list[3])+0

        print("%.3f %.3f" %(x, y))

    except EOFError:
        break
Buggy python submission (verdict: Runtime Error):

line = raw_input()

print line.reverse()

Fixed submission:

line = raw_input()
print line[::-1]
Buggy python submission (verdict: Runtime Error):
def solve(X, Y, Z, V, E, A):
    dp = [[0.0] * 6001 for _ in range(Y + max(V) + 1)]
    dp[0][0] = 1.0
    for i in range(Y):
        for j in range(5001):
            if dp[i][j] <= 0.0:
                continue
            for k in V:
                t = i + k
                if t > Y:
                    dp[Y][j] += dp[i][j]/X
                elif E[t] == 1:
                    dp[min(Y, t+A[t])][j] += dp[i][j]/X
                else:
                    dp[t][max(0, j+A[t])] += dp[i][j]/X

    s = 0
    for i in range(5001):
        if dp[Y][i] <= 0.0:
            continue
        s += i * dp[Y][i]
    print int(s)

if __name__ == "__main__":
    import sys

    while True:
        X, Y, Z = map(int, input().split())
        if X | Y | Z == 0:
            sys.exit()
        V = map(int, input().split())
        E = [0] * 100
        A = [0] * 100
        for _ in range(Z):
            n, e, a = map(int, input().split())
            E[n] = e
            if e == 3:
                A[n] = -a
            else:
                A[n] = a
        solve(X, Y, Z, V, E, A)

Fixed submission:
def solve(X, Y, Z, V, E, A):
    dp = [[0.0] * 6001 for _ in range(Y + 11)]
    dp[0][0] = 1.0
    for i in range(Y):
        for j in range(5001):
            if dp[i][j] <= 0.0:
                continue
            for k in V:
                t = i + k
                if t > Y:
                    dp[Y][j] += dp[i][j]/X
                elif E[t] == 1:
                    dp[min(Y, t+A[t])][j] += dp[i][j]/X
                else:
                    dp[t][max(0, j+A[t])] += dp[i][j]/X

    s = 0
    for i in range(5001):
        s += i * dp[Y][i]
    print(int(s))

if __name__ == "__main__":

    while True:
        X, Y, Z = map(int, input().split())
        if X | Y | Z == 0:
            break
        V = list(map(int, input().split()))
        E = [0] * 100
        A = [0] * 100
        for _ in range(Z):
            n, e, a = map(int, input().split())
            E[n] = e
            if e == 3:
                A[n] = -a
            else:
                A[n] = a
        solve(X, Y, Z, V, E, A)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
if __name__ == "__main__":
import sys
    dp = [0.0] * 100001
    dp[1] = 1.0
    for i in xrange(2, 100001):
        p = 1.0
        w = 0.5
        for j in xrange(1,i):
            if p < 1e-13:
                break
            dp[i] += (p*(1-w))*(j+dp[max(0,i-j-1)])
            p *= w
            w *= 0.5
        dp[i] += i*p
    while True:
        N = int(raw_input())
        if N == 0:
            sys.exit()
        print "%.8f" % dp[N]

Fixed submission:
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    import sys
    dp = [0.0] * 100001
    dp[1] = 1.0
    for i in xrange(2, 100001):
        p = 1.0
        w = 0.5
        for j in xrange(1,i):
            if p < 1e-13:
                break
            dp[i] += (p*(1-w))*(j+dp[max(0,i-j-1)])
            p *= w
            w *= 0.5
        dp[i] += i*p
    while True:
        N = int(raw_input())
        if N == 0:
            sys.exit()
        print "%.8f" % dp[N]
Buggy python submission (verdict: Runtime Error):
import sys
k=int(input())
n0 =input().split()
n=list(map(int,n0))
a=[]
for i in range(k-1,-1,-1):
    a.append(n[i])
for i in a:
    if i == a[k-1]:
        print(str(i))
    else:
        print(str(i)+' ', end="")
            

Fixed submission:
raw_input()
l = raw_input().split()
l.reverse()
print " ".join(l)

Buggy python submission (verdict: Runtime Error):
import sys
k=int(input())
str_n =input().split()
n=list(map(int,str_n))
a=[]
for i in range(k-1,-1,-1):
    a.append(n[i])
for i in a:
    if i != a[k-1]:
        print(str(i)+' ', end="")
    else:
        print(str(i))
     

Fixed submission:
raw_input()
l = raw_input().split()
l.reverse()
print " ".join(l)

Buggy python submission (verdict: Runtime Error):
import sys
k=int(input())
str_n =input().split()
n=list(map(int,str_n))
a=[]
for i in range(k-1,-1,-1):
    a.append(n[i])
for i in a:
    if i != a[k-1]:
        print(str(i), end=" ")
    else:
        print(str(i))
     

Fixed submission:
raw_input()
l = raw_input().split()
l.reverse()
print " ".join(l)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

while(True):
	try:
		a, b=map(int, input().split())
		
		gcd=0
		for i in range(a):
			if(a%i==0 and b%i==0):
				gcd=i
		lcm=a*b/gcd

		print("{0} {1}".format(gcd, lcm))

	except EOFError:
		break

Fixed submission:
#!/usr/bin/env python3

while(True):
	try:
		a,b=map(int, input().split())
	except EOFError:
		break

	#euclidian algorithm	
	r=a%b
	x,y=a,b
	while(r>0):
		x=y
		y=r
		r=x%y
	gcd=y
	lcm=int(a*b/gcd)
	print("{0} {1}".format(gcd, lcm))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

while(True):
	try:
		a, b=map(int, input().split())
	except EOFError:
		break

	gcd=0
	for i in range(a):
		if(a%i==0 and b%i==0):
			gcd=i
	lcm=a*b/gcd
	print("{0} {1}".format(gcd, lcm))

Fixed submission:
#!/usr/bin/env python3

while(True):
	try:
		a,b=map(int, input().split())
	except EOFError:
		break

	#euclidian algorithm	
	r=a%b
	x,y=a,b
	while(r>0):
		x=y
		y=r
		r=x%y
	gcd=y
	lcm=int(a*b/gcd)
	print("{0} {1}".format(gcd, lcm))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

while(True):
	try:
		a,b=map(int, input().split())
	except EOFError:
		break
	gcd=1
	for i in range(1, a):
		if(a%i==0 and b%i==0):
			gcd=i
	lcm=int(a*b/gcd)
	print("{0} {1}".format(gcd, lcm))

Fixed submission:
#!/usr/bin/env python3

while(True):
	try:
		a,b=map(int, input().split())
	except EOFError:
		break

	#euclidian algorithm	
	r=a%b
	x,y=a,b
	while(r>0):
		x=y
		y=r
		r=x%y
	gcd=y
	lcm=int(a*b/gcd)
	print("{0} {1}".format(gcd, lcm))
Buggy python submission (verdict: Runtime Error):
class Sequence:
    def __init__(self,num, seq):
        self.n = num
        self.sequence = seq

def LinearSearch(A, n, key):
    i=0
    A[n] = key
    while A[i] != key:
        i += 1
    if i==n:
        return "NOT_FOUND"
    return i

if __name__ == "__main__":
    with open("LinearSearch.txt") as fp:
        data = fp.readlines()

    x = data[1].split()
    x.append(" ")
    A = Sequence(int(data[0]), x)
    x = data[3].split()
    x.append(" ")
    B = Sequence(int(data[2]), x)

    C = []

    for i in range(B.n):
        res = LinearSearch(A.sequence, A.n, B.sequence[i])
        if res != "NOT_FOUND":
            C.append(A.sequence[res])

    print(C)

Fixed submission:
class Sequence:
    def __init__(self,num, seq):
        self.n = num
        self.sequence = seq

def LinearSearch(A, n, key):
    i=0
    A[n] = key
    while A[i] != key:
        i += 1
    if i==n:
        return "NOT_FOUND"
    return i

if __name__ == "__main__":

    n = int(raw_input())
    x =	map(int, raw_input().split())
    x.append(" ")
    A = Sequence(n, x)
    n =	int(raw_input())
    x =	map(int, raw_input().split())
    x.append(" ")
    B = Sequence(n, x)

    C_num = 0

    for i in range(B.n):
        res = LinearSearch(A.sequence, A.n, B.sequence[i])
        if res != "NOT_FOUND":
            C_num += 1

    print(C_num)
Buggy python submission (verdict: Runtime Error):
def main():
    while True:
        input_line = raw_input()
        num1 = int(input_line.split(' ')[0])
        num2 = int(input_line.split(' ')[1])
        
        sum = str(num1 + num2)
        
        count = 0
        for num in sum:
            count += 1
        else:
            print(count)
    
if __name__ == '__main__':
    main()

Fixed submission:
import sys

def main():
    for input_line in sys.stdin:
        num1 = int(input_line.split(' ')[0])
        num2 = int(input_line.split(' ')[1])
        
        sum = str(num1 + num2)
        
        count = 0
        for num in sum:
            count += 1
        else:
            print(count)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys

def main():
    for input_line in sys.stdin:
        num1 = int(input_line.split(' ')[0])
        num2 = int(input_line.split(' ')[1])
        
        if num1 <= num2:
            dividend(num1, num2, num1)
        elif num1 > num2:
            dividend(num1, num2, num2)
            
        result.sort(reverse=True)
        greatest_common_divisor = result[0]
        least_common_multiple = num1 * num2 / greatest_common_divisor
        
        print('%s %s' % (greatest_common_divisor, least_common_multiple))
        
def dividend(num1, num2, num):
    for i in range(num).sort(reverse=True):
        divisor = i+1
        if num1 % divisor == 0 and num2 % divisor == 0:
            result.append(divisor)
            break
        
if __name__ == '__main__':
    result = []
    main()

Fixed submission:
import sys

def dividend(num, Q):
    a = Q
    b = (num / Q) * Q
    Q = num - (num / Q) * Q
    if num  == b:
        aaa(a)
        return
    dividend(a, Q)
    
def aaa(greatest_common_divisor):
    least_common_multiple = num1 * num2 / greatest_common_divisor
    print('%s %s' % (greatest_common_divisor, least_common_multiple))
    return

for input_line in sys.stdin:
    num1 = int(input_line.split(' ')[0])
    num2 = int(input_line.split(' ')[1])
    
    if num1 <= num2:
        dividend(num2, num1)
    elif num1 > num2:
        dividend(num1, num2)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())

for _ in range(N):
    a = int(input())
    b = int(input())
    s = str(a + b)
    limit = '1' + '0'*79
    if len(s) <= limit:
        print(s)
    else:
        print('overflow')

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())

for _ in range(N):
    a = int(input())
    b = int(input())
    s = str(a + b)
    if len(s) <= 80:
        print(s)
    else:
        print('overflow')
Buggy python submission (verdict: Runtime Error):
import sys

for input_line in sys.stdin:
    input_line = raw_input().split()
    input_line.sort(reverse=True)
    print ' '.join(input_line)

Fixed submission:
import sys

for input_line in sys.stdin:
    input_line = input_line.split()
    input_line = [int(char) for char in input_line]
    input_line.sort(reverse=True)
    input_line = [str(num) for num in input_line]
    print ' '.join(input_line)
Buggy python submission (verdict: Time Limit Exceeded):
def check():
    count1 = 0
    for i in range(4):
        if A[i] == B[i]:
            count1 += 1
    count2 = 0
    for v in B:
        if v in A:
            count2 += 1
    Hit = count1
    Blow = count2 - count1
    
    print Hit, Blow
    
while True:
    try:
        A = list(raw_input().split())
        B = list(raw_input().split())
        check()
    except EOFError:
        pass

Fixed submission:
def check():
    count1 = 0
    for i in range(4):
        if A[i] == B[i]:
            count1 += 1
    count2 = 0
    for v in B:
        if v in A:
            count2 += 1
    Hit = count1
    Blow = count2 - count1
    
    print Hit, Blow
    
while True:
    try:
        A = list(raw_input().split())
        B = list(raw_input().split())
        check()
    except EOFError:
        break
Buggy python submission (verdict: Runtime Error):
def brain(l):
    c = l[1] - l[0]
    if 0 < c:
        result.append(c)
        del lis[0]
        del lis[0]
    else:
        lis.append(l[0])
        del lis[0]
        
def cisco(l):
    for i in range(len(l)):
        if l[i] == 'I':
            l[i] = 1
        elif l[i] == 'V':
            l[i] = 5
        elif l[i] == 'X':
            l[i] = 10
        elif l[i] == 'L':
            l[i] = 50
        elif l[i] == 'C':
            l[i] = 100
        elif l[i] == 'D':
            l[i] = 500
        elif l[i] == 'M':
            l[i] = 1000
    return l

while True:
    result = []
    try:
        lis = list(raw_input())+['*']
        while lis:
            if not (lis[0] == '*' or lis[1] == '*'):
                l = cisco([lis[0], lis[1]])
                brain(l)
            else:
                lis.append(lis[0])
                del lis[0]
                del lis[0]
                break
        result.append(sum(cisco(lis)))
        print sum(result)
    except EOFError:
        break

Fixed submission:
def brain(l):
    c = l[1] - l[0]
    if 0 < c:
        result.append(c)
        del lis[0]
        del lis[0]
    else:
        lis.append(l[0])
        del lis[0]
        
def cisco(l):
    for i in range(len(l)):
        if l[i] == 'I':
            l[i] = 1
        elif l[i] == 'V':
            l[i] = 5
        elif l[i] == 'X':
            l[i] = 10
        elif l[i] == 'L':
            l[i] = 50
        elif l[i] == 'C':
            l[i] = 100
        elif l[i] == 'D':
            l[i] = 500
        elif l[i] == 'M':
            l[i] = 1000
    return l

while True:
    result = []
    try:
        lis = list(raw_input())+['*']
        while lis:
            if not (lis[0] == '*' or lis[1] == '*'):
                l = cisco([lis[0], lis[1]])
                brain(l)
            elif lis[0] == '*':
                del lis[0]
                break
            elif lis[1] == '*':
                l = cisco([lis[0]])
                lis.append(l[0])
                del lis[0]
                del lis[0]
                break
        result.append(sum(lis))
        print sum(result)
    except EOFError:
        break
Buggy python submission (verdict: Runtime Error):
import sys

def suicide(lis):
    if len(lis) == 1:
        print lis[0]
    pokakito = []
    for i in range(len(lis)-1):
        check = lis[i] + lis[i+1]
        one = int(str(check)[-1])
        pokakito.append(one)
    else:
        suicide(pokakito)

for line in sys.stdin:
    lis = [int(char) for char in line.rstrip()]
    suicide(lis)

Fixed submission:
def suicide(lis):
    if len(lis) == 1:
        print lis[0]
        return
    pokakito = []
    for i in range(len(lis)-1):
        check = lis[i] + lis[i+1]
        one = int(str(check)[-1])
        pokakito.append(one)
    else:
        suicide(pokakito)

while True:
    try:
        lis = [int(char) for char in raw_input()]
        suicide(lis)
    except EOFError:
        break

Buggy python submission (verdict: Runtime Error):
def suicide(lis):
    if len(lis) == 1:
        print lis[0]
    pokakito = []
    for i in range(len(lis)-1):
        check = lis[i] + lis[i+1]
        one = int(str(check)[-1])
        pokakito.append(one)
    else:
        suicide(pokakito)

while True:
    try:
        lis = [int(char) for char in raw_input()]
        suicide(lis)
    except EOFError:
        break

Fixed submission:
def suicide(lis):
    if len(lis) == 1:
        print lis[0]
        return
    pokakito = []
    for i in range(len(lis)-1):
        check = lis[i] + lis[i+1]
        one = int(str(check)[-1])
        pokakito.append(one)
    else:
        suicide(pokakito)

while True:
    try:
        lis = [int(char) for char in raw_input()]
        suicide(lis)
    except EOFError:
        break
Buggy python submission (verdict: Time Limit Exceeded):
count = 0
while True:
    try:
        s_lis1 = list(raw_input())
        s_lis2 = s_lis1[:]
        s_lis2.reverse()
        if s_lis1 == s_lis2:
            count += 1
    except EOFError:
        print count

Fixed submission:
count = 0
while True:
    try:
        s_lis1 = list(raw_input())
        s_lis2 = s_lis1[:]
        s_lis2.reverse()
        if s_lis1 == s_lis2:
            count += 1
    except EOFError:
        print count
        break
Buggy python submission (verdict: Runtime Error):
while True:
    N = int(input())
    if N == 0:
        break
    d = {}
    for n in range(N):
        num, p, q = map(int, input().split())
        if num in d:
            d[num][1] += (p*q) 
        else:
            d[num] = [n, p*q]
    else:
        fla = False
        for k, v in sorted(d.items(), key=lambda x[1][0]):
            if v[1] >= 1000000:
                print(k)
                fla = True
        else:
            if not fla:
                print('NA')

Fixed submission:
while True:
    N = int(input())
    if N == 0:
        break
    d = {}
    for n in range(N):
        num, p, q = map(int, input().split())
        if num in d:
            d[num][1] += (p*q)
        else:
            d[num] = [n, p*q]
    else:
        fla = False
        for k, v in sorted(d.items(), key=lambda x: x[1][0]):
            if v[1] >= 1000000:
                print(k)
                fla = True
        else:
            if not fla:
                print('NA')
Buggy python submission (verdict: Runtime Error):
while True:
    try:
        N = int(raw_input())
        p = 0
        b = [0,0,0]
        o = 0
        for i in range(N):
            e = raw_input()
            if e == 'HIT':
                if b[-1] == 1:
                    p += 1
                b[0],b[1],b[2] = 1,b[0],b[1]
            elif e == 'HOMERUN':
                p += sum(b)+1
                b = [0,0,0]
            elif e == 'OUT':
                o += 1
                if o == 3:
                    print p
                    p = 0
                    b = [0,0,0]
                    o = 0
    except EOFError:
        break

Fixed submission:
for i in range(int(input())):
    point = 0
    out = 0
    runner = [0, 0, 0]
    while True:
        event = input()
        if event == 'HIT':
            if runner[2] == 1:
                point += 1
                runner[2] = 0
            if runner[1] == 1:
                runner[2] = 1
                runner[1] = 0
            if runner[0] == 1:
                runner[1] = 1
            runner[0] = 1
        elif event == 'HOMERUN':
            point += (sum(runner)+1)
            runner = [0, 0, 0]
        elif event == 'OUT':
            out += 1
            if out == 3:
                print(point)
                break

Buggy python submission (verdict: Runtime Error):
for i in range(int(input())):
    point = 0
    out = 0
    runner = [0, 0, 0]
    while True:
        event = input()
        if event == 'HIT':
            if runner[2] == 1:
                point += 1
            if runner[1] == 1:
                runner[2] = 1
            if runner[0] == 1:
                runner[1] = 1
            runner[0] = 1
        elif event == 'HOMERUN':
            point += (sum(runner)+1)
        elif event == 'OUT':
            out += 1
            if out == 3:
                print(point)

Fixed submission:
for i in range(int(input())):
    point = 0
    out = 0
    runner = [0, 0, 0]
    while True:
        event = input()
        if event == 'HIT':
            if runner[2] == 1:
                point += 1
                runner[2] = 0
            if runner[1] == 1:
                runner[2] = 1
                runner[1] = 0
            if runner[0] == 1:
                runner[1] = 1
            runner[0] = 1
        elif event == 'HOMERUN':
            point += (sum(runner)+1)
            runner = [0, 0, 0]
        elif event == 'OUT':
            out += 1
            if out == 3:
                print(point)
                break
Buggy python submission (verdict: Runtime Error):
for line in open('s.txt').readlines():
    n = ''
    lis = []
    for c in line.rstrip():
        if c.isdigit() or c == 'X':
            n += c
        elif c == '+':
            lis.append(n)
            n = ''
        elif c == '=':
            lis.append(n)
            n = ''
    else:
        lis.append(n)
     
    c_lis = lis[:]   
    for n in range(10):
        for i, v in enumerate(lis):
            if 'X' in v:
                c_lis[i] = c_lis[i].replace('X', str(n))
        else:
            flag = False
            if n == 0:
                for v in c_lis:
                    if len(v) >= 2 and v[0] == '0':
                        flag = True
                        break
            if not flag:
                if int(c_lis[0]) + int(c_lis[1]) == int(c_lis[2]):
                    print n
                    break
            c_lis = lis[:]
    else:
        print 'NA'

Fixed submission:
import sys

for line in sys.stdin:
    n = ''
    lis = []
    for c in line.rstrip():
        if c.isdigit() or c == 'X':
            n += c
        elif c == '+':
            lis.append(n)
            n = ''
        elif c == '=':
            lis.append(n)
            n = ''
    else:
        lis.append(n)
     
    c_lis = lis[:]   
    for n in range(10):
        for i, v in enumerate(lis):
            if 'X' in v:
                c_lis[i] = c_lis[i].replace('X', str(n))
        else:
            flag = False
            if n == 0:
                for v in c_lis:
                    if len(v) >= 2 and v[0] == '0':
                        flag = True
                        break
            if not flag:
                if int(c_lis[0]) + int(c_lis[1]) == int(c_lis[2]):
                    print n
                    break
            c_lis = lis[:]
    else:
        print 'NA'