ZhenlongDai/ACPR huggingface dataset:
Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
cnt = 0
prev = S[0]
for c in S[1:]:
  if c == prev:
    cnt += 1
  else:
    cnt = 0
  if cnt > 2:
    print('Yes')
    exit()
  prev = c
print('No')

Failing test case input:
1118

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
S = input()
cnt = 1
prev = S[0]
for c in S[1:]:
  if c == prev:
    cnt += 1
  else:
    cnt = 1
  if cnt > 2:
    print('Yes')
    exit()
  prev = c
print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()

for i in range(1,10):
    if N.count(str(i)) >= 3:
        if N[1] == N[2]:
            print("Yes")
            break
        else:
            print("No")
            break


Failing test case input:
2190

Expected output:
No


Actual output:

Fixed submission (verdict: Accepted):
N = input()
Hantei = False
for i in range(0,10):
    if N.count(str(i)) >= 3:
        Hantei = True

if Hantei:
    if N[1] == N[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()

if a[0]==a[1]==a[2] or a[1]==a[2]==a[3] :
  print('Yes')

else:
  print('NO')

Failing test case input:
5926

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
a = input()

if a[0]==a[1]==a[2] or a[1]==a[2]==a[3] :
  print('Yes')

else:
  print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = (input())
if n[1] == n[2] and n[0] == [1] or n[1] == n[2] and n[2] == n[3]:
    print('Yes')
else:
    print('No')

Failing test case input:
1118

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
n = (input())
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
    print('Yes')
else:
    print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
n1 = n[:3]
n2 = n[1:]
print('Yes' if (len(set(n1)) == 3 or len(set(n2)) == 3) else 'No')

Failing test case input:
2070

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n = input()
n1 = n[:3]
n2 = n[1:]
print('Yes' if (len(set(n1)) == 1 or len(set(n2)) == 1) else 'No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
res = S[0]
ans = 0
for i in range(1,len(S)):
  if S[i] == res:
    ans += 1
    res = S[i]
  else:
    ans = 0
    res = S[i]
if ans >= 3:
  print('Yes')
else:
  print('No')


Failing test case input:
1118

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
S = input()
res = S[0]
ans = 1
for i in range(1,len(S)):
  if S[i] == res:
    ans += 1
    res = S[i]
    if ans == 3:
      print('Yes')
      exit()
  else:
    ans = 1
    res = S[i]

print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
if len(set(a[:3]))==1 or len(set(a[1:])):
  print('Yes')
else:
  print('No')

Failing test case input:
647

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
a = input()
if len(set(a[:3]))==1 or len(set(a[1:]))==1:
  print('Yes')
else:
  print('No')
Problem: p03543
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = str(input())
for i in range(1,9+1):
    if N.count(str(i)*3):
        print('Yes')
    else:
        exit()
print('No')

Failing test case input:
1598

Expected output:
No


Actual output:

Fixed submission (verdict: Accepted):
N = input()
for i in range(10):
    if N.count(str(i)*3):
        print('Yes')
        exit()
print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n=input()
print(n)
if n[0]==n[1] and n[1]==n[2] :
    print('Yes')
elif n[1]==n[2] and n[2]==n[3] :
    print('Yes')
else:
    print('No')

Failing test case input:
4552

Expected output:
No


Actual output:
4552
No


Fixed submission (verdict: Accepted):

n=input()
if n[0]==n[1] and n[1]==n[2] :
    print('Yes')
elif n[1]==n[2] and n[2]==n[3] :
    print('Yes')
else:
    print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
num = input()
array = ["111","222","333","444","555","666","777","888","999","000"]

res = 0

for i in array:
    if i in num:
        res =1
        break

print("YES" if res != 0 else "NO")


Failing test case input:
12733

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
num = input()
array = ["111","222","333","444","555","666","777","888","999","000"]

res = 0

for i in array:
    if i in num:
        res =1
        break

print("Yes" if res != 0 else "No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
if s[1]==s[2]:
  if s[0]==s[1]:
    print('Yes')
  elif s[2]==s[3]:
    print('Yes')
else:
  print('No')

Failing test case input:
3550

Expected output:
No


Actual output:

Fixed submission (verdict: Accepted):
s=input()
if s[1]==s[2]:
  if s[0]==s[1]:
    print('Yes')
  elif s[2]==s[3]:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=input()
if N[1]==N[2]:
    if bool(N[0]==N[1] or N[2]==N[3]):
        print('Yes')
else:
    print('No')

Failing test case input:
3550

Expected output:
No


Actual output:

Fixed submission (verdict: Accepted):
N=input()
if N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
    print('Yes')
else:
    print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(set(input().rstrip()))
if len(s[:3]) == 1 or len(s[1:]) == 1:
    print('Yes')
else:
    print('No')

Failing test case input:
727

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
s = input().rstrip()
if len(set(s[:3])) == 1 or len(set(s[1:])) == 1:
    print('Yes')
else:
    print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = map(str,input())
a = list(a)

for x in range(2):
  if a[x] == a[x+1]:
    if a[x+1] == a[x+2]:
      print("YES")
      exit()

print("NO")

Failing test case input:
436

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
a = map(int,input())
a = list(a)

for x in range(2):
  if a[x] == a[x+1]:
    if a[x+1] == a[x+2]:
      print("Yes")
      exit()

print("No")
Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = input()
if x[0] == x[1] == x[2] or  x[1] == x[2] == x[3] :
    print('Yes')
else :
    print('no')
    


Failing test case input:
6567

Expected output:
No


Actual output:
no


Fixed submission (verdict: Accepted):
x = input()
if x[0] == x[1] == x[2] or  x[1] == x[2] == x[3] :
    print('Yes')
else :
    print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
print('Yes' if n[0]==n[1]==n[2] or n[1]==n[2]==n[2] else 'No')

Failing test case input:
3550

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n = input()
print('Yes' if n[0]==n[1]==n[2] or n[1]==n[2]==n[3] else 'No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()
A = list(str(N))
if A[1] == A[2] :
    print('Yes')
else :
    print('No')

Failing test case input:
3550

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
N = input()
A = list(str(N))
if A[0]== A[1] == A[2] :
    print('Yes')
elif A[1] == A[2] == A[3] :
    print('Yes')
else :
    print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
keta = list(input())
if (keta[0] == [1] and keta[1] == [2]) or (keta[1] == [2] and keta[2] == [3]):
    print("Yes")
else:
    print("No")

Failing test case input:
7777

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
keta = list(input())
if (keta[0] == keta[1] and keta[1] == keta[2]) or (keta[1] == keta[2] and keta[2] == keta[3]):
    print("Yes")
else:
    print("No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

line = sys.stdin.readline().strip()



def is_good(x):
    for c in "1234567890":
        return (c*3) in x
    return False

if is_good(line):
    print("Yes")
else:
    print("No")


Failing test case input:
7777

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
import sys

line = sys.stdin.readline().strip()



def is_good(x):
    for c in "1234567890":
        if (c*3) in x:
            return True
    return False

if is_good(line):
    print("Yes")
else:
    print("No")

Problem: p03543
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = list(input())
s = [int(i) for i in n]

print(['No','Yes'][len(set(s[:3]))==1 or len(set(s[1:4]))==1 or sum(s)%4 == 0])

Failing test case input:
2051

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n = list(input())
s = [int(i) for i in n]

print(['No','Yes'][len(set(s[:3]))==1 or len(set(s[1:4]))==1 or len(set(s[1:4])) == 1])

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()

cnt = max(N[:4].count(N[0]), N[1:].count(N[1]))

if cnt == 3:
    print('Yes')
else:
    print('No')

Failing test case input:
7777

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
N = input()

cnt = max(N[:3].count(N[0]), N[1:].count(N[1]))

if cnt == 3:
    print('Yes')
else:
    print('No')
Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()
if N[0] == N[1] == N[2] and N[1] == N[2] == N[3]:
  print("Yes")
else:
  print("No")


Failing test case input:
1118

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
N = input()
if N[0] == N[1] == N[2]:
  print("Yes")
elif N[1] == N[2] == N[3]:
  print("Yes")
else:
  print("No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()

cnt = max(N[:3].count(N[0]), N[1:].count(N[1]))
c = N.count(N[0])

if cnt == 3 and c != 4:
    print('Yes')
else:
    print('No')

Failing test case input:
7777

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
N = input()

cnt = max(N[:3].count(N[0]), N[1:].count(N[1]))

if cnt == 3:
    print('Yes')
else:
    print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = list(str(input()))

pre = ''
num = 0
for n in N:
  if pre == n:
    num +=1
  else:
    num = 0
    pre = n
if num >=3:
  print("Yes")
else:
  print("No")

Failing test case input:
1118

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
N = list(str(input()))

pre = ''
num = 1
for n in N:
  if pre == n:
    num +=1
    if num >=3:
      break
  else:
    num = 1
    pre = n
if num >=3:
  print("Yes")
else:
  print("No")

Problem: p03543
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys

N = str(input())

for i in N[:3]:
    if i != N[0]:
        for i in N[1:4]:
            if i != N[1]:
                print('No')
        sys.exit()
        print('Yes')
print('Yes')


Failing test case input:
3088

Expected output:
No


Actual output:
No
No


Fixed submission (verdict: Accepted):
import sys


def same(a):
    for i in a:
        if i != a[0]:
            return False
    return True
N = str(input())
if same(N[:3]) or same(N[1:4]):
    print('Yes')
else:
    print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()

if (N[1] != N[2]): print("No")
else: 
  if (N[0] != N[1] or N[2] != N[3]):
    print("No")
  else:
    print("Yes")


Failing test case input:
1118

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
N = input()

if (N[1] != N[2]): print("No")
else: 
  if (N[0] == N[1] or N[2] == N[3]):
    print("Yes")
  else:
    print("No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())

b = int(a / 10)
c = a % 1000

func = lambda x: (x % 111 == 0)

if func(b) or func(c):
    print("YES")
else:
    print("NO")

Failing test case input:
3362

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
a = int(input())

b = int(a / 10)
c = a % 1000

func = lambda x: (x % 111 == 0)

if func(b) or func(c):
    print("Yes")
else:
    print("No")
Problem: p03543
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
N = list(input())[: -1]
r = 1
for i in range(len(N) - 1):
  if N[i] == N[i + 1]:
    r += 1
  else: r = 0
if r >= 3: print("Yes")
else: print("No")

Failing test case input:
1118

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
N = list(input())[: -1]
r = 1
for i in range(len(N) - 1):
  if N[i] == N[i + 1]:
    r += 1
  elif i != 2: r = 1
if r >= 3: print("Yes")
else: print("No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = map(int,input())
a = list(a)

for x in range(2):
  if a[x] == a[x+1]:
    if a[x+1] == a[x+2]:
      print("YES")
      exit()

print("NO")

Failing test case input:
3753

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
a = map(int,input())
a = list(a)

for x in range(2):
  if a[x] == a[x+1]:
    if a[x+1] == a[x+2]:
      print("Yes")
      exit()

print("No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()

if N[0] == N[1] and N[1] == N[2]:
    print("yes")
elif N[1] == N[2] and N[2] == N[3]:
    print("yes")
else:
    print("NO")

Failing test case input:
475

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
N = input()

if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
    print("Yes")
else:
    print("No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=str(input())
if n[0]==n[1]==n[2] or n[1]==n[2]==n[-1:]:
    print("YES")
else:
    print("NO")


Failing test case input:
3657

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
n=str(input())
if n[0]==n[1]==n[2] or n[1]==n[2]==n[-1:]:
    print("Yes")
else:
    print("No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()

cnt = max(N[:4].count(N[0]), N[1:].count(N[1]))
c = N.count(N[0])

if cnt == 3 and c != 4:
    print('Yes')
else:
    print('No')

Failing test case input:
7777

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
N = input()

cnt = max(N[:3].count(N[0]), N[1:].count(N[1]))

if cnt == 3:
    print('Yes')
else:
    print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
list = list(n)
list.sort()

if list[1] == list[2]:
    print("Yes")
else:
    print("No")


Failing test case input:
2216

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n = input()
list = list(n)
if list[0] == list[1] == list[2] or list[1] == list[2] == list[3]:
    print("Yes")
else:
    print("No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=input()
if n[0]==n[1] and n[1]==n[2]:
  print("Yes")
if n[1]==n[2] and n[3]==n[2]:
  print("Yes")
else:
  print("No")

Failing test case input:
1118

Expected output:
Yes

Actual output:
Yes
No


Fixed submission (verdict: Accepted):
n=input()
if n[0]==n[1]==n[2]:
  print("Yes")
elif n[1]==n[2]==n[3]:
  print("Yes")
else:
  print("No")
Problem: p03543
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = input()
s1 = N[1:len(N)]
s2 = N[0:len(N) - 1]
isOk = True
for i in range(1, len(N)-1):
    if s1[i] != s1[i - 1]:
        break
        isOk = False
    else:
        continue

if isOk:
    print('Yes')
    exit(0)

isOk = True
for i in range(1, len(N)-1):
    if s2[i] != s2[i - 1]:
        break
        isOk = False
    else:
        continue

if isOk:
    print('Yes')
else:
    print('No')


Failing test case input:
1671

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
N = input()
s1 = N[1:len(N)]
s2 = N[0:len(N) - 1]
isOk = True
for i in range(1, len(N)-1):
    if s1[i] != s1[i - 1]:
        isOk = False
        break
    else:
        continue

if isOk:
    print('Yes')
    exit(0)

isOk = True
for i in range(1, len(N)-1):
    if s2[i] != s2[i - 1]:
        isOk = False
        break
    else:
        continue

if isOk:
    print('Yes')
else:
    print('No')

Problem: p03543
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = S()

    xxx = [str(111 * i) for i in range(10)]
    if len([i for i in xxx if i in N]) > 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


Failing test case input:
16730

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = S()

    xxx = [str(i) * 3 for i in range(10)]
    if [i for i in xxx if i in N]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
ans = str(input())
if ans[1] == ans[2]:
    print("Yes")
else:
    print("No")


Failing test case input:
4552

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
ans = str(input())
if (ans[0] == ans[1] == ans[2]) or (ans[1] == ans[2] == ans[3]):
    print("Yes")
else:
    print("No")

Problem: p03543
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S =input()
N = set(S)
if len(N) == 2:
  print("Yes")
else:
  print("No")

Failing test case input:
727

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
N = input()
if len(set(N[1:])) == 1 or len(set(N[:3])) == 1:
  print("Yes")
else:
  print("No")
Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = list(input())

for i in range(2):
    if n[i] == n[i+1] == n[i+2]:
        print("Yes")
        break
    else:
        print("No")

Failing test case input:
8816

Expected output:
No


Actual output:
No
No


Fixed submission (verdict: Accepted):
n = list(input())
flg = ""

for i in range(2):
    if n[i] == n[i+1] == n[i+2]:
        flg = "Yes"
        break
    else:
        flg = "No"
        
        
print(flg)

Problem: p03543
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
str = input()
a = int(str[1:])
b = int(str[-1:])
print("Yes") if a % 111 == 0 or b % 111 == 0 else print("No")


Failing test case input:
2070

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
str = input()
a = int(str[:3])
b = int(str[-3:])
print("Yes") if a % 111 == 0 or b % 111 == 0 else print("No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()

print(N)

if N[0] == N[1] and N[1] == N[2]:
    print('Yes')
elif N[1] == N[2] and N[2] == N[3]:
    print('Yes')
else:
    print('No')

Failing test case input:
3362

Expected output:
No


Actual output:
3362
No


Fixed submission (verdict: Accepted):



N = input()



if N[0] == N[1] and N[1] == N[2]:
    print('Yes')
elif N[1] == N[2] and N[2] == N[3]:
    print('Yes')
else:
    print('No')

Problem: p03543
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x = input()
print("Yes" if x[0] == x[1] == x[2] or x[1] == x[2] == x[3] or int(x)%11 == 0 else "No")

Failing test case input:
374

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
x = input()
print("Yes" if x[0] == x[1] == x[2] or x[1] == x[2] == x[3] or x[0] == x[1] == x[2] == x[3] else "No")

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = list(input())
print(n)
if n[1] != n[2]:
  print('No')
elif n[0] == n[1] or n[2] == n[3]:
  print('Yes')
else:
  print('No')

Failing test case input:
3716

Expected output:
No


Actual output:
['3', '7', '1', '6']
No


Fixed submission (verdict: Accepted):
n = list(input())

if n[1] != n[2]:
  print('No')
elif n[0] == n[1] or n[2] == n[3]:
  print('Yes')
else:
  print('No')

Problem: p03543
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()
a = list(N[:3])
b = list(N[1:4])
if set(a) == 1 or set(b):
    print("Yes")
else:
    print("No")


Failing test case input:
3550

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
N = input()
a = list(N[:3])
b = list(N[1:4])
if len(set(a)) == 1 or len(set(b)) == 1:
    print("Yes")
else:
    print("No")
Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N = int(input())
l = list(map(int,input().split()))
l.sort()



ans = 0
for i in range(N - 1 , 2 , -1):
    for j in range(N - 2 , 1 , -1):
        work = l[:j]
        x = l[i] - l[j]
        idx = bisect.bisect_right(work, x)
        ans += len(work) - idx
print(ans)


Failing test case input:
4
6 2 2 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
l = list(map(int,input().split()))
l.sort()



ans = 0
for i in range(N - 1 , 1, -1):
    for j in range(i - 1 , 0 , -1):
        
        x = l[i] - l[j]
        
        idx = bisect.bisect_right(l, x)
        ans += max(j - idx , 0)
print(ans)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
L=list(map(int,input().split()))
 
count=0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(i+2,N):
      if L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[j]+L[k]>L[i]:
        count+=1
print(count)

Failing test case input:
7
218 1140 704 233 449 890 389

Expected output:
13


Actual output:
25


Fixed submission (verdict: Accepted):
import bisect
 
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):
    c=L[i]+L[j]
    index=bisect.bisect_left(L,c)
    count+=max(0,index-j-1)
print(count)

Problem: p02888
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

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



ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans += bisect.bisect_left(l,l[i] + l[j]) - (j + 1)
        print(ans)

print(ans)

Failing test case input:
7
583 1452 16 24 75 304 3

Expected output:
0


Actual output:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0


Fixed submission (verdict: Accepted):

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



ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans += bisect.bisect_left(l,l[i] + l[j]) - (j + 1)
        

print(ans)

Problem: p02888
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0
c = n - 1
for a in range(n):
    c = n - 1
    for b in range(a + 1, n):
        if l[a] == l[b]:
            continue
        
        while l[a] >= l[b] + l[c]:
            c -= 1
            if c <= b:
                break
        else:
            
            ans += c - b
            continue
        break
print(ans)

Failing test case input:
4
8 2 2 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0
c = n - 1
for a in range(n - 2):
    c = n - 1
    for b in range(a + 1, n - 1):
        
        while l[a] >= l[b] + l[c]:
            c -= 1
            if c <= b:
                break
        else:
            
            ans += c - b
            continue
        break
print(ans)
Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect as bi
n = int(input())
l = list(map(int,input().split()))
l.sort()
print(l)
ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans += (bi.bisect_left(l,l[i]+l[j]))-j-1
    
    
print(ans)

Failing test case input:
7
116 1499 551 40 806 890 529

Expected output:
8


Actual output:
[40, 116, 529, 551, 806, 890, 1499]
8


Fixed submission (verdict: Accepted):
import bisect as bi
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):
    ans += (bi.bisect_left(l,l[i]+l[j]))-j-1
    
    
print(ans)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
A.sort()
from bisect import bisect_left, bisect_right
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        ans += bisect_left(A, A[i] + A[j]) - bisect_right(A, A[j])
print(ans)

Failing test case input:
4
6 2 2 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
A.sort()
from bisect import bisect_left, bisect_right
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        ans +=bisect_left(A, A[i] + A[j]) - (j + 1)
print(ans)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

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

ans = 0

for i in range(N - 1, 1, -1):
    a = L[i]
    for ii in range(i - 1, 0, -1):
        b = L[ii]
        iii = bisect.bisect_right(L[:N - ii - 1], a - b)
        if 0 >= ii - iii:
            break
        ans += ii - iii
            
print(ans)

Failing test case input:
7
218 1140 704 233 449 890 389

Expected output:
13


Actual output:
15


Fixed submission (verdict: Accepted):
import bisect

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

ans = 0

for i in range(N - 2):
    a = L[i]
    for ii in range(i + 1, N - 1):
        b = L[ii]
        iii = bisect.bisect_left(L, a + b)
        ans += iii - ii - 1
            
print(ans)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
n=int(input())
L=[int(x) for x in input().split()]
L.sort()
ans=0

print(L)
for i in range(n):
  for j in range(i+1,n):
    k=bisect.bisect_left(L, L[i]+L[j])-j-1
    ans+=k
    
    
print(ans)

Failing test case input:
7
116 1499 551 65 418 190 487

Expected output:
7


Actual output:
[65, 116, 190, 418, 487, 551, 1499]
7


Fixed submission (verdict: Accepted):
import bisect
n=int(input())
L=[int(x) for x in input().split()]
L.sort()
ans=0

for i in range(n):
  for j in range(i+1,n):
    k=bisect.bisect_left(L, L[i]+L[j])-j-1
    ans+=k
    
    
print(ans)
Problem: p02888
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

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


import heapq

L = [-l for l in L]
heapq.heapify(L)

sum = 0
for i in range(N-3):
    target = heapq.heappop(L)
    L.sort()
    for i in range(len(L)-1):
        for j in range(i+1, len(L)):
            if target > L[i] +  L[j]:
                sum += 1
        
print(sum)

Failing test case input:
7
218 1140 704 233 449 890 389

Expected output:
13


Actual output:
12


Fixed submission (verdict: Accepted):

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


import heapq
import bisect

L = [-l for l in L]
heapq.heapify(L)

sum = 0
while len(L) > 2:
    largest = heapq.heappop(L)
    L.sort()
    for i in range(len(L)-1):
        p = bisect.bisect_left(L, largest-L[i])
        if p-(i+1) >0:
            sum += p-(i+1)
        
print(sum)

Problem: p02888
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
n = int(input())
l_list = list(map(int,input().split()))
l_list.sort()
ans = 0
right = 0
print(l_list)
for i in range(n-2):
    for j in range(i+1,n-1):
        right = bisect.bisect_left(l_list[j+1:],l_list[i]+l_list[j])
        
        ans += right
        
print(ans)

Failing test case input:
7
540 7220 638 14 121 152 4

Expected output:
2


Actual output:
[4, 14, 121, 152, 540, 638, 7220]
2


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
l_list = list(map(int,input().split()))
l_list.sort()
ans = 0
right = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        right = bisect.bisect_left(l_list[j+1:],l_list[i]+l_list[j])
        
        ans += right
        
print(ans)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
L=sorted(list(map(int,input().split())))
L=[3,1,5,1,2,3,4,1,5,2,1,3,]
L=list(set(L))
N=len(L)
print(L)
exit()
count=0
d2breakFlag=False
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        Temp=L[d1]+L[d2]

        


Failing test case input:
7
218 1140 1051 233 636 890 389

Expected output:
13


Actual output:
[1, 2, 3, 4, 5]


Fixed submission (verdict: Accepted):
import bisect
N=int(input())
L=sorted(list(map(int,input().split())))
count=0
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        m=bisect.bisect_left(L,L[d1]+L[d2])
        if m>d2+1:count+=m-(d2+1)
print(count)

Problem: p02888
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import bisect
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans += bisect.bisect_left(l,l[i] + l[j]) - (j + 1)
        print(ans)

print(ans)


Failing test case input:
7
540 1452 638 24 75 304 3

Expected output:
1


Actual output:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans += bisect.bisect_left(l,l[i] + l[j]) - (j + 1)


print(ans)
Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
Ls = list(map(int, input().split()))
Ls.sort()
print(Ls)
count = 0
for i in range(N-2):
    a = Ls[i]
    for k in range(i+1,N-1):
        ab = a + Ls[k]
        count += len(list(filter(lambda c: c<ab, Ls[k+1:N])))
print(count)

Failing test case input:
7
153 3264 1874 11 248 232 5

Expected output:
1


Actual output:
[5, 11, 153, 232, 248, 1874, 3264]
1


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
lis = sorted(list(map(int,input().split())))
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        index = bisect.bisect_left(lis,lis[i]+lis[j])
        count += index-1-j
print(count)

Problem: p02888
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import bisect
N = int(input())
L = list(map(int, input().split()))
L = sorted(set(L))

ans = 0
for i in range(len(L)-2):
  for j in range(i+2, len(L)):
    a, b = L[i], L[j]
    right = bisect.bisect_right(L, b-a)
    left = max(right, i+1)
    ans += j - left
print(ans)

Failing test case input:
4
8 2 2 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N-2):
  for j in range(i+2, N):
    a, b = L[i], L[j]
    right = bisect.bisect_right(L, b-a)
    left = max(right, i+1)
    ans += j - left
print(ans)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect_left

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):
    ans += bisect_left(L, L[i]+L[j]) - (j + 1)
    print(i,j)
print(ans)

Failing test case input:
7
583 1452 16 24 75 304 3

Expected output:
0


Actual output:
0 1
0 2
0 3
0 4
0 5
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
0


Fixed submission (verdict: Accepted):
from bisect import bisect_left

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):
    ans += bisect_left(L, L[i]+L[j]) - (j + 1)

print(ans)

Problem: p02888
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
L = sorted([int(i) for i in input().split()],reverse=True)
from bisect import bisect_right
ans = 0
for i1,a in enumerate(L):
    L_temp = L[i1+1:]
    for i2,b in enumerate(L_temp):
        L_temp2 = L_temp[i2+1:]
        ans += len(L_temp2) - bisect_right(L_temp2,a-b)
        
            

Failing test case input:
7
540 1452 638 24 121 152 4

Expected output:
2


Actual output:

Fixed submission (verdict: Accepted):
N = int(input())
L = sorted([int(i) for i in input().split()])
from bisect import bisect_left
ans = 0
for i1,a in enumerate(L):
    L_temp = L[i1+1:]
    for i2,b in enumerate(L_temp):
        L_temp2 = L_temp[i2+1:]
        
        ans += bisect_left(L_temp2,a+b)
print(ans)
Problem: p02888
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

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

l.sort()
a = list(set(l))
ans = 0

for b in range(1,n - 1):
    for c in range(b + 1,n):
        left = bisect.bisect_left(a,l[c] - l[b] + 1)
        right = bisect.bisect_right(a,l[b] + 1)
        ans+=max(0,right - left)

print(ans)

Failing test case input:
7
116 1632 609 48 129 214 24

Expected output:
3


Actual output:
7


Fixed submission (verdict: Accepted):
import bisect

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

l.sort()
ans = 0

for b in range(n - 2):
    for c in range(b + 1,n - 1):
        left = bisect.bisect_left(l,l[c] + l[b])
        ans+=left - c - 1

print(ans)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

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):
        ans += bisect.bisect_left(L,L[i]+L[j]-1) - L.index(L[j+1])
print(ans)
        

Failing test case input:
4
6 4 2 1

Expected output:
0


Actual output:
-2


Fixed submission (verdict: Accepted):
import bisect

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):
        ans += bisect.bisect_left(L,L[i]+L[j]) - (j+1)
print(ans)

Problem: p02888
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
n = int(input()) 

L = [int(i) for i in input().split()]
L.sort()
pairs = []
for i in range(n):
    for j in range(i + 1, n):
        pairs.append((i, j))

ans = 0
for i, j in pairs:
    a, b = L[i], L[j]
    l = bisect_left(L, b - a)
    r = bisect_left(L, a - 1)
    if l < r:
        ans += (r - l)
print(ans)

Failing test case input:
4
5 2 2 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):

from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
n = int(input()) 

L = [int(i) for i in input().split()]
L.sort()
pairs = []
for i in range(n):
    for j in range(i + 1, n):
        pairs.append((i, j))

ans = 0
for i, j in pairs:
    a, b = L[i], L[j]
    ans += bisect_left(L, a + b) - 1 - j
print(ans)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    ans = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            ind = bisect.bisect_right(a, a[i] + a[j])
            ans += ind - j - 1
    print(ans)

Failing test case input:
4
8 2 1 1

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
c = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        ind = bisect.bisect_left(l, l[i]+l[j])
        c += ind-j-1               
print(c)
Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect
from bisect import bisect_left

_ = input()
l = input()
l = sorted(list(map(int, l.split())))
count = 0

for i in range(len(l)):
	for j in range(bisect(l,l[i]), len(l)):
		c = l[i]+l[j]
		count += bisect_left(l,c) - bisect(l,l[j])

print(count)


Failing test case input:
4
6 2 2 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
from bisect import bisect
from bisect import bisect_left

_ = input()
l = input()
l = sorted(list(map(int, l.split())))
count = 0

for i in range(len(l)):
	for j in range(i+1, len(l)):
		c = l[i]+l[j]
		count += bisect_left(l,c) - (j+1)

print(count)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

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

count = 0
for n in range(N-2):
    for m in range(n+1,N-1):
        count += bisect.bisect_left(L,L[m]-L[n]+1) -m-1

print(count)

Failing test case input:
4
6 4 2 1

Expected output:
0


Actual output:
-3


Fixed submission (verdict: Accepted):
import bisect

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

count = 0
for n in range(N-2):
    for m in range(n+1,N-1):
        count += bisect.bisect_left(L,L[m]+L[n]) -m-1

print(count)

Problem: p02888
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))

cnt=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        k=bisect.bisect_left(l,l[j]+1)
        p=bisect.bisect_right(l,l[i]+l[j]-1)
        cnt+=max(p-k,0)
print(cnt)


Failing test case input:
4
5 2 2 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))

cnt=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        p=bisect.bisect_right(l,l[i]+l[j]-1)
        cnt+=max(p-j-1,0)
print(cnt)

Problem: p02888
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
l = sorted(list(map(int, input().split())))
 
from bisect import bisect_left, bisect_right

cnt = 0
for i in range(N):
    a = l[i]
    for j in range(i+1, N):
        b = l[j]
        cnt += bisect_left(l[b:], a+b)
print(cnt)

Failing test case input:
7
218 786 704 271 645 728 389

Expected output:
24


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
l = sorted(list(map(int, input().split())))
 
from bisect import bisect_left

cnt = 0
for i in range(N):
    a = l[i]
    for j in range(i+1, N):
        b = l[j]
        cnt += bisect_left(l[j+1:], a+b)
print(cnt)
Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
n = int(input())
 
l = list(map(int, input().split()))
l.sort()
a = 0
print(l)
for i in range(n):
    for j in range(i+1,n):
        s = bisect.bisect_left(l,l[i]+l[j])-j-1
        a+=s


print(a)

Failing test case input:
7
218 1140 1051 31 636 1549 389

Expected output:
6


Actual output:
[31, 218, 389, 636, 1051, 1140, 1549]
6


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
 
l = list(map(int, input().split()))
l.sort()
a = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        s = bisect.bisect_left(l,l[i]+l[j])-j-1
        a+=s


print(a)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
L = list(map(int,input().split()))
L.sort()
import bisect
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        c = a+b+1
        n = bisect.bisect_left(L,c)
        ans += N - n
print(ans)
        

Failing test case input:
7
153 7220 638 14 121 152 9

Expected output:
3


Actual output:
32


Fixed submission (verdict: Accepted):
N = int(input())
L = list(map(int,input().split()))
L.sort()
import bisect
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        c = a+b
        n = bisect.bisect_left(L,c)
        ans += n-j-1	
print(ans)

Problem: p02888
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import bisect
N = int(input())
L = list(map(int, input().split()))
L = sorted(set(L))

ans = 0
for i in range(len(L)-2):
  for j in range(i+2, len(L)):
    a, b = L[i], L[j]
    right = bisect.bisect_right(L, b-a)
    if b-a < a:
      right += 1
    left = max(right, i+1)
    ans += j - left
print(ans)

Failing test case input:
4
6 2 2 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N-2):
  for j in range(i+2, N):
    a, b = L[i], L[j]
    right = bisect.bisect_right(L, b-a)
    left = max(right, i+1)
    ans += j - left
