Problem:


Score : 200 points

Problem Statement

We have sticks numbered 1, \cdots, N. The length of Stick i (1 \leq i \leq N) is L_i.

In how many ways can we choose three of the sticks with different lengths that can form a triangle?

That is, find the number of triples of integers (i, j, k) (1 \leq i < j < k \leq N) that satisfy both of the following conditions:

L_i, L_j, and L_k are all different.

There exists a triangle whose sides have lengths L_i, L_j, and L_k.

Constraints

1 \leq N \leq 100

1 \leq L_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
L_1 L_2 \cdots L_N

Output

Print the number of ways to choose three of the sticks with different lengths that can form a triangle.

Sample Input 1

5
4 4 9 7 5

Sample Output 1

5

The following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).

Sample Input 2

6
4 5 4 3 3 5

Sample Output 2

8

We have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.

There is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.

Sample Input 3

10
9 4 6 1 9 6 10 6 6 8

Sample Output 3

39

Sample Input 4

2
1 1

Sample Output 4

0

No triple (i, j, k) satisfies 1 \leq i < j < k \leq N, so we should print 0.



Sample input:
5
4 4 9 7 5


Sample output:
5

Submission status: Accepted

Solution code:
def isTriangle(a,b,c):
    if a==b or b==c or a==c:
        return False
    
    if a+b>c and b+c>a and a+c>b:
        return True
    else:
        return False
N = int(input())
L = list(map(int, input().split()))
ans = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        for c in range(b+1,N):
            if isTriangle(L[a],L[b],L[c]):
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
L.sort()
i=0
for a in range(len(L)):
    for b in range(a+1,len(L)):
        for c in range(b+1,len(L)):
            if L[a]==L[b] or L[a]==L[c] or L[b]==L[c]:
                continue
            if L[a]+L[b]>L[c]:
             
                i+=1

print(i)

Submission status: Accepted

Solution code:
#import numpy as np
#import collections
#import math

#f = open('./input_B.txt')
##
#N=int(f.readline())
#L=list(map(int, f.readline().split()))

N=int(input())
L=list(map(int, input().split()))

#L.sort()
ans=0
for i in range(N):
    Li=L[i]
    for j in range(i+1,N):
        Lj=L[j]
        for k in range(j+1,N):
            Lk=L[k]
            T=[Li,Lj,Lk]
            T.sort()
            if T[0]!=T[1] and T[1]!=T[2] and T[0]+T[1]>T[2]:
                ans+=1
            
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    L = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if L[i] == L[j]:
                continue
            for k in range(j+1, N): 
                if L[i] == L[k] or L[j] == L[k]:
                    continue
                if (((L[i] + L[j]) > L[k]) and ((L[j] + L[k]) > L[i]) and ((L[i] + L[k])) > L[j]):
                     ans += 1
    print(ans)

main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    L = sorted(list(readnums()))
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if L[i] == L[j]:
                continue
            for k in range(j + 1, N):
                if L[i] == L[k] or L[j] == L[k]:
                    continue
                if L[i] + L[j] > L[k]:
                    ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for j in range(1,N-1):
    for i in range(j):
        for k in range(j+1,N):
            if L[i] + L[j] > L[k] and L[i] != L[j] and L[k] != L[j] and L[i] != L[k]:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
import itertools

def main():
    n = int(input())
    if n < 3:
        return 0
    l_array = list(map(int, input().split()))
    ans = 0
    for (a, b, c) in itertools.combinations(l_array, 3):
        if a == b or b == c or c == a:
            continue
        elif a + b <= c or b + c <= a or c + a <= b:
            continue
        else:
            ans += 1
    return ans
        
print(main())

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(n,a):
  res = 0
  for i in range(n-2):
    x = a[i]
    for j in range(i+1,n-1):
      y = a[j] 
      if x == y:
        continue
      for k in range(j+1,n):
        z = a[k]
        if y == z:
          continue
        if abs(x-y) < z < x+y:
          res += 1
  return res



