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

import numpy as np
n = int(input())
a =np.array([int(x) for x in input().split()])
q = int(input())
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]

ans = np.sum(a)
for i in range(q):
    if np.count_nonzero(a == b[i]) > 0:
        ans += np.count_nonzero(a == b[i])*(c[i]-b[i])
        a = np.where(a == b[i], c[i],a)
    print(ans)

### FIXED CODE ###

import numpy as np
import collections

n = int(input())
a =np.array([int(x) for x in input().split()])
q = int(input())
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]

count_dict = collections.Counter(a)
ans = np.sum(a)
for i in range(q):
    if count_dict[b[i]] > 0:
        ans += count_dict[b[i]]*(c[i]-b[i])
        count_dict[c[i]] += count_dict[b[i]]
        count_dict[b[i]] = 0
    print(ans)
### BUGGY CODE ###

import queue 
MOD = 10**9 +7
INF = 10**9
def main():
    n,m = map(int,input().split())
    V0 = [[] for _ in range(n)]
    V1 = [[] for _ in range(n)]
    V2 = [[] for _ in range(n)]
    for _ in range(m):
        u,v = map(int,input().split())
        u -= 1
        v -= 1
        V0[u].append(v)
        V1[u].append(v)
        V2[u].append(v)
    
    s,t = map(int,input().split())
    s -= 1
    t -= 1
    
    d0 = [-1]*n
    d1 = [-1]*n
    d2 = [-1]*n
    d0[s] = 0

    q = queue.Queue()
    q.put([s,0])
    while q.qsize() != 0:
        p = q.get()
        mod = p[1]
        v = p[0]
        if mod == 0:
            for e in V0[v]:
                if d1[e] == -1:
                    d1[e] = d0[v] + 1
                    q.put([e,1])

        elif mod == 1:
            for e in V1[v]:
                if d2[e] == -1:
                    d2[e] = d1[v] + 1
                    q.put([e,2])
        
        else:
            for e in V2[v]:
                if d0[e] == -1:
                    d0[e] = d2[v] + 1
                    q.put([e,0])
    
    if d0[t] == -1:
        print(-1)
    else:
        print(d0[t]//3)
   
if __name__=='__main__':
    main()


### FIXED CODE ###

import queue 
MOD = 10**9 +7
INF = 10**9
def main():
    n,m = map(int,input().split())
    V0 = [[] for _ in range(n)]
    V1 = [[] for _ in range(n)]
    V2 = [[] for _ in range(n)]
    for _ in range(m):
        u,v = map(int,input().split())
        u -= 1
        v -= 1
        V0[u].append(v)
        V1[u].append(v)
        V2[u].append(v)
    
    s,t = map(int,input().split())
    s -= 1
    t -= 1
    
    d0 = [-1]*n
    d1 = [-1]*n
    d2 = [-1]*n
    d0[s] = 0

    q = queue.Queue()
    q.put([s,0])
    while q.qsize() != 0:
        p = q.get()
        mod = p[1]
        v = p[0]
        if mod == 0:
            for e in V0[v]:
                if d1[e] == -1:
                    d1[e] = d0[v] + 1
                    q.put([e,1])

        elif mod == 1:
            for e in V1[v]:
                if d2[e] == -1:
                    d2[e] = d1[v] + 1
                    q.put([e,2])
        
        else:
            for e in V2[v]:
                if d0[e] == -1:
                    d0[e] = d2[v] + 1
                    q.put([e,0])
    
    if d0[t] == -1:
        print(-1)
    else:
        print(d0[t]//3)
   
if __name__=='__main__':
    main()
### BUGGY CODE ###

a,b = map(int, input().split())
L = []
for i in range (a,b+1):
  L.append(i)
P = 1
for j in L:
  P *= j
if P > 0:
  print('Positive')
elif P == 0:
  print('Zero')
else:
  print('Negative')

### FIXED CODE ###

a,b = map(int, input().split())
if a > 0:
  print("Positive")
elif b<0:
  if((b-a)%2 == 0):
    print("Negative")
  else:
    print("Positive")
else:
  print("Zero")
### BUGGY CODE ###

import sys
from collections import deque
import copy
def main():
    N = int(input())
    S = []
    for i in range(N):
        s = input()
        if i == 0:
            S.append(s)
            continue
        flag = False
        for j in range(len(S)):
            flag = False
            if len(s) != len(S[j]):
                flag = True
            else:
                for k in range(len(s)):
                    if s[k] != S[j][k]:
                        flag = True
                        break
            if not flag:
                break
        if flag:
            S.append(s)
    print(len(S))
    

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque
import copy
def main():
    N = int(input())
    S = []
    for i in range(N):
        s = input()
        S.append(s)
    S.sort()
    count = N
    for i in range(1, len(S)):
        if S[i - 1] == S[i]:
            count -= 1
    print(count)
    

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

S = input()

modList = [0] * 2019 # あまりは0～2018の2019個

ans = 0

modList[0] = 1 # 解答でいうT(n)=0 の場合

# 最大20万回ループ、時間かかるならＤＰする？
# ↓ではTLEになった
# for i in range(len(S)):
#     m = int(S[i:]) % 2019
#     modList[m] += 1
T = 0
for i in range(1,len(S)+1):
    # T += int(S[-i]) * 10**i
    T += int(S[-i]) * ((10**i) % 2019)
    modList[T % 2019] +=1


#print(modList)

for j in modList:
    if j <= 1:
        continue
    else:
        ans += j*(j-1)/2

print(int(ans))


### FIXED CODE ###

S = input()

modList = [0] * 2019 # あまりは0～2018の2019個

ans = 0

modList[0] = 1 # 解答でいうT(n)=0 の場合

# 最大20万回ループ、時間かかるならＤＰする？
# ↓ではTLEになった
# for i in range(len(S)):
#     m = int(S[i:]) % 2019
#     modList[m] += 1

# ↓　これでもTLEになった
# T = 0
# for i in range(1,len(S)+1):
#     # T += int(S[-i]) * 10**i
#     T += int(S[-i]) * ((10**i) % 2019)
#     modList[T % 2019] +=1

T = 0
a = 1
for s in S[::-1]:
    T = T+int(s) * a
    modList[T%2019]+=1
    a*=10
    a%=2019
#print(modList)

for j in modList:
    if j <= 1:
        continue
    else:
        ans += j*(j-1)/2

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

x = input()

length = len(x)
while True:
    x = x.replace("ST", "")
    if len(x) == length:
        break
    else:
        length = len(x)

print(len(x))

### FIXED CODE ###

x = input()

pair_cnt = 0
s_cnt = 0
for i in x:
    if i == "S":
        s_cnt += 1
    elif i == "T" and s_cnt:
        pair_cnt += 1
        s_cnt -= 1

print(len(x) - pair_cnt * 2)
### BUGGY CODE ###

def union_set(x, y):
    lx, x_set = x
    ly, y_set = y
    l = max(lx, ly)
    if lx == ly:
        z_set = x_set.union(y_set)
    else:
        z_set = x_set if lx > ly else y_set
    return [l, z_set]

def update_set(x, t):
    l, s = x
    return [l + len(t), {si + t for si in list(s)}]

s = input()
t = input()

table = [[[0, {''}] for j in range(len(t) + 1)] for i in range(len(s) + 1)]

for i, si in enumerate(s):
    for j, tj in enumerate(t):
        if si == tj:
            table[i + 1][j + 1] = update_set(table[i][j], si)
        else:
            table[i + 1][j + 1] = union_set(table[i + 1][j], table[i][j + 1])
print(list(table[-1][-1][1])[0])


### FIXED CODE ###

s = input()
t = input()

table = [[0 for j in range(len(t) + 1)] for i in range(len(s) + 1)]

for i, si in enumerate(s):
    table_pre = table[i]
    table_cur = table[i + 1]
    for j, tj in enumerate(t):
        if si == tj:
            table_cur[j + 1] = table_pre[j] + 1
        else:
            table_cur[j + 1] = max(table_cur[j], table_pre[j + 1])

ls, lt = len(s), len(t)
ans = ''
while ls and lt:
    if table[ls][lt] == table[ls][lt - 1]:
        lt -= 1
    elif table[ls][lt] == table[ls - 1][lt]:
        ls -= 1
    else:
        ans = s[ls - 1] + ans
        ls -= 1
        lt -= 1
print(ans)
### BUGGY CODE ###

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

bit_nums = [0 for _ in range(K)]
ans = 0
mod = 10 ** 9 + 7

for a in A:
    for i in range(K):
        if a >> i & 1 == 1:
            bit_nums[i] += 1

ans = 0
for i in range(K):
    ans += (2 ** i) * (bit_nums[i] * (N - bit_nums[i]))
    ans %= mod
    
print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

K = len(bin(np.max(A))) - 2

ans = 0
mod = 10 ** 9 + 7
N %= mod

for i in range(K):
    bit = np.count_nonzero(A >> i & 1) % mod
    ans += 2 ** i * bit * (N - bit)
    ans %= mod
    
print(ans)
### BUGGY CODE ###

from collections import deque

N, M = map(int, input().split())

graph = [[] for i in range(N)]
for i in range(M):
  u, v = map(int, input().split())
  graph[u-1].append(v-1)

s, t = map(int, input().split())
s -= 1
t -= 1

is_visited = [False]*N
is_visited[s] = True

d = deque([s])
ans = 0
while d:
  ans += 1
  diff = 0
  for step in range(1, 4):
    if d:
      len_d = len(d)
      for i in range(len_d):
        node = d.popleft()
        children = graph[node]
        for child in children:
          if step == 3:
            if child == t:
              d = []
              diff = 1
              break
            if not is_visited[child]:
              is_visited[child] = True
              diff += 1
              d.append(child)
          else:
            d.append(child)
        
        else:
          continue
        break
    
    else:
      ans = -1
      break
  
  if not diff:
    ans = -1
    break

print(ans)

### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())

graph = [[] for i in range(3*N)]
for i in range(M):
  u, v = map(int, input().split())
  u, v = 3*(u - 1), 3*(v - 1)
  graph[u].append(v+1)
  graph[u+1].append(v+2)
  graph[u+2].append(v)

s, t = map(int, input().split())
s, t = 3*(s - 1), 3*(t - 1)


dist = [10**9] * 3*N
dist[s] = 0
d = deque([s])
while d:
  node = d.popleft()
  children = graph[node]
  for child in children:
    if dist[child] > dist[node] + 1:
      d.append(child)
      dist[child] = dist[node] + 1

if dist[t] < 10**9:
  print(dist[t]//3)
else:
  print(-1)
### BUGGY CODE ###

import numpy as np

N = int(input())
S = []
for i in range(N):
  S.append(list(input()))

S = np.array(S)

s = list('abcdefghijklmnopqrstuvwxyz')

T = np.zeros([N, 26])

for i, a in enumerate(s):
  T[:, i] = np.sum(S == a, axis=1)


c = 0
for i in range(N):
  for j in range(i+1, N):
    if (T[i] == T[j]).all():
      c += 1

print(c)

### FIXED CODE ###

def number(x):
  return int((1 + (1 + 8*x)**0.5) / 2)


N = int(input())
d = {}
for i in range(N):
  s = ''.join(sorted(input()))
  if s in d.keys():
    d[s] += number(d[s])
  else:
    d[s] = 0


print(sum(d.values()))
### BUGGY CODE ###

S = input()
K = int(input())
sub = set(S)
for step in range(2, len(S) + 1):
    for i in range(0, len(S) - step + 1):
        sub.add(S[i:i+step])
print(sorted(sub)[K - 1])


### FIXED CODE ###

S = input()
K = int(input())
sub = set(S)
for step in range(2, 6):
    for i in range(0, len(S) - step + 1):
        sub.add(S[i:i+step])
print(sorted(sub)[K - 1])
### BUGGY CODE ###

import math
import time

t = time.time()
def iip():
    return [int(i) for i in input().split()]

H, N = iip()
mp_for_damage = [10**9 for i in range(H+1)]
mp_for_damage[0] = 0
ab = []

for i in range(N):
    ab.append(iip())

ab= sorted(ab, key=lambda x:x[0], reverse=True)

for i in range(N):
    a, b = ab[i]
    for j in range(H+1):
        if a < H and mp_for_damage[a] < b:
            continue

        for k in range(1, a):
            if k > H:
                break
            mp_for_damage[k] = min(mp_for_damage[k], b)

        if j + a > H:
            break
        mp_for_damage[j+a] = min(mp_for_damage[j+a], mp_for_damage[j] + b)

#print(mp_for_damage)
print(mp_for_damage[H])

#print(time.time() - t)

### FIXED CODE ###

import math
import time


t = time.time()
def iip():
    return [int(i) for i in input().split()]

def main():
    H, N = iip()
    mp_for_damage = [10**9 for i in range(H+1)]
    mp_for_damage[0] = 0
    ab = []

    for i in range(N):
        ab.append(iip())

    ab= sorted(ab, key=lambda x:x[0]/x[1], reverse=True)

    for i in range(N):
        a, b = ab[i]

        for k in range(1, min(a, H) + 1):
            mp_for_damage[k] = min(mp_for_damage[k], b)
            # print(k, b)

        if a >= H:
            mp_for_damage[H] = min(mp_for_damage[H], b)
            continue

        if a < H and mp_for_damage[a] < b:
            continue

        for j in range(H-a+1):
            mp_for_damage[j+a] = min(mp_for_damage[j+a], mp_for_damage[j] + b)

    #print(mp_for_damage)
    #print(mp_for_damage)
    print(mp_for_damage[H])

    #print(time.time() - t)

main()
### BUGGY CODE ###

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

dic = {}

max_dice = 0
for i in range(K-1, N):
    tmp_dice = 0
    for j in range(i - K + 1, i + 1):
        if p[j] in dic:
            tmp_kitai = dic[p[j]]
        else:
            tmp_kitai = 0
            for k in range(p[j]):
                tmp_kitai += (k + 1)
            tmp_kitai = tmp_kitai / p[j]
            dic[p[j]] = tmp_kitai
        tmp_dice += tmp_kitai
    if tmp_dice > max_dice:
        max_dice = tmp_dice
print(max_dice)

### FIXED CODE ###

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

dp = [0] * (N)
dp_sub = [0] * (N)

dp[0] = (p[0] + 1) / 2
dp_sub[0] = (p[0] + 1) / 2

for i in range(1, K):
    dp_sub[i] = (p[i] + 1) / 2
    dp[i] = dp[i - 1] + dp_sub[i]

for i in range(K, N):
    dp_sub[i] = (p[i] + 1) / 2
    dp[i] = dp[i - 1] + dp_sub[i] - dp_sub[i-K]
    
print(max(dp))
### BUGGY CODE ###

a, b, c, k = map(int, input().split())

if a == b == c:
    print(0)
    exit(0)
for i in range(k):
    w_a = b + c
    w_b = a + c
    w_c = a + b
    a = w_a
    b = w_b
    c = w_c
print(a - b)


### FIXED CODE ###

a, b, c, k = map(int, input().split())

if k % 2 == 0:
    print(a - b if abs(a - b) < 10 ** 18 else 'Unfair')
else:
    print(b - a if abs(b - a) < 10 ** 18 else 'Unfair')
### BUGGY CODE ###

n, a, b, c = map(int, input().split())
mod = 10 ** 9 + 7

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

an = n
bn = n
for i in range(n):
    an *= a
    an *= (a + b)
    an %= mod
    bn *= b
    bn *= (a + b)
    bn %= mod
sum_a = an
sum_b = bn
for i in range(1, n):
    an *= (n + i)
    an *= mod_inv(i, mod)
    an *= b
    an *= mod_inv(a + b, mod)
    an %= mod
    bn *= (n + i)
    bn *= mod_inv(i, mod)
    bn *= a * mod_inv(a + b, mod)
    bn %= mod
    sum_a += an
    sum_b += bn
total = (sum_a + sum_b) * 100
q = 1
for i in range(2 * n):
    q *= (a + b)
    q %= mod
q *= (100 - c)
print(total * mod_inv(q, mod) % mod)

### FIXED CODE ###

n, a, b, c = map(int, input().split())
mod = 10 ** 9 + 7

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

an = n
bn = n
for i in range(n):
    an *= a
    an *= (a + b)
    an %= mod
    bn *= b
    bn *= (a + b)
    bn %= mod
sum_a = an
sum_b = bn
inv_ab = mod_inv(a + b, mod)
for i in range(1, n):
    an *= (n + i)
    an *= mod_inv(i, mod)
    an *= b
    an *= inv_ab
    an %= mod
    bn *= (n + i)
    bn *= mod_inv(i, mod)
    bn *= a
    bn *= inv_ab
    bn %= mod
    sum_a += an
    sum_b += bn
total = (sum_a + sum_b) * 100
q = 1
for i in range(2 * n):
    q *= (a + b)
    q %= mod
q *= (100 - c)
print(total * mod_inv(q, mod) % mod)
### BUGGY CODE ###

from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

data = [A+i for i in range(B-A+1)]

result = "0"

for d in data:
    # 排他的論理和
    result = (bin(int(result, 2) ^ d))

print(int(result, 2))

### FIXED CODE ###

from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

def isOdd(num):
    if num % 2 == 0:
        return False
    else:
        return True

def solve(num):
    if isOdd(num):
        if (num // 2) % 2 == 0:
            return 1
        else:
            return 0
    else:
        return solve(num+1) ^ (num+1) 


print(solve(B) ^ solve(A-1))
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

N, Q = list(map(int, readline().split()))
S = list(readline())
lr = []
for i in range(Q):
    l, r = list(map(int, readline().split()))
    lr.append([l-1, r])

ac = 0
acs = [0 for i in range(N)]
for i in range(N):
    if S[i] == 'A' and ac == 0:
        ac += 1
    elif S[i] == 'C' and ac == 1:
        acs[i - 1] = 1
        ac = 0
    else:
        ac = 0

for i in range(Q):
    l, r = lr[i]
    print(acs[l:r-1].count(1))

### FIXED CODE ###

import sys
readline = sys.stdin.readline

N, Q = map(int, readline().split())
S = readline()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, readline().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

from collections import deque
n,m=map(int,input().split())
path=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
l=deque()
l.append(0)
while True:
  flag=True
  for i in path[l[0]]:
    if not i in l:
      l.appendleft(i)
      flag=False
      break
  for i in path[l[-1]]:
    if not i in l:
      l.append(i)
      flag=False
      break
  if flag:
    break
print(len(l))
for i in range(len(l)):
  l[i]+=1
print(*l)

### FIXED CODE ###

from collections import deque
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
path=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
l=deque()
s=set()
l.append(0)
s.add(0)
while True:
  for i in path[l[0]]:
    if not i in s:
      l.appendleft(i)
      s.add(i)
      break
  else:break
while True:
  for i in path[l[-1]]:
    if not i in s:
      l.append(i)
      s.add(i)
      break
  else:break
print(len(l))
l=list(map(lambda x:x+1,l))
print(*l)
### BUGGY CODE ###

N, W = map(int, input().split())
items = [list(map(int, input().split())) for i in range(N)]

dpt = [0] * (W+1)

for i in range(N):
    w, v = items[i]
    for j in range(W, w-1, -1):
        dpt[j] = max(dpt[j], dpt[j-w] + v)

print(dpt[W])


### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    N, W = map(int, input().split())
    
    dpt = [0] * (W+1)
    
    for i in range(N):
        w, v = map(int, input().split())
        for j in range(W, w-1, -1):
            a = dpt[j]
            b = dpt[j-w]+v
            if a > b:
                dpt[j] = a
            else:
                dpt[j] = b
    
    print(dpt[W])

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

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

road = []
x_list = []

for i in range(N):
    s,t,x = list(map(int,input().split()))
    road.append([0,s-x,x])
    road.append([1,t-x,x])

for i in range(Q):
    road.append([2,int(input()),i])

from collections import defaultdict

counter = defaultdict(int)
counter[10**27] = 1
ans = [0]*Q

road.sort(key=lambda x:x[0])
road.sort(key=lambda x:x[1])

q = [10**27]

from heapq import heappop,heappush

for id,_,x in road:
    if id==0:
        heappush(q,x)
        counter[x]+=1
    elif id==1:
        counter[x]-=1
    else:
        while counter[q[0]]==0:
            heappop(q)
        #print(q)
        if q[0]<10**27:
            ans[x] = q[0]
        else:
            ans[x] = -1
print(*ans,sep="\n")

### FIXED CODE ###

import sys

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

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

    road = []
    x_list = []

    for i in range(N):
        s,t,x = list(map(int,input().split()))
        road.append([0,s-x,x])
        road.append([1,t-x,x])

    for i in range(Q):
        road.append([2,int(input()),i])

    from collections import defaultdict

    counter = defaultdict(int)
    counter[10**27] = 1
    ans = [0]*Q

    road.sort(key=lambda x:x[0])
    road.sort(key=lambda x:x[1])

    q = [10**27]

    from heapq import heappop,heappush

    for id,_,x in road:
        if id==0:
            heappush(q,x)
            counter[x]+=1
        elif id==1:
            counter[x]-=1
        else:
            while counter[q[0]]==0:
                heappop(q)
            #print(q)
            if q[0]<10**27:
                ans[x] = q[0]
            else:
                ans[x] = -1
    print("\n".join(map(str,ans)))

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

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,A=map(int,input().split())
    x=list(map(lambda x:int(x)-A,input().split()))
    d={}
    for i in range(2**(N//2)):
        tmp=0
        for j in range(N//2):
            if (i>>j)&1:
                tmp+=x[j]
        if tmp in d:
            d[tmp]+=1
        else:
            d[tmp]=1
    ans=0
    for i in range(2**(-(-N//2))):
        tmp=0
        for j in range(-(-N//2)):
            if (i>>j)&1:
                tmp+=x[N//2+j]
        if -tmp in d:
            ans+=d[-tmp]
    print(ans-1)

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,A=map(int,input().split())
    x=list(map(int,input().split()))
    dp=[[[0]*2501 for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0][0]=1
    for i in range(N):
        for j in range(i+1):
            for k in range(2501):
                dp[i+1][j][k]+=dp[i][j][k]
                if k-x[i]>=0 and j<=i:
                    dp[i+1][j+1][k]+=dp[i][j][k-x[i]]
    ans=0
    for i in range(1,N+1):
        ans+=dp[-1][i][i*A]
    print(ans)

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

# coding: utf-8
# Your code here!
N,P=map(int,input().split())

i=1
ans=1

if N==1:
    print(P)
else:
    while i**N<=P:
        if P%(i**N)==0:
            ans=i
        i+=1
    print(ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
N,P=map(int,input().split())
l=[0]*int(-(-P**0.5//1)+1)

if N==1:
    print(P)
    exit()

for i in range(2,int(-(-P**0.5//1)+1))[::-1]:
    p=P
    count=0
    while p%i==0:
        p/=i
        count+=1
        if count==N:
            print(i)
            exit()
print(1)
### BUGGY CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
p=0
for i in range(K-1,N):
    m=1
    for j in range(K):
        m*=A[i-j]
    if K-1<i:print('Yes' if p<m else 'No')
    p=m

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(K,N):
    print('Yes' if A[i-K]<A[i] else 'No')