print(ans)
Problem: p02888
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
import copy
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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




N=one_int()
L=many_int()

L=sorted(L)

sankaku_dict={}
search_end={}
count=0
for i in range(len(L)-1):
    low=L[i]
    
    for j in range(i+1, len(L)):
        
        temp = str(L[i]) +","+ str(L[j])
        if temp in search_end:
            continue
        high = L[j]
        Lcopy2 = L[j:]
        
        
        under_index = bisect.bisect_right(Lcopy2,high-low)
        
        high_index = bisect.bisect_left(Lcopy2,high+low)
        




        count+=len(Lcopy2[under_index:high_index])


print(count)


Failing test case input:
7
116 1499 551 65 418 890 487

Expected output:
7


Actual output:
28


Fixed submission (verdict: Accepted):
import bisect
import copy
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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


N=one_int()
L=many_int()

L=sorted(L)

sankaku_dict={}
count=0
for i in range(len(L)-1):
    low=L[i]
    for j in range(i+1, len(L)):
        
        high = L[j]
        
        
        high_index = bisect.bisect_left(L[j+1:], high+low)
        count+=high_index


print(count)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
number_of_sticks = int(input())

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

sticks.sort()

print(sticks)

triangles = 0

import bisect

for i in range (number_of_sticks - 2):
    for j in range (i+2, number_of_sticks):
        
        
        
        max_range = j
        min_range = max(bisect.bisect(sticks, sticks[j] - sticks[i]), i + 1)
        
        
        triangles += max(0, max_range - min_range)

