Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M, K = list(map(int, input().split()))

mod = 998244353


def factorial(x, p):
    a = 1
    for i in range(1, x + 1):
        a *= i
        a %= p
    return a


def comb(a, b, p):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    c = 1
    c *= factorial(a, p)
    c *= pow(factorial(b, p), p - 2, p)
    c *= pow(factorial(a - b, p), p - 2, p)
    return c % p


ans = 0
ans += M * pow(M-1, N-1)
ans %= mod

for k in range(1, K+1):
    ans += comb(N-1, k, mod) * (M * pow(M-k, N-1-k)

print(ans % mod)


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

mod = 998244353


fac = [0] * (N+1)
fac[0] = 1
fac[1] = 1
for i in range(2, N+1):
    fac[i] = (fac[i-1] * i) % mod


def comb(a, b, p):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    c = fac[a]
    c *= pow(fac[b], p - 2, p)
    c *= pow(fac[a-b], p - 2, p)
    return c % p


ans = 0
ans += M * pow(M-1, N-1, mod)
ans %= mod

for k in range(1, K+1):
    ans += comb(N-1, k, mod) * M * pow(M-1, N-1-k, mod)
    ans %= mod

print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, K = list(map(int, input().split()))

mod = 998244353


def factorial(x, p):
    a = 1
    for i in range(1, x + 1):
        a *= i
        a %= p
    return a


def comb(a, b, p):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    c = 1
    c *= factorial(a, p)
    c *= pow(factorial(b, p), p - 2, p)
    c *= pow(factorial(a - b, p), p - 2, p)
    return c % p


ans = 0
ans += M * pow(M-1, N-1)
ans %= mod

for k in range(1, K+1):
    ans += comb(N-1, k, mod) * (M * pow(M-k, N-1-k)

print(ans % mod)


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

mod = 998244353


fac = [0] * (N+1)
fac[0] = 1
fac[1] = 1
for i in range(2, N+1):
    fac[i] = (fac[i-1] * i) % mod


def comb(a, b, p):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    c = fac[a]
    c *= pow(fac[b], p - 2, p)
    c *= pow(fac[a-b], p - 2, p)
    return c % p


ans = 0
ans += M * pow(M-1, N-1, mod)
ans %= mod

for k in range(1, K+1):
    ans += comb(N-1, k, mod) * M * pow(M-1, N-1-k, mod)
    ans %= mod

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import numpy as np
N = int(input())
A = list(map(int, input().split()))

D = defaultdict(int)

ans = 0

for i, a in enumerate(A):
    ans += D[i-a]
    D[i+a] += 1

print(ans)


Fixed submission:
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

D = defaultdict(int)

ans = 0

for i, a in enumerate(A):
    ans += D[i-a]
    D[i+a] += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input().strip()

M = [[0] * 3 for _ in range(N+1)]

for i in range(N-1, -1, -1):
    for j in range(3):
        M[i][j] = M[i+1][j]
    if S[i] == "R":
        M[i][0] += 1
    elif S[i] == "G":
        M[i][1] += 1
    else:
        M[i][2] += 1

ans = 0

T = "RGB"


for i in range(N-2):
    for j in range(i+1, N-1):
        m = [0, 0, 0]
        if S[i] == "R":
            m[0] += 1
        elif S[i] == "G":
            m[1] += 1
        else:
            m[2] += 1

        k = j + (j-i)
        if S[j] == "R":
            if m[0] == 0:
                m[0] += 1
                idx = m.index(0)
                ans += M[j+1][idx]
                if k < N and S[k] == T[idx]:
                    ans -= 1
            else:
                continue
        elif S[j] == "G":
            if m[1] == 0:
                m[1] += 1
                idx = m.index(0)
                ans += M[j+1][idx]
                if k < N and S[k] == T[idx]:
                    ans -= 1
            else:
                continue
        else:
            if m[2] == 0:
                m[2] += 1
                idx = m.index(0)
                ans += M[j+1][idx]
                if k < N and S[k] == T[idx]:
                    ans -= 1
            else:
                continue

print(ans)


Fixed submission:
N = int(input())
S = input().strip()

M = [[0] * 3 for _ in range(N+1)]

for i in range(N-1, -1, -1):
    for j in range(3):
        M[i][j] = M[i+1][j]
    if S[i] == "R":
        M[i][0] += 1
    elif S[i] == "G":
        M[i][1] += 1
    else:
        M[i][2] += 1

ans = 0

T = "RGB"


for i in range(N-2):
    for j in range(i+1, N-1):
        m = [0, 0, 0]
        if S[i] == "R":
            m[0] += 1
        elif S[i] == "G":
            m[1] += 1
        else:
            m[2] += 1

        k = j + (j-i)
        if S[j] == "R":
            if m[0] == 0:
                m[0] += 1
                idx = m.index(0)
                ans += M[j+1][idx]
                if k < N and S[k] == T[idx]:
                    ans -= 1
            else:
                continue
        elif S[j] == "G":
            if m[1] == 0:
                m[1] += 1
                idx = m.index(0)
                ans += M[j+1][idx]
                if k < N and S[k] == T[idx]:
                    ans -= 1
            else:
                continue
        else:
            if m[2] == 0:
                m[2] += 1
                idx = m.index(0)
                ans += M[j+1][idx]
                if k < N and S[k] == T[idx]:
                    ans -= 1
            else:
                continue

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from decimal import Decimal
a, b, c = list(map(int, input().split()))


def f(x):
    return Decimal(Decimal(x)**2 + s) / (2 * Decimal(x))


s = a * b   # √s
x = 2   # 初期値（0以外の値）
for i in range(10**4):
    x = f(x)

l = 2 * x + a + b

if l < c:
    print("Yes")
else:
    print("No")


Fixed submission:
from decimal import Decimal
a, b, c = list(map(int, input().split()))


def f(x):
    return Decimal(Decimal(x)**2 + s) / (2 * Decimal(x))


s = a * b   # √s
x = 2   # 初期値（0以外の値）
while True:
    newX = f(x)
    if abs(newX - x) < 1e-7:
        x = newX
        break
    x = newX

l = 2 * x + a + b

if l < c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

S = input().strip()
Q = int(input())

reverse = False

before = ""
after = ""

for _ in range(Q):
    s = input().strip()
    if s[0] == "1":
        reverse = not reverse
    else:
        _, f, c = s.split()
        if f == "1":
            if reverse:
                after = after + c
            else:
                before = c + before
        else:
            if reverse:
                before = c + before
            else:
                after = after + c

if reverse:
    print(after[::-1] + S[::-1] + before[::-1])
else:
    print(before + S + after)


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

ans = -1
i = 1
while i < 2000:

    a = int(i * 1.08) - i
    b = int(i * 1.1) - i
    if A == a and B == b:
        ans = i
        break
    i += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

S = input().strip()
Q = int(input())

reverse = False

before = ""
after = ""

for _ in range(Q):
    s = input().strip()
    if s[0] == "1":
        reverse = not reverse
    else:
        _, f, c = s.split()
        if f == "1":
            if reverse:
                after = after + c
            else:
                before = c + before
        else:
            if reverse:
                before = c + before
            else:
                after = after + c

if reverse:
    print(after[::-1] + S[::-1] + before[::-1])
else:
    print(before + S + after)


Fixed submission:
import sys
input = sys.stdin.readline

S = input().strip()
Q = int(input())

reverse = False

before = ""
after = ""

for _ in range(Q):
    s = input().strip()
    if s[0] == "1":
        reverse = not reverse
    else:
        _, f, c = s.split()
        if f == "1":
            if reverse:
                after = after + c
            else:
                before = c + before
        else:
            if reverse:
                before = c + before
            else:
                after = after + c

if reverse:
    print(after[::-1] + S[::-1] + before[::-1])
else:
    print(before + S + after)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

S = input().strip()
Q = int(input())

reverse = False

for _ in range(Q):
    s = input().strip()
    if s.startswith("1"):
        reverse = not reverse
    else:
        _, f, c = s.split()
        if f == "1":
            if reverse:
                S = S + c
            else:
                S = c + S
        else:
            if reverse:
                S = c + S
            else:
                S = S + c

if reverse:
    print(S[::-1])
else:
    print(S)


Fixed submission:
import sys
input = sys.stdin.readline

S = input().strip()
Q = int(input())

reverse = False

before = ""
after = ""

for _ in range(Q):
    s = input().strip()
    if s[0] == "1":
        reverse = not reverse
    else:
        _, f, c = s.split()
        if f == "1":
            if reverse:
                after = after + c
            else:
                before = c + before
        else:
            if reverse:
                before = c + before
            else:
                after = after + c

if reverse:
    print(after[::-1] + S[::-1] + before[::-1])
else:
    print(before + S + after)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10 ** 9 + 7

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

ans = 0
total = pow(2, n, MOD)


def comb(n, k):
    bunshi = 1
    bunbo = 1
    for i in range(k):
        bunshi *= n - i
        bunbo *= i+1
        bunshi %= MOD
    return (bunshi * pow(bunbo, MOD-2, MOD)) % MOD


ans = total - (comb(n, a) + comb(n, b)) - 1
print(ans % MOD)


Fixed submission:
MOD = 10 ** 9 + 7

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

ans = 0
total = pow(2, n, MOD)


def comb(n, k):
    bunshi = 1
    bunbo = 1
    for i in range(k):
        bunshi *= n - i
        bunbo *= i+1
        bunshi %= MOD
        bunbo %= MOD
    return (bunshi * pow(bunbo, MOD-2, MOD)) % MOD


ans = total - (comb(n, a) + comb(n, b)) - 1
print(ans % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
ans = 0
 
for k in range(N-2):
    for j in range(k+1, N-1):
        ans += bisect.bisect_left(L[j+1:], L[k]+L[j])
 
 
print(ans)

Fixed submission:
import bisect
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
ans = 0
 
for k in range(N-2):
    for j in range(k+1, N-1):
        ans += bisect.bisect_left(L[j+1:], L[k]+L[j])
 
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0

for k in range(N-2):
    for j in range(k+1, N-1):
        ans += bisect.bisect_left(L[j+1:], L[k]+L[j])


print(ans)


Fixed submission:
import bisect
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
ans = 0
 
for k in range(N-2):
    for j in range(k+1, N-1):
        ans += bisect.bisect_left(L[j+1:], L[k]+L[j])
 
 
print(ans)

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

L.sort()

ans = 0

for k in range(N-2):
    for j in range(k+1, N-1):
        for i in range(j+1, N):
            if L[i] < L[k] + L[j]:
                ans += 1
            else:
                break

print(ans)


Fixed submission:
import bisect
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
ans = 0
 
for k in range(N-2):
    for j in range(k+1, N-1):
        ans += bisect.bisect_left(L[j+1:], L[k]+L[j])
 
 
print(ans)
Buggy python submission (verdict: Runtime Error):
foo

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

ans = 0
count = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        ans += 1
    if S[i] != S[i+1]:
        count += 1

while count > 0 and K > 0:
    if count == 1:
        count -= 1
        ans += 1
        K -= 1
    else:
        K -= 1
        count -= 2
        ans += 2

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

L = []
R = []

for a in A:
    if len(L) == 0:
        L.append(a)
    L.append(max(L[-1]), a)

A.reverse()
for a in A:
    if len(R) == 0:
        R.append(a)
    R.append(max(R[-1]), a)

R.reverse()

print(R[0])
for i in range(1, N-1):
    print(max(L[i-1], R[i+1]))
print(L[len(L)-2])


Fixed submission:
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

L = [1]
for n in range(N-1):
    L.append(max(L[-1], A[n]))

R = [1]
A.reverse()
for n in range(N-1):
    R.append(max(R[-1], A[n]))
R.reverse()

for i in range(N):
    print(max(L[i], R[i]))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = list(map(int, input().split()))

num = [0] * N

for _ in range(M):
    L, R = list(map(int, input().split()))
    L = L - 1
    R = R - 1
    for i in range(L, R+1):
        num[i] += 1

ans = 0

for i in range(N):
    if num[i] == M:
        ans += 1

print(ans)


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

num = [0] * N

L = 1
R = N

for _ in range(M):
    l, r = list(map(int, input().split()))
    if l > L:
        L = l
    if r < R:
        R = r

print(max(R - L + 1, 0))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))


if N == 2:
    print(max(A[0], A[1]))
else:
    m = min(A)

    ans = -1
    for i in range(m+1, 1, -1):
        count = 0
        for n in range(N):
            if count > 1:
                break
            if A[n] % i != 0:
                count += 1
        if count <= 1:
            ans = i
            break

    print(ans)


Fixed submission:
A, B, T = map(int, input().split())

ans = 0
for i in range(1, T+1):
    if i % A == 0:
        ans += B
print(ans)

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


if N == 2:
    print(max(A[0], A[1]))
else:
    m = min(A)

    ans = -1
    for i in range(1, m+1):
        count = 0
        for n in range(N):
            if count > 1:
                break
            if A[n] % i != 0:
                count += 1
        if count <= 1 and i > ans:
            ans = i

    print(ans)

Fixed submission:
A, B, T = map(int, input().split())

ans = 0
for i in range(1, T+1):
    if i % A == 0:
        ans += B
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))

