Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections

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

C = collections.Counter(A)

for a in A:
    s = 0
    for c in C:
        if c == a:
            s += (C[c] - 1) * (C[c] - 2) // 2
        else:
            s += C[c] * (C[c] - 1) // 2
    print(s)


Fixed submission:
import collections

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

C = collections.Counter(A)

s_all = 0
for c in C:
    s_all += C[c] * (C[c] - 1) // 2

for a in A:
    s = 0
    s += s_all - (C[a] - 1)
    print(s)

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

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

C = collections.Counter(A)

for a in A:
    s = 0
    for c in C:
        if c == a:
            s += (C[c] - 1) * (C[c] - 2) // 2
        else:
            s += C[c] * (C[c] - 1) // 2
    print(s)


Fixed submission:
import collections

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

C = collections.Counter(A)

s_all = 0
for c in C:
    s_all += C[c] * (C[c] - 1) // 2

for a in A:
    s = 0
    s += s_all - (C[a] - 1)
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

S = deque(list(input()))
Q = int(input())

for q in range(Q):
    query = list(input().split())
    if len(query) > 1:
        if query[1] == "1":
            S.appendleft(query[2])
        elif query[1] == "2":
            S.append(query[2])
    else:
        S.reverse()

print("".join(S))


Fixed submission:
from collections import deque

S = deque(list(input()))
Q = int(input())
rvs = False

for q in range(Q):
    query = list(input().split())
    if len(query) > 1:
        if query[1] == "1":
            if rvs:
                S.append(query[2])
            else:
                S.appendleft(query[2])
        elif query[1] == "2":
            if rvs:
                S.appendleft(query[2])
            else:
                S.append(query[2])
    else:
        rvs = not (rvs)

if rvs:
    S.reverse()

print("".join(S))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
s = []
c = []
for m in range(M):
    si, ci = map(int, input().split())
    s.append(si)
    c.append(ci)

s = 10 ** (N - 1)
if N == 1:
    s -= 1

for i in range(s, 10 ** N):
    for m in range(M):
        if str(i)[s[m] - 1] != str(c[m]):
            break
    else:
        print(i)
        exit()

print(-1)


Fixed submission:
N, M = map(int, input().split())
s = []
c = []
for m in range(M):
    si, ci = map(int, input().split())
    s.append(si)
    c.append(ci)

ss = 10 ** (N - 1)
if N == 1:
    ss -= 1

for i in range(ss, 10 ** N):
    for m in range(M):
        if str(i)[s[m] - 1] != str(c[m]):
            break
    else:
        print(i)
        exit()

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

V = [0] * (N + 1)

for i in range(N):
    V[i + 1] = V[i] + sum(range(1, P[i] + 1)) / P[i]

# print(V)

res = 0
for i in range(N + 1 - K):
    res = max(res, V[i + K] - V[i])

print(res)


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

V = [0] * (N + 1)
S = [0] * (1010)
for i in range(1009):
    S[i + 1] = S[i] + (i + 1)
# print(S)

for i in range(N):
    p = P[i]
    V[i + 1] = V[i] + S[p] / p

# print(V)

res = 0
for i in range(N + 1 - K):
    res = max(res, V[i + K] - V[i])

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

dp = [10 ** 18] * (H + 1)

dp[0] = 0

for i in range(H + 1):
    for A, B in AB:
        if i + A >= H:
            dp[H] = min(dp[H], dp[i] + B)
        else:
            dp[i + A] = min(dp[i + A], dp[i] + B)

res = dp[H]

print(res)


Fixed submission:
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

dp = [10 ** 18] * (H + 1)

dp[0] = 0

for i in range(H + 1):
    for A, B in AB:
        if i + A >= H:
            dp[H] = min(dp[H], dp[i] + B)
        else:
            dp[i + A] = min(dp[i + A], dp[i] + B)

res = dp[H]

print(res)
Buggy python submission (verdict: Runtime Error):
import math

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

