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

Fixed submission:
N,K=map(int,input().split())
XY=[list(map(int,input().split())) for i in range(N)]
XY=sorted(XY,key=lambda x:x[0])
Mlst=[]

if N>=2:
    for s1 in range(N-1):
        for s2 in range(s1+1,N):
            x1,y1=XY[s1]
            x2,y2=XY[s2]
            y1,y2=min(y1,y2),max(y1,y2)
            count=2
            for i in range(s1+1,s2):
                count+=y1<=XY[i][1]<=y2
            if count>=K:
                Mlst.append((y2-y1)*(x2-x1))
if N>=3:
    for s1 in range(N-2):
        for s2 in range(s1+1,N-1):
            for s3 in range(s2+1,N):
                x1,y1=XY[s1]
                x2,y2=XY[s2]
                x3,y3=XY[s3]
                x1,x2=x1,x3
                y1,y2=min(y1,y2,y3),max(y1,y2,y3)
                count=2
                for i in range(s1+1,s3):
                    count+=y1<=XY[i][1]<=y2
                if count>=K:
                    Mlst.append((y2-y1)*(x2-x1))
if N>=4:
    for s1 in range(N-3):
        for s2 in range(s1+1,N-2):
            for s3 in range(s2+1,N-1):
                for s4 in range(s3+1,N):
                    x1,y1=XY[s1]
                    x2,y2=XY[s2]
                    x3,y3=XY[s3]
                    x4,y4=XY[s4]
                    x1,x2=x1,x4
                    y1,y2=min(y1,y2,y3,y4),max(y1,y2,y3,y4)
                    count=2
                    for i in range(s1+1,s4):
                        count+=y1<=XY[i][1]<=y2
                    if count>=K:
                        Mlst.append((y2-y1)*(x2-x1))
print(min(Mlst))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
XY=[list(map(int,input().split())) for i in range(N)]

Mlst=set()
for s in range(N-1):
    for g in range(s,N):
        for z in range(g,N):
            x1,y1=XY[s]
            x2,y2=XY[g]
            x3,y3=XY[z]
            x1,x2=min(x1,x2,x3),max(x1,x2,x3)
            y1,y2=min(y1,y2,y3),max(y1,y2,y3)
            if sum([x1<=X<=x2 and y1<=Y<=y2 for X,Y in XY])>=K:
                Mlst.add((y2-y1)*(x2-x1))
print(min(Mlst))
Problem p03583 (python)

