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

Fixed submission:
n,s,k=int(input()),input(),int(input()) #入力を順番に一気に定義する
A=s[k-1]
for i in range(n):
    if s[i]!=A:
        s=s.replace(s[i],'*')
print(s)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
m=map(str,input())
A=m[k-1]
for i in range(n):
    if m[i]!=A:
        m.replace(m[i],'*')
print(m)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
m=map(str,input())
A=m[k-1]
for i in range(n):
    if m[i]==A:
        continue
        if m[i]!=A:
            m.replace(m[i],'*')
print(m)

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
m=map(str,input())
A=m[l-1]
for i in range(5):
    if m[i]==A:
        continue
        if m[i]!=A:
            m.replace(m[i],'*')
print(m)

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
m=map(str,input())
A=m[l-1]
for i in range(5):
    if m[i]==A:
        continue
        if m[i]!=A:
            m[i]='*'
print(m)
Problem p03074 (python)

Fixed submission:
n, k = map(int,input().split())
s = input()

ns = []
now_num = s[0]
cnt = 0
for i in range(n):
    if now_num == s[i]:
        cnt += 1
    else:
        ns.append((now_num, cnt))
        now_num = s[i]
        cnt = 1
ns.append((now_num, cnt))
len_ns = len(ns)
pre = [0] * (len_ns + 1)
for i in range(len_ns):
    pre[i + 1] = pre[i] + ns[i][1]

ans = 1
for i in range(len_ns - 2*k + 1):
    temp = pre[i + 2*k] - pre[i]
    if i > 0 and ns[i - 1][0] == '1':temp += ns[i - 1][1]
    if i + 2*k < len_ns and ns[i + 2*k][0] == '1':temp += ns[i + 2*k][1]
    if temp > ans:ans = temp
print(ans if len_ns - 2*k + 1 > 0 else len(s))

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

ns = []
now_num = s[0]
cnt = 0
for i in range(n):
    if now_num == s[i]:
        cnt += 1
    else:
        ns.append((now_num, cnt))
        now_num = s[i]
        cnt = 1
ns.append((now_num, cnt))
#print(ns)
len_ns = len(ns)
pre = [0] * (len_ns + 1)
for i in range(len_ns):
    pre[i + 1] = pre[i] + ns[i][1]
#print(pre)

ans = 1
for i in range(len_ns - 2*k + 1):
    temp = pre[i + 2*k] - pre[i]
    if ns[i - 1][0] == '1':temp += ns[i - 1][1]
    elif i + 2*k != len_ns and ns[i + 2*k][0] == '0':temp += ns[i + 2*k + 1][1]
    if temp > ans:ans = temp
print(ans if len_ns - 2*k + 1 > 0 else len(s))
Problem p03076 (python)

Fixed submission:
l=[int(input()) for i in range(5)]
ans=[]
ans1=[]
for i in l:
    if i%10==0:
        ans+=[i]
    else:
        ans1+=[i]
