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:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement, groupby
from math import sqrt, ceil, floor, factorial, gcd
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
import sys  # def input(): return sys.stdin.readline().rstrip() # sys.setrecursionlimit(10**6)

n = int(input())
L = list(int(x) for x in input().split())
if n <= 2:
    print(0)
    exit()
ans = 0
for a, b, c in combinations(L, 3):
    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

def main():
    N = int(sys.stdin.readline().rstrip())
    L = [int(x) for x in sys.stdin.readline().rstrip().split()]
    L = np.array(L)
    # L.sort()
    # print(L)
    cnt = 0

    if N < 3:
        print(0)
        return

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

    print(cnt)


main()

Submission status: Accepted

Solution code:
from itertools import combinations

N, *L = map(int, open(0).read().split())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left
from itertools import product
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def LF(): return list(map(float, input().split()))
def LC(): return [c for c in input().split()]
def LLI(n): return [LI() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]

def array2d(N, M, initial=0):
    return [[initial]*M for _ in range(N)]

def copy2d(orig, N, M):
    ret = array2d(N, M)
    for i in range(N):
        for j in range(M):
            ret[i][j] = orig[i][j]
    return ret


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


def main():
    N = INT()
    L = LI()
    L.sort()
    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]:
                    continue
                if L[i]+L[j] > L[k]:
                    count += 1
    print(count)

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

l.sort()
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i] != l[j] and l[j] != l[k] and l[i]+l[j] > l[k]:
        ans+=1
print(ans)

Submission status: Accepted

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

cnt = 0

# ３つの相異なる数字（i, j, k）の組み合わせを調べること
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
            else:
                if a<b+c and b<c+a and c<a+b:
                    cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(l) for l in input().split()]
cnt = 0
for i in range(N):
    Li = L[i]
    for j in range(i + 1, N):
        Lj = L[j]
        for k in range(j + 1, N):
            Lk = L[k]

            if Li != Lj and Lj != Lk and Lk != Li:
                _L = sorted([Li, Lj, Lk])
                if _L[0] + _L[1] > _L[2]:
                    cnt += 1

print(cnt)

Submission status: Accepted

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

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

res = 0
for i in range(len(nums)-2):
  for j in range(i+1,len(nums)-1):
    if(nums[i]==nums[j]):
      continue
    for k in range(j+1,len(nums)):
      if(nums[i]==nums[k] or nums[j]==nums[k]):
        continue
      
      m = max(nums[i],nums[j],nums[k])
      if m==nums[i] and m<nums[j]+nums[k]:
        res+=1
      elif m==nums[j] and m<nums[i]+nums[k]:
        res+=1
      elif m==nums[k] and m<nums[i]+nums[j]:
        res+=1

print(res)

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

print(count)

Submission status: Accepted

Solution code:
import sys
import numpy as np
import math
import collections
import copy
import decimal
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

