Language: C++

#include<bits/stdc++.h>
using namespace std;

//***---***---***---***---***---***---BEGIN USELESS CODE---***---***---***---***---***---***//

#define ll long long
#define ld long double
const char newl = '\n';

template<class T> void read(vector<T>& vt);
template<class T>
void read(T& args) { cin >> args; }
template<class A, class... B >
void read(A& argc, B&... argv) {
	read(argc);
	read(argv...);
}
template<class T>
void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool bo) { return (bo ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(const char* str) { return string(str);}
string to_string(string str) { return str; }
template<class T>
string to_string(T vt) {
	bool ft = 1;
	string res;
	for(auto &a : vt) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += to_string(a);
	}
	return res;
}
string to_string(vector<bool> vt) {
	string res;
	bool ft = 1;
	for(int i = 0; i < (int)vt.size(); ++i) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += char('0' + vt[i]);
	}
	return res;
}

template<class T>
void write(T args) { cout << to_string(args); }
template<class A, class... B>
void write(const A argc, const B... argv) {
	write(argc);
	write(argv...);
}

void print() { write(newl); }
template<class A, class... B>
void print(const A argc, const B... argv) {
	write(argc);
	if(sizeof...(argv))
		write(' ');
	print(argv...);
}

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << to_string(argc);
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

//***---***---***---***---***---***---END USELESS CODE---***---***---***---***---***---***//

int ts;
int n,m;
vector<int> c;
vector<vector<pair<int,int>>> q;
vector<int> ans, cnt;
vector<int> BIT;

void upd#include<bits/stdc++.h>
using namespace std;

//***---***---***---***---***---***---BEGIN USELESS CODE---***---***---***---***---***---***//

#define ll long long
#define ld long double
const char newl = '\n';

template<class T> void read(vector<T>& vt);
template<class T>
void read(T& args) { cin >> args; }
template<class A, class... B >
void read(A& argc, B&... argv) {
	read(argc);
	read(argv...);
}
template<class T>
void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool bo) { return (bo ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(const char* str) { return string(str);}
string to_string(string str) { return str; }
template<class T>
string to_string(T vt) {
	bool ft = 1;
	string res;
	for(auto &a : vt) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += to_string(a);
	}
	return res;
}
string to_string(vector<bool> vt) {
	string res;
	bool ft = 1;
	for(int i = 0; i < (int)vt.size(); ++i) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += char('0' + vt[i]);
	}
	return res;
}

template<class T>
void write(T args) { cout << to_string(args); }
template<class A, class... B>
void write(const A argc, const B... argv) {
	write(argc);
	write(argv...);
}

void print() { write(newl); }
template<class A, class... B>
void print(const A argc, const B... argv) {
	write(argc);
	if(sizeof...(argv))
		write(' ');
	print(argv...);
}

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << to_string(argc);
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

//***---***---***---***---***---***---END USELESS CODE---***---***---***---***---***---***//

int ts;
int n,m;
vector<int> c;
vector<vector<pair<int,int>>> q;
vector<int> ans, cnt;
vector<int> BIT;

void update(int ind, int value) {
	++ind;
	for(; ind <= n; ind += ind&-ind)
		BIT[ind] += value;
}

int query(int ind) {
	//++ind;
	int sum  = 0;
	for(; ind > 0; ind -= ind&-ind)
		sum += BIT[ind];
	return sum;
}

void solve() {
	read(n,m);
	c = vector<int>(n);
	q = vector<vector<pair<int,int>>>(n);
	BIT = vector<int>(n + 1);
	read(c);
	for(int i = 0; i < m; ++i) {
		int x,y;
		read(x,y);
		--x;
		--y;
		q[y].push_back({x, i});
	}
	ans = vector<int>(m);
	cnt = vector<int>(n, -1);
	map<int,int> mp;
	for(int i = 0; i < n; ++i) {
		if(mp.find(c[i]) != mp.end())
			update(mp[c[i]], -1);
		update(i, 1);
		for(auto a : q[i]) {
			ans[a.second] = query(n) - query(a.first);
		}
		mp[c[i]] = i;
	}
	print(ans);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	//read(ts);
	//while(ts--)
		solve();
}

