title: Distributing Items Person Cannot Take Two Items Type
signature: distributing_items_person_cannot_take_two_items_type <- function(arr, n, k) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, k, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n, k), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(1L, 1L, 2L, 3L, 1L), 5L, 2L, 
          TRUE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(2L, 3L, 3L, 5L, 3L, 3L), 6L, 2L, 
          TRUE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 1L, 1L, 1L), 2L, 1L, 
          TRUE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(7L, 60L, 78L, 91L, 80L, 75L, 85L, 21L, 41L, 63L, 1L, 84L, 69L, 13L, 94L, 25L, 54L, 54L, 52L, 68L, 53L, 35L, 17L, 37L, 98L, 27L, 2L, 31L), 24L, 2L, 
          TRUE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-96L, -94L, -82L, -80L, -78L, -66L, -36L, -24L, -18L, -12L, -2L, -2L, 6L, 8L, 10L, 12L, 36L, 38L, 42L, 58L, 64L, 68L, 82L, 84L, 86L, 88L, 94L), 24L, 3L, 
          TRUE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 0L), 34L, 2L, 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(16L, 19L, 25L, 25L, 32L, 37L, 48L, 59L, 60L, 60L, 71L, 74L, 77L, 81L, 91L, 94L), 10L, 8L, 
          TRUE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-62L, -94L, 72L, -22L, 86L, -80L, 64L, 98L, -82L, -50L, 12L, -4L, 56L, 46L, -80L, 2L, -86L, -44L, -26L, 68L, -94L, -82L, 74L, 26L, 94L, 40L, 50L, -40L, -42L, -10L), 20L, 4L, 
          TRUE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L), 5L, 2L, 
          FALSE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(83L, 57L, 2L, 47L, 70L, 22L, 49L, 51L, 25L, 57L, 32L, 7L, 8L, 99L, 6L, 86L, 24L, 79L, 42L, 43L, 1L, 24L, 68L, 11L, 24L, 12L, 43L, 40L, 14L, 45L, 11L, 46L, 12L, 80L, 66L), 21L, 33L, 
          TRUE
      )))
  
  }
  
  main()
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;
  }