#K85727. Array Query Processor

    ID: 36706 Type: Default 1000ms 256MiB

Array Query Processor

Array Query Processor

You are given an array of n integers and q queries. You need to process the queries one by one. There are two types of queries:

  • Update Query: 1 x y — update the element at position x to value y, where \(1 \le x \le n\) and \(1 \le y \le 10^5\).
  • Range Counting Query: 2 l r — count the number of elements in the array that are between l and r (inclusive), where \(1 \le l \le r \le 10^5\).

After processing all queries, output the results of all range counting queries in the order they appear. The input will be provided via stdin and the output must be printed to stdout.

inputFormat

The input consists of multiple lines:

  1. The first line contains two integers n and q, representing the number of elements in the array and the number of queries, respectively.
  2. The second line contains n space-separated integers, representing the initial state of the array.
  3. The following q lines each describe a query in one of the following formats:
    • 1 x y — update the element at index x with value y.
    • 2 l r — count and output the number of elements between l and r (inclusive).

outputFormat

For each query of type 2, output a single line containing the result of the range count query. The results should appear in the same order as the queries.

## sample
5 3
1 2 3 4 5
2 2 4
1 3 10
2 2 4
3

2

</p>