title: Count Pairs Two Sorted Arrays Whose Sum Equal Given Value X 2
signature: def count_pairs_two_sorted_arrays_whose_sum_equal_given_value_x_2(arr1, arr2, m, n, x):
source_py: def count_pairs_two_sorted_arrays_whose_sum_equal_given_value_x_2(arr1, arr2, m, n, x):
      (count, l, r) = (0, 0, (n - 1))
      while ((l < m) and (r >= 0)):
          if ((arr1[l] + arr2[r]) == x):
              l += 1
              r -= 1
              count += 1
          elif ((arr1[l] + arr2[r]) < x):
              l += 1
          else:
              r -= 1
      return count
source_cpp: int count_pairs_two_sorted_arrays_whose_sum_equal_given_value_x_2(vector<int> arr1, vector<int> arr2, int m, int n, int x) {
    int count = 0;
    int l = 0, r = n - 1;
    while ( l < m && r >= 0 ) {
      if ( ( arr1 [ l ] + arr2 [ r ] ) == x ) {
        l ++;
        r --;
        count ++;
      }
      else if ( ( arr1 [ l ] + arr2 [ r ] ) < x ) l ++;
      else r --;
    }
    return count;
  }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(arr1, arr2, m, n, x, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              arr1, arr2, m, n, x),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver([5, 5, 7, 10, 14, 14, 17, 21, 32, 34, 37, 40, 40, 40, 46, 46, 50, 50, 51, 55, 57, 62, 65, 67, 67, 69, 70, 70, 72, 73, 76, 77, 77, 78, 84, 85, 85, 86, 87, 88, 88, 89, 89, 90, 93, 99], [2, 5, 8, 8, 10, 12, 13, 15, 17, 18, 20, 20, 21, 27, 28, 31, 34, 37, 40, 46, 48, 52, 53, 54, 54, 58, 59, 60, 66, 68, 68, 69, 70, 71, 72, 73, 77, 77, 80, 84, 84, 92, 92, 95, 97, 97], 28, 29, 23, 3)
      print(f"TEST-0...{result}")
  
      result = driver([-84, 52, -34, 96, 16, 92, -64, -74], [-22, 26, -12, -54, 66, 86, 38, 76], 6, 5, 7, 0)
      print(f"TEST-1...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 37, 26, 42, 0)
      print(f"TEST-2...{result}")
  
      result = driver([60, 92, 42, 83, 55, 76, 29, 62], [71, 2, 74, 42, 80, 71, 26, 76], 4, 7, 7, 0)
      print(f"TEST-3...{result}")
  
      result = driver([-94, -94, -58, -40, -40, -26, -24, -22, -22, -22, -2, 0, 4, 8, 12, 16, 16, 18, 22, 32, 42, 44, 50, 58, 64, 78, 80, 90], [-86, -84, -78, -76, -72, -70, -62, -58, -54, -54, -50, -46, -44, -40, -30, -28, -16, -10, 10, 36, 36, 48, 70, 84, 84, 90, 94, 98], 17, 27, 17, 0)
      print(f"TEST-4...{result}")
  
      result = driver([0, 0, 1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1, 0, 0, 0, 0], 5, 8, 9, 0)
      print(f"TEST-5...{result}")
  
      result = driver([1, 5, 7, 7, 7, 14, 15, 16, 17, 18, 18, 19, 20, 25, 27, 31, 36, 42, 47, 51, 56, 56, 56, 58, 58, 59, 63, 63, 63, 65, 66, 67, 76, 83, 93, 94, 97], [2, 3, 7, 8, 9, 10, 17, 18, 21, 28, 29, 29, 33, 35, 46, 47, 47, 49, 49, 49, 53, 56, 58, 59, 59, 60, 65, 67, 70, 78, 81, 85, 85, 87, 90, 92, 96], 28, 34, 31, 1)
      print(f"TEST-6...{result}")
  
      result = driver([78, -74, 52, 56, -8, 92, 14, 56, -72, -92, 32, -94, -26, -8, -66, 72, -24, 36, -84, -4, -68, 14, 78, 40, -82, -10, 16, 56, 6, -16, 30, 24, -32], [-74, 22, -14, -2, 36, 86, -70, -20, -76, -84, -40, -36, 42, 22, -60, -94, -18, 8, -14, -42, -68, 62, -60, 2, 40, -66, 68, 96, 70, 98, -38, -74, -92], 16, 30, 24, 1)
      print(f"TEST-7...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 25, 33, 33, 0)
      print(f"TEST-8...{result}")
  
      result = driver([17, 50, 65, 4, 19, 10, 45, 70, 76, 81, 28, 97, 55, 70, 38, 2, 40, 67, 36, 33, 6, 85, 25], [78, 92, 65, 23, 7, 94, 18, 4, 2, 53, 31, 58, 98, 18, 46, 16, 17, 92, 80, 92, 43, 70, 50], 16, 22, 22, 0)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.entry_fn_name: count_pairs_two_sorted_arrays_whose_sum_equal_given_value_x_2
question_info.test_list: [{"idx": 0, "outputs": 3, "inputs": {"arr1": [5, 5, 7, 10, 14, 14, 17, 21, 32, 34, 37, 40, 40, 40, 46, 46, 50, 50, 51, 55, 57, 62, 65, 67, 67, 69, 70, 70, 72, 73, 76, 77, 77, 78, 84, 85, 85, 86, 87, 88, 88, 89, 89, 90, 93, 99], "arr2": [2, 5, 8, 8, 10, 12, 13, 15, 17, 18, 20, 20, 21, 27, 28, 31, 34, 37, 40, 46, 48, 52, 53, 54, 54, 58, 59, 60, 66, 68, 68, 69, 70, 71, 72, 73, 77, 77, 80, 84, 84, 92, 92, 95, 97, 97], "m": 28, "n": 29, "x": 23}}, {"idx": 1, "outputs": 0, "inputs": {"arr1": [-84, 52, -34, 96, 16, 92, -64, -74], "arr2": [-22, 26, -12, -54, 66, 86, 38, 76], "m": 6, "n": 5, "x": 7}}, {"idx": 2, "outputs": 0, "inputs": {"arr1": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "arr2": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "m": 37, "n": 26, "x": 42}}, {"idx": 3, "outputs": 0, "inputs": {"arr1": [60, 92, 42, 83, 55, 76, 29, 62], "arr2": [71, 2, 74, 42, 80, 71, 26, 76], "m": 4, "n": 7, "x": 7}}, {"idx": 4, "outputs": 0, "inputs": {"arr1": [-94, -94, -58, -40, -40, -26, -24, -22, -22, -22, -2, 0, 4, 8, 12, 16, 16, 18, 22, 32, 42, 44, 50, 58, 64, 78, 80, 90], "arr2": [-86, -84, -78, -76, -72, -70, -62, -58, -54, -54, -50, -46, -44, -40, -30, -28, -16, -10, 10, 36, 36, 48, 70, 84, 84, 90, 94, 98], "m": 17, "n": 27, "x": 17}}, {"idx": 5, "outputs": 0, "inputs": {"arr1": [0, 0, 1, 1, 1, 0, 0, 1, 1, 1], "arr2": [1, 1, 1, 0, 1, 1, 0, 0, 0, 0], "m": 5, "n": 8, "x": 9}}, {"idx": 6, "outputs": 1, "inputs": {"arr1": [1, 5, 7, 7, 7, 14, 15, 16, 17, 18, 18, 19, 20, 25, 27, 31, 36, 42, 47, 51, 56, 56, 56, 58, 58, 59, 63, 63, 63, 65, 66, 67, 76, 83, 93, 94, 97], "arr2": [2, 3, 7, 8, 9, 10, 17, 18, 21, 28, 29, 29, 33, 35, 46, 47, 47, 49, 49, 49, 53, 56, 58, 59, 59, 60, 65, 67, 70, 78, 81, 85, 85, 87, 90, 92, 96], "m": 28, "n": 34, "x": 31}}, {"idx": 7, "outputs": 1, "inputs": {"arr1": [78, -74, 52, 56, -8, 92, 14, 56, -72, -92, 32, -94, -26, -8, -66, 72, -24, 36, -84, -4, -68, 14, 78, 40, -82, -10, 16, 56, 6, -16, 30, 24, -32], "arr2": [-74, 22, -14, -2, 36, 86, -70, -20, -76, -84, -40, -36, 42, 22, -60, -94, -18, 8, -14, -42, -68, 62, -60, 2, 40, -66, 68, 96, 70, 98, -38, -74, -92], "m": 16, "n": 30, "x": 24}}, {"idx": 8, "outputs": 0, "inputs": {"arr1": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "arr2": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "m": 25, "n": 33, "x": 33}}, {"idx": 9, "outputs": 0, "inputs": {"arr1": [17, 50, 65, 4, 19, 10, 45, 70, 76, 81, 28, 97, 55, 70, 38, 2, 40, 67, 36, 33, 6, 85, 25], "arr2": [78, 92, 65, 23, 7, 94, 18, 4, 2, 53, 31, 58, 98, 18, 46, 16, 17, 92, 80, 92, 43, 70, 50], "m": 16, "n": 22, "x": 22}}]
question_info.entry_cls_name: Solution