malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int DEBUG = 0;   bool isss(vector<int> s1, vector<int> s2) {     int si1, si2;     si1 = s1.size();     si2 = s2.size();     for (int i = 0; i < si1; i++) {       bool ttt = false;       for (int j = 0; j < si2; j++) {         if (s1[i] == s2[j]) {           ttt = true;         }       }       if (!ttt) return false;     }     return true;   }   int main(int argc, char **argv) {     DEBUG = (argc >= 2) ? atoi(argv[1]) : 0;     int n;     cin >> n;     int m[n];     vector<int> a[n];     for (int i = 0; i < n; i++) {       cin >> m[i];       for (int j = 0; j < m[i]; j++) {         int tmp;         cin >> tmp;         a[i].push_back(tmp);       }     }     bool isp[n];     for (int i = 0; i < n; i++) isp[i] = true;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (i != j) {           if (isss(a[i], a[j])) {             isp[j] = false;           }         }       }     }     for (int i = 0; i < n; i++)       if (isp[i])         cout <<  YES  << endl;       else         cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int arr[3][3];     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) cin >> arr[i][j];     }     bool chk[3][3];     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) chk[i][j] = 1;     }     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         if (arr[i][j] % 2 == 0)           continue;         else {           if (chk[i][j] == 1)             chk[i][j] = 0;           else             chk[i][j] = 1;           if (j + 1 <= 2) {             if (chk[i][j + 1] == 1)               chk[i][j + 1] = 0;             else               chk[i][j + 1] = 1;           }           if (j - 1 >= 0) {             if (chk[i][j - 1] == 1)               chk[i][j - 1] = 0;             else               chk[i][j - 1] = 1;           }           if (i + 1 <= 2) {             if (chk[i + 1][j] == 1)               chk[i + 1][j] = 0;             else               chk[i + 1][j] = 1;           }           if (i - 1 >= 0) {             if (chk[i - 1][j] == 1)               chk[i - 1][j] = 0;             else               chk[i - 1][j] = 1;           }         }       }     }     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         cout << chk[i][j];       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = (long long)1e5 + 10;   vector<long long> G[MAXN];   pair<long long, long long> p;   vector<long long> v;   long long n, x, y, k, ans, sum, flag;   string s;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x >> y;       v.push_back(x);       v.push_back(y);     }     cin >> k;     long long i = 0;     while (!flag) {       if (v[i] < k) {         i++;       } else {         flag = 1;         i--;       }     }     cout << n - (i + 1) / 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, i, j, k;     cin >> n;     vector<string> v;     vector<pair<int, string> > v1;     for (i = 0; i < n; i++) {       string s;       cin >> s;       v.push_back(s);       v1.push_back(make_pair(s.length(), s));     }     sort(v1.begin(), v1.end());     int flag = 1;     for (i = n - 1; i >= 0; i--) {       pair<int, string> temp = v1[i];       string s = temp.second;       for (j = 0; j < i; j++) {         pair<int, string> temp1 = v1[j];         string s1 = temp1.second;         if (s.length() != s1.length()) {           if (s.find(s1) != std::string::npos)             continue;           else {             flag = 0;             break;           }         } else {           if (s != s1) {             flag = 0;             break;           }         }       }       if (flag == 0) break;     }     if (flag == 0)       cout <<  NO n ;     else {       cout <<  YES n ;       for (i = 0; i < n; i++) cout << v1[i].second <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, i, sum = 0, x, count = 0;     cin >> n;     long long int a[n];     for (i = 0; i < n; i++) {       cin >> a[i];       sum = sum + a[i];     }     sort(a, a + n);     if (sum % 2 == 0) {       cout << sum;       return 0;     } else {       for (i = 0; i < n; i++) {         x = sum - a[i];         if (x % 2 == 0) {           cout << x;           return 0;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   bool m(int i, int j) { return (i % 10) > (j % 10); }   int main() {     int x, y;     cin >> y >> x;     vector<int> vi;     int i = 0, j = 0;     int k = 0;     for (i = 0; i < y; i++) {       cin >> j;       k += (j % 10);       vi.push_back(j);     }     sort(vi.begin(), vi.begin() + y, m);     for (i = 0; i < y && x > 0; i++) {       k = (10 - (vi[i] % 10));       if (x >= k && (vi[i] + k) <= 100) {         x -= k;         vi[i] += k;       }     }     for (i = 0; i < y && x > 0; i++) {       while ((vi[i] < 100) && (x >= 10)) {         vi[i] += 10;         x -= 10;       }     }     k = 0;     for (i = 0; i < y; i++) k += vi[i] / 10;     cout << k <<    ;     return EXIT_SUCCESS;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unsigned long long y = 0;     unsigned int x = 0;     int i;     string s;     cin >> s;     if (s.length() > 19)       printf( BigInteger n );     else if (s.length() > 10) {       y = 0;       for (i = 0; i < s.length(); i++) {         if (y > 0) y *= 10;         y += s[i] -  0 ;       }       if (y > 9223372036854775807)         printf( BigInteger n );       else         printf( long n );     } else if (s.length() > 5) {       y = 0;       for (i = 0; i < s.length(); i++) {         if (y > 0) y *= 10;         y += s[i] -  0 ;       }       if (y > 2147483647)         printf( long n );       else         printf( int n );     } else if (s.length() > 3) {       y = 0;       for (i = 0; i < s.length(); i++) {         if (y > 0) y *= 10;         y += s[i] -  0 ;       }       if (y > 32767)         printf( int n );       else         printf( short n );     } else if (s.length() > 0) {       y = 0;       for (i = 0; i < s.length(); i++) {         if (y > 0) y *= 10;         y += s[i] -  0 ;       }       if (y > 127)         printf( short n );       else         printf( byte n );     } else       printf( byte n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, a, sum = 0, p = 0, res = 0;     map<long long, long long> m;     cin >> n;     m[0] = 1;     for (long long i = 1; i <= n; i++) {       cin >> a;       sum += a;       p = max(p, m[sum]);       res += i - p;       m[sum] = i + 1;     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   int lo[N];   int n, r[N], lb[N], rb[N], i, j, k;   struct ST {     pair<int, int> f[20][N];     function<pair<int, int>(pair<int, int>, pair<int, int>)> uni;     void ini(int* a) {       for (int i = 1; i <= n * 3; ++i) f[0][i] = {a[i], i};       for (int i = 1; (1 << i) <= n * 3; ++i)         for (int j = 1; j + (1 << i) - 1 <= n * 3; ++j)           f[i][j] = uni(f[i - 1][j], f[i - 1][j + (1 << i - 1)]);     }     inline pair<int, int> ask(int x, int y) {       int l = lo[y - x + 1];       return uni(f[l][x], f[l][y - (1 << l) + 1]);     }   } ss[2];   int anc[2][20][N];   inline int calc(int x, int y) {     int x1, y1, step = 0, x2, y2;     x1 = ss[0].ask(x, y).second;     y1 = ss[1].ask(x, y).second;     for (int i = 19; i >= 0; --i) {       x2 = anc[0][i][x1];       y2 = anc[1][i][y1];       if (rb[y2] - lb[x2] + 1 >= n ||           (lb[x2] < x && ss[1].ask(lb[x2], x - 1).first > y) ||           (y < rb[y2] && ss[0].ask(y + 1, rb[y2]).first < x))         continue;       step += 1 << i;       x1 = x2;       y1 = y2;     }     x1 = lb[x1];     y1 = rb[y1];     ++step;     return y1 - x1 + 1 >= n ? step : calc(x1, y1) + step;   }   int main() {     for (i = 2; i < N; ++i) lo[i] = lo[i >> 1] + 1;     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (i = 1; i <= n; ++i) cin >> r[i], r[i + n] = r[i + n * 2] = r[i];     for (i = 1; i <= n * 3; ++i)       lb[i] = max(1, i - r[i]), rb[i] = min(n * 3, i + r[i]);     ss[0].uni = [&](pair<int, int> a, pair<int, int> b) { return min(a, b); };     ss[1].uni = [&](pair<int, int> a, pair<int, int> b) { return max(a, b); };     ss[0].ini(lb);     ss[1].ini(rb);     for (i = 1; i <= n * 3; ++i)       anc[0][0][i] = ss[0].ask(lb[i], rb[i]).second,       anc[1][0][i] = ss[1].ask(lb[i], rb[i]).second;     for (k = 0; k < 2; ++k)       for (i = 1; i < 20; ++i)         for (j = 1; j <= n * 3; ++j)           anc[k][i][j] = anc[k][i - 1][anc[k][i - 1][j]];     for (i = n + 1; i <= n * 2; ++i) cout << (n == 1 ? 0 : calc(i, i)) <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Fast() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   int gcd(int a, int b) {     if (b == 0) return a;     gcd(b, a % b);   }   int lcm(int a, int b) { return a * b / gcd(a, b); }   int main() {     Fast();     string s;     cin >> s;     int cnt = 0;     while (s.size() >= 2) {       int n = 0;       for (int i = 0; i < s.length(); i++) n += s[i] -  0 ;       s = to_string(n);       cnt++;     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   const int inf = 0x7fffffff;   const int maxn = 505;   const long long mod = 1e9 + 7;   long long dp[maxn][maxn];   int n;   int main() {     ios::sync_with_stdio(false);     cin >> n;     dp[1][1] = dp[1][0] = 1;     for (int i = 2; i <= n; i++) {       for (int j = 0; j <= n; j++) {         for (int k = 0; k + j <= n; k++) {           long long x = (dp[i - 1][j] * dp[i - 1][k]) % mod;           dp[i][k + j] += x * (2 * (k + j) + 1);           dp[i][k + j] %= mod;           dp[i][k + j + 1] = (dp[i][k + j + 1] + x) % mod;           dp[i][k + j - 1] += x * (k + j) * (k + j - 1);           dp[i][k + j - 1] %= mod;         }       }     }     cout << dp[n][1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int n, i, d;     cin >> n;     long int a[n], b[n], c[1000000];     for (i = 0; i < n; i++) {       cin >> a[i];     }     for (i = 0; i < n; i++) {       cin >> b[i];       c[b[i]] = i;     }     d = 0;     for (i = 1; i < n; i++) {       if (c[a[i]] < c[a[i - 1]]) {         d++;         c[a[i]] = c[a[i - 1]];       }     }     cout << d;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> per, obs;   long long n, k, p;   bool check(long long t) {     long long i = 0;     for (long long j = 0; j <= obs.size() - 1; j++) {       if (abs(per[i] - obs[j]) + abs(p - obs[j]) <= t) {         i++;         if (i == n) return 1;       }     }     return 0;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     t = 1;     for (long long test = 1; test <= t; test++) {       cin >> n >> k >> p;       per.resize(n);       obs.resize(k);       for (long long i = 0; i <= n - 1; i++) cin >> per[i];       for (long long i = 0; i <= k - 1; i++) cin >> obs[i];       sort(per.begin(), per.end());       sort(obs.begin(), obs.end());       long long ans = 1e10, st = 0, end = 1e10;       while (st <= end) {         long long mid = (st + end) >> 1;         if (check(mid)) {           ans = min(ans, mid);           end = mid - 1;         } else           st = mid + 1;       }       cout << ans;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void prt(long x) { cerr << x; }   void prt(long long x) { cerr << x; }   void prt(unsigned x) { cerr << x; }   void prt(unsigned long x) { cerr << x; }   void prt(unsigned long long x) { cerr << x; }   void prt(float x) { cerr << x; }   void prt(double x) { cerr << x; }   void prt(long double x) { cerr << x; }   void prt(char x) { cerr <<      << x <<     ; }   void prt(const char *x) { cerr <<     << x <<    ; }   void prt(const string &x) { cerr <<     << x <<    ; }   void prt(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void prt(const pair<T, V> &x) {     cerr <<  { ;     prt(x.first);     cerr <<  , ;     prt(x.second);     cerr <<  } ;   }   template <typename T>   void prt(const T &x) {     long long f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), prt(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     prt(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   void err(istream_iterator<string> it) {}   template <typename T, typename... brgs>   void err(istream_iterator<string> it, T a, brgs... args) {     cerr << *it <<   =   << a << endl;     err(++it, args...);   }   long long kadane(long long *a, long long n) {     long long max_so_far = INT_MIN, max_ending_here = 0;     for (__typeof(n) i = (0); i != (n); i += 1 - 2 * ((0) > (n))) {       max_ending_here += a[i];       max_so_far = max(max_so_far, max_ending_here);       if (max_ending_here < 0) max_ending_here = 0;     }     return max_so_far;   }   void solve() {     long long n;     cin >> n;     double ans = 1.0 / tan(3.1415926535897932384626 / (2 * n));     cout << fixed;     cout << setprecision(10) << ans << endl;     return;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > ed[200005];   int n, m, k;   unsigned long long Hash[200005];   unsigned long long H = 1e9 + 7;   unsigned long long a[10][10];   unsigned long long sum;   long long ans = 0;   void dfs(int kk1, unsigned long long s) {     if (kk1 == k) {       if (s == sum) {         ans += 1;       }       return;     }     for (int i = 0; i < kk1 + 1; i++) {       dfs(kk1 + 1, s + a[kk1 + 1][i]);     }   }   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       ed[u].push_back(make_pair(w, v));     }     for (int i = 1; i <= n; i++) {       sort(ed[i].begin(), ed[i].end());     }     Hash[1] = 1;     sum = 1;     for (int i = 2; i <= n; i++) {       Hash[i] = Hash[i - 1] * H;       sum += Hash[i];     }     for (int i = 1; i <= n; i++) {       int tp = ed[i].size();       for (int j = 0; j < tp; j++) {         int tpp = ed[i][j].second;         a[tp][j] += Hash[tpp];       }     }     dfs(1, a[1][0]);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int compare(const void *a, const void *b) {     int A = *((int *)a);     int B = *((int *)b);     return B - A;   }   int main() {     long long a[200000], b, c = 0, d, f = 0, i, j, k, n, m, p = 0, q = 0, r,                             t = 0, l, mid = 0, sum = 0, x, y, s = 0;     string ch[3000][2];     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     i = 0;     j = n - 1;     while (i <= j) {       c++;       if (c % 2 != 0) {         if (a[i] > a[j]) {           s = s + a[i];           i++;         } else {           s = s + a[j];           j--;         }       } else {         if (a[i] > a[j]) {           f = f + a[i];           i++;         } else {           f = f + a[j];           j--;         }       }     }     cout << s <<     << f;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int arr[n + 2];     vector<int> s;     s.push_back(n);     for (int i = 2; i < n + 1; i++) cin >> arr[i];     arr[1] = 0;     int k = n;     while (k > 0) {       s.push_back(arr[k]);       k = arr[k];     }     for (int i = s.size() - 2; i > -1; i--) {       cout << s[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long c[105], x[105][105], dp[105][105][105];   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, m, k, i, j, l, p, ans = 10000000000000000;     cin >> n >> m >> k;     for (i = 1; i <= n; i++) cin >> c[i];     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) cin >> x[i][j];     for (i = 0; i <= 100; i++)       for (j = 0; j <= 100; j++)         for (l = 0; l <= 100; l++) dp[i][j][l] = 10000000000000000;     if (c[1] == 0) {       for (i = 1; i <= m; i++) dp[1][1][i] = x[1][i];     } else       dp[1][1][c[1]] = 0;     for (i = 2; i <= n; i++) {       if (c[i] == 0) {         for (p = 1; p <= k; p++) {           for (j = 1; j <= m; j++) {             for (l = 1; l <= m; l++) {               if (j == l) {                 dp[i][p][l] = min(dp[i][p][l], dp[i - 1][p][j] + x[i][l]);               } else {                 dp[i][p + 1][l] = min(dp[i][p + 1][l], dp[i - 1][p][j] + x[i][l]);               }             }           }         }       } else {         for (p = 1; p <= k; p++) {           for (j = 1; j <= m; j++) {             if (j == c[i]) {               dp[i][p][c[i]] = min(dp[i][p][c[i]], dp[i - 1][p][j]);             } else {               dp[i][p + 1][c[i]] = min(dp[i][p + 1][c[i]], dp[i - 1][p][j]);             }           }         }       }     }     if (c[n] == 0) {       for (i = 1; i <= m; i++) ans = min(ans, dp[n][k][i]);     } else       ans = dp[n][k][c[n]];     if (ans != 10000000000000000)       cout << ans;     else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = (int)1e6;   vector<int> g[MAXN + 1];   pair<int, int> arr[MAXN + 1];   int k;   void dfs(int nod, int par, int lvl) {     arr[nod] = {2 * MAXN, 0};     for (auto it : g[nod]) {       if (it != par) {         dfs(it, nod, lvl + 1);         if (lvl >= arr[it].first) {           arr[nod].first = min(arr[nod].first, arr[it].first);           arr[nod].second += arr[it].second;         }       }     }     if (g[nod].size() == 0) {       arr[nod] = {lvl - k, 1};     }   }   int dp[MAXN + 1];   void dfs1(int nod, int par, int lvl) {     dp[nod] = (g[nod].size() == 0);     for (auto it : g[nod]) {       if (it != par) {         dfs1(it, nod, lvl + 1);         int cur = arr[nod].second;         if (lvl >= arr[it].first) {           cur -= arr[it].second;         }         dp[nod] = max(dp[nod], cur + dp[it]);       }     }   }   int main() {     int i, n, x, y;     ios::sync_with_stdio(false);     cin >> n >> k;     for (i = 2; i <= n; i++) {       cin >> x;       g[x].push_back(i);     }     dfs(1, 0, 1);     dfs1(1, 0, 1);     cout << dp[1];     return 0;   }
#include <bits/stdc++.h>   char s[101];   char t[10] =  ><+-.,[] ;   int c[10] = {8, 9, 10, 11, 12, 13, 14, 15};   void func() {     int n = strlen(s), i, j, ans = 0;     const int mod = 1000003;     for (i = 0; i < n; i++) {       for (j = 0; j < 8; j++) {         if (t[j] == s[i]) {           ans = (ans * 16 + c[j]) % mod;           break;         }       }     }     printf( %d n , ans);   }   int main(int argc, char **argv) {     while (scanf( %s , s) == 1) {       func();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int i = 1; i <= t; i++) {       int x1, x2, y1, y2;       string arr[8];       for (int i = 0; i < 8; i++) cin >> arr[i];       bool check = 0;       for (int i = 0; i < 8; i++) {         for (int j = 0; j < 8; j++) {           if (arr[i][j] ==  K  && check == 0) {             check = 1;             x1 = j;             y1 = i;           } else if (arr[i][j] ==  K ) {             x2 = j;             y2 = i;           }         }       }       if ((x1 == x2 && abs(y1 - y2) == 4) || (y1 == y2 && abs(x1 - x2) == 4))         cout <<  YES ;       else if (abs(x1 - x2) == 4 && abs(y1 - y2) == 4)         cout <<  YES ;       else         cout <<  NO ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long MOD = 1e9 + 7;   long long MAX = 9223372036854775807;   int visited[1001][1001];   int main() {     ios_base::sync_with_stdio(0);     ;     int n, m;     cin >> n >> m;     int a[n][m], l[n][m], r[n][m], u[n][m], d[n][m];     for (int i = 0; i < n; ++i) {       string s;       cin >> s;       for (int j = 0; j < s.size(); ++j) {         if (s[j] ==  . )           a[i][j] = 0;         else           a[i][j] = 1;       }     }     for (int i = 0; i < n; ++i) {       int temp = 0;       for (int j = 0; j < m; ++j) {         l[i][j] = temp;         temp += a[i][j];         if (a[i][j] == 0) temp = 0;       }       temp = 0;       for (int j = m - 1; j >= 0; j--) {         r[i][j] = temp;         temp += a[i][j];         if (a[i][j] == 0) temp = 0;       }     }     for (int j = 0; j < m; ++j) {       int temp = 0;       for (int i = 0; i < n; ++i) {         u[i][j] = temp;         temp += a[i][j];         if (a[i][j] == 0) temp = 0;       }       temp = 0;       for (int i = n - 1; i >= 0; i--) {         d[i][j] = temp;         temp += a[i][j];         if (a[i][j] == 0) temp = 0;       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (a[i][j]) {           l[i][j] = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j]));         }       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         u[i][j] = 0;         r[i][j] = 0;       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (a[i][j] and l[i][j] > 0) {           int k = l[i][j];           u[i - k][j]++;           if (i + k + 1 < n) u[i + k + 1][j]--;           r[i][j - k]++;           if (j + k + 1 < m) r[i][j + k + 1]--;         }       }     }     for (int i = 0; i < n; ++i) {       int temp = 0;       for (int j = 0; j < m; ++j) {         temp += r[i][j];         visited[i][j] = temp;       }     }     for (int j = 0; j < m; ++j) {       int temp = 0;       for (int i = 0; i < n; ++i) {         temp += u[i][j];         visited[i][j] += temp;       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (a[i][j] and visited[i][j] == 0) {           cout << -1 <<   n ;           return 0;           ;         }         if (a[i][j] == 0 and visited[i][j] > 0) {           cout << -1 <<   n ;           return 0;           ;         }       }     }     vector<pair<pair<int, int>, int> > ans;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (a[i][j] and l[i][j] > 0) {           ans.push_back({{i + 1, j + 1}, l[i][j]});         }       }     }     cout << ans.size() <<   n ;     ;     for (auto i : ans) {       cout << i.first.first <<    ;       ;       cout << i.first.second <<    ;       ;       cout << i.second <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     int n, m, k;     cin >> n >> m >> k;     vector<int> p(n);     for (int i = 0; i < n; ++i) cin >> p[i];     vector<int> s(n);     for (int i = 0; i < n; ++i) cin >> s[i];     vector<int> c(k);     for (int i = 0; i < k; ++i) cin >> c[i];     vector<vector<int>> schools(m + 1, vector<int>());     for (int i = 0; i < n; ++i) {       schools[s[i]].push_back(p[i]);     }     int ans = 0;     for (int i = 0; i < k; ++i) {       int cur = c[i];       int school = s[cur - 1];       int power = p[cur - 1];       vector<int> ss = schools[school];       sort(ss.rbegin(), ss.rend());       if (ss[0] != power) ans++;     }     cout << ans << endl;     return 0;   }