Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

items = [a, b, c, d, e]
pps = [0] * 5
pps[0] = n
time = 0
flg = True
while flg:
    carry = 0
    for i, (item, pp) in enumerate(zip(items, pps)):
        pp_bef = pp
        num = pp - item
        if num < 0:
            num = 0
        pps[i] = num + carry
        pp_aft = num
        carry = pp_bef - pp_aft
    time += 1
    if pps == [0] * 5:
        flg = False
print(time)


### FIXED CODE ###

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

import math
items = [a, b, c, d, e]
min_item = min(items)
min_idx = items.index(min_item)
n_times = math.ceil(n / min_item)
print(len(items) + n_times - 1)
### BUGGY CODE ###

import math
import sys
import collections


mod = 1000000007
sys.setrecursionlimit(mod)
fact = {1: 1}


def run(n, m):
    # print('{}を{}個の数列で表現'.format(m, n))
    ans = 1
    primes = []
    for i in range(2, m):
        if m == 1:
            break
        if i*i > m:
            break
        if m % i == 0:
            cnt = 0
            while m % i == 0:
                cnt += 1
                m //= i
                primes.append(i)
            # ans *= comb(cnt+n-1, n-1)
            # ans %= mod
    counts = collections.Counter(primes)
    # print(counts)
    for (_, v) in counts.items():
        ans *= comb(v+n-1, n-1)
        ans %= mod
    if m != 1:
        ans *= n
        ans %= mod
    return ans


def comb(n, r):
    mul = math.factorial(n) // math.factorial(n - r)
    div = math.factorial(r)
    # mul = factorial(n) // factorial(n - r)
    # div = factorial(r)
    mul %= mod
    div %= mod
    return (mul * modpow(div, (mod-2))) % mod


'''
def factorial(n):
    if n in fact:
        return fact[n]
    else:
        fact[n] = n*factorial(n-1)
        return fact[n]
'''


def modpow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        halfp = p // 2
        half = modpow(a, halfp)
        return int((half * half) % mod)
    else:
        return int((a * modpow(a, p-1)) % mod)


def main():
    n, m = map(int, input().split())
    print(run(n, m))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
import sys
import collections


mod = 1000000007
sys.setrecursionlimit(mod)
fact = {1: 1}


def run(n, m):
    # print('{}を{}個の数列で表現'.format(m, n))
    ans = 1
    primes = []
    for i in range(2, m):
        if m == 1:
            break
        if i*i > m:
            break
        if m % i == 0:
            cnt = 0
            while m % i == 0:
                cnt += 1
                m //= i
                primes.append(i)
            ans *= comb(cnt+n-1, n-1)
            ans %= mod
    # counts = collections.Counter(primes)
    # print(counts)
    # for (_, v) in counts.items():
    #     ans *= comb(v+n-1, n-1)
    #     ans %= mod
    if m != 1:
        ans *= n
        ans %= mod
    return ans


def comb(n, r):
    if r > (n-r):
        r = n-r
    mul = 1
    div = 1
    for i in range(r):
        mul *= n-i
        div *= i+1
        mul %= mod
        div %= mod
    # mul = math.factorial(n) // math.factorial(n - r)
    # div = math.factorial(r)
    # mul = factorial(n) // factorial(n - r)
    # div = factorial(r)
    mul %= mod
    div %= mod
    return (mul * modpow(div, (mod-2))) % mod


'''
def factorial(n):
    if n in fact:
        return fact[n]
    else:
        fact[n] = n*factorial(n-1)
        return fact[n]
'''


def modpow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        halfp = p // 2
        half = modpow(a, halfp)
        return int((half * half) % mod)
    else:
        return int((a * modpow(a, p-1)) % mod)


def main():
    n, m = map(int, input().split())
    print(run(n, m))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

class SegTree():
    def __init__(self, initial, operation, identity):
        n = len(initial)
        self.initial = initial
        self.operation = operation
        self.identity = identity
        self.num = 1 << (len(bin(n - 1)) - 2)
        self.tree = [identity] * (2 * self.num - 1)
        for i in range(n):
            self.tree[i + self.num - 1] = self.initial[i]
        for i in reversed(range(self.num - 1)):
            self.tree[i] = min(self.tree[2*i + 1], self.tree[2*i + 2])
    
    def update(self, k, x):
        k += self.num - 1
        self.tree[k] = x
        while k >= 1:
            k = (k - 1) // 2
            self.tree[k] = self.operation(self.tree[2*k + 1], self.tree[2*k + 2])
    
    def query(self, l, r):
        res = self.identity
        l += self.num - 1
        r += self.num - 1
        while l < r:
            if l % 2 == 0:
                res = self.operation(res, self.tree[l])
                l += 1
            if r % 2 == 0:
                res = self.operation(res, self.tree[r - 1])
            l = (l - 1) // 2
            r = (r - 1) // 2
        return res

