FREQUENT segment tree #include <iostream> #include <algorithm> #include <stdio.h> #define sf(i) scanf("%d", &i) #define pf(i) printf("%d\n", i) #define pii pair<int, int> #define mp make_pair #define f first // value #define s second //frequency #define FOR(a, b) for(int i = a; i < b; i++) using namespace std; const int N = 100001; struct node { pii m; pii l; pii r; }; int n, q; int arr[N]; node seg[4 * N]; node combine(node &a, node &b) { node res; if(a.l.f == b.r.f) //if all the elements are same { res.l.f = res.r.f = res.m.f = a.l.f; res.l.s ...