Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input(). split())
if (a*b) % 2:
    ptint('Odd')
else:
    print('Even')

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

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input(). split())
if a*b % 2:
    ptint('Odd')
else:
    print('Even')

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

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input(). split())
if a*b % 2:
    ptint('Odd')
else:
    print('Even')
    

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

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input(), split())
if a*b % 2:
    ptint('Odd')
else:
    print('Even')

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

Buggy python submission (verdict: Runtime Error):
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a,b = map(int, input(), split())\n",
    "if a*b % 2:\n",
    "    ptint('Odd')\n",
    "else:\n",
    "    print()\n",
    "    "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}


Fixed submission:
a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")
Buggy python submission (verdict: Runtime Error):
s = str(input())
t = str(input())
s = (sorted(s))
t = (sorted(t,reverse = True))
s2 = ''.join(s)
t2 = ''.join(t)

if s2 < t2:
    print('Yes')
else:
    print('No')

Fixed submission:
import math
a,b = map(int,input().split())
x = (a + b)/2
print(math.ceil(x))

Buggy python submission (verdict: Runtime Error):
s = str(input())
t = str(input())
s2 = ''.join(sorted(s))
t2 = ''.join(sorted(t,reverse=True))

if s2 < t2:
    print('Yes')
else:
    print('No')

Fixed submission:
import math
a,b = map(int,input().split())
x = (a + b)/2
print(math.ceil(x))

Buggy python submission (verdict: Runtime Error):
s = str(input())
t = str(input())
s2 = ''.join(sorted(s))
t2 = ''.join(sorted(t))

if s2 < t2:
    print('Yes')
else:
    print('No')

Fixed submission:
import math
a,b = map(int,input().split())
x = (a + b)/2
print(math.ceil(x))
Buggy python submission (verdict: Runtime Error):
a = str(input())
s = o
for i in range(0, 3):
    if a[i] == '1':
        s += 1
print(s)

Fixed submission:
a = str(input())
s = 0
for i in range(0, 3):
    if a[i] == '1':
        s += 1
print(s)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())

ans = 0

while A % 2 == 0:
    A = A / 2
    ans = ans +1
return ans

print(ans)

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

def x(n):
    ans = 0
    while n % 2 == 0:
        n /= 2
        ans += 1
    return ans

ans = min(map(x, A))

print(ans)
Buggy python submission (verdict: Runtime Error):
r = input()
g = input()
print(2*g - r)

Fixed submission:
r = int(input())
g = int(input())
print(int(2*g - r))
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = list(input() for _ in range(h))

for i in range(h):
    ans = ""
    for j in range(w):
        if s[i][j] == "#":
            ans += "#"
        else:
            ans += str(sum(k[max(0, j-1):min(w, j+2)]) for k in s[max(0, i-1):min(h, i+2)]
        print(ans)

Fixed submission:
h, w = map(int, input().split())
s = list(input() for _ in range(h))

for i in range(h):
    ans = ""
    for j in range(w):
        if s[i][j] == "#":
            ans += "#"
        else:
            ans += str(sum(k[max(0, j-1):min(w, j+2)].count('#') for k in s[max(0, i-1):min(h, i+2)]))
    print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

res = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    res = res.replace(s[i], "")
if len(s) == 0:
    print("None")
else:
    print(res[0])

Fixed submission:
s = input()

res = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    res = res.replace(s[i], "")
if len(res) == 0:
    print("None")
else:
    print(res[0])
Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 1
whille ans*2 <= n:
    ans *= 2
print(ans)

Fixed submission:
n = int(input())

ans = 1

while ans*2 <= n:
    ans *= 2
print(ans)

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

ans = 1
whille ans*2 <= n:
    ans += 2
print(ans)

Fixed submission:
n = int(input())

ans = 1

while ans*2 <= n:
    ans *= 2
print(ans)
Buggy python submission (verdict: Runtime Error):
r,g,b = map(int, input().split)
x = 100*r +10*g +b
if x % 4 == 0:
    print('YES')
else:
    print('NO')

Fixed submission:
r,g,b = map(int, input().split())
x = 100*r +10*g + b
if x % 4 == 0:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

p = 1

for i in range(1, n+1):
    p *= i
print(p%(10**9+7))

Fixed submission:
n = int(input())

p = 1

for i in range(1, n+1):
    p = p*i%(10**9+7)
print(p)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

flag = False

for i in range(n):
    for j in range(n-m+1):
        cnt = 0
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] == b[k][l]:
                    cnt += 1
        if cnt == m**2:
            flag = True
            break
    if flag:
        break
