Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
T,X,Y=0,0,0


for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        print('No')
        exit()
    T,X,Y=t,x,y
print('Yes')

Fixed submission:
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
if count==N:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=int(input())
T,X,Y=0,0,0


for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        print('No')
        sys.exit()
    T,X,Y=t,x,y
print('Yes')


Fixed submission:
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
if count==N:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=int(input())
T,X,Y=0,0,0

a='Yes'
for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        a='No'
        break
    T,X,Y=t,x,y
print('{}'.format(a))

Fixed submission:
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
if count==N:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=int(input())
T,X,Y=0,0,0

a='Yes'
for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        a='No'
        break
    T,X,Y=t,x,y
print(a)


Fixed submission:
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
if count==N:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=int(input())
T,X,Y=0,0,0

for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        print('No')
        break
    T,X,Y=t,x,y
print('Yes')

Fixed submission:
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
if count==N:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import numpy as np

def how_many_times_divisibles(j):
	counter=0
	while j%2==0:
		j/=2
		counter+=1
	return counter

n=int(input())
a=map(int,input().split())
ans=min(map(how_many_times_divisibles,a))
print(ans)

Fixed submission:
s=input()
counter=0

for n in range(3):
  if int(s[n])==1:
    counter+=1

print(counter)

Buggy python submission (verdict: Runtime Error):
s=int(input())
counter=0
for n in range(3):
  if s[n]==1:
    counter+=1

print(counter)

Fixed submission:
s=input()
counter=0

for n in range(3):
  if int(s[n])==1:
    counter+=1

print(counter)
Buggy python submission (verdict: Runtime Error):


def how_many_times_divisibles(j):
	counter=0
	while j%2==0:
		j/=2
		counter+=1
	return counter

n=int(input())
a=map(int,input().split())
ans=min(map(how_many_times_dibishibles,a))

print(ans)

Fixed submission:
import numpy as np

def how_many_times_divisibles(j):
	counter=0
	while j%2==0:
		j/=2
		counter+=1
	return counter

n=int(input())
a=map(int,input().split())
ans=min(map(how_many_times_divisibles,a))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
counter=0

for x in range(k+1):
	for y in range(k+1):
		for z in range(k+1):
			if x+y+z==s:
				counter+=1

print(counter)


Fixed submission:
k,s=map(int,input().split())
counter=0

for x in range(k+1):
	for y in range(k+1):
		if 0<=s-x-y<=k:
			counter+=1

print(counter)
Buggy python submission (verdict: Runtime Error):
import math

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

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  ans = ans *  math.pow(d_count[i], d_count[i+1])
  ans = ans % 998244353

ans = ans % 998244353

print(int(ans))

Fixed submission:
n = int(input())

ans = (n-1)//2

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

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

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  ans = ans *  math.pow(d_count[i], d_count[i+1])
  ans = ans % 998244353

ans = ans % 998244353

print(int(ans))


Fixed submission:
import math

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

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  for j in range(d_count[i+1]):
    ans = ans * d_count[i]
    ans = ans % 998244353

ans = ans % 998244353

print(int(ans))

Buggy python submission (verdict: Runtime Error):
import math

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

print(len(d))
print(d[n-1])

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  ans = ans *  math.pow(d_count[i], d_count[i+1])
  ans = ans % 998244353

ans = ans % 998244353

print(int(ans))

Fixed submission:
import math

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

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  for j in range(d_count[i+1]):
    ans = ans * d_count[i]
    ans = ans % 998244353

ans = ans % 998244353

print(int(ans))

Buggy python submission (verdict: Runtime Error):
import math

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

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  ans = ans *  math.pow(d_count[i], d_count[i+1])

ans = ans % 998244353

print(int(ans))

Fixed submission:
import math

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

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  for j in range(d_count[i+1]):
    ans = ans * d_count[i]
    ans = ans % 998244353

ans = ans % 998244353

print(int(ans))
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)

if n == 1:
  p = 1
else:
  p = n//2
d = 0
for i in range(p):
  if s[2*i] == "L" or s[2*i+1] == "R":
    print("No")
    d = 1
    break

if d == 0:
  print("Yes")

Fixed submission:
s = input()
n = len(s)

k = s[0::2]
g = s[1::2]

d = 0

for i in range(len(k)):
  if k[i] == "L":
    print("No")
    d = 1
    break

if d == 0:
  for i in range(len(g)):
    if g[i] == "R":
      print("No")
      d = 1
      break
