Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
for i in range(n):
  if a[i]>=b[i]:
    c+=int(b[i])
  else:
    if (a[i]+a[i+1])>=b[i]:
      c+=int(b[i])
      a[i+1]=a[i]+a[i+1]-b[i]
    else:
      c+=int(a[i]+a[i+1])
print(c)

Fixed submission:
A, B=map(int,input().split())
k = (A+B)//2 
if (A+B)%2 == 0:
  print(k)
else:
  print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
for i in range(n):
  if a[i]>=b[i]:
    c+=int(b[i])
  else:
    if (a[i]+a[i+1])>=b[i]:
      c+=int(b[i])
      a[i+1]=a[i]+a[i+1]-b[i]
    else:
      c+=int(a[i]+a[i+1])
print(c)

Fixed submission:
A, B=map(int,input().split())
k = (A+B)//2 
if (A+B)%2 == 0:
  print(k)
else:
  print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
N = int(input())
m = list(map(int, input().split()))
b = list(map(int, input().split()))
s = 0
for i in range(N):
  if m[i]<b[i]:
    if (m[i]+m[i+1])>b[i]:
        s += b[i]
        m[i+1] += m[i]-b[i]
    else:
       s += m[i]+m[i+1]
  else:
    s += b[i]
print(s)

Fixed submission:
A, B=map(int,input().split())
k = (A+B)//2 
if (A+B)%2 == 0:
  print(k)
else:
  print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
b = sorted(a)
k = 0
for i in range(N):
  if a[i] != b[i]:
    k += 1
if k >2 :
  print("NO")
else:
  print("YES")
  


Fixed submission:
A, B=map(int,input().split())
k = (A+B)//2 
if (A+B)%2 == 0:
  print(k)
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N = input()
p = list(map(int,input().split()))
s = sorted(p)
k = 0
for i in range(N):
  if p[i]!=s[i]:
    k += 1
if k < 3 :
   print("YES")
else:
   print("NO")

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = sorted(a)
k = 0
for i in range(N):
  if a[i] != b[i]:
    k += 1
if k >2 :
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for i in range(N)]
s = sorted(a,reverse=True)
for i in range(N):
  if s[0]!=a[i]:
    print(s[0])
  else:
    print(s[1])
    

Fixed submission:
a = input()
b = 3*(int(a)**2)
print(b)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = a//(2*b+1)
if a%(2*b+1) == 0:
  print(s)
else:
  print(s+1)

Fixed submission:
a = input()
b = 3*(int(a)**2)
print(b)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int,input().split())
if n＊a < b:
  print(int(n＊a))
elif n＊a >= b:
  print(int(b))


Fixed submission:
n, a, b = map(int,input().split())
if n*a > b:
  print(b)
else:
  print(n*a)

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int,input().split())
if n＊a < b:
  print(n＊a)
elif n＊a >= b:
  print(b)


Fixed submission:
n, a, b = map(int,input().split())
if n*a > b:
  print(b)
else:
  print(n*a)

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int,input().split())
if n＊a <= b:
  print(n＊a)
else:
  print(b)

Fixed submission:
n, a, b = map(int,input().split())
if n*a > b:
  print(b)
else:
  print(n*a)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = False
if s[0] == s[1] :
  if s[0] != s[2] and s[2] ==s[3] :
    ans = True
elif s[0] == s[2] :
  if s[0] != s[1] and s[1] ==s[3] :
    ans = True
else s[0] == s[3] :
  if s[0] != s[1] and s[2] ==s[1] :
    ans = True
if ans :
  print('Yse')
else:
  print('No')

Fixed submission:
s=input()
ans=False
if s[0]==s[1]:
    if s[0]!=s[2] and s[2]==s[3]:
        ans=True
elif s[0]==s[2]:
    if s[0]!=s[1] and s[1]==s[3]:
        ans=True
elif s[0]==s[3]:
    if s[0]!=s[1] and s[1]==s[2]:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = input()
ans = False
if s[0] == s[1] :
  if s[0] != s[2] and s[2] ==s[3] :
  ans = True
