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

n, t = list(map(int, input().split()))
a = list(map(int, input().split()))

max_benefit = 0
ans = 0
for i in range(n - 1):
    benefit = (max(a[i + 1:]) - a[i])
    if  benefit == max_benefit:
        ans += 1
    elif benefit > max_benefit:
        ans = 1
        max_benefit = benefit

print(ans)

### FIXED CODE ###

n, t = list(map(int, input().split()))
a = list(map(int, input().split()))

max_benefit = 0
a_min = a[0]
ans = 0
for i in range(1, n):
    if a[i] < a_min:
        a_min = a[i]
    benefit = (a[i] - a_min)
    if  benefit == max_benefit:
        ans += 1
    elif benefit > max_benefit:
        ans = 1
        max_benefit = benefit

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

import queue
def tree(edges, n, q):
    distance = [0]*(n+1)
    visited = [0]*(n+1)
    for _ in range(0, q):
        p, x = map(int, input().split())
        distance[p] += x
    Q = queue.Queue()
    Q.put(1)
    visited[1] = 1
    while (not Q.empty()):
        xx = Q.get()
        for i in range(0, len(edges[xx])):
            if visited[edges[xx][i]]:
                continue
            distance[edges[xx][i]] += distance[xx]
            Q.put(edges[xx][i])
            visited[edges[xx][i]] = 1
    return distance[1:]
def addEdge(edges, u, v):
    edges[u].append(v)
    edges[v].append(u)
n, q = map(int, input().split())
edges = [[] for i in range(n + 1)]
for _ in range(0, n - 1):
    u, v = map(int, input().split())
    addEdge(edges, u, v)
print(*tree(edges, n, q))

### FIXED CODE ###

from collections import deque
def tree(edges, n, q):
    distance = [0]*(n+1)
    visited = [0]*(n+1)
    for _ in range(0, q):
        p, x = map(int, input().split())
        distance[p] += x
    Q = deque([])
    Q.append(1)
    visited[1] = 1
    while Q:
        xx = Q.popleft()
        for i in range(0, len(edges[xx])):
            if visited[edges[xx][i]]:
                continue
            distance[edges[xx][i]] += distance[xx]
            Q.append(edges[xx][i])
            visited[edges[xx][i]] = 1
    return distance[1:]
def addEdge(edges, u, v):
    edges[u].append(v)
    edges[v].append(u)
n, q = map(int, input().split())
edges = [[] for i in range(n + 1)]
for _ in range(0, n - 1):
    u, v = map(int, input().split())
    addEdge(edges, u, v)
print(*tree(edges, n, q))
### BUGGY CODE ###

def find(i, m):
    if m[i] < 0:
        return i
    return find(m[i], m)


def count(i, m):
    if m[i] < 0:
        return abs(m[i])
    return count(m[i], m)


def union(i, j, par, mem):
    pi, pj = find(i, par), find(j, par)
    mi = mem[pi]
    if pi != pj:
        par[pj] += par[pi]
        par[pi] = pj
        for k in mi:
            par[k] = pj

        mem[pi] = []
        mem[pj].extend(mi)


def main():
    import sys
    sys.setrecursionlimit(200000)
    n, m, *ab = map(int, open(0).read().split())
    ab = ab[::-1]
    tmp = n * (n - 1) // 2
    utl = []
    par = [-1] * (n + 1)
    mem = [[i] for i in range(n + 1)]
    for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = count(u, par), count(v, par)
            utl.append(tmp)
            tmp -= i * j
            union(u, v, par, mem)
            
    ans = '\n'.join(map(str, utl[::-1]))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def find(i, m):
    if m[i] < 0:
        return i
    return find(m[i], m)


def count(i, m):
    if m[i] < 0:
        return abs(m[i])
    return count(m[i], m)


def main():
    n, m, *ab = map(int, open(0).read().split())
    ab = ab[::-1]
    tmp = n * (n - 1) // 2
    utl = []
    par = [-1] * (n + 1)

    for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = find(u, par), find(v, par)
            utl.append(tmp)
            tmp -= par[i] * par[j]
            if par[i] > par[j]:
                i, j = j, i
            par[i] += par[j]
            par[j] = i

    ans = '\n'.join(map(str, utl[::-1]))
    print(ans)


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

n = int(input())
ans = 0

