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

Fixed submission:
N = int(input())

from math import sqrt
ans = 0
if N != 1:
    for k in range(1,int(sqrt(N)+1)):
        if N%k == 0:
            m = N//k-1
            if k == N%m: ans += m

print(ans)

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

from math import sqrt
ans = 0
for k in range(1,int(sqrt(N)+1)):
    if N%k == 0:
        m = N//k-1
        if k == N%m: ans += m

print(ans)
Problem p03292 (python)

Fixed submission:
A = sorted(map(int,input().split()))
ans = 0
for i in range(2): ans += A[i+1] - A[i]
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

def lcm(a,b): return a*b//gcd(a,b)

l = A[0]
for i in range(1,N):
    l = lcm(l,A[i])
l -= 1

ans = 0
for a in A: ans += l % a
print(ans)
Problem p03294 (python)

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

def lcm(a,b): return a*b//gcd(a,b)

l = A[0]
for i in range(1,N):
    l = lcm(l,A[i])
l -= 1

ans = 0
for a in A: ans += l % a
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
N = int(input())
A = list(map(int,input().split()))

def lcm(a,b): return a*b//gcd(a,b)

l = A[0]
for i in range(1,N):
    l = lcm(l,A[i])
l -= 1

ans = 0
for a in A: ans += l % a
print(ans)
Problem p03447 (python)

Fixed submission:
X = int(input())
A = int(input())
B = int(input())

print((X - A) % B)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(0, A+1):
    xi = X - 500 * i
    if xi < 0: break
    for j in range(0, B+1):
        xj = xi - 100 * j
        if xj < 0: break
        for k in range(0, C+1):
            xk = xj - 50 * k
            # print('{} {} {} {}'.format(i,j,k,xk))
            if xk == 0: ans += 1
            if xk < 0: break

print(ans)
Problem p03457 (python)

Fixed submission:
N = int(input())

flag = True
t0 = x0 = y0 = 0
for i in range(N):
    t1, x1, y1 = map(int, input().split())
    t = t1 - t0
    x = x1 - x0
    y = y1 - y0
    if (abs(x) + abs(y)) == 0:
        if t % 2 == 0: pass
    elif t % (abs(x) + abs(y)) != 0:
        flag = False
    t0 = t1
    x0 = x1
    y0 = y1

if flag: print('Yes')
else: print('No')

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

flag = True
t0 = x0 = y0 = 0
for i in range(N):
    t1, x1, y1 = map(int, input().split())
    t = t1 - t0
    x = x1 - x0
    y = y1 - y0
    if t % (abs(x) + abs(y)) != 0: flag = False
    t0 = t1
    x0 = x1
    y0 = y1

if flag: print('Yes')
else: print('No')
Problem p03651 (python)

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

ans = 'IMPOSSIBLE'
if max(A) >= K:
    # from math import gcd
    from fractions import gcd
    from functools import reduce
    g = reduce(gcd,A)
    # print(g)
    if K % g == 0: ans = 'POSSIBLE'

print(ans)

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

ans = 'IMPOSSIBLE'
if max(A) >= K:
    from math import gcd
    from functools import reduce
    g = reduce(gcd,A)
    if K % g == 0: ans = 'POSSIBLE'

print(ans)
Problem p03846 (python)

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

# N が奇数なら、Aはすべて偶数であり、かつ0を除いてすべて1ペア、かつ0が1つあるはず
# N が偶数なら、Aはすべて奇数であり、かつすべて1ペア
# 上記を確認するための辞書
dic = {}

for a in A:
    if a in dic.keys():
        dic[a] += 1
    else: dic[a] = 1

flag = True
ini = N
if N % 2 == 1:
    if 0 in A:
        if dic[0] == 1:
            ini = 2
        else:
            flag = False
    else:
        flag = False
else:
    ini = 1

for i in range(ini,N,2):
    if not flag: break
    if i in dic:
        if dic[i] != 2:
            flag = False
    else: flag = False