ans2=[]
amari=[]
for i in ans1:
    amari+=[i%10]
    i=((i//10)+1)*10
    ans2+=[i]

amari.sort()
print(sum(ans+ans2)-(10-amari[0]) if len(amari)!=0 else sum(ans+ans2) )

Buggy submission (verdict: Runtime Error):
l=[int(input()) for i in range(5)]
ans=[]
ans1=[]
for i in l:
    if i%10==0:
        ans+=[i]
    else:
        ans1+=[i]
ans2=[]
amari=[]
for i in ans1:
    amari+=[i%10]
    i=((i//10)+1)*10
    ans2+=[i]

amari.sort()
print(sum(ans+ans2)-(10-amari[0]))
Problem p03078 (python)

Fixed submission:
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()))

c = sorted(c, reverse=True)
ab = []
for i in range(x):
    for j in range(y):
        temp = a[i] + b[j]
        ab.append(temp)

ab = sorted(ab, reverse=True)
ans = []
for i in range(z):
    for j in range(min(x * y, k)):
        temp = c[i] + ab[j]
        ans += [temp]
ans = sorted(ans, reverse=True)

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

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
from heapq import *
from collections import defaultdict
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 = sorted(a, reverse = True)
b = sorted(b, reverse = True)
c = sorted(c, reverse = True)

ans = [[-(a[0] + b[0] + c[0]), 1, 1, 1]]
heapify(ans)
log = defaultdict(lambda :0)

d = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
for i in range(k):
    temp, s, t, u = heappop(ans)
    temp = temp * (-1)
    print(temp)
    for ds, dt, du in d:
        ns = s + ds
        nt = t + dt
        nu = u + du
        if not(0 <= ns < x and 0 <= nt < y and 0 <= nu < z):continue
        if log[(ns, nt, nu)]:continue
        heappush(ans, [-(a[ns - 1] + b[nt - 1] + c[nu - 1]), ns, nt, nu])
        log[(ns, nt, nu)] = 1

Buggy submission (verdict: Runtime Error):
from heapq import *
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 = sorted(a, reverse = True)
b = sorted(b, reverse = True)
c = sorted(c, reverse = True)

ans = heapify([-(a[0] + b[0] + c[0]), 1, 1, 1])
log = [[[0] * len(c) for i in range(len(b))] for j in range(len(a))]
log[0][0][0] = 1

d = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
for i in range(k):
    temp, s, t, u = heappop(ans)
    temp = temp * (-1)
    print(temp)
    for ds, dt, du in d:
        ns = s + ds
        nt = t + dt
        nu = u + du
        if log[ns - 1][nt - 1][nu - 1]:continue
        heappush(ans, [-(a[ns - 1] + b[nt - 1] + c[nu - 1]), ns, nt, nu])
        log[ns - 1][nt - 1][nu - 1] = 1

Buggy submission (verdict: Runtime Error):
from heapq import *
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 = sorted(a, reverse = True)
b = sorted(b, reverse = True)
c = sorted(c, reverse = True)

ans = heapify([-(a[0] + b[0] + c[0]), 1, 1, 1])
log = [[[0] * len(c) for i in range(len(b))] for j in range(len(a))]
log[0][0][0] = 1

d = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
for i in range(k):
    temp, s, t, u = heappop(ans)
    temp = temp * (-1)
    print(temp)
    for ds, dt, du in d:
        ns = s + ds
        nt = t + dt
        nu = u + du
        if log[ns - 1][nt - 1][nu - 1]:continue
        heappush(ans, [-(a[ns - 1] + b[nt - 1] + c[nu - 1]), ns, nt, nu])
        log[ns - 1][nt - 1][nu - 1] = 1
Problem p03086 (python)

Fixed submission:
s=input()
l=['A','C','G','T']
len_s=[]
count=0
for i in range(len(s)):
    if s[i] in l and i!=len(s)-1:
        count+=1
    elif s[i] not in l:
        len_s+=[count]
        count=0
    else:
        count+=1
        len_s+=[count]
print(max(len_s))

Buggy submission (verdict: Runtime Error):
s=input()
l=['A','C','G','T']
index_s=[]
count=0
for i in range(len(s)):
    if s[i] not in l:
        index_s+=[i]
    
    else:
        count+=1
        if count==len(s):
            print(len(s))
            exsit()
    
ans=[index_s[0]]
for i in range(len(index_s)-1):
    ans+=[index_s[i+1]-index_s[i]-1]

ans.sort()    
print(ans[-1])

Buggy submission (verdict: Runtime Error):
s=input()
l=['A','C','G','T']
index_s=[]
for i in range(len(s)):
    if s[i] not in l:
        index_s+=[i]
        
ans=[index_s[0]]
for i in range(len(index_s)-1):
    ans+=[index_s[i+1]-index_s[i]-1]

ans.sort()    
print(ans[-1])
Problem p03087 (python)

Fixed submission:
#122-C
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for i in range(q)]
m=[0]*(n+1)
for i in range(len(s)-1):
    
    if s[i]=='A' and s[i+1]=='C':
        m[i+1]=m[i]+1
    else:
        m[i+1]=m[i]

for i in l:
    print(m[i[1]-1]-m[i[0]-1])

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
S=input()
L=[list(map(int,input().split())) for i in range(q)]

s=[0]*(n+1)
for i in range(1,n+1):
    if S[i-1]=='A' and S[i]=='C':
        s[i]=s[i-1]+1
    else:
        s[i]=s[i-1]

#print(s)
for l,r in L:
    ans=s[r-1]-s[l-1]
    print(ans)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
S=input()
L=[list(map(int,input().split())) for i in range(q)]

s=[0]*(n+1)
for i in range(1,n+1):
    if S[i-1]=='A' and S[i]=='C':
        s[i]=s[i-1]+1
    else:
        s[i]=s[i-1]

#print(s)
for l,r in L:
    ans=s[r]-s[l-1]
    print(ans)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
S=input()
l=[list(map(int,input().split())) for i in range(q)]

s=[0]*(n+1)
for i in range(1,n+1):
    if S[i-1]=='A' and S[i]=='C':
        s[i]=s[i-1]+1
    else:
        s[i]=s[i-1]

#print(s)
for k,v in l:
    ans=s[v-1]-s[k-1]
    print(ans)

Buggy submission (verdict: Runtime Error):
#122-C
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for i in range(q)]
m=[0]*(n+1)
for i in range(n):
    if s[i]=='A' and s[i+1]=='C':
        m[i+1]=m[i]+1
    else:
        m[i+1]=m[i]

