TTRGRAPH - Tetrahedrons in the country
Today we continue examine topology of the ancient country GRAPH. It was said that any four cities form a tetrahedron (or 4-vertex clique) if from every city of the tetrahedron there is a road to another tetrahedron city. In the picture below is an example of tetrahedron.
Theoretical note: all test cases are Erdős–Rényi connected low density graphs.
Your task is to find the number of tetrahedrons in the country.
The first line of input will contain one integer number 4 ≤ N ≤ 900, number of cities in GRAPH. Follow N lines. Each line represents cities (direct neighbors) connected to the city number i (cities numbering is zero based) by one road.
Print number of tetrahedrons in the GRAPH.
Input: 4 1 2 3 0 2 3 0 1 3 0 1 2