#include <iostream>
#include <sstream>
std::string FirstNWords(std::string str, int N) {
std::stringstream iss(str);
std::string word, firstn = "";
while (N != 0 && iss >> word) {
firstn += word + " ";
N--;
}
return firstn;
}
int main() {
std::string s = "c++ c c# java python";
int N = 2;
std::string first2 = FirstNWords(s, N);
std::cout << first2;
return 0;
}
/*
run:
c++ c
*/