func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   void dbs(string str, T t) {     cerr << str <<   :   << t <<   n ;   }   template <class T, class... S>   void dbs(string str, T t, S... s) {     int idx = str.find( , );     cerr << str.substr(0, idx) <<   :   << t <<  , ;     dbs(str.substr(idx + 1), s...);   }   template <class S, class T>   ostream& operator<<(ostream& os, const pair<S, T>& p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <class T>   ostream& operator<<(ostream& os, const vector<T>& p) {     os <<  [  ;     for (auto& it : p) os << it <<    ;     return os <<  ] ;   }   template <class T>   ostream& operator<<(ostream& os, const set<T>& p) {     os <<  [  ;     for (auto& it : p) os << it <<    ;     return os <<  ] ;   }   template <class S, class T>   ostream& operator<<(ostream& os, const map<S, T>& p) {     os <<  [  ;     for (auto& it : p) os << it <<    ;     return os <<  ] ;   }   template <class T>   void prc(T a, T b) {     cerr <<  [ ;     for (T i = a; i != b; ++i) {       if (i != a) cerr <<  ,  ;       cerr << *i;     }     cerr <<  ] n ;   }   const int N = 100010;   const int LOG = 18;   string s;   int n;   int p[LOG][N];   pair<pair<int, int>, int> vec[N];   pair<int, int> suff[N];   int save[N];   int lcp(int a, int b) {     int temp = a;     for (int i = LOG - 1; i >= 0 and max(a, b) < n; i--) {       if (p[i][a] == p[i][b]) {         a += (1 << i), b += (1 << i);       }     }     return a - temp;   }   int main() {     cin >> s;     n = int(s.size());     for (int i = (int)(0); i <= (int)(n - 1); i++) {       p[0][i] = s[i];     }     for (int i = (int)(1); i <= (int)(LOG - 1); i++) {       for (int j = (int)(0); j <= (int)(n - 1); j++) {         if (j + (1 << (i - 1)) >= n) {           vec[j] = make_pair(make_pair(p[i - 1][j], -1), j);         } else {           vec[j] =               make_pair(make_pair(p[i - 1][j], p[i - 1][j + (1 << (i - 1))]), j);         }       }       sort(vec, vec + n);       for (int j = (int)(1); j <= (int)(n - 1); j++) {         if (vec[j].first == vec[j - 1].first) {           p[i][vec[j].second] = p[i][vec[j - 1].second];         } else {           p[i][vec[j].second] = j;         }       }     }     for (int i = (int)(0); i <= (int)(n - 1); i++) {       suff[i] = make_pair(p[LOG - 1][i], i);     }     sort(suff, suff + n);     for (int i = (int)(0); i <= (int)(n - 2); i++) {       save[i] = lcp(suff[i].second, suff[i + 1].second);     }     long long answer1 = 0;     stack<pair<long long, long long>> s1;     s1.push(make_pair(save[0], 1));     long long currSum = save[0];     for (int i = (int)(1); i <= (int)(n - 1); i++) {       answer1 += currSum;       long long x = save[i], cnt = 1;       if (i == n - 1) break;       while (!s1.empty() and s1.top().first > x) {         currSum -= s1.top().first * s1.top().second;         cnt += s1.top().second;         s1.pop();       }       s1.push(make_pair(save[i], cnt));       currSum += x * cnt;     }     cout << answer1 + (n * 1LL * (n + 1)) / 2 <<   n ;     return 0;   }   