Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict as d
p=d(str)
n=int(input())
print(0, flush = True)
s = input()
if s == "Vacant": exit()
else:
    print(n-1,flush=True)
    t=input()
    if t == "Vacant": exit()
    else:
        p[0]=s
        p[n-1]=t
        l=0
        r=n-1
        while 1:
            g=(l+r)//2
            if p[l]=="":
                print(l, flush = True)
                s = input()
                p[l]=s
                if s == "Vacant": exit()
                else:
                    s=p[l]
            if p[g]=="":
                print(g, flush = True)
                t = input()
                p[g]=t
                if t == "Vacant": exit()
                else:
                    t=p[g]
            if ((g-l)%2!=0 and s!=t) or ((g-l)%2!=1 and s==t):
                l=g+1
            else:
                r=g-1


Fixed submission:
x,y=map(int,input().split())
print(x if x%y!=0else-1)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[[]for i in range(n+1)]
b=[""]*(n+1)
for i in range(m):
    l,r,d=map(int,input().split())
    a[l].append([r,d])
    a[r].append([l,-d])
for i in range(1,n+1):
    if b[i]=="":
        b[i]=0
        k=[i]
        while k:
            s=k.pop(i)
            for x,y in a[s]:
                if b[x]=="":
                    k.append(x)
                    b[x]=b[i]+y
c="Yes"
for i in range(1,n+1):
    for p,q in a:
        if a[i]+q!=p:
            c="No"
print(c)

Fixed submission:
n,m=map(int,input().split())
a=[[]for i in range(n+1)]
b=[""]*(n+1)
for i in range(m):
    l,r,d=map(int,input().split())
    a[l].append([r,d])
    a[r].append([l,-d])
for i in range(1,n+1):
    if b[i]=="":
        b[i]=0
        k=[i]
        while k:
            s=k.pop()
            for x,y in a[s]:
                if b[x]=="":
                    k.append(x)
                    b[x]=b[s]+y
c="Yes"
for i in range(1,n+1):
    for p,q in a[i]:
        if b[i]+q!=b[p]:
            c="No"
print(c)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[[]for i in range(n+1)]
b=[]for i in range(n):
for i in range(n):
    l,r,d=map(int,input().split())
    a[l].append([r,d])
    a[r].append([l,-d])
for i in range(1,n+1):
    if b[i]==None:
        b[i]=0
        k=[i]
        while k:
            s=k.pop(i)
            for x,y in a[s]:
                if b[x]==None:
                    k.append(x)
                    b[x]=b[i]+y
c="Yes"
for i in range(1,n+1):
    for p,q in a:
        if a[i]+q!=p:
            c="No"
print(c)

Fixed submission:
n,m=map(int,input().split())
a=[[]for i in range(n+1)]
b=[""]*(n+1)
for i in range(m):
    l,r,d=map(int,input().split())
    a[l].append([r,d])
    a[r].append([l,-d])
for i in range(1,n+1):
    if b[i]=="":
        b[i]=0
        k=[i]
        while k:
            s=k.pop()
            for x,y in a[s]:
                if b[x]=="":
                    k.append(x)
                    b[x]=b[s]+y
c="Yes"
for i in range(1,n+1):
    for p,q in a[i]:
        if b[i]+q!=b[p]:
            c="No"
print(c)
Buggy python submission (verdict: Runtime Error):
k=int(input())
a=list(map(int,input().split()))
l,r=1,10**18
def f(x,a):
    for i in a:
        x=max(0,x-x%i)
    return x
while r-l>1:
    t=(l+r)//2
    if f(t,a)>2:
        r=t
    else:
        l=t
p,q=1,10**18
while q-p>1:
    t=(p+q)//2
    if f(t,a)<=1:
        p=t
    else:
        q=t
print(*(q,l) if q<=l else -1)

Fixed submission:
k=int(input())
a=list(map(int,input().split()))
s=2+k*max(a)
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>=2:
        l=p
    else:
        r=p
e=l
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>2:
        l=p
    else:
        r=p
print(str(max(e,2))+" "+str(r)if r>e or r<2 else -1)

