func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   bool Max(T1& a, T2 b) {     return a < b ? a = b, 1 : 0;   }   template <typename T1, typename T2>   bool Min(T1& a, T2 b) {     return a > b ? a = b, 1 : 0;   }   const int N = 200002, inf = 1e9 + 1;   int s[N], g[N], ans[N];   bool vi[N];   vector<int> cap[N * 10];   void solve() {     int n, m;     cin >> n;     int mncap = N * 10;     for (int i = 0; i < (n); ++i) {       cin >> s[i] >> g[i];       g[i] += s[i];       ans[i] = g[i];     }     int mn = inf;     for (int i = 0; i < (n); ++i) {       mn++;       Min(mn, g[i]);       Min(ans[i], mn);     }     mn = inf;     for (int i = n - 1; i >= (0); --i) {       mn++;       Min(mn, g[i]);       Min(ans[i], mn);     }     long long ret = 0;     for (int i = 0; i < (n); ++i) {       if (ans[i] < s[i]) {         cout << -1 <<   n ;         return;       }       ret += ans[i] - s[i];     }     cout << ret <<   n ;     for (int i = 0; i < (n); ++i) cout << ans[i] <<    ;     cout <<   n ;   }   void init() {}   int main(void) {     ios::sync_with_stdio(false);     cin.tie(0);     cout.setf(ios::fixed);     cout.precision(20);     init();     int TC = 1;     for (int TI = 1; TI <= (TC); ++TI) {       solve();     }     return 0;   }   