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:
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0

for i in range(n-2):
    for y in range(i+1,n-1):
        if a[y]==a[i]:
            continue
        for j in range(y+1,n):
            if a[j]==a[y]:
                continue
            if a[i]+a[y]>a[j]:
                ans+=1
            else:
                break

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):
            if (l[i] != l[j] and l[j] != l[k] and l[i] != l[k]) \
            and (l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]):
                cnt += 1
                
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = input().split()
count = 0
for x in range(N-2):
    X = int(L[x])
    for y in range(x+1, N-1):
        Y = int(L[y])
        for z in range(y+1, N):
            Z = int(L[z])

            if X == Y or Y == Z or Z == X:
                pass
            elif X + Y > Z and X + Z > Y and Y + Z > X:
                count += 1
            else:
                pass
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

n = int(input())
num_list = list(map(int, input().split()))

combi = list(itertools.combinations(num_list, 3))

new_list = []
for a in combi:
  if not((a[0] == a[1] or a[1] == a[2] or a[0] == a[2]) or sum(a)-max(a) <= max(a)):
    new_list.append(a)
print(len(new_list))

Submission status: Accepted

Solution code:
n=int(input())
a=[int(k) for k in input().split()][ :n]
c=0
a.sort();
for i in range(len(a)):
    for j in range(i+1,len(a)):
        for m in range(j + 1, len(a) ):
            if (a[i]+a[j]>a[m] and a[i]+a[m]>a[j] and a[m]+a[j]>a[i]) and (a[i]<a[j] and a[j]<a[m]) :
                c+=1

print(c)

Submission status: Accepted

Solution code:
N=int(input())
ai=list(map(int,input().split()))
c=int(0)
if N > 2:
  for i in range(N):
    for k in range(i+1,N):
      for l in range(k+1,N):
        if ai[i] != ai[k] and ai[i] != ai[l] and ai[l] != ai[k]:
          if max(ai[i],ai[k],ai[l]) < ai[i] + ai[k] + ai[l] - max(ai[i],ai[k],ai[l]):
             c += 1          
print(c)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
LN=list(input().split(' '))
LN.sort(key=int)
LN_sort=list(dict.fromkeys(LN))
cbn=list(itertools.combinations(LN_sort,3))
cnt=int(0)
for i in range(len(cbn)):
    if int(cbn[i][0])+int(cbn[i][1])>int(cbn[i][2]):
        cnt+=LN.count(cbn[i][0])*LN.count(cbn[i][1])*LN.count(cbn[i][2])

print(cnt)

Submission status: Accepted

Solution code:
import itertools

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

comb = list(itertools.combinations(l, 3))

# print(comb)

count = 0

for c in comb:
    if c[0] + c[1] > c[2] and c[1] + c[2] > c[0] and c[0] + c[2] > c[1]\
            and c[0]!=c[1] and c[0]!=c[2] and c[1]!=c[2]:
        # print(c)
        count += 1

print(count)

Submission status: Accepted

Solution code:
from itertools import combinations 
N = int(input())
L = list(map(int,input().split()))


ans = list(combinations(L,3))
ans1 = 0
for i in ans:
    if (i[0]+i[1]>i[2] and i[0]+i[2]>i[1] and i[1]+i[2]>i[0] and i[0]!=i[1] and i[0]!=i[2] and i[1]!=i[2]):
        ans1+=1

print(ans1)

Submission status: Accepted

Solution code:
n = int(input())
sis = list(map(int,input().split(" ")))
cou = 0
li = []
for i in range(n-2):
    for j in range(i+1,n-1):
        if sis[j] != sis[i]:
            for k in range(j+1,n):
                if sis[j] != sis[k] and sis[k]!= sis[i]:
                    if sis[k] < (sis[j] + sis[i]) and sis[j] < (sis[k] + sis[i]) and sis[i] < (sis[j] + sis[k]):
                        li.append((sis[i],sis[j],sis[k]))
                        cou += 1
                        
