Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03696 (python)

Fixed submission:
def main():
    N = int(input())
    S = input()

    s = S
    while True:
        s = s.replace('()', '')
        if s.count('()') == 0:
            break

    if len(s) == 0:
        print(S)
        return

    left = ''
    right = ''
    if s[0] == ')':
        left = '(' * s.count(')')
    if s[-1] == '(':
        right = ')' * s.count('(')

    print('{}{}{}'.format(left, S, right))

main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    S = input()

    s = S
    while True:
        s = s.replace('()', '')
        if s.count('()') == 0:
            break

    left = ''
    right = ''
    l = s.count('(')
    r = s.count(')')
    if s[0] == ')':
        left = '(' * r
    if s[-1] == '(':
        right = ')' * l

    print('{}{}{}'.format(left, S, right))

main()
Problem p03760 (python)

Fixed submission:
def main():
    O = list(input())
    E = list(input())

    if len(O) > len(E):
        E.append('')

    i = 0
    passwd = ''
    while i < len(O):
        passwd = passwd + O[i] + E[i]
        i += 1
    print(passwd)

main()

Buggy submission (verdict: Runtime Error):
def main():
    O = list(input())
    E = list(input())

    if len(E) % 2 != 0:
        E.append('')

    i = 0
    passwd = ''
    while i < len(O):
        passwd = passwd + O[i] + E[i]
        i += 1
    print(passwd)

main()
Problem p03761 (python)

Fixed submission:
import sys

def main():
    N = int(input())

    i = 0
    S = []
    while i < N:
        S.append(list(str(input())))
        i += 1
    if N == 1:
        ans = sorted(S[0])
        print(''.join(ans))
        sys.exit()

    i = 0
    while i < N - 1:
        sset = set(S[i]) & set(S[i+1])
        i += 2

    ans = []
    for a in sset:
        i = 0
        n = []
        while i < N:
            n.append(S[i].count(a))
            i += 1
        small = min(n)
        ans.append(a * small)

    ans.sort()
    print(''.join(ans))

main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())

    i = 0
    S = []
    while i < N:
        S.append(list(str(input())))
        i += 1

    i = 0
    while i < N - 1:
        sset = set(S[i]) & set(S[i+1])
        i += 2

    ans = []
    for a in sset:
        i = 0
        n = []
        while i < N:
            n.append(S[i].count(a))
            i += 1
        small = min(n)
        ans.append(a * small)

    ans.sort()
    print(''.join(ans))

main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())

    i = 0
    S = []
    while i < N:
        S.append(sorted(list(str(input()))))
        i += 1

    i = 0
    while i < N - 1:
        s = set(S[i]) & set(S[i+1])
        i += 2

    ans = []
    for a in s:
        i = 0
        x = []
        while i < N:
            x.append(S[i].count(a))
            i += 1
        n = min(x)
        ans.append(a * n)

    ans.sort()
    print(''.join(ans))

main()
Problem p03807 (python)

Fixed submission:
def even(num):
    if num & 1:
        return('uneven')
    else:
        return('even')

N = int(input())
A = list(map(int, input().split()))

n = 0
for a in A:
    if even(a) == 'uneven':
        n += 1

if even(n) == 'even':
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
def even(num):
    if num & 1:
        return('uneven')
    else:
        return('even')

N = int(input())
A = list(map(int, input().split()))

n = 0
for a in A:
    if even(a) == 'uneven':
        n += 1

if even(n) =a= 'even':
    print('YES')
else:
    print('NO')
Problem p03828 (python)

Fixed submission:
def main():
    N = int(input())

    if N == 1:
        print(1)
        return

    lst = erastosthenes(N)
    plist = [i for i in range(3, N + 1, 2) if lst[i]]
    plist = [2] + plist

    mod = 1000000007
    ans = 1
    for p in plist:
        cnt = 0
        i = 1
        while 1:
            x = p ** i
            if x > N:
                break
            cnt += N // x
            i += 1
        ans = ans * (cnt + 1) % mod
    print(ans)

