#include <iostream> #include <map> #include <vector> #include <string> #include <algorithm> #define totalPoints first #define totalGoals second #define name first #define stats second using namespace std; map <string, pair <int, int>> M; vector <pair <string, pair <int, int>>> v; int goalsA, goalsB, bonusA, bonusB; string teamA, teamB; bool cmp(pair <string, pair <int, int>> A, pair <string, pair <int, int>> B) { if(A.stats.totalPoints != B.stats.totalPoints) return A.stats.totalPoints > B.stats.totalPoints; if(A.stats.totalGoals != B.stats.totalGoals) return A.stats.totalGoals > B.stats.totalGoals; return A.name < B.name; } int main() { for(int i=1; i<=6; i++) { cin>>teamA>>teamB>>goalsA>>goalsB; if(goalsA > goalsB) bonusA = 3, bonusB = 0; else if(goalsA == goalsB) bonusA = 1, bonusB = 1; else bonusA = 0, bonusB = 3; if(M.find(teamA) == M.end()) M[teamA] = make_pair(0, 0); if(M.find(teamB) == M.end()) M[teamB] = make_pair(0, 0); M[teamA] = make_pair(M[teamA].totalPoints + bonusA, M[teamA].totalGoals + goalsA); M[teamB] = make_pair(M[teamB].totalPoints + bonusB, M[teamB].totalGoals + goalsB); } for(auto team:M) v.push_back(team); sort(v.begin(), v.end(), cmp); for(auto team:v) cout<<team.name<<"\n"; return 0; }