KQUERY - K-query #include <iostream> #include <algorithm> #define pf(i) printf("%ld\n", i) #define sf(i) scanf("%d", &i) #define sl(i) scanf("%ld", &i) using namespace std; int n, q; long int l, r, k; struct node { int l, r, p; int v; }; node makenode(int v,int l, int r, int p) { node temp; temp.v = v; //value temp.l = l; //left limit temp.r = r; //right limit temp.p = p; //position return temp; } bool comp(node a, node b) { if(a.v == b.v) { return a.l > b.l; } return a.v > b.v; } void update(long int seg[], int l, int r, int index, int pos) { if(l == r) { seg[index]++; } else ...