if d == 0:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int, input().split()))
y = 0
x = 0
for i in range(n-1):
  if x > y:
        y = x
  x = 0
  for j in range(n-i-1):
    if h[i+j] >= h[i+j+1]:
      x += 1
    else:
      break
print(y)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
y = 0
x = 0
for i in range(n-1):
  if h[i] >= h[i+1]:
      x += 1
      if x > y:
        y = x
  else:
      x = 0
print(y)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
for i in range(0,n):
    l.append(sorted(input()))

s = 0
for i in range(n-1):
  for k in range(i+1,n):
    if l[i] == l[k]:
      s +=1
 
print(s)

Fixed submission:
n = int(input())
 
l = []
for i in range(n):
	l.append(sorted(str(input())))
 
d = sorted(l)
c = 0
ans = 0
for i in range(n-1):
	if d[i] == d[i+1]:
		c += 1
		ans += c
	else:
		c = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = list(map(int, input().split()))
d = 0

for i in range(N-1):
  if l[i] - l[i+1] >= 2:
    d = 1
  else l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] == 1:
        d = 1
        break

if d == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
d = 0

for i in range(N-1):
  if l[i] - l[i+1] >= 2:
    d = 1

for i in range(N-2):
  if l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] <= -1:
        break
      if l[j] - l[j+1] == 0:
        continue
      if l[j] - l[j+1] == 1:
        d = 1
        break

if d == 0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))
d = 0
for i in range(N-1):
  if l[i] - l[i+1] >= 2:
    d = 1

for i in range(N-1):
  if l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] == 1:
        d = 1

if d == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
d = 0

for i in range(N-1):
  if l[i] - l[i+1] >= 2:
    d = 1

for i in range(N-2):
  if l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] <= -1:
        break
      if l[j] - l[j+1] == 0:
        continue
      if l[j] - l[j+1] == 1:
        d = 1
        break

if d == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
list = [int(i) for i in input().split()]
score == 0
for i in range(N):
    if list[i] != i+1:
        score += 1
if score == 0 or 2:
    print("YES")
else:
    print("NO")

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
score = 0
for i in range(N):
  if not l[i] == i+1:
    score += 1
if score  ==0 or score ==2:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
N = int(input())
list = [int(i) for i in input().split()]
score == 0
for i in range(N):
    if list[i] != i+1:
        score =+ 1
if score == 0 or 2:
    print("YES")
else:
    print("NO")

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
score = 0
for i in range(N):
  if not l[i] == i+1:
    score += 1
if score  ==0 or score ==2:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
  d = A[i]
  A[i] = 0
  print(max(A))
  A[i] = d

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A)
for a in A:
  if a == B[-1]:
    print(B[-2])
  else:
    print(B[-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

mark = 0
dekiru_f = True

while dekiru_f:
	if len(S) == 1:
		break
	elif S[mark] == S[mark+1]:
		S = S.replace("{}{}".format(S[mark], S[mark+1]), "{}".format(S[mark]))
	elif S[mark] != S[mark+1]:
		mark += 1
		l = len(S)
		if mark == l-1:
			dekiru_f = False
		else:
			continue

print(len(S))


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

cnt = 0
for i in range(N-1):
	if S[i] == S[i+1]:
		cnt += 1

print(N - cnt)
Buggy python submission (verdict: Runtime Error):
import sys

A,B = map(int,input().split())

for _ in range(1,10000):
    if( (A-1)*(_-1)+A >= B):
        print(_)
        break


Fixed submission:
S = list(input())
T = list(input())

count = 0

for i in range(3):
    if(S[i] == T[i]):count = count + 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())

H = list(map(int,input().split()))

max = 0
for i in range(N):
    count = 0
    for j in range(i+1,N):
        #print('i',i,' j',j,' H[j-1]', H[j-1], ' H[j]', H[j])
        if(H[j-1] >= H[j]):
            count = count+1
            if(count > max): max = count
        else:
            break

print(max)


Fixed submission:
import sys

N = int(input())

H = list(map(int,input().split()))

max = 0
count = 0
for i in range(N-1):
    if(H[i] >= H[i+1]):
        count = count+1
        if(max < count): max = count
    else:
        count = 0
print(max)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())

max = 0
for _ in range(1,N):
    max = max + _
print(max)


Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()

lr = [list(map(int,input().split())) for _ in range(Q)]

#print(N,Q,S)
#print(lr)

