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

Fixed submission:
import math
n,d=map(int,raw_input().split())
print int( math.ceil(float(n)/(2*d+1)))

Buggy submission (verdict: Runtime Error):
import math
n,d=map(int,raw_input())
print int( math.ceil(float(n)/(2*d+1)))
Problem p03013 (python)

Fixed submission:
#ABC129-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,m=IL()
D=[True]*n
for i in range(m):
    D[I()-1]=False
A=[0]*n
if n==1:
    if D[0]:
        print(1)
    else:
        print(0)

else:
    if D[0]:
        A[0]=1
        if D[1]:
            A[1]=2
        else:
            A[1]=0
    else:
        A[0]=0
        if D[1]:
            A[1]=1
        else:
            A[1]=0
    for i in range(2,n):
        if D[i]:
            A[i]=A[i-1]+A[i-2]
        else:
            A[i]=0
    print(A[n-1]%1000000007)

Buggy submission (verdict: Runtime Error):
#ABC129-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,m=IL()
D=[True]*n
for i in range(m):
    D[I()-1]=False
A=[0]*n
if D[0]:
    A[0]=1
    if D[1]:
        A[1]=2
    else:
        A[1]=0
else:
    A[0]=0
    if D[1]:
        A[1]=1
    else:
        A[1]=0
for i in range(2,n):
    if D[i]:
        A[i]=A[i-1]+A[i-2]
    else:
        A[i]=0
print(A[n-1]%1000000007)
Problem p03221 (python)

Fixed submission:
n,m=map(int,input().split())
p=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p.append([i,t1,t2])
p.sort(key=lambda x:x[2])
c=[1 for i in range(n+1)]
num=[]
for i,pre,yea in p:
    tmp=str(pre).zfill(6)+str(c[pre]).zfill(6)
    num.append([i,tmp])
    c[pre]+=1