# input = sys.stdin.readline
N = int(input())
Ln = list(map(int, input().split()))
Ln.sort()
Lc = collections.Counter(Ln)
ans = 0
Cmb = combinations(Lc, 3)
for Cm in Cmb:
    l1, l2, l3 = Cm
    if (l1 + l2 <= l3):
        continue
    ans += Lc[l1] * Lc[l2] * Lc[l3]
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):
        if l[i] == l[j]:
            continue
        for k in range(j+1, n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            a = l[i]
            b = l[j]
            c = l[k]
            if a+b > c and b+c > a and c+a > b:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

if N <= 2:
    print(0)
else:
    L = itertools.combinations(L, 3)
    cnt = 0
    for L1, L2, L3 in L:
        if L1 == L2 or L2 == L3 or L3 == L1:
            continue

        if L3 < L2+L1 and L2 < L1+L3 and L1 < L2+L3:
            cnt += 1
    print(cnt)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import combinations


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

ans = 0
c = Counter(l)

for pat in combinations(c.keys(), 3):
    x, y, z = sorted(pat)
    if x + y > z:
        ans += c[x] * c[y] * c[z]

print(ans)

Submission status: Accepted

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


L.sort()
#print(L)
cnt = 0
for i in range(N):
    a = L[i]
    for j in range(i+1,N):
        b = L[j]
        if b == a :
            continue
        for k in range(j+1,N):
            c = L[k]
            if  c == b :
                continue
            elif a + b <= c :
                break
            else:
                # print([a,b,c])
                cnt += 1
print(cnt)

Submission status: Accepted

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

L.sort()
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
def check(i,j,h):
    return i!=j and j!=h and h!=i and i+j>h and j+h>i and i+h>j

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

ans = 0
for i in range(N):
    for j in range(i,N):
        for h in range(j,N):
            ans += check(L[i],L[j],L[h])

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
enum = enumerate
inf = 1001001001

import collections
import random

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

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

def dist(x1,y1,x2,y2):
	return abs(x1-x2)+abs(y1-y2)

def ran():
	vRan = [random.randint(1,5) for i in range(8)]
	return vRan

def bye(res):
	sT = "No Yes".split()
	print(sT[res])
	#exit(0)

def main():
	N, = linput()
	vL = linput()
	
	res = 0
	if N<3: print(res); return

	for i,a in enum(vL[0:]):
		for j,b in enum(vL[i+1:]):
			if a==b: continue
			for k,c in enum(vL[i+j+1:]):
				if a==c or b==c: continue
				p,q,r = sorted([a,b,c])
				if not(p+q<=r):
					res += 1

	print(res)
	

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
import collections


def main():
    n = int(input())
    L = sorted(list(map(int, input().split())))
    counter = collections.Counter(L)
    keys = list(counter.keys())
    lenKeys = len(keys)
    if lenKeys < 3:
        print(0)
        return
    cnt = 0
    for a in range(lenKeys - 2):
        for b in range(a + 1, lenKeys - 1):
            for c in range(b + 1, lenKeys):
                if keys[a] + keys[b] > keys[c]:
                    cnt += counter[keys[a]] * \
                        counter[keys[b]] * counter[keys[c]]
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import itertools as it

def li():
    return [int(x) for x in input().split()]

N = int(input())
L = li()

# 組み合わせ列挙
com = it.combinations(L, 3)
com_list = list(com)

cnt = 0
for l in com_list:
    unique_l = len(set(l))
    if unique_l != 3:
        continue
    a, b, c = l[0], l[1], l[2]
    if a < b + c and b < c + a and c < a + b:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys
import math
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
e = 0

for i in range(len(L)):
    s = 0
    s = L[i]
    for j, b in enumerate(L[i+1:]):
        if L[i] == b:
            continue
        g = s + b
        for w, n in enumerate(L[i+j+2:]):
            if n == b or n == L[i]:
                continue

            a = g - n
            if a > 0:
                e += 1

print(e)

Submission status: Accepted

Solution code:
N = int(input())
L = input()

Li = L.split(' ')
Li = map((lambda x: int(x)), Li)
L = [i for i in Li]

if len(L) < 3:
    L = [0,0,0]

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

Submission status: Accepted

Solution code:
N = int(input())
L = input()

Li = L.split(' ')
Li = map((lambda x: int(x)), Li)
L = [i for i in Li]

if len(L) < 3:
    L = [0,0,0]

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

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    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):
            if L[i] == L[j]:
                continue

            for k in range(j + 1, N):
                if L[j] != L[k]:
                    if L[i] + L[j] > L[k]:
                        count += 1
                    else:
                        break

    print(count)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools

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

count = 0

for triple in itertools.combinations(ary_L, 3):
    l = list(triple)
    l.sort()
    a, b, c = l
    if a != b and a != c and b != c and (a + b > c):
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
lis = [int(x) for x in input().split()]
lis.sort()
nas = 0
ans = 0
for i in range(n-2):
  for y in range(i+1, n-1):
    for z in range(y+1,n):
      if lis[i] != lis[y] and lis[y] != lis[z] and lis[i] != lis[z] and lis[i]+lis[y] > lis[z]:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
L = [int(i) for i in input().split()]

ans = 0
for a, b, c in combinations(L, 3):
    if a != b and b != c and c != a and 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()))
if N <= 2:
    print(0)
else:
    ans = 0
    L.sort()
    for i in range(N):
        for j in range(i,N):
            for k in range(j,N):
                if L[i]+L[j] > L[k] and L[i]<L[j]<L[k]:
                    ans += 1
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import *
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i,j,k in combinations(a,3):
    if i<j<k and i+j>k:
      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-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if L[i] != L[j] != L[k] != L[i] and L[i]+L[j]+L[k] > 2*max(L[i], L[j], L[k]):
                cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

n = r()
a = rl()
ans = 0
a.sort()
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] and a[j]!=a[k] and a[k]!=a[i] and a[i]+a[j]>a[k]:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

for li, lj, lk in combinations(l, 3):
    if li < lj < lk < li + lj:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
