func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, k;   struct kni {     int p, c, id;     long long ans;   } a[100005];   long long s[100005];   inline char nc() {     static char buf[10001], *p1 = buf, *p2 = buf;     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 10000, stdin), p1 == p2)                ? EOF                : *p1++;   }   inline int read() {     register int s = 0, w = 1;     register char c = nc();     while (c <  0  || c >  9 ) {       if (c ==  - ) w = -1;       c = nc();     }     while (c >=  0  && c <=  9 ) s = (s << 1) + (s << 3) + c - 48, c = nc();     return s * w;   }   inline void print(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x > 9) print(x / 10);     putchar(x % 10 + 48);   }   inline bool cmp(const kni &a, const kni &b) { return a.p < b.p; }   inline bool cmp2(const kni &a, const kni &b) { return a.id < b.id; }   int main() {     n = read();     k = read();     for (int i = 1; i <= n; ++i) a[i].p = read(), a[i].id = i;     for (int i = 1; i <= n; ++i) a[i].c = read();     sort(a + 1, a + n + 1, cmp);     priority_queue<long long, vector<long long>, greater<long long> > q;     for (int i = 1; i <= n; ++i) {       if (i <= k)         q.push(a[i].c), s[i] = s[i - 1] + a[i].c;       else if (k) {         if (q.top() < a[i].c) {           s[i] = s[i - 1] + a[i].c - q.top();           q.pop();           q.push(a[i].c);         } else           s[i] = s[i - 1];       }       a[i].ans = a[i].c + s[i - 1];     }     sort(a + 1, a + n + 1, cmp2);     for (int i = 1; i <= n; ++i) print(a[i].ans), putchar(   );     return 0;   }   