def erastosthenes(n):
    prime = [0, 1] * ((n + 1) // 2)
    if not n % 2:
        prime += [0]
    prime[1], prime[2] = 0, 1

    sqrt = n ** 0.5
    i = 3
    while i <= sqrt:
        for j in range(i ** 2, n + 1, i):
            prime[j] = 0
        i += 2
    return prime

main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())

    lst = erastosthenes(N)
    plist = [i for i in range(3, N + 1, 2) if lst[i]]
    plist = [2] + plist

    mod = 1000000007
    ans = 1
    for p in plist:
        cnt = 0
        i = 1
        while 1:
            x = p ** i
            if x > N:
                break
            cnt += N // x
            i += 1
        ans = (ans % mod * (cnt + 1) % mod) % mod
    print(ans)

def erastosthenes(n):
    prime = [0, 1] * ((n + 1) // 2)
    if not n % 2:
        prime += [0]
    prime[1], prime[2] = 0, 1

    sqrt = n ** 0.5
    i = 3
    while i <= sqrt:
        for j in range(i ** 2, n, i):
            prime[j] = 0
        i += 2
    return prime

main()
Problem p03964 (python)

Fixed submission:
def main():
    N = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in [0] * N)

    if N == 1:
        print(sum(A[0]))
        return

    before_t = A[0][0]
    before_a = A[0][1]
    for t, a in A[1:]:
        n1 = -(-before_t // t)
        n2 = -(-before_a // a)
        n = max(n1, n2)
        taka, aoki = t * n, a * n
        before_t, before_a = taka, aoki

    print(taka + aoki)

main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in [0] * N)

    before_t = A[0][0]
    before_a = A[0][1]
    for t, a in A[1:]:
        n1 = -(-before_t // t)
        n2 = -(-before_a // a)
        n = max(n1, n2)
        taka, aoki = t * n, a * n
        before_t, before_a = taka, aoki

    print(taka + aoki)

main()
Problem p03998 (python)

Fixed submission:
a = list(input())
b = list(input())
c = list(input())

n = a[0]
if len(a) < 1:
    del a[0]

while True:
    if n == "a":
        n = a[0]
        del a[0]
        if len(a) == 0:
            print("A")
            break
    elif n == "b":
        n = b[0]
        del b[0]
        if len(b) == 0:
            print("B")
            break
    elif n == "c":
        n = c[0]
        del c[0]
        if len(c) == 0:
            print("C")
            break

Buggy submission (verdict: Runtime Error):
a = list(input())
b = list(input())
c = list(input())

n = a[0]
del a[0]
if len(a) == 0:
    print("A")
while True:
    if n == "a":
        n = a[0]
        del a[0]
        if len(a) == 0:
            print("A")
            break
    elif n == "b":
        n = b[0]
        del b[0]
        if len(b) == 0:
            print("B")
            break
    elif n == "c":
        n = c[0]
        del c[0]
        if len(c) == 0:
            print("C")
            break

Buggy submission (verdict: Runtime Error):
a = list(input())
b = list(input())
c = list(input())

n = a[0]
del a[0]
if len(a) == 0:
    print("A")
    break
while True:
    if n == "a":
        n = a[0]
        del a[0]
        if len(a) == 0:
            print("A")
            break
    elif n == "b":
        n = b[0]
        del b[0]
        if len(b) == 0:
            print("B")
            break
    elif n == "c":
        n = c[0]
        del c[0]
        if len(c) == 0:
            print("C")
            break

Buggy submission (verdict: Runtime Error):
a = list(input())
b = list(input())
c = list(input())

n = a[0]
del a[0]
while True:
    if n == "a":
        n = a[0]
        del a[0]
        if len(a) == 0:
            print("A")
            break
    elif n == "b":
        n = b[0]
        del b[0]
        if len(b) == 0:
            print("B")
            break
    elif n == "c":
        n = c[0]
        del c[0]
        if len(c) == 0:
            print("C")
            break
Problem p04013 (python)

Fixed submission:
def main():
    N, A = map(int, input().split())
    X = tuple(map(int, input().split()))

    x = [i - A for i in X]
    nx = max(X) * N
    dp = [[0] * (2 * nx + 1) for _ in [0] * (N + 1)]
    for i in range(N + 1):
        for j in range(2 * nx + 1):
            if not i:
                if j == nx:
                    dp[i][j] = 1
            elif j - x[i-1] < 0 or j - x[i-1] > 2 * nx:
                dp[i][j] = dp[i-1][j]
            elif 0 <= j - x[i-1] <= 2 * nx:
                dp[i][j] = dp[i-1][j] + dp[i-1][j - x[i-1]]
    print(dp[N][nx] - 1)

main()

Buggy submission (verdict: Runtime Error):
def main():
    N, A = map(int, input().split())
    X = tuple(map(int, input().split()))

    x = [i - A for i in X]
    nx = max(x) * N
    dp = [[0] * (2 * nx + 1) for _ in [0] * (N + 1)]
    for i in range(N + 1):
        for j in range(2 * nx + 1):
            if not i:
                if j == nx:
                    dp[i][j] = 1
            elif j - x[i-1] < 0 or j - x[i-1] > 2 * nx:
                dp[i][j] = dp[i-1][j]
            elif 0 <= j - x[i-1] <= 2 * nx:
                dp[i][j] = dp[i-1][j] + dp[i-1][j - x[i-1]]
    print(dp[N][nx] - 1)

main()
Problem p04045 (python)

Fixed submission:
def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))

    for i in range(10):
        if i not in D:
            min_ = i
            break

    ans = []
    apnd = ans.append
    num, top, i = N, 0, 0
    while num > 0:
        while num % 10 in D:
            num += 1
            top = i
        num, m = divmod(num, 10)
        apnd(m)
        i += 1

    ans[0:top] = [min_] * top
    print(*ans[::-1], sep='')

main()

Buggy submission (verdict: Runtime Error):
def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))

    for i in range(10):
        if i not in D:
            min_ = i
            break

    ans = []
    apnd = ans.append
    num, i = N, 0
    while num > 0:
        while num % 10 in D:
            num += 1
            top = i
        num, m = divmod(num, 10)
        apnd(m)
        i += 1

    ans[0:top] = [min_] * top
    print(*ans[::-1], sep='')

