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: Wrong Answer

Solution code:
N = int(input())
L = [int(x) for x in input().split()]
sum = 0
for i in range(N):
    for j in range(i+1,N):
        if L[i] == L[j]:
            continue
        for k in range(j+1,N):
            if L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[k]+L[j]>L[i]:
                print(L[i],L[j],L[k])
                sum += 1
print(sum)

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
list = list(map(int, input().split()))
list2 = itertools.permutations(list, 3)

ans = 0
for ele in list2:
    a = ele[0]
    b = ele[1]
    c = ele[2]
    if a == b or b == c or c == a:
        continue
    if abs(a-b) < c and c < a+b:
        print(ele)
        ans += 1
print(ans//6)

Submission status: Wrong Answer

Solution code:

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

set_nums = sorted(list(set(nums)))
set_dup = set_nums.copy()

if N <= 2:
    print(0)
else:
    for i, d in enumerate(set_dup):
        count = 0
        for n in nums:
            if n == d:
                count += 1
        set_dup[i] = count

    count = 0
    for a in range(len(set_nums)):
        for b in range(a+1, len(set_nums)):
            for c in range(b+1, len(set_nums)):
                # print(a, b, c)
                if set_nums[a] + set_nums[b] >= set_nums[c]:
                    print(set_nums[a], set_nums[b], set_nums[c])
                    count += set_dup[a] * set_dup[b] * set_dup[c]
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
L = list(map(int,input().split(" ")))
L.sort()
ans = 0
if len(L) <= 2:
    print(ans)
else:
    for i in range(1,len(L)):
        for j in range(2,len(L)):
            if L[0] != L[i] and L[i] != L[j] and L[0] != L[j]:
                if L[0] + L[i] > L[j]:
                    ans += 1
    del L[:1]
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

def ans(arr, n): 
	
	count = 0
	for i in range(n): 
		for j in range(i + 1, n):
			for k in range(j + 1, n):
			    if (arr[i] + arr[j] > arr[k] and arr[i] + arr[k] > arr[j] and arr[k] + arr[j] > arr[i]):
			        if(arr[i]!=arr[j]!=arr[k]):
			            count += 1
	return count 


n = int(input())
arr = [int(x) for x in input().split()]
if(n<=2):
    print(0)
else:
    print(ans(arr,n))

Submission status: Wrong Answer

Solution code:
N = int(input())

Ls = list(map(int, input().split()))
L = sorted(Ls, reverse=True)


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

l.sort()

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

Submission status: Wrong Answer

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

result = 0
ind = range(len(L_list))
for i_1 in ind:
  ind_2 = range(i_1 + 1, len(L_list))
  for i_2 in ind_2:
    ind_3 = range(i_2 + 1, len(L_list))
    for i_3 in ind_3:
      if (L_list[i_1] + L_list[i_2] > L_list[i_3]) and (L_list[i_1] + L_list[i_3] > L_list[i_2]) and (L_list[i_3] + L_list[i_2] > L_list[i_1]):
        if (L_list[i_1] != L_list[i_2]) and (L_list[i_3] != L_list[i_2]) and (L_list[i_1] != L_list[i_3]): 
          result += 1

Submission status: Wrong Answer

Solution code:

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

set_nums = sorted(list(set(nums)))
set_dup = set_nums.copy()

if N <= 2:
    print(0)
else:
    for i, d in enumerate(set_dup):
        count = 0
        for n in nums:
            if n == d:
                count += 1
        set_dup[i] = count

    count = 0
    for a in range(len(set_nums)):
        for b in range(a+1, len(set_nums)):
            for c in range(b+1, len(set_nums)):
                if set_nums[a] + set_nums[b] > set_nums[c]:
                    print(set_nums[a], set_nums[b], set_nums[c])
                    count += set_dup[a] * set_dup[b] * set_dup[c]
    print(count)

Submission status: Wrong Answer

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


ans = 0
if len(l) < 3:
    print(0)
else:
    prelst = list(itertools.combinations(l,3))

    for lst in prelst:
        lst = sorted(lst)
        if lst[0] + lst[1] > lst[2] and lst[0] != lst[1] != lst[2]:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = 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):
      lst2 = [lst[i], lst[j], lst[k]]
      lst3 = sorted(lst2)
      if(lst3[2] < lst3[1] + lst3[0]):
        ans = ans + 1
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans=0
for pair in itertools.combinations(l,3):
    pair=list(pair)
    pair.sort()
    print(pair)
    if pair[0]+pair[1]>pair[2]>abs(pair[0]-pair[1]) and pair[0]!=pair[1]!=pair[2]:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

