Language: C++

#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

int n,m,price[5050];
map<string,int> id;

int par[200010]; // ???
int rnk[200010]; // ??±???

/* Union Find ????????? */
void init(int n){
  for(int i=0;i<=n;i++){
    par[i] = i;
    rnk[i] = 1;
  }
}

/* x???????????¨y?????????????????? */
void unite(int x, int y) {
    x = find(x); y = find(y);
    if(x == y) return;
    if(rnk[x] > rnk[y]) par[y] = x;
    else {
        par[x] = y;
        if(rnk[x] == rnk[y]) rnk[y]++;
    }
}

/* x????????????????????¢?´¢ */
int find(int x){
  if(par[x] == x){
    return x;
  }
  else {
    return par[x] = find(par[x]);
  }
}

/* x??¨y????????????????????????????????? */
bool same(int x,int y){
  return find(x) == find(y);
}

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		string str;
		int a;
		cin >> str >> a;
		id[str] = i;
		price[i] = a;
	}
	cin >> m;
	for(int i=0;i<m;i++){
		string a,b;
		cin >> a >> b;
		unite(id[a],id[b]);
	}
	for(int i=0;i<n;i++){
		price[find(i)] = min(price[find(i)],price[i]);
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		ans += price[find(i)];
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'void unite(int, int)':
a.cc:22:13: error: no matching function for call to 'find(int&)'
   22 |     x = find(x); y = find(y);
      |         ~~~~^~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 1 provided
a.cc:22:26: error: no matching function for call to 'find(int&)'
   22 |     x = find(x); y = find(y);
      |                      ~~~~^~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 1 provided