Edit a c++ code that I’ve made

Job ID: 35002183

Budget: $10 – $30 CAD

#include <bits/stdc++.h>

using namespace std;

int main() {
int t;
cin>>t;
int m,n;
while(t--){
cin>>m;
vector<string> per;
vector<int> count;
string s;
int meals=0,days=1;
for(int i=0;i<m;i++){
cin>>s;
cin>>n;
bool exist=false;
for(auto val:per){
if(val==s) exist=true;
}

if(!exist){
per.push_back(s);
count.push_back(-1*n);
}
else{
int j=0;
while(true){
if(s==per[j]) break;
j++;
}
count[j]-=n;
}

exist=false;
for(int j=0;j<n;j++){
cin>>s;
for(auto val:per){
if(val==s) exist=true;
}

if(!exist){
per.push_back(s);
count.push_back(1);
}
else{
int j=0;
while(true){
if(s==per[j]) break;
j++;
}
count[j]++;
}
}

}
int min=0;
for(int w=0;w<per.size();w++){
if(count[w]>0)
meals+=count[w];
if(count[w]<min)
min=count[w];
}

days=min;

cout<<meals<<" "<<abs(days)<<endl;
}

}

That’s the code and it’s not working properly I need someone to edit it based on the requirements, pleas take a look at the code and pictures posted
Related categories: PHP C Programming Python C# Programming C++ Programming