用vector容器来保存文件和行号拼接成的字符串
用unordered_map来统计相同的错误

#include<iostream>
#include<vector>
#include<unordered_map>
#include<string>
using namespace std;

vector<string> textName;

unordered_map<string, int> um;

void countError(const string& str, const int& n);

int main(){
    string s;
    int num;
    while(cin >> s >> num){
        countError(s, num);
    }
    int i = 0;
    if(textName.size() > 8){
        i = textName.size() - 8;
    }
    for(i; i < textName.size(); ++i){
        cout << textName[i] << " " << um[textName[i]] << endl;
    }
    return 0;
}

void countError(const string& str, const int& n){
    string temp;
    int i = str.size() - 1;
    while(i >= 0 && str[i] != '\\'){
        i--;
    }
    if(str.size() - i - 1 > 16){ //判断文件名是否超过16位
        temp = str.substr(str.size() - 16, 16);
    }else{
        temp = str.substr(i + 1, str.size() - i - 1);
    }
    temp = temp + " " + to_string(n); //将文件名和行号拼接作为key值
    if(um.find(temp) == um.end()){
        textName.push_back(temp);
    }
    um[temp]++;
}