Language: C++

#ifdef _WIN32
#define DEBUG	1
#endif

#define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;

#ifdef DEBUG
#include "include.h"
#else
inline void wait(){}
inline void dout(const char *arg, ...){}
#endif

//template<typename T>inline void swap(T a, T b){T t = a; a = b; b = t;}

#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define max(a, b) a > b ? a : b;
#define min(a, b) a > b ? b : a;
#define Sin(deg) sin((deg)*MATH_PI/180)
#define Cos(deg) cos((deg)*MATH_PI/180)
#define Tan(deg) tan((deg)*MATH_PI/180)
#define Rad(deg) ((deg)*MATH_PI/180)
#define ff(param, num) for(int param=0 ; param<num ; ++param)
#define fi(num) for(int i=0 ; i<num ; ++i)
#define fj(num) for(int j=0 ; j<num ; ++j)
#define fk(num) for(int k=0 ; k<num ; ++k)
#define fl(num) for(int l=0 ; l<num ; ++l)
#define fn(num) for(int n=0 ; n<num ; ++n)
#define ffr(param, num) for(int param=num-1 ; param>=0 ; --param)
#define fir(num) for(int i=num-1 ; i>=0 ; --i)
#define fjr(num) for(int j=num-1 ; j>=0 ; --j)
#define fkr(num) for(int k=num-1 ; k>=0 ; --k)
#define flr(num) for(int l=num-1 ; l>=0 ; --l)
#define fnr(num) for(int n=num-1 ; n>=0 ; --n)
#define gi(p) Scanf("%d", p)
#define gi2(p1, p2) Scanf2("%d %d", p1, p2)
#define gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3)
#define gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4)
#define gll(p) Scanf("%lld", p)
#define gll2(p1, p2) Scanf2("%lld %lld", p1, p2)
#define gll3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3)
#define gll4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4)
#define gf(p) Scanf("%f", p)
#define gf2(p1, p2) Scanf2("%f %f", p1, p2)
#define gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3)
#define gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4)
#ifdef DEBUG
#define gc(buf) fscanf(local_in.fp, "%s", buf)
#define Scanf(expr, p) fscanf(local_in.fp, expr, &p)
#define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4)
#else
#define gc(buf) Scanf("%s", buf)
#define Scanf(expr, p) scanf(expr, &p)
#define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4)
#endif
#define ans(p) cout << p << endl;
void CombSort(int N, int *ar, int order_ascending=1){int h=int(N/1.3);int flag;int i;while(true){flag=0;for(i=0;i+h<N;++i){if((order_ascending&&ar[i]>ar[i+h])||(!order_ascending&&ar[i]< ar[i+h])){swap<int>(ar[i],ar[i+h]);flag=1;}}if(h==1&&!flag)break;if(h==9||h==10) h=11;if(h>1)h=int(h/1.3);}}
int EuclideanAlgorithm(int N, int *ar){fn(N-1){while(true){if(ar[n]%ar[n+1]==0||ar[n+1]%ar[n]==0){ar[n+1]=min(ar[n],ar[n+1]);break;}if(ar[n]>ar[n+1]){ar[n]%= ar[n+1];}else{ar[n+1]%=ar[n];}}}return ar[N-1];}

int table[40] = {0};
long long int dat[100010] = {0};