print(cou)

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]:
            #print(l[i],l[j])
            t = l[i] + l[j]
            for k in range(j+1,n):
                t_2 = l[j] + l[k]
                t_3 = l[i] + l[k]
                if l[k] != l[i] and l[k] != l[j] and l[k] < t and l[i] < t_2 and l[j] < t_3:
                    #print(i+1,j+1,k+1)
                    ans += 1
        else:
            continue

print(ans)

Submission status: Accepted

Solution code:
import itertools as it
n=int(input())
tr=list(map(int,input().split()))
tr=it.combinations(tr, 3)
ans=[]
c=0
for i in tr:
    if (i[0]+i[1]>i[2] and i[2]+i[1]>i[0] and i[0]+i[2]>i[1]) and (i[0]!=i[1] and i[0]!=i[2]) and (i[1]!=i[2] and i[1]!=i[0]) :
        c+=1
print(c)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N):
    j = i+1
    for j in range(N):
        k = j+1
        for k in range(N):
            if 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[i]+L[k] and L[k]<L[i]+L[j]:
                    ans += 1
            k += 1
        j += 1
    i += 1
print(ans//6)

Submission status: Accepted

Solution code:
import itertools

n=int(input())
a=list(map(int,input().split()))
count=0

n=list(itertools.combinations(a,3))

for i in n:
  if i[0]!=i[1] and i[1]!=i[2] and i[0]!=i[2]:
    if i[0]+i[1]>i[2] and i[0]+i[2]>i[1] and i[2]+i[1]>i[0]:
      count+=1

print(count)

Submission status: Accepted

Solution code:
a = [input().split() for l in range(2)]
count = 0
N = int(a[0][0])
for i in range(N):
    for j in range(i):
        for k in range(j):
           if int(a[1][i]) != int(a[1][j]) and int(a[1][j]) != int(a[1][k]) and int(a[1][k]) != int(a[1][i]):
                if int(a[1][i]) > abs(int(a[1][j])-int(a[1][k])) and int(a[1][i]) < int(a[1][j])+int(a[1][k]):
                    count = count + 1
print(count)

Submission status: Accepted

Solution code:
x=input()
y = list(map(int, input().split()))
total = 0
for p in y:
    for j in y:
        for k in y:
            if p != j and j!= k and k !=p:
                if p + j > k and j + k > p and k + p > j:
                    total += 1
print(int(total/6))

Submission status: Accepted

Solution code:
from itertools import combinations
n=int(input())
l=[int(i) for i in input().split()][:n]
cnt=0
if n<3:
  print(0)
else:
  c=list(combinations(l,3))
  for j in range(len(c)):
    if c[j][0]==c[j][1] or c[j][1]==c[j][2] or c[j][0]==c[j][2]:
      continue
    else:
        if c[j][0]+c[j][1]>c[j][2] and c[j][0]+c[j][2]>c[j][1] and c[j][1]+c[j][2]>c[j][0]:
            cnt+=1
    
  print(cnt)

Submission status: Accepted

Solution code:
import itertools

def has_duplicates(seq):
    return len(seq) != len(set(seq))

N = int(input())

if N < 3:
  print('0')
else:
 numList = list(map(int,input().split()))
 cnt = 0
 comblist = itertools.combinations(numList,3)
 for pair  in comblist:
  if has_duplicates(pair):  
   continue
  else:
   if (pair[0] + pair[1] > pair[2]) and (pair[0] + pair[2] > pair[1]) and (pair[1] + pair[2] > pair[0]):
    cnt = cnt + 1
 print(cnt)

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,N):
        for k in range(j,N):
            if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                # print(L[i],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]:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = sorted(list(map(int,input().split())))
SS = itertools.combinations(L,3)
count = 0

for x,y,z in SS:
    if x + y > z and x + z > y and y + z > x and x != y != z:
        count += 1
print(count)

