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
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'



def main():
    N=ii()
    L=lmis()
    L.sort()
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                a, b, c = L[i], L[j], L[k]
                if a!=b!=c!=a:
                    # if abs(a-b)<c or abs(b-c)<a or abs(c-a)<b:
                    if a+b > c:
                        # print(i+1, j+1, k+1)
                        ans += 1
    print(ans)


main()

Submission status: Accepted

Solution code:
import itertools

def canMakeTriangle(x,y,z):
    if x == y or x == z or y == z:
        return False
    elif x+y>z and y+z>x and z+x>y:
        return True
    else:
        return False


def resolve():
    _ = int(input())
    L = list(map(int, input().split()))
    cnt = 0
    for l in itertools.combinations(L,3):
        if canMakeTriangle(l[0], l[1], l[2]):
           cnt += 1

    print(cnt) 
    
resolve()

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	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] and A[j] != A[k] and A[i] != A[k]:
					if A[i] + A[j] > A[k] and A[j] + A[k] > A[i] and A[k] + A[i] > A[j]:
						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] or L[j] == L[k] or L[k] == L[i]:
                continue
            l = [L[i], L[j], L[k]]
            l.sort()
            if l[0] + l[1] > l[2]:
                ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

input()
l = sorted(map(int, input().split()))
print(sum(a + b > c and a != b != c != a for a, b, c in combinations(l, 3)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

res = 0
for i, j, k in combinations(l, 3):
    if i != j != k != i:
        if i < j + k and j < i + k and k < i + j:
            res += 1
print(res)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce


N = a_int()
L = ints()
L.sort()
cnt = 0
for i, j, k in combinations(ra(N), r=3):
    if L[k] < L[j] + L[i] and L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = list([int(x) for x in 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[i] != L[k] and L[j] != L[k]:
                if abs(L[i] - L[j]) < L[k]:
                    if L[i] + L[j] > L[k]:
                        count += 1

print(count)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
res=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):
                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]):
                        res+=1
    print(res)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import combinations

N = int(input())
if N == 0:
    print(0)
else:
    L = [int(s) for s in input().split()]

    set_L = Counter(L)

    uniq_L = set_L.keys()

    res = 0
    if len(uniq_L) < 3:
        print(res)
    else:
        for Li, Lj, Lk in combinations(uniq_L, 3):
            if Li + Lj > Lk and Li + Lk > Lj and Lj + Lk > Li:
                res += set_L[Li] * set_L[Lj] * set_L[Lk]

        print(res)

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

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline().rstrip("\n"))
l = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
l.sort()
ans = 0
for a in range(n):
    for b in range(a+1,n):
        for c in range(b+1,n):
            if l[a] != l[b] and l[b] != l[c] and l[c] != l[a]:
                if l[a]+l[b] > l[c]:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

#maincode-------------------------------------------------
n = ini()
l = inl()
ans = 0
for k in range(n):
    for j in range(k):
        if l[k] == l[j]:
            continue
        for i in range(j):
            if l[k] == l[i] or l[j] == l[i]:
                continue
            if l[j] + l[i] <= l[k] or l[k] + l[i] <= l[j] or l[j] + l[k] <= l[i]:
                continue
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
from bisect import bisect_left

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

Submission status: Accepted

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

Submission status: Accepted

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

    if n <= 2:
        print(0)
        return 0
    
    l.sort(reverse=True)
    
    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[i] == l[j] or l[j] == l[k]:
                    continue
                elif l[i] < l[j] + l[k]:
                    cnt += 1

    print(cnt)

    

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):
    one = l[i]
    for j in range(i+1, n):
        two = l[j]
        if one == two:
            continue
        for k in range(j+1, n):
            three = l[k]
            if two == three:
                continue
            if one < two + three and two < one + three and three < one + two:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

L.sort()

ans = 0

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

Submission status: Accepted

Solution code:
from itertools import *
n = int(input())
Ls = list(map(int, input().split()))
ans = 0
if n <= 2:
  print('0')
  exit()
else:
  for v in combinations(Ls, 3):
    l = list(v)
    l.sort(reverse = False)
    if l[2] < l[1] + l[0] and len(set(l)) == 3:
      ans += 1
print(ans)

Submission status: Accepted

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

l_col = collections.Counter(l)
keys = list(l_col.keys())
res = 0
for x in itertools.combinations(keys, 3):
    if max(x)*2 < sum(x):
        c = 1
        for d in x:
            c *= l_col[d]
        res += c
print(res)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import collections
import itertools

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

l = list(set(a))
ans = 0
for v in itertools.combinations(a,3):
    x,y,z = v[0],v[1],v[2]
    if x != y and y != z and z !=x:
        if (x+y+z-max(x,y,z)) - max(x,y,z) > 0:
            ans += 1

print(ans)

Submission status: Accepted

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