def main():
  N = int(input())
  a = list(sorted(map(int,input().split())))
  print(solve(N,a))
  return

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0

for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i] == L[j] or L[j] == L[k]:
        continue
      if (L[i] + L[j]) > L[k]:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
bou = list(map(int,input().split()))

abc = 0
def checker(a,b,c):
    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            return 1
        else:
            return 0
    else:
        return 0

ans = 0

for i in range(N - 2):
    for j in range(i, N - 1):
        for k in range(j, N):
            ans += checker(bou[i],bou[j],bou[k])
            
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[k] <L[i]+L[j]:
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
#N=5
num=0
for a in range(1,N-1):
    for b in range(a+1,N):
        for c in range(b+1,N+1):
            #print(a,b,c)
            if L[a-1]!=L[b-1] and L[b-1]!=L[c-1] and L[c-1]!=L[a-1] :
                if L[a-1]+L[b-1]>L[c-1] and L[b-1]+L[c-1]>L[a-1] and L[a-1]+L[c-1]>L[b-1] :
                    num+=1
print(num)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if L[i] == L[j]:
            continue
        for k in range(j+1, N):
            if L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i] < L[j] + L[k] and L[j] < L[i] + L[k] and L[k] < L[j] + L[i]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
                continue
            if l[k] < l[i] + l[j]:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
arr = list(map(int, input().split()))
cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if arr[i] == arr[j] or arr[j] == arr[k] or arr[i] == arr[k]:
                continue
            if not ((arr[i] + arr[j]) > arr[k] and (arr[j] + arr[k]) > arr[i] and (arr[i] + arr[k]) > arr[j]):
                continue
            cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

A.sort()

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            a, b, c = A[i], A[j], A[k]

            if (a == b) or (b == c) or (c == a):
                continue

            if (a+b > c) and (b+c > a) and (c+a > b):
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
if n<3:
  print(0)
  exit()
for i in range(n-2):
  for j in range(i,n-1):
    for k in range(j,n):
      if l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[k]+l[j]>l[i] and l[i]!=l[j]!=l[k]:
        ans +=1
     
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))

l.sort()

icnt=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]!=l[j] and l[j]!=l[k]:
                if l[k]<l[i]+l[j]:
                    icnt+=1
                    
print(icnt)

Submission status: Accepted

Solution code:
import sys
import itertools

if __name__ == '__main__':
    N = int(sys.stdin.readline())
    L = list(map(lambda x: int(x), sys.stdin.readline().rstrip().split()))

    num = 0
    for items in itertools.combinations(L, 3):
        a, b, c = items
        if a == b or b == c or c == a:
            continue
        if a+b > c and b+c > a and c+a > b:
            num += 1
    print(num)

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
L = [int(x) for x in input().split()]

ans = 0
for a, b, c in combinations(L, 3):
    if a == b or b == c or c == a:
        continue
    if a + b > c and b + c > a and c + a > b:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
N=int(sys.stdin.readline().strip())
L=map(int, sys.stdin.readline().split())
LL=list( itertools.combinations(L,3) )
ans=0
for a,b,c in LL:
    if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
        ans+=1
print ans

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                tmp = [L[i], L[j], L[k]]
                tmp.sort()
                if tmp[0]+tmp[1] > tmp[2]:
                    ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(map(int, input().split()))
ans=0
for i in range(n):
  for j in range(i):
    for k in range(j):
      if l[i]!=l[j]and l[k]!=l[j]and l[k]!=l[i]:
        if l[k] +l[j] > l[i]:
          ans+=1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N = int(input())
    L_lsit = list(map(int, input().split()))

    L_lsit.sort()

    answer = 0
    for i in range(N):
        for j in range(i+1, N):
            if L_lsit[i] != L_lsit[j]:
                for k in range(j+1, N):
                    if (L_lsit[j] != L_lsit[k]) and (L_lsit[i] + L_lsit[j] > L_lsit[k]):
                        answer += 1
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools

