code: def count_triplets_1(arr, k):
      count = 0
      n = len(arr)
  
      for i in range(n - 2):
          elements = set()
          curr_sum = k - arr[i]
  
          for j in range(i + 1, n):
              if (curr_sum - arr[j]) in elements:
                  count += 1
              elements.add(arr[j])
  
      return count
  
label_desc: Use image node_id 1 for calling a global function with example usage: count_triplets_1(arr, k) and returns: count