def add(n):
    if n%2 == 0:
        return sum(range(1,n))
    else:
        p = (n // 2 ) + 1
        return (n % p) + sum(range(p,n)) + add(p-1)

print(add(n))


### FIXED CODE ###

n = int(input())
ans = 0

def add(n):
    if n%2 == 0:
        return sum(range(1,n))
    else:
        p = (n // 2 ) + 1
        return (n % p) + sum(range(1,n)) - (p-1)

print(add(n))
### BUGGY CODE ###

from statistics import median

N = int(input())
num_lis = [int(_) for _ in input().split()]

for i in range(N):
    tmp = num_lis.copy()
    del tmp[i]
    print(median(tmp))

### FIXED CODE ###


N = int(input())
X = [int(_) for _ in input().split()]
tmp = sorted(X)

one = N // 2 - 1
two = N // 2

for x in X:
    if x <= tmp[one]:
        print(tmp[two])
    else:
        print(tmp[one])
### BUGGY CODE ###

S = input()

max_S = 10**9 + 7

N_Q = S.count("?")
N_C = S.count("C")

t_A = 0
t_Q = 0
if(S[0:1] == "C"):
    t_C = N_C - 1
else:
    t_C = N_C

S_list = [{"bA": t_A, "bQ": t_Q, "aC": t_C, "aQ": N_Q - t_Q}]
for i in range(1, len(S)):
    if(S[i - 1:i] == "A"):
        t_A += 1
    elif(S[i - 1:i] == "?"):
        t_Q += 1

    ba_dic = {}
    ba_dic["bA"] = t_A
    ba_dic["bQ"] = t_Q
    if(S[i:i + 1] == "?"):
        ba_dic["aQ"] = N_Q - t_Q - 1
    else:
        ba_dic["aQ"] = N_Q - t_Q
    if(S[i:i + 1] == "C"):
        t_C -= 1
    ba_dic["aC"] = t_C

    S_list.append(ba_dic)

ans = 0
for i in range(len(S)):
    if(S[i:i + 1] == "A" or S[i:i + 1] == "C"):
        continue

    bA = S_list[i]["bA"]
    bQ = S_list[i]["bQ"]
    aC = S_list[i]["aC"]
    aQ = S_list[i]["aQ"]

    ans += bA * aC * int(3**(bQ + aQ))
    ans = ans % max_S

    ans += bQ * aQ * int(3**(bQ + aQ - 2))
    ans = ans % max_S

    ans += (bA * aQ + bQ * aC) * int(3**(bQ + aQ - 1))
    ans = ans % max_S

print(ans)

### FIXED CODE ###

S = input()

d = [0, 0, 0, 1]

max_ans = 10**9 + 7

for c in reversed(S):
    # print(c, d)
    m = [c == "A", c == "B", c == "C", c == "?"]
    if(m[3] is True):
        tmp = 3
    else:
        tmp = 1

    for j in range(3):
        d[j] = (tmp * d[j] + int(m[j] or m[3]) * d[j + 1]) % max_ans
    d[3] = (tmp * d[3]) % max_ans

print(d[0])
### BUGGY CODE ###

S = list(input())
S = S[::-1]

ans = 0
bc_score = 0
flag = 1

if len(S) <= 1:
    print(0)
    exit()

while len(S) != 0:
    if S[0]=="C" and S[1] == "B":
        bc_score = 0
        bc_score += 1
        S.pop(0)
        S.pop(0)
        flag = 1
        while flag == 1 and len(S) != 0:
            flag = 0
            if S[0]=="C" and S[1] == "B":
                bc_score += 1
                S.pop(0)
                S.pop(0)
                flag = 1
            if S[0] == "A":
                ans += bc_score
                S.pop(0)
                flag = 1
    else:
        S.pop(0)

print(ans)

### FIXED CODE ###

S = list(input())
S = S[::-1]

t = 0
ans = 0
bc_score = 0
flag = 1

if len(S) <= 2:
    print(0)
    exit()

while t <= len(S)-2:
    if S[t]=="C" and S[t+1] == "B":
        bc_score = 0
        bc_score += 1
        t += 2
        flag = 1
        if t == len(S)-1:
            if S[t] == "A":
                ans += 1
            t += 1
        while flag == 1 and t <= len(S) - 1:
            flag = 0
            if S[t]=="C" and S[t+1] == "B":
                bc_score += 1
                t += 2
                flag = 1
            if t <= len(S) - 1:
                if S[t] == "A":
                    ans += bc_score
                    t += 1
                    flag = 1
    else:
        t += 1

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

n = int(input())

a = []
for i in range(n):
	a.append(int(input()))	

for i in range(n):
	print(max(a[:i]+a[i+1:]))

### FIXED CODE ###

import collections

n = int(input())

a = []
for i in range(n):
	a.append(int(input()))

b=sorted(a,reverse=True)
c=collections.Counter(a)
if c[b[0]] > 1:
	for i in range(n):
		print(b[0])
else:
	for i in range(n):
		if a[i] == b[0]:
			print(b[1])
		else:
			print(b[0])
### BUGGY CODE ###

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

res = True
if N >= 2:
    for i in range(N - 1):
        for j in range(1, N - i):
            if H[i] - H[i + j] >= 2:
                res = False

if res == True:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

res = True
if N >= 2:
    for i in range(N - 1):
        if H[i] - H[i + 1] >= 2:
            res = False

y_card = 0
if N >= 3 and res == True:
    for i in range(N - 1):
        if H[i] - H[i + 1] == 1:
            y_card += 1
            if y_card == 2:
                res = False
                break
        elif H[i] == H[i + 1]:
            pass
        elif H[i + 1] - H[i] >= 1:
            y_card -= H[i + 1] - H[i]
            if y_card < 0:
                y_card = 0


if res == True:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

s=input()
n=len(s)
dp=[13*[0]for _ in range(n+1)]
dp[0][0]=1
mod=10**9+7
for i in range(1,n+1):
  if s[i-1]=="?":
    for j in range(13):
      for k in range(10):
        m=(j*10+k)%13
        dp[i][m]+=dp[i-1][j]
        dp[i][m]%=mod
  else:
    for j in range(13):
      m=(j*10+int(s[i-1]))%13
      dp[i][m]+=dp[i-1][j]
      dp[i][m]%=mod
print(dp[-1][5])

### FIXED CODE ###

s=input()
n=len(s)
dp=[13*[0]for _ in range(n)]
if s[0]=="?":dp[0]=10*[1]+[0]*3
else:dp[0][int(s[0])]+=1
for i in range(1,n):
  if s[i]!="?":
    for j in range(13):
      dp[i][(j*10+int(s[i]))%13]=dp[i-1][j]
  else:
    for j in range(13):
      for k in range(10):
        dp[i][(j*10+k)%13]+=dp[i-1][j]
  for j in range(13):dp[i][j]%=10**9+7
print(dp[-1][5])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import math
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9+7

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ans = 0
    for d in range(40,-2,-1):# X, Kは高々40bit
        # dはXとKのbitが初めて一致しない桁（全探索している）
        if d != -1 and not (K & (1<<d)):# Kが0の桁はdの候補から外れる
            continue

        tmp = 0
        for e in range(40,-1,-1):# 上の桁から見ていく
            mask = 1<<e# e桁目の数字だけ
            num = 0
            # 配列Aのそれぞれのe桁目のbitの和
            for i in range(N):
                if A[i] & mask:
                    num += 1
            
            if e > d:
                if K & mask:# e桁目が1なので元が0の数だけ立ち上がる
                    tmp += mask*(N-num)
                else:
                    tmp += mask*num
            elif e == d:# K==1よりX==0, よって元が1の数だけ立ち上がる
                tmp += mask*num
            else:# Xが自由に選べるから立ち上がる数が大きくなるようにGreedyに取れる
                tmp += mask*max(num,N-num)
        ans = max(ans,tmp)

    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ans = 0
    for d in range(40,-2,-1):# X, Kは高々40bit
        # dはXとKのbitが初めて一致しない桁（全探索している）
        if d != -1 and not (K & (1<<d)):# Kが0の桁はdの候補から外れる
            continue

        tmp = 0
        for e in range(40,-1,-1):# 上の桁から見ていく
            mask = 1<<e# e桁目の数字だけ
            num = 0
            # 配列Aのそれぞれのe桁目のbitの和
            for i in range(N):
                if A[i] & mask:
                    num += 1
            
            if e > d:
                if K & mask:# e桁目が1なので元が0の数だけ立ち上がる
                    tmp += mask*(N-num)
                else:
                    tmp += mask*num
            elif e == d:# K==1よりX==0, よって元が1の数だけ立ち上がる
                tmp += mask*num
            else:# Xが自由に選べるから立ち上がる数が大きくなるようにGreedyに取れる
                tmp += mask*max(num,N-num)
        ans = max(ans,tmp)

    print(ans)

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

print(sum(range(1, int(input()))))

### FIXED CODE ###

N = int(input())
print(int((N - 1) * N // 2))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
from collections import defaultdict,Counter
def saiki(S):
  hitomozi = []
  d = defaultdict(lambda: [])
  cnts = defaultdict(lambda: 0)
  for s in S:
    if len(s)==1:
      hitomozi.append(s)
    else:
      d[s[0]].append(s[1:])
      c = Counter(s)
      for k in c.keys():
        cnts[k] += 1
  for h in hitomozi:
    ans[0] += cnts[h]
  for k,v in d.items():
    if len(v)<=1:
      continue
    saiki(v)

N = int(input())
S = [input()[::-1] for _ in range(N)]
ans = [0]
saiki(S)
print(ans[0])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
from collections import defaultdict,Counter
def saiki(cnts):
  hitomozi = []
  d = defaultdict(lambda: [])
  heads = defaultdict(lambda: 0)
  for s,c in cnts:
    if len(s)==1:
      hitomozi.append(s[0])
    else:
      for k,v in c.items():
        if v>0:
          heads[k] += 1
      t = s[-1]
      c[t] -= 1
      s.pop(-1)
      d[t].append([s,c])
  for h in hitomozi:
    ans[0] += heads[h]
  for v in d.values():
    if len(v)<=1:
      continue
    saiki(v)
  return 

N = int(input())
S = [list(input()) for _ in range(N)]
ans = [0]
cnts = []
for s in S:
  cnts.append([s,Counter(s)])
saiki(cnts)
print(ans[0])
### BUGGY CODE ###

def logic(N, K):
    count = 0
    for a in range(1, N + 1):
        b_s = K - (a % K)
        for b in range(b_s, N + 1, K):
            for c in range(b_s, N + 1, K):
                if (b + c) % K == 0:
                    count += 1
    return count

def main():
    N, K = map(int, input().split())
    print(logic(N, K))

if __name__ == '__main__':
    main()

### FIXED CODE ###

N, K = map(int,input().split())
print(int(N/K)**3+[int((N+K/2)/K)**3,0][K%2])
### BUGGY CODE ###

N = int(input())
L = map(int, input().split())
SL = sorted(list(L))
A = [0] * (10 ** 3 + 10)

for i in SL:
    A[i] = True
for i in range(len(A)):
    if A[i] == True:
        A[i] = A[i-1] + 1
    else:
        A[i] = A[i-1]

# print(A[4-1] - A[2])

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        # for k in range(j+1, N):
        #     a = SL[i]
        #     b = SL[j]
        #     c = SL[k]
        #     if a < b + c and b < c + a and c < a + b:
        #         ans += 1
        a = SL[i]
        b = SL[j]
        for k in range(j+1, N):
            c = SL[k]
            if abs(a - b) >= c:
                print('continue')
                continue
            elif c >= a + b:
                break
            else:
                ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
L = map(int, input().split())
SL = sorted(list(L))
# print('SL', SL)
import bisect

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ab = SL[i] + SL[j]
        # print(i, j)
        # print(SL[i], SL[j])
        r = bisect.bisect_left(SL, ab)
        l = j + 1
        # print('r', r)
        # print('l', l)
        # print('---')
        ans += max(0, r - l)

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

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

ans = 0
for i in range(60):
  num_one = len([1 for x in A if x & (1 << i)])
  ans = ans + (1 << i) * num_one * (N - num_one)
print(ans % 1000000007)

### FIXED CODE ###

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

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)
### BUGGY CODE ###

N, = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
def f(x):
    # q < x の数を探す
    c = 0
    for i, q in enumerate(Q):
        if q < x:
            c+=1
    return c
mxk = 28
msk = (1<<mxk) - 1
msk2 = (1<<(mxk-1))
r = 0
for i in range(mxk):
    # 下からiビット目をみる
    for j in range(N):
        Q[j] = Q[j] & msk
        P[j] = P[j] & msk
    msk >>= 1
    Q.sort()
#    print(mxk-1-i, P)
#    print(Q)
    b = 0
    for p in P:
        if p & msk2:
            # i bit が1になる
            # q < msk2 - p&msk
            # msk2 <= q < 2*msk2 - p
            # 0
            # msk2-p&msk <= q < msk2 
            # 2*msk2 - p <= q
            x = f(2*msk2 - (p&msk))
            z = f(msk2 - (p&msk))
#            print(x, y, z, msk2)
            b += z+N-x
#            print(p, z+N-x, msk2)
        else:
            x = f(2*msk2 - (p&msk))
            z = f(msk2 - (p&msk))
#            print(p, x, y, z)
#            print(2*msk2 - p&msk, msk2, msk2 - p&msk)
            b += x-z
#            print(p, x-z)
#    print(b)
    if b%2:
        r += 1<<(mxk-1-i)
    msk2 >>= 1
print(r)


### FIXED CODE ###

N, = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
mxk = 29
msk = (1<<mxk) - 1
msk2 = (1<<(mxk-1))
r = 0
for i in range(mxk):
    # 下からiビット目をみる
    for j in range(N):
        Q[j] = Q[j] & msk
        P[j] = P[j] & msk
    msk >>= 1
    P.sort()
    Q.sort()
    j1 = N-1
    j2 = N-1
    b = 0
    ss = N
#    print(P, Q)
    for l in range(N):
        if P[l] & msk2:
            ss = l
            break
        k1 = msk2 - (P[l]&msk)
        k2 = k1 + msk2
        while j1 >= 0:
            if Q[j1] < k1:
                break
            j1 -= 1
        while j2 >= 0:
            if Q[j2] < k2:
                break
            j2 -= 1
        b += j2 - j1
#        print("a",j2-j1,k1,k2,j1,j2)

    j1 = N-1
    j2 = N-1
#    print(ss)
    for l in range(ss, N):
        k1 = msk2 - (P[l]&msk)
        k2 = k1 + msk2
        while j1 >= 0:
            if Q[j1] < k1:
                break
            j1 -= 1
        while j2 >= 0:
            if Q[j2] < k2:
                break
            j2 -= 1
#        print("b",j1 - j2 + N)
        b += j1 + N - j2

#    b = 0
#    for p in P:
#        if p & msk2:
#            x = g(2*msk2 - (p&msk))
#            z = g(msk2 - (p&msk))
#            b += z+N-x
#        else:
#            x = g(2*msk2 - (p&msk))
#            z = g(msk2 - (p&msk))
#            b += x-z
#    print(b, r, i)
    if b%2:
        r += 1<<(mxk-1-i)
    msk2 >>= 1
print(r)
### BUGGY CODE ###

N,K = map(int,input().split())
A  = list(map(int,input().split()))
l,r=0,0
ans = 0
for i in range(N):
    if A[i] == min(A):
        ans += len(A[l:i])
        l = i+1
if A[-1] != min(A):
    ans += len(A[l:])
print(ans//(K-1) if ans%(K-1)==0 else ans//(K-1)+1)

### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 1
n = N-K
ans += n//(K-1)
ans += 1 if n%(K-1) != 0 else 0
print(ans)
### BUGGY CODE ###

import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))


v=[[1,0],[-1,0],[0,1],[0,-1]]
h,w=mp()
grid=["#"*(w+2)]
ans=[]
for i in range(h):
    grid.append("#"+input()+"#")
grid.append("#"*(w+2))
for i in range(h*w):
    for j in range(h*w):
        if grid[i//w+1][i%w+1]=="." and grid[j//w+1][j%w+1]==".":
            sx,sy,gx,gy=i//w+1,i%w+1,j//w+1,j%w+1
            que=deque([[sx,sy,0]])
            while len(que):
                q=que.popleft()
                if q[0]==gx and q[1]==gy:
                    ans.append(q[2])
                    break
                for x,y in v:
                    if grid[q[0]+x][q[1]+y]==".":
                        que.append([q[0]+x,q[1]+y,q[2]+1])
print(max(ans))

### FIXED CODE ###

import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))


v=[[1,0],[-1,0],[0,1],[0,-1]]
h,w=mp()
grid=["#"*(w+2)]
ans=[]
for i in range(h):
    grid.append("#"+input()+"#")
grid.append("#"*(w+2))
for i in range(h*w):
    ch=[[0]*(w+2) for i in range(h+2)]
    if grid[i//w+1][i%w+1]==".":
        sx,sy=i//w+1,i%w+1
        que=deque([[sx,sy,0]])
        while len(que):
            q=que.popleft()
            ch[q[0]][q[1]]=1
            ans.append(q[2])
            for x,y in v:
                if grid[q[0]+x][q[1]+y]=="." and ch[q[0]+x][q[1]+y]==0:
                    ch[q[0]+x][q[1]+y]=1
                    que.append([q[0]+x,q[1]+y,q[2]+1])
            
print(max(ans))
### BUGGY CODE ###

def count_up(N, A, x, check, card, total):
  if check == N:
    return 1 if card > 0 and card * A == total else 0
  else:
    return count_up(N, A, x, check+1, card+1, total+x[check]) + count_up(N, A, x, check+1, card, total)

def bad_method(N, A, x):
  print count_up(N, A, x, 0, 0, 0)

line = raw_input().split()
N = int(line[0])
A = int(line[1])
line = raw_input().split()
x = {}
for i in range(N):
  x[i] = int(line[i])

bad_method(N, A, x)

### FIXED CODE ###

def count_up(N, A, x, check, card, total):
  if check == N:
    return 1 if card > 0 and card * A == total else 0
  else:
    return count_up(N, A, x, check+1, card+1, total+x[check]) + count_up(N, A, x, check+1, card, total)

def bad_method(N, A, x):
  print count_up(N, A, x, 0, 0, 0)

def well_method(N, A, x):
  dp = [[[1 for a in range(N*50)] for b in range(N+1)] for c in range(N+1)]
  for j in range(N+1):
    for k in range(N+1):
      for s in range(N*50):
        if j == 0 and k == 0 and s == 0:
          dp[j][k][s] = 1
        elif j >= 1 and s < x[j-1]:
          dp[j][k][s] = dp[j-1][k][s]
        elif j >= 1 and k >= 1 and s >= x[j-1]:
          dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
        else:
          dp[j][k][s] = 0

  answer = 0
  for i in range(1, N+1):
    answer += dp[N][i][A * i]
  print answer

def good_method(N, A, x):
  y = {}
  for i in range(len(x)):
    y[i] = x[i] - A
  dp = [[0 for a in range(N*50*2+1)] for b in range(N+1)]
  for j in range(N+1):
    for t in range(N*50*2+1):
      if j == 0 and t == N*50:
        dp[j][t] = 1
      elif j >= 1 and (t - y[j-1] < 0 or t - y[j-1] > N*50*2):
        dp[j][t] = dp[j-1][t]
      elif j >= 1 and 0 <= t - y[j-1] and t - y[j-1] <= N*50*2:
        dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j-1]]
      else:
        dp[j][t] = 0

  print dp[N][N*50]-1

