Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

j=0
ans=0
count=[0]*N
while j!=1:
    ans+=1
    j=A[j]-1
    count[ans]=j
    if count.count(j)>=2:
        ans=-1
        break

print(ans)

Fixed submission:
N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

j=0
ans=0
count=[0]*N
while j!=1:
    ans+=1
    j=A[j]-1
    count[j]+=1
    if count[j]>=2:
        ans=-1
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

j=0
ans=0
count=[0]*N
while j!=1:
    ans+=1
    j=A[j]-1
    count[ans]=j
    if count.count(j)==2:
        ans=-1
        break

print(ans)

Fixed submission:
N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

j=0
ans=0
count=[0]*N
while j!=1:
    ans+=1
    j=A[j]-1
    count[j]+=1
    if count[j]>=2:
        ans=-1
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

j=0
ans=0
count=[]
while j!=1:
    j=A[j]-1
    count.append(j)
    if count.count(j)==2:
        ans=-1
        break
    ans+=1

print(ans)

Fixed submission:
N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

j=0
ans=0
count=[0]*N
while j!=1:
    ans+=1
    j=A[j]-1
    count[j]+=1
    if count[j]>=2:
        ans=-1
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
if A=1:
    A=14
if B=1:
    B=14
print(['ABloibc e'[A<B::2],'Draw'][A==B])

Fixed submission:
A,B=map(int,input().split())
if A==1:
    A=14
if B==1:
    B=14
print(['ABloibc e'[A<B::2],'Draw'][A==B])
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())

ans=0
X=0
while X<=K:
    Y=0
    while Y<=K:
        Z=S-(X+Y)
        if 0<=Z and Z<=K:
            ans+=1
        Y+=1
    X+=1

print(ans)

Fixed submission:
K,S=map(int,input().split())

ans=0
for X in range(K+1):
    for Y in range(K+1):
        ans+=1*(0<=S-X-Y<=K)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())

ans=0
X=0
while X<=K:
    Y=0
    while Y<=K:
        Z=S-(X+Y)
        if 0<=Z<=K:
            ans+=1
        Y+=1
    X+=1

print(ans)

Fixed submission:
K,S=map(int,input().split())

ans=0
for X in range(K+1):
    for Y in range(K+1):
        ans+=1*(0<=S-X-Y<=K)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,X=map(int,input().split())
*A,=map(int,input().split())

ans=0
k=A[0]
while k>X:
    ans+=1
    A[0]-=1
    k-=1 

i=0
while i+1<=N-1:
    j=A[i]+A[i+1]
    while j>X:
        A[i+1]-=1
        j-=1
        ans+=1
    i+=1

print(ans)

Fixed submission:
N,X=map(int,input().split())
*A,=map(int,input().split())

ans=0

if A[0]>X:
    ans+=A[0]-X
    A[0]=X 

i=0
while i+1<=N-1:
    if A[i]+A[i+1]>X:
        ans+=A[i]+A[i+1]-X
        A[i+1]=X-A[i]
    i+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
T=input()
ans=S+T

while ans[-N:]==T:
    recover=ans
    if ans[N-1]==ans[N]:
        ans=ans[:N]+ans[N+1:]
    else:
        recover=ans
        break

if S in T:
    print(len(T))
elif T in S:
    print(len(S))
else:
    print(len(recover))

Fixed submission:
N=int(input())
S=input()
T=input()

ans=2*N
i=N
while i:
    if S[-i:]==T[:i]:
        ans-=i
        break
    i-=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=map(int,input().split())
i=0
ans=0
while i<N:
    if i+1 in A:
        if A[i]==A.index(i+1)+1:
            ans+=1
    i+=1
