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

from math import ceil
INF = float('inf')
d, g = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(d)]
def f(data, score, targets):
  if score <= 0:
    return 0
  result = INF
  for i in targets:
    t = ceil(score / ((i + 1) * 100))
    if t < data[i][0]:
      result = min(result, t)
  for i in range(len(targets)):
    j = targets[i]
    x = (j + 1) * 100 * data[j][0] + data[j][1]
    t = data[j][0] + f(data, score - x, targets[0:i] + targets[i + 1:])
    result = min(result, t)
  return result
print(f(data, g, list(range(len(data)))))


### FIXED CODE ###

INF = float('inf')
d, g = map(int, input().split())
data = []
for i in range(d):
  p, c = map(int, input().split())
  data.append([p, c, (i + 1) * 100, (i + 1) * 100 * p + c])
def f(data, total, targets):
  if total <= 0:
    return 0
  result = INF
  for i in targets:
    score = data[i][2]
    t = (total + score - 1) // score
    if t < data[i][0] and t < result:
      result = t
  for i in range(len(targets)):
    j = targets[i]
    p, c, score, subtotal = data[j]
    t = p + f(data, total - subtotal, targets[0:i] + targets[i + 1:])
    if t < result:
      result = t
  return result
print(f(data, g, list(range(len(data)))))
### BUGGY CODE ###

K, S = map(int, input().split())
ans = 0
for x in range(K + 1):
  for y in range(K + 1):
    for z in range(K + 1):
      if x + y + z == S:
        ans += 1

print(ans)

### FIXED CODE ###

K, S = map(int, input().split())

ans = 0
for i in range(K + 1):
  for j in range(K + 1):
    if i + j == S:
      ans += 1
    elif 0 <= S - (i + j) <= K:
      ans += 1
print(ans)
### BUGGY CODE ###

import sys
n = int(input())
a = list(map(int, input().split()))
ans = 0
flag = 0
if n % 2 == 1:
  if a.count(0) != 1:
    print(0)
    sys.exit()
  else:
    sa = n-1
    while sa > 0:
      if a.count(sa) != 2:
        print(0)
        sys.exit()
      sa -= 2
else:
  if a.count(0) != 0:
    print(0)
    sys.exit()
  else:
    sa = n-1
    while sa > 0:
      if a.count(sa) != 2:
        print(0)
        sys.exit()
      sa -= 2