line = raw_input().split()
N = int(line[0])
A = int(line[1])
line = raw_input().split()
x = {}
for i in range(N):
  x[i] = int(line[i])

# bad_method(N, A, x)
# well_method(N, A, x)
good_method(N, A, x)
### BUGGY CODE ###

import itertools

K,S=map(int,input().split())
a=list(range(K+1))
#print(a)
combi=list(itertools.product(a,repeat=3))
#print(combi)
print([sum(combi[i]) for i in range(len(combi))].count(S))

### FIXED CODE ###

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

X,Y,Z,K = map(int,input().split())
*A, = map(int,input().split())
*B, = map(int,input().split())
*C, = map(int,input().split())
AB = sorted(a+b for a in A for b in B)[::-1][:K]
ABC = sorted(ab+c for ab in AB for c in C)[::-1][:K]
print(*ABC,sep="\n")

### FIXED CODE ###

X,Y,Z,K = list(map(int,input().split()))
A = sorted(list(map(int,input().split())),reverse=True)
B = sorted(list(map(int,input().split())),reverse=True)
C = sorted(list(map(int,input().split())),reverse=True)

ma,mb,mc = A[0],B[0],C[0]
sA = [a-ma for a in A] + [-10**15]
sB = [b-mb for b in B] + [-10**15]
sC = [c-mc for c in C] + [-10**15]

ia,ib,ic = 0,0,0
while min(10**5,(X)*(Y)*(Z)) > (ia+1)*(ib+1)*(ic+1):
    m = max(sA[ia+1],sB[ib+1],sC[ic+1])
    if ia < (X-1) and sA[ia+1] == m:
        ia = min(ia+1,X-1)
    if ib < (Y-1) and sB[ib+1] == m:
        ib = min(ib+1,Y-1)
    if ic < (Z-1) and sC[ic+1] == m:
        ic = min(ic+1,Z-1)
ans = []
for a in A[:ia+1]:
    for b in B[:ib+1]:
        for c in C[:ic+1]:
            ans.append(a+b+c)
ans.sort(reverse=True)
for out in ans[:K]:
    print(out)