Language: C++

#include<iostream>
#include<fstream>
#include<bitset>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>#include<iostream>
#include<fstream>
#include<bitset>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>
#include<climits>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}


#define int LL
#define rep(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF INT_MAX
#define INF LLONG_MAX
#define MOD ((int)pow(10,9)+7)



using namespace std;

using LL = long long;
using st = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<int>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<int>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<int, int>;
using ppi = pair<pi, int>;
using mii = map<int, int>;
using mpii = map<pi, int>;
using mib = map<int, bool>;
using mci = map<char, int>;
using msb = map<st, bool>;
using vpi = vector<pi>;
using vppi = vector<ppi>;
using spi = stack<pi>;
using qpi = queue<pi>;



//4,2,8,6,1,7,3,9,5
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };

istream &operator>>(istream &in, vi &v) {
	rep(i, size(v)) {
		in >> v[i];
	}
	return in;
}

ostream &operator<<(ostream &out, vi &v) {
	rep(i, size(v)) {
		out << "v[" << i << "] = " << v[i] << endl;
	}
	return out;
}

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL vmax(vi v) {
	int n = size(v);
	int MAX = 0;
	rep(i, n) {
		MAX = max(MAX, v[i]);
	}
	return MAX;
}

LL vmin(vi v) {
	int n = size(v);
	int MIN = INF;
	rep(i, n) {
		MIN = min(MIN, v[i]);
	}
	return MIN;
}

LL vsum(vi v) {
	int n = size(v);
	int sum = 0;
	rep(i, n) {
		sum += v[i];
	}
	return sum;
}

LL gcd(LL a, LL b) {
	if (b == 0) {
		swap(a, b);
	}
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

bool is_square(int n) {
	if ((int)sqrt(n)*(int)sqrt(n) == n) {
		return true;
	}
	else {
		return false;
	}
}


bool is_prime(int n) {
	if (n == 1) {
		return false;
	}
	else {
		for (int i = 2; i*i <= n; i++) {
			if (n % i == 0) {
				return false;
			}
		}
	}
	return true;
}

void dec_num(int n, vi &v) {
	int a = 2;
	v.push_back(1);
	v.push_back(n);
	while (a*a <= n) {
		if (n%a == 0) {
			v.push_back(a);
			v.push_back(n / a);

		}
		a++;
	}
	sort(all(v));
}


void dec_prime(int n, vi &v) {
	v.push_back(1);
	int a = 2;
	while (a*a <= n) {
		if (n % a == 0) {
			v.push_back(a);
			n /= a;
		}
		else {
			a++;
		}
	}
	v.push_back(n);
}


int sieve_prime(LL a, LL b) {
	if (a > b)swap(a, b);
	vb s(b + 1, true);
	int cnt_a = 0, cnt_b = 0;
	for (int i = 2; i <= b; i++) {
		for (int j = 2; i*j <= b; j++) {
			s[i*j] = false;
		}
	}
	for (int i = 2; i <= b; i++) {
		if (s[i]) {
			//cout << i << " ";
			if (i < a) {
				cnt_a++;
			}
			cnt_b++;
		}
	}
	return cnt_b - cnt_a;
}


LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= MOD;
	}
	return ret;
}


const int COMBMAX = 4000;
int comb[COMBMAX+5][COMBMAX+5];

void init_comb() {
	comb[0][0] = 1;
	rep(i, COMBMAX) {
		rep(j, i + 1) {
			comb[i + 1][j] += comb[i][j];
			comb[i + 1][j] %= MOD;
			comb[i + 1][j + 1] += comb[i][j];
			comb[i + 1][j + 1] %= MOD;
		}
	}
}

int combination(int n, int k) {
	if (k<0 || k>n)return 0;
	else return comb[n][k];
}


const int COMBMODMAX = 510000;
int fac[COMBMODMAX], facinv[COMBMODMAX], inv[COMBMODMAX];

void init_comb_mod() {
	fac[0] = fac[1] = 1;
	facinv[0] = facinv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < COMBMODMAX; i++) {
		fac[i] = fac[i - 1] * i%MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		facinv[i] = facinv[i - 1] * inv[i] % MOD;
	}
}

int comb_mod(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (facinv[k] * facinv[n - k] % MOD) % MOD;
}

