func_code_string: #include <bits/stdc++.h>   using namespace std;   long long a[500005], inc[1002], n, q, d;   vector<pair<long long, long long> > v[1002];   int main() {     ios::sync_with_stdio(false);     cin.tie(), cout.tie();     cin >> n >> q;     d = sqrt(n);     long long cnt = 1;     for (int i = 1; i <= n; i++) {       long long x;       cin >> x;       v[cnt].push_back({x, i});       if (i % d == 0) {         sort(v[cnt].begin(), v[cnt].end());         cnt++;       }     }     sort(v[cnt].begin(), v[cnt].end());     while (q--) {       long long t, l, r, x;       cin >> t;       if (t == 1) {         cin >> l >> r >> x;         long long lower = ceil(l / (double)d);         long long upper = ceil(r / (double)d);         for (int i = 0; i < v[lower].size(); i++) {           if (v[lower][i].second >= l && v[lower][i].second <= r)             v[lower][i].first += x;         }         sort(v[lower].begin(), v[lower].end());         if (upper != lower) {           for (int i = 0; i < v[upper].size(); i++) {             if (v[upper][i].second >= l && v[upper][i].second <= r)               v[upper][i].first += x;           }           sort(v[upper].begin(), v[upper].end());         }         for (int i = lower + 1; i < upper; i++) inc[i] += x;       } else {         cin >> x;         long long l = 1e18, r = -1e18;         for (int i = 1; i <= cnt; i++) {           x -= inc[i];           if (v[i].size() == 0) continue;           long long lo = 0, hi = v[i].size() - 1;           while (lo <= hi) {             long long mid = (lo + hi) / 2;             if (v[i][mid].first == x) {               l = min(l, v[i][mid].second);               hi = mid - 1;             } else if (v[i][mid].first > x)               hi = mid - 1;             else               lo = mid + 1;           }           lo = 0, hi = v[i].size() - 1;           while (lo <= hi) {             long long mid = (lo + hi) / 2;             if (v[i][mid].first == x) {               r = max(r, v[i][mid].second);               lo = mid + 1;             } else if (v[i][mid].first > x)               hi = mid - 1;             else               lo = mid + 1;           }           x += inc[i];         }         if (l == 1e18)           cout << -1 << endl;         else           cout << r - l << endl;       }     }   }   