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

Fixed submission:
import sys
sys.setrecursionlimit(10**5+100)

N,M=map(int,input().split())
G=[[] for _ in range(N)]
for _ in  range(M):
    xi,yi=map(int,input().split())
    G[xi-1].append(yi-1)

dp=[-1]*N #各ノードを始点とした時の最長経路

def rec(v):
    if dp[v]!=-1:
        return dp[v]
    
    res=0

    for nv in G[v]:
        res=max(res,rec(nv)+1)
    
    dp[v]=res
    return res

ans=0
for v in range(N):
    ans=max(ans,rec(v))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
G=[[] for _ in range(N)]
for _ in  range(M):
    xi,yi=map(int,input().split())
    G[xi-1].append(yi-1)

dp=[-1]*(N+1) #各ノードを始点とした時の最長経路

def rec(v):
    if dp[v]!=-1:
        return dp[v]
    
    res=0

    for nv in G[v]:
        res=max(res,rec(nv)+1)
    
    dp[v]=res
    return res

ans=0
for v in range(N):
    ans=max(ans,rec(v))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
G=[[] for _ in range(N)]
for _ in  range(M):
    xi,yi=map(int,input().split())
    G[xi-1].append(yi-1)

dp=[-1]*N #各ノードを始点とした時の最長経路

def rec(v):
    if dp[v]!=-1:
        return dp[v]
    
    res=0

    for nv in G[v]:
        res=max(res,rec(nv)+1)
    
    dp[v]=res
    return res

ans=0
for v in range(N):
    ans=max(ans,rec(v))
print(ans)

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

G=[[] for _ in range(N)]
for _ in  range(M):
    xi,yi=map(int,input().split())
    G[xi-1].appedn(yi-1)

dp=[-1]*N #各ノードを始点とした時の最長経路

def rec(v):
    if dp[v]!=-1:
        return dp[v]
    
    res=0

    for nv in G[v]:
        res=max(res,rec(nv)+1)
    
    dp[v]=res
    return res

ans=0
for v in range(N):
    ans=max(ans,rec(v))
print(ans)
Problem p03167 (python)

Fixed submission:
H,W=map(int,input().split())
#G=[[-1 if input() else 0 for i in range(W)] for _ in range(H)]
MOD=10**9+7
#リストver
dp=[[-1]*W for _ in range(H)]
for i in range(H):
    s=input()
    for j in range(W):
        if s[j]=='#':
            dp[i][j]=0
dp[0][0]=1

'''
#numpy ver
import numpy as np
dp=np.array([list(input()) for _ in range(H)])

dp=np.where(dp=='.',-1,dp)
dp=np.where(dp=='#',0,dp)

dp[0][0]=1
'''
for i in range(H):
    for j in range(W):
        if dp[i][j]==-1:
            if i>0 and j>0:
                dp[i][j]=dp[i-1][j]+dp[i][j-1]
            elif i>=1 and j==0:
                dp[i][j]=dp[i-1][j]
            elif i==0 and j>=1:
                dp[i][j]=dp[i][j-1]

print(dp[H-1][W-1]%MOD)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
#G=[[-1 if input() else 0 for i in range(W)] for _ in range(H)]

'''リストver
dp=[[-1]*W for _ in range(H)]
for i in range(H):
    s=input()
    for j in range(W):
        if s[j]=='#':
            dp[i][j]=0
dp[0][0]=1
'''

#numpy ver
import numpy as np
dp=np.array([list(input()) for _ in range(H)])

dp=np.where(dp=='.',-1,dp)
dp=np.where(dp=='#',0,dp)

dp=dp.astype(int)
dp[0][0]=1

for i in range(H):
    for j in range(W):
        if dp[i][j]==-1:
            if i>0 and j>0:
                dp[i][j]=dp[i-1][j]+dp[i][j-1]
            elif i>=1 and j==0:
                dp[i][j]=dp[i-1][j]
            elif i==0 and j>=1:
                dp[i][j]=dp[i][j-1]

print(dp[H-1][W-1])
Problem p03171 (python)

