Language: C++



#include <iostream>


//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll


//std::ios::sync_with_stdio(false); cin.tie(NULL);

int countDivisors( int n) 
{ 
     int cnt = 0; 
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
/*inline bool isprime(int n){
   //2 is considered as prime 
   if(n==2){
        return true;
    }
    //if number is even then its not prime
    else if(n%2==0){
        return false;
    }
    else{
        //we can skip to check divisible by even numbers as the numbers which came to this else will only be odds
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}
int  seive(int n)
{   //declaring a boolean array of n elements
    int primes[n+1];
    int count=0;//to count number of primes upto n
    //intializing a boolean array of n elements with 1
    //(assuming that all elements are prime)
    for(int i=0;i<=n;++i)
    {
        primes[i]=1;
    }
    //now removing 0,1 through the list of prime because the are not prime 
    primes[0]=0;primes[1]=0;
  
    //traversing all the numbers from 2 to n 
    //now start with first prime number and go upto sqrt(n)
    for(int i=2;i*i<=n;++i)
    {    
        //checks that the number is prime if yes then it will 
        //remove all multiples of that number n
        if(primes[i]==1)
        {
          
           for(int j=2;i*j<=n;j++)
           {
               primes[i*j]=0;//crosses all the multiple of the number 
           }
           
        }
        
    }
    for(int i=0;i<n;++i)
    {
        if ( primes[i]==1)
         {
            // cout<<i<<" ";
             count++;
         }
    }
     return count;
}
inline int gcd (int a, int b) {
    // 1 case : when a=0
    if (a == 0)
        return b;
   // 2 case : when b=0
    else if(b==0)
        return a;
  // 3 case : when a!=0 and b!=0
    else
        return gcd (b,a%b);
}
int LCM(int a, int b)
{
return b*a/gcd(a,b);
}*/
int main()
{
    int  n,sum=0;
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        sum+=i*countDivisors(i);
    }
    cout<<sum<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'long long int countDivisors(long long int)':
a.cc:43:26: error: 'sqrt' was not declared in this scope
   43 |     for (int i = 1; i <= sqrt(n); i++) {
      |                          ^~~~
At global scope:
cc1plus: error: '::main' must return 'int'