Buggy python submission (verdict: Runtime Error):
k=int(input())
a=list(map(int,input().split()))
l,r=1,10**18
def f(x,a):
    for i in a:
        x=x-x%i
    return x
while r-l>1:
    t=(l+r)//2
    if f(t,a)>2:
        r=t
    else:
        l=t
p,q=1,10**18
while q-p>1:
    t=(p+q)//2
    if f(t,a)<=1:
        p=t
    else:
        q=t
print(*(q,l) if q<=l else -1)

Fixed submission:
k=int(input())
a=list(map(int,input().split()))
s=2+k*max(a)
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>=2:
        l=p
    else:
        r=p
e=l
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>2:
        l=p
    else:
        r=p
print(str(max(e,2))+" "+str(r)if r>e or r<2 else -1)

Buggy python submission (verdict: Runtime Error):
k=int(input())
a=list(map(int,input().split()))
l,r=1,10**18
def f(x,a):
    for i in a:
        x=x-x%i
    return x
while r-l>1:
    t=(l+r)//2
    if f(t,a)>2:
        r=t
    else:
        l=t
p,q=1,10**18
while q-p>1:
    t=(p+q)//2
    if f(t,a)<=1:
        p=t
    else:
        q=t
print(*(q,l) if q<=l else -1)

Fixed submission:
k=int(input())
a=list(map(int,input().split()))
s=2+k*max(a)
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>=2:
        l=p
    else:
        r=p
e=l
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>2:
        l=p
    else:
        r=p
print(str(max(e,2))+" "+str(r)if r>e or r<2 else -1)
Buggy python submission (verdict: Runtime Error):
print(len(set([input()for i in range(n)])))

Fixed submission:
n=int(input())
print(len(set([int(input())for i in range(n)])))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
c=list(map(int,input().split()))
s=list(set(c))
p=[]
if len(s)<=k:
    print(0)
else:
    for i in range(len(s)):
        p.append(c.count(s[i]))
    p.sort()
    print(sum(p[:len(s)-k]))

Fixed submission:
import collections 
n,k=map(int,input().split())
c=list(map(int,input().split()))
l=collections.Counter(c)
s=l.most_common()
p=[]
if len(s)<=k:
    print(0)
else:
    d=0
    for a,b in s[:k]:
        d+=b
    print(n-d)
Buggy python submission (verdict: Runtime Error):
from heapq import *
from itertools import accumulate as ac
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
    else:
        b[h].append([i,j])
s=[0]*(2*10**5+2)
for i in b:
    for h,w in i:
        s[2*h-1]+=1
        s[2*w+1]-=1
print(max(list(ac(s))))

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))
Buggy python submission (verdict: Runtime Error):
from heapq import *
from itertools import chain
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
    else:
        b[h].append([i,j])
d=sorted(chain.from_iterable(b))
b=[d[0][1]]
for i,j in d[1:]:
    s=heappop(b)
    if i<=s:
        heappush(b,s)
        heappush(b,j)
    else:
        heppush(b,j)
print(len(b))

Fixed submission:
from heapq import *
from itertools import accumulate as ac
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
        else:
            b[h].append([i,j])
    else:
        b[h].append([i,j])
s=[0]*(2*10**5+2)
for i in b:
    for h,w in i:
        s[2*h-1]+=1
        s[2*w+1]-=1
print(max(list(ac(s))))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate as ac
n=int(input())
a,b=[],[]
for i in range(n):
    x,s=map(int,input().split())
    a.append(x)
    b.append(s)
r=[0]+list(ac(b))
l=r[:]
for i in range(n):
    r[i]+=-a[i]
    l[i+1]+=-a[i]
q,d=r[0],0
for i in range(1,n+1):
    d=max(l[i]-q,d)
    q=min(q,r[i-1])
print(d)

