Language: C++

#include <bits/stdc++.h>
using namespace std;              

#define SZ size()
#define MIN LLONG_MIN
#define MAX LLONG_MAX
#define M 1000000007
#define MP make_pair
#define F first
#define S second
#define endl "\n"
#define sqr(x) ((x)*(x))
#define INF 0x3f3f3f3f

#define pb push_back
#define N 100005
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<char> vc;
typedef vector< vc > vvc;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector< vb > vvb;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef set<pii> spii;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<char, int> mci;
typedef map<string, int> msi;
//    vector<vector<int> > vec( n , vector<int> (m, 0)); 
//  memset(a, 0, sizeof(a)); -> a array hai

 
 vector<string> vec(10);
int main(){
	ll n,cnt = 0;  cin >> n;
	 for(int i =0;i<n;i++)cin >> vec[i];
	// sort(vec.begin(),vec.end(),greater<string>());
	 sort(vec.begin(),vec.end());

	for(int i =0;i<n;i++){
	//	cout << vec[i] << "\n";
	}
		for(int i =0;i<n;i++) {
			for(int j = i + 1;j<n;j++) {
				if(abs(vec[i].size() - vec[j].size()) == 1 ){
					string p = vec[i][0] + vec[i].substr(2,vec[i].size()-2);
					string ss = vec[i][1] + vec[i].substr(2,vec[i].size()-2);
						// cout << p << "   " << ss << "\n";
					if(vec[j] == p || vec[j] == ss)cnt++;
				}
			}
		}
	  cout << cnt << "\n";

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:39: error: call of overloaded 'abs(std::__cxx11::basic_string<char>::size_type)' is ambiguous
   53 |                                 if(abs(vec[i].size() - vec[j].size()) == 1 ){
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~