Fixed submission:
N=int(input())
a=4/N
h_st=max(int(N*(1/4))-1,1)
#h_st=1
for h in range(h_st,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if 4*h*n*n-(n*n+h*n+h*n)*N<=0 and 4*h*n*3500-(n*3500+h*3500+h*n)*N>=0:

            st,end=n,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
            while st!=end:
                #print(h,n,st,end)
                w=int((st+end)/2)
                if end-st==1:
                    end=w
                    st=w
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
                elif B>0:
                    end=w
                else:
                    st=w

        if flag:
            break
    if flag:
        break

print(h,n,w)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=4/N
h_st=int(N*(1/4))
for h in range(h_st,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if a-H-1/n-1/n<=0 and a-H-1/n-1/3500>=0:

            st,end=h,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    break
            while st!=end:
                #print(h,n,st,end)
                w=int((st+end)/2)
                if end-st==1:
                    end=w
                    st=w
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
                elif B>0:
                    end=w
                else:
                    st=w

        if flag:
            break
    if flag:
        break

print(h,n,w)
Problem p03612 (python)

Fixed submission:
N=int(input())
P=list(map(int,input().split()))
count=0
flag=0
for i in range(N):
    if flag:
        flag=0
        continue
    if P[i]==i+1:
        count+=1
        if i!=N-1:
            if P[i+1]==i+2:
                flag=1
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
P=list(map(int,input().split()))
count=0
flag=0
for i in range(N):
    if flag:
        flag=0
        continue
    if P[i]==i+1:
        count+=1
        if P[i+1]==i+2:
            flag=1
print(count)
Problem p03633 (python)

Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions .gcd(x, y)


N=int(input())
T=[int(input()) for i in range(N)]
temp=T[0]
for i in range(1,N):
    temp=lcm(temp,T[i])

print(temp)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


N=int(input())
T=[int(input()) for i in range(N)]
temp=T[0]
for i in range(1,N):
    temp=lcm(temp,T[i])

print(temp)
Problem p03651 (python)

Fixed submission:
import collections
import fractions
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K in A:
    print("POSSIBLE")
    exit()
if max(A)<K or len(A)==1:
    print("IMPOSSIBLE")
    exit()
S=collections.Counter([A[i+1]-A[0] for i in range(N-1)])
gcd=S[0]
for s in S:
    gcd=fractions.gcd(gcd,s)


if K%gcd==A[0]%gcd:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K in A:
    print("POSSIBLE")
    exit()
s=A[1]-A[0]
for i in range(1,N-1):
    if A[i+1]-A[i]!=s:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
Problem p03665 (python)

Fixed submission:
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,P=map(int,input().split())
A=list(map(lambda x:int(x)%2,input().split()))
A0,A1=A.count(0),A.count(1)
if P==1:
    if not A1:
        print(0)
        exit()
value0=0
for i in range(0,A0+1):
    value0+=comb(A0, i)
value1=(1 if not P else 0)
for i in range(2-P,A1+1,2):
    value1+=comb(A1, i)
print(value0*value1)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N,P=map(int,input().split())
A=list(map(int,input().split()))
A=[i%2 for i in A]
A0,A1=A.count(0),A.count(1)
if P==1:
    if not A1:
        print(0)
        exit()
value0=0
for i in range(0,A0+1):
    value0+=comb(A0, i, exact=True)
value1=0
for i in range(2-P,A1+1,2):
    value1+=comb(A1, i, exact=True)
print(value0*value1+(1 if not P else 0))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N,P=map(int,input().split())
A=list(map(lambda x:int(x)%2,input().split()))
A0,A1=A.count(0),A.count(1)
if P==1:
    if not A1:
        print(0)
        exit()
value0=0
for i in range(0,A0+1):
    value0+=comb(A0, i, exact=True)
value1=0
for i in range(2-P,A1+1,2):
    value1+=comb(A1, i, exact=True)
print(value0*value1+(1 if not P else 0))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N,P=map(int,input().split())
A=list(map(lambda x:int(x)%2,input().split()))
A0,A1=A.count(0),A.count(1)
if P==1:
    if not A1:
        print(0)
        exit()
value0=0
for i in range(0,A0+1):
    #print(value0)
    value0+=comb(A0, i, exact=True)
value1=0
for i in range(2-P,A1+1,2):
    #print(value1,i)
    #print(comb(A1, i, exact=True))
    value1+=comb(A1, i, exact=True)
print(value0*value1+(1 if not P else 0))
Problem p03715 (python)

Fixed submission:
H,W=map(int,input().split())
if H%3==0 or W%3==0:
    print(0)

else:
    for m in range(2):
        H,W=W,H
        if H%2==0:
            A1=(H//2)* W
        else:
            A1=(H//2 +1)* W
        A2=(H//2)* W
        A3=0
        if m == 0:
            value=max(A1,A2,A3)-min(A1,A2,A3)
        else:
            value=min(max(A1,A2,A3)-min(A1,A2,A3),value)
        for i in range(W):
            A3+=H
            if H%2==0:
                A1-=H//2
            else:
                A1-=H//2 + 1
            A2-=H//2
            value=min(max(A1,A2,A3)-min(A1,A2,A3),value)
    value=min(value,H,W)



    print(value)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
if H%3==0 or W%3==0:
    print(0)

elif H%2==0 or W%2==0:
    if W%2==0:
        H,W=W,H
    A1=(H//2 )* W
    A3=0
    value=A1-A3
    for i in range(1,W//2 +):
        A3+=H
        A1-=H//2
        value=min(int(abs(A1-A3)),value)
    print(value)
else:
    A1=(H//2 +1)* W
    A2=(H//2)* W
    A3=0
    value=max(A1,A2,A3)-min(A1,A2,A3)
    for i in range(1,W//2):
        A3+=H
        A1-=H//2 + 1
        A2-=H//2
        value=min(max(A1,A2,A3)-min(A1,A2,A3),value)

    H,W=H,W
    A1=(H//2 +1)* W
    A2=(H//2) * W
    A3=0
    value=min(max(A1,A2,A3)-min(A1,A2,A3),value)
    for i in range(1,W//2):
        A3+=H
        A1-=H//2 + 1
        A2-=H//2
        value=min(max(A1,A2,A3)-min(A1,A2,A3),value)
    print(value)
Problem p03716 (python)

Fixed submission:
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math

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

lst=A[:N]
_sum=sum(lst)
heapify(lst)

sumlstleft=[0 for i in range(N+1)]
sumlstleft[0]=_sum
for i in range(N,2*N):
    heappush(lst,A[i])
    a=heappop(lst)
    _sum+=A[i]-a
    sumlstleft[i-N+1]=_sum
lst=A[N*2:]
_sum=sum(lst)
lst=[-i for i in lst]
heapify(lst)
sumlstright=[0 for i in range(N+1)]
sumlstright[-1]=_sum
for i in range(2*N-1,N-1,-1):
    heappush(lst,-A[i])
    a=heappop(lst)
    _sum-=-a
    _sum+=A[i]
    sumlstright[i-N]=_sum
print(max([sumlstleft[i]-sumlstright[i] for i in range(N+1)]))

Buggy submission (verdict: Runtime Error):
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math

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

lst=A[:N]
_sum=sum(lst)
heapify(lst)

sumlst=[0 for i in range(N*3)]
sumlst[0]=_sum
for i in range(N,2*N):
    heappush(lst,A[i])
    a=heappop(lst)
    _sum+=A[i]-a
    sumlst[i-N+1]=_sum
lst=A[N*2:]
_sum=sum(lst)
lst=[-i for i in lst]
heapify(lst)
sumlst[-1]=_sum
for i in range(2*N-1,N-1,-1):
    heappush(lst,-A[i])
    a=heappop(lst)
    _sum-=-a
    _sum+=A[i]
    sumlst[i+N-1]=_sum

print(max([sumlst[i]-sumlst[2*N-1+i] for i in range(3*N//2)]))
Problem p03721 (python)

Fixed submission:
N,K=map(int,(input().split()))
ab=[list(map(int,(input().split()))) for i in range(N)]
ab=sorted(ab,key=lambda x:x[0])
count=0
for i in ab:
    count+=i[1]
    if count>=K:
        print(i[0])
        exit()

Buggy submission (verdict: Runtime Error):
[[print(ab[[index for index in [SumI if NK[1]<=sum([ab[1][I] for I in range(SumI)]) else -1 for SumI in range(NK[0])] if index!=-1][0]][0]) for ab in [sorted([list(map(int,(input().split()))) for i in range(NK[0])],key=lambda x:x[0])]] for NK in [list(map(int,(input().split())))]]
Problem p03722 (python)

Fixed submission:
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy
#input()
N,M=map(int,input().split())
ABC=[list(map(int,input().split())) for i in range(M)]

idle_max=10**18+1

dist=[idle_max for i in range(N+1)]
dist[1]=0


for loop in range(N-1):
    for a,b,c in ABC:
        c=-c
        if dist[a] != idle_max:
            dist[b]=min(dist[a] + c,dist[b])

value=dist[N]
for loop in range(N):
    for a,b,c in ABC:
        c=-c
        if dist[a] != idle_max:
            dist[b]=min(dist[a] + c,dist[b])
if value!=dist[N]:
    print("inf")
else:
    print(-value)

Buggy submission (verdict: Runtime Error):
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy
#input()
N,M=map(int,input().split())
ABC=[list(map(int,input().split())) for i in range(M)]
data=[[] for i in range(N+1)]
for a,b,c in ABC:
    data[a].append([b,c])

stack=[[1,0,set([1]),0,{1:0}]]#p,nagasa,visited,flag
ac=[]
while stack:
    p,m,miti,flag,dic=stack.pop()
    if not flag:
        for np,value in data[p]:
            if p in miti and m+value>dic[np]:
                flag=1
                if N in miti:
                    print("inf")
                    exit()
                break
    for np,value in data[p]:
        if np==N:

            if not flag:
                ac.append(m+value)
            else:
                print("inf")
                exit()
        if not np in miti:
            tempm=m+value
            tempmiti=copy.copy(miti)
            tempmiti.add(np)
            dic=copy.copy(dic)
            dic.update({np:tempm})
            stack.append([np,tempm,tempmiti,flag,dic])
print(max(ac))
Problem p03739 (python)

Fixed submission:
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

n=int(input())
A=list(map(int,input().split()))

def main(c,temp):

    if temp>0:
        flag=1
    elif temp<0:
        flag=0
    for i in range(1,n):
        temp+=A[i]
        if flag:
            if temp>=0:
                c+=temp-(-1)
                temp=-1
            flag=0
        else:
            if temp<=0:
                c+=1-temp
                temp=1
            flag=1
    return(c)

temp=A[0]
if temp:
    a=main(0,temp)
    if temp>0:
        b=main(temp - (-1),-1)
    else:
        b=main(1-temp,1)
    print(min(a,b))
else:
    temp=1
    a=main(1,temp)
    temp=-1
    b=main(1,temp)
    print(min(a,b))

Buggy submission (verdict: Runtime Error):
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

n=int(input())
A=list(map(int,input().split()))


temp=A[0]
if temp<0:
    flag=0
if temp>0:
    flag=1

count=0
for i in range(1,n):
    temp+=A[i]


    if flag:
        if temp>=0:
            count+=temp-(-1)
            temp=-1
        flag=0
    else:
        if temp<=0:
            count+=1-temp
            temp=1
        flag=1
    #print(temp,flag)

print(count)
Problem p03815 (python)

Fixed submission:
x=int(input())
print(int(x/11)*2+(x%11>0)+(x%11>6))

Buggy submission (verdict: Runtime Error):
x=int(input())
print(max(int(x/11)*2+(x%11>0)+(x%11>5)),1)
Problem p03844 (python)

Fixed submission:
a=input().split()
print(int(a[0])+int(a[2]) if a[1]=="+" else int(a[0])-int(a[2]))

Buggy submission (verdict: Runtime Error):
a=input.split()
print(int(a[0])+int(a[1]) if a[1]="+" else int(a[0])-int(a[1]))

Buggy submission (verdict: Runtime Error):
a=input.split()
print(int(a[0])+int(a[1]) if a[1]="+" else int(a[0])-int(a[1]))
Problem p03952 (python)

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


if x==1 or x==2*N-1:
    print("No")
elif N==2:
    print("Yes")
    for i in range(1,4):
        print(i)
else:
    lst=[0 for i in range(2*N-1)]
    nlst=set([i for i in range(1,2*N)])
    if x>=N:
        lst[N-1]=x
        lst[N]=x+1
        lst[N+1]=x-1
        lst[N-2]=x-2
        nlst.remove(x)
        nlst.remove(x+1)
        nlst.remove(x-1)
        nlst.remove(x-2)
    else:
        lst[N-1]=x
        lst[N]=x-1
        lst[N+1]=x+1
        lst[N-2]=x+2
        nlst.remove(x)
        nlst.remove(x-1)
        nlst.remove(x+1)
        nlst.remove(x+2)

    idxlst=set([i for i in range(2*N-1)])
    idxlst.remove(N-2)
    idxlst.remove(N-1)
    idxlst.remove(N)
    idxlst.remove(N+1)

    nlst=list(nlst)
    idxlst=list(idxlst)
    for n,i in zip(nlst,idxlst):
        lst[i]=n
    print("Yes")
    for i in lst:
        print(i)

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

lst=[0 for i in range(2*N-1)]
if x==1 or x==2*N-1:
    print("No")
else:
    nlst=set([i for i in range(1,2*N)])
    if x>=N:
        lst[N-1]=x
        lst[N]=x+1
        lst[N+1]=x-1
        lst[N-2]=x-2
        nlst.remove(x)
        nlst.remove(x+1)
        nlst.remove(x-1)
        nlst.remove(x-2)
    else:
        lst[N-1]=x
        lst[N]=x-1
        lst[N+1]=x+1
        lst[N-2]=x+2
        nlst.remove(x)
        nlst.remove(x-1)
        nlst.remove(x+1)
        nlst.remove(x+2)

    idxlst=set([i for i in range(2*N-1)])
    idxlst.remove(N-2)
    idxlst.remove(N-1)
    idxlst.remove(N)
    idxlst.remove(N+1)

    nlst=list(nlst)
    idxlst=list(idxlst)
    for n,i in zip(nlst,idxlst):
        lst[i]=n
    print(" ".join([str(i) for i in lst]))
Problem p03959 (python)

Fixed submission:
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""

N=int(input())
T=list(map(int,input().split()))
A=list(map(int,input().split()))
mod=10**9+7
lst=[0 for i in range(N)]


lst[0]=T[0]
lst[N-1]=A[N-1]
if T[N-1]!=A[0]:
    print(0)
    exit()
for i in range(1,N):
    if T[i]>T[i-1]:
        if lst[i] and lst[i]!=T[i]:
            print(0)
            exit()
        lst[i]=T[i]

for i in range(N-2,-1,-1):
    if A[i]>A[i+1]:
        if lst[i] and lst[i]!=A[i]:
            print(0)
            exit()
        elif not lst[i] and T[i]<A[i]:
            print(0)
            exit()
        lst[i]=A[i]

count=1
for i in range(N):
    if not lst[i]:
        count=count*min(T[i],A[i])%mod
print(count)

Buggy submission (verdict: Runtime Error):
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""

N=int(input())
T=list(map(int,input().split()))
A=list(map(int,input().split()))
mod=10**9+7
lst=[0 for i in range(N)]


lst[0]=T[0]
lst[N-1]=A[N-1]
if T[N-1]!=A[0]:
    print(0)
    exit()
for i in range(1,N):
    if T[i]>T[i-1]:
        if lst[i] and lst[i]!=T[i]:
            print(0)
            exit()
        lst[i]=T[i]

for i in range(N-2,-1,-1):
    if A[i]>A[i+1]:
        if lst[i] and lst[i]!=A[i]:
            print(0)
            exit()
        elif not lst[i] and T[i]<A[i]
        lst[i]=A[i]

count=1
for i in range(N):
    if not lst[i]:
        count=count*min(T[i],A[i])%mod
print(count)
Problem p03994 (python)

Fixed submission:
s=list(input())
K=int(input())
for i in range(len(s)-1):
    if s[i]!="a":
        a= ord("z")+1 - ord(s[i])
        if K>=a:
            s[i]="a"
            K-=a
if K:
    s[-1]=chr((K+ord(s[-1])-ord("a"))%(ord("z") - ord("a")+1)+ord("a"))
print("".join(s))

Buggy submission (verdict: Runtime Error):
s=list(input())
K=int(input())
for i in range(len(s)-1):
    if s[i]!="a"
        a= ord("z")+1 - ord(s[i])
        if K>=a:
            s[i]="a"
            K-=a
if K:
    s[-1]=chr((K+ord(s[-1])-ord("a"))%(ord("z") - ord("a")+1)+ord("a"))
print("".join(s))
Problem p04032 (python)

Fixed submission:
s=input()

for i in range(len(s)-2):
    if s[i]==s[i+1]:
        print(i + 1 ,i+1 + 1)
        exit()
    if s[i]==s[i+2]:
        print(i + 1,i+2 + 1)
        exit()

if s[-2]==s[-1 ]:
    print(len(s)-1 ,len(s))
    exit()

print(-1,-1)

Buggy submission (verdict: Runtime Error):
s=input()

for i in range(len(s)-2):
    if s[i]==s[i+1]:
        print(i + 1 ,i+1 + 1)
        exit()
    if s[i]==s[i+2]:
        print(i + 1,i+2 + 1)
        exit()

if s[i-2]==s[i -1 ]:
    print(i-2 +1 ,i-1)
    exit()

print(-1,-1)
Problem p03471 (python)

Fixed submission:
def solve(args):
    n, y = args

    #.
    for i in range(n+1):
        for j in range(0, n-i+1):
            #.
            k = n - i - j

            #.
            if i*10000 + j*5000 + k*1000 == y:
                return "{} {} {}".format(i, j, k)

    return "-1 -1 -1"

print(solve(map(int, input().split())))

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

#.
y = y // 1000

#.
for i in range(n+1):
    for j in range(n+1):
        #.
        money = y - i*10 - j*50

        #.
        if money == n - i - j:
            print("{} {} {}".format(i, j, money))
            return 0

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

#.
y /= 1000

#.
ans = 0

#.
for i in range(n+1):
    for j in range(n+1):
        #.
        money = y - i*10 - j*50

        #.
        if money == n - i - j:
            ans += 1

print(ans)

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

#.
ans = 0

#.
for i in range(n+1):
    for j in range(n+1):
        #.
        money = y - i*10000 - j*5000

        #.
        if money % 1000 != 0:
            continue

        #.
        if money / 1000 <= n - i - j:
            ans++

print(ans)
Problem p03263 (python)

Fixed submission:
H,W = map(int,raw_input().split())
count = 0
c = []
d = 0
e = []
for i in range(H):
  count += 1
  a = raw_input().split()
  b = []
  for j in range(W):
    b.append(int(a[j]))
  for k in range(W-1):
    if b[k]%2 == 1:
      d += 1
      f = [count,k+1,count,k+2]
      e.append(f)
      b[k] -= 1
      b[k+1] += 1
  c.append(b[W-1])
count = 0
for i in range(H-1):
  count += 1
  if c[i]%2 == 1:
    d += 1
    f = [count,W,count+1,W]
    e.append(f)
    c[i] -= 1
    c[i+1] +=1
print d
for i in range(d):
  x = e[i]
  print x[0],x[1],x[2],x[3]

Buggy submission (verdict: Runtime Error):
H,W = map(int,raw_input().split())
count = 0
c = []
d = 0
e = []
for i in range(H):
  count += 1
  a = raw_input().split()
  b = []
  for j in range(W):
    b.append(int(a[j]))
  for k in range(W-1):
    if b[k]%2 == 1:
      d += 1
      f = [count,k+1,count,k+2]
      e.append(f)
      b[k] -= 1
      b[k+1] += 1
  c.append(b[W-1])
count = 0
for i in range(H-1):
  count += 1
  if c[i]%2 == 1:
    d += 1
    f = [count,k+1,count,k+2]
    e.append(f)
print d
for i in range(d):
  x = e[i]
  print x[0],x[1],x[2],x[3]
Problem p03289 (python)

Fixed submission:
a = list(raw_input())
b = a[2:-1]
if a[0] == "A" and b.count("C") == 1:
  c = b.index("C")
  a.pop(0)
  a.pop(c+1)
  d = ""
  for i in range(len(a)):
     d += a[i] 
  if d.islower():
     print "AC"
  else:
     print "WA"
else:
  print "WA"

Buggy submission (verdict: Runtime Error):
a = raw_input().split()
b = a[2:-1]
if a[0] == "A" and b.count("C") == 1:
  a.del("A")
  a.del("C")
  if a.islower() == True:
     print "AC"
else:
  print "WA"
Problem p02554 (python)

Fixed submission:
n = int(input())

MOD = 10**9 + 7

ans = pow(10, n, MOD)-pow(9, n, MOD) - pow(9, n, MOD) + pow(8, n, MOD)

#負の処理
ans = (ans+MOD)%MOD

print(ans)

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

MOD = 10**9 + 7

ans = pow(10, n, MOD)-pow(9, n, MOD) - pow(9, n, MOD) + pow(8, n, MOD)

#負の処理
ans (ans+MOD)%MOD

print(ans)
Problem p02628 (python)

Fixed submission:
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))

ans = 0
for i in range(k):
    ans += p[i]

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = sorted(list(int, input().split()))

ans = 0
for i in range(k):
    ans += p[i]

print(ans)
Problem p02678 (python)

Fixed submission:
from collections import deque

n, m = map(int, input().split())
u = [[] for _ in range(n)] 

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    u[a].append(b)
    u[b].append(a)

q = deque([0])
ans = [-1] * n
count = 0

while len(q):
    p = q.popleft()
    for x in u[p]:
        if ans[x] == -1:
            ans[x] = p+1
            q.append(x)

ans[0] = 'Yes'

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

Buggy submission (verdict: Runtime Error):
from collections import deque

n, m = map(int, input().split())
u = [[] for _ in range(n)] 

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    u[a].append(b)
    u[b].append(a)

q = deque([0])
ans = [-1] * n
count = 0

while len(q):
    p = q.popleft()
    for x in u[p]:
        if ans[x] == -1:
            ans[x] = p+1
            q.append(x)
    print(q)

ans[0] = 'Yes'

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