Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
using namespace std;

class data {
	public:
		int a, b;
		int c;

		data(int p1, int p2, int cost) {
			a = p1;
			b = p2;
			c = cost;
		}

		bool operator<(const data & c_) const {
			return c > c_.c;
		}
};

int n, m;
vector<data> cost;
vector<data> modefied_cost;
vector<vector<int> > used_point;

void init() {
	cost.clear();
	modefied_cost.clear();
	used_point.clear();
}

bool input() {
	cin >> n;
	if(!n)
		return false;

	cin >> m;
	for(int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d,%d,%d", &a, &b, &c);
		cost.push_back(data(a, b, c));
	}

	return true;
}

void modefy_cost() {
	for(int i = 0; i < cost.size(); i++) {
		modefied_cost.push_back(data(cost[i].a, cost[i].b, cost[i].c / 100 - 1));
	}
}

pair<pair<int,int>,pair<int,int> > find_point(data d) {
	pair<pair<int, int>, pair<int, int> > ij_pair(pair<int,int>(-1, -1), pair<int,int>(-2, -2));
	for(int i = 0; i < used_point.size(); i++) {
		for(int j = 0; j < used_point[i].size(); j++) {
			if(used_point[i][j] == d.a) {
				ij_pair.first.first = i;
				ij_pair.first.second = j;
			}
			else if(used_point[i][j] == d.b) {
				ij_pair.second.first = i;
				ij_pair.second.second = j;
			}
		}
	}

	return ij_pair;
}

int solve() {
	modefy_cost();
	sort(modefied_cost.begin(), modefied_cost.end());
	int ans = 0;

	for(int i = 1; i < modefied_cost.size(); i++) {
		pair<pair<int,int>,pair<int,int> > tmp;
		tmp = find_point(modefied_cost[i]);

		if(tmp.first.first == tmp.second.first)
			continue;

		else if(tmp.first.first > -1 && tmp.second.first < 0) {
			used_point[tmp.first.first].push_back(modefied_cost[i].b);
			ans += modefied_cost[i].c;
		}
		else if(tmp.first.first < 0 && tmp.second.first > -1) {
			used_point[tmp.second.first].push_back(modefied_cost[i].a);
			ans += modefied_cost[i].c;
		}
		else if(tmp.first.first > -1 && tmp.second.first > -1) {
			used_point[tmp.first.first].insert(used_point[tmp.first.first].end(),
					used_point[tmp.second.first].begin(), used_point[tmp.second.first].end());
			used_point.erase(used_point.begin() + tmp.second.first, used_point.begin() + tmp.second.first + 1);
			ans += modefied_cost[i].c;
		}
		else {
			used_point.push_back(vector<int>(modefied_cost[i].a, modefied_cost[i].b));
			ans += modefied_cost[i].c;
		}
	}
	return ans;
}

int main() {
	while(init(), input()) {
		cout << solve() << endl;
	}
}

Compiler output:
a.cc:24:12: error: template argument 1 is invalid
   24 | vector<data> cost;
      |            ^
a.cc:24:12: error: template argument 2 is invalid
a.cc:25:12: error: template argument 1 is invalid
   25 | vector<data> modefied_cost;
      |            ^
a.cc:25:12: error: template argument 2 is invalid
a.cc: In function 'void init()':
a.cc:29:14: error: request for member 'clear' in 'cost', which is of non-class type 'int'
   29 |         cost.clear();
      |              ^~~~~
a.cc:30:23: error: request for member 'clear' in 'modefied_cost', which is of non-class type 'int'
   30 |         modefied_cost.clear();
      |                       ^~~~~
a.cc: In function 'bool input()':
a.cc:43:22: error: request for member 'push_back' in 'cost', which is of non-class type 'int'
   43 |                 cost.push_back(data(a, b, c));
      |                      ^~~~~~~~~