print(triangles)

Failing test case input:
4
8 2 1 1

Expected output:
0


Actual output:
[1, 1, 2, 8]
0


Fixed submission (verdict: Accepted):
number_of_sticks = int(input())

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

sticks.sort()

triangles = 0

import bisect

for i in range (number_of_sticks - 2):
    for j in range (i+2, number_of_sticks):
        max_range = j
        min_range = max(bisect.bisect(sticks, sticks[j] - sticks[i]), i + 1)
        triangles += max_range - min_range

print(triangles)

Problem: p02888
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import bisect
 
N = int(input())
Ls = list(map(int, input().split(" ")))
Ls.sort()
 
ans = 0
 
for i in range(0,N-2):
  for j in range(i+1,N-1):
    k = bisect.bisect_left(Ls,Ls[i]+Ls[j])
    ans += k - (j + 1)
    print(ans)
       
print(ans)

Failing test case input:
7
583 1452 22 31 128 304 3

Expected output:
0


Actual output:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0


Fixed submission (verdict: Accepted):
import bisect
 
N = int(input())
Ls = list(map(int, input().split(" ")))
Ls.sort()
 
ans = 0
 
for i in range(0,N-2):
  for j in range(i+1,N-1):
    k = bisect.bisect_left(Ls,Ls[i]+Ls[j])
    ans += k - (j + 1)
       
