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())
l = list(map(int, input().split()))
ans = []
for i in range(n):
  for j in range(i,n):
    for k in range(j,n):
      if l[i]+l[j]+l[k]-2*max(l[i],l[j],l[k])>0 and 2<n and len(list(set([l[i],l[j],l[k]])))==3:
        m = sorted([l[i],l[j],l[k]])
        #if m not in ans:
        ans.append(m)
print(len(ans))

Submission status: Accepted

Solution code:
N = int(input())
L = [int(x) for x in input().split()]
sum = 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[i]+L[k]>L[j] and L[k]+L[j]>L[i]:
                sum += 1
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(e) for e in input().split()]

l.sort()
count = 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]:
                count += 1
                
print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections import Counter

def solve(N: int, L: "List[int]"):
    L=sorted(L)
    ans=0
    if N<3:
        print(0)
        exit()
    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 a==c or b==c:
                    continue
                if a < b + c and b < a + c and c < a + b:
                    ans+=1

    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools

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

count = 0
triangle_list = itertools.combinations(L, 3)
for triangle in triangle_list:
    if len(set(triangle)) != 3:
        continue
    a, b, c = sorted(triangle)
    if a + b > c:
        count += 1

print(count)

Submission status: Accepted

Solution code:
import itertools

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

n = int(input())
l = map(int, input().split())
res = 0
for a, b, c in itertools.combinations(l, 3):
  if check(a,b,c):
    res += 1

print(res)

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:
n = int(input())
in_list = list(map(int,input().split()))
in_list.sort()
count = 0
for i in range(0, n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if in_list[i]!=in_list[j] and in_list[j]!=in_list[k]:
                if in_list[i]+in_list[j]>in_list[k]:
                    count += 1
                    

print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from bisect import *
n,*l=map(int, open(0).read().split())
l.sort()
n = len(l)
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if len({l[i],l[j],l[k]}) ==3 and l[i] + l[j] > l[k] and l[i] > l[k]- l[j]:
                ans +=1
print(ans)

Submission status: Accepted

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

out = 0

for i in range(n):
    for j in range(n - i - 1):
        j_i = i + j + 1
        for k in range(n - j_i - 1):
            k_i = j_i + k + 1
            L1 = L[i]
            L2 = L[j_i]
            L3 = L[k_i]
            if L1 != L2 and L2 != L3 and L3 != L1:
                M = [L1, L2, L3]
                M.sort()
                if M[2] < M[0] + M[1]:
                    # print(M)
                    out += 1
print(out)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
import math,sys,heapq
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
from os import path
import bisect as bi
def yes():print('YES')
def no():print('NO')
if (path.exists('input.txt')): 
    #------------------Sublime--------------------------------------#
    sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
    def I():return (int(input()))
    def In():return(map(int,input().split()))
else:
    #------------------PYPY FAst I/o--------------------------------#
    def I():return (int(stdin.readline()))
    def In():return(map(int,stdin.readline().split()))
#sys.setrecursionlimit(1500)
def dict(a):
    d={} 
    for x in a:
        if d.get(x,-1)!=-1:
            d[x]+=1
        else:
            d[x]=1
    return d


def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bi.bisect_right(a, x)
    if i != len(a):
        return i
    else:            
        return -1

def main():
    try:
        n=I()
        l=list(In())
        l.sort()
        ans=0
        for i in range(n):
            for j in range(i+1,n):
                for k in range(j+1,n):
                    q=0
                    if l[i]+l[j]>l[k]:
                        q+=1
                    if l[j]+l[k]>l[i]:
                        q+=1
                    if l[i]+l[k]>l[j]:
                        q+=1
                    if q==3 and (l[i]!=l[j]) and(l[j]!=l[k]) and (l[i]!=l[k]):
                        #print(i+1,j+1,k+1)
                        ans+=1
        print(ans)
    except: 
        pass
        
M = 998244353
P = 1000000007
Inf=1000000000000000000
if __name__ == '__main__':
    #for _ in range(I()):main()
    for _ in range(1):main()

Submission status: Accepted

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

c=[]
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      c.append((i,j,k))
cnt=0
for i in c:
  s=l[i[0]]
  t=l[i[1]]
  u=l[i[2]]
  
  if s+t>u and t+u>s and u+s>t and len(set([s,t,u]))==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(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]:
                Max=max(L[i],L[j],L[k])
                two=L[i]+L[j]+L[k]-Max
                if Max<two:
                    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] or L[j] == L[k] or L[k] == L[i]:
        continue
      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:
