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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


from itertools import combinations_with_replacement
N = INT()
L = LIST()

C = Counter(L)
S = sorted(set(L))
# print(S)
# print(C)

A = list(combinations(S, 3))
# print(a)
cnt = 0
for a, b, c in A:
    if a != b != c:
        if a + b > c:
            # print(a, b, c)
            # print(c[a])
            # print(c[a])
            cnt += C[a] * C[b] * C[c]
print(cnt)

# cnt = 0
# p = 0
# for idx in range(len(S)-1):
#     p = 0
#     while p + idx != len(S) - 1:
#         s_num = c[S[idx]]
#         min_wa = S[idx] + S[idx + p]
#         print(min_wa)
#         right = S[idx+2:]
#         print(right)
#         a = bisect_left(right, min_wa)
#         print("idx", a)
#         cnt += a * s_num
#         p += 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[k]<l[i]+l[j] and l[i]!=l[j] and l[j]!=l[k]):
                ans+=1


print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import combinations

N = int(input())
L = map(int, input().split())
c = Counter(L)

P = list(combinations(c.keys(), 3))
cnt = 0
for x, y, z in P:
    if x + y > z and y + z > x and z + x > y:
        cnt += c[x] * c[y] * c[z]

print(cnt)

Submission status: Accepted

Solution code:
t=int(input())
arr=list(map(int,input().strip().split()))[:t]
arr.sort()
ct=0
for i in range(0,t-2):
    for j in range(i+1,t-1):
        if(arr[i]==arr[j]):
            continue
        x=arr[i]+arr[j]
        for k in range(j+1,t):
            if(arr[k]==arr[j] or arr[k]==arr[i]):
                continue
            if(x>arr[k]):
                ct+=1
print(ct)

Submission status: Accepted

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

count = 0
l_set = set()
for i1 in range(len(Ls)):
    for i2 in range(i1+1,len(Ls)):
        for i3 in range(i2+1, len(Ls)):
            l1 = Ls[i1]
            l2 = Ls[i2]
            l3 = Ls[i3]
            if l1 == l2 or l2 == l3 or l1==l3:
                continue
            max_l = max(l1, l2 ,l3)
            if max_l < l1+l2+l3 - max_l:
                if tuple(sorted([l1, l2, l3])) not in l_set:
                    count += 1
print(count)

Submission status: Accepted

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

for i in range(N-2):
    for j in range(i+1, N-1, 1):
        if L[i] == L[j]:
            continue
        min = L[j] - L[i]
        max = L[j] + L[i]
        for k in range(j+1, N, 1):
            if L[j] == L[k]:
                continue
            if (min < L[k]) and (L[k] < max):
                ans += 1

print(ans)

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

print(count)

Submission status: Accepted

Solution code:
import itertools

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

count = 0
p = itertools.combinations(M, 3)
for l in p:
  a = l[0]
  b = l[1]
  c = l[2]
  if ((a == b) or (b == c) or (c == a)):
    continue
  if ((a + b > c) and (b + c > a) and (c + a > ｂ)):
    count += 1
print(count)

Submission status: Accepted

Solution code:
from itertools import combinations as comb

def fits(m: iter):
    a, b, c = m
    return a!=b!=c and c!=a and a<b+c and b<a+c and c<a+b

n = int(input())
l = map(int, input().split())
ans = 0

for cwr in comb(l, 3): ans += fits(cwr)
print(ans)

Submission status: Accepted

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

for i in range(len(L)):
    for j in range(len(L) - (i+1)):
        for k in range(len(L) - (i+1+j+1)):
            if L[i] != L[j+i+1] and L[i] != L[k+i+j+2] and L[j+i+1] != L[k+i+j+2]:
                if L[i]+L[j+i+1] > L[k+i+j+2] and L[i]+L[k+i+j+2] > L[j+i+1] and L[k+i+j+2]+L[j+i+1] > L[i]:
                    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import itertools

N = input()
L = input().split()

num = 0
for x in itertools.combinations(L, 3):
  if x[0] != x[1] and x[0] != x[2] and x[1] != x[2]:
      if int(x[0]) + int(x[1]) > int(x[2]) and int(x[0]) + int(x[2]) > int(x[1]) and int(x[1]) + int(x[2]) > int(x[0]) :
          num = num+1

print(num)

Submission status: Accepted

Solution code:
from itertools import combinations as C

N = int(input())
L = list(map(int, input().split()))
L = list(C(L, 3))
ans = 0
for l in L:
    l = list(l)
    l.sort()
    #print(l)
    if l[0] == l[1] or l[1] == l[2] or l[0] == l[2]:
        continue
    if l[0] + l[1] > l[2]:
        ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