main()
Problem p02576 (python)

Fixed submission:
N,X,T = map(int,input().split())
a = N // X
Time = 0
if N % X == 0:
    Time = a*T
else:
    Time = (a+1)*T
print(Time)

Buggy submission (verdict: Runtime Error):
N,X,T = map(int,input().split())
a = N // X
if N % X == 0:
    Time = a*T
else:
    Tiem = (a+1)*T
print(Time)
Problem p02584 (python)

Fixed submission:
X,K,D = map(int,input().split())
X = abs(X)
ans = 0
if X - D*K> 0:
    ans = X-D*K
else:
    count = X//D
    K -= count
    X -= count*D
    if K%2 == 1:
        X = abs(X-D)
    ans = X
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
X,K,D = map(int,input().split())
lst = lst = list(map(sum, itertools.product([0, 1], repeat=K)))
ans = 10**15
for i in range(2**K):
    x = 0
    p = 0; n = 0
    p = lst[i]*D
    n = (K-lst[i])*(-D)
    x = abs(X + n + p)
    if x < ans:
        ans = x
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
X,K,D = map(int,input().split())
lst = list(map(list, itertools.product([0, 1], repeat=K)))
ans = 10**15
for i in range(2**K):
    x = 0
    n = (lst[i].count(0))*-D
    p = (lst[i].count(1))*D
    x = abs(X + n + p)
    if x < ans:
        ans = x
print(ans)
Problem p02717 (python)

Fixed submission:
#imput
a,b,c = map(int,input().split())

