malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int ma = 35;   int n, m, mat[ma][ma];   int main() {     int t;     scanf( %d , &t);     int ans, one, zero;     int sum, temp;     int l, r;     while (t--) {       scanf( %d%d , &n, &m);       one = zero = 0;       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) {           scanf( %d , &mat[i][j]);           if (mat[i][j])             one++;           else             zero++;         }       ans = min(zero, one);       zero = one = sum = 0;       if (m > n) {         l = 1, r = m;         while (1) {           temp = one = zero = 0;           while ((1 + temp <= n) && (l - temp >= 1)) {             if (mat[1 + temp][l - temp])               one++;             else               zero++;             temp++;           }           temp--;           if ((1 + temp == n) && (l - temp == r)) break;           temp = 0;           while ((n - temp >= 1) && (r + temp <= m)) {             if (mat[n - temp][r + temp])               one++;             else               zero++;             temp++;           }           sum += min(zero, one);           if ((l + 1) == r + temp - 1) break;           l++, r--;         }       } else {         l = 1, r = n;         while (1) {           temp = one = zero = 0;           while (l - temp >= 1 && 1 + temp <= m) {             if (mat[l - temp][1 + temp])               one++;             else               zero++;             temp++;           }           temp--;           if (l - temp == r && 1 + temp == m) break;           temp = 0;           while (r + temp <= n && m - temp >= 1) {             if (mat[r + temp][m - temp])               one++;             else               zero++;             temp++;           }           sum += min(zero, one);           if (l + 1 == r + temp - 1) break;           l++, r--;         }       }       printf( %d n , min(ans, sum));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   int freq[26];   int main() {     string s;     cin >> s;     int mx = -1;     char g = s[0];     for (int i = 0; i < s.size(); i++) {       freq[s[i] -  a ]++;       if (s[i] >= g) {         mx = max(mx, freq[s[i] -  a ]);         g = s[i];       }     }     string d(freq[g -  a ], g);     cout << d << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const double pi = acos(-1);   const int inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int N = 2e5 + 5;   int n, m;   char a[N], b[N];   void solve() {     scanf( %d , &n);     scanf( %s , a + 1);     scanf( %s , b + 1);     int res = 0;     for (int i = 1; i <= n; ++i) {       if (b[i] ==  1 ) {         if (a[i] ==  0  || a[i - 1] ==  1 )           ++res;         else if (a[i + 1] ==  1 ) {           a[i + 1] =  * ;           ++res;         }       }     }     printf( %d n , res);   }   int main() {     int t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int p, x, y;   queue<int> q;   int mmap[100000];   bool check(int s) {     int i = s / 50 % 475;     for (int j = 0; j < 25; ++j) {       i = (i * 96 + 42) % 475;       if (26 + i == p) return true;     }     mmap[s] = 1;     return false;   }   int main() {     cin >> p >> x >> y;     q.push(0);     while (!q.empty()) {       int n = q.front();       q.pop();       int s = x + n * 100;       while (s >= y) {         if (mmap[s]) {           s -= 50;           continue;         }         if (check(s)) {           cout << n << endl;           return 0;         }         s -= 50;       }       q.push(n + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       string s;       cin >> s;       int left0 = 0;       for (int i = 0; i < n; i++) {         if (s[i] ==  0 ) {           left0 = i + 1;         } else {           break;         }       }       int right1 = 0;       for (int i = n - 1; i >= 0; i--) {         if (s[i] ==  1 ) {           right1 = right1 + 1;         } else {           break;         }       }       for (int i = 0; i < left0; i++) {         cout << 0;       }       if (left0 + right1 == n - 1 && (left0 != 0 || right1 != 0)) {         cout << s[left0];       } else if (left0 + right1 != n) {         cout << 0;       }       for (int i = 0; i < right1; i++) {         cout << 1;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct no {     long long i, h, m;   };   long long dp[40][40][40];   char str[40];   no pre[40][40][40];   long long pw[19];   vector<char> ans;   int main() {     long long n;     scanf( %lld , &n);     scanf( %s , str + 1);     pw[0] = 1;     for (long long i = 1; i < 19; i++) pw[i] = pw[i - 1] * 10LL;     for (long long i = 0; i < 40; i++)       for (long long j = 0; j < 40; j++)         for (long long k = 0; k < 40; k++) dp[i][j][k] = -9999999999999LL;     dp[0][0][0] = 0;     pre[0][0][0] = {-1, -1, -1};     for (long long i = 1; i <= 2 * n; i++) {       for (long long h = 0; h <= n; h++) {         for (long long m = 0; m <= n; m++) {           if (h) {             if (dp[i - 1][h - 1][m] + pw[n - h] * (str[i] -  0 ) > dp[i][h][m]) {               dp[i][h][m] = dp[i - 1][h - 1][m] + pw[n - h] * (str[i] -  0 );               pre[i][h][m] = {i - 1, h - 1, m};             }           }           if (m) {             if (dp[i - 1][h][m - 1] + pw[n - m] * (str[i] -  0 ) > dp[i][h][m]) {               dp[i][h][m] = dp[i - 1][h][m - 1] + pw[n - m] * (str[i] -  0 );               pre[i][h][m] = {i - 1, h, m - 1};             }           }         }       }     }     no check = {-1, -1, -1};     no tren = {2 * n, n, n};     no pred = pre[tren.i][tren.h][tren.m];     while (pred.i != -1) {       if (tren.h == pred.h)         ans.push_back( M );       else         ans.push_back( H );       tren = pred;       pred = pre[tren.i][tren.h][tren.m];     }     reverse(ans.begin(), ans.end());     for (long long i = 0; i < ans.size(); i++) printf( %c , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long a[5005];   void input() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       a[i + 1] = a[i] + x;     }   }   void solve() {     long long outx, outy, outz, ans;     ans = outx = outy = outz = 0;     for (int i = 0; i <= n; i++) {       long long z = a[i], lft = i;       for (int j = i; j <= n; j++) {         if (a[j] < z) {           lft = j, z = a[j];         }         if (a[i] - a[lft] + a[j] > ans) {           ans = a[i] - a[lft] + a[j];           outx = i, outz = j, outy = lft;         }       }     }     printf( %lld %lld %lld , outx, outy, outz);   }   int main() {     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char s[18];     for (int i = 1; i <= 8; i++) {       cin >> s;       bool p = false;       for (int j = 1; j < 8; j++)         if (s[j] == s[j - 1]) {           p = true;           break;         }       if (p) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define inf 1999999999999999999   #define mod 1000000007   #define lb lower_bound   #define ub upper_bound   #define pb push_back   #define pf push_front   #define bn binary_search   #define pq priority_queue   #define int long long   #define pii pair<int,int>   #define mii map<int,int>   #define umii unordered_map<int,int>   #define um unordered_map   #define vi vector<int>   #define mii map<int,int>   #define si set<int>   #define ft first   #define sc second   #define gcd(a,b) __gcd(a,b)   #define lcm(a,b) a*(b/gcd(a,b))   #define bp(a) __builtin_popcountll(a)   #define mmst(a,b) memset(a,b,sizeof(a))   #define ld long double   void lc(){cout<<endl;}   int md(int n){return n%mod;}   void solve()   {    int n;    ld k;    cin>>n>>k;    //k=k*((ld)(sqrt(2)));    pii p[n];    for(int i=0;i<n;i++)    cin>>p[i].ft>>p[i].sc;    for(int i=0;i<n;i++)    {     int mind=0;     for(int j=0;j<n;j++)     {      if(i==j)continue;      int dis=abs(p[i].ft-p[j].ft)+abs(p[i].sc-p[j].sc);      mind=max(mind,dis);     }     if(mind<=k)      {       cout<< 1 ;       return;      }    }       cout<< -1 ;       }   signed main()   {     ios::sync_with_stdio(0);    cin.tie(0);    int t=1;    cin>>t;    while(t--)    {      solve();      lc();    }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 3;   const long long OO = 0x3f3f3f3f3f3f3f3f;   long long n, a, b;   vector<int> primes, v;   long long mem[N][3];   void fact(int num) {     if (num % 2 == 0) primes.push_back(2);     while (num % 2 == 0) num /= 2;     for (int i = 3; i * i <= num; ++i) {       if (num % i == 0) primes.push_back(i);       while (num % i == 0) num /= i;     }     if (num > 1) primes.push_back(num);   }   long long solve(int idx, int typ, const int& gcd) {     if (idx == n) return 0;     long long& ret = mem[idx][typ];     if (~ret) return ret;     ret = OO;     if (typ < 2) {       ret = min(ret, a + solve(idx + 1, 1, gcd));     }     if (typ == 1) typ = 2;     for (int i = -1; i <= 1; ++i) {       if (((v[idx] + i) % gcd) == 0)         ret = min(ret, (i == 0 ? 0 : b) + solve(idx + 1, typ, gcd));     }     return ret;   }   int main() {     cin >> n >> a >> b;     v = vector<int>(n);     for (auto& it : v) cin >> it;     for (int i = -1; i <= 1; ++i) {       fact(v[0] + i);       fact(v[n - 1] + i);     }     set<int> st(primes.begin(), primes.end());     primes = vector<int>(st.begin(), st.end());     long long ans = OO;     for (auto it : primes) {       memset(mem, -1, sizeof mem);       long long rt = solve(0, 0, it);       ans = min(ans, rt);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   int mx = (int)1e9;   char an;   void ask_query(int i, int j) {     cout <<  ?   << i <<     << j << endl;     cin >> an;     if (an ==  e ) exit(0);   }   int solbin(int l, int r) {     if (r == l + 1) return r;     int mid = (l + r) / 2;     ask_query(l, mid);     if (an ==  x ) {       return solbin(l, mid);     } else {       return solbin(mid, r);     }   }   int sol(int shift, int en) {     if (en == 2) {       ask_query(shift, shift + 1);       if (an ==  y ) {         return shift + 2;       } else {         return shift + 1;       }     }     an =  y ;     int i = 0, j = 2;     int it = 0;     while (an !=  x  && 2 * j < en) {       if (it != 0) {         i = j;         j = min(2 * j, en);       }       ask_query(shift + i, shift + j);       it++;     }     if (2 * j >= en && an !=  x ) {       i = j;       j = en;     }     return solbin(shift + i, shift + j);   }   void solve() {     string s;     cin >> s;     while (s ==  start ) {       int ans = sol(0, mx);       cout <<  !   << ans << endl;       cin >> s;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   class Piece {    public:     int up[600];     int down[600];     vector<int> pcs;     Piece() {}   } pieces[20];   int x[600][600], w, h, p, u;   void readPhoto() {     cin >> h >> w >> p;     for (int i = 0; i < h; ++i)       for (int j = 0; j < w; ++j) cin >> x[i][j];     h /= p;   }   void setPieces() {     int st = 0;     for (int i = 0; i < p; ++i) {       pieces[i].pcs.push_back(i + 1);       for (int j = 0; j < w; j++) {         pieces[i].up[j] = x[st][j] + x[st + 1][j];         pieces[i].down[j] = x[st + h - 2][j] + x[st + h - 1][j];       }       st += h;     }     u = p;   }   bool comp(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {     return a.first < b.first;   }   int calcDiff(int a, int b) {     int diff = 0;     for (int i = 0; i < w; ++i)       diff += ((pieces[a].down[i] - pieces[b].up[i]) *                (pieces[a].down[i] - pieces[b].up[i]));     return diff;   }   void mrgPieces(int a, int b) {     pieces[a].pcs.insert(pieces[a].pcs.end(), pieces[b].pcs.begin(),                          pieces[b].pcs.end());     swap(pieces[a].down, pieces[b].down);     swap(pieces[b], pieces[--u]);   }   void cmpPieces() {     vector<pair<int, pair<int, int> > > v;     for (int i = 0; i < u; ++i)       for (int j = 0; j < u; ++j)         if (i != j) {           int diff = calcDiff(i, j);           v.push_back(make_pair(diff, make_pair(i, j)));         }     sort(v.begin(), v.end(), comp);     mrgPieces(v[0].second.first, v[0].second.second);     v.clear();   }   void cleanPieces() {     for (int i = 0; i < 20; ++i) pieces[i].pcs.clear();   }   int main() {     ios_base::sync_with_stdio(false);     int c;     cin >> c;     while (c--) {       readPhoto();       setPieces();       while (u > 1) cmpPieces();       int tmpPrint[20];       int spx = 1;       for (__typeof(pieces[0].pcs.begin()) it = pieces[0].pcs.begin();            it != pieces[0].pcs.end(); ++it)         tmpPrint[*it - 1] = spx++;       for (int i = 0; i < p; ++i) cout << tmpPrint[i] <<    ;       cout << endl;       cleanPieces();     }   }
#include <bits/stdc++.h>   using namespace std;   bool dp[5001][5001];   vector<int> bits[10001];   vector<pair<int, int> > cur;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s, ans;     cin >> s;     int n = s.size();     dp[0][0] = 1;     cur.push_back(make_pair(0, 0));     int cnt = 0;     while ((1 << cnt) < n) cnt++;     cnt--;     ans =   ;     for (int i = 0; i < (1 << cnt); i++)       for (int j = 0; j < cnt; j++)         if ((i & (1 << j)) == 0) bits[i].push_back(j);     int l = 1;     int m = n;     while (m > l) {       m -= l;       l *= 2;     }     while (ans.size() < m) {       char min_chr =  z ;       for (int i = 0; i < cur.size(); i++) {         auto x = cur[i];         for (auto j : bits[x.second]) {           if (dp[x.first + (1 << j)][x.second | (1 << j)] == 0) {             cur.push_back(make_pair(x.first + (1 << j), x.second | (1 << j)));             dp[x.first + (1 << j)][x.second | (1 << j)] = 1;           }         }         min_chr = min(min_chr, s[x.first]);       }       ans.push_back(min_chr);       vector<pair<int, int> > tmp;       for (auto x : cur) {         if (s[x.first] == min_chr) {           dp[x.first + 1][x.second] = 1;           tmp.push_back(make_pair(x.first + 1, x.second));         }       }       cur = tmp;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   int n, m;   vector<int> me, a, nme;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     int num;     for (int i = 1; i <= n; i++) {       cin >> num;       me.push_back(num);     }     for (int i = 1; i <= m; i++) {       cin >> num;       a.push_back(num);     }     for (int i = 0; i < 30; i++) {       for (int j = 0; j < me.size(); j++) {         if (me[j] & (1 << i)) {           nme.push_back((1 << i));         }       }     }     sort(a.begin(), a.end());     int ans = 0;     int cm = 0;     for (int i = 0; i < nme.size(); i++) {       while (cm < a.size() and nme[i] >= (1 << a[cm])) {         nme[i] -= (1 << a[cm]);         cm += 1;         ans += 1;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x;   bool isp(int n) {     if (n == 1) return false;     for (long long i = 2; i * i <= n; ++i)       if (n % i == 0) return false;     return true;   }   int mpow(long long x, int k) {     long long ans = 1;     while (k > 0) {       if (k & 1) ans = (ans * x) % n;       x = (x * x) % n;       k /= 2;     }     return ans;   }   int main() {     cin >> n >> x;     ++n;     if (!isp(n)) {       cout <<  -1 ;       return 0;     }     int m = n - 1;     vector<int> p;     for (int i = 2; i <= m; ++i) {       if (m % i == 0) {         p.push_back(i);         while (m % i == 0) m /= i;       }     }     if (m > 1) p.push_back(m);     for (int y = x - 1; y > 0; --y) {       bool ok = true;       for (int i = 0; i < p.size(); ++i) {         int k = (n - 1) / p[i];         if (mpow(y % n, k) == 1) {           ok = false;           break;         }       }       if (ok) {         cout << y;         return 0;       }     }     cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 100;   const int oo = 1e9 + 7;   int N;   int H[MAXN];   deque<int> dq;   int L[MAXN], R[MAXN], l[MAXN], r[MAXN];   int d[MAXN];   vector<int> G[MAXN];   void Dijkstra(int u) {     for (int i = (1), _b = (N + 1); i <= _b; ++i) d[i] = +oo;     d[u] = 0;     priority_queue<pair<int, int>, vector<pair<int, int>>,                    greater<pair<int, int>>>         pq;     pq.push(pair<int, int>(0, u));     while (pq.size()) {       int du = pq.top().first;       int u = pq.top().second;       pq.pop();       if (du != d[u]) continue;       for (auto &v : G[u]) {         if (d[v] > du + 1) {           d[v] = du + 1;           pq.push(pair<int, int>(d[v], v));         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> N;     for (int i = (1), _b = (N); i <= _b; ++i) cin >> H[i];     dq.clear();     for (int i = (N), _a = (1); i >= _a; --i) {       while (dq.size() && H[dq.front()] <= H[i]) dq.pop_front();       if (dq.size())         R[i] = dq.front() - 1;       else         R[i] = i;       dq.push_front(i);     }     dq.clear();     for (int i = (1), _b = (N); i <= _b; ++i) {       while (dq.size() && H[dq.front()] <= H[i]) dq.pop_front();       if (dq.size())         L[i] = dq.front() + 1;       else         L[i] = i;       dq.push_front(i);     }     dq.clear();     for (int i = (1), _b = (N); i <= _b; ++i) {       while (dq.size() && H[dq.front()] >= H[i]) dq.pop_front();       if (dq.size())         l[i] = dq.front() + 1;       else         l[i] = i;       dq.push_front(i);     }     dq.clear();     for (int i = (N), _a = (1); i >= _a; --i) {       while (dq.size() && H[dq.front()] >= H[i]) dq.pop_front();       if (dq.size())         r[i] = dq.front() - 1;       else         r[i] = i;       dq.push_front(i);     }     for (int i = (1), _b = (N); i <= _b; ++i) G[i].push_back(i + 1);     for (int i = (1), _b = (N); i <= _b; ++i) {       if (H[i] < min(H[L[i] - 1], H[R[i] + 1])) {         G[L[i] - 1].push_back(R[i] + 1);       }     }     for (int i = (1), _b = (N); i <= _b; ++i) {       if (max(H[l[i] - 1], H[r[i] + 1]) < H[i]) {         G[l[i] - 1].push_back(r[i] + 1);       }     }     Dijkstra(1);     cout << d[N] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long MOD = 1000000007;   const long long INF = 1e12;   const long long N = 1e6 + 10;   vector<long long> G[100001];   long long n, m, match[100001], dist[100001];   bool bfs() {     long long i, u, v, len;     queue<long long> Q;     for (i = 1; i <= n; i++) {       if (match[i] == 0) {         dist[i] = 0;         Q.push(i);       } else         dist[i] = (1 << 28);     }     dist[0] = (1 << 28);     while (!Q.empty()) {       u = Q.front();       Q.pop();       if (u != 0) {         len = G[u].size();         for (i = 0; i < len; i++) {           v = G[u][i];           if (dist[match[v]] == (1 << 28)) {             dist[match[v]] = dist[u] + 1;             Q.push(match[v]);           }         }       }     }     return (dist[0] != (1 << 28));   }   bool dfs(long long u) {     long long i, v, len;     if (u != 0) {       len = G[u].size();       for (i = 0; i < len; i++) {         v = G[u][i];         if (dist[match[v]] == dist[u] + 1) {           if (dfs(match[v])) {             match[v] = u;             match[u] = v;             return true;           }         }       }       dist[u] = (1 << 28);       return false;     }     return true;   }   long long hopcroft_karp() {     long long matching = 0, i;     while (bfs())       for (i = 1; i <= n; i++)         if (match[i] == 0 && dfs(i)) matching++;     return matching;   }   vector<pair<long long, pair<long long, long long>>> edges;   long long check(long long x) {     for (long long i = 0; i <= 2 * n + 1; i++) {       G[i].clear();       match[i] = 0;       dist[i] = (1 << 28);     }     for (long long i = 0; i < (long long)edges.size() && edges[i].first <= x;          i++) {       long long u = edges[i].second.first, v = edges[i].second.second;       G[u].push_back(v);       G[v].push_back(u);     }     long long res = hopcroft_karp();     return n == res;   }   void solve() {     long long V;     cin >> n >> V;     m = n;     for (long long i = 0; i < V; i++) {       long long d, u, v;       cin >> u >> v >> d;       edges.push_back({d, {u, v + n}});     }     sort(edges.begin(), edges.end());     long long l = 1, h = 1e9 + 1;     long long ans = h;     while (l <= h) {       long long mid = (l + h) / 2;       if (check(mid)) {         h = mid - 1;         ans = mid;       } else {         l = mid + 1;       }     }     if (ans == 1e9 + 1)       cout << -1 <<   n ;     else       cout << ans;   }   signed main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     long long t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   struct node {     double x, y;   } g[500];   int main() {     int i, j, k, n, m;     scanf( %d , &n);     for (i = 0; i < n; ++i) {       scanf( %lf%lf , &g[i].x, &g[i].y);     }     double maxx = 0;     double m1, m2;     for (i = 0; i < n - 1; ++i)       for (j = i + 1; j < n; ++j) {         m1 = m2 = 0;         for (k = 0; k < n; ++k) {           if (i == k || j == k) continue;           double temp = (g[i].x - g[k].x) * (g[j].y - g[k].y) -                         (g[j].x - g[k].x) * (g[i].y - g[k].y);           if (temp > 0) {             if (temp > m1) m1 = temp;           } else {             if (temp < m2) m2 = temp;           }         }         if (m1 != 0 && m2 != 0)           if (maxx < m1 + abs(m2)) maxx = m1 + abs(m2);       }     printf( %lf , maxx / 2);   }
#include <bits/stdc++.h>   using namespace std;   int mb[3], cd[3];   int mn[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   bool chk() {     if (mb[1] > 12) return 0;     int i, j, k, tm;     tm = mn[mb[1]];     if (mb[1] == 2 && !(mb[2] & 3)) tm++;     if (tm < mb[0]) return 0;     for (i = mb[2]; i < cd[2]; i++)       ;     i -= (mb[2] + 1);     int dy, m;     if (mb[0] == 29 && mb[1] == 2 && (cd[2] & 3)) {       dy = 1;       m = 3;     } else {       dy = mb[0];       m = mb[1];     }     if (cd[1] > m || (cd[1] == m && cd[0] >= dy)) i++;     return i >= 18;   }   int main() {     bool f = 0;     scanf( %d.%d.%d %d.%d.%d , &cd[0], &cd[1], &cd[2], &mb[0], &mb[1], &mb[2]);     sort(mb, mb + 3);     do {       if (chk()) {         f = 1;         break;       }     } while (next_permutation(mb, mb + 3));     if (f)       puts( YES );     else       puts( NO );     return 0;   }