func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline bool upmin(T &x, T y) {     return y < x ? x = y, 1 : 0;   }   template <typename T>   inline bool upmax(T &x, T y) {     return x < y ? x = y, 1 : 0;   }   const long double eps = 1e-11;   const long double pi = acos(-1);   const int oo = 1 << 30;   const long long loo = 1ll << 62;   const int mods = 1e9 + 7;   const int MAXN = 5005;   const int INF = 0x3f3f3f3f;   inline int read() {     int f = 1, x = 0;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = (x << 3) + (x << 1) + (c ^ 48);       c = getchar();     }     return x * f;   }   struct anode {     int u, v;     long long c;   };   vector<anode> Ans;   long long a[MAXN];   int f[MAXN][MAXN], frm[MAXN][MAXN], flag[MAXN], n, k, V;   void add(int u, int v, long long c) {     long long t = min(c * k, a[u]);     a[u] -= t, a[v] += t;     Ans.push_back((anode){u, v, c});   }   signed main() {     long long sum = 0;     n = read(), k = read(), V = read();     for (int i = 1; i <= n; i++) a[i] = read(), sum += a[i];     if (sum < V) {       puts( NO );       return 0;     }     f[0][0] = 1;     for (int i = 1; i <= n; i++)       for (int j = 0; j < k; j++)         if (f[i - 1][j])           f[i][j] = 1, frm[i][j] = 0;         else if (f[i - 1][(j - a[i] % k + k) % k])           f[i][j] = 1, frm[i][j] = 1;     int nw = V % k, id1 = 0, id2 = 0;     if (!f[n][nw]) {       puts( NO );       return 0;     }     puts( YES );     for (int i = n; i >= 1; i--) {       if (frm[i][nw])         flag[i] = 1, nw = (nw - a[i] % k + k) % k, id1 = i;       else         id2 = i;     }     for (int i = 1; i <= n; i++)       if (a[i] && i != id1 && i != id2) {         if (flag[i])           add(i, id1, (a[i] - 1) / k + 1);         else           add(i, id2, (a[i] - 1) / k + 1);       }     if (!id1) id1 = (id2 == n ? id2 - 1 : id2 + 1);     if (!id2) id2 = (id1 == n ? id1 - 1 : id1 + 1);     if (a[id1] > V) add(id1, id2, (a[id1] - V) / k);     if (a[id1] < V) add(id2, id1, (V - a[id1]) / k);     for (auto v : Ans) printf( %lld %d %d n , v.c, v.u, v.v);     return 0;   }   