elif s[0] == s[2] :
  if s[0] != s[1] and s[1] ==s[3] :
  ans = True
else s[0] == s[3] :
  if s[0] != s[1] and s[2] ==s[1] :
  ans = True
if ans :
  print('Yse')
else:
  print('No')

Fixed submission:
s=input()
ans=False
if s[0]==s[1]:
    if s[0]!=s[2] and s[2]==s[3]:
        ans=True
elif s[0]==s[2]:
    if s[0]!=s[1] and s[1]==s[3]:
        ans=True
elif s[0]==s[3]:
    if s[0]!=s[1] and s[1]==s[2]:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = input()
ans = Felse
if s[0] == s[1] and s[2] == s[3] :
  ans = True
if s[0] == s[2] and s[1] == s[3] :
  ans = True
if s[0] == s[3] and s[0] == s[2] :
  ans = True
if ans :
  print('Yse')
else:
  print('No')

Fixed submission:
s=input()
ans=False
if s[0]==s[1]:
    if s[0]!=s[2] and s[2]==s[3]:
        ans=True
elif s[0]==s[2]:
    if s[0]!=s[1] and s[1]==s[3]:
        ans=True
elif s[0]==s[3]:
    if s[0]!=s[1] and s[1]==s[2]:
        ans=True
if ans:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = input()
a = map(int, input().split())
ans = 0
for i in range(1:n-1):
  if a[i-1]<a[i]<a[i+1] :
    ans+=1 
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1,n-1):
  if a[i-1]<a[i]<a[i+1] or a[i-1]>a[i]>a[i+1] :
    ans+=1 
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
if N%2==0:
  print(a[N/2]-a[N/2-1])
else:
  print(0)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a.sort()
if N%2==0:
  print(a[int(N/2)]-a[int(N/2-1)])
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
ans = 0
if N%2==0:
  print(a[N]-a[N-1])
else:
  print(0)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a.sort()
if N%2==0:
  print(a[int(N/2)]-a[int(N/2-1)])
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: 
      return 1
    over = reduce(mul, range(n,n-r,-1))
    under = reduce(mul, range(1,r+1))
    return over//under

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    
      out(cmb(k-1,i-1)*cmb(n-k+1,i))