Submission status: Accepted

Solution code:
def MakingTriangle():
    
    num = int(input())

    data = list(map(int,input().split()))

    count = 0

    if num <= 2:
        print(0)
        
    else:
        
        for i in range(num - 2):
            
            for j in range(i+1, num-1):
            
                for k in range(j+1, num):
                    if (data[i] != data[j]) and (data[j] != data[k]) and (data[i] != data[k]):
                        
                        if (data[i] + data[j] > data[k]) and (data[j] + data[k] > data[i]) and (data[i] + data[k] > data[j]):

                            count = count + 1
            
        print(count)
        
if __name__ == '__main__':
    MakingTriangle()

Submission status: Accepted

Solution code:
n = int(input())
l_before = input()

l = l_before.split(' ')



i = 0
j = 0
k = 0

count = 0

for ic in range(n):
    for jc in range(n-ic-1):
        for kc in range(n-ic-jc-2):
            i = ic
            j = i + jc + 1
            k = j + kc + 1
            if int(l[i]) != int(l[j]):
                if int(l[j]) != int(l[k]):
                    if int(l[i]) != int(l[k]):
                        if int(l[i]) >= int(l[j]):
                            if int(l[k]) >= int(l[i]):
                                if int(l[k]) < int(l[i]) + int(l[j]):
                                    count = count + 1
                            else:
                                if int(l[i]) < int(l[k]) + int(l[j]):
                                    count = count + 1
                        else:
                            if int(l[k]) > int(l[j]):
                                if int(l[k]) < int(l[i]) + int(l[j]):
                                    count = count + 1
                            else:
                                if int(l[j]) < int(l[k]) + int(l[i]):
                                    count = count + 1

print(count)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int , input().split()))
B = sorted(list(set(A)),reverse=True)
S = len(B)
if N <=2 or S<= 2:
    print(0)
else:
    count = 0
    for i in range(S-2):
        high = B[i]
        hc = A.count(B[i])
        for j in range(S-2-i):
            mid = B[i +j+1]
            mc = A.count(B[i +j+1])
            for k in range(S-2- i -j):
                if B[i +j+k +2]>(high - mid):
                    lc = A.count(B[i +j+k +2])
                    count += (hc*mc*lc)
    print(count)

Submission status: Accepted

Solution code:
N, = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
R = 0
for i in range(N):
    x = X[i]
    for j in range(i+1, N):
        y = X[j]
        if x == y:
            continue
        for k in range(j+1, N):
            z = X[k]
            if x == z or y == z:
                continue
            if x+y>z:
                R += 1
print(R)

Submission status: Accepted

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

l.sort()
ans = 0
f = l[0]
for i in range(len(l)):
    less = l[:i]
    for v in itertools.combinations(less, 2):
        if v[0] != v[1]:
            if l[i] < v[0] + v[1]:
                if not l[i] in v: 
                    ans += 1
print(ans)

Submission status: Accepted

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


count = 0
R = set(range(N))
A = set()
for i in R:
    B = set()
    A.add(i)
    B = A.union(B)
    for j in R - A:
        B.add(j)
        if K[i] != K[j]:
            for k in R - B:
                if (K[i] != K[k]) and (K[j] != K[k]) and ((K[i]+K[j]) > K[k]) and ((K[j]+K[k]) > K[i]) and ((K[k]+K[i]) > K[j]):
                    count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
n= len(l)
cnt = 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]) and l[i]<(l[j]+l[k]) and l[j]<(l[i]+l[k]) and l[i]!=l[j]!=l[k]:
                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,N):
        for k in range(j,N):
            li = L[i]
            lj = L[j]
            lk = L[k]
            if li + lj > lk and lj + lk > li and lk + li >= lj and li != lj and lj != lk:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools


n = input()
l = list(map(int, input().split())) 
l.sort()
cnt = 0
c_list = list(itertools.combinations(l, 3))
# print(c_list)


