#include <iostream>
#include <fstream>
#include <cctype>
#include <map>
#include <cstring>
#include <string>
#include <algorithm>

int main(int argc, char* argv[])
{
	setlocale(LC_ALL, "");

	if (argc == 1)
	{
		std::cout << "Не введен аргумент командной строки!" << std::endl;
		return 1;
	}
	std::ifstream fin(argv[1]);
	
	if (!fin.is_open())
	{
		std::cout << "Не удалось открыть файл!" << std::endl;
		return 1;
	}

	std::string str;

	const char *delimit = ".,!?1234567890-=+#% \t";

	std::map<std::string, size_t> words;

	while (std::getline(fin, str))
	{
		for (std::string::size_type pos = 0; (pos = str.find_first_not_of(delimit, pos)) != std::string::npos;)
		{
			std::string::size_type n = pos;
			pos = str.find_first_of(delimit, pos);
			std::string word = str.substr(n, pos == std::string::npos ? pos : pos - n);

			for (char &c : word)
				c = std::tolower((unsigned char)c);

			++words[word];
		}
	}
	fin.close();

	std::map<std::string, size_t>::iterator it;
	for (it = words.begin(); it != words.end(); ++it)
	{
		std::cout << (it->first.c_str()) << " - " << it->second << std::endl;
	}

	return 0;
}