#include <stdint.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define FOR_N(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define FOR_R(i, b, e) for (int64_t i = int64_t(b); i < (int64_t)(e); i++)

int main() {
    int64_t N, C;
    cin >> N >> C;

    vector<pair<int64_t, int64_t>> P(N * 2);

    FOR_N(i, N) {
        int64_t a, b, c;
        cin >> a >> b >> c;
        P[2 * i + 0] = make_pair(a, c);
        P[2 * i + 1] = make_pair(b + 1, -c);
    }

    std::sort(P.begin(), P.end(), [](auto& a, auto& b) { return a.first < b.first; });

    int64_t i = 0, cost = 0, paid = 0;
    while (i < P.size()) {
        const int64_t now = P[i].first;
        while (i < P.size() && P[i].first <= now) {
            cost += P[i++].second;
        }
        if (i < P.size()) {
            paid += std::min(cost, C) * (P[i].first - now);
        }
    }
    cout << paid << endl;

    return 0;
}
#include <bits/stdc++.h> 
using namespace std;

#define mnto(x, y) x = min(x, (__typeof__(x)) y)
#define mxto(x, y) x = max(x, (__typeof__(x)) y)
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb emplace_back
typedef vector<int> vi;
typedef vector<ii> vii;

#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 200005

int k, n, m;
ll a[MAXN], b[MAXN];
priority_queue<pll> pq;

int main() {
	scanf("%d%d%d", &k, &n, &m);
	REP (i, 0, k) {
		scanf("%lld", &a[i]);
		a[i] *= m;
	}
	int sum = 0;
	REP (i, 0, k) {
		b[i] = a[i] / n;
		sum += b[i];
		pq.push(MP(a[i] - b[i] * n, i));
	}
	int rem = m - sum;
	REP (i, 0, rem) {
		assert(!pq.empty());
		auto [_, id] = pq.top(); pq.pop();
		b[id]++;
	}
	REP (i, 0, k) {
		printf("%lld ", b[i]);
	}
	printf("\n");
	return 0;
}