a, b = b, a
a, c = c, a

print(a,b,c)

Buggy submission (verdict: Runtime Error):
import fractions
N, K = map(int,input().split())
N = fractions.gcd(N,K)
min = N
for i in range(10**8):
    N = abs(N-K)
    if min > N:
        min = N
    if N == 0:
        min = 0
        break
print(min)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left

N, M = map(int,input().split())
A = list(map(int,input().split()))

#print(M)
A.sort()
#print(A)

limit = sum(A)/(4*M)
#print(limit)

n = bisect_left(A, limit)
#print(N-n-1)
if N-n-1 >= M:
    print("Yes")
else:
    print("No")
Problem p02719 (python)

Fixed submission:
#
N, K = map(int,input().split())
N  %= K
min = N
for i in range(10**6):
    N = abs(N-K)
    if min > N:
        min = N
    if N == 0:
        min = 0
        break
print(min)

Buggy submission (verdict: Runtime Error):
from collections import deque
k = int(input())
Q = deque(range(1, 10))
for _ in range(k):
  x = Q.popleft()
  y = x % 10
  z = 10*x + y
  if y != 0:
    Q += [z-1]
  Q += [z]
  if y != 9:
    Q += [z+1]
print(x)

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int,input().split())
N = math.gcd(N,K)
for i in range(10*6):
    N = abs(N-K)
    if N == 0:
        break
print(N)

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int,input().split())

N = math.gcd(N,K)

for i in range(10*6):
    N = abs(N-K)
    if N == 0:
        break

print(N)

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int,input().split())

#print(N,K)

N = math.gcd(N,K)

for i in range(10*7):
    N = abs(N-K)
    if N == 0:
        break

print(N)
Problem p02755 (python)

Fixed submission:
#input
A, B = map(int,input().split())
#消費税0.08 0.1
import math

ans = -1

for n in range(1001):##最大値を間違えていた
        if math.floor(n*0.08) == A and math.floor(n*0.1) == B:
            ans = int(n)
            break

print(ans)

Buggy submission (verdict: Runtime Error):
ans = -1

for n in range(1001):##最大値を間違えていた
        if math.floor(n*0.08) == A and math.floor(n*0.1) == B:
            ans = n
            break

print(ans)
Problem p03031 (python)

Fixed submission:
N,M = map(int,input().split()) #N:スイッチ　＃M：電球
light=[]
for i in range(M):
    light.append(list(map(int,input().split())))



p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    #print("num {}" .format(i), end="")
    sw = [0]*N
    for j in range(N):
        if ((i >>j) & True):
            sw[j]=1
    On_Light_nmb = 0
    for m in range(M): #電球ごとに判定
        sum = 0
        for k in range(light[m][0]):
            s_nmb = int(light[m][k+1])
            sum += sw[s_nmb-1]

        if sum%2 == p[m]: #電球mのOnスイッチの合計が
            #Ans.append(1)
            On_Light_nmb +=1


    #もしすべてのライトがついていたら
    if On_Light_nmb == m+1:
        ans +=1

print(ans)

Buggy submission (verdict: Runtime Error):
M = map(int,input().split()) #N:スイッチ　＃M：電球
#print(N)

light=[]
for i in range(M):
    light.append(list(map(int,input().split())))
#print(light)


p = list(map(int,input().split()))
#print(p)

ans = 0
for i in range(2**N):
    #print("num {}" .format(i), end="")
    sw = [0]*N
    for j in range(N):
        if ((i >>j) & True):
            sw[j]=1

    else:
        pass
        #print(sw)

    #Ans =[]
    On_Light_nmb = 0
    for m in range(M): #電球ごとに判定
        sum = 0
        for k in range(light[m][0]):
            s_nmb = int(light[m][k+1])
            #print(s_nmb)
            #print(sw[s_nmb-1])
            sum += sw[s_nmb-1]

        if sum%2 == p[m]: #電球mのOnスイッチの合計が
            #Ans.append(1)
            On_Light_nmb +=1
            #print('light '+str(m)+' on')
        else:
            pass
            #Ans.append(0)
            #print('light '+str(m)+' off')

    #print('ans:'+str(ans))

    #もしすべてのライトがついていたら
    if On_Light_nmb == m+1:
        ans +=1