import sys
N = int(input())
Ls = sorted(list(map(int, input().split())))

if len(Ls) < 3:
    print("0")
    sys.exit(0)

count = 0
for i in reversed(range(len(Ls))):
    max_l = Ls[i]
    for j in range(1,i+1):
        sec_l = Ls[i-j]

        if sec_l < max_l/2:
            break
        if sec_l == max_l:
            continue

        for k in range(j+1,i+1):
            thi_l = Ls[i-k]

            if sec_l == thi_l:
                continue

            if thi_l + sec_l > max_l:
                count += 1
            else:
                break
print(count)

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))
if n<=2:
    print(0)
    exit()
else:
    t=len(l)
    ans=0
    for i in range(t-2):
        for j in range(i+1,t-1):
            for k in range(j+1,t):
                if l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[j]+l[k]>l[i]:
                    ans=ans+c[l[i]]*c[l[j]]*c[l[k]]
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(_) for _ in 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
            X = (L[i], L[j], L[k])
            if max(X) < sum(X) - max(X):
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools

n=int(input())
l=[int(x) for x in input().split()]

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

ans=0
for x in itertools.combinations(l,3):
    x=list(x)
    x.sort(reverse=True)
    if x[0]<x[1]+x[2]:
        if x[0]!=x[1] and x[1]!=x[2] and x[2]!=x[0]:
            ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(l)

num = list(c.keys())
val = list(c.values())

ans = 0

for i in range(len(num) - 2):
    for j in range(len(num) - 2 - i):
        for k in range(len(num) - 2 - i -j):
            sel = [num[i],num[i + j + 1],num[i + j + 2 + k]]
            if 2 * max(sel) < sum(sel):
                ans += val[i]*val[i + j + 1]*val[i + j + 2 + k]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int,input().split()))
count = 0
for i in range(n):
    for ii in range(n-i):
        if li[i] != li[i+ii]:
            for iii in range (n-i-ii):
                if li[i] != li[i+ii+iii] and li[i+ii]!=li[i+ii+iii]:
                    tri = []
                    tri.append(li[i])
                    tri.append(li[i+ii])
                    tri.append(li[i+ii+iii])
                    if max(tri)<(sum(tri)-max(tri)):
                        count +=1
print(count)

Submission status: Accepted

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

l = list(set(h))
l.sort()
a = []
for i in range(len(l)):
    a.append(h.count(l[i]))
ans = 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] > l[k]:
                ans += a[i] * a[j] * a[k]
print(ans)

Submission status: Accepted

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

for a in range(n-2):
    for b in range(a, n-1):
        for c in range(b, n):
            if l[a] != l[b] != l[c]:
                if abs(l[b] - l[c]) < l[a] < l[b] + l[c]:
                    ans += 1

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
brr=list(map(int,raw_input().split()))

def solve(arr,n):
    if n<=2:
        return 0

    freq=Counter(brr)
    arr=list(set(brr))
    arr.sort()
    count=0
    for i in range(len(arr)-2):
        for j in range(i+1,len(arr)-1):
            for k in range(j+1,len(arr)):
                if arr[i]+arr[j]>arr[k]:
                    count+=freq[arr[i]]*freq[arr[j]]*freq[arr[k]]
    return count

print(solve(brr,n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

def main():
    n = int(input())
    l = list(map(int, input().split()))
    
    if n<3:
        print(0)
        return
    
    leng = n
    ans = 0
    for i in range(leng-2):
        a = l[i]
        for j in range(i+1, leng-1):
            b = l[j]
            if a==b:
                continue
            
            for j in range(j+1, leng):
                c = l[j]
                if c==a or c==b:
                    continue
                
                if a<b+c:
                    if b<c+a:
                        if c<a+b:
                            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x = int(input())
xyz = list(map(int, input().split()))
ans=0
xyz.sort(reverse=True)
for i in range(x):
    a=xyz[i]
    for j in range(i+1,x):
        b=xyz[j]
        if a>b:
            for k in range(j+1,x):
                c=xyz[k]
                if b>c:
                    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()))

c=0
for i in range(0,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[k]==l[i]:
                continue
               
            if abs(l[j]-l[k])<l[i] and l[i]<l[j]+l[k]:
                c+=1
print(c)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int, input().split()))
Lset= list(set(L))
ans = 0
count = 0