int pow_mod(int x, int n, int p) {
	if (n == 0)return 0;
	int res = pow_mod(x*x%p, n / 2, p);
	if (n % 2 == 1)res = res * x % p;
	return res;
}

class UF {
public:

	vi par;
	vi rank;

	UF(int n) {
		par.resize(n, -1);
		rank.resize(n, 0);
	}
	
	int root(int x) {
		if (par[x] == -1)return x;
		return par[x] = root(par[x]);
	}

	//xの集合の位数
	int order(int x) {
		return -par[root(x)];
	}

	//xとyを併合
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) {
			return;
		}

		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if(rank[x]==rank[y])rank[x]++;
		}
	}

	//xとyが同じ集合にあるか
	bool is_same(int x, int y) {
		return root(x) == root(y);
	}
};

struct edge {
	int to;
	int cost;
};


using ve = vector<edge>;
using vve = vector<ve>;

/*****************************************************************************/
signed main() {

	int n;
	cin >> n;
	vi c(n - 1), s(n - 1), f(n - 1);
	rep(i, n - 1) {
		cin >> c[i] >> s[i] >> f[i];
	}
	rep(i, n) {
		int ans = 0;
		for(int j=i;j<n-1;j++) {
			if (ans < s[j]) {
				ans = s[j];
			}
			else {
				ans += ans % f[j];
			}
			ans += c[j];
		}
		cout << ans << endl;
	}
	return 0;
}
#include<regex>
#include<climits>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}


#define int LL
#define rep(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF INT_MAX
#define INF LLONG_MAX
#define MOD ((int)pow(10,9)+7)



using namespace std;

using LL = long long;
using st = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<int>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<int>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<int, int>;
using ppi = pair<pi, int>;
using mii = map<int, int>;
using mpii = map<pi, int>;
using mib = map<int, bool>;
using mci = map<char, int>;
using msb = map<st, bool>;
using vpi = vector<pi>;
using vppi = vector<ppi>;
using spi = stack<pi>;
using qpi = queue<pi>;



//4,2,8,6,1,7,3,9,5
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };

istream &operator>>(istream &in, vi &v) {
	rep(i, size(v)) {
		in >> v[i];
	}
	return in;
}

ostream &operator<<(ostream &out, vi &v) {
	rep(i, size(v)) {
		out << "v[" << i << "] = " << v[i] << endl;
	}
	return out;
}

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL vmax(vi v) {
	int n = size(v);
	int MAX = 0;
	rep(i, n) {
		MAX = max(MAX, v[i]);
	}
	return MAX;
}

LL vmin(vi v) {
	int n = size(v);
	int MIN = INF;
	rep(i, n) {
		MIN = min(MIN, v[i]);
	}
	return MIN;
}

LL vsum(vi v) {
	int n = size(v);
	int sum = 0;
	rep(i, n) {
		sum += v[i];
	}
	return sum;
}

LL gcd(LL a, LL b) {
	if (b == 0) {
		swap(a, b);
	}
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

bool is_square(int n) {
	if ((int)sqrt(n)*(int)sqrt(n) == n) {
		return true;
	}
	else {
		return false;
	}
}


bool is_prime(int n) {
	if (n == 1) {
		return false;
	}
	else {
		for (int i = 2; i*i <= n; i++) {
			if (n % i == 0) {
				return false;
			}
		}
	}
	return true;
}

void dec_num(int n, vi &v) {
	int a = 2;
	v.push_back(1);
	v.push_back(n);
	while (a*a <= n) {
		if (n%a == 0) {
			v.push_back(a);
			v.push_back(n / a);

		}
		a++;
	}
	sort(all(v));
}


void dec_prime(int n, vi &v) {
	v.push_back(1);
	int a = 2;
	while (a*a <= n) {
		if (n % a == 0) {
			v.push_back(a);
			n /= a;
		}
		else {
			a++;
		}
	}
	v.push_back(n);
}


int sieve_prime(LL a, LL b) {
	if (a > b)swap(a, b);
	vb s(b + 1, true);
	int cnt_a = 0, cnt_b = 0;
	for (int i = 2; i <= b; i++) {
		for (int j = 2; i*j <= b; j++) {
			s[i*j] = false;
		}
	}
	for (int i = 2; i <= b; i++) {
		if (s[i]) {
			//cout << i << " ";
			if (i < a) {
				cnt_a++;
			}
			cnt_b++;
		}
	}
	return cnt_b - cnt_a;
}


LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= MOD;
	}
	return ret;
}


