Language: C++

#include<bits/stdc++.h>
using namespace std;
string to_string(int a)
{
    ostringstream temp;
    temp << a;
    return temp.str();
}
string multiply(string num1, string num2)
{
    int len1 = num1.size();
    int len2 = num2.size();
    if (len1 == 0 || len2 == 0)
    return "0";

    // will keep the result number in vector
    // in reverse order
    vector<int> result(len1 + len2, 0);

    // Below two indexes are used to find positions
    // in result.
    int i_n1 = 0;
    int i_n2 = 0;

    // Go from right to left in num1
    for (int i=len1-1; i>=0; i--)
    {
        int carry = 0;
        int n1 = num1[i] - '0';

        // To shift position to left after every
        // multiplication of a digit in num2
        i_n2 = 0;

        // Go from right to left in num2
        for (int j=len2-1; j>=0; j--)
        {
            // Take current digit of second number
            int n2 = num2[j] - '0';

            // Multiply with current digit of first number
            // and add result to previously stored result
            // at current position.
            int sum = n1*n2 + result[i_n1 + i_n2] + carry;

            // Carry for next iteration
            carry = sum/10;

            // Store result
            result[i_n1 + i_n2] = sum % 10;

            i_n2++;
        }

        // store carry in next cell
        if (carry > 0)
            result[i_n1 + i_n2] += carry;

        // To shift position to left after every
        // multiplication of a digit in num1.
        i_n1++;
    }

    // ignore '0's from the right
    int i = result.size() - 1;
    while (i>=0 && result[i] == 0)
    i--;

    // If all were '0's - means either both or
    // one of num1 or num2 were '0'
    if (i == -1)
    return "0";

    // generate the result string
    string s = "";

    while (i >= 0)
        s += to_string(result[i--]);

    return s;
}
#define MOD 1000000007
int main()
{
    map<string,long long>mp;
    int n;
    cin>>n;
    long long ans = 0;
    for(int i=1; i<=n; i++)
    {
        string s1,s2;
        cin>>s1>>s2;
        int m1 = 1, m2 = 1;
        if(s1[0]=='-'){
                m1 = -1;
                s1 =s1.substr(1);
        }
        if(s2[0]=='-'){
                m2 = -1;
                s2 =s2.substr(1);
        }
        string s = multiply(s1,s2);
        //cout<<s<<endl;
        if(m1*m2 == -1)
        {
            s = "-"+s;
        }
        if(mp.find(s)!=mp.end())
        {
            int nn = i-1;
            long long prev = (nn*(nn-1))/2;
            ans = (ans%MOD + prev%MOD)%MOD;
        }
        else
        {
            int nn = i-1;
            long long left = (nn-mp[s]);
            nn = left;
            long long prev = (nn*(nn-1))/2;
            ans = (ans%MOD + prev%MOD)%MOD;
        }
        mp[s]++;
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'std::string multiply(std::string, std::string)':
a.cc:78:23: error: call of overloaded 'to_string(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' is ambiguous
   78 |         s += to_string(result[i--]);
      |              ~~~~~~~~~^~~~~~~~~~~~~
a.cc:3:8: note: candidate: 'std::string to_string(int)'
    3 | string to_string(int a)
      |        ^~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4240:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
 4240 |   to_string(int __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4259:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
 4259 |   to_string(unsigned __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4275:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
 4275 |   to_string(long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4294:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
 4294 |   to_string(unsigned long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4310:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
 4310 |   to_string(long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4327:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
 4327 |   to_string(unsigned long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4401:3: note: candidate: 'std::string std::__cxx11::to_string(float)'
 4401 |   to_string(float __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4411:3: note: candidate: 'std::string std::__cxx11::to_string(double)'
 4411 |   to_string(double __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4421:3: note: candidate: 'std::string std::__cxx11::to_string(long double)'
 4421 |   to_string(long double __val)
      |   ^~~~~~~~~