malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1000000007;   int x1[48] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30,                 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31,                 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int x2[48] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30,                 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31,                 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int x3[48] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30,                 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31,                 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int x4[48] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30,                 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31,                 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int x5[11] = {31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31};   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     vector<int> pos;     for (int i = 0; i < 48 - n + 1; i++) {       if (x1[i] == a[0]) pos.push_back(i);     }     for (int i = 0; i < pos.size(); i++) {       int p = pos[i];       bool ans = true;       for (int j = 0; j < n; j++) {         if (x1[p] != a[j]) {           ans = false;           break;         }         p++;       }       if (ans) {         cout <<  YES               <<   n ;         return 0;       }     }     pos.clear();     for (int i = 0; i < 48 - n + 1; i++) {       if (x2[i] == a[0]) pos.push_back(i);     }     for (int i = 0; i < pos.size(); i++) {       int p = pos[i];       bool ans = true;       for (int j = 0; j < n; j++) {         if (x2[p] != a[j]) {           ans = false;           break;         }         p++;       }       if (ans) {         cout <<  YES               <<   n ;         return 0;       }     }     pos.clear();     for (int i = 0; i < 48 - n + 1; i++) {       if (x3[i] == a[0]) pos.push_back(i);     }     for (int i = 0; i < pos.size(); i++) {       int p = pos[i];       bool ans = true;       for (int j = 0; j < n; j++) {         if (x3[p] != a[j]) {           ans = false;           break;         }         p++;       }       if (ans) {         cout <<  YES               <<   n ;         return 0;       }     }     pos.clear();     for (int i = 0; i < 48 - n + 1; i++) {       if (x4[i] == a[0]) pos.push_back(i);     }     for (int i = 0; i < pos.size(); i++) {       int p = pos[i];       bool ans = true;       for (int j = 0; j < n; j++) {         if (x4[p] != a[j]) {           ans = false;           break;         }         p++;       }       if (ans) {         cout <<  YES               <<   n ;         return 0;       }     }     pos.clear();     cout <<  NO           <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 100005;   char en =   n ;   long long inf = 1e16;   long long mod = 1e9 + 7;   long long power(long long x, long long n, long long mod) {     long long res = 1;     x %= mod;     while (n) {       if (n & 1) res = (res * x) % mod;       x = (x * x) % mod;       n >>= 1;     }     return res;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, k;     cin >> n >> k;     long long curr = n * (n + 1) / 2;     if (curr > k) {       cout << -1 << en;       return 0;     }     long long arr[n + 5];     for (long long i = 1; i <= n; i++) arr[i] = i;     long long rem = k - curr;     long long start = 1;     while (rem) {       long long end1 = n - start + 1;       long long max1 = end1 - start;       if (max1 <= 0) break;       if (rem >= max1) {         swap(arr[start], arr[end1]);         rem -= max1;       } else {         swap(arr[start], arr[start + rem]);         break;       }       start++;     }     long long ans = 0;     for (long long i = 1; i <= n; i++) {       ans += max(i, arr[i]);     }     cout << ans << en;     for (long long i = 1; i <= n; i++) cout << i <<    ;     cout << en;     for (long long i = 1; i <= n; i++) cout << arr[i] <<    ;     cout << en;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 9000020;   const int K = 60;   const int MOd = 1e9 + 7;   int a, b;   int nex[maxn][2];   int ar[3020], st[maxn];   int dn[maxn], N;   int ans;   int add(int a, int b) {     a += b;     a %= MOd;     if (a < 0) return a + MOd;     return a;   }   void dfs(int p, int n, int x) {     st[n] = p;     if (nex[p][0]) dfs(nex[p][0], n + 1, (x + x) & 15);     if (nex[p][1]) dfs(nex[p][1], n + 1, (x + x + 1) & 15);   }   int main() {     scanf( %d , &a);     for (int i = 1; i <= a; i++) scanf( %d , &ar[i]);     dn[0] = 1;     for (int i = 1; i <= a; i++) {       int n = 0;       for (int j = i, p = 0, x = 0; j >= 1; j--) {         st[n++] = p;         x = (x + x + ar[j]) & 15;         if (!nex[p][ar[j]]) {           nex[p][ar[j]] = ++N;           p = nex[p][ar[j]];           if (n > 0) dn[p] = add(dn[p], dn[st[n - 1]]);           if (n > 1) dn[p] = add(dn[p], dn[st[n - 2]]);           if (n > 2) dn[p] = add(dn[p], dn[st[n - 3]]);           if (n > 3 && x != 12 && x != 10 && x != 7 && x != 15)             dn[p] = add(dn[p], dn[st[n - 4]]);           ans = add(ans, dn[p]);         } else           p = nex[p][ar[j]];       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MaxN = 500 + 5;   int n, m, mod, h[MaxN], tmp, tot[3];   long long f[MaxN << 1][MaxN];   char ch;   void read(int &num) {     ch = 0;     while (ch <  0  || ch >  9 ) ch = getchar();     num = ch -  0 ;   }   int main() {     scanf( %d%d%d , &n, &m, &mod);     for (int i = 1; i <= m; i++)       for (int j = 1; j <= n; j++) {         read(tmp);         if (tmp) h[j]++;       }     for (int i = 1; i <= n; i++) tot[h[i]]++;     f[tot[1]][tot[0]] = 1;     for (int j = tot[0]; j >= 0; j--)       for (int i = tot[1] + tot[0]; i >= 0; i--) {         if (i >= 2)           f[i - 2][j] = (f[i - 2][j] + f[i][j] * (i * (i - 1)) / 2) % mod;         if (j >= 1) f[i][j - 1] = (f[i][j - 1] + f[i][j] * i * j) % mod;         if (j >= 2)           f[i + 2][j - 2] = (f[i + 2][j - 2] + f[i][j] * (j * (j - 1)) / 2) % mod;       }     cout << f[0][0];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   const int N = 1e6 + 10;   struct UFS {     stack<pair<int *, int>> stk;     int fa[N], rnk[N];     inline void init(int n) {       for (int i = 0; i <= n; ++i) fa[i] = i, rnk[i] = 0;     }     inline int Find(int x) {       while (x ^ fa[x]) x = fa[x];       return x;     }     inline void Merge(int x, int y) {       x = Find(x), y = Find(y);       if (x == y) return;       if (rnk[x] <= rnk[y]) {         stk.push({fa + x, fa[x]});         fa[x] = y;         if (rnk[x] == rnk[y]) {           stk.push({rnk + y, rnk[y]});           rnk[y]++;         }       } else {         stk.push({fa + y, fa[y]});         fa[y] = x;       }     }     inline void Undo() {       *stk.top().first = stk.top().second;       stk.pop();     }   } ufs;   struct Edge {     int u, v;   };   int main() {     int n, m, k;     cin >> n >> m >> k;     vector<int> c(n + 1);     for (int i = 1; i <= n; i++) cin >> c[i];     vector<Edge> same_edges;     map<pair<int, int>, vector<Edge>> diff_edges;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       if (c[u] == c[v])         same_edges.push_back({u, v});       else {         if (c[u] > c[v]) swap(u, v);         diff_edges[{c[u], c[v]}].push_back({u, v});       }     }     vector<int> group_flag(k + 1, 1);     ufs.init((n + 1) * 2);     for (auto &[u, v] : same_edges) {       ufs.Merge(u * 2, v * 2 + 1);       ufs.Merge(u * 2 + 1, v * 2);       if (ufs.Find(u * 2) == ufs.Find(u * 2 + 1)) group_flag[c[u]] = 0;       if (ufs.Find(v * 2) == ufs.Find(v * 2 + 1)) group_flag[c[v]] = 0;     }     ll good_group_cnt = 0;     for (int i = 1; i <= k; i++)       if (group_flag[i]) good_group_cnt++;     ll cnt_fail = 0;     for (auto &[key, row] : diff_edges) {       if (!group_flag[key.first]) continue;       if (!group_flag[key.second]) continue;       int mark = (int)ufs.stk.size();       int flag = 1;       for (auto &[u, v] : row) {         ufs.Merge(u * 2, v * 2 + 1);         ufs.Merge(u * 2 + 1, v * 2);         if (ufs.Find(u * 2) == ufs.Find(u * 2 + 1)) flag = 0;         if (ufs.Find(v * 2) == ufs.Find(v * 2 + 1)) flag = 0;       }       if (!flag) cnt_fail++;       while ((int)ufs.stk.size() > mark) {         ufs.Undo();       }     }     ll ans = good_group_cnt * (good_group_cnt - 1) / 2;     ans = ans - cnt_fail;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t;     cin >> n >> t;     int edge_n = 2 * n;     double edges[edge_n];     double currX, currA;     for (int i = 0; i < n; i++) {       cin >> currX >> currA;       edges[2 * i] = currX - currA / 2;       edges[2 * i + 1] = currX + currA / 2;     }     for (int i = 0; i < edge_n; i++) {       for (int j = i; j > 0 && (edges[j] < edges[j - 1]);) {         double temp = edges[j - 1];         edges[j - 1] = edges[j];         edges[j] = temp;         j--;       }     }     int count = 2;     for (int i = 1; i < edge_n; i += 2) {       if (edges[i + 1] - edges[i] > t) {         count += 2;       } else if (edges[i + 1] - edges[i] == t) {         count++;       }     }     cout << count;   }
#include <bits/stdc++.h>   using namespace std;   int bs(int a[], int l, int u, int x) {     int m, p = -1;     while (l <= u) {       m = (l + u) / 2;       if (a[m] == x || (a[m] < x && m + 1 <= u && a[m + 1] >= x))         return m;       else if (a[m] < x) {         p = m;         l = m + 1;       } else {         u = m - 1;       }     }     return p;   }   int gc(int a, int b) {     if (!a) return b;     return gc(b % a, a);   }   bool isP(unsigned long long int x) {     if (x == 2) return true;     if (x % 2 == 0 || x <= 1) return false;     for (int i = 3; i <= sqrt(x); i += 2) {       if ((x % i) == 0) return false;     }     return true;   }   int main() {     int n, j, g, g1, pre, i, uc, f4, l, v, li, ri, a4, e1, ind, t3, n9, t, r, f,         c1, p, p1, p3, y, x, z, t1, t2, t3n, m, k;     int a[100000];     unordered_map<string, int> mp;     priority_queue<pair<int, int>> pq;     int ty = 0, ty1;     set<int> st;     set<int> sto;     ty = INT_MAX;     g = 0;     vector<int> ar;     cin >> n >> k;     for (i = 0; i < n; i++) {       cin >> a[i];       g += a[i];     }     f = 1;     if (g % k != 0)       cout <<  No n ;     else {       g1 = 0;       ind = 0;       for (i = 0; i < n; i++) {         g1 += a[i];         ind++;         if (g1 == (g / k)) {           ar.push_back(ind);           g1 = 0;           ind = 0;         } else if (g1 > (g / k)) {           f = 0;           cout <<  No n ;           break;         }       }       if (f) {         cout <<  Yes n ;         for (i = 0; i < ar.size(); i++) cout << ar[i] <<    ;         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxint = -1u >> 1;   int n;   long long x[100010];   bool v[100010];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %I64d , &x[i]);     sort(x, x + n);     long long a = -1, b = -1;     long long ret = 0;     for (int i = n - 2; i >= 0; i--) {       if (v[i + 1]) continue;       if (x[i + 1] - x[i] <= 1) {         if (a == -1) {           a = x[i];           v[i] = true;         } else {           b = x[i];           v[i] = true;           ret += a * b;           a = -1;         }       }     }     cout << ret << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, count = 0, ans;     cin >> n;     string s;     cin >> s;     long long r = 0, b = 0;     for (long long i = 0; i < n; i++)       if (s[i] ==  r )         r++;       else if (s[i] ==  b )         b++;     for (long long i = 0; i < n; i++)       if (i % 2 == 0 && s[i] !=  r )         count++;       else if (i % 2 == 1 && s[i] !=  b )         count++;     long long rx = n % 2 == 1 ? 1 + (long long)(n / 2) : n / 2;     ans = abs(r - rx);     count -= ans;     ans += (count / 2);     count = 0;     for (long long i = 0; i < n; i++)       if (i % 2 == 1 && s[i] !=  r )         count++;       else if (i % 2 == 0 && s[i] !=  b )         count++;     ans = min(ans, abs(b - rx) + (count - abs(b - rx)) / 2);     cout << ans;   }
#include <bits/stdc++.h>   int main() {     int a, b, s = 0, t = 0, r = 0, i, c, d;     scanf( %d %d , &a, &b);     for (i = 1; i <= 6; i++) {       c = abs(a - i);       d = abs(b - i);       if (c < d)         s++;       else if (c > d)         t++;       else         r++;     }     printf( %d %d %d n , s, r, t);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int v;     long long w;     node(){};     node(int v, long long w) : v(v), w(w) {}   };   vector<vector<node> > G;   int b[102550];   long long solve(int s) {     long long ans = 10000000000000000;     int len = G[s].size();     for (int i = 0; i < len; i++) {       node p = G[s][i];       if (b[p.v]) {         ans = min(ans, p.w);       }     }     if (ans == 10000000000000000) ans = -1;     return ans;   }   int main() {     int n, m, k, num;     scanf( %d %d %d , &n, &m, &k);     G.clear();     G.resize(n + 5);     memset(b, 0, sizeof(b));     for (int i = 1; i <= m; i++) {       int u, v;       long long w;       scanf( %d %d %I64d , &u, &v, &w);       G[u].push_back(node(v, w));       G[v].push_back(node(u, w));     }     for (int i = 1; i <= k; i++) {       scanf( %d , &num);       b[num] = 1;     }     long long ans = 10000000000000000;     for (int i = 1; i <= n; i++) {       if (b[i] == 1) continue;       long long num = solve(i);       if (num != -1) ans = min(ans, num);     }     if (ans == 10000000000000000) ans = -1;     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, s, ans = 0, counter = 0;     cin >> n >> s;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     while (ans < s) {       counter++;       ans += a[n - counter];     }     cout << counter;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:60777216 )   using namespace std;   int main() {     int tc;     cin >> tc;     for (int TC = (0); TC < (tc); TC++) {       int n, k;       string s;       cin >> n >> k >> s;       k--;       string res =   ;       for (int i = (0); i < (n / 2 - k); i++) res.push_back( ( );       for (int i = (0); i < (n / 2 - k); i++) res.push_back( ) );       for (int i = (0); i < (k); i++) res.push_back( ( ), res.push_back( ) );       vector<pair<int, int> > r;       for (int i = (0); i < (n); i++)         if (res[i] != s[i]) {           for (int j = (i + 1); j < (n); j++)             if (s[j] == res[i]) {               reverse(s.begin() + i, s.begin() + j + 1);               r.push_back(pair<int, int>(i, j));               break;             }         }       cout << r.size() << endl;       for (int i = (0); i < (r.size()); i++)         printf( %d %d n , r[i].first + 1, r[i].second + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 500 + 4;   const int maxlog = 22;   const int mod = 1e9 + 7;   const int sq = 350;   int n, m;   int ans[maxn][maxn][2];   pair<int, int> par[maxn][maxn][2];   queue<pair<pair<int, int>, bool> > q;   vector<int> edge[maxn];   void solve() {     while (!q.empty()) {       int u = q.front().first.first;       int v = q.front().first.second;       bool b = q.front().second;       q.pop();       if (b == 0) {         for (int i = 0; i < edge[u].size(); i++) {           int k = edge[u][i];           if (!ans[k][v][1]) {             par[k][v][1] = make_pair(u, v);             ans[k][v][1] = ans[u][v][0] + 1;             q.push(make_pair(make_pair(k, v), 1));           }         }       } else {         for (int i = 0; i < edge[v].size(); i++) {           int k = edge[v][i];           if (!ans[u][k][0] && k != u) {             par[u][k][0] = make_pair(u, v);             ans[u][k][0] = ans[u][v][1] + 1;             q.push(make_pair(make_pair(u, k), 0));           }         }       }     }   }   vector<pair<int, int> > res;   void print(int x, int y, bool b) {     if (x == 0 && y == 0) return;     res.push_back(make_pair(x, y));     print(par[x][y][b].first, par[x][y][b].second, b ^ 1);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout.precision(20);     cin >> n >> m;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       edge[u].push_back(v), edge[v].push_back(u);     }     ans[1][n][0] = 1;     q.push(make_pair(make_pair(1, n), 0));     solve();     if (ans[n][1][0] / 2 == 0) {       cout << -1;       return 0;     }     cout << ans[n][1][0] / 2 << endl;     print(n, 1, 0);     reverse(res.begin(), res.end());     for (int i = 0; i < res.size(); i += 2) cout << res[i].first <<    ;     cout << endl;     for (int i = 0; i < res.size(); i += 2) cout << res[i].second <<    ;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, m;     char c[12][13];     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %s , &c[i][1]);     int eaten(0);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (c[i][j] ==  W ) {           if (c[i - 1][j] ==  P  || c[i + 1][j] ==  P  || c[i][j - 1] ==  P  ||               c[i][j + 1] ==  P ) {             eaten += 1;           }         }       }     }     printf( %d n , eaten);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     while (cin >> n) {       int arr[100005];       for (int i = 1; i <= n; i++) {         cin >> arr[i];       }       long long cnt = 0;       for (int i = 1; i < n; i++) {         long long x = log2(n - i);         arr[i + (1 << x)] += arr[i];         cnt += arr[i];         arr[i] = 0;         cout << cnt << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long s[10000] = {0};   long long c[10000] = {0};   long long dp[2][10000] = {0};   int main() {     for (int i = 0; i < 10000; i++) {       dp[0][i] = 100000000000000;       dp[1][i] = 100000000000000;     }     cin >> n;     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < n; i++) cin >> c[i];     for (int i = 0; i < n; i++) {       for (int j = 0; j < i; j++) {         if (s[j] < s[i]) {           dp[0][i] = min(dp[0][i], c[i] + c[j]);         }       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < i; j++) {         if (s[j] < s[i]) {           dp[1][i] = min(dp[1][i], dp[0][j] + c[i]);         }       }     }     long long ans = 100000000000000;     for (int i = 0; i < n; i++) {       ans = min(ans, dp[1][i]);     }     if (ans == 100000000000000) ans = -1;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100100] = {}, b[100100] = {}, c[100100] = {};   int main() {     int n, x, y;     cin >> n >> x >> y;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       b[i] = a[i];     }     sort(a + 1, a + n + 1);     if (x < y) {       int t = x, z = a[y + 1];       for (int i = 1; i <= n; i++) {         if (b[i] > z) {           c[i] = 1;           t--;         } else           c[i] = 2;       }       for (int i = 1; i <= n; i++) {         if (b[i] == z && t > 0) {           c[i] = 1;           t--;         }       }     }     if (x > y) {       int t = x, z = a[x];       for (int i = 1; i <= n; i++) {         if (b[i] < z) {           c[i] = 1;           t--;         } else           c[i] = 2;       }       for (int i = 1; i <= n; i++) {         if (b[i] == z && t > 0) {           c[i] = 1;           t--;         }       }     }     if (x == y) {       for (int i = 1; i <= x; i++) c[i] = 1;       for (int i = 1; i <= x; i++) c[i + x] = 2;     }     for (int i = 1; i < n; i++) cout << c[i] <<    ;     cout << c[n] << endl;   }
#include <bits/stdc++.h>   using namespace std;   string flip1(string st) {     swap(st[0], st[1]);     swap(st[1], st[2]);     swap(st[2], st[3]);     return st;   }   string flip2(string st) {     swap(st[0], st[4]);     swap(st[4], st[2]);     swap(st[2], st[5]);     return st;   }   string fun(string x) {     string res = x;     int i, j, k;     for (i = 0; i < 2; i++) {       for (j = 0; j < 4; j++) {         for (k = 0; k < 4; k++) {           x = flip1(x);           res = min(res, x);         }         x = flip2(x);       }       x = flip1(x);     }     return res;   }   int main() {     set<string> s;     int n, m, i, j, k;     string x, y;     cin >> x;     sort(x.begin(), x.end());     do {       s.insert(fun(x));     } while (next_permutation(x.begin(), x.end()));     cout << s.size() << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a, b;   int main() {     while (cin >> a >> b) {       int min = 0;       int temp = a;       while (temp) {         if (min < temp % 10) min = temp % 10;         temp /= 10;       }       temp = b;       while (temp) {         if (min < temp % 10) min = temp % 10;         temp /= 10;       }       min++;       int i = 0;       int c = 0;       temp = a + b;       while (a || b || c) {         int sum = a % 10 + b % 10 + c;         c = sum / min;         a /= 10;         b /= 10;         i++;       }       cout << i << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:20000000 )   string problem_name =  a ;   void init() { freopen((problem_name +  .in ).c_str(),  rt , stdin); }   struct tpoint {     int x, y;   };   long long vp(tpoint a, tpoint b, tpoint c) {     tpoint f, s;     f.x = b.x - a.x;     f.y = b.y - a.y;     s.x = c.x - a.x;     s.y = c.y - a.y;     return f.x * (long long)s.y - (long long)f.y * s.x;   }   tpoint mas[100111];   int main() {     int n, t;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d%d , &mas[i].x, &mas[i].y);     int p = 1;     scanf( %d , &t);     while (t--) {       tpoint c;       long long res = 0;       scanf( %d%d , &c.x, &c.y);       p = 1;       bool ok = 1;       for (int i = 0; i < n; i++) {         if (vp(mas[i], mas[(i + 1) % n], c) >= 0) ok = 0;       }       if (ok)         for (int i = 0; i < n; i++) {           if (p == i) p++;           if (p >= n) p = 0;           while (vp(mas[i], mas[p], c) < 0) {             p++;             if (p == n) p = 0;           }           p--;           if (p < 0) p = n - 1;           long long col = p - i + 1;           if (col <= 0) col += n;           if (col > 2) {             col--;             res += col * (col - 1) / 2;           }         }       if (!ok)         res = 0;       else         res = (long long)n * (n - 1) * (n - 2) / 6 - res;       cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 9e5 + 7;   const long long INF = 1e9 + 7;   int main() {     cout << 2000 << endl;     for (int i = 1; i <= 1000; i++) cout << i <<   1   << i <<   2 n ;     for (int i = 1000; i >= 1; i--) cout << i <<   1   << i <<   2 n ;     return 0;   }