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

N, A, B, C, D = map(int, input().split())
mod = 10 ** 9 + 7

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N + 2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))


# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod


# n人いたときに、k人組を、x個つくる場合の数
def f(n, k, x):
    return nCr(n, k * x) * factorial[k * x] * pow(pow(factorial[k], x, mod), mod-2, mod) * inverse[x] % mod


dp = [[0] * (N + 1) for i in range(2)]
dp[0][0] = 1

for k in range(1, N + 1):  # k人からなるグループをこれから作りますよ
    for n in range(N + 1):  # すでにn人は使っちゃってますよ
        cnt = 0
        if A <= k <= B:  # グループの大きさの条件
            X = [0] + list(range(C, D + 1))
        else:
            X = [0]
        for x in X:
            if n - k * x < 0:  # はみ出る段階で打ち切りますよ
                break
            if k % 2 == 1:
                cnt += f(n, k, x) * dp[0][n - k * x] % mod
            else:
                cnt += f(n, k, x) * dp[1][n - k * x] % mod

        if k % 2 == 1:
            dp[1][n] = cnt
        else:
            dp[0][n] = cnt

if N % 2 == 1:
    print(dp[1][N])
else:
    print(dp[0][N])


### FIXED CODE ###

N, A, B, C, D = map(int, raw_input().split())
mod = 10 ** 9 + 7

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in xrange(1, N + 2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))


# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod


# n人いたときに、k人組を、x個つくる場合の数
def f(n, k, x):
    return nCr(n, k * x) * factorial[k * x] * pow(pow(factorial[k], x, mod), mod-2, mod) * inverse[x] % mod


dp = [0] * (N + 1)
dp[0] = 1

for k in xrange(A, B + 1):  # k人からなるグループをこれから作りますよ
    for n in range(1, N + 1)[::-1]:  # すでにn人は使っちゃってますよ
        X = xrange(C, D + 1)
        for x in X:
            if n - k * x < 0:  # はみ出る段階で打ち切りますよ
                break
            dp[n] += f(n, k, x) * dp[n - k * x] % mod

print(dp[N] % mod)
### BUGGY CODE ###

import math
import itertools

K=int(input())
s=0
for a,b,c in itertools.product(range(1,K+1),range(1,K+1),range(1,K+1)):
    	s+=math.gcd(math.gcd(a,b),c)
print(s)

### FIXED CODE ###

import math
from itertools import product

K=int(input())
s=0
for a,b,c in product(range(1,K+1), repeat=3):
    	s+=math.gcd(math.gcd(b,c),a)
print(s)
### BUGGY CODE ###

import operator
import functools
N=int(input())
A=list(map(int,input().split(' ')))
if functools.reduce(operator.mul, A, 1)>10**18:
    print(-1)
else:
    print(functools.reduce(operator.mul, A, 1))

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split(' ')))
def mul(x):
    l=1
    if 0 in x:
        l=0
    else:   
        for i in x:
                l=l*i
                if l>10**18:
                    l=-1
                    break
    return l
print(mul(A))
### BUGGY CODE ###

import copy
n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))
max_s = max(s)
d = copy.copy(s)
for i in range(n):
    if max_s != s[i]:
        print(max_s)
    else:
        d = copy.copy(s)
        del d[i]
        print(max(d))

### FIXED CODE ###

n = int(input())
s = []
second = 0
max_k = 0
for _ in range(n):
    k = int(input())
    max_k, min_k = max(k, max_k), min(k, max_k)
    second = max(min_k, second)
    s.append(k)
kk = s.index(max_k)
for i in range(n):
    if i != kk:
        print(max_k)
    else:
        print(second)
### BUGGY CODE ###

n=int(input())
a=[int(input()) for _ in [0]*n]
for i in range(n):
    print(max(a[:i]+a[i+1:]))

### FIXED CODE ###

n=int(input())
a=[int(input()) for _ in [0]*n]
M=max(a)
k=a.index(M)
m=max(a[:k]+a[k+1:])
for i in range(n):
    if i!=k:print(M)
    else:print(m)
### BUGGY CODE ###