N, Q = [int(i) for i in input().split()]

H, W = SegTree([N]*N, min, N), SegTree([N]*N, min, N)
revd = 0
for _ in range(Q):
    t, x = [int(i) for i in input().split()]
    if t == 1:
        h = H.query(x, N + 1)
        revd += h - 2
        W.update(h, min(x, W.query(h, N + 1)))
    else:
        w = W.query(x, N + 1)
        revd += w - 2
        H.update(w, min(x, H.query(w, N + 1)))

ans = (N - 2)*(N - 2) - revd
print(ans)

### FIXED CODE ###

class SegTree():
    def __init__(self, initial, operation, identity):
        n = len(initial)
        self.initial = initial
        self.operation = operation
        self.identity = identity
        self.num = 1 << (len(bin(n - 1)) - 2)
        self.tree = [identity] * (2 * self.num - 1)
        for i in range(n):
            self.tree[i + self.num - 1] = self.initial[i]
        for i in reversed(range(self.num - 1)):
            self.tree[i] = min(self.tree[2*i + 1], self.tree[2*i + 2])
    
    def update(self, k, x):
        k += self.num - 1
        self.tree[k] = x
        while k >= 1:
            k = (k - 1) // 2
            self.tree[k] = self.operation(self.tree[2*k + 1], self.tree[2*k + 2])
    
    def query(self, l, r):
        res = self.identity
        l += self.num - 1
        r += self.num - 1
        while l < r:
            if l % 2 == 0:
                res = self.operation(res, self.tree[l])
                l += 1
            if r % 2 == 0:
                res = self.operation(res, self.tree[r - 1])
            l = (l - 1) // 2
            r = (r - 1) // 2
        return res

N, Q = [int(i) for i in input().split()]

H, W = SegTree([N]*N, min, N), SegTree([N]*N, min, N)
revd = 0
for _ in range(Q):
    t, x = [int(i) for i in input().split()]
    if t == 1:
        h = H.query(x, N + 1)
        w = W.query(h, N + 1)
        revd += h - 2
        W.update(h, min(x, w))
    else:
        w = W.query(x, N + 1)
        h = H.query(w, N + 1)
        revd += w - 2
        H.update(w, min(x, h))

ans = (N - 2)*(N - 2) - revd
print(ans)
### BUGGY CODE ###

import copy
from collections import deque

h, w = map(int, input().split())
grid = [list(map(lambda x: x == "#", input().rstrip())) for _ in range(h)]

nq = deque([])
for i in range(h):
    for j in range(w):
        if grid[i][j]:
            nq.append([i, j])

moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

cnt = 0
while sum(sum(grid, [])) < h * w:
    cnt += 1
    q = copy.deepcopy(nq)
    while q:
        curr = q.popleft()
        for m in moves:
            nx, ny = curr[0] + m[0], curr[1] + m[1]
            if nx < 0 or ny < 0 or nx > h - 1 or ny > w - 1 or grid[nx][ny]:
                continue
            else:
                if not grid[nx][ny]:
                    nq.append([nx, ny])
                    grid[nx][ny] = True

print(cnt)

### FIXED CODE ###

import copy
from collections import deque

h, w = map(int, input().split())
grid = [list(map(lambda x: x == "#", input().rstrip())) for _ in range(h)]

q = deque([])
for i in range(h):
    for j in range(w):
        if grid[i][j]:
            q.append([i, j, 0])

moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

ans = 0
while q:
    curr = q.popleft()
    ans = max(ans, curr[2])
    for m in moves:
        nx, ny = curr[0] + m[0], curr[1] + m[1]
        if nx < 0 or ny < 0 or nx > h - 1 or ny > w - 1 or grid[nx][ny]:
            continue
        else:
            q.append([nx, ny, curr[2] + 1])
            grid[nx][ny] = True

print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
    ans *= a
print(ans if ans <= 10 ** 18 else -1)


### FIXED CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

# 累積和
acc = [0] + list(accumulate(A))

dp = list2d(N+1, N+1, INF)
for i in range(N):
    dp[i][i+1] = 0