if a == b:
    print(a+b)
else:
    print(max(a, b)*2-1

Fixed submission:
a, b = list(map(int, input().split()))
 
if a == b:
    print(a+b)
else:
    print(max(a, b)*2-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = list(map(int, input().split()))
S = input()

a = [0] * len(S)

for i in range(len(S)):
    if S[i:i+2] == "AC":
        a[i] = 1

for q in range(Q):
    l, r = list(map(int, input().split()))
    print(sum(a[l-1: r-1]))


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

a = [0] * N

count = 0
for i in range(1, N):
    if S[i-1:i+1] == "AC":
        count += 1
    a[i] = count


for q in range(Q):
    l, r = list(map(int, input().split()))
    print(a[r-1] - a[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

C = [-1] * N
C[0] = 0
for n in range(1, N):
    for m in range(max(0, n-K), n):
        C[n] = abs(H[n] - H[m]) + \
            C[m] if C[n] < 0 else min(abs(H[n] - H[m]) + C[m], C[n])

print(C[N-1])


Fixed submission:
import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

C = [-1] * N
C[0] = 0
for n in range(1, N):
    for m in range(max(0, n-K), n):
        C[n] = abs(H[n] - H[m]) + \
            C[m] if C[n] < 0 else min(abs(H[n] - H[m]) + C[m], C[n])

print(C[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

C = [-1] * N
C[0] = 0
for n in range(1, N):
    for m in range(max(0, n-K), n):
        if C[n] < 0:
            C[n] = abs(H[n] - H[m]) + C[m]
        else:
            C[n] = min(abs(H[n] - H[m]) + C[m], C[n])

print(C[N-1])


Fixed submission:
import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

C = [-1] * N
C[0] = 0
for n in range(1, N):
    for m in range(max(0, n-K), n):
        C[n] = abs(H[n] - H[m]) + \
            C[m] if C[n] < 0 else min(abs(H[n] - H[m]) + C[m], C[n])

print(C[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, W = list(map(int, input().split()))
WV = []
for _ in range(N):
    WV.append(list(map(int, input().split())))

DP = [[0] * (W+1)]
for n in range(N):
    DP.append([0]*(W+1))


for n in range(N):
    for w in range(W+1):
        if w < WV[n][0]:
            DP[n+1][w] = DP[n][w]
        else:
            DP[n+1][w] = max(DP[n][w-WV[n][0]]+WV[n][1], DP[n][w])

print(DP[N][W])


Fixed submission:
import sys
input = sys.stdin.readline
N, W = list(map(int, input().split()))
WV = []
for _ in range(N):
    WV.append(list(map(int, input().split())))

DP = [[0] * (W+1)]
for n in range(N):
    DP.append([0]*(W+1))


for n in range(N):
    for w in range(W+1):
        if w < WV[n][0]:
            DP[n+1][w] = DP[n][w]
        else:
            DP[n+1][w] = max(DP[n][w-WV[n][0]]+WV[n][1], DP[n][w])

print(DP[N][W])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, W = list(map(int, input().split()))
WV = [list(map(int, input().split())) for _ in range(N)]

DP = [0] * (W+1)

for n in range(N):
    next = [0] * (W+1)
    for w in range(1, W+1):
        if w < WV[n][0]:
            next[w] = DP[w]
        else:
            next[w] = max(DP[w], DP[w-WV[n][0]]+WV[n][1])
    DP = next

print(DP[W])


Fixed submission:
import sys
input = sys.stdin.readline
N, W = list(map(int, input().split()))
WV = [list(map(int, input().split())) for _ in range(N)]

DP = [[float("inf")] * (10**5+1)]
for _ in range(N):
    DP.append([float("inf")] * (10**5+1))

DP[0][0] = 0

for n in range(N):
    for v in range(10 ** 5 + 1):
        if v - WV[n][1] >= 0:
            DP[n+1][v] = min(DP[n+1][v], DP[n][v - WV[n][1]] + WV[n][0])
        DP[n+1][v] = min(DP[n+1][v], DP[n][v])

ans = 0
for v in range(10 ** 5 + 1):
    if DP[N][v] <= W:
        ans = v

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

from collections import deque
from collections import defaultdict
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))

T = defaultdict(list)

Y = [True] * N
for _ in range(M):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    T[x].append(y)
    Y[y] = False

DP = [0] * N

q = deque()
for n in range(N):
    if Y[n]:
        q.append(n)


while q:
    e = q.popleft()
    for t in T[e]:
        DP[t] = max(DP[e] + 1, DP[t])
        q.append(t)

print(max(DP))


Fixed submission:

from collections import deque
from collections import defaultdict
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))

T = defaultdict(list)
in_num = defaultdict(int)

for _ in range(M):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    T[x].append(y)
    in_num[y] += 1

q = deque()

for n in range(N):
    if in_num[n] == 0:
        q.append(n)


DP = [0] * N

while q:
    v = q.popleft()
    t = T[v]
    for y in t:
        in_num[y] -= 1
        if in_num[y] == 0:
            q.append(y)
            DP[y] = max(DP[y], DP[v]+1)


print(max(DP))

Buggy python submission (verdict: Time Limit Exceeded):

from collections import deque
from collections import defaultdict
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))

T = defaultdict(list)

Y = [True] * N
for _ in range(M):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    T[x].append(y)
    Y[y] = False

DP = [0] * N

q = deque()
for n in range(N):
    if Y[n]:
        q.append(n)


while q:
    e = q.popleft()
    for t in T[e]:
        DP[t] = max(DP[e] + 1, DP[t])
        q.append(t)

print(max(DP))


Fixed submission:

from collections import deque
from collections import defaultdict
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))

