Harryxun/stf_run huggingface dataset:
N = int(input())
S = input()

for i in reversed(range(N)):
    if S[i] == ")":
        tmp = i
        break
left = ""
for i in range(N-tmp-1):
    left += ")"

migi_kakko = 0
hidari_kakko = 0
for i in range(tmp+1):
    if S[i] == ")":
        migi_kakko += 1
    else:
        hidari_kakko += 1

right = ""
for i in range(migi_kakko-hidari_kakko):
    right += "("
for i in range(hidari_kakko-migi_kakko):
    left += ")"

ans = ""
ans += right
ans += S
ans += left
print(ans)


### FIXED CODE ###

# 始めカッコの個数を先に確定させる
# ある特定の時点で")"の方が多いなら、あとから"("が出て来ても遅い
ans = 0  # これの最小値になった絶対値分を文頭につける
N = int(input())
S = input()
hazimekakko = 0
owarikakko = 0
for i in range(N):
    if S[i] == "(":
        hazimekakko += 1
    else:
        owarikakko += 1
    ans = max(ans, owarikakko-hazimekakko)
# 終わりかっこの方が多いタイミングのその量を確定させる
S = abs(ans)*"(" + S

hazimekakko = 0
owarikakko = 0
for i in range(len(S)):
    if S[i] == "(":
        hazimekakko += 1
    else:
        owarikakko += 1

S = S + (hazimekakko-owarikakko)*")"
print(S)
s=list(map(int,tuple(input())))
k=int(input())
i=0
if 1 in s:
  i=s.index()
  if i+1>=k:
      print(1)
  else:
      print(s[i+1])
else:
  print(s[0])

### FIXED CODE ###

s=list(map(int,tuple(input())))
k=int(input())
i=0
if 1 in s:
  for i in range(len(s)):
    if s[i]!=1:
      break
  if i>=k:
      print(1)
  else:
      print(s[i])
else:
  print(s[0])
s = input()
dp = [[0]*13 for _ in range(len(s))]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][s[0]] = 1
for k in range(len(s)-1):
    if s[k+1] == '?':
        for i in range(13):
            for j in range(10):
                dp[k+1][((i*10%13)+j)%13] += dp[k][i]
                dp[k+1][((i*10%13)+j)%13] %= (10**9+7)
    else:
        for i in range(13):
            dp[k+1][((i*10%13)+int(s[k+1]))%13] += dp[k][i]
            dp[k+1][((i*10%13)+int(s[k+1]))%13] %= (10**9+7)
print(dp[-1][5])


### FIXED CODE ###

s = input()
dp = [[0]*13 for _ in range(len(s))]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
for k in range(len(s)-1):
    if s[k+1] == '?':
        for i in range(13):
            for j in range(10):
                dp[k+1][((i*10%13)+j)%13] += dp[k][i]
                dp[k+1][((i*10%13)+j)%13] %= (10**9+7)
    else:
        for i in range(13):
            dp[k+1][((i*10%13)+int(s[k+1]))%13] += dp[k][i]
            dp[k+1][((i*10%13)+int(s[k+1]))%13] %= (10**9+7)
print(dp[-1][5])
def main():
    n = int(input())
    matrix = [int(num) for num in [input().split() for _ in range(2)]]

    candies = [sum(matrix[0][:d+1]) + sum(matrix[1][d:]) for d in range(n)]
    print(max(candies))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    matrix = []
    matrix.append([int(num) for num in input().split()])
    matrix.append([int(num) for num in input().split()])

    candies = [sum(matrix[0][:d+1]) + sum(matrix[1][d:]) for d in range(n)]
    print(max(candies))


if __name__ == '__main__':
    main()
a,b=map(input().split())
if a=="H" and b== "H":print("H")
elif a=="H" and b== "D":print("D")
elif a=="D" and b== "H":print("D")
else:print("H")


### FIXED CODE ###