print(ans)
Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect_left
N=int(input())
triangle=[]
count=0
L=list(map(int,input().split()))
L.sort()

for a in range(1,N):
    for b in range(a+1,N):
        c=L[a]+L[b]
        zahyo=bisect_left(L,c)
        count+=max(0,zahyo-b-1)
print(count)

Failing test case input:
7
218 554 380 233 449 890 389

Expected output:
22


Actual output:
13


Fixed submission (verdict: Accepted):
from bisect import bisect_left
N=int(input())
triangle=[]
count=0
L=list(map(int,input().split()))
L.sort()

for a in range(N):
    for b in range(a+1,N):
        c=L[a]+L[b]
        zahyo=bisect_left(L,c)
        count+=max(0,zahyo-b-1)
print(count)

Problem: p02888
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
l_list = list(map(int, input().split()))
l_list.sort()
from bisect import *
max_l = max(l_list)
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = l_list[i]
        b = l_list[j]
        low = max((abs(a - b), a, b))
        high = a + b
        id1 = bisect_left(l_list, high)
        id2 = bisect_right(l_list, low)
        tmp = max(0, id1 - id2)
        ans += tmp
print(ans)


Failing test case input:
4
6 2 2 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
l_list = list(map(int, input().split()))
l_list.sort()
from bisect import *
ans = 0
for i in range(N):
    for j in range(i + 1, N - 1):
        a = l_list[i]
        b = l_list[j]
        high = a + b
        id1 = bisect_right(l_list, high - 1)
        ans += max(0, id1 - (j + 1))
