malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k, a[300001], seti = 0, l, r, z = 0, maxi = 0, fz, lt = -1,                                rt = -1;     cin >> n >> k;     for (long long i = 0; i < n; i++) cin >> a[i];     l = 0;     for (long long i = 0; i < n; i++) {       if (a[i] == 0) {         z++;         if (z == k + 1) {           r = i - 1;           if (r - l + 1 > maxi) {             maxi = r - l + 1;             lt = l;             rt = r;           }           z--;           if (a[l] == 0) {             l++;           } else {             for (long long j = l + 1; j < n; j++) {               if (a[j] == 0) {                 l = j + 1;                 break;               }             }           }         }       }     }     if (n - l > maxi) {       lt = l;       rt = n - 1;       maxi = n - l;     }     cout << maxi << endl;     if (lt != -1)       for (long long i = lt; i <= rt; i++) a[i] = 1;     for (long long i = 0; i < n; i++) cout << a[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   inline int sbt(int x) { return __builtin_popcount(x); }   inline long long gl(long long a, long long b) { return (b - a + 1); }   inline long long mul(long long a, long long b,                        long long m = (long long)(1e9 + 7)) {     return ((a % m) * (b % m)) % m;   }   inline long long add(long long a, long long b,                        long long m = (long long)(1e9 + 7)) {     return (a + b) % m;   }   inline long long sub(long long a, long long b,                        long long m = (long long)(1e9 + 7)) {     return (a - b + m) % m;   }   long long fastpow(long long a, long long b) {     long long res = 1;     while (b > 0) {       if (b & 1) res = mul(res, a);       a = mul(a, a);       b >>= 1;     }     return res;   }   long long modinv(long long a) { return fastpow(a, (long long)(1e9 + 7) - 2); }   void get_ac() {     long long n, k;     cin >> n >> k;     string s;     cin >> s;     vector<vector<long long>> v;     bool f;     long long mink = 0, maxk = 0;     while (1) {       f = 0;       vector<long long> va;       for (int i = 0; i < n - 1; i++) {         if (s[i] ==  R  && s[i + 1] ==  L ) {           swap(s[i], s[i + 1]);           f = 1;           va.push_back(i);           i++;         }       }       if (!f) break;       v.push_back(va);       maxk += (long long)(va.size());       mink++;     }     if (k < mink || k > maxk) {       cout << -1;       return;     }     long long i = 0, j = 0;     while (k > mink - i) {       cout << 1 <<     << v[i][j] + 1;       cout <<   n ;       j++;       if (j == (long long)(v[i].size())) {         i++;         j = 0;       }       k--;     }     for (int l = i; l < mink; l++) {       cout << ((long long)(v[l].size()) - j) <<    ;       for (int m = j; m < (long long)(v[l].size()); m++) {         cout << v[l][m] + 1 <<    ;       }       j = 0;       cout <<   n ;     }   }   int main() {     cin.sync_with_stdio(false);     cout.sync_with_stdio(false);     cin.tie(NULL);     { get_ac(); }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   struct Point {     int x;     int y;   };   int direction(Point a, Point b, Point c) {     return (c.x - a.x) * (b.y - a.y) - (c.y - a.y) * (b.x - a.x);   }   bool onsegment(Point a, Point b, Point c) {     return (min(a.x, b.x) <= c.x && max(a.x, b.x) >= c.x &&             min(a.y, b.y) <= c.y && max(a.y, b.y) >= c.y);   }   bool intersects(Point a, Point b, Point c, Point d) {     int d1 = direction(c, d, a), d2 = direction(c, d, b), d3 = direction(a, b, c),         d4 = direction(a, b, d);     if (d1 * d2 < 0 && d3 * d4 < 0) {       return true;     } else if (d1 == 0 && onsegment(c, d, a)) {       return true;     } else if (d2 == 0 && onsegment(c, d, b)) {       return true;     } else if (d3 == 0 && onsegment(a, b, c)) {       return true;     } else if (d4 == 0 && onsegment(a, b, d)) {       return true;     } else {       return false;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     Point a[5], b[5];     for (int i = 0; i < 4; i++) {       int x, y;       cin >> x >> y;       a[i] = {x, y};     }     a[4] = a[0];     for (int i = 0; i < 4; i++) {       int x, y;       cin >> x >> y;       b[i] = {x, y};     }     b[4] = b[0];     for (int i = 0; i < 4; i++) {       if (intersects(b[i], b[i + 1], a[0], a[2]) ||           intersects(b[i], b[i + 1], a[1], a[3])) {         return cout <<  YES n , 0;       }     }     for (int i = 0; i < 4; i++) {       if (b[i].x >= min(min(a[0].x, a[1].x), min(a[2].x, a[3].x)) &&           b[i].x <= max(max(a[0].x, a[1].x), max(a[2].x, a[3].x)) &&           b[i].y >= min(min(a[0].y, a[1].y), min(a[2].y, a[3].y)) &&           b[i].y <= max(max(a[0].y, a[1].y), max(a[2].y, a[3].y))) {         return cout <<  YES n , 0;       }     }     for (int i = 0; i < 5; i++) {       a[i] = {a[i].x - a[i].y, a[i].x + a[i].y};       b[i] = {b[i].x - b[i].y, b[i].x + b[i].y};     }     for (int i = 0; i < 4; i++) {       if (a[i].x >= min(min(b[0].x, b[1].x), min(b[2].x, b[3].x)) &&           a[i].x <= max(max(b[0].x, b[1].x), max(b[2].x, b[3].x)) &&           a[i].y >= min(min(b[0].y, b[1].y), min(b[2].y, b[3].y)) &&           a[i].y <= max(max(b[0].y, b[1].y), max(b[2].y, b[3].y))) {         return cout <<  YES n , 0;       }     }     return cout <<  NO n , 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a;     while (n) {       int x = n, p = 1, m = 0;       while (x) {         if (x % 10) m += p;         x /= 10;         p *= 10;       }       n -= m;       a.push_back(m);     }     cout << a.size() << endl;     for (int &i : a) cout << i <<    ;   }
#include <bits/stdc++.h>   int main() {     long long n;     scanf( %lld , &n);     long long a[1000005] = {0};     for (int i = 1; i <= n; i++) {       scanf( %lld , &a[i]);     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       ans = ans + a[i] * i - (i - 1);     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef long long LL;   typedef pair<int, int> PII;   typedef pair<LL,LL> PLL;   const int INF = 0x3f3f3f3f, N = 1e5 + 10;   inline int lc(int u) {return u << 1;}   inline int rc(int u) {return u << 1 | 1;}   inline int lowbit(int x) {return x & (-x);}   int y[27] = {10010,11020,20011,21012,11011,21021,22022,12021,11011,12012,10120,11130,20121,21122,11121,21131,22132,12131,11121,12122,10221,11231,12113,20222,21223,11222};   char x[30000];   inline void solve() {       for (int i = 0; i < 26; i ++ ) {           if (x[y[i]] == 0) x[y[i]] = i +  a ;       }       int n; cin >> n;       for (int i = 1; i <= n; i ++ ) {           int res = 0;           for (int j = 0; j < 5; j ++ ) {               int tmp; cin >> tmp;               res = res * 10 + tmp;           }           cout << x[res];       }   }   int main() {   //    ios::sync_with_stdio(false), cin.tie(nullptr);   //    int t; cin >> t;   //    while (t -- )           solve();       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   int n, k, root, ans;   vector<int> g[N];   int dfs(int u, int f) {     if (g[u].size() == 1) return 0;     vector<int> d;     for (int v : g[u])       if (v != f) d.push_back(dfs(v, u) + 1);     sort(d.begin(), d.end());     int sz = d.size();     while (sz >= 2) {       if (d[sz - 1] + d[sz - 2] <= k) break;       ans++, sz--;       d.pop_back();     }     int ret = d.back();     d.clear();     return ret;   }   int main() {     scanf( %d %d , &n, &k);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d %d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);     }     for (int i = 1; i <= n; i++)       if (g[i].size() > 1) {         root = i;         break;       }     dfs(root, -1);     printf( %d , ans + 1);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops )   #pragma GCC optimize( no-stack-protector,fast-math )   using namespace std;   const long long N = 1e6 + 100, OO = 724249387, T = (1 << 20) + 10,                   M = 998244353, P = 6151, SQ = 280, lg = 64;   long long n, m, k, num, ed, t;   vector<long long> v[N];   bool mark[N];   void dfs(long long x) {     mark[x] = 1;     num++;     for (auto u : v[x])       if (!mark[u]) dfs(u);   }   int32_t main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> m >> k;     for (long long i = 0; i < m; i++) {       long long x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     for (long long i = 1; i <= n; i++) {       if (!mark[i]) {         num = 0;         dfs(i);         ed += min(num, k);         t++;       }     }     ed /= 2;     if (k == 1) return cout << max((long long)0, t - 2), 0;     cout << max((long long)0, t - 1 - ed);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char ch = getchar();     int res = 0, flag = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) flag = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       res = res * 10 + ch -  0 ;       ch = getchar();     }     return res * flag;   }   int r, c, n, k, p[3005][3005], x, y, cnt[3005], nxt[3005], lst[3005], tmp[3005];   long long ans;   int main() {     r = read();     c = read();     n = read();     k = read();     for (register int i = 1; i <= n; ++i) {       x = read();       y = read();       p[x][++p[x][0]] = y;     }     for (register int i = 1; i <= r; ++i) sort(p[i] + 1, p[i] + p[i][0] + 1);     for (register int i = r; i; --i) {       int h = 1, t = 0, s = 0;       long long now = 0;       for (register int j = 1; j <= p[i][0]; ++j) ++cnt[p[i][j]];       while (1) {         while (t < c && s < k) {           ++t;           s += cnt[t];         }         if (s < k) break;         while (h <= t && s >= k) {           s -= cnt[h];           ++h;           now += c - t + 1;         }       }       nxt[0] = 1;       lst[c + 1] = c;       for (register int j = 1; j <= c; ++j) {         nxt[j] = j + 1;         lst[j] = j - 1;       }       for (register int j = 1; j <= c; ++j)         if (!cnt[j]) {           nxt[lst[j]] = nxt[j];           lst[nxt[j]] = lst[j];         }       memcpy(tmp, cnt, sizeof(cnt));       for (register int j = r; j >= i; --j) {         ans += now;         for (register int u = 1; u <= p[j][0]; ++u) {           h = t = p[j][u];           int s1 = tmp[h], s2 = 0;           while (nxt[t] <= c && s1 + s2 + tmp[nxt[t]] <= k) {             t = nxt[t];             s2 += tmp[t];           }           while (1) {             if (s1 + s2 == k) now -= (h - lst[h]) * (nxt[t] - t);             h = lst[h];             s1 += tmp[h];             if (!h || s1 > k) break;             while (s1 + s2 > k) {               s2 -= tmp[t];               t = lst[t];             }           }           --tmp[p[j][u]];           if (!tmp[p[j][u]]) {             nxt[lst[p[j][u]]] = nxt[p[j][u]];             lst[nxt[p[j][u]]] = lst[p[j][u]];           }         }       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = int(1e9 + 5);   const long long MAXL = long long(1e18 + 5);   const long long MOD = long long(1e9 + 7);   const long long MOD2 = long long(998244353);   void fastio() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     return;   }   void precision(int x) {     cout.setf(ios::fixed | ios::showpoint);     cout.precision(x);     return;   }   long long gcd(long long a, long long b) {     if (a > b) {       swap(a, b);     }     if (a == 0) {       return b;     }     if (a == b) {       return a;     }     return gcd(b % a, a);   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   bool is_prime(long long a) {     if (a == 1) {       return false;     }     long long i;     for (i = 2; i * i <= a; i++) {       if (a % i == 0) {         return false;       }     }     return true;   }   bool is_square(long long a) {     long long b = long long(sqrt(a));     return (b * b == a);   }   bool is_cube(long long a) {     long long b = long long(cbrt(a));     return (b * b * b == a);   }   int digit_sum(long long a) {     int sum = 0;     while (a) {       sum += int(a % 10);       a /= 10;     }     return sum;   }   long long binpow(long long a, int b) {     long long ans = 1;     while (b) {       if ((b & 1) == 1) {         ans *= a;       }       b >>= 1;       a *= a;     }     return ans;   }   long long binpow_by_mod(long long a, long long b, long long mod) {     long long ans = 1;     while (b) {       if ((b & 1) == 1) {         ans *= a;         ans %= mod;       }       b >>= 1;       a *= a;       a %= mod;     }     return ans;   }   long long factorial(int a) {     int i;     long long ans = 1;     for (i = 2; i <= a; i++) {       ans *= long long(i);     }     return ans;   }   long long factorial_by_mod(int a, long long mod) {     int i;     long long ans = 1;     for (i = 2; i <= a; i++) {       ans *= long long(i);       ans %= mod;     }     return ans;   }   const int N = 200005;   int a[N];   int n;   void solve() {     int i, j;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a[i];     }     sort(a + 1, a + n + 1);     for (i = 2; i <= (n / 2) + 1; i++) {       cout << a[i] <<     << a[1] << endl;     }     return;   }   void precalc() { return; }   int main() {     fastio();     precalc();     int tests = 1, tc;     cin >> tests;     for (tc = 1; tc <= tests; tc++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e3 + 10;   long long n, m, ans, h[N][N];   char ar[N][N];   bool get(long long i, long long j) {     long long x = h[i][j];     i -= x;     if (i < 0) return 0;     if (h[i][j] != x) return 0;     i -= x;     if (i < 0) return 0;     return h[i][j] >= x;   }   bool ok(long long row, long long l, long long r) {     long long x = h[row][l];     if (ar[row][l] != ar[row][r]) return 0;     row -= x;     if (ar[row][l] != ar[row][r]) return 0;     row -= x;     return ar[row][l] == ar[row][r];   }   long long choose2(long long x) { return (x * (x - 1)) / 2; }   long long solve(vector<bool> &vec, long long row) {     assert(vec.size() == m);     long long res = 0;     for (long long i = 0; i < vec.size(); i++) {       if (!vec[i]) continue;       long long r = i + 1;       while (r < vec.size() && vec[r] && h[row][i] == h[row][r] && ok(row, i, r))         r++;       res += choose2(r - i + 1);       i = r - 1;     }     return res;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (long long i = 0; i < n; i++)       for (long long j = 0; j < m; j++) cin >> ar[i][j];     for (long long j = 0; j < m; j++) h[0][j] = 1;     for (long long i = 1; i < n; i++)       for (long long j = 0; j < m; j++) {         if (ar[i][j] == ar[i - 1][j])           h[i][j] = h[i - 1][j] + 1;         else           h[i][j] = 1;       }     for (long long i = 0; i < n; i++) {       vector<bool> vec;       for (long long j = 0; j < m; j++) vec.push_back(get(i, j));       ans += solve(vec, i);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   void solve(int test_case) {     int a, b;     cin >> a >> b;     cout << b % max(b / 2 + 1, a) <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int t;     cin >> t;     for (int test_case = 1; test_case <= t; ++test_case) {       solve(test_case);     }   }
#include <bits/stdc++.h>   using namespace std;   int a[1000001];   int mod = 1000000007;   int f(int x, int y) {     int res = 1;     long long xx = x;     while (y > 0) {       if (y % 2) res = (res * xx) % mod;       xx = (xx * xx) % mod;       y = y / 2;     }     return res;   }   int main() {     int t, p;     int n, ba;     int i, j;     scanf( %d , &t);     for (p = 1; p <= t; p++) {       scanf( %d%d , &n, &ba);       for (i = 1; i <= n; i++) scanf( %d , &a[i]);       if (ba == 1) {         printf( %d n , n % 2);         continue;       }       sort(a + 1, a + n + 1);       long long cur = 1;       for (i = n - 1; i >= 1; i--) {         if (a[i] == a[i + 1]) {           if (cur == 0)             cur++;           else             cur--;         } else {           if (cur == 0)             cur++;           else {             while (a[i + 1] > a[i] && cur < i) {               a[i + 1]--;               cur = cur * ba;             }             if (cur < i)               cur--;             else               break;           }         }       }       if (i == 0)         printf( %d n , (cur * f(ba, a[1])) % mod);       else {         int res = (cur * f(ba, a[i + 1])) % mod;         for (; i >= 1; i--) res = ((res - f(ba, a[i])) % mod + mod) % mod;         printf( %d n , res);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   char grid[101][101];   bool rw[101], cl[101];   int main() {     bool f, r = 0, c = 0;     int cnt;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %s , grid[i]);       f = 1;       for (int j = 0; j < n; ++j) {         f &= (grid[i][j] ==  E );         if (grid[i][j] ==  . ) rw[i] = cl[j] = 1;       }       c |= f;     }     for (int j = 0; j < n; ++j) {       f = 1;       for (int i = 0; i < n; ++i) {         f &= (grid[i][j] ==  E );       }       r |= f;     }     if (r && c) {       printf( -1 n );     } else {       cnt = 0;       for (int i = 0; i < n; ++i) cnt += rw[i];       if (cnt == n) {         for (int i = 0; i < n; ++i) {           for (int j = 0; j < n; ++j) {             if (grid[i][j] ==  . ) {               printf( %d %d n , i + 1, j + 1);               break;             }           }         }       } else {         for (int j = 0; j < n; ++j) {           for (int i = 0; i < n; ++i) {             if (grid[i][j] ==  . ) {               printf( %d %d n , i + 1, j + 1);               break;             }           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, k, a[4] = {2, 3, 4, 5}, x, min = 250;     scanf( %d %d , &n, &k);     if (n * 5 == k || n * 3 == k || n * 4 == k) {       printf( 0 );       return 0;     }     for (int i = n; i >= 0; i--) {       x = i * 5;       if (x > k) continue;       for (int j = n; j >= 0; j--) {         x = i * 5 + j * 4;         if (x > k) continue;         for (int z = n; z >= 0; z--) {           x = i * 5 + j * 4 + z * 3;           if (x > k) continue;           for (int l = 0; l <= n; l++) {             x = i * 5 + j * 4 + z * 3 + l * 2;             if (x > k) break;             if (x == k && l < min && (i + j + z + l == n)) min = l;           }         }       }     }     printf( %d , min);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool check(vector<vector<int>> &a, int n, int x) {     deque<pair<int, int>> q;     map<pair<int, int>, bool> was;     q.push_back({1, 1});     was[{1, 1}] = true;     int dx[] = {1, 0, -1, 0};     int dy[] = {0, 1, 0, -1};     while (!q.empty()) {       auto u = q.front();       q.pop_front();       for (int i = 0; i < 4; i++) {         int xx = u.first + dx[i];         int yy = u.second + dy[i];         if (xx == n && yy == n) return false;         if (a[xx][yy] == x && !was[{xx, yy}]) {           q.push_back({xx, yy});           was[{xx, yy}] = true;         }       }     }     return true;   }   void v(vector<vector<int>> &a, int n) {     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         cout << a[i][j];       }       cout << endl;     }   }   void solve() {     vector<vector<int>> a;     int n;     cin >> n;     a = vector<vector<int>>(n + 2, vector<int>(n + 2, 2));     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         char x;         cin >> x;         if (x !=  S  && x !=  F ) {           a[i][j] = x -  0 ;         }       }     }     vector<pair<int, int>> c = {         {n - 1, n - 1}, {n - 1, n}, {n, n - 1}, {n - 2, n}, {n, n - 2}};     if (check(a, n, 1) && check(a, n, 0)) {       cout << 0 << endl;       return;     }     for (int i = 0; i < c.size(); i++) {       a[c[i].first][c[i].second] = 1 - a[c[i].first][c[i].second];       if (check(a, n, 1) && check(a, n, 0)) {         cout << 1 <<   n ;         cout << c[i].first <<     << c[i].second << endl;         return;       }       a[c[i].first][c[i].second] = 1 - a[c[i].first][c[i].second];     }     for (int i = 0; i < c.size(); i++) {       for (int j = i + 1; j < c.size(); j++) {         a[c[i].first][c[i].second] = 1 - a[c[i].first][c[i].second];         a[c[j].first][c[j].second] = 1 - a[c[j].first][c[j].second];         if (check(a, n, 1) && check(a, n, 0)) {           cout << 2 <<   n ;           cout << c[i].first <<     << c[i].second << endl;           cout << c[j].first <<     << c[j].second << endl;           return;         }         a[c[i].first][c[i].second] = 1 - a[c[i].first][c[i].second];         a[c[j].first][c[j].second] = 1 - a[c[j].first][c[j].second];       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t = 1;     cin >> t;     for (int i = 1; i <= t; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long t[5005], c[5005], ans[5005], n, i, l, b, v;   int main() {     cin >> n;     for (i = 1; i <= n; i++) cin >> t[i];     for (l = 1; l <= n; l++) {       for (i = 1; i <= n; i++) c[i] = 0;       b = 0;       for (i = l; i <= n; i++) {         v = t[i];         c[v]++;         if (c[v] > c[b] || (c[v] == c[b] && v < b)) b = v;         ans[b]++;       }     }     for (i = 1; i <= n - 1; i++) cout << ans[i] <<    ;     cout << ans[n] << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int l, r, a, n;     scanf( %d %d %d , &l, &r, &a);     if (l > r) {       if (r + a < l) {         printf( %d n , 2 * (r + a));       } else {         n = r + a - l;         printf( %d n , 2 * (l + n / 2));       }     } else {       if (l + a < r) {         printf( %d n , 2 * (l + a));       } else {         n = l + a - r;         printf( %d n , 2 * (r + n / 2));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200010;   pair<int, int> bug[N];   pair<int, pair<int, int> > stud[N];   set<pair<int, int> > smart;   int ans[N];   int studs, bugs, exams;   long long solve(int days) {     long long sum = 0;     smart.clear();     int last = 0;     for (int i = 0; i < bugs; i += days) {       while (last < studs && stud[last].first >= bug[i].first) {         smart.insert(stud[last].second);         last++;       }       if (smart.empty()) {         return (long long)1e18;       }       pair<int, int> t = *(smart.begin());       smart.erase(smart.begin());       sum += t.first;       for (int j = i; j < bugs && j < i + days; j++) {         ans[bug[j].second] = t.second;       }     }     return sum;   }   int main() {     scanf( %d%d%d , &studs, &bugs, &exams);     for (int i = 0; i < bugs; i++) {       scanf( %d , &(bug[i].first));       bug[i].second = i;     }     for (int i = 0; i < studs; i++) {       scanf( %d , &(stud[i].first));     }     for (int i = 0; i < studs; i++) {       scanf( %d , &(stud[i].second.first));       stud[i].second.second = i;     }     sort(bug, bug + bugs);     reverse(bug, bug + bugs);     sort(stud, stud + studs);     reverse(stud, stud + studs);     int ll = 1, rr = bugs + 1;     while (ll < rr) {       int mid = (ll + rr) >> 1;       if (solve(mid) <= exams)         rr = mid;       else         ll = mid + 1;     }     if (ll > bugs) {       cout <<  NO n ;       return 0;     }     solve(ll);     printf( YES n );     for (int i = 0; i < bugs; i++) {       printf( %d  , ans[i] + 1);     }     return 0;   }