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:
input()

sticks = [int(x) for x in input().split(' ')]

cnt = 0
for i in range(len(sticks)):
    for j in range(i + 1, len(sticks)):
        for k in range(j + 1, len(sticks)):
            si = sticks[i]
            sj = sticks[j]
            sk = sticks[k]
            if si != sj and sj != sk and sk != si:
                if si + sj > sk and sj + sk > si and sk + si > sj:
                    cnt += 1

print(cnt)

Submission status: Accepted

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

for i in range(n):
    for j in range(n):
        for k in range(n):
            if (l[i]!=l[j])and(l[j]!=l[k])and(l[k]!=l[i])and(abs(l[i]-l[j])<l[k])and(abs(l[j]-l[k])<l[i])and(abs(l[k]-l[i])<l[j]):
                a += 1
print(a//6)

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0
for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
print(count)

Submission status: Accepted

Solution code:
import collections
from itertools import combinations

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

c = collections.Counter(li)

clist = list(c.keys())
var = len(clist)

ll = combinations(clist,3)

cnt = 0

for i,j,k in list(ll):
    if (i+j>k) and (i+k>j) and (j+k>i):
        cnt += 1*c[i]*c[j]*c[k]
print(cnt)

Submission status: Accepted

Solution code:
num = int(input())
length = [int(s) for s in input().split(' ')]

count = 0

for i in range(num):
    for j in range(i+1, num):
        for k in range(j + 1, num):
            l = [length[i], length[j], length[k]]
            if len(l) == len(set(l)) and max(l) < sum(sorted(l)[:2]):
                count += 1

print(str(count))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(Lis)):
    for j in range(len(Lis)):
        for k in range(len(Lis)):
            if i < j < k:
                if Lis[i] < Lis[j] < Lis[k]:
                    if (Lis[i] < Lis[j] + Lis[k]) and (Lis[j] < Lis[i] + Lis[k]) and (Lis[k] < Lis[j] + Lis[i]):
                        c += 1
print(c)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
dicts = {}
for i in temparr:
    i = int(i)
    arr.append(int(i))
    if i not in dicts:
        dicts[i] = 1 
    else:
        dicts[i] += 1 
arr = sorted(arr)
#print(dicts)
#print(arr)
keys = []
for key, value in dicts.items():
    keys.append(key)
keys = sorted(keys)
freq = []
total = 0 
nn = len(keys)
#print(keys)
for i in range(nn - 2):
    for j in range(i + 1 , nn - 1):
            for k in range(j + 1, nn ):
                #print("i " + str(i) + " j " + str(j) + " k " + str(k))
                if keys[i] + keys[j] <= keys[k]:
                    break 
                total += dicts[keys[i]] * dicts[keys[j]] * dicts[keys[k]]
            #print(total)
print(total)

Submission status: Accepted

Solution code:

def istri(a, b, c):
	f = False
	if a == b or b == c or c == a:
		return f
	elif a < b+c and b < c+a and c < a+b:
		f = True
	return f

n = int(input())
l = list(map(int, input().split()))
ans = 0
# print(l)
# print(istri(l[0], l[1], l[2]))


for i in range(n-2):
	for j in range(i+1, n-1):
		for k in range(j+1, n):
			if istri(l[i], l[j], l[k]):
				ans += 1
print(ans)

Submission status: Accepted

Solution code:
import math
def func():
    a=int(input())
    b = list(map(int,input().split()))
    f = [[[0 for i3 in range(100)] for i2 in range(100)] for i1 in range(100)]
    #print(a)
    #for i in range(a):
    #    print(b[i])
    z=0
    for i in range(a-2):
        ii=i
        p=b[ii]
        for j in range(a-1-ii):
            jj=ii+j+1
            q=b[jj]
            for k in range(a-1-jj):
                kk=jj+k+1
                r=b[kk]
                if p+q>r and q+r>p and r+p>q:
                    if p!=q and q!=r and r!=p:
                        z=z+1
    print(z)

func()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

n=input()
x=0

s=list(map(int,input().split()))
s2=set(s)
s3=sorted(s2)

s4=list(itertools.combinations(s3,3))

for i in s4:
    if i[0]+i[1]>i[2]:
        x=x+s.count(i[0])*s.count(i[1])*s.count(i[2])

print(x)

Submission status: Accepted