Fixed submission:
n, k = map(int, input().split())

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: 
      return 1
    over = reduce(mul, range(n,n-r,-1))
    under = reduce(mul, range(1,r+1))
    return over//under

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    if n-k+1 < i :
      print("0")
    else:
      out(cmb(k-1,i-1)*cmb(n-k+1,i))

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

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: 
      return 1
    over = reduce(mul, range(n,n-r,-1)
    under = reduce(mul, range(1,r+1))
    return over//under

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    if n-k+1 < i :
       return print('0')
    else out(cmb(k-1,i-1)*cmb(n-k+1,i))

Fixed submission:
n, k = map(int, input().split())

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: 
      return 1
    over = reduce(mul, range(n,n-r,-1))
    under = reduce(mul, range(1,r+1))
    return over//under

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    if n-k+1 < i :
      print("0")
    else:
      out(cmb(k-1,i-1)*cmb(n-k+1,i))

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

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: 
      return 1
    over = reduce(mul, range(n,n-r,-1)
    under = reduce(mul, range(1,r+1))
    return over//under

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    if n-k+1 < 1 :
       return 0
    else out(cmb(k-1,i-1)*cmb(n-k+1,i))

Fixed submission:
n, k = map(int, input().split())

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: 
      return 1
    over = reduce(mul, range(n,n-r,-1))
    under = reduce(mul, range(1,r+1))
    return over//under

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    if n-k+1 < i :
      print("0")
    else:
      out(cmb(k-1,i-1)*cmb(n-k+1,i))
Buggy python submission (verdict: Runtime Error):
l=list(map(int,input().split()))
for i in range(5):
  if l[i]==0:
    print(i+1)
    eixt()

Fixed submission:
l=list(map(int,input().split()))
for i in range(5):
  if l[i]==0:
    print(i+1)
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
from itertools import accumulate
import numpy as np
def main():
  n,k=map(int,input().split())
  a=np.array(list(map(int,input().split())))
  k=k if k<50 else 50
  for _ in range(k):
    b=np.zeros(n+1,dtype=int)
    for i in range(n):
      ai=a[i]
      l,r=i-ai,i+ai+1
      l=0 if l<0 else l
      r=n if r>n else r
      b[l]+=1
      b[r]-=1
    b=tuple(accumulate(b))[:-1]
    a=b
    if min(set(b))==n:
      break
  print(*a)
if __name__ == '__main__':
  main()

Fixed submission:
import sys
input=sys.stdin.readline
from itertools import accumulate
def main():
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  k=k if k<50 else 50
  for _ in range(k):
    b=[0]*(n+1)
    for i in range(n):
      ai=a[i]
      l,r=i-ai,i+ai+1
      l=0 if l<0 else l
      r=n if r>n else r
      b[l]+=1
      b[r]-=1
    b=tuple(accumulate(b))[:-1]
    a=b
    if min(set(b))==n:
      break
  print(*a)
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  import numpy as np
  n,k=map(int,input().split())
  a=np.array(list(map(int,input().split())))
  k=k if k<50 else 50
  for _ in range(k):
    b=np.zeros(n+1,dtype=int)
    for i in range(n):
      ai=a[i]
      l=0 if i-ai<0 else i-ai
      r=n if i+ai+1>n else i+ai+1
      b[l]+=1
      b[r]-=1
    for i in range(n-1):
      b[i+1]+=b[i]
    a=b[:-1]
    if min(a)==n:
      break
  print(*a)
if __name__=='__main__':
  main()

Fixed submission:
import sys
input=sys.stdin.readline
from itertools import accumulate
def main():
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  k=k if k<50 else 50
  for _ in range(k):
    b=[0]*(n+1)
    for i in range(n):
      ai=a[i]
      l,r=i-ai,i+ai+1
      l=0 if l<0 else l
      r=n if r>n else r
      b[l]+=1
      b[r]-=1
    b=tuple(accumulate(b))[:-1]
    a=b
    if min(set(b))==n:
      break
  print(*a)
if __name__ == '__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,m=map(int,input().split())
ab=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  ab[a].append(b)
  ab[b].append(a)
l,ll=deque([1]),deque([])
ans=[-1]*n
while l:
  x=l.popleft()
  ll.append(x)
  for i in ab[x]:
    if i in ll:
      continue
    if i in l:
      continue
    l.append(i)
    ans[i-1]=x
print('Yes')
for i in ans[1:]:
  print(i) 

Fixed submission:
def main():
  from collections import deque
  n,m=map(int,input().split())
  ab=[[] for _ in range(n+1)]
  for _ in range(m):
    a,b=map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)
  
  l=deque([1])
  ans=[-1]*n
  while l:
    x=l.popleft()
    for i in ab[x]:
      if ans[i-1]==-1:
        ans[i-1]=x
        l.append(i)
  print('Yes')
  for i in ans[1:]:
    print(i) 
    
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,m=map(int,input().split())
ab=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  ab[a].append(b)
  ab[b].append(a)
if not ab[1]:
  print('No')
  exit()
l,ll=deque([1]),deque([])
ans=[-1]*n
while l:
  x=l.popleft()
  ll.append(x)
  for i in ab[x]:
    if i in ll:
      continue
    if i in l:
      continue
    l.append(i)
    ans[i-1]=x
if all(i>=0 for i in ans[1:]):
  print('Yes')
  for i in ans[1:]:
    print(i) 
else:
  print('No')

Fixed submission:
def main():
  from collections import deque
  n,m=map(int,input().split())
  ab=[[] for _ in range(n+1)]
  for _ in range(m):
    a,b=map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)
  
  l=deque([1])
  ans=[-1]*n
  while l:
    x=l.popleft()
    for i in ab[x]:
      if ans[i-1]==-1:
        ans[i-1]=x
        l.append(i)
  print('Yes')
  for i in ans[1:]:
    print(i) 
    
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,m=map(int,input().split())
ab=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  ab[a].append(b)
  ab[b].append(a)
