malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   const long long mod = 1e9 + 7;   long long qpow(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = res * a % mod;       a = a * a % mod;       b >>= 1;     }     return res;   }   int n;   int vis[N], prime[N], num, mu[N], inv[N];   void makeMobius(int siz) {     mu[1] = 1, num = 0;     for (int i = 2; i <= siz; i++) {       if (!vis[i]) prime[++num] = i, mu[i] = -1;       for (int j = 1; j <= num && i * prime[j] <= siz; j++) {         vis[i * prime[j]] = 1;         if (i % prime[j] == 0) {           mu[i * prime[j]] = 0;           break;         } else           mu[i * prime[j]] = mu[i] * mu[prime[j]];       }     }     inv[1] = 1;     for (int i = 2; i <= siz; i++) inv[i] = qpow(i, mod - 2);   }   long long calc(long long d) {     long long y = n / d;     return y * inv[n - y] % mod;   }   int main() {     scanf( %d , &n);     makeMobius(n);     long long ans = 1;     for (int d = 2; d <= n; d++) ans = (ans - calc(d) * mu[d] % mod + mod) % mod;     printf( %lld n , (ans + mod) % mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, k, b, e;     cin >> n >> k;     if (n == 1) {       cout <<  0  << endl;       return 0;     }     long long p = ((k - 1) * k) / 2 - 1;     if (n >= 2 && n <= (p + 2)) {       b = 2;       e = k - 2;       if (n == p + 2)         cout << k - 1 << endl;       else if (n >= 2 && n <= k)         cout <<  1  << endl;       else {         while (b <= e) {           long long mid = (e + b) / 2;           long long g = k - mid + 1;           long long begin = (k * (k + 1)) / 2 - (g * (g + 1)) / 2;           long long f = mid - 2;           begin = begin - f + 1;           g--;           long long end = (k * (k + 1)) / 2 - (g * (g + 1)) / 2;           long long f2 = mid - 1;           end = end - f2;           if (n >= begin && n <= end) {             cout << mid << endl;             break;           } else if (n > end)             b = mid + 1;           else             e = mid - 1;         }       }     } else       cout <<  -1  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct custom_hash {     static uint64_t splitmix64(uint64_t x) {       x += 0x9e3779b97f4a7c15;       x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;       x = (x ^ (x >> 27)) * 0x94d049bb133111eb;       return x ^ (x >> 31);     }     size_t operator()(uint64_t x) const {       static const uint64_t FIXED_RANDOM =           chrono::steady_clock::now().time_since_epoch().count();       return splitmix64(x + FIXED_RANDOM);     }   };   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long tc;     cin >> tc;     while (tc--) {       long long n, m;       cin >> n >> m;       string s;       cin >> s;       long long arr[m];       for (long long i = 0; i < m; i++) cin >> arr[i];       long long MM = 97;       long long dp[n + 1][26];       unordered_map<long long, long long, custom_hash> mp;       for (auto ch : s) mp[ch % MM]++;       for (long long i = 0; i < 26; i++) {         dp[n][i] = mp[i];       }       for (long long i = n - 1; i >= 1; i--) {         long long target = s[i] % MM;         for (long long j = 0; j < 26; j++) {           if (target == j) {             dp[i][j] = dp[i + 1][j] - 1;           } else {             dp[i][j] = dp[i + 1][j];           }         }       }       long long res[26];       for (long long i = 0; i < 26; i++) {         res[i] = dp[n][i];       }       for (long long i = 0; i < m; i++) {         long long l = arr[i];         for (long long j = 0; j < 26; j++) res[j] += dp[l][j];       }       for (long long i = 0; i < 26; i++) cout << res[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 100;   const int mod = 1e9 + 7;   mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());   int q, n = 1000000;   long long seg[maxn * 4], lazy[maxn * 4];   void build(int id = 1, int l = 1, int r = n) {     if (l == r) {       seg[id] = l;       return;     }     int mid = (l + r) / 2;     build(id * 2, l, mid);     build(id * 2 + 1, mid + 1, r);     seg[id] = max(seg[id * 2], seg[id * 2 + 1]);   }   void upd(int id, long long val) {     seg[id] += val;     lazy[id] += val;   }   void shift(int id) {     if (!lazy[id]) return;     upd(id * 2, lazy[id]);     upd(id * 2 + 1, lazy[id]);     lazy[id] = 0;   }   void modify(int first, int second, long long val, int id = 1, int l = 1,               int r = n) {     if (l > second || r < first) return;     if (l >= first && r <= second) {       upd(id, val);       return;     }     shift(id);     int mid = (l + r) / 2;     modify(first, second, val, id * 2, l, mid);     modify(first, second, val, id * 2 + 1, mid + 1, r);     seg[id] = max(seg[id * 2], seg[id * 2 + 1]);   }   long long query(int first, int second, int id = 1, int l = 1, int r = n) {     if (l > second || r < first) return 0;     if (l >= first && r <= second) return seg[id];     shift(id);     int mid = (l + r) / 2;     return max(query(first, second, id * 2, l, mid),                query(first, second, id * 2 + 1, mid + 1, r));   }   long long f[maxn];   void add(int i, long long a) {     for (; i <= n; i += i & -i) f[i] += a;   }   long long get(int i) {     long long ret = 0;     for (; i > 0; i -= i & -i) ret += f[i];     return ret;   }   long long get(int l, int r) { return get(r) - get(l - 1); }   pair<int, int> que[300005];   int main() {     ios_base::sync_with_stdio(false), cin.tie(0);     build();     cin >> q;     for (int i = 1; i <= q; i++) {       char type;       cin >> type;       if (type ==  + ) {         int pos, d;         cin >> pos >> d;         modify(1, pos, d);         add(pos, d);         que[i] = {pos, d};       } else if (type ==  - ) {         int id, pos, d;         cin >> id;         tie(pos, d) = que[id];         modify(1, pos, -d);         add(pos, -d);       } else {         int pos;         cin >> pos;         long long sum = query(1, pos);         sum -= get(pos + 1, n);         cout << sum - pos <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using INT = long long;   string a[111];   int main() {     int n;     string s;     cin >> s;     cin >> n;     int flag = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] == s) flag |= 3;       if (a[i][1] == s[0]) flag |= 1;       if (a[i][0] == s[1]) flag |= 2;     }     if (flag == 3) return puts( YES ), 0;     return puts( NO ), 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, a, b, res = 0, ans = 0;   int main() {     cin >> n >> m;     a = n % m;     b = n / m;     ans = (m - a) * b * (b - 1) / 2 + a * b * (b + 1) / 2;     res = (n - m + 1) * (n - m) / 2;     cout << ans <<     << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double gimmearea(long double x1, long double y1, long double r1,                         long double x2, long double y2, long double r2,                         long double c) {     long double t1, t2, p1, p2;     t1 = acos((r1 * r1 + c - r2 * r2) / (2 * r1 * sqrt(c)));     t2 = acos((r2 * r2 + c - r1 * r1) / (2 * r2 * sqrt(c)));     p1 = sin(2 * t1);     p2 = sin(2 * t2);     return (r1 * r1 * t1 + r2 * r2 * t2) - 0.5 * (r1 * r1 * p1 + r2 * r2 * p2);   }   int main() {     long double x1, y1, r1, x2, y2, r2, c, ans;     cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;     c = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);     if (c >= (r1 + r2) * (r1 + r2)) {       ans = 0;     } else if (sqrt(c) <= fabs(r1 - r2)) {       if (r2 < r1) r1 = r2;       ans = 3.14159265358979323846264338 * r1 * r1;     } else {       ans = gimmearea(x1, y1, r1, x2, y2, r2, c);     }     cout << fixed << setprecision(15);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, k, l, m, n, ok = 0;     char s1[110], s2[110], ans[110];     scanf( %s , s1);     scanf( %s , s2);     l = strlen(s1);     for (i = 0; i < l; i++) {       if (s1[i] > s2[i]) {         ans[i] = s2[i];       } else if (s1[i] < s2[i]) {         ok = 1;         break;       } else         ans[i] = s1[i];     }     ans[l] =   0 ;     if (ok)       printf( -1 n );     else       puts(ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mm = 1000000007;   const long long inf = 1e18;   long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   vector<int> e[6005];   int a[6005], q[6005], n, ans;   void dfs(int u, int top, int fa) {     int pos, tmp;     if (!top || a[u] > q[top]) {       pos = ++top;       tmp = q[top];       q[top] = a[u];       ans = max(ans, top);     } else {       pos = lower_bound(q + 1, q + 1 + top, a[u]) - q;       tmp = q[pos];       q[pos] = a[u];     }     for (int i = 0; i < (int)e[u].size(); i++) {       int v = e[u][i];       if (v == fa) continue;       dfs(v, top, u);     }     q[pos] = tmp;   }   int main() {     n = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i <= n - 1; i++) {       int x = read(), y = read();       e[x].push_back(y);       e[y].push_back(x);     }     for (int i = 1; i <= n; i++) dfs(i, 0, 0);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int N = 1e5 + 7;   const int inf = INT_MAX / 2;   const long long INF = LLONG_MAX / 3;   const int MOD = 998244353;   const long double eps = 1e-6;   const pair<int, int> dir[] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};   signed main() {     cout << fixed << setprecision(9);     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int q;     cin >> q;     while (q--) {       long long n;       cin >> n;       cout << (n % 4 == 0 ?  YES n  :  NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int v, fr;     node(){};     node(int a, int b) { v = a, fr = b; }   } C[115 + 115];   long long f[115 + 115][115], K;   int ar[115 + 115], n, m, P[115][115];   inline bool cmp(node a, node b) { return a.v < b.v; }   inline void pluss(long long &p, long long p1) {     p += p1;     if (p > 2000000000000000011LL) p = 2000000000000000011LL;   }   int main() {     int i, j, e, t, k;     cin >> n >> m >> K;     for (i = 1; i <= n; ++i)       for (j = 1; j <= m; ++j) scanf( %d , &P[i][j]);     for (i = 1; i < n + m; ++i) C[i] = node((~0U >> 1), i);     for (i = 1; i <= n; ++i)       for (j = 1; j <= m; ++j) C[i + j - 1].v = min(C[i + j - 1].v, P[i][j]);     sort(C + 1, C + n + m, cmp);     for (e = ((n + m) >> 1) + 1, t = 1; t < n + m; ++t) {       ar[C[t].fr] = 1;       memset(f, 0, sizeof(f));       for (f[0][0] = i = 1; i < n + m; ++i) {         if (ar[i]) {           k = (ar[i] == 1 ? -1 : 1);           for (j = 0; j <= e; ++j)             if (j + k > -1) pluss(f[i][j], f[i - 1][j + k]);         } else           for (j = 0; j <= e; ++j) {             if (j > 0) pluss(f[i][j], f[i - 1][j - 1]);             pluss(f[i][j], f[i - 1][j + 1]);           }       }       if (f[n + m - 1][0] < K) {         ar[C[t].fr] = 2;         K -= f[n + m - 1][0];       }     }     for (i = 1; i <= n; ++i) {       for (j = 1; j <= m; ++j) {         if (ar[i + j - 1] == 1)           printf( ( );         else           printf( ) );       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   long double eps = 1e-8;   int main() {     int n, k;     std::cin >> n >> k;     std::vector<long double> probabilities(n);     for (long double& probability : probabilities) {       std::cin >> probability;     }     long long max_size = (1 << n);     std::vector<std::vector<long double>> dp(n,                                              std::vector<long double>(max_size));     std::vector<long double> result(n, 0.0);     for (int i = 0; i < n; ++i) {       dp[i][0] = probabilities[i];       result[i] += dp[i][0];     }     for (int mask = 1; mask < max_size; ++mask) {       long double mask_probability = 0;       if (__builtin_popcount(mask) >= k) {         continue;       }       for (int i = 0; i < n; ++i) {         if (mask & (1 << i)) {           mask_probability += probabilities[i];         }       }       for (int k = 0; k < n; ++k) {         if (mask & (1 << k)) {           continue;         }         long double sum = 0;         for (int j = 0; j < n; ++j) {           if (!(mask & (1 << j))) {             continue;           }           sum += dp[j][mask - (1 << j)];         }         if (mask_probability > 1.0 - eps) {           sum = 0;         } else {           sum *= probabilities[k] / (1 - mask_probability);         }         dp[k][mask] = sum;         result[k] += dp[k][mask];       }     }     std::cout.precision(20);     std::cout << std::fixed;     for (int i = 0; i < n; ++i) {       std::cout << result[i] <<    ;     }     std::cout << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int kkk = 0, x = 1;     char c = getchar();     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) c = getchar(), x = -1;     while (c >=  0  && c <=  9 )       kkk = (kkk << 3) + (kkk << 1) + (c -  0 ), c = getchar();     return kkk * x;   }   int n, can[200001], maxn, ans, sum[200001], a[200001], minn[400001];   int c1[200001], c2[200001];   void check(int v) {     memset(c1, 0, sizeof(c1));     memset(c2, 0, sizeof(c2));     int L = 1;     c2[0] = n;     for (int i = 1; i <= n; ++i) {       if (a[i] == maxn && c1[a[i]] == v) {         while (a[L] != maxn) {           --c2[c1[a[L]]];           --c1[a[L]];           ++c2[c1[a[L]]];           ++L;         }         ++L;       } else {         --c2[c1[a[i]]];         ++c1[a[i]];         ++c2[c1[a[i]]];       }       if (c1[maxn] == v && c2[c1[maxn]] >= 2) ans = max(ans, i - L + 1);     }   }   int main() {     n = read();     for (int i = 1; i <= n; ++i) {       a[i] = read();       ++can[a[i]];       if (can[a[i]] > can[maxn]) maxn = a[i];     }     for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + (a[i] == maxn);     int lim = sqrt(n);     for (int col = 1; col <= n; ++col) {       if (col == maxn) continue;       if (can[col] >= lim) {         for (int i = 1; i <= 2 * n; ++i) minn[i] = n + 1;         minn[n] = 0;         int sumv = 0;         for (int i = 1; i <= n; ++i) {           sumv += (a[i] == col);           int v = sumv - sum[i] + n;           ans = max(ans, i - minn[v]);           minn[v] = min(minn[v], i);         }       }     }     for (int i = 1; i <= lim; ++i) check(i);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using str = string;   using pi = pair<int, int>;   using pl = pair<ll, ll>;   using pd = pair<ld, ld>;   using vi = vector<int>;   using vb = vector<bool>;   using vl = vector<ll>;   using vd = vector<ld>;   using vs = vector<str>;   using vpi = vector<pi>;   using vpl = vector<pl>;   using vpd = vector<pd>;   str Tout[2] = { NO ,  YES };   str tout[2] = { No ,  Yes };   int main() {     ll n, k;     cin >> n >> k;     ll a[n + 17];     for (int i = (0); i < (n); i++) cin >> a[i];     if (k == 2) {       cout << max(a[0], a[n - 1]);       return 0;     }     sort(a, a + n);     if (k == 1)       cout << a[0];     else       cout << a[n - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x[100005], y[100005], q[100005], N = ((long long)1 << 40) - 1;   struct node {     long long r, l, v, sum;   } tree[400005];   void buildtree(int i, int l, int r) {     tree[i].l = l;     tree[i].r = r;     tree[i].v = 0;     if (tree[i].r == tree[i].l) {       tree[i].sum = 0;       return;     }     buildtree(i * 2, l, (r + l) / 2);     buildtree(i * 2 + 1, (l + r) / 2 + 1, r);     tree[i].sum = tree[i * 2].sum & tree[i * 2 + 1].sum;   }   void downadd(long long v) {     tree[v * 2].v |= tree[v].v;     tree[v * 2 + 1].v |= tree[v].v;     tree[v * 2].sum |= tree[v].v;     tree[v * 2 + 1].sum |= tree[v].v;     tree[v].v = 0;   }   void update(long long i, long long l, long long r, long long k) {     if (tree[i].l >= l && tree[i].r <= r) {       tree[i].sum |= k;       tree[i].v |= k;       return;     }     downadd(i);     long long m = (tree[i].l + tree[i].r) / 2;     if (l <= m) update(i * 2, l, r, k);     if (r > m) update(i * 2 + 1, l, r, k);     tree[i].sum = tree[i * 2].sum & tree[i * 2 + 1].sum;   }   long long query(long long i, long long l, long long r) {     if (tree[i].l >= l && tree[i].r <= r) {       return tree[i].sum;     }     downadd(i);     long long ans = N, m = (tree[i].r + tree[i].l) / 2;     if (l <= m) ans &= query(i * 2, l, r);     if (r > m) ans &= query(i * 2 + 1, l, r);     return ans;   }   int main() {     int n, m;     cin >> n >> m;     buildtree(1, 1, n);     for (int i = 1; i <= m; i++) {       cin >> x[i] >> y[i] >> q[i];       update(1, x[i], y[i], q[i]);     }     for (int i = 1; i <= m; i++) {       long long v = query(1, x[i], y[i]);       if (v != q[i]) {         cout <<  NO  << endl;         return 0;       }     }     cout <<  YES  << endl;     for (int i = 1; i <= n; i++) {       cout << query(1, i, i) <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   char op[600001];   long long id[600001], ans[600001], s[600001];   long long n, m, t;   bool cmp(long long x, long long y) {     long long pa, pb;     if (op[x] ==  L ) {       pa = ((s[x] - t) % m + m) % m;     } else       pa = (s[x] + t) % m;     if (op[y] ==  L ) {       pb = ((s[y] - t) % m + m) % m;     } else       pb = (s[y] + t) % m;     if (pa != pb) return pa < pb;     return op[x] ==  L ;   }   long long id2[300001];   bool cmp2(long long x, long long y) {     if (s[x] != s[y]) {       return s[x] < s[y];     }     return op[x] ==  L ;   }   signed main() {     cin >> n >> m >> t;     for (long long i = 0; i < n; i++) {       cin >> s[i] >> op[i];       s[i]--;       id[i] = id2[i] = i;     }     sort(id, id + n, cmp);     sort(id2, id2 + n, cmp2);     long long pos = 0;     if (op[0] ==  L ) {       long long x = s[0] - t;       for (long long i = 0; i < n; i++)         if (op[i] ==  R ) {           long long y = s[i] + t;           if (s[i] > s[0]) y -= m;           if (y < x) continue;           pos = (pos + (y - x) / m + 1) % n;         }       pos = (n - pos) % n;     } else {       long long x = s[0] + t;       for (long long i = 0; i < n; i++) {         if (op[i] ==  L ) {           long long y = s[i] - t;           if (s[i] < s[0]) y += m;           if (y > x) continue;           pos = (pos + (x - y) / m + 1) % n;         }       }     }     long long p = 0;     for (long long i = 0; i < n; i++) {       if (id2[i] == 0) p = i;     }     p = (p + pos) % n;     long long q = 0;     for (long long i = 0; i < n; i++) {       if (id[i] == 0) q = i;     }     for (long long i = 0; i < n; i++) {       long long j = id[(q + i) % n];       long long x = (q + i) % n, y;       if (op[j] ==  L )         y = ((s[j] - t) % m + m) % m;       else         y = (s[j] + t) % m;       long long z = id2[(p + i) % n];       ans[z] = y + 1;     }     for (long long i = 0; i < n; i++) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e6 + 5;   long long add[N << 2], sum[N << 2], color[N << 1];   int n, m;   void down(int rt, int len) {     if (add[rt]) {       add[(rt << 1)] += add[rt];       add[(rt << 1 | 1)] += add[rt];       sum[(rt << 1)] += add[rt] * (len - (len >> 1));       sum[(rt << 1 | 1)] += add[rt] * (len >> 1);       add[rt] = 0;       color[(rt << 1)] = color[(rt << 1 | 1)] = color[rt];       color[rt] = 0;     }   }   void build(int rt, int l, int r) {     if (l == r) {       color[rt] = l;       return;     }     int mid = (l + r) >> 1;     build((rt << 1), l, mid);     build((rt << 1 | 1), mid + 1, r);     color[rt] = (color[(rt << 1)] == color[(rt << 1 | 1)]) ? color[(rt << 1)] : 0;     sum[rt] = sum[(rt << 1)] + sum[(rt << 1 | 1)];   }   void modify(int rt, int l, int r, int L, int R, int x) {     if (L <= l && r <= R && color[rt]) {       add[rt] += abs(color[rt] - x);       sum[rt] += (r - l + 1) * abs(color[rt] - x);       color[rt] = x;       return;     }     down(rt, r - l + 1);     int mid = (l + r) >> 1;     if (L <= mid) modify((rt << 1), l, mid, L, R, x);     if (mid < R) modify((rt << 1 | 1), mid + 1, r, L, R, x);     color[rt] = (color[(rt << 1)] == color[(rt << 1 | 1)]) ? color[(rt << 1)] : 0;     sum[rt] = sum[(rt << 1)] + sum[(rt << 1 | 1)];   }   long long query(int rt, int l, int r, int L, int R) {     if (L <= l && r <= R) {       return sum[rt];     }     down(rt, r - l + 1);     long long t = 0ll;     int mid = (l + r) >> 1;     if (L <= mid) t += query((rt << 1), l, mid, L, R);     if (mid < R) t += query((rt << 1 | 1), mid + 1, r, L, R);     return t;   }   int main() {     scanf( %d%d , &n, &m);     build(1, 1, n);     while (m--) {       int op, l, r, x;       scanf( %d , &op);       if (op == 1) {         scanf( %d%d%d , &l, &r, &x);         modify(1, 1, n, l, r, x);       } else {         scanf( %d%d , &l, &r);         printf( %I64d n , query(1, 1, n, l, r));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 260, mo = 777777777;   int f[30][N][N], c[N * 2][N * 2], n, k, ans;   int power(int x, int y) {     int s = 1;     for (; y; y /= 2, x = 1ll * x * x % mo)       if (y & 1) s = 1ll * s * x % mo;     return s;   }   int main() {     scanf( %d%d , &n, &k);     k = n - k;     for (int i = 0; i <= n; i++) c[i][0] = 1;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mo;     f[0][0][0] = 1;     for (int i = n; i >= 1; i--)       for (int v = min(22, n / i); v >= 0; v--)         for (int v1 = k; v1 >= 0; v1--)           for (int v2 = n - k; v2 >= 0; v2--) {             int tmp = 1ll * f[v][v1][v2] * c[v1 + v2 + i][i] % mo;             if (v1 + i <= k)               (((f[v + 1][v1 + i][v2]) += (tmp)) >= mo                    ? f[v + 1][v1 + i][v2] -= mo                    : 233);             ;             if (v2 + i <= n - k)               (((f[v + 1][v1][v2 + i]) += (mo - tmp)) >= mo                    ? f[v + 1][v1][v2 + i] -= mo                    : 233);             ;           }     for (int v = 0; v <= min(n, 23); v++)       for (int v2 = 0; v2 <= n - k; v2++)         (((ans) += (1ll * f[v][k][v2] * c[n][k + v2] % mo *                     power(n - v, n - k - v2) % mo)) >= mo              ? ans -= mo              : 233);     ;     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, count;     long long l, u;     scanf( %d , &n);     long long int a[n];     long long int h[n];     for (i = 0; i < n; ++i) {       cin >> a[i] >> h[i];     }     l = a[0];     h[n - 1] = 0;     h[0] = 0;     u = a[n - 1];     if (n > 1) {       count = 2;       for (i = 1; i < n - 1; ++i) {         if (a[i] - h[i] > l) {           count++;           l = a[i];         } else {           if (a[i] + h[i] < a[i + 1]) {             l = a[i] + h[i];             count++;           } else             l = a[i];         }       }     } else       count = 1;     printf( %d n , count);     return 0;   }