Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
a.sort()
mm = a.pop()
ind = bisect.bisect_left(a,mm/2)
print(mm,a[ind])

Fixed submission:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
a.sort()
ma = a.pop()
mi = -1
dif = mod
for i in range(n-1):
    if abs(ma/2-a[i]) < dif:
        mi = i
        dif = abs(ma/2-a[i])
print(ma,a[mi])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,k = inpl()
res = []
for i in range(a,b+1):
    if i < a+k or i > b-k:
        res.append(i)
res.sort()
print(*res)

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,k = inpl()
res = []
for i in range(k):
    if a+i <= b and not a+i in res:
        res.append(a+i)
    if b-i >= a and not b-i in res:
        res.append(b-i)
res.sort()
print(*res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
a.append(0)
b = [abs(a[0])]
c = [abs(a[1])]
for i in range(n):
    b.append(abs(a[i] - a[i+1]))
    if i < n-1:
        c.append(abs(a[i] - a[i+2]))

for i in range(n):
    ans = c[i]
    for j in range(0,i):
        ans += b[j]
    for k in range(i+2,n+1):
        ans += b[k]
    print(ans)


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
a.append(0)
b = [abs(a[0])]
c = [abs(a[1])]

for i in range(n):
    b.append(abs(a[i] - a[i+1]))
    if i < n-1:
        c.append(abs(a[i] - a[i+2]))
sum_b = sum(b)
for i in range(n):
    print(sum_b + c[i] - b[i] - b[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n,k = map(int,input().split())
a = [i for i in input().split()]
cnt = Counter(a)
ll = len(cnt)
ans = 0
if ll < k:
    print(0)
    quit()
for i in range(k):
    ans += cnt.most_common()[i][1]
print(n-ans)

Fixed submission:
from collections import Counter
n,k = map(int,input().split())
a = [i for i in input().split()]
cnt = Counter(a)
li = list(cnt.values())
li.sort()
ll = len(li)
if ll > k:
    print(sum(li[:ll-k]))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,copy
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
l = 0; r = n-1
res = []
while r > l:
    pl = None
    mx = 0
    ind = -1
    for i in range(l,r+1):
        if abs(a[i]) > mx:
            mx = abs(a[i])
            ind = i
            if a[i] > 0:
                pl = True
            else:
                pl = False
    if mx == 0:
        break
    if pl:
        for i in range(ind,r):
            i += 1
            res.append([i,i+1])
            res.append([i,i+1])
        r = ind
    else:
        for i in range(l,ind)[::-1]:
            i += 1
            res.append([i+1,i])
            res.append([i+1,i])
        l = ind
print(len(res))
for x in res:
    print(*x)


Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,copy
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
mx = 0
pl = None
ind = -1
res = []
for i,x in enumerate(a):
    if abs(x) > mx:
        mx = abs(x)
        ind = i
        pl = True if x > 0 else False
if mx == 0:
    print(0)
    quit()
if not pl: mx *= -1
for i in range(n):
    if i == ind: continue
    res.append([ind+1,i+1])
    a[i] += mx
if pl:
    for i in range(n-1):
        res.append([i+1,i+2])
else:
    for i in range(n-1)[::-1]:
        res.append([i+2,i+1])
print(len(res))
for x in res:
    print(*x)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())
cnt = [0] * n
res = 0
for i,b in enumerate(B):
    c = bisect.bisect_left(C,b+1)
    cnt[i] = n-c

acc = [0]
for x in cnt:
    acc += [acc[-1] + x]

for i,a in enumerate(A):
    c = bisect.bisect_left(B,a+1)
    res += sum(cnt) - acc[c]
print(res)

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())
cnt = [0] * n
res = 0
for i,b in enumerate(B):
    c = bisect.bisect_left(C,b+1)
    cnt[i] = n-c

acc = [0]
for x in cnt:
    acc += [acc[-1] + x]
su = sum(cnt) 
for i,a in enumerate(A):
    c = bisect.bisect_left(B,a+1)
    res += su - acc[c]
print(res)
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
snx = []

for i in range(n):
    if s[i] != 'x':
        snx.append(s[i])
ln = len(snx)
for i in range(ln//2):
    if snx[i] != snx[ln-i-1]:
        print(-1)
        quit()

j = 0
if ln%2:
    for l in range(n):
        if s[l] == snx[j]:
            j += 1
            if j >= ln//2+1:  
                break
    print(n-l-l-1)
else:
    for l in range(n):
        if s[l] == snx[j]:
            j += 1
            if j >= ln//2:  
                break 
    j = ln-1
    for r in range(n)[::-1]:
        if s[r] == snx[j]:
            j -= 1
            if j <= ln//2-1:
                break

    print(abs(n-r-l-1))

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
l = 0
r = n-1
res = 0
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        res += 1
        l += 1
    elif s[r] == 'x':
        res += 1
        r -= 1
    else:
        print(-1)
        break
else:
    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
xary = []; yary = []
a = []
for i in range(n):
    x,y = inpl()
    xary += [x]; yary += [y]
    a += [[x,y]]
xary.sort(); yary.sort()
res = INF
for xi in range(n-1):
    for xj in range(xi+1,n):
        for yi in range(n-1):
            for yj in range(yi+1,n):
                cnt = 0
                l = xary[xi]; r = xary[xj]
                d = yary[yi]; u = yary[yj]
                # print(l,r,d,u)
                for i in range(n):
                    x,y = a[i]
                    if l<=x<=r and d<=y<=u:
                        cnt += 1
                if cnt >= k:
                    res = min(res, (r-l)*(u-d))
print(res)


Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,K = inpl()
a = [inpl() for _ in range(n)]
res = INF
for i in range(1):
    a.sort(key=lambda x:x[i])
    for j in range(n-1):
        for k in range(j+1,n):
            l = a[j][i]
            r = a[k][i]
            b = [a[j],a[k]]
            cnt = 2
            for _ in range(n):
                if _ == j or _ == k:
                    continue
                if l < a[_][i] < r:
                    cnt += 1
                    b += [a[_]]
            if cnt < K: continue
            b.sort(key=lambda x:x[i^1])
            # print(j,k,b,i)
            for _ in range(cnt-K+1):
                u = max(x[i^1] for x in b[_:_+K])
                d = min(x[i^1] for x in b[_:_+K])
                res = min(res, (r-l)*(u-d))
                # print(res)
print(res)
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = 0
for i in range(n):
    if i == n and a[i] == i+1:
        cnt += 1
        continue
    if a[i] == i+1:
        a[i], a[i+1] = a[i+1], a[i]
        cnt += 1
print(cnt)

Fixed submission:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = 0
for i in range(n):
    if i == n-1 and a[i] == i+1:
        cnt += 1
        continue
    if a[i] == i+1:
        a[i], a[i+1] = a[i+1], a[i]
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,fractions
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))
def inpl_str(): return list(sys.stdin.readline().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n = inp()
t = inpln(n)
tmp = t[0]
for i in range(n-1):
    tmp = lcm(tmp, t[i+1])
print(tmp)


Fixed submission:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,fractions
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))
def inpl_str(): return list(sys.stdin.readline().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n = inp()
t = inpln(n)
tmp = t[0]
for i in range(n-1):
    tmp = lcm(tmp, t[i+1])
print(tmp)
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inp()
print((n-1)*(m-1))

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
print((n-1)*(m-1))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a = inpl()
cnt = 0
while True:
    for i in a:
        if i%2:
            print(cnt)
            quit()
if a[0] == a[1] == a[2]:
    print(-1)
else:
    while True:
        for i in a:
            if i%2:
                print(cnt)
                quit()
        b = [0] * 3
        b[0] = (a[1] + a[2]) // 2
        b[1] = (a[0] + a[2]) // 2
        b[2] = (a[1] + a[0]) // 2
        cnt += 1
        a[::] = b[::]



Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a = inpl()
cnt = 0
for i in a:
    if i%2:
        print(cnt)
        quit()
if a[0] == a[1] == a[2]:
    print(-1)
else:
    while True:
        for i in a:
            if i%2:
                print(cnt)
                quit()
        b = [0] * 3
        b[0] = (a[1] + a[2]) // 2
        b[1] = (a[0] + a[2]) // 2
        b[2] = (a[1] + a[0]) // 2
        cnt += 1
        a[::] = b[::]
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    n = inp()
    res = 1
    for i in range(1,n+1):
        res *= i%mod
    print(res%mod) 
if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    n = inp()
    res = 1
    for i in range(1,n+1):
        res = res * i % mod
    print(res%mod) 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
res = 1
for i in range(1,n+1):
    res *= i%mod
print(res%mod) 

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    n = inp()
    res = 1
    for i in range(1,n+1):
        res = res * i % mod
    print(res%mod) 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
res = 1
for i in range(1,n+1):
    res *= i%mod
print(res%mod) 

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    n = inp()
    res = 1
    for i in range(1,n+1):
        res = res * i % mod
    print(res%mod) 
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
s = [list(input()) for i in range(h)]
seq = [0]*(h-1) + [1]*(w-1)
d = set()
if s[0][0] != '#':
    print('Impossible')
    quit()
s[0][0] = '.'
for i in itertools.permutations(seq,h+w-2):
    if i in d:
        continue
    d.add(i)
    t = [['' for k in range(w)] for j in range(h)] 
    for k in range(h):
        for j in range(w):
            tmp = s[k][j]
            t[k][j] = tmp
    nx = ny = 0
    # print('t')
    # print(t)
    # print('s')
    # print(s)
    # print(i)
    for j in i:
        if j:
            nx += 1
        else:
            ny += 1
        if t[ny][nx] == '#':
            t[ny][nx] = '.'
    for j in t:
        if '#' in j:
            break
    else:
        print('Possible')
        # print(i)
        # print(t)
        break
else:
    print('Impossible')


Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
s = [list(input()) for i in range(h)]
if s[0][0] != '#':
    print('Impossible')
    quit()
s[0][0] = '.'
for i in itertools.combinations(range(h+w-2),h-1):
    # print(i)
    cnt = [1] * (h+w-2)
    for l in range(h+w-2):
        if l in i:
            cnt[l] = 0 
    # print(cnt)
    t = [['' for k in range(w)] for j in range(h)] 
    for k in range(h):
        for j in range(w):
            tmp = s[k][j]
            t[k][j] = tmp
    nx = ny = 0
    # print('t')
    # print(t)
    # print('s')
    # print(s)
    # print(i)
    for j in cnt:
        if j:
            nx += 1
        else:
            ny += 1
        if t[ny][nx] == '#':
            t[ny][nx] = '.'
    for j in t:
        if '#' in j:
            break
    else:
        print('Possible')
        # print(i)
        # print(t)
        break
else:
    print('Impossible')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,A = inpl()
x = inpl()
dp = [[[0 for _ in range(n+5)] for i in range(3005)] for j in range(n+5)]
dp[0][0][0] = 1
for i in range(n):
    for j in range(sum(x)+1):
        for k in range(n):
            if j >= x[i]:
                dp[i+1][j][k+1] = dp[i][j-x[i]][k] + dp[i][j][k+1]
            else:
                dp[i+1][j][k] = dp[i][j][k]
# for i in range(n+1):
#     print(dp[i][:50])
ans = 0
for j in range(1,sum(x)+1):
    for k in range(1,n+1):
        if j/k == A:
            ans += dp[n][j][k]
print(ans)

Fixed submission:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,A = inpl()
x = inpl()
dp = [[[0 for _ in range(n+5)] for i in range(3005)] for j in range(n+5)]
dp[0][0][0] = 1
for i in range(n):
    for j in range(sum(x)+1):
        for k in range(n):
            if j >= x[i]:
                dp[i+1][j][k+1] = dp[i][j-x[i]][k] + dp[i][j][k+1]
            else:
                dp[i+1][j][k] = dp[i][j][k]
# for i in range(n+1):
#     print(dp[i][:50])
ans = 0
for j in range(1,sum(x)+1):
    for k in range(1,n+1):
        if j/k == A:
            ans += dp[n][j][k]
print(ans)