print("Yes" if flag else "No")

Fixed submission:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

flag = False

for i in range(n-m+1):
    for j in range(n-m+1):
        cnt = 0
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] == b[k][l]:
                    cnt += 1
        if cnt == m**2:
            flag = True
            break
    if flag:
        break
print("Yes" if flag else "No")
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())

cnt = 0

for i in range(a, b+1):
    if i%x == 0:
        cnt += 1
print(cnt)

Fixed submission:
a, b, x = map(int, input().split())

ans = b//x - (a-1)//x

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

ans = []

for i in s:
    if i == "0":
        ans.append("0")
    elif i == "1":
        ans.append("1")
    else:
        ans.pop()
print("".join(ans))

Fixed submission:
s = input()

ans = []

for i in s:
    if i == "0":
        ans.append("0")
    elif i == "1":
        ans.append("1")
    elif i == "B" and len(ans) == 0:
        ans
    else:
        ans.pop()
print("".join(ans))
Buggy python submission (verdict: Runtime Error):
n = map(int, input().split())
for i in range(5):
  if n[i] == 0:
    print(i+1)
	exit()

Fixed submission:
print(list(input().split()).index("0")+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())))
s = 1
if o in a:
    print(0)
    exit()
for i in range(n):
  s *= a[i]
  if s>10**18:
      print(-1)
      exit()
print(s)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
  s *= a[i]
  if s>10**18:
      print(-1)
      exit()
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(n-1):
  a[i+1]*=a[i]
print(a[i+1] if a[i+1]<=10**18 else -1)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
  s *= a[i]
  if s>10**18:
      print(-1)
      exit()
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

if 0 in a :
  ans = 0
else :
  ans = 1
  
for i in range(n) :
  ans *= a[i]
  if ans > 10**18 :
    ans = -1
    
print(ans)

Fixed submission:
import sys

n = int(input())
a = list(map(int,input().split()))

if 0 in a :
  print(0)
  sys.exit()

ans = 1
for i in range(n) :
  ans *= a[i]
  if ans > 10**18 :
    ans = -1
    break
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

if 0 in a :
  ans = 0
else :
  ans = 1
  
for i in range(n) :
  ans *= a[i]
  if ans > 10**18 :
    ans = -1
    
print(ans)

Fixed submission:
import sys

n = int(input())
a = list(map(int,input().split()))

if 0 in a :
  print(0)
  sys.exit()

ans = 1
for i in range(n) :
  ans *= a[i]
  if ans > 10**18 :
    ans = -1
    break
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

ans = 1
for i in range(n) :
  ans *= a[i]
    
if ans > 10**18 :
    ans = -1
    
print(ans)

Fixed submission:
import sys

n = int(input())
a = list(map(int,input().split()))

if 0 in a :
  print(0)
  sys.exit()

ans = 1
for i in range(n) :
  ans *= a[i]
  if ans > 10**18 :
    ans = -1
    break
    
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

ans = 1
for n in range(n) :
  ans *= a[i]
  if ans > 10**18 :
    ans = -1
    break
    
print(ans)

Fixed submission:
import sys

n = int(input())
a = list(map(int,input().split()))

if 0 in a :
  print(0)
  sys.exit()

ans = 1
for i in range(n) :
  ans *= a[i]
  if ans > 10**18 :
    ans = -1
    break
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = map(int,input().split())

ans = 0
for i in range(1,k+1) :
    if i <= a :
        ans += 1
    if i >= a+b+1 :
        ans -= 1

print(ans)

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


if k <= a :
    ans = k
elif k <= a+b :
    ans = a
else :
    ans = a - (k-a-b)

print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = [[0]*n for i in range(k)]

for i in range(k) :
    index = int(input()) - 1
    a = list(map(int,input().split()))
    a = [i-1 for i in a]
    for c in a :
        s[index][c] = 1

ans = 0
for i in range(n) :
    check = 1
    for j in range(k) :
        if s[j][i] == 1 :
            check = 0
            break
    if check == 1 :
        ans += 1

print(ans)

Fixed submission:
n,k = map(int,input().split())
s = [[0]*n for i in range(k)]

for i in range(k) :
    n_i = int(input())
    a = list(map(int,input().split()))
    a = [i-1 for i in a]
    for j in range(n_i) :
        s[i][a[j]] = 1

ans = 0
for i in range(n) :
    check = 1
    for j in range(k) :
        if s[j][i] == 1 :
            check = 0
            break
    if check == 1 :
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

a,b,n = map(int,input().split())

