Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
stmts = [input().split() for i in range(n)]

mapper = {}
for i, stmt in enumerate(stmts):
    mapper[stmt[0]] = i

vn = {}
for stmt in stmts:
    for ope in stmt[2:]:
        if ope.isalpha() and ope not in vn:
            vn[ope] = len(vn)
vs = [0]*len(vn)
def check(x):
    return 0 <= x < 16
def value(var):
    if var.isalpha():
        return vs[vn[var]]
    return int(var)
def assign(var, x):
    vs[vn[var]] = x

result = 1
state = set()
pc = 0
cnts = [0]*n
LIM = 16**5 + 10
while pc < n:
    cnts[pc] += 1
    if cnts[pc] > LIM:
        result = 0
        break
    stmt = stmts[pc]
    op = stmt[1]
    if op == 'ADD':
        v1, v2, v3 = stmt[2:]
        if not check(value(v2) + value(v3)):
            break
        assign(v1, value(v2) + value(v3))
        pc += 1
    elif op == 'SUB':
        v1, v2, v3 = stmt[2:]
        if not check(value(v2) - value(v3)):
            break
        assign(v1, value(v2) - value(v3))
        pc += 1
    elif op == 'SET':
        v1, v2 = stmt[2:]
        assign(v1, value(v2))
        pc += 1
    elif op == 'IF':
        v1, dest = stmt[2:]
        if value(v1) > 0:
            if dest not in mapper:
                break
            pc = mapper[dest]
        else:
            pc += 1
    elif op == 'HALT': # 'HALT'
        break
    else:
        assert 0
if result:
    for k in sorted(vn):
        print("%s=%d" % (k, vs[vn[k]]))
else:
    print("inf")

Fixed submission:
n = int(input())
stmts = [input().split() for i in range(n)]

mapper = {}
for i, stmt in enumerate(stmts):
    mapper[stmt[0]] = i

vn = {}
for stmt in stmts:
    for ope in stmt[2:]:
        if ope.isalpha() and ope not in vn:
            vn[ope] = len(vn)
vs = [0]*len(vn)
def stmt_add(v1, v2, v3):
    v1 = vn[v1]
    if v3.isdigit():
        v2 = vn[v2]
        const = int(v3)
        def run(pc):
            assert vs[v2] + const < 16
            vs[v1] = vs[v2] + const
            return pc+1
    else:
        v2 = vn[v2]
        v3 = vn[v3]
        def run(pc):
            assert vs[v2] + vs[v3] < 16
            vs[v1] = vs[v2] + vs[v3]
            return pc+1
    return run
def stmt_sub(v1, v2, v3):
    v1 = vn[v1]
    if v3.isdigit():
        v2 = vn[v2]
        const = int(v3)
        def run(pc):
            assert 0 <= vs[v2] - const
            vs[v1] = vs[v2] - const
            return pc+1
    else:
        v2 = vn[v2]
        v3 = vn[v3]
        def run(pc):
            assert 0 <= vs[v2] - vs[v3]
            vs[v1] = vs[v2] - vs[v3]
            return pc+1
    return run
def stmt_set(v1, v2):
    v1 = vn[v1]
    if v2.isdigit():
        v2 = int(v2)
        def run(pc):
            vs[v1] = v2
            return pc+1
    else:
        v2 = vn[v2]
        def run(pc):
            vs[v1] = vs[v2]
            return pc+1
    return run
def stmt_if(v1, dest):
    v1 = vn[v1]
    def run(pc):
        return mapper[dest] if vs[v1] else pc+1
    return run
def stmt_halt():
    def run(pc):
        return n
    return run
stmt_func = []
for i, stmt in enumerate(stmts):
    op = stmt[1]
    if op == 'ADD':
        stmt_func.append(stmt_add(*stmt[2:]))
    elif op == 'SUB':
        stmt_func.append(stmt_sub(*stmt[2:]))
    elif op == 'SET':
        stmt_func.append(stmt_set(*stmt[2:]))
    elif op == 'IF':
        stmt_func.append(stmt_if(*stmt[2:]))
    else:
        stmt_func.append(stmt_halt())

result = 1
pc = 0
cnts = [0]*n
LIM = 16**len(vn) + 10
try:
    while 1:
        run = stmt_func[pc]
        cnts[pc] += 1
        if cnts[pc] > LIM:
            result = 0
            break
        pc = run(pc)
except:...
if result:
    for k in sorted(vn):
        print("%s=%d" % (k, vs[vn[k]]))
else:
    print("inf")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
stmts = [input().split() for i in range(n)]

