Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
    import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    S = single_input()
    YYMM = False
    MMYY = False
    if 1 <= int(S[2:]) <= 12: YYMM = True
    if 1 <= int(S[:2]) <= 12: MMYY = True

    if YYMM and MMYY: print("AMBIGUOUS")
    elif YYMM: print("YYMM")
    elif MMYY: print("MMYY")
    else: print("NA")
    return 0
  
if __name__ == "__main__":
    solve()

Fixed submission:
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    S = single_input()
    YYMM = False
    MMYY = False
    if 1 <= int(S[2:]) <= 12: YYMM = True
    if 1 <= int(S[:2]) <= 12: MMYY = True

    if YYMM and MMYY: print("AMBIGUOUS")
    elif YYMM: print("YYMM")
    elif MMYY: print("MMYY")
    else: print("NA")
    return 0
  
if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
import heapq
X, Y, Z, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A.sort(reverse = True)
A.append(-100000)
B.sort(reverse = True)
B.append(-100000)
C.sort(reverse = True)
C.append(-100000)

Q = []
heapq.heapify(Q)
heapq.heappush(Q, (-(A[0]+B[0]+C[0]), 0, 0, 0))
count = 0
fin = {}
while count < K:
    value, a, b, c = heapq.heappop(Q)
    if (a, b, c) not in fin:
        fin[(a, b, c)] = 1
        print(-value)
        heapq.heappush(Q, (-(A[a+1]+B[b]+C[c]), a+1, b, c))
        heapq.heappush(Q, (-(A[a]+B[b+1]+C[c]), a, b+1, c))
        heapq.heappush(Q, (-(A[a]+B[b]+C[c+1]), a, b, c+1))
        count += 1

Fixed submission:
import heapq
X, Y, Z, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A.sort(reverse = True)
A.append(-10**20)
B.sort(reverse = True)
B.append(-10**20)
C.sort(reverse = True)
C.append(-10**20)

Q = []
heapq.heapify(Q)
heapq.heappush(Q, (-(A[0]+B[0]+C[0]), 0, 0, 0))
count = 0
fin = {}
while count < K:
    value, a, b, c = heapq.heappop(Q)
    if (a, b, c) not in fin:
        fin[(a, b, c)] = 1
        print(-value)
        heapq.heappush(Q, (-(A[a+1]+B[b]+C[c]), a+1, b, c))
        heapq.heappush(Q, (-(A[a]+B[b+1]+C[c]), a, b+1, c))
        heapq.heappush(Q, (-(A[a]+B[b]+C[c+1]), a, b, c+1))
        count += 1
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000000)
N = int(input())
C = [int(input())]
cindex = {C[0]:[0]}
mod = 7 + 10 ** 9
counter = 0
for _ in range(N-1):
    c = int(input())
    if c != C[-1]:
        C.append(c)
        counter += 1
        if c in cindex:
            cindex[c].append(counter)
        else:
            cindex[c] = [counter]

def variation(i, memo = {}):
    if i == len(C)-1: return 1
    try:
        return memo[i]
    except KeyError:
        total = 0
        L = cindex[C[i]]
        for l in L:
            if l > i:
                total += variation(l, memo) #lまで塗る
                total %= mod
                break
        total += variation(i + 1, memo)
        total %= mod
        memo[i] = total
        return total
 
memo = {}
print(variation(0, memo))

Fixed submission:
N = int(input())
S = input()
mod = 7 + 10 ** 9

word = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"\
    ,"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y","z"]
count = [1] * 26
for i in range(N):
    count[word.index(S[i])] += 1
Total = 1
for c in count:
    Total *= c
    Total %= mod
print(Total - 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000000)
N = int(input())
C = [int(input())]
cindex = {C[0]:[0]}
mod = 7 + 10 ** 9
counter = 0
for _ in range(N-1):
    c = int(input())
    if c != C[-1]:
        C.append(c)
        counter += 1
        if c in cindex:
            cindex[c].append(counter)
        else:
            cindex[c] = [counter]

def variation(i, memo = {}):
    if i == len(C)-1: return 1
    try:
        return memo[i]
    except KeyError:
        total = 0
        L = cindex[C[i]]
        for l in L:
            if l > i:
                total += variation(l, memo) #lまで塗る
                total %= mod
                break
        total += variation(i + 1, memo)
        total %= mod
        memo[i] = total
        return total
 
