Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
plus = []
total_minus = 0
for i in range(n):
    diff = a[i] - b[i]
    if diff >= 0:
        plus.append(diff)
    else:
        total_minus += (-1) * diff
plus.sort(reverse=True)
if total_minus == 0:
    print(0)
elif sum(plus) < total_minus:
    print(-1)
else:
    ans = n - len(plus)
    for i in range(n):
        if total_minus <= 0:
            break
        total_minus -= plus[i]
        ans += 1
print(ans)

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
plus = []
minus = []
for i in range(n):
    diff = a[i] - b[i]
    if diff >= 0:
        plus.append(diff)
    else:
        minus.append((-1) * diff)
plus.sort(reverse=True)
plus = collections.deque(plus)
if len(minus) == 0:
    print(0)
    exit()
if sum(plus) < sum(minus):
    print(-1)
    exit()
ans = len(minus)
total = sum(minus)
while total > 0:
    total -= plus.popleft()
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    cost = [float('inf')] * n
    cost[0] = 0
    for i in range(1, n):
        for j in range(1, k + 1):
            if i - j < 0:
                break
            else:
                cost[i] = min(cost[i], cost[i - j] + abs(h[i] - h[i - j]))
    print(cost[n - 1])


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    cost = [float('inf')] * n
    cost[0] = 0
    for i in range(1, n):
        for j in range(1, k + 1):
            if i - j < 0:
                break
            else:
                cost[i] = min(cost[i], cost[i - j] + abs(h[i] - h[i - j]))
    print(cost[n - 1])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
cost = [float('inf')] * n
cost[0] = 0
for i in range(1, n):
    for j in range(1, k + 1):
        if i - j < 0:
            break
        else:
            cost[i] = min(cost[i], cost[i - j] + abs(h[i] - h[i - j]))
print(cost[n - 1])

Fixed submission:
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    cost = [float('inf')] * n
    cost[0] = 0
    for i in range(1, n):
        for j in range(1, k + 1):
            if i - j < 0:
                break
            else:
                cost[i] = min(cost[i], cost[i - j] + abs(h[i] - h[i - j]))
    print(cost[n - 1])


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n, w = map(int, input().split())
weight = []
value = []
for _ in range(n):
    wi, vi = map(int, input().split())
    weight.append(wi)
    value.append(vi)
weight.append(0)
value.append(0)
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - weight[i] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - weight[i]] + value[i])
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[n][w])

Fixed submission:
n, w = map(int, input().split())
weight = []
value = []
for _ in range(n):
    wi, vi = map(int, input().split())
    weight.append(wi)
    value.append(vi)
