title: Count Pairs Two Sorted Arrays Whose Sum Equal Given Value X 1
signature: count_pairs_two_sorted_arrays_whose_sum_equal_given_value_x_1 <- function(arr1, arr2, m, n, x) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr1, arr2, m, n, x, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr1, arr2, m, n, x), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(1L, 2L, 5L, 5L, 9L, 11L, 12L, 14L, 16L, 18L, 35L, 36L, 39L, 44L, 50L, 52L, 52L, 59L, 69L, 81L, 82L, 84L, 85L, 87L, 87L, 87L, 88L, 88L, 89L, 90L, 90L, 92L, 97L), list(5L, 5L, 8L, 20L, 20L, 24L, 25L, 29L, 34L, 37L, 43L, 45L, 48L, 49L, 59L, 60L, 68L, 70L, 70L, 72L, 72L, 75L, 76L, 77L, 79L, 81L, 84L, 85L, 86L, 88L, 95L, 96L, 96L), 17L, 29L, 32L, 
          2L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(52L, 28L, -38L, 78L, -86L, 78L, -48L, -70L, -80L, 28L, -8L, 60L, -28L, 90L, 6L, 76L, 32L, -54L, 30L, 30L, -32L, -24L, -36L, 62L, 36L, -66L, 56L, 92L, -20L, 90L, 32L), list(-88L, -32L, 30L, 32L, -46L, 62L, -92L, -90L, -18L, -18L, 10L, 16L, 60L, -40L, 32L, -88L, 60L, -82L, 76L, 50L, 86L, -82L, -48L, -68L, -42L, 34L, 4L, 0L, 98L, 92L, -78L), 30L, 27L, 17L, 
          0L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 13L, 11L, 8L, 
          0L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(91L, 95L, 13L, 13L, 76L, 18L, 36L, 86L, 26L, 13L, 17L, 68L, 58L, 42L, 38L, 9L, 42L, 90L, 14L, 74L, 38L, 64L, 15L), list(16L, 96L, 8L, 35L, 12L, 27L, 81L, 21L, 32L, 82L, 95L, 81L, 53L, 76L, 72L, 16L, 9L, 16L, 61L, 1L, 36L, 71L, 28L), 11L, 12L, 15L, 
          0L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-96L, -94L, -94L, -92L, -74L, -70L, -66L, -54L, -48L, -20L, -18L, -10L, -6L, -2L, 2L, 18L, 36L, 48L, 52L, 58L, 68L, 74L, 88L, 90L, 94L), list(-92L, -72L, -72L, -64L, -58L, -52L, -30L, -28L, -24L, -24L, -16L, -10L, -2L, 4L, 12L, 22L, 30L, 38L, 44L, 62L, 64L, 68L, 86L, 88L, 90L), 19L, 14L, 21L, 
          0L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 0L), list(1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L), 18L, 19L, 29L, 
          0L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(7L, 18L, 19L, 20L, 24L, 25L, 25L, 27L, 30L, 35L, 39L, 42L, 58L, 59L, 63L, 64L, 64L, 66L, 66L, 68L, 69L, 77L, 86L, 93L), list(2L, 2L, 18L, 20L, 22L, 22L, 31L, 35L, 36L, 40L, 41L, 41L, 41L, 42L, 42L, 43L, 45L, 61L, 79L, 83L, 87L, 91L, 95L, 96L), 22L, 18L, 18L, 
          0L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(86L, 44L, 10L, 80L, 12L, 52L, -92L, 2L, 42L, -32L, -14L, 2L, -42L, 40L, 96L, 22L, 58L, -90L, -20L, 22L, 96L, 10L, -92L, -28L, -28L, 80L, 36L, 72L, -2L, 32L, -46L, 62L, -58L, 20L, 22L, 32L, -98L, -2L, -42L, -90L, 10L, 70L, 54L, -32L), list(-4L, -76L, -98L, 14L, 30L, -10L, -10L, 62L, 88L, -94L, -74L, -82L, 84L, 44L, 58L, 8L, -42L, -66L, -18L, 68L, -78L, 42L, -32L, 38L, -98L, 38L, -78L, 42L, 86L, -38L, -6L, -72L, -44L, 8L, -6L, -48L, -62L, 82L, 94L, -92L, -56L, 28L, -54L, 34L), 26L, 36L, 31L, 
          0L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 1L, 1L, 1L, 1L), list(0L, 0L, 1L, 1L, 1L, 1L), 5L, 3L, 5L, 
          0L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(43L, 2L, 4L, 99L, 45L, 80L, 27L, 8L, 64L, 77L, 57L, 55L, 71L, 67L, 51L, 42L, 58L, 70L, 5L, 62L, 55L, 20L, 61L, 47L, 66L, 80L, 70L, 24L, 56L, 22L, 58L, 63L, 61L, 41L, 20L, 97L, 47L), list(11L, 66L, 41L, 17L, 93L, 25L, 24L, 17L, 12L, 33L, 62L, 86L, 48L, 68L, 36L, 36L, 39L, 82L, 7L, 66L, 5L, 48L, 27L, 9L, 56L, 6L, 61L, 91L, 98L, 74L, 61L, 63L, 98L, 96L, 57L, 63L, 85L), 24L, 29L, 21L, 
          2L
      )))
  
  }
  
  main()
source_py: def count_pairs_two_sorted_arrays_whose_sum_equal_given_value_x_1(arr1, arr2, m, n, x):
      count = 0
      us = set()
      for i in range(m):
          us.add(arr1[i])
      for j in range(n):
          if ((x - arr2[j]) in us):
              count += 1
      return count
source_cpp: int count_pairs_two_sorted_arrays_whose_sum_equal_given_value_x_1(vector<int> arr1, vector<int> arr2, int m, int n, int x) {
    int count = 0;
    unordered_set < int > us;
    for ( int i = 0;
    i < m;
    i ++ ) us . insert ( arr1 [ i ] );
    for ( int j = 0;
    j < n;
    j ++ ) if ( us . find ( x - arr2 [ j ] ) != us . end ( ) ) count ++;
    return count;
  }