for lis in c_list:
    # print(lis[0])
    if (lis[-3]+ lis[-2] > lis[-1])and (lis[-1]!=lis[-2])and (lis[-1]!=lis[-3])and(lis[-2]!=lis[-3]):
        cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
nlist = list(map(int, input().split()))
nnlist = sorted(nlist)
kei = 0
l = 0
for i in range(l,N-2):
    for j in range(i,N-1):
        for k in range(j,N):
            if nnlist[i]!=nnlist[j]:
                if nnlist[i]!=nnlist[k]:
                    if nnlist[j]!=nnlist[k]:
                        if nnlist[i]+nnlist[j]>nnlist[k]:
                            kei = kei+1
print(kei)

Submission status: Accepted

Solution code:
n=int(input())
L=list(map(int,input().split()))
l=len(L)
ans=0
for i in range(l-2):
  for j in range(i+1,l-1):
    if L[i]==L[j]:
      continue
    for k in range(j+1,l):
      if L[j]==L[k] or L[k]==L[i]:
        continue
      m=max(L[i],L[j],L[k])
      s=L[i]+L[j]+L[k]
      if s <= 2*m:
        continue
      ans+=1
print(ans)

Submission status: Accepted

Solution code:
def solve(n, a):
	cnt = 0
	# lists = []
	# S = set(lists)
	S = []
	for i in range(n):
		for j in range(i+1, n):
			for k in range(j+1, n):
				lens = a[i]+a[j]+a[k]
				ma = max(a[i], max(a[j], a[k]))
				rest = lens - ma
				if (ma < rest):
					# lists = []
					# lists.append(ma)
					# lists.append(rest)
					# print(ma, rest)
					# if(lists not in S):
					# 	S.append(lists)
					# print("i, j, k: ", i+1, j+1, k+1)
					if(a[i] != a[j] & a[j] != a[k]):
						if(a[i] != a[k]):
							cnt += 1
	return cnt

N = int(input())
ls = list(map(int, input().split()))
# ls = set(ls)
# ls = list(ls)
cnt = solve(N, ls)
print(cnt)

Submission status: Accepted

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


#print(L)

count = 0

for i in range(len(L)):
    for j in range(len(L)):
        for k in range(len(L)):
            if i < j and j < k:
                if L[i] != L[j] and L[i]!= L[k]:
                    if L[j] != L[k]:
                        #print(L[i],L[j],L[k])
                        koko = [L[i],L[j],L[k]]
                        #print(koko)
                        koko.sort()
                        #print(koko)
                        if koko[2] < koko[1]+koko[0]:
                            count += 1
                            #print(L[i],L[j],L[k])
print(count)

Submission status: Accepted

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

new_L = sorted(L, reverse = True)

k = 0
j = k + 1
i = j + 1
count = 0

while(k < N):

    while(j < N):

        while(i < N):

            if (new_L[k] < (new_L[j] + new_L[i])):
                if(new_L[k] != new_L[j]) and (new_L[j] != new_L[i]) and (new_L[i] != new_L[k]):
                    count += 1

            i += 1
        
        j += 1
        i = j + 1
    
    k += 1
    j = k + 1
    i = j + 1

print(count)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
count = 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] and L[k]!=L[i] and L[i]+L[j]>L[k] and L[k]+L[j]>L[i] and L[i]+L[k]>L[j]:
        count += 1
        
print(count)

Submission status: Accepted

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

if n < 3 :
    print(0)
    exit(0)

l = sorted(l)

cnt = 0

for x in range(len(l)):
    for y in range(x+1, len(l)):
        su = l[x] + l[y]
        for z in range(y+1, len(l)):
            if l[x] == l[y] or l[x] == l[z] or l[y] == l[z]:
                continue
            if su > l[z]:
                cnt += 1
                #print(l[x], l[y], l[z])
            else:
                break

    continue

print(cnt)

Submission status: Accepted

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

