#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <unordered_map>
struct Person
{
std::string code;
int data;
};
typedef std::unordered_map<int, Person> PersonMap;
int main()
{
//std::ifstream fin("test.txt"); // here std::cin
PersonMap persons;
/* line by line reading */
for (std::string line; std::getline(std::cin, line); )
{
std::istringstream iss(line);
int personId;
Person personData;
/* parse line as std::string, int, int */
iss >> personData.code >> personId >> personData.data;
/* insert into map and save result */
std::pair<PersonMap::iterator, bool> insertResult =
persons.insert(std::pair<int, Person>(personId, personData));
/* if personId is already there */
if (!insertResult.second)
{
insertResult.first->second.data += personData.data;
}
}
/* output whole map */
for(auto const &person : persons)
{
std::cout << person.first << " : " << person.second.data << "\n";
}
std::cout << std::flush;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPGZzdHJlYW0+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDx1bm9yZGVyZWRfbWFwPgoKc3RydWN0IFBlcnNvbgp7CiAgIHN0ZDo6c3RyaW5nIGNvZGU7CiAgIGludCAgICAgICAgIGRhdGE7Cn07Cgp0eXBlZGVmIHN0ZDo6dW5vcmRlcmVkX21hcDxpbnQsIFBlcnNvbj4gUGVyc29uTWFwOwoKaW50IG1haW4oKQp7CiAgIC8vc3RkOjppZnN0cmVhbSBmaW4oInRlc3QudHh0Iik7IC8vIGhlcmUgc3RkOjpjaW4KCiAgIFBlcnNvbk1hcCBwZXJzb25zOwoKICAgLyogbGluZSBieSBsaW5lIHJlYWRpbmcgKi8KICAgZm9yIChzdGQ6OnN0cmluZyBsaW5lOyBzdGQ6OmdldGxpbmUoc3RkOjpjaW4sIGxpbmUpOyApCiAgIHsKICAgICAgc3RkOjppc3RyaW5nc3RyZWFtIGlzcyhsaW5lKTsKCiAgICAgIGludCAgICBwZXJzb25JZDsKICAgICAgUGVyc29uIHBlcnNvbkRhdGE7CgogICAgICAvKiBwYXJzZSBsaW5lIGFzIHN0Z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