Problem: Count arrays having at least K elements exceeding XOR of all given array elements by X given operations
Given an array arr[] of size N, the task is to count the number of arrays having at least K elements greater than the XOR of all array elements, generated by performing the following operations X times.
Select either first or last element from the given array.
Either increment the selected element by 1 or delete the selected element.

Sample Input: arr[] = {3, 3, 4}, X = 3, K = 2
Sample Output: 3

Solution (python):
# Python program for the above approach

# Stores the final answer
ans = 0

# Utility function to count arrays
# having at least K elements exceeding
# XOR of all given array elements
def countArraysUtil( arr, X, K, xorVal):
    global ans
    
    # If no operations are left
    if (X == 0):
      
        # Stores the count of
        # possible arrays
        cnt = 0

        # Count array elements are
        # greater than XOR
        for i in range(len(arr)):
            if (arr[i] > xorVal):
                cnt += 1
        if (cnt >= K):
            ans += 1
        return
    
    # Stores first element
    temp = arr[0]

    # Delete first element
    arr.pop(0)

    # Recursive call
    countArraysUtil(arr, X - 1, K, xorVal)

    # Insert first element into vector
    arr.insert(0, temp)

    # Stores the last element
    temp = arr[-1]

    # Remove last element from vector
    arr.pop()

    # Recursive call
    countArraysUtil(arr, X - 1, K, xorVal)

    # Push last element into vector
    arr.append(temp)

    # Increment first element
    arr[0] += 1
  
    # Recursive call
    countArraysUtil(arr, X - 1,K, xorVal)
  
    # Decrement first element
    arr[0] -= 1

    # Increment last element
    arr[len(arr) - 1] += 1
  
    # Recursive call
    countArraysUtil(arr, X - 1, K, xorVal)
  
    # Decrement last element
    arr[len(arr) - 1] -= 1

# Function to find the count of 
# arrays having atleast K elements 
# greater than XOR of array
def countArrays(arr, X, K):
  
    # Stores the XOR value
    # of original array
    xorVal = 0

    # Traverse the vector
    for i in range(len(arr)):
        xorVal = xorVal ^ arr[i]
    countArraysUtil(arr, X, K, xorVal)

    # Print the answer
    print(ans)
    
# Driver Code
# Given vector
arr = [ 10, 2, 10, 5 ]

# Given value of X & K
X = 3
K = 3
countArrays(arr, X, K)