memo = {}
print(variation(0, memo))

Fixed submission:
N = int(input())
C = [int(input())]
cindex = {C[0]: 0}
mod = 7 + 10 ** 9
counter = 0
for _ in range(N-1):
    c = int(input())
    if c != C[-1]:
        C.append(c)
        counter += 1
        if c not in cindex:
            cindex[c] = counter

DP = [[0, 1] for i in range(len(C))]
for i in range(1, len(C)):
    if cindex[C[i]] == i:
        DP[i][1] = DP[i-1][1]
    else:
        DP[i][0] = DP[cindex[C[i]]][1] 
        DP[i][1] = DP[i][0] + DP[i-1][1]
        DP[i][1] %= mod
        cindex[C[i]] = i
print(DP[-1][1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000000)
N = int(input())
C = [int(input())]
cindex = {C[0]:[0]}
mod = 7 + 10 ** 9
counter = 0
for _ in range(N-1):
    c = int(input())
    if c != C[-1]:
        C.append(c)
        counter += 1
        if c in cindex:
            cindex[c].append(counter)
        else:
            cindex[c] = [counter]

def variation(i, memo = {}):
    if i == len(C)-1: return 1
    try:
        return memo[i]
    except KeyError:
        total = 0
        L = cindex[C[i]]
        for l in L:
            if l > i:
                total += variation(l, memo) #lまで塗る
                total %= mod
                break
        total += variation(i + 1, memo)
        total %= mod
        memo[i] = total
        return total
 
memo = {}
print(variation(0, memo))

Fixed submission:
N = int(input())
C = [int(input())]
cindex = {C[0]: 0}
mod = 7 + 10 ** 9
counter = 0
for _ in range(N-1):
    c = int(input())
    if c != C[-1]:
        C.append(c)
        counter += 1
        if c not in cindex:
            cindex[c] = counter

DP = [[0, 1] for i in range(len(C))]
for i in range(1, len(C)):
    if cindex[C[i]] == i:
        DP[i][1] = DP[i-1][1]
    else:
        DP[i][0] = DP[cindex[C[i]]][1] 
        DP[i][1] = DP[i][0] + DP[i-1][1]
        DP[i][1] %= mod
        cindex[C[i]] = i
print(DP[-1][1])
Buggy python submission (verdict: Runtime Error):
from math import ceil
L = int(input())
A = [int(input()) for _ in range(L)]
even = 0
start, end = 0, L-1
if A[0] == 0:
	for i in range(1, L):
		if A[i] != 0:
			start = i
			break
if A[-1] == 0:
	for i in reversed(range(L-1)):
		if A[i] != 0:
			end = i
			break
for a in A[start:end+1]:
	if a % 2 == 0:
		even += 1
if A[start] % 2 == 0 and A[start+1] % 2 == 1:
	even -= 1
if A[end-1] % 2 == 1 and A[end] % 2 == 0:
	even -= 1
		
print(ceil(even/2))

Fixed submission:
L = int(input())
A = [int(input()) for _ in range(L)]
INF = 10**20
DP = [[INF for i in range(5)] for _ in range(L)]
DP[0][0] = A[0]
DP[0][1] = (2 if A[0] == 0 else 1 if A[0] % 2 == 1 else 0)
DP[0][2] = (1 if A[0] % 2 == 0 else 0)
DP[0][3] = (2 if A[0] == 0 else 1 if A[0] % 2 == 1 else 0)
DP[0][4] = A[0]

for i in range(1, L):
    a = A[i]
    DP[i][0] = DP[i-1][0] + a
    DP[i][1] = min(DP[i-1][:2]) + (2 if a == 0 else 1 if a % 2 == 1 else 0)
    DP[i][2] = min(DP[i-1][:3]) + (1 if a % 2 == 0 else 0)
    DP[i][3] = min(DP[i-1][:4]) + (2 if a == 0 else 1 if a % 2 == 1 else 0)
    DP[i][4] = min(DP[i-1]) + a

print(min(DP[L-1]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = [float(p) for p in input().split()]

DP = [[0 for n in range(N+1)] for _ in range(N)]
DP[0][0] = 1-P[0]
DP[0][1] = P[0]

for i in range(1, N):
    use = P[i]
    DP[i][0] = DP[i-1][0] * (1-use)
    for j in range(1, i+2):
        DP[i][j] = DP[i-1][j] * (1-use) + DP[i-1][j-1] * use

print(sum(DP[N-1][N//2+1:]))



Fixed submission:
N = int(input())
P = [float(p) for p in input().split()]

DP = [[0 for n in range(N+1)] for _ in range(N)]
DP[0][0] = 1-P[0]
DP[0][1] = P[0]

for i in range(1, N):
    use = P[i]
    DP[i][0] = DP[i-1][0] * (1-use)
    for j in range(1, i+2):
        DP[i][j] = DP[i-1][j] * (1-use) + DP[i-1][j-1] * use

print(sum(DP[N-1][N//2+1:]))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = [float(p) for p in input().split()]

DP = [[0 for n in range(N+1)] for _ in range(N)]
DP[0][0] = 1-P[0]
DP[0][1] = P[0]

for i in range(1, N):
    use = P[i]
    dontuse = 1 - use
    for j in range(N):
        if j == 0: DP[i][0] = DP[i-1][0] * dontuse
        else:
            DP[i][j] = DP[i-1][j] * dontuse + DP[i-1][j-1] * use
    if i == N-1: DP[N-1][N] = DP[N-2][N-1] * use

print(sum(DP[N-1][N//2+1:]))

Fixed submission:
N = int(input())
P = [float(p) for p in input().split()]

DP = [[0 for n in range(N+1)] for _ in range(N)]
DP[0][0] = 1-P[0]
DP[0][1] = P[0]

for i in range(1, N):
    use = P[i]
    DP[i][0] = DP[i-1][0] * (1-use)
    for j in range(1, i+2):
        DP[i][j] = DP[i-1][j] * (1-use) + DP[i-1][j-1] * use

print(sum(DP[N-1][N//2+1:]))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9
    DP = [[0 for j in range(K + 1)] for i in range(N)]
    for i in range(A[0] + 1): DP[0][i] = 1
    for i in range(1, N):
        cum = [0] * (K + 2)
        for j in range(1, K + 2):
            cum[j] = (cum[j-1] + DP[i-1][j-1]) % mod
        #print(cum)
        for j in range(K + 1):
            DP[i][j] = (cum[j + 1] - cum[max(0, j - A[i])]) % mod
    print(DP[N-1][K])
    #print(DP)

    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9
    DP = [[0 for j in range(K + 1)] for i in range(N)]
    for i in range(A[0] + 1): DP[0][i] = 1
    cum = [0] * (K + 2)
    for i in range(1, N):
        for j in range(1, K + 2): cum[j] = (cum[j-1] + DP[i-1][j-1]) % mod
        for j in range(K + 1): DP[i][j] = (cum[j + 1] - cum[max(0, j - A[i])]) % mod
    print(DP[N-1][K])

    return 0

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

class segTree(): #range minimum query
    def __init__(self, N, V): #create segment tree with initial value V
        d = 1
        while d < N: d <<= 1
        self.tree = [V for _ in range(2 * d - 1)]
        self.size = d
    
    def update(self, i, a): #update cell i with value a
        now = self.size - 1 + i 
        self.tree[now] = a
        while now > 0:
            now = (now - 1) // 2
            self.tree[now] = max(self.tree[2 * now + 1], self.tree[2 * now + 2])

    def search(self, lower, higher, lbound, hbound, pos): #search minimum value of [lower, higher) init: lbound = 0, hbound = self.size, pos = 0
        if higher <= lbound or hbound <= lower: return 0
        if lower <= lbound and hbound <= higher: return self.tree[pos]
        else:
            left = self.search(lower, higher, lbound, (lbound + hbound) // 2, 2 * pos + 1)
            right = self.search(lower, higher, (lbound + hbound) // 2, hbound, 2 * pos + 2)
            return max(left, right)
        
def solve():
    input = sys.stdin.readline
    N = int(input())
    H = [int(h) for h in input().split()]
    A = [int(a) for a in input().split()]
    highest = max(H) + 1
    ans = segTree(highest, 0)
    for i, h in enumerate(H): 
        maxSum = ans.search(0, h, 0, ans.size, 0)
        ans.update(h, A[i] + maxSum)
    print(ans.search(0, highest, 0, ans.size, 0))

    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import sys

class segTree():
    def __init__(self, N, value):
        d, k = 1, 0
        while d < N:
            d *= 2
            k += 1
        self.tree = [value for _ in range(2 * d - 1)]
        self.size = d
    
    def update(self, i, a):
        now = self.size - 1 + i 
        self.tree[now] = a
        while now > 0:
            now = (now - 1) // 2
            self.tree[now] = max(self.tree[2 * now + 1], self.tree[2 * now + 2])
        #print(self.tree)

    def search(self, lower, higher, lbound, hbound, pos):
        if higher <= lbound or hbound <= lower: return 0
        if lower <= lbound and hbound <= higher: return self.tree[pos]
        else:
            left = self.search(lower, higher, lbound, (lbound + hbound) // 2, 2 * pos + 1)
            right = self.search(lower, higher, (lbound + hbound) // 2, hbound, 2 * pos + 2)
            return max(left, right)
        
def solve():
    input = sys.stdin.readline
    N = int(input())
    H = [int(h) for h in input().split()]
    A = [int(a) for a in input().split()]
    highest = max(H) + 1
    ans = segTree(highest, 0)
    for i, h in enumerate(H): 
        maxSum = ans.search(0, h, 0, ans.size, 0)
        ans.update(h, A[i] + maxSum)
    print(ans.search(0, highest, 0, ans.size, 0))

    return 0

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
Q = int(input())
K = [int(k) for k in input().split()]

def Counter(S, k):
    Total = 0
    count = [0, 0, 0] #D, M, DMの数
    for i in range(N):    
        if S[i] == "D": count[0] += 1
        elif S[i] == "M": 
            count[1] += + 1
            count[2] += count[0]
        elif S[i] == "C":
            Total += count[2]
        if i >= k - 1:
            if S[i-k+1] == "D":
                count[0] -= 1
                count[2] -= count[1]
            elif S[i-k+1] == "M":
                count[1] -= 1
    return Total

for i in range(Q):
    print(Counter(S, K[i]))

Fixed submission:
N = int(input())
S = input()
Q = int(input())
K = [int(k) for k in input().split()]

def Counter(S, k):
    Total = 0
    count = [0, 0, 0] #D, M, DMの数
    for i in range(N):
        
        if S[i] == "D": count[0] += 1
        elif S[i] == "M": 
            count[1] += + 1
            count[2] += count[0]
        elif S[i] == "C":
            Total += count[2]
        if i >= k - 1:
            if S[i-k+1] == "D":
                count[0] -= 1
                count[2] -= count[1]
            elif S[i-k+1] == "M":
                count[1] -= 1
    return Total

for i in range(Q):
    print(Counter(S, K[i]))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
Pref = [[] for i in range(N)]
City = [N+1 for i in range(M)]
for i in range(M):
    p, y = map(int, input().split())
    Pref[p-1].append(y)
    City[i] = (p, y)
for i in range(N):
    Pref[i].sort()
for i in range(M):
    first = City[i][0]
    second = Pref[first-1].index(City[i][1])
    ans = "{0:06d}".format(first) + "{0:06d}".format(second+1)
    print(ans)

Fixed submission:
N, M = map(int, input().split())
Pref = [1 for i in range(N)]
City = []
Ans = ["" for i in range(M)]
for i in range(M):
    p, y = map(int, input().split())
    City.append((y, p-1, i))
City.sort()
for i in range(M):
    Ans[City[i][2]] =  "{0:06d}".format(City[i][1]+1) + "{0:06d}".format(Pref[City[i][1]])
    Pref[City[i][1]] += 1

for i in range(M):
    print(Ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
Pref = [[] for i in range(N)]
City = [N+1 for i in range(M)]
for i in range(M):
    p, y = map(int, input().split())
    Pref[p-1].append((y, i))
    City[i] = (p, y)
for i in range(N):
    Pref[i].sort()
for i in range(M):
    first = City[i][0]
    second = Pref[first-1].index((City[i][1], i))
    ans = "{0:06d}".format(first) + "{0:06d}".format(second+1)
    print(ans)

Fixed submission:
N, M = map(int, input().split())
Pref = [1 for i in range(N)]
City = []
Ans = ["" for i in range(M)]
for i in range(M):
    p, y = map(int, input().split())
    City.append((y, p-1, i))
City.sort()
for i in range(M):
    Ans[City[i][2]] =  "{0:06d}".format(City[i][1]+1) + "{0:06d}".format(Pref[City[i][1]])
    Pref[City[i][1]] += 1

for i in range(M):
    print(Ans[i])
Buggy python submission (verdict: Runtime Error):
def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)
 
N = int(input())
P = [[0 for i in range(101)] for j in range(101)]
x, y, h = map(int, input().split())
P[x][y] = h
for i in range(101):
    for j in range(101):
        P[i][j] = dist(i, j, x, y, h)
 
for i in range(N-1):
    a, b, c = map(int, input().split())
    if P[a][b] != c:
        P[a][b] = False
    for j in range(101):
        for k in range(101):
            if P[j][k] != False and P[j][k] != dist(j, k, a, b, c):
                P[j][k] = False
temp = (0, 0, 0)
for i in range(101):
    for j in range(101):
        if P[i][j] > temp[2]:
            temp = (i, j, P[i][j])
print(temp[0], temp[1], temp[2])

Fixed submission:
import math
N, M = map(int, input().split())
ulim = M//N
mid = int(math.sqrt(M))
if ulim >= mid:
    ans = []
    for i in range(1, mid+1):
        if M%i == 0:
            ans.append(i)
            if M//i <= ulim:
                ans.append(M//i)
    print(max(ans))

else:
    for i in reversed(range(1, ulim+1)):
        if M%i == 0:
            print(i)
            break

Buggy python submission (verdict: Runtime Error):
def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)
 
N = int(input())
P = [[0 for i in range(101)] for j in range(101)]
x, y, h = map(int, input().split())
P[x][y] = h
for i in range(101):
    for j in range(101):
        P[i][j] = dist(i, j, x, y, h)
 
for i in range(N-1):
    a, b, c = map(int, input().split())
    if P[a][b] != c:
        P[a][b] = False
    for j in range(101):
        for k in range(101):
            if P[j][k] != False and P[j][k] != dist(j, k, a, b, c):
                P[j][k] = False
temp = (0, 0, 0)
for i in range(101):
    for j in range(101):
        if P[i][j] > ans:
            temp = (i, j, P[i][j])
print(temp[0], temp[1], temp[2])

Fixed submission:
import math
N, M = map(int, input().split())
ulim = M//N
mid = int(math.sqrt(M))
if ulim >= mid:
    ans = []
    for i in range(1, mid+1):
        if M%i == 0:
            ans.append(i)
            if M//i <= ulim:
                ans.append(M//i)
    print(max(ans))

else:
    for i in reversed(range(1, ulim+1)):
        if M%i == 0:
            print(i)
            break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
XY = []
L = []
maxL = 0
for i in range(N):
    x,  y = map(int, input().split())
    XY.append([x, y])
    maxL = max(maxL, abs(x) + abs(y))

m = maxL
D = [1 for _ in range(m)]
Move = []
Able = True
for i in range(N):
    x, y = XY[i][0], XY[i][1]
    if x > 0:
        move = "R" * x
    elif x < 0:
        move = "L" * abs(x)
    else:
        move = ""
    if y > 0:
        move += "U" * y
    elif y < 0:
        move += "D" * abs(y)
    if (m - abs(x) - abs(y)) % 2 == 0:
        move += "UD" * ((m-abs(x)-abs(y))//2)
    else:
        Able = False
    Move.append(move)

if Able:
    print(m)
    print(" ".join(map(str, D)))
    for i in range(N):
        print(Move[i])
else:
    print(-1)

Fixed submission:
import sys, math, collections, heapq, itertools
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())
    N = int(file())
    point = [[int(i) for i in file().split()] for j in range(N)]
    length = (point[0][0] + point[0][1]) % 2
    for i in range(1, N):
        if sum(point[i]) % 2 != length:
            print(-1)
            break
    else:
        d = [pow(2, i) for i in range(31)]
        direction = {("0", "0"): "L", ("1","1"): "R", ("0", "1"): "D", ("1", "0"): "U"}
        ans = ""
        add = (0 if length == 1 else 1)
        if add == 1: d.append(1)
        for i in range(N):
            U, V = point[i][0] + point[i][1] + add, point[i][0] - point[i][1] + add
            ubit = format((U + pow(2, 31) - 1)//2, "b").zfill(31)
            vbit = format((V + pow(2, 31) - 1)//2, "b").zfill(31)
            arm = ""
            for j in reversed(range(31)):
                arm += direction[(ubit[j], vbit[j])]
            if add == 1: arm += "L"
            ans += arm + "\n"
        print(len(d))
        print(" ".join(map(str, d)))
        print(ans)

    INF = 10 ** 25
    mod = 7 + 10 ** 9
    return 0
  
if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
import sys

def solve():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    A = [[int(a) for a in input().split()] for _ in range(H)]
    Ans = []
    for n in range(H * W - 1):
        h, w = n // W, n % W
        if A[h][w] % 2 == 1:
            if w < W - 1:
                Ans.append((h+1, w+1, h+1 w+2))
                A[h][w] -= 1
                A[h][w+1] += 1
            else:
                Ans.append((h+1, w+1, h+2, w+1))
                A[h][w] -= 1
                A[h+1][w] += 1
    print(len(Ans))
    for move in Ans:
        print(" ".join(map(str, move)))
   
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
H, W = map(int, input().split())
A = [[int(_) for _ in input().split()] for _ in range(H)]
N = 0
move = []
for i in range(H):
    for j in range(W):
        if A[i][j] % 2 == 1 and j <= W-2:
            A[i][j+1] += 1
            N += 1
            move.append([i+1, j+1, i+1, j+2])
        elif A[i][j]%2 == 1 and j == W-1 and i!=H-1:
            A[i+1][j] += 1
            N += 1
            move.append([i+1, j+1, i+2, j+1])

print(N)
for i in range(N):
    print(move[i][0], move[i][1], move[i][2], move[i][3])
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
 
if K == 1:
  print(int(S[0]))
elif len(S) == 1:
  print(int(S))
elif S[:K] == "1"*K:
  print(1)
else:
  for i in range(K+1):
    if S[i] != "1":
      print(int(S[i]))
      break

Fixed submission:
S = input()
K = int(input())
 
one = True
for i in range(K):
  if S[i] != "1":
    print(int(S[i]))
    one = False
    break
if one:
  print(1)

Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
 
if K == 1:
  print(int(S[0]))
elif len(S) == 1:
  print(int(S))
elif S[:K] == "1"*K:
  print(1)
else:
  for i in range(K+1):
    if S[i] != "!":
      print(int(S[i]))
      break

Fixed submission:
S = input()
K = int(input())
 
one = True
for i in range(K):
  if S[i] != "1":
    print(int(S[i]))
    one = False
    break
if one:
  print(1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())
LR =[[] for i in range(N)]
for i in range(M):
    L, R = map(int, input().split())
    LR[L-1].append(R)

ans = []
for i in range(Q):
    p, q = map(int, input().split())
    count = 0
    for j in range(p-1, q):
        for k in LR[j]:
            if k <= q:
                count += 1
    ans.append(count)

for i in range(len(ans)):
    print(ans[i])

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

LR =[[0 for j in range(N+2)] for i in range(N+1)]
for i in range(M):
    L, R = map(int, input().split())
    LR[L][R] += 1
    LR[0][R] -= 1
    LR[L][N+1] -= 1
    LR[0][N+1] += 1

for i in range(1, N+1): #R方向への累積和
    for j in range(1, N+2):
        LR[i][j] += LR[i][j-1]
for i in range(N-1, -1, -1): #L方向への累積和
    for j in range(1, N+2):
        LR[i][j] += LR[i+1][j]

ans = []
for i in range(Q):
    p, q = map(int, input().split())
    ans.append(LR[p][q])

for i in range(Q):
    print(ans[i])