print(A * B // math.gcd(A, B))


Fixed submission:
import fractions as f

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

print(A * B // f.gcd(A, B))
Buggy python submission (verdict: Runtime Error):
X = int(input())

dp = [0] * (100000)
dp[0] = 1

for i in range(X + 1):
    if dp[i] == 1:
        for j in range(6):
            dp[i + 100 + j] = 1
            if i + 100 + j == X:
                print(1)
                exit()
print(0)


Fixed submission:
X = int(input())

x = X % 100
tmp = (x // 5) * 105
if x % 5 != 0:
    tmp += 100 + (x % 5)
if tmp > X:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

res = []
pw = ""
for i in range(2 ** N):
    cnt = 0
    for j in range(N):
        if (i >> j) & 1 == 1:
            cnt += 1
            pw += S[j]
        if cnt > 3:
            break
    if cnt == 3:
        res.append(pw)
        pw = ""
    else:
        pw = ""

print(len(set(res)))

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

res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            x = S.find(str(i))
            y = S.find(str(j), x + 1)
            z = S.find(str(k), y + 1)

            if -1 < x < y < z:
                res += 1

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

res = []
pw = ""
for i in range(2 ** N):
    cnt = 0
    for j in range(N):
        if (i >> j) & 1 == 1:
            cnt += 1
            pw += S[j]
    if cnt == 3:
        res.append(pw)
        pw = ""
    else:
        pw = ""

print(len(set(res)))


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

res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            x = S.find(str(i))
            y = S.find(str(j), x + 1)
            z = S.find(str(k), y + 1)

            if -1 < x < y < z:
                res += 1

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations as cmb
N = int(input())
L = list(map(int, input().split()))

res = 0
for a, b, c in cmb(L, 3):
    if a < b + c and b < c + a and c < a + b:
        res += 1

print(res)


Fixed submission:
import bisect

N = int(input())
L = sorted(map(int, input().split()))

res = 0
for i in reversed(range(1, N)):
    for j in reversed(range(i)):
        index = bisect.bisect_left(L, L[i] + L[j])
        n = N - index
        res += (N - 1 - i) - n

print(res)
Buggy python submission (verdict: Runtime Error):
S = list(input())
K = int(input())
S.extend(S)

prev = ''
cnt = 0
for s in S:
    if s == prev:
        cnt += 1
        prev = ''
    else:
        prev = s

b = 0
if K > 2 and S[0] == S[-1]:
    mae = 1
    while S[mae] == S[0]:
        mae += 1
    if mae % 2 == 1 and mae != len(S):
        usiro = 1
        i = len(S) - 2
        while S[i] == S[-1]:
            usiro += 1
            i -= 1
        if usiro % 2 == 1:
            b = K // 2

if K % 2 == 0:
    res = cnt * (K // 2) + (b - 1)
else:
    res = cnt * (K // 2) + cnt // 2 + b
print(res)


Fixed submission:
S = list(input())
K = int(input())
S.extend(S)

prev = ''
cnt = 0
for s in S:
    if s == prev:
        cnt += 1
        prev = ''
    else:
        prev = s

b = 0
if K % 2 == 0:
    b += 1
if K > 2 and S[0] == S[-1]:
    mae = 1
    while mae < len(S) and S[mae] == S[0]:
        mae += 1
    if mae % 2 == 1 and mae != len(S):
        usiro = 1
        i = len(S) - 2
        while S[i] == S[-1]:
            usiro += 1
            i -= 1
        if usiro % 2 == 1:
            b = K // 2

if K % 2 == 0:
    res = cnt * (K // 2) + (b - 1)
else:
    res = cnt * (K // 2) + cnt // 2 + b
print(res)
Buggy python submission (verdict: Runtime Error):
def factorization(n):
    s = set()
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            s.add(i)

    if temp != 1:
        s.add(temp)

    if s == {}:
        s.add(n)

    return s


A, B = map(int, input().split())
mini = min(A, B)
maxi = max(A, B)

s = factorization(mini)

res = 0
for i in s:
    if maxi % i == 0:
        res += 1

print(res + 1)
def factorization(n):
    s = set()
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            s.add(i)

    if temp != 1:
        s.add(temp)

    if s == {}:
        s.add(n)

    return s


A, B = map(int, input().split())
mini = min(A, B)
maxi = max(A, B)

s = factorization(mini)

res = 0
for i in s:
    if maxi % i == 0:
        res += 1

print(res + 1)


Fixed submission:
def factorization(n):
    s = set()
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            s.add(i)

    if temp != 1:
        s.add(temp)

    if len(s) == 0:
        s.add(n)

    return s


A, B = map(int, input().split())
mini = min(A, B)
maxi = max(A, B)

ss = factorization(mini)

res = 1
for i in ss:
    if maxi % i == 0:
        res += 1

if mini == 1:
    res = 1

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


def dfs(G, start):
    S = deque()
    S.append(start)
    while len(S) > 0:
        x, parent = S.pop()
        Counter[x] += Counter[parent]
        for g in G[x]:
            if g == parent:
                continue
            S.append((g, x))


N, Q = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N - 1)]
PX = [tuple(map(int, input().split())) for _ in range(Q)]
G = [[] for _ in range(N + 1)]
for a, b in AB:
    G[a].append(b)
    G[b].append(a)

Counter = [0 for _ in range(N + 1)]

for p, x in PX:
    Counter[p] += x

dfs(G, (1, 0))
Counter = [str(a) for a in Counter]
print(" ".join(Counter[1:]))


Fixed submission:
from collections import deque


def dfs(G, start):
    S = deque()
    S.append(start)
    while len(S) > 0:
        x, parent = S.pop()
        Counter[x] += Counter[parent]
        for g in G[x]:
            if g == parent:
                continue
            S.append((g, x))


N, Q = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N - 1)]
PX = [tuple(map(int, input().split())) for _ in range(Q)]
G = [[] for _ in range(N + 1)]
for a, b in AB:
    G[a].append(b)
    G[b].append(a)

Counter = [0 for _ in range(N + 1)]

for p, x in PX:
    Counter[p] += x

dfs(G, (1, 0))
Counter = [str(a) for a in Counter]
print(" ".join(Counter[1:]))
Buggy python submission (verdict: Time Limit Exceeded):
import sys, heapq, bisect, math, fractions
from collections import deque

N = int(input())
S = [sorted(sys.stdin.readline().strip()) for _ in range(N)]

res = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if S[i] == S[j]:
            res += 1

print(res)

Fixed submission:
N = int(input())

dic = {}
for i in range(N):
    s = sorted(input())
    ss = "".join(s)
    if ss in dic:
        dic[ss] += 1
    else:
        dic[ss] = 1

res = 0
for d in dic.values():
    res += d * (d - 1) // 2

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
res = 10 ** 15
for i in range(L, R):
    for j in reversed(range(i + 1, R + 1)):
        res = min((i % 2019) * (j % 2019) % 2019, res)

print(res)


Fixed submission:
L, R = map(int, input().split())

if R - L > 2030:
    print(0)
else:
    res = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            res = min(res, (i * j) % 2019)
    print(res)
Buggy python submission (verdict: Runtime Error):
import math

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

cntC = B // C - A // C + int(A % C == 0)
cntD = B // D - A // D + int(A % D == 0)

lcm = C * D // math.gcd(C, D)
cntCD = B // lcm - A // lcm + int(A % lcm == 0)

print((B - A + 1) - (cntC + cntD - cntCD))


Fixed submission:
import fractions

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

cntC = B // C - A // C + int(A % C == 0)
cntD = B // D - A // D + int(A % D == 0)

lcm = C * D // fractions.gcd(C, D)
cntCD = B // lcm - A // lcm + int(A % lcm == 0)

print((B - A + 1) - (cntC + cntD - cntCD))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N, M = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))
A.sort()
C = []

for _ in range(M):
    b, c = map(int, input().split())
    C.extend([c] * b)

C.sort(reverse=True)

res = 0
for i in range(N):
    if i < len(C):
        if A[i] < C[i]:
            res += C[i]
        else:
            res += A[i]
    else:
        res += A[i]
print(res)


Fixed submission:
import sys

N, M = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))
BC = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(M)]
A.sort()
BC.sort(reverse=True, key=lambda x: x[1])
C = []