l,ll=deque([1]),deque([])
ans=[-1]*n
while l:
  x=l.popleft()
  ll.append(x)
  for i in ab[x]:
    if i in ll:
      continue
    if i in l:
      continue
    l.append(i)
    ans[i-1]=x
if all(i>=0 for i in ans[1:]):
  print('Yes')
  for i in ans[1:]:
    print(i) 
else:
  print('No')

Fixed submission:
def main():
  from collections import deque
  n,m=map(int,input().split())
  ab=[[] for _ in range(n+1)]
  for _ in range(m):
    a,b=map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)
  
  l=deque([1])
  ans=[-1]*n
  while l:
    x=l.popleft()
    for i in ab[x]:
      if ans[i-1]==-1:
        ans[i-1]=x
        l.append(i)
  print('Yes')
  for i in ans[1:]:
    print(i) 
    
if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  n=int(input())
  a=[0]+list(map(int,input().split()))
  ans=0
  for i in range(1,n):
    if a[i]<n-i:
      for j in range(i+1,n+1):
        if j-i==a[i]+a[j]:
          ans+=1
  print(ans)
if __name__=='__main__':
  main()

Fixed submission:
def main():
  import bisect
  n=int(input())
  a=list(map(int,input().split()))
  b=[a[i]+i+1 for i in range(n)]
  c=[i+1-a[i] for i in range(n)]
  b.sort()
  c.sort()
  ans=0
  for i in b:
    x=bisect.bisect_left(c,i)
    y=bisect.bisect_right(c,i)
    z=y-x
    ans+=z
  print(ans)
if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  s=input()
  l=len(s)
  mod=2019
  x=[0]*l
  x[0]=(int(s[0])*(pow(10,l-1)))%mod
  for i in range(1,l):
    x[i]=((int(s[i])*(pow(10,l-i-1)))%mod+x[i-1])%mod
  cnt=x.count(0)
  print(l-len(set(x))+cnt)
if __name__=='__main__':
  main()

