func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, q, p[200005], a[200005], pi[200005], mra[200005], t;   int mar[200005], su[200005], pr[200005], mm[200005], l, lr, r, Ilmm[200005];   vector<int> v[200005];   bool pa;   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> m >> q;     for (int i = 1; i <= n; ++i) {       cin >> p[i];       pi[p[i]] = i;     }     for (int i = 1; i <= m; ++i) {       cin >> a[i];     }     for (int i = 1; i <= m; ++i) {       mar[a[i]] = i;       if (pi[a[i]] == 1) {         pr[i] = i;       } else if (mar[p[pi[a[i]] - 1]]) {         pr[i] = pr[mar[p[pi[a[i]] - 1]]];       }     }     for (int i = 1; i <= n; ++i) mar[i] = 0;     for (int i = m; i > 0; --i) {       v[a[i]].push_back(i);       mar[a[i]] = i;       if (pi[a[i]] == n) {         su[i] = i;       } else if (mar[p[pi[a[i]] + 1]]) {         su[i] = su[mar[p[pi[a[i]] + 1]]];       }       if (!su[i]) continue;       if (pi[a[i]] > 1) {         t = p[pi[a[i]] - 1];         l = 0;         r = v[t].size();         --r;         int tp = 0;         while (l <= r) {           lr = (l + r) / 2;           if (pr[v[t][lr]] > su[i]) {             tp = v[t][lr];             l = lr + 1;           } else {             r = lr - 1;           }         }         mm[i] = tp;       } else {         mm[i] = su[i];       }     }     for (int i = m; i > 0; --i) {       Ilmm[i] = Ilmm[i + 1];       if ((mm[i] && mm[i] < Ilmm[i]) || !Ilmm[i]) {         Ilmm[i] = mm[i];       }     }     for (int i = 1; i <= q; ++i) {       cin >> l >> r;       pa = 0;       if (Ilmm[l] && Ilmm[l] <= r) {         pa = 1;       }       cout << pa;     }   }   