for n in itertools.combinations(Lset, 3):
    if n[0]+n[1]>n[2] and n[1]+n[2]>n[0] and n[2]+n[0]>n[1]:
        ans += 1
        count += ans*L.count(n[0])*L.count(n[1])*L.count(n[2])
        ans = 0
print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for a in range(0, n-2):
    for b in range(a+1, n-1):
        for c in range(b+1, n):
            if l[a] + l[b] > l[c] and l[b] + l[c] > l[a] and l[c] + l[a] > l[b] and l[a] != l[b] and l[a] != l[c] and l[b] != l[c]:
                cnt += 1
print(cnt)

Submission status: Accepted

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

l= list(itertools.combinations_with_replacement(L, 3))
ans=0
for ll in l:
    if ll[0]!=ll[1] and ll[0]!=ll[2] and ll[1]!=ll[2]:
        if (ll[0]+ll[1])>ll[2] and (ll[1]+ll[2])>ll[0] and (ll[2]+ll[0])>ll[1]:
            ans+=1
                    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
line = list(map(int, input().split()))
count = 0
for i in range(n):
    result = []
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if line[i] != line[k] and line[i] != line[j] and line[j] != line[k]:
                _len = line[i] + line[k] + line[j]
                max_r = max(line[i], line[k], line[j])
                if max_r < _len - max_r:
                    count += 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())

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

A.sort()
count = 0
for i in range(N):
    a = A[i]
    for j in range(i+1, N):
        b = A[j]
        if b == a:
            continue
        for k in range(j+1, N):
            c = A[k]
            if b == c:
                continue
            if c < a + b:
                count += 1
            else:
                break

print(count)

Submission status: Accepted

Solution code:
import collections
import itertools
N = int(input())
L = list(map(int,input().split()))
s = list(set(L))
c = collections.Counter(L)
ans = 0
for x in itertools.combinations(s, 3):
  if (max(x) < sum(x)-max(x)):
    prd = 1
    for i in range(len(x)):
      prd *= c[x[i]]
    ans += prd
print(ans)

Submission status: Accepted

Solution code:
import itertools


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


cL = list(itertools.combinations(L, 3))

cLlen = len(cL)

for num in range(cLlen):
    if (
        cL[num][0] + cL[num][1] > cL[num][2]
        and cL[num][1] + cL[num][2] > cL[num][0]
        and cL[num][2] + cL[num][0] > cL[num][1]
    ):
        if (
            cL[num][0] != cL[num][1]
            and cL[num][1] != cL[num][2]
            and cL[num][2] != cL[num][0]
        ):
            cnt = cnt + 1


print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
l.sort()
max = len(l)
l.append(10000000000)
ans = 0
for i in range(max-2):
    for j in range(i+1,max-1):
        if l[i] != l[j]:
            k = j+1
            while l[j] == l[k]:
                k += 1
            while l[i] + l[j] > l[k]:
                ans += 1
                k += 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):
        for k in range(j):
            q=L[i];w=L[j];e=L[k]
            # q,w,e=sorted([q,w,e])
            if sum([q,w,e])>max(q,w,e)*2:
                if q!=w and w!=e and e!=q:
                    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-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            x, y, z = L[i], L[j], L[k]
            if x != y and x != z and y != z:
                if max(x, y, z) < x + y + z - max(x, y, z):
                    ans += 1
print(ans)

Submission status: Accepted

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

count = 0
for i,j,k in combinations(range(n),3):
    if i != j and j != k and i != k and l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k]+l[i] > l[j] and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n=int(input())
a_list=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 or j==k or i==k:
                ans+=0
            elif a_list[i]==a_list[j]or a_list[k]==a_list[i] or a_list[j]==a_list[k]:
                ans+=0
            else:
                #print(i,j,k)
                if max(a_list[i],a_list[j],a_list[k]) < a_list[i]+a_list[j]+a_list[k]-max(a_list[i],a_list[j],a_list[k]):
                    #print(a_list[i],a_list[j],a_list[k])
                    ans+=1
print(ans//6)

Submission status: Accepted

Solution code:
import numpy as np

N=int(input())
L=np.array(list(map(int,input().split())))
L.sort(axis=0)
c=0
for i,L1 in enumerate(L):
  for j,L2 in enumerate(L[i+1:]):
    if L1==L2:
      continue
    c+=np.count_nonzero(L[i+j+2:]<L1+L2)-np.count_nonzero(L[i+j+2:]==L2)
print(c)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
if n < 3:
    print(ans)
else:
    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] and l[j] != l[k]:
                    ans += 1
                
    print(ans)