#print(S[0:5])

CC=[]
for _ in range(1,N+1):
    CC.append(S[0:_].count('AC'))

#print(CC)

for _ in range(Q):
    l = lr[_][0]
    r = lr[_][1]

    print(CC[r-1]-CC[l-1])

#for _ in range(Q):
#    l = lr[_][0]
#    r = lr[_][1]
    #print(_,S[0:r],S[0:(l-1)])
    #print(S[0:r].count('AC')-S[0:l].count('AC'))
    #print(_,S[l-1:r])
#    print(S[l-1:r].count('AC'))


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

lr = [list(map(int,input().split())) for _ in range(Q)]

#print(N,Q,S)
#print(lr)

#print(S[0:5])

CC=[0]
for _ in range(1,N):
    if (S[_-1:_+1] == 'AC'):
        CC.append(CC[_-1]+1)
    else:
        CC.append(CC[_-1])

    #CC.append(S[0:_].count('AC'))

#print(CC)

for _ in range(Q):
    l = lr[_][0]
    r = lr[_][1]

    print(CC[r-1]-CC[l-1])

#for _ in range(Q):
#    l = lr[_][0]
#    r = lr[_][1]
    #print(_,S[0:r],S[0:(l-1)])
    #print(S[0:r].count('AC')-S[0:l].count('AC'))
    #print(_,S[l-1:r])
#    print(S[l-1:r].count('AC'))

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

lr = [list(map(int,input().split())) for _ in range(Q)]

#print(N,Q,S)
#print(lr)

#print(S[0:5])

for _ in range(Q):
    l = lr[_][0]
    r = lr[_][1]
    #print(_,S[0:r],S[0:(l-1)])
    #print(S[0:r].count('AC')-S[0:l].count('AC'))
    #print(_,S[l-1:r])
    print(S[l-1:r].count('AC'))


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

lr = [list(map(int,input().split())) for _ in range(Q)]

#print(N,Q,S)
#print(lr)

#print(S[0:5])

CC=[0]
for _ in range(1,N):
    if (S[_-1:_+1] == 'AC'):
        CC.append(CC[_-1]+1)
    else:
        CC.append(CC[_-1])

    #CC.append(S[0:_].count('AC'))

#print(CC)

for _ in range(Q):
    l = lr[_][0]
    r = lr[_][1]

    print(CC[r-1]-CC[l-1])

#for _ in range(Q):
#    l = lr[_][0]
#    r = lr[_][1]
    #print(_,S[0:r],S[0:(l-1)])
    #print(S[0:r].count('AC')-S[0:l].count('AC'))
    #print(_,S[l-1:r])
#    print(S[l-1:r].count('AC'))

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

lr = [list(map(int,input().split())) for _ in range(Q)]

#print(N,Q,S)
#print(lr)

#print(S[0:5])

for _ in range(Q):
    l = lr[_][0]
    r = lr[_][1]
    #print(_,S[0:r],S[0:(l-1)])
    print(S[0:r].count('AC')-S[0:l].count('AC'))

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

lr = [list(map(int,input().split())) for _ in range(Q)]

#print(N,Q,S)
#print(lr)

#print(S[0:5])

CC=[0]
for _ in range(1,N):
    if (S[_-1:_+1] == 'AC'):
        CC.append(CC[_-1]+1)
    else:
        CC.append(CC[_-1])

    #CC.append(S[0:_].count('AC'))

#print(CC)

for _ in range(Q):
    l = lr[_][0]
    r = lr[_][1]

    print(CC[r-1]-CC[l-1])

#for _ in range(Q):
#    l = lr[_][0]
#    r = lr[_][1]
    #print(_,S[0:r],S[0:(l-1)])
    #print(S[0:r].count('AC')-S[0:l].count('AC'))
    #print(_,S[l-1:r])
#    print(S[l-1:r].count('AC'))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import xor

A, B = map(int,input().split())

def main():
    val = []
    for i in range(A,B+1):
        val.append(i)
    #print(val)
    ans = reduce(xor,val)
    #print(ans)
    return ans

print(main())


Fixed submission:
from functools import reduce
from operator import xor

A, B = map(int,input().split())