weight.append(0)
value.append(0)
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - weight[i] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - weight[i]] + value[i])
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[n][w])
Buggy python submission (verdict: Runtime Error):
import math
n, p = map(int, input().split())
cnt = [0] * math.ceil(math.sqrt(p))
ans = 1
for i in range(2, math.ceil(math.sqrt(p))):
    cnt = 0
    while p % i == 0 and p != 0:
        p //= i
        cnt[i] += 1
    ans *= i ** (cnt[i] // n)
ans *= p ** (1 // n)
print(ans)

Fixed submission:
import math
n, p = map(int, input().split())
cnt = [0] * math.ceil(math.sqrt(p))
tmp = p
for i in range(2, math.ceil(math.sqrt(p))):
    while p % i == 0 and p != 0:
        p //= i
        cnt[i] += 1
ans = 1
for i in range(2, math.ceil(math.sqrt(tmp))):
    ans *= i ** (cnt[i] // n)
ans *= p ** (1 // n)
print(ans)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
distance = [0] * (n + 1)
total = 0
for i in range(1, n + 2):
    distance[i - 1] = a[i] - a[i - 1]
    total += abs(a[i] - a[i - 1])
for i in range(1, n + 1):
    diff = abs(distance[i]) + abs(distance[i - 1]) - \
        abs(distance[i] + distance[i - 1])
    print(total - diff)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
distance = [0] * (n + 1)
total = 0
for i in range(1, n + 2):
    distance[i - 1] = a[i] - a[i - 1]
    total += abs(a[i] - a[i - 1])
for i in range(1, n + 1):
    diff = abs(distance[i]) + abs(distance[i - 1]) - abs(distance[i] + distance[i - 1])
    print(total - diff)
Buggy python submission (verdict: Runtime Error):
s = [input() for _ in range(n)]
prefix = ['M', 'A', 'R', 'C', 'H']
cnt = [0] * 5
ans = 0
for i in range(n):
    for j in range(5):
        if s[i][0] == prefix[j]:
            cnt[j] += 1
for i in range(2 ** 5):
    flag = [False] * 5
    for j in range(5):
        if (i >> j) & 1:
            flag[j] = True
    if flag.count(True) == 3:
        tmp = 1
        for k in range(5):
            if flag[k]:
                tmp *= cnt[k]
        ans += tmp
print(ans)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
prefix = ['M', 'A', 'R', 'C', 'H']
cnt = [0] * 5
ans = 0
for i in range(n):
    for j in range(5):
        if s[i][0] == prefix[j]:
            cnt[j] += 1
for i in range(2 ** 5):
    flag = [False] * 5
    for j in range(5):
        if (i >> j) & 1:
            flag[j] = True
    if flag.count(True) == 3:
        tmp = 1
        for k in range(5):
            if flag[k]:
                tmp *= cnt[k]
        ans += tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1, n + 1):
    now = 0
    for c in str(i):
        now += int(c)
    ans = max(ans, now)
print(ans)

Fixed submission:
n = list(input())
ans = 0
if len(n[1:]) == n[1:].count('9'):
    ans = sum(list(map(int, n)))
else:
    ans = int(n[0]) - 1 + 9 * (len(n) - 1)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque


def bfs(sx, sy, gx, gy):
    q = deque([(sx, sy)])
    cost[sx][sy] = 1
    while q != []:
        x, y = q.popleft()
        for dx, dy in nb:
            nx = x + dx
            ny = y + dy
            if 0 <= nx and nx < h and 0 <= ny and ny < w and grid[nx][ny] == "." and cost[nx][ny] == float("inf"):
                q.append((nx, ny))
                cost[nx][ny] = cost[x][y] + 1
                if nx == gx and ny == gy:
                    return cost[nx][ny]
    return -1


h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
cost = [[float("inf")] * w for _ in range(h)]
nb = [(-1, 0), (0, -1), (1, 0), (0, 1)]
black_cnt = 0
ans = 0

for i in range(h):
    black_cnt += str(grid[i]).count("#")

print(h * w - bfs(0, 0, h - 1, w - 1) - black_cnt)


Fixed submission:
from collections import deque


def bfs(sx, sy, gx, gy):
    q = deque([(sx, sy)])
    cost[sx][sy] = 1
    while q:
        x, y = q.popleft()
        for dx, dy in nb:
            nx = x + dx
            ny = y + dy
            if 0 <= nx and nx < h and 0 <= ny and ny < w and grid[nx][ny] == "." and cost[nx][ny] == float("inf"):
                q.append((nx, ny))
                cost[nx][ny] = cost[x][y] + 1
                if nx == gx and ny == gy:
                    return cost[nx][ny]
    return -1


h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
cost = [[float("inf")] * w for _ in range(h)]
nb = [(-1, 0), (0, -1), (1, 0), (0, 1)]
black_cnt = 0
ans = 0

for i in range(h):
    black_cnt += str(grid[i]).count("#")

can_reach = bfs(0, 0, h - 1, w - 1)
if can_reach > 0:
    print(h * w - can_reach - black_cnt)
else:
    print(can_reach)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 8)
n, m = map(int, input().split())
g = [[False] * n for _ in range(n)]
visited = [False] * n
a = []
b = []
ans = 0


def dfs(v):
    visited[v] = True
    for to in range(n):
        if not g[v][to]:
            continue
        if visited[to]:
            continue
        dfs(v)


for _ in range(m):
    ai, bi = map(int, input().split())
    ai -= 1
    bi -= 1
    a.append(ai)
    b.append(bi)
    g[ai][bi] = True
    g[bi][ai] = True

for i in range(m):
    g[a[i]][b[i]] = False
    g[b[i]][a[i]] = False
    for j in range(n):
        visited[j] = False
    dfs(0)
    for j in range(n):
        if not visited[j]:
            ans += 1
            break
    g[a[i]][b[i]] = True
    g[b[i]][a[i]] = True

print(ans)

Fixed submission:
n, m = map(int, input().split())
g = [[False] * n for _ in range(n)]
visited = [False] * n
a = []
b = []
ans = 0


def dfs(v):
    visited[v] = True
    for to in range(n):
        if not g[v][to]:
            continue
        if visited[to]:
            continue
        dfs(to)


for _ in range(m):
    ai, bi = map(int, input().split())
    ai -= 1
    bi -= 1
    a.append(ai)
    b.append(bi)
    g[ai][bi] = True
    g[bi][ai] = True

for i in range(m):
    g[a[i]][b[i]] = False
    g[b[i]][a[i]] = False
    for j in range(n):
        visited[j] = False
    dfs(0)
    for j in range(n):
        if not visited[j]:
            ans += 1
            break
    g[a[i]][b[i]] = True
    g[b[i]][a[i]] = True

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
# 辺の必要性
f = [[True] * n for _ in range(n)]
for k in range(n):
    for i in range(n):
        for j in range(n):
            # ワーシャルフロイドの更新が適用されたらダメ
            # 迂回路も最短コストなら直結路は不要
            if a[i][k] + a[k][j] < a[i][j]:
                print(-1)
                exit()
            elif a[i][k] + a[k][j] == a[i][j] and i != k and k != j:
                f[i][j] = False

ans = 0
for i in range(n):
    for j in range(n):
        if f[i][j]:
            ans += a[i][j]
ans //= 2
print(ans)

Fixed submission:
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
# 辺の必要性
f = [[True] * n for _ in range(n)]
for k in range(n):
    for i in range(n):
        for j in range(n):
            # ワーシャルフロイドの更新が適用されたらダメ
            # 迂回路も最短コストなら直結路は不要
            if a[i][k] + a[k][j] < a[i][j]:
                print(-1)
                exit()
            elif a[i][k] + a[k][j] == a[i][j] and i != k and k != j:
                f[i][j] = False

ans = 0
for i in range(n):
    for j in range(n):
        if f[i][j]:
            ans += a[i][j]
ans //= 2
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
candidate = []
for i in range(n):
    dd[str(a[i])] += 1
for k in dd.keys():
    if dd[k] >= 2:
        candidate.append(int(k))
candidate.sort(reverse=True)
if len(candidate) < 2:
    print(0)
else:
    print(candidate[0] * candidate[1])

Fixed submission:
import collections
dd = collections.defaultdict(int)
n = int(input())
a = list(map(int, input().split()))
candidate = []
for i in range(n):
    dd[str(a[i])] += 1
for k in dd.keys():
    if dd[k] >= 2:
        candidate.append(int(k))
    if dd[k] >= 4:
        candidate.append(int(k))
candidate.sort(reverse=True)
if len(candidate) < 2:
    print(0)
else:
    print(candidate[0] * candidate[1])
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
grid = [[0] * w for _ in range(h)]
cnt = 0


def dfs(x, y, num):
    for i in range(-1, 2):
        for j in range(-1, 2):
            next_x = x + i
            next_y = y + j
            global cnt
            if 0 <= next_x and next_x < h and 0 <= next_y and next_y < w and grid[next_x][next_y] == 0 and cnt > 0:
                grid[next_x][next_y] = num
                cnt -= 1
                dfs(next_x, next_y, num)


for i in range(n):
    cnt = a[i]
    for j in range(h):
        for k in range(w):
            dfs(j, k, i + 1)
for i in range(h):
    print(*grid[i])

Fixed submission:
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
grid = [[0] * w for _ in range(h)]
cnt = 0
color = []
for i in range(n):
    for j in range(a[i]):
        color.append(i + 1)
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            grid[i][j] = color[cnt]
            cnt += 1
    else:
        for j in range(w - 1, -1, -1):
            grid[i][j] = color[cnt]
            cnt += 1
for i in range(h):
    print(*grid[i])
Buggy python submission (verdict: Runtime Error):
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
g = a[0]
for i in range(n):
    g = math.gcd(g, a[i])
if k % g == 0 and k <= a[-1]:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
new_balls = []
a.sort()
if k > a[-1]:
    print('IMPOSSIBLE')
    exit()
if k in a:
    print('POSSIBLE')
    exit()
for i in range(1, n):
    diff = a[i] - a[i - 1]
    if diff > 0:
        new_balls.append(diff)
for nb in new_balls:
    if (a[-1] - k) % nb == 0:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if (b - a) = (c - b):
    print('YES')
else:
    print('NO')

Fixed submission:
a, b, c = map(int, input().split())
if (b - a) == (c - b):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
for i in range(len(a) - 1, -1, -1):
    if sum(a[:i]) * 2 < a[i]:
        break
    ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
strength = [0] * (n + 1)
for i in range(1, n):
    strength[i] = strength[i - 1] + a[i - 1]
for i in range(len(a) - 1, -1, -1):
    if strength[i] * 2 < a[i]:
        break
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(1, n + 1):
    ans *= i
ans %= 10 ** 9 + 7
print(ans)

Fixed submission:
n = int(input())
ans = 1
for i in range(n):
    ans *= i + 1
    ans %= 10 ** 9 + 7
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = set(map(int, input().split()))
kinds = len(a)
if kinds % 2 == 1:
    print(kinds)
else:
    print(kinds - 1)

Fixed submission:
x = int(input())
if x % 11 == 0:
    print(x // 11 * 2)
else:
    cnt = x // 11 * 2
    x -= x // 11 * 11
    while x > 0:
        if cnt % 2 == 0:
            x -= 6
        else:
            x -= 5
        cnt += 1
    print(cnt)
Buggy python submission (verdict: Runtime Error):
import math


def sieve_of_eratosthenes(n):
    max_prime = int(math.sqrt(n))
    targets = [i for i in range(2, n + 1)]
    primes = []
    while targets[0] <= max_prime:
        p = targets[0]
        primes.append(p)
        targets = [i for i in targets if i % p != 0]
    primes.extend(targets)
    return primes


n = int(input())
p = sieve_of_eratosthenes(n)
ans = 1
for i in p:
    cnt = 0
    for j in range(2, n + 1):
        while j % i == 0:
            j //= i
            cnt += 1
    ans *= cnt + 1
    ans %= 10 ** 9 + 7
print(ans)

Fixed submission:
import math


def sieve_of_eratosthenes(n):
    max_prime = int(math.sqrt(n))
    targets = [i for i in range(2, n + 1)]
    primes = []
    if n == 1:
        return primes
    while targets[0] <= max_prime:
        p = targets[0]
        primes.append(p)
        targets = [i for i in targets if i % p != 0]
    primes.extend(targets)
    return primes


n = int(input())
p = sieve_of_eratosthenes(n)
ans = 1
for i in p:
    cnt = 0
    for j in range(2, n + 1):
        while j % i == 0:
            j //= i
            cnt += 1
    ans *= cnt + 1
    ans %= 10 ** 9 + 7
print(ans)
Buggy python submission (verdict: Runtime Error):
if abs(x) == abs(y):
    print(1)
    exit()
if x * y < 0:
    print(abs(abs(x) - abs(y)) + 1)
elif x == 0 or y == 0:
    print(max(abs(x), abs(y)))
elif x < y:
    print(y - x)
elif y > 0:
    print(x + y + 2)
else:
    print(abs(y) - abs(x) + 2)

Fixed submission:
x, y = map(int, input().split())
ans = float('inf')
if x <= y:
    ans = min(ans, y - x)
if (-1) * x <= y:
    ans = min(ans, y + x + 1)
if x <= (-1) * y:
    ans = min(ans, -y - x + 1)
if (-1) * x <= (-1) * y:
    ans = min(ans, -y + x + 2)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())))