print(2 ** (n // 2))


### FIXED CODE ###

import math
N = int(input())


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

A.sort()
ans = 0
flag = True
if N % 2 == 1:
  # 0,2,2,4,4,～みたいに並んでるはず
  if A[0] == 0:
    for i in range(1,N,2):
      if A[i] != i+1 or A[i+1] != i+1:
        flag = False
        break
  
    if flag: ans = 2**(N//2) % (10**9 + 7)

else:
  if A[0] != 0:
    for i in range(0,N,2):
      if A[i] != i+1 or A[i+1] != i+1:
        flag = False
        break
  
    if flag: ans = 2**(N//2) % (10**9 + 7)
    
    
    
print(ans)
### BUGGY CODE ###

n = int(input())
list_ = list(map(int, input().split()))

for i in range(1,n+1):
  print(list_.count(i))

### FIXED CODE ###

n = int(input())

list_ = [0]*n
joshi_list = list(map(int, input().split()))[::-1]

for i,num in enumerate(joshi_list):
  list_[num-1]+=1

for num in list_:
  print(num)
### BUGGY CODE ###

N = int(input())
S = input()

ans = float('inf')
for i in range(N):
    cnt = S[0:i].count('W') + S[i+1:].count('E')
    if ans > cnt:
        ans = cnt

print(ans)

### FIXED CODE ###

N = int(input())
S = input()

ans = float('inf')
sum_E = [0]
sum_W = [0]
cnt_e = 0
cnt_w = 0

for i in range(N):
	if S[i] == 'E':
		cnt_e += 1
	else:
		cnt_w += 1
	sum_E.append(cnt_e)
	sum_W.append(cnt_w)

for i in range(N):
	ans = min(ans, sum_W[i] + sum_E[-1] - sum_E[i+1])

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

n=int(input())
s=[input() for _ in range(n)]
ans=0
for i in range(n):
    lst=list(s[i])
    for j in range(i+1,n):
        lst1=list(s[j])
        for k in lst:
            for l in lst1:
                if k==l:
                    lst1.remove(l)
                    break
        if len(lst1)==0:
            ans+=1
print(ans)


### FIXED CODE ###

n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


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

K, S = list(map(int, input().split()))
count = 0

for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if x + y + z == S:
                count += 1

print(count)

### FIXED CODE ###

K, S = list(map(int, input().split()))
count = 0

for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if z >= 0 and z <= K:
            count += 1

print(count)
### BUGGY CODE ###

import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
input=sys.stdin.readline
h,w=map(int,input().split())
a=[list(map(str,input())) for _ in range(h)]
b=deque()
n=[-1]*(h*w)
c=0
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
             b.append((i,j))
             n[i*w+j]=0
        else:
            continue
while b:
    z=b.popleft()
    i=z[0]
    j=z[1]
    if i<h-1 and a[i+1][j]=="." and n[(i+1)*w+j]==-1:
      n[(i+1)*w+j]=n[i*w+j]+1
      c=max(c,n[i*w+j]+1)
      b.append(((i+1),j))
      f=True
    if i>0 and a[i-1][j]=="." and n[(i-1)*w+j]==-1:
      n[(i-1)*w+j]=n[i*w+j]+1
      c=max(c,n[i*w+j]+1)
      b.append(((i-1),j))
      f=True
    if j<w-1 and a[i][j+1]=="." and n[i*w+(j+1)]==-1:
      f=True
      n[i*w+(j+1)]=n[i*w+j]+1
      c=max(c,n[i*w+j]+1)
      b.append((i,(j+1)))
    if j>0 and a[i][j-1]=="."  and n[i*w+(j-1)]==-1:
      f=True
      n[i*w+(j-1)]=n[i*w+j]+1
      c=max(c,n[i*w+j]+1)
      b.append((i,(j-1)))
   
print(c)
        

### FIXED CODE ###

import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
input=sys.stdin.readline
h,w=map(int,input().split())
a=[list(map(str,input())) for _ in range(h)]
b=deque()
n=[-1]*(h*w)
c=0
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
             b.append((i,j))
             n[i*w+j]=0
        else:
            continue
p = [(1,0),(-1,0),(0,1),(0,-1)]

while b:
    i,j=b.popleft()
    for s,t in p:
      if 0 <= i+s <= h-1 and 0 <= j+t <= w-1:
        if n[(i+s)*w+(j+t)]==-1:
          n[(i+s)*w+(j+t)]=n[i*w+j]+1
          c=max(c,n[i*w+j]+1)
          b.append(((i+s),(j+t)))
    
print(c)
### BUGGY CODE ###

n = int(input())
x = list(map(int, input().split()))

for i in range(n):
    temp = sorted(x[:i] + x[i + 1:])
    ans = temp[n // 2 - 1]
    print(ans)


### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))

y = sorted(x)
mid1 = y[(n + 1) // 2]
mid2 = y[(n - 1) // 2]

for i in range(n):
    if mid1 == mid2:
        ans = mid1
    elif x[i] >= mid1:
        ans = mid2
    elif x[i] <= mid2:
        ans = mid1

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

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

#dp[足場i]=足場iにたどり着く最小コスト
dp = [10**10 for _ in range(N+10)]

dp[0] = 0
for i in range(N):
    for k in range(1,K+1):
        if i+k <= N-1:
            dp[i+k] = min(dp[i+k], dp[i] + abs(H[i]-H[i+k]))

print(dp[N-1])


### FIXED CODE ###

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

#dp[足場i]=足場iにたどり着く最小コスト
dp = [10**10 for _ in range(N+10)]

dp[0] = 0
for i in range(N):
    for k in range(1,min(K+1,N-i)):
        dp[i+k] = min(dp[i+k], dp[i] + abs(H[i]-H[i+k]))

print(dp[N-1])
### BUGGY CODE ###

import itertools
H,W,K = map(int,input().split())
S = []
for i in range(H):
  s= map(int,input())
  S.append(list(s))
l = list(itertools.product([0,1], repeat=H-1))
l = [list(li) for li in l]
for i in range(len(l)):
  l[i] = [j+1 for j in range(len(l[i])) if l[i][j] > 0]
  
S_t = [list(x) for x in zip(*S)]
for i in range(W):
  for j in range(1,H):
    S_t[i][j] += S_t[i][j-1]
flag = False  
min_cnt = H*W
for i in range(len(l)):
  cnt = 0
  bh = [0]+[li  for li in l[i] if li > 0]+[H]
  white = [0]*(len(bh)-2+1)
  j = 0
  while j < W:
    if flag == True:
      white = [0]*(len(bh)-2+1)
      cnt += 1
      flag = False
    for k in range(len(bh)-1):
      if bh[k] == 0:
        su = S_t[j][bh[k+1]-1]
      else:
        su = S_t[j][bh[k+1]-1]-S_t[j][max(0,bh[k]-1)]
      if white[k] + su > K:
        flag = True
        break
      white[k] += su
    if flag == False:
      j += 1
  min_cnt = min(cnt+len(bh)-2,min_cnt)
  
print(min_cnt)
    
      

    

### FIXED CODE ###

import itertools
H,W,K = map(int,input().split())
S = []
for i in range(H):
  s= map(int,input())
  S.append(list(s))
l = list(itertools.product([0,1], repeat=H-1))
l = [list(li) for li in l]
for i in range(len(l)):
  l[i] = [j+1 for j in range(len(l[i])) if l[i][j] > 0]
  
S_t = [list(x) for x in zip(*S)]
for i in range(W):
  for j in range(1,H):
    S_t[i][j] += S_t[i][j-1]
flag = False  
min_cnt = H*W
for i in range(len(l)):
  cnt = 0
  bh = [0]+[li  for li in l[i] if li > 0]+[H]
  white = [0]*(len(bh)-2+1)
  j = 0
  while j < W:
    if flag == True:
      white = [0]*(len(bh)-2+1)
      cnt += 1
      flag = False
    for k in range(len(bh)-1):
      if bh[k] == 0:
        su = S_t[j][bh[k+1]-1]
      else:
        su = S_t[j][bh[k+1]-1]-S_t[j][max(0,bh[k]-1)]
      if white[k] + su > K:
        if su > K:
          j = W
          cnt = H*W+1
          flag = False
        else:
          flag = True
        break
      white[k] += su
    if flag == False:
      j += 1
  min_cnt = min(cnt+len(bh)-2,min_cnt)
  
print(min_cnt)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(200000)

n = int(input())

Adj_dict = {}
All_edges = []
for i in range(n):
    new = {i:[]}
    Adj_dict.update(new)
for _ in range(n-1):
    a, b = map(int, input().split())
    Adj_dict[a-1].append(b-1)
    Adj_dict[b-1].append(a-1)
    All_edges.append((a-1,b-1))

max_val_count = 0
start_node = 0
for key, val in Adj_dict.items():
    if len(val) >= max_val_count:
        max_val_count = len(val)
        start_node = key


Visited = [False for _ in range(n)]
Colors_use = [False for _ in range(max_val_count)]
Colors_use_raw = [False for _ in range(max_val_count)]

edges_colors = {}

def coloring(Adj_dict, start, Visited, Colors_use):
    
    # 終端処理
    if Visited[start]:
        return
    
    Visited[start] = True

    for node in Adj_dict[start]:
        if Visited[node] == False:
            color = Colors_use.index(False) + 1
            Colors_use[color-1] = True
            
            edge_color = {(min(node, start), max(node, start)): color}
            edges_colors.update(edge_color)
            
            New_Colors_use = Colors_use_raw.copy()
            New_Colors_use[color-1] = True
            
            coloring(Adj_dict, node, Visited, New_Colors_use)
    return

coloring(Adj_dict, start_node, Visited, Colors_use)

print(max_val_count)
for edge in All_edges:
    print(edges_colors[edge])

### FIXED CODE ###

from collections import deque

n = int(input())
Adj_dict = {x:[] for x in range(1,n+1)}
AB_dict = {}
AB = []
for _ in range(n-1):
    a, b = map(int, input().split())
    Adj_dict[a].append(b)
    Adj_dict[b].append(a)
    AB.append([a,b])
    AB_dict.update({str(a)+'_'+str(b):0})

max_edges = 0
node_max_edges = 0
for key, value in Adj_dict.items():
    edges = len(value)
    if edges >= max_edges:
        max_edges = edges
        node = key

dq = deque()
dq.append(1)

Visited = [False for _ in range(n+1)]
Visited[1] = True
Colors = [0 for _ in range(n+1)]

while dq:
    c = 1
    node = dq.popleft()
    Next_nodes = Adj_dict[node]

    for next_node in Next_nodes:
        if Visited[next_node] == True:
            continue
        dq.append(next_node)
        Visited[next_node] = True

        if c == Colors[node]:
            c += 1
        Colors[next_node] = c
        c += 1
        if node < next_node:
            AB_dict[str(node)+'_'+str(next_node)] = Colors[next_node]
        else:
            AB_dict[str(next_node)+'_'+str(node)] = Colors[next_node]

print(max_edges)
for ab in AB:
    a = ab[0]
    b = ab[1]
    print(AB_dict[str(a)+'_'+str(b)])
# print(AB_dict)
### BUGGY CODE ###

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

i=0
j=0
while True:
    j+=1
    if a[i]==1:
        print(j)
        break
    elif a[i]==0:
        print(-1)
        break
    else:
        i=a[i]


### FIXED CODE ###

n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)
'''
#TLEチーンコ
i=0
j=0
b=[]
while True:
    j+=1
    if a[i]==1:
        print(j)
        break
    elif a[i] in b:
        print(-1)
        break
    else:
        b.append(a[i])
        i=a[i]
'''
i=0
j=0
while True:
    j+=1
    if a[i]==1:
        print(j)
        break
    elif j==n:
        print(-1)
        break
    else:
        i=a[i]
### BUGGY CODE ###

import sys

S = input()
Q = int(input())
QUERY = sys.stdin.readlines()

state = 0
q1 = ''
q2 = ''
for i in range(Q):
    query = QUERY[i]
    if query[0] == '1':
        state ^= 1
    else:
        _, F, C = query.split()
        if (state + int(F)) % 2:
            q1 += C
        else:
            q2 += C

ans = ''
if state == 0:
    print(q1[::-1], end='')
    print(S, end='')
    print(q2)
else:
    print(q2[::-1], end='')
    print(S[::-1], end='')
    print(q1)


### FIXED CODE ###

import sys

S = input()
Q = int(input())
QUERY = sys.stdin.readlines()

state = 0
q1 = ''
q2 = ''
for i in range(Q):
    query = QUERY[i]
    if query[0] == '1':
        state ^= 1
    else:
        _, F, C = query.split()
        if (state + int(F)) % 2:
            q1 += C
        else:
            q2 += C

ans = ''
if state == 0:
    print(q1[::-1], end='')
    print(S, end='')
    print(q2)
else:
    print(q2[::-1], end='')
    print(S[::-1], end='')
    print(q1)
### BUGGY CODE ###

import collections

def comb2(n):
    return int(n * (n - 1) / 2)

def dictcomb(dic):
    ans = 0
    for key in dic:
        ans += comb2(dic[key])
    return ans

def solve(a, dic):
    for i in a:
        dic[i] -= 1
        print(dictcomb(dic))
        dic[i] += 1

def main():
    n = int(input())
    a = list(map(int,input().split()))
    d = collections.Counter(a)
    solve(a, d)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import collections

def comb2(n):
    return int(n * (n - 1) / 2)

def combdict(dic, dp):
    ans = 0
    for v in dic.values():
        ans += dp[v]
    return ans

def solve(a, dic, dp):
    allsum = combdict(dic,dp)
    for i in a:
        print(allsum - dp[dic[i]] + dp[dic[i]-1])

def main():
    dp = [comb2(i) for i in range(2 * ( 10 ** 5) + 1)]
    n = int(input())
    a = list(map(int,input().split()))
    d = collections.Counter(a)
    solve(a, d, dp)

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

N, M = map(int, input().split())
requests = [tuple(map(int, input().split())) for _ in range(M)]
requests.sort(key=lambda x: x[1])
connects = [1] * N
for a, b in requests:
    if all(connects[a:b]):
        connects[b-1] = 0
print(connects.count(0))

### FIXED CODE ###

N, M = map(int, input().split())
requests = [tuple(map(int, input().split())) for _ in range(M)]
requests.sort(key=lambda x: x[1])
counts = 0
left = 0
for a, b in requests:
    if a >= left:
        left = b
        counts += 1
print(counts)
### BUGGY CODE ###

n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())
s = list(set(s))

count = 0
for i in t:
    if i in s:
        count += 1

print count

### FIXED CODE ###

n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
l = len(s)-1

count = 0
for i in t:
    low = 0
    high = l
    while low <= high:
        mid = (low+high)/2
        if s[mid] == i:
            count += 1
            break
        if s[mid] < i:
            low = mid+1
        else:
            high = mid-1

print count
### BUGGY CODE ###

A, B, K = list(map(int, input().split()))
for i in range(A,B+1):
    if (i < A+K) or (i>B-K):
        print(i)

### FIXED CODE ###

A, B, K = list(map(int, input().split()))

if abs(A-B)<K:
    for i in range(A, B+1):
        print(i)
else:
    x = {i for i in range(A, A+K)}
    y = {j for j in range(B-K+1, B+1)}
    z = x | y
    z = sorted(list(z))
    for a in z:
        print(a)
### BUGGY CODE ###

n,m=map(int, input().split(" "))
#min=0
#max=1000000000
arr=[[0,100000000]]
for i in range(m):
    flag=1
    a,b=map(int, input().split(" "))
    for j in arr:
        flag=1
        if j[0]<=a and j[1]>=b:
            arr.remove(j)
        elif j[0]>=a and j[1]<=b:
            flag=0
            break
    if flag==1:
        arr.append([a,b])

arr.sort(key=lambda x:x[0])
#print(arr)
#count=0
num=0
count=0
for i in range(len(arr)):
    if arr[i][0]-num>=0:
        count+=1
        num=arr[i][1]

print(count)

### FIXED CODE ###

n,m=map(int, input().split(" "))
arr=[]
for i in range(m):
    a,b=map(int, input().split(" "))

    arr.append([a,b])

#arr.sort(key=lambda x:x[0])
arr.sort(key=lambda x:(x[0],x[1]))
left=0
num=0
count=0
for i in range(len(arr)):
    if arr[i][0]==left:
        pass
    if arr[i][1]<=num:
        num=arr[i][1]
    if arr[i][0]-num>=0:
        count+=1
        num=arr[i][1]
        left=arr[i][0]
    #print(arr[i],count)
print(count)
### BUGGY CODE ###

[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = []
for i in range(N-L+1) : 
    B = A[i:i+L]
    B.sort()
    ans.append(B[0])
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*(2*N)        
for x in range(0,N):
    for y in range(0,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])


### FIXED CODE ###

from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(x,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])
### BUGGY CODE ###

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
S = []
for x in A:
    for y in B:
        S.append(x+y)
S.sort(reverse = True)
S1 = []
for i in range(min(K,X*Y)):
    for z in C:
        S1.append(S[i]+z)
S1.sort(reverse = True)
for i in range(K):
    print(S1[i])

### FIXED CODE ###

from heapq import nlargest

x,y,z,k = map(int,input().split())
A,B,C = [list(map(int,input().split())) for _ in [0]*3]

AB = nlargest(k,[a+b for a in A for b in B])
ABC = nlargest(k,[ab+c for ab in AB for c in C])
print("\n".join(map(str,ABC)))
### BUGGY CODE ###

n=int(input())
s=input()
ans=0

for i in range(n):
  Z=[0]*n
  for j in range(i+1,n):
    if s[i]==s[j]:
      k=0
      while i+k<j and j+k<n and s[i+k]==s[j+k]:
        k+=1
      Z[j]=k
    else:
      Z[j]=0
  ans=max(ans,max(Z))
print(ans)

### FIXED CODE ###

def main():
  n=int(input())
  s=input()
  dp=[[0]*(n+1) for i in range(n+1)]
  for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
      if s[i]==s[j]:
        dp[i][j]=dp[i+1][j+1]+1
  #for i in dp:
  #  print(i)
  
  ans=0
  for i in range(n-1):
    for j in range(i+1,n):
      ans=max(ans,min(j-i,dp[i][j]))
  print(ans)      
        

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

def main():
    #入力
    n, a = map(int,input().split())
    x = list(map(int,input().split()))

    #パターン0~2^n
    #ptの0bit目が0->x1を選択する
    pt = 0
    count = 0

    for pt in range(2**n):
        #ptにしたがって選択カードの合計を計算
        sum_tmp = 0
        num_tmp = 0
        average = 0
        for j in range(n):
            if (pt >> j)&1 :
                sum_tmp += x[j]
                num_tmp += 1
        
        #選択カードの合計から平均を計算
        if num_tmp!=0:
            average = sum_tmp/num_tmp

        if average == a:
            count += 1
        
    print(count)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    #入力
    n, a = map(int,input().split())
    x = [0] + list(map(int,input().split()))

    sum_max = (n)*(max(x))+1

    #dp[i][j][k]:x1-xiからj枚選んで、合計をkにする選び方の数
    dp = [[[0]*2501 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(n+1):
            for k in range(50*j+1):
                #xi>kのとき
                if x[i]>k:
                    dp[i][j][k] = dp[i-1][j][k]
                elif j>=1 and x[i]<=k:
                    #xi<=kのとき
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]]

    count = 0
    for j in range(1,n+1):
        count += dp[n][j][j*a]
    
    print(count)


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

N = int(input())
S = input()

r , g, b = S.count("R"), S.count("G"), S.count("B")
ans = r * g * b

for i in range(N-2):
    for d in range(N//2+1):
        j = i + d
        k = j + d
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
print(ans)

### FIXED CODE ###

N = int(input())
S = input()

r , g, b = S.count("R"), S.count("G"), S.count("B")
ans = r * g * b

for i in range(N-2):
    for d in range(N//2+1):
        j = i + d
        k = j + d
        if k >= N:break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)