if len(set(l)) < 3:
    print("0")
    exit()

result = []
for i in range(len(l)):
  for j in range(i + 1, len(l)):
    for k in range(j + 1, len(l)):
        if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
            if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                result.append([l[i], l[j], l[k]])
print(len(result))

Submission status: Accepted

Solution code:
N=int(input())
S=list(map(int,input().split()))
d=len(S)
S.sort()
r=0
x=1
b=1
for i in range(N):
  x=1
  while d-2>=i+x:
    b=1
    a=S[i]+S[i+x]
    z=abs(S[i]-S[i+x])
    while d-1>=i+x+b:
      if z<S[i+x+b]<a and S[i]!=S[i+x] and S[i]!=S[i+x+b] and S[i+x]!=S[i+x+b]:
        r+=1
      b+=1
    x+=1
print(r)

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
ls_str_l = input().split()

if n < 3:
  print(0)
else:
  ls_l = []
  for l in ls_str_l:
    ls_l.append(int(l))
  
  count = 0
  ls_tri_n = list(combinations(ls_l, 3))
  for ls_tri in ls_tri_n:
    if ls_tri[0] == ls_tri[1] or ls_tri[0] == ls_tri[2] or ls_tri[1] == ls_tri[2]:
      continue
    if ls_tri[0] + ls_tri[1] > ls_tri[2] and ls_tri[0] + ls_tri[2] > ls_tri[1] and \
        ls_tri[1] + ls_tri[2] > ls_tri[0] :
      count += 1

  print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
import itertools
ans = 0
for i in itertools.combinations(l, 3):
    if abs(i[0]-i[1])<i[2] and i[2] < i[0]+i[1] and i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(e) for e in input().split()]
c = 0

if len(set(L)) >= 3:
  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] and L[k] != L[i]:
          if L[i] < L[j] + L[k] and L[j] < L[k] + L[i] and L[k] < L[i] + L[j]:
            c += 1
print(c)

Submission status: Accepted

Solution code:
def tri(a, b, c):
    if abs(b-c) < a and a < (b + c):
        return True
    else:
         return False

def solve():
    N = input()
    L = list(map(int,input().split()))
    ans = set()
    count = 0
    for i in range(len(L)):
        for j in range((i+1), len(L)):
            for k in range((j+1), len(L)):
                if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
                    #print("pass", L[i], L[j], L[k])
                    pass
                elif tri(L[i], L[j], L[k]):
                    #print("l", L[i], L[j], L[k])
                    ans.add((i, j, k))
    #print(ans)
    print(len(ans))


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

result = 0


for i in range(n-2):
    #print("i")
    #print(i)
    for j in range(n-i-1):
        #print("j")
        #print(j)
        j += i+1
        for k in range(n-j-1):
            #print("k")
            #print(k)
            k+= j+1
            if l[i] == l[j] or l[j] == l[k] or l[i] == l[k]:
                pass
            elif max(l[i], l[j], l[k]) < l[i]+l[j]+l[k]-max(l[i], l[j], l[k]):
                result +=1

print(result)

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    L=list(map(int,input().split()))
    counter=0
    for i in range(len(L)):
        for j in range(i,len(L)):
            for k in range(j,len(L)):
                if L[i]!=L[j] and L[i]!=L[k] and L[j]!=L[k]:
                    triangle=[L[i],L[j],L[k]]
                    triangle.sort()
                    if triangle[0]+triangle[1]>triangle[2]:
                        counter+=1
    print(counter)
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys

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

#print(L)
ans = 0


for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            q = []
            q.append(L[i])
            q.append(L[j])
            q.append(L[k])
            q.sort(reverse=True)
            #print(q)
            if q[0]<(q[1]+q[2]) and (q[1]-q[2])*(q[1]-q[0])*(q[0]-q[2])!=0:
                ans += 1
                

print(ans)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int, input().strip().split()))
#print(L);
t_count = 0;
three_numbers = list(itertools.combinations(L, 3))
#print(three_numbers)