a,b=input().split()
if a=="H" and b== "H":print("H")
elif a=="H" and b== "D":print("D")
elif a=="D" and b== "H":print("D")
else:print("H")
import math
a, b , c, d = map(int, input().split())
def num_cm(a, b, m):
    if a % m == 0:
        return (b//m) - (a//m) + 1 
    else:
        return (b//m) - (a//m)
lcm = (c * d) // math.gcd(c, d)
ans =  b - a + 1 - num_cm(a, b, c) - num_cm(a, b, d) + num_cm(a, b, lcm)
print(ans)

### FIXED CODE ###

a, b , c, d = map(int, input().split())
def num_cm(a, b, m):
    if a % m == 0:
        return (b//m) - (a//m) + 1 
    else:
        return (b//m) - (a//m)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a    
lcm = (c * d) // gcd(c, d)
ans =  b - a + 1 - num_cm(a, b, c) - num_cm(a, b, d) + num_cm(a, b, lcm)
print(ans)
n=int(input())
a=list(map(int,input().split()))
c=0
idx = list()
for i in range(n-1):
  if a[i]>a[i+1]:
    idx.append(i)
    c+=1
print("YES" if c<2 or c==2 and a[idx[0]-1]<a[idx[1]+1]<a[idx[0]+1] and a[idx[1]]<a[idx[0]]<a[idx[1]+2] else "NO")
  


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n-1):
  if a[i]!=i+1:
    c+=1
print("YES" if c<3 else "NO")
n = int(input())
A = list(map(int, input().split()))
A = list(map(lambda x: x//400, A))
#print(A)

import collections
c = collections.Counter(A)
#print(c)
f1 = f2 = 0
for k in c.keys():
    if k >= 8:
        f1 += 1
        f2 += c[k]
if f1 == 0:
    min_ = max_ = len(c.keys())

else:
    min_ = len(c.keys()) -f1
    max_ = len(c.keys()) -f1 +f2
if max_ >8:
    max_ = 8
if mix_ <0:
    min_ = 0
print(min_, max_)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
A = list(map(lambda x: x//400, A))
#print(A)

import collections
c = collections.Counter(A)
#print(c)
f1 = f2 = 0
for k in c.keys():
    if k >= 8:
        f1 += 1
        f2 += c[k]
        
if f1 == 0:
    min_ = max_ = len(c.keys())

else:
    min_ = len(c.keys()) -f1
    max_ = len(c.keys()) -f1 +f2
'''if max_ >8:
    max_ = 8'''
if min_ <1:
    min_ = 1
print(min_, max_)
(h, w) = map(int, input().split())
sw = [['.' for i in range(h + 2)]]
for i in range(w):
    sw.append(['.'] + list(input()) + ['.'])
sw.append(['.' for i in range(h + 2)])

dirs = [[1, 0], [-1, 0], [0, 1], [0, -1]]
ng = False
for i in range(1, w + 1):
    if ng == True:
        break
    for j in range(1, h + 1):
        if ng == True:
            break
        if sw[i][j] == '.':
            continue
        ok = False
        for dir in dirs:
            if sw[i + dir[0]][j + dir[1]] == '#':
                ok = True
                break
        if ok == False:
            print('No')
            ng = True
if ng == False:
    print('Yes')

### FIXED CODE ###

import sys
(h, w) = map(int, input().split())
D = '.'
sw = []
sw.append([D for i in range(w + 2)])
for i in range(h):
    sw.append([D] + list(input()) + [D])
sw.append([D for i in range(w + 2)])

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if sw[i][j] == D:
            continue
        ok = False
        for dir in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
            if sw[i + dir[0]][j + dir[1]] == '#':
                ok = True
                break
        if ok == False:
            print('No')
            sys.exit(0)
print('Yes')
def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a

n = input()
print(2*n/gcd(2,n))

### FIXED CODE ###

def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a

n = int(input())
print(2*n//gcd(2,n))
s=[int(0) for i in range(26)]
for s in input():
    x=input()
    if x[len(list(x))-1]=='EOF':
        break
    for i in range(len(list(x))):
        if 97<=ord(list(x)[i].lower())<=122:
            s[ord(list(x)[i].lower())-97]=s[ord(list(x)[i].lower())-97]+1
    
for i in range(26):
    print(chr(97+i),":",s[i])

### FIXED CODE ###

s=[int(0) for i in range(26)]
while True:
    try:
        x=input()
        for i in range(len(list(x))):
            if 97<=ord(list(x)[i].lower())<=122:
                s[ord(list(x)[i].lower())-97]=s[ord(list(x)[i].lower())-97]+1
    except EOFError:
        break
for i in range(26):
    print(chr(97+i),":",s[i])
# -*- coding: utf-8 -*-
from sys import stdin, stdout


def read():
    x0 = stdin.readline().rstrip()
    return x0


def __main__():

    n, k = map(int, read().split())

    if n == 0 or k == 1:
        r = 0
    else:
        d = abs(n-k)
        r = n % d
        if abs(r-d) < r:
            r = abs(r-d)

    print(r)

__main__()

### FIXED CODE ###

# -*- coding: utf-8 -*-
from sys import stdin, stdout


def read():
    x0 = stdin.readline().rstrip()
    return x0


def __main__():

    n, k = map(int, read().split())

    if n == 0 or k == 1:
        r = 0
    else:
        r = n % k
        if abs(r-k) < r:
            r = abs(r-k)

    print(r)
    
__main__()
import numpy as np

N,H = map(int,input().split())
ab = np.asarray([list(map(int,input().split())) for _ in range(N)])

#ソート
a_sort = sorted(ab[:,0], reverse=True)
b_sort = sorted(ab[:,1], reverse=True)
ab_sort = sorted(ab.reshape(2*N), reverse=True)

ans = 0
i = 0 #ab_sortの中で大きいのから順に引いていく
while H > 0:
  H -= ab_sort[i]
  ans += 1
  if np.sum(b_sort == ab_sort[i]): #値がbにあれば次に大きい値を引く
    i += 1
    
print(ans)

### FIXED CODE ###

import numpy as np
 
N,H = map(int,input().split())
ab = np.asarray([list(map(int,input().split())) for _ in range(N)])
 
 
#bのうち大きなものから引いていく
#b[i]のうち、max(a)が大きければ、以降max(a)で攻撃し続ける
 
max_a = np.max(ab[:,0])
b_sort = np.sort(ab[:,1])[::-1] #降順
 
ans = 0
 
b_sort = b_sort[np.where(b_sort > max_a)]
 
#b_sortの中で大きいのから順に引いていく
for i in range(len(b_sort)):
  H -= b_sort[i]
  ans += 1
  if H <= 0:
    print(ans)
    exit()
 
#bをすべて引いてもH>0ならaで攻撃
if H % max_a == 0:
  ans += H // max_a
else:
  ans += H // max_a + 1
 
print(ans)
a=int(input())
if a = 1:
  print(a)
elif int(a/2)=0:
  print((a/2)/a)
else:
  print((int(a/2)+1)/a)


### FIXED CODE ###

import math
a=int(input())
b=math.floor(float(a/2))
print(float((a-b)/a))
N=input()
w=int(n[-1])
h=[2,4,5,7,9]
p=[0,1,6,8]
b=3
if w==b:
  print('bon')
elif w in p:
  print('pon')
else:
  print('hon')

### FIXED CODE ###

N=input()
w=int(N[-1])
h=[2,4,5,7,9]
p=[0,1,6,8]
b=3
if w==b:
  print('bon')
elif w in p:
  print('pon')
else:
  print('hon')
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = i = 1
  x = c.get(i)
  while x and i < n:
    p = x; i += 1; x = c.get(i); n -= x
    r = r * pow(p, x, M) % M
print((r, 0)[n > 1])

### FIXED CODE ###

from collections import Counter

M = 998244353
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
if a[0] == 0 and c[0] == 1:
    r = i = 1
    while c[i]:
        r = r * pow(c[i - 1], c[i], M) % M
        n -= c[i]
        i += 1
print(r if n == 1 else 0)
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
"""
n=2*100000
d=0
a=1
xh=[[pow(10,9)//i,pow(10,9)] for i in range(1,1+n)]
"""
xh.sort(key=lambda x:x[0])
import numpy as np
fd=np.zeros(2*d+1,np.int64) # fd[i]:ターゲットのモンスターから座標+i離れたところにいるモンスターに与えたダメージ
ans=0
pre_x=xh[0][0]
for x,h in xh:
  fdt=np.zeros(2*d+1,np.int64)
  if 0<x-pre_x and x-pre_x<2*d+1:
    fdt[:-x+pre_x]=fd[x-pre_x:]
  fd=fdt
  if h-fd[0]<=0:
    pass
  else:
    c=(h-fd[0]+a-1)//a
    fd+=c*a
    ans+=c
  pre_x=x
print(ans)

### FIXED CODE ###

n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort(key=lambda x:x[0])
from collections import deque
minusd=deque()
nowd=0
ans=0
for x,h in xh:
  while minusd and minusd[0][1]<=x:
    d_,_=minusd.popleft()
    nowd-=d_
  tmp=max(0,(h-nowd+a-1)//a)
  ans+=tmp
  nowd+=tmp*a
  minusd.append([tmp*a,x+2*d+1])
  #print(ans,nowd)
print(ans)
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
c=0
for i in range(k):
    h.pop(0)

for i in range(len(h)):
    c+=h[i]
print(c)


### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
c=0
for i in range(k,n):
    c+=h[i]

print(c)
if S=="Sunny":
    print(Cloudy)
if S=="Cloudy":
    print(Rainy)
if S=="Rainy":
    print(Sunny)

### FIXED CODE ###

S=input()
a=["Sunny", "Cloudy", "Rainy"]
print(a[((a.index(S)+1))%3])
import sys

n=int(raw_input())
buf =[[] for i in range(n)]

while True:
    text = raw_input().split()
    if text[0] == 'quit':
        break
    elif text[0] == 'push':
        buf[int(text[1])-1].append(text[2])
    elif text[0] == 'pop':
        print buf[int(text[1])-1][-1]
        buf[text[1]-1].pop()
    elif text[0] == 'move':
        buf[int(text[2])-1].append(buf[int(text[1])-1][-1])
        buf[int(text[1])-1].pop()

### FIXED CODE ###

import sys

n=int(raw_input())
buf =[[] for i in range(n)]

while True:
    text = raw_input().split()
    if text[0] == 'quit':
        break
    elif text[0] == 'push':
        buf[int(text[1])-1].append(text[2])
    elif text[0] == 'pop':
        print buf[int(text[1])-1][-1]
        buf[int(text[1])-1].pop()
    elif text[0] == 'move':
        buf[int(text[2])-1].append(buf[int(text[1])-1][-1])
        buf[int(text[1])-1].pop()
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
mi = 0
zero = 0
for a in A:
  if a<0:
    mi+=1
  elif a==0:
    zero+=1
  else:
    break

plu = N-mi-zero
A_mi = A[0:mi:]
A_mi_rev = A_mi[::-1]
A_plu = A[mi+zero::]
A_plu_rev = A_plu[::-1]
num_mi = plu*mi
num_zero = (plu+mi)*zero+(zero*(zero-1))//2
print(A_mi[0]*A_mi[1])

### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
mi = 0
zero = 0
for a in A:
  if a<0:
    mi+=1
  elif a==0:
    zero+=1
  else:
    break

plu = N-mi-zero
A_mi = A[0:mi:]
A_mi_rev = A_mi[::-1]
A_plu = A[mi+zero::]
A_plu_rev = A_plu[::-1]
num_mi = plu*mi
num_zero = (plu+mi)*zero+(zero*(zero-1))//2
r = max(A[-1]**2+10,A[0]**2+10)
l = A[0]*A[-1]-10
while l+1!=r:
  m = (l+r)//2
  num = 0
  if m>0:
    num+=num_mi+num_zero
    if num>=K:
      r=m
      continue
    cou=0
    for i in range(0,plu):
      while True:
        if cou>=plu-i-1:
          num+=plu-i-1
          break
        x = A_plu_rev[i]*A_plu[cou]
        if x<m:
          cou+=1
        else:
          num+=cou
          break
          
      if num>=K:
        break
    if num>=K:
      r=m
      continue
    cou = 0
    for i in range(0,mi):
      while True:
        if cou>=mi-i-1:
          num+=mi-i-1
          break
        x = A_mi[i]*A_mi_rev[cou]
        if x<m:
          cou+=1
        else:
          num+=cou
          break
          
      if num>=K:
        break

    if num>=K:
      r=m
    else:
      l=m
    
  elif m==0:
    num+=num_mi
    if num>=K:
      r=m
    else:
      l=m
  else:
    cou = 0
    for a in A_mi_rev:
      while True:
        if cou==plu:
          num+=cou
          break
        x = a*A_plu_rev[cou]
        if x<m:
          cou+=1
        else:
          num+=cou
          break
          
      if num>=K:
        break
    if num>=K:
      r = m
    else:
      l = m
      
print(l)
N = int(input())
A = list(map(int, input().split()))

import numpy as np

a = np.zeros((N, N))
for i in range(N):
    a[i][i] = 1
    if i + 1 == N:
        a[i][0] = 1
    else:
        a[i][i+1] = 1
b = np.array(A)
X = np.linalg.solve(a, b) * 2
X = map(int, X)
print(" ".join(map(str, X)))

### FIXED CODE ###

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

x = [None] * N
x[0] = sum(A) - 2 * sum([a for a in A[1::2]])
for i in range(N-1):
    x[i+1] = 2 * A[i] - x[i]
print(" ".join(map(str, x)))
from itertools import combinations

mod = 2019

for i, j in combinations(range(L, R+1), 2):
    i, j = i%mod, j%mod
    mini = min(mini, i*j % mod)
    if mini == 0:
        break
print(mini)

### FIXED CODE ###

L, R = map(int, input().split())
from itertools import combinations

mod = 2019

if R - L >= mod:
    print(0)
else:
    mini = mod - 1
    for i, j in combinations(range(L, R+1), 2):
        mini = min(mini, i*j % mod)
        if mini == 0:
            break
    print(mini)
n=int(input()
d,x=map(int,input().split())
ans=x
a=[int(input()) for _ in range(n)]
for i in range(n):
    ans+=((d-1)//a[i])+1
print(ans)


### FIXED CODE ###

n=int(input())
d,x=map(int,input().split())
ans=x
a=[int(input()) for _ in range(n)]
for i in range(n):
    ans+=((d-1)//a[i])+1
print(ans)
x = list(map(int,input().split()))
while x[1] != 0 and x[2] != 0:
    print(x[1] x[2])
    x = list(map(int, input().split)


### FIXED CODE ###

while True :
    x, y = sorted(map(int, input().split()))
    if x == y and y == 0 : break
    print(x, y)
n, m = map(int, input().split())
# l = [list(map(int, input().split())) for _ in range(m)]


class UnionFind:
    def __init__(self, n):
        self.__par = list(range(n))
        self.__siz = [1]*len(self.__par)

    def root(self, ix):
        if self.__par[ix] == ix:
            return ix
        return self.root(self.__par[ix])

    def unite(self, ix, iy):
        rx = self.root(ix)
        ry = self.root(iy)
        if rx == ry:
            return
        self.__siz[ry] += self.__siz[rx]
        self.__par[rx] = ry

    def isAkin(self, ix, iy):
        return self.root(ix) == self.root(iy)

    def size(self, ix):
        return self.__siz[self.root(ix)]


uf = UnionFind(n)
for i in range(m):
    x,y = map(int, input().split())
    uf.unite(x-1, y-1)

res = 0
for i in range(n):
    res = max(res, uf.size(i))
print(res)


### FIXED CODE ###

l=lambda:map(int, input().split())
n,m=l()
p=[-1]*n
def r(x):
  if p[x]<0:return x
  p[x]=r(p[x]);return r(p[x])
def u(x,y):
  x,y=r(x),r(y)
  if x==y: return  
  p[x]+=p[y]
  p[y]=x
def e(x,y):
  return r(x)==r(y)
def s(x):
  return -p[r(x)]
for _ in range(m):
  a,b=l()
  u(a-1,b-1)
print(-min(p))
n,*l=open(0);n=int(n);l=list(map(int,l.split()))
p=[0]*n;d=[0]*n
for i in range(n):p[i]=l[i]+p[i-2];d[i]=max(p[i-1]if(i&1)else d[i-1],l[i]+d[i-2])
print(d[-1])

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
if n<=3:print(max(a));exit()
if n&1:
  dp=[3*[-(10**20)]for _ in range(n)]
  dp[0][0]=a[0]
  for i in range(1,n):
    if i%2==0:
      dp[i][0]=dp[i-2][0]+a[i]
      if i>=3:dp[i][2]=max(dp[i-2][2]+a[i],dp[i-3][1]+a[i])
      else:dp[i][2]=a[i]
    else:
      if i>=3:dp[i][1]=max(dp[i-2][1]+a[i],dp[i-3][0]+a[i])
      else:dp[i][1]=a[i]
  print(max(dp[-1][2],dp[-2][1],dp[-3][0]))
else:
  b=[a[0]]
  c=[a[1]]
  for i in range(2,n):
    if i%2==0:b.append(b[-1]+a[i])
    else:c.append(c[-1]+a[i])
  ans=max(b[-1],c[-1])
  for i in range(n//2-1):
    ans=max(ans,b[i]+c[-1]-c[i])
  print(ans)
def main(h, w, n)
  n_push = []

  for n_h in range(h):
    for n_w in range(w):
      n_tmp = n_h*w + n_w*h - (n_h*n_w)

      if n_tmp>n_push:
          n_push.append = n_h + n_w

  return min(n_push)

### FIXED CODE ###

h = int(input())
w = int(input())
n = int(input())

n_push = []

for n_h in range(h+1):
  for n_w in range(w+1):
    n_tmp = (n_h)*w + (n_w)*h - ((n_h)*(n_w))

    if n_tmp>=n:
      n_push.append(n_h + n_w)

print(min(n_push))
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    print (round(x, 3)+' '+round(y, 3))


### FIXED CODE ###

import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    #print (str(round(x, 3))+' '+str(round(y, 3)))#dont int+str
    print("%.3f %.3f"%(x,y))
import math
n=int(input())
k=list(map(int,input().split()))
c=k[0]

for i in range(len(k)):
    c=math.gcd(c,k[i])
    
print(c)

### FIXED CODE ###


n=int(input())
k=list(map(int,input().split()))
c=k[0]

def regcd(a,b):
    while b != 0:
        a, b = b, a%b
    return a

for i in k:
    c=regcd(max(c,i),min(c,i))

    
print(c)
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n,a = imap()
x = np.array(iarr()) - a

# dp[i][和 + NA]
# 本来のSの範囲は、n*(1-a)からn*(50-a)
# 負の数はdp半以外なのでNAたすと、1*nから50*N
# 和０のときは dp[n][0+NA]
dp = np.zeros((n+1, 50*n+1)).astype(int)
dp[0][n*a] = 1

for i in range(n):
    for s in range(50*n+1):
        dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s]

ans = dp[n][n*a] - 1 #実際は初期条件の０個選ぶパターンを除外
print(ans)



### FIXED CODE ###

import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n,a = imap()
x = np.array(iarr()) - a

# dp[i][和 + NA]
# 本来のSの範囲は、1N-NAから50N-NA
# 負の数はdp範囲外なのでNAたすと、1Nから50N
# 和０のときは dp[n][0+NA]
dp = np.zeros((n+1, 50*n+100)).astype(int)
dp[0][n*a] = 1

for i in range(n):
    for s in range(50*n+1):
        dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s]

ans = dp[n][n*a] - 1 #実際は初期条件の０個選ぶパターンを除外
print(ans)
N = int(input())
arr = [i for i in range(1, N + 1)]
# N == len(arr)
nums = N*[0]
for j in range(N):
    target = arr[j]
    num = 0
    while target % 2 == 0:
        num += 1
        target /= 2
    nums[j] = num

print(nums)

max = 0
for k in range(N):
    if nums[k] > max:
        max_index = k
        max = nums[k]
 
print(arr[max_index])

### FIXED CODE ###

N = int(input())
arr = [i for i in range(1, N + 1)]
# N == len(arr)
nums = N*[0]
for j in range(N):
    target = arr[j]
    num = 0
    while target % 2 == 0:
        num += 1
        target /= 2
    nums[j] = num

# print(nums)

max = 0
for k in range(N):
    if nums[k] > max:
        max_index = k
        max = nums[k]
    elif N == 1:
        max_index=0
 
print(arr[max_index])
N,M = map(int,input().split())
cntNode = [0]*N
for i in range(N):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    cntNode[a] += 1
    cntNode[b] += 1

flag = True
for i in range(N):
    if(cntNode[i] % 2 != 0):
        flag = False
        break
if(flag):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N,M = map(int,input().split())
cntNode = [0]*N
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    cntNode[a] += 1
    cntNode[b] += 1

flag = True
for i in range(N):
    if(cntNode[i] % 2 != 0):
        flag = False
        break
if(flag):
    print('YES')
else:
    print('NO')
ans = input()
if 400 <= ans <= 599:
  print(8)
elif 600 <= ans <= 799:
  print(7)
elif 800 <= ans <= 999:
  print(6)
elif 1000 <= ans <= 1199:
  print(5)
elif 1200 <= ans <= 1399:
  print(4)
elif 1400 <= ans <= 1599:
  print(3)
elif 1600 <= ans <= 1799:
  print(2)
elif 1800 <= ans <= 1999:
  print(1)

### FIXED CODE ###

import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
 
X=int(input())
ans=0
if(400<=X and X<=599):
    ans=8
if(600<=X and X<=799):
    ans=7
if(800<=X and X<=999):
    ans=6
if(1000<=X and X<=1199):
    ans=5
if(1200<=X and X<=1399):
    ans=4
if(1400<=X and X<=1599):
    ans=3
if(1600<=X and X<=1799):
    ans=2
if(1800<=X and X<=1999):
    ans=1
 
print(ans)