Fixed submission:
#EDPC L メモ化再帰じゃTLEで通らないのでやり直し

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

#dp[l][r]:=区間[l,r]が残っている時の(直後の人の最終的な得点-そうじゃない方の最終的な得点）

dp=[[-1]*N for _ in range(N)]

for k in range(N):
    dp[k][k]=a[k]

for r in range(1,N):
    for l in reversed(range(r)):
        dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1])

print(dp[0][N-1])

Buggy submission (verdict: Runtime Error):
#EDPC L
import sys
sys.setrecursionlimit(10**5)


def main():
    N=int(input())
    a=list(map(int,input().split()))
    #dp[l][r]:=区間[l,r]が残っている時の(直後の人の最終的な得点-そうじゃない方の最終的な得点）
    dp=[[-1]*N for _ in range(N)]
    print(rec(0,N-1))

def rec(l,r):
    if dp[l][r]!=-1:
        return dp[l][r]
    
    if l==r:
        dp[l][r]=a[l]
        return dp[l][r]
    
    dp[l][r]=max(a[l]-rec(l+1,r),a[r]-rec(l,r-1))

    return dp[l][r]
main()

Buggy submission (verdict: Runtime Error):
#EDPC L
import sys
sts.setrecursionlimit(10**8)

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

#dp[l][r]:=区間[l,r]が残っている時の(直後の人の最終的な得点-そうじゃない方の最終的な得点）

dp=[[-1]*N for _ in range(N)]


#for i in range(N-1):
#    for j in range()
def rec(l,r):
    if dp[l][r]!=-1:
        return dp[l][r]
    
    if l==r:
        dp[l][r]=a[l]
        return dp[l][r]
    
    dp[l][r]=max(a[l]-rec(l+1,r),a[r]-rec(l,r-1))

    return dp[l][r]


print(rec(0,N-1))

Buggy submission (verdict: Runtime Error):
#EDPC L
import sys
sts.setrecursionlimit(10**5+100)

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

#dp[l][r]:=区間[l,r]が残っている時の(直後の人の最終的な得点-そうじゃない方の最終的な得点）

dp=[[-1]*N for _ in range(N)]


#for i in range(N-1):
#    for j in range()
def rec(l,r):
    if dp[l][r]!=-1:
        return dp[l][r]
    
    if l==r:
        dp[l][r]=a[l]
        return dp[l][r]
    
    dp[l][r]=max(a[l]-rec(l+1,r),a[r]-rec(l,r-1))

    return dp[l][r]


print(rec(0,N-1))

Buggy submission (verdict: Runtime Error):
#EDPC L

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

#dp[l][r]:=区間[l,r]が残っている時の(直後の人の最終的な得点-そうじゃない方の最終的な得点）

dp=[[-1]*N for _ in range(N)]


#for i in range(N-1):
#    for j in range()
def rec(l,r):
    if dp[l][r]!=-1:
        return dp[l][r]
    
    if l==r:
        dp[l][r]=a[l]
        return dp[l][r]
    
    dp[l][r]=max(a[l]-rec(l+1,r),a[r]-rec(l,r-1))

    return dp[l][r]


print(rec(0,N-1))
Problem p03212 (python)

Fixed submission:
n=int(input())
 
def dfs(s):
  if int(s)>n:
    return 0
  cnt=1 if all(s.count(i)>0 for i in '753') else 0
  for j in '753':
    cnt+=dfs(s+j)
  return cnt
  
print(dfs('0'))

Buggy submission (verdict: Runtime Error):
N = int(input())
def dfs(s): # 文字列 s で始まる七五三数の個数 
if int(s) > N:
	return 0
ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1 
for c in '753':
  ret += dfs(s + c)
  return ret
print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Buggy submission (verdict: Runtime Error):
N = int(input())
def dfs(s): # 文字列 s で始まる七五三数の個数 if int(s) > N:
return 0
ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1 for c in '753':
         ret += dfs(s + c)
     return ret
print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく
Problem p03244 (python)