for b, c in BC:
    if len(C) >= N:
        break
    for _ in range(b):
        C.append(c)

C.sort(reverse=True)

res = 0
lenC = len(C)
for i in range(N):
    if i < lenC and A[i] < C[i]:
        res += C[i]
    else:
        res += A[i]
print(res)

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

N, M = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))
A.sort()
C = []

for _ in range(M):
    b, c = map(int, input().split())
    C.extend([c] * b)

C.sort(reverse=True)

res = 0
for i in range(N):
    if i < len(C):
        if A[i] < C[i]:
            res += C[i]
        else:
            res += A[i]
    else:
        res += A[i]
print(res)


Fixed submission:
import sys

N, M = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))
BC = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(M)]
A.sort()
BC.sort(reverse=True, key=lambda x: x[1])
C = []

for b, c in BC:
    if len(C) >= N:
        break
    for _ in range(b):
        C.append(c)

C.sort(reverse=True)

res = 0
lenC = len(C)
for i in range(N):
    if i < lenC and A[i] < C[i]:
        res += C[i]
    else:
        res += A[i]
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

res = 0
for i in range(N // R + 1):
    for j in range(N // G + 1):
        b = N - (i * R + j * G)
        if b >= 0 and b % B == 0:
            res += 1
print(res)


Fixed submission:
R, G, B, N = map(int, input().split())

res = 0
for i in range(N // R + 1):
    for j in range(N // G + 1):
        b = N - (i * R + j * G)
        if b >= 0 and b % B == 0:
            res += 1
print(res)
Buggy python submission (verdict: Runtime Error):
s = list(input().split('/'))

if s[0] < 2019:
  print("Heisei")
elif s[0] == 2019:
  if s[1] < 4:
    print("Heisei)
  elif (s[1] == 4 and s[2] <= 30) or s[1] > 4:
    print("TBD")
else:
  print("TBD")

Fixed submission:
s = list(input().split('/'))
s = [int(ss) for ss in s]

if s[0] < 2019:
  print("Heisei")
elif s[0] == 2019:
  if s[1] < 4 or (s[1] == 4 and s[2] <= 30):
    print("Heisei")
  else:
    print("TBD")
else:
  print("TBD")
Buggy python submission (verdict: Runtime Error):
import math

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

for i in range(N - 1):
    A[i + 1] = math.gcd(A[i], A[i + 1])

res = A[N - 1]
print(res)

Fixed submission:
import fractions as f

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

for i in range(N - 1):
    A[i + 1] = f.gcd(A[i], A[i + 1])

res = A[N - 1]
print(res)

Buggy python submission (verdict: Runtime Error):
import math

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

for i in range(N - 1):
    A[i + 1] = math.gcd(A[i], A[i + 1])

print(A[N - 1])

Fixed submission:
import fractions as f

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

for i in range(N - 1):
    A[i + 1] = f.gcd(A[i], A[i + 1])

res = A[N - 1]
print(res)

Buggy python submission (verdict: Runtime Error):
import math

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

for i in range(N - 1):
    A[i + 1] = math.gcd(A[i], A[i + 1])

print(A[N - 1])


Fixed submission:
import fractions as f

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

for i in range(N - 1):
    A[i + 1] = f.gcd(A[i], A[i + 1])

res = A[N - 1]
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N, K = map(int, input().split())
H = list(map(int, sys.stdin.readline().rsplit()))

dp = [10 ** 9] * (N + K)
dp[0] = 0

for i in range(N):
    for k in range(1, K + 1):
        if i + k < N:
            dp[i + k] = min(
                dp[i + k],
                dp[i] + abs(H[i] - H[i + k])
            )

print(dp[N - 1])


Fixed submission:
import sys

N, K = map(int, input().split())
H = list(map(int, sys.stdin.readline().rsplit()))

dp = [10 ** 9] * (N + K)
dp[0] = 0

for i in range(N):
    for k in range(1, K + 1):
        if i + k < N:
            dp[i + k] = min(
                dp[i + k],
                dp[i] + abs(H[i] - H[i + k])
            )

print(dp[N - 1])
Buggy python submission (verdict: Time Limit Exceeded):
N, WM = map(int, input().split())
W = []
V = []
dp = [[0] * (WM + 1) for _ in range(N + 1)]

for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

for i in range(N):
    for w in range(WM + 1):
        if w - W[i] >= 0:
            dp[i + 1][w] = max(dp[i + 1][w], dp[i][w - W[i]] + V[i])
        dp[i + 1][w] = max(dp[i + 1][w], dp[i][w])

print(dp[N][WM])


Fixed submission:
N, WM = map(int, input().split())
W = []
V = []
dp = [[0] * (WM + 1) for _ in range(N + 1)]

for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

for i in range(N):
    for w in range(WM + 1):
        if w - W[i] >= 0:
            dp[i + 1][w] = max(dp[i + 1][w], dp[i][w - W[i]] + V[i])
        dp[i + 1][w] = max(dp[i + 1][w], dp[i][w])

print(dp[N][WM])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
G = [[] for _ in range(M)]
res = [""] * M
for i in range(M):
    p, y = map(int, input().split())
    G[p - 1].append((y, i))

G = list(map(sorted, G))
for p in range(N):
    for m, (y, i) in enumerate(G[p], 1):
        res[i] = 10 ** 12 + (p + 1) * 10 ** 6 + m

for r in res:
    print(str(r)[1:])

Fixed submission:
N, M = map(int, input().split())
G = [[] for _ in range(N)]
res = [""] * M
for i in range(M):
    p, y = map(int, input().split())
    G[p - 1].append((y, i))

G = list(map(sorted, G))
for p in range(N):
    for m, (y, i) in enumerate(G[p], 1):
        res[i] = 10 ** 12 + (p + 1) * 10 ** 6 + m

for r in res:
    print(str(r)[1:])

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
G = [[] for _ in range(M)]
res = [""] * M
for i in range(M):
    p, y = map(int, input().split())
    G[p - 1].append((y, i))

for i, g in enumerate(G):
    l = len(str(i + 1))
    g.sort()
    for j, gg in enumerate(g):
        ll = len(str(j + 1))
        res[gg[1]] = "0" * (6 - l) + str(i + 1) + "0" * (6 - ll) + str(j + 1)

print("\n".join(res))


Fixed submission:
N, M = map(int, input().split())
G = [[] for _ in range(N)]
res = [""] * M
for i in range(M):
    p, y = map(int, input().split())
    G[p - 1].append((y, i))

G = list(map(sorted, G))
for p in range(N):
    for m, (y, i) in enumerate(G[p], 1):
        res[i] = 10 ** 12 + (p + 1) * 10 ** 6 + m

for r in res:
    print(str(r)[1:])
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for _ in range(N)]

if N % 2 == 0:
    res = 2 * (sum(a[N // 2:]) - sum(a[:N // 2]))
    res += a[N // 2 - 1] - a[N // 2]
    print(res)
else:
    res = 2 * (sum(a[N // 2 + 1:]) - sum(a[N // 2]))
    print(res - min(a[N // 2 + 1] - a[N // 2] - a[N // 2 - 1]))


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

if N % 2 == 0:
    res = 2 * (sum(a[N // 2:]) - sum(a[:N // 2]))
    res += a[N // 2 - 1] - a[N // 2]
    print(res)
else:
    res = 2 * (sum(a[N // 2 + 1:]) - sum(a[:N // 2]))
    print(res - min(a[N // 2 + 1] - a[N // 2], a[N // 2] - a[N // 2 - 1]))
Buggy python submission (verdict: Runtime Error):
import math

N, M = map(int, input().split())
S = input()
T = input()

if N == M:
    print(N if S == T else -1)
else:
    G = math.gcd(N, M)
    L = N * M // G
    n = N // G
    m = M // G
    ans = True
    for k in range(G):
        if S[k * n] != T[k * m]:
            ans = False
            break
    print(L if ans else -1)


Fixed submission:
import fractions

N, M = map(int, input().split())
S = input()
T = input()

if N == M:
    print(N if S == T else -1)
else:
    G = fractions.gcd(N, M)
    L = N * M // G
    n = N // G
    m = M // G
    ans = True
    for k in range(G):
        if S[k * n] != T[k * m]:
            ans = False
            break
    print(L if ans else -1)
Buggy python submission (verdict: Runtime Error):
import sys

H, W = map(int, input().split())
A = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(H)]

res = []
for i in range(H):
    for j in range(W):
        if A[i][j] % 2 != 0 and i < W - 1:
            A[i][j] -= 1
            A[i][j + 1] += 1
            res.append([i + 1, j + 1, i + 2, j + 1])
        elif A[i][j] % 2 != 0 and i != H - 1 and j == W - 1:
            A[i][j] -= 1
            A[i + 1][j] += 1
            res.append([i + 1, j + 1, i + 1, j + 2])
print(len(res))
for i in range(len(res)):
    print(*res[i])


Fixed submission:
import sys, heapq, bisect, math, fractions
from collections import deque
from collections import Counter
from collections import OrderedDict

H, W = map(int, input().split())
A = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(H)]

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

print(len(res))
for i in range(len(res)):
    print(*res[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())

res = "No"
for cake in range(0, int(n/4) + 1):
    for dornut in range(0, int(n/7) + 1):
        if 4 * cake + 7 * dornut == n:
            res = "Yes"
            break
    else:
        continue
    break

print(res)

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

print(int(N % K != 0))
Buggy python submission (verdict: Runtime Error):
N = int(input())

n = N - int((len(str(N)) - 1) * '9')
tmp = (len(str(N)) - 1) * '9'
if len(str(n)) > (len(str(N)) - 1):
    tmp = str(n)[0] + tmp

res = 0
for t in tmp:
    res += int(t)

print(res)


Fixed submission:
N = input()

f = int(N[0])
res = (len(N) - 1) * 9 + f - 1
s = 0
for i in N:
    s += int(i)

print(max(res, s))

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

n = N - int((len(str(N)) - 1) * '9')
tmp = (len(str(N)) - 1) * '9'
if len(tmp) > (len(str(N)) - 1):
    tmp = str(n)[0] + tmp

res = 0
for t in tmp:
    res += int(t)

print(res)


Fixed submission:
N = input()

f = int(N[0])
res = (len(N) - 1) * 9 + f - 1
s = 0
for i in N:
    s += int(i)

print(max(res, s))