if __name__ == '__main__':
    N = int(input())
    order_list = list(map(int, input().split()))

    for i in range(1, (N+1)):
        print(order_list.index(i) + 1, end=" ")

### FIXED CODE ###

if __name__ == '__main__':
    N = int(input())
    order_list = list(map(int, input().split()))
    present_list = list(range(1, N+1))
    temp = zip(order_list, present_list)
    temp = sorted(temp)
    order_list, present_list = zip(*temp)
    print(' '.join(map(str,present_list)))
### BUGGY CODE ###

import copy
[H,W] = [int(i) for i in input().split()]
A = []
for h in range(H):
    A_temp = input().replace(".","w")
    A_temp = A_temp.replace("#","b")
    A_temp2 = []
    for w in range(W):
        A_temp2.append(A_temp[w])
    A.append(A_temp2)
cnt = 0
while True:
    A2 = copy.deepcopy(A)
    # 白があるかチェック
    chk = True
    for h in range(H):
        chk *= ("w" not in A2[h])
    if chk == True:
        break
    cnt += 1
    # 白があったら書き換え
    for h in range(H):
        for w in range(W):
            if A[h][w] == "b":
                # 左
                if w != 0:
                    A2[h][w-1] = "b_temp"
                # 上
                if h != 0:
                    A2[h-1][w] = "b_temp"
                # 右
                if w != W-1:
                    A2[h][w+1] = "b_temp"
                # 下
                if h != H-1:
                    A2[h+1][w] = "b_temp"
    for h in range(H):
        for w in range(W):
            if A2[h][w] == "b_temp":
                A2[h][w] = "b" 
    A = copy.deepcopy(A2)
print(cnt)

### FIXED CODE ###

import numpy as np

H,W=map(int,input().split(' '))
# 回数の最大値はH+W
max_value = H+W
values =[]

# マス目に回数を入れる。黒なら0、白なら最大値を入れておく
for i in range(H):
    values.append([0 if i == '#' else max_value for i in list(input())])
# numpy配列に
values = np.array(values)

# 右のセルと比較して、
for x in range(W-1):
    values[:,x+1] = np.minimum(values[:,x]+1,values[:,x+1])
for x in range(W-1,0,-1):
    values[:,x-1] = np.minimum(values[:,x-1],values[:,x]+1)
for x in range(H-1):
    values[x+1,:] = np.minimum(values[x,:]+1,values[x+1,:])
for x in range(H-1,0,-1):
    values[x-1,:] = np.minimum(values[x,:]+1,values[x-1,:])
print(np.max(values))
### BUGGY CODE ###

import collections
import math

N_ = 10 ** 3
A=list(range(2,N_+1))
p=list()
while A[0]**2<=N_:
	tmp=A[0]
	p.append(tmp)
	A=[e for e in A if e%tmp!=0]
p_list = p+A

def search_divisor_num_1(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))

        divisor_num = 1
        for prime in p_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num
    
def main():
    N = int(input())
    ans = 0
    for c in range(1, N):
        ans += search_divisor_num_1(N - c)
    return ans
 
if __name__ == '__main__':
    print(main())

### FIXED CODE ###

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data
 
p_list = get_sieve_of_eratosthenes(10**3)
 
def factorization_counta(n):
    arr = []
    temp = n
    for i in p_list:
        if i * i > n:
            break
        elif temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append(cnt)
            
    if temp != 1:
        arr.append(1)
    if arr == []:
        arr.append(1)
    return arr

def main():
    N = int(input())
    ans = 1
    for c in range(2, N):
        p = factorization_counta(c)
        tmp = 1
        for v in p:
            tmp *= (v + 1)
        ans += tmp
    return ans
 
if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a%b)

N = getInput()[0]
sums = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        n = gcd(max(i, j), min(i,j))
        for k in range(1, N+1):
            sums += gcd(max(n, k), min(n, k))

print(sums)

### FIXED CODE ###

import math
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]


N = getInput()[0]
sums = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        n = math.gcd(i, j)
        for k in range(1, N+1):
            sums += math.gcd(n, k)