Solution code:
import itertools
#import math
N = int(input())
L = list(map(int, input().split()))
cnt = 0
tmp_l = list(itertools.combinations(L,3))
for ls in tmp_l:
    if (ls[0] + ls[1] > ls[2]) & (ls[1] + ls[2] > ls[0]) & (ls[0] + ls[2] > ls[1]):
        if (ls[0] != ls[1] ) & (ls[1] != ls[2] ) & (ls[0] != ls[2] ):
            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]:
                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:
def checkValidity(a, b, c):  
      
    # check condition  
    if (a + b <= c) or (a + c <= b) or (b + c <= a) : 
        return False
    else: 
        return True 
n=int(input())
l=list(map(int,input().split()))
count=0
a,b,c=0,0,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])and (l[k]!=l[i]):
                    a=l[i]
                    b=l[j]
                    c=l[k]
                    if checkValidity(a, b, c):
                        count=count+1
print(count)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int, input().split()))
ans = 0
for x in itertools.combinations(L, 3):
    if max(x)*2 < sum(x) and len(x) == len(set(x)):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
if len(L)<3:
    print(0)
else:
    Lrev = sorted(L,reverse=True)
    count = 0
    for i in range(len(L)-2):
        e1 = Lrev[i]
        for j in range(i+1,len(L)-1):
            e2 = Lrev[j]
            if e1!=e2:
                for k in range(j+1,len(L)):
                    e3 = Lrev[k]
                    if e1!=e3 and e2!=e3 and e1<e2+e3:
                        count += 1
            
    print(count)

Submission status: Accepted

Solution code:
def search(num):
    i = num[0]
    ind = 2
    count = 0

    for j in list(num[1:len(num)]):
        for k in list(num[ind:len(num)]):
            if i != j and i != k and j != k:
                lst = []
                lst.append(int(i))
                lst.append(int(j))
                lst.append(int(k))
                lst.sort()
                if lst[2] < lst[0] + lst[1]:
                    count += 1

        ind += 1

    return count


def main():
    n = int(input())
    num = list(map(int, input().split()))
    
    count = 0
    for i in range(len(num)-2):
        count += search(num[i:len(num)])
    
    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
l=[int(x) for x in input().split()]
dicti={}
for i in range(n):
    if(l[i] in dicti):
        dicti[l[i]]+=1
    else:
        dicti[l[i]]=1
l=set(l)
l=list(l)
l.sort()
cout=0
if(len(l)<3):
    print(0)
else:
    i=0
    j=i+1
    while(i<len(l)-2):
        k=j+1
        while(k<len(l) and l[k]<l[i]+l[j]):
            cout+=(dicti[l[i]]*dicti[l[j]]*dicti[l[k]])
            k+=1
        j=j+1
        if(j==len(l)):
            i+=1
            j=i+1 
    print(cout)

Submission status: Accepted

Solution code:
import itertools

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

ans = 0
for i in itertools.combinations(l, 3):
    x, y, z = i[0], i[1], i[2]

    if x!=y and y!=z and z!=x and x+y>z and y+z>x and x+z>y:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
# a+b > c AND b+c > a AND c+a > b

import itertools
triangle = 0

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


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

print(triangle)

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    n = int(input())
    alist = list(map(int, input().split()))
    if n < 3:
        print(0)
        sys.exit()

    s = list(combinations(alist, 3))
    count = 0

    for i in s:
        if not(has_duplicates(i)):
            if i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[2]+i[0]>i[1]:
                count += 1

    print(count)

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


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


def main():
    N = int(input())
    l = list(map(int, input().split()))
    c = 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 and lj < li + lk and lk < li + lj:
                    c += 1
    print(c)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools
N=int(input())
L=list(map(int,input().split(' ')))
l=0
T=[]
for u in list(itertools.combinations(L, 3)):
    i,j,k=u
    if 2*max(i,j,k)<i+j+k and i!=k and i!=j and j!=k:
        l=l+1
print(l)

Submission status: Accepted

Solution code:
def max(a,b):
	if(a>b):
		return a
	else:
		return b

def min(a,b):
	if(a<b):
		return a
	else:
		return b

list = []
def segitiga(a, b, c):

	a=int(a)
	b=int(b)
	c=int(c)

	if(a==b or b==c or a==c):
		return False;
	else:
		x=min(a,min(b,c))
		y=max(min(a,b), min(max(a,b),c))
		z=max(a,max(b,c))
		ans = (x+y >z)
		return ans




n=int(input())
sisi=input()
sisi=sisi.split()
cnt=0
for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			if(i!=j and i!=k and j!=k):
				if(segitiga(sisi[i], sisi[j], sisi[k])):
					cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