if flag:
    print(2**(N//2)%(10**9+7))
else:
    print(0)

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

# N が奇数なら、Aはすべて偶数であり、かつ0を除いてすべて1ペア、かつ0が1つあるはず
# N が偶数なら、Aはすべて奇数であり、かつすべて1ペア
# 上記を確認するための辞書
dic = {}

for a in A:
    if a in dic.keys():
        dic[a] += 1
    else: dic[a] = 1

flag = True
ini = N
if N % 2 == 1:
    if 0 in A:
        if dic[0] == 1:
            ini = 2
        else:
            flag = False
    else:
        flag = False
else:
    ini = 1

for i in range(ini,N,2):
    if not flag: break
    if dic[i] != 2:
        flag = False

if flag:
    print(2**(N//2)%(10**9+7))
else:
    print(0)

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

dic = {}

for a in A:
    if a in dic.keys():
        dic[a] += 1
    else: dic[a] = 1

flag = True
ini = N
if N % 2 == 1:
    if 0 in A:
        if dic[0] == 1:
            ini = 2
    else:
        flag = False
else:
    ini = 1
    
for i in range(ini,N,2):
    if not flag: break
    if dic[i] != 2:
        flag = False

if flag:
    print(2**(N//2)%(10**9+7))
else:
    print(0)

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

dic = {}

for a in A:
    if a in dic.keys():
        dic[a] += 1
    else: dic[a] = 1

flag = True
ini = 0
if N % 2 == 1:
    if dic[0] == 1:
        ini = 2
    else:
        flag = False
else:
    ini = 1

flag = True
for i in range(ini,N,2):
    if not flag: break
    if dic[i] != 2:
        flag = False

if flag:
    print(2**(N//2)%(10**9+7))
else:
    print(0)
Problem p02783 (python)

Fixed submission:
a,b=map(int,input().split())
if a%b!=0:print((a//b)+1)
else:print(a//b)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a%b!=0:print((a//b)+1) else:print(a//b)
Problem p02844 (python)

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

count = 0
for i in range(1000):
  pin = "00" + str(i)
  pin = pin[-3:]
  
  idx = 0
  for j in range(n):
    if s[j] == pin[idx]:
      idx += 1
      
    if idx == 3:
      break

  if idx == 3:
    count += 1
      
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
numlist = [str(i) for i in range(10)]
numlist *= 3

numcombi = list(itertools.combinations(numlist, 3))

print(numcombi)
Problem p02814 (python)

Fixed submission:
from fractions import gcd

def calc_half(n):
    return n//2

def lcm(L):
    ret=1
    for i in range(len(L)):
        ret=(ret*L[i])//gcd(ret,L[i])
    return ret

def f(n):
    ret=0
    while n%2==0:
        ret+=1
        n=n//2
    return ret

def g(L):
    l=[]
    for i in L:
        l.append(f(i))
    if len(set(l))==1:
        return False
    else:
        return True

n,m=map(int,input().split())
A=list(map(int,input().split()))
Auniq=list(set(A))
Ahalf=list(map(calc_half,Auniq))
lcm_ori=lcm(Auniq)
lcm_half=lcm(Ahalf)

if m<lcm_half or g(Auniq):
    print("0")
else:
    print(1+(m-lcm_half)//lcm_ori)

Buggy submission (verdict: Runtime Error):
from math import gcd

def calc_half(n):
    return n//2

def lcm(L):
    ret=1
    for i in range(len(L)):
        ret=(ret*L[i])//gcd(ret,L[i])
    return ret

def f(n):
    ret=0
    while n%2==0:
        ret+=1
        n=n//2
    return ret

def g(L):
    l=[]
    for i in L:
        l.append(f(i))
    if len(set(l))==1:
        return False
    else:
        return True

n,m=map(int,input().split())
A=list(map(int,input().split()))
Auniq=list(set(A))
Ahalf=list(map(calc_half,Auniq))
lcm_ori=lcm(Auniq)
lcm_half=lcm(Ahalf)

if m<lcm_half or g(Auniq):
    print("0")
else:
    print(1+(m-lcm_half)//lcm_ori)

Buggy submission (verdict: Runtime Error):
from math import gcd

def calc_half(n):
    return n//2

def lcm(L):
    ret=1
    for i in range(len(L)):
        ret=(ret*L[i])//gcd(ret,L[i])
    return ret

n,m=map(int,input().split())
A=list(map(int,input().split()))
Auniq=list(set(A))
Ahalf=list(map(calc_half,Auniq))
lcm_ori=lcm(Auniq)
lcm_half=lcm(Ahalf)

if m<lcm_half:
    print("0")
else:
    print(1+(m-lcm_half)//lcm_ori)
Problem p02936 (python)

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(2*10**5)
n,q=map(int,input().split())
graph=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
counter=[0]*n
for _ in range(q):
  p,x=map(int,input().split())
  counter[p-1]+=x
score=[0]*(n+1)
stack=[(0,-1)]
while stack!=[]:
  node,prev=stack.pop()
  score[node]=score[prev]+counter[node]
  for i in graph[node]:
    if i!=prev:
      stack.append((i,node))
print(*score[:-1])

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
sys.sstrecursionlimit(2*10**5)
n,q=map(int,input().split())
graph=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
counter=[0]*n
for _ in range(q):
  p,x=map(int,input().split())
  counter[p-1]+=x
score=[0]*(n+1)
stack=[(0,-1)]
while stack!=[]:
  node,prev=stack.pop()
  score[node]=score[prev]+counter[node]
  for i in graph[node]:
    if i!=prev:
      stack.append((i,node))
print(*score[:-1])

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(2*10**5)
n,q=map(int,input().split())
graph=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
prev=[-1]*n
prev[0]=0
def f(n):
    for i in graph[n]:
        if prev[i]==-1:
            prev[i]=n
            f(i)
f(0)
counter=[0]*n
for _ in range(q):
    p,x=map(int,input().split())
    counter[p-1]+=x
score=[0]*n
score[0]=counter[0]
stack=[0]
while stack!=[]:
    memo=[]
    for i in stack:
        for j in graph[i]:
            if j!=prev[i]:
                score[j]=score[i]+counter[j]
                memo.append(j)
    stack=memo
print(" ".join(score))

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
def Nodify(n):
    for i in graph[n]:
        if Tree[i]==-1:
            Tree[i]=n
            Nodify(i)
n,q=map(int,input().split())
graph=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
Tree=[-1]*n
Nodify(0)
counter=[0 for _ in range(n)]
for _ in range(q):
    p,x=map(int,input().split())
    counter[p-1]+=x
for i in range(n):
    y=i
    ret=counter[y]
    while y!=0:
        ret+=counter[Tree[y]]
        y=Tree[y]
    print(ret, end=" ")

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
def Nodify(n):
    for i in graph[n]:
        if Tree[i]==-1:
            Tree[i]=n
            Nodify(i)
n,q=map(int,input().split())
graph=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
Tree=[-1]*n
Nodify(0)
counter=[0 for _ in range(n)]
for _ in range(q):
    p,x=map(int,input().split())
    counter[p-1]+=x
for i in range(n):
    y=i
    ret=counter[y]
    while y!=0:
        ret+=counter[Tree[y]]
        y=Tree[y]
    print(ret, end=" ")
Problem p02957 (python)

Fixed submission:
a,b=map(int,input().split())
if (a+b)%2==1:print("IMPOSSIBLE")
else:print((a+b)//2)

Buggy submission (verdict: Runtime Error):
S=input()
MOD=10**9+7
dp=[0]*13
dp[0]=1
for i in range(len(S)):
    new_dp=[0]*13
    s=S[-1-i]
    if s=="?":
        for j in range(10):
            rem=(j*10**i)%13
            for k in range(13):
                new_dp[(k+rem)%13]+=dp[k]
    else:
        rem=(int(s)*10**i)%13
        for k in range(13):
            new_dp[(k+rem)%13]+=dp[k]
    for l in range(13):
        new_dp[l]%=MOD
    dp=new_dp
print(dp[5])
Problem p02972 (python)

Fixed submission:
from collections import deque
N=int(input())
A=deque(list(map(int,input().split())))
D={}
ans=[]
M=0
for i in range(N):
    a=A.pop()
    if N//(N-i)==1:
        D[N-i]=a
        if a==1:
            M+=1
            ans.append(str(N-i))
    else:
        p=N//(N-i)
        memo=0
        for j in range(1,p):
            memo+=D[(N-i)*(j+1)]
        if memo%2==a:
            D[N-i]=0
        else:
            D[N-i]=1
            M+=1
            ans.append(str(N-i))
print(M)
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
D={}
ans=""
M=0
for i in range(N):
    if N//(N-i)==1:
        a=A[N-i-1]
        D[N-i]=a
        if a==1:
            M+=1
            ans=ans+str(N-i)+" "
    else:
        a=N//(N-i)
        memo=0
        for j in range(1,a):
            memo+=D[(N-i)*(j+1)]
        if memo%2==A[N-i-1]:D[N-i]=0
        else:
            D[N-i-1]=1
            M+=1
            ans=ans+str(N-i)+" "
ans=ans[:-1]
print(M)
print(ans)
Problem p03000 (python)

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

ans,D=1,0

for l in L:
   D+=l
   if D<=X:
       ans+=1
       
print(ans)

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

ans,i,D=0,1,0

while D<=X:
    D+=L[i-1]
    ans+=1
    i+=1
    
print(ans)
Problem p03006 (python)

Fixed submission:
from collections import Counter
n=int(input())
L=[]
for _ in range(n):
   x,y=map(int,input().split())
   L.append((x,y))
D=[]
if n==1:print(1)
else:
   for i in range(n):
      for j in range(i+1,n):
          D.append((L[i][0]-L[j][0],L[i][1]-L[j][1]))
          D.append((L[j][0]-L[i][0],L[j][1]-L[i][1]))
   C=Counter(D)
   print(n-C.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
L=[]
for _ in range(n):
   x,y=map(int,input().split())
   L.append((x,y))
D=[]
for i in range(n):
   for j in range(i+1,n):
         D.append((L[i][0]-L[j][0],L[i][1]-L[j][1]))
         D.append((L[j][0]-L[i][0],L[j][1]-L[i][1]))
C=Counter(D)
print(n-C.most_common()[0][1])
Problem p03059 (python)

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

print(B*(T//A))

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

p_m=1
for n in range(N):
    p_m*=LA[n]
    
LA_absolute=[i*(-1) if i<0 else i for i in LA]


if p_m>=0:
    print(sum(LA_absolute))
else:
    print(sum(LA_absolute)-2*min(LA_absolute))

Buggy submission (verdict: Runtime Error):
N=int(input())
LA=list(map(int,input().split()))
ans=[]

def gcd(m,n):
    while n:
        m,n=n,m%n
    return m

from functools import reduce
def multigcd(item):
    return reduce(gcd, item)

for n in range(N):
    L=LA[:n]+LA[n+1:]
    ans.append(multigcd(L))

print(max(ans))
Problem p03061 (python)

Fixed submission:
N=int(input())
LA=list(map(int,input().split()))
ans=[]

def gcd(m,n):
    if m==0 or n==0:
        return m+n
    while n:
        m,n=n,m%n
    return m

La=[0]
Lb=[0]

for n in range(N-1):
    La.append(gcd(La[n],LA[n]))
    Lb.append(gcd(Lb[n],LA[-(n+1)]))

for n in range(N):
    ans.append(gcd(La[n],Lb[-(n+1)]))
        
print(max(ans))

Buggy submission (verdict: Runtime Error):
N=int(input())
LA=list(map(int,input().split()))
ans=[]

from math import gcd
from functools import reduce
def multigcd(item):
    return reduce(gcd, item)

for n in range(N):
    L=LA[:n]+LA[n+1:]
    ans.append(multigcd(L))

print(max(ans))

Buggy submission (verdict: Runtime Error):
N=int(input())
LA=list(map(int,input().split()))
ans=[]

from math import gcd
from functools import reduce
def func(item):
    return reduce(gcd, item)

for n in range(N):
    L=LA[:n]+LA[n+1:]
    ans.append(func(L))

print(max(ans))

Buggy submission (verdict: Runtime Error):
N=int(input())
LA=list(map(int,input().split()))
ans=[]

from math import gcd
from functools import reduce
def func(item):
    return reduce(gcd, item)

for n in range(N):
    L=LA[:n]+LA[n+1:]
    ans.append(func(L))

print(max(ans))
Problem p03078 (python)

Fixed submission:
import sys
def main():
    input=sys.stdin.readline
    X,Y,Z,K=map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    C=list(map(int,input().split()))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    AB=[]
    append=AB.append
    for i in range(min(K,X)):
        for j in range(min(K,Y)):
            append(A[i]+B[j])
    AB.sort(reverse=True)

    ABC=[]
    appendd=ABC.append
    for k in range(min(K,len(AB))):
        for l in range(min(K,Z)):
            appendd(AB[k]+C[l])
    ABC.sort(reverse=True)

    for m in range(K):
        print(ABC[m])

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
X,Y,Z,K=list(map(int,input().split()))
LA=list(map(int,input().split()))
LB=list(map(int,input().split()))
LC=list(map(int,input().split()))

LA.sort(reverse=True)
LB.sort(reverse=True)
LC.sort(reverse=True)

L=[]

for p in range(min(X,K-2)):
    for q in range(min(Y,K-p-1)):
        for r in range(min(Z,K-p-q)):
            L.append(LA[p]+LB[q]+LC[r])

L.sort(reverse=True)

for k in range(K):
    print(L[k])
Problem p03231 (python)

Fixed submission:
from fractions import gcd
N,M=map(int,input().split())
S=input()
T=input()
s=(M//gcd(N,M))
t=(N//gcd(N,M))
SS=[i*s for i in range(N)]
TT=[j*t for j in range(M)]
p,q=0,0
ans=N*s
while True:
    if SS[p]==TT[q]:
        if S[p]!=T[q]:ans=-1
        p+=1
        q+=1
    elif SS[p]>TT[q]:
        q+=1
    else:
        p+=1
    if p==N or q==M:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
N,M=map(int,input().split())
S=input()
T=input()
s=(M//gcd(N,M))
t=(N//gcd(N,M))
SS=[i*s for i in range(N)]+["end"]
TT=[j*t for j in range(M)]+["end"]
p,q=0,0
ans=N*s
for k in range(N*s):
    if SS[p]==k:
        if TT[q]==k:
            if S[p]!=T[q]:
                ans=-1
        p+=1
    if TT[q]==k:
        q+=1
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N,M=map(int,input().split())
S=input()
T=input()
s=(M//gcd(N,M))
t=(N//gcd(N,M))
SS=[i*s for i in range(N)]
TT=[j*t for j in range(M)]
p,q=0,0
ans=N*s
for k in range(N*s):
    if k==SS[p]:
        if k==TT[q]:
            if S[p]!=T[q]:
                ans=-1
        p+=1
    if k==TT[q]:
        q+=1
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N,M=map(int,input().split())
S=input()
T=input()
s=M//gcd(N,M)
t=N//gcd(N,M)
if s==1:SS=S
else:SS=("?"*(s-1)).join(list(S))+"?"*(s-1)
if t==1:TT=T
else:TT=("?"*(t-1)).join(list(T))+"?"*(t-1)
for i in range(len(SS)):
    if SS[i]==TT[i] or SS[i]=="?" or TT[i]=="?":pass
    else:
        print(-1)
        exit()
print(len(SS))

Buggy submission (verdict: Runtime Error):
from math import gcd
N,M=map(int,input().split())
S=input()
T=input()
s=M//gcd(N,M)
t=N//gcd(N,M)
if s==1:SS=S
else:SS=("?"*(s-1)).join(list(S))+"?"*(s-1)
if t==1:TT=T
else:TT=("?"*(t-1)).join(list(T))+"?"*(t-1)
for i in range(len(SS)):
    if SS[i]==TT[i] or SS[i]=="?" or TT[i]=="?":pass
    else:
        print(-1)
        exit()
print(len(SS))
Problem p03263 (python)

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

h,w=map(int,input().split())

B,ans,cnt=[],[],0
Bappend=B.append
ansappend=ans.append
fflag=False

for i in range(h):
    A=list(map(int,input().split()))
    flag=False
    for j in range(w-1):
        if flag:
            if A[j]%2==0:
                ansappend((i+1,j+1,i+1,j+2))
                flag=True
                cnt+=1
            else:
                flag=False
        else:
            if A[j]%2==1:
                ansappend((i+1,j+1,i+1,j+2))
                flag=True
                cnt+=1
    if i!=h-1:
        if flag+fflag==1:
            if A[w-1]%2==0:
                ansappend((i+1,w,i+2,w))
                fflag=True
                cnt+=1
            else:
                fflag=False
        else:
            if A[w-1]%2==0:
                fflag=False
            else:
                ansappend((i+1,w,i+2,w))
                fflag=True
                cnt+=1
                
print(cnt)
for a in ans:
    print(*a)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline

h,w=map(int,input().split())

B,ans,cnt=[],[],0
Bappend=B.append
ansappend=ans.append
fflag=False

for i in range(h):
    A=list(map(int,input().split()))
    flag=False
    for j in range(w-1):
        if flag:
            if A[j]%2==0:
                ansappend((i+1,j+1,i+1,j+2))
                flag=True
                cnt+=1
            else:
                flag=False
        else:
            if A[j]%2==1:
                ansappend((i+1,j+1,i+1,j+2))
                flag=True
                cnt+=1
    if i!=h-1:
        if flag+fflag==1:
            if A[w-1]%2==0:
                ansappend((i+1,j+1,i+2,j+1))
                fflag=True
                cnt+=1
            else:
                fflag=False
        else:
            if A[w-1]%2==0:
                fflag=False
            else:
                ansappend((i+1,j+1,i+2,j+1))
                fflag=True
                cnt+=1
                
print(cnt)
for a in ans:
    print(*a)
Problem p03282 (python)

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

i=0
while i<=len(S)-1:
    if S[i]=="1":
        i+=1
    else:
        break

if K<=i:
    print("1")
else:
    print(S[i])

Buggy submission (verdict: Runtime Error):
S=input()
K=int(input())

i=0
while i<=len(S):
    if S[i]=="1":
        i+=1
    else:
        break

if K<=i:
    print("1")
else:
    print(S[i])

Buggy submission (verdict: Runtime Error):
S=input()
K=int(input())

i=0
while i<=len(S):
    if S[i]=="1":
        i+=1
    else:
        break

if K<=i-1:
    print(1)
else:
    print(S[i])
Problem p03463 (python)

Fixed submission:
n,a,b=map(int,input().split())
if (b-a+1)%2==0:
    print("Borys")
else:
    print("Alice")

Buggy submission (verdict: Runtime Error):
n,a,b=int(input().split())
if (b-a+1)%2==0:
    print("Borys")
else:
    print("Alice")
Problem p03546 (python)

Fixed submission:
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
distance=[]
for _ in range(10):
   distance.append(list(map(int,input().split())))

for k in range(10):
   for j in range(10):
      for i in range(10):
         distance[i][j]=min(distance[i][j],distance[i][k]+distance[k][j])

ans=0
for _ in range(h):
   A=list(map(int,input().split()))
   for a in A:
      if a!=-1:
         ans+=distance[a][1]
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
distance=[]
for _ in range(10):
   distance.append(list(map(int,input().split())))

for k in range(10):
   for j in range(10):
      for i in range(10):
         distance[i][j]=min(distance[i][j],distance[i][k]+distance[k][j])

ans=0
for _ in range(h):
   A=list(map(int,input().split()))
   for a in A:
      if a!=-1:
         ans.append(distance[a][0])
print(ans)
Problem p03633 (python)

Fixed submission:
from fractions import gcd
def lcm(a,b):return (a//gcd(a,b))*b
N,x=int(input()),1
for _ in range(N):x=lcm(x,int(input()))
print(x)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
def lcm(a,b):return int(a*b/gcd(a,b))
N,x=int(input()),1
for _ in range(N):x=lcm(x,int(input()))
print(x)
Problem p03651 (python)

Fixed submission:
from fractions import gcd
from bisect import bisect_right
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
if k>A[n-1]:ans=-1
elif k==A[n-1]:ans=1
else:
    a=A[0]
    for i in range(1,n):
        a=gcd(a,A[i])
    m=A[bisect_right(A,k)]
    if (m-k)%a==0:
        ans=1
    else:
        ans=-1
if ans==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from bisect import bisect_right
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
if k>A[n-1]:ans=-1
elif k=A[n-1]:ans=1
else:
    a=A[0]
    for i in range(1,n):
        a=gcd(a,A[i])
    m=A[bisect_right(A,k)]
    if (m-k)%a==0:
        ans=1
    else:
        ans=-1
if ans==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from bisect import bisect_right
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
if k>A[n-1]:ans=-1
else:
    a=A[0]
    for i in range(1,n):
        a=gcd(a,A[i])
    m=A[bisect_right(A,k)]
    if (m-k)%a==0:
        ans=1
    else:
        ans=-1
if ans==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")