print(sums)
### BUGGY CODE ###

import re
S = input()

hatena = S.count('?')

MOD = 10 ** 9 + 7
S_len = len(S)
pattern = S.replace('?', '\d')
repatter = re.compile(pattern)

count = 0
for i in range(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000):
    if len(str(i * 13 + 5)) > S_len:
        break
    s = str(i * 13 + 5).zfill(S_len)
    result = repatter.match(s)
    if result:
        count += 1

print(count)




### FIXED CODE ###


S = input()

MOD = 10 ** 9 + 7
count = 0
S_len = len(S)

dp = [[0 for i in range(13)] for j in range(100006)]
c = -1
if S[0] != '?':
    c = int(S[0])
for j in range(10):
    if c == -1:
        dp[1][j] = 1
    else:
        dp[1][c] = 1

for i in range(2, S_len + 1):
    c = -1
    if S[i - 1] != '?':
        c = ord(S[i - 1]) - ord('0')

    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i][(k * 10 + j) % 13] += dp[i - 1][k] % MOD


print(dp[S_len][5] % MOD)
### BUGGY CODE ###

N = int(input())

T = [''.join(sorted(input())) for _ in range(N)]
S = set(T)

ans = 0
for moji in S:
    c = T.count(moji)
    ans += c * (c - 1) // 2

print(ans)

### FIXED CODE ###

N = int(input())

S = [''.join(sorted(input())) for _ in range(N)]

table = {}

ans = 0
for s in S:
    if s in table:
        table[s] += 1
    else:
        table[s] = 1

for k in table:
    ans += table[k] * (table[k] - 1)

ans //= 2
print(ans)
### BUGGY CODE ###

from collections import Counter, defaultdict
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

U = N + 1
inf = 1e18

dp = [[[inf] * U for _ in range(U)] for _ in range(U)]
dp[0][0][0] = 0.0

for c in range(N + 1):
    for b in range(N + 1):
        for a in range(N + 1):
            if a + b + c == 0:
                continue
            prob = 0
            E = N
            if a > 0:
                E += a * dp[a - 1][b][c]
                prob += a
            if b > 0 and a < N:
                E += b * dp[a + 1][b - 1][c]
                prob += b
            if c > 0 and b < N:
                E += c * dp[a][b + 1][c - 1]
                prob += c
            dp[a][b][c] = E / prob

x = C[1]
y = C[2]
z = C[3]
print(dp[x][y][z])

### FIXED CODE ###

from collections import Counter, defaultdict
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

U = N + 1
inf = 1e18

dp = [[[inf] * U for _ in range(U)] for _ in range(U)]
dp[0][0][0] = 0.0

for c in range(N + 1):
    for b in range(N + 1):
        if c + b > N:
            break
        for a in range(N + 1):
            if a + b + c == 0:
                continue
            if a + b + c > N:
                break
            prob = 0
            E = N
            if a > 0:
                E += a * dp[a - 1][b][c]
                prob += a
            if b > 0 and a < N:
                E += b * dp[a + 1][b - 1][c]
                prob += b
            if c > 0 and b < N:
                E += c * dp[a][b + 1][c - 1]
                prob += c
            dp[a][b][c] = E / prob

x = C[1]
y = C[2]
z = C[3]
print(dp[x][y][z])
### BUGGY CODE ###

import collections
import math

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


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


c = collections.Counter(aa)

for a in aa:
    cc = c.copy()
    cc[a] -= 1
    ans = 0
    for i in cc.values():
        if i >= 2:
            ans += combinations_count(i, 2)
    print(ans)


### FIXED CODE ###

import collections
import math


n = int(input())
aa = list(map(int, input().split()))
ls = [0] * (n+1)

c = collections.Counter(aa)

for i, j in c.items():
    ls[i] = j*(j-1)//2

total = sum(ls)

for i in aa:
    before = (c[i]-1)*(c[i]-2) // 2
    print(total - ls[i] + before)
### 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()))

A.sort()
B.sort()
sublist = []
for i in range(max(X-K-1, 0), X):
    for j in range(max(Y - K - 1, 0), Y):
        sublist.append(A[i]+B[j])

