Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
d = [0 for _ in range(n)]
d[0] = 1
sarr = []
if m == 0 and n == 1:
    d[0] = 0
for i in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and not n == 1:
        print(-1)
        exit()
    if s in sarr and c != d[s-1]:
        print(-1)
        exit()
    d[s-1] = c
    sarr.append(s)
    #print(sarr)
    #print(d)
ans = ''
for i in range(n):
    ans += str(d[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, m = MAP()
arr = [[] for _ in range(n)]
for _ in range(m):
    s, c = MAP()
    arr[s - 1].append(c)
tmp1 = [len(set(arr[i])) for i in range(n)]
tmp2 = Counter(tmp1)
if tmp2[0] + tmp2[1] != n or (arr[0][0] == 0 and n != 0):
    print(-1)
    exit()
tmp3 = [str(arr[i][0]) if tmp1[i] else '0' for i in range(n)]
if tmp3[0] == '0' and n > 1:
    tmp3[0] = '1'
print(''.join(tmp3))
Problem p02768 (python)

Fixed submission:
mod = 10 ** 9 + 7

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

def combmod(n,k,mod):
    a = 1
    b = 1
    for i in range(k):
        a = a * (n-i) % mod
        b = b * (i+1) % mod
    return a * pow(b, mod-2, mod) % mod

nca = combmod(n, a, mod) #comb(n, a, mod)#factorial(n) // factorial(a) // factorial(n-a)
ncb = combmod(n, b, mod) #comb(n, b, mod)#factorial(n) // factorial(b) // factorial(n-b)

ans = pow(2, n, mod)

ans -= 1 + nca + ncb
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

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

mod = 10 ** 9 + 7


import numpy as np
 
def prepare(n, MOD):
    nrt = int(n ** 0.5) + 1
    nsq = nrt * nrt
    facts = np.arange(nsq, dtype=np.int64).reshape(nrt, nrt)
    facts[0, 0] = 1
    for i in range(1, nrt):
        facts[:, i] = facts[:, i] * facts[:, i - 1] % MOD
    for i in range(1, nrt):
        facts[i] = facts[i] * facts[i - 1, -1] % MOD
    facts = facts.ravel().tolist()
 
    invs = np.arange(1, nsq + 1, dtype=np.int64).reshape(nrt, nrt)
    invs[-1, -1] = pow(facts[-1], MOD - 2, MOD)
    for i in range(nrt - 2, -1, -1):
        invs[:, i] = invs[:, i] * invs[:, i + 1] % MOD
    for i in range(nrt - 2, -1, -1):
        invs[i] = invs[i] * invs[i + 1, 0] % MOD
    invs = invs.ravel().tolist()
 
    return facts, invs


facts, invs = prepare(n, mod)

def comb(n, r, mod):
    return facts[n] * invs[r] % mod * invs[n-r] % mod

nca = comb(n, a, mod)#factorial(n) // factorial(a) // factorial(n-a)
ncb = comb(n, b, mod)#factorial(n) // factorial(b) // factorial(n-b)

ans = pow_k(2, n)

ans -= 1 + nca + ncb
ans %= mod
print(ans)
Problem p02784 (python)

Fixed submission:
h,n = map(int,input().split())
a = [int(i) for i in input().split()]
b = sum(a)
ans = 'Yes'
if b < h:
    ans = 'No'
print(ans)

Buggy submission (verdict: Runtime Error):
211 5
31 41 59 26 53
Problem p02787 (python)

Fixed submission:
import math
h,n = map(int,input().split())


a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
    a[i], b[i] = map(int,input().split())

dp = []
for i in range(h + max(a)):
    dp.append(pow(2, 31) - 1)
dp[0] = 0

for i in range(1, len(dp)):
    '''
    tmp = dp[i]
    for j in range(n):
        tmp = min(tmp, dp[max(0, i-a[j])] + b[j])
    dp[i] = tmp
    '''
    dp[i] = min(dp[i - A] + B for A, B in zip(a, b))

print(min(dp[h:]))

Buggy submission (verdict: Runtime Error):
import math
h,n = map(int,input().split())

dp = []
for i in range(n):
    a, b = map(int,input().split())
    if i == 0:
        for j in range(h):
            dp.append(math.ceil((j + 1) / a) * b)
    for j in range(h):
        if dp[j] > dp[j - a] + b:
            dp[j] = dp[j - a] + b
print(dp[h - 1])
Problem p02817 (python)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

s, t = S_MAP()
print(t + s)

Buggy submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

s, t = STR()
print(s + t)
Problem p02848 (python)

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

for i in range(len(s)):
    tmp = ord(s[i]) + n
    if tmp > ord('Z'):
        tmp -= ord('Z') - ord('A') + 1
    s[i] = chr(tmp)

ans = ''
for i in range(len(s)):
    ans += s[i]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(str(input()))

for i in range(len(s)):
    tmp = ord(s[i]) + n
    if tmp > ord('Z')
        s[i] = chr(tmp - ord('Z'))
    else:
        s[i] = chr(tmp)

ans = ''
for i in range(len(s)):
    ans += s[i]

print(ans)
Problem p02923 (python)

Fixed submission:
#https://atcoder.jp/contests/abc139/tasks/abc139_c

n = int(input())
h = [int(i) for i in input().split()]

cnt = []
if n!=1:
    a = []
    for i in range(n-1):
        a.append(h[i+1]-h[i])

    tmp=0
    for i in range(len(a)):
        if a[i] <= 0:
            tmp+=1
            if i == len(a)-1:
                cnt.append(tmp)
        else:
            cnt.append(tmp)
            tmp=0
else:
    cnt.append(0)

cnt.sort(reverse=True)

#print(a,cnt)
print(cnt[0])

Buggy submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc139/tasks/abc139_c

n = int(input())
h = [int(i) for i in input().split()]

a = []

for i in range(n-1):
    a.append(h[i+1]-h[i])

cnt = []
tmp=0
for i in range(len(a)):
    if a[i] <= 0:
        tmp+=1
        if i == len(a)-1:
            cnt.append(tmp)
    else:
        cnt.append(tmp)
        tmp=0
    
cnt.sort(reverse=True)

#print(a,cnt)
print(cnt[0])
Problem p03030 (python)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
sp = [S_LIST() for _ in range(n)]
for i in range(n):
    sp[i][1] = float(1 / (int(sp[i][1]) + 1))
    sp[i].append(i + 1)
sp.sort()
for i in range(n):
    print(sp[i][2])

Buggy submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
sp = [S_LIST() for _ in range(n)]
for i in range(n):
    sp[i][1] = float(1 / int(sp[i][1]))
    sp[i].append(i + 1)
sp.sort()
for i in range(n):
    print(sp[i][2])
Problem p03061 (python)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
a = LIST()
arr1 = [0 for _ in range(n)]
arr2 = [0 for _ in range(n)]
arr1[0] = a[0]
arr2[-1] = a[-1]
for i in range(1, n):
    arr1[i] = gcd(arr1[i - 1], a[i])
for i in reversed(range(n - 1)):
    arr2[i] = gcd(arr2[i + 1], a[i])
ans = arr1[-1]
for i in range(n): #delete a[i]
    if 0 < i < n - 1:
        ans = max(ans, gcd(arr1[i - 1], arr2[i + 1]))
    elif i == 0:
        ans = max(ans, arr2[1])
    elif i == n - 1:
        ans = max(ans, arr1[n - 2])
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

i=2
b=[1]#a=0
c=[1]
d=[]
while True:
    a = 0
    for j in range(N):
        if A[j] % i != 0:
            a += 1
        if a > 1:
            d.append(i) #black list
            break

    print(i,A,a)

    if a == 0:
        b.append(i) #white list
        for j in range(len(A)):
            A[j] = int(A[j] / i)
        i = 2
    if a == 1:
        c.append(i) #gray list
    if a > 0:
        i += 1
    
    k=0
    while True:
        if k >= len(d):
            break
        if i % d[k] == 0:
            i += 1
            k = -1
        k += 1


    if i > min(A):
        break

bs = 1
for i in range(len(b)):
    bs *= b[i]
print(bs * max(c))
Problem p03076 (python)

Fixed submission:
p={} #調理時間
r={} #注文-次の注文までの時間
for i in range(5):
    p[i] = int(input())
    r[i] = int((p[i] + 9) /10) * 10
    #print(r[i])

"""
for i in range(5):
    print(p[i],end=' ')
print('')

for i in range(5):
    print(r[i],end=' ')
print('')
"""
lastnum = 0
for i in range(1,5):
    if r[lastnum] - p[lastnum] < r[i] - p[i]:
        lastnum = i

#print(lastnum)

time = 0
for i in range(5):
    if i != lastnum:
        time += r[i]
    else:
        time += p[i]

print(time)

Buggy submission (verdict: Runtime Error):
p={} #調理時間
r={} #注文-次の注文までの時間
for i in range(5):
    p[i] = int(input())
    if p[i] % 10 != 0:
        r[i] = p[i] + 10 - p[i] % 10

lastnum = 0
for i in range(1,5):
    if r[lastnum] - p[lastnum] < r[i] - p[i]:
        lastnum = i

#print(lastnum)

time = 0
for i in range(5):
    if i != lastnum:
        time += r[i]
    else:
        time += p[i]

print(time)

Buggy submission (verdict: Runtime Error):
p={} #調理時間
r={} #注文-次の注文までの時間
for i in range(5):
    p[i] = int(input())
    if p[i] % 10 != 0:
        r[i] = p[i] + 10 - p[i] % 10

lastnum = 0
for i in range(1,5):
    if r[lastnum] - p[lastnum] < r[i] - p[i]:
        lastnum = i

print(lastnum)

time = 0
for i in range(5):
    if i != lastnum:
        time += r[i]
    else:
        time += p[i]

print(time)

Buggy submission (verdict: Runtime Error):
p={} #調理時間
q={} #調理時間/10のあまり
r={} #注文-次の注文までの時間
for i in range(5):
    p[i] = int(input())
    q[i] = p[i] % 10
    if q[i] != 0:
        r[i] = p[i] + 10 - q[i]

maxloss = 0
maxlossnum = 0
for i in range(5):
    if maxloss < r[i] - p[i]:
        maxloss = r[i] - p[i]
        maxlossnum = i

time = int(0)
for i in range(5):
    if i != maxlossnum:
        time += r[i]
    else:
        time += p[i]

print(time)

Buggy submission (verdict: Runtime Error):
p={} #調理時間
q={} #調理時間/10のあまり
r={} #注文-次の注文までの時間
for i in range(5):
    p[i] = int(input())
    q[i] = p[i] % 10
    if q[i] != 0:
        r[i] = p[i] + 10 - q[i]

maxloss = 0
maxlossnum = 0
for i in range(5):
    if maxloss < r[i] - p[i]:
        maxloss = r[i] - p[i]
        maxlossnum = i

time = int(0)
for i in range(5):
    if i != maxlossnum:
        time += r[i]
    else:
        time += p[i]

print(time)
Problem p03087 (python)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, q = MAP()
s = STR()
arr = [1 if s[i] + s[i + 1] == 'AC' else 0 for i in range(n - 1)]
arr2 = [[0, False] for _ in range(n - 1)]
arr2[0] = [arr[0], True if arr[0] == 1 else False]
for i in range(1, n - 1):
    arr2[i][0] = arr2[i - 1][0] + arr[i]
    arr2[i][1] = True if arr[i] == 1 else False
for _ in range(q):
    l, r = MAP()
    print(arr2[r - 2][0] - arr2[l - 1][0] + arr2[l - 1][1])

Buggy submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

def bsearch(arr, num):
    r = len(arr) - 1
    l = 0
    while r - l > 1:
        c = (r + l) // 2
        if arr[c] > num:
            r = c
        elif arr[c] < num:
            l = c
        else:
            l = c
            r = c
            break
    return [l, r]

n, q = MAP()
s = STR()
index = []
for i in range(len(s) - 1):
    if s[i] + s[i + 1] == 'AC':
        index.append(i)
ans = 0
for _ in range(q):
    l, r = MAP()
    ll = bsearch(index, l - 1)
    rr = bsearch(index, r - 2)
    lll = ll[0] if index[ll[0]] >= l - 1 else ll[1]
    rrr = rr[1] if index[rr[1]] <= r - 2 else rr[0]
    print(rrr - lll + 1)
Problem p03095 (python)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
s = list(STR())
t = list(set(s))
u = Counter(s)
v = []
for i in t:
    v.append(u[i] + 1)
ans = 1
for i in range(len(t)):
    ans *= v[i]
    ans %= mod
ans -= 1
print(ans % mod)

Buggy submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
s = list(STR())
t = list(set(s))
u = Counter(s)
v = []
for i in t:
    v.append(u[i] + 1)
ans = 1
for i in range(len(t)):
    ans *= v[i]
    ans %= mod
ans -= 1
print(ans %= mod)
Problem p03263 (python)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h, w = MAP()
a = [LIST() for _ in range(h)]
ans = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[i][j] % 2 == 1:
                y = i
                x = j + 1
                if x >= w:
                    y += 1
                    x = w - 1
                if y < h:
                    a[y][x] += 1
                    ans.append([str(i + 1), str(j + 1), str(y + 1), str(x + 1)])
    else:
        for j in reversed(range(w)):
            if a[i][j] % 2 == 1:
                y = i
                x = j - 1
                if x < 0:
                    y += 1
                    x = 0
                if y < h:
                    a[y][x] += 1
                    ans.append([str(i + 1), str(j + 1), str(y + 1), str(x + 1)])
print(len(ans))
for i in range(len(ans)):
    print(' '.join(ans[i]))

Buggy submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h, w = MAP()
a = [LIST() for _ in range(h)]
ans = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[i][j] % 2 == 1:
                y = i
                x = j + 1
                if x >= w:
                    y += 1
                    x = 0
                a[y][x] += 1
                ans.append([str(i + 1), str(j + 1), str(y + 1), str(x + 1)])
    else:
        for j in reversed(range(w)):
            if a[i][j] % 2 == 1:
                y = i
                x = j - 1
                if x < 0:
                    y += 1
                    x = w - 1
                a[y][x] += 1
                ans.append([str(i + 1), str(j + 1), str(y + 1), str(x + 1)])
print(len(ans))
for i in range(len(ans)):
    print(' '.join(ans[i]))
Problem p03296 (python)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
cnt=0
flag=False
for i in range(1,n):
    if a[i]==a[i-1]:
        if flag:
            flag=False
        else:
            cnt+=1
            flag=True
    else:
        flag=False
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in inpup().split()]
cnt=0
flag=False
for i in range(1,n):
    if a[i]==a[i-1]:
        if flag:
            flag=False
        else:
            cnt+=1
            flag=True
    else:
        flag=False
print(cnt)
Problem p03319 (python)

Fixed submission:
n,k=map(int, input().split())
a=[int(i) for i in input().split()]
if n==k:
    print(1)
else:
    k-=1
    print((n+k-2)//k)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
a=[int(i) for in input().split()]
if n==k:
    print(1)
else:
    k-=1
    print((n+k-1)//k)