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

Fixed submission:
s=input()
t=input()
a = len(s)
b = len(t)
l = []
for i in range(a-b+1):
    cnt = 0
    c = s[i:i+b]
    for x, y in zip(c, t):
        if x != y:
            cnt +=1
    l.append(cnt)
print(min(l))

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
a = len(s)
b = len(t)
l = []
for i in range(a-b+1):
    cnt = 0
    c = s[i,i+t]
    for x, y in zip(c, t):
        if x != y:
            cnt +=1
    l.append(cnt)
print(min(l))
Problem p02577 (python)

Fixed submission:
N=int(input())
print('Yes' if N%9==0 else 'No')

Buggy submission (verdict: Runtime Error):
N =int(input())
if N%9 == 0:
  print('Yes')
else;
  print('No')

Buggy submission (verdict: Runtime Error):
N =input()
if N%9==0:
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
N= int(input())
if N%9==0:
  print('Yes')
  
  else :
    print('No')
Problem p02594 (python)

Fixed submission:
N = int(input())
if N >=30:
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
S,W =map(int,input().split())
if W >=S:
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
N =input()
if N >=30:
    print('Yes')
else :
    print('No')
Problem p02595 (python)

Fixed submission:
N,D=map(int,input().split())
ans =0

for i in range(N):
    X,Y =map(int,input().split())
    if D**2>=X**2+Y**2:
        ans +=1

print(ans)

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

for i in range(N):
X,Y =map(int,input().split())
if D::2>=X**2+y**2:
    ans +=1

print(ans)
Problem p02629 (python)

Fixed submission:
n=int(input())
ans = ''
while n>0:
        n = n-1
        ans += chr(ord('a') + (n)% 26)
        n//=26
ans = ans[::-1]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans = ''
while n>0:
        n = n-1
        s += chr(ord('a') + (n)% 26)
        n//=26
ans = ans[::-1]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s = ''
while n>0:
        s += chr(ord('a') + (n-1)% 26)
        (n-1)//=26

print(s[::-1])
Problem p02659 (python)

Fixed submission:
A,B =map(str,input().split())
A=int(A)
B =B.replace('.','')
B =int(B)
ans = A*B//100
print(ans)

Buggy submission (verdict: Runtime Error):
A,B =map(str,input().split())
A=int(A)
B.replace(',','')
B =int(B)
ans = A*B//100
print(ans)
Problem p02676 (python)

Fixed submission:
K=int(input())
s =input()
x = len(s)

if x<=K:
    print(s)
else:
    print(s[:K]+'...')

Buggy submission (verdict: Runtime Error):
K=int(input())
s =input()
x = len(s)

if x<=K:
    print(s)
else:
    print(S[:K]+'...')
Problem p02689 (python)

Fixed submission:
n,m=map(int,input().split())                       
h =list(map(int,input().split()))
cnt = 0
l = [[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split()) 
    l[a-1].append(h[b-1])
    l[b-1].append(h[a-1])

for i in range(n):
    if l[i] == []:
        cnt+=1

    elif h[i] > max(l[i]):
        cnt +=1
    

print(cnt)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())                       
h =list(map(int,input().split()))
cnt = 0
l = [[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split()) 
    l[a-1].append(b)
    l[b-1].append(a)

for i in range(n):
    if h[i] > max(l[i]):
        cnt +=1
    elif l[i] == []:
        cnt+=1

print(cnt)
Problem p02693 (python)

Fixed submission:
K =int(input())
A,B =map(int,input().split())
count =0
for i in range(A,B+1):
    if i%K==0:
        print('OK')
        count =1
        break
if count ==0:   
    print('NG')

Buggy submission (verdict: Runtime Error):
K =int(input())
A,B =map(int,input().split())
count ==0
for i in range(A,B+1):
    if i%K==0:
        print('OK')
        count =1
        break
if count ==0:   
    print('NG')

Buggy submission (verdict: Runtime Error):
K =int(input())
A,B =map(int,input().split())
count ==0
for i in range(A,B+1):
    if i%K==0:
        print('OK')
        count =1
        break
 if count ==0:   
        print('NG')
Problem p03077 (python)

Fixed submission:
n=int(input())
x = [int(input()) for _ in range(5)]
p = min(x)
q = n//p
if n % p == 0:
        print(q+4)
else:
        print(q+5)

Buggy submission (verdict: Runtime Error):
n=int(input())
x = [int(input()) for _ in range(n)]
p = min(x)
q = n//p
print(q+5)
Problem p03208 (python)

Fixed submission:
n,k =map(int,input().split())
h = [int(input()) for _ in range(n)]
l = []
h.sort()
for i in range(n+1-k):
        x = h[i+k-1] - h[i]
        l.append(x)
print(min(l))

Buggy submission (verdict: Runtime Error):
n,k =map(int,input().split())
h = [int(input()) for _ in range(n)]
l = []
h.sort()
for i in range(n-1-k):
        x = h[i+k-1] - h[i]
        l.append(x)
print(min(l))
Problem p02781 (python)

Fixed submission:

import numpy as np

N=input()
K=input()
dp=np.zeros((len(str(N))+10,len(str(N))+10,2))
dp=dp.tolist()


x0=int(N[0])
dp[0][0][0]=1


for i in range(0,len(N),1):
    for j in range(0,4,1):
        for k in range(0,2,1):
            nd=int(N[i])
            for d in range(0,10,1):
                ni=i+1
                nj=j
                nk=k
                if not(d==0):
                    nj=nj+1
                if ((k==0)and(d<nd)):
                    nk=1
                if (not(nj>int(K)))and(not((k==0)and(d>nd))):
                    dp[ni][nj][nk]=dp[ni][nj][nk]+dp[i][j][k]


print(int(dp[len(N)][int(K)][0]+dp[len(N)][int(K)][1]))

Buggy submission (verdict: Runtime Error):
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)