sublist.sort()
subanslist = sublist[-K::1]
anslist = []

for i in subanslist:
    for j in range(max(Z - K - 1, 0), Z):
        anslist.append(i+C[j])

anslist.sort()
ans = anslist[:-K-1:-1]
for i in ans:
    print(i)

### FIXED 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()))

A.sort()
B.sort()
sublist = []
for i in range(max(X-K-1, 0), X):
    for j in range(max(Y - K - 1, 0), Y):
        if (X-i)*(Y-j) <= K:
            sublist.append(A[i]+B[j])

sublist.sort()
# print(sublist)
subanslist = sublist[-K::1]
sbsize = len(subanslist)
anslist = []
C.sort()

for num, i in enumerate(subanslist):
    for j in range(max(Z - K - 1, 0), Z):
        if (sbsize-num)*(Z-j) <= K:
            anslist.append(i+C[j])

anslist.sort()
ans = anslist[:-K-1:-1]
print(*ans, sep="\n")
### BUGGY CODE ###

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

h,w = map(int,input().rstrip().split())
sy,sx = map(int,input().rstrip().split())
gy,gx = map(int,input().rstrip().split())
a = [list(input().rstrip())for _ in range(h)]

sx -= 1
sy -= 1
gx -= 1
gy -= 1

dx=[1,0,-1,0]
dy=[0,1,0,-1]

@jit
def bfs():
    d = [[float("inf")]*w for _ in range(h)]
    q = deque([])
    q.append((sx,sy))
    d[sy][sx] = 0 #warp回数
    goal = False
    local_area = deque([])

    while q:
        p = q.popleft()
        local_area.append((p[0],p[1]))
        if p[0] == gx and p[1] == gy:
            goal = True
            break

        for i in range(4):
            nx = p[0]+dx[i]
            ny = p[1]+dy[i]
            if 0<=nx<w and 0<=ny<h and a[ny][nx] != "#" and d[ny][nx] == float("inf"):
                q.append((nx,ny))
                d[ny][nx] = d[p[1]][p[0]]
        if len(q) == 0 and goal == False:
            while local_area:
                p = local_area.popleft()
                for i in range(-2,3):
                    for j in range(-2,3):
                        nx = p[0]+i 
                        ny = p[1]+j
                        if 0<=nx<w and 0<=ny<h and a[ny][nx] != "#" and d[ny][nx] == float("inf"):
                            q.append((nx,ny))
                            d[ny][nx] = d[p[1]][p[0]] + 1                        

    if goal == False:
        return -1
    else:
        return d[gy][gx]
        
print(bfs())

### FIXED CODE ###

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

h,w = map(int,input().rstrip().split())
sy,sx = map(int,input().rstrip().split())
gy,gx = map(int,input().rstrip().split())
a = [list(input().rstrip())for _ in range(h)]

sx -= 1
sy -= 1
gx -= 1
gy -= 1

dx=[1,0,-1,0]
dy=[0,1,0,-1]

def bfs():
    d = [[float("inf")]*w for _ in range(h)]
    q = deque([])
    q.append((sx,sy))
    d[sy][sx] = 0 #warp回数
    goal = False
    local_area = deque([])

    while q:
        p = q.popleft()
        local_area.append((p[0],p[1]))
        if p[0] == gx and p[1] == gy:
            goal = True
            break

        for i in range(4):
            nx = p[0]+dx[i]
            ny = p[1]+dy[i]
            if 0<=nx<w and 0<=ny<h and a[ny][nx] != "#" and d[ny][nx] == float("inf"):
                q.append((nx,ny))
                d[ny][nx] = d[p[1]][p[0]]
        if len(q) == 0 and goal == False:
            while local_area:
                p = local_area.popleft()
                for i in range(-2,3):
                    for j in range(-2,3):
                        nx = p[0]+i 
                        ny = p[1]+j
                        if 0<=nx<w and 0<=ny<h and a[ny][nx] != "#" and d[ny][nx] == float("inf"):
                            q.append((nx,ny))
                            d[ny][nx] = d[p[1]][p[0]] + 1                        

    if goal == False:
        return -1
    else:
        return d[gy][gx]
        