c = 0
ans = -1
for i in range(1,10**7) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    if ans > math.floor((a*x)/b)-a*math.floor(x/b) :
        break
    ans = math.floor((a*x)/b)-a*math.floor(x/b)
    if c == 1 :
        break

print(ans)

Fixed submission:
import math

a,b,n = map(int,input().split())

c = 0
ans = -1
for i in range(1,10**7) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    if ans > math.floor((a*x)/b)-a*math.floor(x/b) :
        break
    ans = math.floor((a*x)/b)-a*math.floor(x/b)
    if c == 1 :
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

a,b,n = map(int,input().split())

c = 0
ans = -1
for i in range(1,10**18) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    if ans > math.floor((a*x)/b)-a*math.floor(x/b) :
        break
    ans = math.floor((a*x)/b)-a*math.floor(x/b)
    if c == 1 :
        break

print(ans)

Fixed submission:
import math

a,b,n = map(int,input().split())

c = 0
ans = -1
for i in range(1,10**7) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    if ans > math.floor((a*x)/b)-a*math.floor(x/b) :
        break
    ans = math.floor((a*x)/b)-a*math.floor(x/b)
    if c == 1 :
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

a,b,n = map(int,input().split())

c = 0
ans = 0
for i in range(1,10**18) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    ans = max(ans,math.floor((a*x)/b)-a*math.floor(x/b))
    if c == 1 :
        break

print(ans)

Fixed submission:
import math

a,b,n = map(int,input().split())

c = 0
ans = -1
for i in range(1,10**7) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    if ans > math.floor((a*x)/b)-a*math.floor(x/b) :
        break
    ans = math.floor((a*x)/b)-a*math.floor(x/b)
    if c == 1 :
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

a,b,n = map(int,input().split())

c = 0
ans = 0
for i in range(1,10**18) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    ans = max(ans,math.floor((a*x)/b)-a*math.floor(x/b))
    if c == 1 :
        break

print(ans)

Fixed submission:
import math

a,b,n = map(int,input().split())

c = 0
ans = -1
for i in range(1,10**7) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    if ans > math.floor((a*x)/b)-a*math.floor(x/b) :
        break
    ans = math.floor((a*x)/b)-a*math.floor(x/b)
    if c == 1 :
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = 0
for i in range(n-2) :
  si = s[i]
  for j in range(i+1,n-1) :
    sj = s[j]
    if si == sj :
      continue
    for k in range(j+1,n) :
      sk = s[k]
      if si == sk or sj == sk or j-i == k-j :
        continue
      ans += 1
      
print(ans)

Fixed submission:
n = int(input())
s = input()

R_i = {}
G_i = {}
B_i = {}

ans = 0
for i in range(n) :
  if s[i] == 'R' :
    R_i[i] = 1
  if s[i] == 'G' :
    G_i[i] = 1
  if s[i] == 'B' :
    B_i[i] = 1

ans = len(R_i)*len(G_i)*len(B_i)

for ri in R_i :
  for gi in G_i :
    # Rが真ん中
    if 2*ri-gi in B_i :
      ans -= 1
    # Gが真ん中
    if 2*gi-ri in B_i :
      ans -= 1
    # Bが真ん中
    if (ri+gi)%2 == 0 :
      if (ri+gi)//2 in B_i :
        ans -= 1
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = 0
for i in range(n-2) :
  si = s[i]
  for j in range(i+1,n-1) :
    sj = s[j]
    if si == sj :
      continue
    for k in range(j+1,n) :
      sk = s[k]
      if si == sk or sj == sk or j-i == k-j :
        continue
      ans += 1
      
print(ans)

Fixed submission:
n = int(input())
s = input()

R_i = {}
G_i = {}
B_i = {}

ans = 0
for i in range(n) :
  if s[i] == 'R' :
    R_i[i] = 1
  if s[i] == 'G' :
    G_i[i] = 1
  if s[i] == 'B' :
    B_i[i] = 1

ans = len(R_i)*len(G_i)*len(B_i)

for ri in R_i :
  for gi in G_i :
    # Rが真ん中
    if 2*ri-gi in B_i :
      ans -= 1
    # Gが真ん中
    if 2*gi-ri in B_i :
      ans -= 1
    # Bが真ん中
    if (ri+gi)%2 == 0 :
      if (ri+gi)//2 in B_i :
        ans -= 1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

ss = input()
q = int(input())
s = deque()

for i in range(len(ss)) :
  s.append(ss[i])