ans=0
 
 
for i in range(2,n):
    for j in range(1,i):
        for k in range(j):
            if l[k]==l[j] or l[i]==l[j] or l[i]==l[k]:
                continue
            x=l[k]+l[j]
 
            if x > l[i]:
                ans+=1
 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    from itertools import combinations

    _ = int(input())
    *L, = map(int, input().split())
    L.sort(reverse=True)

    cnt = 0
    for comb in combinations(L, r=3):  # 降順維持
        cond = all([
            len(set(comb)) == 3,
            sum(comb) - comb[0] * 2 > 0
        ])
        if cond:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from itertools import combinations

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    _ = int(rl())
    L = list(map(int, rl().split()))
    L.sort()
    ans = 0
    for li, lj, lk in combinations(L, 3):
        ans += li < lj < lk < li + lj
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    l = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            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:
                    ans += 1
    print(ans)
main()

Submission status: Accepted

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

import sys
input=sys.stdin.readline

n=int(input())
arr=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):
            tmp=[arr[i],arr[j],arr[k]]
            tmp=sorted(tmp)
            s=set(tmp)
            if len(s)==3 and tmp[0]+tmp[1]>tmp[2]:
                ans+=1
print(ans)

Submission status: Accepted

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

cnt=0

for i in range(len(l)):
    for j in range(len(l)):
        for k in range(len(l)):
            if l[i]<l[j]<l[k]:
                if l[k]<l[i]+l[j]:
                    cnt+=1


print(cnt)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
L = list(map(int, input().split()))
cnt = 0
for tri in itertools.combinations(L, 3):
    if max(tri) < sum(tri) - max(tri) and tri[0] != tri[1] and tri[0] != tri[2] and tri[1] != tri[2]:
        cnt += 1
print(cnt)

Submission status: Accepted

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

def main():
    import itertools
    input = sys.stdin.readline
    _ = int(input())
    l = list(map(int, input().split()))
    ans = 0
    for i in itertools.combinations(l, 3):
        if len(set(i)) == 3 and abs(i[0] - i[1]) < i[2] < i[0] + i[1]:
            ans += 1
    print(ans)




if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
L = [*map(int, input().split())]
L.sort()
c = 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[j] == L[k]: continue
            if L[k] == L[i]: continue
            if L[i] + L[j] > L[k]: c += 1
print(c)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
M = sorted(L, reverse=True)
u = 0
c = [0]*3
for i in range(N):
  for j in range(i,N):
    for k in range(j,N):
      if(L[k]<L[i]+L[j] and L[i] < L[k]+L[j] and L[j]<L[i] + L[k] and
         (not(L[i]==L[j])) and (not(L[j]==L[k])) and (not(L[i]==L[k]))):
        u+=1
print(u)

Submission status: Accepted

Solution code:
import itertools

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

count = 0

for pattern in itertools.combinations(L, 3):
    if len(set(pattern)) == len(pattern):
        if max(pattern) < (sum(pattern) - max(pattern)):
            count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l_sort = sorted(L)
cnt = 0

for i in l_sort:
    for j in l_sort:
        for k in l_sort:
            if i >= j or i >= k or j >= k: continue
            if i + j <= k: continue
            cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
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())

N = I()
L =LI()
cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] and abs(L[j] - L[k]) < L[i] < L[j] + L[k]:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
L = [*map(int, input().split())]
M = {}
for l in L:
    if l in M: M[l] += 1
    else: M[l] = 1
M = list(M.items())
M.sort()
m = len(M)
c = 0
for i in range(m):
    for j in range(i+1, m):
        for k in range(j+1, m):
            if M[i][0]+M[j][0] > M[k][0]:
                c += M[i][1] * M[j][1] * M[k][1]
print(c)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
res = 0
for i in range(n):
  for j in range(i + 1, n):
    for k in range(j + 1, n):
      if len(set([a[i], a[j], a[k]])) < 3:
        continue
      if a[i] + a[j] > a[k]:
        res += 1
print(res)

Submission status: Accepted

Solution code:
def 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] > a[k] and a[j]+a[k] > a[i] and a[k]+a[i] > a[j] and a[i] != a[j] and a[j] != a[k] and a[k] != a[i]:
                    cnt += 1
    print(cnt)


main()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            longest = max(L[i], L[j], L[k])
            if longest*2 < L[i] + L[j] + L[k] and len(set([L[i], L[j], L[k]])) == 3:
                res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    
    
    n = ii()
    L = lmi()
    cnt = 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 and b != c and c != a and abs(b - c) < a < b + c:
                    cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for j in range(n):
    for k in range(j + 1, n):
        if l[j] == l[k]:
            continue

        ans += max(bisect_left(l, l[j]) - bisect_right(l, l[k] - l[j]), 0)

print(ans)

Submission status: Accepted

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

t = 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] < l[c] and l[a] + l[b] > l[c]:
                t += 1

print(t)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 175
# B - Making Triangle

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

ans=0

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

print(ans)