def calc(A):
    A = A+1
    cnt = 0
    ans = 0
    for i in range(0,50):
        # i=0 2回周期で1が出現
        # i=1 4回周期で1が出現
        loop = pow(2,i+1)

        #端数を覗いた2の出現回数
        #Aが6 / iが1のときは loop=4
        # 7//4 = 1 * 2^1 = 2
        cnt = (A//loop)*pow(2,i)

        # 端数を計算
        # 7%4 - 4/2 = 3-2 = 1
        # 端数は1なので加算
        if((A%loop - loop//2) > 0):
            cnt = cnt + (A%loop - loop//2)

        # cntが奇数の場合は ans 2^iをに加算
        if(cnt%2 == 1):
            ans = ans + pow(2,i)

    return ans



def main():
    return calc(A-1)^calc(B)

print(main())

Buggy python submission (verdict: Runtime Error):
from functools import reduce
from operator import xor

A, B = map(int,input().split())

def main():
    val = []
    for i in range(A,B+1):
        val.append(i)
        print(val)
    ans = reduce(xor,val)
    return ans

print(main())

Fixed submission:
from functools import reduce
from operator import xor

A, B = map(int,input().split())


def calc(A):
    A = A+1
    cnt = 0
    ans = 0
    for i in range(0,50):
        # i=0 2回周期で1が出現
        # i=1 4回周期で1が出現
        loop = pow(2,i+1)

        #端数を覗いた2の出現回数
        #Aが6 / iが1のときは loop=4
        # 7//4 = 1 * 2^1 = 2
        cnt = (A//loop)*pow(2,i)

        # 端数を計算
        # 7%4 - 4/2 = 3-2 = 1
        # 端数は1なので加算
        if((A%loop - loop//2) > 0):
            cnt = cnt + (A%loop - loop//2)

        # cntが奇数の場合は ans 2^iをに加算
        if(cnt%2 == 1):
            ans = ans + pow(2,i)

    return ans



def main():
    return calc(A-1)^calc(B)

print(main())
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))
l=sorted(L,reverse=True)
ans=0
for i in range(N):
    c=l[i]
    for j in range(i+1,N):
        b=l[j]
        for k in range(j+1,N):
            a=l[k]
            if a+b>c:
                ans+=1
            else:
                break
print(ans)

Fixed submission:
import bisect
N=int(input())
L=list(map(int,input().split()))
l=sorted(L)
result=0
for i in range(N-2):
    for j in range(i+1,N-1):
        result+=bisect.bisect_left(l,l[i]+l[j])-j-1
print(result)
Buggy python submission (verdict: Runtime Error):
N,K,Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
B = [0 for i in range(N)]
for i in range(Q):
    j=A[i]-1
    B[j]+=1
for j in range(N):
    if K - Q + B[i]>0:
        print('Yes')
    else :
        print('NO')

Fixed submission:
N, K, Q = map(int, input().split(" "))    # N:人数, K:初期スコア, Q:問題数
A = [int(input()) for i in range(Q)]    # 正解者のリスト
B = [0 for i in range(N)]    # 各人の正解数

for i in range(Q):
    num_ans_person = A[i] - 1
    B[num_ans_person] += 1

# 得点は, 最初の点数 - 他人の正解数
# 他人の正解数は, 問題数 - 自分の正解数
# 得点は, 最初の点数 - 問題数 + 自分の正解数
# 得点 > 0 であれば, "Yes"
for i in range(N):
    if K - Q + B[i] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
    import sys
     
    s = sys.stdin.read().strip()
    c = 0
    l = len(s)
    for i in range(int(l/2)):
      if s[i] != s[l-i-1]:
        c += 1
    print(c)

Fixed submission:
import sys

s = sys.stdin.read().strip()
c = 0
l = len(s)
for i in range(int(l/2)):
  if s[i] != s[l-i-1]:
    c += 1
print(c)

Buggy python submission (verdict: Runtime Error):
import sys

s = sys.stdin()
c = 0
l = len(s)
for i in range(l/2):
  if s[0] != s[l-i]:
    c += 1
print(c)

Fixed submission:
import sys

s = sys.stdin.read().strip()
c = 0
l = len(s)
for i in range(int(l/2)):
  if s[i] != s[l-i-1]:
    c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_right
N = int(input())
D = list(map(int, input().split()))
D.sort(reverse=False)

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        l = D[:N - j - 1]
        ind = bisect_right(D, D[i] + D[j] - 1)
        count += max(ind - j - 1, 0)

print(count)


Fixed submission:
D = input().split(' ')
A = int(D[0])
B = int(D[1])

res = A - B * 2

if res < 0:
    res = 0

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right
N = int(input())
D = list(map(int, input().split()))
D.sort(reverse=False)

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        l = D[:N - j - 1]
        ind = bisect_right(D, D[i] + D[j] - 1)
        count += max(ind - j - 1, 0)

print(count)


Fixed submission:
from bisect import bisect_right
N = int(input())
D = list(map(int, input().split()))
D.sort(reverse=False)

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        # target = int(D[N - i - 1]) - int(D[N - j - 1])
        # l = D[:N - j - 1]
        # count += len(l) - bisect_right(l, target)
        ind = bisect_right(D, D[i] + D[j] - 1)
        count += max(ind - j - 1, 0)

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right
N = int(input())
D = list(map(int, input().split()))
D.sort(reverse=False)

count = 0

for i in range(N):
    for j in range(i + 1, N - 1):
        target = int(D[N - i - 1]) - int(D[N - j - 1])
        l = D[:N - j - 1]
        count += len(l) - bisect_right(l, target)

print(count)


Fixed submission:
from bisect import bisect_right
N = int(input())
D = list(map(int, input().split()))
D.sort(reverse=False)

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        # target = int(D[N - i - 1]) - int(D[N - j - 1])
        # l = D[:N - j - 1]
        # count += len(l) - bisect_right(l, target)
        ind = bisect_right(D, D[i] + D[j] - 1)
        count += max(ind - j - 1, 0)

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split(' ')

t = []
for i in range(N):
    t.append(0)

for i in range(N):
    t[int(A[i]) - 1] = i + 1

res = ''
for i in range(N):
    res = res + str(t[i]) + ' '

print(res.strip())


Fixed submission:
N = int(input())
A = input().split(' ')

t = []
for i in range(N):
    t.append(0)

for i in range(N):
    t[int(A[i]) - 1] = str(i + 1)

print(' '.join(t))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split(' ')

c = {}
for i in range(N):
    c.update({str(A[i]): i + 1})

res = ''

for i in range(1, N + 1):
    res = res + str(c[str(i)]) + ' '

print(res.strip())


Fixed submission:
N = int(input())
A = input().split(' ')

t = []
for i in range(N):
    t.append(0)

for i in range(N):
    t[int(A[i]) - 1] = str(i + 1)

print(' '.join(t))
Buggy python submission (verdict: Runtime Error):
d = input().split(' ')
h = d[0]
w = d[1]
a = d[2]
b = d[3]

s1 = ''
s2 = ''
for j in range(h):
  if j < a:
    s1 = s1 + '1'
    s2 = s2 + '0'
  else:
    s1 = s1 + '0'
    s2 = s2 + '1'

k = []
for i in range(w):
  if i < b:
    print(s1)
  else:
    print(s2)

Fixed submission:
d = input().split(' ')
w = int(d[0])
h = int(d[1])
a = int(d[2])
b = int(d[3])

s1 = ''
s2 = ''
for j in range(h):
  if j < a:
    s1 = s1 + '1'
    s2 = s2 + '0'
  else:
    s1 = s1 + '0'
    s2 = s2 + '1'

k = []
for i in range(w):
  if i < b:
    print(s1)
  else:
    print(s2)
Buggy python submission (verdict: Time Limit Exceeded):
D = input().split(' ')
N = int(D[0])
M = int(D[1])
D2 = input().split(' ')

A = []
for i in D2:
  A.append(int(i))

A.sort(reverse=True)

used = 0
n = 0

while True:
  A[0] = int(A[0] / 2)
  k = 0
  for k in range(N - 1):
    if A[k] < A[k + 1]:
      tmp = A[k]
      A[k] = A[k + 1]
      A[k + 1] = tmp
    else:
      break
      
  used = used + 1
  if used == M:
    break

sum = 0
for i in range(N):
  sum = sum + A[i]
  
print(sum)

Fixed submission:
D = input().split(' ')
N = int(D[0])
M = int(D[1])
D2 = input().split(' ')

A = []
for i in D2:
  A.append(int(i))

A.sort(reverse=True)

used = 0

while True:
  max = A[0]
  n = 0
  while True:
    if A[n] >= int(max / 2):
      A[n] = int(A[n] / 2)
      used = used + 1
    else:
      break
      
    n = n + 1

    if n == N or used == M:
      break
      
  if used == M:
    break
    
  A.sort(reverse=True)
    
sum = 0
for i in range(N):
  sum = sum + A[i]
  
print(sum)