T = defaultdict(list)
in_num = defaultdict(int)

for _ in range(M):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    T[x].append(y)
    in_num[y] += 1

q = deque()

for n in range(N):
    if in_num[n] == 0:
        q.append(n)


DP = [0] * N

while q:
    v = q.popleft()
    t = T[v]
    for y in t:
        in_num[y] -= 1
        if in_num[y] == 0:
            q.append(y)
            DP[y] = max(DP[y], DP[v]+1)


print(max(DP))
Buggy python submission (verdict: Runtime Error):
H, W = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]

tmp = 0

ans = []

for j in range(H):
    if j % 2 == 0:
        for i in range(W):
            if j == H-1 and i == W-1:
                break
            if A[j][i] % 2 != 0:
                A[j][i] -= 1
                if i == W-1:
                    A[j+1][i] += 1
                    ans.append([j, i, j+1, i])
                else:
                    A[j][i+1] += 1
                    ans.append([j, i, j, i+1])

    else:
        for i in range(W-1, -1, -1):
            if j == H-1 and i == 0:
                break
            if A[j][i] % 2 != 0:
                A[j][i] -= 1
                if i == W-1:
                    A[j+1][i] += 1
                    ans.append([j, i, j+1, i])
                else:
                    A[j][i-1] += 1
                    ans.append([j, i, j, i-1])