list = list(map(int, input().split()))
mydict = {}
number = []
for i in list:
    if i in mydict.keys():
        mydict[i] += 1
    else:
        mydict[i] = 1
        number.append(i)
number.sort()

count = 0
length = len(number)
if length >= 3:
    for i in range(2,length):
        max = number[i]
        for j in range(0,i):
            for k in range(j+1, i):
                if max < number[j]+number[k]:
                    count += mydict[max]*mydict[number[j]]*mydict[number[k]]

print(count)

Submission status: Accepted

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

ls.sort(reverse=True)
ans = 0

for i in range(0, n - 2):
    longest = ls[i]
    for j in range(i + 1, n - 1):
        second = ls[j]
        if longest == second:
            continue
        for k in range(j + 1, n):
            shortest = ls[k]
            if second == shortest:
                continue
            elif longest < second + shortest:
                ans += 1
            else:
                break

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0

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

Submission status: Accepted

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

for m in range(N):
    for n in range(m+1, N):
        for l in range(n+1, N):
            if K[m] != K[n] and K[m] != K[l] and K[l] != K[n]:
                now_list = sorted([K[m], K[n], K[l]])
                if now_list[2] < now_list[0] + now_list[1]:
                    count += 1

print(count)

Submission status: Accepted

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

import sys
import argparse
import logging
#import math

logging.basicConfig(filename='logger.log', level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)


