malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   pair<int, int> arr[100001];   int main() {     int n, d, a, b;     cin >> n >> d >> a >> b;     for (int i = 0; i < n; i++) {       int c, d;       cin >> c >> d;       arr[i].first = c * a + d * b;       arr[i].second = i + 1;     }     sort(arr, arr + n);     long long counter = 0;     int in = n;     for (int i = 0; i < n; i++) {       counter += arr[i].first;       if (counter > d) {         in = i;         break;       }     }     cout << in << endl;     for (int i = 0; i < in; i++) {       cout << arr[i].second <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void print1d(vector<long long> &A) {     for (auto i : A) cout << i <<    ;     cout << endl;   }   void print2d(vector<vector<long long>> &A) {     for (auto i : A) {       for (auto j : i) cout << j <<    ;       cout << endl;     }   }   void printadj(unordered_map<long long, vector<long long>> &mp) {     for (auto it : mp) {       cout << it.first <<   -->  ;       for (long long i = 0; i < it.second.size(); i++) {         cout << it.second[i] <<    ;       }       cout << endl;     }   }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     long long n, m;     cin >> n >> m;     long long a, b, c;     map<long long, long long> mp;     for (long long i = 0; i < m; i++) {       set<long long> s;       s.insert(1);       s.insert(2);       s.insert(3);       cin >> a >> b >> c;       if (mp.find(a) != mp.end()) {         s.erase(mp[a]);         if (mp[a] == 1) {           mp[b] = 2;           mp[c] = 3;         } else if (mp[a] == 2) {           mp[b] = 1;           mp[c] = 3;         } else if (mp[a] == 3) {           mp[b] = 1;           mp[c] = 2;         }       } else if (mp.find(b) != mp.end()) {         s.erase(mp[b]);         if (mp[b] == 1) {           mp[a] = 2;           mp[c] = 3;         } else if (mp[b] == 2) {           mp[a] = 1;           mp[c] = 3;         } else if (mp[b] == 3) {           mp[a] = 1;           mp[c] = 2;         }       } else if (mp.find(c) != mp.end()) {         s.erase(mp[c]);         if (mp[c] == 1) {           mp[a] = 2;           mp[b] = 3;         } else if (mp[c] == 2) {           mp[a] = 1;           mp[b] = 3;         } else if (mp[c] == 3) {           mp[a] = 1;           mp[b] = 2;         }       } else {         mp[a] = 1;         mp[b] = 2;         mp[c] = 3;       }     }     for (auto it : mp) {       cout << it.second <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1510;   const int MOD = 1000000007;   const int SZ = 100010;   inline int add(int u, int v) { return (u += v) >= MOD ? u - MOD : u; }   inline int sub(int u, int v) { return (u -= v) < 0 ? u + MOD : u; }   inline int mul(int u, int v) { return (long long)u * v % MOD; }   inline int power(int u, int v) {     int res = 1;     while (v) {       if (v & 1) res = mul(res, u);       u = mul(u, u);       v >>= 1;     }     return res;   }   inline int inv(int u) { return power(u, MOD - 2); }   int n, m, a, b, k, p;   int dp[N][N];   int pref[N][N];   int sumG[N], g[N];   int fac[SZ], invFac[SZ];   int comb(int n, int k) {     if (k > n || k < 0) return 0;     return mul(fac[n], mul(invFac[k], invFac[n - k]));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     cin >> a >> b;     cin >> k;     p = mul(a, inv(b));     fac[0] = 1;     for (int i = 1; i < SZ; i++) {       fac[i] = mul(fac[i - 1], i);     }     invFac[SZ - 1] = inv(fac[SZ - 1]);     for (int i = SZ - 2; i >= 0; i--) {       invFac[i] = mul(invFac[i + 1], i + 1);     }     for (int i = 0; i <= m; i++) {       g[i] = comb(k, i);       if (g[i] != 0) {         g[i] = mul(g[i], power(p, i));         g[i] = mul(g[i], power(sub(1, p), k - i));       }       sumG[i] = g[i];       if (i > 0) sumG[i] = add(sumG[i], sumG[i - 1]);     }     memset(dp, 0, sizeof dp);     memset(pref, 0, sizeof pref);     dp[0][m] = 1;     for (int i = 1; i <= n; i++) {       for (int r = 1; r <= m; r++) {         int p1 = mul(sumG[r - 1], sub(dp[i - 1][m], dp[i - 1][m - r]));         int p2 = pref[i - 1][r - 1];         int foo = mul(sub(p1, p2), g[m - r]);         dp[i][r] = add(dp[i][r - 1], foo);         pref[i][r] = add(pref[i][r - 1], mul(g[r], dp[i][r]));       }     }     cout << dp[n][m] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[101], k, i, n, check[101][101], j = 0, kil1, kil2, ans;   int main() {     cin >> n >> k;     for (i = 1; i <= n; i++) {       cin >> a[i];     }     for (i = 1; i <= k; i++) {       kil1 = 0;       kil2 = 0;       for (j = i; j <= n; j += k) {         if (a[j] == 1)           kil1++;         else           kil2++;       }       ans += min(kil1, kil2);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, c = 0;     cin >> n;     int a[n], b[n];     map<int, int> mp;     for (int i = 1; i <= 1001; i++) {       mp[i] = 0;     }     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = n - 1; i >= 0; i--) {       if (mp[a[i]] == 0) {         mp[a[i]] = 1;         b[c] = a[i];         c++;       }     }     reverse(b, b + c);     cout << c << endl;     for (int i = 0; i < c; i++) cout << b[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     char x;     int min, max;     cin >> x >> min >> max;     if (min > max) {       swap(min, max);     }     for (int i = 0; i < n - 1; i += 1) {       char y;       int m, n;       cin >> y >> m >> n;       if (y ==  + ) {         if (m > n) {           swap(m, n);         }         if (m > min) {           min = m;         }         if (n > max) {           max = n;         }       } else {         if (m > n) {           swap(m, n);         }         if (m >= min && n >= max) {           cout <<  YES  << endl;         } else {           cout <<  NO  << endl;         }       }     }   }
#include <bits/stdc++.h>   using ll = long long;   using namespace std;   void solve() {     ll n, k;     cin >> n >> k;     int mn = 2e9;     for (int i = 1; i < sqrt(n) + 1; i++) {       if (n % i == 0) {         int y = i * k;         int x = n / i * k;         for (int j = 0; y / k == i; j++) {           if ((y % k) * (y / k) == n) {             mn = min(mn, y);             break;           }           y++;         }         for (int j = 0; x / k == n / i; j++) {           if ((x % k) * (x / k) == n) {             mn = min(mn, x);             break;           }           x++;         }       }     }     cout << mn << endl;   }   int main() { solve(); }
#include <bits/stdc++.h>   using namespace std;   const long double eps = 1e-9;   const long double pi = acos(-1.0);   const long double inf = 1e+9;   long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }   int xabs(int a) { return a >= 0 ? a : -a; }   int sign(int a) { return (a < 0) ? -1 : 1; }   int main() {     int n, m;     cin >> n >> m;     vector<int> a(n + 1), b(m + 1);     for (int i = 0; i < n + 1; i++) cin >> a[i];     for (int i = 0; i < m + 1; i++) cin >> b[i];     if (n > m) {       if (a[0] < 0 && b[0] > 0) cout <<  - ;       if (a[0] > 0 && b[0] < 0) cout <<  - ;       cout <<  Infinity  << endl;     }     if (n < m) {       cout <<  0/1  << endl;     }     if (n == m) {       int g = gcd(a[0], b[0]);       a[0] /= g;       b[0] /= g;       if (b[0] < 0) {         a[0] *= -1;         b[0] *= -1;       }       cout << a[0] <<  /  << b[0] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     int nMin;     int ans = 0;     int n;     int inter[150001];     cin >> t;     while (t--) {       ans = 0;       cin >> n;       for (int i = 0; i < n; i++) {         cin >> inter[i];       }       for (int i = n - 1; i >= 0; i--) {         if (i == n - 1) {           nMin = inter[i];         } else {           if (inter[i] <= nMin) {             nMin = inter[i];           } else {             ans++;           }         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;   int n, a[55][55], ans[55];   int main() {     ios_base::sync_with_stdio(0);     while (scanf( %d , &n) == 1) {       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= n; ++j) scanf( %d , &a[i][j]);       for (int i = 1; i <= n; ++i) {         set<int> s;         for (int j = 1; j <= n; ++j) s.insert(a[i][j]);         if (s.size() != n) continue;         for (int j = 1; j <= n; ++j) ans[j] = a[i][j] ? a[i][j] : n;         bool ok = true;         for (int j = 1; j <= n; ++j) {           for (int k = 1; k <= n; ++k) {             if (j == k) continue;             if (min(ans[j], ans[k]) != a[j][k]) {               ok = false;               break;             }           }           if (!ok) break;         }         if (ok) break;       }       for (int i = 1; i <= n; ++i) printf( %d%c , ans[i],    n [i == n]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long val[2001000];   int f[2001000], pre[2001000];   void getans(long long F) {     for (int i = 1; i <= n + n; i++) f[i] = 0, pre[i] = i;     int pl = 1;     int ans = 0x7fffffff;     for (int i = n + 1; i <= n + n; i++) {       while (pl < i && val[i] - val[pl] > F) pl++;       f[i] = f[pl] + 1;       pre[i] = pre[pl];       if (i - pre[i] >= n) ans = min(ans, f[i]);     }     printf( %d n , ans);   }   void solve() {     int q;     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) scanf( %lld , &val[i]), val[i + n] = val[i];     for (int i = 2; i <= n + n; i++) val[i] += val[i - 1];     for (int i = 1; i <= q; i++) {       long long t;       scanf( %lld , &t);       getans(t);     }   }   int main() {     solve();     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     if (n < 3) {       cout << -1;     } else {       long long a[n][n];       long long offset = n * n - 9;       a[0][0] = 9 + offset;       a[0][1] = 5 + offset;       a[0][2] = 6 + offset;       a[1][0] = 7 + offset;       a[1][1] = 2 + offset;       a[1][2] = 8 + offset;       a[2][0] = 1 + offset;       a[2][1] = 3 + offset;       a[2][2] = 4 + offset;       long long x = 0;       for (long long j = n - 1; j > (long long)2; --j) {         if (j & 1) {           for (long long i = 0; i < (long long)j + 1; ++i) {             a[i][j] = ++x;           }           for (long long i = j - 1; i > (long long)-1; --i) {             a[j][i] = ++x;           }         } else {           for (long long i = 0; i < (long long)j + 1; ++i) {             a[j][i] = ++x;           }           for (long long i = j - 1; i > (long long)-1; --i) {             a[i][j] = ++x;           }         }       }       for (long long i = 0; i < (long long)n; ++i) {         for (long long j = 0; j < (long long)n; ++j) {           cout << a[i][j] <<    ;         }         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long count, x, f, total = 0;     std::cin >> count;     long long a[count];     for (long long i = 0; i < count; i++) {       std::cin >> a[i];     }     std::cin >> x >> f;     for (long long i = 0; i < count; i++) {       total += a[i] / (f + x);       if (a[i] % (x + f) > x) total++;     }     std::cout << total * f <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     scanf( %d , &n);     long long ans = 0;     int cur = 0;     for (int i = 0; i < n; ++i) {       int a;       scanf( %d , &a);       int p = min(cur, a / 2);       a -= p * 2, cur -= p, ans += p;       ans += a / 3, a %= 3;       cur += a;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<long double, int> v[100005];   int n;   long double minn = 2 * 3.14159265358979323846264338327950288419716939937510 + 1;   int minPos;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       int x, y;       cin >> x >> y;       long double angle = atan2l(y, x);       v[i] = {           angle >= 0               ? angle               : angle + 2 * 3.14159265358979323846264338327950288419716939937510,           i};     }     sort(v + 1, v + n + 1);     for (int i = 1; i < n; i++) {       if (v[i + 1].first - v[i].first < minn) {         minn = v[i + 1].first - v[i].first;         minPos = i;       }     }     if (2 * 3.14159265358979323846264338327950288419716939937510 - v[n].first +             v[1].first <         minn) {       minn = 2 * 3.14159265358979323846264338327950288419716939937510 -              v[n].first + v[1].first;       minPos = n;     }     cout << v[minPos].second <<     << v[(minPos == n) ? 1 : (minPos + 1)].second;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, t;     cin >> n >> t;     int d = 1;     while (t > 1) {       if (t % 2) {         cout << 0 << endl;         return 0;       }       t /= 2;       d++;     }     long long dp[60][60] = {};     dp[1][1] = 1;     long long cur = 1;     long long lv = 1;     long long ans = 0;     int i = 2;     n++;     for (i = 2; i <= 60; i++) {       for (int j = 1; j <= i; j++) {         dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];       }       lv *= 2;       cur += lv;       if (cur > n) break;       ans += dp[i][d];     }     n -= lv - 1;     while (lv > 1) {       lv /= 2;       i--;       if (n >= lv) {         ans += dp[i][d];         n -= lv;         d--;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n;     cin >> n;     long long int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     int t = a[n - 1];     a[n - 1] = a[n - 2];     a[n - 2] = t;     if (a[0] + a[n - 2] <= a[n - 1] || a[n - 1] + a[n - 3] <= a[n - 2]) {       cout <<  NO ;       return 0;     }     cout <<  YES  << endl;     for (int i = 0; i < n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int ar[n];     int f[n + 1], cnt[n + 1];     for (int i = 0; i < n; i++) cin >> ar[i];     memset(f, 0, n + 1);     memset(cnt, 0, n + 1);     f[1] = 1;     cnt[1] = 1;     for (int i = 2; i <= n; i++) {       if (ar[i - 1] > ar[i - 2])         f[i] = f[i - 1] + 1;       else         f[i] = 1;       cnt[i] = max(cnt[i - 1], f[i]);     }     cout << cnt[n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e5 + 10;   vector<int> tu[MAXN];   struct node {     int val, flag;   } tree[MAXN * 4];   int in[MAXN], out[MAXN], fa[MAXN];   int flag, n, q, cnt;   void dfs(int son, int father) {     int i, k;     in[son] = ++cnt;     for (i = 0; i < tu[son].size(); i++) {       k = tu[son][i];       if (k == father) continue;       fa[k] = son;       dfs(k, son);     }     out[son] = cnt;   }   void putup(int deep) {     if (tree[deep * 2].val == 1 && tree[deep * 2 + 1].val == 1)       tree[deep].val = 1;     else       tree[deep].val = 0;   }   void putdown(int deep) {     if (tree[deep].flag) {       tree[deep * 2].flag = tree[deep * 2 + 1].flag = tree[deep].flag;       tree[deep * 2].val = tree[deep * 2 + 1].val = tree[deep].flag;       tree[deep].flag = 0;     }   }   void update(int L, int R, int l, int r, int deep, int k) {     if (L == 0) return;     if (L <= l && r <= R) {       if (tree[deep].val == 0) flag = 1;       tree[deep].val = k, tree[deep].flag = k;       return;     }     putdown(deep);     int mid = (l + r) / 2;     if (L <= mid) update(L, R, l, mid, deep * 2, k);     if (mid < R) update(L, R, mid + 1, r, deep * 2 + 1, k);     putup(deep);   }   void query(int L, int R, int l, int r, int deep) {     if (L <= l && r <= R) {       if (tree[deep].val == 0) flag = 1;       return;     }     putdown(deep);     int mid = (l + r) / 2;     if (L <= mid) query(L, R, l, mid, deep * 2);     if (mid < R) query(L, R, mid + 1, r, deep * 2 + 1);   }   int main() {     int i, x, y;     scanf( %d , &n);     for (i = 1; i <= n - 1; i++) {       scanf( %d%d , &x, &y);       tu[x].push_back(y);       tu[y].push_back(x);     }     cnt = 0;     dfs(1, 0);     scanf( %d , &q);     while (q--) {       scanf( %d%d , &x, &y);       if (x == 1) {         flag = 0;         update(in[y], out[y], 1, n, 1, 1);         if (flag) update(in[fa[y]], in[fa[y]], 1, n, 1, 0);       } else if (x == 2)         update(in[y], in[y], 1, n, 1, 0);       else {         flag = 0;         query(in[y], out[y], 1, n, 1);         if (flag)           printf( 0 n );         else           printf( 1 n );       }     }   }
#include <bits/stdc++.h>   const int MAX_N = 1e5 + 1;   const long long int MOD = 1e9 + 7;   const long long int INF = 1e9;   using namespace std;   void solve() {     int n, max = 0, idx;     cin >> n;     vector<int> v(n);     for (int i = 0; i < n; i++) {       cin >> v[i];       if (v[i] > max) {         max = v[i];         idx = i + 1;       }     }     sort(v.begin(), v.end());     cout << idx <<     << v[v.size() - 2] <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long int   #include<vector>   bool fun(pair<ll,ll>a,pair<ll,ll>b)   {       if((a.second>b.second))           return 1;       return 0;   }   bool chec(ll n)   {       ll x,c=n;       while(c)       {           x=c%10;           if(x!=0&&n%x!=0)           {               return false;           }           c=c/10;       }       return true;   }   int check(ll x)   {       ll sum=0;       while(x)       {           sum=sum+x%10;           x=x/10;       }       return sum;   }   ll poww(ll sx,ll a)   {       ll i,j=1;       for(i=0;i<a;i++)       {           j=j*sx;       }       return j;   }   int main()   {       ios_base::sync_with_stdio(false);    cin.tie(0);    cout.tie(0);    ll t;    cin>>t;    while(t--)       {           ll x,y=0;           cin>>x;           ll curr=0,i=1;           while(curr<x)           {               curr=curr+i;               i++;           }           if(curr==x+1)               cout<<i<<endl;           else               cout<<i-1<<endl;       }   }
#include <bits/stdc++.h>   using namespace std;   const int sz = 5005;   const int mod = 998244353;   long long int n, a[sz], b[sz], dp[15][1005][1005], c[sz], d[sz], m, c0, d0;   long long int dipi(int i, int cnt, int rem) {     if (rem > n) return -100000;     if (i > m) return 0;     if (~dp[i][cnt][rem]) return dp[i][cnt][rem];     if (a[i] - cnt * b[i] < 0) {       return dp[i][cnt][rem] = dipi(i + 1, 1, rem);     }     return dp[i][cnt][rem] =                max({d[i] + dipi(i, cnt + 1, rem + c[i]), dipi(i + 1, 1, rem),                     d[i] + dipi(i + 1, 1, rem + c[i])});   }   void solve() {     cin >> n >> m >> c0 >> d0;     memset(dp, -1, sizeof dp);     c[0] = c0, d[0] = d0;     a[0] = 0, b[0] = 0;     for (int i = 1; i <= m; i++) {       cin >> a[i] >> b[i] >> c[i] >> d[i];     }     cout << dipi(0, 1, 0) << endl;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long n, m;     cin >> n >> m;     for (long long i = 0; i < n; i++) cout <<  1 ;     cout <<   n ;     for (long long i = 0; i < n - 1; i++) cout <<  8 ;     cout <<  9 n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int to;     int l, r;     node() {}     node(int to, int l, int r) : to(to), l(l), r(r) {}   };   struct node1 {     int l, r;     node1() {}     node1(int l, int r) : l(l), r(r) {}   };   vector<node> G[1010];   vector<node1> Q[1010];   int n, m, ans = 0;   bool book[1010], came[1010];   void init() {     for (int i = 1; i <= n; i++) {       G[i].clear();       Q[i].clear();     }   }   void add(int u, int v, int l, int r) {     G[u].push_back(node(v, l, r));     G[v].push_back(node(u, l, r));   }   void dfs(int cur, int le, int ri) {     if (book[cur]) return;     if (cur == n) {       ans = max(ans, ri - le + 1);       return;     }     if (ans >= ri - le + 1) return;     book[cur] = 1;     for (int i = 0; i < G[cur].size(); i++) {       node tmp = G[cur][i];       int newl = max(le, G[cur][i].l);       int newr = min(ri, G[cur][i].r);       if (newl > newr) continue;       int flag = 1;       for (int j = 0; j < Q[tmp.to].size(); j++) {         if (Q[tmp.to][j].l <= newl && Q[tmp.to][j].r >= newr) {           flag = 0;           break;         }       }       if (flag) {         Q[tmp.to].push_back(node1(newl, newr));         dfs(tmp.to, newl, newr);       }     }     book[cur] = 0;   }   int main() {     scanf( %d%d , &n, &m);     init();     for (int i = 1; i <= m; i++) {       int u, v, l, r;       scanf( %d%d%d%d , &u, &v, &l, &r);       add(u, v, l, r);     }     ans = 0;     memset(book, 0, sizeof(book));     memset(came, 0, sizeof(came));     dfs(1, 0, 1000000 + 10);     if (ans)       printf( %d n , ans);     else       printf( Nice work, Dima! n );   }
#include <bits/stdc++.h>   using namespace std;   int t, n, bad, w[5000 * 1000], g[5000 * 1000], p[5000 * 1000], ans[5000 * 1000],       d[5000 * 1000], cnt;   pair<int, int> buf[5000 * 1000];   vector<pair<int, int> > v, e;   map<int, vector<pair<int, int> > > m;   void go(int x) {     if (w[x]) return;     w[x] = 1;     d[cnt++] = x;     go(p[x]);   }   void place(int x) {     if (w[x] == 2) return;     w[x] = 2;     ans[x] = g[cnt++];     place(p[x]);   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) scanf( %d , &p[i]);     for (int i = 1; i <= n; i++) {       if (!w[i]) {         cnt = 0;         go(i);         if (cnt & 1) {           for (int j = 0; j < cnt; j++) g[j] = d[(cnt + j - cnt / 2) % cnt];           cnt = 0;           place(i);         } else {           v.clear();           for (int j = 0, t = i; j < cnt; j++, t = p[t]) {             v.push_back(make_pair(d[j], t));           }           if (m[cnt].empty()) {             bad++;             m[cnt] = v;           } else {             bad--;             e = m[cnt];             for (int j = 0; j < cnt; j++) {               ans[v[j].second] = e[j].first;               ans[e[j].second] = v[(j + 1) % cnt].first;             }             m[cnt].clear();           }         }       }     }     if (bad) {       cout << -1;       return 0;     }     for (int i = 1; i <= n; i++) {       printf( %d  , ans[i]);       d[i] = ans[ans[i]];     }   }
#include <bits/stdc++.h>   using namespace std;   long double w, h, a;   long double an;   long double y;   long double x, c, s;   long double k;   int main() {     cin >> w >> h >> a;     k = min(w, h);     w /= k;     h /= k;     long double res = 0.;     if (a == 0 || a == 180) {       res = w * h;     } else if (a == 90) {       long double m = min(w, h);       res = m * m;     } else {       if (a > 90) {         a = 180 - a;       }       an = a / 180. * 3.14159265358979323846;       c = cosl(an);       s = sinl(an);       y = (w - sinl(an) * h / (1 + cosl(an))) /           (cosl(an) + 1 - sinl(an) * sinl(an) / (1 + cosl(an)));       x = (h - y * sinl(an)) / (1 + cosl(an));       if (x > 0 && y > 0) {         res = w * h;         res -= y * sinl(an) * y * cosl(an);         res -= x * sinl(an) * x * cosl(an);       } else {         if (w < h) {           swap(w, h);         }         res = h * h / sinl(an);       }     }     res *= k * k;     cout.precision(17);     cout << res << endl;     return 0;   }