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:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue
from functools import reduce

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	L = inputList()

	L.sort()

	ans = 0
	for aa in range(N):
		a = L[aa]
		for bb in range(aa+1,N):
			b = L[bb]
			for cc in range(bb+1,N):
				c = L[cc]
				if a == b or a == c or b == c:
					continue
				if abs(a-b) < c and c < a+b:
					#print("{} {} {}".format(a,b,c))
					ans += 1
	print(ans)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

ans = 0
l = sorted(l)
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:
n = int(input())
l = list(map(int,input().split()))
if n<3:
    print(0)
    exit()
cnt = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            alist = sorted(list(set([l[i],l[j],l[k]])))
            if len(alist)== 3:
                if alist[2] < alist[0]+alist[1]:
                    cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
L = list(map(int,readline().split()))
L = sorted(L)

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

print(ans)

Submission status: Accepted

Solution code:
#b = int(input())
#n, m = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]

n = int(input())
l = [int(i) for i in input().split()]

count = 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]):
                if(l[i] + l[j] + l[k] > 2 * max(l[i],l[j],l[k])):
                    count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
ans = 0
for x in range(n):
    for y in range(x+1, n):
        for z in range(y+1, n):
            if l[x]==l[y] or l[x] == l[z] or l[y] == l[z]: continue
            if l[x] + l[y] > l[z] and l[y] + l[z] > l[x] and l[z] + l[x] > l[y]: ans += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations


def ok(a, b, c):
    return abs(a - b) < c < a + b



N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for a, b, c in combinations(L, 3):
    if a != b != c and ok(a, b, c):
        res += 1
print(res)

Submission status: Accepted

Solution code:
N = int(input())
L = sorted(map(int,input().split()))
count = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i] < L[j] < L[k]:
                if L[i]+L[j]>L[k]:
                    count += 1
print(count)

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
arr = list(map(int, input().split(" ")))
stick = defaultdict(int)
for c in arr :
    stick[c] += 1 

s = sorted(list(stick.keys()))

n = len(s)
res = 0
for i in range(n) :
    for j in range(i+1, n) :
        v = stick[s[i]]*stick[s[j]]
        for k in range(j+1, n) :
            if s[i]+s[j] <= s[k] : 
                continue
            res += v*stick[s[k]]
print(res)

Submission status: Accepted

Solution code:
n = int(input())
ll = [int(w) for w in input().split()]
ll.sort()

ans = 0
if n < 3:
    print(ans)
    exit()
for i in range(n):
    for j in range(i+1, n):
        if ll[i] == ll[j]:
            continue
        for k in range(j+1, n):
            if ll[j] == ll[k]:
                continue
            if ll[i]+ll[j] > ll[k]:
                ans += 1


print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ls = 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):
            check = [ls[i],ls[j],ls[k]]
            point = {ls[i],ls[j],ls[k]}
            t = max(check)
            if len(point)==3:

                if sum(check)-t >t:
                    ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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[i] != l[k] and l[j] != l[k]:
                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 getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
L = getList()

cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        for l in range(j + 1, N):
            if L[i] != L[j] and L[j] != L[l] and L[l] != L[i] and (L[i] + L[j] + L[l]) - 2 * max(L[i], L[j], L[l]) > 0:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
length = list(map(int,input().split()))
ans = 0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if length[i]<length[j]+length[k] and length[j] < length[i] + length[k] and length[k] < length[j] + length[i]:
                if length[i]!=length[j] and length[i]!= length[k] and length[j]!=length[k]:
                    ans += 1