r1,c1,r2,c2=map(int,input().split())
n1=r2+c2+2
n2=r2+c1+1
n3=r1+c2+1
n4=r1+c1
l=[r2+1,r2+1,r1,r1]
p=10**9+7
buf=1
cnt=0
l=[0]*(10**6+10)
l2=[0]*20
inv=[0]*(10**6+10)
for i in range(2,n1+3,1):#n1+1
    l[i]=(l[i-1]*i)%p
print((((l[n1]*modinv(l[r2+1],p)*modinv(l[n1-r2-1],p))%p)-(l[n2]*modinv(l[r2+1],p)*modinv(l[n2-r2-1],p))-(l[n3]*modinv(l[r1],p)*modinv(l[n3-r1],p))+(l[n4]*modinv(l[r1],p)*modinv(l[n4-r1],p)))%p)
Problem p02829 (python)

Fixed submission:


A=int(input())
B=int(input())

print(str(6-A-B))

Buggy submission (verdict: Runtime Error):


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

print(str(6-A-B))
Problem p02912 (python)

Fixed submission:
import heapq
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
logof2=[0]*N
mi=0
buf=0
#print(A)
for i in range(N):
    A[i]=-A[i]
heapq.heapify(A)
for i in range(M):
    buf=heapq.heappop(A)
    buf=(-buf)//2
    buf=-buf
    heapq.heappush(A,buf)
    #print(A)
for i in range(N):
    mi=mi-math.floor(A[i])

print(mi)

Buggy submission (verdict: Runtime Error):
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
logof2=[0]*N
mi=0
#print(A)
for i in range(N):
    logof2[i]=math.log2(A[i])
#print(logof2)
for i in range(M):
    if logof2[0]<0:
        break
    else:
        logof2[0]=logof2[0]-1
        logof2.sort(reverse=True)
    #print(logof2)
for i in range(N):
    mi=mi+math.floor(pow(2,logof2[i]))

print(mi)
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]
dp=[0]*N
id=0
p=10**9+7
id=0
for i in range(N):
    if (i==0):
        dp[i]=1
    elif (i==1):
        dp[i]=dp[i-1]+1
    else:
        dp[i]=dp[i-1]+dp[i-2]
    if len(a)>0:
        if a[id]==i+1:
            dp[i]=0
            if id<len(a)-1:
                id=id+1
print(dp[N-1]%p)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]
dp=[0]*N
id=0
p=10**9+7
point=a[id]
for i in range(N):
    if i==0:
        if a[id]!=(i+1):
            dp[i]=1
        else:
            id=id+1
    elif i==1:
        if a[id]!=(i+1):
            dp[i]=dp[i-1]+1
        else:
            id=id+1
    else:
        dp[i]=dp[i-1]+dp[i-2]
        if a[id]==i+1:
            dp[i]=0
            if id<len(a)-1:
                id=id+1
print(dp[N-1]%p)
Problem p03107 (python)

Fixed submission:
S=input()
i=0
s=S
count0=0
count1=0
for i in range(len(S)):
    if S[i]=="0":
        count0=count0+1
    else:
        count1 = count1 + 1
