C++ Solution (Got 376 ms runtime)
Will love to hear the improvements for this code in terms of performance as well as code quality .\n\n\nclass Solution {\n    int MOD=1e9+7;\npublic:\n    int s
Will love to hear the improvements for this code in terms of performance as well as code quality .\n\n```\nclass Solution {\n    int MOD=1e9+7;\npublic:\n    int sumOfFlooredPairs(vector<int>& nums) {\n        vector<int> freq(1e5+1,0);\n        vector<int> validNums;\n        int maxNum=INT_MIN;\n        for(int i=0;i<nums.size();i++)\n        {\n            if(!freq[nums[i]])\n            {\n                validNums.push_back(nums[i]);\n            }\n            freq[nums[i]]++;\n            maxNum=max(maxNum,nums[i]);\n        }\n        int prevSum=0;\n        for(int i=1;i<=maxNum;i++)\n        {\n            freq[i]+=prevSum;\n            prevSum=freq[i];\n        }\n        int ans=0;\n        for(int i=0;i<validNums.size();i++)\n        {\n            int num=validNums[i];\n            int prevNum=0;\n            int quotient=0;\n            int currAns=0;\n            for(int j=num;j<=maxNum;j=j+num)\n            {\n                if(prevNum)\n                {\n                    int currQuotient=j/num;\n                    int currNum=j;\n                    if(currQuotient!=quotient)\n                    {\n                        currNum=j-1;\n                    }\n                    int count=freq[currNum]-freq[prevNum-1];\n                    currAns=(currAns%MOD+(quotient%MOD*count%MOD)%MOD)%MOD;\n                }\n                quotient=(j/num);\n                prevNum=j;\n            }\n            int count=freq[maxNum]-freq[prevNum-1];\n            int currNumFreq=freq[num]-freq[num-1];\n            currAns=(currAns%MOD+(count%MOD*quotient%MOD)%MOD)%MOD;\n            ans=(ans%MOD+((long long)currAns%MOD*currNumFreq%MOD)%MOD)%MOD;\n        }\n        return ans;\n        \n    }\n};\n```
[]