#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
vector<string> split(const string &str)
{
vector<string> ret;
int start = 0, end = 0;
while (end < str.size())
{
while (end < str.size() && str[end] != ' ')
end++;
if (start < end)
{
ret.push_back(str.substr(start, end - start));
start = end;
}
while (end < str.size() && str[end] == ' ')
{
end++;
start = end;
}
}
return ret;
}
bool is_space(char ch)
{
return ch == ' ';
}
bool not_space(char ch)
{
return ch != ' ';
}
vector<string> split_iter(const string & str)
{
vector<string> ret;
string::const_iterator start, end;
start = end = str.begin();
while (end != str.end())
{
start = find_if(start, str.end(), not_space);
end = start;
end = find_if(start, str.end(), is_space);
if (start != end)
{
ret.push_back(string(start, end));
start = end;
}
}
return ret;
}