from collections import Counter


N = int(input())

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

def judge_tri(a,b,c,dic):
    if a + b > c:
        return dic[a]*dic[b]*dic[c]
    else:
        return 0

count = Counter(L)
num_list = sorted(list(count.keys()))
num_tri = 0
if len(num_list) > 2:
    for i in range(len(num_list)-2):
        a = num_list[i]
        for j in range(i+1, len(num_list)-1):
            b= num_list[j]
            for k in range(j+1, len(num_list)):
                c = num_list[k]
                num_tri += judge_tri(a,b,c,count)
    print(num_tri)
else:
    print(0)

Submission status: Accepted

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

count = 0
for c_i in range(2, n):
    for b_i in range(1, c_i):
        for a_i in range(b_i):
            a, b, c = length_array[a_i], length_array[b_i], length_array[c_i]
            if a + b > c and c + a > b:
                if a != b and b != c:
                    count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in 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[j] + l[k] > l[i]):
          count += 1
          
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# 整数の入力
N = int(input())
#配列の入力
data = 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 data[i] != data[j] and data[j] != data[k] and data[k] != data[i]:
                l = [data[i],data[j],data[k]]
                ld = sorted(l, reverse = True)
                if ld[0] < ld[1]+ld[2]:
                    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):
            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]:
                    cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    l = [int(e) for e in lines[1].split(' ')]

    return (n, l)


def solve(n, l):

    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[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]:
                        count = count + 1
    
    return count


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int, input().split()))
ans = 0
for i in range(len(li)-2):
  for j in range(i+1,len(li)-1):
    for k in range(j+1,len(li)):
      a = li[i]
      b = li[j]
      c = li[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_org = [int(x) for x in input().split()]
L = sorted(L_org)

cnt = 0

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[j] != L[k]:
                    if (L[i] + L[j] > L[k]):
                        cnt += 1
                    else:
                        break

print(cnt)

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 not ((l[i] == l[j]) or (l[j] == l[k]) or (l[k] == l[i])):
                temp = []
                temp.append(l[i])
                temp.append(l[j])
                temp.append(l[k])
                temp.sort()

                x = temp.pop()
                y = temp.pop()
                z = temp.pop()

                if x < y + z:
                    count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
from itertools import combinations
LC = list(combinations(L, 3))
for l in LC:
	if l[2] < l[0] + l[1]:
		s = set(l)
		if len(s) == 3:
			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):
        if l[i]==l[j]:
            continue
        for k in range (j+1,n):
            
            if l[k]==l[i] or l[k]==l[j]:
                continue
            if l[k]<l[i]+l[j] and l[i]<l[j]+l[k] and l[j]<l[k]+l[i] :
                count+=1
print(count)

Submission status: Accepted

Solution code:
N=input()
N=int(N)
arr=list(map(int,input().rstrip().split()))
aa=arr
n = len(aa) 
arr.sort() 
count = 0
for i in range(0, n-2): 
    k = i + 2
    for j in range(i + 1, n):
        for k in range(j+1,n):
            if aa[i]!=aa[j] and aa[i]!=aa[k] and aa[j]!=aa[k]:
                 if (arr[i] + arr[j] > arr[k] and 
                    arr[i] + arr[k] > arr[j] and 
                    arr[k] + arr[j] > arr[i]): 
                    count += 1
   
        
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

# print(c['str']) # strの個数を表示
# print(c.keys()) # キーを表示
# print(c.values()) # 値を表示
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *l = map(int, read().split())

# l.sort()
c = Counter(l)
h = []
for k, v in c.items():
    h.append([k, v])
h.sort()
# print(h)
ans = 0
for i in range(len(h) - 2):
    for j in range(i + 1, len(h) - 1):
        for k in range(j + 1, len(h)):
            if h[k][0] < h[j][0] + h[i][0]:
                ans += h[i][1] * h[j][1] * h[k][1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n = 0
import sys
if N<3:
    print(0)
    sys.exit()

for i in range(N-2):
    a = A[i]
    for j in range(i+1,N-1):
        if a == A[j]:continue
        b = A[j]
        for k in range(j+1,N):
            if (a == A[k])|(b==A[k]):continue
            c = A[k]
            if (a+b>c)&(b+c>a)&(c+a>b):
                n+=1

print(n)

Submission status: Accepted

Solution code:
def findNumberOfTriangles(arr, n): 
      
    # Count of triangles 
    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
                    arr[i]!=arr[j] and
                    arr[j]!=arr[k] and
                    arr[i]!=arr[k]): 
                    count += 1
    return count 
  