Compiler output:
a.cc:92:9: error: stray '#' in program
   92 | void upd#include<bits/stdc++.h>
      |         ^
a.cc:92:10: error: expected initializer before 'include'
   92 | void upd#include<bits/stdc++.h>
      |          ^~~~~~~
a.cc:99:12: error: redefinition of 'const char newl'
   99 | const char newl = '\n';
      |            ^~~~
a.cc:8:12: note: 'const char newl' previously defined here
    8 | const char newl = '\n';
      |            ^~~~
a.cc:103:6: error: redefinition of 'template<class T> void read(T&)'
  103 | void read(T& args) { cin >> args; }
      |      ^~~~
a.cc:12:6: note: 'template<class T> void read(T&)' previously declared here
   12 | void read(T& args) { cin >> args; }
      |      ^~~~
a.cc:105:6: error: redefinition of 'template<class A, class ... B> void read(A&, B& ...)'
  105 | void read(A& argc, B&... argv) {
      |      ^~~~
a.cc:14:6: note: 'template<class A, class ... B> void read(A&, B& ...)' previously declared here
   14 | void read(A& argc, B&... argv) {
      |      ^~~~
a.cc:110:6: error: redefinition of 'template<class T> void read(std::vector<_Tp>&)'
  110 | void read(vector<T>& vt) {
      |      ^~~~
a.cc:19:6: note: 'template<class T> void read(std::vector<_Tp>&)' previously declared here
   19 | void read(vector<T>& vt) {
      |      ^~~~
a.cc:115:8: error: redefinition of 'std::string to_string(bool)'
  115 | string to_string(bool bo) { return (bo ? "true" : "false"); }
      |        ^~~~~~~~~
a.cc:24:8: note: 'std::string to_string(bool)' previously defined here
   24 | string to_string(bool bo) { return (bo ? "true" : "false"); }
      |        ^~~~~~~~~
a.cc:116:8: error: redefinition of 'std::string to_string(char)'
  116 | string to_string(char c) { return string(1, c); }
      |        ^~~~~~~~~
a.cc:25:8: note: 'std::string to_string(char)' previously defined here
   25 | string to_string(char c) { return string(1, c); }
      |        ^~~~~~~~~
a.cc:117:8: error: redefinition of 'std::string to_string(const char*)'
  117 | string to_string(const char* str) { return string(str);}
      |        ^~~~~~~~~
a.cc:26:8: note: 'std::string to_string(const char*)' previously defined here
   26 | string to_string(const char* str) { return string(str);}
      |        ^~~~~~~~~
a.cc:118:8: error: redefinition of 'std::string to_string(std::string)'
  118 | string to_string(string str) { return str; }
      |        ^~~~~~~~~
a.cc:27:8: note: 'std::string to_string(std::string)' previously defined here
   27 | string to_string(string str) { return str; }
      |        ^~~~~~~~~
a.cc:120:8: error: redefinition of 'template<class T> std::string to_string(T)'
  120 | string to_string(T vt) {
      |        ^~~~~~~~~
a.cc:29:8: note: 'template<class T> std::string to_string(T)' previously declared here
   29 | string to_string(T vt) {
      |        ^~~~~~~~~
a.cc:131:8: error: redefinition of 'std::string to_string(std::vector<bool>)'
  131 | string to_string(vector<bool> vt) {
      |        ^~~~~~~~~
a.cc:40:8: note: 'std::string to_string(std::vector<bool>)' previously defined here
   40 | string to_string(vector<bool> vt) {
      |        ^~~~~~~~~
a.cc:144:6: error: redefinition of 'template<class T> void write(T)'
  144 | void write(T args) { cout << to_string(args); }
      |      ^~~~~
a.cc:53:6: note: 'template<class T> void write(T)' previously declared here
   53 | void write(T args) { cout << to_string(args); }
      |      ^~~~~
a.cc:146:6: error: redefinition of 'template<class A, class ... B> void write(A, const B ...)'
  146 | void write(const A argc, const B... argv) {
      |      ^~~~~
a.cc:55:6: note: 'template<class A, class ... B> void write(A, const B ...)' previously declared here
   55 | void write(const A argc, const B... argv) {
      |      ^~~~~
a.cc:151:6: error: redefinition of 'void print()'
  151 | void print() { write(newl); }
      |      ^~~~~
a.cc:60:6: note: 'void print()' previously defined here
   60 | void print() { write(newl); }
      |      ^~~~~
a.cc:153:6: error: redefinition of 'template<class A, class ... B> void print(A, const B ...)'
  153 | void print(const A argc, const B... argv) {
      |      ^~~~~
a.cc:62:6: note: 'template<class A, class ... B> void print(A, const B ...)' previously declared here
   62 | void print(const A argc, const B... argv) {
      |      ^~~~~
a.cc:160:6: error: redefinition of 'void DEBUGLOCAL()'
  160 | void DEBUGLOCAL() { cerr << ")" << newl; }
      |      ^~~~~~~~~~
a.cc:69:6: note: 'void DEBUGLOCAL()' previously defined here
   69 | void DEBUGLOCAL() { cerr << ")" << newl; }
      |      ^~~~~~~~~~
a.cc:162:6: error: redefinition of 'template<class A, class ... B> void DEBUGLOCAL(A, B ...)'
  162 | void DEBUGLOCAL(A argc, B... argv) {
      |      ^~~~~~~~~~
a.cc:71:6: note: 'template<class A, class ... B> void DEBUGLOCAL(A, B ...)' previously declared here
   71 | void DEBUGLOCAL(A argc, B... argv) {
      |      ^~~~~~~~~~
a.cc:176:5: error: redefinition of 'int ts'
  176 | int ts;
      |     ^~
a.cc:85:5: note: 'int ts' previously declared here
   85 | int ts;
      |     ^~
a.cc:177:5: error: redefinition of 'int n'
  177 | int n,m;
      |     ^
a.cc:86:5: note: 'int n' previously declared here
   86 | int n,m;
      |     ^
a.cc:177:7: error: redefinition of 'int m'
  177 | int n,m;
      |       ^
a.cc:86:7: note: 'int m' previously declared here
   86 | int n,m;
      |       ^
a.cc:178:13: error: redefinition of 'std::vector<int> c'
  178 | vector<int> c;
      |             ^
a.cc:87:13: note: 'std::vector<int> c' previously declared here
   87 | vector<int> c;
      |             ^
a.cc:179:31: error: redefinition of 'std::vector<std::vector<std::pair<int, int> > > q'
  179 | vector<vector<pair<int,int>>> q;
      |                               ^
a.cc:88:31: note: 'std::vector<std::vector<std::pair<int, int> > > q' previously declared here
   88 | vector<vector<pair<int,int>>> q;
      |                               ^
a.cc:180:13: error: redefinition of 'std::vector<int> ans'
  180 | vector<int> ans, cnt;
      |             ^~~
a.cc:89:13: note: 'std::vector<int> ans' previously declared here
   89 | vector<int> ans, cnt;
      |             ^~~
a.cc:180:18: error: redefinition of 'std::vector<int> cnt'
  180 | vector<int> ans, cnt;
      |                  ^~~
a.cc:89:18: note: 'std::vector<int> cnt' previously declared here
   89 | vector<int> ans, cnt;
      |                  ^~~
a.cc:181:13: error: redefinition of 'std::vector<int> BIT'
  181 | vector<int> BIT;
      |             ^~~
a.cc:90:13: note: 'std::vector<int> BIT' previously declared here
   90 | vector<int> BIT;
      |             ^~~