for j in range(q):
    ans=m[l[j][1]-1]-m[l[j][0]-1]
    print(ans)

Buggy submission (verdict: Runtime Error):
#122-C
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for i in range(q)]
m=[0]*(n+1)
for i in range(len(s)):
    
    if s[i]=='A' and s[i+1]=='C':
        m[i+1]=m[i]+1
    else:
        m[i+1]=m[i]

for i in l:
    print(m[i[1]-1]-m[i[0]-1])

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for i in range(q)]
m=[0]*(n+1)
for i in range(len(s)):
    
    if s[i]=='A' and s[i+1]=='C':
        m[i+1]=m[i]+1
    else:
        m[i+1]=m[i]

print(m)
for i in l:
    print(m[i[1]-1]-m[i[0]-1])
Problem p03101 (python)

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
lw=H*W-(h*W+H*w-h*w)
print(lw)

Buggy submission (verdict: Runtime Error):
s=[int(input()) for i in range(4)]

ans=s[1]*s[2]-s[2]*s[3]-s[1]*s[4]+s[3]*s[4]
print(ans)
Problem p03125 (python)

Fixed submission:
n=list(map(int,input().split()))
if n[1]%n[0]==0:
    print(n[0]+n[1])
else:
    print(n[1]-n[0])

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

Buggy submission (verdict: Runtime Error):
A,B=int(input())
if B%A==0:
    print(A+B)
else:
    print(B-A)

Buggy submission (verdict: Runtime Error):
#-*-coding:utf-8-*-

A,B=input()
if B%A==0:
    print(A+B)
else:
	print(B-A)

Buggy submission (verdict: Runtime Error):
a,b=input()
if b%a==0:
    print(a+b)
else:
	print(b-a)

Buggy submission (verdict: Runtime Error):
if B%A==0:
    print(A+B)
else:
	print(B-A)

Buggy submission (verdict: Runtime Error):
a=int(input('A'))
b=int(input('B'))
if b%a==0:
    print(a+b)
else:
  print(b-a)
Problem p03160 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))

dp=[float('inf')]*n
dp[0]=0#初期条件を設定

for i in range(1,n):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    #i=1の時i-2<0となるので先にここを計算する
    if i>=2:
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
        
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(8000)
 
n=int(input())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
 
