malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = double;   using pll = pair<ll, ll>;   using vll = vector<ll>;   using vpll = vector<pll>;   using vvll = vector<vll>;   vector<vector<ll>> g;   vector<bool> v;   ll res;   pair<bool, bool> dfs(int u, int depth) {     v[u] = true;     if (depth > 2 && g[u].size() == 1) return make_pair(false, false);     bool inSet = false;     bool isDominated = false;     for (ll i = 0; i < (ll)g[u].size(); ++i) {       if (v[g[u][i]]) continue;       auto t = dfs(g[u][i], depth + 1);       inSet |= !t.first;       isDominated |= t.second;     }     if (depth <= 1) return make_pair(true, true);     if (inSet) res++;     return make_pair(isDominated || inSet, inSet);   }   int main() {     ios::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     ll n;     cin >> n;     g = vector<vector<ll>>(n);     v = vector<bool>(n);     for (ll i = 0; i < (ll)n - 1; ++i) {       ll u, v;       cin >> u >> v;       u--;       v--;       g[u].push_back(v);       g[v].push_back(u);     }     dfs(0, 0);     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   void solve() {     long long n;     cin >> n;     vector<long long> a(n), b;     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     b = a;     sort(b.begin(), b.end());     b.resize(unique(b.begin(), b.end()) - b.begin());     for (long long i = 0; i < n; i++) {       a[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin();     }     vector<long long> dp(n, -1e9);     dp[a[0]] = 1;     for (long long i = 1; i < n; i++) {       dp[a[i]] = 1;       if (a[i]) dp[a[i]] = max(dp[a[i]], dp[a[i] - 1] + 1);     }     long long ans = n - *max_element(dp.begin(), dp.end());     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long q;     cin >> q;     while (q--) {       solve();     }   }
#include <bits/stdc++.h>   int n, up, s;   int a[20], ans[5][5], s1[5], s2[5], s3, s4, idx[1 << 16], cnt[1 << 16];   bool ans_u, vis[1 << 16];   void dfs(int sta) {     if (sta == up) {       if (ans_u) return;       printf( %d n , s);       for (int i = 0, j; i < n; ++i) {         for (j = 0; j < n; ++j) {           if (j) putchar(   );           printf( %d , ans[i][j]);         }         puts(  );       }       ans_u = 1;       return;     }     int x = cnt[sta] / n, y = cnt[sta] % n;     for (int ts = up ^ sta, t, u; ts && !ans_u; ts ^= ts & (-ts)) {       t = a[idx[ts & (-ts)]];       s1[x] += t;       s2[y] += t;       if (x == y) s3 += t;       if (x + y == n - 1) s4 += t;       u = 1;       if (y == n - 1 && s1[x] != s) u = 0;       if (x == n - 1 && s2[y] != s) u = 0;       if (x == n - 1 && y == n - 1 && s3 != s) u = 0;       if (x == n - 1 && y == 0 && s4 != s) u = 0;       if (u) {         ans[x][y] = t, dfs(sta ^ ((ts & (-ts))));       }       s1[x] -= t;       s2[y] -= t;       if (x == y) s3 -= t;       if (x + y == n - 1) s4 -= t;     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n * n; ++i) {       scanf( %d , &a[i]);       s += a[i];     }     s /= n;     up = (1 << (n * n)) - 1;     idx[1] = 0;     for (int i = 1, j = 1; i < up; idx[i <<= 1] = j++)       ;     cnt[0] = 0;     for (int i = 1; i <= up; ++i) cnt[i] = cnt[i >> 1] + (i & 1);     dfs(0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0), cin.tie(0);     int n, j = 0;     cin >> n;     int a[n], b[n];     pair<int, int> s[n];     for (auto &i : s) cin >> i.first, i.second = j++;     sort(s, s + n);     map<int, int> mp;     for (int i = 0; i < n; i++) mp[s[i].second] = i;     for (int i = 0; i < (n + 2) / 3; i++) a[i] = i;     for (int i = (n + 2) / 3; i < (2 * n + 2) / 3; i++) b[i] = i;     for (int i = n - 1; i >= (2 * n + 2) / 3; i--) b[i] = n - 1 - i;     for (int i = (n + 2) / 3; i < n; i++) a[i] = s[i].first - b[i];     for (int i = 0; i < (n + 2) / 3; i++) b[i] = s[i].first - a[i];     cout <<  YES  <<   n ;     for (int i = 0; i < n; i++) cout << a[mp[i]] <<    ;     cout <<   n ;     for (int i = 0; i < n; i++) cout << b[mp[i]] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   void populate(string& s, char c, int n) {     for (int i = 0; i < n; ++i) s[s.find_first_of( ? )] = c;   }   int main() {     ios::sync_with_stdio(0);     int n;     cin >> n;     string s;     cin >> s;     auto na = count(s.begin(), s.end(),  A );     auto nc = count(s.begin(), s.end(),  C );     auto ng = count(s.begin(), s.end(),  G );     auto nt = count(s.begin(), s.end(),  T );     auto nq = count(s.begin(), s.end(),  ? );     auto m = max(na, max(nc, (max(ng, nt))));     auto da = m - na;     auto dc = m - nc;     auto dg = m - ng;     auto dt = m - nt;     if (nq < da + dc + dg + dt) {       cout <<  ===  << endl;     } else if ((nq - (da + dc + dg + dt)) % 4 != 0) {       cout <<  ===  << endl;     } else {       populate(s,  A , da);       populate(s,  C , dc);       populate(s,  G , dg);       populate(s,  T , dt);       for (int i = 0; i < (nq - (da + dc + dg + dt)); i += 4) {         populate(s,  A , 1);         populate(s,  C , 1);         populate(s,  G , 1);         populate(s,  T , 1);       }       cout << s << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long k;       vector<long long> ans;       if (n > 3) {         if (n % 2 == 1)           k = n - 1;         else           k = n;         while (k > 0) {           if (k == 4) ans.push_back(2);           if (k == 2) ans.push_back(4);           if (k != 4 && k != 2) ans.push_back(k);           k -= 2;         }         k = 1;         while (k <= n) {           ans.push_back(k);           k += 2;         }         for (auto u : ans) cout << u <<    ;         cout << endl;       } else {         cout <<  -1  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int n, r;     cin >> n >> r;     double alpha = 90.0 - 180.0 / n;     double val = cos(alpha * 3.14159265 / 180.0);     double ans = val * (double)r / (1 - val);     cout << fixed << setprecision(6) << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int d[3000], g[3000], q[3000];   int i, j, k, m, n, r, t;   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) {       scanf( %d , &g[i]);       if (g[i] <= m)         d[g[i]]++;       else         r++;     }     for (k = 0;; k++) {       t = 1;       for (i = 2; i <= m; i++)         if (d[i] < d[t]) t = i;       if (d[t] == n / m) break;       d[t]++;       if (r)         r--;       else {         t = 1;         for (i = 2; i <= m; i++)           if (d[i] > d[t]) t = i;         d[t]--;       }     }     printf( %d %d n , n / m, k);     for (i = 1; i <= n; i++)       if ((g[i] <= m) && (d[g[i]])) {         q[i] = g[i];         d[g[i]]--;       } else if ((g[i] > m) && (r)) {         q[i] = g[i];         r--;       }     for (i = 1; i <= n; i++)       if (q[i])         printf( %d  , q[i]);       else         for (j = 1; j <= m; j++)           if (d[j]) {             printf( %d  , j);             d[j]--;             break;           }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100009;   int acc[MAXN], sav[MAXN];   int extr(string &s) {     int num = 0;     for (int i = 1; i < s.length(); i++) {       num *= 10;       num += (s[i] -  0 );     }     return num;   }   int main() {     int n, m;     scanf( %d , &n);     scanf( %d , &m);     int pl = 0, mn = 0;     vector<string> statements;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       statements.push_back(s);       int z = extr(s);       if (s[0] ==  + )         acc[z]++, pl++;       else         sav[z]++, mn++;     }     set<int> Suspects;     for (int i = 1; i < n + 1; i++) {       int tr = acc[i] + mn - sav[i];       if (tr == m) {         Suspects.insert(i);       }     }     for (int i = 0; i < n; i++) {       string s = statements[i];       int z = extr(s);       if (s[0] ==  + ) {         if (Suspects.find(z) == Suspects.end()) {           cout <<  Lie  <<   n ;           continue;         }         if (Suspects.size() == 1) {           cout <<  Truth  <<   n ;         } else {           cout <<  Not defined  <<   n ;         }       } else {         if (Suspects.size() == 1 && Suspects.find(z) != Suspects.end()) {           cout <<  Lie  <<   n ;           continue;         }         if (Suspects.find(z) == Suspects.end()) {           cout <<  Truth  <<   n ;           continue;         } else           cout <<  Not defined  <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 1e6 + 1e5 + 5;   struct Node {     int len, pa;     int trans[26];   } st[maxN + 1];   int n, m, last, cnt;   int L[11], R[11];   int sum[11][maxN + 1];   char s[maxN + 1];   vector<int> son[maxN + 1];   inline int insert(int c) {     if (st[last].trans[c] && st[st[last].trans[c]].len == st[last].len + 1)       return st[last].trans[c];     int np = ++cnt, p = last, f = np;     st[np].len = st[p].len + 1;     while (p && !st[p].trans[c]) st[p].trans[c] = np, p = st[p].pa;     if (!p)       st[np].pa = 1;     else {       int q = st[p].trans[c];       if (st[q].len == st[p].len + 1)         st[np].pa = q;       else {         int nq = ++cnt;         if (p == last) f = nq;         st[nq] = st[q];         st[nq].len = st[p].len + 1;         st[np].pa = st[q].pa = nq;         while (p && st[p].trans[c] == q) st[p].trans[c] = nq, p = st[p].pa;       }     }     return f;   }   inline void calc(int u) {     for (int i = 0; i < son[u].size(); i++) {       int v = son[u][i];       calc(v);       for (int j = 0; j <= m; j++) sum[j][u] += sum[j][v];     }   }   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     last = cnt = 1;     for (int i = 1; i <= n; i++) last = insert(s[i] -  a ), sum[0][last]++;     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       scanf( %s %d %d , s + 1, &L[i], &R[i]);       int len = strlen(s + 1);       last = 1;       for (int j = 1; j <= len; j++) last = insert(s[j] -  a ), sum[i][last]++;     }     for (int i = 1; i <= cnt; i++) son[st[i].pa].push_back(i);     calc(1);     long long ans = 0;     for (int i = 2; i <= cnt; i++) {       if (!sum[0][i]) continue;       bool flag = true;       for (int j = 1; j <= m; j++)         if (sum[j][i] < L[j] || sum[j][i] > R[j]) {           flag = false;           break;         }       if (flag) ans += st[i].len - st[st[i].pa].len;     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long linf = 4000000000000000000LL;   const long long inf = 1000000007;   void pv(vector<int> a) {     for (auto& x : a) cout << x <<    ;     cout << endl;   }   void pv(vector<long long> a) {     for (auto& x : a) cout << x <<    ;     cout << endl;   }   void pv(vector<vector<int>> a) {     for (int i = (0); i < (int(a.size())); ++i) {       cout << i << endl;       pv(a[i]);       cout << endl;     }   }   void pv(vector<vector<long long>> a) {     for (int i = (0); i < (int(a.size())); ++i) {       cout << i << endl;       pv(a[i]);     }     cout << endl;   }   void pv(vector<string> a) {     for (auto& x : a) cout << x << endl;     cout << endl;   }   void setIO(string second) {     ios_base::sync_with_stdio(0);     cin.tie(0);   }   int n, k;   vector<pair<long long, long long>> a;   void init() {     vector<pair<long long, long long>> t;     for (auto& x : a)       if (x.first == 0 && x.second == 0)         k--, n--;       else         t.push_back(x);     a = t;   }   bool check(long double r) {     long double pi = acos(-1);     vector<pair<long double, int>> ranges;     for (int i = (0); i < (n); ++i) {       long double d = sqrt(a[i].first * a[i].first + a[i].second * a[i].second);       if (d > 2 * r) continue;       long double theta = acos(d / (2 * r));       long double theta1 = atan((long double)a[i].second / a[i].first);       if (theta1 < 0 || (theta1 == 0 && a[i].first < 0)) theta1 += pi;       if (a[i].second < 0) theta1 += pi;       long double x = theta1 - theta, y = theta1 + theta;       if (x < 0 && y >= 0) {         ranges.push_back({x + 2 * pi, 1});         ranges.push_back({2 * pi, -1});         ranges.push_back({0, 1});         ranges.push_back({y, -1});       } else if (x < 2 * pi && y >= 2 * pi) {         ranges.push_back({x, 1});         ranges.push_back({2 * pi, -1});         ranges.push_back({0, 1});         ranges.push_back({y - 2 * pi, -1});       } else {         ranges.push_back({x, 1});         ranges.push_back({y, -1});       }     }     sort(ranges.begin(), ranges.end(),          [](pair<long double, int> x, pair<long double, int> y) {            if (x.first == y.first) return x.second > y.second;            return x.first < y.first;          });     int m = 0;     int cur = 0;     for (auto& x : ranges) {       cur += x.second;       m = max(m, cur);     }     return m >= k;   }   int main() {     setIO( test1 );     cin >> n >> k;     a.resize(n);     for (auto& x : a) cin >> x.first >> x.second;     init();     long double l = 0, r = 222222;     for (int i = (0); i < (31); ++i) {       long double m = (l + r) / 2;       if (check(m))         r = m;       else         l = m;     }     cout << setprecision(20) << l << endl;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());   const long long G = 300005, BASE = 666667, M1 = 2e9 + 11, M2 = 1e9 + 9;   long long IB1, IB2;   long long a, o;   long long m[G], pwb1[G], pwb2[G];   long long binpow(long long x, long long k, long long mod) {     long long res = 1;     for (; k; k >>= 1) {       if (k & 1) res = res * x % mod;       x = x * x % mod;     }     return res;   }   long long modInv(long long x, long long mod) { return binpow(x, mod - 2, mod); }   void rec(long long l, long long r) {     long long d = r - l + 1;     if (d < 2) return;     long long md = (l + r) / 2;     vector<pair<long long, long long> > hl, hr;     vector<long long> stq;     for (long long q = md, hs1 = 0, hs2 = 0; q >= l; q--) {       if (stq.size() && stq.back() == m[q]) {         hs1 = (hs1 - m[q] + M1) % M1;         hs1 = hs1 * IB1 % M1;         hs2 = (hs2 - m[q] + M2) % M2;         hs2 = hs2 * IB2 % M2;         stq.pop_back();       } else {         stq.push_back(m[q]);         hs1 = (hs1 * BASE + m[q]) % M1;         hs2 = (hs2 * BASE + m[q]) % M2;       }       hl.push_back({hs1, hs2});     }     stq.clear();     for (long long q = md + 1, hs1 = 0, hs2 = 0; q <= r; q++) {       if (stq.size() && stq.back() == m[q]) {         hs1 = (hs1 - m[q] + M1) % M1;         hs1 = hs1 * IB1 % M1;         hs2 = (hs2 - m[q] + M2) % M2;         hs2 = hs2 * IB2 % M2;         stq.pop_back();       } else {         stq.push_back(m[q]);         hs1 = (hs1 * BASE + m[q]) % M1;         hs2 = (hs2 * BASE + m[q]) % M2;       }       hr.push_back({hs1, hs2});     }     sort(hl.begin(), hl.end());     sort(hr.begin(), hr.end());     for (pair<long long, long long> i : hl) {       o += upper_bound(hr.begin(), hr.end(), i) -            lower_bound(hr.begin(), hr.end(), i);     }     rec(l, md);     rec(md + 1, r);   }   long long solve() {     cin >> a;     for (int q = 0; q < a; q++) cin >> m[q];     o = 0;     rec(0, a - 1);     return o;   }   int main() {     cin.tie(0);     cout.tie(0);     cin.sync_with_stdio(0);     cout.sync_with_stdio(0);     ;     IB1 = modInv(BASE, M1);     IB2 = modInv(BASE, M2);     pwb1[0] = 1;     pwb2[0] = 1;     for (int q = 1; q < G; q++) pwb1[q] = pwb1[q - 1] * BASE % M1;     for (int q = 1; q < G; q++) pwb2[q] = pwb2[q - 1] * BASE % M2;     int z;     cin >> z;     for (; z--;) {       cout << solve() <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long unorder(int n) {     if (n == 0) return 1;     if (n == 1) return 0;     bool good;     long long ans = 0;     vector<int> V(n);     for (int i = 0; i < n; i++) V[i] = i;     do {       good = true;       for (int i = 0; i < n && good; i++) good = (V[i] != i);       if (good) ans++;     } while (next_permutation(V.begin(), V.end()));     return ans;   }   long long newton(int n, int k) {     if (k > n) return 0;     if (2 * k > n) k = n - k;     long long ans = 1;     for (int i = n - k + 1; i <= n; i++) ans *= i;     for (int i = 1; i <= k; i++) ans /= i;     return ans;   }   int main() {     int n, k;     long long ans = 0;     cin >> n >> k;     for (int i = 0; i <= k; i++) {       long long unorders = unorder(i), combinations = newton(n, n - i);       ans += combinations * unorders;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dist[100010], n;   vector<pair<int, int> > gr[100010];   void dfs() {     memset(dist, -1, sizeof(dist));     dist[1] = 0;     queue<int> q;     q.push(1);     while (!q.empty()) {       int u = q.front();       q.pop();       for (int i = 0; i < gr[u].size(); i++) {         int next = gr[u][i].first;         if (dist[next] == -1) {           dist[next] = dist[u] + 1;           q.push(next);         }       }     }   }   vector<pair<int, pair<int, int> > > ans;   int v_ans = 0;   int dp[100010];   map<pair<int, int>, int> mark;   int calc_dp(int u) {     if (dp[u] != -1) return dp[u];     if (u == 1) return dp[u] = 0;     for (int i = 0; i < gr[u].size(); i++) {       int next = gr[u][i].first;       if (dist[next] == dist[u] - 1)         dp[u] = max(dp[u], calc_dp(next) + gr[u][i].second);     }     return dp[u];   }   void calc_ans(int u) {     if (u == 1) {       return;     }     for (int i = 0; i < gr[u].size(); i++) {       int next = gr[u][i].first;       if (dist[next] == dist[u] - 1 && dp[next] == dp[u] - gr[u][i].second) {         calc_ans(next);         mark[{min(next, u), max(next, u)}] = 1;         break;       }     }   }   int main() {     ios::sync_with_stdio(false);     memset(dp, -1, sizeof(dp));     int m;     cin >> n >> m;     int cont = 0;     vector<pair<int, pair<int, int> > > edges;     for (int i = 0; i < m; i++) {       int a, b, z;       cin >> a >> b >> z;       cont += z;       gr[a].push_back({b, z});       gr[b].push_back({a, z});       edges.push_back({z, {min(a, b), max(a, b)}});     }     dfs();     int v = calc_dp(n);     cout << (cont - v) + (dist[n] - v) << endl;     calc_ans(n);     for (int i = 0; i < m; i++) {       if (edges[i].first == 1 && !mark[edges[i].second])         cout << edges[i].second.first <<     << edges[i].second.second <<   0 n ;       if (edges[i].first == 0 && mark[edges[i].second])         cout << edges[i].second.first <<     << edges[i].second.second <<   1 n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a, b;   vector<pair<int, int> > x[255][4005];   int main() {     scanf( %d n , &n);     for (int i = 0; i < n; i++) {       scanf( %d %d n , &a, &b);       x[a / 4000][b / 250].push_back(make_pair(a, i + 1));     }     for (int i = 0; i < 252; i++) {       for (int j = 0; j < 4002; j++)         if (!x[i][j].empty()) {           sort(x[i][j].begin(), x[i][j].end());           for (size_t k = 0; k < x[i][j].size(); k++)             printf( %d  , x[i][j][k].second);         }       i++;       for (int j = 4001; j >= 0; j--)         if (!x[i][j].empty()) {           sort(x[i][j].begin(), x[i][j].end());           for (size_t k = 0; k < x[i][j].size(); k++)             printf( %d  , x[i][j][k].second);         }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k;     cin >> k;     vector<vector<int> > v = {{1}};     for (int i = 0; i < k; i++) {       int current = v.size();       for (int j = 0; j < current; j++) {         vector<int> vnew(2 * current);         for (int l = 0; l < current; l++) {           vnew[l] = v[j][l];           vnew[current + l] = v[j][l];           v[j].push_back(-v[j][l]);         }         v.push_back(vnew);       }     }     for (int i = 0; i < v.size(); i++) {       for (int j = 0; j < v[i].size(); j++) {         cout << ((v[i][j] == 1) ?  +  :  * );       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   namespace IO {   template <typename t>   inline void read(t& x) {     x = 0;     bool f = 1;     char ch;     for (ch = getchar(); ch <  0  ||  9  < ch; ch = getchar())       if (ch ==  - ) f ^= 1;     for (;  0  <= ch && ch <=  9 ; ch = getchar())       x = (x << 3) + (x << 1) + (ch ^ 48);     x = f ? x : -x;   }   }  // namespace IO   const int MAXN = 50 + 10;   const int CHAR_RANGE = 26 + 10;   int n, len[2], f[MAXN][MAXN];   bool can[2][MAXN][MAXN][CHAR_RANGE];   char str[2][MAXN], tmp[10];   vector<int> trans[CHAR_RANGE], rtrans[CHAR_RANGE * CHAR_RANGE + 100];   void calc(int _) {     for (int i = (1), iend = (len[_]); i <= iend; ++i)       can[_][i][i][str[_][i] -  a ] = true;     for (int l = (2), lend = (len[_]); l <= lend; ++l) {       for (int i = (1), iend = (len[_] - l + 1); i <= iend; ++i) {         int j = i + l - 1;         for (int k = (i), kend = (j - 1); k <= kend; ++k)           for (int ch1 = (0), ch1end = (25); ch1 <= ch1end; ++ch1)             if (can[_][i][k][ch1])               for (int ch2 = (0), ch2end = (25); ch2 <= ch2end; ++ch2) {                 if (can[_][k + 1][j][ch2]) {                   for (int x : rtrans[26 * ch1 + ch2]) can[_][i][j][x] = true;                 }               }       }     }   }   int main() {     scanf( %s , str[0] + 1), scanf( %s , str[1] + 1);     len[0] = strlen(str[0] + 1), len[1] = strlen(str[1] + 1);     IO::read(n);     for (int i = (1), iend = (n); i <= iend; ++i) {       scanf( %s , tmp + 1);       rtrans[26 * (tmp[4] -  a ) + tmp[5] -  a ].push_back(tmp[1] -  a );     }     memset(f, -1, sizeof f);     f[0][0] = 0;     calc(0), calc(1);     for (int i = (1), iend = (len[0]); i <= iend; ++i)       for (int j = (1), jend = (len[1]); j <= jend; ++j) {         f[i][j] = 1e9;         for (int i2 = (0), i2end = (i - 1); i2 <= i2end; ++i2)           for (int j2 = (0), j2end = (j - 1); j2 <= j2end; ++j2)             if (f[i2][j2] != -1)               for (int ch1 = (0), ch1end = (25); ch1 <= ch1end; ++ch1) {                 if (can[0][i2 + 1][i][ch1] && can[1][j2 + 1][j][ch1]) {                   f[i][j] = min(f[i2][j2] + 1, f[i][j]);                 }               }         if (f[i][j] == 1e9) f[i][j] = -1;       }     printf( %d n , f[len[0]][len[1]]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char **argv) {     int n, h;     cin >> n >> h;     bool flag;     for (int k = 0; k < n; k++) {       flag = false;       for (int j = 0; j < n; j++) {         if (flag) cout <<    ;         flag = true;         if (j == k)           cout << h;         else           cout <<  0 ;       }       cout << endl;     }     return 0;   }