title: Distributing Items Person Cannot Take Two Items Type
signature: def distributing_items_person_cannot_take_two_items_type(arr, n, k):
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(arr, n, k, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              arr, n, k),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver([1, 1, 2, 3, 1], 5, 2, True)
      print(f"TEST-0...{result}")
  
      result = driver([2, 3, 3, 5, 3, 3], 6, 2, True)
      print(f"TEST-1...{result}")
  
      result = driver([0, 0, 1, 1, 1], 2, 1, True)
      print(f"TEST-2...{result}")
  
      result = driver([7, 60, 78, 91, 80, 75, 85, 21, 41, 63, 1, 84, 69, 13, 94, 25, 54, 54, 52, 68, 53, 35, 17, 37, 98, 27, 2, 31], 24, 2, True)
      print(f"TEST-3...{result}")
  
      result = driver([-96, -94, -82, -80, -78, -66, -36, -24, -18, -12, -2, -2, 6, 8, 10, 12, 36, 38, 42, 58, 64, 68, 82, 84, 86, 88, 94], 24, 3, True)
      print(f"TEST-4...{result}")
  
      result = driver([0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0], 34, 2, False)
      print(f"TEST-5...{result}")
  
      result = driver([16, 19, 25, 25, 32, 37, 48, 59, 60, 60, 71, 74, 77, 81, 91, 94], 10, 8, True)
      print(f"TEST-6...{result}")
  
      result = driver([-62, -94, 72, -22, 86, -80, 64, 98, -82, -50, 12, -4, 56, 46, -80, 2, -86, -44, -26, 68, -94, -82, 74, 26, 94, 40, 50, -40, -42, -10], 20, 4, True)
      print(f"TEST-7...{result}")
  
      result = driver([0, 0, 0, 0, 0, 1, 1, 1], 5, 2, False)
      print(f"TEST-8...{result}")
  
      result = driver([83, 57, 2, 47, 70, 22, 49, 51, 25, 57, 32, 7, 8, 99, 6, 86, 24, 79, 42, 43, 1, 24, 68, 11, 24, 12, 43, 40, 14, 45, 11, 46, 12, 80, 66], 21, 33, True)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
source_py: def distributing_items_person_cannot_take_two_items_type(arr, n, k):
      for i in range(n):
          count = 0
          for j in range(n):
              if (arr[j] == arr[i]):
                  count += 1
              if (count > (2 * k)):
                  return False
      return True
source_cpp: bool distributing_items_person_cannot_take_two_items_type(vector<int> arr, int n, int k) {
    int count;
    for ( int i = 0;
    i < n;
    i ++ ) {
      count = 0;
      for ( int j = 0;
      j < n;
      j ++ ) {
        if ( arr [ j ] == arr [ i ] ) count ++;
        if ( count > 2 * k ) return false;
      }
    }
    return true;
  }