num.sort()
for i in num:
    print(i[1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
p=[[] for i in range(n)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(n):
    tl=p[i].sort()
    for j in range(len(p[i])):
        u=str(i+1)
        w=tl.index(p[i][j])
        d=str(w+1)
        while len(u)<6:
            u="0"+u
        while len(d)<6:
            d="0"+d
        t=u+d
        nl.append(t)
for i in range(m):
    print(nl[i])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
p=[[] for i in range(m)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(m):
    for j in range(len(p[i])):
        u=str(i+1)
        d=str(j+1)
        while len(u)<6:
            u="0"+u
        while len(d)<6:
            d="0"+d
        t=u+d
        nl.append(t)
for i in range(m):
    print(nl[i])
Problem p03253 (python)

Fixed submission:
n,m=map(int,input().split())
pem=1
if m==1:
    print(1)
def fctr2(n): #それぞれの素因数の指数だけ出力
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append(c)
            c=0
    if n!=1:
        f.append(1)
    return f

mod=10**9+7
fuc=[1]
def fucfun(n):
    for i in range(1,n):
        e=fuc[i-1]*i
        fuc.append(e%mod)
def com(n,k):
    com=(fuc[n]%mod)*pow(fuc[k],mod-2,mod)*pow(fuc[n-k],mod-2,mod)
    return com
f=fctr2(m)
if m!=1:
    a=max(f)+n
    fucfun(a)
    s=1
    for i in range(len(f)):
        t=com(f[i]+n-1,f[i])
        s=(s*t)%mod
    print(s)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
pem=1
if m==1:
    print(1)
    pem=-1
def fctr2(n): #それぞれの素因数の指数だけ出力
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append(c)
            c=0
    if n!=1:
        f.append(1)
    return f

mod=10**9+7
fuc=[1]
def fucfun(n):
    for i in range(1,n):
        e=fuc[i-1]*i
        fuc.append(e%mod)
def com(n,k):
    com=(fuc[n]%mod)*pow(fuc[k],mod-2,mod)*pow(fuc[n-k],mod-2,mod)
    return com
f=fctr2(m)
a=max(f)+n
fucfun(a)
s=1
for i in range(len(f)):
    t=com(f[i]+n-1,f[i])
    s=(s*t)%mod
if pem==1:
    print(s)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
def fctr2(n): #それぞれの素因数の指数だけ出力
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append(c)
            c=0
    if n!=1:
        f.append(1)
    return f

mod=10**9+7
fuc=[1]
def fucfun(n):
    for i in range(1,n):
        e=fuc[i-1]*i
        fuc.append(e%mod)
def com(n,k):
    com=(fuc[n]%mod)*pow(fuc[k],mod-2,mod)*pow(fuc[n-k],mod-2,mod)
    return com
f=fctr2(m)
a=max(f)+n
fucfun(a)
s=1
for i in range(len(f)):
    t=com(f[i]+n-1,f[i])
    s=(s*t)%mod
print(s)
Problem p03307 (python)

Fixed submission:
N=int(input())
if N/2==N//2:
    print(N)
else:
    print(N*2)

Buggy submission (verdict: Runtime Error):
import copy
input()
a=[int(i) for i in input().split()]
sa=copy.copy(a)
for i in range(len(a)):
    sa[i]=sa[i]-(i+1)
sa.sort()
msa=sa[int(len(sa)/2)]
sb=0
for i in range(len(a)):
    sb=sb+abs(a[i]-(msa+i+1))
print(sb)

Buggy submission (verdict: Runtime Error):
import copy
input()
a=[int(i) for i in input().split()]
sa=copy.copy(a)
for i in range(len(a)):
    sa[i]=sa[i]-(i+1)
sa.sort()
msa=sa[int(len(sa)/2)]
sb=0
for i in range(len(a)):
    sb=sb+abs(a[i]-(sma+i+1))
print(sb)

Buggy submission (verdict: Runtime Error):
import copy
input()
a=[int(i) for i in input().split()]
sa=copy.copy(a)
for i in range(len(a)):
    sa[i]=sa[i]-(i+1)
sa.sort()
b=sa[int(len(sa)/2)]
sb=0
for i in range(len(a)):
    sb=sb+abs(a[i]-(b+i+1))
print(sb)

Buggy submission (verdict: Runtime Error):
import copy
input()
a=[int(i) for i in input().split()]
sa=copy.copy(a)
for i in range(len(a)):
    sa[i]=sa[i]-(i+1)
sa.sort()
b=sa[int(len(sa)/2)]
c=sa[int(len(sa)/2)+1]
sb=0
sc=0
for i in range(len(a)):
    sb=sb+abs(a[i]-(b+i+1))
    sc=sc+abs(a[i]-(c+i+1))
print(min(sb,sc))

Buggy submission (verdict: Runtime Error):
N=int(input())
if N/2==N//2:
    print(N)
else:
    print(n*2)
Problem p03426 (python)

Fixed submission:
# ABC089-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
h,w,d=IL()
A=[IL() for i in range(h)]
Al=[0]*(h*w+1)
for i in range(h):
    for j in range(w):
        Al[A[i][j]]=[i,j]

rui={}
for i in range(d):
    T=[0]
    for j in range(1,h*w+1-i-d,d):
        T.append(abs(Al[j+i][0]-Al[j+d+i][0])+abs(Al[j+i][1]-Al[j+d+i][1]))
    for j in range(len(T)-1):
        T[j+1]+=T[j]
    rui[(i+1)%d]=T
q=I()
for w in range(q):
    l,r=IL()
    idx=l%d
    if idx==0:
        li=l//d-1
        ri=r//d-1
    else:
        li=l//d
        ri=r//d
    print(rui[idx][ri]-rui[idx][li])

Buggy submission (verdict: Runtime Error):
# ABC089-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
h,w,d=IL()
A=[IL() for i in range(h)]
Al=[0]*(h*w+1)
for i in range(h):
    for j in range(w):
        Al[A[i][j]]=[i,j]

rui={}
for i in range(d):
    T=[0]
    for j in range(1,h*w+1-i-d,d):
        T.append(abs(Al[j+i][0]-Al[j+d+i][0])+abs(Al[j+i][1]-Al[j+d+i][1]))
    for j in range(len(T)-1):
        T[j+1]+=T[j]
    rui[(i+1)%d]=T
q=I()
for w in range(q):
    l,r=IL()
    idx=l%d
    li=l//d
    ri=r//d
    print(rui[idx][ri]-rui[idx][li])

Buggy submission (verdict: Runtime Error):
# ABC089-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
h,w,d=IL()
A=[IL() for i in range(h)]
Al=[0]*(h*w+1)
for i in range(h):
    for j in range(w):
        Al[A[i][j]]=[i,j]

rui=[]
for i in range(d):
    T=[0]
    for j in range(1,h*w,d):
        T.append(abs(Al[j][0]-Al[j+1][0])+abs(Al[j][1]-Al[j+1][1]))
    for j in range(len(T)-1):
        T[j+1]+=T[j]
    rui.append(T)
q=I()
for w in range(q):
    l,r=IL()
    idx=l%d
    li=l//d
    ri=r//d
    print(rui[idx][ri]-rui[idx][li])
Problem p03634 (python)

Fixed submission:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
import sys
sys.setrecursionlimit(10 ** 6)
n=I()
nl=[[] for i in range(n)]
used=[False for i in range(n)]
for i in range(n-1):
    a,b,c=IL()
    nl[a-1].append([b-1,c])
    nl[b-1].append([a-1,c])
d=[None for i in range(n)]
def dfs(now,pre,dis):
    used[now]=True
    d[now]=dis
    for i in nl[now]:
        if i[0]!=pre and not used[i[0]]:
            dfs(i[0],now,dis+i[1])
    
    return
q,k=IL()
dfs(k-1,-1,0)
for i in range(q):
    x,y=IL()
    print(d[x-1]+d[y-1])

Buggy submission (verdict: Runtime Error):
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n=I()
nl=[[] for i in range(n)]
used=[False for i in range(n)]
for i in range(n-1):
    a,b,c=IL()
    nl[a-1].append([b-1,c])
    nl[b-1].append([a-1,c])
d=[None for i in range(n)]
def dfs(now,pre,dis):
    used[now]=True
    d[now]=dis
    for i in nl[now]:
        if i[0]!=pre and not used[i[0]]:
            dfs(i[0],now,dis+i[1])
    
    return
q,k=IL()
dfs(k-1,-1,0)
for i in range(q):
    x,y=IL()
    print(d[x-1]+d[y-1])
Problem p03135 (python)

Fixed submission:
t,x = list(map(int,input().split()))
print(t/x)

Buggy submission (verdict: Runtime Error):
t,x = list(map(int,input().strip()))

num = t / x

print(float(num))
Problem p02987 (python)

Fixed submission:
n= input()

n_list=list(n)

a=(n_list.count(n_list[0]))
b=(n_list.count(n_list[1]))
c=(n_list.count(n_list[2]))
d=(n_list.count(n_list[3]))

if a==2:
    if b==2:
        if c==2:
            if d==2:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

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

n_list=list(n)

a=(n_list.count(n_list[0]))
b=(n_list.count(n_list[1]))
c=(n_list.count(n_list[2]))
d=(n_list.count(n_list[3]))
print(a,b,c,d)
if (a==3 and c==and b==2 and d==2):
    print("Yes")
else:
    print("No")
Problem p02987 (python)

Fixed submission:
list1 = [0,0]
S=input()

a1 = S[0]
a2 = "NUM"

if S[1] == a1:
    list1[0]=2
else:
    a2 = S[1]

if S[2]==a1:
    list1[0]=2
else:
    if S[1]==a1:
        a2 =S[2]
    else:
        if S[2]==a2:
            list1[1]=2
        else:
            pass

if S[3]==a1:
    list1[0]=2
else:
    if S[2]==a1 and S[1] == a1:
        a2 = S[3]
    else:
        if S[3]==a2:
            list1[1]=2
        else:
            pass
        
if list1[1]==2 and list1[0]==2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
list1 = [0,0]
S=""

a1 = S[0]
a2 = "NUM"

if S[1] == a1:
    list1[0]=2
else:
    a2 = S[1]

if S[2]==a1:
    list1[0]=2
else:
    if S[1]==a1:
        a2 =S[2]
    else:
        if S[2]==a2:
            list1[1]=2
        else:
            pass

if S[3]==a1:
    list1[0]=2
else:
    if S[2]==a1:
        a2 = S[3]
    else:
        if S[3]==a2:
            list1[1]=2
        else:
            pass

if list1[1]==2 and list1[0]==2:
    print("Yes")
else:
    print("No")
Problem p03012 (python)

Fixed submission:
n = int(input())
w = list(map(int,input().split()))
l=[]
for i in range(n):
    s_1=sum(w[:i])
    s_2=sum(w[i:])
    l.append(abs(s_1-s_2))
print(min(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
w = list(map(int,input().split()))
l=[]
for i in range(n):
    s_1=sum(w[:i])
    s_2=sum(w[i+1])
    l.append(abs(s_1,s_2))
print(min(l))
Problem p03042 (python)

Fixed submission:
S=input()
AB=int(S[:2])
CD=int(S[2:])
if  (1<=AB<=12) and  (1<=CD<=12):
    print('AMBIGUOUS')
elif (AB==0 or AB>=13) and  (1<=CD<=12):
    print('YYMM')
elif (1<=AB<=12) and (CD==0 or CD>=13):
    print('MMYY')
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
S=input()
AB=int(S[:2])
CD=int(S[2:])
if 1=< AB =<12 and 1 <= CD <= 12:
    print('AMBIGUOUS')
elif (AB=0 or AB=>13) and (1<=CD<=12):
    print('YYMM')
elif (1<=AB<=12) and (CD=0 or CD=>13):
    print('MMYY')
else:
    print('NA')
Problem p03307 (python)

Fixed submission:
N = int(input())

if N%2 == 0:
    print(N)
else:
    print(N*2)

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

if N%2 == 0:
    print N
else:
    print N*2
Problem p02990 (python)

Fixed submission:
N, B = map(int,input().split())
R = N-B
T = 1000000007

def generating_combination(n):
	T = 1000000007
	C = C = [[0 for i in range(n+1)] for j in range(n+1)]
	C[0][0] = 1
	C[1][0] = 1
	C[1][1] = 1
	for i in range(2,n+1):
		C[i][0] = 1
		C[i][i] = 1
		for j in range(1,i):
			C[i][j] = (C[i-1][j-1] + C[i-1][j])%T
	return(C)

D = generating_combination(2000)
for i in range(1,B+1):
	print((D[B-1][i-1]*D[R+1][i])%T)

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int,input().split())
devisor = 10 ** 9 + 7

def C(n,r):
    if r == 0 or r==n:
        return 1
    elif r == 1 or r == n-1:
        return n
    else:
        return math.factorial(n)//math.factorial(r)//math.factorial(n-r)

for i in range(K):
    print(C(N-K+1, i+1)*C(K-1, i) % devisor)

Buggy submission (verdict: Runtime Error):

import math

N, K = map(int,input().split())
devisor = 10 ** 9 + 7

def C(n,r):
    if n == 0 or n==r:
        return 1
    elif r == 1:
        return n
    else:
        return math.factorial(n)//math.factorial(r)//math.factorial(n-r)

for i in range(K):
    print(C(N-K+1, i+1)*C(K-1, i) % devisor)

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
devisor = 10 ** 9 + 7

import math


def C(n,r):
    return math.factorial(n)//math.factorial(r)//math.factorial(n-r)

for i in range(K):
    print(C(N-K+1, i+1)*C(K-1, i) % devisor)

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

import math


def C(n,r):
    return math.factorial(n)//math.factorial(r)//math.factorial(n-r)

for i in range(K):
    print(int(C(N-K+1, i+1)*C(K-1, i)))
Problem p03017 (python)

Fixed submission:
N,A,B,C,D=map(int,input().split())
S=input()

if "##" in S[A:C-1] or "##" in S[B:D-1]:
    print("No")
    exit()
elif C>D and "..." not in S[B-2:D+1]:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
if A<B<C<D:
    if "##" not in S:
        print("Yes")
    else:
        print("No")
else A<C<B<D:
    if "##" not in S[A:C-1] or "##" in S[B:D-1]:
        print("Yes")
    else:
        print("No")
elif A<B<D<C
    if "##" not in S and "..." in S[B-2:D+1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,A,B,C,D=map(int,input().split())
S=input()

if C<D:
    if "##" not in S[A:C-1] or "##" not in S[B:D-1]:
        print("Yes")
    else:
        print("No")
elif C>D
    if "##" not in S and "..." not in S[B-2:D+1]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N,A,B,C,D=map(int,input().split())
S=input()
print("No" if "##" in S else "No" if "..." not in S[B-1.D-1] and C>D else "Yes")

Buggy submission (verdict: Runtime Error):
N,A,B,C,D=map(int,input().split())
S=input()
if "##" in:
    print("No")
elif (S[C-2])=="#" and C>D:
    print("No")
elif (S[C])=="#" and C>D:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N,A,B,C,D=map(int,input().split())
S=input()
print("No" if "##" in S else "No" if ((S[C-2])=="#" or (S[C])=="#") and C>D else "Yes")
Problem p03045 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
N, M = map(int, input().split())
num_edges = M
edges = [list(map(int, input().split())) for i in range(num_edges)]
adj = [[] for i in range(N+1)]
for ed in edges:
    adj[ed[0]] += [[ed[1], ed[2]]]
    adj[ed[1]] += [[ed[0], ed[2]]]
col_list = [-1 for i in range(N+1)]

def recfun(v, col):
    col_list[v] = col #色を更新
    for ed in adj[v]: #隣接する頂点をみる
        if col_list[ed[0]] == -1: #更新していない場合
            recfun(ed[0], col) #同じ色でその先をみる
count = 0
for i in range(1, N+1):
    if col_list[i] == -1:
        count +=1
        recfun(i, count)
print(count)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
num_edges = M
edges = [list(map(int, input().split())) for i in range(num_edges)]
adj = [[] for i in range(N+1)]
for ed in edges:
    adj[ed[0]] += [[ed[1], ed[2]]]
    adj[ed[1]] += [[ed[0], ed[2]]]
col_list = [-1 for i in range(N+1)]

def recfun(v, col):
    col_list[v] = col #色を更新
    for ed in adj[v]: #隣接する頂点をみる
        if col_list[ed[0]] == -1: #更新していない場合
            recfun(ed[0], col) #同じ色でその先をみる
count = 0
for i in range(1, N+1):
    if col_list[i] == -1:
        count +=1
        recfun(i, count)
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

#####
N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    ui, vi, wi = map(int, input().split())
    uf.union(ui, vi)
print(len(np.unique(uf.par[1:])))
Problem p03038 (python)

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

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

count = 0
BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))

A.sort()
BC.sort(reverse=True, key=lambda x: x[1])

count = 0
CArr = []
for b, c in BC:
    if count >= N:
        break
    for i in range(b):
        CArr.append(c)
        count += 1
        if count >= N:
            break

for i in range(len(CArr)):
    if A[i] < CArr[i]:
        A[i] = CArr[i]

ans = sum(A)
print(ans)

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

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

B = []
for i in range(M):
    b, c = map(int, input().split())
    for j in range(b):
        B.append(c)

A.sort()
B.sort(reverse=True)
for i in range(M):
    if A[i] < B[i]:
        A[i] = B[i]

ans = sum(A)
print(ans)
Problem p03127 (python)

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

ans = 10 ** 10
while min(A) != ans:
    ans = min(A)
    for i, a_i in enumerate(A):
        if a_i > ans:
            A[i] = a_i % ans
            if A[i] == 0:
                del A[i]

print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def gcd_arr(a):
    ans = a[0]
    for i, a_i in enumerate(a):
        ans = gcd(ans, a_i)
    return ans

print(gcd_arr(A))
Problem p02970 (python)

Fixed submission:
n, d = input().split()
n=int(n)
d=int(d)
sum=0
count=0
while 1:
  sum=sum+2*d+1
  count+=1
  if sum>=n:
    break
print(count)

Buggy submission (verdict: Runtime Error):
n, d = input().split()
n=int(n)
d=int(d)
sum=0
count=0
while 1:
  sum=sum+2*d+1
  count+=1
    break
print(count)
Problem p02987 (python)

Fixed submission:
s = input()
result = 0
count = 0
for i in s:
  if s.count(i) == 2:
    result = 0
    count+=1
  else:
    count = 5
    break
if result == 1 or count > 4:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-2):
  if ((p[i]>p[i+1]) and (p[i+1]>p[i+2]) and (p[i]>p[i+2])) or ((p[i]<p[i+1]) and (p[i+1]<p[i+2]) and (p[i]<p[i+2])):
    count += 1
print(count)
Problem p02990 (python)

Fixed submission:
from sys import stdin
from math import factorial

n, k = [int(x) for x in stdin.readline().rstrip().split()]
MOD = 1000000007


def combination(x, y):
    return factorial(x) // (factorial(x-y) * factorial(y))


for i in range(1, k+1):
    if n - k + 1 < i:
        ans = 0
    else:
        blue = combination(k-1, i-1)
        red = combination(n-k+1, i)
        ans = blue * red
    print(ans % MOD)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from math import factorial

n, k = [int(x) for x in stdin.readline().rstrip().split()]
MOD = 1000000007


def combination(x, y):
    return factorial(x) // (factorial(x-y) * factorial(y))


for i in range(1, k+1):
    blue = combination(k-1, i-1)
    red = combination(n-k+1, i)
    ans = blue * red
    print(ans % MOD)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from math import factorial

n, k = [int(x) for x in stdin.readline().rstrip().split()]
MOD = 1000000007


def combination(x, y):
    return factorial(x) // (factorial(x-y) * factorial(y))


def f2(n, k):
    return combination(n+k-1, k-1)


def f(n, k):
    if n < k:
        return 0
    if n == 0 and k == 0:
        return 1
    if k < 1:
        return 0
    return f2(n-k, k)


for i in range(1, k+1):
    blue = f(k, i)
    red = f2(n-k-(i-1), i+1)
    ans = blue * red
    print(ans % MOD)
Problem p02990 (python)

Fixed submission:
import math

def fact(N):
    total = 1
    for i in range(1, N+1):
        total = total * i
    return total

def comb(a, b):
    return fact(a) // (fact(a-b) * fact(b))


def main():
    N, K = list(map(int, input().split(" ")))
    a = N - K + 1
    b = 1
    mod = 1000000007
    ans = ((a % mod) * (b % mod)) % mod
    print(ans)
    for i in range(1, K):
        tmp_a = (N-K+1-i)
        if tmp_a == 0:
            tmp_a = 1
        tmp_b = (K-1-i+1)
        if tmp_b == 0:
            tmp_b = 1
        a = (a * tmp_a) // (i+1)
        b = (b * tmp_b) // i
        ans = ((a % mod) * (b % mod)) % mod
        print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def fact(N):
    total = 1
    for i in range(1, N+1):
        total = total * i
    return total

def comb(a, b):
    return fact(a) / (fact(a-b) * fact(b))

def main():
    N, K = list(map(int, input().split(" ")))
    mod = 1000000007
    for i in range(1, K+1):
        # blue cluster
        comb1 = int(comb(N-K+1, i))
        comb2 = int(comb(K-1, i-1))
        ans = ((comb1 % mod) * (comb2 % mod)) % mod
        print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def fact(N):
    total = 1
    for i in range(1, N+1):
        total = total * i
    return total

def comb(a, b):
    return fact(a) / (fact(a-b) * fact(b))

def main():
    N, K = list(map(int, input().split(" ")))
    for i in range(1, K+1):
        #blue cluster
        comb1 = int(comb(N-K+1, i))
        comb2 = int(comb(K-1, i-1))
        total_comb = comb1 * comb2
        ans = total_comb%(10**9+7)
        print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    N, K = list(map(int, input().split(" ")))
    for i in range(1, K+1):
        #blue cluster
        blue_remain = K-i
        blue_comb = i**blue_remain
        red_remain = N-K-(i-1)
        red_comb = (i+1)**red_remain+1
        comb = blue_comb * red_comb
        print(comb)
        

if __name__ == '__main__':
    main()
Problem p03327 (python)

Fixed submission:
n = int(input())

if n <=999:
    print("ABC")
else:
    print("ABD")

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

if N <=999:
    print("ABC")
else:
    print("ABD")