Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import re
class c(int):
    global p
    def __add__(self,n):
        return c((int(self)+int(n))%p)
    def __sub__(self,n):
        return c((int(self)-int(n))%p)
    def __mul__(self,n):
        return c((int(self)*int(n))%p)
    def __truediv__(self,n):
        if n==0:raise ZeroDivisionError
        return self*(int(n)**(p-2))%p
  
while 1:
    p,f=input().replace(' ','').split(':')
    p=int(p)
    if p==0:break
    try:print('%s = %s (mod %s)'%(f,eval(re.sub(r'(\d+)',r'c(\1)',f)),p))
    except:
        print('NG')

Fixed submission:
import re
class c(int):
    global p
    def __add__(self,n):
        return c((int(self)+int(n))%p)
    def __sub__(self,n):
        return c((int(self)-int(n))%p)
    def __mul__(self,n):
        return c((int(self)*int(n))%p)
    def __truediv__(self,n):
        if n==0:raise ZeroDivisionError
        return self*pow(int(n),p-2,p)
  
while 1:
    p,f=input().replace(' ','').split(':')
    p=int(p)
    if p==0:break
    try:print('%s = %s (mod %s)'%(f,eval(re.sub(r'(\d+)',r'c(\1)',f)),p))
    except:print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n,k=map(int,input().split())
    if n==0:break
    a=[int(input()) for _ in range(k)]
    m=sum(a)
    for i in range(n-k):
        a.append(int(input()))
        m=max(m,sum(a[-k:]))
    print(m)

Fixed submission:
import queue
while 1:
    n,k=map(int,input().split())
    if n==0:break
    a=queue.deque(int(input()) for _ in range(k))
    m=b=sum(a)
    for i in range(n-k):
        c=a.popleft()
        d=int(input())
        a.append(d)
        b+=d-c
        m=max(b,m)        
    print(m)

Buggy python submission (verdict: Time Limit Exceeded):
import queue
while 1:
    n,k=map(int,input().split())
    if n==0:break
    a=queue.deque(int(input()) for _ in range(k))
    m=sum(a)
    for i in range(n-k):
        a.popleft()
        a.append(int(input()))
        m=max(m,sum(a))
    print(m)

Fixed submission:
import queue
while 1:
    n,k=map(int,input().split())
    if n==0:break
    a=queue.deque(int(input()) for _ in range(k))
    m=b=sum(a)
    for i in range(n-k):
        c=a.popleft()
        d=int(input())
        a.append(d)
        b+=d-c
        m=max(b,m)        
    print(m)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
while 1:
    n,m=map(int,input().split())
    if n==0:break
    s,a=[],[0]*(n+1)
    for i in range(1,n+1):
        a[i]=int(input())
        for j in range(i+1):
            if a[i]+a[j]<=m:s+=[a[i]+a[j]]
            else:break
    s.sort()
    print(max(i+s[bisect.bisect_right(s,m-i)-1]for i in s))

Fixed submission:
import bisect
while 1:
    n,m=map(int,input().split())
    if n==0:break
    s=[]
    a=[0]+sorted([int(input()) for _ in range(n)])
    for i in range(n+1):
        for j in a[i:]:
            if a[i]+j>m:break
            s+=[a[i]+j]
    s.sort()
    print(max(i+s[bisect.bisect_right(s,m-i)-1]for i in s))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
while 1:
    n,m,s=map(int,input().split())
    if n==0:break
    dp=[[0 for _ in range(s+2)] for _ in range(n*n+1)]
    dp[0][0]=1
    for i,j in itertools.product(range(1,m+1),range(n*n,0,-1)):
        for k in range(i,s+1):
            dp[j][k]=(dp[j][k]+dp[j-1][k-i])%100000
    print(dp[n*n][s])

Fixed submission:
import itertools
while 1:
    n,m,s=map(int,input().split())
    if n==0:break
    dp=[[0 for _ in range(s+1)] for _ in range(n*n+1)]
    dp[0][0]=1
    for i,j in itertools.product(range(1,n*n+1),range(s+1)):
        if j>=i:dp[i][j]+=dp[i-1][j-i]+dp[i][j-i]
        if j-m>=1:dp[i][j]-=dp[i-1][j-m-1]
        dp[i][j]%=100000
    print(dp[n*n][s])
Buggy python submission (verdict: Runtime Error):
c,d=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

