Problem p03848 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from collections import Counter

def maybe_check(n,A):
    try:
        if n <= 0 or n > 100000:
            raise

        div = 1000000007
        maybe_list = [abs(abs(i - n) - ((n -1 ) - abs(i - n))) for i in range(1, n+1)]
        maybe_list.sort()
        A.sort()
        if A !=  maybe_list:
            raise

        pattern = len([num for num,count in Counter(maybe_list).items() if count != 1])
        return (2 ** pattern) % div

    except:
        return 0


_n = int(raw_input())
_A = map(int,raw_input().split())

print maybe_check(_n,_A)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

def maybe_check(n,A):
    try:
        if n <= 0 or n >= 10000:
            raise

        if len(A) <= 0 or len(A) > n:
            raise

        div = 10 ** 9 + 7
        maybe_list = []
        for i in range(1, n+1):
            left = abs(i - n)
            right = (n -1 )- left
            maybe_list.append(abs(left - right))

        pattern =  len(set([x for x in maybe_list if maybe_list.count(x) != 1]))

        for i in A:
            if i in maybe_list:
                maybe_list.remove(i)
            else:
                raise

        return (2 ** pattern) % div

    except:
        return 0


args = sys.argv
_n = int(args[1])
_A = map(int,args[2:])

print maybe_check(_n,_A)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

def maybe_check(n,A):
    if n <= 0 or n >= 10000:
        return False

    if len(A) <= 0 or len(A) > n:
        print len(A),n-1
        return False

    div = 10 ** 9 + 7
    maybe_list = []
    for i in range(1, n+1):
        left = abs(i - n)
        right = (n -1 )- left
        maybe_list.append(abs(left - right))

    pattern =  len(set([x for x in maybe_list if maybe_list.count(x) != 1]))

    for i in A:
        if i in maybe_list:
            maybe_list.remove(i)
        else:
            return 0

    return (2 ** pattern) % div



args = sys.argv
_n = int(args[1])
_A = map(int,args[2:])

print maybe_check(_n,_A)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

def maybe_check(n,A):
    if n <= 0 or n >= 10000:
        return False

    if len(A) <= 0 or len(A) > n:
        print len(A),n-1
        return False

    maybe_list = []
    for i in range(1, n+1):
        left = abs(i - n)
        right = (n -1 )- left
        maybe_list.append(abs(left - right))

    pattern =  len(set([x for x in maybe_list if maybe_list.count(x) != 1]))

    for i in A:
        if i in maybe_list:
            maybe_list.remove(i)
        else:
            return 0

    return (2 ** pattern) % div



args = sys.argv
n = int(args[1])
A = map(int,args[2:])

div = 10 ** 9 + 7
print maybe_check(n,A)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

def maybe_check(A,n):
    maybe_list = []
    for i in range(1, n+1):
        left = abs(i - n)
        right = (n -1 )- left
        maybe_list.append(abs(left - right))

    pattern =  len(set([x for x in maybe_list if maybe_list.count(x) != 1]))

    for i in A:
        if i in maybe_list:
            maybe_list.remove(i)
        else:
            return 0

    return (2 ** pattern) % div


args = sys.argv
n = int(args[1])
A = map(int,args[2:])
div = 10 ** 9 + 7
print maybe_check(A, n)

Buggy submission (verdict: Runtime Error):
import sys

def maybe_check(A,n):
    maybe_list = []
    for i in range(1, n+1):
        left = abs(i - n)
        right = (n -1 )- left
        maybe_list.append(abs(left - right))

    pattern =  len(set([x for x in maybe_list if maybe_list.count(x) != 1]))

    for i in A:
        if i in maybe_list:
            maybe_list.remove(i)
        else:
            return 0

    return (2 ** pattern) % div


args = sys.argv
n = int(args[1])
A = map(int,args[2:])
div = 10 ** 9 + 7
print maybe_check(A, n)