Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int N;

void train(int i, int &ans){
  if(i == N) return;
  

  

  while(time[i][1] > ans || ans % time[i][2] != 0){
      ans++:
  }
  
  
  train(i+1, ans+time[i][0]);
  return;
}

  
  
int main(){ 
  cin >> N;
  vector<vector<int>> time(N-1, vector<int> (3, 0));
  rep(i, N-1) rep(J, 3) cin >> time[i][j];
  
  //i駅にいるとき
  rep(i, N-1){
    ans = time[i][1]+time[i][0];
    train(i+1, ans);
    cout << ans << endl;
  }
  
  cout << 0 << endl;
}

Compiler output:
a.cc: In function 'void train(int, int&)':
a.cc:14:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   14 |   while(time[i][1] > ans || ans % time[i][2] != 0){
      |               ^
a.cc:14:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   14 |   while(time[i][1] > ans || ans % time[i][2] != 0){
      |                  ^
a.cc:14:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |   while(time[i][1] > ans || ans % time[i][2] != 0){
      |         ~~~~~~~~~~~^~~~~
a.cc:14:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   14 |   while(time[i][1] > ans || ans % time[i][2] != 0){
      |                                         ^
a.cc:14:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   14 |   while(time[i][1] > ans || ans % time[i][2] != 0){
      |                                            ^
a.cc:14:33: error: invalid operands of types 'int' and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator%'
   14 |   while(time[i][1] > ans || ans % time[i][2] != 0){
      |                             ~~~ ^ ~~~~~~~~~~
      |                             |              |
      |                             int            time_t(time_t*) noexcept {aka long int(long int*) noexcept}
a.cc:15:12: error: expected ';' before ':' token
   15 |       ans++:
      |            ^
      |            ;
a.cc:19:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |   train(i+1, ans+time[i][0]);
      |                        ^
a.cc:19:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |   train(i+1, ans+time[i][0]);
      |                           ^
a.cc:19:17: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |   train(i+1, ans+time[i][0]);
      |              ~~~^~~~~~~~~~~
a.cc:19:17: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
   19 |   train(i+1, ans+time[i][0]);
      |              ~~~^~~~~~~~~~~
      |                 |
      |                 time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:8:24: note:   initializing argument 2 of 'void train(int, int&)'
    8 | void train(int i, int &ans){
      |                   ~~~~~^~~
a.cc:19:17: error: cannot bind rvalue '(int)(time + (((sizetype)i) + ((sizetype)ans)))' to 'int&'
   19 |   train(i+1, ans+time[i][0]);
      |              ~~~^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:28:40: error: 'j' was not declared in this scope
   28 |   rep(i, N-1) rep(J, 3) cin >> time[i][j];
      |                                        ^
a.cc:32:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |     ans = time[i][1]+time[i][0];
      |     ^~~
      |     abs