Here is my code for the problem at CodeChef: Practical coding for everyone

```
#include <bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define inf 1e+18L
int main()
{
FastIO
int t;
cin >> t;
while(t--)
{
int n, m;
cin >> n >> m;
vector<int> f(n), p(n);
rep(i,0,n) cin >> f[i];
rep(i,0,n) cin >> p[i];
vector<int> cost(m, 0);
rep(i,0,n) cost[f[i]] += p[i];
int minCost = INT_MAX;
for(auto c : cost)
{
if(c == 0)
continue;
minCost = min(minCost, c);
}
cout << minCost << "\n";
}
return 0;
}
```

It works correctly for the sample test case but gives WA on submission. Where am I going wrong? Please help.