for i in range(len(three_numbers)):
    three_number = three_numbers[i];
    #print(three_number)
    li = three_number[0]
    lj = three_number[1]
    lk = three_number[2]
    #print(li);
    #print(lj);
    #print(lk);

    if li == lj:
        continue;
    elif li == lk:
        continue;
    elif lj == lk:
        continue;

    if li+lj <= lk:
        continue;
    elif li+lk <= lj:
        continue;
    elif lj+lk <= li:
        continue;
    t_count+=1;
            
print(t_count);

Submission status: Accepted

Solution code:
N=int(input())
li = list(map(int, input().split()))
c=0
ali=[]
for i in range(0,N):
  for j in range(0,N):
    for k in range(0,N):
      if li[i]+li[j]>li[k] and li[j]+li[k]>li[i] and li[k]+li[i]>li[j]:
        if li[i]!=li[j] and li[j]!=li[k] and li[k]!=li[i]:
          if i!=j and j!=k and k!=i and i<j and j<k:
            ali.append(sorted([i,j,k]))
print(len(ali))

Submission status: Accepted

Solution code:
import itertools

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

count = 0
c_list = list(itertools.combinations(L,3))
for i in range(len(c_list)):
    x = int(c_list[i][0])
    y = int(c_list[i][1])
    z = int(c_list[i][2])
    if x != y and y != z and x != z:
        if x + y > z and x + z > y and y + z > x:
            count +=1
print(count)

Submission status: Accepted

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

ans = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if int(l[i])==int(l[j]) or int(l[i])==int(l[k]) or int(l[k])==int(l[j]):
                ans += 0
            elif int(l[i])+int(l[j])>int(l[k]) and int(l[i])+int(l[k])>int(l[j]) and int(l[k])+int(l[j])>int(l[i]):
                ans += 1
            else:
                ans += 0
                
if n <= 2:
    print(0)
else:
    print(ans)

Submission status: Accepted

Solution code:
_ = input()
L = [int(i) for i in input().split()]
L.sort()
def countSmaller(num, L, exclude):
  counter = 0
  for i in L:
    if i==exclude: continue
    if num<=i: break
    #print(i)
    counter += 1
  return counter
#print(L)
counter = 0
for i in range(len(L)):
  for j in range(i+1, len(L)):
    if L[i]==L[j]: continue
    #print(L[i], L[j], countSmaller(L[i]+L[j], L[j+1:], L[j]))
    counter += countSmaller(L[i]+L[j], L[j+1:], L[j])
print(counter)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
l = list(map(int,input().split()))
c = Counter(l)
l = list(set(l))
ans = 0
l.sort()

n = len(l)
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[k] > l[j] and l[j]+l[k]>l[i]:
                ans += c[l[i]]*c[l[j]]*c[l[k]]
print(ans)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
L = list(map(int, input().split()))
# L = set(L)
# print(L)
PL = []
c = 1
for l in L:
    PL.append([c, l])
    c += 1

cnt = 0
result = []
for hen in itertools.combinations(PL, 3):
    if(hen[0][1] + hen[1][1] > hen[2][1] and hen[0][1] + hen[2][1] > hen[1][1] and hen[1][1] + hen[2][1] > hen[0][1] and hen[0][1] != hen[1][1] and hen[1][1] != hen[2][1] and hen[0][1] != hen[2][1]):
        # print(hen)
        result.append(hen)
    # cnt += 1
# result = set(result)
print(len(result))
# print(result)
# print(cnt)

Submission status: Accepted

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

cnt = 0
Aorg = A
Aset = set(A)
Aset = list(Aset)
Aset.sort()
l = []
for i in Aset:
    l.append(Aorg.count(i))
    
for i in range(len(Aset)-2):
    for j in range(i+1,len(Aset)-1):
        for k in range(j+1,len(Aset)):
            if Aset[i] + Aset[j] > Aset[k]:
                cnt += l[i]*l[j]*l[k]
