Help with UVA Runtime Error problem

Iโ€™m trying to submit this problem but the UVA Judge pop a Runtime error, how can I solve it?
Thanks :slight_smile:

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include <unordered_map>

using namespace std;

#define endl โ€˜\nโ€™
#define fastIO() cin.tie(0); cout.tie(0);
#define FO(i, b) for (int i = 0; i < (b); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rFOR(i, a, b) for (int i = (a); i > (b); iโ€“)
#define TR(v, arr) for(auto& (v) : (arr))
#define debug(x) cout << #x << " = โ€œ; _debug(x); cout << endl;
#define si(x) scanf(โ€%d", &x);
#define sl(x) scanf("%lld", &x);
#define pi(x) printf("%d\n", x);
#define pl(x) printf("%lld\n", x);
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define LB(arr,x) lower_bound(all(arr),x) -(arr).begin()
#define UB(arr,x) upper_bound(all(arr),x) -(arr).begin()

typedef long long ll;
typedef vector vi;
typedef vector vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD= 1e9 + 7;
const ll INF= 1e9;

void setIO(){
string file = FILE;
file = string(file.begin() , file.end() - 3);
string in_file = file+โ€œinโ€;
string out_file = file+โ€œoutโ€;
freopen(in_file.c_str() , โ€œrโ€, stdin);
freopen(out_file.c_str(), โ€œwโ€,stdout);
}

template
void _debug(T& x){
cout << x;
}

template <typename T1, typename T2>
void _debug(pair<T1,T2>& pair){

cout <<"{"; _debug(pair.F); cout << ","; _debug(pair.S); cout << "}";

}

template
void _debug(vector & vec){
int n = sz(vec);
if(n == 0){cout << โ€œ[ ]โ€; return;}
cout << โ€œ[โ€;
FO(i,n-1){
_debug(vec[i]); cout << " ";
}
_debug(vec[n - 1]); cout << โ€œjโ€;
}

void _debug(vector& vec){
int n= sz(vec);
cout << endl;
FO(i,n){

    cout << vec[i] << endl;
}

}

template
void _debug(vector<vector>& A){
int n = sz(A);
cout << endl;
FO(i,n){
_debug(A[i]); cout << endl;
}
}

template
void print(T& x){
cout << x << endl;
return;
}

template
void print(vector& vec, int a=0, int b=-1){
if(b == -1){b = sz(vec);}
if(b == 0){return;}
FOR(i, a, b - 1){
cout << vec[i] << " ";
}
cout << vec[b - 1] << endl;
return;
}

// -----------------------------------------------------------------------------
// Here begins our solution
// -----------------------------------------------------------------------------

class UnionFind { // OOP style
private:
vi p, rank, setSize; // remember: vi is vector
int numSets;
public:
UnionFind(int N) {
setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
void unionSet(int i, int j) {
if (!isSameSet(i, j)) { numSetsโ€“;
int x = findSet(i), y = findSet(j);
// rank is used to keep the tree short
if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
else { p[x] = y; setSize[y] += setSize[x];
if (rank[x] == rank[y]) rank[y]++; } } }
int numDisjointSets() { return numSets; }
int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

void solve() {
unordered_map<string,int> m;
int j = 1;
int f;
string a,b;
vector v;
si(f);

for (int i = 0; i < f; i++)
{
    cin >> a >> b;
    v.push_back(a);
    v.push_back(b);
}

for (int i = 0; i < v.size(); i++)
{
    if (m.find(v[i]) == m.end())
    {
        m.insert(make_pair(v[i],j));
        j++;
    }
}

UnionFind UF(m.size());

for (int i = 0; i < v.size(); i += 2)
{
    UF.unionSet(m[v[i]],m[v[i+1]]);
    cout << UF.sizeOfSet(UF.findSet(m[v[i]])) << endl;
}
m.clear();

}

int main() {
fastIO();
if(getenv(โ€œLOCALโ€)){setIO();}
int T; si(T);
FO(tc, T){
solve();
}
return 0;
}