hehehehehe
Code\ncpp []\nclass Solution {\npublic:\n    string tostg(int a){\n        string ans="";\n        while(a){\n            ans+=(\'0\'+(a%10));\n            a/=1
# Code\n```cpp []\nclass Solution {\npublic:\n    string tostg(int a){\n        string ans="";\n        while(a){\n            ans+=(\'0\'+(a%10));\n            a/=10;\n        }\n        return ans;\n    }\n    int countPairs(vector<int>& nums) {\n        map<int,int> mp;\n        vector<string> v;\n        int maxi=*max_element(nums.begin(),nums.end());\n        string chk=tostg(maxi);\n        int maxsz=chk.size();\n        // int maxsz = 7;\n        for(auto it:nums){\n            string s1=tostg(it);\n            int diff=maxsz-s1.size();\n            while(diff--){\n                s1+=\'0\';\n            }\n            reverse(s1.begin(),s1.end());\n            mp[it]++;\n            v.push_back(s1);\n        }\n        // for(auto it:v){cout<<it<<\' \';}\n        // cout<<endl;\n        // cout<<endl;\n        // for(auto it:mp){\n        //     cout<<it.first<<\' \'<<it.second<<endl;\n        // }\n        int sz=maxsz;\n        int ans=0;\n        for(auto it:v){\n            string s=it;\n            \n            mp[stoi(s)]--;\n            // set<string> st;\n            set<int> st;\n            st.insert(stoi(s));\n            for(int i=0;i<sz;i++){\n                for(int j=i+1;j<sz;j++){\n\n                    string s2=s;\n                    if(s2[i] == s2[j])\n                    {\n                        continue;\n                    }\n\n                    swap(s2[i],s2[j]);\n\n                    st.insert(stoi(s2));\n\n                    for(int k=0;k<sz;k++){\n                        for(int l=k+1;l<sz;l++){\n                            if(min(k,l) == min(i,j) && max(k,l) == max(i,j))\n                            {\n                                continue;\n                            }\n                            string s3 = s2;\n                            if(s3[k] == s3[l])\n                            {\n                                continue;\n                            }\n                            swap(s3[k],s3[l]);\n                            st.insert(stoi(s3));\n                        }\n                    }\n                }\n            }\n            for(auto it:st){\n                    ans+=mp[it];\n            }\n        }\n        return ans;\n        \n    }\n        \n};\n```
['C++']