Buggy python submission (verdict: Runtime Error):

import sys


def solv(s):
    left, right = s.split('=')
    for i in range(10):
        l = left.replace('X', str(i))
        r = right.replace('X', str(i))
        if eval(l) == int(r):
            return str(i)
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))

Fixed submission:

import sys


def solv(s):
    for i in range(10):
        i = str(i)
        s2 = s.replace('X', i)
        left, right = s2.split('=')
        l1, l2 = left.split('+')
        if any([x[0] == '0' and len(x) > 1 for x in [l1, l2, right]]):
            continue
        if int(l1) + int(l2) == int(right):
            return i
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))

Buggy python submission (verdict: Runtime Error):

import sys


def solv(s):
    left, right = s.split('=')
    for i in range(10):
        l = left.replace('X', str(i))
        r = right.replace('X', str(i))
        if eval(l) == int(r):
            return str(i)
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))

Fixed submission:

import sys


def solv(s):
    for i in range(10):
        i = str(i)
        s2 = s.replace('X', i)
        left, right = s2.split('=')
        l1, l2 = left.split('+')
        if any([x[0] == '0' and len(x) > 1 for x in [l1, l2, right]]):
            continue
        if int(l1) + int(l2) == int(right):
            return i
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))

Buggy python submission (verdict: Runtime Error):

import sys


def solv(s):
    left, right = s.split('=')
    for i in range(10):
        l = left.replace('X', str(i))
        r = right.replace('X', str(i))
        l1, l2 = l.split('+')
        if l1[0] == '0' or l2[0] == '0' or r[0] == '0':
            next
        if eval(l) == int(r):
            return str(i)
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))

Fixed submission:

import sys


def solv(s):
    for i in range(10):
        i = str(i)
        s2 = s.replace('X', i)
        left, right = s2.split('=')
        l1, l2 = left.split('+')
        if any([x[0] == '0' and len(x) > 1 for x in [l1, l2, right]]):
            continue
        if int(l1) + int(l2) == int(right):
            return i
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))

Buggy python submission (verdict: Runtime Error):

import sys


def solv(s):
    left, right = s.split('=')
    for i in range(10):
        i = str(i)
        l = left.replace('X', i)
        r = right.replace('X', i)
        l1, l2 = l.split('+')
        if l1[0] == '0' or l2[0] == '0' or r[0] == '0':
            next
        if eval(l) == int(r):
            return i
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))

Fixed submission:

import sys


def solv(s):
    for i in range(10):
        i = str(i)
        s2 = s.replace('X', i)
        left, right = s2.split('=')
        l1, l2 = left.split('+')
        if any([x[0] == '0' and len(x) > 1 for x in [l1, l2, right]]):
            continue
        if int(l1) + int(l2) == int(right):
            return i
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))

Buggy python submission (verdict: Runtime Error):

import sys


def solv(s):
    left, right = s.split('=')
    for i in range(10):
        i = str(i)
        l = left.replace('X', i)
        r = right.replace('X', i)
#        l1, l2 = l.split('+')
#        if i == '0' and (l1[0] == '0' or l2[0] == '0' or r[0] == '0'):
#            continue
        if eval(l) == int(r):
            return i
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))

Fixed submission:

import sys


def solv(s):
    for i in range(10):
        i = str(i)
        s2 = s.replace('X', i)
        left, right = s2.split('=')
        l1, l2 = left.split('+')
        if any([x[0] == '0' and len(x) > 1 for x in [l1, l2, right]]):
            continue
        if int(l1) + int(l2) == int(right):
            return i
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))