Fixed submission:
#111
from collections import Counter
n=int(input())
v=list(map(int,input().split()))

c0=Counter(v[0::2]).most_common()
c1=Counter(v[1::2]).most_common()

if c0[0][0]!=c1[0][0]:#再頻出の数がRとLで同一ではない場合
    ans=n-c0[0][1]-c1[0][1]
elif len(c0)!=1 and len(c1)!=1:
    ans=n-max(c0[0][1]+c1[1][1],c0[1][1]+c1[0][1])
elif len(c0)!=1 and len(c1)==1:
    ans=n-c0[1][1]-c1[0][1]
elif len(c0)==1 and len(c1)!=1:
    ans=n-c0[0][1]-c1[1][1]
elif len(c0)==1 and len(c1)==1:
    ans=n//2
print(ans)

Buggy submission (verdict: Runtime Error):
#111
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
L=list(Counter(v[0::2]).items())
R=list(Counter(v[1::2]).items())


if L[0][0]!=R[0][0]:#再頻出の数がRとLで同一ではない場合
    ans=n-L[0][1]-R[0][1]
elif len(R)!=1 and len(L)!=1:
    ans=n-max(L[0][1]+R[1][1],L[1][1]+R[0][1])
elif len(R)!=1 and len(L)==1:
    ans=n-R[1][1]-L[0][1]
elif len(R)==1 and len(L)!=1:
    ans=n-R[0][1]-L[1][1]
elif : len(R)==1 and len(L)==1:
    ans=n//2
print(ans)

Buggy submission (verdict: Runtime Error):
#112
from itertools import product

N=int(input())
px=[]
py=[]
ph=[]

for _ in range(N):
    x,y,h=map(int,input().split())
    if h!=0:
        px.append(x)
        py.append(y)
        ph.append(h)


        
def Calc_H(Cxi,Cyj,pxi,pyj,hi):
    return hi+abs(Cxi-pxi)+abs(Cyj-pyj)

    
    
for Cxi,Cyj in product(range(101),range(101)):
    preH=Calc_H(Cxi,Cyj,px[0],py[0],ph[0])
    for i in range(1,N):
        nowH=Calc_H(Cxi,Cyj,px[i],py[i],ph[i])
        if preH!=nowH:
            break
        preH=nowH
    else:
        print(Cxi,Cyj,nowH)
Problem p03262 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

N,X=map(int,input().split())

def int_X(x):
    return abs(int(x)-X)

ls=list(map(int_X,input().split()))

print(reduce(gcd,ls))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce

N,X=map(int,input().split())
ls=[]

for _ in range(N):
    ls.append(abs(int(input())-X))

print(reduce(gcd,ls))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce

N,X=map(int,input().split())
ls=[abs(int(input())-X) for _ in range(N)]

print(reduce(gcd,ls))
Problem p03266 (python)

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

num=[0]*(max(N+1,K))
for i in range(1,N+1):
    num[i%K]+=1
#print(num)
ans=0
for a in range(K):
    b=(K-a)%K#a=0なら0 a!=0ならk-aになる賢い手
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	#print(a)
        ans+=num[a]*num[b]*num[c]
        #print(a,b,c)
print(ans)

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

