Buggy python submission (verdict: Runtime Error):
import sys 
def sieves(m):
    global S
    S = range(1,m+1,2)
    r = int(m**.5)
    h = len(S)
    S[0] = 0
    for i in range(h):
        x = S[i]
        if x>r: break
        if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
    S[0] = 2
    return

S=[]
sieves(50001)
for s in sys.stdin:
    n = int(s)
    p1 = n/2-1
    p2 = (n+1)/2
    while S[p1]==0: p1 -=1
    while S[p2]==0: p2 +=1
    print S[p1],S[p2]

Fixed submission:
import sys
def primes(m):
    N = range(1,m+1,2)
    r = int(m**.5)
    h = len(N)
    N[0] = 0
    i=0
    while N[i]<=r:
        x = N[i]
        if x and i+x<h: N[i+x:h:x] = [0]*((h-1-i-x)/x+1)
        i += 1
    x = [2] + filter(None,N)
    return x

PRIMES = primes(50030)
for s in sys.stdin:
    n = int(s)
    for a in PRIMES:
        if a>n: break
        elif a<n: b = a
    print b,a

Buggy python submission (verdict: Runtime Error):
import sys 
def sieves(m):
    global S
    S = range(1,m+1,2)
    r = int(m**.5)
    h = len(S)
    S[0] = 0
    for i in range(h):
        x = S[i]
        if x>r: break
        if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
    S[0] = 2
    return

S=[]
sieves(50001)
for s in sys.stdin:
    n = int(s)
    p1 = n/2-1
    p2 = (n+1)/2
    while S[p1]==0: p1 -=1
    while S[p2]==0: p2 +=1
    print S[p1],S[p2]

Fixed submission:
import sys
def primes(m):
    N = range(1,m+1,2)
    r = int(m**.5)
    h = len(N)
    N[0] = 0
    i=0
    while N[i]<=r:
        x = N[i]
        if x and i+x<h: N[i+x:h:x] = [0]*((h-1-i-x)/x+1)
        i += 1
    x = [2] + filter(None,N)
    return x

PRIMES = primes(50030)
for s in sys.stdin:
    n = int(s)
    for a in PRIMES:
        if a>n: break
        elif a<n: b = a
    print b,a

Buggy python submission (verdict: Runtime Error):
import sys
m = 50001
S = range(1,m+1,2)
r = int(m**.5)
h = len(S)
S[0] = 0
for i in range(h):
    x = S[i]
    if x>r: break
    if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
S[0] = 2

for s in sys.stdin:
    n = int(s)
    for p1 in range(n/2-1,0,-1):
        if S[p1]: break
    for p2 in range((n+1)/2,m/2):
        if S[p2]: break
    print S[p1],S[p2]

Fixed submission:
import sys
def primes(m):
    N = range(1,m+1,2)
    r = int(m**.5)
    h = len(N)
    N[0] = 0
    i=0
    while N[i]<=r:
        x = N[i]
        if x and i+x<h: N[i+x:h:x] = [0]*((h-1-i-x)/x+1)
        i += 1
    x = [2] + filter(None,N)
    return x

PRIMES = primes(50030)
for s in sys.stdin:
    n = int(s)
    for a in PRIMES:
        if a>n: break
        elif a<n: b = a
    print b,a

Buggy python submission (verdict: Runtime Error):
import sys,math
def sieves(m):
    global S
    S = range(1,m+1,2)
    r = int(m**.5)
    h = len(S)
    S[0] = 0
    for i in range(h):
        x = S[i]
        if x>r: break
        if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
    S[0] = 2
    return
m = 50100
sieves(m)
for s in sys.stdin:
    n = int(s)
    for p1 in range(n/2-1,0,-1):
        if S[p1]: break
    for p2 in range((n+1)/2,m/2+1):
        if S[p2]: break
    print S[p1],S[p2]

Fixed submission:
import sys
def primes(m):
    N = range(1,m+1,2)
    r = int(m**.5)
    h = len(N)
    N[0] = 0
    i=0
    while N[i]<=r:
        x = N[i]
        if x and i+x<h: N[i+x:h:x] = [0]*((h-1-i-x)/x+1)
        i += 1
    x = [2] + filter(None,N)
    return x

PRIMES = primes(50030)
for s in sys.stdin:
    n = int(s)
    for a in PRIMES:
        if a>n: break
        elif a<n: b = a
    print b,a

Buggy python submission (verdict: Runtime Error):
import sys,math
def sieves(m):
    global S
    S = range(1,m+1,2)
    r = int(m**.5)
    h = len(S)
    S[0] = 0
    for i in range(h):
        x = S[i]
        if x>r: break
        if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
    S[0] = 2
    return
m = 50100
S = []
sieves(m)
for s in sys.stdin:
    n = int(s)
    for p1 in range(n/2-1,0,-1):
        if S[p1]: break
    for p2 in range((n+1)/2,m/2+1):
        if S[p2]: break
    print S[p1],S[p2]

Fixed submission:
import sys
def primes(m):
    N = range(1,m+1,2)
    r = int(m**.5)
    h = len(N)
    N[0] = 0
    i=0
    while N[i]<=r:
        x = N[i]
        if x and i+x<h: N[i+x:h:x] = [0]*((h-1-i-x)/x+1)
        i += 1
    x = [2] + filter(None,N)
    return x

PRIMES = primes(50030)
for s in sys.stdin:
    n = int(s)
    for a in PRIMES:
        if a>n: break
        elif a<n: b = a
    print b,a