Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03181 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
def dfs(v,p):
    if res_v[v]!=-1:
        return res_v[v]
    size[v]=len(G[v])
    dp[v]=[0]*size[v]
    res=1
    for i in range(size[v]):
        nv=G[v][i]
        if nv==p:
            p_i[v]=i
            continue
        R=dfs(nv,v)
        dp[v][i]=R
        res=res*(R+1)%MOD
    return res
    
def reroot(v,res_p,p):
    if p!=-1:
        dp[v][p_i[v]]=res_p
    for i in range(size[v]):
        ans[v]=ans[v]*(dp[v][i]+1)%MOD
    dp_L=[1]*(size[v]+1)
    dp_R=[1]*(size[v]+1)
    for i in range(size[v]):
        dp_L[i+1]=dp_L[i]*(dp[v][i]+1)%MOD
    for i in reversed(range(size[v])):
        dp_R[i]=dp_R[i+1]*(dp[v][i]+1)%MOD
        
    for i in range(size[v]):
        nv=G[v][i]
        if nv==p:
            continue
        reroot(nv,dp_L[i]*dp_R[i+1]%MOD,v)

N,MOD=map(int,input().split())
G=[[] for i in range(N)]
for i in range(N-1):
    x,y=map(lambda x:int(x)-1,input().split())
    G[x].append(y)
    G[y].append(x)
res_v=[-1]*N
dp=[[] for i in range(N)]
size=[-1]*N
p_i=[-1]*N
dp_L=[[] for i in range(N)]
dp_R=[[] for i in range(N)]
ans=[1]*N

z_root=dfs(0,-1)
res_v[0]=z_root
reroot(0,0,-1)
print(*ans,sep='\n')

Buggy submission (verdict: Runtime Error):
def dfs(v,p):
    if res_v[v]!=-1:
        return res_v[v]
    size[v]=len(G[v])
    dp[v]=[0]*size[v]
    res=1
    for i in range(size[v]):
        nv=G[v][i]
        if nv==p:
            p_i[v]=i
            continue
        R=dfs(nv,v)
        dp[v][i]=R
        res=res*(R+1)%MOD
    return res
    
def reroot(v,res_p,p):
    if p!=-1:
        dp[v][p_i[v]]=res_p
    for i in range(size[v]):
        ans[v]=ans[v]*(dp[v][i]+1)%MOD
    dp_L=[1]*(size[v]+1)
    dp_R=[1]*(size[v]+1)
    for i in range(size[v]):
        dp_L[i+1]=dp_L[i]*(dp[v][i]+1)%MOD
    for i in reversed(range(size[v])):
        dp_R[i]=dp_R[i+1]*(dp[v][i]+1)%MOD
        
    for i in range(size[v]):
        nv=G[v][i]
        if nv==p:
            continue
        reroot(nv,dp_L[i]*dp_R[i+1]%MOD,v)

N,MOD=map(int,input().split())
G=[[] for i in range(N)]
for i in range(N-1):
    x,y=map(lambda x:int(x)-1,input().split())
    G[x].append(y)
    G[y].append(x)
res_v=[-1]*N
dp=[[] for i in range(N)]
size=[-1]*N
p_i=[-1]*N
dp_L=[[] for i in range(N)]
dp_R=[[] for i in range(N)]
ans=[1]*N

z_root=dfs(0,-1)
res_v[0]=z_root
reroot(0,0,-1)
print(*ans,sep='\n')
Problem p03215 (python)

Fixed submission:
N,K=map(int,input().split())
a=list(map(int,input().split()))
cum=[0]*(N+1)
for i in range(N):
    cum[i+1]=cum[i]+a[i]
A=[]
for i in range(N+1):
    for j in range(i):
        A.append(cum[i]-cum[j])
L=len(A)
ans=0
for j in reversed(range(46)):
    li=[]
    for i in range(L):
        if A[i]>>j&1:
            li.append(A[i])
    if len(li)<K:
        continue
    ans+=1<<j
    A=li
    L=len(A)
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
a=list(map(int,input().split()))
cum=[0]*(N+1)
for i in range(N):
    cum[i+1]=cum[i]+a[i]
beau=[]
for i in range(N+1):
    for j in range(i):
        beau.append(cum[i]-cum[j])
beau.sort()
bit=[0]*30
for x in beau:
    j=0
    while((x>>j)>0):
        bit[j]+=x>>j&1
        j+=1
