Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
l2=set(l)
c=0
for i in l2:
  if i>l.count(i):
    c+=l.count(i)
  else:
    c+=l.count(i)-i
  
    
    
print(c)

Fixed submission:
from collections import defaultdict
l=defaultdict(int)
n=int(input())
l1=list(map(int,input().split()))
for i in l1:
  l[i]+=1
b=True
lset=set(l1)
answer=0
for i in lset:
  if l[i]!=i:
    if l[i]<i:
      answer+=l[i]
    else:
      answer+=min(l[i]-i,l[i])
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
l1=set(l)
c=0
for i in l1:
  if l.count(i)>=i:
    c+=l.count(i)-i
  else:
    c+=l.count(i)
print(c)


Fixed submission:
from collections import defaultdict
l=defaultdict(int)
n=int(input())
l1=list(map(int,input().split()))
for i in l1:
  l[i]+=1
b=True
lset=set(l1)
answer=0
for i in lset:
  if l[i]!=i:
    if l[i]<i:
      answer+=l[i]
    else:
      answer+=min(l[i]-i,l[i])
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=sorted(list(map(int,input().split())))
l1=set(l)
c=0
for i in l1:
  if l.count(i)>=i:
    c+=l.count(i)-i
  else:
    c+=l.count(i)
print(c)

Fixed submission:
from collections import defaultdict
l=defaultdict(int)
n=int(input())
l1=list(map(int,input().split()))
for i in l1:
  l[i]+=1
b=True
lset=set(l1)
answer=0
for i in lset:
  if l[i]!=i:
    if l[i]<i:
      answer+=l[i]
    else:
      answer+=min(l[i]-i,l[i])
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l=list(map(int,input().split()))
l1=[]
l2=[]
c=0
for i in l:
  if i in l1:
    l2[l1.index(i)]+=1
  else:
    l1.append(i)
    l2.append(1)
if m>=len(l2):
  print(0)
else:
  l2=sorted(l2)
  for i in range(len(l2)-m):
    c+=l2[i]
  print(c)

Fixed submission:
n,m=map(int,input().split())
l=list(map(int,input().split()))
d={}

c=0
for i in l:
  if i in d:
    d[i]+=1
  else:
    d[i]=1
l1=d.values()
if m>=len(l1):
  print(0)
else:
  l1=sorted(l1)
  for i in range(len(l1)-m):
    c+=l1[i]
  print(c)
Buggy python submission (verdict: Time Limit Exceeded):
i=input()
while True:
  if int(i[0])+int(i[1])+int(i[2])+int(i[3])==7:
    print(i[0]+"+"+i[1]+"+"+i[2]+"+"+i[3]+"="+"7")
    exit
  elif int(i[0])+int(i[1])+int(i[2])-int(i[3])==7:
    print(i[0]+"+"+i[1]+"+"+i[2]+"-"+i[3]+"="+"7")
    exit
  elif int(i[0])+int(i[1])-int(i[2])-int(i[3])==7:
    print(i[0]+"+"+i[1]+"-"+i[2]+"-"+i[3]+"="+"7")
    exit
  elif int(i[0])-int(i[1])+int(i[2])-int(i[3])==7:
    print(i[0]+"-"+i[1]+"+"+i[2]+"-"+i[3]+"="+"7")
    exit
  elif int(i[0])-int(i[1])-int(i[2])-int(i[3])==7:
    print(i[0]+"-"+i[1]+"-"+i[2]+"-"+i[3]+"="+"7")
    exit
  elif int(i[0])+int(i[1])-int(i[2])+int(i[3])==7:
    print(i[0]+"+"+i[1]+"-"+i[2]+"+"+i[3]+"="+"7")
    exit
  elif int(i[0])-int(i[1])+int(i[2])+int(i[3])==7:
    print(i[0]+"-"+i[1]+"+"+i[2]+"+"+i[3]+"="+"7")
    exit
  elif int(i[0])-int(i[1])-int(i[2])+int(i[3])==7:
    print(i[0]+"-"+i[1]+"-"+i[2]+"+"+i[3]+"="+"7")
    exit

