malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #define int long long   using namespace std;      long long gcd(long long a, long long b)   {       if(!b)           return a;       return gcd(b, a % b);   }      long long lcm(long long a, long long b)   {       long long z = gcd(a, b);       a /= z;       if(a > 1e18 / b)           return -1;       return a * b;   }   const int MOD = 1e9 + 7;   int inv(int x)   {       int y = MOD - 2, r = 1;       while(y)       {           if(y&1)               r=1LL*r*x%MOD;           y>>=1;           x=1LL*x*x%MOD;       }       return r;   }   int32_t main()   {       long long n;       int t;       cin >> t;       while(t--)       {          cin >> n;           long long q = 1, ans = 0;              for(int i = 1; i <= 1000; ++i)           {                  long long p = lcm(q, i);                  if(p == -1)                   break;               else                   q = p;               long long mul = (i + 1) / gcd(q, (i + 1));               long long divI = n / q, t3 = divI / mul;               long long pqr = divI - t3;               long long qq = (1LL * pqr * (i + 1)) % MOD;               ans = (ans + qq) % MOD;           }           cout << ans <<   n ;          }   }
#include <bits/stdc++.h>   using namespace std;   const int Nmax = 1000005, Mod = 1e9 + 7;   const int Mod1 = 1e9 + 7, Mod2 = 1e9 + 9;   char A[Nmax], B[Nmax];   int hash1[Nmax], hash2[Nmax];   int inv_hash1[Nmax], inv_hash2[Nmax];   int main() {     ios::sync_with_stdio(false);     int N, M;     cin >> N >> M;     cin >> (B + 1);     int K = strlen(B + 1);     for (int i = 1; i <= K; ++i) {       hash1[i] = (27LL * hash1[i - 1] + B[i] -  a  + 1) % Mod1;       hash2[i] = (27LL * hash2[i - 1] + B[i] -  a  + 1) % Mod2;     }     for (int i = K, pw1 = 1, pw2 = 1; i > 0; --i) {       inv_hash1[i] = (inv_hash1[i + 1] + 1LL * (B[i] -  a  + 1) * pw1) % Mod1;       inv_hash2[i] = (inv_hash2[i + 1] + 1LL * (B[i] -  a  + 1) * pw2) % Mod2;       pw1 = 27LL * pw1 % Mod1;       pw2 = 27LL * pw2 % Mod2;     }     set<int> insertions;     bool goodSol = true;     while (M-- > 0) {       int left;       cin >> left;       int right = left + K - 1;       auto it = insertions.upper_bound(left);       if (it != insertions.begin()) {         --it;         int p = *it;         if (p + K - 1 >= left) {           int p1 = p + K - left, p2 = K - p1 + 1;           if (hash1[p1] != inv_hash1[p2] || hash2[p1] != inv_hash2[p2]) {             goodSol = false;             break;           }         }       }       it = insertions.lower_bound(left);       if (it != insertions.end()) {         int p = *it;         if (p <= right) {           int p1 = right - p + 1, p2 = K - p1 + 1;           if (hash1[p1] != inv_hash1[p2] || hash2[p1] != inv_hash2[p2]) {             goodSol = false;             break;           }         }       }       insertions.insert(left);     }     if (goodSol == false)       cout <<  0 n ;     else {       int ans = 1;       for (int i = 1; i <= N; ++i) {         auto it = insertions.upper_bound(i);         if (it != insertions.begin()) {           --it;           int p = *it;           if (p + K - 1 < i) ans = 26LL * ans % Mod;         } else {           ans = 26LL * ans % Mod;         }       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     long long n, k;     cin >> n >> k;     vector<long long> v(n);     for (int i = 0; i < n; i++) {       cin >> v[i];     }     long long ans = 0;     unordered_map<int, int> m;     for (int r = 0, l = 0; r < n; r++) {       m[v[r]]++;       while (m[v[r]] >= k) {         m[v[l++]]--;       }       ans += l;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   void yash() {     int arr[4], count = 1;     for (int i = 0; i < 4; i++) {       cin >> arr[i];     }     sort(arr, arr + 4);     for (int i = 0; i < 3; i++) {       if (arr[i] != arr[i + 1]) {         count++;       }     }     cout << 4 - count <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     yash();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, x;     cin >> n >> m;     x = m - n;     if (x >= 2 && n % 2 == 0)       cout << n <<     << n + 1 <<     << n + 2 << endl;     else if (x >= 3 && n % 2 != 0)       cout << n + 1 <<     << n + 2 <<     << n + 3 << endl;     else       cout <<  -1  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3000 + 5;   int n, m;   int l[N][N], r[N][N], cnt[N], fen[N];   char s[N][N];   vector<int> del[N];   void up(int x, int k) {     cnt[x] += k;     for (; x; x -= x & -x) fen[x] += k;   }   int get(int x) {     int res = 0;     for (; x < N; x += x & -x) res += fen[x];     return res;   }   long long start(int x, int y) {     memset(fen, 0, sizeof(fen));     memset(cnt, 0, sizeof(cnt));     for (int i = 1; i <= n; i++) del[i].clear();     long long ans = 0;     int go = x;     while (x <= n and y >= 1) {       for (auto u : del[x]) up(u, -1);       if (s[x][y] ==  . ) {         for (int i = go; i < x; i++)           if (cnt[i]) up(i, -1);         go = x + 1;         x++;         y--;         continue;       }       up(x, +1);       if (x + l[x][y] <= n) del[x + l[x][y]].push_back(x);       int len = min(r[x][y], x - go + 1);       ans += get(x - len + 1);       x++;       y--;     }     return ans;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %s , s[i] + 1);       for (int j = 1; j <= m; j++) {         l[i][j] = s[i][j] ==  z  ? l[i][j - 1] + 1 : 0;       }       for (int j = m; j >= 1; j--) {         r[i][j] = s[i][j] ==  z  ? r[i][j + 1] + 1 : 0;       }     }     long long ans = 0;     for (int i = 1; i <= m; i++) {       ans += start(1, i);     }     for (int i = 2; i <= n; i++) {       ans += start(i, m);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[111111], b[111111];   vector<int> v;   long long t[555][555];   int main() {     int n;     cin >> n;     int r, c;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> t[i][j];         if (t[i][j] == 0) {           r = i;           c = j;         }       }     }     if (n == 1) {       cout <<  1  << endl;       return 0;     }     long long sum = 0;     if (r == 0) {       for (int i = 0; i < n; i++) sum += t[1][i];     } else {       for (int i = 0; i < n; i++) sum += t[0][i];     }     long long lel = 0;     for (int i = 0; i < n; i++) {       lel += t[r][i];     }     if (lel >= sum) {       cout <<  -1 ;       return 0;     }     t[r][c] = sum - lel;     for (int i = 0; i < n; i++) {       long long cur = 0;       for (int j = 0; j < n; j++) {         cur += t[i][j];       }       if (cur != sum) {         cout <<  -1 ;         return 0;       }     }     for (int i = 0; i < n; i++) {       long long cur = 0;       for (int j = 0; j < n; j++) {         cur += t[j][i];       }       if (cur != sum) {         cout <<  -1 ;         return 0;       }     }     long long cur = 0;     for (int i = 0; i < n; i++) {       cur += t[i][i];     }     if (cur != sum) {       cout <<  -1 ;       return 0;     }     cur = 0;     for (int i = 0; i < n; i++) {       cur += t[i][n - 1 - i];     }     if (cur != sum) {       cout <<  -1 ;       return 0;     }     cout << t[r][c];     return 0;   }
#include <bits/stdc++.h>   char s[100001];   int a[100000];   int b[100000];   void func() {     int n = strlen(s), i, ans = 1 << 29;     if (isupper(s[0])) {       a[0] = 0;     } else {       a[0] = 1;     }     for (i = 1; i < n; i++) {       if (isupper(s[i])) {         a[i] = a[i - 1];       } else {         a[i] = a[i - 1] + 1;       }     }     if (islower(s[n - 1])) {       b[n - 1] = 0;     } else {       b[n - 1] = 1;     }     for (i = n - 2; i >= 0; i--) {       if (islower(s[i])) {         b[i] = b[i + 1];       } else {         b[i] = b[i + 1] + 1;       }     }     for (i = 0; i < n; i++) {       if (i == 0) {         ans = ((ans) < (b[i]) ? (ans) : (b[i]));       }       if (i < n - 1) {         ans = ((ans) < (a[i] + b[i + 1]) ? (ans) : (a[i] + b[i + 1]));       } else {         ans = ((ans) < (a[i]) ? (ans) : (a[i]));       }     }     printf( %d n , ans);   }   int main() {     while (scanf( %s , s) == 1) {       func();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f;   long long c[maxn][maxn], pw[2][maxn], f[maxn][maxn];   inline int add(long long a, long long b) {     a += b;     return a >= mod ? a - mod : a;   }   inline int mul(long long a, long long b) { return a * b % mod; }   inline long long kpow(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = res * a % mod;       a = a * a % mod;       b >>= 1;     }     return res;   }   void init(int n, int m) {     for (int i = 0; i <= n; ++i) c[i][0] = 1;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= i; ++j)         c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;     for (int i = 0; i <= n; ++i) {       pw[0][i] = kpow(m - 1, i);       pw[1][i] = kpow(m, i);     }   }   int main() {     int n, m;     cin >> n >> m;     init(n, m);     f[0][0] = 1;     for (int i = 1; i <= n; ++i)       for (int j = 0; j <= n; ++j) {         for (int k = 1; k <= j; ++k)           f[i][j] =               add(f[i][j],                   mul(mul(mul(f[i - 1][j - k], c[n - j + k][k]), pw[1][j - k]),                       pw[0][n - j]));         f[i][j] =             add(f[i][j], mul(f[i - 1][j], mul((pw[1][j] - pw[0][j] + mod) % mod,                                               kpow(m - 1, n - j))));       }     cout << f[n][n];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INT_INF = 1e9;   const long long LL_INF = 1e18;   int getInt(char c) { return c -  0 ; }   int getDistance(int index, int y, int z, vector<vector<int>>& last) {     int p = last[index][y];     if (p == -1) return INT_INF;     int q = last[p][z];     if (q == -1) return INT_INF;     return index - q + 1;   }   int main() {     int tt;     cin >> tt;     while (tt--) {       string s;       cin >> s;       int n = (int)s.size();       vector<vector<int>> last(n, vector<int>(3, -1));       last[0][getInt(s[0]) - 1] = 0;       int ans = INT_INF;       for (int i = 1; i < n; i++) {         int u = getInt(s[i]) - 1;         for (int j = 0; j < 3; j++) {           if (u == j)             last[i][u] = i;           else             last[i][j] = last[i - 1][j];         }         if (u == 0) {           ans = min(ans, getDistance(i, 1, 2, last));           ans = min(ans, getDistance(i, 2, 1, last));         } else if (u == 1) {           ans = min(ans, getDistance(i, 0, 2, last));           ans = min(ans, getDistance(i, 2, 0, last));         } else {           ans = min(ans, getDistance(i, 0, 1, last));           ans = min(ans, getDistance(i, 1, 0, last));         }       }       cout << (ans == INT_INF ? 0 : ans) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int n, tmp, ans = 0, mx = -1;     cin >> n;     for (int i = 0; i < n && cin >> tmp; ++i) mx = max(tmp, mx);     cout << (mx > 25 ? mx - 25 : 0);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 212345, LG = 21, mod = 1000000007;   const double eps = 1e-3, pi = acos(-1.0);   int in[N];   vector<int> adj[N];   map<pair<int, int>, int> mp;   set<pair<int, int>> s;   int main() {     int n, m;     scanf( %d , &n), scanf( %d , &m);     for (int i = 1; i <= m; ++i) {       int u, v;       scanf( %d , &u), scanf( %d , &v);       adj[u].push_back(v);       mp[{u, v}] = i;       in[v]++;     }     for (int i = 1; i <= n; ++i) s.insert({in[i], i});     int ans = -1;     while (s.size() > 1) {       int t = s.begin()->second;       s.erase(s.begin());       if (in[t] != 0) {         ans = -1;         break;       }       if (s.begin()->first == 0) {         ans = -1;         break;       }       for (int i = 0; i < adj[t].size(); ++i) {         int u = adj[t][i];         s.erase({in[u], u});         in[u]--;         s.insert({in[u], u});       }       ans = max(ans, mp[{t, s.begin()->second}]);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int A = 100000, MD = 998244353;   int kk[A + 1];   int pp[A + 1][6][6], aa[6][6], tt[6][6];   int uu_[6], vv_[6], *uu = uu_, *vv = vv_;   int kp[A + 1];   bool sq[A + 1];   void init(int *aa, int a0, int a1, int a2, int a3, int a4, int a5) {     aa[0] = a0, aa[1] = a1, aa[2] = a2, aa[3] = a3, aa[4] = a4, aa[5] = a5;   }   void init(int aa[][6], int x) {     int x2 = x * 2 % MD;     int xx = (long long)x * x % MD;     init(aa[0], 2, 1, x2, x2, xx, xx);     init(aa[1], 0, 2, 0, x2, 0, xx);     init(aa[2], 0, 0, 2, 1, x, x);     init(aa[3], 0, 0, 0, 2, 0, x);     init(aa[4], 0, 0, 0, 0, 2, 1);     init(aa[5], 0, 0, 0, 0, 0, 2);   }   void mult(int aa[][6], int *uu, int *vv) {     for (int i = 0; i < 6; i++) {       long long v = 0;       for (int j = 0; j < 6; j++) v += (long long)aa[i][j] * uu[j];       vv[i] = v % MD;     }   }   void mult(int aa[][6], int bb[][6], int cc[][6]) {     for (int i = 0; i < 6; i++)       for (int j = 0; j < 6; j++) {         long long c = 0;         for (int k = 0; k < 6; k++) c += (long long)aa[i][k] * bb[k][j];         cc[i][j] = c % MD;       }   }   void power(int aa[][6], int pp[][6], int tt[][6], int k) {     if (k == 0) {       for (int i = 0; i < 6; i++) {         for (int j = 0; j < 6; j++) pp[i][j] = 0;         pp[i][i] = 1;       }       return;     }     if (k & 1) {       power(aa, pp, tt, k >> 1);       mult(pp, pp, tt);       mult(tt, aa, pp);     } else {       power(aa, tt, pp, k >> 1);       mult(tt, tt, pp);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int m;     cin >> m;     while (m--) {       int a, k;       cin >> a >> k;       kk[a] = k;       init(aa, a);       power(aa, pp[a], tt, k);     }     long long ans = 0;     for (int a = 1; a <= A; a++) {       if (sq[a]) continue;       if (a > 1 && kp[a] == 0) {         for (int b = a; b <= A; b += a) kp[b]++;         if (a <= A / a)           for (int s = a * a, t = s; t <= A; t += s) sq[t] = true;       }       fill(uu, uu + 6, 0);       uu[5] = 1;       for (int b = a; b <= A; b += a)         if (kk[b] > 0) {           mult(pp[b], uu, vv);           swap(uu, vv);         }       int z = uu[0] - uu[1];       ans += kp[a] % 2 == 0 ? z : -z;     }     ans %= MD;     if (ans < 0) ans += MD;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, K, p;   char s[11];   int calc(int x, int y) {     printf( 1 %d %d n , x, y);     fflush(stdout);     scanf( %s , s + 1);     return s[1] ==  T ;   }   int find(int l, int r) {     while (l < r) {       int mid = (l + r) >> 1;       if (calc(mid, mid + 1))         r = mid;       else         l = mid + 1;     }     return l;   }   int main() {     scanf( %d%d , &n, &K);     p = find(1, n);     int l = 1, r = p;     while (l < r) {       int mid = (l + r + 1) >> 1;       if (calc(mid - 1, mid)) return printf( 2 %d %d n , p, find(l, mid - 1)), 0;       l = mid;     }     l = p;     r = n;     while (l < r) {       int mid = (l + r) >> 1;       if (calc(mid + 1, mid)) return printf( 2 %d %d n , p, find(mid + 1, r)), 0;       r = mid;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 100;   int n, k;   char str[N];   bool f[N];   int main() {     scanf( %s , str + 1), n = strlen(str + 1);     while (1 << k < n) ++k;     if (1 << k > n) --k;     memset(f, 1, sizeof(f));     for (int i = 1; i <= n - (1 << k) + 1; ++i) {       char ch =  z ;       for (int s = 0; s < 1 << k; ++s)         if (f[s])           for (int t = 0; t < k; ++t) f[s | (1 << t)] = 1;       for (int s = 0; s < 1 << k; ++s)         if (f[s]) ch = min(str[i + s], ch);       for (int s = 0; s < 1 << k; ++s)         if (str[i + s] != ch) f[s] = 0;       putchar(ch);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int l, r;     cin >> l >> r;     while (l <= r) {       int arr[9] = {0};       int x = l;       bool diff = 1;       while (x) {         int num = x % 10;         x /= 10;         if (arr[num]) {           diff = 0;           l++;           break;         }         arr[num]++;       }       if (diff) {         cout << l << endl;         return 0;       }     }     cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   string s, str;   long long mns, all, pls, nom, maxi, mini, n, sum, otn;   vector<char> v;   vector<long long> ans;   int main() {     getline(cin, s);     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  - ) mns++;       if (s[i] ==  ? ) all++;       if (s[i] ==  = ) nom = i;     }     pls = all - mns;     string str;     str = s.substr(nom + 2, s.size() - nom - 2);     n = atoll(str.c_str());     maxi = n * pls - mns;     mini = pls - mns * n;     if (n < mini || n > maxi) {       cout <<  Impossible ;       return 0;     }     cout <<  Possible n ;     v.push_back( + );     for (int i = 0; i < s.size(); i++)       if (s[i] ==  + )         v.push_back( + );       else if (s[i] ==  - )         v.push_back( - );     for (int i = 0; i < v.size(); i++)       if (v[i] ==  + )         ans.push_back(n);       else         ans.push_back(1);     sum = maxi;     for (int i = 0; i < ans.size(); i++)       if (sum > n)         if (v[i] ==  + ) {           otn = min(n - 1, sum - n);           ans[i] -= otn;           sum -= otn;         } else {           otn = min(n - 1, sum - n);           ans[i] += otn;           sum -= otn;         }     cout << ans[0] <<    ;     for (int i = 1; i < v.size(); i++) cout << v[i] <<     << ans[i] <<    ;     cout <<  =   << n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};     long a, b;     cin >> a;     cin >> b;     int count = 0;     int i;     long x;     do {       x = a;       while (x >= 10) {         i = x % 10;         count += m[i];         x /= 10;       }       count += m[x];       a++;     } while (a <= b);     cout << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   ll cnt_inv[30][2];   void rec(vector<int>& a, int b) {     if (b < 0 || a.empty()) return;     vector<int> s, us;     for (int& i : a) {       int val = i & (1 << b);       if (val)         cnt_inv[b][1] += us.size(), s.push_back(i);       else         cnt_inv[b][0] += s.size(), us.push_back(i);     }     rec(s, b - 1);     rec(us, b - 1);   }   void solve() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < int(n); i++) cin >> a[i];     memset(cnt_inv, 0, sizeof cnt_inv);     rec(a, 29);     ll inv = 0, x = 0;     for (int b = 29; b >= 0; b--) {       inv += min(cnt_inv[b][0], cnt_inv[b][1]);       int val = 1;       if (cnt_inv[b][0] <= cnt_inv[b][1]) val = 0;       x += (val << b);     }     cout << inv <<     << x <<   n ;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   namespace LYYY {   int read() {     int s = 0;     char c = getchar();     int f = 1;     while (c < 48 || c > 57) {       if (c == 45) f = -1;       c = getchar();     }     while (c >= 48 && c <= 57) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();     return s * f;   }   long long readl() {     long long s = 0;     char c = getchar();     int f = 1;     while (c < 48 || c > 57) {       if (c == 45) f = -1;       c = getchar();     }     while (c >= 48 && c <= 57) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();     return s * f;   }   void write(int x) {     if (x >= 10) write(x / 10);     putchar(x % 10 + 48);   }   void W(int x) {     if (x < 0) x = -x, putchar(45);     write(x);   }   void writel(long long x) {     if (x >= 10) write(x / 10);     putchar(x % 10 + 48);   }   void Wl(long long x) {     if (x < 0) x = -x, putchar(45);     write(x);   }   }  // namespace LYYY   using namespace LYYY;   const int mod = 1000 * 1000 * 1000 + 7;   int mul(int x, long long k) {     long long ans = 1, mid = x;     while (k) {       if (k & 1) ans = ans * mid % mod;       mid = mid * mid % mod;       k >>= 1;     }     return ans;   }   int Get(long long n, int x) {     if (n < x) return 1;     return (long long)mul(x, n / x) * Get(n / x, x) % mod;   }   int main() {     int x = read();     long long n = readl(), ans = 1;     for (int i = 2; i * i <= x; ++i)       if (x % i == 0) {         ans = ans * Get(n, i) % mod;         while (x % i == 0) x /= i;       }     if (x > 1) ans = ans * Get(n, x) % mod;     writel(ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct msg {     long long lstl = 0;     long long lstr = 0;     long long num = 0;   };   int32_t main() {     long long n, k;     cin >> n >> k;     long long a[n];     msg ms[n];     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     for (long long i = 0; i < n; i++) {       if (a[i] == 0) {         ms[i].lstl = max(i - k, 0LL);         ms[i].lstr = min(i + k, n - 1);         ms[i].num = 1 + ms[i].lstr - ms[i].lstl;       } else {         ms[i].lstl = max(i - k, 0LL);         ms[i].lstr = min(i + k, n - 1);         long long nmr, nml;         if (ms[i].lstl <= ms[a[i] - 1].lstr) {           if (ms[a[i] - 1].lstr < i) {             nml = k - (ms[a[i] - 1].lstr - ms[i].lstl + 1);           } else {             nml = 0;           }         } else {           nml = i - ms[i].lstl;         }         if (ms[a[i] - 1].lstr < i) {           nmr = ms[i].lstr - i + 1;         } else if (ms[a[i] - 1].lstr == i) {           nmr = ms[i].lstr - i;         } else {           nmr = ms[i].lstr - ms[a[i] - 1].lstr;         }         ms[i].num = nmr + nml + ms[a[i] - 1].num;       }     }     for (long long i = 0; i < n; i++) {       cout << ms[i].num <<    ;     }     return 0;   }