malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s1, s2;     while (cin >> n) {       vector<string> array(4);       array[0] =  |#.#.#.#.#.#.#.#.#.#.#.|D|) ;       array[3] =  |#.#.#.#.#.#.#.#.#.#.#.|.|) ;       array[1] =  |#.#.#.#.#.#.#.#.#.#.#.|.| ;       array[2] =  |#.......................| ;       s1 = array[0].size() - 5, s2 = array[2].size() - 4;       cout <<  +------------------------+  << endl;       for (int j = 1; j < s1; j += 2) {         for (long long i = 0; i < 4; i++) {           if (!i || i == 3 && n) {             if (!n)               goto bara;             else               array[i][j] =  O , n--;           } else if (j == 1 && i == 2 && n)             array[i][j] =  O , n--;           else if (i == 1 && n)             if (!n)               goto bara;             else               array[i][j] =  O , n--;           else if (!n)             goto bara;         }       }     bara:;       for (long long i = 0; i < 4; i++) cout << array[i] << endl;       cout <<  +------------------------+  << endl;     }     return 0;   }
#include <bits/stdc++.h>   template <typename Tp>   void in(Tp &x) {     char ch = getchar(), f = 1;     x = 0;     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) f = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     x *= f;   }   template <typename Tp>   bool chkmax(Tp &x, Tp y) {     return x >= y ? 0 : (x = y, 1);   }   template <typename Tp>   bool chkmin(Tp &x, Tp y) {     return x <= y ? 0 : (x = y, 1);   }   template <typename Tp>   Tp Max(const Tp &x, const Tp &y) {     return x > y ? x : y;   }   template <typename Tp>   Tp Min(const Tp &x, const Tp &y) {     return x < y ? x : y;   }   const int MAXN = 400010;   int n;   int s[MAXN], g[MAXN];   int head[MAXN], nxt[MAXN << 1], data[MAXN << 1], flow[MAXN << 1], cnt;   void add(int x, int y, int z) {     nxt[cnt] = head[x];     data[cnt] = y;     flow[cnt] = z;     head[x] = cnt++;   }   using std::queue;   queue<int> q;   bool instack[MAXN];   long long dis[MAXN];   void spfa() {     memset(dis, 0x3f, sizeof dis);     dis[0] = 0;     instack[0] = true;     q.push(0);     while (!q.empty()) {       int now = q.front();       q.pop();       instack[now] = false;       for (int i = head[now]; i != -1; i = nxt[i]) {         if (dis[data[i]] > dis[now] + flow[i]) {           dis[data[i]] = dis[now] + flow[i];           if (!instack[data[i]]) {             q.push(data[i]);             instack[data[i]] = true;           }         }       }     }     long long ans1 = 0;     for (int i = (1), i_END_ = (n); i <= i_END_; ++i) {       ans1 += dis[i];       if (dis[i] < 0) {         puts( -1 );         return;       }     }     printf( %I64d n , ans1);     for (int i = (1), i_END_ = (n); i <= i_END_; ++i)       printf( %I64d  , dis[i] + s[i]);     putchar(10);   }   int main() {     in(n);     for (int i = (1), i_END_ = (n); i <= i_END_; ++i) in(s[i]), in(g[i]);     memset(head, -1, sizeof head);     for (int i = (1), i_END_ = (n); i <= i_END_; ++i) add(0, i, g[i]);     for (int i = (1), i_END_ = (n - 1); i <= i_END_; ++i) {       int t = s[i] - s[i + 1];       add(i, i + 1, 1 + t);       add(i + 1, i, 1 - t);     }     spfa();     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, i, j, c;     int a[1000][1000];     int b[10000];     c = 0;     scanf( %d , &n);     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++) scanf( %d , &a[i][j]);     for (i = 1; i <= n; i++) {       int flag = 0;       for (j = 1; j <= n; j++) {         if (a[i][j] == 3 || a[i][j] == 1) flag = 1;       }       if (flag == 0) {         b[c] = i;         c++;       }     }     printf( %d n , c);     if (c != 0) {       for (i = 0; i < c; i++) printf( %d  , b[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t = 0;     scanf( %d , &t);     for (int qwe = 0; qwe < t; qwe++) {       long long r = 0, l = 0, y = 0;       scanf( %lld%lld , &l, &r);       printf( %lld %lld n , l, l * 2);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long i, j, k;     int n;     cin >> n;     vector<long long> arr(n);     long long sum = 0;     for (i = 0; i < n; i++) {       cin >> arr[i];       sum += arr[i];     }     if (sum % 3 != 0) {       cout << 0 << endl;       return 0;     }     if (n < 3) {       cout << 0 << endl;       return 0;     }     long long s = sum / 3;     vector<int> ans(n, 0);     long long pref = 0;     for (i = n - 1; i >= 0; i--) {       pref += arr[i];       if (pref == s) {         ans[i] = 1;       }     }     for (i = n - 2; i >= 0; i--) {       ans[i] += ans[i + 1];     }     pref = 0;     long long soln = 0;     for (i = 0; i < n - 2; i++) {       pref += arr[i];       if (pref == s) {         soln += ans[i + 2];       }     }     cout << soln << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > numbersWithGrundy(1);   int a[200001], grundyValues[200001];   bool isPrime[200001], isMoveValid[200001];   vector<string> players{ Alice ,  Bob };   void PreProcess(int n, int m) {     vector<int> primes;     for (int i = 2; i <= n; ++i) {       isPrime[i] = 1;     }     for (int i = 2; i <= n; ++i) {       if (!isPrime[i]) {         continue;       }       for (int j = i + i; j <= n; j += i) {         isPrime[j] = 0;       }       primes.push_back(i);       for (int prime : primes) {         if (i * prime > n) {           break;         }         isMoveValid[i * prime] = 1;       }       isMoveValid[i] = 1;     }     isMoveValid[m] = 0;     numbersWithGrundy[0].push_back(0);     for (int i = 1; i <= n; ++i) {       int &k = grundyValues[i];       for (; k < numbersWithGrundy.size(); ++k) {         bool valid = 1;         for (int l = 0, r = numbersWithGrundy[k].size() - 1; l <= r && valid;              ++l, --r) {           valid = !(isMoveValid[i - numbersWithGrundy[k][l]] ||                     isMoveValid[i - numbersWithGrundy[k][r]]);         }         if (valid) {           break;         }       }       if (k >= numbersWithGrundy.size()) {         numbersWithGrundy.resize(k + 1);       }       numbersWithGrundy[k].push_back(i);     }   }   int main() {     int n, k;     scanf( %d%d , &n, &k);     for (int i = 1, j = 0; i <= n; ++i) {       int b, w, r;       scanf( %d%d%d , &b, &w, &r);       a[++j] = w - b - 1;       a[++j] = r - w - 1;     }     n = 2 * n;     int m = 0;     for (int i = 1; i <= n; ++i) {       m = max(m, a[i]);     }     PreProcess(m, k);     int ans = 0;     for (int i = 1; i <= n; ++i) {       ans ^= grundyValues[a[i]];     }     ans = (ans == 0) ? 1 : 0;     for (int i = 0; i < players.size(); ++i) {       cout << players[i ^ ans] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   const int INF = 0x3f3f3f3f;   using namespace std;   int a[3030], b[3030];   int dp[3030];   int main() {     int t;     cin >> t;     while (t--) {       int n;       memset(dp, 0, sizeof(dp));       cin >> n;       for (int i = 1; i <= n; i++) {         cin >> a[i];         b[i] = a[i];       }       sort(b + 1, b + 1 + n);       for (int i = 1; i <= n; i++) {         a[i] = lower_bound(b + 1, b + n + 1, a[i]) - b;       }       int ans = 0;       for (int i = 1; i <= n; i++) {         dp[a[i]] = dp[a[i] - 1] + 1;         ans = max(ans, dp[a[i]]);       }       cout << n - ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   struct SNM {     vector<SNM*> trgs;     vector<SNM*> rv_trgs;     int stype;     bool asgn;     bool used;     void asgnN() {       if (asgn) return;       asgn = true;       for (vector<SNM*>::iterator i = trgs.begin(); i != trgs.end(); i++) {         (*i)->asgnN();       }     }     void usedN() {       if (used) return;       used = true;       if (stype == 1) return;       for (vector<SNM*>::iterator i = rv_trgs.begin(); i != rv_trgs.end(); i++) {         (*i)->usedN();       }     }     SNM() {       used = false;       asgn = false;     }   };   SNM nodes[100000];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %d , &nodes[i].stype);     }     for (int i = 0; i < m; i++) {       int a, b;       scanf( %d%d , &a, &b);       a--;       b--;       nodes[a].trgs.push_back(&nodes[b]);       nodes[b].rv_trgs.push_back(&nodes[a]);     }     for (int i = 0; i < n; i++) {       if (nodes[i].stype == 1) {         nodes[i].asgnN();       }     }     for (int i = 0; i < n; i++) {       if (nodes[i].stype == 2) {         nodes[i].usedN();       }     }     for (int i = 0; i < n; i++) {       if (nodes[i].asgn && nodes[i].used) {         printf( 1 n );       } else {         printf( 0 n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int main() {     long long n, q, x, y;     cin >> n >> q;     for (long long i = 1; i <= q; i++) {       cin >> x >> y;       if ((x + y) % 2 == 0) {         if (n % 2 == 0) {           long long linie = n / 2;           long long first = linie * (x - 1);           long long kth = (y + 1) / 2;           cout << first + kth <<   n ;         } else {           long long linie = n / 2;           long long lines = linie * (x - 1) + (x - 1) / 2 + (x - 1) % 2;           long long kth = (y + 1) / 2;           cout << lines + kth <<   n ;         }       } else {         long long depl = (n * n) / 2 + (n * n) % 2;         if (n % 2 == 0) {           long long linie = n / 2;           long long first = linie * (x - 1);           long long kth = (y + 1) / 2;           cout << depl + first + kth <<   n ;         } else {           long long linie = n / 2;           long long lines = linie * (x - 1) + (x - 1) / 2;           long long kth = (y + 1) / 2;           cout << depl + lines + kth <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int num2 = {}, num3 = {};       while (n % 2 == 0) {         n /= 2;         num2++;       }       while (n % 3 == 0) {         n /= 3;         num3++;       }       if (n != 1 || num2 > num3)         cout <<  -1 n ;       else         cout << 2 * num3 - num2 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool valid(char str[]) {     int now = 0;     for (int i = 0; str[i]; i++) {       if (str[i] > now +  a ) return false;       if (str[i] == now +  a ) now++;     }     return true;   }   int main() {     char in[550];     scanf( %s , in);     int mx = 0;     for (int i = 0; in[i]; i++) mx = max(mx, in[i] -  a );     int cnt = 0;     if (valid(in))       printf( YES );     else       printf( NO );   }
#include <bits/stdc++.h>   int main() {     int n, m, k, p = 1;     scanf( %d , &n);     m = n;     while (m != 0) {       if (m % 10 == 1) {         m = m / 10;         continue;       }       if (m % 100 == 14) {         m = m / 100;         continue;       }       if (m % 1000 == 144) {         m = m / 1000;         continue;       }       p = 0;       break;     }     if (p == 1)       printf( YES );     else       printf( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105, A = 26;   bool win[N][N][A], known[N][N][A];   char g[N][N];   int n;   bool follow(int u, int v, char c) {     if (known[u][v][c -  a ]) return win[u][v][c -  a ];     for (int i = 1; i <= n; ++i)       if (g[u][i] >= c) win[u][v][c -  a ] |= !follow(v, i, g[u][i]);     known[u][v][c -  a ] = 1;     return win[u][v][c -  a ];   }   int main() {     int m;     scanf( %d%d , &n, &m);     while (m--) {       int a, b;       char c;       scanf( %d%d %c , &a, &b, &c);       g[a][b] = c;     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         printf( %c , follow(i, j,  a ) ?  A  :  B );       }       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   vector<long long> g[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       long long n;       cin >> n;       string s;       cin >> s;       long long i, j;       long long ans = 1e16;       for (int i = 0; i < n - 3; i++) {         long long sm = 0, c = 0;         for (int j = i; j < i + 4; j++) {           if (c % 4 == 0) {             sm += min(abs(s[j] -  A ), abs(s[j] -  Z ) + 1);           }           if (c % 4 == 1) {             sm += min(abs(s[j] -  C ), abs(s[j] -  Z ) + 3);           }           if (c % 4 == 2) {             sm += min(abs(s[j] -  T ), abs(s[j] -  A ) + 7);           }           if (c % 4 == 3) {             sm += min(abs(s[j] -  G ), abs(s[j] -  Z ) + 7);           }           c++;         }         ans = min(ans, sm);       }       cout << ans <<   n ;     }     return 0;   }
/*       Author - Param Kothari       Ah shit, here we go again   */      #include <bits/stdc++.h>       using namespace std;      #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);   #define pb push_back   #define mk make_pair      typedef long long ll;   typedef long double ld;      void solve(){       int n;       cin >> n;       vector<int> a(n);       for(int i = 0; i < n; i++){           cin >> a[i];       }       vector<ll> c(n + 1);       for(int i = 0; i < n; i++){           c[a[i]]++;       }       vector<ll> pref(n + 2);       for(int i = 1; i <= n; i++){           pref[i] = pref[i - 1] + c[i];       }       ll res = 0;       auto nC2 = [&](ll x){           return (x * (x - 1)) / 2;       };       auto nC3 = [&](ll x){           return (x * (x - 1) * (x - 2)) / 6;       };       for(int i = 1; i <= n - 2; i++){           ll l = i, r = i + 2;           ll cnt = pref[r - 1] - pref[l];           res += 1LL * c[l] * c[r] * cnt;           res += 1LL * nC2(c[l]) * c[r];           res += 1LL * c[l] * nC2(c[r]);       }       for(int i = 1; i <= n - 1; i++){           ll l = i, r = i + 1;           res += 1LL * nC2(c[l]) * c[r];           res += 1LL * c[l] * nC2(c[r]);       }       for(int i = 1; i <= n; i++){           res += 1LL * nC3(c[i]);       }       cout << res <<   n ;       return;   }      int main(){       IOS;       int t = 1;       cin >> t;       for(int i = 1; i <= t; i++){           solve();       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double dp[9000001] = {};   bool vis[9000001] = {};   long double solve(int inv) {     if (inv == 0) return 0;     if (inv == 1) return 1;     if (vis[inv]) return dp[inv];     vis[inv] = 1;     return dp[inv] = 4 + solve(inv - 2);   }   int main() {     std::ios::sync_with_stdio(false);     int n;     cin >> n;     std::vector<int> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     int inv = 0;     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++)         if (v[j] < v[i]) inv++;     }     cout << fixed << setprecision(9) << solve(inv);   }
#include <bits/stdc++.h>   using namespace std;   const long double eps = 1e-9;   const double EPS = 1e-9;   int ar[] = {1, -1, 0, 0, 1, 1, -1, -1};   int ac[] = {0, 0, 1, -1, 1, -1, 1, -1};   int p[200005];   int q[200005];   void solve1(int n) {     int k = 1;     if (n & 1) {       cout <<  NO n ;       return;     }     cout <<  YES n ;     while (k <= n) k *= 2;     k /= 2;     int last = n + 1;     while (k != 0) {       for (int i = k; i < last; i++) {         p[i] = k - (i - k + 1);         p[k - (i - k + 1)] = i;       }       last = min(last, k - (last - k));       k /= 2;     }     for (int i = 1; i <= n; i++) cout << p[i] <<    ;     cout <<   n ;   }   void solve2(int n) {     if (n < 6) {       cout <<  NO n ;       return;     }     int k = 1;     while (2 * k <= n) k *= 2;     if (n == k) {       cout <<  NO n ;       return;     }     cout <<  YES n ;     if (n == 6) {       cout <<  3 6 2 5 1 4 n ;       return;     }     for (int i = k; i < n; i++) q[i] = i + 1;     q[n] = k;     while (k != 4) {       for (int i = k / 2; i < k - 1; i++) {         q[i] = i + 1;       }       q[k - 1] = k / 2;       k /= 2;     }     q[1] = 5;     q[2] = 3;     q[3] = 2;     q[4] = 6;     q[5] = 7;     q[6] = 4;     q[7] = 1;     for (int i = 1; i <= n; i++) cout << q[i] <<    ;     cout <<   n ;     return;   }   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     solve1(n);     solve2(n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int MAX = 200002;   int arr[MAX];   int cnt[MAX];   int main() {     int n, wrong = 0;     cin >> n;     for (int i = (1); i <= (n); i++) {       cin >> arr[i];     }     string s;     cin >> s;     cnt[1] = s[0] -  0 ;     for (int i = (2); i <= (n); i++) {       cnt[i] = s[i - 1] -  0 ;       cnt[i] += cnt[i - 1];     }     bool yes = 1;     for (int i = (1); i <= (n); i++) {       if (arr[i] != i) {         int has = 0;         if (arr[i] > i)           has = cnt[arr[i] - 1] - cnt[i - 1];         else           has = cnt[i - 1] - cnt[arr[i] - 1];         if (has < abs(arr[i] - i)) {           yes = 0;           break;         }       }     }     if (yes)       cout <<  YES n ;     else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   vector<int> v[maxn];   vector<int> edge[maxn];   int flag[maxn], val[2][maxn];   bool bad[maxn];   int par[maxn][20];   inline int dfs(int x, int p) {     par[x][0] = p;     for (int i = 1; i < 20; i++) par[x][i] = par[par[x][i - 1]][i - 1];     flag[x] = flag[p] + 1;     int ret = flag[x];     int cnt = 0;     for (int i = 0; i < v[x].size(); i++) {       int u = v[x][i];       if (flag[u] == 0)         ret = min(ret, dfs(u, x));       else {         if (flag[u] == flag[x] - 1)           cnt++;         else           ret = min(ret, flag[u]);       }     }     if (cnt > 1) ret = min(ret, flag[x] - 1);     bad[x] = ret == flag[x];     return ret;   }   inline int Par(int x, int k) {     for (int i = 20; i >= 0; i--)       if (k & (1 << i)) {         x = par[x][i];         k -= (1 << i);       }     return x;   }   inline int cpar(int x, int y) {     if (flag[x] < flag[y]) swap(x, y);     x = Par(x, flag[x] - flag[y]);     if (x == y) return x;     for (int i = 19; i >= 0; i--)       if (par[x][i] != par[y][i]) {         x = par[x][i];         y = par[y][i];       }     return par[x][0];   }   inline pair<int, int> dfs2(int x) {     pair<int, int> ret(0, 0);     ret.first += val[0][x];     ret.second += val[1][x];     flag[x] = true;     for (int i = 0; i < v[x].size(); i++)       if (flag[v[x][i]] == 0) {         pair<int, int> g = dfs2(v[x][i]);         ret.first += g.first;         ret.second += g.second;       }     if (bad[x] && ret.first && ret.second) {       cout <<  No ;       exit(0);     }     return ret;   }   int main() {     int n, m, q;     cin >> n >> m >> q;     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     for (int i = 1; i <= n; i++)       if (flag[i] == 0) dfs(i, 0);     while (q--) {       int x, y;       cin >> x >> y;       int u = cpar(x, y);       val[0][x]++;       val[0][u]--;       val[1][u]--;       val[1][y]++;     }     memset(flag, 0, sizeof flag);     for (int i = 1; i <= n; i++)       if (flag[i] == 0) {         pair<int, int> G = dfs2(i);         if (G.first || G.second) {           cout <<  No ;           return 0;         }       }     cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int s, n, b[7][7], a[49], used[49], n2;   bool check() {     for (int i = 0; i < (int)(n); i++) {       int sr = 0;       for (int j = 0; j < (int)(n); j++) sr += b[i][j];       if (sr != s) return false;       sr = 0;       for (int j = 0; j < (int)(n); j++) sr += b[j][i];       if (sr != s) return false;     }     int sr = 0;     for (int i = 0; i < (int)(n); i++) sr += b[i][i];     if (sr != s) return false;     sr = 0;     for (int i = 0; i < (int)(n); i++) sr += b[i][n - 1 - i];     if (sr != s) return false;     return true;   }   void rec(int i, int j, int sr) {     if (i == n) {       if (!check()) return;       for (int q = 0; q < (int)(n); q++) {         for (int w = 0; w < (int)(n); w++) {           if (w) printf(   );           printf( %d , b[q][w]);         }         printf(  n );       }       exit(0);     }     if (j == n - 1) {       int r1 = s - sr;       int r2 = r1;       int r3 = r1;       if (i == n - 1) {         r2 = 0, r3 = 0;         for (int z = 0; z < (int)(n - 1); z++) r2 += b[z][z], r3 += b[z][n - 1];         r2 = s - r2, r3 = s - r3;       }       if (r1 != r2 || r1 != r3) return;       for (int q = 0; q < (int)(n2); q++)         if (!used[q] && a[q] == r1) {           used[q] = true;           b[i][j] = a[q];           rec(i + 1, 0, 0);           used[q] = false;           break;         }       return;     }     if (i == n - 1) {       int sw = 0;       for (int z = 0; z < (int)(n - 1); z++) sw += b[z][j];       int t1 = s - sw;       int t2 = t1;       if (j == 0) {         int ss = 0;         for (int z = 0; z < (int)(n - 1); z++) ss += b[z][n - 1 - z];         t2 = s - ss;       }       if (t1 != t2) return;       for (int q = 0; q < (int)(n2); q++)         if (!used[q] && a[q] == t1) {           used[q] = true;           b[i][j] = a[q];           rec(i, j + 1, sr + a[q]);           used[q] = false;         }       return;     }     int lu = a[0] - 1;     for (int q = 0; q < (int)(n2); q++)       if (!used[q] && a[q] != lu) {         used[q] = true;         b[i][j] = lu = a[q];         rec(i, j + 1, sr + lu);         used[q] = false;       }   }   int aa(int x) { return x < 0 ? -x : x; }   int main() {     scanf( %d , &n);     n2 = n * n;     for (int i = 0; i < (int)(n2); i++) scanf( %d , &a[i]);     sort(a, a + n2);     s = 0;     for (int i = 0; i < (int)(n2); i++) s += a[i];     s /= n;     printf( %d n , s);     rec(0, 0, 0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     x = 0;     char c = getchar();     int f = 1;     while (!isdigit(c)) {       if (c ==  - ) f = -1;       c = getchar();     }     while (isdigit(c)) {       x = x * 10 + c -  0 ;       c = getchar();     }     x *= f;   }   inline unsigned int R() {     static unsigned int seed = 416;     return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;   }   const int N = 2333;   int n, l[N], r[N], a[N], s[N];   void GG() {     puts( NO );     exit(0);   }   int main() {     read(n);     for (register int i = 1; i <= n; i++) read(l[i]);     for (register int i = 1; i <= n; i++) read(r[i]);     for (register int i = 1; i <= n; i++) a[i] = n - (l[i] + r[i]);     for (register int i = 1; i <= n; i++) {       int p = 0;       for (register int j = 1; j <= i - 1; j++) p += a[j] > a[i];       if (p != l[i]) GG();       p = 0;       for (register int j = i + 1; j <= n; j++) p += a[j] > a[i];       if (p != r[i]) GG();     }     puts( YES );     for (register int i = 1; i <= n; i++) printf( %d  , a[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool vt[202][202];   int cnt, n;   int dfs(int x, int y) {     int mx1 = 0, mx2 = 0, mx = 0;     for (int i = 1; i <= n; i++)       if (vt[x][i] && i != y) {         mx = max(mx, dfs(i, x));         if (cnt > mx1)           mx2 = mx1, mx1 = cnt;         else if (cnt > mx2)           mx2 = cnt;       }     mx = max(mx, mx1 + mx2);     cnt = mx1 + 1;     return mx;   }   int main() {     ios::sync_with_stdio(0);     int x, y, m, sm = 0;     cin >> n;     for (int i = 0; i < n - 1; i++) cin >> x >> y, vt[x][y] = 1, vt[y][x] = 1;     int mx = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         int l = 0, k = 0;         if (vt[i][j]) {           l = dfs(i, j);           k = dfs(j, i);           mx = max(mx, l * k);         }       }     cout << mx;   }