#include <string>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <vector>
#include <iostream>
using namespace std;
class line {
    string data;
 public:
    operator string() const { return data; }
    bool operator==(const line& ln) const { return data == ln.data; }
    friend istream& operator>>(istream& is, line& ln) {
        return getline(is, ln.data);
    }
};

string stringCleaner(const string &str)
{
    istringstream tempStr(str);
    ostringstream cleanLine;
    unique_copy(istream_iterator<line>(tempStr),
                istream_iterator<line>(),
                ostream_iterator<string>(cleanLine, "\n"));
    return cleanLine.str();
}

int main()
{
    std::cout << stringCleaner("http://www aaa com\nhttp://www bbb com\n"
                               "http://www bbb com\nhttp://www ccc com\n"
                               "http://www ddd com\nhttp://www ddd com\n"
                               "http://www ddd com\nhttp://www ddd com\n"
                               "http://www eee com");
}