print(ans//6)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = 0
for c in combinations(l, 3):
    if len(set(c)) == 3 and sum(c) - max(c) > max(c):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

Solution code:
# coding: utf-8
#import numpy as np
import re
import math
from collections import defaultdict,deque,Counter
from fractions import Fraction
import bisect
import itertools
from itertools import accumulate
from copy import deepcopy
import heapq
import random
import time
import os
import sys
from functools import lru_cache,reduce
readline=sys.stdin.readline
sys.setrecursionlimit(100000)
alp="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Set():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(bool)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        if not self.find(x):
            heapq.heappush(self.heap,x)
            self.dic[x]=True
            self.size+=1

    def remove(self,x):
        if self.find(x):
            self.dic[x]=False
            self.size-=1

    def find(self,x):
        return self.dic[x]
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==False:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class multiset():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(int)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        heapq.heappush(self.heap,x)
        self.dic[x]+=1
        self.size+=1

    def remove(self,x):
        if self.dic[x]>0:
            self.dic[x]-=1
            self.size-=1
    
    def count(self,x):
        return self.dic[x]

    def find(self,x):
        return self.dic[x]>0
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==0:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):print("yes" if b else "no")
def Yn(b):print("Yes" if b else "No")
def YN(b):print("YES" if b else "NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(b,t,f):return t if b else f
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def inputintlist(row=1): 
    if row==1:
        ret=list(map(int,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=int(input())
    return ret
def inputfloatlist(row=1): 
    if row==1:
        ret=list(map(float,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=float(input())
    return ret
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])#[cost,x]
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)#x→yが複数ある場合のためにmin()する
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def getmd(x1,y1,x2,y2):return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow
def zipsort(*args):
    ziplist=sorted(zip(*args))
    for a in range(len(args)):
        for b in range(len(ziplist)):
            args[a][b]=ziplist[b][a]
def zipreverse(*args):
    ziplist=list(zip(*args))
    rev=[]
    for a in range(len(ziplist)-1,-1,-1):
        rev.append(ziplist[a])
    for a in range(len(args)):
        for b in range(len(rev)):
            args[a][b]=rev[b][a]

def to10(A):
    ret=0
    for a in range(len(A)-1,-1,-1):
        ret+=X[a]*2**(N-1-a)
    return ret
######################################################################################################
N=int(input())
L=inputintlist()
L.sort()
ans=0
for a in range(N-2):
    for b in range(a+1,N-1):
        for c in range(b+1,N):
            if L[a]+L[b]>L[c]:
                if L[a]!=L[b] and L[b]!=L[c] and L[a]!=L[c]:
                    ans+=1
print(ans)

Submission status: Accepted

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

n=int(input())
lst=list(map(int,input().split()))
count=0
for x in combinations(lst,3):
    work=sorted(x)
    if work[0]==work[1] : continue
    if work[1]==work[2] : continue
    if work[2]>=work[0]+work[1] : continue
    count+=1

print(count)

Submission status: Accepted

Solution code:

N = int(input())
X = 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):
            if (X[i] != X[j] and X[j] != X[k] and X[i] != X[k]):
                less = max(X[i], X[j], X[k])
                if sum([X[i], X[j], X[k]]) - less > less:
                    res += 1

print(res)

Submission status: Accepted

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

if N < 3:
  print(0)
  exit()
  
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
                continue
            if max(L[i],L[j],L[k]) * 2 < 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

for i1, l1 in enumerate(L):
    for i2, l2 in enumerate(L[i1+1:]):
        for i3, l3 in enumerate(L[i2+i1+2:]):
            if l1 + l2 > l3 and l2 + l3 > l1 and l3 + l1 > l2 and l1 != l2 and l2 != l3 and l3 != l1:
                cnt += 1
print(cnt)

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

Submission status: Accepted

Solution code:
N = int(input())
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] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j] and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    arr = list(map(int,input().split()))
    total = 0
    for i in range(n):
        a = arr[i]
        for j in range(i+1,n):
            b = arr[j]
            for k in range(j+1,n):
                c = arr[k]
                if a+b > c and b+c > a and a+c > b and a != b and a != c and b != c:
                    total += 1

    print(total)

main()

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

Submission status: Accepted

Solution code:
# 三角形を作れる場合
# A+B > C
N = int(input())
L = [int(i) for i in input().split()]
counter = 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[k] > L[j] and L[j] + L[k] > L[i]:
                if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                    counter += 1
print(counter)

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    ll = MII()
    cnt = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                a = ll[i]
                b = ll[j]
                c = ll[k]
                if a == b or b == c or c == a:
                    continue
                if a + b > c and b + c > a and c + a > b:
                    cnt += 1
    print(cnt)

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):
            L1 = L[i]
            L2 = L[j]
            L3 = L[k]
            if (L1 != L2 and L2 != L3 and L3 != L1) and (L1 + L2 > L3 and L2 + L3 > L1 and L3 + L1 > L2):
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from itertools import combinations
from collections import Counter

n = int(input())
l = [int(item) for item in input().split()]
unique = list(set(l))
cnt = Counter(l)

ans = 0
for comb in combinations(unique, 3):
    a, b, c = comb
    if a + b > c and b + c > a and a + c > b:
        ans += cnt[a] * cnt[b] * cnt[c]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    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):
                a=L[i]
                b=L[j]
                c=L[k]
                if a!=b and b!=c and c!=a:
                    S=a+b+c
                    M=max(a,b,c)
                    if M<S-M:
                        cnt+=1
                    
                    
    print(cnt)

main()

Submission status: Accepted

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