print(min(count0,count1)*2)

Buggy submission (verdict: Runtime Error):
S=input()
i=0
s=S
count=0
while True:
    if (i==(len(s)-1))or(len(s)==0):
        break
    if not(s[i]==s[i+1]):
        #print(s[:i],s[i+2:])
        s="".join((s[:i],s[i+2:]))
        #print(s)
        input()
        i=0
        count=count+1
    else:
        i=i+1
print(count*2)
Problem p03332 (python)

Fixed submission:
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
N,A,B,K=map(int,input().split())
p=998244353
fracmod=[1]*(N+1)
fracmodinv=[1]*(N+1)
ans=0
i=0
j=0
for i in range(1,N+1):
    fracmod[i]=(fracmod[i-1]*i)%p
#print(fracmod[:6])
for i in range(N+1):
    fracmodinv[i]=modinv(fracmod[i],p)
for i in range(N+1):
    forb=K-i*A      #bに割く得点
    if (forb%B==0)and(0<=(forb//B)<=N):
        j=forb//B
        #print(i,j)
        ans=(ans+((((fracmod[N]*fracmodinv[N-i]*fracmodinv[i])%p)*(fracmod[N]*fracmodinv[N-j]*fracmodinv[j]))%p))%p
print(ans)

Buggy submission (verdict: Runtime Error):
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
N,A,B,K=map(int,input().split())
p=998244353
fracmod=[1]*(N+1)
fracmodinv=[1]*(N+1)
ans=0
i=0
j=0
for i in range(1,N+1):
    fracmod[i]=(fracmod[i-1]*i)%p
#print(fracmod[:6])
for i in range(N+1):
    fracmodinv[i]=modinv(fracmod[i],p)
for i in range(N+1):
    forb=K-i*A      #bに割く得点
    if (forb%B==0)and(forb//B>=0):
        j=forb//B
        #print(i,j)
        ans=(ans+((((fracmod[N]*fracmodinv[N-i]*fracmodinv[i])%p)*(fracmod[N]*fracmodinv[N-j]*fracmodinv[j]))%p))%p
print(ans)

Buggy submission (verdict: Runtime Error):
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
N,A,B,K=map(int,input().split())
p=998244353
fracmod=[1]*(N+1)
fracmodinv=[1]*(N+1)
ans=0
i=0
j=0
for i in range(1,N+1):
    fracmod[i]=(fracmod[i-1]*i)%p
#print(fracmod[:6])
for i in range(N+1):
    fracmodinv[i]=modinv(fracmod[i],p)
for i in range(N+1):
    forb=K-i*A      #bに割く得点
    if forb%B==0:
        j=forb//B
        #print(i,j)
        ans=(ans+((((fracmod[N]*fracmodinv[N-i]*fracmodinv[i])%p)*(fracmod[N]*fracmodinv[N-j]*fracmodinv[j]))%p))%p
print(ans)
Problem p02571 (python)

Fixed submission:
S=input()
T=input()
ans=len(T)
for i in range(len(S)-len(T)+1):
  _ans=0
  for j in range(len(T)):
    if S[i+j]!=T[j]:
      _ans+=1
  ans=min(ans,_ans)
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
ans=len(T)
for i in range(len(S)-len(T)+1):
  _ans=0
  for j in range(len(T)):
    if S[i+j]!=T[i+j]:
      _ans+=1
  ans=min(ans,_ans)
print(ans)
Problem p02682 (python)

Fixed submission:
A,B,C,K=map(int,input().split())
if A>=K:
  print(K)
elif A+B>=K:
  print(A)
else:
  print(A+A+B-K)

Buggy submission (verdict: Runtime Error):
A,B,C,K=map(input().split())
if A>=K:
  print(K)
elif A+B>=K:
  print(A)
else:
  print(A+A+B-K)
Problem p02685 (python)

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

def cmb(n, r, mod):
  if ( r<0 or r>n ):
    return 0
  r = min(r, n-r)
  return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
  g1.append( ( g1[-1] * i ) % mod )
  inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
  g2.append( (g2[-1] * inverse[-1]) % mod )

ans=0
for k in range(K+1):
  ans+=(M*pow(M-1,N-1-k,mod)*cmb(N-1,k,mod))%mod
  ans=ans%mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
MOD=998244353
X=M*pow(M-1,N-1,MOD)
#X=M*pow(M-1,N-1)
ans=X%MOD
i=1
'''
s=[]
a=1
for j in range(1,K+1):
  a*=N-j
  a=a//j
  s.append(a%MOD)
'''
for k in range(1,K+1):
  i*=(N-k)
  i=i//k
  #ans+=(i*X[-1-k])%MOD
  #i%=MOD
  ans+=((i%MOD)*X*pow(M-1,-k,MOD))%MOD
  #X=X//M-1
  #ans+=(i*X)%MOD
  ans%=MOD
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
MOD=998244353
X=M*pow(M-1,N-1,MOD)
#X=M*pow(M-1,N-1)
ans=X%MOD
i=1
s=[]
a=1
for j in range(1,K+1):
  a*=N-j
  a=a//j
  s.append(a%MOD)
for k in range(1,K+1):
  #i*=(N-k)
  #i=i/k
  #ans+=(i*X[-1-k])%MOD
  #i%=MOD
  ans+=(s[k-1]*X*pow(M-1,-k,MOD))%MOD
  #X=X//M-1
  #ans+=(i*X)%MOD
  ans%=MOD
print(ans%MOD)
Problem p02771 (python)

Fixed submission:
A=list(map(int,input().split()))
A=sorted(A)
if A[0]==A[1] and A[1]!=A[2]:
  print('Yes')
elif A[2]==A[1] and A[1]!=A[0]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split()))
A=sorted(A)
if A[0]==A[1] and A[1]!=A[2]:
  print('Yes')
elif if A[2]==A[1] and A[1]!=A[0]:
  print('Yes')
else:
  print('No')
Problem p02862 (python)

Fixed submission:
X,Y=map(int, input().split())
if (X+Y)%3!=0:
  print(0)
  exit()
n=(X+Y)//3
flg=True
for i in range(n+1):
  if 2*i +(n-i) == X:
    right=i
    up=n-i
    flg=False
    break
  elif 2*(n-i)+i == X:
    up=i
    right=n-i
    flg=False
    break
if flg:
  print(0)
  exit()
  

def cmb(n, r, mod):
    if r<0 or r>n :
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a = cmb(n,right,mod)
print(a)

Buggy submission (verdict: Runtime Error):
import math
X,Y=map(int, input().split())
if (X+Y)%3!=0:
  print(0)
  exit()
n=(X+Y)//3
for i in range(n+1):
  if 2*i +(n-i) == X:
    right=i
    up=n-i
    if 2*(n-i)+i !=Y:
      print(0)
      exit()
    break
  elif 2*(n-i)+i == X:
    up=i
    right=n-i
    if 2*i +(n-i) == Y:
      print(0)
      exit()
    break

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a = cmb(n,right,mod)
print(a)

Buggy submission (verdict: Runtime Error):
import math
X,Y=map(int, input().split())
if (X+Y)%3!=0:
  print(0)
  exit()
n=(X+Y)//3
for i in range(n+1):
  if 2*i +(n-i) == X:
    right=i
    up=n-i
    break
  elif 2*(n-i)+i == X:
    up=i
    right=n-i
    break

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a = cmb(n,right,mod)
print(a)
Problem p02891 (python)

Fixed submission:
S=input()
K=int(input())
flg=False
for s in S:
    if S[0] != s:
        flg=True
        break
if not flg:
    print(len(S)*K//2)
    exit()
ans = 0
i=0
while i<len(S)-1:
    renzoku=1
    x=i
    while S[x] == S[i+1]:
        renzoku+=1
        if i+2 < len(S):
            i=i+1
        else:
            break

    if renzoku >1:
        ans+=renzoku//2
    i+=1

if S[0] == S[-1]:
    s=S[0]
    top=0
    bottom=0
    i=0
    while S[i] == s:
        top+=1
        i+=1
    i=-1
    while S[i] == s:
        bottom+=1
        i-=1
    if (top%2) + (bottom%2) == 2:
        print((ans+1)*K-1)
        exit()
    
print(ans*K)

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

end=0
if K!=1:
    S_old = S
    i=0
    while S_old[-1] == S_old[i]:
        S= S + S[i]
        i+=1
ans = 0
i=0
while i<len(S)-1:
    renzoku=1
    x=i
    while S[x] == S[i+1]:
        renzoku+=1
        if i+2 < len(S):
            i=i+1
        else:
            break
    if renzoku >1:
        ans+=renzoku//2
    i+=1
if K== 1:
    print(ans)
else:
    S=S_old
    ans = ans*(K-1)
    i=0
    while S[i] == S[0]:
        i+=1
    S=S[i:]
    i=0
    while i<len(S)-1:
        renzoku=1
        x=i
        while S[x] == S[i+1]:
            renzoku+=1
            if i+2 < len(S):
                i=i+1
            else:
                break
        if renzoku >1:
            ans+=renzoku//2
        i+=1
    print(ans)

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

end=0
if K!=1:
    S_old = S
    i=-1
    while S_old[0] == S_old[i]:
        S= S + S[0]
        i-=1
ans = 0
i=0
while i<len(S)-1:
    renzoku=1
    x=i
    while S[x] == S[i+1]:
        renzoku+=1
        if i+2 < len(S):
            i=i+1
        else:
            break
    if renzoku >1:
        ans+=renzoku//2
    i+=1
if K== 1:
    pass
else:
    S=S_old
    ans = ans*(K-1)
    i=0
    while S[i] == S[0]:
        i+=1
    S=S[i:]
    i=0
    while i<len(S)-1:
        renzoku=1
        x=i
        while S[x] == S[i+1]:
            renzoku+=1
            if i+2 < len(S):
                i=i+1
            else:
                break
        if renzoku >1:
            ans+=renzoku//2
        i+=1
print(ans)

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

ans = 0
i=0
while i<len(S)-1:
    renzoku=1
    x=i
    while S[x] == S[i+1]:
        i=i+1
        renzoku+=1
    if renzoku >1:
        ans+=renzoku//2
    i+=1
    
print(ans*K)
Problem p02912 (python)

Fixed submission:
N, M= map(int, input().split())
A = list(map(int,input().split()))
A=[-1*a for a in A]
import heapq
import math
hq=heapq.heapify(A)
for m in range(M):
    X=heapq.heappop(A)
    heapq.heappush(A,math.ceil(X/2))
print(sum(A)*-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int,input().split()))
def waribiki():
    global M
    A[-1]=A[-1]//2
    M-=1
    if A[-2]<A[-1]:
        waribiki()
while M>0:
    A.sort()
    waribiki()
print(sum(A))
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a<3200:
  print('red')
else:
  print(s)

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()
if a<3200:
  print('red',flush=true)
else:
  print(s,flush=true)
Problem p03036 (python)

Fixed submission:
r,D,x=map(int,input().split())
for i in range(10):
  x=r*x-D
  print(x)

Buggy submission (verdict: Runtime Error):
r,D,x=map(int,input().split())
for i in range(10):
   x=r*x-D
    print(x)
Problem p03041 (python)

Fixed submission:
d={'A':'a','B':'b','C':'c'}
N,K=map(int,input().split())
S=input()
print(S[:K-1]+d[S[K-1]]+S[K:])

Buggy submission (verdict: Runtime Error):
d={'A':'a','B':'b','C':'c'}
N,K=map(input().split())
S=input()
print(S[:K-1]+d[S[K-1]]+S[K:])
Problem p03075 (python)

Fixed submission:
a=int(input())
for i in range(3):
  z=input()
e=int(input())
k=int(input())
if e-a<=k:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
a=int(input())
for i in range(3):
  input()
e=int(input())
k=int(input())
if e-a<=K:
  print('Yay!')
else:
  print(':(')
Problem p03426 (python)

Fixed submission:
from collections import defaultdict
import itertools
d = defaultdict(int)
x='MARCH'
for i in range(5):
  d[x[i]]=i+1
x=[0]*5
def sub(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
N=H*W
P=[0]*(N)
for h in range(H):
  for w in range(W):
    P[A[h][w]-1]=(h,w)
X=[]
for d in range(D):
  _=[0]+[sub(P[i%N],P[i-D]) for i in range(d+D,N+D,D)]
  cumsum = list(itertools.accumulate(_))
  X.append(cumsum)

Q=int(input())
for q in range(Q):
  l,r=map(int,input().split())
  l,r=l-1,r-1
  g=l%D
  if l>r:
    r+=N
    ans=X[g][-1]-X[g][l//D]
    ans+=X[g][r//D]-X[g][0]
  else:
    ans=X[g][r//D]-X[g][l//D]
  
  print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import itertools
d = defaultdict(int)
x='MARCH'
for i in range(5):
  d[x[i]]=i+1
x=[0]*5
def sub(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
N=H*W
P=[0]*(N)
for h in range(H):
  for w in range(W):
    P[A[h][w]-1]=(h,w)

X=[]
for d in range(D):
  p=P[(d+D)%(D+1)::D]
  n=len(p)
  _=[sub(p[(i+1)%n],p[i]) for i in range(n)]
  X.append(_)
Q=int(input())
for q in range(Q):
  l,r=map(int,input().split())
  if l>r:
    r+=N
  g=l%D
  ans=0
  for i in range(l,r,D):
    ans+=X[g][(i%N)//D]
  print(ans)
Problem p02547 (python)

Fixed submission:
(n,), *dd = [list(map(int, s.split())) for s in open(0)]

cnt = 0
ans = False
for i in range(n):
    a,b = dd[i]
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ans = True
if ans:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
cnt = 0
ans = False
for i in range(n):
    a,b = dd[i]
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ans = True
if ans:
    print('Yes')
else:
    print('No')
Problem p02580 (python)

Fixed submission:
# from sys import stdin
# input = stdin.readline
(H,W,M) = map(int, input().split())
hsum = [0]*H
wsum = [0]*W
bombs = set()
for _ in range(M):
    h,w = map(int, input().split())
    hsum[h-1] += 1
    wsum[w-1] += 1
    bombs.add((h-1,w-1))

hmax = max(hsum)
wmax = max(wsum)

cross_w_zero = False
hargmax = sum(1 for x in hsum if x == hmax)
wargmax = sum(1 for x in wsum if x == wmax)
cnt = sum(1 for h,w in bombs if hsum[h] == hmax and wsum[w] == wmax)
if hargmax * wargmax == cnt:
    print(hmax + wmax - 1)
else:
    print(hmax + wmax)

Buggy submission (verdict: Runtime Error):
import numpy as np

(H,W,M) = map(int, input().split())
# hsum = [0]*H
# wsum = [0]*W
grid = np.zeros((H,W), dtype='int')
for _ in range(M):
    h,w = map(int, input().split())
    grid[h-1][w-1] = 1

row = grid.sum(axis=0)
col = grid.sum(axis=1)

cm = col.max()
rm = row.max()
if grid[col==cm][:, row==rm].min() == 0:
    print(cm+rm)
else:
    print(cm+rm-1)

Buggy submission (verdict: Runtime Error):
import numpy as np

(H,W,M) = map(int, input().split())
# hsum = [0]*H
# wsum = [0]*W
grid = np.zeros((H,W), dtype='int')
for _ in range(M):
    h,w = map(int, input().split())
    grid[h-1][w-1] = 1

row = grid.sum(axis=0)
col = grid.sum(axis=1)

cm = col.max()
rm = row.max()
if grid[col == cm, row == rm].min() == 0:
    print(cm+rm)
else:
    print(cm+rm-1)
Problem p02623 (python)

Fixed submission:
from collections import deque

(n, m, k), aa, bb = [list(map(int, l.split())) for l in open(0)]

from itertools import accumulate

aaa = list(zip(list(accumulate([0]+aa)), range(len(aa)+1)))
bbb = list(zip(list(accumulate([0]+bb)), range(len(bb)+1)))

i = 0
j = len(bb)

ans = 0

while i<len(aaa) and j >= 0:
    aco, abo = aaa[i]
    bco, bbo = bbb[j]
    if aco+bco > k:
        j -= 1
        continue
    else:
        ans = max(abo+bbo, ans)
        i += 1

print(ans)

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

(n, m, k), aa, bb = [deque(map(int, l.split())) for l in open(0)]

i = 0

while k - min(aa[0], bb[0])>0:
    if aa[0]>bb[0]:
        k -= bb.popleft()
        i+=1
    else:
        k -= aa.popleft()
        i+=1

print(i)
Problem p02685 (python)

Fixed submission:
# from math import factorial
from sys import exit
n,m,k = map(int, input().split())
if m == 1:
    if k == n-1:
        print(1)
    else:
        print(0)
    exit()
MOD = 998244353

ans = tmp = (m * (m-1) ** (n-1)) % MOD

for i in range(k):
    tmp *= (n-1-i)
    tmp %= MOD
    tmp *= pow((m-1) * (i+1), -1, MOD)
    ans += tmp
    ans %= MOD

print(ans)

Buggy submission (verdict: Runtime Error):
# from math import factorial
from sys import exit
n,m,k = map(int, input().split())
if m == 1:
    if k == n-1:
        print(1)
    else:
        print(0)
    exit()
MOD = 998244353

ans = tmp = (m * (m-1) ** (n-1)) % MOD

for i in range(k):
    tmp *= (n-1-i)
    tmp %= MOD
    tmp *= pow((m-1) * (i+1), -1, MOD)
    ans += tmp
    ans %= MOD

print(ans)