Submission status: Accepted

Solution code:
a = int(input())
lengt = list(map(int, input().split()))
lengt.sort(reverse = False)

count = 0

for m, x in enumerate(lengt[:-2]):
  for n, y in enumerate(lengt[m+1:-1]):
    if x == y:
      count += 0
    else:
      for p, z in enumerate(lengt[m+n+1:]):
        if x+y>z and x!=z and y!=z:
          count += 1
        else:
          count += 0

print(count)

Submission status: Accepted

Solution code:
def CountTriangles(arr, n): 

    count = 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] > arr[k] and 
                    arr[i] + arr[k] > arr[j] and 
                    arr[k] + arr[j] > arr[i] and len(set([arr[i],arr[j],arr[k]]))==3): 
                    count += 1
    return count 


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

##d=dict()
##for i in range(n):
##    for j in range(n):
##        for k in range(n):
##            if i==j or j==k or i==k:
##                continue
##            if checktri(l[i],l[j],l[k]):
##                
##                trip=[l[i],l[j],l[k]]
##                trip.sort()
##                if trip in

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# abc175 b
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
4 4 9 7 5"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """6
4 5 4 3 3 5"""
        output = """8"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10
9 4 6 1 9 6 10 6 6 8"""
        output = """39"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2
1 1"""
        output = """0"""
        self.assertIO(input, output)


def resolve():
    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] or L[j] == L[k] or L[i] == L[k]:
                    continue
                if abs(L[j] - L[k]) < L[i] < L[j] + L[k]:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()

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):
            a,b,c = sorted([l[i], l[j], l[k]])
            if a==b or b==c:
                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())

lst = input().split()

for i in range(N):
   lst[i] = int(lst[i])

#lst = list(set(lst))

lst.sort()

L = len(lst)

count = 0

if 3 <= L:
   for i in range(L - 2):
      for j in range(i + 1, L - 1):
         if lst[i] != lst[j]:
            for k in range(j + 1, L):
               if lst[i] + lst[j] > lst[k] and lst[i] != lst[k] and lst[j] != lst[k]:
                  count += 1

print(count)

Submission status: Accepted

Solution code:
def is_triangle(x,y,z):
  return x+y>z and x!=y and y!=z and x!=z
N=int(input())
L=sorted(list(map(int,input().split())))
from itertools import combinations
print(len([(x,y,z) for (x,y,z) in combinations(L,3) if is_triangle(x,y,z)]))

Submission status: Accepted

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

def check_triangle(i, j, k):
  if i + j > k and j + k > i and i + k > j:
    return True
  return False

num = 0
candidate = []
for i in range(N):
  for j in range(i, N):
    for k in range(j, N):
      if i == j or j == k or i == k:
        continue
      if stick[i] == stick[j] or stick[j] == stick[k] or stick[i] == stick[k]:
        continue
      if check_triangle(stick[i],stick[j],stick[k]):
        #candidate.append([i+1,j+1,k+1])
        num += 1
      
#print(candidate)
print(num)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
List  = list(map(int,input().split()))
List_triangle = []
count = 0

for triangle in itertools.combinations(List,3):
    List_triangle.append(triangle)

for i in range(len(List_triangle)):
    if len(set(List_triangle[i])) == len(List_triangle[i]):
        if sorted(List_triangle[i])[-1] < sorted(List_triangle[i])[-2] + sorted(List_triangle[i])[-3]:
            count += 1
        else:
            pass
    else:
        pass

print(count)

Submission status: Accepted

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

if n < 3:
    print(0)
    exit()
flag = 0
for i in itertools.combinations(lis, 3):
    a = list(i)
    if (a[0] + a[1] > a[2]) and (a[1] + a[2] > a[0]) and (a[0] + a[2] > a[1]):
        max_ = l.count(a[0])*l.count(a[1])*l.count(a[2])
        flag += max_ 
print(flag)

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 abs(L[j] - L[k]) < L[i] and L[i] < L[j] + L[k]:
        count += 1
        if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
          count -= 1
print(count)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
dt = input()
l = dt.split()
count = 0
for team in itertools.combinations(l,3):
    team1 = list(team)
    for i in range(3):
        team1[i] = int(team1[i])
        
    if team1[0] != team1[1] and team1[1] != team1[2] and team1[0] != team1[2]:
        if team1[0] + team1[1] > team1[2] and team1[0] + team1[2] > team1[1] and team1[1] + team1[2] > team1[0]:
            count += 1

print(count)

Submission status: Accepted

Solution code:
from sys import stdin
import collections
#stdin = open('sample.txt')

input = stdin.readline

def main():
    ans = 0
    N = int(input())
    L = list(map(int, input().rstrip().split()))
    l = collections.Counter(L)
    ll = sorted(l.items())
    for i in range(len(ll)):
        for j in range(i):
            for k in range(j):
                if ll[i][0] < ll[j][0] + ll[k][0]:
                    ans += ll[i][1] * ll[j][1] * ll[k][1]
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math
import itertools


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


def main():
    N = I()
    LArray = LI()
    ans = 0
    if N < 3:
        print(ans)
        return

    for v in list(itertools.combinations(LArray, 3)):
        v = list(v)
        v.sort()

        if v[0] == v[1] or v[2] == v[1] or v[0] == v[2]:
            continue
        elif v[0]+v[1] <= v[2]:
            continue
        else:
            ans += 1
        
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from itertools import combinations

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    L = list(map(int, readline().split()))
    count = Counter(L)
    ans = 0
    for a in combinations(count.keys(),3):
        if sum(a)-max(a)*2>0:
            ans += count[a[0]]*count[a[1]]*count[a[2]]
    print(ans)




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-2):
    for j in range(1,n-1):
        for k in range(2,n):
            if i<j<k:
                kari=[l[i],l[j],l[k]]
                if kari[0]!=kari[1]!=kari[2] :
                    if kari[0]+kari[1]>kari[2] and kari[1]-kari[0]<kari[2]:
                        ans+=1    
print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())

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

li = list(itertools.combinations(li, 3))

count = 0

for i in li:
    amari = sum(i) - max(i)
    if amari > max(i):
        if len(set(i)) == 3:
            count += 1

print(count)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int,input().split()))
res = 0
for i in itertools.combinations(L,3):
    i = list(i)
    i.sort()
    if i[0] != i[1] and i[1] != i[2]: 
        if i[2] < i[0]+i[1]:
            res += 1
print(res)

Submission status: Accepted

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

# a+b>c かつ b+c>a かつ c+a>b

import itertools
work_list = list()
for i in itertools.combinations(l, 3):
    if i[0] != i[1] and i[0] != i[2] and i[1] != i[2]:
        work_list.append(i)

def check(set_value):
    if set_value[0] + set_value[1] > set_value[2] and \
       set_value[1] + set_value[2] > set_value[0] and \
       set_value[2] + set_value[0] > set_value[1]:
        return 'ok'
    else:
        return 'ng'
ans = 0
for i in work_list: 
    if check(i) == 'ok':
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
# print(l)
ans=0
a=len(l)
for i in range(a):
    for j in range(i,a):
        if l[i] == l[j]:
            continue
        for k in range(j,a):
            if l[j]==l[k]:
                continue
            elif l[k]>=l[i]+l[j]:
                continue
            # print(l[i],l[j],l[k])
            ans+=1
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = [0 for x in range(n)]
l = list(map(int,input().split()))
l.sort()
cnt = 0
a = 0
b = 0
c = 0
if n < 3:
    print(0)
else:
    for i in range(n-2):
        a = l[i]
        for j in range(i+1,n-1):
            b = l[j]
            for k in range(j+1,n):
                c = l[k]
                if a+b > c and a != b and b != c:
                    cnt += 1
    print(cnt)

Submission status: Accepted

Solution code:

from itertools import combinations
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    CMB = list(combinations(A, 3))
    ans = 0
    for (i, j, k) in CMB:
        if i==j or i==k or j==k:
            continue
        x = sorted([i,j,k])
        if (sum(x[:2])) > x[-1]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

l.sort(reverse=True)
ans = 0
if n < 3:
  ans = 0
else:
  for k in range(0, n-2):
    for j in range(k+1, n-1):
      if l[k]/2 > l[j]:
        break
      if l[k] == l[j]:
        continue
      for i in range(j+1, n):
        if l[k] >= l[j] + l[i] or l[j] == l[i]:
          continue
        else:
          ans += 1
print(ans)

Submission status: Accepted

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

L.sort()
# print(input_L.sort())
length = len(L)
count = 0

# print(L)
if N <= 2:
    print("0")

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

    print(count)

Submission status: Accepted

Solution code:
N = int(input())

a = 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 a[i] == a[j] or a[j] == a[k] or a[i] == a[k]:
                continue
            if a[i] + a[j] <= a[k] or a[i] + a[k] <= a[j] or a[k] + a[j] <= a[i]:
                continue
            cnt += 1

print(cnt)