print(ans)

Problem: p02888
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

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

l.sort()
a = sorted(list(set(l)))
ans = 0

for b in range(1,n - 1):
    for c in range(b + 1,n):
        left = bisect.bisect_left(l,l[c] - l[b] + 1)
        right = bisect.bisect_right(l,l[b])
        ans+=max(0,right - left - 1)

print(ans)

Failing test case input:
4
6 2 2 1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect

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

l.sort()
ans = 0

for b in range(n - 2):
    for c in range(b + 1,n - 1):
        left = bisect.bisect_left(l,l[c] + l[b])
        ans+=left - c - 1

print(ans)

Problem: p02888
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

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

L = sorted(L)
print(L)
for c in reversed(range(2, N)):
	for b in reversed(range(1, c)):
		a = bisect.bisect_left(L, L[c]-L[b])
		if a<b:
			s += b-a
		print("{},{},{}".format(a,b,c))

print(s)

Failing test case input:
4
8 2 2 1

Expected output:
1


Actual output:
[1, 2, 2, 8]
3,2,3
3,1,3
0,1,2
1


Fixed submission (verdict: Accepted):
import bisect

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

L = sorted(L)

for c in reversed(range(2, N)):
	for b in reversed(range(1, c)):
		a = bisect.bisect_right(L, L[c]-L[b])
		if a<b:
			s += b-a
print(s)