Language: C++

include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int N, D;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ifstream ifs("2176_input.txt");
    int _t, _s;
    while(cin >> N >> D && N){
        vector<int> m[100];
        vector<int> sum(N, 0);
        rep(i, N){
            cin >> _t;
            rep(j, _t){
                cin >> _s;
                m[i].push_back(_s);
                sum[i] += _s;
            }
        }
        while(true){
            bool updated = false;
            rep(i, N)
              while(m[i].size()){
                  sum[i] -= m[i].back();
                  if(*max_element(sum.begin(), sum.end()) - sum[i] <= D){
                      m[i].pop_back();
                      updated = true;
                  }else{
                      sum[i] += m[i].back();
                      break;
                  }
              }
            if(!updated) break;
        }
        rep(i, N - 1) sum[i + 1] += sum[i];
        if(sum[N - 1] == 0)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
    }
    return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin.tie(0);
      |     ^~~
a.cc:10:5: error: 'ios' has not been declared
   10 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:11:5: error: 'ifstream' was not declared in this scope
   11 |     ifstream ifs("2176_input.txt");
      |     ^~~~~~~~
a.cc:14:9: error: 'vector' was not declared in this scope
   14 |         vector<int> m[100];
      |         ^~~~~~
a.cc:14:16: error: expected primary-expression before 'int'
   14 |         vector<int> m[100];
      |                ^~~
a.cc:15:16: error: expected primary-expression before 'int'
   15 |         vector<int> sum(N, 0);
      |                ^~~
a.cc:20:17: error: 'm' was not declared in this scope
   20 |                 m[i].push_back(_s);
      |                 ^
a.cc:21:17: error: 'sum' was not declared in this scope
   21 |                 sum[i] += _s;
      |                 ^~~
a.cc:27:21: error: 'm' was not declared in this scope
   27 |               while(m[i].size()){
      |                     ^
a.cc:28:19: error: 'sum' was not declared in this scope
   28 |                   sum[i] -= m[i].back();
      |                   ^~~
a.cc:29:23: error: 'max_element' was not declared in this scope
   29 |                   if(*max_element(sum.begin(), sum.end()) - sum[i] <= D){
      |                       ^~~~~~~~~~~
a.cc:39:23: error: 'sum' was not declared in this scope
   39 |         rep(i, N - 1) sum[i + 1] += sum[i];
      |                       ^~~
a.cc:40:12: error: 'sum' was not declared in this scope
   40 |         if(sum[N - 1] == 0)
      |            ^~~
a.cc:41:11: error: 'cout' was not declared in this scope
   41 |           cout << "YES" << endl;
      |           ^~~~
a.cc:41:28: error: 'endl' was not declared in this scope
   41 |           cout << "YES" << endl;
      |                            ^~~~
a.cc:43:11: error: 'cout' was not declared in this scope
   43 |           cout << "NO" << endl;
      |           ^~~~
a.cc:43:27: error: 'endl' was not declared in this scope
   43 |           cout << "NO" << endl;
      |                           ^~~~