#include <array>
#include <fstream>
#include <iostream>
#include <string>
#include <string_view>

using namespace std;

std::array<std::string_view, 45> csv_entries;


int main()
{
    std::ifstream inFile("list.txt");
    std::ofstream outFile("nodup.txt");
    std::ios_base::sync_with_stdio(false);

    if (!inFile.is_open()) {
        return -1;
    }

    string line;

    while (getline(inFile, line)) {

        std::string_view line_view = line;

        for (std::size_t a = 0, b, i = 0;
                (b = line_view.find(';', a)) != std::string_view::npos;
                a = b + 1)
        {
            csv_entries[i++] = std::string_view(line.data() + a, b + 1 - a);
        }

        for (std::size_t i = 3; i < csv_entries.size() - 1; ++i) {

            for (std::size_t j = i + 1; j < csv_entries.size(); ++j) {

                if (!csv_entries[i].empty() && csv_entries[i] == csv_entries[j]) {
                    csv_entries[j] = ";";
                }
            }
        }

        for (const auto sv : csv_entries) {
            outFile.write(sv.data(), sv.length());
        }

        outFile.put('\n');
    }

    return 0;
}
