Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,A=tuple(map(lambda x:int(x),input().split()))
x=tuple(map(lambda x:int(x),input().split()))
dp=np.zeros((n+1,n+1,n*A+1), dtype=int)
dp[:,0,0]=1
for i in range(1,n+1):
    for k in range(1, n+1):
        for j in range(1,n*A+1):
            if k<=i and 0<=j-x[i-1]:
                dp[i,k,j]=dp[i-1,k,j]+dp[i-1,k-1,j-x[i-1]]
            else:
                dp[i,k,j]=dp[i-1,k,j]
c=0
for k in range(1,n+1):
    c+=dp[n,k,k*A]
print(c)


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,A=tuple(map(lambda x:int(x),input().split()))
x=tuple(map(lambda x:int(x),input().split()))
dp=np.zeros((n+1,n+1,n*A+1), dtype=int)
dp[0,0,0]=1
for i in range(1,n+1):
    for k in range(n+1):
        for j in range(n*A+1):
            if 1<=k<=i and 0<=j-x[i-1]:
                dp[i,k,j]=dp[i-1,k,j]+dp[i-1,k-1,j-x[i-1]]
            else:
                dp[i,k,j]=dp[i-1,k,j]
c=0
for k in range(1,n+1):
    c+=dp[n,k,k*A]
print(c)


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=np.array(list(map(lambda x:int(x),input().split())))
dp=np.zeros((n+1,n+1,max(x)*n+1), dtype=int)
dp[:,0,0]=1
c=0
for i in range(n):
    for j in range(i):
        for k in range(max(x)*(i+1)):
            if k-x[i]>=0:
                dp[i+1,j,k]=dp[i,j,k]+dp[i,j-1,k-x[i]]
            else:
                dp[i+1,j,k]=dp[i,j,k]
        c+=dp[i+1,j,j*avea]
print(c)


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np


def add2(l):
    ys = np.empty(0, dtype=int)
    for i in range(len(l)):
        zs = l[i] + l[i+1:]
        ys = np.concatenate([ys, zs], 0)
    return ys


def add(n, l):
    if len(l) == 0:
        return np.empty(0)
    elif n == 1:
        return l
    elif n == 2:
        return add2(l)
    else:
        ys = add(n, l[1:])
        zs = l[0] + add(n-1, l[1:])
        return np.concatenate([ys, zs], 0)