Fixed submission:
def main():
  s=input()[::-1]
  l,mod=len(s),2019
  x=[0]*mod
  x[0]=1
  a,t=0,1
  for i in range(l):
    a = (a + int(s[i])*t) % 2019
    x[a]+=1
    t=(t*10)%mod
  ans=sum([i*(i-1)//2 for i in x])
  print(ans)
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
mod=2019
x=[(int(s[i])*(pow(10,l-i-1)))%2019 for i in range(l)]
y=[0]*l
y[0]=x[0]%mod
for i in range(1,l):
  y[i]=(y[i-1]+x[i])%mod
cnt=y.count(0)
print(l-len(set(y))+cnt)

Fixed submission:
def main():
  s=input()[::-1]
  l,mod=len(s),2019
  x=[0]*mod
  x[0]=1
  a,t=0,1
  for i in range(l):
    a = (a + int(s[i])*t) % 2019
    x[a]+=1
    t=(t*10)%mod
  ans=sum([i*(i-1)//2 for i in x])
  print(ans)
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
ans=0
for i in range(l-3):
  for j in range(i+3,l):
    if int(s[i:j+1])%2019==0:
      ans+=1
print(ans)

Fixed submission:
def main():
  s=input()[::-1]
  l,mod=len(s),2019
  x=[0]*mod
  x[0]=1
  a,t=0,1
  for i in range(l):
    a = (a + int(s[i])*t) % 2019
    x[a]+=1
    t=(t*10)%mod
  ans=sum([i*(i-1)//2 for i in x])
  print(ans)
if __name__=='__main__':
  main()
Buggy python submission (verdict: Runtime Error):
x,y,z=input().split()
print(' '.join[z,x,y])


Fixed submission:
x,y,z=input().split()
print(' '.join([z,x,y]))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=tuple(map(int,input().split()))
b=[0]*n
x=0
for i in set(a):
  b[i-1]=a.count(i)
  x+=(b[i-1]*(b[i-1]-1))//2
for i in a:
  y=b[i-1]-1
  print(x-y if x>=y else 0)

Fixed submission:
def main():
  from collections import Counter
  n=int(input())
  a,b=tuple(map(int,input().split())),[0]*n
  c=Counter(a)
  x=0
  for i in set(a):
    b[i-1]=c[i]
    x+=(b[i-1]*(b[i-1]-1))//2
  b=tuple(b)
  for i in a:
    y=b[i-1]-1
    print(x-y if x>=y else 0)
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
x=sum([(a.count(i)*(a.count(i)-1))//2 for i in set(a)])
for i in a:
  y=a.count(i)-1
  print(max(0,x-y))

Fixed submission:
def main():
  from collections import Counter
  n=int(input())
  a,b=tuple(map(int,input().split())),[0]*n
  c=Counter(a)
  x=0
  for i in set(a):
    b[i-1]=c[i]
    x+=(b[i-1]*(b[i-1]-1))//2
  b=tuple(b)
  for i in a:
    y=b[i-1]-1
    print(x-y if x>=y else 0)
if __name__=='__main__':
  main()
Buggy python submission (verdict: Runtime Error):
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  sc=[list(map(int,input().split())) for _ in range(m)]
  sc=sorted(sc,key=lambda x: (x[0],x[1]))
  l=[0.0]*n
  if n==1:
    if sc[0][1]==sc[-1][1]:
      print(sc[0][1])
      exit()
    else:
      print(-1)
      exit()
  for i in range(len(sc)):
    if type(l[sc[i][0]-1])==float:
      l[sc[i][0]-1]=sc[i][1]
    else:
      if l[sc[i][0]-1]!=sc[i][1]:
        print(-1)
        exit()
  if len(''.join([str(int(i)) for i in l]))==n and int(''.join([str(int(i)) for i in l]))>=pow(10,n-1):
    print(int(''.join([str(int(i)) for i in l])))
  else:
    print(-1)
  
if __name__ == '__main__':
    main()

Fixed submission:
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  if m==0:
    if n==1:
      print(0)
      exit()
    else:
      print(pow(10,n-1))
      exit()
  sc=[list(map(int,input().split())) for _ in range(m)]
  sc=list(map(list, set(map(tuple, sc))))
  sc=sorted(sc,key=lambda x: (x[0],x[1]))
  if len(sc)>n:
    print(-1)
    exit()
  l=['0']*n
  l[0]='1'
  if n==1:
    if sc[0][0]==1:
      print(sc[0][1])
      exit()
    else:
      print(-1)
      exit()
  for i in range(len(sc)):
    if type(l[sc[i][0]-1])==str:
      l[sc[i][0]-1]=sc[i][1]
    else:
      if l[sc[i][0]-1]!=sc[i][1]:
        print(-1)
        exit()
  if len(''.join([str(int(i)) for i in l]))==n and int(''.join([str(int(i)) for i in l]))>=pow(10,n-1):
    print(int(''.join([str(int(i)) for i in l])))
  else:
    print(-1)
  
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
s=input()
l=len(s)
print(x*l)

Fixed submission:
s=input()
l=len(s)
print('x'*l)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=sorted(list(map(int,input().split())))
ans=0
for i in range(k):
  ans+=h[i]
print(ans)

Fixed submission:
n,k=map(int,input().split())
h=sorted(list(map(int,input().split())))
ans=0
if k>=n:
  print(0)
else:
  for i in range(n-k):
    ans+=h[i]
  print(ans)
Buggy python submission (verdict: Runtime Error):
from sympy import nextprime
x=int(input())
print(nextprime(x))

Fixed submission:
x=int(input())
import math

def is_prime(n):
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
for i in range(x,10**6):
  if is_prime(i)==True:
    print(i)
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  n=int(input())
  l=sorted(list(map(int,input().split())))
  ans=0
  for a in range(n-2):
    for b in range(a+1,n-1):
      p,q=l[a]+l[b],l[b+1:]
      ans+=sum(x<p for x in q)
  print(ans)
if __name__=='__main__':
  main()

Fixed submission:
def main():
  import bisect
  n=int(input())
  l=sorted(list(map(int,input().split())))
  ans=0
  for a in range(n-2):
    for b in range(a+1,n-1):
      ans+=bisect.bisect_left(l,l[a]+l[b])-b-1
  print(ans)
if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  import bisect
  n,m = map(int,input().split())
  a = sorted(list(map(int,input().split())))
  for _ in range(m):
    x= a.pop(-1)/2
    index = bisect.bisect_left(a, x) 
    a.insert(index, x)
  print(int(sum(i//1 for i in a)))
if __name__=='__main__':
  main()

Fixed submission:
def main():
  import heapq
  n,m = map(int,input().split())
  a =sorted(list(map(lambda x: int(x)*(-1),input().split())))
  heapq.heapify(a)
  for _ in range(m):
    x=heapq.heappop(a)/2
    heapq.heappush(a,x) 
  print(int(sum((-1)*i//1 for i in a)))
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
for i in range(m):
  a[-1] = a[-1] / 2
  a = sorted(a)
print(int(sum( i//1 for i in a)))

Fixed submission:
def main():
  import heapq
  n,m = map(int,input().split())
  a =sorted(list(map(lambda x: int(x)*(-1),input().split())))
  heapq.heapify(a)
  for _ in range(m):
    x=heapq.heappop(a)/2
    heapq.heappush(a,x) 
  print(int(sum((-1)*i//1 for i in a)))
if __name__=='__main__':
  main()

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = a.sort()
for i in range(m):
  a[-1] = a[-1]*0.5
  a = a.sort()
sum( i//1 for i in a)

Fixed submission:
def main():
  import heapq
  n,m = map(int,input().split())
  a =sorted(list(map(lambda x: int(x)*(-1),input().split())))
  heapq.heapify(a)
  for _ in range(m):
    x=heapq.heappop(a)/2
    heapq.heappush(a,x) 
  print(int(sum((-1)*i//1 for i in a)))
if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))
a,m = 0,0
for i in range(n-1):
  if m < n-i:
    for j in range(i+1,n):
      if h[j-1] >= h[j]:
        a += 1
        if j == n-1:
          m = max(m,a)
          a = 0
      else:
        i = i + a + 1
        m = max(m,a)
        a = 0
        break
print(m)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))

count,m = 0,0

for i in range(n-1):
  if h[i] >= h[i+1]:
    count += 1
  else:
    m = max(m,count)
    count = 0
m = max(m,count)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))
a,m = 0,0
for i in range(n-1):
  if m < n-i:
    for j in range(i+1,n):
      if h[j-1] >= h[j]:
        a += 1
        if j == n-1:
          m = max(m,a)
          a = 0
      else:
        m = max(m,a)
        a = 0
        break
print(m)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))

count,m = 0,0

for i in range(n-1):
  if h[i] >= h[i+1]:
    count += 1
  else:
    m = max(m,count)
    count = 0
m = max(m,count)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))
a,m = 0,0
for i in range(n-1):
  for j in range(i+1,n):
    if h[j-1] >= h[j]:
      a += 1
      if j == n-1:
        m = max(m,a)
        a = 0
    else:
      m = max(m,a)
      a = 0
      break
print(m)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))

count,m = 0,0

for i in range(n-1):
  if h[i] >= h[i+1]:
    count += 1
  else:
    m = max(m,count)
    count = 0
m = max(m,count)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))
count = [0]*n
for i in range(n-1):
  for j in range(i+1,n):
    if h[j-1] >= h[j]:
      count[i] += 1
    else:
      break

m = max(count)
print(m)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))

count,m = 0,0

for i in range(n-1):
  if h[i] >= h[i+1]:
    count += 1
  else:
    m = max(m,count)
    count = 0
m = max(m,count)
print(m)