Why is my code not working?

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll T;
cin >> T;
while(T–){
ll N,M;
cin >> N >> M;
vectora;
vectorleft;
vectorright;
for(ll i = 0 ; i < N; i++){
ll x;
cin >> x;
a.push_back(x);
}
for(ll i = 0 ; i < N ; i++){
if(a[i]==1)left.push_back(i);
else if(a[i]==2)right.push_back(i);
}
ll o = M;
while(o–){
ll des;
cin >> des;
ll des1 = INT_MAX;
ll des2 = INT_MAX;
auto it = lower_bound(left.begin(),left.end(),des);
if(it != left.end()){
des1 = *it - des;
}
auto id = lower_bound(right.begin(),right.end(),des);
if(id != right.end() && (*id)== des){
des2 = 0;
}
else {
if(id != right.begin()){
id–;
des2 = des - (*id);
}
}

        ll ans = min(des1,des2);
        if(ans==INT_MAX)cout << -1 << " ";
        if (des==1) cout << 0 << " ";
        else cout << ans << " ";
    }
    cout << endl;
}
return 0;

}

problem : Contest Page | CodeChef

Please go through your code once again, there’s many error, bugs and undeclared variables. Read compiler error and warning, I am sure you can solve it.