import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
public static void main
(String[] args
) { Map
<String, String
> map
= new HashMap
<>(); map.put("Пупкин", "Василий");
map.put("Иванов", "Василий");
map.put("Пушкин", "Александр");
Map
<String,Integer
> counts
= new HashMap
<>(); for (String firstName
: map.
values()) { counts.put(firstName, counts.getOrDefault(firstName, 0) + 1);
}
Map
<String, String
> result
= new HashMap
<>(); for (Map.
Entry<String, String
> entry
: map.
entrySet()) { if (counts.get(entry.getValue()) == 1) {
result.put(entry.getKey(), entry.getValue());
}
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIE1hcDxTdHJpbmcsIFN0cmluZz4gbWFwID0gbmV3IEhhc2hNYXA8PigpOwogICAgICAgIG1hcC5wdXQoItCf0YPQv9C60LjQvSIsICLQktCw0YHQuNC70LjQuSIpOwogICAgICAgIG1hcC5wdXQoItCY0LLQsNC90L7QsiIsICLQktCw0YHQuNC70LjQuSIpOwogICAgICAgIG1hcC5wdXQoItCf0YPRiNC60LjQvSIsICLQkNC70LXQutGB0LDQvdC00YAiKTsKCiAgICAgICAgTWFwPFN0cmluZyxJbnRlZ2VyPiBjb3VudHMgPSBuZXcgSGFzaE1hcDw+KCk7CiAgICAgICAgZm9yIChTdHJpbmcgZmlyc3ROYW1lIDogbWFwLnZhbHVlcygpKSB7CiAgICAgICAgICAgIGNvdW50cy5wdXQoZmlyc3ROYW1lLCBjb3VudHMuZ2V0T3JEZWZhdWx0KGZpcnN0TmFtZSwgMCkgKyAxKTsKICAgICAgICB9CiAgICAgICAgTWFwPFN0cmluZywgU3RyaW5nPiByZXN1bHQgPSBuZXcgSGFzaE1hcDw+KCk7CiAgICAgICAgZm9yIChNYXAuRW50cnk8U3RyaW5nLCBTdHJpbmc+IGVudHJ5IDogbWFwLmVudHJ5U2V0KCkpIHsKICAgICAgICAgICAgaWYgKGNvdW50cy5nZXQoZW50cnkuZ2V0VmFsdWUoKSkgPT0gMSkgewogICAgICAgICAgICAgICAgcmVzdWx0LnB1dChlbnRyeS5nZXRLZXkoKSwgZW50cnkuZ2V0VmFsdWUoKSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKHJlc3VsdCk7CiAgICB9Cn0=