#include <iostream>
#include <vector>
using namespace std;

vector<int> occ(int n, vector<int>& a, int t) {
    // Base case
    if (n == 0) {
        return vector<int>();
    }
    
    // Get the vector from the recursive call first
    vector<int> ans = occ(n - 1, a, t);
    
    // Check the current element and append if it matches
    if (a[n - 1] == t) {
        ans.push_back(n - 1);
    }
    
    return ans;
}

int main() {
    int n = 5;
    vector<int> a = {1, 3, 5, 6, 5};
    int t = 5;
    
    vector<int> ans = occ(n, a, t);
    
    // Output should be: 24 (since 5 is at index 2 and index 4)
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << " ";
    }
    
    return 0;
}