ans=0
for i in range(len(beau)-K+1):
    res=1023
    for j in range(i,i+K):
        res&=beau[j]
    ans=max(ans,res)
print(ans)
Problem p03240 (python)

Fixed submission:
INF=10**20
N=int(input())
xyh=[list(map(int,input().split())) for i in range(N)]
xyh=sorted(xyh,key=lambda xyh:xyh[2],reverse=True)
for i in range(101):
    for j in range(101):
        res=-INF
        T=True
        for k in range(N):
            tmp=xyh[k][2]+abs(xyh[k][0]-i)+abs(xyh[k][1]-j)
            if(xyh[k][2]>0):
                if(res==-INF):
                    res=tmp
                elif(res!=tmp):
                    T=not T
                    break
            elif(xyh[k][2]==0):
                if(tmp<res):
                    T=not T
                    break
        if T:
            print(i,j,res)
            exit()

Buggy submission (verdict: Runtime Error):
INF=10**20
N=int(input())
x=[];y=[];h=[]
for i in range(N):
    X,Y,H=map(int,input().split())
    x.append(X);y.append(Y);h.append(H)
for i in range(101):#Cx
    for j in range(101):#Cy
        res=-INF
        T=True
        mli=[]
        for k in range(N):
            tmp=h[k]+abs(x[k]-i)+abs(y[k]-j)
            if(h[k]>0):
                if(res==-INF):
                    res=tmp
                elif(res!=tmp):
                    T=not T
                    break
            elif(h[k]==0):
                mli.append(tmp)
        for x in mli:
            if(x<res):
                T=not T
                break
        if T:
            print(i,j,res)
            exit()
Problem p03476 (python)

Fixed submission:
import math
import bisect
def era(n):
    data=[i for i in range(2,n+1)]
    for d in data:
        data=[x for x in data if(x==d or x%d != 0)]
    return data
    
def prime(n):
    max=int(math.sqrt(n))
    li=[i for i in range(2,n+1)]
    primes=[]
    while li[0]<=max:
        primes.append(li[0])
        tmp=li[0]
        li=[i for i in li if i%tmp!=0]
    primes.extend(li)
    return primes

Q=int(input())
l=[]
r=[]
up=0
for i in range(Q):
    a,b=map(int,input().split())
    up=max([up,a,b])
    
    l.append(a)
    r.append(b)
s=prime(up)
like=[]

for i in range(len(s)):#O(10000*log(10000))
    if((s[i]+1)/2==s[bisect.bisect_left(s,(s[i]+1)/2)]):
        like.append(s[i])
        
sumli=[0]*100001
tmp=0
for i in range(2,100001):#O(100000)
    if(i==like[tmp]):
        sumli[i]=sumli[i-1]+1
        if(tmp<(len(like)-1)):
            tmp+=1
    else:
        sumli[i]=sumli[i-1]

for i in range(Q):
    print(sumli[r[i]]-sumli[l[i]-1])

Buggy submission (verdict: Runtime Error):
import bisect
def prime(n):
    max_=int(n**0.5)
    li=[i for i in range(2,n+1)]
    primes=[]
    while li[0]<=max_:
        primes.append(li[0])
        tmp=li[0]
        li=[i for i in li if i%tmp!=0]
    primes.extend(li)
    return primes
Q=int(input())
arr=prime(100000)
likenum=[]
n=len(arr)
for i in range(n):
    lik=(arr[i]+1)//2
    x=bisect.bisect_left(arr,lik)
    if(x<n and arr[x]==(lik)):
        likenum.append(arr[i])
for i in range(Q):
    L,R=map(int,input().split())
    r=bisect.bisect_left(likenum,R)
    l=bisect.bisect_left(likenum,L)
    if(likenum[r]==R):
        r+=1
    print(r-l)
Problem p03605 (python)

Fixed submission:
N=input()
for i in N:
    if(i=='9'):
        print("Yes")
        exit()
print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
ans=1
li=[A[0]]
for i in range(1,N):
    ans+=1 if li.count(A[i])%2==0 else -1
    li.append(A[i])
print(ans)
Problem p03612 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
i=0
cnt=0
while(i<N):
    if(A[i]==i+1):
        if(i!=N-1):
            A[i],A[i+1]=A[i+1],A[i]
        cnt+=1
        i+=2
        continue
    i+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
i=0
cnt=0
while(i<N):
    if(A[i]==i+1):
        A[i],A[i+1]=A[i+1],A[i]
        cnt+=1
        i+=2
        continue
    i+=1