def main():
    n, a = (int(x) for x in input().split())
    xs = np.array([int(x) for x in input().split()], dtype='int')
    tot = np.sum(xs)

    if n == 1:
        # count = len([x for x in xs if x == a])
        count = np.sum(xs == a)
    else:
        count = 0
        lop = n // 2 + 1
        for i in range(1, n//2+1):
            ys = add(i, xs)
            count += np.sum(ys == a * i)
            if n - i > i:
                zs = tot - ys
                count += np.sum(zs == a * (n - i))
        if np.sum(xs) == n * a:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

Buggy python submission (verdict: Time Limit Exceeded):
def add2(l):
    ys = []
    for i in range(len(l)):
        ys += [l[i] + x for x in l[i+1:]]
    return ys


def add(n, l):
    if not l:
        return []
    elif n == 1:
        return l
    elif n == 2:
        return add2(l)
    else:
        ys = add(n, l[1:])
        ys += [l[0] + x for x in add(n-1, l[1:])]
        return ys


def main():
    n, a = (int(x) for x in input().split())
    xs = [int(x) for x in input().split()]
    tot = sum(xs)

    if n == 1:
        count = len([x for x in xs if x == a])
    else:
        count = 0
        lop = n // 2 + 1
        for i in range(1, n//2+1):
            ys = add(i, xs)
            count += len([y for y in ys if y == a * i])
            if n - i > i:
                zs = [tot - x for x in ys]
                count += len([z for z in zs if z == a * (n - i)])
        if sum(xs) == n * a:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

Buggy python submission (verdict: Time Limit Exceeded):
def add2(l):
    ys = []
    for i in range(len(l)):
        ys += [l[i] + x for x in l[i+1:]]
    return ys


def add(n, l):
    if not l:
        return []
    elif n == 1:
        return l
    elif n == 2:
        return add2(l)
    else:
        ys = [x for x in add(n, l[1:])]
        ys += [l[0] + x for x in add(n-1, l[1:])]
        return ys


def main():
    n, a = (int(x) for x in input().split())
    xs = [int(x) for x in input().split()]
    tot = sum(xs)

    if n == 1:
        count = len([x for x in xs if x == a])
    else:
        count = 0
        lop = n // 2 + 1
        for i in range(1, n//2+1):
            ys = add(i, xs)
            count += len([y for y in ys if y == a * i])
            if n - i > i:
                zs = [tot - x for x in ys]
                count += len([z for z in zs if z == a * (n - i)])
        if sum(xs) == n * a:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

Buggy python submission (verdict: Time Limit Exceeded):
def add2(l):
    ys = []
    for i in range(len(l)):
        ys += [l[i] + x for x in l[i+1:]]
    return ys


def add(n, l):
    if not l:
        return []
    elif n == 1:
        return l
    elif n == 2:
        return add2(l)
    else:
        ys = [x for x in add(n, l[1:])]
        ys += [l[0] + x for x in add(n-1, l[1:])]
        return ys


def main():
    n, a = (int(x) for x in input().split())
    xs = [int(x) for x in input().split()]
    tot = sum(xs)

    if n == 1:
        count = len(list(filter(lambda x: x == a, xs)))
    else:
        count = 0
        lop = n // 2 + 1
        for i in range(1, n//2+1):
            ys = add(i, xs)
            count += len(list(filter(lambda x: x == a * i, ys)))
            if n - i > i:
                zs = [tot - x for x in ys]
                count += len(list(filter(lambda x: x == a * (n - i), zs)))
        if sum(xs) == n * a:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

Buggy python submission (verdict: Time Limit Exceeded):
def add2(l):
    ys = []
    for i in range(len(l)):
        ys += [l[i] + x for x in l[i+1:]]
    return ys


def add(n, l):
    if not l:
        return []
    elif n == 1:
        return l
    elif n == 2:
        return add2(l)
    else:
        ys = [x for x in add(n, l[1:])]
        ys += [l[0] + x for x in add(n-1, l[1:])]
        return ys


def main():
    n, a = (int(x) for x in input().split())
    xs = [int(x) for x in input().split()]
    tot = sum(xs)

    if n == 1:
        count = len(list(filter(lambda x: x == a, xs)))
    else:
        count = 0
        lop = n // 2 + 1
        for i in range(1, n//2+1):
            ys = add(i, xs)
            count += len(list(filter(lambda x: x == a * i, ys)))
            if n - i > i:
                zs = list(map(lambda x: tot - x, ys))
                count += len(list(filter(lambda x: x == a * (n - i), zs)))
        if sum(xs) == n * a:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

Buggy python submission (verdict: Time Limit Exceeded):
def add2(l):
    ys = []
    for i in range(len(l)):
        ys += [l[i] + x for x in l[i+1:]]
    return ys


def add(n, l):
    if not l:
        return []
    elif n == 2:
        return add2(l)
    else:
        ys = [x for x in add(n, l[1:])]
        ys += [l[0] + x for x in add(n-1, l[1:])]
        return ys


def main():
    n, a = (int(x) for x in input().split())
    xs = [int(x) for x in input().split()]

    count = len(list(filter(lambda x: x == a, xs)))
    for i in range(2, n+1):
        ys = add(i, xs)
        count += len(list(filter(lambda x: x == a * i, ys)))

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy


def add2(l):
    ys = []
    for i in range(len(l)):
        ys += [l[i] + x for x in l[i+1:]]
    return ys


def add(n, l):
    if not l:
        return []
    elif n == 2:
        return add2(l)
    else:
        ys = [x for x in add(n, l[1:])]
        ys += [l[0] + x for x in add(n-1, l[1:])]
        return ys


def main():
    n, a = (int(x) for x in input().split())
    xs = [int(x) for x in input().split()]

    # i == 1
    ys = copy.deepcopy(xs)
    count = len(list(filter(lambda x: x == a, ys)))

    # i == 2 ~ n-2
    for i in range(2, n+1):
        ys = add(i, xs)
        count += len(list(filter(lambda x: x == a * i, ys)))
    '''
    # i == n-1
    ys = [sum(xs[:i]+xs[i+1:]) for i in range(n)]
    print(ys)
    count += len(list(filter(lambda x: x == a * (n - 1), ys)))

    # i == n
    if sum(xs) == n*a:
        count += 1
    '''
    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy


def add2(l):
    ys = []
    for i in range(len(l)):
        ys += [l[i] + x for x in l[i+1:]]
    return ys


def add(n, l):
    if not l:
        return []
    elif n == 2:
        return add2(l)
    else:
        ys = [x for x in add(n, l[1:])]
        ys += [l[0] + x for x in add(n-1, l[1:])]
        return ys


def main():
    n, a = (int(x) for x in input().split())
    xs = [int(x) for x in input().split()]

    ys = copy.deepcopy(xs)
    count = len(list(filter(lambda x: x == a, ys)))
    for i in range(2, n+1):
        ys = add(i, xs)
        count += len(list(filter(lambda x: x == a * i, ys)))

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(n):
    for j in range(2*w+1):
        if 0<=j-x[i]<=2*w:
            dp[i+1,j]=dp[i,j]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)