/** G. Hagopian
1. Write a template function f() that adds the elements of
one vector<T> to the elements of another; for example,
f(v1,v2) should do v1[i]+=v2[i] for each element of v1.
*/

#include<iostream>
#include<vector>
using namespace std;

template<typename T>
vector<T> f(vector<T> v1, vector<T> v2 ) {
    for(int i = 0; i < min(v1.size(),v2.size()); ++i)
        v1[i]+=v2[i];
    if(v1.size()<v2.size())
        for(int i = v1.size(); i < v2.size(); ++i)
            v1.push_back(v2[i]);
    return v1;
}

int main() {
    vector<int> v1{1,2,3}, v2{4,5,6,7};
    v1 = f(v1,v2);
    for(int i: v1) cout << i << " ";
}