print(ans//2)

Fixed submission:
N=int(input())
*A,=map(int,input().split())
i=0
ans=0
while i<N:
    if i+1==A[A[i]-1]:
        ans+=1
    i+=1
print(ans//2)
Buggy python submission (verdict: Time Limit Exceeded):
S=list(input())
N=int(input())

i=0
while i<len(S)-1:
    if S[i]!='a' and 123-ord(S[i])<=N:
        N-=123-ord(S[i])
        S[i]='a'
    i+=1

while N:
    if S[-1]=='z':
        S[-1]='a'
    else:
        S[-1]=chr(ord(S[-1])+1)
    N-=1

print(''.join(S))


Fixed submission:
S=list(input())
N=int(input())

i=0
while i<len(S)-1:
    if S[i]!='a' and 123-ord(S[i])<=N:
        N-=123-ord(S[i])
        S[i]='a'
    i+=1

N=N%26
while N:
    if S[-1]=='z':
        S[-1]='a'
    else:
        S[-1]=chr(ord(S[-1])+1)
    N-=1

print(''.join(S))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

cnt = 0
for A in range(1, N):
  for B in range(1, N // A + 1):
    if A * B < N:
      cnt += 1
      
print(cnt)

Fixed submission:
N = int(input())

cnt = 0
for A in range(1, N):
  for B in range(1, (N - 1) // A + 1):
    cnt += 1
      
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
As = list(map(int, input().split()))
 
sum_humidai = 0
 
for person_idx, person_height in enumerate(As):
  
  if person_idx == 0:
    continue
    
  max_front_person = max(As[:person_idx])
  if max_front_person > person_height:
    humidai = max_front_person - person_height
    sum_humidai += humidai
 
print(sum_humidai)

Fixed submission:
N = int(input())
As = list(map(int, input().split()))
 
sum_humidai = 0
max_front_person = 0
  
for person_idx, person_height in enumerate(As):
  
  if person_idx == 0:
    continue
    
  max_front_person = max(max_front_person, As[person_idx - 1])
  if max_front_person > person_height:
    humidai = max_front_person - person_height
    sum_humidai += humidai
 
print(sum_humidai)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
As = list(map(int, input().split()))
 
sum_humidai = 0
 
for person_idx, person_height in enumerate(As):
  
  if person_idx == 0:
    continue
    
  max_front_person = max(As[:person_idx])
  max_person_idx = np.asarray(As[:person_idx]).argmax()
  
  if max_front_person > person_height:
    humidai = max_front_person - person_height
    As[person_idx] += humidai
    sum_humidai += humidai

print(sum_humidai)

Fixed submission:
N = int(input())
As = list(map(int, input().split()))
 
sum_humidai = 0
max_front_person = 0
  
for person_idx, person_height in enumerate(As):
  
  if person_idx == 0:
    continue
    
  max_front_person = max(max_front_person, As[person_idx - 1])
  if max_front_person > person_height:
    humidai = max_front_person - person_height
    sum_humidai += humidai
 
print(sum_humidai)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
As = list(map(int, input().split()))

sum_humidai = 0

for person_idx, person_height in enumerate(As):
  
  for other_idx, other_person_height in enumerate(As[person_idx:]):
    if other_person_height < person_height:
      humidai = person_height - other_person_height
      As[person_idx + other_idx] += humidai
      sum_humidai += humidai
      
print(sum_humidai)

Fixed submission:
N = int(input())
As = list(map(int, input().split()))
 
sum_humidai = 0
max_front_person = 0
  
for person_idx, person_height in enumerate(As):
  
  if person_idx == 0:
    continue
    
  max_front_person = max(max_front_person, As[person_idx - 1])
  if max_front_person > person_height:
    humidai = max_front_person - person_height
    sum_humidai += humidai
 
print(sum_humidai)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import itertools

h, w, k = list(map(int, input().split(' ')))

cells = []
for _ in range(h):
  cells.append(list(input()))
cells = np.asarray(cells)

n_choice = 0
for n_target_rows in range(h + 1):
  target_rows = list(itertools.combinations(range(h), n_target_rows))
  
  for n_target_clms in range(w + 1):
    target_clms = list(itertools.combinations(range(w), n_target_clms))
    
    for rows in target_rows:
      row_converted_cells = cells.copy()
      row_converted_cells[rows, :] = 'r' * w
      
      for clms in target_clms:
        clm_converted_cells = row_converted_cells.copy()
        clm_converted_cells[:, clms] = 'r'
        n_black = np.count_nonzero(clm_converted_cells == '#')
        
        if n_black == k:
          n_choice += 
                    
print(n_choice)

Fixed submission:
import numpy as np
import itertools

h, w, k = list(map(int, input().split(' ')))

cells = []
for _ in range(h):
  cells.append(list(input()))
cells = np.asarray(cells)

n_choice = 0
for n_target_rows in range(h + 1):
  target_rows = list(itertools.combinations(range(h), n_target_rows))
  
  for n_target_clms in range(w + 1):
    target_clms = list(itertools.combinations(range(w), n_target_clms))
    
    for rows in target_rows:
      row_converted_cells = cells.copy()
      row_converted_cells[rows, :] = 'r' * w
      
      for clms in target_clms:
        clm_converted_cells = row_converted_cells.copy()
        clm_converted_cells[:, clms] = 'r'
        n_black = np.count_nonzero(clm_converted_cells == '#')
        
        if n_black == k:
          n_choice += 1
                    
print(n_choice)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0
import math
for c in range(1, N + 1):
  a_b = N - c

  if a_b % 2 == 1:
    roop = range(1, int(math.sqrt(a_b)) + 1, 1)
  else:
    roop = range(1, int(math.sqrt(a_b)) + 1)
  for i in roop:
    if a_b % i == 0:
      ans += 2
      if int(a_b / i) == i:
        ans -= 1

print(ans)

Fixed submission:
N = int(input())
ans = 0
for b in range(1, N + 1):
  ans += (N  - 1) // b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0
import math
for c in range(1, N + 1):
  a_b = N - c

  for i in range(1, int(math.sqrt(a_b)) + 1):
    if a_b % i == 0:
      ans += 2
      if int(a_b / i) == i:
        ans -= 1

print(ans)

Fixed submission:
N = int(input())
ans = 0
for b in range(1, N + 1):
  ans += (N  - 1) // b
print(ans)
Buggy python submission (verdict: Runtime Error):
x, k, d = list(map(int, input().split()))

sign = int(x /abs(x))

if (abs(x) // d) < k:
  tmp = x - sign * d * (abs(x) // d)
  #print(tmp)
  if (k - (abs(x) // d)) % 2 == 0:
    print(abs(tmp))
  else:
    print(min(abs(tmp + d), abs(tmp - d)))
else:
  print(abs(x - sign * d * k))

Fixed submission:
x, k, d = list(map(int, input().split()))

sign = 0
if x != 0:
  sign = int(x /abs(x))

if (abs(x) // d) < k:
  tmp = x - sign * d * (abs(x) // d)
  #print(tmp)
  if (k - (abs(x) // d)) % 2 == 0:
    print(abs(tmp))
  else:
    print(min(abs(tmp + d), abs(tmp - d)))
else:
  print(abs(x - sign * d * k))

Buggy python submission (verdict: Runtime Error):
x, k, d = list(map(int, input().split()))

sign = int(x /abs(x))

if (abs(x) // d) < k:
  tmp = x - sign * d * (abs(x) // d)
  #print(tmp)
  if (k -(abs(x) // d)) % 2 == 0:
    print(tmp)
  else:
    print(min(abs(tmp + d), abs(tmp - d)))
else:
  print(abs(x - sign * d * k))

Fixed submission:
x, k, d = list(map(int, input().split()))

sign = 0
if x != 0:
  sign = int(x /abs(x))

if (abs(x) // d) < k:
  tmp = x - sign * d * (abs(x) // d)
  #print(tmp)
  if (k - (abs(x) // d)) % 2 == 0:
    print(abs(tmp))
  else:
    print(min(abs(tmp + d), abs(tmp - d)))
else:
  print(abs(x - sign * d * k))

Buggy python submission (verdict: Runtime Error):
x, k, d = list(map(int, input().split()))

sign = int(x /abs(x))

if (abs(x) // d) < k:
  tmp = x - sign * d * (abs(x) // d)
  if (abs(x) // d) % 2 == 0:
    print(tmp)
  else:
    print(min(abs(tmp + d), abs(tmp - d)))
else:
  print(abs(x - sign * d * k))

Fixed submission:
x, k, d = list(map(int, input().split()))

sign = 0
if x != 0:
  sign = int(x /abs(x))

if (abs(x) // d) < k:
  tmp = x - sign * d * (abs(x) // d)
  #print(tmp)
  if (k - (abs(x) // d)) % 2 == 0:
    print(abs(tmp))
  else:
    print(min(abs(tmp + d), abs(tmp - d)))
else:
  print(abs(x - sign * d * k))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))


d = [[0]*(N+1) for _ in range(N+1)]
for i in range(M):
  A, B = list(map(int, input().split()))
  d[A][B] = 1
  d[B][A] = 1


ans = 0
for i in range(1, N + 1):
  cnt = 0
  for j in range(1, N + 1):
    if d[i][j] == 1 and H[j - 1] >= H[i - 1]:
      cnt +=1
      break
  if cnt == 0:
    ans += 1
print(ans)

Fixed submission:
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))

d = {}
for i in range(1, N + 1):
  d[i] = []
for i in range(M):
  A, B = list(map(int, input().split()))
  d[A].append(B)
  d[B].append(A)

#print(d)
ans = 0
for i in range(1, N + 1):
  cnt = 0
  for j in d[i]:
    if H[j - 1] >= H[i - 1]:
      cnt +=1
      break
  if cnt ==0:
    ans +=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())

ans = 0
for i in range(1, N + 1):
  for j in range(1, N + 1):
    for k in range(1, N + 1):
      ans += math.gcd(math.gcd(i, j), k)
print(ans)

Fixed submission:
import math

N = int(input())

ans = 0
for i in range(1, N + 1):
  for j in range(1, N + 1):
    for k in range(1, N + 1):
      ans += math.gcd(math.gcd(i, j), k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
d = {}
d_sum = {}
for i in range(N):
  if A[i] in d:
    d[A[i]] += 1
    d_sum[A[i]] += d[A[i]] - 1
  else:
    d[A[i]] = 1
    d_sum[A[i]] = 0
#print(A, d,d_sum)
#print(sum(A), sum(d.values()))
for i in range(N):
  print(sum(d_sum.values()) - (d[A[i]] - 1))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
d = {}
d_sum = {}
for i in range(N):
  if A[i] in d:
    d[A[i]] += 1
    d_sum[A[i]] += d[A[i]] - 1
  else:
    d[A[i]] = 1
    d_sum[A[i]] = 0
#print(A, d,d_sum)
#print(sum(A), sum(d.values()))
ans = sum(d_sum.values())
for i in range(N):
  print(ans - (d[A[i]] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
d = {}
for i in range(N):
  if A[i] in d:
    d[A[i]] += 1
  else:
    d[A[i]] = 1
#合計を求める
d_sum = {}
for i in set(A):
  d_sum[i] = int(d[i] *(d[i] - 1)/ 2)

#print(A, d,d_sum)
#print(sum(A), sum(d.values()))
for i in range(N):
  print(sum(d_sum.values()) - (d[A[i]] - 1))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
d = {}
d_sum = {}
for i in range(N):
  if A[i] in d:
    d[A[i]] += 1
    d_sum[A[i]] += d[A[i]] - 1
  else:
    d[A[i]] = 1
    d_sum[A[i]] = 0
#print(A, d,d_sum)
#print(sum(A), sum(d.values()))
ans = sum(d_sum.values())
for i in range(N):
  print(ans - (d[A[i]] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
d = {}
for i in range(N):
  if A[i] in d:
    d[A[i]] += 1
  else:
    d[A[i]] = 1
#print(A, d)

for i in range(N):
  ans = 0
  for k, v in d.items():
    if k == A[i]:
      ans+= (v-1)*max(v-2,0)/2
    else:
      ans+= v * (v-1)/ 2
  print(int(ans))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
d = {}
d_sum = {}
for i in range(N):
  if A[i] in d:
    d[A[i]] += 1
    d_sum[A[i]] += d[A[i]] - 1
  else:
    d[A[i]] = 1
    d_sum[A[i]] = 0
#print(A, d,d_sum)
#print(sum(A), sum(d.values()))
ans = sum(d_sum.values())
for i in range(N):
  print(ans - (d[A[i]] - 1))
Buggy python submission (verdict: Runtime Error):

a, b, c = map(int, input().split())
import math

if
if (c - a - b) **2 <= 4 * a * b  or c - a - b <= 0:
  print("No")
else:
  print("Yes")

Fixed submission:

a, b, c = map(int, input().split())
import math

if (c - a - b) **2 <= 4 * a * b  or c - a - b <= 0:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
#query = [input().split() for _ in range(Q)]

rev = False
forw = ""
back = ""
for i in range(Q):
  query = input().split()
  if query[0] == "1":
    rev = not rev
  else:
    if (not rev and query[1] == "1") or (rev and query[1] == "2"):
      forw = query[2] + forw
    else:
      back += query[2]
#S = forw + S + back
if rev:
  S = back[::-1] + S[::-1] + forw[::-1]
else:
  S = forw + S + back
print(S)

Fixed submission:
S = input()
Q = int(input())
#query = [input().split() for _ in range(Q)]

rev = False
forw = ""
back = ""
for i in range(Q):
  query = input().split()
  if query[0] == "1":
    rev = not rev
  else:
    if (not rev and query[1] == "1") or (rev and query[1] == "2"):
      forw = query[2] + forw
    else:
      back += query[2]
#S = forw + S + back
if rev:
  S = back[::-1] + S[::-1] + forw[::-1]
else:
  S = forw + S + back
print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
#query = [input().split() for _ in range(Q)]

rev = False
for i in range(Q):
  query = input().split()
  if query[0] == "1":
    rev = not rev
    pass
  else:
    if (not rev and query[1] == "1") or (rev and query[1] == "2"):
      S = query[2] + S
    else:
      S += query[2]
if rev:
  S = S[::-1]
print(S)

Fixed submission:
S = input()
Q = int(input())
#query = [input().split() for _ in range(Q)]

rev = False
forw = ""
back = ""
for i in range(Q):
  query = input().split()
  if query[0] == "1":
    rev = not rev
  else:
    if (not rev and query[1] == "1") or (rev and query[1] == "2"):
      forw = query[2] + forw
    else:
      back += query[2]
#S = forw + S + back
if rev:
  S = back[::-1] + S[::-1] + forw[::-1]
else:
  S = forw + S + back
print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
query = [input().split() for _ in range(Q)]

rev = False
for i in range(Q):
  if query[i][0] == "1":
    rev = not rev
    pass
  else:
    if (not rev and query[i][1] == "1") or (rev and query[i][1] == "2"):
      S = query[i][2] + S
    else:
      S += query[i][2]
  
if rev:
  S = S[::-1]
print(S)

Fixed submission:
S = input()
Q = int(input())
#query = [input().split() for _ in range(Q)]

rev = False
forw = ""
back = ""
for i in range(Q):
  query = input().split()
  if query[0] == "1":
    rev = not rev
  else:
    if (not rev and query[1] == "1") or (rev and query[1] == "2"):
      forw = query[2] + forw
    else:
      back += query[2]
#S = forw + S + back
if rev:
  S = back[::-1] + S[::-1] + forw[::-1]
else:
  S = forw + S + back
print(S)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A_ = {}

for a in A:
  if a not in A_:
    A_[a] = 1
  else:    
    A[a] += 1
    break
if len(A) == len(A_):
  print("YES")
else:
  print("NO")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A_ = {}

for a in A:
  if a not in A_:
    A_[a] = 1
  else:    
    A_[a] += 1
    break
if len(A) == len(A_):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
P = list(map(lambda x: (int(x) * (int(x) + 1)) / 2 / int(x), input().split()))
#print(P)
ans = 0
for i in range(N - K + 1):
  tmp = 0
  for j in range(i, i + K):
    tmp += P[j]
  if tmp > ans:
    ans = tmp
print(ans)

Fixed submission:
N, K = list(map(int, input().split()))
P = list(map(lambda x: (int(x) * (int(x) + 1)) / 2 / int(x), input().split()))
#print(P)
ans = sum(P[:K])
tmp = ans
#print(ans)
for i in range(1, N - K + 1):
  tmp = tmp - P[i - 1] + P[i + K - 1]
  #print(tmp, P[i - 1], P[i + K - 1])
  if tmp > ans:
    ans = tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
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):
#      #print(str(i) + str(j) + str(k))
#      if L[i] < L[j] + L[k] and abs(L[j] - L[k]) < L[i]:
#        ans += 1
#print(ans)
comb = list(itertools.combinations(L, 3))
comb = list(map(list, comb))
for i in range(len(comb)):
  if comb[i][0] < comb[i][1] + comb[i][2] and abs(comb[i][1] - comb[i][2]) < comb[i][0]:
    ans += 1
print(ans)



Fixed submission:
import bisect
N = int(input())
#ソートしておく
L = sorted(list(map(int, input().split())))
ans = 0

#短い2辺を総当たりで選択
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    #小さい順に並べた時の成立条件
    # l1 + l2 > l3
    l12 = L[i] + L[j]
    #l2の隣から　l12以下のところまで全部が対象、成立しない場合
    #ans += max(bisect.bisect_left(L, l12) - j - 1, 0)
    ans += bisect.bisect_left(L, l12) - j - 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
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):
      #print(str(i) + str(j) + str(k))
      if L[i] < L[j] + L[k] and abs(L[j] - L[k]) < L[i]:
        ans += 1
print(ans)

Fixed submission:
import bisect
N = int(input())
#ソートしておく
L = sorted(list(map(int, input().split())))
ans = 0

#短い2辺を総当たりで選択
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    #小さい順に並べた時の成立条件
    # l1 + l2 > l3
    l12 = L[i] + L[j]
    #l2の隣から　l12以下のところまで全部が対象、成立しない場合
    #ans += max(bisect.bisect_left(L, l12) - j - 1, 0)
    ans += bisect.bisect_left(L, l12) - j - 1
print(ans)

Buggy python submission (verdict: Runtime Error):
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):
#      #print(str(i) + str(j) + str(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)
comb = list(itertools.combinations(L, 3))
print(comb)



Fixed submission:
import bisect
N = int(input())
#ソートしておく
L = sorted(list(map(int, input().split())))
ans = 0

#短い2辺を総当たりで選択
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    #小さい順に並べた時の成立条件
    # l1 + l2 > l3
    l12 = L[i] + L[j]
    #l2の隣から　l12以下のところまで全部が対象、成立しない場合
    #ans += max(bisect.bisect_left(L, l12) - j - 1, 0)
    ans += bisect.bisect_left(L, l12) - j - 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
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):
      #print(str(i) + str(j) + str(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)

Fixed submission:
import bisect
N = int(input())
#ソートしておく
L = sorted(list(map(int, input().split())))
ans = 0

#短い2辺を総当たりで選択
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    #小さい順に並べた時の成立条件
    # l1 + l2 > l3
    l12 = L[i] + L[j]
    #l2の隣から　l12以下のところまで全部が対象、成立しない場合
    #ans += max(bisect.bisect_left(L, l12) - j - 1, 0)
    ans += bisect.bisect_left(L, l12) - j - 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = [0]*N
for i in range(1,N):
  if H[i - 1] <= now_:
    ans[i] = ans[i - 1] + 1
print(max(ans))

Fixed submission:
import math
N = int(input())
H = list(map(int, input().split()))
ans = [0]*N
for i in range(1,N):
  if H[i] <= H[i - 1]:
    ans[i] = ans[i - 1] + 1
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s_n = [sorted(list(input())) for i in range(N)]

ans = 0
for i in range(N - 1):
  for j in range(i + 1, N):
    if s_n[i] == s_n[j]:
      ans += 1
print(ans)

Fixed submission:
n = int(input())
d = {}
ans = 0

for i in range(n):
    s = ''.join(sorted(input()))
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
#print(d)
for k, v in d.items():
  ans += v * (v - 1) / 2

print(int(ans))