Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import queue
def search(sy,sx,ey,ex):
    global H,W,Maze
    q = queue.Queue()

    Visit = [[-1]*W for _ in range(H)]
    Dir = [[0,1],[0,-1],[1,0],[-1,0]]

    Visit[sy][sx] = 0 
    q.put([sy,sx])

    while not q.empty():
        ty,tx = q.get()
        path = Visit[ty][tx]

        for dy,dx in Dir:
            ny = ty + dy
            nx = tx + dx
            if 0 <= ny and ny < H and 0 <= nx and nx < W:
                if Maze[ny][nx] == '.':
                    if ny == ey and nx == ex:
                        return path+1

                    if Visit[ny][nx] == -1:
                        Visit[ny][nx] = path+1
                        q.put([ny,nx])
    return -1

H,W = map(int,input().split())
Maze = []
for h in range(H):
    Maze.append(input())

ans = 0
for sy in range(H):
    for sx in range(W):
        if Maze[sy][sx] == '#':
            continue
        for ey in range(H):
            for ex in range(W):
                if Maze[ey][ex] == '#':
                    continue
                if sx == ex and sy == ey:
                    continue
                p = search(sy,sx,ey,ex)          
                if p != -1:
                    ans = max(ans,p)
print(ans)


Fixed submission:
import queue
def search(sy,sx):
    global H,W,Maze
    q = queue.Queue()

    Visit = [[-1]*W for _ in range(H)]
    Dir = [[0,1],[0,-1],[1,0],[-1,0]]

    Visit[sy][sx] = 0 
    q.put([sy,sx])

    while not q.empty():
        ty,tx = q.get()
        path = Visit[ty][tx]

        for dy,dx in Dir:
            ny = ty + dy
            nx = tx + dx
            if 0 <= ny and ny < H and 0 <= nx and nx < W:
                if Maze[ny][nx] == '.':
                    if Visit[ny][nx] == -1:
                        Visit[ny][nx] = path+1
                        q.put([ny,nx])
    max1 = 0
    for h in range(H):
        for w in range(W):
            max1 = max(max1,Visit[h][w])
    return max1

H,W = map(int,input().split())
Maze = []
for h in range(H):
    Maze.append(input())

ans = 0
for sy in range(H):
    for sx in range(W):
        if Maze[sy][sx] == '#':
            continue
        p = search(sy,sx)          
        if p > 0:
            ans = max(ans,p)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9+7

N   = int(input())
A   = list(map(int,input().split()))
A2   = [0]*N
BitNum = [0]*(61)

for i in range(1,61):
    A2 = [0] * N
    for j in range(N):
        A2[j] = A[j] % 2
        A[j] //= 2
    BitNum[i] = sum(A2)

ans = 0
beki = 0
for i in range(1,61):
    x = BitNum[i]
    y = N - x
    ans += (x*y)*(2**beki)
    ans %= MOD
    beki += 1
print(ans)


Fixed submission:
MOD = 10**9+7

N   = int(input())
A   = list(map(int,input().split()))
A2   = [0]*N
BitNum = [0]*(61)

for i in range(1,61):
    A2 = [0] * N
    for j in range(N):
        A2[j] = A[j] % 2
        A[j] //= 2
    BitNum[i] = sum(A2)

ans = 0
beki = 0
for i in range(1,61):
    x = BitNum[i]
    y = N - x
    ans += (x*y)*(2**beki)
    ans %= MOD
    beki += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
Data = [0]*(X+1)
Data[0] = 1

for c in range(100,106):
    for i in range(X+1):
        if Data[i] == 1:
            n = 1
            while c*n + i <= X:
                Data[c*n+i] = 1
                n+=1
if Data[X] == 1:
    print(1)
else:
    print(0)


Fixed submission:
X = int(input())

Data = [0]*(X+1)
Data[0] = 1

for c in range(100,106):
    for i in range(X+1):
        if Data[i] == 1:
            n = 1
            while c*n + i <= X:
                Data[c*n+i] = 1
                n+=1