Fixed submission:
k,a,b=map(int,input().split());print(1+2*((k-a-1)//(a-b)+1)if a-b>0 else(1 if k<=a else -1))

Buggy python submission (verdict: Runtime Error):
k,a,b=map(int,input().split());print(-1if a<b else 2*((k-1)//(a-b))+1)

Fixed submission:
k,a,b=map(int,input().split());print(1+2*((k-a-1)//(a-b)+1)if a-b>0 else(1 if k<=a else -1))
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
if n==1:
    for i in range(q):
        v,w=map(int,input().split())
        print(min(v,w))
else:
    for i in range(q):
        v,w=map(int,input().split())
        while v!=w:
            if v>w:v,w=w,v
            w=(w+n-2)//n
        print(v)

Fixed submission:
n,q=map(int,input().split())
if n==1:
    for i in range(q):
        v,w=map(int,input().split())
        print(min(v,w))
else:
    for i in range(q):
        v,w=map(int,input().split())
        while v!=w:
            if v>w:v,w=w,v
            w=(w+n-2)//n
        print(v)

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
if n==1:
    for i in range(q):
        v,w=map(int,input().split())
        print(min(v,w))
else:
    for i in range(q):
        v,w=map(int,input().split())
        while v!=w:
            while v>w:
                v=(v+n-2)//n
            while w>v:
                w=(w+n-2)//n
        print(v)

Fixed submission:
n,q=map(int,input().split())
if n==1:
    for i in range(q):
        v,w=map(int,input().split())
        print(min(v,w))
else:
    for i in range(q):
        v,w=map(int,input().split())
        while v!=w:
            if v>w:v,w=w,v
            w=(w+n-2)//n
        print(v)

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
if n==1:
    for i in range(q):
        v,w=map(int,input().split())
        print(min(v,w))
for i in range(q):
    v,w=map(int,input().split())
    while v!=w:
        if v>w:
            v=(v+n-2)//n
        else:
            w=(w+n-2)//n
    print(v)

Fixed submission:
n,q=map(int,input().split())
if n==1:
    for i in range(q):
        v,w=map(int,input().split())
        print(min(v,w))
else:
    for i in range(q):
        v,w=map(int,input().split())
        while v!=w:
            if v>w:v,w=w,v
            w=(w+n-2)//n
        print(v)

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
for i in range(q):
    v,w=map(int,input().split())
    while v!=w:
        if v>w:
            v=(v+n-2)//n
        else:
            w=(w+n-2)//n
    print(v)

Fixed submission:
n,q=map(int,input().split())
if n==1:
    for i in range(q):
        v,w=map(int,input().split())
        print(min(v,w))
else:
    for i in range(q):
        v,w=map(int,input().split())
        while v!=w:
            if v>w:v,w=w,v
            w=(w+n-2)//n
        print(v)

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
for i in range(q):
    v,w=map(int,input().split())
    c=[1]
    while v!=1:
        c.append(v)
        v=(v+n-2)//n
    while w not in c:
        w=(w+n-2)//n
    print(w)

Fixed submission:
n,q=map(int,input().split())
if n==1:
    for i in range(q):
        v,w=map(int,input().split())
        print(min(v,w))
else:
    for i in range(q):
        v,w=map(int,input().split())
        while v!=w:
            if v>w:v,w=w,v
            w=(w+n-2)//n
        print(v)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
l,r=2*(10**18)+1,0
while l-r>1:
    t=(l+r)//2
    c=0
    for i,j in a:
        c+=max(0,(t-i)//j+1)
    if c<k:
        r=t
    else:
        l=t
print(l)

Fixed submission:
n,k=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
l,r=2*(10**18)+1,0
while l-r>1:
    t=(l+r)//2
    c=0
    for i,j in a:
        c+=max(0,(t-i)//j+1)
    if c<k:
        r=t
    else:
        l=t
print(l)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n,m=map(int,input().split())
a=[i for i in range(n+1)]
b=[0]*(n+1)
def f(x):
    if a[x]==x:
        return x
    x=a[x]
    return(f(x))
def s(x,y):
    x=f(x)
    y=f(y)
    if x!=y:
        if b[x]>b[y]:
            a[y]=x
            b[y]+=1
        else:
            a[x]=y
            b[x]+=1
for i in range(m):
    c,d=map(int,input().split())
    s(c,d)
for i in range(1,n+1):
    a[i]=f(i)
d=a.count(a[2])
print(((n-d)*(n-d-1)//2)-m+(d*(d-1)//2))

Fixed submission:
n,m=map(int,input().split())
a=[i for i in range(n+1)]
b=[0]*(n+1)
def f(x):
    if a[x]==x:
        return x
    x=a[x]
    return(f(x))
def s(x,y):
    x=f(x)
    y=f(y)
    if x!=y:
        if b[x]<b[y]:
            a[x]=y
            b[y]+=1
        else:
            a[y]=x
            b[x]+=1
for i in range(m):
    c,d=map(int,input().split())
    s(c,d)
for i in range(1,n+1):
    a[i]=f(i)
d=a.count(a[2])
s=a.count(a[1])
print(max(((n-d)*(n-d-1)//2)-m+(d*(d-1)//2),((n-s)*(n-s-1)//2)-m+(s*(s-1)//2)))

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n,m=map(int,input().split())
a=[i for i in range(n+1)]
b=[0]*(n+1)
def f(x):
    if a[x]==x:
        return x
    x=a[x]
    return(f(x))
def s(x,y):
    x=f(x)
    y=f(y)
    if x!=y:
        if b[x]>b[y]:
            a[y]=x
            b[y]+=1
        else:
            a[x]=y
            b[x]+=1
for i in range(m):
    c,d=map(int,input().split())
    s(c,d)
for i in range(1,n+1):
    a[i]=f(i)
d=a.count(a[2])
print(((n-d)*(n-d-1)//2)-m+(d*(d-1)//2))

Fixed submission:
n,m=map(int,input().split())
a=[i for i in range(n+1)]
b=[0]*(n+1)
def f(x):
    if a[x]==x:
        return x
    x=a[x]
    return(f(x))
def s(x,y):
    x=f(x)
    y=f(y)
    if x!=y:
        if b[x]<b[y]:
            a[x]=y
            b[y]+=1
        else:
            a[y]=x
            b[x]+=1
for i in range(m):
    c,d=map(int,input().split())
    s(c,d)
for i in range(1,n+1):
    a[i]=f(i)
d=a.count(a[2])
s=a.count(a[1])
print(max(((n-d)*(n-d-1)//2)-m+(d*(d-1)//2),((n-s)*(n-s-1)//2)-m+(s*(s-1)//2)))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate as ac
n=int(input())
a,b=[],[]
for i in range(n):
    x,s=map(int,input().split())
    a.append(x)
    b.append(s)
r=[0]+list(ac(b))
l=b[:]
for i in range(n):
    r[i]+=-a[i]
    l[i+1]+=-a[i]
q,d=0,0
for i in range(1,n+1):
    d=max(l[i]-q,d)
    q=min(q,r[i-1])
print(d)

Fixed submission:
from itertools import accumulate as ac
n=int(input())
a,b=[],[]
for i in range(n):
    x,s=map(int,input().split())
    a.append(x)
    b.append(s)
r=[0]+list(ac(b))
l=r[:]
for i in range(n):
    r[i]+=-a[i]
    l[i+1]+=-a[i]
q,d=r[0],0
for i in range(1,n+1):
    d=max(l[i]-q,d)
    q=min(q,r[i])
print(d)
Buggy python submission (verdict: Runtime Error):
s=input()
a,b=s.count("a"),s.count("b"),s.count("c")
print("NO" if max(a,b,c)-min(a,b,c)>1 else"YES")

Fixed submission:
s=input()
a,b,c=s.count("a"),s.count("b"),s.count("c")
print("NO" if max(a,b,c)-min(a,b,c)>1 else"YES")

Buggy python submission (verdict: Runtime Error):
s=input()
a,b=s.count("a"),s.count("b"),s.count("c")
print("NO" if max(a,b,c)-min(a,b,c)>1 else"YES")

Fixed submission:
s=input()
a,b,c=s.count("a"),s.count("b"),s.count("c")
print("NO" if max(a,b,c)-min(a,b,c)>1 else"YES")
Buggy python submission (verdict: Runtime Error):
s=input()
c=0
l=["+","-"]
for i in range(2):
  if c!=0
  	break
  for j in range(2):
    	if c!=0
      		break
    for p in range(2):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")
        c=1
        break

Fixed submission:
s=input()
c=0
l=["+","-"]
for i in range(2):
  if c!=0:
  	break
  for j in range(2):
    if c!=0:
      	break
    for p in range(2):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")
        c=1
        break

Buggy python submission (verdict: Runtime Error):
s=input()
l=["+","-"]
for i in range(1):
  for j in range(i):
    for p in range(1):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        break
print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")

Fixed submission:
s=input()
c=0
l=["+","-"]
for i in range(2):
  if c!=0:
  	break
  for j in range(2):
    if c!=0:
      	break
    for p in range(2):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")
        c=1
        break
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[list(map(int,input().split()))for i in range(3)]
c=0
for i in range(n):
    p=s[2][i]
    q=[j for j in s[1] if j<p]
    f=[j for j in s[0] if j<p]
    for a in range(len(q)):
        r=q[a]
        t=[j for j in f if j<r]
        c+=len(t)
print(c)

Fixed submission:
n=int(input())
s=[list(map(int,input().split()))for i in range(3)]
s[0].sort()
s[1].sort()
s[2].sort()
c,d,e=0,0,0
for i in range(n):
    while d<n and s[0][d]<s[1][i]:
        d+=1
    while e<n and s[2][e]<=s[1][i]:
        e+=1
    c+=d*(n-e)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
c=float("inf")
for i in range(10**5,10**6+1):
    c=min(c,sum([int(d) for d in str(k*i)]))
print(c)    

Fixed submission:
from collections import deque
k=int(input())
t=[1]*k
q=deque()
q.append((1,1))
while q:
    p,r=q.popleft()
    if p==0:
        print(r)
        break
    if t[p]:
        t[p]=0
        q.appendleft(((p*10)%k,r))
        q.append(((p+1)%k,r+1))
Buggy python submission (verdict: Runtime Error):
a,n=map(int,input().split())
if a%2==0:
    print(" ".join(str(a//2)+str(a)*(n-1)))
else:
    d=[(a+1)//2]*n
    r=n-1
    for i in range((n-1)//2+1):
        if d[r]==1:
            d[r]=0
            r-=1
        else:
            d=d[:r]+[d[r]-1]+[a]*(n-r-1)
            r=n-1
    while d[-1]==0:
        d.pop()
    print(" ".join(str(i)for i in d))

Fixed submission:
a,n=map(int,input().split())
if a%2==0:
    print(*[a//2]+[a]*(n-1))
else:
    d=[(a+1)//2]*n
    for i in range(n//2):
        if d[-1]==1:
            d.pop()
        else:
            d[-1]-=1
            d.extend([a]*(n-len(d)))
    print(" ".join(str(i)for i in d))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate as ac
n=int(input())+2
t=[0]+list(map(int,input().split()))+[0]
v=[0]+list(map(int,input().split()))+[0]
s=[0]+list(ac(t))
def f(i,x):
    if s[i]<=x<=s[i+1]:return v[i]
    elif x<s[i]:return v[i]+s[i]-x
    else:return v[i]+x-s[i+1]
c=float("INF")
for i in range(n):
    c=min(c,f(i,0))
e=0
for i in range(1,2*s[-1]+1):
    i=i/2
    d=float("INF")
    for j in range(n):
        d=min(d,f(j,i))
    e+=0.25*(c+d)
    c=d
print(e)

Fixed submission:
a=int(input())
b=int(input())
print(2*b-a)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate as ac
n=int(input())+2
t=[0]+list(map(int,input().split()))+[0]
v=[0]+list(map(int,input().split()))+[0]
s=[0]+list(ac(t))
def f(i,x):
    if s[i]<=x<=s[i+1]:return v[i]
    elif x<s[i]:return v[i]+s[i]-x
    else:return v[i]+x-s[i+1]
c=float("INF")
for i in range(n):
    c=min(c,f(i,0))
e=0
for i in range(1,2*s[-1]+1):
    i=i/2
    d=float("INF")
    for j in range(n):
        d=min(d,f(j,i))
    e+=0.25*(c+d)
    c=d
print(e)

Fixed submission:
from itertools import accumulate as ac
n=int(input())+2
t=[0]+list(map(int,input().split()))+[0]
v=[0]+list(map(int,input().split()))+[0]
s=[0]+list(ac(t))
def f(i,x):
    if s[i]<=x<=s[i+1]:return v[i]
    elif x<s[i]:return v[i]+s[i]-x
    else:return v[i]+x-s[i+1]
c=float("INF")
for i in range(n):
    c=min(c,f(i,0))
e=0
for i in range(1,2*s[-1]+1):
    i=i/2
    d=float("INF")
    for j in range(n):
        d=min(d,f(j,i))
    e+=0.25*(c+d)
    c=d
print(e)
Buggy python submission (verdict: Runtime Error):
s=input()
i=0
j=len(s)-1
c=0
while i>=j:
    if s[i]!=s[j]:
        c+=1
        if s[i]=="x":
            i+=1
        elif s[j]=="x":
            j-=1
        else:
            print(-1)
            break
    else:
        i+=1
        j-=1
else:
    print(c)

Fixed submission:
s=input()
i=0
j=len(s)-1
c=0
while i<j:
    if s[i]!=s[j]:
        c+=1
        if s[i]=="x":
            i+=1
        elif s[j]=="x":
            j-=1
        else:
            print(-1)
            break
    else:
        i+=1
        j-=1
else:
    print(c)

Buggy python submission (verdict: Runtime Error):
s=input()
i=0
j=len(s)-1
c=0
while i!=j:
    if s[i]!=s[j]:
        c+=1
        if s[i]=="x":
            i+=1
        elif s[j]=="x":
            j-=1
        else:
            print(-1)
            break
    else:
        i+=1
        j-=1
else:
    print(c)

Fixed submission:
s=input()
i=0
j=len(s)-1
c=0
while i<j:
    if s[i]!=s[j]:
        c+=1
        if s[i]=="x":
            i+=1
        elif s[j]=="x":
            j-=1
        else:
            print(-1)
            break
    else:
        i+=1
        j-=1
else:
    print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
p=list(set(b))
c=0
for i in range(len(p)):
    if b.count(p[i])>a.count(p[i]):
        c=1
print("YES"if c!=1else"NO")

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a=Counter(a)
m=int(input())
b=list(map(int,input().split()))
b=Counter(b)
for d,e in b.items():
    if a[d]<e:
        print("NO")
        exit()
print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
a=[i for i in a if i in b]
p=list(set(b))
c=0
for i in range(len(p)):
    if b.count(p[i])>a.count(p[i]):
        c=1
print("YES"if c!=1else"NO")

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a=Counter(a)
m=int(input())
b=list(map(int,input().split()))
b=Counter(b)
for d,e in b.items():
    if a[d]<e:
        print("NO")
        exit()
print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
c=0
for i in range(m):
    if b[i] in a:
        a[a.index(b[i])]=0
    else:
        c=1
print("YES"if c!=1else"NO")

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a=Counter(a)
m=int(input())
b=list(map(int,input().split()))
b=Counter(b)
for d,e in b.items():
    if a[d]<e:
        print("NO")
        exit()
print("YES")
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=[[]for i in range(n+1)]
c=[0]*(n+1)
for i in range(m):
    a,b=map(int,input().split())
    s[a].append(b)
    s[b].append(a)
def dfs(v,t):
    c[v]=t
    for i in s[v]:
        if c[i]==t:
            return false
        if c[i]==0 and not dfs(i,-t):
            return false
    else:
        return True
if dfs(1,1):
    q=c.count(1)
    print((n-q)*q-m)
else:
    print((n*(n-1)//2)-m)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=[[]for i in range(n+1)]
c=[0]*(n+1)
for i in range(m):
    a,b=map(int,input().split())
    s[a].append(b)
    s[b].append(a)
def dfs(v,t):
    c[v]=t
    for i in s[v]:
        if c[i]==t:
            return False
        if c[i]==0 and not dfs(i,-t):
            return False
    else:
        return True
if dfs(1,1):
    q=c.count(1)
    print((n-q)*q-m)
else:
    print((n*(n-1)//2)-m)