Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
ans=0
## a<b and k>0
ans+=(n-k)*(n-k+1)//2

#print(ans)
## a>b
for i in range(k,n+1):
    for j in range(1,i):
        if i%j>=k:
            ans+=1

print(ans)


Fixed submission:
n,k=map(int,input().split())
if k==0:
    print(n*n)
    exit()
ans=0
for i in range(k+1,n+1):
    ans+=((n+1)//i)*(i-k)+max(0,((n+1)%i-k))
print(ans)
Buggy python submission (verdict: Runtime Error):
print(int(input()//3))

Fixed submission:
print(int(input())//3)

Buggy python submission (verdict: Runtime Error):
print(int(input()//3)

Fixed submission:
print(int(input())//3)
Buggy python submission (verdict: Time Limit Exceeded):
def sol():
    h,w,d=map(int,input().split())
    a=[[int(i) for i in input().split()] for i in range(h)]
    t,ans={},{}
    for i in range(h):
        for j in range(w):
            t[a[i][j]]=(i,j)
    for i in t:
        o,p=t[i]
        if i+d in t: ans[i]=abs(o-t[i+d][0])+abs(p-t[i+d][1])
    q=int(input())
    for i in range(q):
        chk=0
        l,r=map(int,input().split())
        for j in range(300*300):
            if l==r: break
            chk+=ans[l]
            l+=d
        print(chk)

if __name__=="__main__":
    sol()


Fixed submission:
def sol():
    h,w,d=map(int,input().split())
    a=[[int(i) for i in input().split()] for i in range(h)]
    t={}
    for i in range(h):
        for j in range(w):
            t[a[i][j]]=(i,j)
    ans=[0]*(h*w+1)
    for i in range(h*w,d,-1):
        o,p=t[i]
        ans[i-d]=ans[i]+abs(o-t[i-d][0])+abs(p-t[i-d][1])
    q=int(input())
    for i in range(q):
        l,r=map(int,input().split())
        print(ans[l]-ans[r])

if __name__=="__main__":
    sol()

Buggy python submission (verdict: Time Limit Exceeded):
def sol():
    h,w,d=map(int,input().split())
    a=[[int(i) for i in input().split()] for i in range(h)]
    t,ans={},{}
    for i in range(h):
        for j in range(w):
            t[a[i][j]]=(i,j)
    for i in t:
        o,p=t[i]
        if i+d in t: ans[i]=abs(o-t[i+d][0])+abs(p-t[i+d][1])
    q=int(input())
    for i in range(q):
        chk=0
        l,r=map(int,input().split())
        for j in range(300):
            if l==r: break
            chk+=ans[l]
            l+=d
        print(chk)

if __name__=="__main__":
    sol()

Fixed submission:
def sol():
    h,w,d=map(int,input().split())
    a=[[int(i) for i in input().split()] for i in range(h)]
    t={}
    for i in range(h):
        for j in range(w):
            t[a[i][j]]=(i,j)
    ans=[0]*(h*w+1)
    for i in range(h*w,d,-1):
        o,p=t[i]
        ans[i-d]=ans[i]+abs(o-t[i-d][0])+abs(p-t[i-d][1])
    q=int(input())
    for i in range(q):
        l,r=map(int,input().split())
        print(ans[l]-ans[r])

if __name__=="__main__":
    sol()

Buggy python submission (verdict: Time Limit Exceeded):
h,w,d=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(h)]
t={}
for i in range(h):
    for j in range(w):
        t[a[i][j]]=(i,j)

q=int(input())
for i in range(q):
    chk=0
    l,r=map(int,input().split())
    o,p=t[l]
    for j in range(300):
        if l==r: break
        chk+=abs(o-t[l+d][0])+abs(p-t[l+d][1])
        o=t[l+d][0]
        p=t[l+d][1]
        l+=d
    print(chk)

Fixed submission:
def sol():
    h,w,d=map(int,input().split())
    a=[[int(i) for i in input().split()] for i in range(h)]
    t={}
    for i in range(h):
        for j in range(w):
            t[a[i][j]]=(i,j)
    ans=[0]*(h*w+1)
    for i in range(h*w,d,-1):
        o,p=t[i]
        ans[i-d]=ans[i]+abs(o-t[i-d][0])+abs(p-t[i-d][1])
    q=int(input())
    for i in range(q):
        l,r=map(int,input().split())
        print(ans[l]-ans[r])

if __name__=="__main__":
    sol()
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
print("Yes" if a[0]-b[0]==a[1]-b[1]==a[2]-b[2] and a[0]-c[0]==a[1]-c[1]==a[2]-c[2] else "No")

Fixed submission:
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
print("Yes" if a[0]-b[0]==a[1]-b[1]==a[2]-b[2] and a[0]-c[0]==a[1]-c[1]==a[2]-c[2] else "No")
Buggy python submission (verdict: Runtime Error):
ans=chk=0
h,w=map(int,input().split())
d=[[0]*w for i in range(h)]
l=[]
for i in range(h):
    a=input()
    chk+=a.count("#")
    l.append(a)
p=set([(0,0)])
while len(p):
    a,b=p.pop()
    for y,x in xy:
        y+=a
        x+=b
        if 0<=y<h and 0<=x<w and l[y][x]!="#":
            if d[y][x]==0 or d[y][x]>d[a][b]+1:
                d[y][x]=d[a][b]+1
                p.add((y,x))

print(-1 if d[h-1][w-1]==0 else h*w-1-chk-d[h-1][w-1])

Fixed submission:
xy=[(1,0),(-1,0),(0,1),(0,-1)]
ans=chk=0
h,w=map(int,input().split())
d=[[0]*w for i in range(h)]
l=[]
for i in range(h):
    a=input()
    chk+=a.count("#")
    l.append(a)
p=set([(0,0)])
while len(p):
    a,b=p.pop()
    for y,x in xy:
        y+=a
        x+=b
        if 0<=y<h and 0<=x<w and l[y][x]!="#":
            if d[y][x]==0 or d[y][x]>d[a][b]+1:
                d[y][x]=d[a][b]+1
                p.add((y,x))

print(-1 if d[h-1][w-1]==0 else h*w-1-chk-d[h-1][w-1])
Buggy python submission (verdict: Time Limit Exceeded):
x,y=map(int,input().split())
if x//y>=1 and x%y==0:
    print(-1)
    exit()
t=2
p=100000000000000000
while 1:
    if x*t>p:
        break
    elif x*t%y:
        print(x*t)
        exit()
print(-1)


Fixed submission:
x,y=map(int,input().split())
if x//y>=1 and x%y==0:
    print(-1)
    exit()
a=x*(y-1)
b=x*(y+1)
t=1000000000000000000
if a>0 and a%y and a<=t:
    print(a)
elif b>0 and b%y and b<=t:
    print(b)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print('Odd' if (a*b)%2 else 'Even'))

Fixed submission:
a,b=map(int,input().split())
print('Odd' if (a*b)%2 else 'Even')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
if '-' not in s or s.count('-')>1 or s[0]=='-' or s[-1]=='-':
    print('No')
    exit()

p=s.split('-')
print('No' if s[a]!='-' or len(p[0]!=a or len(p[1])!=b) else 'Yes')

Fixed submission:
a,b=map(int,input().split())
s=input()
if '-' not in s or s.count('-')>1 or s[0]=='-' or s[-1]=='-':
    print('No')
    exit()

p=s.split('-')
print('No' if s[a]!='-' or len(p[0])!=a or len(p[1])!=b else 'Yes')

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
p=s.split('-')
print('No' if s[a]!='-' or len(p[0]!=a or len(p[1])!=b) else 'Yes')

Fixed submission:
a,b=map(int,input().split())
s=input()
if '-' not in s or s.count('-')>1 or s[0]=='-' or s[-1]=='-':
    print('No')
    exit()

p=s.split('-')
print('No' if s[a]!='-' or len(p[0])!=a or len(p[1])!=b else 'Yes')
Buggy python submission (verdict: Runtime Error):
def prime_t(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i+=1
    return 1
d=[]
n=10**5+1
for i in range(2,n):
    if prime_t(i):
        d.append(i)
 
q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    for j in range(l,r+1,2):
        if (j in d and (j+1)//2 in d): ans+=1
    print(ans)
def prime_t(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i+=1
    return 1
d=[]
n=10**5+1
for i in range(2,n):
    if prime_t(i):
        d.append(i)

q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    for j in range(l,r+1,2):
        if (j in d and (j+1)//2 in d): ans+=1
    print(ans)


Fixed submission:
def prime_t(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i+=1
    return 1
d=set([])
n=10**5+1
p=[0]*(10**5+1)
for i in range(2,n):
    if prime_t(i):
        d.add(i)
    if (i in d and (i+1)//2 in d): p[i]=p[i-1]+1
    else: p[i]=p[i-1]

q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    print(p[r]-p[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
def prime_t(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i+=1
    return 1
d=[]
n=10**5+1
for i in range(2,n):
    if prime_t(i):
        d.append(i)

q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    for j in range(l,r+1,2):
        if (j in d and (j+1)//2 in d): ans+=1
    print(ans)


Fixed submission:
def prime_t(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i+=1
    return 1
d=set([])
n=10**5+1
p=[0]*(10**5+1)
for i in range(2,n):
    if prime_t(i):
        d.add(i)
    if (i in d and (i+1)//2 in d): p[i]=p[i-1]+1
    else: p[i]=p[i-1]

q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    print(p[r]-p[l-1])
Buggy python submission (verdict: Runtime Error):
s=input()
x,y=map(int,input().split())
xx,yy=[],[]
w=[0,0]
ans=chk=0
f=0
for i in s:
    if f==0 and i=='F':
        w[0]+=1
    elif f==0 and i=='T':
        f=1
    elif f==1 and i=='F':
        chk+=1
    elif f==1 and i=='T':
        yy.append(chk)
        chk=0
        f=2
    elif f==2 and i=='F':
        chk+=1
    elif f==2 and i=='T':
        xx.append(chk)
        chk=0
        f=1
if chk and f==1:
    yy.append(ckh)
elif chk and f==2:
    xx.append(chk)
xx.sort()
yy.sort()
for i in xx[::-1]:
    if w[0]<=x:
        w[0]+=i
    else:
        w[0]-=i
for i in yy[::-1]:
    if w[1]<=y:
        w[1]+=i
    else:
        w[1]-=i
print("Yes" if w[0]==x and w[1]==y else "No")


Fixed submission:
s=input()
x,y=map(int,input().split())
xx,yy=[],[]
w=[0,0]
ans=chk=0
f=0
for i in s:
    if f==0 and i=='F':
        w[0]+=1
    elif f==0 and i=='T':
        f=1
    elif f==1 and i=='F':
        chk+=1
    elif f==1 and i=='T':
        yy.append(chk)
        chk=0
        f=2
    elif f==2 and i=='F':
        chk+=1
    elif f==2 and i=='T':
        xx.append(chk)
        chk=0
        f=1
if chk and f==1:
    yy.append(chk)
elif chk and f==2:
    xx.append(chk)
xx.sort()
yy.sort()
for i in xx[::-1]:
    if w[0]<=x:
        w[0]+=i
    else:
        w[0]-=i
for i in yy[::-1]:
    if w[1]<=y:
        w[1]+=i
    else:
        w[1]-=i
print("Yes" if w[0]==x and w[1]==y else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x,t=n,0
while n:
    t+=x%10
    x//=10
print("Yes" if n%t==0 else "No")


Fixed submission:
n=int(input())
t=0
for i in str(n):
    t+=int(i)
print("Yes" if n%t==0 else "No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
print("Yes" if n[1]==n[2] and (n[0]==n[1] or n[3]==n[1])  else "No")

Fixed submission:
n=input()
print("Yes" if n[1]==n[2] and (n[0]==n[1] or n[3]==n[1])  else "No")
Buggy python submission (verdict: Runtime Error):
l=[2,1]
for i in range(85):
    l.append(l[-1]+l[-2])
n=int(input

Fixed submission:
l=[2,1]
for i in range(85):
    l.append(l[-1]+l[-2])
n=int(input())
print(l[n])
Buggy python submission (verdict: Runtime Error):
def sol():
    h,w=map(int,input().split())
    c=[list(map(int,input().split())) for i in range(10)]
    a=[list(map(int,input().split())) for i in range(h)]
    for k in range(10):
        for i in range(10):
            for j in range(10):
                #if (c[i][k]!=0 and c[k][j]!=0): c[i][j]=min(c[i][j],c[i][k]+c[k][j])
                c[k][j]!=0): c[i][j]=min(c[i][j],c[i][k]+c[k][j])
    ans=0
    for i in range(h):
        for j in range(w):
            if a[i][j]==-1: pass
            else: ans+=c[a[i][j]][1]
    print(ans)

if __name__=="__main__":
    sol()

Fixed submission:
h,w=map(int,input().split())
c=[]
for i in range(10):
    l=[int(i) for i in input().split()]
    c.append(l)
a=[]
for i in range(h):
    l=[int(i) for i in input().split()]
    a.append(l)
p=[0]*10
for i in range(10):
    if i==1: continue
    d=[1003]*10
    d[i]=0
    q=set([i])
    while 1:
        if len(q)==0: break
        x=q.pop()
        for j in range(10):
            if i==j: continue
            if (d[j]>d[x]+c[x][j]):
                d[j]=d[x]+c[x][j]
                q.add(j)
    p[i]=d[1]
ans=0
for i in range(h):
    for j in range(w):
        if a[i][j]==-1: pass
        else: ans+=p[a[i][j]]
print(ans)

Buggy python submission (verdict: Runtime Error):
def son():
    h,w=map(int,input().split())
    c=[]
    for i in range(10):
        l=[int(i) for i in input().split()]
        c.append(l)
    a=[]
    for i in range(h):
        l=[int(i) for i in input().split()]
        a.append(l)
    p=[0]*10
    for i in range(10):
        if i==1: continue
        d=[1003]*10
        d[i]=0
        q=set([i])
        while 1:
            if len(q)==0: break
            x=q.pop()
            for j in range(10):
                if i==j: continue
                if (d[j]>d[x]+c[x][j]):
                    d[j]=d[x]+c[x][j]
                    q.add(j)
        p[i]=d[1]
    ans=0
    for i in range(h):
        for j in range(w):
            if a[i][j]==-1: pass
            else: ans+=p[a[i][j]]
    print(ans)

if __name__=="__main__":
    sol()


Fixed submission:
h,w=map(int,input().split())
c=[]
for i in range(10):
    l=[int(i) for i in input().split()]
    c.append(l)
a=[]
for i in range(h):
    l=[int(i) for i in input().split()]
    a.append(l)
p=[0]*10
for i in range(10):
    if i==1: continue
    d=[1003]*10
    d[i]=0
    q=set([i])
    while 1:
        if len(q)==0: break
        x=q.pop()
        for j in range(10):
            if i==j: continue
            if (d[j]>d[x]+c[x][j]):
                d[j]=d[x]+c[x][j]
                q.add(j)
    p[i]=d[1]
ans=0
for i in range(h):
    for j in range(w):
        if a[i][j]==-1: pass
        else: ans+=p[a[i][j]]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort()
b.sort()
b=b[::-1]
c.sort()
ans=tmp=0
for i in a:
    for j in b:
        if i>=j: break
        tmp=bisect.bisect_right(c, j)
        ans+=(n-tmp)
print(ans)

Fixed submission:
import bisect
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort()
b.sort()
b=b[::-1]
c.sort()
ans=tmp=0
for i in b:
    x=bisect.bisect_left(a,i)
    y=bisect.bisect_right(c, i)
    ans+=x*(n-y)
print(ans)
Buggy python submission (verdict: Runtime Error):
a*=100
b*=100
res=chk=0
ans=[]
for i in range(31):
    for j in range(31):
        for k in range(31):
            for l in range(31):
                w=i*a+j*b
                s=k*c+l*d
                if w+s==0: pass
                elif w+s<f and (100*s)//(w+s)<=e*(w//100):
                    res=max(res,(100*s)//(w+s))
                    ans=[w+s,s]
print(*ans)


Fixed submission:
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
res=chk=0
ans=[]

for i in range(16):
    for j in range(16):
        for k in range(1501):
            w=(i*a)+(j*b)
            s=(k*c)
            o=(w//100)*e
            if w==0:
                pass
            elif w+s>f or s>o:
                break
            else:
                s+=(min(f-w-s,o-s)//d)*d
                if len(ans)==0:
                    ans=[s/(w+s),w+s,s]
                elif s/(w+s)>ans[0]:
                    ans=[s/(w+s),w+s,s]
print(ans[1],ans[2])

Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
ans=chk=0
for i in range(31)
    for j in range(31):
        for k in range(31):
            for l in range(31):
                w=i*a+j*b
                s=k*c+l*d
                if w+s<f and (100*s)//(w+s)<=e*(w//100): ans=max(ans,(100*s)//(w+s)
print(ans)


Fixed submission:
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
res=chk=0
ans=[]

for i in range(16):
    for j in range(16):
        for k in range(1501):
            w=(i*a)+(j*b)
            s=(k*c)
            o=(w//100)*e
            if w==0:
                pass
            elif w+s>f or s>o:
                break
            else:
                s+=(min(f-w-s,o-s)//d)*d
                if len(ans)==0:
                    ans=[s/(w+s),w+s,s]
                elif s/(w+s)>ans[0]:
                    ans=[s/(w+s),w+s,s]
print(ans[1],ans[2])
Buggy python submission (verdict: Runtime Error):
mod=1000000007
n=int(input())
s=input()

d=[0]
for i in range(1,n):
    if s[i-1]==s[i]:
        d[-1]+=1
    else:
        d.append(0)
ans=[3,6][d[0]]
for i in range(1,len(d)):
    if d[i-1]==d[i]==1:
        t=3
    elif d[i-1]!=1:
        t=2
    ans=(ans*t)%mod
print(ans)

Fixed submission:
mod=1000000007
n=int(input())
a=input()
b=input()
#1 22
#1
d=[1]
for i in range(1,n):
    if a[i-1]==a[i]:
        d[-1]+=1
    else:
        d.append(1)
ans=[3,6][d[0]-1]
for i in range(1,len(d)):
    if d[i-1]==d[i]==1:
        t=2
    elif d[i-1]==d[i]==2:
        t=3
    elif d[i-1]==2 and d[i]==1:
        t=1
    else:
        t=2
    ans=(ans*t)%mod
print(ans)

Buggy python submission (verdict: Runtime Error):
mod=1000000007
n=int(input())
a=input()

d=[0]
for i in range(1,n):
    if s[i-1]==s[i]:
        d[-1]+=1
    else:
        d.append(0)
ans=[3,6][d[0]]
for i in range(1,len(d)):
    if d[i-1]==d[i]==1:
        t=3
    elif d[i-1]==1:
        t=1
    else:
        t=2
    ans=(ans*t)%mod
print(ans)

Fixed submission:
mod=1000000007
n=int(input())
a=input()
b=input()
#1 22
#1
d=[1]
for i in range(1,n):
    if a[i-1]==a[i]:
        d[-1]+=1
    else:
        d.append(1)
ans=[3,6][d[0]-1]
for i in range(1,len(d)):
    if d[i-1]==d[i]==1:
        t=2
    elif d[i-1]==d[i]==2:
        t=3
    elif d[i-1]==2 and d[i]==1:
        t=1
    else:
        t=2
    ans=(ans*t)%mod
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=1
for i in range(n):
    t=int(input())
    print(t)
    ans=lcm(ans,t)
print(ans)

Fixed submission:
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b//gcd(a,b)
n=int(input())
ans=1
for i in range(n):
    t=int(input())
    ans=lcm(ans,t)
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
n=int(input())
a=[int(i) for i in input().split()]
s=""
for i in range(n):
  s+=str(i+1)*a[i]
for i in range(h):
  if i%2=0:
    print(*list(s[i*w:i*w+w]))
  else:
    print(*list(s[i*w:i*w+w][::-1]))

Fixed submission:
h,w=map(int,input().split())
n=int(input())
a=[int(i) for i in input().split()]
f=0
d=[]
for i in range(n):
  for j in range(a[i]):
    d.append(i+1)
    if len(d)==w and f:
      print(*d[::-1])
      f=0
      d=[]
    elif len(d)==w:
      print(*d)
      f=1
      d=[]

Buggy python submission (verdict: Runtime Error):
import numpy as np
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

hw = []

for i, ai in enumerate(a):
    for j in range(ai):
        hw.append(i+1)
        
hw = np.asarray(hw)
HW = np.reshape(hw, (H, W))

for i in range(H):
#     print(*HW[i])
    if i % 2 == 1:
        print(*HW[i][::-1])
    else:
        print(*HW[i])


Fixed submission:
h,w=map(int,input().split())
n=int(input())
a=[int(i) for i in input().split()]
f=0
d=[]
for i in range(n):
  for j in range(a[i]):
    d.append(i+1)
    if len(d)==w and f:
      print(*d[::-1])
      f=0
      d=[]
    elif len(d)==w:
      print(*d)
      f=1
      d=[]
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[int(i) for i in input().split()]
cnt=[0]*9
ans=0
for i in l:
    if i>3199:
        i=3200
    cnt[i//400]+=1
for p in range(n-1):
    i=cnt[p]
    if i!=0:
        ans+=1
print(ans if ans!=0 else 1,ans+cnt[-1])

Fixed submission:
n=int(input())
l=[int(i) for i in input().split()]
cnt=[0]*9
ans=0
for i in l:
    if i>3199:
        i=3200
    cnt[i//400]+=1
for p in range(8):
    i=cnt[p]
    if i!=0:
        ans+=1
print(ans if ans!=0 else 1,ans+cnt[-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
cnt=[0]*9
ans=0
for i in l:
    if i>3199:
        i=3200
    cnt[i//400]+=1
for p in range(n-1):
    i=cnt[p]
    if i!=0:
        ans+=1
print(ans if ans!=0 else 1,ans+cnt[-1])

Fixed submission:
n=int(input())
l=[int(i) for i in input().split()]
cnt=[0]*9
ans=0
for i in l:
    if i>3199:
        i=3200
    cnt[i//400]+=1
for p in range(8):
    i=cnt[p]
    if i!=0:
        ans+=1
print(ans if ans!=0 else 1,ans+cnt[-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
t=s[0]
chk=0
d=[]
for i in s:
    if i==")"==t:
        chk-=1
    elif i=="("==t:
        chk+=1
    else:
        d.append(chk)
        t=["(",")"][i==")"]
        chk=[1,-1][i==")"]
d.append(chk)
if d[0]<0: d=[0]+d
if d[-1]>0: d.append(d[-1]*-1)
p=sum(d)
if p<0: ans[0]+=abs(p)
if p>0: ans[-1]+=p
ans=""
for i in d:
    ans+=["(",")"][i<0]*abs(i)
print(ans)


Fixed submission:
n=int(input())
s=input()
d=[0,0]
for i in s:
    if i=="(": d[0]+=1
    if i==")" and d[0]>0: d[0]-=1
for i in s[::-1]:
    if i==")": d[1]+=1
    if i=="(" and d[1]>0: d[1]-=1
s="("*d[1]+s+")"*d[0]
print(s)
Buggy python submission (verdict: Runtime Error):
import heapq
#n=int(input())
n,a,b=map(int,input().split())
ans=chk=0
d=[]
for i in range(n):
    x=int(input())
    heapq.heappush(d,-x)
c=a-b
while 1:
#for i in range(5):
    t=heapq.heappop(d)
    if t+chk>=0: break
    ans+=1
    p=(abs(t-d[0])+c-1)//c
    p=max(1,p)
    t+=c*p
    chk+=b*p
    heapq.heappush(d,t)
print(ans)

Fixed submission:
n,a,b=map(int,input().split())
t=a-b

ans=[0]*2

d=[]
for i in range(n):
    h=int(input())
    d.append(h)
d.sort(reverse=True)
ans[1]=max(d)
while ans[1]-ans[0]!=1:
    x=z=(ans[1]+ans[0])//2
    y=x*b
    for i in range(n):
        p=d[i]-y
        if p<=0:
            break
        x-=(p+t-1)//t
        if x<0:
            break
    if x<0:
        ans[0]=z
    else:
        ans[1]=z
print(ans[1])
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

h,w=map(int,input().split())
for i in range(h+2):
    if i==0 or i==h+1:
        print("#"*w+"##")
    else:
        a=input()
        print("#"+a+"#")

Fixed submission:
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

x,y=map(int,input().split())
a=[4,6,9,11]
if x==2 or y==2 or (x in a and y not in a) or (x not in a and y in a):
    print("No")
else:
    print("Yes")