def f(n: int, l_list: list, i: int = None, j: int = None, k: int = None) -> int:
    '''
    >>> f(0, [])
    0
    >>> f(1, [1])
    0
    >>> f(2, [1, 1])
    0
    >>> f(3, [1, 1, 1])
    0
    >>> f(3, [1, 1, 2])
    0
    >>> f(3, [1, 2, 2])
    0
    >>> f(3, [1, 2, 3])
    0
    >>> f(3, [1, 2, 4])
    0
    >>> f(3, [1, 3, 4])
    0
    >>> f(3, [2, 3, 4])
    1
    >>> f(5, [4, 4, 9, 7, 5])
    5
    >>> f(6, [4, 5, 4, 3, 3, 5])
    8
    >>> f(10, [9, 4, 6, 1, 9, 6, 10, 6, 6, 8])
    39
    '''
    if n <= 2:
        return 0
    result = 0
    for i in range(0, n-2):
        li = l_list[i]
        for j in range(i+1, n-1):
            lj = l_list[j]
            if li == lj:
                continue
            for k in range(j+1, n):
                lk = l_list[k]
                if li == lk or lj == lk:
                    continue
                #logger.debug("(n, i,j,k)=(%d, %d,%d,%d)" % (n, i, j, k))
                l_ijk = sorted([l_list[i], l_list[j], l_list[k]])
                if l_ijk[0] + l_ijk[1] > l_ijk[2]:
                    #logger.debug("yes")
                    result += 1
    return result


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument(
            '--doctest', action='store_true', default=False)
    args = parser.parse_args()
    if args.doctest:
        import doctest
        doctest.testmod(verbose=True)
        sys.exit()

    n = int(sys.stdin.readline().rstrip())
    l_list = list(map(lambda x: int(x), sys.stdin.readline().rstrip().split()))
    print(f(n, l_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

L.sort()

L_ = []

#何が何回出てきたか
tmp = L[0]
k = 1
for i in range(1,N):
    if tmp != L[i]:
        L_.append([tmp,k])
        k=1
    else:
        k += 1
    tmp = L[i]
L_.append([tmp,k])
    
ans = 0

for k in range(len(L_)-1,1,-1):
    for j in range(k-1,0,-1):
        for i in range(j-1,-1,-1):
            if L_[j][0] - L_[i][0] < L_[k][0] and L_[j][0] + L_[i][0] > L_[k][0]:
                ans += L_[i][1]*L_[j][1]*L_[k][1]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

bou = list(map(int,input().split()))
bou.sort(reverse=True)
l_bou = len(bou)

for i in range(l_bou):
    for j in range(i+1, l_bou):
        for k in range(j+1, l_bou):
            if ((bou[i] != bou[j]) and (bou[j] != bou[k]) and (bou[i] != bou[k])): 
                if (bou[i] < bou[j] + bou[k]):
                    ans += 1

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L = list(map(int,input().split()))
count=0
for i in range(0,N):
    A =L[i]
    for j in range(i+1, N):
        B =L[j]
        for k in range(j + 1, N):
            C = L[k]
            X =[A,B,C]
            Y =sorted(X)
            if A==B or B == C or C ==A:
                pass
            elif Y[0] + Y[1] <= Y[2]:
                pass
            else:
                count =count +1

print(count)

Submission status: Accepted

Solution code:
N = int(input())
l_list = list(map(int, input().split()))
l_list.sort()
total = 0

for i in range(N-2):
    li = l_list[i]
    a = l_list.count(li)
    if l_list[i] == l_list[i-1]:
        a = 0
    
    for j in range(i+1,N-1):
        lj = l_list[j]
        b = l_list.count(lj)
        if li == lj or lj == l_list[j-1]:
            b = 0
        for k in range(j+1,N):
            lk = l_list[k]
            c = l_list.count(lk)
            if lk == lj or lk == l_list[k-1]:
                c = 0 
            if li + lj > lk:
                total += a*b*c

print(total)

Submission status: Accepted

Solution code:
from itertools import combinations
import collections


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

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

ans = list(combinations(L, 3))

cnt = 0
for i in range(len(ans)):
    a = ans[i][0]
    b = ans[i][1]
    c = ans[i][2]
    if len(collections.Counter(ans[i])) != 3:
        cnt += 1
    elif not (a + b > c and b + c > a and c + a > b):
        cnt += 1

print(len(ans) - cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
input()
x = list(map(int, input().split()))
x.sort()
x=np.array(x)
ans=0
for i in x[:-2]:
    y = x[x>i]
    for j in y:
        z = y[y>j]
        for k in z:
            if i+j>k:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

import itertools
l=list(map(int ,input().split()))

comb=list(itertools.combinations(l,3))
comber=[]
a=[]
kosuu=0
for i in comb:
    a=list(i)
    a.sort()
    comber.append(a)
for i in range(len(comber)):
    if comber[i][2]<comber[i][1]+comber[i][0]:
        if comber[i][0]!=comber[i][1]!=comber[i][2]:
            kosuu+=1
print(kosuu)

Submission status: Accepted

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

import itertools
result = 0
# 6C3の羅列
for l in itertools.combinations(L, 3):
    if len(set(l)) != 3:continue
    l = list(l)
    l = sorted(l)
    if (l[0]+l[1])>l[2] and l[2]>abs(l[0]-l[1]):result+=1
print(result)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
L_int_list = list(map(int, input().split()))
L_int_set = set(L_int_list)

ans = 0

if len(L_int_set) < 3:
    print(ans)
    exit()

for i in itertools.combinations(L_int_list, 3):
    if len(set(i)) == 3:
        if max(i) < sum(i) - max(i):
            ans += 1

print(ans)

Submission status: Accepted

Solution code:

import collections
from functools import lru_cache


def read():
    return input().strip()


def readInt():
    return int(input().strip())


def readList():
    return list(map(int, input().strip().split()))


def solve(N, arr):
    arr.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 = arr[i], arr[j], arr[k]

                if len(set([a, b, c])) == 3 and a+b > c:
                    ans += 1

    return ans


N = readInt()
arr = readList()

print(solve(N, arr))

Submission status: Accepted

Solution code:
import sys
import itertools

n = int(input())
# = map(int, input().split())
l = sorted(list(map(int, input().split())))
if n < 3 or len(set(l)) < 3:
    print(0)
    sys.exit()
c = list(itertools.combinations(l, 3))
ans = 0
for i in range(len(c)):
    if len(set(c[i])) < 3:
        continue
    if c[i][0] + c[i][1] <= c[i][2]:
        continue
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
n=int(input())
stickl=[]
stickl=input().split()
      
li=list(itertools.combinations(range(n), 3))
count=0
for i in li:
  a=i[0]
  b=i[1]
  c=i[2]
  d=int(stickl[a])
  e=int(stickl[b])
  f=int(stickl[c])
  m=max(d,e,f)
  if d==e or e==f or f==d:
    continue
  if d+e+f>2*m:
    count+=1
print(count)

Submission status: Accepted

Solution code:
def ok(i,j,k):
    if i<j+k and j<i+k and k<i+j:
        return(True)
    else:
        return(False)

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

an=0
if n<3:
    print('0')
    exit()
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
            else:
                if ok(l[i],l[j],l[k]):
                    an+=1
print(an)

Submission status: Accepted

Solution code:
import sys
import itertools

sys.setrecursionlimit(10**6)
input = sys.stdin.readline
#read = sys.stdin.buffer.read

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

    if N < 3:
        print(0)
        return
    
    ans = 0
    for i,j,k in itertools.combinations(L, 3):
        if len(set([i, j, k])) != 3:
            continue
        if i + j <= k:
            continue
        ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.append(-1)
L.append(-2)
i =0
j = 0
k = 0
x = 0
for i in range(0,len(L)-2):
  j = i
  k = i
  while not L[1 + j] == -1:
    while not L[2 + k] == -2:
      a,b,c = (L[0+i],L[1+j],L[2+k])
      if not (a == b or a == c or b == c):
        if a+b>c and b+c>a and c+a>b:
          x += 1
      k += 1
    j += 1
    k = j

print(x)

Submission status: Accepted

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

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

    print(count)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# abc175_b.py
# https://atcoder.jp/contests/abc175

global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    # 長さごとのDictを構成
    dct = dict()
    for value in values:
        if value in dct.keys():
            dct[value] += 1
        else:
            dct[value] = 1

    log(dct)

    lengths = list(dct.keys())
    lengths.sort()

    log(f'lengths=[{lengths}]')

    # 種類の数 [4 5 4 3 3 5] -> [3 4 5] -> 3
    lenlen = len(lengths)

    # 種類数が不足する場合0をReturn
    if lenlen < 3:
        return [0]

    result = 0
    # 3つを選ぶ
    for a in range(lenlen-2):
        for b in range(a+1, lenlen-1):
            for c in range(b+1, lenlen):
                log(str(a) + ':' + str(b) + ':' + str(c))
                log('ABC')
                log(lengths[a])
                log(lengths[b])
                log(lengths[c])
                if lengths[a] + lengths[b] > lengths[c]:
                    result += dct[lengths[a]] * dct[lengths[b]] * dct[lengths[c]]

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['5', '4 4 9 7 5']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['6', '4 5 4 3 3 5']
        lines_export = [8]
    if pattern == 3:
        lines_input = ['10', '9 4 6 1 9 6 10 6 6 8']
        lines_export = [39]
    if pattern == 4:
        lines_input = ['2', '1 1']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
import numpy as np

if __name__ == '__main__':
    N = int(input())
    L = list(map(int,input().split()))
    L1 = []
    L2 = []
    L.sort()
    L.append(1000000000000)
    c = L[0]
    acc = 0
    for l in L:
        if l != c:
            L1.append(c)
            c = l
            L2.append(acc)
            acc = 1
        else:
            acc += 1

    L3 = list(zip(L1, L2))


    accum = 0

    for i,(i1,i2) in enumerate(L3):
        for j,(j1,j2) in enumerate(L3):
            #print(f"i {i} j {j} i1 {i1} j1 {j1} i2 {i2} j2 {j2}")
            if i >= j:
                continue

            #print(L3)
            lis = list(filter(lambda elem : (i1 + j1 > elem[0]) and (i1 < elem[0]) and (j1 < elem[0]), L3))
            #print(i1, j1)
            #print(i2, j2)
            #print(lis)
            #print("")
            if lis != []:
                accum += i2*j2*np.sum(list(elem[1] for elem in lis))

    print(int(accum))

Submission status: Accepted

Solution code:
#B
N=input()
L =list(map(int, input().split()))
import itertools
combi=list(sorted(itertools.combinations(L,3)))
for i in range(len(combi)):
    combi[i]=sorted(combi[i])
count=0
for i in range(len(combi)):
    if combi[i][2] != combi[i][1] and combi[i][2] != combi[i][0] and combi[i][1] != combi[i][0]:
        if combi[i][2] < combi[i][1] + combi[i][0]:
            count +=1
print(count)

Submission status: Accepted

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

count = 0
for i in range(0, n):
  for j in range(i + 1, n):
    for k in range(j + 1, n):
      if l[i] == l[j] or l[j] == l[k] or l[i] == l[k]:
        # break
        # continue
        pass
      elif int(l[i]) + int(l[j]) > int(l[k]) and int(l[i]) + int(l[k]) > int(l[j]) and int(l[j]) + int(l[k]) > int(l[i]):
        count += 1
        pass
      else:
        pass

print(count)

Submission status: Accepted

Solution code:
N = int(input())
Ln = list(map(int, input().split()))
Ln.sort()
# Lc = collections.Counter(Ln)
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if (Ln[i] == Ln[j]):
            continue
        for k in range(j+1, N):
            if (Ln[i] == Ln[k] or Ln[j] == Ln[k]):
                continue
            if Ln[i] + Ln[j] > Ln[k]:
                ans += 1
print(ans)