Buggy python submission (verdict: Runtime Error):
import math
from collections import Counter
M = 256

def entropy(ctr):
    ret = 0
    for v in ctr.values():
        ret -= (v / N) * math.log2(v / N)
    return ret

while True:
    N = int(input())
    if N == 0: break
    src = list(map(int,input().split()))
    ans_h = float('inf')
    ans_sac = None
    for s in range(16):
        for a in range(16):
            for c in range(16):
                ctr = Counter()
                r = s
                for i in src:
                    r = (a*r + c) % M
                    o = (i + r) % M
                    ctr.update([o])
                h = entropy(ctr)
                if h < ans_h:
                    ans_h = h
                    ans_sac = (s,a,c)
    print(' '.join(map(str,ans_sac)))

Fixed submission:
import math
M = 256

def entropy_if_smallest(ctr,bound):
    ret = 0
    for v in ctr:
        if v == 0: continue
        ret -= (v / N) * math.log2(v / N)
        if ret >= bound:
            return None
    return ret

def solve(src):
    ans_h = float('inf')
    ans = None
    for s in range(16):
        for a in range(16):
            for c in range(16):
                ctr = [0] * M
                r = s
                for i in src:
                    r = (a*r + c) % M
                    o = (i + r) % M
                    ctr[o] += 1
                h = entropy_if_smallest(ctr,ans_h)
                if h is not None:
                    ans = (s,a,c)
                    ans_h = h
                    if ans_h == 0:
                        return ans
    return ans

while True:
    N = int(input())
    if N == 0: break
    src = list(map(int,input().split()))
    print(' '.join(map(str,solve(src))))

Buggy python submission (verdict: Runtime Error):
import math
from collections import Counter
M = 256

def entropy(ctr):
    ret = 0
    for v in ctr.values():
        ret -= (v / N) * math.log2(v / N)
    return ret

def solve(src):
    ans_h = float('inf')
    ans = None
    for s in range(16):
        for a in range(16):
            for c in range(16):
                ctr = Counter()
                r = s
                for i in src:
                    r = (a*r + c) % M
                    o = (i + r) % M
                    ctr.update([o])
                h = entropy(ctr)
                if h < ans_h:
                    ans = (s,a,c)
                    ans_h = h
                    if ans_h == 0:
                        return ans
    return ans

while True:
    N = int(input())
    if N == 0: break
    src = list(map(int,input().split()))
    print(' '.join(map(str,solve(src))))

Fixed submission:
import math
M = 256

def entropy_if_smallest(ctr,bound):
    ret = 0
    for v in ctr:
        if v == 0: continue
        ret -= (v / N) * math.log2(v / N)
        if ret >= bound:
            return None
    return ret

def solve(src):
    ans_h = float('inf')
    ans = None
    for s in range(16):
        for a in range(16):
            for c in range(16):
                ctr = [0] * M
                r = s
                for i in src:
                    r = (a*r + c) % M
                    o = (i + r) % M
                    ctr[o] += 1
                h = entropy_if_smallest(ctr,ans_h)
                if h is not None:
                    ans = (s,a,c)
                    ans_h = h
                    if ans_h == 0:
                        return ans
    return ans

while True:
    N = int(input())
    if N == 0: break
    src = list(map(int,input().split()))
    print(' '.join(map(str,solve(src))))

Buggy python submission (verdict: Runtime Error):
import math
from collections import Counter
M = 256

def entropy_if_smallest(ctr,bound):
    ret = 0
    for v in ctr.values():
        ret -= (v / N) * math.log2(v / N)
        if ret >= bound:
            return None
    return ret

def solve(src):
    ans_h = float('inf')
    ans = None
    for s in range(16):
        for a in range(16):
            for c in range(16):
                ctr = Counter()
                r = s
                for i in src:
                    r = (a*r + c) % M
                    o = (i + r) % M
                    ctr.update([o])
                h = entropy_if_smallest(ctr,ans_h)
                if h is not None:
                    ans = (s,a,c)
                    ans_h = h
                    if ans_h == 0:
                        return ans
    return ans

while True:
    N = int(input())
    if N == 0: break
    src = list(map(int,input().split()))
    print(' '.join(map(str,solve(src))))

Fixed submission:
import math
M = 256

def entropy_if_smallest(ctr,bound):
    ret = 0
    for v in ctr:
        if v == 0: continue
        ret -= (v / N) * math.log2(v / N)
        if ret >= bound:
            return None
    return ret

def solve(src):
    ans_h = float('inf')
    ans = None
    for s in range(16):
        for a in range(16):
            for c in range(16):
                ctr = [0] * M
                r = s
                for i in src:
                    r = (a*r + c) % M
                    o = (i + r) % M
                    ctr[o] += 1
                h = entropy_if_smallest(ctr,ans_h)
                if h is not None:
                    ans = (s,a,c)
                    ans_h = h
                    if ans_h == 0:
                        return ans
    return ans

while True:
    N = int(input())
    if N == 0: break
    src = list(map(int,input().split()))
    print(' '.join(map(str,solve(src))))