WA - Suggest the changes

#include<bits/stdc++.h>

using namespace std;

int maxLenAP(vector<int> v){
	int n = v.size();

	// for(auto i:v)	cout<<i<<" ";
	// cout<<endl;

	int ans = 0;

	map<int, set<int> > m;

	for(int i=0;i<n;i++) m[v[i]].insert(i);

	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int k = 2;
			int d = v[j]-v[i];
			// cout<<v[i]<<" "<<v[j]<<"\t"<<d;
			// cout<<"\n---------------\n";

			int ind = j, cur;
			set<int> s;

			while(1){
				cur = v[ind]+d;
				s = m[cur];

				// cout<<v[ind]<<" "<<cur<<"\t";

				auto it = s.upper_bound(ind);

				if(it == s.end()){
					// cout<<"Last"<<endl;	
					break;
				}
				k++;
				// cout<<(*it)<<" "<<k<<endl;

				ind = (*it);
			}
			ans = max(ans,k);
			// cout<<ans<<endl;
			// cout<<"===============\n";
		}
	}
	return ans;
}

int main(){
    char s[100000],s1[1000000];
	cin>>s;
	for(int i=1;i<strlen(s)-1;i++)		s1[i-1]=s[i];
	
    char* t = strtok(s1,",");
    vector<int> v;

	while(t){
		v.push_back(atoi(t));
		t = strtok(NULL,",");
	}

	cout<<maxLenAP(v)<<endl;

    return 0;
}

@Hyperian hey there were many errors in your code . modified your code

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.