#include #define endl '\n' using namespace std; const int MAXN=2e5+5; const int MAXLOG=17; int n,q; int a[MAXN]; int last[MAXN]; int st[MAXN][MAXLOG]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); freopen("matchingseq.in","r",stdin); freopen("matchingseq.out","w",stdout); cin>>n>>q; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) { st[i][0]=st[i-1][0]; st[i][0]=max(st[i][0], last[a[i]]); last[a[i]]=i; //cout<0) st[i][j]=st[st[i][j-1]-1][j-1]; else st[i][j]=0; } } /* for(int i=1;i<=n;i++) { cout<>l>>r; int ans=0; for(int j=MAXLOG-1;j>=0;j--) { if(st[r][j]>=l) { ans+=(1<