print(cnt)
Problem p03625 (python)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
m=c.most_common()
t=sorted(m,key=lambda m:m[0],reverse=True)
w=0
b=0
for i in range(len(t)):
    if(t[i][1]>=4):
        if(w==b==0):
            w=t[i][0]
            b=t[i][0]
        elif(w==0):
            w=t[i][0]
        elif(b==0):
            b=t[i][0]
    elif(t[i][1]>=2):
        if(w==0):
            w=t[i][0]
        elif(b==0):
            b=t[i][0]
print(w*b)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))

c=Counter(a)
m=c.most_common()
tmp=[]
for i in range(len(m)):
    if(m[i][1]>=2):
        tmp.append(m[i])
d=sorted(tmp,key=lambda tmp:tmp[1])

if(d[0][1]>=4):
    print(d[0][0]**2)
elif(len(d)>=2):
    print(d[0][0]*d[1][0])
else:
    print(0)
Problem p03734 (python)

Fixed submission:
import itertools
N,W=map(int,input().split())
item=[[] for i in range(4)]
for i in range(N):
    w,v=map(int,input().split())
    if(i==0):
        base=w
        item[0].append(v)
    else:
        item[w-base].append(v)
for i in range(4):
    item[i].sort(reverse=True)
l1=len(item[0]);l2=len(item[1]);l3=len(item[2]);l4=len(item[3])
res=0
for x in itertools.product(range(l1+1),range(l2+1),range(l3+1),range(l4+1)):
    if(x[0]*base+x[1]*(base+1)+x[2]*(base+2)+x[3]*(base+3)>W):
        continue
    tmp=sum(item[0][:x[0]])+sum(item[1][:x[1]])+sum(item[2][:x[2]])+sum(item[3][:x[3]])
    res=max(res,tmp)
print(res)

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
weight=[0]*N;value=[0]*N
sumv=0
for i in range(N):
    weight[i],value[i]=map(int,input().split())
    sumv+=value[i]
dp=[[10**12]*(sumv+1) for i in range(N+1)]
dp[0][0]=0
for i in range(N):
    for j in range(sumv+1):
        if(value[i]<=j):
            dp[i+1][j]=min(dp[i][j-value[i]]+weight[i],dp[i][j])
        else:
            dp[i+1][j]=min(dp[i+1][j],dp[i][j])
res=0
for i in range(sumv+1):
    if(dp[N][i]<=W):
        res=max(res,i)
print(res)
Problem p03846 (python)

Fixed submission:
MOD=1000000007
def modpow(a,n,mod):
    res=1
    a=a%mod
    while(n>0):
        if(n&1):
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res

N=int(input())
A=list(map(int,input().split()))
cnt=[0]*100001
for i in range(N):
    cnt[A[i]]+=1
if(N%2==1):
    if(cnt[0]!=1):
        print(0)
        exit()
    for i in range(2,N,2):
        if(cnt[i]!=2):
            print(0)
            exit()
elif(N%2==0):
    for i in range(1,N,2):
        if(cnt[i]!=2):
            print(0)
            exit()