print(ans)
Problem p02924 (python)

Fixed submission:
n=int(input())
if n==1:
  print(0)
else:
  print(n*(n-1)//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=(n*(n+1)//2)-1-n+n%2
if n==1:
  print("0")
else if n==2:
  print("1")
else:
  print(ans)
Problem p03302 (python)

Fixed submission:
a,b=map(int,input().split())
if a + b == 15:
  print('+')
elif a * b == 15:
  print('*')
else:
  print('x')

Buggy submission (verdict: Runtime Error):
a,b=map(int,intput().split())
if a + b == 15:
  print('+')
elif a * b == 15:
  print('*')
else:
  print('x')
Problem p03308 (python)

Fixed submission:
n = int(input())
min_A = 10**9+7
max_A = -1
for i in input().split():
  tmp = int(i)
  max_A = max(tmp,max_A)
  min_A = min(min_A,tmp)
  
print(abs(max_A-min_A))

Buggy submission (verdict: Runtime Error):
n = int(input())
min_A = 10**9+7
max_A = -1
for i in range(n):
  tmp = int(input())
  max_A = max(tmp,max_A)
  min_A = min(min_A,tmp)
  
print(abs(max_A-min_A))
Problem p03324 (python)

Fixed submission:
d,n=map(int,input().split())
if n == 100: n = 101
print(n*10**(2*d))

Buggy submission (verdict: Runtime Error):
d,n=map(int,intput().split())
print(n*10**(2*d))
Problem p03359 (python)

Fixed submission:
a, b=map(int,input().split())
if  a <= b :
	print(a)
else:
	print(a-1)

Buggy submission (verdict: Runtime Error):
a,b=int(input())
if a < b:
	print(a)
else:
	print(a-1)
Problem p03369 (python)

Fixed submission:
n=input()
ans=700
for i in range (3):
	if n[i]=='o':
  		ans=ans+100
print(ans)

Buggy submission (verdict: Runtime Error):
n=input
ans=700
for i in range (3):
	if n[0]=='o':
  		ans=ans+100
print(ans)
Problem p03385 (python)

Fixed submission:
s=sorted(input())
ans="abc"
flag=1
for i in range(3):
  if s[i] != ans[i]:
    print("No")
    flag=0
    break

if flag==1:
  print("Yes")

Buggy submission (verdict: Runtime Error):
s=sorted(input())
ans="abc"
flag=1
for i in range(3)
	if s[i] != ans[i]:
    	print("No")
        flag=0
    	break
if flag==1:
  print("Yes")
Problem p03455 (python)

Fixed submission:
a, b=map(int,input().split())
if a%2 and b%2:
  print("Odd")
else:
  print("Even")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a%2 || b%2:
  print("Even")
else:
  print("Odd")
Problem p03477 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
l=a+b
r=c+d
if l < r:
  print("Right")
elif l==r:
  print("Balanced")
else:
  print("Left")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
l=a+b
r=c+d
if l < r:
  print("Right")
else if l==r:
  print("Blanceed")
else:
  print("Left")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().spilit())
l=a+b
r=c+d
if l < r:
  print("Right")
else:
  print("Left")
Problem p03501 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a*b < c:
  print(a*b)
else:
  print(c)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a*b < c:
  print(a*b)
else:
  pirnt(c)
Problem p03547 (python)

Fixed submission:
a,b =input().split()
if a == b:
  print("=")
elif a < b:
  print("<")
else:
  print(">")

Buggy submission (verdict: Runtime Error):
a,b =map(input())
if a == b:
  print("=")
elif a < b:
  print("<")
else:
  print(">")