Fixed submission:
s=list(map(int,input().split()))
if len(s)>1:c=s[0];d=s[1]
else:c=s[0];d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

Buggy python submission (verdict: Runtime Error):
s=map(int,input().split())
if len(s)==2:c=s[0];d=s[1]
else:c=s[0];d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

Fixed submission:
s=list(map(int,input().split()))
if len(s)>1:c=s[0];d=s[1]
else:c=s[0];d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

Buggy python submission (verdict: Runtime Error):
try:c,d=int(input().split())
except:d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

Fixed submission:
s=list(map(int,input().split()))
if len(s)>1:c=s[0];d=s[1]
else:c=s[0];d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

Buggy python submission (verdict: Runtime Error):
try:c,d=map(int,input().split())
except:d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

Fixed submission:
s=list(map(int,input().split()))
if len(s)>1:c=s[0];d=s[1]
else:c=s[0];d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

Buggy python submission (verdict: Runtime Error):
try:c,d=map(int,input().split())
except:c,d=5000;input()
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

Fixed submission:
s=list(map(int,input().split()))
if len(s)>1:c=s[0];d=s[1]
else:c=s[0];d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)
Buggy python submission (verdict: Time Limit Exceeded):
a=[['\'',',','.','!','?'],
   ['a','b','c','A','B','C'],
   ['d','e','f','D','E','F'],
   ['g','h','i','G','H','I'],
   ['j','k','l','J','K','L'],
   ['m','n','o','M','N','O'],
   ['p','q','r','s','P','Q','R','S'],
   ['t','u','v','T','U','V'],
   ['w','x','y','z','W','X','Y','Z']]
while 1:
    try:b=input()+'@'
    except:pass
    c=0
    ans=''
    for i in range(len(b)-1):
        if b[i]!=b[i+1]:
            if b[i]!='0':
                d=int(b[i])-1
                ans+=a[d][c%len(a[d])]
            c=0
        else: c+=1
        if b[i]==b[i+1]=='0':ans+=' '
    print(ans)

Fixed submission:
a=[['\'',',','.','!','?'],
   ['a','b','c','A','B','C'],
   ['d','e','f','D','E','F'],
   ['g','h','i','G','H','I'],
   ['j','k','l','J','K','L'],
   ['m','n','o','M','N','O'],
   ['p','q','r','s','P','Q','R','S'],
   ['t','u','v','T','U','V'],
   ['w','x','y','z','W','X','Y','Z']]