if Data[X] == 1:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
def match(S,pat):
    i = 0
    for s in S:
        if s == pat[i]:
            i += 1
        if i == 3:
            return True
    return False

N = int(input())
S = input()
ans = 0

for n in range(1000):
    s = str(n)
    if len(s) == 1:
        s = '00'+s
    elif len(s) == 2:
        s = '0'+s
    else:
        pass
    if  match(S,s):
        ans += 1
    
print(ans)

Fixed submission:
def match(S,pat):
    i = 0
    for s in S:
        if s == pat[i]:
            i += 1
        if i == 3:
            return True
    return False

N = int(input())
S = input()
ans = 0

for n in range(1000):
    s = str(n)
    if len(s) == 1:
        s = '00'+s
    elif len(s) == 2:
        s = '0'+s
    else:
        pass
    if  match(S,s):
        ans += 1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9+7
S = input()
LenS = len(S)
DP = [[0] * 13 for _ in range(LenS+1)]

c = S[0]
if c == '?':
    for i in range(10):
        DP[1][i] = 1
else:
    n = int(c)
    DP[1][n] = 1

for i in range(2,LenS+1):
    c = S[i-1]
    if c == '?':
        for n in range(10):
            for j in range(13):
                k = (10*j+n) % 13
                DP[i][k] += DP[i-1][j] 
                DP[i][k] %= MOD
    else:
        n = int(c)  
        for j in range(13):
            k = (10*j+n) % 13
            DP[i][k] = DP[i-1][j] 
            DP[i][k] %= MOD

print(DP[LenS][5])

Fixed submission:
MOD = 10**9+7
S = input()
LenS = len(S)
DP = [[0] * 13 for _ in range(LenS+1)]

c = S[0]
if c == '?':
    for i in range(10):
        DP[1][i] = 1
else:
    n = int(c)
    DP[1][n] = 1

for i in range(2,LenS+1):
    c = S[i-1]
    if c == '?':
        for n in range(10):
            for j in range(13):
                k = (10*j+n) % 13
                DP[i][k] += DP[i-1][j] 
                DP[i][k] %= MOD
    else:
        n = int(c)  
        for j in range(13):
            k = (10*j+n) % 13
            DP[i][k] = DP[i-1][j] 
            DP[i][k] %= MOD

print(DP[LenS][5])
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int, input().split())

GcdCD = math.gcd(C,D)
LcmCD = (C*D)//GcdCD

