import java.util.* fun main(args: Array) { val count = readLine()!!.toInt() var items = mutableListOf() (1..count).forEach { items.addAll(readLine()!!.split(" ").map { it.toInt() }) } var ans = 0 while (items.size >= 2) { items.sortWith(kotlin.Comparator { a, b -> comp(a,b,items) }) val (a,b) = items.take(2) if(a == b) { ans++ (0..1).forEach { items.removeAt(0) } } else if(items.size >= 4) { ans = ans + items.size / 4 break } else { break } } println(ans) } fun comp(a:Int, b:Int, list : List):Int { val num1 = list.count { it == a } val num2 = list.count { it == b } if(num1 == num2) { return a.compareTo(b) } return num2.compareTo(num1) }