for d in range(2, N+1):
    for l in range(N+1-d):
        r = l + d
        for m in range(l+1, r):
            dp[l][r] = min(dp[l][r], dp[l][m]+dp[m][r])
        # この先切った分の最小値に、今回のlとrを合体させる分を足す
        dp[l][r] += acc[r] - acc[l]
print(dp[0][N])


### FIXED CODE ###

# -*- coding: utf-8 -*-

"""
参考：https://kyopro-friends.hatenablog.com/entry/2019/01/12/231035
　　　https://atcoder.jp/contests/dp/submissions/3970847
・メモ化再帰
・累積和
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
aN = LIST()

# 累積和
sm = [0] * (N+1)
for i in range(N):
    sm[i+1] = sm[i] + aN[i]

memo = list2d(N+1, N+1, INF)
def rec(l, r):

    if memo[l][r] != INF: 
        return memo[l][r]
    if l == r:
        return 0
    mn = INF
    # 開区間にした
    for m in range(l, r):
        mn = min(mn, rec(l, m) + rec(m+1, r))
    # この先切った分の最小値に、今回のlとrを合体させる分を足す
    memo[l][r] = mn + (sm[r] - sm[l-1])
    return memo[l][r]

print(rec(1, N))
### BUGGY CODE ###

N = int(input())
A = []
A_ap = A.append
for i in range(N):
    A_ap(int(input()))
    
max_A = max(A)
for i in range(N):
    if A[i] != max_A:
        print(max_A)
    else:
        print(sorted(A)[-2])

### FIXED CODE ###

N = int(input())
A = []
A_ap = A.append
for i in range(N):
    A_ap(int(input()))
    
max_A = sorted(A)[-1]
max_2A = sorted(A)[-2]
for i in range(N):
    if A[i] != max_A:
        print(max_A)
    else:
        print(max_2A)
### BUGGY CODE ###

from itertools import combinations as cmb
n=int(input())
s=input()
sss=[]
for i in range(len(s)):
    sss.append(s[i])
combiset=set(cmb(sss,3))
print(len(combiset))


### FIXED CODE ###

n=int(input())
s=list(map(int,list(input())))
ans=0
for i in range(10):
    try:
        ss=s[s.index(i)+1:]
        for j in range(10):
            try:
                sss=ss[ss.index(j)+1:]
                for k in range(10):
                    if k in sss:ans+=1
            except:pass
    except:pass

print(ans)
### BUGGY CODE ###

N=int(input())
P=list(map(int,input().split()))
cnt=0
for i in range(N):
  if min(P[:i+1])==P[i]:
    cnt+=1
print(cnt)

### FIXED CODE ###

N=int(input())
P=[int(x) for x in input().split()]
cnt=0
tmp=P[0]
for i in range(N):
  if P[i]<=tmp:
    cnt+=1
    tmp=P[i]
print(cnt)
### BUGGY CODE ###

import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    l, r = list(map(int, readline().split()))
    t = 10 ** 20
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            t = min(t, i * j % 2019)
            if t == 0:
                break
    print(t)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

l, r = map(int, input().split())
ans = 10 ** 9
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            print(ans)
            exit()
print(ans)
### BUGGY CODE ###

from collections import defaultdict
N = int(input())
mm = defaultdict(int)

for i in range(N):
    key = input()
    mm[key] += 1

max_mms = [kv for kv in mm.items() if kv[1] == max(mm.values()) ]
max_mms.sort()

for i, k in max_mms:
    print(i)


### FIXED CODE ###

from collections import defaultdict
N = int(input())
mm = defaultdict(int)

for i in range(N):
    key = input()
    mm[key] += 1

max_val= max(mm.values())
mm_max = []
for kv in mm.items():
    if kv[1] == max_val:
        mm_max.append(kv)

mm_max.sort()
for v in mm_max:
    print(v[0])
### BUGGY CODE ###

k, s = map(int, input().split())
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        if i + j + (s - i - j) == s and 0 <= s - i - j <= k:
            count += 1
print(count)

### FIXED CODE ###

k, s = map(int, input().split())
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            count += 1
print(count)
### BUGGY CODE ###

s = input()
q = int(input())
r = False
for _ in range(q):
    xs = input().split()
    if xs[0] == "1":
        r = not r
    else:
        if (not r and xs[1] == "1") or (r and xs[1] == "2"):
            s = "".join([xs[2], s])
        else:
            s = "".join([s, xs[2]])
print(s[::-1] if r else s)


### FIXED CODE ###

from collections import deque

s = input()
q = int(input())

d = deque()
for v in s:
    d.append(v)
r = False
for _ in range(q):
    xs = input().split()
    if xs[0] == "1":
        r = not r
    else:
        if (not r and xs[1] == "1") or (r and xs[1] == "2"):
            d.appendleft(xs[2])
        else:
            d.append(xs[2])
s = "".join(d)
print(s[::-1] if r else s)
### BUGGY CODE ###

def main():
    s = input().rstrip()
    s = s[::-1] + "0"
    n = len(s)
    dp = [[float("inf")]*2 for _ in range(n+1)]
    dp[0][0] = 0
    for i, c in enumerate(s):
        for j in range(2):
            x = int(c) + j
            for num in range(10):
                ni = i+1
                nj = 0
                rem = num - x
                if rem < 0:
                    nj = 1
                    rem += 10
                dp[ni][nj] = min(dp[ni][nj], dp[i][j] + num + rem)
    print(dp[n][0])

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    s = input().rstrip()
    s = "0" + s
    dp = [0, float("inf")]
    for c in s:
        x = int(c)
        dp = [min(dp[0] + x, dp[1] + (10-x)), min(dp[0] + x+1, dp[1] + (10-x) - 1)]
    print(dp[0])

if __name__ == "__main__":
    main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

ans = 0
while 1:
    new_a = [a // 2 if a % 2 == 0 else -1 for a in A]
    if -1 in new_a:
        break
    ans += 1

print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

ans = 0
new_a = A.copy()
while 1:
    new_a = [a // 2 if a % 2 == 0 else -1 for a in new_a]
    if -1 in new_a:
        print(ans)
        exit()
    ans += 1

print(ans)
### BUGGY CODE ###


def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    B = [0 for i in range(M)]
    C = [0 for i in range(M)]

    for i in range(M):
        B[i], C[i] = map(int, input().split())
    for j in range(M):
        A.sort()
        for i in range(B[j]):
            if A[i] < C[j]:
                A[i] = C[j]

    print(sum(A))


if __name__ == '__main__':
    main()


### FIXED CODE ###


def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    BC = [list(map(int, input().split())) for i in range(M)]

    BC.sort(key=lambda x: x[1], reverse=True)
    A.sort()
    index = 0
    for j in range(M):
        if index >= N:
            break
        elif A[index] > BC[j][1]:
            break
        for i in range(BC[j][0]):
            if index >= N:
                break
            elif A[index] < BC[j][1]:
                A[index] = BC[j][1]
                index += 1

    print(sum(A))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n,k=map(int,input().split())
p=tuple(map(float,input().split()))
exp=tuple([(pi+1)/2 for pi in p])
ans=0
for i in range(0,n-k+1):
  ans=max(ans,sum(exp[i:i+k]))
print(ans)

### FIXED CODE ###

import numpy as np
n,k=map(int,input().split())
exp=tuple(map(lambda x: (int(x)+1)/2,input().split()))
l=np.cumsum(exp)

ans=l[k-1]
for i in range(0,n-k):
  x=l[i+k]-l[i]
  ans=max(ans,x)
print(ans)
### BUGGY CODE ###

n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n) :
    if i == 0 :
        count += 1
    else :
        mn = min(p[0:i+1])
        if mn == p[i] :
            count += 1
print(count)


### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n) :
    if i == 0 :
        mn = p[i]
        count += 1
    else :
        if mn > p[i] :
            mn = p[i]
            count += 1
print(count)
### BUGGY CODE ###

n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np
dists = np.ones((n + 1, n + 1)) * float('inf')
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dists[a, b] = dists[b, a] = c

from itertools import product, permutations
for i, j, k in product(range(1, 1 + n), repeat=3):
    if dists[j, k] > dists[j, i] + dists[i, k]:
        dists[j, k] = dists[k, j] = dists[j, i] + dists[i, k]

ans = float('inf')
for path in permutations(rs):
    val = sum(dists[i, j] for i, j in zip(path, path[1:]))
    val = int(val)
    if val < ans:
        ans = val

print(ans)

### FIXED CODE ###

n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np
dists = np.ones((n + 1, n + 1)) * float('inf')
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
    dists[i, i] = 0

from itertools import product, permutations
for i, k in product(range(1, 1 + n), repeat=2):
    dists[:, k] = np.minimum(dists[:, k], dists[:, i] + dists[i, k])

ans = float('inf')
for path in permutations(rs):
    val = sum(dists[i, j] for i, j in zip(path, path[1:]))
    val = int(val)
    if val < ans:
        ans = val

print(ans)
### BUGGY CODE ###

from sys import stdin
input = stdin.readline

from collections import deque

N,M = [int(x) for x in input().split()]
next =[set() for _ in range(N+1)]

for i in range(M):
    A,B = [int(x) for x in input().split()]
    next[A].add(B)
    next[B].add(A)

opened = deque()
opened.append(1)

closed = [False] * (N+1)
prev = [-1] * (N+1)
prevlen = [float('inf')] * (N+1)
prevlen[1] = 0

while len(opened) != 0:
    target = opened.popleft()
    closed[target] = True
    for n in next[target]:
        if closed[n] == False:
            opened.append(n)
        if prevlen[n] > prevlen[target]+1:
            prev[n] = target
            prevlen[n] = prevlen[target]+1


print('Yes')
for i in range(2,N+1):
    print(prev[i])

### FIXED CODE ###

from sys import stdin
input = stdin.readline
from collections import deque

N,M = [int(x) for x in input().split()]
next =[set() for _ in range(N+1)]

for i in range(M):
    A,B = [int(x) for x in input().split()]
    next[A].add(B)
    next[B].add(A)

opened = deque()
opened.append(1)

prev = [-1] * (N+1)
prev[1] = 1

while len(opened) != 0:
    target = opened.popleft()
    for n in next[target]:
        if prev[n] == -1:
            opened.append(n)
            prev[n] = target


print('Yes')
# for i in range(2,N+1):
#     print(prev[i])
print(" ".join([str(x) for x in prev[2:]]))
### BUGGY CODE ###

#!/usr/bin/env python3

def main():
    K = int(input())
    if K % 7 == 0:
        L = 9 * K / 7
    else:
        L = 9 * K
    if L == 2 or L == 5:
        ans = -1
    else:
        i = 1
        tmp = 10
        while True:
            tmp %= L
            if tmp == 1:
                ans = i
                break
            i += 1
            tmp *= 10

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    K = int(input())
    if K % 7 == 0:
        L = 9 * K / 7
    else:
        L = 9 * K
    if L % 2 == 0 or L % 5 == 0:
        ans = -1
    else:
        i = 1
        tmp = 10
        while True:
            tmp %= L
            if tmp == 1:
                ans = i
                break
            i += 1
            tmp *= 10

    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

n,a=map(int,input().split())
x=list(map(int,input().split()))
s=max(sum(x)+1,n*a+1)
dp=[[s*[0]for _ in range(n+1)]for _ in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  for j in range(i+1):
    for k in range(s):
      dp[i][j][k]=dp[i-1][j][k]
      if j!=0 and k>=x[i-1]:dp[i][j][k]+=dp[i-1][j-1][k-x[i-1]]
ans=0
for j in range(1,n+1):ans+=dp[-1][j][j*a]
print(ans)

### FIXED CODE ###

n,a=map(int,input().split())
x=list(map(int,input().split()))
X=max(max(x),a)
dp=[[[0]*(X*n+1)for j in range(n+1)]for i in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  xi=x[i-1]
  for j in range(i+1):
      for h in range(j*X+1):
        if h<xi:dp[i][j][h]=dp[i-1][j][h]
        if xi<=h and j>=1:dp[i][j][h]=dp[i-1][j][h]+dp[i-1][j-1][h-xi]
ans=0
for j in range(1,n+1):ans+=dp[n][j][j*a]
print(ans)
### BUGGY CODE ###

from collections import defaultdict as dd
N = int(input())
S = []
for i in range(N):
    s = input()
    s = sorted(s)
    s = ''.join(s)
    S.append(s)
S.sort()
SS = sorted(list(set(S)))
SN = []
for i in range(len(SS)):
    sn = 0
    for j in range(len(S)):
        if SS[i] == S[j]:
            sn += 1
        else:
            break
    S = S[sn:]
    SN.append(sn)

res = 0
for sn in SN:
    res += sn * (sn - 1) // 2

print(res)

### FIXED CODE ###

def main():
    N = int(input())
    S = []
    for i in range(N):
        s = input()
        s = sorted(s)
        s = ''.join(s)
        S.append(s)
    S.sort()
    SS = sorted(list(set(S)))
    SN = []
    M = len(SS)
    l = 0
    r = len(S)
    for i in range(M):
        for j in range(l, r):
            if S[j] != SS[i]:
                r = j
                break
        SN.append(r - l)
        l = r
        r = len(S)        

    res = 0
    for sn in SN:
        res += sn * (sn - 1) // 2

    print(res)
if __name__ == "__main__":
    main()