Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from itertools import combinations_with_replacement

L = range(2, 50000)
P = []
while L[0] ** 2 < 50000:
    P.append(L[0])
    L = [i for i in L if i % P[-1]]
P.extend(L)
del L

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    cnt = 0
    for a, b in combinations_with_replacement(P, 2):
        if a >= n:
            break
        if a + b == n:
            cnt += 1
    print(cnt)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(m):
    L = [True for _ in xrange(m + 1)]
    L[0] = L[1] = False

    for i in xrange(2, m + 1):
        if L[i]:
            for j in xrange(i + i, m + 1, i):
                L[j] = False
            if m < i * i:
                break
    return L

FLAGS = enum_prime(50000)
PRIMES = [i for i, isprime in enumerate(FLAGS) if isprime]

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    n2 = n // 2
    cnt = 0
    if n % 2 == 0:
        for p in PRIMES:
            if p > n2:
                break
            if FLAGS[n - p]:
                cnt += 1
    elif FLAGS[n - 2]:
        cnt = 1
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from itertools import combinations_with_replacement

L = range(2, 50000)
P = []
while L[0] ** 2 < 50000:
    P.append(L[0])
    L = [i for i in L if i % P[-1]]
P.extend(L)
del L

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    cnt = 0
    if n % 2 or not (n in P):
        for a, b in combinations_with_replacement(P, 2):
            if a >= n:
                break
            if a + b == n:
                cnt += 1
    print(cnt)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(m):
    L = [True for _ in xrange(m + 1)]
    L[0] = L[1] = False

    for i in xrange(2, m + 1):
        if L[i]:
            for j in xrange(i + i, m + 1, i):
                L[j] = False
            if m < i * i:
                break
    return L

FLAGS = enum_prime(50000)
PRIMES = [i for i, isprime in enumerate(FLAGS) if isprime]

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    n2 = n // 2
    cnt = 0
    if n % 2 == 0:
        for p in PRIMES:
            if p > n2:
                break
            if FLAGS[n - p]:
                cnt += 1
    elif FLAGS[n - 2]:
        cnt = 1
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from itertools import combinations_with_replacement

def enum_prime(m):
    L = range(2, m)
    P = []
    while L[0] ** 2 < m:
        P.append(L[0])
        L = [i for i in L if i % P[-1]]
    return P + L

P1 = enum_prime(50000)
P2 = P1[:]

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    cnt = 0
    if n % 2 == 0:
        for a in P1:
            if a + a == n:
                cnt += 1
                break
            for b in P2:
                if b < a:
                    continue
                if a + b == n:
                    cnt += 1
                    break
                if a + b > n:
                    break
    print(cnt)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(m):
    L = [True for _ in xrange(m + 1)]
    L[0] = L[1] = False

    for i in xrange(2, m + 1):
        if L[i]:
            for j in xrange(i + i, m + 1, i):
                L[j] = False
            if m < i * i:
                break
    return L

FLAGS = enum_prime(50000)
PRIMES = [i for i, isprime in enumerate(FLAGS) if isprime]

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    n2 = n // 2
    cnt = 0
    if n % 2 == 0:
        for p in PRIMES:
            if p > n2:
                break
            if FLAGS[n - p]:
                cnt += 1
    elif FLAGS[n - 2]:
        cnt = 1
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(m):
    L = range(2, m)
    P = []
    while L[0] ** 2 < m:
        P.append(L[0])
        L = [i for i in L if i % P[-1]]
    return P + L

P = enum_prime(50000)
length = len(P)

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    cnt = 0
    if (n - 2) in P:
        cnt = 1
    elif n % 2 == 0:
        for i in xrange(length):
            for j in xrange(i, length):
                s = P[i] + P[j]
                if s >= n:
                    if s == n:
                        cnt += 1
                    break
    print(cnt)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(m):
    L = [True for _ in xrange(m + 1)]
    L[0] = L[1] = False

    for i in xrange(2, m + 1):
        if L[i]:
            for j in xrange(i + i, m + 1, i):
                L[j] = False
            if m < i * i:
                break
    return L

FLAGS = enum_prime(50000)
PRIMES = [i for i, isprime in enumerate(FLAGS) if isprime]

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    n2 = n // 2
    cnt = 0
    if n % 2 == 0:
        for p in PRIMES:
            if p > n2:
                break
            if FLAGS[n - p]:
                cnt += 1
    elif FLAGS[n - 2]:
        cnt = 1
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(m):
    L = range(2, m)
    P = []
    while L[0] ** 2 < m:
        P.append(L[0])
        L = [i for i in L if i % P[-1]]
    return P + L

P = enum_prime(50000)

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    cnt = 0
    if n % 2 == 0:
        for p in P:
            if (n - p) in P:
                cnt += 1
            elif p + p > n:
                break
    elif (n - 2) in P:
        cnt = 1
    print(cnt)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(m):
    L = [True for _ in xrange(m + 1)]
    L[0] = L[1] = False

    for i in xrange(2, m + 1):
        if L[i]:
            for j in xrange(i + i, m + 1, i):
                L[j] = False
            if m < i * i:
                break
    return L

FLAGS = enum_prime(50000)
PRIMES = [i for i, isprime in enumerate(FLAGS) if isprime]

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    n2 = n // 2
    cnt = 0
    if n % 2 == 0:
        for p in PRIMES:
            if p > n2:
                break
            if FLAGS[n - p]:
                cnt += 1
    elif FLAGS[n - 2]:
        cnt = 1
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(m):
    L = [True for _ in xrange(m + 1)]
    L[0] = L[1] = False

    for i in xrange(2, m + 1):
        if not L[i]:
            continue
        for j in xrange(i + i, m + 1, i):
            L[j] = False
        if m < i * i:
            break
    return L

P = enum_prime(50000)

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    cnt = 0
    if n % 2 == 0:
        for p, isprime in enumerate(P):
            if not isprime:
                continue
            if p + p > n:
                break
            if P[n - p]:
                cnt += 1
    elif P[n - 2]:
        cnt = 1
    print(cnt)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(m):
    L = [True for _ in xrange(m + 1)]
    L[0] = L[1] = False

    for i in xrange(2, m + 1):
        if L[i]:
            for j in xrange(i + i, m + 1, i):
                L[j] = False
            if m < i * i:
                break
    return L

FLAGS = enum_prime(50000)
PRIMES = [i for i, isprime in enumerate(FLAGS) if isprime]

for line in stdin:
    if line.startswith('0'):
        break
    n = int(line)
    n2 = n // 2
    cnt = 0
    if n % 2 == 0:
        for p in PRIMES:
            if p > n2:
                break
            if FLAGS[n - p]:
                cnt += 1
    elif FLAGS[n - 2]:
        cnt = 1
    print(cnt)