#include <iostream>
#include <sstream>  
#include <map>
#include <algorithm>
#include <cstdlib>
#include <iterator>
#include <fstream>
using namespace std;
int main() {
	int i = 0;
	map<string, string> data;
	ifstream fin("D:\\text.txt");//файл в котором логинпароль
	if (!fin.is_open()) {
		cout << "Error";
        system("PAUSE");
		return 0;
	}
	string pass, log,temp;
	char buf;
	while (!fin.eof()) {
		fin >> temp;
		while (i < temp.size() && temp[i] != ':')
			log += temp[i++];
		while (i < temp.size())
			pass += temp[i++];
		i = 0;
		data.insert(make_pair(pass, log));
		log.clear(), pass.clear();
	}
	fin.close();
	
	ofstream fout("D:\\CompleteFile.txt");// файл конечный
	for (auto i:data) {
		fout << (i).second << (i).first << endl;
	}
	fout.close();
	cout<<"OK";
    system("PAUSE");
	return 0;
}