Check if the third number is present in the map and it is not equal to any other two elements and also check if this triplet is not counted already using their indexes
if li [ j ] != 0 and product % ( li [ j ] * li [ i ] ) == 0 : NEW_LINE INDENT if product // ( li [ j ] * li [ i ] ) in li : NEW_LINE INDENT n = li . index ( product // ( li [ j ] * li [ i ] ) ) NEW_LINE if n > i and n > j : NEW_LINE INDENT flag = 1 NEW_LINE count += 1 NEW_LINE DEDENT DEDENT DEDENT print ( count ) NEW_LINE