for i in range(q) :
  t = list(map(str,input().split()))
  if t[0] == '1' :
    s.reverse()
  if t[0] == '2' :
    f = t[1] ; c = t[2]
    if f == '1' :
      s.appendleft(c)
    else :
      s.append(c)
      
print(*s,sep='')

Fixed submission:
from collections import deque

ss = input()
q = int(input())
s = deque()

for i in range(len(ss)) :
  s.append(ss[i])

r = 0
for i in range(q) :
  t = list(map(str,input().split()))
  if t[0] == '1' :
    r += 1
  if t[0] == '2' :
    f = t[1] ; c = t[2]
    if r%2 == 0 :
      if f == '1' :
        s.appendleft(c)
      else :
        s.append(c)
    else :
      if f == '2' :
        s.appendleft(c)
      else :
        s.append(c)
        
if r%2 == 1 :
  s.reverse()
  
print(*s,sep='')

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for i in range(q) :
  t = list(map(str,input().split()))
  if t[0] == '1' :
    s = s[::-1]
  if t[0] == '2' :
    f = t[1] ; c = t[2]
    if f == '1' :
      s = c + s
    else :
      s = s + c
      
print(s)


Fixed submission:
from collections import deque

ss = input()
q = int(input())
s = deque()

for i in range(len(ss)) :
  s.append(ss[i])

r = 0
for i in range(q) :
  t = list(map(str,input().split()))
  if t[0] == '1' :
    r += 1
  if t[0] == '2' :
    f = t[1] ; c = t[2]
    if r%2 == 0 :
      if f == '1' :
        s.appendleft(c)
      else :
        s.append(c)
    else :
      if f == '2' :
        s.appendleft(c)
      else :
        s.append(c)
        
if r%2 == 1 :
  s.reverse()
  
print(*s,sep='')

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for i in range(q) :
  t = list(map(str,input().split()))
  if t[0] == '1' :
    s = s[::-1]
  if t[0] == '2' :
    f = t[1] ; c = t[2]
    if f == '1' :
      s = c + s
    else :
      s = s + c
      
print(s)

Fixed submission:
from collections import deque

ss = input()
q = int(input())
s = deque()

for i in range(len(ss)) :
  s.append(ss[i])

r = 0
for i in range(q) :
  t = list(map(str,input().split()))
  if t[0] == '1' :
    r += 1
  if t[0] == '2' :
    f = t[1] ; c = t[2]
    if r%2 == 0 :
      if f == '1' :
        s.appendleft(c)
      else :
        s.append(c)
    else :
      if f == '2' :
        s.appendleft(c)
      else :
        s.append(c)
        
if r%2 == 1 :
  s.reverse()
  
print(*s,sep='')
Buggy python submission (verdict: Runtime Error):
import sys

n,m = map(int,input().split())
s = [] ; c = []
for i in range(m) :
  st,ct = map(int,input().split())
  s.append(st) ; c.append(ct)

if n == 1 :
  ans(c[0])
  sys.exit()

ans = [[0,0] for i in range(n)]  
for i in range(m) :
  if s[i] == 1 and c[i] == 0 :
    print(-1)
    sys.exit()
  if ans[s[i]-1][1] == 0 :
    ans[s[i]-1][0] = c[i] 
    ans[s[i]-1][1] = 1
  else :
    if ans[s[i]-1][0] != c[i] :
      print(-1)
      sys.exit()

if ans[0][0] == 0 :
  ans[0][0] = 1

ansn = 0
for i in range(n) :
  ansn += ans[i][0]*10**(n-1-i)
  
print(ansn)

Fixed submission:
import sys

n,m = map(int,input().split())
s = [] ; c = []
for i in range(m) :
  st,ct = map(int,input().split())
  s.append(st) ; c.append(ct)

ans = [[0,0] for i in range(n)]  
for i in range(m) :
  if s[i] == 1 and c[i] == 0 and n >= 2 :
    print(-1)
    sys.exit()
  if ans[s[i]-1][1] == 0 :
    ans[s[i]-1][0] = c[i] 
    ans[s[i]-1][1] = 1
  else :
    if ans[s[i]-1][0] != c[i] :
      print(-1)
      sys.exit()

if ans[0][0] == 0 and n >= 2 :
  ans[0][0] = 1

ansn = 0
for i in range(n) :
  ansn += ans[i][0]*10**(n-1-i)
  
print(ansn)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(float,input().split()))

for i in range(n) :
  p[i] = (p[i]+1)/2

ans = 0
for i in range(n-k+1) :
  ans = max(ans,sum(p[i:k+i]))
  
print(ans)

