import java.util.*;
import java.lang.*;
import java.io.*;
import java.io.*;
import java.util.stream.Collectors;

class Ideone
{
	public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("Пупкин", "Василий");
        map.put("Иванов", "Василий");
        map.put("Пушкин", "Александр");

        Map<String, String> result = new HashMap<>();

        map.entrySet()
                .stream()
                .collect(Collectors.groupingBy(Map.Entry::getValue))
                .entrySet()
                .stream()
                .filter(entry -> entry.getValue().size() == 1)
                .forEach(listEntry -> result.put(listEntry.getKey(), listEntry.getValue().get(0).getKey()));

        System.out.println(result);
    }
}