N = 5
ARR = [4, 4, 9, 7, 5]


N = 10
ARR = [9, 4, 6, 1, 9, 6, 10, 6, 6, 8]

N = int(input())
ARR = list(map(int,input().split()))

result = 0
for item in itertools.combinations(ARR, 3):
    x, y, z = item

    if x == y:
        continue
    if x == z:
        continue
    if y == z:
        continue

    if x + y > z:
        if abs(x - y) < z:
            result += 1

print(result)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))

L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                continue
            if L[i] + L[j] > L[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
# B - Making Triangle
N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i] and L[i]+L[j]+L[k]>2*max(L[i],L[j],L[k]):
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
L_list = list(map(int, input().split()))

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            if L_list[i] == L_list[j] or L_list[j] == L_list[k] or L_list[k] == L_list[i]:
                continue
            if L_list[i] + L_list[j] > L_list[k] and L_list[j] + L_list[k] > L_list[i] and L_list[k] + L_list[i] > L_list[j]:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n):
    for j in range(i, n):
        for k in range(j, n):
            if l[i] != l[j] and l[j] != l[k] and l[k] < l[i] + l[j]:
                cnt +=1
            else:
                pass
print(cnt)

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    L = il()

    ret = 0
    for i in range(N):
        for j in range(i, N):
            for k in range(j, N):
                if i != j and i != k and j != k and L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                    if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                        ret += 1
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n= int(input())
l_s= list(map(int, input().split()))
l_s.sort()
count=0
for a in range(len(l_s)):
	for b in range(a+1, len(l_s)):
		for c in range(b+1, len(l_s)):
			if l_s[a]==l_s[b]:
				pass
			elif l_s[b]==l_s[c]:
				pass
			else:
				if l_s[a]+l_s[b]>l_s[c]:
					count+=1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
L = list(sorted(map(int, input().split())))
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if L[i] == L[j]: continue
        for k in range(j+1, n):
            if L[j] == L[k]: continue
            if L[i] + L[j] > L[k]: ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
L = list(map(int, input().split()))

cnt = 0
for i, j, k in itertools.combinations(L, 3):
    if abs(j - k) < i and i < j + k:
        if i != j and j != k and k != i:
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N = I()
L = LI()

L.sort()
l = list(itertools.combinations(L,3))

count = 0
for a in l:
    length = len(collections.Counter(a))
    # print(length)
    if not length==3:
        continue
    # print('OK')
    if a[0]+a[1]>a[2] and a[1]+a[2]>a[0] and a[2]+a[0]>a[1]:
        count += 1
print(count)

Submission status: Accepted

Solution code:

def main():
    counter = 0
    n = int(input())
    l = list(map(int,input().split()))
    l.sort()
    for i in range(n-2):
        for j in range(i+1,n):
            for k in range(j+1,n):
                if l[i]==l[j] or l[j]==l[k] or l[k]==l[i]:
                    continue
                if l[k] < (l[i] + l[j]):
                    #print(l[i],l[j],l[k])
                    counter += 1

    print(counter)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i!=j and j!=k and k!=i:
                if l[i]!=l[j] and l[k]!=l[j] and l[k]!=l[i]:
                    if l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[k]+l[j]>l[i]:
                        ans+=1
print(ans//6)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(x) for x in input().split()]
L.sort()

ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i] + L[j] > L[k] and L[i] != L[j] and L[j] != L[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))

if (N < 3):
    print(0)
    exit(0)
count = 0

for i in range(N-2):
    for j in range(i + 1, N-1):
        for k in range(j + 1, N):
            a = L[i]
            b = L[j]
            c = L[k]

            if (a != b and b != c and c != a and a + b > c and b + c > a and c + a > b):
                count += 1