t = 0
if n <= 2:
    print(0)

else:
    for i in range(0, n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                if a[i] < a[j] + a[k] and a[i] != a[j] and a[j] != a[k]:
                    t = t + 1
print(t)

Submission status: Wrong Answer

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

    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                if l[i] + l[j] > l[k] and l[i] != l[j]:
                    if l[j] + l[k] > l[i] and l[j] != l[k]:
                        if l[k] + l[i] > l[j] and l[k] != l[i]:
                            cnt += 1
                            print(i,j,k)
                
    print(cnt)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in l:
  for j in l:
    for k in l:
      if(i != j and i != k and j != k):
        if(i + j > k and i + k > j and j + k > i):
          count += 1
          
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in l:
    for j in l:
        for k in l:
            if i != j and i != k and j != k:
                cnt += 1
print(int(cnt/6))

Submission status: Wrong Answer

Solution code:
from collections import Counter
def factorial_cor(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


n = int(input())
s = list(map(int, input().split()))
common = Counter(s)

ans = factorial_cor(n)/(factorial_cor(n-3)* factorial_cor(3))

for i in common.values():
    ans /= i
print(int(ans))

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

for i in comb:
  if i[0] + i[1] >= i[2] and i[1] + i[2] >= i[0] and i[0] + i[2] >= i[1]:
    sett.add(i)
    
print(len(sett))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
tmp = set()
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]) not in tmp and abs(l[i]-l[j])<l[k]<l[i]+l[j]:
                ans += 1
            tmp.add((l[i],l[j],l[k]))

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
N = input()
L = input().split()
count = 0

for v in itertools.permutations(L, 3):
    if (v[0]+v[1]>v[2]) and (v[1]+v[2]>v[0]) and (v[2]+v[0]>v[1]):
        count += 1
        
print(count)

Submission status: Wrong Answer

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

t = 0
if n <= 2:
    print(0)

else:
    for i in range(0, n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                if a[i] < a[j] + a[k] and a[i] != a[j] and a[j] != a[k]:
                    t = t + 1

print(t)

Submission status: Wrong Answer

Solution code:
n = int(input())
sum = 0
if n < 3:
  print(0)
else:
  number = list(map(int, input().split()))
  for i in range(n):
    for j in range(n):
      for k in range(n):
        if i != j and i != k and j != k:
          if i + j > k and i + k > j and j + k > i:
            sum += 1

print(sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

for i in comb:
  if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
    sett.add(i)
    
print(len(sett))

Submission status: Wrong Answer

Solution code:
import collections

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

c=sorted(c.items(),key=lambda x:x[0])

item=[]
num=[]

for i,n in c:
    item.append(i)
    num.append(n)
    
count=0

if n<3:
    print(0)
else:
    for i in range(len(item)-2):
        for j in range(i+1,len(item)-1):
            k=j+1
            sumij=item[i]+item[j]
            mulij=num[i]*num[j]
            while k<len(item) and item[k]<sumij:
                count+=mulij*num[k]
                k+=1
    print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int, input().split()))
cnt = 0
for i in range(N):
    for j in range(N):
        for k in range(N):
            tmp_list = [nums[i], nums[j], nums[k]]
            if i == j or j == k or k == i:
                continue
            if tmp_list != list(set(tmp_list)):
                continue
            else:
                tmp_list.sort()
                if tmp_list[-1] >= sum(tmp_list[:-1]):
                    continue
                else:
                    cnt += 1
print(cnt)

Submission status: Wrong Answer

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

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += bisect_left(L, L[i] + L[j]) - (j + 1)

print(ans)

Submission status: Wrong Answer

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]:
                    print(i+1, j+1, k+1)
                    print(l)
                    cnt += 1

    print(cnt)