print(cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
    n = int(input())
    l = list(map(int, input().split(" ")))
    ans = 0

    for i1, one in enumerate(l):
        for i2, two in enumerate(l):
            if one>=two:
                continue
            for i3, three in enumerate(l):
                if one>=three or two>=three:
                    continue
                if three - two < one and one < three + two:
                    ans+=1
    print(ans)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))
lst1.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 lst1[i]+lst1[j] > lst1[k] and lst1[i] != lst1[j] and \
                lst1[i] != lst1[k] and lst1[j] != lst1[k]:
                ans += 1
"""import itertools

for i,j,k in itertools.combinations([i for i in range(n)],3):
    if lst1[i] + lst1[j] > lst1[k]:
        ans += 1"""
print(ans)

Submission status: Accepted

Solution code:
num = int(input())
nums = [int(i) for i in input().split()]
if num < 3:
    print(0)
    exit()
ans = 0
for i in range(0, num-2):
    for j in range(i+1, num-1):
        for k in range(j+1, num):
            t = [nums[i], nums[j], nums[k]]
            temp = sum(t)
            if (temp - max(t)) > max(t) and len(set(t)) == 3:
                # print(t)
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int, input().split()))
c = itertools.combinations(l, 3)
result = 0

for i in c:
  if abs(i[0] - i[1]) < i[2] and i[2] < i[0] + i[1]:
    if i[0] != i[1] and i[0] != i[2] and i[1] != i[2]:
      result += 1
    else:
      continue
  else:
    continue
    
print(result)

Submission status: Accepted

Solution code:
N = int(input())
mylist = list(map(int, input().split()))
set = 0

if(N<3):
  print(set)
else:
  for num in range(len(mylist)-2):
    for num2 in range(len(mylist)-1):
      if(num < num2 and mylist[num] != mylist[num2]):
        for num3 in range(N):
          if(num2 < num3 and mylist[num3] != mylist[num] and mylist[num3] != mylist[num2]):
            newlist = [mylist[num], mylist[num2], mylist[num3]]
            if(max(newlist) < sum(newlist)-max(newlist)):
               set += 1
            
  print(set)

Submission status: Accepted

Solution code:
import itertools as it
N=int(input())
ans=0
K=list(map(int,input().split()))
for i in it.combinations_with_replacement(K,3):
  a=i[0]
  b=i[1]
  c=i[2]
  if a!=b and b!=c and c!=a:
    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=list(map(int,input().split()))

l=[]
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i]!=L[j]:
            for k in range(j+1,N):
                if (L[i]!=L[k])&(L[j]!=L[k]):
                    l.append([i+1,j+1,k+1])
                else:
                    continue
        else:
            continue

answer=[]
for m in range(len(l)):
    L_new=[]
    for n in l[m]:
        L_new.append(L[n-1])
    if max(L_new)<(sum(L_new)-max(L_new)):
        answer.append(l[m])
    else:
        continue

print(len(answer))

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
l += [-999]
val = -9
count = 0
new_list = []
for i in range(n + 1):
    if l[i] == val:
        count += 1
    else:
        new_list += [(val, count)]
        count = 1
        val = l[i]
new_list = new_list[1:]

ans = 0

for first in range(len(new_list) - 2):
    val1 = new_list[first][0]
    amo1 = new_list[first][1]
    second = first + 1
    third = second + 1
    while second < len(new_list) - 1 and third < len(new_list):
        val3 = new_list[third][0]
        amo3 = new_list[third][1]
        val2 = new_list[second][0]
        amo2 = new_list[second][1]

        if val1 + val2 <= val3:
            second += 1
            third = second + 1
        else:
            ans += amo1 * amo2 * amo3
            third += 1
        if second == third:
            third += 1
        elif third == len(new_list):
            second += 1
            third = second+1
print(ans)