s1 = B- ((B//C)+(B//D)-(B//LcmCD))
s2 = (A-1)-(((A-1)//C)+((A-1)//D)-((A-1)//LcmCD))
if s2 < 0:
    s2 = 0
print(s1-s2)

Fixed submission:
def gcd(a, b):
    if b > a:
        _ = b
        b = a
        a = _
    while b:
        a, b = b, a % b
    return a

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

GcdCD = gcd(C,D)
LcmCD = (C*D)//GcdCD

s1 = B- ((B//C)+(B//D)-(B//LcmCD))
s2 = (A-1)-(((A-1)//C)+((A-1)//D)-((A-1)//LcmCD))
if s2 < 0:
    s2 = 0
print(s1-s2)
Buggy python submission (verdict: Runtime Error):

N,M = map(int,input().split())
step  = [-1] * (N + 1)

for _ in range(M):
    a = int(input())
    step[a-1] = 0

if step[0] == -1:
    step[0] = 1

if step[1] == -1:
    step[1] = step[0]+1

for i in range(2,N):
    if step[i] == -1:
        step[i] = step[i-1]+step[i-2]

print(step[N-1] % 1000000007)


Fixed submission:
P,Q,R = map(int,input().split())
print(min(P+Q,min(P+R,Q+R)))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
step  = [-1] * N

for _ in range(M):
    a = int(input())
    step[a-1] = 0

if step[0] == -1:
    step[0] = 1

if step[1] == -1:
    step[1] = step[0]+1

for i in range(2,N):
    if step[i] == -1:
        step[i] = step[i-1]+step[i-2]

print(step[N-1] % 1000000007)


Fixed submission:

N,M = map(int,input().split())
step  = [-1] * (N + 1)

for _ in range(M):
    a = int(input())
    step[a-1] = 0

if step[0] == -1:
    step[0] = 1

if step[1] == -1:
    step[1] = step[0]+1

for i in range(2,N):
    if step[i] == -1:
        step[i] = step[i-1]+step[i-2]

print(step[N-1] % 1000000007)
Buggy python submission (verdict: Runtime Error):
r,D,x2000 = map(int,raw_input().split())
xi = x2000
for i in range(1,11):
    xi = r * xi - D
    print(xi)


Fixed submission:
#!/usr/bin/python3
A,B = map(int,input().split())
x = 0
if A >= 13:
    x = B
elif 6 <= A and A <= 12:
    x = B//2
else:
    x = 0
print(x)

Buggy python submission (verdict: Runtime Error):
r,D,x2000 = map(int,input().split())
xi = x2000
for i in range(1,11):
    xi = r * xi - D
    print(xi)


Fixed submission:
#!/usr/bin/python3
A,B = map(int,input().split())
x = 0
if A >= 13:
    x = B
elif 6 <= A and A <= 12:
    x = B//2
else:
    x = 0
print(x)
Buggy python submission (verdict: Runtime Error):
r,D,x2000 = map(int,raw_input().split())
xi = x2000
for i in range(1,11):
    xi = r * xi - D
    print(xi)


Fixed submission:
r,D,xi = map(int,input().split())
for i in range(10):
    xi = r * xi - D
    print(xi)
Buggy python submission (verdict: Runtime Error):
import sys
def dfs(n,c):
    if Ans[n] == -1:
        Ans[n] = c
        for m,w in Data[n]:
            if w % 2 == 0:
                dfs(m,c)
            else:
                dfs(m,1-c)
    elif Ans[n] == c:
        return
    else:
        return

sys.setrecursionlimit(10000)
N = int(input())
Data = []
Ans  = [-1] * N
for i in range(N):
    Data.append([])
for i in range(N-1):
    u,v,w = map(int,input().split())
    Data[u-1].append([v-1,w])
    Data[v-1].append([u-1,w])
dfs(0,0)

for a in Ans:
    print(a)

Fixed submission:
import sys
def dfs(n,c):
    if Ans[n] == -1:
        Ans[n] = c
        for m,w in Data[n]:
            if w % 2 == 0:
                dfs(m,c)
            else:
                dfs(m,1-c)
    elif Ans[n] == c:
        return
    else:
        return

sys.setrecursionlimit(100000)
N = int(input())
Data = []
Ans  = [-1] * N
for i in range(N):
    Data.append([])
for i in range(N-1):
    u,v,w = map(int,input().split())
    Data[u-1].append([v-1,w])
    Data[v-1].append([u-1,w])
dfs(0,0)

for a in Ans:
    print(a)

Buggy python submission (verdict: Runtime Error):
def dfs(n,c):
    if Ans[n] == -1:
        Ans[n] = c
        for m,w in Data[n]:
            if w % 2 == 0:
                dfs(m,c)
            else:
                dfs(m,1-c)
    elif Ans[n] == c:
        return
    else:
        return

N = int(input())
Data = []
Ans  = [-1] * N
for i in range(N):
    Data.append([])
for i in range(N-1):
    u,v,w = map(int,input().split())
    Data[u-1].append([v-1,w])
    Data[v-1].append([u-1,w])
dfs(0,0)

for a in Ans:
    print(a)

Fixed submission:
import sys
def dfs(n,c):
    if Ans[n] == -1:
        Ans[n] = c
        for m,w in Data[n]:
            if w % 2 == 0:
                dfs(m,c)
            else:
                dfs(m,1-c)
    elif Ans[n] == c:
        return
    else:
        return

sys.setrecursionlimit(100000)
N = int(input())
Data = []
Ans  = [-1] * N
for i in range(N):
    Data.append([])
for i in range(N-1):
    u,v,w = map(int,input().split())
    Data[u-1].append([v-1,w])
    Data[v-1].append([u-1,w])
dfs(0,0)

for a in Ans:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
def weight( n, lst ):
    l = len(lst)
    wei = 0
    for i in range(N):
        if n % 2 == 1:
            wei += lst[l-i-1] 
        n  = n // 2
    return wei

N = int(input())
Vlist = list(map(int,input().split()))
Clist = list(map(int,input().split()))

maxval = 0
for i in range(2 ** N):
    vsum = weight(i,Vlist)
    csum = weight(i,Clist)
    gain = vsum - csum
    if i == 0:
        maxval = gain
    else:
        if maxval < gain:
            maxval = gain

print(maxval)

Fixed submission:
N = int(input())
Vlist = list(map(int,input().split()))
Clist = list(map(int,input().split()))
sum1 = 0
for i in range(N):
    x = Vlist[i]
    c = Clist[i]
    if x - c > 0:
        sum1 += (x-c)
print(sum1)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)

Data = list(S)
Data = list(map(int,Data))

delnum = 1

while delnum != 0:
    i = 0
    delnum = 0
    while i < N:
        while i < N and Data[i] == -1:
            i += 1
        if i >= N:
            break

        c = Data[i]
        #
        c1_pos = i
        j = i + 1
        c1_count = 1 
        while j < N and (Data[j] == c or Data[j]==-1):
            if Data[j] == c:
                c1_count += 1
            j += 1
        #
        c2_pos = j
        c2_count = 0
        k = j
        while k < N and (Data[j] == (1-c) or Data[j] == -1):
            if Data[k] == 1-c:
                c2_count += 1
            k += 1

        i = k

        delnum = min(c1_count,c2_count)
        d = 0
        ii = 0

        while d < delnum:
            if Data[c1_pos+ii] == c:
                Data[c1_pos+ii]= -1
                d += 1
            ii += 1
        d = 0
        ii = 0
        while d < delnum:
            if Data[c2_pos+ii] == 1-c:
                Data[c2_pos+ii] = -1
                d += 1
            ii += 1
        
ans = 0
for n in Data:
    if n == -1:
        ans += 1
print(ans)


Fixed submission:
S = input()
n0 = S.count('0')
n1 = S.count('1')
print(len(S)-abs(n0-n1))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
AList = list(map(int,input().split()))
AList.sort(reverse=True)
NList=[0,2,5,5,4,5,6,3,7,6]
CList=[]
minnum = (-1)*(10**10)
dp = [0]*(N+1)

for a in AList:
    u = NList[a]
    if (u in CList) == False:
        CList.append(u)

dp[0] = 0
for n in range(1,N+1):
    max1 = minnum
    for c in CList:
        if c <= n:
            if dp[n-c] == minnum:
                num = minnum
            else:
                num = dp[n-c]+1
            if max1 < num:
                max1 = num
    dp[n] = max1

keta = dp[N]
s = ''
nn = N
for n in range(keta):
    for a in AList:
        if dp[nn-NList[a]] == dp[nn]-1:
            s += str(a)
            nn -= NList[a]
            break
print(s)


Fixed submission:
N,M = map(int,input().split())
AList = list(map(int,input().split()))
AList.sort(reverse=True)
NList=[0,2,5,5,4,5,6,3,7,6]
CList=[]
minnum = (-1)*(10**10)
dp = [0]*(N+1)

for a in AList:
    u = NList[a]
    if (u in CList) == False:
        CList.append(u)

dp[0] = 0
for n in range(1,N+1):
    max1 = minnum
    for c in CList:
        if c <= n:
            if dp[n-c] == minnum:
                num = minnum
            else:
                num = dp[n-c]+1
            if max1 < num:
                max1 = num
    dp[n] = max1
keta = dp[N]
s = ''
nn = N
for n in range(keta):
    for a in AList:
        if nn >= NList[a] and dp[nn-NList[a]] == dp[nn]-1:
            s += str(a)
            nn -= NList[a]
            break
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
INF = 10**12
Data = list(map(int,input().split()))
Data.insert(0,0)
DP = [INF]*(N+1)
DP[1]=0
for i in range(2,N+1):
    for j in range(1,K+1):
        if i-j >= 1:
            diff = abs(Data[i]-Data[i-j])
            DP[i] = min(DP[i],DP[i-j]+diff)
print(DP[N])

Fixed submission:
N,K = map(int,input().split())
INF = 10**12
Data = list(map(int,input().split()))
Data.insert(0,0)
DP = [INF]*(N+1)
DP[1]=0
for i in range(2,N+1):
    for j in range(1,K+1):
        if i-j >= 1:
            diff = abs(Data[i]-Data[i-j])
            DP[i] = min(DP[i],DP[i-j]+diff)
print(DP[N])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
HList = list(map(int,input().split()))
dp = [0]*(N)

for i in range(N):
    for k in range(1,K+1):
        if i + k > N-1:
            break
        cost = dp[i]+abs(HList[i]-HList[i+k])
        if dp[i+k] == 0:
            dp[i+k] = cost
        else:
            dp[i+k]= min(dp[i+k],cost)

print(dp[N-1])

Fixed submission:
N,K = map(int,input().split())
INF = 10**12
Data = list(map(int,input().split()))
Data.insert(0,0)
DP = [INF]*(N+1)
DP[1]=0
for i in range(2,N+1):
    for j in range(1,K+1):
        if i-j >= 1:
            diff = abs(Data[i]-Data[i-j])
            DP[i] = min(DP[i],DP[i-j]+diff)
print(DP[N])
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
INF = 10**12
V = 1000 * N
Data = []
Data.append([0,0])
for _ in range(N):
    Data.append(list(map(int,input().split())))

#DP[n][v]: n番目までの品物で 価値vの品物を選んだ場合の重さの最小
DP = [[INF]*(V+1) for _ in range(N+1)]
for n in range(N+1):
    DP[n][0] = 0

for n in range(1,N+1):
    for v in range(1,V+1):
        wi,vi = Data[n]
        if v >= vi:
            DP[n][v] = min(DP[n][v],DP[n-1][v-vi]+wi)
        DP[n][v] = min(DP[n][v],DP[n-1][v])

ans = 0
for  v in range(V+1):
    if DP[N][v] <= W:
        ans = v
print(ans)

Fixed submission:
N,W = map(int,input().split())
INF = 10**12
V = 1000 * N
Data = []
Data.append([0,0])
for _ in range(N):
    Data.append(list(map(int,input().split())))

DP = [[INF]*(V+1) for _ in range(N+1)]
for n in range(N+1):
    DP[n][0] = 0

for n in range(1,N+1):
    for v in range(1,V+1):
        wi,vi = Data[n]
        if v >= vi:
            DP[n][v] = min(DP[n][v],DP[n-1][v-vi]+wi)
        DP[n][v] = min(DP[n][v],DP[n-1][v])

ans = 0
for  v in range(V+1):
    if DP[N][v] <= W:
        ans = v
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def disp(dp):
    for d in dp:
        print(d)
    print("")

s = input()
t = input()

dp = []
for i in range(len(s)+1):
    dp.append([0]*(len(t)+1))

#s のi番目 tのj番目(indexではないまでの共通部分文字列
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1]==t[j-1]:
            dp[i][j] = max(dp[i][j],dp[i-1][j-1]+1)
        dp[i][j] = max(dp[i][j],dp[i-1][j])
        dp[i][j] = max(dp[i][j],dp[i][j-1])

        #print(s[:i])
        #print(t[:j])
        #disp(dp)

i = len(s)
j = len(t)
res = ""
while i > 0 and j > 0:
    #print( "i={} j={}".format(i,j))
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i-1][j-1]+1:
        res += s[i-1]
        i -= 1
        j -= 1

print(res[::-1])

Fixed submission:
S = input()
T = input()
lens = len(S)
lent = len(T)

DP = [[0]*(lent+1) for _ in range(lens+1)]

for i in range(1,lens+1):
    for j in range(1,lent+1):
        if S[i-1] == T[j-1]:
            DP[i][j] = max(DP[i][j],DP[i-1][j-1]+1)
        DP[i][j] = max(DP[i][j],DP[i][j-1])
        DP[i][j] = max(DP[i][j],DP[i-1][j])
ans = ""
i = lens
j = lent
while i > 0 and j > 0:
    if DP[i][j] == DP[i-1][j]:
        i -= 1
    elif DP[i][j] == DP[i][j-1]:
        j -= 1
    else:
        ans += S[i-1]
        i -= 1
        j -= 1
print(ans[::-1])
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
Data = []
for _ in range(N):
    x,y,h = map(int,input().split())
    if h != 0:
        Data.append([x,y,h])

Data.sort(key=lambda x:x[2],reverse=True)

for cx in range(101):
    for cy in range(101):
        found = True
        ans   = -1
        for i in range(0,N):
            x,y,h = Data[i]
            if i == 0:
                ans = h + abs(x-cx)+abs(y-cy)
            else:
                ph = h + abs(x-cx)+abs(y-cy)
                if ans != ph:
                    found = False
                    break
        if found == True:
            print( '{} {} {}'.format(cx,cy,ans))
            sys.exit()

Fixed submission:
import sys
N = int(input())
Data = []
for _ in range(N):
    x,y,h = map(int,input().split())
    Data.append([x,y,h])

Data.sort(key=lambda x:x[2],reverse=True)

for cx in range(101):
    for cy in range(101):
        found = True
        ans   = -1
        for i in range(N):
            x,y,h = Data[i]
            if i == 0:
                # h != 0
                ans = h + abs(x-cx)+abs(y-cy)
            else: 
                diff = ans - abs(x-cx)-abs(y-cy)
                if  diff < 0:
                    if h != 0:
                        found = False
                        break
                else: 
                    if diff != h:
                        found = False
                        break
        if found == True:
            print( '{} {} {}'.format(cx,cy,ans))
            sys.exit()
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
Data = []
for _ in range(H):
    List = list(map(int,input().split()))
    Data.append(List)
Ans = []
for i in range(H-1):
    for j in range(W):
        if Data[i][j] % 2 != 0:
            Data[i][j] -= 1
            Data[i+1][j] += 1
            Ans.append([i,j,i+1,j])
for j in range(W-1):
    if Data[H-1][j] % 2 != 0:
        Data[H-1][j] -= 1
        Data[H-1][j+1] += 1
        Ans.append([H-1,j,H-1,j+1])

print(len(Ans))
for ans in Ans:
    print( "{} {} {} {}".fo

Fixed submission:
H,W = map(int,input().split())
Data = []
for _ in range(H):
    List = list(map(int,input().split()))
    Data.append(List)
Ans = []
for i in range(H-1):
    for j in range(W):
        if Data[i][j] % 2 != 0:
            Data[i][j] -= 1
            Data[i+1][j] += 1
            Ans.append([i,j,i+1,j])
for j in range(W-1):
    if Data[H-1][j] % 2 != 0:
        Data[H-1][j] -= 1
        Data[H-1][j+1] += 1
        Ans.append([H-1,j,H-1,j+1])

print(len(Ans))
for ans in Ans:
    print( "{} {} {} {}".format(ans[0]+1,ans[1]+1,ans[2]+1,ans[3]+1))
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
Data1 = []

for _ in range(H):
    Data1.append(s)

hdata = {}
wdata = {}

for h in range(H):
    for w in range(W):
        if Data1[h][w] == '#':
            hdata.add(h)
            wdata.add(w)

for h in range(H):
    for w in range(W):
        if h in hdata or w in wdata:
            print(Data[h][w],end='')

Fixed submission:
H,W = map(int,input().split())
Data1 = []

tbl = str.maketrans({'.':'0','#':'1'})
for _ in range(H):
    s = input().translate(tbl)
    s = list(map(int,list(s)))
    if sum(s) > 0:
        Data1.append(s)

dellist = []
for w in range(W):
    flag = False
    for data in Data1:
        if data[w] == 1:
            flag = True
            break
    if flag == False:
        dellist.append(w)

for i in range(len(dellist)-1,-1,-1):
    for data in Data1:
        data.pop(dellist[i])

for data in Data1:
    for i in range(len(data)):
        if data[i] == 0:
            print('.',end='')
        else:
            print('#',end='')
    print("")
Buggy python submission (verdict: Runtime Error):
AList = list(map(int,input().split()))
AList.sort()
print(abs(AList[0]-AList[1])+abs(AList[2]-AList[1])

Fixed submission:
AList = list(map(int,input().split()))
AList.sort()
print(abs(AList[0]-AList[1])+abs(AList[2]-AList[1]))
Buggy python submission (verdict: Time Limit Exceeded):
Data = []
def diff(b):
    sum1 = 0
    for d in Data:
        sum1 += abs(b-d)
    return sum1

N = int(input())
Data = list(map(int,input().split()))
for i in range(N):
    Data[i] -= (i+1) 

ans = 10**20
for d in Data:
    ans = min(ans,diff(d))
print(ans)

Fixed submission:
Data = []
def diff(b):
    sum1 = 0
    for d in Data:
        sum1 += abs(b-d)
    return sum1

N = int(input())
Data = list(map(int,input().split()))
for i in range(N):
    Data[i] -= (i+1) 

Data.sort()
if N % 2 != 0:
    mid = Data[N//2]
    ans = diff(mid)
else:
    mid1 = Data[N//2-1]
    mid2 = Data[N//2]
    ans = min(diff(mid1),diff(mid2))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
K = int(input())
Data = set()

for s in range(N):
    for e in range(s+1,N+1):
        Data.add(S[s:e])
print(sorted(Data)[K-1])

Fixed submission:
S = input()
N = len(S)
K = int(input())
Data = set()

for s in range(N):
    for e in range(s+1,min(N+1,s+1+K+1)):
        Data.add(S[s:e])
print(sorted(Data)[K-1])
Buggy python submission (verdict: Runtime Error):
def calc_prime(N):
    for i in range(3,N+1,2):
        x = int(math.sqrt(i))+1
        j = 0
        prime = True
        while j < len(PrimeList) and PrimeList[j] <= x:
            if i % PrimeList[j] == 0:
                prime = False
                break
            j += 1
        if prime:
            PrimeList.append(i)

calc_prime(55555)
AnsList = []
for p in PrimeList:
    if p % 5 == 1:
        AnsList.append(p)

N = int(input())
for i in range(N):
    print(AnsList[i],end=' ')
print('')

Fixed submission:
import math
PrimeList = [2]

def calc_prime(N):
    for i in range(3,N+1,2):
        x = int(math.sqrt(i))+1
        j = 0
        prime = True
        while j < len(PrimeList) and PrimeList[j] <= x:
            if i % PrimeList[j] == 0:
                prime = False
                break
            j += 1
        if prime:
            PrimeList.append(i)

calc_prime(55555)
AnsList = []
for p in PrimeList:
    if p % 5 == 1:
        AnsList.append(p)

N = int(input())
for i in range(N):
    print(AnsList[i],end=' ')
print('')
Buggy python submission (verdict: Runtime Error):
a1=input() 
a2=input() 
a3=input() 
rint(a1[0]+a2[1]+a3[2])

Fixed submission:
a1=input() 
a2=input() 
a3=input() 
print(a1[0]+a2[1]+a3[2])