Submission status: Wrong Answer

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

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

cnt = 0
for l in c_list:
    unique_l = len(set(l))
    if unique_l != 3:
        continue
    sum_l = l[0] + l[1] + l[2]
    max_l = max(l)
    sum_lest = sum_l - max_l
    if sum_lest > max_l:
        print(l)
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
ll=list(map(int,input().split()))
t=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      sa=[ll[i], ll[j], ll[k]]
      ma=max(sa)
      sal=sum(sa)-ma
      if ma<sal:t+=1
      
print(t)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N = int(input())
L = list(map(int, input().split()))
ans = 0
for l in combinations(L, 3):
    if set(l) != 3:
        continue
    a = l[0]
    b = l[1]
    c = l[2]
    if a + b > c and b + c > a and c + a > b:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import permutations
N = int(input())
L = list(map(int, input().split()))
ans = 0
for l in permutations(L, 3):
    if set(l) != 3:
        continue
    a = l[0]
    b = l[1]
    c = l[2]
    if a + b > c and b + c > a and c + a > b:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = sorted(set(map(int, input().split())))
n = len(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] > l[k]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
L=list(map(int,input().split()))
L.sort()
i=0
for a in range(len(L)):
    for b in range(a+1,len(L)):
        for c in range(b+1,len(L)):
            if L[a]==L[b] or L[a]==L[c] or L[b]==L[c]:
                continue
            if L[a]+L[b]>L[c]:
                print(L[a],L[b],L[c])
                i+=1

print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#N = int(input())
#LL = [int(n) for n in input().split(" ")]


N = 10
LL = [9,4,6,1,9,6,10,6,6,8]
OO = [n for n in range(N)]

import copy
import itertools

def makeCombination(candidate, n, lessFlag):
    if len(candidate) <= 0:
        return [[]]
    _candidate = [n for n in candidate]
    _candidate = sorted(_candidate)
    result = []
    if lessFlag is False:
        tmp = list(set(list(itertools.combinations(_candidate, n))))
        for t in tmp:
            result.append(list(t))
    else:
        for i in range(n):
            result += makeCombination(candidate, i + 1, False)
        result += [[]]
    return result

def triangle(ll):
    lll = copy.deepcopy(ll)

    maxlen = max(lll)

    lll.remove(maxlen)

    if lll[0] + lll[1] > maxlen:
        return True
    return False

ok = 0
candidates = makeCombination(OO, 3, False)
for cand in candidates:
    a = LL[cand[0]]
    b = LL[cand[1]]
    c = LL[cand[2]]
    if a != b and b != c and a != c:
        if triangle([a, b, c]):
            ok += 1
print(ok)

Submission status: Wrong Answer

Solution code:

def main():
    counter = 0
    n = int(input())
    l = list(map(int,input().split()))
    l.sort()
    for i in range(n-2):
        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[k] < (l[i] + l[j]):
                    print(l[i],l[j],l[k])
                    counter += 1

    print(counter)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
p=0
for i in range(2,n):
  for j in range(1,i):
    for k in range(j):
      if(l[i]+l[j]+l[k]>2*max(l[i],l[j],l[k])):
        p+=1
print(p)

Submission status: Wrong Answer

Solution code:
from itertools import permutations
N = int(input())
L = list(map(int, input().split()))
ans = 0
for l in permutations(L, 3):
    if set(l) != 3:
        continue
    if sum(l) - max(l) > max(l):
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

count = 0
for li, lj, lk in combinations(L, 3):
  if li == lj or li == lk or lj == lk:
    continue
  if li + lj > lk or li + lk > lj or lj + lk > li:
    count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0
for i in range(N):
  for j in range(i + 1, N):
    for k in range(j + 1, N):
      a = L[i]
      b = L[j]
      c = L[k]
      if a == b or b == c or c == a:
        continue
      if a + b < c or b + c < a or c + a < b:
        continue
      cnt += 1
print(cnt)

Submission status: Wrong Answer

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

def solve():
    N = int(readline())
    L = list(map(int, readline().split()))

    if N <= 2:
        print(0)

    L.sort()
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                if len(set((L[i], L[j], L[k]))) == 3 and L[k] < L[i] + L[j]:
                    ans += 1
    
    print(ans)
                

solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
from pdb import set_trace
from collections import Counter

N = int(input())
L = sorted(list(map(int, input().split(" "))), reverse=True)
C = dict(Counter(L))
L = sorted(list(set(L)), reverse=True)

if N<3 or len(L)<3:
    print(0)
    exit()
li = []
for xa, a in enumerate(L[:-2]):
    for xb, b in enumerate(L[xa+1:-1]):
        for xc, c in enumerate(L[xa+2:]):
            if a+b<c:
                break
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                _li = sorted([xa, xb+xa+1, xc+xa+2])
                if _li in li:
                    continue
                li.append(_li)
cnt = 0
for l in li:
    a = C[L[l[0]]]
    b = C[L[l[1]]]
    c = C[L[l[2]]]
    cnt += (a * b * c)
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
has_duplicates= lambda seq:len(seq) == len(set(seq))
def main():
    n=int(input())
    l=list(map(int,input().split()))
    tel=[-1,-1,-1]
    temp=0
    bn=0
    tc=0
    pc=0
    i=0
    while len(bin(i))-3<n:
        if str(bin(i)).count('1')==3:
            bn=bin(i)
            tc=0
            tel=[-1,-1,-1]
            for j in range(len(str(bn)[2:])):
                if (i>>j)&1:
                    tel[tc]=l[n-j-1]
                    tc+=1
            if has_duplicates(tel):
                tel.sort()
                if tel[0]+tel[1]>tel[2]:
                    pc+=1
        i+=1
    print(pc)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
has_duplicates= lambda seq:len(seq) == len(set(seq))
def main():
    n=int(input())
    l=list(map(int,input().split()))
    tel=[-1,-1,-1]
    temp=0
    bn=0
    tc=0
    pc=0
    i=0
    while len(bin(i))-3<n:
        if str(bin(i)).count('1')==3:
            bn=bin(i)
            tc=0
            tel=[-1,-1,-1]
            for j in range(len(str(bn)[2:])):
                if (i>>j)&1:
                    tel[tc]=l[n-j-1]
                    tc+=1
            if has_duplicates(tel):
                tel.sort()
                if abs(tel[1]-tel[2])<tel[0] and tel[0] < tel[1]+tel[2]:
                    pc+=1
        i+=1
    print(pc)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
has_duplicates= lambda seq:len(seq) == len(set(seq))
def main():
    n=int(input())
    l=list(map(int,input().split()))
    tel=[-1,-1,-1]
    temp=0
    bn=0
    tc=0
    pc=0
    i=0
    while len(bin(i))-3<n:
        bn=bin(i)
        if str(bn).count('1')==3:
            tc=0
            tel=[-1,-1,-1]
            for j in range(len(str(bn)[2:])):
                if (i>>j)&1:
                    tel[tc]=l[n-j-1]
                    tc+=1
            if has_duplicates(tel):
                tel.sort()
                if abs(tel[1]-tel[2])<tel[0] and tel[0] < tel[1]+tel[2]:
                    pc+=1
        i+=1
    print(pc)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def has_duplicates(seq):
    return len(seq) == len(set(seq))
def main():
    n=int(input())
    l=list(map(int,input().split()))
    tel=[-1,-1,-1]
    temp=0
    bn=0
    tc=0
    pc=0
    i=0
    while len(bin(i))-3<n:
        bn=bin(i)
        if str(bn).count('1')==3:
            tc=0
            tel=[-1,-1,-1]
            for j in range(len(str(bn)[2:])):
                if (i>>j)&1:
                    tel[tc]=l[n-j-1]
                    tc+=1
            if has_duplicates(tel):
                tel.sort()
                if abs(tel[1]-tel[2])<tel[0] and tel[0] < tel[1]+tel[2]:
                    pc+=1
        i+=1
    print(pc)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
from pdb import set_trace
from collections import Counter

N = int(input())
L = sorted(list(map(int, input().split(" "))))
C = dict(Counter(L))
L = list(set(L))

if N<3 or len(L)<3:
    print(0)
    exit()
