title: Total Number Of Non Decreasing Numbers With N Digits
signature: long long totalNumberOfNonDecreasingNumbersWithNDigits(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(long long actual, long long expected){
      return actual == expected;
  }
  
  string driver(int n, long long 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(21, 14307150); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver(40, 2054455634); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver(83, 868754947060); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver(93, 2290415157800); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver(43, 3679075400); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver(98, 3585446225075); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver(35, 708930508); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver(86, 1174992339235); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver(76, 411731930610); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver(88, 1429144287220); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
source_py: def total_number_of_non_decreasing_numbers_with_n_digits(n):
      dp = [[0 for i in range((n + 1))] for i in range(10)]
      for i in range(10):
          dp[i][1] = 1
      for digit in range(10):
          for len in range(2, (n + 1)):
              for x in range((digit + 1)):
                  dp[digit][len] += dp[x][(len - 1)]
      count = 0
      for i in range(10):
          count += dp[i][n]
      return count
source_cpp: long long int total_number_of_non_decreasing_numbers_with_n_digits(int n) {
    long long int dp [ 10 ] [ n + 1 ];
    memset ( dp, 0, sizeof dp );
    for ( int i = 0;
    i < 10;
    i ++ ) dp [ i ] [ 1 ] = 1;
    for ( int digit = 0;
    digit <= 9;
    digit ++ ) {
      for ( int len = 2;
      len <= n;
      len ++ ) {
        for ( int x = 0;
        x <= digit;
        x ++ ) dp [ digit ] [ len ] += dp [ x ] [ len - 1 ];
      }
    }
    long long int count = 0;
    for ( int i = 0;
    i < 10;
    i ++ ) count += dp [ i ] [ n ];
    return count;
  }