print(modpow(2,N//2,MOD))

Buggy submission (verdict: Runtime Error):
MOD=1000000007
def modpow(a,n,mod):
    res=1
    a=a%mod
    while(n>0):
        if(n&1):
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res

N=int(input())
A=list(map(int,input().split()))
cnt=[0]*10001
for i in range(N):
    cnt[A[i]]+=1
if(N%2==1):
    if(cnt[0]!=1):
        print(0)
        exit()
    for i in range(2,N,2):
        if(cnt[i]!=2):
            print(0)
            exit()
elif(N%2==0):
    for i in range(1,N,2):
        if(cnt[i]!=2):
            print(0)
            exit()
print(modpow(2,N//2,MOD))
Problem p03854 (python)

Fixed submission:
S=input()
while(len(S)>=5):
    if(len(S)>=7 and S[len(S)-7:len(S)]=='dreamer'):
        S=S[:len(S)-7]
    elif(len(S)>=6 and S[len(S)-6:len(S)]=='eraser'):
        S=S[:len(S)-6]
    elif(S[len(S)-5:len(S)]=='dream' or S[len(S)-5:len(S)]=='erase'):
        S=S[:len(S)-5]
    else:
        print("NO")
        exit()
if(len(S)!=0):
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
S=input()
print(S)
while(len(S)>=5):
    if(S[len(S)-7:len(S)]=='dreamer'):
        S=S[:len(S)-7]
    elif(S[len(S)-6:len(S)]=='eraser'):
        S=S[:len(S)-6]
    elif(S[len(S)-5:len(S)]=='dream' or S[len(S)-5:len(S)]=='erase'):
        S=S[:len(S)-5]
    else:
        print("NO")
        exit()
    print(S)
if(len(S)!=0):
    print("NO")
else:
    print("YES")
Problem p04013 (python)

Fixed submission:
N,A=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0]*2600 for j in range(N+10)] for i in range(N+10)]
dp[0][0][0]=1
for i in range(N):
    for j in range(N+1):
        for k in range(2501):
            if(dp[i][j][k]!=0):
                dp[i+1][j][k]+=dp[i][j][k]
                dp[i+1][j+1][k+x[i]]+=dp[i][j][k]
print(sum(dp[N][i][i*A] for i in range(1,N+1)))

Buggy submission (verdict: Runtime Error):
N,A=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0]*(N*N+100) for j in range(N+10)] for i in range(N+10)]
dp[0][0][0]=1
for i in range(N):
    for j in range(N+1):
        for k in range(sum(x)+1):
            if(dp[i][j][k]!=0):
                dp[i+1][j][k]+=dp[i][j][k]
                dp[i+1][j+1][k+x[i]]+=dp[i][j][k]
print(sum(dp[N][i][i*A] for i in range(1,N+1)))
Problem p02576 (python)

Fixed submission:
import math
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

# N = I()
N,X,T = LI()

ans = math.ceil(N/X) * T

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import os
from collections import deque

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")

INF = float("inf")

H,W = LI()
C = LI()
D = LI()
maze = [list(_S()) for i in range(H)]

def bfs():
    # すべてのマスを INF で初期化
    d = [[INF] * W for i in range(H)]
    
    sx = C[0]-1
    sy = C[1]-1
    gx = D[0]-1
    gy = D[1]-1

    # スタート地点をキューに入れ、ワープ数を0にする
    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    # ワープ対象
    que2 = deque([])

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    # ワープのベクトル
    dx2 = [-2, -2, -2, -2, -2, -1, -1, -1, -1,  0, 0, 1, 1,  1,  1, 2, 2, 2,  2, 2]
    dy2 = [-2, -1,  0,  1,  2, -2, -1,  1,  2, -2, 2, 2, 1, -1, -2, 2, 1, 0, -1, -2]

    while que: 
        while que:
            p = que.popleft()       
            # 取り出してきた状態がゴールなら探索をやめる
            if p[0] == gx and p[1] == gy:
                ans = d[p[0]][p[1]]
                print(ans)
                exit()
            que2.append((p[0], p[1]))
            # 移動4方向をループ
            for i in range(4):
                # 移動した後の点を (nx, ny) とする
                nx = p[0] + dx[i]
                ny = p[1] + dy[i]

                # 移動可否判定、d[nx][ny] == INF であれば訪れたことがない
                if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] != "#" and d[nx][ny] == INF:
                    # 移動できるならキューに入れ、その点のワープ回数を p までのワープ回数で確定する
                    que.append((nx, ny))
                    d[nx][ny] = d[p[0]][p[1]]
                    
        while que2:
            # キューの先頭を取り出す
            p = que2.popleft()
            for i in range(20):
            # for dxi in range(-2,3):
            #     for dyi in range(-2,3):
                nx = p[0] + dx2[i]
                ny = p[1] + dy2[i]
                if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] != "#" and d[nx][ny] == INF:
                    # 移動できるならキューに入れ、その点のワープ回数を p からのワープ回数 +1 で確定する
                    que.append((nx, ny))
                    d[nx][ny] = d[p[0]][p[1]]+1  
        # print('after que2: ',d)  
    return

bfs()
print(-1)
Problem p02602 (python)

Fixed submission:
import decimal
import numpy as np
import sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

N,K = LI()
A = LI()

ans = []

for i in range(K,N):
    if A[i-K] < A[i]:
        ans.append('Yes')
    else:
        ans.append('No')

print('\n'.join(ans))

Buggy submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,string,decimal
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N,K = LI()
_A = LI()

# A = np.array(_A, dtype='float128')
A = np.array(_A, dtype=decimal.Decimal)

A /= decimal.Decimal(10)
# print(A)