Buggy submission (verdict: Runtime Error):
x=input()
y=input()
if x==y:
  print("=")
elif x < y:
  print("<")
else:
  print(">")
Problem p03609 (python)

Fixed submission:
a,b=map(int,input().split())
if a <= b:
  print(0)
else:
  print(a-b)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a <= b:
  print(0)
else:
  print(a-b):
Problem p02584 (python)

Fixed submission:
x,k,d=map(int,input().split())
x =abs(x)
o =x//d
if (x-d*k) >=0:
    print(x-d*k)
    exit()
else:
    if (k-o)%2==0:
        print(abs(x%d))
        exit()
    else:
        print(abs(x%d-d))
        exit()

Buggy submission (verdict: Runtime Error):
x,k,d=map(int,input().split())
o =x//d
if x <0 and x-(1*d*0)+(1*d*(k-0)) <=0:
    print(x-(1*d*0)+(1*d*(k-0)))
    exit()
else:
    print(min(x+(1*d*o,x+(1*d*(o+1),x+(1*d*(o-1)))
    exit()
    
if x >0 and x-(1*d*k)+(1*d*(0)) >=0:
    print(x-(1*d*k)+(1*d*(0)))
    exit()
else:
   print( min(x-(1*d*o,x-(1*d*(o+1),x-(1*d*(o-1)))
   exit()

Buggy submission (verdict: Runtime Error):
x,k,d=map(int,input().split())
o =x//d
if x <0 and x-(1*d*0)+(1*d*(k-0)) <=0:
    print(x-(1*d*0)+(1*d*(k-0)))
    exit()
else:
    print(min(x+(1*d*o,x+(1*d*(o+1),x+(1*d*(o-1)))
    
if x >0 and x-(1*d*k)+(1*d*(0)) >=0:
    print(x-(1*d*k)+(1*d*(0)))
    exit()
else:
   print( min(x-(1*d*o,x-(1*d*(o+1),x-(1*d*(o-1)))
Problem p02602 (python)

Fixed submission:
N,K = map(int,input().split())
T = list(map(int,input().split()))
for p in range(N-K):
    if T[p] - T[p+K] <0:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
T = list(map(int,input().split()))
Number = []
for j in range(N-K+1):
    Num=1
    for i in range(K):
        Num *=T[i+j]/10***3
    Number.append(Num)

for p in range(N-K):
    if Number[p+1] - Number[p] >0:
        print('Yes')
    else:
        print('No')
Problem p02803 (python)

Fixed submission:
from collections import deque
H, W = map(int, input().split())
maze = [input() for i in range(H)]

def bfs(maze, sy, sx):
    visited = [[-1]*W for j in range(H)]
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        ans=0
        y, x = queue.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if 0 <= new_y < H and 0 <= new_x < W:
                if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1 :
                    visited[new_y][new_x] = visited[y][x] + 1
                    queue.append([new_y, new_x])
                    
    for l in range(H):
        for m in range(W):
            ans = max(ans,visited[l][m])
            
    return ans
        
ma=0
for sy in range(H):
    for sx in range(W):
        if maze[sy][sx] == ".":
            if bfs(maze,sy,sx) is not None:
                ma = max(bfs(maze, sy, sx),ma)
print(ma)

Buggy submission (verdict: Runtime Error):
from collections import deque
H, W = map(int, input().split())
maze = [input() for i in range(H)]

def bfs(maze, sy, sx, gy, gx):
    visited = [[-1]*W for j in range(H)]
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if 0 <= new_y < H and 0 <= new_x < W:
                if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1 :
                    visited[new_y][new_x] = visited[y][x] + 1
                    queue.append([new_y, new_x])
ma=0
for sy in range(H):
    for sx in range(W):
        for gy in range(H):
            for gx in range(W):

        if maze[sy][sx] == "." and maze[gy][gx] == ".":
            if bfs(maze,sy,sx,gy,gx) is not None:
                ma = max(bfs(maze, sy, sx, gy, gx),ma)
print(ma)