const int COMBMAX = 4000;
int comb[COMBMAX+5][COMBMAX+5];

void init_comb() {
	comb[0][0] = 1;
	rep(i, COMBMAX) {
		rep(j, i + 1) {
			comb[i + 1][j] += comb[i][j];
			comb[i + 1][j] %= MOD;
			comb[i + 1][j + 1] += comb[i][j];
			comb[i + 1][j + 1] %= MOD;
		}
	}
}

int combination(int n, int k) {
	if (k<0 || k>n)return 0;
	else return comb[n][k];
}


const int COMBMODMAX = 510000;
int fac[COMBMODMAX], facinv[COMBMODMAX], inv[COMBMODMAX];

void init_comb_mod() {
	fac[0] = fac[1] = 1;
	facinv[0] = facinv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < COMBMODMAX; i++) {
		fac[i] = fac[i - 1] * i%MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		facinv[i] = facinv[i - 1] * inv[i] % MOD;
	}
}

int comb_mod(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (facinv[k] * facinv[n - k] % MOD) % MOD;
}

int pow_mod(int x, int n, int p) {
	if (n == 0)return 0;
	int res = pow_mod(x*x%p, n / 2, p);
	if (n % 2 == 1)res = res * x % p;
	return res;
}

class UF {
public:

	vi par;
	vi rank;

	UF(int n) {
		par.resize(n, -1);
		rank.resize(n, 0);
	}
	
	int root(int x) {
		if (par[x] == -1)return x;
		return par[x] = root(par[x]);
	}

	//xの集合の位数
	int order(int x) {
		return -par[root(x)];
	}

	//xとyを併合
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) {
			return;
		}

		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if(rank[x]==rank[y])rank[x]++;
		}
	}

	//xとyが同じ集合にあるか
	bool is_same(int x, int y) {
		return root(x) == root(y);
	}
};

struct edge {
	int to;
	int cost;
};


using ve = vector<edge>;
using vve = vector<ve>;

/*****************************************************************************/
signed main() {

	int n;
	cin >> n;
	vi c(n - 1), s(n - 1), f(n - 1);
	rep(i, n - 1) {
		cin >> c[i] >> s[i] >> f[i];
	}
	rep(i, n - 1) {
		int ans = 0;
		for(int j=i;j<n-1;j++){
			if (j == i)ans += s[j] + c[j];
			else {
				if (ans >= s[j]) {
					if ((ans - s[j]) % f[j] == 0) {
						ans += c[j];
					}
					else {
						ans += f[j] - (ans%f[j]);
					}
				}
				else {
					ans = s[j] + c[j];
				}
			}
		}
		cout << ans << endl;
	}
	cout << 0 << endl;
	return 0;
}

Compiler output:
a.cc:14:18: warning: extra tokens at end of #include directive
   14 | #include<utility>#include<iostream>
      |                  ^
