title: Count Even Length Binary Sequences With Same Sum Of First And Second Half Bits 1
signature: class Solution {
  
      public decimal CountEvenLengthBinarySequencesWithSameSumOfFirstAndSecondHalfBits1(int n) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(decimal actual, decimal expected){
              return Math.Abs(actual - expected) < 1e-09m;
          }
  
          public string driver(int n, decimal expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                decimal pred_result = solution_cls.PLACEHOLDER_FN_NAME(n); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  25, 
                  126410606437752.0m
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  18, 
                  9075135300.0m
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  17, 
                  2333606220.0m
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  8, 
                  12870.0m
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  8, 
                  12870.0m
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );
          }
      }
  }
  
source_py: def count_even_length_binary_sequences_with_same_sum_of_first_and_second_half_bits_1(n):
      nCr = 1
      res = 1
      for r in range(1, (n + 1)):
          nCr = ((nCr * ((n + 1) - r)) / r)
          res += (nCr * nCr)
      return res
source_cpp: int count_even_length_binary_sequences_with_same_sum_of_first_and_second_half_bits_1(int n) {
    int nCr = 1, res = 1;
    for ( int r = 1;
    r <= n;
    r ++ ) {
      nCr = ( nCr * ( n + 1 - r ) ) / r;
      res += nCr * nCr;
    }
    return res;
  }