Fixed submission:
n,k = map(int,input().split())
p = list(map(float,input().split()))

for i in range(n) :
  p[i] = (p[i]+1)/2

# ans[i] = iを含めてk個前までの期待値の総和
ans = [0 for i in range(n)]
ans[k-1] = sum(p[0:k])
for i in range(k,n) :
  ans[i] = ans[i-1] + p[i] - p[i-k]
  
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 0
for i in range(1,10) :
  for j in range(i,10) :
    c_a = 0
    c_b = 0
    for k in range(1,n+1) :
      if int(str(k)[0]) == i and int(str(k)[-1]) == j :
        c_a += 1
      if int(str(k)[0]) == j and int(str(k)[-1]) == i :
        c_b += 1
    if i == j :
      ans += c_a*c_b
    else :
      ans += c_a*c_b*2
print(ans)

Fixed submission:
n = int(input())

ans = 0
for i in range(1,10) :
  for j in range(i,10) :
    c_a = 0
    c_b = 0
    for k in range(1,n+1) :
      kl = len(str(k))
      if k//(10**(kl-1)) == i and k%10 == j :
        c_a += 1
      if k//(10**(kl-1)) == j and k%10 == i :
        c_b += 1
    if i == j :
      ans += c_a*c_b
    else :
      ans += c_a*c_b*2
      
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

def bfs(maze, visited, sy, sx, gy, gx):
  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 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])

h,w = map(int,input().split())
wall = ''
for i in range(w+2):
  wall += '#'
maze = [wall]
for i in range(h) :
  m1 = input()
  maze.append('#'+m1+'#')
maze .append(wall)

s = [[1,1],[1,h],[w,1],[w,h]]
g = [[w,h],[w,1],[1,h],[1,1]]

ans = []
for i in range(4) :
  sy = s[i][1] ; sx = s[i][0]
  for j in range(1,h+1) :
    for k in range(1,w+1) :
      gy = j ; gx = k
      if maze[gy][gx] == '#' :
        break
      visited = [[-1]*(w+2) for _ in range(h+2)]
      ans.append(bfs(maze, visited, sy, sx, gy, gx))

print(max(ans))

Fixed submission:
n,m = map(int,input().split())
p = []
s = []

for i in range(m):
  p1,s1 = map(str,input().split())
  p.append(int(p1))
  s.append(s1)

#0が正答したかどうか（正答が1）、1がペナルティの数
ans = [[0,0] for i in range(n)]

for i in range(m) :
  if s[i] == 'AC' :
    ans[p[i]-1][0] = 1
  if s[i] == 'WA' and ans[p[i]-1][0] == 0 :
    ans[p[i]-1][1] += 1

ac = 0
pe = 0
for i in range(n) :
  ac += ans[i][0]
  if ans[i][0] == 1 :
    pe += ans[i][1]

print(ac,pe)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

r = 0
index = -1
ans = 0
for i in range(n) :
  index += 1
  r += 1
  if index >= n :
    break
  for j in range(n) :
    if a[index] == r :
      break
    ans += 1
    index += 1
      
if ans == n :
  print(-1)
else :
  print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

r = 0
index = 0
ans = 0
for i in range(n) :
  r += 1
  for j in range(n) :
    if index >= n :
      break
    if a[index] == r :
      index += 1
      break
    ans += 1
    index += 1
      
if ans == n :
  print(-1)
else :
  print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ip = []

for i in range(n):
  a = int(input())
  ip.append(a)
  for j in range(a):
    x,y = map(int,input().split())
    ip.append([x,y])

max = 0    
for i in range(n) :
  max += 2**i

ans = 0
for i in range(0,max+1) :
  s = [2 for _ in range(n)]
  bit = i
  count = 0
  index = 0
  check = 0
  for j in range(n) :
    if bit%2 == 1 :
      if s[j] == 0 :
        check = 1
      s[j] = 1
    else :
      if s[j] == 1 :
        check = 1
      s[j] = 0
    bit = bit//2
    for k in range(ip[index]) :
      if s[j] == 1 :
        if ip[index+1+k][1] == 1 :
          if s[ip[index+1+k][0]-1] == 0 :
            check = 1
          s[ip[index+1+k][0]-1] = 1
        elif ip[index+1+k][1] == 0 :
          if s[ip[index+1+k][0]-1] == 1 :
            check = 1
          s[ip[index+1+k][0]-1] = 0
    index += ip[index] + 1
  if ans < s.count(1) and check ==0 :
    ans = s.count(1)

print(ans)

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

if a+b+c >= 22 :
  print('bust')
else :
  print('win')