Fixed submission:
i=input()
b=True
while b==True:
  if int(i[0])+int(i[1])+int(i[2])+int(i[3])==7:
    print(i[0]+"+"+i[1]+"+"+i[2]+"+"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])+int(i[1])+int(i[2])-int(i[3])==7:
    print(i[0]+"+"+i[1]+"+"+i[2]+"-"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])+int(i[1])-int(i[2])-int(i[3])==7:
    print(i[0]+"+"+i[1]+"-"+i[2]+"-"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])-int(i[1])+int(i[2])-int(i[3])==7:
    print(i[0]+"-"+i[1]+"+"+i[2]+"-"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])-int(i[1])-int(i[2])-int(i[3])==7:
    print(i[0]+"-"+i[1]+"-"+i[2]+"-"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])+int(i[1])-int(i[2])+int(i[3])==7:
    print(i[0]+"+"+i[1]+"-"+i[2]+"+"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])-int(i[1])+int(i[2])+int(i[3])==7:
    print(i[0]+"-"+i[1]+"+"+i[2]+"+"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])-int(i[1])-int(i[2])+int(i[3])==7:
    print(i[0]+"-"+i[1]+"-"+i[2]+"+"+i[3]+"="+"7")
    exit
    b=False
Buggy python submission (verdict: Runtime Error):
print((int((input())**(1/2)))**2)