from itertools import combinations
count = 0
for seq in combinations(range(0, n), 3):
  if l[seq[0]] + l[seq[1]] <= l[seq[2]]:
    continue
  if l[seq[0]] + l[seq[2]] <= l[seq[1]]:
    continue
  if l[seq[2]] + l[seq[1]] <= l[seq[0]]:
    continue
  if l[seq[0]] == l[seq[1]]:
    continue
  if l[seq[2]] == l[seq[1]]:
    continue
  if l[seq[2]] == l[seq[0]]:
    continue
  
  count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:30:06 2020

@author: divyarth
"""

import sys
import heapq
import math

#sys.setrecursionlimit(100000)
#input=sys.stdin.readline
#print=sys.stdout.write

from collections import deque
from collections import defaultdict
from collections import Counter

modH=int(10**9)+7
I=lambda : list(map(int,input().split(' ')))
def PRINT(lst,sep=' '): print(sep.join(map(str,lst)))


'''
s=input()
stack=[]
mm=0
for i in range(len(s)):
    if s[i]=='R':
        stack.append('R')
    else:
        cnt=0
        while len(stack):
            stack.pop()
            cnt+=1
        mm=max(mm,cnt)        
cnt=0
while len(stack):
    stack.pop()
    cnt+=1
mm=max(mm,cnt)
print(mm)

    
'''
n=int(input())
lst=I()

if len(lst)<=2:
    print(0)
else:
    ans=0
    for i in range(len(lst)-2):
        for j in range(i+1,len(lst)-1):
            for k in range(j+1,len(lst)):
                a,b,c=sorted([lst[i],lst[j],lst[k]])
                if c<b+a and a!=b and b!=c and c!=a:
                    ans+=1
    print(ans)

Submission status: Accepted

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

ans = 0
for i in range(len(a)):
        for j in range(i, len(a)):
            for k in range(j,len(a)):            
                if i == j or j == k:
                    pass
                else:
                    if (a[i] <(a[j]+a[k])) and (a[j] <(a[i]+a[k])) and (a[k] <(a[j]+a[i])) and (a[i] != a[j]) and a[j] != a[k] and a[k] != a[i]:
                        ans += 1
                    else:
                        pass

print(ans)

Submission status: Accepted

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

l = sorted(l)

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

print(count)

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

Submission status: Accepted

Solution code:
a=int(input())
b=list(map(int,input().split()))
cnt=0
for i in range(a-2):
  for j in range(i+1,a-1):
    for k in range(j+1,a):
      if not b[i]==b[j] and not b[j]==b[k] and not b[k]==b[i]:
        if b[i]+b[k]>b[j] and b[k]+b[j]>b[i] and b[i]+b[j]>b[k]:
          cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
from itertools import combinations as combo

def check_tri(c):
    c = list(c)
    if len(set(c)) != 3:
        return False
    else:
        c.sort()
        if c[0] + c[1] > c[2]:  return True
        else:   return False



n = int(input())
ls = list(map(int, input().split()))
tri = list(combo(ls, 3))

ans = 0

for i in tri:
    a = check_tri(i)
    if a:
        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):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            bar = []
            bar.append(L[i])
            bar.append(L[j])
            bar.append(L[k])
            bar.sort()
            if bar[0] == bar[1] or bar[1] == bar[2]:
                continue
            if bar[2] >= bar[0] + bar[1]:
                continue
            count += 1
print(count)

Submission status: Accepted

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

ans = 0
for no1,l1 in enumerate(L):
  for no2, l2 in enumerate(L):
    for no3, l3 in enumerate(L):
      if (no1 < no2) and (no2 < no3):
        sort_L = sorted( [l1,l2,l3] ) 
        if (len(set(sort_L )) == 3) and (sort_L[0] + sort_L[1] > sort_L[2]):
          ans += 1
      else:
        continue
print( ans )

Submission status: Accepted

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

cnt = 0
for i in range(n-2):
    for j in range(1, n-1):
        for k in range(2, n):
            ijk = sorted([l[i], l[j], l[k]])
            if not i < j < k:
                continue
            if len(set(ijk)) != 3:
                continue
            if ijk[0]+ijk[1] > ijk[2]:
                cnt += 1

print(cnt)

Submission status: Accepted

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

if n <= 2:
    print(0)
else:
    cnt = 0

    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if li[i] == li[j] or li[j] == li[k] or li[i] == li[k]:
                    continue

                l = sorted([li[i], li[j], li[k]])

                if l[0] + l[1] > l[2]:
                    cnt += 1

    print(cnt)

Submission status: Accepted

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

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):
            len = l[i]+l[j]+l[k]
            ma = max(l[i],max(l[j],l[k]))
            res = len - ma
            if ma<res and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                ans += 1
                
print(ans)

Submission status: Accepted

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

cnt = 0
for i in range(N):
    li = L[i]
    for j in range(i + 1, N):
        lj = L[j]
        if li == lj: continue
        for k in range(j + 1, N):
            lk = L[k]
            if li == lk or lj == lk: continue
            if li + lj > lk:
                cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools


def dbg(s):
    # print(s)
    pass


N = int(input())
Ls = [int(i) for i in input().split()]


def is_ok(i, j, k):
    dbg(f"{i=},{j=},{k=}")
    if not (i != j and j != k and i != k):
        return False
    ls = [i, j, k]
    ls.sort()
    dbg(f"{ls=}")
    return ls[2] < ls[0] + ls[1]


count = 0
for tri in itertools.combinations(Ls, 3):
    if is_ok(tri[0], tri[1], tri[2]):
        count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in range(n):
    a = l[i]
    for j in range(n-i-1):
        b = l[i+1+j]
        for k in range(n-i-j-2):
            c = l[i+1+j+1+k]
            if a != b and a != c and b != c:
                test = [a,b,c]
                test.sort()
                if test[2] < test[0] + test[1]:
                    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-2):
  for j in range(1, N-1):
    if L[i] == L[j]:
      continue
    for k in range(2, N):

      if i < j and j < k:
        if L[i] == L[k]:
          continue

        if L[j] == L[k]:
          continue

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

Submission status: Accepted

Solution code:
from itertools import combinations as comb
def main():
    N = int(input())
    L = list(map(int, input().split()))
    count = 0
    for a, b, c in comb(L, 3):
        a, b, c = sorted([a, b, c])
        if a == b or b == c or c == a:
            continue
        if c < a + b:
            count += 1
    print(count)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0
for i in range(len(l)-2):
    for j in range(i+1, len(l)-1):
        for k in range(j+1, len(l)):
            if l[i] == l[j]:
                continue
            elif l[i] == l[k]:
                continue
            elif l[j] == l[k]:
                continue
            elif 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())
L = list(map(int, input().split()))

def judge(i, j, k):
    return (i + j > k) and (j + k > i) and (k + i > j) and (i != j) and (j != k) and (k != i)


sum = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if (i == j or j == k or k == i):
                continue
            else:
                if (judge(L[i], L[j], L[k])):
                    sum += 1

print(sum)

Submission status: Accepted

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


import itertools
A=list(itertools.combinations(L,3))
ans=0
for a in A:
	if max(a)*2<sum(a) and len(a)==len(set(a)):
		ans+=1

print(ans)

# 2darray [[0] * 4 for i in range(3)]
# import itertools

Submission status: Accepted

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

# L = list(set(L))
L.sort()

c = itertools.combinations(L, 3)

count = 0
for i in c:
    if i[0] + i[1] > i[2] and i[0] != i[1] and i[0] != i[2] and i[1] != i[2]:
        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 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[i]+L[k] and L[k] < L[i]+L[j]:
                    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 初期入力
import sys
from itertools import combinations

input = sys.stdin.readline  #文字列では使わない
N = int(input())
L = list(map(int, input().split()))
used =set()
count =0
for t in combinations(L, 3):
    if t[0] !=t[1] and t[1] !=t[2] and t[2] !=t[0]:
        t_l =list(t)
        t_l.sort()
        if t_l[2] < t_l[0] +t_l[1]:
            count +=1
print(count)

Submission status: Accepted

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

l.sort(reverse=True)
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]:continue
            if l[k] == l[j]:continue
            if l[i] < l[j]+l[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

count = 0
for logs in combinations(L, 3):
    logs = sorted(list(logs))
    if logs[0] + logs[1] > logs[2] and logs[0] != logs[1] and logs[1] != logs[2] and logs[2] != logs[0]:
        count += 1
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

# L = sorted(L, reverse=True)
Len = len(L)
cnt = 0
for i in range(Len):
    for j in range(i, Len):
        if L[i] == L[j]:
            continue
        for k in range(j, Len):
            if L[i] == L[k] or L[j] == L[k]:
                continue
            longer = max(L[i], L[j], L[k])
            other = L[i] + L[j] + L[k] - longer
            if longer < other:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
#ceilevenoddformula
import math
from queue import PriorityQueue
import bisect
import copy
import time
from collections import Counter
#map(int,input().split())
#int(x) for x in input().split()
n=int(input())
l=[int(x) for x in input().split()]
c=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] or l[k]+l[j]<=l[i] or l[i]+l[k]<=l[j] :
					continue
				else:
					c+=1

print(c)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
ans = 0
for s in range(n):
    for t in range(s+1,n):
        for u in range(t+1,n):
            a = l[s]
            b = l[t]
            c = l[u]
            if a+b>c and b+c>a and a+c>b and a!=b and b!=c and a!=c:
                ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

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

cnt = 0
for a, b, c in C:
    if a == b or b == c or a == c:
        continue

    maxhen = max(max(a, b), c)
    if maxhen < (a + b + c - maxhen):
        cnt += 1

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):
      a = l[i]
      b = l[j]
      c = l[k]
      if a==b or b==c or c==a:
        continue
      if a + b > c and b + c > a and c + a > b:
        count += 1
print(count)

Submission status: Accepted

Solution code:

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

# n==100
cnt=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            a=l[i]
            b=l[j]
            c=l[k]
            if a==b or b==c or c==a:
                continue
            if abs(b-c)<a<b+c:
                cnt+=1
print(cnt)