int main()
{
    std::ifstream input_file("input.txt");// for reading
    if (!input_file)
    {
        std::cerr << "Impossible to open the input file.\n";
        return 1;
    }
    std::ofstream output_file("output.txt");//for writing

    if (!output_file)
    {
        std::cerr << "Impossible to open the output file.\n";
        return 1;
    }

    std::string stringLine;
    int count = 0;

    while (std::getline(input_file, stringLine))
    {
        // перевіряємо, чи містить рядок оператор присвоєння виду "змінна = змінна + число;"
        std::size_t pos = stringLine.find(" = ");

        if (pos != std::string::npos && stringLine.find("+", pos + 3) != std::string::npos) //npos the biggest value of size_t
        {
            // замінюємо оператор на "змінна += число;"
            stringLine.replace(pos, 3, " += ");
            count++;
        }

        // записуємо рядок у вихідний файл
        output_file << stringLine << "\n";
    }

    input_file.close();
    output_file.close();

    // відкриваємо вхідний файл для читання та запису
    std::fstream input_output_file("input.txt");

    // перевіряємо, чи вдалося відкрити файл
    if (!input_output_file)
    {
        std::cerr << "Unable to open input/output file.\n";
        return 1;
    }

    std::string last_line;

    // зчитуємо весь вміст файлу та знаходимо останній оператор присвоєння
    while (std::getline(input_output_file, stringLine))
    {
        if (stringLine.find("=") != std::string::npos)
        {
            last_line = stringLine;
        }
    }

    // вставляємо кількість змінених операторів у останній оператор присвоєння
    if (!last_line.empty())
    {
    std::size_t pos = last_line.find("=");
    last_line.insert(pos + 1, " " + std::to_string(count));
    }
// закриваємо файл
    input_output_file.close();

    std::cout << "Input file:\n";
    input_file.open("input.txt");
    while (std::getline(input_file, stringLine))
    {
        std::cout << stringLine << "\n";
    }
    input_file.close();

    std::cout << "\nOutput file:\n";
    output_file.open("output.txt");
    while (std::getline(output_file, stringLine))

    {
        std::cout << stringLine << "\n";
    }
    output_file.close();

// виводимо кількість змінених операторів
    std::cout << "\nNumber of changed operators: " << count << "\n";

    return 0;
}