#include <vector>
#include <algorithm>
using namespace std;
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
}; 
signed main() {

	int ii, jj, kk, ll;
	int ret = 0;
	int flag = 0;
	char cbuf[8192];

	int N, M;
	gi2(N, M);

	UnionFind tree(N+1);

	int A, B, C;
	fi(M){
		gi3(A, B, C);
		tree.unite(A, B);
	}

	fi(N){
		dat[tree.root(i+1)] = 1;
	}

	int cnt = 0;
	fi(N){
		if(dat[i+1]) cnt++;
	}
	
	
	ans(cnt);

	wait();

	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algo.h:59,
                 from /usr/include/c++/14/algorithm:61,
                 from a.cc:73:
/usr/include/c++/14/bits/algorithmfwd.h:408:41: error: macro "max" passed 3 arguments, but takes just 2
  408 |     max(const _Tp&, const _Tp&, _Compare);
      |                                         ^
a.cc:22:9: note: macro "max" defined here
   22 | #define max(a, b) a > b ? a : b;
      |         ^~~
/usr/include/c++/14/bits/algorithmfwd.h:421:41: error: macro "min" passed 3 arguments, but takes just 2
  421 |     min(const _Tp&, const _Tp&, _Compare);
      |                                         ^
a.cc:23:9: note: macro "min" defined here
   23 | #define min(a, b) a > b ? b : a;
      |         ^~~
/usr/include/c++/14/bits/algorithmfwd.h:449:30: error: macro "min" requires 2 arguments, but only 1 given
  449 |     min(initializer_list<_Tp>);
      |                              ^
a.cc:23:9: note: macro "min" defined here
   23 | #define min(a, b) a > b ? b : a;
      |         ^~~
/usr/include/c++/14/bits/algorithmfwd.h:459:30: error: macro "max" requires 2 arguments, but only 1 given
  459 |     max(initializer_list<_Tp>);
      |                              ^
a.cc:22:9: note: macro "max" defined here
   22 | #define max(a, b) a > b ? a : b;
      |         ^~~
In file included from /usr/include/c++/14/bits/stl_algo.h:65:
/usr/include/c++/14/bits/uniform_int_dist.h:188:11: error: macro "min" requires 2 arguments, but only 1 given
  188 |       min() const
      |           ^
a.cc:23:9: note: macro "min" defined here
   23 | #define min(a, b) a > b ? b : a;
      |         ^~~
/usr/include/c++/14/bits/uniform_int_dist.h:195:11: error: macro "max" requires 2 arguments, but only 1 given
  195 |       max() const
      |           ^
a.cc:22:9: note: macro "max" defined here
   22 | #define max(a, b) a > b ? a : b;
      |         ^~~
/usr/include/c++/14/bits/uniform_int_dist.h:295:72: error: macro "min" requires 2 arguments, but only 1 given
  295 |         constexpr __uctype __urngmin = _UniformRandomBitGenerator::min();
      |                                                                        ^
a.cc:23:9: note: macro "min" defined here
   23 | #define min(a, b) a > b ? b : a;
      |         ^~~
/usr/include/c++/14/bits/uniform_int_dist.h:296:72: error: macro "max" requires 2 arguments, but only 1 given
  296 |         constexpr __uctype __urngmax = _UniformRandomBitGenerator::max();
      |                                                                        ^
a.cc:22:9: note: macro "max" defined here
   22 | #define max(a, b) a > b ? a : b;
      |         ^~~
/usr/include/c++/14/bits/uniform_int_dist.h:390:35: error: macro "min" requires 2 arguments, but only 1 given
  390 |         static_assert( __urng.min() < __urng.max(),
      |                                   ^
a.cc:23:9: note: macro "min" defined here
   23 | #define min(a, b) a > b ? b : a;
      |         ^~~
/usr/include/c++/14/bits/uniform_int_dist.h:390:50: error: macro "max" requires 2 arguments, but only 1 given
  390 |         static_assert( __urng.min() < __urng.max(),
      |                                                  ^
a.cc:22:9: note: macro "max" defined here
   22 | #define max(a, b) a > b ? a : b;
      |         ^~~
/usr/include/c++/14/bits/uniform_int_dist.h:393:51: error: macro "min" requires 2 arguments, but only 1 given
  393 |         constexpr __uctype __urngmin = __urng.min();
      |                                                   ^
a.cc:23:9: note: macro "min" defined here
   23 | #define min(a, b) a > b ? b : a;
      |         ^~~
/usr/include/c++/14/bits/uniform_int_dist.h:394:51: error: macro "max" requires 2 arguments, but only 1 given
  394 |         constexpr __uctype __urngmax = __urng.max();
      |                                                   ^
a.cc:22:9: note: macro "max" defined here
   22 | #define max(a, b) a > b ? a : b;
      |         ^~~
/usr/include/c++/14/bits/stl_algo.h:3647:66: error: macro "min" passed 3 arguments, but takes just 2
 3647 |       return std::min(std::max(__val, __lo, __comp), __hi, __comp);
      |                                                                  ^
a.cc:23:9: note: macro "min" defined here
   23 | #define min(a, b) a > b ? b : a;
      |         ^~~
/usr/include/c++/14/bits/stl_algo.h:3720:45: error: macro "max" requires 2 arguments, but only 1 given
 3720 |       const __uc_type __urngrange = __g.max() - __g.min();
      |                                             ^
a.cc:22:9: note: macro "max" defined here
   22 | #define max(a, b) a > b ? a : b;
      |         ^~~
/usr/include/c++/14/bits/stl_algo.h:3720:57: error: macro "min" requires 2 arguments, but only 1 given
 3720 |       const __uc_type __urngrange = __g.max() - __g.min();
      |                                                         ^
a.cc:23:9: note: macro "min" defined here
   23 | #define min(a, b) a > b ? b : a;
      |         ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:34: error: macro "min" requires 2 arguments, but only 1 given
 5686 |     min(initializer_list<_Tp> __l)
      |                                  ^
a.cc:23:9: note: macro "min" defined here
   23 | #define min(a, b) a > b ? b : a;
      |         ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:34: error: macro "max" requires 2 arguments, but only 1 given
 5706 |     max(initializer_list<_Tp> __l)
      |                                  ^
a.cc:22:9: note: macro "max" defined here
   22 | #define max(a, b) a > b ? a : b;
      |         ^~~
/usr/include/c++/14/bits/stl_algo.h:5777:45: error: macro "max" requires 2 arguments, but only 1 given
 5777 |       const __uc_type __urngrange = __g.max() - __g.min();
      |                                             ^
a.cc:22:9: note: macro "max" defined here
   22 | #define max(a, b) a > b ? a : b;
      |         ^~~
/usr/include/c++/14/bits/stl_algo.h:5777:57: error: macro "min" requires 2 arguments, but only 1 given
 5777 |       const __uc_type __urngrange = __g.max() - __g.min();
      |                                                         ^
a.cc:23:9: note: macro "min" defined here
   23 | #define min(a, b) a > b ? b : a;
      |         ^~~
/usr/include/c++/14/bits/stl_bvector.h: In member function 'std::vector<bool, _Alloc>::size_type std::vector<bool, _Alloc>::_M_check_len(size_type, const char*) const':
/usr/include/c++/14/bits/stl_bvector.h:1535:47: error: no matching function for call to 'size()'
 1535 |         const size_type __len = size() + std::max(size(), __n);
      |                                               ^
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:7:
/usr/include/c++/14/bits/range_access.h:262:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:272:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/algorithmfwd.h: At global scope:
/usr/include/c++/14/bits/algorithmfwd.h:403:5: error: expected initializer before '&' token
  403 |     max(const _Tp&, const _Tp&);
      |     ^~~
/usr/include/c++/14/bits/algorithmfwd.h:408:5: error: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max' conflicts with a previous declaration
  408 |     max(const _Tp&, const _Tp&, _Compare);
      |     ^~~
In file included from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: previous declaration 'namespace std { }::max'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/algorithmfwd.h:416:5: error: expected initializer before '&' token
  416 |     min(const _Tp&, const _Tp&);
      |     ^~~
/usr/include/c++/14/bits/algorithmfwd.h:421:5: error: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min' conflicts with a previous declaration
  421 |     min(const _Tp&, const _Tp&, _Compare);
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: previous declaration 'namespace std { }::min'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/algorithmfwd.h:449:5: error: 'template<class _Tp> constexpr const _Tp std::min' conflicts with a previous declaration
  449 |     min(initializer_list<_Tp>);
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: previous declaration 'namespace std { }::min'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:23:21: error: invalid declarator before '>' token
   23 | #define min(a, b) a > b ? b : a;
      |                     ^
/usr/include/c++/14/bits/algorithmfwd.h:459:5: error: 'template<class _Tp> constexpr const _Tp std::max' conflicts with a previous declaration
  459 |     max(initializer_list<_Tp>);
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: previous declaration 'namespace std { }::max'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:22:21: error: invalid declarator before '>' token
   22 | #define max(a, b) a > b ? a : b;
      |                     ^
/usr/include/c++/14/bits/uniform_int_dist.h:188:7: error: expected ';' at end of member declaration
  188 |       min() const
      |       ^~~
      |          ;
/usr/include/c++/14/bits/uniform_int_dist.h:189:7: error: expected unqualified-id before '{' token
  189 |       { return this->a(); }
      |       ^