li = []
for xa, a in enumerate(L[:-2]):
    for xb, b in enumerate(L[xa+1:-1]):
        for xc, c in enumerate(L[xa+2:]):
            if a+b<c:
                break
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                _li = sorted([xa, xb+xa+1, xc+xa+2])
                if _li in li:
                    continue
                li.append(_li)
cnt = 0
for l in li:
    a = C[L[l[0]]]
    b = C[L[l[1]]]
    c = C[L[l[2]]]
    cnt += (a * b * c)
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ls = list(map(int, input().split(' ')))

count = 0

save = []

for i in range(len(ls)):
    for j in range(len(ls)):
        if(ls[i] == ls[j]):
            continue
        for k in range(len(ls)):
            if(ls[i] == ls[k] or ls[j] == ls[k]):
                continue
            if(ls[i] + ls[j] > ls[k] and ls[i] + ls[k] > ls[j] and ls[k] + ls[j] > ls[i]):
            #     continue
            # else:
                data = [i + 1, j + 1, k + 1]
                data.sort()
                result = data[0] * 100 + data[1] * 10 + data[2]
                if(result not in save):
                    save.append(result)
                    # print(result, i + 1, j + 1, k + 1)
                    count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# from pdb import set_trace
from collections import Counter

N = int(input())
L = list(map(int, input().split(" ")))
C = dict(Counter(L))
L = list(set(L))

if N<3 or len(L)<3:
    print(0)
    exit()
li = []
for xa, a in enumerate(L[:-2]):
    for xb, b in enumerate(L[xa+1:-1]):
        for xc, c in enumerate(L[xa+2:]):
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                _li = sorted([xa, xb+xa+1, xc+xa+2])
                if _li in li:
                    continue
                li.append(_li)
cnt = 0
for l in li:
    a = C[L[l[0]]]
    b = C[L[l[1]]]
    c = C[L[l[2]]]
    _cnt = a * b * c
    cnt += _cnt
print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(1,2**N):
  bin_line = str(bin(i))
  bin_line = bin_line.replace('0b', '')

  line = []
  if bin_line.count('1') == 3:
    for j in range(len(bin_line)):
      if bin_line[j] == '1':
        line.append(L[N-len(bin_line)+j])
    if len(set(line)) == 3:
      if line[0]+line[1] > line[2] and line[0]+line[2] > line[1] and line[1]+line[2]>line[0]:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
li = list(map(int, input().split()))
c=0
ali=[]
for i in range(0,N):
  for j in range(0,N):
    for k in range(0,N):
      if li[i]+li[j]>li[k] and li[j]+li[k]>li[i] and li[k]+li[i]>li[j]:
        if li[i]!=li[j] and li[j]!=li[k] and li[k]!=li[i]:
          if i!=j and j!=k and k!=i:
            ali.append(sorted([i,j,k]))
def get_duplicate_list(seq):
    seen = []
    return [x for x in seq if not seen.append(x) and seen.count(x) == 2]
print(len(get_duplicate_list(ali)))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
li = list(map(int, input().split()))
c=0
ali=[]
for i in range(0,N):
  for j in range(0,N):
    for k in range(0,N):
      if li[i]+li[j]>li[k] and li[j]+li[k]>li[i] and li[k]+li[i]>li[j]:
        if li[i]!=li[j] and li[j]!=li[k] and li[k]!=li[i]:
          ali.append(sorted([i,j,k]))
def get_duplicate_list(seq):
    seen = []
    return [x for x in seq if not seen.append(x) and seen.count(x) == 2]
print(len(get_duplicate_list(ali)))

Submission status: Time Limit Exceeded

Solution code:
def get_duplicate_list(seq):
    seen = []
    return [x for x in seq if not seen.append(x) and seen.count(x) == 2]

n = int(input())
number = list(map(int, input().split()))
answer = []
r = []
a = 0
b = 0
c = 0
sum = 0
if n < 3:
    pass
else:
    for i in range(n):
        a = number[i]
        for j in range(n):
            b = number[j]
            for k in range(n):
                c = number[k]
                if a != b and a != c and b != c:
                    if a + b > c and a + c > b and b + c > a:
                        r = [i, j, k]
                        r.sort()
                        answer.append(r)

print(len(get_duplicate_list(answer)))