print(count)

Submission status: Accepted

Solution code:
from itertools import combinations_with_replacement
n=int(input())
L=list(map(int,input().split()))
A=[i for i in range(n)]

cnt=0
for a,b,c in combinations_with_replacement(A,3):
    i,j,k=sorted([L[a],L[b],L[c]])
    if i+j>k and i!=j and j!=k and k!=i:
        cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())

L=list(map(int,input().split()))
L.sort()

# print(L)

ntri=0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i] < L[j]:
            Lij = L[i]+L[j]
            for k in range(j+1, N):
                if L[j]<L[k] and Lij>L[k]:
                    ntri+=1

print(ntri)

Submission status: Accepted

Solution code:
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if L[i] == L[j]:
            continue
        for k in range(j+1, N):
            if L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i] + L[j] > L[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import random


def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)


def lcm(a, b):
    return (a * b) / gcd(a, b)

n=int(input())
a=list(map(int, input().split()))
c=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1, n):
            if a[i]+a[j]>a[k] and a[i]+a[k]>a[j] and a[j]+a[k]>a[i] and a[i]!=a[j] and a[j]!=a[k] and a[k]!=a[i]:
                #print(a[i],a[j],a[k])
                c+=1
print(c)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N, LS):
    # LS = list(sorted(set(LS)))
    # N = len(LS)
    LS.sort()
    ret = 0
    for i in range(N):
        for j in range(i + 1, N):
            if LS[i] == LS[j]:
                continue
            for k in range(j + 1, N):
                if LS[j] == LS[k]:
                    continue
                if LS[i] + LS[j] > LS[k]:
                    # debug(": i,j,k", i, j, k, "  ", LS[i], LS[j], LS[k])
                    ret += 1
    return ret


def main():
    # parse input
    N = int(input())
    LS = list(map(int, input().split()))
    print(solve(N, LS))


# tests
T1 = """
5
4 4 9 7 5
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
5
"""

T2 = """
6
4 5 4 3 3 5
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
8
"""

T3 = """
10
9 4 6 1 9 6 10 6 6 8
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
39
"""