# Driver code 
n=int(input());
arr=list(map(int,input().split()))
  
print(findNumberOfTriangles(arr, n))

Submission status: Accepted

Solution code:

n=int(input())
hoge=list(map(int,input().split()))
ans=0
for a in range(n):
  for b in range(n-a):
    b+=a
    for c in range(n-b):
      c+=+b
      if(a!=b and b!=c and c!=a):
        if(abs(hoge[a]-hoge[b])<hoge[c] and hoge[c]<hoge[a]+hoge[b] 
           and hoge[a]!=hoge[b] and hoge[b]!=hoge[c] and hoge[c]!=hoge[a]):
          ans+=1
          
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(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[i] != l[j] and l[j] != l[k] and l[k] != l[i] and 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:
n = int(input())
a = 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 a[i]+a[j]>a[k] and a[j]+a[k]>a[i] and a[i]+a[k]>a[j]:
                if a[i]!=a[j] and a[i]!=a[k] and a[j]!=a[k]:
                    count+=1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
sticks = list(map(int, input().split()))
sticks.sort()
ans = 0
for i in range(n):
    for j in range(i+1,n):
        li = sticks[i]
        lj = sticks[j]
        if li < lj:
            for k in range(j+1, n):
                lk = sticks[k]
                if lj < lk:
                    if lk >= li +lj:
                        break
                    else:
                        ans += 1
print(ans)

Submission status: Accepted

Solution code:
#NC3 * 3!
from itertools import combinations
N = int(input())
L = list(map(int,input().split()))
#重複ありの線分集合L
edges = list(combinations(L,3))
#Lの組み合わせedges
count = 0
for i in edges:
    if i[0] < i[1] + i[2] and i[1] < i[2] + i[0] and i[2] < i[0] + i[1]:
        if i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
            count += 1
print(count)

Submission status: Accepted

Solution code:
from itertools import combinations
n=int(input())
a=list(map(int,input().split()))
c=0
for x in combinations(a,3):
    if x[0]!=x[1] and x[1]!=x[2] and x[2]!=x[0]:
        if x[0]<x[1]+x[2] and x[1]<x[0]+x[2] and x[2]<x[0]+x[1]:
            c+=1
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
L = sorted([int(x) for x in input().split()])
def f(i, j, k):
    l, m, n = L[i], L[j], L[k]
    if l == m or m == n:
        return False
    return n < l + m
ans = 0
if len(L) < 3:
    print(0)
    exit()
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            ans += f(i, j, k)
print(ans)

Submission status: Accepted

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

count = 0
A.sort()
for i in range(len(A) - 2):
  for j in range(i,len(A)):
    for k in range(j,len(A)):
      if not A[i] == A[j] and not A[i] == A[k] and not A[j] == A[k]:
        if A[k] < A[i]+A[j]:
          count += 1
print(count)

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):
            #print(str(i+1)+" "+str(j+1)+" "+str(k+1)+" "+str(L[i])+" "+str(L[j])+" "+str(L[k])+" "+str(cnt))
            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue
            elif L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[i] + L[k] > L[j]:
                cnt += 1
                
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
LI = lambda: list(map(int, input().split()))

N = int(input())
L = LI()


def judge(i, j, k):
    if len(set([L[i], L[j], L[k]])) < 3:
        return False
    a = L[i] + L[j] > L[k]
    b = L[j] + L[k] > L[i]
    c = L[k] + L[i] > L[j]
    if a and b and c:
        return True
    else:
        return False


def main():
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                if judge(i, j, k):
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

def a():
    s = input()
    if s == 'RRR':
        print(3)
    elif 'RR' in s:
        print(2)
    elif 'R' in s:
        print(1)
    else:
        print(0)


def b():
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    count = 0
    for i, li in enumerate(l):
        for j, lj in enumerate(l[i + 1:],i + 1):
            for lk in l[j + 1:]:
                if lk < li + lj and li != lj and lj != lk:
                    # print(li,lj,lk)
                    count += 1
    print(count)




def c():
    pass



def d():
    pass