print(bfs())
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
m = 1
for i in a:
  m = m*i
print(m if m <= 10**18 else -1)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
m = 1
if 0 in a:
    print(0)
else:
    for i in range(n):
        m = m * a[i]
        if m > 10 ** 18:
            print(-1)
            break
        elif i == n - 1:
            print(m)
### BUGGY CODE ###

n, k, q = map(int, input().split())
A = [int(input()) for _ in range(q)]
# print(A)
for i in range(1, n + 1):
    if k - q + (A.count(i)) > 0:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

n, k, q = map(int, input().split())
Point = [k - q] * n
for _ in range(q):
    Point[int(input()) - 1] += 1

for e in Point:
    if e > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

N = int(input())
s = [sorted(input()) for _ in range(N)]

def isAnagram(s1, s2):
  return 1 if s1 == s2 else 0

print( sum([sum( [isAnagram(s[i], s[j])for j in range(i+1, N)]) for i in range(N)]) )
  

### FIXED CODE ###

from collections import defaultdict
import math

N = int(input())
s = [str(sorted(input())) for _ in range(N)]
rl_s = defaultdict(int)
for _s in s:
  rl_s[_s] += 1

c = 0
for v in rl_s.values():
  c += sum([i for i in range(v)])
print( c )
### BUGGY CODE ###

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

def solve():
    N, M = list(map(int, input().split()))
    """
    from1 := 1から行ける島番号のリスト
    toN := Nに行ける島番号のリスト
    from1とtoNの両方に同じ島番号が存在するとき、POSSIBLE
    """
    from1, toN = [], []
    for i in range(M):
        a, b = list(map(int, input().split()))
        if a == 1:
            from1.append(b)
        elif b == N:
            toN.append(a)
    
    for b in from1:
        if b in toN:
            print("POSSIBLE")
            return
    print("IMPOSSIBLE")
        

if __name__ == "__main__":
    solve()


### FIXED CODE ###

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

def solve():
    N, M = list(map(int, input().split()))
    """
    from1 := 1から行ける島番号のリスト
    canN[i] := 島iがNに行くことができるか否か
    from1とtoNの両方に同じ島番号が存在するとき、POSSIBLE
    """
    from1 = []
    canN = [False] * (N+1)
    for i in range(M):
        a, b = list(map(int, input().split()))
        if a == 1:
            from1.append(b)
        elif b == N:
            canN[a] = True
    
    for b in from1:
        if canN[b]:
            print("POSSIBLE")
            return
    print("IMPOSSIBLE")
        

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

import collections
n = int(input())
a = []
for i in range(n):
  s = input()
  c = collections.Counter(list(s))
  a.append(c)
ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    if a[i] == a[j]:
      ans += 1
print(ans)

### FIXED CODE ###

import collections
n = int(input())
a = []
for i in range(n):
  s = input()
  b = list(s)
  b.sort()
  b = ''.join(b)
  a.append(b)
c = collections.Counter(a)
ans = 0
for e in c:
  ans += c[e] * (c[e] - 1) // 2
print(ans)
### BUGGY CODE ###

n,a,b=map(int,input().split())
def fac(N):
  s=1
  while N>=1:
    s=s*N
    N=N-1
  return (s)
def com(m,n):
  k=int(fac(m)/(fac(m-n)*fac(n)))
  return (k)
S=0
for i in range(1,n+1):
  if i!=a and i!=b:
    S=S+com(n,i)
print(S)

### FIXED CODE ###

n,a,b=map(int,input().split())
p=1000000007
def pmod(N,K,p):
  s=1
  for i in range(K):
    s=(s*(N-i))%p
  return (s)

def bin(N):
    lists=[]
    t=0
    while N>0:
        lists.append(N%2)
        N=N//2
        t=t+1
    lists.append(t)
    return (lists)

def digb(N):
    t=0
    while N>0:
        N=N//2
        t=t+1
    return (t)

