func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:100000000 )   using namespace std;   int b[500][100005], c[500];   int main() {     srand(time(0));     int n, m, i, j, k;     scanf( %d %d , &n, &m);     map<int, vector<int> > a;     for (i = 0; i < n; i++) {       scanf( %d , &k);       if (k <= n) a[k].push_back(i + 1);     }     vector<int> v;     map<int, vector<int> >::iterator it;     for (it = a.begin(); it != a.end(); it++)       if (it->first > it->second.size()) v.push_back(it->first);     for (i = 0; i < v.size(); i++) a.erase(v[i]);     k = 0;     for (it = a.begin(); it != a.end(); it++) {       c[k] = it->first;       for (i = 0; i < it->second.size(); i++) b[k][it->second[i]] = 1;       for (i = 1; i <= n; i++) b[k][i] += b[k][i - 1];       k++;     }     while (m--) {       scanf( %d %d , &i, &j);       int cnt = 0;       for (n = 0; n < k; n++)         if (c[n] == b[n][j] - b[n][i - 1]) cnt++;       printf( %d n , cnt);     }     return 0;   }   