Problem p02759 (python)

Fixed submission:
N = int(input())

if N % 2 == 1:
    print(N//2 + 1)
else:
    print(N//2)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
S = []
C = []
for i in range(M):
    temp1,temp2 = map(int,input().split())
    S.append(temp1)
    C.append(temp2)

Flag = True
temp = [-1,-1,-1]
for i in range(M):
    if S[i] == 3:
        if temp[2] == -1:
            temp[2] = C[i]
        else:
            if temp[2] == C[i]:
                next
            else:
                Flag = False

for i in range(M):
    if S[i] == 2:
        if temp[1] == -1:
            temp[1] = C[i]
        else:
            if temp[1] == C[i]:
                next
            else:
                Flag = False

for i in range(M):
    if S[i] == 1:
        if temp[0] == -1:
            temp[0] = C[i]
        else:
            if temp[0] == C[i]:
                next
            else:
                Flag = False

a = ''
if Flag == False:
    print(-1)
elif temp[0] ==0:
    print(-1)
elif temp[2] == -1:
    if temp[1] == -1:
        print(temp[0])
    elif temp[0] == -1:
        print(int(str(1) + str(temp[1])))
    else:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(temp[1])))
else:
    if temp[0] == -1 and temp[1] == -1:
        print(temp[2])
    elif temp[0] == -1 and temp[1] != -1:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[1]) + str(temp[2])))
    elif temp[0] != -1 and temp[1] == -1:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(0) + str(temp[2])))
    else:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(temp[1]) + str(temp[2])))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
S = []
C = []
for i in range(M):
    temp1,temp2 = map(int,input().split())
    S.append(temp1)
    C.append(temp2)

Flag = True
temp = [-1,-1,-1]
for i in range(M):
    if S[i] == 3:
        if temp[2] == -1:
            temp[2] = C[i]
        else:
            if temp[2] == C[i]:
                next
            else:
                Flag = False

for i in range(M):
    if S[i] == 2:
        if temp[1] == -1:
            temp[1] = C[i]
        else:
            if temp[1] == C[i]:
                next
            else:
                Flag = False

for i in range(M):
    if S[i] == 1:
        if temp[0] == -1:
            temp[0] = C[i]
        else:
            if temp[0] == C[i]:
                next
            else:
                Flag = False

a = ''
if Flag == False:
    print(-1)
elif temp[0] ==0:
    print(-1)
elif temp[2] == -1:
    if temp[1] == -1:
        print(temp[0])
    elif temp[0] == -1:
        print(int(str(1) + str(temp[1]))
    else:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(temp[1])))
else:
    if temp[0] == -1 and temp[1] == -1:
        print(temp[2])
    elif temp[0] == -1 and temp[1] != -1:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[1]) + str(temp[2])))
    elif temp[0] != -1 and temp[1] == -1:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(0) + str(temp[2])))
    else:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(temp[1]) + str(temp[2])))