using System.Collections.Generic;
public partial class Program
public static void Main()
var line = Console.ReadLine();
var tokens = line.Split(' ', '\t');
var T = int.Parse(tokens[0]);
var H = int.Parse(tokens[1]);
var tickets = new List<Ticket>();
line = Console.ReadLine();
tokens = line.Split(' ', '\t');
var h = int.Parse(tokens[0]);
var hotels = new List<int>();
hotels.Add(int.Parse(tokens[k]));
tickets.Add(new Ticket(hotels));
var hotelsToPayFor = Solution.CountPaidHotels(tickets, H);
Console.WriteLine(hotelsToPayFor);
public Ticket(List<int> hotels) { this.Hotels = hotels; }
private static Dictionary<int,List<int>> CreateReverseLookup(List<Ticket> tickets)
throw new NotImplementedException();
public static int CountPaidHotels(List<Ticket> tickets, int numHotels)
var reverse = CreateReverseLookup(tickets);
var payHotels = numHotels;
var removed = new HashSet<int>();
for(int j=tickets.Count-1; j>=0; j--) {
if(ticket.Hotels.Count==1) {
var h = ticket.Hotels[0];
foreach(var u in uList) {
if(!removed.Contains(u)) {
tickets[u].Hotels.Remove(h);
if(tickets[u].Hotels.Count==0) {
var diff = tickets.Count - removed.Count;
public partial class Program
public static void testCases()
Console.WriteLine("Hello World");