malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long inf = LLONG_MAX / 2;   const long long MX = 1e5 + 10;   int a[MX];   set<int> s;   vector<int> v;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     for (long long(i) = (0); (i) <= (n - 1); ++(i)) {       cin >> a[i];       s.insert(a[i]);     }     int num = 1;     while (m >= num) {       if (!s.count(num)) {         m -= num;         v.push_back(num);       }       num++;     }     cout << v.size() << endl;     for (auto it : v) {       cout << it <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long tr(long long d) { return d * (d + 1) / 2; }   inline long long tr2(long long d) { return 2 * tr(d) - d; }   int n;   long long solve(int y, int x, long long c) {     long long res = 4 * (tr(c + 1) - c - 1) + 1;     if (c - (y + 1) >= 0) res -= tr2(c - (y + 1) + 1);     if (c - (n - y) >= 0) res -= tr2(c - (n - y) + 1);     if (c - (x + 1) >= 0) res -= tr2(c - (x + 1) + 1);     if (c - (n - x) >= 0) res -= tr2(c - (n - x) + 1);     if (c - (y + x + 2) >= 0) res += tr(c - (y + x + 2) + 1);     if (c - (y + 1 + n - x) >= 0) res += tr(c - (y + 1 + n - x) + 1);     if (c - (x + 1 + n - y) >= 0) res += tr(c - (x + 1 + n - y) + 1);     if (c - (n - x + n - y) >= 0) res += tr(c - (n - x + n - y) + 1);     return res;   }   int main() {     int y, x, c;     while (scanf( %d%d%d%d , &n, &y, &x, &c) >= 1) {       --y, --x;       int l = -1, r = (int)2e9 + 1;       while (l + 1 < r) {         int m = l + (r - l) / 2;         if (solve(y, x, m) >= (long long)c)           r = m;         else           l = m;       }       printf( %d n , r);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void setIO(string name =   ) {     ios_base::sync_with_stdio(0);     cin.tie(0);     if (int((name).size())) {       freopen((name +  .in ).c_str(),  r , stdin);       freopen((name +  .out ).c_str(),  w , stdout);     }   }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long mcm(long long a, long long b) { return (a * b) / gcd(a, b); }   bool prime(long long n, long long i) {     if (i > sqrt(n)) return true;     if (n % i == 0)       return false;     else       return prime(n, i + 1);   }   struct compii {     bool operator()(const pair<int, int> &a, const pair<int, int> &b) {       if (a.first == a.second) return a.second < b.second;       return a.first > b.first;     }   };   bool comp(int a, int b) { return a > b; }   int dx[] = {1, 0, -1, 0};   int dy[] = {0, 1, 0, -1};   void solve() {     int n;     cin >> n;     vector<int> num(n);     int c0 = 0;     int c1 = 0;     for (auto &x : num) {       cin >> x;       if (x == 1)         c1++;       else         c0++;     }     int i = 0;     for (i = 0; i < n; i++) {       if (num[i] == 1)         c1--;       else         c0--;       if (c1 == 0) break;       if (c0 == 0) break;     }     cout << i + 1 << endl;   }   int main() {     setIO(  );     int t = 1;     while (t-- > 0) solve();     return 0;   }
#include <bits/stdc++.h>   #define int long long   using namespace std;   const int maxm=5e5+5;   int stk[maxm],head;   int d[maxm];   int a[maxm];   int n;   //   int rt[maxm],tot;   int lc[maxm*40],rc[maxm*40],ma[maxm*40];   inline void pp(int k){       ma[k]=max(ma[lc[k]],ma[rc[k]]);   }   void update(int x,int val,int l,int r,int &k,int last){       k=++tot;       lc[k]=lc[last];       rc[k]=rc[last];       if(l==r){           ma[k]=val;           return ;       }       int mid=(l+r)/2;       if(x<=mid)update(x,val,l,mid,lc[k],lc[last]);       else update(x,val,mid+1,r,rc[k],rc[last]);       pp(k);   }   int ask(int st,int ed,int l,int r,int k){       if(!k)return 0;       if(st<=l&&ed>=r)return ma[k];       int mid=(l+r)/2;       int ans=0;       if(st<=mid)ans=max(ans,ask(st,ed,l,mid,lc[k]));       if(ed>mid)ans=max(ans,ask(st,ed,mid+1,r,rc[k]));       return ans;   }   //   void solve(){       cin>>n;       //init       tot=0;       ma[0]=0;       //       for(int i=1;i<=n;i++){           cin>>a[i];       }       int ans=0;       head=0;       for(int i=1;i<=n;i++){           while(head&&a[stk[head]]<a[i]){               head--;           }           d[i]=1;           d[i]=max(d[i],ask(1,a[i],1,n,rt[i-1])+1);           if(head){               int k=stk[head];               d[i]=max(d[i],ask(1,a[i],1,n,rt[k-1])+2);           }           update(a[i],d[i],1,n,rt[i],rt[i-1]);           stk[++head]=i;           ans=max(ans,d[i]);       }       cout<<ans<<endl;   }   signed main(){       ios::sync_with_stdio(0);       int T;cin>>T;       while(T--){           solve();       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> fact(2000006);   vector<long long int> prime_check(1e7 + 2);   vector<long long int> primes;   long long powmod(long long x, long long y, long long m) {     long long res = 1LL;     while (y) {       if (y & 1) res = (res * x) % m;       x = (x * x) % m;       y /= 2;     }     return res;   }   void init_fact() {     fact[0] = 1;     for (long long int i = 1; i < 2000006; i++) {       fact[i] = (fact[i - 1] * i) % 1000000007;     }   }   long long int C(long long int n, long long int r) {     if (n < r) return 0;     long long int temp =         fact[n] * powmod(fact[r], 1000000007 - 2, 1000000007) % 1000000007;     temp *= powmod(fact[n - r], 1000000007 - 2, 1000000007);     temp %= 1000000007;     return temp;   }   void Sieve() {     for (long long int i = 2; i <= 1e7 + 1; i++) {       if (prime_check[i]) continue;       primes.push_back(i);       for (long long int j = 2 * i; j <= 1e7 + 1; j += i) prime_check[j] = i;     }   }   long long int phi(long long int n) {     long long int i, res = n;     for (i = 2; i * i <= n; i++)       if (n % i == 0) {         while (n % i == 0) n /= i;         res -= res / i;       }     if (n > 1) res -= res / n;     return res;   }   long long int n, x, y;   vector<long long int> a(2000006), b(2000006), cnt(2000006), sum(2000006);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> x >> y;     for (long long int i = 1; i <= n; i++) cin >> a[i], b[a[i]]++;     for (long long int i = 1; i < 2000006; i++)       cnt[i] = cnt[i - 1] + b[i], sum[i] = sum[i - 1] + b[i] * i;     long long int c = x / y;     long long int ans = INT64_MAX;     for (long long int i = 2; i <= 1e6; i++) {       long long int cost = 0, f = i - min(i, c);       for (long long int j = 0; j <= 1e6; j += i) {         long long int st = j + 1, en = j + i, st2 = max(st, st + f - 1);         long long int c1 = cnt[st2 - 1] - cnt[st - 1];         long long int c2 = cnt[en] - cnt[st2 - 1];         long long int c3 = sum[en] - sum[st2 - 1];         cost += c1 * x + y * (c2 * en - c3);       }       ans = min(ans, cost);     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int x1, y1, x2, y2;     cin >> x1 >> y1 >> x2 >> y2;     if ((x1 <= x2 && y1 <= y2) || x1 + y1 <= max(x2, y2)) {       cout <<  Polycarp ;     } else {       cout <<  Vasiliy ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[105], b[105];   int main() {     int n, q, l, r;     for (scanf( %d%d %s , &n, &q, a); q--;) {       memcpy(b, a, sizeof(a));       scanf( %d%d , &l, &r);       l--, r--;       int s[10] = {0}, i = l, p = n, d = 1;       for (; i >= l && i <= r; i += d) {         if (b[i] >=  0  && b[i] <=  9 )           s[(b[i]--) -  0 ]++, p = n;         else if (b[i] ==  <  || b[i] ==  > ) {           if (b[p] ==  <  || b[p] ==  > ) b[p] = 0;           p = i;           d = b[i] ==  <  ? -1 : 1;         }       }       for (i = 0; i < 10; i++) printf( %d  , s[i]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[6], t;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &t), a[t]++;     }     if (a[0] == 0) {       printf( -1 n );       return 0;     }     int k = a[5] / 9;     for (int i = 0; i < k; i++) {       printf( 555555555 );     }     if (k == 0) {       printf( 0 n );     } else {       while (a[0]--) printf( 0 );       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 210;   const int mod = 1e9 + 7;   void reduce(int& x) { x += x >> 31 & mod; }   int mul(int x, int y) { return (long long)x * y % mod; }   void fma(int& x, int y, int z) { x = ((long long)y * z + x) % mod; }   struct vec {     int x, y;     vec() { x = y = 0; }     vec(int a, int b) { x = a, y = b; }     vec operator+(vec b) const { return vec(x + b.x, y + b.y); }     vec operator-(vec b) const { return vec(x - b.x, y - b.y); }     long long operator^(vec b) const {       return (long long)x * b.y - (long long)y * b.x;     }     long long operator*(vec b) const {       return (long long)x * b.x + (long long)y * b.y;     }     bool operator==(vec b) const { return x == b.x && y == b.y; }   } ps[MAXN];   int n;   long long cross(vec x, vec y, vec z) { return (y - x) ^ (z - x); }   inline int sgn(long long x) { return x < 0 ? -1 : x > 0; }   int dp[MAXN][MAXN];   int main() {     std::ios_base::sync_with_stdio(false), std::cin.tie(0);     std::cin >> n;     for (int i = 1; i <= n; ++i) std::cin >> ps[i].x >> ps[i].y;     long long area = 0;     for (int i = 1; i <= n; ++i) area += ps[i] ^ ps[i == n ? 1 : i + 1];     for (int i = 1; i < n; ++i) dp[i][i + 1] = 1;     for (int L = 3; L <= n; ++L)       for (int l = 1; l + L - 1 <= n; ++l) {         int r = l + L - 1;         for (int p = l + 1; p < r; ++p)           if (sgn(cross(ps[p], ps[r], ps[l])) == sgn(area))             fma(dp[l][r], dp[l][p], dp[p][r]);       }     std::cout << dp[1][n] << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505;   long long dp_hor[2][N][N], dp_vert[2][N][N];   vector<pair<int, int>> cost_hor[N][N], cost_vert[N][N];   long long inf = 1e18;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m, k;     cin >> n >> m >> k;     for (int i = 1; i <= k; i++) {       int x, y, d, t, e;       cin >> x >> y >> d >> t >> e;       if (x + y >= t && ((x + y) % 4) == (t % 4))         cost_hor[x][y].push_back({1e9, e}), cost_vert[x][y].push_back({1e9, e});       if (x + y >= t + 1 && ((x + y) % 4) == ((t + 1) % 4))         cost_hor[x + d][y - d].push_back({1e9, e}),             cost_vert[x + d][y - d].push_back({1e9, e});       if (x + y + d >= t + 2 && ((x + y + d) % 4) == ((t + 2) % 4)) {         if (x + y >= t + 1 && ((x + y) % 4) == ((t + 1) % 4))           cost_hor[x + d][y].push_back({d, e});         else           cost_hor[x + d][y].push_back({1e9, e});         if (x + y >= t && ((x + y) % 4) == (t % 4))           cost_vert[x + d][y].push_back({d, e});         else           cost_vert[x + d][y].push_back({1e9, e});       }       if (x + y + d >= t + 3 && ((x + y + d) % 4) == ((t + 3) % 4)) {         if (x + y >= t && ((x + y) % 4) == (t % 4))           cost_hor[x][y + d].push_back({d, e});         else           cost_hor[x][y + d].push_back({1e9, e});         cost_vert[x][y + d].push_back({1e9, e});       }     }     for (int x = 0; x < 2; x++)       for (int y = 0; y < N; y++)         for (int z = 0; z < N; z++) dp_hor[x][y][z] = dp_vert[x][y][z] = inf;     for (int x = 0; x < n; x++) {       for (int y = 0; y < m; y++) {         int f = x & 1;         for (int z = 0; z < N; z++) dp_hor[f][y][z] = dp_vert[f][y][z] = inf;         if (x == 0 && y == 0) {           dp_hor[f][y][0] = dp_vert[f][y][0] = 0;         }         sort(cost_hor[x][y].begin(), cost_hor[x][y].end());         sort(cost_vert[x][y].begin(), cost_vert[x][y].end());         long long cost = 0;         for (int z = y; z >= 1; z--) {           while (cost_hor[x][y].size() > 0 && cost_hor[x][y].back().first > z) {             pair<int, int> t = cost_hor[x][y].back();             cost_hor[x][y].pop_back();             cost += t.second;           }           dp_hor[f][y][z] = dp_hor[f][y - 1][z - 1] + cost;         }         cost = 0;         for (int z = x; z >= 1; z--) {           while (cost_vert[x][y].size() > 0 && cost_vert[x][y].back().first > z) {             pair<int, int> t = cost_vert[x][y].back();             cost_vert[x][y].pop_back();             cost += t.second;           }           dp_vert[f][y][z] = dp_vert[f ^ 1][y][z - 1] + cost;         }         for (int z = 1; z <= x; z++) {           dp_hor[f][y][0] = min(dp_hor[f][y][0], dp_vert[f][y][z]);         }         for (int z = 1; z <= y; z++) {           dp_vert[f][y][0] = min(dp_vert[f][y][0], dp_hor[f][y][z]);         }       }     }     long long ans = inf;     for (int z = 1; z < m; z++) {       ans = min(ans, dp_hor[(n - 1) & 1][m - 1][z]);     }     for (int z = 1; z < n; z++) {       ans = min(ans, dp_vert[(n - 1) & 1][m - 1][z]);     }     if (ans == inf) ans = 0;     cout << ans << endl;   }
#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...);   }   template <class T>   ostream& operator<<(ostream& os, vector<T> V) {     os <<  [  ;     for (auto v : V) os << v <<    ;     return os <<  ] ;   }   template <class L, class R>   ostream& operator<<(ostream& os, pair<L, R> P) {     return os <<  (  << P.first <<  ,  << P.second <<  ) ;   }   const long long int mod = 1e9 + 7;   const long long int maxn = 5 * 100001;   long long int power(long long int x, long long int n) {     x %= mod;     long long int res = 1;     for (; n > 0; n >>= 1) {       if (n & 1) res = (res * x) % mod;       x = (x * x) % mod;     }     return res;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n;     cin >> n;     pair<long long int, long long int> a[n];     for (long long int i = 0; i < n; i++) {       cin >> a[i].first;       a[i].second = i + 1;     }     sort(a, a + n);     long long int dp[n + 1];     dp[n] = 0;     dp[n - 1] = mod;     dp[n - 2] = mod;     dp[n - 3] = a[n - 1].first - a[n - 3].first;     long long int got[n + 5];     got[n - 3] = n;     got[n - 2] = n;     got[n - 1] = n;     for (long long int i = n - 4; i >= 0; i--) {       long long int mini = mod;       mini = min(mini, a[i + 2].first - a[i].first + dp[i + 3]);       if (i + 4 <= n) mini = min(mini, a[i + 3].first - a[i].first + dp[i + 4]);       if (i + 5 <= n) mini = min(mini, a[i + 4].first - a[i].first + dp[i + 5]);       for (long long int j = 2; j <= 4; j++) {         if (j + i + 1 <= n) {           if (mini == a[i + j].first - a[i].first + dp[i + j + 1]) {             got[i] = i + j + 1;             break;           }         }       }       dp[i] = mini;     }     long long int ans[n + 1];     long long int m = 0;     for (long long int i = 0, j = 0; i < n; i = j) {       m++;       while (j != got[i]) {         ans[a[j].second] = m;         j++;       }     }     cout << dp[0] <<     << m << endl;     for (long long int i = 1; i <= n; i++) {       cout << ans[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = INT_MAX;   int n;   struct node {     long double x, y;   } a[100010];   bool check(long double xx) {     long double l, r;     l = -1e19, r = 1e19;     for (int i = 0; i < n; ++i) {       if (a[i].y >= xx * 2 || l > r) return false;       l = max(l, a[i].x - sqrt(2 * a[i].y * xx - a[i].y * a[i].y));       r = min(r, a[i].x + sqrt(2 * a[i].y * xx - a[i].y * a[i].y));     }     return l <= r;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %lf%lf , &a[i].x, &a[i].y);     for (int i = 0; i < n; ++i)       if (a[i].y * a[n - 1].y < 0) {         printf( -1 );         return 0;       } else         a[i].y = (a[i].y > 0) ? a[i].y : -a[i].y;     long double l = 0, r = 1e19, mid;     for (int i = 0; i <= 100; i++) {       mid = (l + r) / 2;       if (check(mid))         r = mid;       else         l = mid;     }     printf( %.10Lf , mid);   }
#include<bits/stdc++.h>   using namespace std;   int read() {    char c=getchar(); int x=0,f=1;    while (c< 0  || c> 9 ) {     if (c== - ) f=-1;     c=getchar();    }    while (c>= 0  && c<= 9 ) {     x=x*10+c- 0 ;     c=getchar();    }    return x*f;   }   const int p=998244353;   int a[1200005],b[1200005],c[1200005],fac[1200005],inv[1200005];    int pow_3[1200005],inv_3[1200005],R[1200005];   void add(int &x,int y) {x+=y; if (x>=p) x-=p;}   int pow_mod(int x,int k) {    int ans=1;    while (k) {     if (k&1) ans=1LL*ans*x%p;     x=1LL*x*x%p;     k>>=1;     }    return ans;   }   void ntt(int *x,int n,int f) {       pow_3[1]=pow_mod(3,(p-1)/n);       if (f==1) {           pow_3[0]=1;            for (int i=1; i<n; i++) pow_3[i]=1LL*pow_3[i-1]*pow_3[1]%p;       }       else {           inv_3[0]=1; inv_3[1]=pow_mod(pow_3[1],p-2);           for (int i=2; i<n; i++) inv_3[i]=1LL*inv_3[i-1]*inv_3[1]%p;       }       int t=0,tp=1;       while (tp<n) tp<<=1,++t;       for (int i=0; i<tp; i++) R[i]=(R[i>>1]>>1)|((i&1)?(tp>>1):0);       for (int i=0; i<n; i++) if (i<R[i]) swap(x[i],x[R[i]]);       for (int l=2; l<=n; l<<=1) {           int m=l/2;           for (int *y=x; y!=x+n; y+=l) {               for (int j=0; j<m; j++) {                   int tmp;                   if (f==1) tmp=1LL*y[j+m]*pow_3[n/l*j]%p;                   else tmp=1LL*y[j+m]*inv_3[n/l*j]%p;                   y[j+m]=y[j]-tmp; if (y[j+m]<0) y[j+m]+=p;                    y[j]+=tmp; if (y[j]>=p) y[j]-=p;               }           }       }       if (f==-1) {           int tmp=pow_mod(n,p-2);           for (int i=0; i<n; i++) x[i]=1LL*x[i]*tmp%p;       }   }   int f[300005],tot;   vector<int> vec[300005];   char s[300005];   int calc(int x) {    return 1LL*f[x+1]*pow_mod(2,tot-x)%p;   }   int main() {    for (int i=0; i<=300001; i++) a[i]=i/2;    for (int i=0; i<=300001; i++) b[i]=pow_mod(2,i);    int N=1;       while (N<=600000) N<<=1;    ntt(a,N,1); ntt(b,N,1);    for (int i=0; i<N; i++) c[i]=1LL*a[i]*b[i]%p;    ntt(c,N,-1);    f[0]=0;    int sum=0;    for (int i=1; i<=300001; i++) {     f[i]=(i-1)/2;     add(f[i],sum);     if (i>=2) add(f[i],c[i-2]);     add(sum,f[i]);    }    int n=read(),m=read(); tot=0;    for (int i=0; i<n; i++) {     scanf( %s , s);     for (int j=0; j<m; j++) {      vec[i].push_back((s[j]== o )?1:-1);      if (s[j]== o ) ++tot;     }    }    int ans=0;    for (int i=0; i<n; i++) {     int cnt=0;     for (int j=0; j<m; j++) {      if (vec[i][j]==1) ++cnt;      else {       if (cnt>0) add(ans,calc(cnt));       cnt=0;      }     }     if (cnt>0) add(ans,calc(cnt));    }    for (int j=0; j<m; j++) {     int cnt=0;     for (int i=0; i<n; i++) {      if (vec[i][j]==1) ++cnt;      else {       if (cnt>0) add(ans,calc(cnt));       cnt=0;      }     }     if (cnt>0) add(ans,calc(cnt));    }    printf( %d n , ans);    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned long long N = 1e10;   int getLen(unsigned long long a) {     int len = 0;     while (a) {       len++;       a /= 10;     }     return len;   }   unsigned long long gcd(unsigned long long a, unsigned long long b) {     return b == 0 ? a : gcd(b, (a % b));   }   unsigned long long lcm(unsigned long long a, unsigned long long b) {     unsigned long long t = gcd(a, b);     if (getLen(a / t) + getLen(b) > 22) return 0;     return a / gcd(a, b) * b;   }   int main() {     unsigned long long t, w, b;     unsigned long long p;     cin >> t >> w >> b;     if (w == b) {       printf( 1/1 n );       return 0;     }     unsigned long long mi = min(w, b);     if (t < mi) {       printf( 1/1 n );       return 0;     }     unsigned long long l = lcm(w, b);     if (l <= 0)       p = mi - 1;     else {       unsigned long long x = t / l;       if (x == 0) {         p = mi - 1;       } else {         p = min(mi, t - x * l + 1) + x * mi - 1;       }     }     unsigned long long d = gcd(p, t);     printf( %lld/%lld n , p / d, t / d);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 300;   inline long long read() {     long long s = 0, ww = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) ww = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) {       s = 10 * s + ch -  0 ;       ch = getchar();     }     return s * ww;   }   struct vec {     long long x, y;     vec() {}     vec(long long _x, long long _y) { x = _x, y = _y; }     inline friend vec operator-(vec a, vec b) {       return vec(a.x - b.x, a.y - b.y);     }     inline friend long long Cross(vec a, vec b) { return a.x * b.y - a.y * b.x; }     inline friend bool InUpper(vec a) { return a.y > 0 || (a.y == 0 && a.x > 0); }   } p[N + 5];   inline bool cmp(pair<long long, long long> i, pair<long long, long long> j) {     vec a = p[i.second] - p[i.first], b = p[j.second] - p[j.first];     bool k1 = InUpper(a), k2 = InUpper(b);     if (k1 != k2) return k1 < k2;     return Cross(a, b) > 0;   }   long long f[N + 5][N + 5][7];   long long n;   pair<long long, long long> seg[N * N + 5];   int main() {     n = read();     for (register int i = 1; i <= n; i++) {       long long x = read(), y = read();       p[i] = vec(x, y);     }     int cnt = 0;     for (register int i = 1; i <= n; i++)       for (register int j = 1; j <= n; j++)         if (i != j) seg[++cnt] = make_pair(i, j);     sort(seg + 1, seg + cnt + 1, cmp);     for (register int i = 1; i <= n; i++) f[i][i][1] = 1;     for (register int k = 1; k <= cnt; k++) {       int u = seg[k].first, v = seg[k].second;       for (register int i = 1; i <= n; i++)         for (register int j = 1; j <= 5; j++) f[i][v][j + 1] += f[i][u][j];     }     long long ans = 0;     for (register int i = 1; i <= n; i++) ans += f[i][i][6];     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int S;     cin >> S;     if (S == 1) {       cout << 1 <<     << 1 <<   n ;       cout << 1 <<   n ;       return 0;     }     cout << (S - 1) * 2 <<     << 2 <<   n ;     cout << 1 <<     << 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 2000 + 10;   bool mrk[MAX_N][MAX_N];   bool Ver[MAX_N][MAX_N];   bool Hor[MAX_N][MAX_N];   int N;   int Total;   void Solve(int x, int y) {     bool flag = false;     if ((mrk[x][y] ^ Ver[x][y] ^ Hor[x][y]) == 1) flag = true;     int dx = -1, dy = 1;     if (x < y) dx = 1, dy = -1;     if (x + dx != y + dx) Ver[x + dx][y] ^= (Ver[x][y] ^ flag);     if (y + dy != x + dy) Hor[x][y + dy] ^= (Hor[x][y] ^ flag);     mrk[x][y] ^= flag;     if (flag) Total++;   }   int main() {     ios::sync_with_stdio(false);     cin >> N;     for (int i = 0; i < N; i++)       for (int j = 0; j < N; j++) {         char temp;         cin >> temp;         mrk[j][i] = (temp -  0 );       }     for (int l = 0; l < N; l++)       for (int i = 0; i <= l; i++) {         Solve(N - 1 - i, l - i);         Solve(i, N - 1 - (l - i));       }     cout << Total << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m, n, i, j, l, r, u, d, sum;     char s[209];     while (scanf( %d , &n) != EOF) {       getchar();       scanf( %s , s);       sum = 0;       for (i = 0; i < n; i++) {         l = r = u = d = 0;         for (j = i + 1; j < n; j++) {           int x = 1, y = 1;           for (int k = i; k <= j; k++) {             if (s[k] ==  U )               y++;             else if (s[k] ==  D )               y--;             else if (s[k] ==  L )               x--;             else               x++;           }           if (x == 1 && y == 1) sum++;         }       }       printf( %d n , sum);     }     return 0;   }