if n % 2 == 1:
    for i in range(0, n, 2):
        if i == 0 and a[i] != 0:
            print(0)
            exit()
        elif a[i] != a[i + 1] or a[i] != 2 * i:
            print(0)
            exit()
else:
    for i in range(0, n, 2):
        if a[i] != a[i + 1] or a[i] != 2 * i + 1:
            print(0)
            exit()
print(2 ** (n // 2))

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
dd = collections.defaultdict(int)
correct = []
if n % 2 == 1:
    correct.append(0)
    for i in range((n - 1) // 2):
        correct.append(2 * i + 2)
        correct.append(2 * i + 2)
else:
    correct.append(1)
    correct.append(1)
    for i in range(n // 2):
        correct.append(2 * i + 3)
        correct.append(2 * i + 3)
a.sort()
correct.sort()
for i in range(n):
    if a[i] != correct[i]:
        print(0)
        exit()
for i in range(n):
    dd[str(a[i])] += 1
ans = 1
for k in dd.keys():
    if dd[k] >= 2:
        ans *= 2
        ans %= 10 ** 9 + 7
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
total = [0] * (n + 1)
ans = set()
num = float('inf')
for i in range(1, n + 1):
    total[i] = total[i - 1] + i
for i in range(1, n + 1):
    if total[i] >= n:
        num = i
        break
remove_num = total[i] - n
for i in range(1, num + 1):
    if i != remove_num:
        ans.add(i)
print(*ans, sep='\n')

Fixed submission:
n = int(input())
ans = set()
num = float('inf')
total = 0
for i in range(1, n + 1):
    total += i
    if total >= n:
        num = i
        break
remove_num = total - n
for i in range(1, num + 1):
    if i != remove_num:
        ans.add(i)
print(*ans, sep='\n')
Buggy python submission (verdict: Runtime Error):
# coding=utf-8
# Date: 2020-01-08
# Author: lee215
get = lambda: int(input().strip())
getl = lambda: input().strip()
gets = lambda: list(map(int, input().strip().split()))
getss = lambda n: [gets() for _ in range(n)]

H, N = gets()
AB = getss(N)
AB.sort(key=lambda a_b: -a_b[0] * 1.0 / a_b[1])

a0, b0 = AB[0]
dp = [0] + [float('inf')] * (H + a0)

cur = 0
while cur <= H + a0:
    dp[cur] = cur // a0 * b0
    cur += a0


for a, b in AB[1:]:
    for i in range(a, H + a0 + 1):
        dp[i] = min(dp[i], dp[i - a] + b)
print(min(dp[H:]))


Fixed submission:
# coding=utf-8
# Date: 2020-01-08
# Author: lee215

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


# fi = open('sample1.in', 'r')
# raw_input = fi.readline

H, A = gets()
if A == 1:
    print H
else:
    print(H + A - 1) / A
Buggy python submission (verdict: Runtime Error):
# coding=utf-8
get = lambda: int(raw_input().strip())
gets = lambda: map(int, raw_input().strip().split())
getss = lambda x: [gets() for _ in xrange(x)]
getl = lambda x: [gets() for _ in xrange(x)]

m, n = gets()
A0 = [list(raw_input().strip()) for _ in xrange(n)]

for i in xrange(m):
    for j in xrange(n):
        if A0[i][j] == '.':
            A0[i][j] = 0
        else:
            A0[i][j] = -1


def test(i, j):
    # print '\ntest ', i, j
    A = [row[:] for row in A0]
    bfs = [[i, j]]
    A[i][j] = 1
    dep = 0
    while bfs:
        dep += 1
        bfs2 = []
        for i, j in bfs:
            for di, dj in [[0, -1], [0, 1], [-1, 0], [1, 0]]:
                i2, j2 = i + di, j + dj
                if 0 <= i2 < m and 0 <= j2 < n and A[i2][j2] == 0:
                    A[i2][j2] = dep + 1
                    bfs2.append([i2, j2])
        bfs = bfs2
    # print A
    return dep


res = 0
for i in xrange(m):
    for j in xrange(n):
        if A0[i][j] < 0: continue
        res = max(res, test(i, j) - 1)
print res


Fixed submission:
# coding=utf-8
get = lambda: int(raw_input().strip())
gets = lambda: map(int, raw_input().strip().split())
getss = lambda x: [gets() for _ in xrange(x)]
getl = lambda x: [gets() for _ in xrange(x)]


m, n = gets()
A0 = [list(raw_input().strip()) for _ in xrange(m)]

for i in xrange(m):
    for j in xrange(n):
        if A0[i][j] == '.':
            A0[i][j] = 0
        else:
            A0[i][j] = -1


def test(i, j):
    # print '\ntest ', i, j
    A = [row[:] for row in A0]
    bfs = [[i, j]]
    A[i][j] = 1
    dep = 0
    while bfs:
        dep += 1
        bfs2 = []
        for i, j in bfs:
            for di, dj in [[0, -1], [0, 1], [-1, 0], [1, 0]]:
                i2, j2 = i + di, j + dj
                if 0 <= i2 < m and 0 <= j2 < n and A[i2][j2] == 0:
                    A[i2][j2] = dep + 1
                    bfs2.append([i2, j2])
        bfs = bfs2
    # for row in A:
    #     print row
    # print
    return dep


res = 0
for i in xrange(m):
    for j in xrange(n):
        if A0[i][j] < 0: continue
        res = max(res, test(i, j) - 1)
print res
Buggy python submission (verdict: Runtime Error):
a,b = raw_input(), raw_input()
print a*b if 1 <= a <= 9 and 1 <= b <= 9 else -1

Fixed submission:
get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

a, b = gets()
print a * b if 1 <= a <= 9 and 1 <= b <= 9 else -1
Buggy python submission (verdict: Runtime Error):
# coding=utf-8

A, B, C, D = 4, 9, 2, 3
A, B, C, D = 10, 40, 6, 8
A, B, C, D = 314159265358979323, 846264338327950288, 419716939, 937510582
A, B, C, D = map(int, raw_input().split())


def f(d):
    return B / d - (A - 1) / d


def gcd(a, b):
    while b != 0:
        a, b = b, b % a
    return a

E = C / gcd(C, D) * D

good = f(C) + f(D) - f(E)
print B - A + 1 - good


Fixed submission:
# coding=utf-8

A, B, C, D = 4, 9, 2, 3
A, B, C, D = 10, 40, 6, 8
A, B, C, D = 314159265358979323, 846264338327950288, 419716939, 937510582
A, B, C, D = map(int, raw_input().split())


def f(d):
    return B / d - (A - 1) / d


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

E = C / gcd(C, D) * D

good = f(C) + f(D) - f(E)
print B - A + 1 - good