malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   using pli = pair<ll, int>;   const int INF = 0x3f3f3f3f, N = 3e3 + 5;   const ll LINF = 1e18 + 5;   int n;   vector<int> G[N];   int sz[N][N], f[N][N];   ll dp[N][N], maxn;   void dfs(int u, int fa, int rt) {     sz[rt][u] = 1;     f[rt][u] = fa;     for (int v : G[u]) {       if (v == fa) continue;       dfs(v, u, rt);       sz[rt][u] += sz[rt][v];     }   }   ll solve(int u, int v) {     if (~dp[u][v]) return dp[u][v];     if (u == v) return dp[u][v] = 0;     return dp[u][v] = max(solve(f[v][u], v), solve(u, f[u][v])) +                       1ll * sz[u][v] * sz[v][u];   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       G[u].push_back(v);       G[v].push_back(u);     }     for (int i = 1; i <= n; i++) dfs(i, 0, i);     memset(dp, -1, sizeof(dp));     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) maxn = max(maxn, solve(i, j));     cout << maxn;     return 0;   }
#include <bits/stdc++.h>   constexpr int N = 55;   int n;   char a[N][N];   int f[N][N][N][N];   int dfs(int x, int y, int xx, int yy) {     if (~f[x][y][xx][yy]) {       return f[x][y][xx][yy];     } else {       if (x == xx && y == yy) {         return f[x][y][x][y] = (a[x][y] ==  # );       } else {         int res = std::max(xx - x + 1, yy - y + 1);         for (int i = x; i < xx; i++) {           res = std::min(res, dfs(x, y, i, yy) + dfs(i + 1, y, xx, yy));         }         for (int i = y; i < yy; i++) {           res = std::min(res, dfs(x, y, xx, i) + dfs(x, i + 1, xx, yy));         }         return f[x][y][xx][yy] = res;       }     }   }   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(nullptr);     memset(f, -1, sizeof f);     std::cin >> n;     for (int i = 0; i < n; i++) {       std::cin >> a[i];     }     std::cout << dfs(0, 0, n - 1, n - 1) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, n, i, a[404040], x[404004];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> t;     while (t--) {       cin >> n;       long long te = 1;       x[1] = -1;       x[2] = -1;       x[3] = -1;       long long ban = 0;       for (long long i = 1; i <= n; i++) cin >> a[i];       for (long long i = 1; (i * 2) <= n; i++) {         ban++;         if (a[i] != a[i + 1] && te == 1) {           x[te] = ban;           te++;           ban = 0;         } else if ((a[i] != a[i + 1]) && (ban > x[1])) {           x[te] = ban;           if (te == 2) {             te++;             ban = 0;           }         }       }       if ((x[3] == -1) || ((x[1] + x[2] + x[3]) * 2 > n)) {         x[1] = 0;         x[2] = 0;         x[3] = 0;       }       cout << x[1] <<     << x[2] <<     << x[3] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int N = 2e5 + 10;   char s[3][N];   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       for (int i = 1; i <= 2; i++)         for (int j = 1; j <= n; j++) {           cin >> s[i][j];           if (s[i][j] ==  1  || s[i][j] ==  2 )             s[i][j] =  1 ;           else             s[i][j] =  2 ;         }       int flag = 0, x = 1, y = 1;       for (int i = 1; i <= n; i++) {         if (s[y][i] ==  1 ) {           x++;         } else if (s[y][i] ==  2 ) {           if (y == 1 && s[y + 1][i] ==  2 ) {             y++;             x++;           } else if (y == 2 && s[y - 1][i] ==  2 ) {             y--;             x++;           } else {             flag = 1;             break;           }         }       }       if (flag)         cout <<  NO  << endl;       else if (x == n + 1 && y == 2)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int k, v, n, m, ans, sum, sum1, l, r, i, j, mx, mn, c, z, x, y,       a[111111], d[111111], t[111111];   string s, sos, ss;   char ch;   bool used[111111];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     cout << (n - 1) / 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool check(vector<int> &a) { return a[0] + a[1] + a[2] == a[3] + a[4] + a[5]; }   signed main() {     int n;     cin >> n;     vector<int> a(n, 0);     for (int i = 0; i < n; ++i) cin >> a[i], --a[i];     vector<int> used(n, 0);     int cnt = 0;     for (int i = n - 1; i > -1; --i) {       if (!used[i]) {         used[i] = 1;         int c = i;         while (a[c] > -1 && !used[a[c]]) used[a[c]] = 1, c = a[c];         ++cnt;       }     }     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int n, arr[200001], ctr[200001];     set<long int> s;     vector<long int> s2;     list<long int> s1;     memset(ctr, 0, sizeof(ctr));     cin >> n;     for (long int i = 0; i < n; i++) {       cin >> arr[i];       s.insert(arr[i]);       ctr[arr[i]]++;     }     if (s.size() == n) {       cout << 0 <<   n ;       for (long int i = 0; i < n; i++) cout << arr[i] <<    ;       return 0;     }     for (long int i = 1; i <= n; i++) {       if (!ctr[i]) s2.push_back(i);     }     sort(s2.begin(), s2.end());     for (auto it : s2) {       s1.push_back(it);     }     vector<bool> visited(n + 1, false);     cout << s2.size() <<   n ;     for (long int i = 0; i < n; i++) {       if (s1.size() == 0) break;       if (ctr[arr[i]] > 1) {         if (s1.front() < arr[i]) {           ctr[arr[i]] = ctr[arr[i]] - 1;           arr[i] = s1.front();           s1.pop_front();         } else if (s1.front() > arr[i] && visited[arr[i]] == false)           visited[arr[i]] = true;         else if (s1.front() > arr[i] && visited[arr[i]] == true) {           ctr[arr[i]] = ctr[arr[i]] - 1;           arr[i] = s1.front();           s1.pop_front();         }       }     }     for (long int i = 0; i < n; i++) cout << arr[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   template <typename T, typename U>   ostream &operator<<(ostream &os, pair<T, U> p) {     os <<  (  << p.first <<  ,  << p.second <<  ) ;     return os;   }   template <typename T, typename U>   istream &operator>>(istream &is, pair<T, U> &p) {     is >> p.first >> p.second;     return is;   }   template <typename T>   istream &operator>>(istream &is, vector<T> &v) {     for (int i = 0; i < int(v.size()); ++i) is >> v[i];     return is;   }   template <typename T>   ostream &operator<<(ostream &os, vector<T> v) {     for (T x : v) os << x <<    ;     return os;   }   template <typename T>   ostream &operator<<(ostream &os, set<T> s) {     for (T x : s) os << x <<    ;     return os;   }   template <typename T>   ostream &operator<<(ostream &os, multiset<T> s) {     for (T x : s) os << x <<    ;     return os;   }   template <typename T, typename U>   ostream &operator<<(ostream &os, map<T, U> m) {     for (auto x : m) os << x <<    ;     return os;   }   template <typename T>   T sum(vector<T> v) {     T summ = 0;     for (int i = 0; i < int(int(v.size())); ++i) summ += v[i];     return summ;   }   long long mod_pow(long long a, long long b) {     long long sol = 1;     while (b) {       if (b & 1) {         sol = (sol * a) % mod;         b--;       } else {         a = (a * a) % mod;         b /= 2;       }     }     return sol;   }   long long rem(long long a, long long b) {     long long res = a % b;     return res < 0 ? res + b : res;   }   void test_case() {     int n;     cin >> n;     vector<pair<char, int>> ops(2 * n);     for (int i = 0; i < int(2 * n); ++i) {       char type;       cin >> type;       if (type ==  + ) {         ops[i].first =  + ;       } else {         ops[i].first =  - ;         cin >> ops[i].second;       }     }     stack<int> bought;     reverse(ops.begin(), ops.end());     vector<int> answer;     for (auto p : ops) {       char type = p.first;       int buy = p.second;       if (type ==  - ) {         if (!bought.empty() && buy > bought.top()) {           cout <<  NO n ;           return;         }         bought.push(buy);       } else {         if (bought.empty()) {           cout <<  NO n ;           return;         }         answer.push_back(bought.top());         bought.pop();       }     }     reverse(answer.begin(), answer.end());     cout <<  YES n  << answer <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     for (int i = 0; i < int(t); ++i) test_case();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int W[24];   bool ok(int n) {     bool l = false;     for (int i = 0; i < 12; i++) {       bool f = true;       for (int j = 0; j < n; j++) {         if (T[i + j] != W[j]) {           if ((i + j) % 12 == 1 && W[j] == 29 && !l) {             l = true;             continue;           } else             f = false;         }       }       if (f == true) return true;     }     return false;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &W[i]);     if (ok(n))       printf( YES n );     else       printf( NO n );   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 2005;   pair<int, int> q[MAX * MAX];   char a[MAX][MAX];   int dx[4] = {-1, 0, 1, 0};   int dy[4] = {0, 1, 0, -1};   char tt[4] = { v ,  < ,  ^ ,  > };   int n, m;   bool isav(int x, int y) {     return (0 <= x && x < n && 0 <= y && y < m && a[x][y] ==  . );   }   int deg(int x, int y) {     int ans = 0;     for (int i = 0; i < 4; i++) {       int nx = x + dx[i];       int ny = y + dy[i];       if (isav(nx, ny)) ans++;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     ios::sync_with_stdio(false);     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> a[i][j];     int h = 0, t = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (isav(i, j) && deg(i, j) == 1) q[t++] = make_pair(i, j);     while (h < t) {       int x = q[h].first, y = q[h].second;       h++;       for (int i = 0; i < 4; i++) {         int nx = x + dx[i];         int ny = y + dy[i];         if (isav(nx, ny)) {           a[x][y] = tt[i];           a[nx][ny] = tt[i ^ 2];           for (int j = 0; j < 4; j++) {             int nnx = nx + dx[j];             int nny = ny + dy[j];             if (isav(nnx, nny) && deg(nnx, nny) == 1)               q[t++] = make_pair(nnx, nny);           }           break;         }       }     }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (a[i][j] ==  . ) {           cout <<  Not unique  << endl;           return 0;         }     for (int i = 0; i < n; i++, cout << endl)       for (int j = 0; j < m; j++) cout << a[i][j];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[8][8], b[8][8];   long long get() {     char c = getchar();     long long x = 0LL;     while (c <  0  || c >  9 ) c = getchar();     while (c >=  0  && c <=  9 ) {       x *= 10LL;       x += (c -  0 );       c = getchar();     }     return x;   }   int main() {     char c;     for (int i = 0; i < 8; i++)       for (int j = 0; j < 8; j++) {         cin >> c;         if (c ==  B ) a[i][j] = 1;       }     int ans = 16;     for (int i = 0; i < (1 << 8); i++)       for (int j = 0; j < (1 << 8); j++) {         for (int x = 0; x < 8; x++)           for (int y = 0; y < 8; y++) {             if (i & (1 << x) || j & (1 << y))               b[x][y] = 1;             else               b[x][y] = 0;           }         bool f = true;         for (int x = 0; x < 8; x++)           for (int y = 0; y < 8; y++)             if (b[x][y] != a[x][y]) f = false;         if (f) {           ans = min(ans, __builtin_popcount(i) + __builtin_popcount(j));         }       }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, kk, a[500010], b[500010];   int sum1[500010], sum2[500010], sum3[500010], num[500010], k1[500010],       k2[500010], k3[500010];   unordered_map<int, int> mp;   int main() {     scanf( %d%d , &n, &kk);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + 1 + n);     b[1] = a[1];     mp[b[1]] = 1;     int k = 1;     for (int i = 2; i <= n; i++) {       if (a[i] != b[k]) {         k++;         b[k] = a[i];         mp[b[k]] = k;       }     }     int p = (kk * 8) / n;     int kind = 1;     for (int i = 1; i <= p; i++) {       kind = kind * 2;       if (kind >= k) {         printf( 0 n );         return (0);       }     }     int res = k - kind;     for (int i = 1; i <= n; i++) num[mp[a[i]]]++;     for (int i = 1; i <= k; i++) {       sum1[i] = sum1[i - 1] + num[i];       k1[i] = k1[i - 1] + (num[i] > 0);     }     for (int i = k; i >= 1; i--) {       sum2[i] = sum2[i + 1] + num[i];       k2[i] = k2[i + 1] + (num[i] > 0);     }     for (int i = 1; i <= k; i++) {       sum3[i] = sum2[k - i + 1];       k3[i] = k2[k - i + 1];     }     int ans = 1e9 + 7;     for (int i = 1; i <= k; i++) {       int x = res - k1[i];       if (x <= 0) ans = min(ans, sum1[i]);       int l = lower_bound(k3 + 1, k3 + 1 + k - i, x) - k3;       if (l != k + 1 - i) {         ans = min(ans, sum1[i] + sum3[l]);       }     }     for (int i = 1; i <= k; i++) {       int x = res - k3[i];       if (x <= 0) ans = min(ans, sum3[i]);     }     printf( %d n , ans);     return (0);   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   const int N = 5e5 + 2;   int seg[N * 4];   int lazy[N * 4];   int hi[N];   int h[N];   int n;   vector<int> g[N];   vector<int> y[N];   pair<int, int> t[N];   void dfs(int v, int p) {     t[v] = t[p];     if (hi[t[v].second] > hi[v]) {       t[v].second = v;     }     if (hi[t[v].second] < hi[t[v].first]) swap(t[v].second, t[v].first);     for (auto &u : g[v]) {       if (u == p) continue;       dfs(u, v);     }   }   void upd(int nod, int l, int r, int L, int R, int val) {     if (l >= R || L >= r) return;     if (l >= L && r <= R) {       seg[nod] += val;       lazy[nod] += val;       return;     }     int mid = (r + l) >> 1;     upd(nod << 1, l, mid, L, R, val);     upd(nod << 1 | 1, mid, r, L, R, val);     seg[nod] = min(seg[nod << 1], seg[nod << 1 | 1]) + lazy[nod];   }   inline bool check(int v, int val) {     for (auto &u : y[v]) {       int x = hi[t[u].first];       int y = min(hi[t[u].second], hi[t[u].first] + val);       int z = upper_bound(h + 1, h + n + 1, x) - h;       int e = upper_bound(h + 1, h + n + 1, y) - h;       upd(1, 1, N, z, e, +1);     }     bool p1 = 0;     if (seg[1] >= 0) p1 = 1;     for (auto &u : y[v]) {       int x = hi[t[u].first];       int y = min(hi[t[u].second], hi[t[u].first] + val);       int z = upper_bound(h + 1, h + n + 1, x) - h;       int e = upper_bound(h + 1, h + n + 1, y) - h;       upd(1, 1, N, z, e, -1);     }     return p1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &hi[i]);     }     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d%d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);     }     int k;     scanf( %d , &k);     for (int i = 1; i <= k; i++) {       scanf( %d , &h[i]);     }     sort(h + 1, h + n + 1);     for (int i = n; i; i--) {       upd(1, 1, N, 1, i + 1, -1);     }     hi[0] = 1e9 + 100;     t[0] = {0, 0};     dfs(1, 0);     for (int i = 1; i <= n; i++) {       y[t[i].first].push_back(i);       int z = upper_bound(h + 1, h + n + 1, hi[t[i].first]) - h;       upd(1, 1, N, 1, z, +1);     }     int l1 = -1, r1 = 1e9 + 2;     for (int i = 1; i <= n; i++) {       int l = -1, r = r1;       if (!(check(i, r - 1))) continue;       while (r - l > 1) {         int mid = (r + l) / 2;         int z = check(i, mid);         if (z)           r = mid;         else           l = mid;       }       r1 = r;     }     if (r1 > 1e9) {       printf( %d , -1);       return 0;     }     printf( %d , r1);   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   void solve() {     ll n, k;     cin >> n >> k;     vector<ll> arr(n);     for (int i = 0; i < n; i++) cin >> arr[i];     ll dp[n][n];     for (int i = 1; i < n; i++) dp[0][i] = 0;     ll curr = 0;     for (int i = 0; i < n; i++) {       if (arr[i] == (i + 1)) curr += 1;       dp[i][0] = curr;     }     for (int i = 1; i < n; i++) {       for (int j = 1; j < n; j++) {         ll temp = (arr[i] == (i - j + 1));         dp[i][j] = max(dp[i - 1][j - 1], dp[i - 1][j] + temp);       }     }     ll ans = -1;     for (int i = 0; i < n; i++) {       if (dp[n - 1][i] >= k) {         ans = i;         break;       }     }     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int maxn = 2e5 + 1;   void solve() {     string s, even, odd;     cin >> s;     for (long long int i = 0; i < s.length(); i++) {       long long int val = s[i] -  0 ;       if (val % 2 == 0)         even += s[i];       else         odd += s[i];     }     if (odd.length() == 0) {       cout << even <<   n ;     } else if (even.length() == 0) {       cout << odd <<   n ;     } else {       long long int n1 = odd.length(), n2 = even.length();       long long int i = 0, j = 0;       while (i < n1 && j < n2) {         if (odd[i] < even[j]) {           cout << odd[i];           i++;         } else if (odd[i] > even[j]) {           cout << even[j];           j++;         } else {           cout << odd[i] << even[j];           i++;           j++;         }       }       while (i < n1) {         cout << odd[i];         i++;       }       while (j < n2) {         cout << even[j];         j++;       }       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int T = 1, p = 0;     cin >> T;     do {       solve();       p++;     } while (p < T);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     int n;     cin >> n;     vector<int> a(n);     int odd = 0;     for (auto &i : a) cin >> i, odd += i & 1;     if (odd > 0 && odd < n) sort(a.begin(), a.end());     for (auto &i : a) cout << i <<    n [&i == &a.back()];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   const int mxn = 1000001, k = 4;   const char c[k] = { ( ,  ) ,  ? ,  ? };   int n;   string second;   long long first[mxn], rf[mxn], iv[mxn], a[k];   vector<long long> dp[mxn];   long long sol() {     int x = a[2] + a[3], y = a[1] + a[3] - a[0] - 1;     if (y < 0) return 0;     if (!dp[x].empty()) return dp[x][min(x, y)];     dp[x].resize(x + 1);     dp[x][0] = 1;     for (int i = 1; i <= x; i++) {       dp[x][i] = (first[x] * rf[i] % mod * rf[x - i] + dp[x][i - 1]) % mod;     }     return dp[x][min(x, y)];   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> second;     n = second.size();     for (int i = 1; i < k; i += 2)       a[i] = count(second.begin(), second.end(), c[i]);     first[0] = rf[0] = iv[0] = 1;     for (int i = 1; i <= n; i++) {       iv[i] = ~-i ? mod - mod / i * iv[mod % i] % mod : 1;       first[i] = i * first[i - 1] % mod;       rf[i] = iv[i] * rf[i - 1] % mod;     }     long long ret = 0;     for (long long i = 0; i < n; i++) {       for (int j = 1; j < k; j += 2) a[j] -= (second[i] == c[j]);       if (!((find(c, c + k, second[i]) - c) & 1)) (ret += sol()) %= mod;       for (int j = 0; j < k; j += 2) a[j] += (second[i] == c[j]);     }     cout << ret <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char key[] =  (8[ ;     char fir[100], sec[100];     int i, len, a, b, c;     scanf( %s%s , fir, sec);     len = strlen(fir);     c = 0;     for (i = 0; i < len; i += 2) {       a = strchr(key, fir[i]) - key;       b = strchr(key, sec[i]) - key;       if (a == b) continue;       if ((a + 1) % 3 == b)         c++;       else         c--;     }     if (c > 0)       puts( TEAM 1 WINS );     else if (c < 0)       puts( TEAM 2 WINS );     else       puts( TIE );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dirx[8] = {0, 0, 1, -1, 1, 1, -1, -1};   int diry[8] = {1, -1, 0, 0, 1, -1, 1, -1};   string tostring(long long n) {     if (!n) return  0 ;     string ans =   ;     while (n != 0) {       ans += (n % 10) +  0 ;       n /= 10;     }     reverse(ans.begin(), ans.end());     return ans;   }   double toDouble(string s) {     double ans = 0;     int i = 0, flag = 0, cnt = 0, ff = 1;     while (i < s.length()) {       if (s[i] ==  - ) {         ff = -1;         i++;         continue;       }       if (s[i] ==  . ) {         flag = 1;         i++;         continue;       }       ans *= 10;       ans += s[i] -  0 ;       if (flag) cnt++;       i++;     }     ans *= ff;     return ans / pow(10, cnt);   }   int ar[1005];   int main() {     int n, a, b;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d %d , &a, &b);       ar[a]++;       ar[b]++;     }     int ans = 0;     for (int i = 1; i <= n; i++) {       ans += (ar[i] == 1);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str;     cin >> str;     cout <<  Mike n ;     int freq[26] = {0};     freq[str[0] -  a ]++;     for (int i = 1; i < str.length(); i++) {       int val = 0;       for (int j = 0; j < str[i] -  a ; j++) {         if (freq[j] > 0) {           val = 1;           break;         }       }       freq[str[i] -  a ]++;       if (val == 1) {         cout <<  Ann n ;       } else {         cout <<  Mike n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[105][105];   int main() {     vector<int> v;     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) cin >> a[i][j];       v.push_back(i);     }     int cnt = 0;     for (int i = 1; i <= n; i++) {       int flag = 0;       for (int j = 1; j <= n; j++) {         if (a[i][j] == 1 || a[i][j] == 3 || a[j][i] == 2 || a[j][i] == 3) {           flag = 1;           v[i - 1] = 0;         }       }       if (flag == 0) cnt++;     }     cout << cnt << endl;     for (auto i = v.begin(); i != v.end(); i++) {       if (*i != 0) cout << *i <<    ;     }     v.clear();   }