malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> v[200010];   bool vis[200010];   int amid[200010];   int n, m;   int a[200010];   vector<int> vv;   vector<pair<int, int> > t;   void dfs(int node) {     vis[node] = 1;     t.push_back({a[node], node});     int sz = v[node].size();     for (int i = 0; i < sz; i++) {       int nx = v[node][i];       if (!vis[nx]) dfs(nx);     }   }   void cal() {     int d = 0;     bool yy = 1;     map<int, int> mm;     for (int i = 0; i < t.size(); i++) {       mm[t[i].first]++;     }     set<int> s;     for (int i = 0; i < t.size(); i++) {       int node = t[i].second, r = t[i].first;       if (!s.count(r)) d += mm[r];       s.insert(r);       amid[node] -= (d - mm[r]);     }   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> a[i];       vv.push_back(a[i]);     }     sort(vv.begin(), vv.end());     for (int i = 1; i <= n; i++) {       amid[i] = lower_bound(vv.begin(), vv.end(), a[i]) - vv.begin();     }     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     for (int i = 1; i <= n; i++) {       int sz = v[i].size();       int r = a[i];       for (int j = 0; j < sz; j++) {         int nx = v[i][j];         if (a[nx] < a[i]) amid[i]--;       }     }     for (int i = 1; i <= n; i++) {       cout << amid[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long MOD = 1000000007;   int d[201][201];   pair<pair<int, int>, int> E[20000];   vector<std::pair<int, int> > Intervals;   int n, m;   bool check(int idx, int x) {     int u = E[idx].first.first, v = E[idx].first.second, w = E[idx].second;     Intervals.clear();     for (int i = 0; i < n; ++i) {       int d1 = d[u][i], d2 = d[v][i];       if (d1 > x and d2 > x) return 0;       int a = 0, b = w;       a = min(w, x - d1) + 1;       b = max(0, w - (x - d2)) - 1;       if (d1 <= x and d2 <= x) {         if (a > b)           continue;         else           Intervals.push_back(std::make_pair(a, b));       } else if (d1 <= x) {         if (a <= w) Intervals.push_back(std::make_pair(a, w));       } else {         if (b >= 0) Intervals.push_back(std::make_pair(0, b));       }     }     if (Intervals.size() < 1) return 1;     sort(Intervals.begin(), Intervals.end());     if (Intervals[0].first > 0) return 1;     int maxY = Intervals[0].second;     for (int i = 1; i < Intervals.size(); ++i) {       if (Intervals[i].first > maxY) return 1;       maxY = max(maxY, Intervals[i].second);     }     return maxY < w;   }   int solve(int idx) {     int u = E[idx].first.first, v = E[idx].first.second;     int l = 0, r = 0, m;     for (int i = 0; i < n; ++i) {       r = max(r, min(d[u][i], d[v][i]));     }     r += E[idx].second + 10;     while (r - l > 1) {       m = (l + r) >> 1;       bool f = check(idx, m);       if (f)         r = m;       else         l = m;     }     if (check(idx, l))       return l;     else       return r;   }   int main() {     int u, v, w;     scanf( %d %d , &n, &m);     for (int i = 0; i < (n); ++i)       for (int j = 0; j < (n); ++j) d[i][j] = (i == j ? 0 : MOD);     for (int i = 0; i < (m); ++i) {       scanf( %d %d %d , &u, &v, &w);       u -= 1, v -= 1, w <<= 1;       d[u][v] = d[v][u] = w;       E[i] = std::make_pair(std::make_pair(u, v), w);     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j)         for (int k = 0; k < n; ++k) {           d[j][k] = min(d[j][k], d[j][i] + d[i][k]);         }     }     int ans = MOD;     for (int i = 0; i < (m); ++i) ans = min(ans, solve(i));     cout << ans / 2.0 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e3 + 10;   int n;   pair<string, int> a[N];   string ans[N];   int main() {     cin >> n;     for (int i = 0; i < n; ++i) {       char c;       cin >> c >> c >> c >> c;       cin >> a[i].first;       a[i].second = i;       if (a[i].first ==  9 ) ans[i] =  1989 ;       if (a[i].first ==  99 ) ans[i] =  1999 ;     }     sort(a, a + n);     for (int i = 0; i < n; ++i) {       if (a[i].first.length() == 1) {         if (a[i].first ==  9 ) continue;         ans[a[i].second] =  199 ;         ans[a[i].second] += a[i].first;       } else if (a[i].first.length() == 2) {         if (a[i].first ==  99 ) continue;         ans[a[i].second] =  20 ;         ans[a[i].second] += a[i].first;       } else if (a[i].first.length() == 3) {         if (a[i].first <  100  && a[i].first !=  099 ) {           ans[a[i].second] =  3 ;           ans[a[i].second] += a[i].first;         } else {           ans[a[i].second] =  2 ;           ans[a[i].second] += a[i].first;         }       } else if (a[i].first.length() == 4) {         if ( 0000  <= a[i].first && a[i].first <  3099 ) ans[a[i].second] =  1 ;         ans[a[i].second] += a[i].first;       } else if (a[i].first.length() == 5) {         if ( 00000  <= a[i].first && a[i].first <  13099 ) ans[a[i].second] =  1 ;         ans[a[i].second] += a[i].first;       } else if (a[i].first.length() == 6) {         if ( 000000  <= a[i].first && a[i].first <  113099 )           ans[a[i].second] =  1 ;         ans[a[i].second] += a[i].first;       } else if (a[i].first.length() == 7) {         if ( 0000000  <= a[i].first && a[i].first <  1113099 )           ans[a[i].second] =  1 ;         ans[a[i].second] += a[i].first;       } else if (a[i].first.length() == 8) {         if ( 00000000  <= a[i].first && a[i].first <  11113099 )           ans[a[i].second] =  1 ;         ans[a[i].second] += a[i].first;       } else if (a[i].first.length() == 9) {         if ( 000000000  <= a[i].first && a[i].first <  111113099 )           ans[a[i].second] =  1 ;         ans[a[i].second] += a[i].first;       }     }     for (int i = 0; i < n; ++i) cout << ans[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10, M = 1e6 + 10;   struct node {     int a, b, w;   } e[M];   int fa[N];   bool cmp(node a, node b) { return a.w < b.w; }   int find(int x) {     if (fa[x] != x) fa[x] = find(fa[x]);     return fa[x];   }   int du[N];   int main() {     int n, m;     cin >> n >> m;     int a1, b1, w1;     for (int i = 1; i <= m; ++i) {       scanf( %d%d%d , &e[i].a, &e[i].b, &e[i].w);       if (i == 1) {         a1 = e[i].a;         b1 = e[i].b;       }     }     for (int i = 1; i <= n; ++i) fa[i] = i;     sort(e + 2, e + 1 + m, cmp);     for (int i = 2; i <= m; ++i) {       int f1 = find(e[i].a);       int f2 = find(e[i].b);       if (f1 == f2) continue;       fa[f1] = f2;       if (find(a1) == find(b1)) {         printf( %d n , e[i].w);         return 0;       }     }     printf( 1000000000 n );   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, a[600000], L, R, r, t, l, f;   long long s;   bool ok(long long x) {     long long r = 0;     for (long long i = 0; i < n; i++)       if (a[i] > x) r += (a[i] - x);     if (r <= t) return 1;     return 0;   }   bool ok1(long long x) {     long long r = 0;     for (long long i = 0; i < n; i++)       if (a[i] < x) r += (x - a[i]);     if (r <= t) return 1;     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> t;     L = 2e9;     for (long long i = 0; i < n; i++) {       cin >> a[i];       s += a[i];       L = min(L, a[i]);       R = max(R, a[i]);     }     long long d1 = R, d2 = L;     l = L;     r = R;     while (r - l > 10) {       long long mid = (r + l) / 2;       if (ok(mid))         r = mid;       else         l = mid + 1;     }     for (long long i = l; i <= r; i++)       if (ok(i)) d1 = min(d1, i);     l = L;     r = R;     while (r - l > 10) {       long long mid = (r + l) / 2;       if (ok1(mid))         l = mid;       else         r = mid - 1;     }     for (long long i = l; i <= r; i++)       if (ok1(i)) d2 = max(d2, i);     if (s % n == 0)       f = 0;     else       f = 1;     cout << max(f, d1 - d2);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k, s;     cin >> n >> k >> s;     if (k > s || k * (n - 1) < s) {       cout <<  NO n ;     } else {       cout <<  YES n ;       long long h = 1;       while (k--) {         long long d = min(n - 1, s - k);         s -= d;         if (h - d <= 0)           h += d;         else           h -= d;         cout << h <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool q[2][1001];   short qf[3][1001], an[1001][1001][50][2];   inline short gt(int l, int r, int p) { return qf[p][r] - qf[p][l - 1]; }   int main() {     int n, p, k;     scanf( %d%d%d , &n, &p, &k);     for (int i = 0; i < (int)(2); ++i) {       int t;       scanf( %d , &t);       while (t--) {         int t;         scanf( %d , &t);         q[i][t] = true;       }     }     for (int i = 1; i < (int)(n + 1); ++i) {       qf[0][i] = qf[0][i - 1] + q[0][i];       qf[1][i] = qf[1][i - 1] + q[1][i];       qf[2][i] = qf[2][i - 1] + (q[0][i] || q[1][i]);     }     for (int i = 0; i < (int)(p + 1); ++i)       for (int j = 0; j < (int)(n + 1); ++j)         for (int w = 0; w < (int)(k); ++w)           for (int c = 0; c < (int)(2); ++c) an[i][j][w][c] = -2000;     for (int l = 0; l < (int)(p + 1); ++l)       for (int i = 0; i < (int)(n + 1); ++i) an[l][i][0][0] = an[l][i][0][1] = 0;     for (int l = 1; l < (int)(p + 1); ++l)       for (int i = 1; i < (int)(n + 1); ++i)         for (int j = 0; j < (int)(min(k, i + 1)); ++j)           for (int c = 0; c < (int)(2); ++c) {             short &a = an[l][i][j][c];             if (j)               a = gt(i, i, c) + an[l - (j == 1)][i - 1][j - 1][c];             else {               for (int z = 1; z < (int)(k); ++z)                 a = max(a, (short)(gt(i, i, c) + an[l][i - 1][z][c]));               a = max(a, an[l][i - 1][0][c]);             }             if (j > 1) a = max(a, an[l][i][j - 1][c]);             for (int z = 0; z < (int)(2); ++z)               a = max(a, (short)(gt(i, i, c) + an[l - 1][i - 1][0][z]));             a = max(a, (short)(gt(i - j + 1, i, 2) +                                an[l - 1][i - j][j ? k - j : 0][c ^ 1]));           }     short a = 0;     for (int i = 0; i < (int)(k); ++i)       for (int j = 0; j < (int)(2); ++j) a = max(a, an[p][n][i][j]);     printf( %u n , a);   }
#include <bits/stdc++.h>   using namespace std;   int n, m, s;   long long ans = 0;   int main() {     int i, j, k;     int a1, b1, a2, b2;     int x1, y1, x2, y2;     int p1, p2;     cin >> n >> m >> s;     for (i = 0; i <= n / 2; i++) {       for (j = 0; j <= m / 2; j++) {         for (k = 0; k <= n / 2; k++) {           a1 = i;           b1 = j;           a2 = k;           x1 = 1 + 2 * a1;           y1 = 1 + 2 * b1;           x2 = 1 + a2 * 2;           if (x2 > x1) {             if ((s - x1 * y1) % (x2 - x1) == 0 && (s - x1 * y1) > 0) {               y2 = (s - x1 * y1) / (x2 - x1);               if (y2 <= y1 && y2 > 0 && y2 % 2 == 1) {                 b2 = (y2 - 1) / 2;                 if (((n - 2 * a2) * (m - 2 * b1)) > 0)                   ans += ((n - 2 * a2) * (m - 2 * b1));               }             }             if (s % x2 == 0) {               y2 = s / x2;               if (y2 > y1 && y2 % 2 == 1) {                 b2 = (y2 - 1) / 2;                 if (((n - 2 * a2) * (m - 2 * b2)) > 0)                   ans += ((n - 2 * a2) * (m - 2 * b2));               }             }           } else if (x2 == x1) {             if (x1 * y1 == s) {               if (((n - 2 * a1) * (m - 2 * b1) * (b1 + 1)) > 0)                 ans += ((n - 2 * a1) * (m - 2 * b1) * (b1 + 1));             }             if (s % x1 == 0) {               y2 = s / x1;               if (y2 > y1 && y2 % 2 == 1) {                 b2 = (y2 - 1) / 2;                 if (((n - 2 * a1) * (m - 2 * b2)) > 0)                   ans += ((n - 2 * a1) * (m - 2 * b2));               }             }           } else {             if (s + x2 * y1 - x1 * y1 > 0 && (s + x2 * y1 - x1 * y1) % x2 == 0) {               y2 = (s + x2 * y1 - x1 * y1) / x2;               if (y2 > y1 && y2 % 2 == 1) {                 b2 = (y2 - 1) / 2;                 if (((n - 2 * a1) * (m - 2 * b2)) > 0)                   ans += ((n - 2 * a1) * (m - 2 * b2));               }             }             if (x1 * y1 == s) {               if (((n - 2 * a1) * (m - 2 * b1) * (b1 + 1)) > 0)                 ans += ((n - 2 * a1) * (m - 2 * b1) * (b1 + 1));             }           }         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fib[100005], mod = 1e9 + 7;   void pre() {     fib[0] = fib[1] = 1;     for (int i = 2; i < 100005; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % mod;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     pre();     long long m, n, x;     cin >> m >> n;     x = (fib[m] + fib[n] - 1) % mod;     cout << (2LL * x) % mod;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 1e2 + 7;   long long p[MAXN], dp[MAXN];   pair<long long, long long> fig[MAXN];   int32_t main() {     long long n;     cin >> n;     for (long long i = 0; i < n; ++i) cin >> fig[i].second >> fig[i].first;     sort(fig, fig + n);     long long t;     cin >> t;     for (long long i = 1; i <= t; ++i) cin >> p[i];     p[t + 1] = (1LL << 60);     long long pos = 1, ans = 0, sum = 0;     for (long long i = 0; i < n; ++i) {       while (fig[i].second) {         if (p[pos] - sum > fig[i].second) {           sum += fig[i].second;           ans += fig[i].second * pos * fig[i].first;           fig[i].second = 0;         } else {           ans += fig[i].first * (p[pos] - sum) * pos;           fig[i].second -= p[pos] - sum;           sum = p[pos];           pos++;         }       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   int btf(int n) {     static int num[10];     memset(num, 0, sizeof(num));     for (int i = 0; i < 4; i++) {       num[n % 10]++;       n /= 10;     }     for (int i = 0; i < 10; i++)       if (num[i] > 1) return 0;     return 1;   }   void solve(int n) {     for (int i = n + 1; 1; i++)       if (btf(i)) {         printf( %d n , i);         return;       }   }   int main() {     int n;     while (scanf( %d , &n) != EOF) solve(n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, m;   void deal() {     for (int i = 0; i <= a && i < m; i++) {       if ((m - (long long int)i * 1000000000 % m) % m > b) {         printf( 1 %.9d n , i);         return;       }     }     printf( 2 n );   }   int main() {     while (scanf( %d%d%d , &a, &b, &m) != EOF) {       deal();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   long long ans[2200], MOD = 1000003;   long long dp[2200][2200], inv[2200], fac[2200], ifac[2200];   void init_math(int N) {     inv[1] = 1LL;     for (int i = 2; i <= N; i++)       inv[i] = (MOD - ((MOD / i) * inv[MOD % i]) % MOD);     fac[0] = 1LL;     ifac[0] = 1LL;     for (int i = 1; i <= N; i++) {       fac[i] = (fac[i - 1] * (long long)(i)) % MOD;       ifac[i] = (ifac[i - 1] * inv[i]) % MOD;     }   }   int st[2200], stc, r, len, ms, t[2200], tc;   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     init_math(2000);     cin >> s;     len = s.size();     ans[1] = 1;     for (int i = 1; i <= 2000; i++)       ans[i + 1] = inv[i + 1] * fac[i * 2] % MOD * ifac[i] % MOD * ifac[i] % MOD;     tc = 0;     bool isn = 0, ist;     for (int i = 0; i < len; i++) {       ist = 0;       if (s[i] <=  9  && s[i] >=  0 )         isn = 1;       else {         if (isn) {           t[tc++] = 0;           isn = 0;         }         if (i == 0 || !(s[i - 1] <=  9  && s[i - 1] >=  0 )) {           if (s[i] ==  *  || s[i] ==  / ) {             cout << 0 << endl;             return 0;           }           t[tc++] = 1;         } else           ist = 1;       }     }     if (isn) t[tc++] = 0;     if (t[tc - 1] == 1 || ist) {       cout << 0 << endl;       return 0;     }     stc = 0;     for (int i = 0; i < tc; i++) {       if (t[i] == 0)         st[stc]++;       else         stc++;     }     if (stc == 0) {       cout << ans[tc] << endl;       return 0;     }     dp[stc + 1][0] = 1;     for (int i = stc; i >= 0; i--) {       r = st[i];       if (i) {         ms += r;         for (int j = 1; j <= ms; j++)           for (int k = max(r - j, 0); k <= ms - j; k++) {             dp[i][k + 1] += (dp[i + 1][k + j - r] * ans[j]) % MOD;             if (dp[i][k + 1] >= MOD) dp[i][k + 1] -= MOD;           }       } else {         for (int j = 0; j <= ms; j++) {           dp[i][j + r] += dp[i + 1][j];           if (dp[i][j + r] >= MOD) dp[i][j + r] -= MOD;         }       }     }     long long res = 0;     for (int i = 1; i <= tc; i++) {       res += (dp[0][i] * ans[i]) % MOD;       if (res >= MOD) res -= MOD;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int two(int x) { return 1 << x; }   inline long long TWO(int x) { return (long long)1 << x; }   template <class T>   void Min(T &x, T y) {     if (y < x) x = y;   }   template <class T>   void Max(T &x, T y) {     if (y > x) x = y;   }   template <class T>   T _abs(T x) {     return x > 0 ? x : -x;   }   template <class T>   T gcd(T a, T b) {     return !b ? a : gcd(b, a % b);   }   const int maxn = 200010;   const int mod = 1000000007;   int get_val() {     int ret(0);     char c;     while ((c = getchar()) ==     || c ==   n  || c ==   r )       ;     ret = c -  0 ;     while ((c = getchar()) !=     && c !=   n  && c !=   r )       ret = ret * 10 + c -  0 ;     return ret;   }   int n, m, k;   int a[maxn], b[maxn];   int num[maxn];   int main() {     cin >> n >> m >> k;     map<int, int> mpa, mpb, mp;     for (int i = 0; i < n; i++) a[i] = get_val(), mpa[a[i]]++, mp[a[i]]++;     for (int i = 0; i < m; i++) b[i] = get_val(), mpb[b[i]]++, mp[b[i]]--;     int tot = 0;     for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {       if (it->second) num[tot++] = it->second;     }     long long s1 = 0, s2 = 0;     for (int i = tot; i >= 0; i--) {       s1 += num[i];       if (s1 > 0) {         return puts( YES ), 0;       }     }     puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n1, n2, k, a;     cin >> n1 >> n2;     vector<int> arr1, arr2;     for (int l = 0; l < n1; l++) {       cin >> a;       arr1.push_back(a);     }     for (int l = 0; l < n2; l++) {       cin >> a;       arr2.push_back(a);     }     sort(arr1.begin(), arr1.end());     sort(arr2.begin(), arr2.end());     for (int k = 0; k < arr1.size(); k++) {       for (int l = 0; l < arr2.size(); l++) {         if (arr1[k] == arr2[l]) {           cout << arr1[k] <<   n ;           return 0;         }       }     }     if (arr1[0] < arr2[0]) {       k = 10 * arr1[0] + arr2[0];       cout << k <<   n ;     } else {       k = 10 * arr2[0] + arr1[0];       cout << k <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     for (int i = 0; i < s.length(); i++) {       if (s[i] !=  a  && s[i] !=  e  && s[i] !=  i  && s[i] !=  o  &&           s[i] !=  u  && s[i] !=  n ) {         if (i != s.length() - 1) {           if (s[i + 1] !=  a  && s[i + 1] !=  e  && s[i + 1] !=  i  &&               s[i + 1] !=  o  && s[i + 1] !=  u ) {             cout <<  NO  << endl;             return 0;           }         } else {           cout <<  NO  << endl;           return 0;         }       }     }     cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int main() {     scanf( %d %d , &n, &m);     if (m > n) {       printf( -1 );       return 0;     }     m -= 2;     if (n == 1) {       printf( a );       return 0;     }     if (n > 1 && m < 0) {       printf( -1 );       return 0;     }     for (int i = 1; i <= n - m; i++)       if (i % 2 == 1)         printf( a );       else         printf( b );     for (int i = 1; i <= m; i++) printf( %c , char(i + 98));     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1000000007;   const long long linf = 1000000000000000000LL;   const double eps = 0.000001;   const double pi = 3.14159265358979323846;   template <class T>   T abs(T k) {     return k >= 0 ? k : -k;   }   template <class T>   T sqr(T n) {     return n * n;   }   template <class T>   T gcd(T a, T b) {     return b ? gcd(b, a % b) : a;   }   template <class T>   T mod(T a, T b) {     return (a % b + b) % b;   }   template <class T>   T addmod(T a, T b, T c) {     return (T)((long long)(a + b) % c);   }   template <class T>   T mulmod(T a, T b, T c) {     return (T)((long long)a * b % c);   }   template <class T>   T powmod(T a, T b, T c) {     return (T)(b ? sqr((long long)powmod(a, b >> 1, c)) % c * (b & 1 ? a : 1) % c                  : 1);   }   template <class T>   void maxe(T &a, T b) {     a = max(a, b);   }   template <class T>   void mine(T &a, T b) {     a = min(a, b);   }   template <class T>   void mode(T &a, T b) {     a = mod(a, b);   }   template <class T>   void addmode(T &a, T b, T c) {     a = addmod(a, b, c);   }   template <class T>   void mulmode(T &a, T b, T c) {     a = mulmod(a, b, c);   }   template <class T>   void powmode(T &a, T b, T c) {     a = powmod(a, b, c);   }   void fileio_in_out() {     freopen( .in ,  r , stdin);     freopen( .out ,  w , stdout);   }   void fileio_txt() {     freopen( input.txt ,  r , stdin);     freopen( output.txt ,  w , stdout);   }   const int N = 111111;   int test;   int n, m, k;   long long ans;   long long d[N], h[N], t[N], s[N], st[N];   long long dp[111][N];   int q[N], head, tail;   long long f1(int i, int j, int k) { return dp[i][k] + st[k] - t[j] * k; }   long long f2(int i, int j, int k) {     return ((dp[i][j] + st[j]) - (dp[i][k] + st[k])) / (j - k);   }   long long getans() {     sort(t + 1, t + 1 + m);     for (int i = 1; i <= m; i++) {       st[i] = st[i - 1] + t[i];       dp[1][i] = t[i] * i - st[i];     }     for (int i = 2; i <= k; i++) {       head = tail = 0;       for (int j = 1; j <= m; j++) {         while (head < tail && f1(i - 1, j, q[head]) >= f1(i - 1, j, q[head + 1]))           head++;         while (head < tail &&                f2(i - 1, q[tail - 1], q[tail]) >= f2(i - 1, q[tail], j))           tail--;         dp[i][j] = t[j] * j - st[j] + f1(i - 1, j, q[head]);         q[++tail] = j;       }     }     return dp[k][m];   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 2; i <= n; i++) {       scanf( %I64d , &d[i]);       s[i] = s[i - 1] + d[i];     }     for (int i = 1; i <= m; i++) {       scanf( %I64d%I64d , &h[i], &t[i]);       t[i] -= s[h[i]];     }     ans = getans();     printf( %I64d n , ans);     return 0;   }