T4 = """
2
1 1
"""
TEST_T4 = """
>>> as_input(T4)
>>> main()
0
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()

Submission status: Accepted

Solution code:
import itertools

N = int(input())
L = list(map(int, input().split()))
res = 0


for pair in itertools.combinations(L, 3):
  if pair[0] == pair[1] or pair[1] == pair[2] or pair[0] == pair[2]:
    continue
  if pair[0] + pair[1] <= pair[2] or pair[1] + pair[2] <= pair[0] or pair[2] + pair[0] <= pair[1]:
    continue
  res += 1
  
print(res)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
# L.sort()
# print(L)
ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] == L[k] or L[k] == L[j] or L[i] == L[j]:
                continue
            if L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[k] + L[j] > L[i]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L=input().split()
for i in range(N): L[i]=int(L[i])
L.sort()
res=0
if N<3: print(0)
else:
  for i in range(N):
    for j in range(i+1,N):
      if L[j]==L[i]: continue
      for k in range(j+1,N):
        if L[i]==L[k] or L[j]==L[k]: continue
        if L[k]<L[j]+L[i]: res+=1
  print(res)

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i]+l[j]>l[k] and l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
ans = 0

for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            maxint = max(L[i],  L[j],  L[k])
            sumint = L[i] + L[j] + L[k]
            if sumint > 2 * maxint:
                if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] :
                    ans += 1

print(ans)

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    L = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                a, b, c = sorted([L[i], L[j], L[k]])
                if c < a + b and a != b and b != c and c != a:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
LL = [int(n) for n in input().split(" ")]


#N = 10
#LL = [9,4,6,1,9,6,10,6,6,8]
OO = [n for n in range(N)]

import copy
import itertools

def makeCombination(candidate, n, lessFlag):
    if len(candidate) <= 0:
        return [[]]
    _candidate = [n for n in candidate]
    _candidate = sorted(_candidate)
    result = []
    if lessFlag is False:
        tmp = list(set(list(itertools.combinations(_candidate, n))))
        for t in tmp:
            result.append(list(t))
    else:
        for i in range(n):
            result += makeCombination(candidate, i + 1, False)
        result += [[]]
    return result

def triangle(ll):
    lll = copy.deepcopy(ll)

    maxlen = max(lll)

    lll.remove(maxlen)

    if lll[0] + lll[1] > maxlen:
        return True
    return False

ok = 0
candidates = makeCombination(OO, 3, False)
for cand in candidates:
    a = LL[cand[0]]
    b = LL[cand[1]]
    c = LL[cand[2]]
    if a != b and b != c and a != c:
        if triangle([a, b, c]):
            ok += 1
print(ok)

Submission status: Accepted

Solution code:
import math
import itertools
import sys
n = int(input())
l = list(map(int, input().split()))


def isTriangle(a, b, c):
    if(a != b and b != c and c != a):
        if(a+b > c and b+c > a and c+a > b):
            return True
        else:
            return False
    else:
        return False


cnt = 0
for i in itertools.combinations(l, 3):
    if(isTriangle(i[0], i[1], i[2])):
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))

L.sort()

ans=0

for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if L[i]+L[j]>L[k] and L[i]!=L[j]!=L[k]:
        ans+=1
        #print("{}{}{}".format(i,j,k))
        
print(ans)
#print(L)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
L = list(map(int,input().split()))
L.sort()
answer=0
for ls in itertools.combinations(L, 3):
    if (ls[0]+ls[1]>ls[2]) and (ls[0]!=ls[1]and ls[1]!=ls[2]):
        answer +=1
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
ar = list(map(int,input().split()))
ans = 0
for i in range(0,n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			s = {ar[i],ar[j],ar[k]}
			if(len(s)!=3):
				continue;
			a , b, c = ar[i],ar[j],ar[k]
			if(a+b>c and b+c>a and c+a>b):
				#print(i,j,k)
				ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    L = LI()
    cnt = 0
    for b in itertools.combinations(L,3):
        a = sorted(b)
        if a[0] < a[1] < a[2] and a[0] + a[1] > a[2]:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
lis = list(map(int, input().split()))

lis.sort()
# print(lis)

ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if lis[i]!=lis[j] and lis[j]!=lis[k] and lis[k]!=lis[i] and lis[k] < lis[i]+lis[j]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))

cnt = 0
for i in range(N):
  for j in range(i + 1, N):
    for k in range(j + 1, N):
      a = L[i]
      b = L[j]
      c = L[k]
      if a == b or b == c or c == a:
        continue
      if a + b <= c or b + c <= a or c + a <= b:
        continue
      cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = sorted(list(map(int, input().split())))
num = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
        pass
      else:
        if L[i] + L[j] > L[k]:
          num += 1
print(num)

Submission status: Accepted

Solution code:
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
from heapq import heapify, heappop, heappush
from math import ceil, log, floor, sqrt
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n = int(data())
arr = L()
answer = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if arr[i] == arr[j]:
            continue
        for k in range(j+1, n):
            if arr[i] == arr[k] or arr[j] == arr[k]:
                continue
            if (arr[i] + arr[j] > arr[k]) and (arr[i] + arr[k] > arr[j]) and (arr[j] + arr[k] > arr[i]):
                answer += 1
out(answer)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            a, b, c = L[i], L[j], L[k]
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

import itertools

n = int(input())
l = list(map(int, input().split(" ")))


def is_triangle(a, b, c):
    return a + b > c and a + c > b and c + b > a

res = 0
for a, b, c in itertools.combinations(l, 3):
    if is_triangle(a, b, c) and a != b and b != c and c != a:
       res += 1

print(res)