a.cc:376:6: error: redefinition of 'void Init()'
  376 | void Init() {
      |      ^~~~
a.cc:31:6: note: 'void Init()' previously defined here
   31 | void Init() {
      |      ^~~~
a.cc:437:5: error: redefinition of 'LL dx []'
  437 | int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
      |     ^~
a.cc:92:5: note: 'LL dx [9]' previously defined here
   92 | int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
      |     ^~
a.cc:438:5: error: redefinition of 'LL dy []'
  438 | int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
      |     ^~
a.cc:93:5: note: 'LL dy [9]' previously defined here
   93 | int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
      |     ^~
a.cc:440:10: error: redefinition of 'std::istream& operator>>(std::istream&, vi&)'
  440 | istream &operator>>(istream &in, vi &v) {
      |          ^~~~~~~~
a.cc:95:10: note: 'std::istream& operator>>(std::istream&, vi&)' previously defined here
   95 | istream &operator>>(istream &in, vi &v) {
      |          ^~~~~~~~
a.cc:447:10: error: redefinition of 'std::ostream& operator<<(std::ostream&, vi&)'
  447 | ostream &operator<<(ostream &out, vi &v) {
      |          ^~~~~~~~
a.cc:102:10: note: 'std::ostream& operator<<(std::ostream&, vi&)' previously defined here
  102 | ostream &operator<<(ostream &out, vi &v) {
      |          ^~~~~~~~
a.cc:454:6: error: redefinition of 'void y_n(bool)'
  454 | void y_n(bool p) {
      |      ^~~
a.cc:109:6: note: 'void y_n(bool)' previously defined here
  109 | void y_n(bool p) {
      |      ^~~
a.cc:458:6: error: redefinition of 'void Y_N(bool)'
  458 | void Y_N(bool p) {
      |      ^~~
a.cc:113:6: note: 'void Y_N(bool)' previously defined here
  113 | void Y_N(bool p) {
      |      ^~~
a.cc:462:4: error: redefinition of 'LL vmax(vi)'
  462 | LL vmax(vi v) {
      |    ^~~~
a.cc:117:4: note: 'LL vmax(vi)' previously defined here
  117 | LL vmax(vi v) {
      |    ^~~~
a.cc:471:4: error: redefinition of 'LL vmin(vi)'
  471 | LL vmin(vi v) {
      |    ^~~~
a.cc:126:4: note: 'LL vmin(vi)' previously defined here
  126 | LL vmin(vi v) {
      |    ^~~~
a.cc:480:4: error: redefinition of 'LL vsum(vi)'
  480 | LL vsum(vi v) {
      |    ^~~~
a.cc:135:4: note: 'LL vsum(vi)' previously defined here
  135 | LL vsum(vi v) {
      |    ^~~~
a.cc:489:4: error: redefinition of 'LL gcd(LL, LL)'
  489 | LL gcd(LL a, LL b) {
      |    ^~~
a.cc:144:4: note: 'LL gcd(LL, LL)' previously defined here
  144 | LL gcd(LL a, LL b) {
      |    ^~~
a.cc:500:4: error: redefinition of 'LL lcm(LL, LL)'
  500 | LL lcm(LL a, LL b) {
      |    ^~~
a.cc:155:4: note: 'LL lcm(LL, LL)' previously defined here
  155 | LL lcm(LL a, LL b) {
      |    ^~~
a.cc:504:6: error: redefinition of 'bool is_square(LL)'
  504 | bool is_square(int n) {
      |      ^~~~~~~~~
a.cc:159:6: note: 'bool is_square(LL)' previously defined here
  159 | bool is_square(int n) {
      |      ^~~~~~~~~
a.cc:514:6: error: redefinition of 'bool is_prime(LL)'
  514 | bool is_prime(int n) {
      |      ^~~~~~~~
a.cc:169:6: note: 'bool is_prime(LL)' previously defined here
  169 | bool is_prime(int n) {
      |      ^~~~~~~~
a.cc:528:6: error: redefinition of 'void dec_num(LL, vi&)'
  528 | void dec_num(int n, vi &v) {
      |      ^~~~~~~
a.cc:183:6: note: 'void dec_num(LL, vi&)' previously defined here
  183 | void dec_num(int n, vi &v) {
      |      ^~~~~~~
a.cc:544:6: error: redefinition of 'void dec_prime(LL, vi&)'
  544 | void dec_prime(int n, vi &v) {
      |      ^~~~~~~~~
a.cc:199:6: note: 'void dec_prime(LL, vi&)' previously defined here
  199 | void dec_prime(int n, vi &v) {
      |      ^~~~~~~~~
a.cc:560:5: error: redefinition of 'LL sieve_prime(LL, LL)'
  560 | int sieve_prime(LL a, LL b) {
      |     ^~~~~~~~~~~
a.cc:215:5: note: 'LL sieve_prime(LL, LL)' previously defined here
  215 | int sieve_prime(LL a, LL b) {
      |     ^~~~~~~~~~~
a.cc:582:4: error: redefinition of 'LL factorial(LL)'
  582 | LL factorial(LL n) {
      |    ^~~~~~~~~
a.cc:237:4: note: 'LL factorial(LL)' previously defined here
  237 | LL factorial(LL n) {
      |    ^~~~~~~~~
a.cc:593:11: error: redefinition of 'const LL COMBMAX'
  593 | const int COMBMAX = 4000;
      |           ^~~~~~~
a.cc:248:11: note: 'const LL COMBMAX' previously defined here
  248 | const int COMBMAX = 4000;
      |           ^~~~~~~
a.cc:594:5: error: redefinition of 'LL comb [4005][4005]'
  594 | int comb[COMBMAX+5][COMBMAX+5];
      |     ^~~~
a.cc:249:5: note: 'LL comb [4005][4005]' previously declared here
  249 | int comb[COMBMAX+5][COMBMAX+5];
      |     ^~~~
a.cc:596:6: error: redefinition of 'void init_comb()'
  596 | void init_comb() {
      |      ^~~~~~~~~
a.cc:251:6: note: 'void init_comb()' previously defined here
  251 | void init_comb() {
      |      ^~~~~~~~~
a.cc:608:5: error: redefinition of 'LL combination(LL, LL)'
  608 | int combination(int n, int k) {
      |     ^~~~~~~~~~~
a.cc:263:5: note: 'LL combination(LL, LL)' previously defined here
  263 | int combination(int n, int k) {
      |     ^~~~~~~~~~~
a.cc:614:11: error: redefinition of 'const LL COMBMODMAX'
  614 | const int COMBMODMAX = 510000;
      |           ^~~~~~~~~~
a.cc:269:11: note: 'const LL COMBMODMAX' previously defined here
  269 | const int COMBMODMAX = 510000;
      |           ^~~~~~~~~~
a.cc:615:5: error: redefinition of 'LL fac [510000]'
  615 | int fac[COMBMODMAX], facinv[COMBMODMAX], inv[COMBMODMAX];
      |     ^~~
a.cc:270:5: note: 'LL fac [510000]' previously declared here
  270 | int fac[COMBMODMAX], facinv[COMBMODMAX], inv[COMBMODMAX];
      |     ^~~
a.cc:615:22: error: redefinition of 'LL facinv [510000]'
  615 | int fac[COMBMODMAX], facinv[COMBMODMAX], inv[COMBMODMAX];
      |                      ^~~~~~
a.cc:270:22: note: 'LL facinv [510000]' previously declared here
  270 | int fac[COMBMODMAX], facinv[COMBMODMAX], inv[COMBMODMAX];
      |                      ^~~~~~
a.cc:615:42: error: redefinition of 'LL inv [510000]'
  615 | int fac[COMBMODMAX], facinv[COMBMODMAX], inv[COMBMODMAX];
      |                                          ^~~
a.cc:270:42: note: 'LL inv [510000]' previously declared here
  270 | int fac[COMBMODMAX], facinv[COMBMODMAX], inv[COMBMODMAX];
      |                                          ^~~
a.cc:617:6: error: redefinition of 'void init_comb_mod()'
  617 | void init_comb_mod() {
      |      ^~~~~~~~~~~~~
a.cc:272:6: note: 'void init_comb_mod()' previously defined here
  272 | void init_comb_mod() {
      |      ^~~~~~~~~~~~~
a.cc:628:5: error: redefinition of 'LL comb_mod(LL, LL)'
  628 | int comb_mod(int n, int k) {
      |     ^~~~~~~~
a.cc:283:5: note: 'LL comb_mod(LL, LL)' previously defined here
  283 | int comb_mod(int n, int k) {
      |     ^~~~~~~~
a.cc:634:5: error: redefinition of 'LL pow_mod(LL, LL, LL)'
  634 | int pow_mod(int x, int n, int p) {
      |     ^~~~~~~
a.cc:289:5: note: 'LL pow_mod(LL, LL, LL)' previously defined here
  289 | int pow_mod(int x, int n, int p) {
      |     ^~~~~~~
a.cc:641:7: error: redefinition of 'class UF'
  641 | class UF {
      |       ^~
a.cc:296:7: note: previous definition of 'class UF'
  296 | class UF {
      |       ^~
a.cc:685:8: error: redefinition of 'struct edge'
  685 | struct edge {
      |        ^~~~
a.cc:340:8: note: previous definition of 'struct edge'
  340 | struct edge {
      |        ^~~~
a.cc:695:8: error: redefinition of 'int main()'
  695 | signed main() {
      |        ^~~~
a.cc:350:8: note: 'int main()' previously defined here
  350 | signed main() {
      |        ^~~~