for a in ans:
    print(*a)


Fixed submission:
H, W = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]

tmp = 0

ans = []

for j in range(H):
    if j % 2 == 0:
        for i in range(W):
            if j == H-1 and i == W-1:
                break
            if A[j][i] % 2 != 0:
                A[j][i] -= 1
                if i == W-1:
                    A[j+1][i] += 1
                    ans.append([j, i, j+1, i])
                else:
                    A[j][i+1] += 1
                    ans.append([j, i, j, i+1])

    else:
        for i in range(W-1, -1, -1):
            if j == H-1 and i == 0:
                break
            if A[j][i] % 2 != 0:
                A[j][i] -= 1
                if i == 0:
                    A[j+1][i] += 1
                    ans.append([j, i, j+1, i])
                else:
                    A[j][i-1] += 1
                    ans.append([j, i, j, i-1])


print(len(ans))
for a in ans:
    a[0] += 1
    a[1] += 1
    a[2] += 1
    a[3] += 1
    print(*a)
Buggy python submission (verdict: Runtime Error):
import statistics
N = int(input())
A = list(map(int, input().split()))

for i, a in enumerate(A):
    A[i] = a - (i+1)

tmp = int(statistics.median(A))

ans = 0
for i, a in enumerate(A):
    ans += abs(a - tmp)

print(ans)


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

for i, a in enumerate(A):
    A[i] = a - (i+1)

tmp = int(statistics.median(A))

ans = 0
for i, a in enumerate(A):
    ans += abs(a - tmp)

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

s = sum(map(int,list(N)))
if N % s == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
N = input()

s = sum(map(int,list(N)))
if int(N) % s == 0:
  print("Yes")
else:
  print("No")

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

s = sum(list(N))
if N % s == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
N = input()

s = sum(map(int,list(N)))
if int(N) % s == 0:
  print("Yes")
else:
  print("No")