空间换时间

使用一个栈来完成

queue = []
while True:
    try:
        tmp = input().split(' ')
    except:
        break
    

    file_name = tmp[0].split('\\')[-1][-16:]
    number = tmp[-1]
    if len(queue) == 0:                     
        queue.append([file_name, number, 1])
    else:
        for q in queue:
            if q[0] == file_name and q[1] == number:
                q[2] += 1
                break
        else:
            queue.append([file_name, number, 1])

if len(queue) >= 8:
    start = len(queue) - 8
else:
    start = 0
for i in range(start, len(queue)):
    print(queue[i][0], queue[i][1], queue[i][2])