title: Sum Pairwise Products 1
signature: int sumPairwiseProducts1(int n) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual == expected;
  }
  
  string driver(int n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver(41, 382571); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver(50, 834275); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver(67, 2645897); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver(18, 15675); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver(60, 1711355); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver(6, 266); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver(27, 74907); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver(46, 601036); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver(50, 834275); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver(20, 23485); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
source_py: def sum_pairwise_products_1(n):
      multiTerms = ((n * (n + 1)) // 2)
      sm = multiTerms
      for i in range(2, (n + 1)):
          multiTerms = (multiTerms - (i - 1))
          sm = (sm + (multiTerms * i))
      return sm
source_cpp: long long int sum_pairwise_products_1(int n) {
    long long int multiTerms = n * ( n + 1 ) / 2;
    long long int sum = multiTerms;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      multiTerms = multiTerms - ( i - 1 );
      sum = sum + multiTerms * i;
    }
    return sum;
  }