malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   template <class t>   inline void read(t &s) {     s = 0;     register int f = 1;     register char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) f = -1;       c = getchar();     }     while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();     s *= f;     return;   }   template <class t, class... A>   inline void read(t &x, A &...a) {     read(x);     read(a...);   }   template <class t>   inline void write(t x) {     if (x < 0) putchar( - ), x = -x;     int buf[21], top = 0;     while (x) buf[++top] = x % 10, x /= 10;     if (!top) buf[++top] = 0;     while (top) putchar(buf[top--] ^  0 );     return;   }   inline void setIn(std::string s) {     freopen(s.c_str(),  r , stdin);     return;   }   inline void setOut(std::string s) {     freopen(s.c_str(),  w , stdout);     return;   }   inline void setIO(std::string s =   ) {     setIn(s +  .in );     setOut(s +  .out );     return;   }   template <class t>   inline bool ckmin(t &x, t y) {     if (x > y) {       x = y;       return 1;     }     return 0;   }   template <class t>   inline bool ckmax(t &x, t y) {     if (x < y) {       x = y;       return 1;     }     return 0;   }   inline int lowbit(int x) { return x & (-x); }   long double f[105], g[105];   int to[105];   inline int id(int x, int y) {     if (x & 1) return (10 - x) * 10 + 11 - y;     return (10 - x) * 10 + y;   }   signed main(void) {     register int x;     for (int i = 1; i <= 10; ++i)       for (int j = 1; j <= 10; ++j) {         read(x);         if (x) to[id(i, j)] = id(i - x, j);       }     for (int i = 0; i <= 100; ++i) g[i] = 1e18;     f[100] = 0;     for (int i = 94; i <= 99; ++i) f[i] = 6;     for (int i = 93; i; --i) {       for (int j = 1; j <= 6; ++j) f[i] += std::min(f[i + j], g[i + j]) + 1;       f[i] /= 6.0;       if (to[i]) ckmin(g[i], f[to[i]]);     }     std::printf( %.99Lf n , std::min(f[1], g[1]));     return 0;   }
#include <bits/stdc++.h>      using namespace std;      typedef long long ll;      const int N = 100010;   const ll INF = 1e9 + 69;      int n, a[N];   string good;   bitset <N> mul;      void fuck (int ss, int ee) {     int st = ss, en = ee;     while (st <= ee and a[st] == 1) ++st;     while (en >= ss and a[en] == 1) --en;     ll prod = 1;     for (int i = ss; i <= ee; ++i) prod = min(INF, prod * a[i]);     if (prod > en - st + 6) {       for (int i = st + 1; i <= en; ++i) mul[i] = 1;       return;     }     vector <ll> vec;     vector <pair <int, int>> range;     for (int i = st; i <= en;) {       int j = i;        ll cur = 1, cnt = 0;       while (j <= en and a[j] != 1) {         if (j > i) mul[j] = 1;         cur = min(INF, cur * a[j++]);       }       vec.emplace_back(cur);       if (j > en) break;       int from = j;       while (j <= en and a[j] == 1) ++cnt, ++j;       range.emplace_back(from, j - 1);       vec.emplace_back(cnt); i = j;     }     if (vec.size() > 1) {       assert(vec.size() & 1);       int sz = (vec.size() - 1) / 2;       ll opt = 0; int opt_mask = -1;       for (int mask = 0; mask < 1 << sz; ++mask) {         ll cur = vec[0], tot = 0;         for (int i = 1, j = 0; i + 1 < vec.size(); i += 2, ++j) {           ll cnt = vec[i], val = vec[i + 1];           if (mask & 1 << j) tot += cur + cnt, cur = val;           else cur *= val;         }         tot += cur;          if (tot > opt) opt = tot, opt_mask = mask;       }       for (int i = 1, j = 0; i + 1 < vec.size(); i += 2, ++j) {         ll cnt = vec[i], val = vec[i + 1];         if (~opt_mask & 1 << j) {           auto [l, r] = range[j];           for (int p = l; p <= r + 1; ++p) mul[p] = 1;         }       }     }   }      int main() {     cin >> n;     for (int i = 1; i <= n; ++i) {       scanf( %d , a + i);     }     cin >> good;     sort(good.begin(), good.end());     if (good.size() == 1 or good ==  +- ) {       for (int i = 1; i <= n; ++i) {         if (i > 1) putchar(good[0]);         printf( %d , a[i]);       }       cout <<   n ;       return 0;     }     if (good ==  *- ) {       int firstZero = 1;       while (firstZero <= n and a[firstZero]) ++firstZero;       for (int i = 1; i <= n; ++i) {         if (i > 1) putchar(i == firstZero ?  -  :  * );         printf( %d , a[i]);       }       cout <<   n ;       return 0;     }     for (int i = 1; i <= n; ++i) {       if (a[i] == 0) continue;       int j = i;       while (j <= n and a[j]) ++j;       fuck(i, j - 1);       i = j - 1;     }     for (int i = 1; i <= n; ++i) {       if (i > 1) putchar(mul[i] ?  *  :  + );       printf( %d , a[i]);     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   int p[N], a[N], idx, pre[N];   void xxs() {     int kns = 0;     for (int i = 2; i <= N; i++) {       if (!a[i]) {         p[++idx] = i;         kns++;       }       for (int j = 1; j <= idx && i * p[j] <= N; j++) {         a[i * p[j]] = 1;         if (i % p[j] == 0) break;       }       pre[i] = kns;     }   }   int main() {     xxs();     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       int k = sqrt(n);       printf( %d n , pre[n] - pre[k] + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 20005;   const long long Inf = 1000000000000000000ll;   int n, m, k;   int s1, s2, f;   int a[Maxn], b[Maxn], lef[Maxn], rig[Maxn];   vector<pair<int, int> > neigh[Maxn];   long long dist1[Maxn], dist2[Maxn];   void Solve(bool wineq) {     fill(dist1, dist1 + n + 1, Inf);     fill(dist2, dist2 + n + 1, Inf);     priority_queue<pair<long long, int> > Q;     dist1[s1] = 0;     Q.push(pair<long long, int>(0, s1));     dist2[s2] = 0;     Q.push(pair<long long, int>(0, s2));     while (!Q.empty()) {       int v = Q.top().second;       long long d = -Q.top().first;       Q.pop();       if (min(dist1[v], dist2[v]) != d) continue;       if (dist1[v] < dist2[v] || wineq && dist1[v] == dist2[v])         for (int i = 0; i < neigh[v].size(); i++) {           int u = neigh[v][i].first;           long long cand = d + lef[neigh[v][i].second];           if (cand < min(dist1[u], dist2[u])) {             dist1[u] = cand;             Q.push(pair<long long, int>(-dist1[u], u));           } else             dist1[u] = min(dist1[u], cand);         }       else         for (int i = 0; i < neigh[v].size(); i++) {           int u = neigh[v][i].first;           long long cand = d + rig[neigh[v][i].second];           if (cand < min(dist1[u], dist2[u])) {             dist2[u] = cand;             Q.push(pair<long long, int>(-dist2[u], u));           } else             dist2[u] = min(dist2[u], cand);         }     }   }   int main() {     scanf( %d %d %d , &n, &m, &k);     scanf( %d %d %d , &s1, &s2, &f);     for (int i = 0; i < m; i++) {       scanf( %d %d %d , &a[i], &b[i], &lef[i]);       rig[i] = lef[i];       neigh[a[i]].push_back(pair<int, int>(b[i], i));     }     for (int i = m; i < m + k; i++) {       scanf( %d %d %d %d , &a[i], &b[i], &lef[i], &rig[i]);       neigh[a[i]].push_back(pair<int, int>(b[i], i));     }     if (s1 == s2) {       printf( DRAW n );       for (int i = m; i < m + k; i++)         printf( %d%c , lef[i], i + 1 < m + k ?     :   n );       return 0;     }     Solve(false);     if (dist1[f] < dist2[f]) {       printf( WIN n );       for (int i = m; i < m + k; i++)         printf( %d%c ,                dist1[a[i]] < dist2[a[i]] && dist1[b[i]] < dist2[b[i]] ? lef[i]                                                                       : rig[i],                i + 1 < m + k ?     :   n );       return 0;     }     Solve(true);     if (dist1[f] <= dist2[f]) {       printf( DRAW n );       for (int i = m; i < m + k; i++)         printf( %d%c ,                dist1[a[i]] <= dist2[a[i]] && dist1[b[i]] <= dist2[b[i]] ? lef[i]                                                                         : rig[i],                i + 1 < m + k ?     :   n );       return 0;     }     printf( LOSE n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mm = 100010;   double f[mm][110], ans;   int a[mm], b[mm], x, y, k, i, j, l, n, m;   int main() {     scanf( %d , &n);     for (i = 1; i <= n; ++i)       scanf( %d , &a[i]), f[i][b[i] = a[i]] = 1, ans += f[i][0];     scanf( %d , &m);     for (i = 1; i <= m; ++i) {       scanf( %d%d%d , &x, &y, &k);       ans -= f[x][0];       for (j = 1; j <= k; ++j) {         for (l = 1; l <= b[x]; ++l) {           f[x][l - 1] += f[x][l] * l / a[x];           f[x][l] *= 1.0 * (a[x] - l) / a[x];         }         a[x]--;       }       a[y] += k;       ans += f[x][0];       printf( %.10lf n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   map<pair<int, int>, bool> mp;   pair<int, int> ara[400005];   int main() {     int n, m, x;     scanf( %d %d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d %d , &ara[i].first, &ara[i].second);       ara[i].first %= n, ara[i].second %= n;       if (ara[i].first > ara[i].second) swap(ara[i].first, ara[i].second);       ara[i + m] = ara[i], mp[ara[i]] = 1;     }     bool f = 0;     for (int i = 1; i * i <= n && !f; i++)       if (!(n % i)) {         x = i;         bool f2 = 1;         for (int j = 1; j <= m && f2; j++) {           int a = (ara[j].first + x) % n;           int b = (ara[j].second + x) % n;           if (a > b) swap(a, b);           f2 = mp[{a, b}];         }         f = f2;         x = (n / i);         if (x == n || f) continue;         f2 = 1;         for (int j = 1; j <= m && f2; j++) {           int a = (ara[j].first + x) % n;           int b = (ara[j].second + x) % n;           if (a > b) swap(a, b);           f2 = mp[{a, b}];         }         f = f2;       }     if (f)       printf( Yes n );     else       printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int n;     cin >> n;     int a[n];     int ans = 0;     int i, j, k;     for (i = 0; i < n; i++) cin >> a[i];     for (i = 1; i < n - 1; i++) {       if (((a[i] > a[i + 1]) && (a[i] > a[i - 1])) ||           ((a[i] < a[i - 1]) && (a[i] < a[i + 1])))         ans++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const string c[5] = { S ,  M ,  L ,  XL ,  XXL };   int n[5], m, i, j, l, r, x;   char st[7];   string s;   int main() {     for (i = 0; i < 5; i++) scanf( %d , &n[i]);     scanf( %d , &m);     for (i = 0; i < m; i++) {       scanf( %s , st);       s = st;       for (j = 0; j < 5; j++)         if (c[j] == s) {           x = j;           break;         }       if (n[x] > 0) {         puts(c[x].c_str());         n[x]--;         continue;       }       l = x - 1;       r = x + 1;       while (true) {         if (r < 5 && n[r] > 0) {           puts(c[r].c_str());           n[r]--;           break;         } else if (l >= 0 && n[l] > 0) {           puts(c[l].c_str());           n[l]--;           break;         }         l--;         r++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, t[155][4], m, f[155][55][55][55], c[4];   char s[155];   int main() {     scanf( %d , &n);     scanf( %s , s + 1);     for (int i = 1; i <= n; ++i) s[i] -=  a ;     for (int i = n; i >= 1; --i) {       c[s[i]] = i;       for (int j = 0; j <= 2; ++j) t[i][j] = c[j];     }     m = n / 3 + 1;     f[1][0][0][0] = 1;     int ans = 0;     for (int i = 1; i <= n; ++i)       for (int j = 0; j <= m; ++j)         for (int k = 0; k <= m; ++k)           for (int l = 0; l <= m; ++l) {             int p = f[i][j][k][l];             if (j + k + l == n && abs(j - k) < 2 && abs(j - l) < 2 &&                 abs(k - l) < 2)               (ans += p) %= 51123987;             ((f[t[i][0]][j + 1][k][l] += p) %= 51123987);             ((f[t[i][1]][j][k + 1][l] += p) %= 51123987);             ((f[t[i][2]][j][k][l + 1] += p) %= 51123987);           }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename A>   istream& operator>>(istream& in, vector<T, A>& p) {     for (auto& i : p) in >> i;     return in;   }   template <typename T, typename A>   ostream& operator<<(ostream& out, std::vector<T, A> const& v) {     for (auto i : v) out << i <<    ;     return out;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, a, b;     cin >> n >> m;     vector<int> cnt(n);     int ans = n;     for (int i = 0; i < m; ++i) {       cin >> a >> b;       --a, --b;       if (a > b) swap(a, b);       if (cnt[a] == 0) ans--;       cnt[a]++;     }     int q, t;     cin >> q;     for (int i = 0; i < q; ++i) {       cin >> t;       if (t == 1) {         cin >> a >> b;         --a, --b;         if (a > b) swap(a, b);         if (cnt[a] == 0) ans--;         cnt[a]++;       } else if (t == 2) {         cin >> a >> b;         --a, --b;         if (a > b) swap(a, b);         if (cnt[a] == 1) ans++;         cnt[a]--;       } else         cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 998244353;   long long int memo[1005][2005][4];   int n, k;   void solve() {     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= i * 2; j++) {         memo[i][j][0] = (memo[i - 1][j][0] + memo[i - 1][j][1] +                          memo[i - 1][j][2] + memo[i - 1][j - 1][3]) %                         MOD;         memo[i][j][1] = (memo[i - 1][j - 1][0] + memo[i - 1][j][1] +                          memo[i - 1][j - 2][2] + memo[i - 1][j - 1][3]) %                         MOD;         memo[i][j][2] = (memo[i - 1][j - 1][0] + memo[i - 1][j - 2][1] +                          memo[i - 1][j][2] + memo[i - 1][j - 1][3]) %                         MOD;         memo[i][j][3] = (memo[i - 1][j - 1][0] + memo[i - 1][j][1] +                          memo[i - 1][j][2] + memo[i - 1][j][3]) %                         MOD;       }     }   }   int main() {     cin >> n >> k;     memo[1][1][0] = 1;     memo[1][2][1] = 1;     memo[1][2][2] = 1;     memo[1][1][3] = 1;     solve();     printf( %lld ,            (memo[n][k][0] + memo[n][k][1] + memo[n][k][2] + memo[n][k][3]) % MOD);   }
#include <bits/stdc++.h>   using namespace std;   inline void re(int &x) {     x = 0;     bool flag = false;     char c = getchar();     while (c <  0  || c >  9 ) {       flag = c ==  - ;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = (x << 1) + (x << 3) + (c ^  0 );       c = getchar();     }     if (flag) x = -x;     return;   }   long long l[100010];   int n;   char s[100010];   int main() {     long long W = 0, G = 0, mn = 5;     long long S = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %I64d , &l[i]);       l[i] *= 2;       S += l[i];     }     scanf( %s , s + 1);     for (int i = 1; i <= n; i++) {       if (s[i] ==  G ) G += l[i];       if (s[i] ==  W ) {         W += l[i];         mn = 3;       }       long long t = l[i];       long long e;       e = min(t / 2, W);       S += 2 * e;       t -= 2 * e;       W -= e;       e = min(t / 2, G);       S += 4 * e;       t -= 2 * e;       G -= e;       S += t * mn;     }     printf( %I64d n , S / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[1010], dp[1010][260], g[10], f[10][1010], h[1010];   int check(int x) {     memset(dp, -0x3f3f3f3f, sizeof(dp));     dp[0][0] = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < 256; j++) {         if (i > 0) dp[i][j] = dp[i - 1][j];         if (j & (1 << (a[i] - 1))) {           if (h[i] >= x)             dp[i][j] =                 max(dp[i][j], dp[f[a[i]][h[i] - x]][j ^ (1 << (a[i] - 1))] + x);           if (h[i] >= x + 1)             dp[i][j] =                 max(dp[i][j],                     dp[f[a[i]][h[i] - x - 1]][j ^ (1 << (a[i] - 1))] + x + 1);         }       }     return dp[n - 1][255];   }   int Sol() {     int l = 1, r = n, mid, ans = 0;     for (int i = 1; i <= 8; i++) {       r = min(r, g[i]);       if (g[i] > 0) ans++;     }     while (l <= r) {       mid = (l + r) >> 1;       int x = check(mid);       ans = max(ans, x);       if (x > 0)         l = mid + 1;       else         r = mid - 1;     }     return ans;   }   int main() {     memset(f, -1, sizeof(f));     memset(g, 0, sizeof(g));     memset(h, 0, sizeof(h));     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       f[a[i]][g[a[i]]++] = i;       h[i] = g[a[i]];     }     printf( %d n , Sol());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   ostream& operator<<(ostream& out, const vector<T>& v) {     out <<  [ ;     for (const T& x : v) {       out << x <<  ,  ;     }     return out <<  ] ;   }   template <typename S, typename T>   ostream& operator<<(ostream& out, const pair<S, T>& p) {     return out <<  {  << p.first <<  ,   << p.second <<  } ;   }   void solve() {     int N;     cin >> N;     string S;     cin >> S;     vector<int> A(N), min_after(N);     for (int n = N - 1; n >= 0; --n) {       A[n] = S[n] -  0 ;     }     vector<int> ans(N);     for (int k = 0; k <= 9; ++k) {       int last1 = -1;       for (int n = 0; n < N; ++n) {         if (A[n] < k) {           ans[n] = 1;           last1 = n;         } else if (A[n] > k) {           ans[n] = 2;         }       }       for (int n = 0; n < N; ++n) {         if (A[n] == k) {           if (n < last1) {             ans[n] = 2;           } else {             ans[n] = 1;           }         }       }       vector<int> test;       for (int d = 1; d <= 2; ++d) {         for (int n = 0; n < N; ++n) {           if (ans[n] == d) {             test.push_back(A[n]);           }         }       }       if (is_sorted(test.begin(), test.end())) {         for (int n = 0; n < N; ++n) {           cout << ans[n];         }         cout <<   n ;         return;       }     }     cout <<  - n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int T;     cin >> T;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = (int)1e5 + 5;   const long long mo = 998244353;   int a[mx], cnt[mx][105];   long long d[mx][105], sum[mx];   int main() {     int n, k, len;     cin >> n >> k >> len;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= k; j++)         cnt[i][j] = cnt[i - 1][j] + (a[i] == j || a[i] == -1);     }     sum[0] = 1;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= k; j++) {         if (a[i] == -1 || a[i] == j) {           d[i][j] = sum[i - 1];           if (i >= len && cnt[i][j] - cnt[i - len][j] == len)             d[i][j] = ((d[i][j] - (sum[i - len] - d[i - len][j] + 2 * mo) % mo) +                        2 * mo) %                       mo;           sum[i] += d[i][j];           sum[i] %= mo;         }       }     }     cout << sum[n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, x, n;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> t;     while (t--) {       vector<long long> v;       cin >> x;       for (long long i = 0; i < x; i++) {         cin >> n;         v.push_back(n);       }       vector<long long> tmp = v;       v[0] = 0;       long long now = 1;       while ((v[now - 1] + 1) <= v[now] && now < v.size()) {         v[now] = v[now - 1] + 1;         now++;       }       long long now2 = 1;       reverse(tmp.begin(), tmp.end());       tmp[0] = 0;       while ((tmp[now2 - 1] + 1) <= tmp[now2] && now2 < v.size()) {         tmp[now2] = tmp[now2 - 1] + 1;         now2++;       }       if (now > (x - now2)) {         cout <<  Yes               <<   n ;       } else {         cout <<  No               <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool sum(int num) {     int ssum = 0;     while (num > 0) {       ssum = ssum + num % 10;       num = num / 10;     }     if (ssum == 10) {       return true;     } else {       return false;     }   }   int main() {     int test, num = 19;     cin >> test;     while (test > 0) {       if (sum(num)) {         test--;       }       num += 9;     }     cout << num - 9 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int const nmax = 1000;   int const modulo = 1000000007;   int dp[1 + nmax][1 + nmax];   int sum[1 + nmax][1 + nmax];   int main() {     int n, m, cond;     cin >> n >> m >> cond;     if (m < n) {       cout << 0;       return 0;     }     dp[0][0] = 1;     sum[0][0] = 1;     for (int val = 1; val <= m; val++) {       for (int i = 0; i <= n; i++)         for (int j = 0; j <= i; j++) {           dp[i][j] = 0;           if (0 < i) dp[i][j] += sum[i - 1][j];           if (0 < j && val != cond) dp[i][j] += sum[i][j - 1];           if (modulo <= dp[i][j]) dp[i][j] -= modulo;           if (0 < i && 0 < j) dp[i][j] += sum[i - 1][j - 1];           if (modulo <= dp[i][j]) dp[i][j] -= modulo;         }       if (val == cond)         for (int i = 0; i <= n; i++)           for (int j = 0; j <= n; j++) sum[i][j] = 0;       for (int i = 0; i <= n; i++)         for (int j = 0; j <= n; j++) {           sum[i][j] += dp[i][j];           if (modulo <= sum[i][j]) sum[i][j] -= modulo;         }     }     int result = sum[n][n];     for (int i = 1; i <= n; i++) result = 1LL * result * i % modulo;     cout << result;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   int n, q;   set<pair<int, int> > st;   set<int> unread[N];   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> q;     int cnt = 0;     while (q--) {       int type, x;       cin >> type;       if (type == 1) {         cin >> x;         ++cnt;         st.insert({cnt, x});         unread[x].insert(cnt);       } else if (type == 2) {         cin >> x;         for (auto it : unread[x]) st.erase({it, x});         unread[x].clear();       } else {         cin >> x;         while (!st.empty() and st.begin()->first <= x) {           auto p = *(st.begin());           st.erase(st.begin());           unread[p.second].erase(p.first);         }       }       cout << st.size() <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, i, s = 0;     cin >> n;     long long a[n];     for (i = 0; i < n; i++) {       cin >> a[i];     }     s = s + a[0];     for (i = 1; i < n; i++) {       if (a[i] != 1) {         s = s + i * (a[i] - 1) + a[i];       } else {         s = s + 1;       }     }     cout << s << endl;   }   int main() {     long long t = 1;     while (t--) {       solve();     }   }