mapper = {}
for i, stmt in enumerate(stmts):
    mapper[stmt[0]] = i

vn = {}
for stmt in stmts:
    for ope in stmt[2:]:
        if ope.isalpha() and ope not in vn:
            vn[ope] = len(vn)
vs = [0]*len(vn)
def value(var):
    if var.isalpha():
        return vs[vn[var]]
    return int(var)
def assign(var, x):
    if not 0 <= x < 16:
        assert 0
    vs[vn[var]] = x

result = 1
state = set()
pc = 0
cnts = [0]*n
LIM = 16**len(vn) + 10
try:
    while 1:
        stmt = stmts[pc]
        cnts[pc] += 1
        if cnts[pc] > LIM:
            result = 0
            break
        op = stmt[1]
        if op == 'ADD':
            v1, v2, v3 = stmt[2:]
            assign(v1, value(v2) + value(v3))
            pc += 1
        elif op == 'SUB':
            v1, v2, v3 = stmt[2:]
            assign(v1, value(v2) - value(v3))
            pc += 1
        elif op == 'SET':
            v1, v2 = stmt[2:]
            assign(v1, value(v2))
            pc += 1
        elif op == 'IF':
            v1, dest = stmt[2:]
            if value(v1) > 0:
                pc = mapper[dest]
            else:
                pc += 1
        else: # 'HALT'
            break
except:...
if result:
    for k in sorted(vn):
        print("%s=%d" % (k, vs[vn[k]]))
else:
    print("inf")

Fixed submission:
n = int(input())
stmts = [input().split() for i in range(n)]

mapper = {}
for i, stmt in enumerate(stmts):
    mapper[stmt[0]] = i

vn = {}
for stmt in stmts:
    for ope in stmt[2:]:
        if ope.isalpha() and ope not in vn:
            vn[ope] = len(vn)
vs = [0]*len(vn)
def stmt_add(v1, v2, v3):
    v1 = vn[v1]
    if v3.isdigit():
        v2 = vn[v2]
        const = int(v3)
        def run(pc):
            assert vs[v2] + const < 16
            vs[v1] = vs[v2] + const
            return pc+1
    else:
        v2 = vn[v2]
        v3 = vn[v3]
        def run(pc):
            assert vs[v2] + vs[v3] < 16
            vs[v1] = vs[v2] + vs[v3]
            return pc+1
    return run
def stmt_sub(v1, v2, v3):
    v1 = vn[v1]
    if v3.isdigit():
        v2 = vn[v2]
        const = int(v3)
        def run(pc):
            assert 0 <= vs[v2] - const
            vs[v1] = vs[v2] - const
            return pc+1
    else:
        v2 = vn[v2]
        v3 = vn[v3]
        def run(pc):
            assert 0 <= vs[v2] - vs[v3]
            vs[v1] = vs[v2] - vs[v3]
            return pc+1
    return run
def stmt_set(v1, v2):
    v1 = vn[v1]
    if v2.isdigit():
        v2 = int(v2)
        def run(pc):
            vs[v1] = v2
            return pc+1
    else:
        v2 = vn[v2]
        def run(pc):
            vs[v1] = vs[v2]
            return pc+1
    return run
def stmt_if(v1, dest):
    v1 = vn[v1]
    def run(pc):
        return mapper[dest] if vs[v1] else pc+1
    return run
def stmt_halt():
    def run(pc):
        return n
    return run
stmt_func = []
for i, stmt in enumerate(stmts):
    op = stmt[1]
    if op == 'ADD':
        stmt_func.append(stmt_add(*stmt[2:]))
    elif op == 'SUB':
        stmt_func.append(stmt_sub(*stmt[2:]))
    elif op == 'SET':
        stmt_func.append(stmt_set(*stmt[2:]))
    elif op == 'IF':
        stmt_func.append(stmt_if(*stmt[2:]))
    else:
        stmt_func.append(stmt_halt())

result = 1
pc = 0
cnts = [0]*n
LIM = 16**len(vn) + 10
try:
    while 1:
        run = stmt_func[pc]
        cnts[pc] += 1
        if cnts[pc] > LIM:
            result = 0
            break
        pc = run(pc)
except:...
if result:
    for k in sorted(vn):
        print("%s=%d" % (k, vs[vn[k]]))
else:
    print("inf")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
stmts = [input().split() for i in range(n)]

mapper = {}
for i, stmt in enumerate(stmts):
    mapper[stmt[0]] = i

vn = {}
for stmt in stmts:
    for ope in stmt[2:]:
        if ope.isalpha() and ope not in vn:
            vn[ope] = len(vn)