def rec(i):
    if dp[i]<float('inf'):
        return dp[i]
    
    if i==0:
        return 0
    
    res=float('inf')#最小に更新する
    
    res=min(res,rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:
        #i-2が負になる場合を避ける
        res=min(res,rec(i-2)+abs(h[i]-h[i-2]))
    
    return res
    
    
print(rec(n-1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000)

n=int(input())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
 
def rec(i):
    if dp[i]<float('inf'):
        return dp[i]
    
    if i==0:
        return 0
    
    res=float('inf')#最小に更新する
    
    res=min(res,rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:
        #i-2が負になる場合を避ける
        res=min(res,rec(i-2)+abs(h[i]-h[i-2]))
    
    return res
    
    
print(rec(n-1))

Buggy submission (verdict: Runtime Error):
import sys
from typing import List

# 再帰の最大回数を増やす
sys.setrecursionlimit(10**4)
n=int(input())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
 
def rec(i):
    if dp[i]<float('inf'):
        return dp[i]
    
    if i==0:
        return 0
    
    res=float('inf')#最小に更新する
    
    res=min(res,rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:
        #i-2が負になる場合を避ける
        res=min(res,rec(i-2)+abs(h[i]-h[i-2]))
    
    return res
    
    
print(rec(n-1))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0

def rec(i):
    if dp[i]<float('inf'):
        return dp[i]
    
    if i==0:
        return 0
    
    res=float('inf')#最小に更新する
    
    res=min(res,rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:
        #i-2が負になる場合を避ける
        res=min(res,rec(i-2)+abs(h[i]-h[i-2]))
    
    return res
    
    
print(rec(n-1))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0

def rec(i):
    if dp[i]<float('inf'):
        return dp[i]
    
    if i==0:
        return 0
    
    res=float('inf')#最小に更新する
    
    res=ch_min(res,rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:
        #i-2が負になる場合を避ける
        res=ch_min(res,rec(i-2)+abs(h[i]-h[i-2]))
    
    return res
    
    
print(rec(n-1))
Problem p03161 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
def ch_min(a,b):
    if a>b:
        return b
    
    return a
def solve():
    dp=[float('inf')]*n
    dp[0]=0

    for i in range(1,n):
    
        for j in range(1,1+k):
            if i-j>=0:
                dp[i]=ch_min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
                
                if dp[i]==0:
                    break
                
    print(dp[-1])
    

solve()

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
def ch_min(a,b):
    if a>b:
        return b

def solve():
    dp=[float('inf')]*n
    dp[0]=0

    for i in range(1,n):
    
        for j in range(1,1+k):
            if i-j>=0:
                dp[i]=ch_min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
                
                
    print(dp[-1])
    

solve()

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
def ch_min(a,b):
    if a>b:
        return b

def solve():
    dp=[float('inf')]*n
    dp[0]=0

    for i in range(1,n):
    
        for j in range(1,1+k):
            if i-j>=0:
                dp[i]=ch_min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
                
                if dp[i]==0:#最小値の時点で打ち切り
                    break
            
    print(dp[-1])
    

solve()
Problem p03164 (python)

Fixed submission:
N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
    x,y=map(int,input().split())
    w+=[x]
    v+=[y]

V_sum=sum(v)+1
dp=[[float('inf')]*(V_sum) for i in range(N+1)]
dp[0][0]=0
for i in range(1,N+1):
    for sum_v in range(V_sum):
        #同価値の場合より軽いほうを入れる
        if sum_v-v[i-1]>=0:
            dp[i][sum_v]=min(dp[i][sum_v],dp[i-1][sum_v-v[i-1]]+w[i-1])

        dp[i][sum_v]=min(dp[i-1][sum_v],dp[i][sum_v])

ans=0
for i in range(V_sum):
    if dp[-1][i]<=W and ans<i:
        ans=i
print(ans)

Buggy submission (verdict: Runtime Error):
n, W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(n)]

dp = [[-1] * (W + 1) for i in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(W + 1):
        if dp[i][j] == -1:continue
        w, v = wv[i]
        if w + j <= W:
            dp[i + 1][w + j] = max(dp[i + 1][w + j], dp[i][j] + v)

        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(max(dp[-1]))
Problem p03219 (python)

Fixed submission:
x,y=map(int,input().split())
print(int(x+y/2))

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
TA=10**5+1
num=0
for i in range(n):
    if TA>abs(a-(t-h[i]*0.006))>0:
        num=i+1
        TA=abs(a-(t-h[i]*0.006))
 
print(num)

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
TA=10**10
num=0
for i in range(n):
    if TA>abs(a-(t-h[i]*0.006))>0:
        num=i+1
        TA=abs(a-(t-h[i]*0.006))
 
print(num)

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
TA=10**5+1
for i in range(n):
    if TA>abs(a-t+h[i]*0.006):
        ans=i+1
        TA=abs(a-t+h[i]*0.006)

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
TA=10**5+1
num=0
for i in range(n):
    if TA>abs(a-(t-h[i]*0.006)):
        num=i+1
        TA=abs(a-(t-h[i]*0.006))

print(num)
Problem p03240 (python)

Fixed submission:
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh=sorted(xyh,reverse=True,key=lambda x:x[2])
#print(xyh)
for cx in range(0,101):
    for cy in range(0,101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1]-cy)
        for x,y,h in xyh:
            if h!= max(H - abs(x - cx) - abs(y - cy),0):
                break

        else:
            if H>=1:
                print(cx,cy,H)
                exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh=sorted(xyh,reverse=True,key=lambda x:x[2])
p#rint(xyh)
for cx in range(0,101):
    for cy in range(0,101):
        H = 0
        for x,y,h in xyh:
            if H == 0:
                H = h + abs(x - cx) + abs(y - cy)
            else:
                temp_H = h + abs(x - cx) + abs(y - cy)
                if temp_H != H:break
        else:
            if H>=1:
                print(cx,cy,H)
                exit()
Problem p03241 (python)

Fixed submission:
n,m=map(int,input().split())

num=m//n
ans=1
for i in range(1,int(m**0.5)+1):
    if m%i==0:
        Num=m//i
        if Num <= num and ans < Num:
            ans = Num

        if i<=num and ans<i:
            ans=i
print(ans)

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

if m%n==0:
    print(m//n)
    exit()
temp=m//n
left=m-temp*n
gcd=math.gcd(temp,temp+left)
print(gcd)
Problem p03273 (python)

Fixed submission:
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]
#h+w回確認する
import numpy as np
change_h=0
change_w=w
ans=[]
for i in range(h):
    if l[i].count('.')!=w:
        ans+=[l[i][:]]
        change_h+=1
l_count=[]
for i in range(w):
    count=0
    for j in range(h):
        if l[j][i]=='.':
            count+=1
    
    if count==h:
        l_count+=[i]
    
l_count=sorted(l_count,reverse=True)#削除したい列番号を後ろから削除する
for i in l_count:
    ans=np.delete(ans,i,axis=1)
    #np.delete(a,b,c):a:配列,b:削除したい行・列番号,c:列か行か

#最後の出力
for i in range(change_h):
    print(*ans[i],sep='')

Buggy submission (verdict: Runtime Error):
import numpy as np
h,w=map(int,input().split())
a=[np.array(input().split()) for i in range(h)]
a=np.array(a)

h_score=[0]*h
w_score=[0]*w
for i in range(h):
    for j in range(w):
        if a[i][j]=='.':
            h_score[j]+=1
            w_score[i]+=1

for i in range(h):
    if h_score[i]==h:
        a=np.delete(a,i,1)
for i in range(w):
    if w_score[i]==w:
        a=np.delete(a,i,0)

for i in a:#行列を入力と同じ形式で出力
    print(*i)
Problem p03282 (python)

Fixed submission:
s=input()
k=int(input())
count=0
ans=''
for i in range(k):
    if s[i]=='1':
        count+=1
    else:
        ans=s[i]
        break
print(1 if count==k else ans)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
count=0
for i in s:
    count+=int(i)**(5*(10**10))
    if count>=k:
        print(i)
        exit()
Problem p03288 (python)

Fixed submission:
r=int(input())
if r>=2800:
    print('AGC')
elif r<1200:
    print('ABC')
else:
    print('ARC')

Buggy submission (verdict: Runtime Error):
import sys
s=list(input())
if s[0]!='A':
    break
count=0
for i in range(2,len(s)-2):
    if s[i]=='C':
        count+=1

if count==1:
    s.remove('A')
    s.remove('C')    
    res=''.join(s)
    print('AC' if res.islower()==True else 'WA') #str.islower():全部小文字ならTrue

else:
    print('WA')
Problem p03289 (python)

Fixed submission:
s=list(input())
count=0
if s[0]!='A':
    count+=2
for i in range(2,len(s)-1):
    if s[i]=='C':
        count+=1

if count==1:
    s.remove('A')
    s.remove('C')    
    res=''.join(s)
    print('AC' if res.islower()==True else 'WA') #str.islower():全部小文字ならTrue

else:
    print('WA')

Buggy submission (verdict: Runtime Error):
import sys
s=list(input())
if s[0]!='A':
    break
count=0
for i in range(2,len(s)-2):
    if s[i]=='C':
        count+=1

if count==1:
    s.remove('A')
    s.remove('C')    
    res=''.join(s)
    print('AC' if res.islower()==True else 'WA') #str.islower():全部小文字ならTrue

else:
    print('WA')
Problem p03293 (python)

Fixed submission:
s,t=list(input()),list(input())
n=len(s)
num=0
ans_t=[]
if s[0]==t[-1] and s[1]==t[0]:
    ans_t=s[1:]+[s[0]]
else:
    for j in range(n-1):
        if s[0]==t[j] and s[1]==t[j+1]:
            num=j
            for i in range(num):
                ans_t.append(s[n-num+i])
            for i in range(n-num):
                ans_t.append(s[i])
print('Yes' if t==ans_t or s==t else 'No')

Buggy submission (verdict: Runtime Error):
s,t=list(input()),list(input())
n=len(s)
num=0
for j in range(n):
        if s[0]==t[j] and (s[1]==t[j+1] or s[-1]==t[j-1]):
            num=j
ans_t=[]
for i in range(num):
    ans_t.append(s[n-num+i])
for i in range(n-num):
    ans_t.append(s[i])
print('Yes' if t==ans_t or s==t else 'No')
Problem p03324 (python)

Fixed submission:
d,n=map(int,input().split())
print(100**d*n if n!=100 else 100**d*(n+1))

Buggy submission (verdict: Runtime Error):
d,n=map(int,input().split())
w=list(range(1,100))
if d==0:
    print(w[n-1])
elif d==1:
    print(n*100)
else:
    print(n*10000)
Problem p03361 (python)

Fixed submission:
h,w=map(int,input().split())
s=[input() for i in range(h)]

dx=[0,1,0,-1]
dy=[1,0,-1,0]
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            cnt=0
            for k in range(4):
                nx=i+dx[k]
                ny=j+dy[k]

                if 0<=nx<=h-1 and 0<=ny<=w-1:
                    if s[nx][ny]=='#':
                        cnt=1
            if cnt!=1:
                print('No')
                exit()

print('Yes')

Buggy submission (verdict: Runtime Error):
from collections import deque
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
def dfs(h,w):
    q=deque()
    q.append((h,w))
    s[h][w]='.'

    dx=[0,1,0,-1]
    dy=[1,0,-1,0]
    cnt=0
    while q:
        task=q[-1]
        for i in range(4):
            nx=task[0]+dx[i]
            ny=task[1]+dy[i]
            if not(0<=nx<W and 0<=ny<H):continue
            if s[nx][ny]!='#':continue
            q.append((nx,ny))
            s[nx][ny]='.'
            cnt+=1
            break
        else:
            if cnt==0:
                print('No')
                exit()
            q.pop()

for i in range(H):
    for j in range(W):
        if s[i][j]=='#':
            dfs(i,j)
"""
for i in s:
    for j in i:
        if j=='#':
            print('No')
            exit()
"""
print('Yes')