num=[0]*(max(N+1,K)
for i in range(1,N+1):
    num[i%K]+=1
#print(num)
ans=0
for a in range(K):
    b=(K-a)%K#a=0なら0 a!=0ならk-aになる賢い手
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	#print(a)
        ans+=num[a]*num[b]*num[c]
        #print(a,b,c)
print(ans)

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

num=[0]*(N+1)
for i in range(1,N+1):
    num[i%K]+=1
#print(num)
ans=0
for a in range(K):
    b=(K-a)%K#a=0なら0 a!=0ならk-aになる賢い手
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	#print(a)
        ans+=num[a]*num[b]*num[c]
        #print(a,b,c)
print(ans)

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

num=[0]*(N)
for i in range(1,N+1):
    num[i%K]+=1
#print(num)
ans=0
for a in range(K):
    b=(K-a)%K#a=0なら0 a!=0ならk-aになる賢い手
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	#print(a)
        ans+=num[a]*num[b]*num[c]
        #print(a,b,c)
print(ans)

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

num=[0]*(N)
for i in range(1,N+1):
    num[i%K]+=1
#print(num)

for a in range(K):
    b=(K-a)%K#a=0なら0 a!=0ならk-aになる賢い手
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	#print(a)
        ans+=num[a]*num[b]*num[c]
        print(a,b,c)
print(ans)

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

num=[0]*(K-1)
for i in range(N):
    num[i%K]+=1

for a in range(K):
    b=(K-a)%K#a=0なら0 a!=0ならk-aになる賢い手
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
        ans=num[a]*num[b]*num[c]
print(ans)
Problem p03274 (python)

Fixed submission:
N,K=[int(i) for i in input().split()]
X=[int(i) for i in input().split()]
m=10**9
for i in range(N-K+1):
    m=min(m,X[K-1+i]-X[i]+min(abs(X[K-1+i]),abs(X[i])))

print(m)

Buggy submission (verdict: Runtime Error):
N,K=[int(i) for i in input().split()]
X=[int(i) for i in input().split()]
m=10**5
for i in range(N-K+1):
    m=min(m,x[K-1+i]-x[i]+min(abs(x[K-1+i]),abs(x[i])))

print(m)

Buggy submission (verdict: Runtime Error):
N,K=[int(i) for i in input().split()]
X=[int(i) for i in input().split()]
m=10**5
for i in range(n-k+1):
    m=min(m,x[k-1+i]-x[i]+min(abs(x[k-1+i]),abs(x[i])))

print(m)

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

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

xm=[]
xp=[]
x0=[]
ans=10**5+1

for i in range(N):
    xi=x[i]
    if xi<0:
        xm.append(xi)
    elif xi==0:
        x0.append(xi)
    else:
        xp.append(xi)

xm.sort(reverse=True)

if x0==[]:
    ajst=0
else:
    ajst=1

K=K-ajst

for i in range(min(len(xp),K)):
    if i<K-1:
        if len(xm)>=K-(i+1):
            ans=min(ans,2*xp[i]-xm[K-ajst-(i+1)-1])
    
    else:#i==K-1
        ans=min(ans,xp[i])

for i in range(min(len(xm),K)):
    if i<K-1:
        if len(xp)-1>=K-(i+1):
            ans=min(ans,-2*xm[i]+xp[K-ajst-(i+1)-1])
    
    else:#i==K-1
        ans=min(ans,-xm[i])

if K==１ and x0!=[]:
    ans=0

print(ans)

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

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

xm=[]
xp=[]
x0=[]
ans=10**5+1

for i in range(N):
    xi=x[i]
    if xi<0:
        xm.append(xi)
    elif xi==0:
        x0.append(xi)
    else:
        xp.append(xi)

xm.sort(reverse=True)

if x0==[]:
    ajst=0
else:
    ajst=1

K=K-ajst

for i in range(min(len(xp),K)):
    if i<K-1:
        if len(xm)>=K-(i+1):
            ans=min(ans,2*xp[i]-xm[K-ajst-(i+1)-1])
    
    else:#i==K-1
        ans=min(ans,xp[i])

for i in range(min(len(xm),K)):
    if i<K-1:
        if len(xp)-1>=K-(i+1):
            ans=min(ans,-2*xm[i]+xp[K-ajst-(i+1)-1])
    
    else:#i==K-1
        ans=min(ans,-xm[i])

if K==１ and x0!=0:
    ans=0

print(ans)
Problem p03290 (python)

Fixed submission:
from itertools import product

D,G=map(int,input().split())
p,c=[],[]

for _ in range(D):
  pi,ci=map(int,input().split())
  p.append(pi)
  c.append(ci)
  
ans=10**4
  
for cpls in product(range(2),repeat=D):
  num=0#回答数
  tensu=0#各cplsの得点
  for i,v in enumerate(cpls,start=1):
    if v==1:
      tensu+=i*100*p[i-1]+c[i-1]
      num+=p[i-1]
  if tensu>=G:
    ans=min(ans,num)
    continue
  for i,v in reversed(list(enumerate(cpls,start=1))):
    if v==0:
      for _ in range(p[i-1]-1):
        tensu+=100*i
        num+=1
        if tensu>=G:
          ans=min(ans,num)
          break
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import product

D,G=map(int,input().split())
p,c=[],[]

for _ in range(D):
  pi,ci=map(int,input().split())
  p.append(pi)
  c.append(ci)
  
ans=10**4
  
for cpls in product((range(2),repeat=D)):
  num=0#回答数
  tensu=0#各cplsの得点
  for i,v in enumerate(cpls,start=1):
    if v==1:
      tensu+=i*100*p[i-1]+c[i-1]
      num+=p[i-1]
  if tensu>=G:
    ans=min(ans,num)
    continue
  for i,v in reversed(list(enumerate(cpls,start=1))):
    if v==0:
      for j in range(1,p[i-1]):
        tesu+=j*100*p[i-1]
        num+=1
        if tensu>=G:
          ans=min(ans,num)
          break
print(ans)

Buggy submission (verdict: Runtime Error):
from intertools import product

D,G=map(int,input().split())
p,c=[],[]

for _ in range(D):
  pi,ci=map(int,input().split())
  p.append(pi)
  c.append(ci)
  
ans=10**4
  
for cpls in product((range(2),repeat=D)):
  num=0#回答数
  tensu=0#各cplsの得点
  for i,v in enumerate(cpls,start=1):
    if v==1:
      tensu+=i*100*p[i-1]+c[i-1]
      num+=p[i-1]
  if tensu>=G:
    ans=min(ans,num)
    continue
  for i,v in reversed(list(enumerate(cpls,start=1))):
    if v==0:
      for j in range(1,p[i-1]):
        tesu+=j*100*p[i-1]
        num+=1
        if tensu>=G:
          ans=min(ans,num)
          break
print(ans)

Buggy submission (verdict: Runtime Error):
from intetools import product

D,G=map(int,input().split())
p,c=[],[]

for _ in range(D):
  pi,ci=map(int,input().split())
  p.append(pi)
  c.append(ci)
  
ans=10**4
  
for cpls in product((range(2),repeat=D)):
  num=0#回答数
  tensu=0#各cplsの得点
  for i,v in enumerate(cpls,start=1):
    if v==1:
      tensu+=i*100*p[i-1]+c[i-1]
      num+=p[i-1]
  if tensu>=G:
    ans=min(ans,num)
    continue
  for i,v in reversed(list(enumerate(cpls,start=1))):
    if v==0:
      for j in range(1,p[i-1]):
        tesu+=j*100*p[i-1]
        num+=1
        if tensu>=G:
          ans=min(ans,num)
          break
print(ans)
Problem p03294 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

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

def lcm_base(x,y):
  return x*y//gcd(x,y)

def lcm(ls):
  return reduce(lcm_base,ls)

def mod(ls,num):
    ans=0
    for i in range(N):
        ans+=num%ls[i]
    return ans
print(mod(a,lcm(a)-1))

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

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

def lcm_base(x,y):
  return x*y//gcd(x,y)

def lcm(ls):
  return reduce(lcm_base,ls)

print(lcm(a)-1)
Problem p03828 (python)

Fixed submission:
import math
from functools import reduce
N=int(input())
MOD=10**9+7
'''
def all_multiple(a):
    return reduce(lambda a,b:a*b,a)
'''
def all_multiple_mod(a,m):
    return reduce(lambda a,b:((a%m)*(b%m))%m,a)

def is_prime(n):
    if n<=1 or (n!=2 and n%2==0):#nが１以下、あるいは、2ではない偶数
        return False
    elif 2<=n<=9:#n1が2以上９以下かつ2以外の偶数ではない
        return True
    else:#nが10以上の奇数〜√nまでの数で割り切れない場合は素数
        res=True
        for d in range(3,int(math.sqrt(n))+1,2):
            if n%d==0:
                res=False
                break
        return res
#print(is_prime(N))

'''
def is_prime(n):
    if n==1: return False
    for k in range(2,int(math.sqrt(n))+1):
        if n%k==0:
            return False
    return True
'''

A=[1]*(N+1)#indexと割られる数を合わせる
ans=1
for N_t in range(2,N+1):
    for num in range(1,N_t+1):
        if is_prime(num):
            cnt=0
            while N_t%num==0:
                N_t=N_t//num
                cnt+=1
            A[num]+=cnt 

print(all_multiple_mod(A,MOD)%MOD)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
N=int(input())
MOD=10**9+7

def all_multiple(a):
    return reduce(lambda a,b:a*b,a)

def is_prime(n):
    if n==1: return False
    for k in range(2,int(math.sqrt(n))+1):
        if n%k==0:
            return False
    return True


A=[1]*(N+1)#indexと割られる数を合わせる
ans=1
for N_t in range(2,N+1):
    for num in range(1,N_t+1):
        if is_prime(num):
            cnt=0
            while N_t%num==0:
                N_t=N_t//num
                cnt+=1
            A[num]+=cnt 

print(all_multiple_mod(A,MOD)%MOD)
Problem p02601 (python)

Fixed submission:
import math
A,B,C = map(int, input().split())
K = int(input())
if A > B:
  K1 = math.ceil(math.log(A/B,2))
  B = B * (2 ** K1)
  if A == B:
    B = B * 2
    K1 = K1 + 1
elif A == B:
  B = B * 2
  K1 = 1
else:
  K1 = 0

if B > C:
  K2 = math.ceil(math.log(B/C,2))
  C = C * (2 ** K2)
  if C == B:
    K2 = K2 + 1
elif B == C:
  K2= 1
else:
  K2= 0
  
if K1 + K2 <= K:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import math
A,B,C = map(int, input().split())
K = int(input())
if A > B:
  K1 = math.ceil(math.log(A,B))
  B = B ** K1
  K1 = K1 -1
elif A == B:
  B = B ** 2
  K1 = 1
else:
  K1 = 0

if B > C:
  K2 = math.ceil(math.log(B,C)) - 1
elif B == C:
  K2= 1
else:
  K2= 0
  
if K1 + K2 <= K:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import math
A,B,C = map(int, input().split())
K = int(input())
if A < B:
  K1 = math.ceil(math.log(A,B))
  B = B ** K1
elif A == B:
  K1 = 2
  B = B ** K1
else
  K1 = 1

if B < C:
  K2 = math.ceil(math.log(B,C))
elif B == C:
  K2= 2
else
  K2= 1
if K1 + K2 -2 <= K:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import math
A,B,C = map(int, input().split())
K = int(input())
if A < B:
  K1 = math.ceil(math.log(A,B))
  B = B ** K1
else if A == B:
  K1 = 2;
  B = B ** K1
else
  K1 = 1;

if B < C:
  K2 = math.ceil(math.log(B,C))
else if B == C:
  K2= 2;
else
  K2= 1;
if K1 + K2 -2 <= K:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import math
A,B,C = map(int, input().split())
K = int(input())
K1 = math.ceil(math.log(A,B))
B = B ** K1
K2 = math.ceil(math.log(B,C))
if K1 + K2 -2 <= K:
  print('Yes')
else:
  print('No')
Problem p02612 (python)

Fixed submission:
import math
N = int(input())
print(math.ceil(N/1000)*1000-N)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = map(int, input().split())
p = 10 ** 9 + 7
A = list(map(int, input().split()))
A_np = np.array(A)
A_pos = A_np[A_np>=0]
A_neg = A_np[A_np<0]
judge = False
s = 1
if len(A_pos) > 0:
  if N > K:
    judge = True
  else:
    if len(A_neg) % 2 == 0:
      judge = True    
else:
  if (K % 2) == 0:
    judge = True
if judge == True:
  A_pos = np.sort(A_pos)[::-1]
  A_neg = np.sort(A_neg)
  if (K % 2) == 1:
    s = A_pos[0]
    A_pos = A_pos[1:]
    K = K - 1
  K = int(K / 2)
  stack = np.array([])
  for n in range(0,int(len(A_pos)/2)):
    stack = np.append(stack, (A_pos[2*n]*A_pos[2*n+1]) % p)
    if n == K:
      break
  for n in range(0,int(len(A_neg)/2)):
    stack = np.append(stack, (A_neg[2*n]*A_neg[2*n+1]) % p)
    if n == K:
      break
  stack = np.sort(stack)[::-1]
  for n in range(0,K):
    s = (s * stack[n]) % p
else:
  Index = np.sort(abs(A_np))
  A_sort = A_np[Index-1]
  for n in range(0,K):
    s = (s * A_sort[n]) % p
print(int(s))
Problem p03591 (python)

Fixed submission:
present = input()
if(present[:4] == 'YAKI'):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
H,W = list(map(int, input().split()))
moji = ''
char = {}
for i in range(H):
    moji += input()
for m in moji:
    if m in char:
        char[m] += 1
    else:
        char.update({m:1})

four = 0
two = 0
one = 0
for c in char:
    four += int(char[c] / 4)
    two += int(char[c]%4/2)
    one += int(char[c]%2)

ans = [(H//2)*(W//2), (H//2)*(W%2)+(H%2)*(W//2), (H%2)*(W%2)]
four -= ans[0]
while(four > 0):
    four -= 1
    ans[1] -= 2
if two == ans[1] and one == ans[2]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
hoge = [int(x) for x in input().split()]
moji = ''
char = {}
for i in range(hoge[0]):
    moji += input()
for m in moji:
    if m in char:
        char[m] += 1
    else:
        char.update({m:1})

four = 0
two = 0
one = 0
for c in char:
    while(char[c] > 0):
        four += char[c] / 4:
        two += char[c]%4/2:
        one += char[c]%2:

if four*4+two*2+one == hoge[0]*hoge[1]:
    print("Yes")
else:
    print("No")
Problem p03593 (python)

Fixed submission:
H,W = list(map(int, input().split()))
moji = ''
char = {}
for i in range(H):
    moji += input()
for m in moji:
    if m in char:
        char[m] += 1
    else:
        char.update({m:1})

four = 0
two = 0
one = 0
for c in char:
    four += int(char[c] / 4)
    two += int(char[c]%4/2)
    one += int(char[c]%2)

ans = [(H//2)*(W//2), (H//2)*(W%2)+(H%2)*(W//2), (H%2)*(W%2)]
four -= ans[0]
while(four > 0):
    four -= 1
    ans[1] -= 2
if two == ans[1] and one == ans[2]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
hoge = [int(x) for x in input().split()]
moji = ''
char = {}
for i in range(hoge[0]):
    moji += input()
for m in moji:
    if m in char:
        char[m] += 1
    else:
        char.update({m:1})

four = 0
two = 0
one = 0
for c in char:
    while(char[c] > 0):
        four += char[c] / 4:
        two += char[c]%4/2:
        one += char[c]%2:

if four*4+two*2+one == hoge[0]*hoge[1]:
    print("Yes")
else:
    print("No")
Problem p02582 (python)

Fixed submission:
s = input()

if "RRR" in s:
    ans = 3
elif "RR" in s:
    ans = 2
elif "R" in s:
    ans = 1
else:
    ans = 0

print(ans)

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

if "RRR" in s:
    ans = 3
elif "RR" in s:
    ans = 2
elif "R" in s:
    ans = 1

print(ans)
Problem p02791 (python)

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

ans=0
p_min=P[0]
for i in range(N):
    if p_min >= P[i]:
        ans += 1
        p_min = P[i]

print(ans)

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

ans=0
p_min=S[0]
for i in range(N):
    if p_min >= P[i]:
        ans += 1
        p_min = P[i]

print(ans)

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

ans=0
p_min=S[0]
for i in range(N):
    if p_min >= P[i]:
        ans++
        p_min = P[i]

print(ans)