vs = [0]*len(vn)
def value(var):
    if var.isalpha():
        return vs[vn[var]]
    return int(var)
def assign(var, x):
    if not 0 <= x < 16:
        assert 0
    vs[vn[var]] = x

def stmt_add(v1, v2, v3):
    def run(pc):
        assign(v1, value(v2) + value(v3))
        return pc+1
    return run
def stmt_sub(v1, v2, v3):
    def run(pc):
        assign(v1, value(v2) - value(v3))
        return pc+1
    return run
def stmt_set(v1, v2):
    def run(pc):
        assign(v1, value(v2))
        return pc+1
    return run
def stmt_if(v1, dest):
    def run(pc):
        if value(v1) > 0:
            return mapper[dest]
        else:
            return pc+1
    return run
def stmt_halt():
    def run(pc):
        return n
    return run
stmt_func = []
for i, stmt in enumerate(stmts):
    op = stmt[1]
    if op == 'ADD':
        stmt_func.append(stmt_add(*stmt[2:]))
    elif op == 'SUB':
        stmt_func.append(stmt_sub(*stmt[2:]))
    elif op == 'SET':
        stmt_func.append(stmt_set(*stmt[2:]))
    elif op == 'IF':
        stmt_func.append(stmt_if(*stmt[2:]))
    else:
        stmt_func.append(stmt_halt())

result = 1
state = set()
pc = 0
cnts = [0]*n
LIM = 16**len(vn) + 10
try:
    while 1:
        run = stmt_func[pc]
        cnts[pc] += 1
        if cnts[pc] > LIM:
            result = 0
            break
        pc = run(pc)
except:...
if result:
    for k in sorted(vn):
        print("%s=%d" % (k, vs[vn[k]]))
else:
    print("inf")

Fixed submission:
n = int(input())
stmts = [input().split() for i in range(n)]

mapper = {}
for i, stmt in enumerate(stmts):
    mapper[stmt[0]] = i

vn = {}
for stmt in stmts:
    for ope in stmt[2:]:
        if ope.isalpha() and ope not in vn:
            vn[ope] = len(vn)
vs = [0]*len(vn)
def stmt_add(v1, v2, v3):
    v1 = vn[v1]
    if v3.isdigit():
        v2 = vn[v2]
        const = int(v3)
        def run(pc):
            assert vs[v2] + const < 16
            vs[v1] = vs[v2] + const
            return pc+1
    else:
        v2 = vn[v2]
        v3 = vn[v3]
        def run(pc):
            assert vs[v2] + vs[v3] < 16
            vs[v1] = vs[v2] + vs[v3]
            return pc+1
    return run
def stmt_sub(v1, v2, v3):
    v1 = vn[v1]
    if v3.isdigit():
        v2 = vn[v2]
        const = int(v3)
        def run(pc):
            assert 0 <= vs[v2] - const
            vs[v1] = vs[v2] - const
            return pc+1
    else:
        v2 = vn[v2]
        v3 = vn[v3]
        def run(pc):
            assert 0 <= vs[v2] - vs[v3]
            vs[v1] = vs[v2] - vs[v3]
            return pc+1
    return run
def stmt_set(v1, v2):
    v1 = vn[v1]
    if v2.isdigit():
        v2 = int(v2)
        def run(pc):
            vs[v1] = v2
            return pc+1
    else:
        v2 = vn[v2]
        def run(pc):
            vs[v1] = vs[v2]
            return pc+1
    return run
def stmt_if(v1, dest):
    v1 = vn[v1]
    def run(pc):
        return mapper[dest] if vs[v1] else pc+1
    return run
def stmt_halt():
    def run(pc):
        return n
    return run
stmt_func = []
for i, stmt in enumerate(stmts):
    op = stmt[1]
    if op == 'ADD':
        stmt_func.append(stmt_add(*stmt[2:]))
    elif op == 'SUB':
        stmt_func.append(stmt_sub(*stmt[2:]))
    elif op == 'SET':
        stmt_func.append(stmt_set(*stmt[2:]))
    elif op == 'IF':
        stmt_func.append(stmt_if(*stmt[2:]))
    else:
        stmt_func.append(stmt_halt())

result = 1
pc = 0
cnts = [0]*n
LIM = 16**len(vn) + 10
try:
    while 1:
        run = stmt_func[pc]
        cnts[pc] += 1
        if cnts[pc] > LIM:
            result = 0
            break
        pc = run(pc)
except:...
if result:
    for k in sorted(vn):
        print("%s=%d" % (k, vs[vn[k]]))
else:
    print("inf")