Chopsticks problem

#include
#include<bits/stdc++.h>
#include

using namespace std;

int choppair(vectorchopsticks,int n,int d)
{
int t= 0;
for(int i = 0;i<n;i++)
{
for(int j =0;j<n;j++)
{
if(abs(chopsticks[i]-chopsticks[j])<=2 && i !=j)
{

         t++;   
        }
    
    }

  return t ; 
}

}
int main()
{
int n,d,m;

cin>>n;
cin>>d;
vector<int>chop(n);
for(int i=0;i<n;i++)
{
    cin>>chop[i];
    
}
m = choppair(chop,n,d);
cout<<m;
return 0 ;

}

this is my code and i m getting a wrong anwer though even it was successfully executed for sample test case

first syntactical mistake, you wrote return statement in for loop.
second is logical mistake, you code will make pair of i and j wil also make a pair with j and i.

consider these three values to be in array 9 9 9 .
you code will pair each 9 to other 2 two nines and output would be 6. where it should have been 1.