#include <iostream>
#include <vector>
#include <functional>

void applyFunction(std::vector<int>& vec, std::function<void(int&, int)> func) {
    for (int i = 0; i < vec.size(); ++i) {
        func(vec[i], i);
    }
}

int main() {
    std::vector<int> numbers = {1, 2, 3, 4, 5};

    applyFunction(numbers, [](int& num, int) { num *= 2; });

    applyFunction(numbers, [](int& num, int) { num = num * num; });

    for (const auto& num : numbers) {
        std::cout << num << " ";
    }

    return 0;
}
