malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool cmp(long long a, long long b) { return (a > b); }   long long ceil(const long long &a, const long long &b) {     if (a % b == 0) return a / b;     return a / b + 1;   }   long long mod = 1000000007;   const long long N = 100005;   using namespace std;   long long a[1100][5];   long long n, m;   int main() {     cin >> n >> m;     string s;     for (long long i = 0; i < n; i++) {       cin >> s;       for (long long j = 0; j < m; j++) {         a[j][s[j] -  A ]++;       }     }     long long ans = 0;     for (long long i = 0; i < m; i++) {       long long w, mx = 0;       cin >> w;       for (long long j = 0; j < 5; j++) {         mx = max(mx, a[i][j]);       }       ans += mx * w;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int l[5010], r[5010];   vector<int> vc;   long long f[2][10100];   int cost[10100];   int doit(int x, int y) {     if (vc[x] <= l[y]) return l[y] - vc[x];     if (vc[x] >= r[y]) return vc[x] - r[y];     return 0;   }   int main() {     int start = 0;     int n;     scanf( %d %d , &n, &start);     vc.push_back(start);     for (int i = 1; i <= n; ++i) {       scanf( %d %d , &l[i], &r[i]);       vc.push_back(l[i]);       vc.push_back(r[i]);     }     sort(vc.begin(), vc.end());     vc.erase(unique(vc.begin(), vc.end()), vc.end());     int now = 0, nxt = 1;     int cnt = vc.size();     for (int i = 0; i < cnt; ++i) {       cost[i] = doit(i, 1);     }     for (int i = 0; i < cnt; ++i) {       f[now][i] = abs(vc[i] - start) + cost[i];     }     for (int i = 1; i < n; ++i) {       memset(cost, 0, sizeof cost);       for (int j = 0; j < cnt; ++j) {         cost[j] = doit(j, i + 1);       }       int mn = f[now][cnt - 1], mx = cnt - 1;       for (int j = cnt - 1; j >= 0; --j) {         if (j < cnt - 1 && f[now][j] - (vc[cnt - 1] - vc[j]) < mn) {           mn = f[now][j] - (vc[cnt - 1] - vc[j]);           mx = j;         }         f[nxt][j] = f[now][mx] + vc[mx] - vc[j] + cost[j];       }       mn = f[now][0], mx = 0;       for (int j = 0; j < cnt; ++j) {         if (j && f[now][j] - (vc[j] - vc[0]) < mn) {           mn = f[now][j] - (vc[j] - vc[0]);           mx = j;         }         f[nxt][j] = min(f[nxt][j], f[now][mx] + vc[j] - vc[mx] + cost[j]);       }       swap(now, nxt);     }     long long ans = 1e18;     for (int i = 0; i < cnt; ++i) ans = min(ans, f[now][i]);     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   string itos(int x) {     stringstream ss;     ss << x;     return ss.str();   }   int n, m, res, bestlone;   map<string, vector<int> > m1;   string str;   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     for (int i = 0, x; i < n; i++) {       cin >> str >> x;       string t = str;       if (not m1.count(str)) m1[str] = vector<int>();       m1[str].push_back(x);     }     for (auto &x : m1) sort(x.second.begin(), x.second.end(), greater<int>());     for (auto x : m1) {       string str = x.first;       string t = str;       reverse(t.begin(), t.end());       vector<int> &v = x.second;       if (str > t)         continue;       else if (str == t) {         for (int i = 0; i < v.size(); i += 2) {           if (i + 1 < v.size()) {             int x = v[i], y = v[i + 1];             if (x < 0)               break;             else if (y < 0) {               if (x + y > 0) {                 bestlone = max(bestlone, -y);                 res += x + y;               } else                 bestlone = max(bestlone, x);             } else               res += x + y;           } else {             int x = v[i];             if (x < 0) break;             bestlone = max(bestlone, x);           }         }       } else {         vector<int> &v2 = m1[t];         for (int i = 0; i < v.size() && i < v2.size(); i++) {           if (v[i] + v2[i] < 0)             break;           else             res += v[i] + v2[i];         }       }     }     res += bestlone;     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c, d;   int main() {     cin >> a >> b >> c >> d;     if (c - d < -1 || c - d > 1 || a < max(c, d) || b < max(c, d)) {       cout << -1;       return 0;     }     if (c - d == -1) {       for (int i = 0; i < d; i++) {         if (i == d - 1)           for (int j = b; j > d; j--) cout << 7;         cout << 74;         if (!i)           for (int j = a; j > d; j--) cout << 4;       }     }     if (c - d == 1) {       for (int i = a; i > c; i--) cout << 4;       for (int i = 0; i < c; i++) cout << 47;       for (int i = b; i > c; i--) cout << 7;     }     if (c == d) {       if (a == c && b == d) {         cout << -1;         return 0;       }       if (a > c) {         for (int i = a; i > c + 1; i--) cout << 4;         for (int i = 0; i < c; i++) {           cout << 47;         }         for (int i = b; i > d; i--) cout << 7;         cout << 4;       } else {         cout << 7;         for (int i = 0; i < c; i++) cout << 47;         for (int i = b; i > d + 1; i--) cout << 7;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int test;     cin >> test;     while (test--) {       int a, b, x, y;       cin >> a >> b;       if (a < b) swap(a, b);       bool ok = 1;       x = 2 * a - b;       if (x % 3 != 0) ok = 0;       y = x / 3;       if ((a + b) % 3 != 0) ok = 0;       x = (a + b) / 3 - y;       if (x < 0 || y < 0) ok = 0;       cout << (ok ?  YES n  :  NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     cin >> a >> b;     int dif, same;     if (a > b) {       dif = b;       same = (a - b) / 2;     } else {       dif = a;       same = (b - a) / 2;     }     cout << dif <<     << same;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline string toString(T a) {     ostringstream os(  );     os << a;     return os.str();   }   template <typename T>   inline long long toLong(T a) {     long long res;     istringstream os(a);     os >> res;     return res;   }   template <typename T>   inline T S(T a) {     return a * a;   }   template <typename T>   inline T gcd(T a, T b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   template <typename T>   inline unsigned long long bigmod(T a, T b, T m) {     if (b == 0)       return 1;     else if (b % 2 == 0)       return S(bigmod(a, b / 2, m)) % m;     else       return (a % m * bigmod(a, b - 1, m)) % m;   }   vector<string> v;   vector<int> vv;   int main() {     int i, j, k;     string str;     int n;     cin >> n;     for (i = 0; i < n; i++) {       cin >> str;       v.push_back(str);       vv.push_back(str.length());     }     cin >> str;     int len = str.length();     int st = 0;     k = 0;     int res = 0;     i = 0;     j = 0;     for (k = 0; k < len; k++) {       if (st == 0) {         if (str[k] ==  < ) st = 1;       } else if (st == 1) {         if (str[k] ==  3 ) st = 2;       } else if (st == 2) {         if (str[k] == v[i][j]) {           j++;         }         if (j == vv[i]) {           i++;           j = 0;           st = 0;         }       }       if (i == n && st == 2) {         res = 1;         break;       }     }     if (res)       puts( yes );     else       puts( no );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mm = 2;   long long n, nn = 0, a1[mm + 1], m0[mm + 1][mm + 1], m1[mm + 1][mm + 1],                tmp[mm + 1][mm + 1], mz[mm + 1][mm + 1], az[mm + 1], dv;   queue<long long> q;   void mul(long long x[mm + 1][mm + 1], long long y[mm + 1][mm + 1],            long long z[mm + 1][mm + 1]) {     long long i, j, r;     for (i = 1; i <= mm; i++) {       for (j = 1; j <= mm; j++) {         tmp[i][j] = 0;         for (r = 1; r <= mm; r++) {           tmp[i][j] = (tmp[i][j] + x[i][r] * y[r][j]) % dv;         }       }     }     for (i = 1; i <= mm; i++) {       for (j = 1; j <= mm; j++) {         z[i][j] = tmp[i][j];       }     }   }   void mpw(long long x) {     if (!x) {       mul(m0, m0, mz);       return;     }     mpw(x / 2);     mul(mz, mz, mz);     if (x % 2) {       mul(mz, m1, mz);     }   }   int main() {     long long i, j, lb, rb, ln, k, z;     for (i = 1; i <= mm; i++) {       m0[i][i] = 1;     }     scanf( %lld%lld%lld%lld , &dv, &lb, &rb, &n);     ln = rb - lb + 1;     if (ln / n <= 1000000) {       for (i = (ln - 1) / (n - 1); i >= ln / n; i--) {         if (rb / i - (lb - 1) / i >= n) {           z = i;           break;         }       }     } else {       for (i = 1; 1; i++) {         for (; nn && q.front() > rb / i; q.pop(), nn--)           ;         q.push((lb - 1) / i + 1);         nn++;         if (nn >= n) {           z = rb / i;           break;         }       }     }     a1[1] = 1;     m1[1][1] = 1;     m1[1][2] = 1;     m1[2][1] = 1;     mpw(z - 1);     for (i = 1; i <= mm; i++) {       for (j = 1; j <= mm; j++) {         az[i] = (az[i] + a1[j] * mz[i][j]) % dv;       }     }     printf( %lld n , az[1]);   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     char ch = getchar();     register long long x = 0;     int f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   const int maxn = 1e6 + 10;   int n, k, ring[maxn >> 1], e[maxn], cnt, r[maxn >> 1], cu, amt[maxn >> 1],       sum[maxn >> 1], odd, minans, maxans;   bool f[maxn], vis[maxn];   inline int dfs(int start, int cur, int l) {     vis[cur] = true;     if (cur == start) return l;     return dfs(start, e[cur], l + 1);   }   int main() {     n = read(), k = read();     for (int i = 1; i <= n; i++) e[i] = read();     for (int i = 1; i <= n; i++)       if (!vis[i]) ring[++cnt] = dfs(i, e[i], 1);     sort(ring + 1, ring + cnt + 1);     for (int i = 1; i <= cnt; i++) {       if (ring[i] == r[cu])         amt[cu]++;       else {         r[++cu] = ring[i];         amt[cu] = 1;       }     }     f[0] = true;     for (int i = 1; i <= cu; i++) {       memset(sum, 0, sizeof(sum));       if (r[i] & 1) odd += amt[i];       for (int j = r[i]; j <= min(k, n - k); j++) {         if (!f[j] && f[j - r[i]] && sum[j - r[i]] < amt[i]) {           f[j] = true;           sum[j] = sum[j - r[i]] + 1;         }       }     }     minans = f[min(k, n - k)] ? k : k + 1;     cnt = (n - odd) >> 1;     if (k <= cnt)       maxans = k << 1;     else       maxans = min(k + cnt, n);     printf( %d %d , minans, maxans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     string s;     cin >> s;     int i = 0, j = 0;     int freq[2] = {0, 0};     int ans = 0;     bool over = 0;     while (j < n) {       while (min(freq[0], freq[1]) <= k && j < n) {         freq[s[j] -  a ]++;         if (min(freq[0], freq[1]) > k) {           over = true;           break;         }         j++;       }       ans = max(ans, j - i);       if (over) {         while (min(freq[0], freq[1]) > k) {           freq[s[i] -  a ]--;           i++;         }         over = 0;         j++;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   const int L = 1e7 + 7;   map<long long, long long> counter;   int lps[L];   void pre() {     lps[1] = 1;     for (int i = 2; i < 10000001; ++i) {       if (lps[i]) continue;       for (int j = i; j <= 10000000; j += i) {         lps[j] = i;       }     }     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, ans = 0;     cin >> n;     int tmp = sqrt(n);     if (n % 2 == 0) {       cout << n / 2;       return 0;     }     for (long long i = 3; i <= tmp + 1; i += 2) {       if (n % i == 0) {         cout << (n - i) / 2 + 1;         return 0;       }     }     cout <<  1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int mark[1000006];   bitset<1000006> prime;   void isprime() {     prime.set();     for (int i = 2; i < 1000006; i++) {       if (prime[i]) {         for (int j = i + i; j < 1000006; j += i) prime[j] = false;       }     }   }   int main(void) {     int n, m = 0;     scanf( %d , &n);     if (n == 4) {       printf( YES n );       return 0 * printf( 1 n3 n2 n4 n );     }     isprime();     if (!prime[n]) {       return 0 * puts( NO );     }     mark[1] = 1;     for (int i = 2; i <= n; i++) {       mark[i] = (long long)(n - n / i) * mark[n % i] % n;     }     mark[n] = n;     puts( YES );     printf( 1 n );     for (int i = 2; i < n; i++) {       printf( %d n , (int)((long long)i * mark[i - 1] % n));     }     if (n != 1) printf( %d n , n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool umin(T& a, T b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool umax(T& a, T b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   int F[100009], arr[100009], ans[100009], imp[100009], pos[100009];   void upd(int x, int val) {     for (; x; x -= x & (-x)) F[x] += val;   }   int tap(int x) {     int res = 0;     for (; x < 100009; x += x & (-x)) res += F[x];     return res;   }   set<int> s;   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , arr + i), pos[arr[i]] = i;     int all = 0;     for (int i = 1; i <= n; i++) {       int res = tap(arr[i]);       if (!res)         imp[i] = 1;       else if (res == 1) {         int val = *s.rbegin();         ans[pos[val]]++;       }       s.insert(arr[i]);       upd(arr[i], +1);       all += imp[i];     }     int mx = -1, who;     for (int i = 1; i <= n; i++) {       int val = all - imp[i] + ans[i];       if (mx < val)         mx = val, who = arr[i];       else if (mx == val)         umin(who, arr[i]);     }     printf( %d n , who);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     string s, str;     int i, k, l, h, n;     cin >> n;     vector<string> v(n + 1);     for (i = 1; i <= n; i++) cin >> v[i];     cin >> s;     if (s.size() < 5) {       cout <<  no ;       return 0;     }     k = 0, h = 0;     while (true) {       if (!h)         if (s[k] ==  < ) h = 1;       if (h)         if (s[k] ==  3 ) break;       k++;       if (k == s.size()) {         cout <<  no ;         return 0;       }     }     for (i = 1; i <= n; i++) {       str = v[i];       int h = 0;       while (true) {         if (s[k] == str[h]) h++;         if (h == str.size()) break;         k++;         if (k == s.size()) {           cout <<  no ;           return 0;         }       }       h = 0;       while (true) {         if (!h)           if (s[k] ==  < ) h = 1;         if (h)           if (s[k] ==  3 ) break;         k++;         if (k == s.size()) {           cout <<  no ;           return 0;         }       }     }     cout <<  yes ;     return 0;   }
#include <bits/stdc++.h>   bool x[1000000] = {0};   int a, b, c;   int y[10001];   int main() {     for (a = 2; a < 1001; a++) {       if (x[a] == 0) {         for (b = a * a; b < 1000000; b = b + a) x[b] = 1;       }     }     int qqq[11200];     int p, q, k, z, r, s = 1, t = 13;     while (s != 11185) {       k = t;       p = 0;       while (k >= 10) {         y[p] = k % 10;         k = k / 10;         p++;       }       y[p] = k;       z = 0;       for (r = 0; r <= p; r++) z = z * 10 + y[r];       if (x[t] == 0 && x[z] == 0 && t != z) {         qqq[s] = t;         s++;       }       t++;     }     while (scanf( %d , &c) == 1) {       printf( %d n , qqq[c]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[200015];   char s[200015];   vector<pair<int, int> > ans;   int main() {     scanf( %d , &n);     for (int i = (1); i <= (n); i++) scanf( %d , &a[i]);     scanf( %s , s + 1);     sort(a + 1, a + n + 1);     int lp = 1, rp = n;     for (int i = (1); i <= (n); i++)       if (i == 1 || s[i] != s[i - 1]) rp--;     lp = rp++;     bool flag = 0;     for (int l = 1, r; l <= n; l = r + 1) {       r = l;       while (r < n && s[r + 1] == s[l]) r++;       int len = r - l + 1;       ans.push_back(make_pair(a[rp++], s[l] ==  R ));       for (int _ = (1); _ <= (len - 1); _++) {         ans.push_back(make_pair(a[lp--], (s[1] ==  L ) ^ flag));         flag ^= 1;       }     }     for (auto x : ans) {       printf( %d %c n , x.first, x.second == 0 ?  L  :  R );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6 + 7;   int h[MAXN], fen[MAXN], pre[MAXN], suf[MAXN], cnt[MAXN];   struct query {     int id, a, b, pre, suf;   } q[MAXN];   bool operator<(query x, query y) { return x.a < y.a; }   bool compare(query x, query y) { return x.id < y.id; }   void upd(int idx, int val) {     if (idx <= 0) return;     for (; idx < MAXN; idx += idx & -idx) fen[idx] = max(fen[idx], val);   }   int get(int idx) {     if (idx <= 0) return 0;     int ret = 0;     for (; idx; idx -= idx & -idx) ret = max(ret, fen[idx]);     return ret;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; ++i) cin >> h[i];     for (int i = 0; i < m; ++i) {       cin >> q[i].a >> q[i].b;       q[i].a--;       q[i].id = i;     }     vector<int> com;     for (int i = 0; i < n; ++i) com.push_back(h[i]);     for (int i = 0; i < m; ++i) com.push_back(q[i].b);     sort(com.begin(), com.end());     com.resize(unique(com.begin(), com.end()) - com.begin());     for (int i = 0; i < n; ++i)       h[i] = lower_bound(com.begin(), com.end(), h[i]) - com.begin() + 1;     for (int i = 0; i < m; ++i)       q[i].b = lower_bound(com.begin(), com.end(), q[i].b) - com.begin() + 1;     int LIS = 0;     for (int i = 0; i < n; ++i) {       pre[i] = get(h[i] - 1) + 1;       LIS = max(LIS, pre[i]);       upd(h[i], pre[i]);     }     memset(fen, 0, sizeof fen);     for (int i = n - 1; i >= 0; --i) {       suf[i] = get(MAXN - h[i] - 1) + 1;       upd(MAXN - h[i], suf[i]);       if (pre[i] + suf[i] - 1 == LIS) cnt[pre[i]]++;     }     vector<int> spec;     for (int i = 0; i < n; ++i)       if (pre[i] + suf[i] - 1 == LIS && cnt[pre[i]] == 1) spec.push_back(i);     sort(q, q + m);     memset(fen, 0, sizeof fen);     int ptr = 0;     for (int i = 0; i < n; ++i) {       while (ptr < m && q[ptr].a == i) {         q[ptr].pre = get(q[ptr].b - 1) + 1;         ptr++;       }       upd(h[i], get(h[i] - 1) + 1);     }     memset(fen, 0, sizeof fen);     ptr = m - 1;     for (int i = n - 1; i >= 0; --i) {       while (ptr >= 0 && q[ptr].a == i) {         q[ptr].suf = get(MAXN - q[ptr].b - 1) + 1;         ptr--;       }       upd(MAXN - h[i], get(MAXN - h[i] - 1) + 1);     }     sort(q, q + m, compare);     for (int i = 0; i < m; ++i) {       int ans = LIS - 1;       if (!binary_search(spec.begin(), spec.end(), q[i].a)) ans = LIS;       cout << max(ans, q[i].pre + q[i].suf - 1) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<string> str_list;     string str;     int max_length = 0, left_more = 0;     while (getline(cin, str)) {       max_length = max((int)str.size(), max_length);       str_list.push_back(str);     }     cout << string(max_length + 2,  * ) << endl;     for (auto s : str_list) {       int n = max_length - (int)s.size();       int left = 0, right = 0;       if (n % 2 == 0 || s.find_first_not_of(   ) == string::npos) {         left = right = n / 2;         right = n - left;       } else {         left = (n + left_more) / 2;         right = n - left;         left_more = 1 - left_more;       }       cout <<  *  << string(left,    ) << s << string(right,    ) <<  *  << endl;     }     cout << string(max_length + 2,  * ) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long int n;     cin >> n;     map<int, int> mp;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       mp[a] = i + 1;     }     for (int i = 1; i <= n; i++) {       cout << mp[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string arr;     cin >> arr;     long long a = 1;     long long counter = 1;     for (int i = 0; i < arr.size() - 1; i++) {       if ((arr[i] -  0 ) + arr[i + 1] -  0  == 9)         a++;       else if (a % 2 == 1)         counter *= (a / 2 + 1), a = 1;       else         a = 1;     }     if (a % 2 == 1) counter *= (a / 2 + 1);     cout << counter << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[1001][1001 + 2][2][2];   int n, k, hv = 1002;   char s[1001 + 5], l[1001 + 5], r[1001 + 5];   long long go(int pos, int pv, int ch, int f) {     if (pos == -1) return (long long)f;     long long &ret = dp[pos][pv][ch][f];     if (ch && ret != -1) return ret;     ret = 0LL;     int mx = s[pos] -  0 ;     if (ch) mx = 9;     for (int i = 0; i <= mx; i++) {       bool nw = ((i == 4) || (i == 7));       ret = (ret + go(pos - 1, (nw) ? pos : pv, ch || (i < mx),                       f || (nw && (pv != hv) && (pv - pos) <= k))) %             1000000007LL;     }     return ret;   }   long long solve(char *str) {     strcpy(s, str);     n = strlen(s);     reverse(s, s + n);     return go(n - 1, hv, 0, 0);   }   void DECbyONE() {     int ln = strlen(l);     if (ln == 1) {       l[0]--;       return;     }     for (int i = ln - 1; i >= 0; i--) {       if (l[i] !=  0 ) {         l[i]--;         break;       } else         l[i] =  9 ;     }     strcpy(s, l);     memset(l, 0, sizeof(l));     int i = 0, kk = 0;     while (s[i] ==  0 ) i++;     for (i; i < ln; i++) l[kk++] = s[i];     l[i] =   0 ;   }   int main() {     int t, N, cs = 1, i, j;     ios_base::sync_with_stdio(0), cin.tie(0);     memset(dp, -1, sizeof(dp));     cin >> t >> k;     while (t--) {       cin >> l >> r;       DECbyONE();       long long R = solve(r);       long long L = solve(l);       cout << (R - L + 1000000007LL) % 1000000007LL << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int n, j;     cin >> n;     int a[1000020];     for (int i = 0; i < 1000020; i++) {       a[i] = 0;     }     for (int i = 0; i < n; i++) {       cin >> j;       a[j]++;     }     j = 0;     for (int i = 0; i < 1000020; i++) {       if (a[i] != 0) {         a[i + 1] += a[i] / 2;         a[i] = a[i] % 2;         if (a[i] != 0) {           j++;         }       }     }     cout << j;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[111111], i, k, l, r, s[111111], ans;   int main() {     cin >> n;     if (n % 2 == 0) {       cout << -1;       return 0;     }     for (i = 0; i < n; i++) {       cout << i <<    ;     }     cout << endl;     for (i = 0; i < n; i++) cout << i <<    ;     cout << endl;     for (i = 0; i < n; i++) cout << (i + i) % n <<    ;   }