#include <bits/stdc++.h>
#include "bubblesort2.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
int Q=X.size();
std::vector<int> answer(Q);
for (int j=0;j<Q;j++) {
A[X[j]] = V[j];
pbds oset;
int ans = 0;
for(int x = 0; x < (int) A.size(); ++x){
ans = max(ans, (int) oset.order_of_key(A[x]));
oset.insert(A[x]);
}
answer[j] = ans;
}
return answer;
}