Fixed submission:
n=int(input())
num=int((n)**(1/2))
print((num)**2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
la=sorted(list(map(int,input().split())))
lb=list(map(int,input().split()))
lc=sorted(list(map(int,input().split())))
def lower(n,l):
  left=-1
  right=len(l)
  while right>left+1:
    mid=left+right
    mid=mid//2
    if n>l[mid]:
      left=mid
    elif n<l[mid]:
      right=mid
  return left+1
def upper(n,l):
  def lower(n,l):
  left=-1
  right=len(l)
  while right>left+1:
    mid=left+right
    mid=mid//2
    if n>l[mid]:
      left=mid
    elif n<l[mid]:
      right=mid
  return len(l)-right
c=0
for i in lb:
  c+=lower(i,la)*upper(i,lb)
print(c)

Fixed submission:
import bisect
n=int(input())
la=sorted(map(int,input().split()))
lb=sorted(map(int,input().split()))
lc=sorted(map(int,input().split()))
countb=[]
count1=0
for i in range(n):
  index=bisect.bisect_left(la,lb[i])
  countb.append(index)
countb2=[]
sum=0
for i in range(n):
  sum+=countb[i]
  countb2.append(sum)
ans=0
for i in range(n):
  index=bisect.bisect_left(lb,lc[i])
  if index==0:
    pass
  else:
    ans+=countb2[index-1]
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
la=sorted(list(map(int,input().split())))
lb=sorted(list(map(int,input().split())))
lc=sorted(list(map(int,input().split())))
def nib1(x,l):
  right=len(l)-1
  left=0
  mid=(right+left)//2
  while left<=right:
    mid=(right+left)//2
    if x<l[mid]:
      right=mid-1
    elif x>l[mid]:
      left=mid+1
    else:
      return mid
  mid=(right+left)//2
  return mid
c=0 
for i in range(n):
  c+=nib1(lb[i],la)*(n-1-nib(lb[i],lc))
print(c)  

Fixed submission:
import bisect
n=int(input())
la=sorted(map(int,input().split()))
lb=sorted(map(int,input().split()))
lc=sorted(map(int,input().split()))
countb=[]
count1=0
for i in range(n):
  index=bisect.bisect_left(la,lb[i])
  countb.append(index)
countb2=[]
sum=0
for i in range(n):
  sum+=countb[i]
  countb2.append(sum)
ans=0
for i in range(n):
  index=bisect.bisect_left(lb,lc[i])
  if index==0:
    pass
  else:
    ans+=countb2[index-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
m=int(input())
num=1
for i in range(n):
  if num<k:
    num*=2
  else:
    num+=k
print(num)

Fixed submission:
n=int(input())
m=int(input())
num=1
for i in range(n):
  if num<m:
    num*=2
  else:
    num+=m
print(num)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
#n,mの偶奇で場合分け
#n,mがともに偶数の時は全部４の倍数個なきゃダメ
#n,mの片方のみ奇数の時は、例えばnが奇数の時は個数が偶数だが４の倍数でない組みがm//2組みまで許される
#n,mがともに奇数の時は個数が偶数だが４の倍数でない組みが(n+m)//2組み許され、ただ一つ奇数が必要
l=[]
for i in range(n):
  l.append(list(input()))
from collections import defaultdict
d=defaultdict(int)
for i in range(n):
  for j in range(m):
    d[l[i][j]]+=1
b=True
count2=0
count1=0
for i in d:
  if d[i]%4==0:
    pass
  elif d[i]%2==0:
    count2+=1
  else:
    if count1!=0:
      b=False
    else:
      count1=1
      index=d[i]
if not b:#奇数個あるのが２組以上
  print("No")
else:
  if n%2==0 and m%2==0:
    if count2>0 or count1>0:
      print("No")
    else:
      print("Yes")
  if n%2==0 and m%2==1:
    if count1>0 or count2>n//2:
      print("No")
    else:
      print("Yes")
  if n%2==1 and m%2==0:
    if count1>0 or count2>m//2:
      print("No")
    else:
      print("Yes")
  else:
    if (index-1)%4==2:
      count2+=1
    if count2>(n+m-2)//2:
      print("No")
    else:
      print("Yes")

Fixed submission:
n,m=map(int,input().split())
#n,mの偶奇で場合分け
#n,mがともに偶数の時は全部４の倍数個なきゃダメ
#n,mの片方のみ奇数の時は、例えばnが奇数の時は個数が偶数だが４の倍数でない組みがm//2組みまで許される
#n,mがともに奇数の時は個数が偶数だが４の倍数でない組みが(n+m)//2組み許され、ただ一つ奇数が必要
l=[]
for i in range(n):
  l.append(list(input()))
from collections import defaultdict
d=defaultdict(int)
for i in range(n):
  for j in range(m):
    d[l[i][j]]+=1
b=True
count2=0
count1=0
for i in d:
  if d[i]%4==0:
    pass
  elif d[i]%2==0:
    count2+=1
  else:
    if count1!=0:
      b=False
    else:
      count1=1
if not b:#奇数個あるのが２組以上
  print("No")
else:
  if n%2==0 and m%2==0:
    if count2>0 or count1>0:
      print("No")
    else:
      print("Yes")
  elif n%2==0 and m%2==1:
    if count1>0 or count2>n//2:
      print("No")
    else:
      print("Yes")
  elif n%2==1 and m%2==0:
    if count1>0 or count2>m//2:
      print("No")
    else:
      print("Yes")
  else:
    if (count1-1)%4==2:
      count2+=1
    if count2>(n+m-2)//2:
      print("No")
    else:
      print("Yes")
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
l=[]
for i in range(0,f//(100*a)+1):
  for j in range(0,f//(100*b)+1):
    if 100*a*i+100*b*j>=f:
      pass
    else:
      l.append(100*a*i+100*b*j)
l1=[]
del l[0]
max1=0
g=0
h=0
for i in l:
  l2=[]
  m=min(f-i,(i//100)*e)
  max2=0
  for j in range(0,m//c+1):
    for k in range(0,m//d+1):
      if j*c+k*d<=m and j*c+k*d>max2:
        max2=j*c+k*d
  if max1<100*max2/(i+max2):
    g=i
    f=max2
    max1=100*max2/(i+max2)
print(i+max2,max2)


Fixed submission:
i=int(input())
s=int(input())
print(i*i-s)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[]
for i in range(n):
  m=int(input())
  l.append(m)
c=0
d=1
e=l[0]
l=sorted(l)
for i in range(1,n):
  if l[i]!=e:
    if d%2==1:
      c+=1
    e=l[i]
    d=1
  else:
    d+=1
if d%2==1:
  c+=1
print(c)


Fixed submission:
n=list(input())
if "9" in n:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[]
for i in range(n):
  m=int(input())
  if m in l:
    del l[l.index(m)]
  else:
    l.append(m)
print(len(l))

Fixed submission:
n=int(input())
l=[]
for i in range(n):
  m=int(input())
  l.append(m)
l=sorted(l)
c=0
d=1
e=l[0]
for i in range(1,n):
  if l[i]!=e:
    if d%2==1:
      c+=1
    e=l[i]
    d=1
  else:
    d+=1
if d%2==1:
  c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
l=input()
w=""
c=1
while len(w)<len(l):
  w+=l[c]
  c+=2
print(w)
  

Fixed submission:
l=input()
w=""
c=0
while len(w)<len(l)/2:
  w+=l[c]
  c+=2
print(w)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
l1={}
l2=[]
for i in l:
  if i in l1:
    if l1[i]%2==0:
      l1[i]+=1
    else:
      l2.append(i)
      l1[i]+=1
  else:
    l1[i]=1
l2=sorted(l2)
print(l2[-1]*l2[-2])

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l1={}
l2=[]
for i in l:
  if i in l1:
    if l1[i]%2==0:
      l1[i]+=1
    else:
      l2.append(i)
      l1[i]+=1
  else:
    l1[i]=1
if len(l2)<2:
  print(0)
else:
  l2=sorted(l2)
  print(l2[-1]*l2[-2])
Buggy python submission (verdict: Runtime Error):
a1,a2,b1,b2=map(int,input().split())
print(max(min(a2,b2)-max(b1,a1),0)


Fixed submission:
a1,a2,b1,b2=map(int,input().split())
print(max(min(a2,b2)-max(b1,a1),0))
Buggy python submission (verdict: Runtime Error):
n=int(input())
t=1
import math
for i in range(n):
  j=int(input())
  t=t*j//math.gcd(t,j)
print(t)

    

Fixed submission:
n=int(input())
t=1
import fractions
for i in range(n):
  j=int(input())
  t=t*j//fractions.gcd(t,j)
print(t)
Buggy python submission (verdict: Runtime Error):
i=int(input())
for n in range(0,9):
  if 2**n=<i<2**(n+1):
    print(2**n)
    break
    

Fixed submission:
i=int(input())
for n in range(0,9):
  if 2**n<=i<2**(n+1):
    print(2**n)
    break
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l1=[]
l2=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    l1.append(b)
  if b==n:
    l2.append(a)
b=False
for i in range(2,n):
  if i in l1 and i in l2:
    b=True
if b:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")


Fixed submission:
n,m=map(int,input().split())
bs=[False for i in range(n)]
bt=[False for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  if a==1 and (b!=n):
    bs[b-1]=True
  elif a!=1 and b==n:
    bt[a-1]=True
bool1=False
for i in range(1,n-1):
  if bs[i] and bt[i]:
    bool1=True
if bool1:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
g=l[0]
max=l[0]
for i in range(1,1+n-1):
  g=gcd(g,l[i])
  if max<l[i]:
    max=l[i]
if max<k:
  print("POSSIBLE")
elif max==k:
  print("POSSIBLE")
else:
  if k%g==0:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  if n>m:
    a=n
    b=m
  else:
    a=m
    b=n
  while b!=0:
    a,b=b,a%b
  return a
g=l[0]
max=l[0]
for i in range(1,1+n-1):
  g=gcd(g,l[i])
  if max<l[i]:
    max=l[i]
if max<k:
  print("IMPOSSIBLE")
elif max==k:
  print("POSSIBLE")
else:
  if k%g==0:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
w=list(input())
for i in range(len(w)):
  del w[-1]
  del w[-1]
  if w[0:len(w)/2]==w[len(w)/2:len(w)]:
    print(len(w))
    break
  
  

Fixed submission:
w=list(input())
for i in range(len(w)):
  del w[-1]
  del w[-1]
  if w[0:len(w)//2]==w[len(w)//2:len(w)]:
    print(len(w))
    break
Buggy python submission (verdict: Runtime Error):
a,s,d=map(int,input().split())
if s-d>=0:
  print("delicious")
elif a+s-d>=-:
  print("safe")
else:
  print("dangerous")

Fixed submission:
a,s,d=map(int,input().split())
if s-d>=0:
  print("delicious")
elif a+s-d>=0:
  print("safe")
else:
  print("dangerous")
Buggy python submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
a=math.factrial(n)
b=math.factrial(m)
if n==m:
  print((2*a**2)%(10**9+7))
elif abs(n-m)==1:
  print((a*b)%(10**9+7))
else:
  print(0)

Fixed submission:
import math
n,m=map(int,input().split())
a=math.factorial(n)
b=math.factorial(m)
if n==m:
  print((2*a**2)%(10**9+7))
elif abs(n-m)==1:
  print((a*b)%(10**9+7))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
def fact(n):
  if n==1:
    return 1
  else:
    return n*fact(n-1)
n,m=map(int,input().split())
if n==m:
  print(2*(fact(n))**2%(10**9+7))
elif abs(n-m)=1:
  print(fact(n)*fact(m)%(10**9+7))
else:
  print(0)
  

Fixed submission:
import math
n,m=map(int,input().split())
a=math.factorial(n)
b=math.factorial(m)
if n==m:
  print((2*a**2)%(10**9+7))
elif abs(n-m)==1:
  print((a*b)%(10**9+7))
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
col=[False for i in range(8)]
val=0
count=0
for i in range(n):
  m=l[i]
  if m<400:
    col[0]=True
  if 400<=m<800:
    col[1]=True
  if 800<=m<1200:
    col[2]=True
  if 1200<=m<1600:
    col[3]=True
  if 1600<=m<2000:
    col[4]=True
  if 2000<=m<2400:
    col[5]=True
  if 2400<=m<2800:
    col[6]=True
  if 2800<=m<3200:
    col[7]=True
  if m>=3200:
    val+=1
for i in range(8):
  if col[i]:
    count+=1
print(count,min(8,count+val))


Fixed submission:
a,s,d=map(int,input().split())
if (10*s+d)%4==0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n=input()
l=list(map(int,input().split()))
col=[False for i in range(8)]
val=0
count=0
for i in range(n):
  m=l[i]
  if m<400:
    col[0]=True
  elif m<800:
    col[1]=True
  elif m<1200:
    col[2]=True
  elif m<1600:
    col[3]=True
  elif m<2000:
    col[4]=True
  elif m<2400:
    col[5]=True
  elif m<2800:
    col[6]=True
  elif m<3200:
    col[7]=True
  else:
    val+=1
for i in range(8):
  if col[i]:
    count+=1
print(count,min(8,count+val))

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
col=[False for i in range(8)]
val=0
count=0
for i in range(n):
  m=l[i]
  if m<400:
    col[0]=True
  if 400<=m<800:
    col[1]=True
  if 800<=m<1200:
    col[2]=True
  if 1200<=m<1600:
    col[3]=True
  if 1600<=m<2000:
    col[4]=True
  if 2000<=m<2400:
    col[5]=True
  if 2400<=m<2800:
    col[6]=True
  if 2800<=m<3200:
    col[7]=True
  if m>=3200:
    val+=1
for i in range(8):
  if col[i]:
    count+=1
print(max(1,count),count+val)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b-1]+=1
b=True
for i in range(m):
  if l[i]%2!=1:
    b=False
if b:
  print("YES")
else:
  print("NO")

Fixed submission:
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b-1]+=1
b=True
for i in range(n):
  if l[i]%2==1:
    b=False
if b:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
lo=list(input())
le=list(input())
l==""
for i in range(len(le)):
  l+=lo[i]
  l+=le[i]
if len(le)==len(lo):
  print(l)
else:
  print(l+lo[-1])

Fixed submission:
lo=list(input())
le=list(input())
l=""
for i in range(len(le)):
  l+=lo[i]
  l+=le[i]
if len(le)==len(lo):
  print(l)
else:
  print(l+lo[-1])
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
if a,b==("H","H") or a,b==("D","D"):
  print("H")
else:
  print("D")

Fixed submission:
a,b=input().split()
if (a,b)==("H","H") or (a,b)==("D","D"):
  print("H")
else:
  print("D")
Buggy python submission (verdict: Runtime Error):
n=int(input())
inport math
m=math.factorial(n)
print(m%(10**9+7))

Fixed submission:
n=int(input())
import math
m=math.factorial(n)
print(m%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n=int(input())
w1=list(input())
s="S"
w="W"
o="o"
x="x"
l=[[s,s],[s,w],[w,w],[w,s]]
for j in range(4):
    for i in range(1,n):
        if w1[i]==o:
            if l[j][-1]==s:
                if l[j][-2]==s:
                    l[j].append(s)
                else:
                    l[j].append(w)
            else:
                if l[j][-2]==s:
                    l[j].append(w)
                else:
                    l[j].append(s)
        else:
            if l[j][-1]==s:
                if l[j][-2]==s:
                    l[j].append(w)
                else:
                    l[j].append(s)
            else:
                if l[j][-2]==s:
                    l[j].append(s)
                else:
                    l[j].append(w)
for i in range(4):
  if l[i][0]==l[i][-1]:
    del l[i][-1]
    answer=l[i]
    b=True
    break
if not b:
    print(-1)
else:
    print("".join(answer))

Fixed submission:
n=int(input())
w1=list(input())
s="S"
w="W"
o="o"
x="x"
l=[[s,s],[s,w],[w,w],[w,s]]
for j in range(4):
    for i in range(1,n):
        if w1[i]==o:
            if l[j][-1]==s:
                if l[j][-2]==s:
                    l[j].append(s)
                else:
                    l[j].append(w)
            else:
                if l[j][-2]==s:
                    l[j].append(w)
                else:
                    l[j].append(s)
        else:
            if l[j][-1]==s:
                if l[j][-2]==s:
                    l[j].append(w)
                else:
                    l[j].append(s)
            else:
                if l[j][-2]==s:
                    l[j].append(s)
                else:
                    l[j].append(w)
b=False
for i in range(4):
  if l[i][0]==l[i][-1] and not b:
    del l[i][-1]
    if l[i][0]==s:
      if (l[i][1]==l[i][-1] and w1[0]==o) or (l[i][1]!=l[i][-1] and w1[0]==x):
        answer=l[i]
        b=True
        break
    else:
      if (l[i][1]!=l[i][-1] and w1[0]==o) or (l[i][1]==l[i][-1] and w1[0]==x):
        answer=l[i]
        b=True
        break
if not b:
    print(-1)
else:
    print("".join(answer))
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
x=0
y=0
while x==0:
  if s[0]!="A":
    del s[0]
  else:
    x=1
while y==0:
  if s[-1]!="Z":
    del s[-1]
  else:
    y=1
print(len(s))
    

Fixed submission:
s=list(input())
x=0
y=0
for i in range(0,len(s)):
  if s[i]=="A":
    x=i
    break
for i in range(1,len(s)):
  if s[-i]=="Z":
    y=i
    break
print(len(s)-x-y+1)

Buggy python submission (verdict: Runtime Error):
s=list(input())
x=0
y=0
while x=0:
  if s[0]!="A":
    del s[0]
  else:
    x=1
while y=0:
  if s[-1]!="Z":
    del s[-1]
  else:
    y=1
print(len(s))
    

Fixed submission:
s=list(input())
x=0
y=0
for i in range(0,len(s)):
  if s[i]=="A":
    x=i
    break
for i in range(1,len(s)):
  if s[-i]=="Z":
    y=i
    break
print(len(s)-x-y+1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(input())
n=0
lis=[]
for i in range(n):
  if l[i]=="D":
    n+=-1
  else:
    n+=1
  lis.append(n)
print(max(lis))
  

Fixed submission:
n=int(input())
l=list(input())
s=0
lis=[0]
for i in range(n):
  if l[i]=="D":
    s+=-1
    lis.append(s)
  else:
    s+=1
    lis.append(s)
print(max(lis))
Buggy python submission (verdict: Runtime Error):
l=list(input())
l[5]=""
l[12]=""
print(sum(l))

Fixed submission:
l=list(input())
l[13]=" "
l[5]=" "
print("".join(l))
Buggy python submission (verdict: Runtime Error):
a,s,d=map(input().split())
if s=="+":
  print(int(a)+int(d))
else:
  print(int(a)-int(d))

Fixed submission:
a,s,d=input().split()
if s=="+":
  print(int(a)+int(d))
else:
  print(int(a)-int(d))
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(input())
m=int(input())
time=0
for i in l:
  time+=i
for i in range(m):
  p,x=map(int,input().split())
  print(time-l(p-1)+x)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
m=int(input())
time=0
for i in l:
  time+=int(i)
for i in range(m):
  p,x=map(int,input().split())
  print(time-l[p-1]+x)
Buggy python submission (verdict: Runtime Error):
s=list(input())
booler=True
while s!=[] and booler==True:
  if s[-5]=="d" and s[-4]=="r" and s[-3]=="e" and s[-2]=="a" and s[-1]=="m":
    for i in range(5):
      del s[-1]
  elif s[-6]=="e" and s[-5]=="r" and s[-4]=="a" and s[-3]=="s" and s[-2]=="e" and s[-1]=="r":
    for i in range(6):
      del s[-1]
  elif s[-5]=="e" and s[-4]=="r" and s[-3]=="a" and s[-2]=="s" and s[-1]=="e":
    for i in range(5):
      del s[-1]
  elif s[-7]=="d" and s[-6]=="r" and s[-5]=="e" and s[-4]=="a" and s[-3]=="m" and s[-2]=="e" and s[-1]=="r":
    for i in range(7):
      del s[-1]
  else:
    booler=False
if booler:
  print("YES")
else:
  print("NO")
  


Fixed submission:
s=list(input())
booler=True
while s!=[] and booler==True:
  if s[-5]=="d" and s[-4]=="r" and s[-3]=="e" and s[-2]=="a" and s[-1]=="m":
    for i in range(5):
      del s[-1]
  elif s[-5]=="e" and s[-4]=="r" and s[-3]=="a" and s[-2]=="s" and s[-1]=="e":
    for i in range(5):
      del s[-1]
  elif s[-6]=="e" and s[-5]=="r" and s[-4]=="a" and s[-3]=="s" and s[-2]=="e" and s[-1]=="r":
    for i in range(6):
      del s[-1]
  elif s[-7]=="d" and s[-6]=="r" and s[-5]=="e" and s[-4]=="a" and s[-3]=="m" and s[-2]=="e" and s[-1]=="r":
    for i in range(7):
      del s[-1]
  else:
    booler=False
if booler:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
s=list(input())
booler=True
while s!=[]:
  if s[-5]=="d" and s[-4]=="r" and s[-3]=="e" and s[-2]=="a" and s[-1]=="m":
    for i in range(5):
      del s[-1]
  elif s[-6]=="e" and s[-5]=="r" and s[-4]=="a" and s[-3]=="s" and s[-2]=="e" and s[-1]=="r":
    for i in range(6):
      del s[-1]
  elif s[-5]=="e" and s[-4]=="r" and s[-3]=="a" and s[-2]=="s" and s[-1]=="e":
    for i in range(5):
      del s[-1]
  elif s[-7]=="d" and s[-6]=="r" and s[-5]=="e" and s[-4]=="a" and s[-3]=="m" and s[-2]=="e" and s[-1]=="r":
    for i in range(7):
      del s[-1]
  else:
    booler=False
if b:
  print("YES")
else:
  print("NO")
  

Fixed submission:
s=list(input())
booler=True
while s!=[] and booler==True:
  if s[-5]=="d" and s[-4]=="r" and s[-3]=="e" and s[-2]=="a" and s[-1]=="m":
    for i in range(5):
      del s[-1]
  elif s[-5]=="e" and s[-4]=="r" and s[-3]=="a" and s[-2]=="s" and s[-1]=="e":
    for i in range(5):
      del s[-1]
  elif s[-6]=="e" and s[-5]=="r" and s[-4]=="a" and s[-3]=="s" and s[-2]=="e" and s[-1]=="r":
    for i in range(6):
      del s[-1]
  elif s[-7]=="d" and s[-6]=="r" and s[-5]=="e" and s[-4]=="a" and s[-3]=="m" and s[-2]=="e" and s[-1]=="r":
    for i in range(7):
      del s[-1]
  else:
    booler=False
if booler:
  print("YES")
else:
  print("NO")