a.cc:43:32: error: reference to 'data' is ambiguous
   43 |                 cost.push_back(data(a, b, c));
      |                                ^~~~
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:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:7: note:                 'class data'
    7 | class data {
      |       ^~~~
a.cc: In function 'void modefy_cost()':
a.cc:50:33: error: request for member 'size' in 'cost', which is of non-class type 'int'
   50 |         for(int i = 0; i < cost.size(); i++) {
      |                                 ^~~~
a.cc:51:31: error: request for member 'push_back' in 'modefied_cost', which is of non-class type 'int'
   51 |                 modefied_cost.push_back(data(cost[i].a, cost[i].b, cost[i].c / 100 - 1));
      |                               ^~~~~~~~~
a.cc:51:41: error: reference to 'data' is ambiguous
   51 |                 modefied_cost.push_back(data(cost[i].a, cost[i].b, cost[i].c / 100 - 1));
      |                                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:7: note:                 'class data'
    7 | class data {
      |       ^~~~
a.cc:51:50: error: invalid types 'int[int]' for array subscript
   51 |                 modefied_cost.push_back(data(cost[i].a, cost[i].b, cost[i].c / 100 - 1));
      |                                                  ^
a.cc:51:61: error: invalid types 'int[int]' for array subscript
   51 |                 modefied_cost.push_back(data(cost[i].a, cost[i].b, cost[i].c / 100 - 1));
      |                                                             ^
a.cc:51:72: error: invalid types 'int[int]' for array subscript
   51 |                 modefied_cost.push_back(data(cost[i].a, cost[i].b, cost[i].c / 100 - 1));
      |                                                                        ^
a.cc: At global scope:
a.cc:55:47: error: reference to 'data' is ambiguous
   55 | pair<pair<int,int>,pair<int,int> > find_point(data d) {
      |                                               ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:7: note:                 'class data'
    7 | class data {
      |       ^~~~
a.cc:55:55: error: expected ',' or ';' before '{' token
   55 | pair<pair<int,int>,pair<int,int> > find_point(data d) {
      |                                                       ^
a.cc: In function 'int solve()':
a.cc:75:28: error: request for member 'begin' in 'modefied_cost', which is of non-class type 'int'
   75 |         sort(modefied_cost.begin(), modefied_cost.end());
      |                            ^~~~~
a.cc:75:51: error: request for member 'end' in 'modefied_cost', which is of non-class type 'int'
   75 |         sort(modefied_cost.begin(), modefied_cost.end());
      |                                                   ^~~
a.cc:75:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   75 |         sort(modefied_cost.begin(), modefied_cost.end());
      |         ^~~~
      |         short
a.cc:78:42: error: request for member 'size' in 'modefied_cost', which is of non-class type 'int'
   78 |         for(int i = 1; i < modefied_cost.size(); i++) {
      |                                          ^~~~
a.cc:80:47: error: invalid types 'int[int]' for array subscript
   80 |                 tmp = find_point(modefied_cost[i]);
      |                                               ^
a.cc:86:76: error: invalid types 'int[int]' for array subscript
   86 |                         used_point[tmp.first.first].push_back(modefied_cost[i].b);
      |                                                                            ^
a.cc:87:45: error: invalid types 'int[int]' for array subscript
   87 |                         ans += modefied_cost[i].c;
      |                                             ^
a.cc:90:77: error: invalid types 'int[int]' for array subscript
   90 |                         used_point[tmp.second.first].push_back(modefied_cost[i].a);
      |                                                                             ^
a.cc:91:45: error: invalid types 'int[int]' for array subscript
   91 |                         ans += modefied_cost[i].c;
      |                                             ^
a.cc:97:45: error: invalid types 'int[int]' for array subscript
   97 |                         ans += modefied_cost[i].c;
      |                                             ^
a.cc:100:71: error: invalid types 'int[int]' for array subscript
  100 |                         used_point.push_back(vector<int>(modefied_cost[i].a, modefied_cost[i].b));
      |                                                                       ^
a.cc:100:91: error: invalid types 'int[int]' for array subscript
  100 |                         used_point.push_back(vector<int>(modefied_cost[i].a, modefied_cost[i].b));
      |                                                                                           ^
a.cc:101:45: error: invalid types 'int[int]' for array subscript
  101 |                         ans += modefied_cost[i].c;
      |                                             ^