Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n = input()
    if n==0:
        break
    s = {i*i % n for i in xrange(1, n)}
    c = (n-1)/2
    m = [0] * (c+1)
    for a in s:
        for b in s:
            if a==b:
                continue
            t = a-b
            if t<0: t += n
            if t > c: t = n - t
            m[t] += 1
    print "\n".join(map(str, m[1:]))

Fixed submission:
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N = int(readline())
    if N == 0:
        return False
    if N == 1:
        return True
    *S, = set(i**2 % N for i in range(1, N))
    S.sort()
    L = len(S)
    C = [0]*N
    D = [0]*((N-1)//2)
    for i in range(L):
        a = S[i]
        for b in S[:i]:
            C[a - b] += 2
    for i in range(1, N):
        D[min(i, N-i)-1] += C[i]
    write("\n".join(map(str, D)))
    write("\n")
    return True
while solve():
    ...

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n = int(raw_input())
    if n==0: break
    s = {i*i % n for i in xrange(1, n)}
    c = (n-1)/2
    m = [0] * (c+1)
    for a in s:
        for b in s:
            if a==b: continue
            t = a-b
            if t<0: t += n
            if t > c: t = n - t
            m[t] += 1
    print "\n".join(map(str, m[1:]))

Fixed submission:
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N = int(readline())
    if N == 0:
        return False
    if N == 1:
        return True
    *S, = set(i**2 % N for i in range(1, N))
    S.sort()
    L = len(S)
    C = [0]*N
    D = [0]*((N-1)//2)
    for i in range(L):
        a = S[i]
        for b in S[:i]:
            C[a - b] += 2
    for i in range(1, N):
        D[min(i, N-i)-1] += C[i]
    write("\n".join(map(str, D)))
    write("\n")
    return True
while solve():
    ...

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n = int(raw_input())
    if n==0: break
    s = list({i*i % n for i in xrange(1, n)})
    c = (n-1)/2
    m = [0] * (c+1)
    for a in s:
        for b in s:
            if a==b: continue
            t = a-b
            if t<0: t += n
            if t > c: t = n - t
            m[t] += 1
    print "\n".join(map(str, m[1:]))

Fixed submission:
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N = int(readline())
    if N == 0:
        return False
    if N == 1:
        return True
    *S, = set(i**2 % N for i in range(1, N))
    S.sort()
    L = len(S)
    C = [0]*N
    D = [0]*((N-1)//2)
    for i in range(L):
        a = S[i]
        for b in S[:i]:
            C[a - b] += 2
    for i in range(1, N):
        D[min(i, N-i)-1] += C[i]
    write("\n".join(map(str, D)))
    write("\n")
    return True
while solve():
    ...

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n = input()
    if n == 0:
        break
    D = {x**2 % n for x in xrange(1, n)}
    C = {}
    print D
    for p in D:
        for q in D:
            if p == q:
                continue
            g = (p - q) % n
            if g > (n - 1)/2:
                g = n - g
            C[g] = C.get(g, 0) + 1
    for i in xrange(1, (n-1)/2+1):
        print C.get(i, 0)

Fixed submission:
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N = int(readline())
    if N == 0:
        return False
    if N == 1:
        return True
    *S, = set(i**2 % N for i in range(1, N))
    S.sort()
    L = len(S)
    C = [0]*N
    D = [0]*((N-1)//2)
    for i in range(L):
        a = S[i]
        for b in S[:i]:
            C[a - b] += 2
    for i in range(1, N):
        D[min(i, N-i)-1] += C[i]
    write("\n".join(map(str, D)))
    write("\n")
    return True
while solve():
    ...

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n = input()
    if n == 0:
        break
    D = {x**2 % n for x in xrange(1, n)}
    C = [0]*((n-1)/2)
    for p in D:
        for q in D:
            if p == q:
                continue
            g = (p - q) % n
            if g > (n - 1)/2:
                g = n - g
            C[g-1] += 1
    print "\n".join(map(str, C))

Fixed submission:
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N = int(readline())
    if N == 0:
        return False
    if N == 1:
        return True
    *S, = set(i**2 % N for i in range(1, N))
    S.sort()
    L = len(S)
    C = [0]*N
    D = [0]*((N-1)//2)
    for i in range(L):
        a = S[i]
        for b in S[:i]:
            C[a - b] += 2
    for i in range(1, N):
        D[min(i, N-i)-1] += C[i]
    write("\n".join(map(str, D)))
    write("\n")
    return True
while solve():
    ...

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n = input()
    if n == 0:
        break
    D = list({x**2 % n for x in xrange(1, n)})
    C = [0]*((n-1)/2)
    for i in xrange(len(D)):
        p = D[i]
        for j in xrange(i):
            q = D[j]
            g = (p - q) % n
            C[min(g, n-g)-1] += 2
    print "\n".join(map(str, C))

Fixed submission:
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N = int(readline())
    if N == 0:
        return False
    if N == 1:
        return True
    *S, = set(i**2 % N for i in range(1, N))
    S.sort()
    L = len(S)
    C = [0]*N
    D = [0]*((N-1)//2)
    for i in range(L):
        a = S[i]
        for b in S[:i]:
            C[a - b] += 2
    for i in range(1, N):
        D[min(i, N-i)-1] += C[i]
    write("\n".join(map(str, D)))
    write("\n")
    return True
while solve():
    ...