Aprod = np.zeros(N + 1, dtype=np.dtype(decimal.Decimal))
# Aprod = np.zeros(N + 1, dtype='float128')
Aprod[0] = 1
Aprod[1:] = np.cumprod(A)
# print(Aprod)

# print(Aprod)
result = np.zeros(N+1-K,dtype=np.dtype(decimal.Decimal))
# result = np.zeros(N+1-K,dtype='float128')
result = Aprod[K:] / Aprod[0:N+1-K]

# print(result)
ans = []
for i in range(1, N+1-K):
    if result[i] <= result[i-1]:
        ans.append('No')
    else:
        ans.append('Yes')

print('\n'.join(ans))

# 5 3
# 96 98 100000000 100000000 100000000
Problem p02630 (python)

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
from numba import njit
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
Q = I()
BC = [LI() for _ in range(Q)]

sum_A = sum(A)
c = collections.Counter(A)

for pair in BC:
    num_from = pair[0]
    num_to = pair[1]
    if num_from in c:
        diff = (num_to - num_from) * c[num_from]
        sum_A += diff
        print(sum_A)
        c[num_to] += c[num_from]
        c[num_from]=0
    else:
        print(sum_A)

Buggy submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
from numba import njit
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
# A = np.array(_A,dtype='int')
Q = I()
BC = [LI() for _ in range(Q)]
# print(BC)

def convert(n):
    return d[n]

d = {1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9}
for i in range(Q):
    for key, value in d.items():
        if BC[i][0] == value:
            d[key]=BC[i][1]
    ans = np.array(list(map(convert,A)),dtype='int')
    print(ans.sum())


# ans = list(map(convert,A))
# for item in ans:
#     print(item)
# print('\n'.join(str(ans)))

#A,B = zip(*AB)
#Ap = np.array(A)
#C = np.zeros(N + 1)

# if ans:
#     print('Yes')
# else:
#     print('No')
Problem p02696 (python)

Fixed submission:
# 具体例を試す
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

A,B,N = LI()
# ans = 0

# a = [0]*N

# for x in range(1,N+1):
#     # ans = max(ans,math.floor(A*x/B) - A * math.floor(x/B))
#     a[x-1]=math.floor(A*x/B) - A * math.floor(x/B)

x = min(N,B-1)
ans = math.floor(A*x/B) - A * math.floor(x/B)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

A,B,N = LI()
ans = 0

a = [0]*N

for x in range(1,N+1):
    # ans = max(ans,math.floor(A*x/B) - A * math.floor(x/B))
    a[x-1]=math.floor(A*x/B) - A * math.floor(x/B)

print(max(a))
Problem p02888 (python)

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
L = LI()
# L = np.array(_L)
#C = np.zeros(N + 1)

# def test(a,b,c):
#     if a<b+c and b<c+a and c<a+b:
#         return True
#     return False

# count = 0
# for pair in itertools.combinations(L, 3):
#     # print(pair)
#     if test(*pair):
#         count += 1
# print(count)

# for i in range(N):
#     for j in range(i+1,N):

from numba import njit
 
@njit
def f(A):
  count = 0
  for i in range(N):
    for j in range(i + 1, N):
      for k in range(j + 1, N):
        count += (A[k] < A[i] + A[j])
  return count
 
A = np.array(L)
A.sort()
print(f(A))

Buggy submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
from numba import njit

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
L = LI()

def test(a,b,c):
    if a<b+c and b<c+a and c<a+b:
        return True
    return False

@ njit
def comb():
    count = 0
    for pair in itertools.combinations(L, 3):
        if test(*pair):
            count += 1
    return count

print(print(comb()))
 
# @njit
# def f(A):
#   count = 0
#   for i in range(N):
#     for j in range(i + 1, N):
#       for k in range(j + 1, N):
#         count += (A[k] < A[i] + A[j])
#   return count
 
# A = np.array(L)
# A.sort()
# print(f(A))

Buggy submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
from numba import njit

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
L = LI()

def test(a,b,c):
    if a<b+c and b<c+a and c<a+b:
        return True
    return False

count = 0
@ njit
for pair in itertools.combinations(L, 3):
    # print(pair)
    if test(*pair):
        count += 1
print(count)
 
# @njit
# def f(A):
#   count = 0
#   for i in range(N):
#     for j in range(i + 1, N):
#       for k in range(j + 1, N):
#         count += (A[k] < A[i] + A[j])
#   return count
 
# A = np.array(L)
# A.sort()
# print(f(A))