malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   string str;   bool judge(char c) {     return (c ==  _  || islower(c) || isdigit(c) || isupper(c));   }   int main() {     int cnt = 0, count = 0, type = 0, len;     cin >> str;     type = 0;     len = str.length();     for (int i = 0; i < len; i++) {       char c = str[i];       if (c ==  @ ) {         if (type == 1) {           cout <<  NO  << endl;           return 0;         }         type = 1;         if (cnt < 1 || cnt > 16) {           cout <<  NO  << endl;           return 0;         };         cnt = 0;       } else if (c ==  / ) {         if (type == 2) {           cout <<  NO  << endl;           return 0;         }         type = 2;         if (cnt < 1 || cnt > 16) {           cout <<  NO  << endl;           return 0;         }         if (count < 1 || count > 32) {           cout <<  NO  << endl;           return 0;         }         cnt = 0;       } else if (c ==  . ) {         if (type != 1) {           cout <<  NO  << endl;           return 0;         }         if (cnt < 1 || cnt > 16) {           cout <<  NO  << endl;           return 0;         }         cnt = 0;       } else if (c > 127 || c < 33) {         cout <<  NO  << endl;         return 0;       } else if (type == 0) {         if (judge(c)) {           cnt++;           continue;         } else {           cout <<  NO  << endl;           return 0;         }       } else if (type == 1) {         if (judge(c)) {           cnt++;           count++;           continue;         } else {           cout <<  NO  << endl;           return 0;         }       } else if (type == 2) {         if (judge(c)) {           cnt++;           continue;         } else {           cout <<  NO  << endl;           return 0;         }       }     }     if (cnt < 0 || cnt > 16) {       cout <<  NO  << endl;       return 0;     }     if (type >= 1 && cnt > 0) {       cout <<  YES  << endl;       return 0;     } else {       cout <<  NO  << endl;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   struct cc {     int x, y, z;     bool operator<(const cc &t) const {       if (y != t.y)         return y > t.y;       else         return x > t.x;     }   } a[N];   struct xx {     int w, id;   } q[N];   long long dp[N];   int main() {     int n, m, i, j, k, ans, num, sum;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d%d%d , &a[i].x, &a[i].y, &a[i].z);     }     sort(a + 1, a + n + 1);     long long maxx = dp[1] = a[1].z;     q[1] = {a[1].x, 1};     int l = 1, r = 1;     for (i = 2; i <= n; i++) {       while (l <= r && q[r].w >= a[i].y) r--;       dp[i] = dp[q[r].id] + a[i].z;       q[++r] = {a[i].x, i};       maxx = max(maxx, dp[i]);     }     printf( %lld n , maxx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int num[300005];   long long dp[300005], ans = -LONG_LONG_MAX;   vector<int> G[300005];   int cnt = 0;   void dfs(int now, int fa) {     for (int k : G[now]) {       if (k != fa) {         dfs(k, now);         dp[now] += max((long long)0, dp[k]);       }     }     ans = max(ans, dp[now]);   }   void dfs2(int now, int fa) {     for (int k : G[now]) {       if (k != fa) {         dfs2(k, now);         dp[now] += max((long long)0, dp[k]);       }     }     if (dp[now] == ans) {       dp[now] = 0;       cnt++;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> num[i];       dp[i] = num[i];     }     for (int i = 1; i < n; i++) {       int x, y;       cin >> x >> y;       G[x].push_back(y);       G[y].push_back(x);     }     dfs(1, -1);     for (int i = 1; i <= n; i++) dp[i] = num[i];     dfs2(1, -1);     cout << cnt * ans <<     << cnt;   }
#include <bits/stdc++.h>   using namespace std;   int kmp(string s) {     vector<int> lps(s.size(), 0);     for (int i = 1; i < s.size(); ++i) {       int index = lps[i - 1];       while (index > 0 && s[i] != s[index]) index = lps[index - 1];       if (s[i] == s[index])         lps[i] = index + 1;       else         lps[i] = index;     }     return lps[lps.size() - 1];   }   int func(string s) {     string t = s +  # ;     reverse(s.begin(), s.end());     t += s;     return kmp(t);   }   int main() {     int t;     cin >> t;     while (t--) {       string s;       cin >> s;       int l = 0, n = s.length();       for (int i = 0, j = n - 1; i < j; i++, j--) {         if (s[i] == s[j])           l++;         else           break;       }       string remaining = s.substr(l, n - 2 * l);       string ans = s.substr(0, l);       if (remaining.size()) {         int lp = func(remaining);         reverse(remaining.begin(), remaining.end());         int ls = func(remaining);         if (lp > ls) {           reverse(remaining.begin(), remaining.end());           ans += remaining.substr(0, lp);         } else           ans += remaining.substr(0, ls);       }       ans += s.substr(n - l, l);       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long y, long long m) {     long long r = 1;     for (; y; y >>= 1) {       if (y & 1) r = r * x % m;       x = x * x % m;     }     return r;   }   const long long N = 105, M = 105;   long long a[N][M];   int run_test() {     long long n, m;     cin >> n >> m;     for (long long i = 0; i < n; i++)       for (long long j = 0; j < m; j++) cin >> a[i][j];     for (long long i = 0; i < n; i++)       for (long long j = 0; j < m; j++) {         if (a[i][j] % 2 != (i + j) % 2) a[i][j]++;       }     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) cout << a[i][j] <<    ;       cout <<   n ;     }     return 0;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     srand(time(NULL));     ;     long long t;     t = 1;     cin >> t;     while (t--) {       run_test();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     if (n < 6)       printf( -1 n );     else {       printf( 1 2 n2 3 n2 4 n3 5 n3 6 n );       for (int i = 7; i <= n; i++) printf( 3 %d n , i);     }     for (int i = 2; i <= n; i++) printf( %d %d n , i - 1, i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long int LINF = 0x3f3f3f3f3f3f3f3fll;   const long double pi = acos(-1);   const int MOD = 1e9 + 7;   int main() {     int n, i;     double ans = 0.0;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       ans += 1 / (float)i;     }     printf( %.6lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M, Q, A[100][100], B[10000][4], i, j;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> N >> M >> Q;     for (i = 0; i < Q; i++) {       cin >> B[i][0] >> B[i][1];       B[i][1]--;       if (B[i][0] == 3) {         cin >> B[i][2] >> B[i][3];         B[i][2]--;       }     }     for (i = Q - 1; i >= 0; i--) {       if (B[i][0] == 1) {         for (j = M - 1; j > 0; j--) {           swap(A[B[i][1]][j], A[B[i][1]][j - 1]);         }       } else if (B[i][0] == 2) {         for (j = N - 1; j > 0; j--) {           swap(A[j][B[i][1]], A[j - 1][B[i][1]]);         }       } else         A[B[i][1]][B[i][2]] = B[i][3];     }     for (i = 0; i < N; i++) {       for (j = 0; j < M; j++) {         cout << A[i][j] <<    ;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     if (n == 0) {       cout << 0 << endl;     } else if ((n + 1) % 2 == 0) {       cout << (n + 1) / 2 << endl;     } else {       cout << n + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   int main() {     ios::sync_with_stdio(false);     int n, m;     cin >> n >> m;     int a[n + 1];     int ev = 2, od = 1;     int tev = 0, tod = 0;     int tot = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       mp[a[i]]++;       if (a[i] % 2 == 0)         tev++;       else         tod++;     }     for (int i = 0; i < n; i++) {       if (mp[a[i]] > 1) {         if (a[i] % 2) {           if (tod > tev) {             while (mp[ev] != 0) ev += 2;             if (ev > m) return cout << -1, 0;             mp[ev] = 1;             mp[a[i]]--;             a[i] = ev;             tev++;             tod--;             tot++;           } else {             while (mp[od] != 0) od += 2;             if (od > m) return cout << -1, 0;             mp[od] = 1;             mp[a[i]]--;             a[i] = od;             tot++;           }         } else {           if (tod < tev) {             while (mp[od] != 0) od += 2;             if (od > m) return cout << -1, 0;             mp[od] = 1;             mp[a[i]]--;             a[i] = od;             tev--;             tod++;             tot++;           } else {             while (mp[ev] != 0) ev += 2;             if (ev > m) return cout << -1, 0;             mp[ev] = 1;             mp[a[i]]--;             a[i] = ev;             tot++;           }         }       }     }     for (int i = 0; i < n; i++) {       if (a[i] % 2) {         if (tev < tod) {           tot++;           while (mp[ev] != 0) ev += 2;           if (ev > m) return cout << -1, 0;           mp[ev] = 1;           a[i] = ev;           tod--;           tev++;         }       } else {         if (tev > tod) {           tot++;           while (mp[od] != 0) od += 2;           if (od > m) return cout << -1, 0;           mp[od] = 1;           a[i] = od;           tod++;           tev--;         }       }     }     cout << tot << endl;     for (int i = 0; i < n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std::chrono;   long long power(long long x, unsigned long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) {         res = res * x;       }       y = y >> 1;       x = x * x;     }     return res;   }   long long powermod(long long x, unsigned long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) {         res = (res * x) % p;       }       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long min(long long a, long long b) { return a < b ? a : b; }   long long max(long long a, long long b) { return a > b ? a : b; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     long long f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   void snow() {     long long a, b, n;     cin >> a >> b >> n;     while (n--) {       long long l, t, m;       cin >> l >> t >> m;       l--;       long long ans = l;       long long r = 1e9;       long long faci = m * t;       if (t < (a + l * (b))) {         cout << -1 <<   n ;         continue;       }       long long start = a + l * (b);       long long ll = l;       while (l <= r) {         long long mid = (l + r) / 2;         long long height = a + mid * (b);         long long sum =             start * (mid - ll + 1) + b * ((mid - ll) * (mid - ll + 1)) / 2;         if (height <= t && sum <= m * t) {           ans = mid;           l = mid + 1;         } else {           r = mid - 1;         }       }       cout << ans + 1 <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t;     t = 1;     while (t--) snow();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class U>   inline T max(T &a, U &b) {     return a > b ? a : b;   }   template <class T, class U>   inline T min(T &a, U &b) {     return a < b ? a : b;   }   template <class T>   T gcd(T a, T b) {     return (b != 0 ? gcd<T>(b, a % b) : a);   }   template <class T>   T lcm(T a, T b) {     return (a / gcd<T>(a, b) * b);   }   class CLASS_NAME {    public:     int method_NAME() {}   };   int main() {     int n;     string a, b;     cin >> n;     for (__typeof(0) i = 0; i <= n - 1; i++) a.push_back( 0 );     for (__typeof(0) i = 0; i <= n - 1; i++) b.push_back( 0 );     int k = n / 2;     for (__typeof(0) i = 0; i <= k - 1; i++) {       a[i] =  1 ;       b[i] =  1 ;     }     vector<int> v, arra, arrb;     for (__typeof(0) i = 0; i <= n - 1; i++) {       int x, y;       cin >> x >> y;       arra.push_back(x);       arrb.push_back(y);       v.push_back(x);       v.push_back(y);     }     sort(v.begin(), v.end());     int tmp = v[n - 1];     for (__typeof(0) i = 0; i <= n - 1; i++) {       if (arra[i] <= tmp) a[i] =  1 ;       if (arrb[i] <= tmp) b[i] =  1 ;     }     cout << a << endl << b << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int a[n];       for (int i = 1; i <= n; i++) cin >> a[i];       for (int i = n; i >= 1; i--) cout << a[i] <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300005;   const int mod = 1e9 + 7;   const double eps = 1e-8;   const double PI = acos(-1.0);   long long qpow(long long a, long long b, long long p) {     long long res = 1;     while (b) {       if (b & 1) res = res * a % p;       a = a * a % p;       b >>= 1;     }     return res;   }   long long a[N];   int main() {     std::ios::sync_with_stdio(false);     int n, p, k;     while (cin >> n >> p >> k) {       for (int i = 1; i <= n; i++) cin >> a[i];       map<long long, long long> mp;       for (int i = 1; i <= n; i++)         mp[(qpow(a[i], 4, p) - k % p * a[i] % p + p) % p]++;       map<long long, long long>::iterator it = mp.begin();       long long ans = 0;       for (it; it != mp.end(); it++) {         ans += (*it).second * ((*it).second - 1) / 2;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       vector<int> arr(n);       vector<pair<int, int>> vpr(n);       for (long long i = 0; i <= n - 1; i++) {         cin >> arr[i];         vpr[i] = {arr[i], i};       }       sort(vpr.begin(), vpr.end());       int j = 0;       vector<int> trfs(n);       unordered_multiset<int> mst;       for (int i = 0; i < n; ++i) {         if (i > 0 && vpr[i].first != vpr[i - 1].first) {           j++;         }         trfs[vpr[i].second] = j;         mst.insert(j);       }       vector<int> dp1(n, 1), dp2(n), dp3(n);       unordered_map<int, int> pos;       for (int i = 0; i < n; ++i) {         if (mst.count(trfs[i])) mst.erase(mst.find(trfs[i]));         if (pos.count(trfs[i] - 1)) {           if (!pos.count(trfs[i])) {             dp2[i] = dp1[pos[trfs[i] - 1]] + 1;             if (!mst.count(trfs[i] - 1)) {               dp2[i] = max(dp2[i], dp2[pos[trfs[i] - 1]] + 1);             }           }           if (!mst.count(trfs[i] - 1)) {             dp3[i] = dp2[pos[trfs[i] - 1]] + 1;           }           dp3[i] = max(dp3[i], dp1[pos[trfs[i] - 1]] + 1);         }         if (pos.count(trfs[i])) {           dp1[i] = dp1[pos[trfs[i]]] + 1;           dp3[i] = max(dp3[i], dp3[pos[trfs[i]]] + 1);           dp2[i] = max(dp2[i], dp2[pos[trfs[i]]] + 1);         }         dp2[i] = max(dp2[i], dp1[i]);         dp3[i] = max(dp3[i], dp2[i]);         pos[trfs[i]] = i;       }       cout << n - *max_element(dp3.begin(), dp3.end()) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long const mod = 1000000007;   long long const md = 998244353;   long long mypow(long long a, long long b) {     long long res = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   ifstream in( txt.in );   ofstream out( txt.out );   int main() {     cout << fixed << setprecision(12);     cin.tie(0);     ios_base::sync_with_stdio(0);     cout.tie(0);     string s;     cin >> s;     long long n;     cin >> n;     while (n--) {       long long l, r, k;       cin >> l >> r >> k;       --l;       --r;       int u = r - l + 1;       k %= u;       char c[10005];       int t = r - k + 1;       for (int i = 1; i <= k; ++i) {         c[i] = s[t];         ++t;       }       t = l;       int i = k + 1;       while (t < r - k + 1) {         c[i] = s[t];         ++t;         ++i;       }       t = 1;       for (int i = l; i <= r; ++i) s[i] = c[t], ++t;     }     cout << s <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   istream& operator>>(istream& is, vector<T>& v) {     for (auto& i : v) is >> i;     return is;   }   template <typename T>   ostream& operator<<(ostream& os, vector<T>& v) {     for (auto& i : v) os << i <<    ;     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, typename U>   ostream& operator<<(ostream& os, pair<T, U>& p) {     os << p.first <<     << p.second;     return os;   }   int main() {     long long b;     cin >> b;     vector<pair<long long, long long>> v;     long long p = 2;     while (p * p <= b) {       if (b % p == 0) {         v.emplace_back(p, 0);         while (b % p == 0) {           b /= p;           v.back().second++;         }       }       ++p;     }     if (b != 1) v.emplace_back(b, 1);     long long c = 1;     for (auto p : v) {       c *= p.second + 1;     }     cout << c <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string S, T;   int L = -1, R = -1;   void solve() {     int i, j, k, l, r, x, y;     string s;     cin >> S >> T;     x = 0;     for (i = 0; i < T.size(); i++) {       if (T[i] == S[x]) {         x++;         if (x == S.size()) {           L = i;           break;         }       }     }     x = S.size() - 1;     for (i = T.size() - 1; i >= 0; i--) {       if (T[i] == S[x]) {         x--;         if (x == -1) {           R = i;           break;         }       }     }     if (L >= 0 && R >= 0 && L <= R)       cout << R - L << endl;     else       cout << 0 << endl;   }   int main(int argc, char** argv) {     string s;     int i;     if (argc == 1) ios::sync_with_stdio(false);     for (i = 0; i < argc - 1; i++) s += argv[i + 1], s +=   n ;     for (i = 0; i < s.size(); i++) ungetc(s[s.size() - 1 - i], stdin);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N;   string A;   string B;   int main() {     ios_base::sync_with_stdio(NULL);     cout.tie(NULL);     cin.tie(NULL);     cin >> N;     cin >> A >> B;     int answer = 0;     for (int i = 0; i < N - 1; ++i) {       if (A[i] == B[i]) continue;       if (A[i + 1] == B[i] && A[i] == B[i + 1])         swap(A[i], A[i + 1]);       else         A[i] = B[i];       ++answer;     }     if (A[N - 1] != B[N - 1]) {       ++answer;       A[N - 1] = B[N - 1];     }     cerr << A << endl;     cout << answer << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> toOrder;   map<int, set<int>> offersByDays;   map<int, set<int>> offers;   int totSum;   int bSearch(int a, int b) {     if (a == b) {       return a;     }     int curSum = totSum;     int mid = (a + b) / 2;     int money = 0;     for (int i = 0; i <= mid; i++) {       money++;       if (offersByDays.count(i) == 0) {         continue;       }       for (auto offer : offersByDays[i]) {         if (money == 0) {           break;         }         set<int>::iterator itr = offers[offer].lower_bound(mid);         if (itr != offers[offer].end() && *itr == mid) {           if (i != mid) {             continue;           }         } else {           itr = prev(itr);           if (i != *itr) {             continue;           }         }         if (money >= toOrder[offer]) {           money -= toOrder[offer];           curSum -= toOrder[offer];         } else {           curSum -= money;           money = 0;         }       }     }     if (money >= 2 * curSum) {       return bSearch(a, mid);     }     return bSearch(mid + 1, b);   }   int main() {     int n, m;     cin >> n >> m;     totSum = 0;     for (int i = 0; i < n; i++) {       int temp;       cin >> temp;       toOrder.push_back(temp);       totSum += temp;     }     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       if (offersByDays.count(a) == 0) {         offersByDays.insert({a, {b}});       } else {         offersByDays[a].insert(b);       }       if (offers.count(b) == 0) {         offers.insert({b, {a}});       } else {         offers[b].insert(a);       }     }     cout << bSearch(0, int(4e5)) + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int i, n, d, h;     cin >> n >> d >> h;     if (n >= d + 1 && d >= h + 1 && d <= 2 * h && h + 1 <= n && d >= 2) {       for (i = 1; i <= h; i++) {         cout << i <<     << i + 1 << endl;       }       i++;       int f = 0;       if (d - h > 0) {         f = 1;         cout <<  1   << i << endl;         int temp = d - h - 1;         for (int j = 1; j <= temp; j++, i++) cout << i <<     << i + 1 << endl;       }       if (f == 1) i++;       for (int j = 1; j <= (n - d - 1); j++, i++) {         cout <<  1   << i << endl;       }     } else if (n >= d + 1 && d == h && d <= 2 * h && h + 1 <= n && d >= 2) {       for (i = 1; i <= h; i++) cout << i <<     << i + 1 << endl;       i++;       int k = i;       for (int j = 1; j <= (n - k + 1); j++, i++) {         cout <<  2   << i << endl;       }     } else if (d == 1 && n == 2 && h == 1) {       cout <<  1              <<  2  << endl;     } else       cout <<  -1  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e9 + 7;   const long long MOD = 1e6 + 7;   long long gcd(long long a, long long b) {     if (a % b) return gcd(b, a % b);     return b;   }   long long n, m;   long long a[200005], c[6];   string s[200005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     long long k = *max_element(a, a + n);     long long s = accumulate(a, a + n, 0LL);     if (s % 2 || k > s / 2)       cout <<  NO ;     else       cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k;     cin >> n >> m >> k;     std::vector<int> power(n, -1), school(n, -1), chosen(k, -1);     int ans = 0;     for (int i = 0; i < n; i++) {       cin >> power[i];     }     for (int i = 0; i < n; i++) {       cin >> school[i];     }     for (int i = 0; i < k; i++) {       cin >> chosen[i];     }     for (int i = 0; i < k; i++) {       for (int j = 0; j < n; j++) {         if (power[j] > power[chosen[i] - 1] &&             school[chosen[i] - 1] == school[j] && chosen[i] - 1 != j) {           ans++;           break;         }       }     }     cout << ans;     return 0;   }