Language: C++

#ifndef ___Class_UnionFind
#define ___Class_UnionFind

// ------ Required ------ //
#include <vector>

// ------ Class ------ //
class QuickUnionFind {
private:
	unsigned size_; std::vector<unsigned> g; std::vector<std::vector<unsigned> > v;
public:
	QuickUnionFind() : size_(0), g(std::vector<unsigned>()), v(std::vector<std::vector<unsigned> >()) {};
	QuickUnionFind(unsigned size__) : size_(size__) {
		g.resize(size_); v.resize(size_);
		for (unsigned i = 0; i < size_; i++) g[i] = i, v[i] = { i };
	};
	unsigned size() { return size_; }
	unsigned root(unsigned x) { return g[x]; }
	unsigned size(unsigned x) { return v[x].size(); }
	bool same(unsigned x, unsigned y) { return g[x] == g[y]; }
	void unite(unsigned x, unsigned y) {
		x = g[x], y = g[y];
		if (x == y) return;
		if (v[x].size() < v[y].size()) std::swap(x, y);
		v[x].insert(v[x].end(), v[y].begin(), v[y].end());
		for (auto &e : v[y]) g[e] = x;
		v[y].clear();
	}
	bool operator==(const QuickUnionFind& u) { return g == u.g; }
	bool operator!=(const QuickUnionFind& u) { return g != u.g; }
};

#endif

#include <iostream>
#include <algorithm>
using namespace std;
int n, a[109];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	QuickUnionFind uf(n);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] % a[j] == 0 || a[j] % a[i] == 0) {
				uf.unite(i, j);
			}
		}
	}
	int ret = 0;
	for (int i = 0; i < n; i++) ret = max(ret, uf.size(i));
	cout << ret << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:46: error: no matching function for call to 'max(int&, unsigned int)'
   51 |         for (int i = 0; i < n; i++) ret = max(ret, uf.size(i));
      |                                           ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:51:46: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'unsigned int')
   51 |         for (int i = 0; i < n; i++) ret = max(ret, uf.size(i));
      |                                           ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:36:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:51:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   51 |         for (int i = 0; i < n; i++) ret = max(ret, uf.size(i));
      |                                           ~~~^~~~~~~~~~~~~~~~~