#include <bits/stdc++.h>
using ll = long long;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set =
tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
std::vector<int> countScans(std::vector<int> a, std::vector<int> x, std::vector<int> v) {
const int n = a.size();
const int q = x.size();
std::vector<int> res(q);
for (int t = 0; t < q; t++) {
a[x[t]] = v[t];
ordered_set<std::array<int, 2>> seen;
int passes = 0, timer = 0;
for (int i : a) {
passes = std::max(passes, (int) (seen.size() - seen.order_of_key({i + 1, -1})));
seen.insert({i, timer++});
}
res[t] = passes;
}
return res;
}