defmodule Main do def main do 1..(IO.read(:line) |> String.trim() |> String.to_integer()) |> Enum.map(fn _ -> IO.read(:line) |> String.trim() |> String.split() |> Enum.map(&String.to_integer/1) end) |> solve |> IO.puts() end def solve(a) do a |> count_rec(%{}) |> Map.to_list() |> calc_rec(0, 0) end def count_rec([], i) do i end def count_rec([[a, b, c] | t], i) do count_rec( t, i |> Map.update(a, 1, &(&1 + 1)) |> Map.update(b, 1, &(&1 + 1)) |> Map.update(c, 1, &(&1 + 1)) ) end def calc_rec([], p, r) do p + (r |> div(4)) end def calc_rec([{_, v} | t], p, r) do calc_rec(t, p + (v |> div(2)), r + (v |> rem(2))) end end