# a()
b()
# c()
# d()

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):
      if max(L[i],L[j],L[k]) < (sum((L[i],L[j],L[k])) - max(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:
import itertools

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

if N>2:
	
	NC=list(itertools.combinations([i for i in range(0,N)],3))
	memo=[]
	memo_=[]
	ans=0
	
	for nc in NC:
		a=L[nc[0]]
		b=L[nc[1]]
		c=L[nc[2]]
		if a!=b and b!=c and c!=a and a+b>c and a+c>b and b+c>a:
			memo.append([L[nc[0]],L[nc[1]],L[nc[2]]])
	
	print(len(memo))

else:
	print(0)

Submission status: Accepted

Solution code:
import itertools

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

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

sides = list(itertools.combinations(L, 3))
count = 0
for side in sides:
    if has_duplicates(side):
        continue
    else:
        temp = sorted(side)
        if temp[1]-temp[0] < temp[2] < temp[0]+temp[1]:
            count += 1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools

N = int(input())
A = list(input().split())
B = list(itertools.combinations(A,3))
cnt = 0
for i in B:
  a = int(i[0])
  b = int(i[1])
  c = int(i[2])
  if (a-b)*(b-c)*(c-a) != 0: 
    if a + b > c and b + c > a and c + a > b:
      cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int, input().split()))
cnt=0
X = list(itertools.combinations(L,3))
for i in range(len(X)):
    if X[i][0] == X[i][1] or X[i][1] == X[i][2] or X[i][0] == X[i][2]:
        continue
    elif X[i][0] < X[i][1]+X[i][2] and X[i][1] < X[i][0]+X[i][2] and X[i][2] < X[i][1]+X[i][0]:
        cnt += 1
        
print(cnt)

Submission status: Accepted

Solution code:
from itertools import combinations


def valid_tri(l)->bool:
    if l[0] != l[1] and l[1] != l[2] and l[0] != l[2]:
        # print(l)
        if l[0] + l[1] > l[2] and l[1] + l[2] > l[0] and l[0] + l[2] > l[1]:
            return True
        else: return False
    else: return False

def main():
    n = int(input())
    l = list(map(int, input().split()))
    cnt = 0
    for l in combinations(l, 3):
        if valid_tri(l):

            cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools

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

seq = [int(x) for x in range(1,N+1)]
lis = list(itertools.combinations(seq,3))
cnt = 0

for i in lis :
    a = i[0]-1
    b = i[1]-1
    c = i[2]-1
    if L[a] != L[b] and L[b] != L[c] and L[c] != L[a] :
        if L[a] + L[b] > L[c] :
            if L[b]+L[c] > L[a] :
                if L[c] + L[a] > L[b] :
                    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import glob

class InputGenerator(object):
    def __init__(self, input_path=None):
        if input_path != None:
            self.g = self.input_generator(input_path)
        else:
            self.g = None

    def input_generator(self, input_path):
        with open(input_path) as f:
            for line in f:
                yield line

    def get_input(self):
        if self.g == None:
            return input()
        else:
            return next(self.g)

def triable(a, b, c):
    cond_0 = a != b and a != c and b != c
    cond_1 = a + b > c
    cond_2 = b + c > a
    cond_3 = c + a > b
    return cond_0 and cond_1 and cond_2 and cond_3

def solve(gen):
    N = int(gen.get_input().rstrip())
    len_list = gen.get_input().rstrip().split()
    len_list = list(map(int, len_list))

    # print(N)
    # print(len_list)

    cnt = 0
    for i in range(0, N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                a = len_list[i]
                b = len_list[j]
                c = len_list[k]
                # print(i+1, j+1, k+1)
                # print(triable(a, b, c))
                if triable(a, b, c) == True:
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    test_flag = len(sys.argv) > 1

    if test_flag == True:
        file_path_list = sorted(glob.glob('test/*'))
    else:
        file_path_list = [None]

    for file_path in file_path_list:
        gen = InputGenerator(file_path)
        solve(gen)

Submission status: Accepted

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

L.sort(reverse=True)

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[j] != L[k] and L[i] < L[j] + L[k]:
        count += 1

print(count)

Submission status: Accepted

Solution code:
import sys

N=int(input())
L= list(map(int, input().split()))  
#if L[0]!=L[0]:
    #ans1=1
ans=0
for i in range(N):
    for j in range(1,N):
        for z in range(2,N):
            if L[i]!=L[j] and L[j]!=L[z] and L[i]!=L[z]:
                if L[i]<L[j]+L[z] and L[j]<L[i]+L[z] and L[z]<L[j]+L[i]:
                    if i<j and j<z:
                        ans+=1
                    #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,n):
    for k in range(j,n):
      if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
        if abs(l[i] - l[j]) < l[k] < l[i] + l[j]:
          cnt += 1
print(cnt)