def mod(a,N,p):
    listm=[]
    for i in range(digb(N)):#2**(2**i)%pの余を記録
        listm.append(a*bin(N)[i])
        a=(a**2)%p
    s=1
    for i in range(digb(N)):
        if listm[i]!=0:
            s=(s*listm[i])%p
    return(s)

print ((mod(2,n,p)-pmod(n,a,p)*mod(pmod(a,a,p),p-2,p)-pmod(n,b,p)*mod(pmod(b,b,p),p-2,p)-1)%p)
### BUGGY CODE ###

from bisect import bisect_left, bisect_right, insort_left

n = int(input())
s = list(input())
q = int(input())
qs = [list(input().split()) for _ in range(q)]

abc = [[] for _ in range(26)]
for i, e in enumerate(s):
    j = ord(e) - ord("a")
    abc[j].append(i)

for t, e1, e2 in qs:
    if t == "1":
        i = int(e1) - 1
        c = e2

        let = s[i]

        idx = ord(let) - ord("a")
        popi = bisect_left(abc[idx], i)
        abc[idx].pop(popi)

        idx = ord(c) - ord("a")
        insort_left(abc[idx], i)

        s[i] = c

    else:
        l = int(e1) - 1
        r = int(e2) - 1

        cnt = 0
        for i in range(26):
            li = bisect_left(abc[i], l)
            ri = bisect_right(abc[i], r)
            if li != ri:
                cnt += 1

        print(cnt)


### FIXED CODE ###

from bisect import bisect_left, insort_left


def main():
    n = int(input())
    s = list(input())
    q = int(input())
    qs = [input().split() for _ in range(q)]

    abc = [[] for _ in range(26)]
    for i, e in enumerate(s):
        j = ord(e) - ord("a")
        abc[j].append(i)

    for t, e1, e2 in qs:
        if t == "1":
            i = int(e1) - 1
            c = e2

            let = s[i]

            if let == c:
                continue

            idx = ord(let) - ord("a")
            popi = bisect_left(abc[idx], i)
            abc[idx].pop(popi)

            idx = ord(c) - ord("a")
            insort_left(abc[idx], i)

            s[i] = c

        else:
            l = int(e1) - 1
            r = int(e2) - 1

            cnt = 0
            for i in range(26):
                li = bisect_left(abc[i], l)
                if li >= len(abc[i]):
                    continue
                if abc[i][li] <= r:
                    cnt += 1

            print(cnt)


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

N=int(input().split(" ")[0])
A=input().split(" ")
x=0
t=1
for i in range(N):
    k=i+1
    y=0
    while k<=N-1:
        if y< int(A[k])-int(A[i]):
            y=int(A[k])-int(A[i])
        k+=1
    if x<y:
        x=y
        t=1
    elif x==y:
        t=t+1

print(t)        
        




### FIXED CODE ###

nt=input().split(" ")
N=int(nt[0])
T=int(nt[1])


a=input().split(" ")
int_a=[]
maxlist=[]
for i in range(N):
    int_a.append(int(a[i]))

reva=int_a
reva.reverse()
max=0
for i in range(N):
    if reva[i]>max:
        max=reva[i]
    maxlist.append(max)

maxlist.reverse()
int_a.reverse()


max=0
count=1
for i in range(N):
    if maxlist[i]-int_a[i]>max:
        count=1
        max=maxlist[i]-int_a[i]
    elif maxlist[i]-int_a[i]==max:
        count+=1

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

N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(int(input()))

case = [0] * (N + 1)
case[0] = 1
if not 1 in A:
    case[1] = 1
for x in range(2, N + 1):
    if x in A:
        case[x] = 0
    elif x - 1 in A:
        case[x] = case[x - 2]
    else:
        case[x] = case[x - 1] + case[x - 2]

print(case[N] % 1000000007)

### FIXED CODE ###

N, M = map(int, input().split())
A = [1] * (N + 1)
ans = [0] * (N + 1)
ans[0] = 1
for _ in range(M):
    A[int(input())] = 0
for i in range(1, N + 1):
    ans[i] = (ans[i - 2] * A[i - 2] + ans[i - 1] * A[i - 1]) % 1000000007

print(ans[N])