while 1:
    try:b=input()+'@'
    except:break
    c=0
    ans=''
    for i in range(len(b)-1):
        if b[i]!=b[i+1]:
            if b[i]!='0':
                d=int(b[i])-1
                ans+=a[d][c%len(a[d])]
            c=0
        else: c+=1
        if b[i]==b[i+1]=='0':ans+=' '
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n=int(input())
    if n==0:break
    a=0
    for i in range(1,n//2):a+=(n+2*i-1)//(2*i)-1
    print(8*(2*n-1+a))

Fixed submission:
while 1:
    n=int(input())
    if n==0:break
    a=0;i=1;b=n//2
    while i*i<b:a+=((b-1)//i+1)-i-1;i+=1
    a=(a+b-1)*2+i
    print(8*(a+n))
Buggy python submission (verdict: Runtime Error):
dp=[.0]*100001
dp[1]=1.
for i in range(2,100001):
    a,b,j=.5,1,1
    while j<i and b> 1e-5:
        dp[i]+=b*(1-a)*(j+dp[i-j-1])
        b*=al;a/=2;j+=1
    dp[i]+=i*b
while 1:
    n=int(input())
    if n==0:break
    print(dp[n])

Fixed submission:
dp=[.0]*100001
dp[1]=1.
for i in range(2,100001):
    a,b,j=.5,1,1
    while j<i and b>1e-15:
        dp[i]+=b*(1-a)*(j+dp[i-j-1])
        b*=a;a/=2;j+=1
    dp[i]+=i*b
while 1:
    n=int(input())
    if n==0:break
    print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n,s=map(int,input().split())
    if not n:break
    a=sorted([int(input()) for _ in range(n)],reverse=1)
    b=0
    try:
        for i in range(n):
            for j in range(i+1,n):
                if a[i]+a[j]>s:b+=1
                else:raise Exception;pass
    except:pass
    print(b)

Fixed submission:
while 1:
    n,s=map(int,input().split())
    if n==0:break
    r=[0]*101
    for _ in [0]*n:r[int(input())]+=1
    a=0
    for i in range(101):
        if i*2>s:a+=(r[i]**2-r[i])//2
        a+=r[i]*sum(r[j] for j in range(max(i+1,s+1-i),101))
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n,s=map(int,input().split())
    if not n:break
    a=sorted([int(input()) for _ in range(n)],reverse=1)
    b=0
    for i in range(n):
        try:
            for j in range(i+1,n):
                if a[i]+a[j]>s:b+=1
                else:raise Exception;break
        except:break
    print(b)

Fixed submission:
while 1:
    n,s=map(int,input().split())
    if n==0:break
    r=[0]*101
    for _ in [0]*n:r[int(input())]+=1
    a=0
    for i in range(101):
        if i*2>s:a+=(r[i]**2-r[i])//2
        a+=r[i]*sum(r[j] for j in range(max(i+1,s+1-i),101))
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n,s=map(int,input().split())
    if not n:break
    a=sorted([int(input()) for _ in range(n)],reverse=1)
    b=0
    for i in range(n):
        for j in range(i+1,n):
            if a[i]+a[j]>s:b+=1
            else:break
        if a[i]+a[j]<=s:break
    print(b)

Fixed submission:
while 1:
    n,s=map(int,input().split())
    if n==0:break
    r=[0]*101
    for _ in [0]*n:r[int(input())]+=1
    a=0
    for i in range(101):
        if i*2>s:a+=(r[i]**2-r[i])//2
        a+=r[i]*sum(r[j] for j in range(max(i+1,s+1-i),101))
    print(a)
Buggy python submission (verdict: Runtime Error):
def f(x,y):
    a[y][x]='0'
    for dx,dy in[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[1,-1],[-1,1],[1,1]]:
        dx+=x;dy+=y
        if 0<=dx<w and 0<=dy<h and a[dy][dx]=='1':f(dx,dy)
while 1:
    w,h=map(int,input().split())
    if w==0:break
    a=[list(input().split()) for _ in[0]*h];b=0
    for i in range(w):
        for j in range(h):
            if a[j][i]=='1':
                b+=1;f(i,j)
    print(b)

Fixed submission:
import sys
sys.setrecursionlimit(10000)
def f(x,y):
    if 0<=x<w and 0<=y<h and a[y][x]=='1':
        a[y][x]='0'
        for dx,dy in[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[1,-1],[-1,1],[1,1]]:f(x+dx,y+dy)
while 1:
    w,h=map(int,input().split())
    if w==0:break
    a=[input().split() for _ in[0]*h];b=0
    for i in range(w):
        for j in range(h):
            if a[j][i]=='1':
                b+=1;f(i,j)
    print(b)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1<<32)
def f(x,y):
    a[y][x]='0'
    for dx,dy in[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[1,-1],[-1,1],[1,1]]:
        dx+=x;dy+=y
        if 0<=dx<w and 0<=dy<h and a[dy][dx]=='1':f(dx,dy)
while 1:
    w,h=map(int,input().split())
    if w==0:break
    a=[list(input().split()) for _ in[0]*h];b=0
    for i in range(w):
        for j in range(h):
            if a[j][i]=='1':
                b+=1;f(i,j)
    print(b)

Fixed submission:
import sys
sys.setrecursionlimit(10000)
def f(x,y):
    if 0<=x<w and 0<=y<h and a[y][x]=='1':
        a[y][x]='0'
        for dx,dy in[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[1,-1],[-1,1],[1,1]]:f(x+dx,y+dy)
while 1:
    w,h=map(int,input().split())
    if w==0:break
    a=[input().split() for _ in[0]*h];b=0
    for i in range(w):
        for j in range(h):
            if a[j][i]=='1':
                b+=1;f(i,j)
    print(b)
Buggy python submission (verdict: Runtime Error):
for i in range(2,1201):
    for j in range(2,int(i**0.5)+1):
        if not i%j:break
    else:p+=[i]
dp=[[0]*1200 for _ in range(15)]
dp[0][0]=1
for x,y in enumerate(p):
    for i in range(min(x+1,14),0,-1):
        for j in range(p[x],1200):
            dp[i][j]+=dp[i-1][j-y]
while 1:
    n,k=map(int,input().split())
    if n==0:break
    print(dp[k][n])

Fixed submission:
p=[]
for i in range(2,1121):
    for j in range(2,int(i**0.5)+1):
        if not i%j:break
    else:p+=[i]
dp=[[0]*1121 for _ in range(15)]
dp[0][0]=1
for x,y in enumerate(p):
    for i in range(min(x+1,14),0,-1):
        for j in range(y,1121):
            dp[i][j]+=dp[i-1][j-y]
while 1:
    n,k=map(int,input().split())
    if n==0:break
    print(dp[k][n])
Buggy python submission (verdict: Runtime Error):
while 1:
    n=int(input())
    if n==0:break
    x=y=10
    b=[list(map(int,input().split())) for _ in range(n)]
    print(b)
    for i,j in [input().split() for _ in range(int(input()))]:
        for _ in range(int(j)):
            if 'N'<=i<='S': y+=1 if i=='N' else -1
            else: x+=1 if i=='E' else -1
            if [x,y] in b:del b[b.index([x,y])]
    print(['Yes','No'][len(b)])

Fixed submission:
while 1:
    n=int(input())
    if n==0:break
    x=y=10
    b=[list(map(int,input().split())) for _ in range(n)]
    for i,j in [input().split() for _ in range(int(input()))]:
        for _ in range(int(j)):
            if 'N'<=i<='S': y+=1 if i=='N' else -1
            else: x+=1 if i=='E' else -1
            if [x,y] in b:del b[b.index([x,y])]
    print(['Yes','No'][bool(b)])

Buggy python submission (verdict: Runtime Error):
while 1:
    n=int(input())
    if n==0:break
    x=y=10
    b=[list(map(int,input().split())) for _ in range(n)]
    for i,j in [input().split() for _ in range(int(input()))]:
        for _ in range(int(j)):
            if 'N'<=i<='S': y+=1 if i=='N' else -1
            else: x+=1 if i=='E' else -1
            if [x,y] in b:del b[b.index([x,y])]
    print(['Yes','No'][len(b)])

Fixed submission:
while 1:
    n=int(input())
    if n==0:break
    x=y=10
    b=[list(map(int,input().split())) for _ in range(n)]
    for i,j in [input().split() for _ in range(int(input()))]:
        for _ in range(int(j)):
            if 'N'<=i<='S': y+=1 if i=='N' else -1
            else: x+=1 if i=='E' else -1
            if [x,y] in b:del b[b.index([x,y])]
    print(['Yes','No'][bool(b)])
Buggy python submission (verdict: Time Limit Exceeded):
def f(p):
    return sum([n for n in range(1,p) if p%n==0])

while 1:
    n=int(input())
    if n==0:break
    m=f(n)
    if n==m:print('perfect number')
    else: print('deficient number' if n>m else 'abundant number')

Fixed submission:
def f(p):
    ans=1
    if p<=5: return 0
    for n in range(2,int(p**0.5)+1):
        if p%n==0:
            if n!=p//n:ans+=n+p//n
            else:ans+=n
    return ans

while 1:
    n=int(input())
    if n==0:break
    m=f(n)
    if n==m:print('perfect number')
    else: print('deficient number' if n>m else 'abundant number')

Buggy python submission (verdict: Time Limit Exceeded):
def f(p):
    ans=0
    for n in range(1,p):
        if p%n==0:ans+=n
    return ans

while 1:
    n=int(input())
    if n==0:break
    m=f(n)
    if n==m:print('perfect number')
    else: print('deficient number' if n>m else 'abundant number')

Fixed submission:
def f(p):
    ans=1
    if p<=5: return 0
    for n in range(2,int(p**0.5)+1):
        if p%n==0:
            if n!=p//n:ans+=n+p//n
            else:ans+=n
    return ans

while 1:
    n=int(input())
    if n==0:break
    m=f(n)
    if n==m:print('perfect number')
    else: print('deficient number' if n>m else 'abundant number')

Buggy python submission (verdict: Time Limit Exceeded):
def f(p):
    ans=0
    if p<=5: return ans
    for n in range(1,int(p/2)+1):
        if p%n==0:ans+=n
    return ans

while 1:
    n=int(input())
    if n==0:break
    m=f(n)
    if n==m:print('perfect number')
    else: print('deficient number' if n>m else 'abundant number')

Fixed submission:
def f(p):
    ans=1
    if p<=5: return 0
    for n in range(2,int(p**0.5)+1):
        if p%n==0:
            if n!=p//n:ans+=n+p//n
            else:ans+=n
    return ans

while 1:
    n=int(input())
    if n==0:break
    m=f(n)
    if n==m:print('perfect number')
    else: print('deficient number' if n>m else 'abundant number')
Buggy python submission (verdict: Runtime Error):
while 1:
    n,a,b=map(int,input().split())
    if n==a==b==0:break
    c=0;d=[1]*(n+1)
    for x in range(a):
        for i in range(x*b,n+1,a):d[i]=0
    print(sum(d))

Fixed submission:
import re
while 1:
    n,m=map(int,input().split())
    if n==0:break
    p=[];s=0
    for _ in [0]*n:
        n,M=input().replace('*','[0-9]').split()
        p.append([re.compile(n),int(M)])
    for _ in [0]*m:
        l=input()
        for n,M in p:
            if n.search(l):
                s+=M;break
    print(s)
Buggy python submission (verdict: Runtime Error):
x=0
for _ in range(int(input())):
    o,y=map(int,input().split())
    if o==1:x+=y
    elif o==2:x-=y
    elif o==3:x*=y
    else:x/=y
print(int(x))

Fixed submission:
m=10000000019
x=0
def mod(x):return (x%m+m)%m
def pow(x,a):
    ret=1
    while a:
        if(a&1):ret=mod(x*ret)
        x=mod(x*x)
        a>>=1
    return ret

for _ in range(int(input())):
    o,y=map(int,input().split())
    if o==1:x=(x+y)%m
    elif o==2:x=(x-y)%m
    elif o==3:x=mod(x*y)
    else:x=mod(x*pow(y,m-2))
print(x if x<(1<<31)else x-m)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
c=0;b=[]
for x in itertools.permutations(input()):
    if x not in b and x==x[::-1]:c+=1;b+=[x]
print(c)

Fixed submission:
import collections
from math import *
s=input()
a=collections.Counter(s)
o=0
for x in a:
    if a[x]&1:
        o+=1
        if o>1:print(0);break
        a[x]-=1
else:
    b=factorial(len(s)//2)
    for x in a.values():
        b//=factorial(x//2)
    print(b)
Buggy python submission (verdict: Time Limit Exceeded):
input()
a=list(map(int,input().split()))
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
[print(['Yes','No'][sum([j for j in a if j<=b[i]])<c[i]])for i in range(m)]

Fixed submission:
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
d=[0]*(n+1)
for i in range(1,n+1):d[i]=d[i-1]+a[i-1]
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
[print(['Yes','No'][d[bisect.bisect_right(a,b[i])]<c[i]]) for i in range(m)]

Buggy python submission (verdict: Time Limit Exceeded):
input()
a=list(map(int,input().split()))
d=[0]*(max(a)+1)
for i in a:d[i]=i*a.count(i)+d[i-1]
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
[print(['Yes','No'][d[b[i]]<c[i]])for i in range(m)]

Fixed submission:
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
d=[0]*(n+1)
for i in range(1,n+1):d[i]=d[i-1]+a[i-1]
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
[print(['Yes','No'][d[bisect.bisect_right(a,b[i])]<c[i]]) for i in range(m)]
Buggy python submission (verdict: Runtime Error):
while 1:
    s=input()
    if s=='#':break
    p=0
    e=[[],[]]
    for x in s:
        if x=='b':e[p]+=['b']
        elif x=='/':p+=1
        else:
            for j in range(int(x)):e[p]+=['.']
    ans=''
    a,b,c,d=map(int,input().split())
    e[a-1][b-1],e[c-1][d-1]=e[c-1][d-1],e[a-1][b-1]
    for i in range(2):
        if i: ans += '/'
        a=0
        for j in e[i]:
            if j=='b':
                if a:ans+=str(a)
                ans+='b'
                a=0
            else:a+=1
        if a:ans+=str(a)
    print(ans)

Fixed submission:
while 1:
    s=input()
    if '#' in s:break
    p=0
    e=[[]*2 for _ in range(10)]
    for x in s:
        if x=='b':e[p]+=['b']
        elif x=='/':p+=1
        else:e[p]+='.'*int(x)
    ans=''
    a,b,c,d=map(int,input().split())
    e[a-1][b-1],e[c-1][d-1]=e[c-1][d-1],e[a-1][b-1]
    for i in range(p+1):
        if i:ans+='/'
        a=0
        for j in e[i]:
            if j=='b':
                if a:ans+=str(a)
                ans+='b'
                a=0
            else:a+=1
        if a:ans+=str(a)
    print(ans)

Buggy python submission (verdict: Runtime Error):
while 1:
    s=input()
    if s=='#':break
    p=0
    e=[[],[]]
    for x in s:
        if x=='b':e[p]+=['b']
        elif x=='/':p+=1
        else:
            for j in range(int(x)):e[p]+=['.']
    ans=''
    a,b,c,d=map(int,input().split())
    e[a-1][b-1]='.'
    e[c-1][d-1]='b'
    for i in range(2):
        if i:ans+='/'
        a=0
        for j in e[i]:
            if j=='b':
                if a:ans+=str(a)
                ans+='b'
                a=0
            else:a+=1
        if a:ans+=str(a)
    print(ans)

Fixed submission:
while 1:
    s=input()
    if '#' in s:break
    p=0
    e=[[]*2 for _ in range(10)]
    for x in s:
        if x=='b':e[p]+=['b']
        elif x=='/':p+=1
        else:e[p]+='.'*int(x)
    ans=''
    a,b,c,d=map(int,input().split())
    e[a-1][b-1],e[c-1][d-1]=e[c-1][d-1],e[a-1][b-1]
    for i in range(p+1):
        if i:ans+='/'
        a=0
        for j in e[i]:
            if j=='b':
                if a:ans+=str(a)
                ans+='b'
                a=0
            else:a+=1
        if a:ans+=str(a)
    print(ans)
Buggy python submission (verdict: Runtime Error):
t=input();p=input()
for i in range(len(t)):
    if t[i:].startwith(p):print(i)

Fixed submission:
t=input();p=input()
[print(i)for i in range(len(t))if t[i:].startswith(p)]
Buggy python submission (verdict: Time Limit Exceeded):
t=input();p=input()
[print(i)for i in range(len(t))if t[i:].startswith(p)]

Fixed submission:
s=input();t=input()
[print(x) for x in range(len(s)-len(t)+1) if s[x:x+len(t)]==t]

Buggy python submission (verdict: Time Limit Exceeded):
t=input();p=input()
[print(i)for i in range(len(t)-len(p)+1)if t[i:].startswith(p)]

Fixed submission:
s=input();t=input()
[print(x) for x in range(len(s)-len(t)+1) if s[x:x+len(t)]==t]
Buggy python submission (verdict: Time Limit Exceeded):
a=[]
for _ in range(int(input())):
    b=input().split()
    if len(b)>1:c=int(b[1])
    b=b[0]
    if b[0]=='i':a=[c]+a
    elif len(b)>10:a=a[1:]
    elif len(b)>6:a.pop()
    else:
        try:a.remove(c)
        except:pass
print(*a)

Fixed submission:
import collections
a=collections.deque()
for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
print(*a)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
a=collections.deque()
for _ in range(int(input())):
    b=input().split()
    if len(b)>1:c=int(b[1])
    b=b[0]
    if b[0]=='i':a.appendleft(c)
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
    else:
        try:a.remove(c)
        except:pass
print(*a)

Fixed submission:
import collections
a=collections.deque()
for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
print(*a)
Buggy python submission (verdict: Time Limit Exceeded):
a=[]
while 1:
    b=input()
    if b[2]=='d':break
    if b[0]=='i':a+=[int(b[7:])]
    else:a.sort();print(a[-1]);a.pop()

Fixed submission:
from heapq import *
a=[]
while 1:
    b=input()
    if b[2]=='d':break
    if b[0]=='i':heappush(a,-int(b[7:]))
    else:print(-heappop(a))

Buggy python submission (verdict: Time Limit Exceeded):
a=[]
while 1:
    b=input()
    if b[2]=='d':break
    if b[0]=='i':a+=[int(b[7:])]
    else:c=max(a);print(c);a.remove(c)

Fixed submission:
from heapq import *
a=[]
while 1:
    b=input()
    if b[2]=='d':break
    if b[0]=='i':heappush(a,-int(b[7:]))
    else:print(-heappop(a))