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

Fixed submission:
a,b = map(int,input().split())
ans = max(a,b)
if min(a,b)>max(a,b)-1:
  ans+=min(a,b)
else:
  ans+=max(a,b)-1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
ans = max(a,b)
if min(a,b)>max(a.b)-1:
  ans+=min(a,b)
else:
  ans+=max(a,b)-1
print(ans)
Problem p03106 (python)

Fixed submission:
a,b,k = map(int,input().split(" "))
c = [1]
for i in range(1,max(a,b)+1):
  if a % i == 0 and b % i == 0 and i!=1:
    c.append(i)
c.sort(reverse=True)
print(c[k-1])

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split(" "))
c = [1]
for i in range(1,max(a,b)):
  if a % i == 0 and b % i == 0 and i!=1:
    c.append(i)
c.sort(reverse=True)
print(c[k-1])

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split(" "))
c = []
for i in range(1,max(a,b)):
  if a % i == 0 and b % i == 0:
    c.append(i)
c.sort(reverse=True)
print(c[k-1])
Problem p02786 (python)

Fixed submission:
h = int(input())
cnt = 0
while h > 0:
  h = h // 2
  cnt = cnt + 1
     
print(int(pow(2, cnt) - 1))

Buggy submission (verdict: Runtime Error):
h = input()
cnt = 0
while h > 0:
	h = h // 2
	cnt = cnt + 1

print(pow(2, cnt) - 1)
Problem p03102 (python)

Fixed submission:
n, m, c = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]

count = 0
for i in range(n):
    a = [int(x) for x in input().split(' ')]
    ab = sum(x * y for (x, y) in zip(a, b))
    if ab + c > 0:
        count += 1
        
print(count)

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

n, m, c = [int(x) for x in input().split(' ')]
b = np.asarray([int(x) for x in input().split(' ')])

a = np.ndarray((n, 3), dtype=np.int32)
for i in range(n):
    a[i] = [int(x) for x in input().split(' ')]


s = np.sum(a * b, axis=1)
print(np.sum(s + c > 0))
Problem p03436 (python)

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

inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
q = [(0, 0)]
p = []
for i in range(h):
    p.append([inf] * w)
p[0][0] = 1

while len(q) > 0:
    x, y = q.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h and s[yy][xx] and (p[yy][xx] > p[y][x] + 1):
           p[yy][xx] = p[y][x] + 1
           q.insert(0, (xx, yy))
if p[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - p[h-1][w-1])

Buggy submission (verdict: Runtime Error):
h, w = [int(s) for s in input().split(' ')]
 
s = []
for i in range(h):
    s.append([s == '.' for s in input()])
 
inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

queue = [(0, 0)]
p = []
for i in range(h):
    p.append([inf] * w)
p[0][0] = 1
 
while len(queue) > 0:
    x, y = queue.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h:
        	if s[yy][xx] and p[yy][xx] > p[y][x] + 1:
            	p[yy][xx] = p[y][x] + 1
           		queue.insert(0, (xx, yy))
           
if p[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - p[h-1][w-1])

Buggy submission (verdict: Runtime Error):
h, w = [int(s) for s in input().split(' ')]
 
s = []
for i in range(h):
    s.append(input())
 
inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
queue = [(0, 0)]
d = []
for i in range(h):
    d.append([inf] * w)
d[0][0] = 1
 
while len(queue) > 0:
    x, y = queue.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h and s[yy][xx] == '.' and d[yy][xx] > d[y][x] + 1:
           d[yy][xx] = d[y][x] + 1
           queue.insert(0, (xx, yy))
if d[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - d[h-1][w-1])
Problem p03471 (python)

Fixed submission:
n, y = list(map(int, input().split(' ')))
if y % 1000 != 0:
    print('-1 -1 -1')
    exit()
for ten_th in range(min(n, int(y / 10000)), -1, -1):
    if y < ten_th * 10000 or n < ten_th:
        continue
    for five_th in range(min(n - ten_th, int((y - ten_th * 10000) / 5000)), -1, -1):
        if y < ten_th * 10000 + five_th * 5000 or n < ten_th + five_th:
            continue
        if (y - ten_th * 10000 - five_th * 5000) % 1000 == 0:
            th = int((y - ten_th * 10000 - five_th * 5000) / 1000)
            if n == ten_th + five_th + th:
                print('{} {} {}'.format(ten_th, five_th, th))
                exit()
print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
n, Y = [int(s) for s in input().split(' ')]
 
for x in range(n, -1, -1):
    if Y < x*10000 or n < x:
        continue
    
    for y in range(n-x, -1, -1):
        if Y < x*10000+y*5000 or n < x+y:
            continue
            
        if (Y-x*10000-y*5000) % 1000 == 0:
            print('{} {} {}'.format(x, y, z))
            exit()
            
print('-1 -1 -1')
Problem p02934 (python)

Fixed submission:
n=int(input())
a=[int(i)for i in input().split()]
x=0
for i in a:
    x+=1/i
print(1/x)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i)for i in input().split())]
x=0
for i in a:
    x+=1/i
print(1/x)
Problem p02953 (python)

Fixed submission:
n=int(input())
H=[int(i) for i in input().split()]
for i in range(n-1,0,-1):
    if H[i]<H[i-1]:
        H[i-1]-=1
        if H[i]<H[i-1]:
            print("No")
            exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
n=int(input())
H=[int(i) for i in input().split()]
for i in range(n):
    if i!=0:
        H=H[:-1]
    if max(H)-H(-1)>1:
        print("No")
        exit(0)
print("Yes")
Problem p03111 (python)

Fixed submission:
N,A,B,C=map(int,input().split())
l=[int(input())for _ in range(N)]
def dfs(i,a,b,c,x):
    if i==N:
        return(abs(A-a)+abs(B-b)+abs(C-c)+10*(x-3))if a*b*c!=0 else 10**9
    ret1=dfs(i+1,a,b,c,x)
    ret2=dfs(i+1,a+l[i],b,c,x+1)
    ret3=dfs(i+1,a,b+l[i],c,x+1)
    ret4=dfs(i+1,a,b,c+l[i],x+1)
    return(min(ret1,ret2,ret3,ret4))
print(dfs(0,0,0,0,0))

Buggy submission (verdict: Runtime Error):
    N, A, B, C = map(int, input().split())
    l = [int(input()) for _ in range(N)]

    def dfs(i, a, b, c, x):
        if i == N:
            return (abs(A - a) + abs(B - b) + abs(C - c) + 10 * (x - 3)) if a * b * c != 0 else 10 ** 9
        ret1 = dfs(i + 1, a, b, c, x)
        ret2 = dfs(i + 1, a + l[i], b, c, x + 1)
        ret3 = dfs(i + 1, a, b + l[i], c, x + 1)
        ret4 = dfs(i + 1, a, b, c + l[i], x + 1)
        return (min(ret1, ret2, ret3, ret4))
Problem p03273 (python)

Fixed submission:
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
for i in range(h):
  if a[i].count('.')==w:
    a[i]=[]
while [] in a:
  a.remove([])
for i in range(w):
  c=0
  for j in range(len(a)):
    if a[j][i]=='.':
      c+=1
  if c==len(a):
    for j in range(len(a)):
      a[j][i]='!'
for i in range(len(a)):
  while '!' in a[i]:
    a[i].remove('!')
for i in a:
  print(*i,sep='')

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
for i in range(h):
  if a[i].count('.')==w:
    a[i]=[]
while [] in a:
  a.remove([])
for i in range(w):
  c=0
  for j in range(len(a)):
    if a[j][i]=='.':
      c+=1
  if c==len(a):
    for j in range(len(a)):
      a[j][i]='!'
for i in range(len(a)):
  while '!' in a[i]:a
    a[i].remove('!')
for i in a:
  print(*i,sep='')
Problem p03293 (python)

Fixed submission:
s=[i for i in input()]
t=[i for i in input()]
a=0
for i in range(len(s)):
    if s==t:
        a+=1
    s=[s[i] for i in range(-1,len(s)-1)]
print("Yes" if a>=1 else "No")

Buggy submission (verdict: Runtime Error):
s=[i for i in input()]
t=[i for i in input()]
a=0
for i in range(len(s)):
    if s==t:
        a+=1
    s=[s[i] for i in range(-1,len(s)-1)]
print("Yes" if a>=1 else "No")s=[i for i in input()]
t=[i for i in input()]
a=0
for i in range(len(s)):
    if s==t:
        a+=1
    s=[s[i] for i in range(-1,len(s)-1)]
print("Yes" if a>=1 else "No")
Problem p03323 (python)

Fixed submission:
a,b=map(int,input().split())
print("Yay!" if a<=8 and b<=8 else ":(")

Buggy submission (verdict: Runtime Error):
a,b=int(input())
print("Yay!" if a<=8 and b<=8 else ":(")
Problem p03351 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
print("NYoe s"[(abs(b-a)<=d and abs(c-b)<=d)or abs(c-a)<=d::2])

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print("Yes"if b-a<=d and c-b<=d elif c-a<=d else "No")
Problem p03565 (python)

Fixed submission:
import copy

S = list(input())
T = list(input())
candidate = []
if len(T) > len(S):
    print("UNRESTORABLE")
    exit()
for i in range(len(S) - len(T) + 1):
    c = 0
    A = copy.copy(S)
    check = False
    for j in range(len(T)):
        if A[i + j] == T[j]:
            c += 1
        elif A[i + j] == "?":
            A[i + j] = T[j]
            c += 1
        else:
            break
        if c == len(T):
            candidate = A
print("".join(candidate).replace("?", "a") if candidate else "UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
import copy
S = list(input())
T = list(input())
for i in range(len(S) - len(T) + 1):
    c = 0
    A=copy.copy(S)
    check = False
    for j in range(len(T)):
        if A[i + j] == T[j]:
            c += 1
        elif A[i + j] == "?":
            A[i + j] = T[j]
            c += 1
        else:
            break
        if c == len(T):
            check = True
    if check:
        break
print("".join(A).replace("?","a") if check else "UNRESTORABLE")
Problem p03206 (python)

Fixed submission:
d=int(input())
print("Christmas"," Eve"*(25-d))

Buggy submission (verdict: Runtime Error):
max=0
k=0
N=int(input())
for i in range(1,N+1):
    p=int(input())
    if p>max:max=p
    k=k+p
    print((k-max)+(max//2))

Buggy submission (verdict: Runtime Error):
max=0
k=0
N=int(input())
for i in range(1,N+1):
    p=int(input())
    if p>max:max=p
    k=k+p
print((k-max)+(max//2))
Problem p02818 (python)

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

if A >= K:
    A -= K
elif A < K < A + B:
    B -= K - A
    A = 0
elif A + B <= K:
    A = B = 0
    
print(A, B)

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

if A => K:
    A -= K
elif A < K < A + B:
    B -= K - A
    A = 0
elif A + B <= K:
    A = B = 0
    
print(A, B)
Problem p02982 (python)

Fixed submission:
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        tmp = 0
        for k in range(D):
            tmp += ((X[i][k] - X[j][k])** 2)
        tmp = math.sqrt(tmp)
        if tmp.is_integer():
            cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N))]
cnt = 0

for i in range(N - 1):
    for j in range(i + 1, N):
    tmp = 0
    for k in range(D):
        tmp += ((X[i][k] - X[j][k])** 2)
    tmp = math.sqrt(tmp)
    if tmp.is_integer:
        cnt += 1

print(cnt)
Problem p03035 (python)

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

if 6 <= A <= 12:
  B = B / 2
elif 5 >= A:
  B = 0
else:
  pass

print(int(B))

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

if 6 <= A <= 12:
  B = B / 2
elif 5 => B:
  B = 0
else:
  psss

print(int(B))
Problem p03109 (python)

Fixed submission:
import sys

if __name__ == '__main__':
    a = input()
    a = a.split('/')
    year = int(a[0])
    month = int(a[1])
    date = int(a[2])
    if year > 2019:
        print('TBD')
    elif year < 2019:
        print('Heisei')
    elif month < 4:
        print('Heisei')
    elif month > 4:
        print('TBD')
    elif date <= 30:
        print('Heisei')
    else:
        print('TBD')

Buggy submission (verdict: Runtime Error):
import sys

if __name__ == '__main__':
    a = input()
    a = a.split('/')
    year = int(a[0])
    month = int(a[1])
    date = int(a[2])
    if year > 2019:
        print('TBD')
    elif year < 2019:
        print('Heisei')
    elif month < 4:
        print('Heisei')
    elif month > 4:
        print('TBD')
    elif data < 30:
        print('Heisei')
    else:
        print('TBD')
Problem p02812 (python)

Fixed submission:
N = int(input())
S = str(input())
print(S.count("ABC"))

Buggy submission (verdict: Runtime Error):
import itertools
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
L = list(map(list,list(itertools.permutations(list(i for i in range(1,N+1)),N))))
a = L.index(P)
b = L.index(Q)
print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
L = list(map(list,list(itertools.permutations(list(i for i in range(1,N+1)),N))))
a = L.index(P)
b = L.index(Q)
print(abs(a-b))
Problem p03437 (python)

Fixed submission:
temp = input()
temp2 = temp.split(" ")
temp = []
for i in temp2:
    temp.append(int(i))

for i in range(1,100000000):
    ans1 = temp[0]*i
    if ans1 % temp[1] != 0:
        break
    if ans1 >= 10^18:
        ans1 = -1
        break
print(ans1)

Buggy submission (verdict: Runtime Error):
import numpy as np
X = int(input())
Y = int(input())

temp = np.random.randint(1,10^18)
temp2 = 0
temp3 = 1
while not temp % X == 0 and temp % Y != 0:
    temp = np.random.randint(1,10^18)
    temp2 = temp2 + 1
    if temp2 == 1000000:
        temp3 = -1 
        break

if temp3 == -1:
    print(temp3)
else:
    print(temp)
Problem p03795 (python)

Fixed submission:
N = int(input())

x = N * 800
y = 0

for i in range(1,N+1):
    if i % 15 == 0:
        y = y + 200

ans = x-y        
print(ans)

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

x = N*800
y = 0

for i in range(N+1):
  if i % 15 == 0:
    y = y + 200

ans = x-y    
print(ans)

Buggy submission (verdict: Runtime Error):
x = 800*N

y = 0
if N % 15 ==0:
  y = y + 200

print(x-y)
Problem p02818 (python)

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

a = max(A - K,0)
if A - K < 0:
    B = max(B - K + A, 0)

print(a, B)

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

a = max(A - K,0)
if A - K < 0:
    b = max(B - K + A, 0)

print(a, b)
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split())

outlet = 1
res = 0

while outlet < b:
    outlet -= 1
    outlet += a
    res += 1

print(res)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

left = max(b - a, 0)
if left == 0:
    print(1)
    exit(1)
print(left // a + 2)
Problem p02934 (python)

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

print(1 / sum(1 / x for x in A))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    mi = min(a, b)
    ma = max(a, b)
    r = ma % mi
    if r == 0:
        return mi
    gcd(mi, r)


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

Sum = sum(A)
s = []
multi = 1.0
for t in A:
    multi = int((multi * t) / gcd(int(multi), int(t)))

for a in A:
    s.append(int(multi / a))

print(multi / sum(s))

Buggy submission (verdict: Runtime Error):
import math

# not solved by myself
N = input()
A = list(map(int, input().split()))

Sum = sum(A)
s = []
multi = 1.0
for t in A:
    multi = int((multi * t) / math.gcd(int(multi), int(t)))

for a in A:
    s.append(int(multi / a))

print(multi / sum(s))

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

# not solved by myself
N = input()
A = list(map(int, input().split()))

Sum = sum(A)
s = []
multi = 1
for t in A:
    multi = np.lcm(multi, t)

for a in A:
    s.append(int(multi / a))

print(multi / sum(s))

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

# not solved by myself
N = input()
A = list(map(int, input().split()))

Sum = sum(A)
s = []
multi = np.lcm.reduce(A)
for a in A:
    s.append(int(multi / a))


print(int(multi / sum(s)))
Problem p03006 (python)

Fixed submission:
N = int(input())

XYs = []

for i in range(N):
    x,y = map(int,input().split())
    tmp = (x,y)
    XYs.append(tmp)


if N == 1:
    print(1)
    exit()

distances = {}

for index_fr in range(N):
    for index_to in range(N):
        if index_fr == index_to:
            continue
        fr = XYs[index_fr]
        to = XYs[index_to]
        key = str(fr[0] - to[0]) + str(fr[1] - to[1])
        if key in distances.keys():
            distances[key] += 1
        else:
            distances[key] = 1


print(N - max(distances.values()))

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

XYs = []

for i in range(N):
    x,y = map(int,input().split())
    tmp = (x,y)
    XYs.append(tmp)

distances = {}

for index_fr in range(N):
    for index_to in range(N):
        if index_fr == index_to:
            continue
        fr = XYs[index_fr]
        to = XYs[index_to]
        key = str(fr[0] - to[0]) + str(fr[1] - to[1])
        if key in distances.keys():
            distances[key] += 1
        else:
            distances[key] = 1



print(N - max(distances.values()))
Problem p03086 (python)

Fixed submission:
#N,Q =map(int,input().strip().split())
#=int(input().strip())
#=list(map(int,input().strip().split()))
S = input()

#for i in range(0,Q):


subs = []
tmp = []
for s in S:
    if "A" == s or "C" == s or "G"== s or "T" == s:
        tmp.append(s)
    else:
        subs.append(tmp)
        tmp = []

subs.append(tmp)
if len(subs) == 0:
    print("0")
    exit()

rs = sorted(subs,key=lambda x: len(x),reverse=True)
print(len(rs[0]))

Buggy submission (verdict: Runtime Error):
#=map(int,input().strip().split())
#=int(input().strip())
#=list(map(int,input().strip().split()))
S = input()

subs = []
tmp = []
for s in S:
    if "A" == s or "C" == s or "G"== s or "T" == s:
        tmp.append(s)
    else:
        subs.append(tmp)
        tmp = []
rs = sorted(subs,key=lambda x: len(x),reverse=True)
print(len(rs[0]))
Problem p03087 (python)

Fixed submission:
N,Q =map(int,input().strip().split())
#=int(input().strip())
#=list(map(int,input().strip().split()))
S = input()

count = [0]
for i in range(0,N - 1):
    if S[i] == "A" and S[i + 1] == "C":
        count.append(count[i] + 1)
    else:
        count.append(count[i])


for i in range(0,Q):
    l,r = map(int,input().strip().split())
    if r > len(count):
        r = len(count)
    if l == 0:
        l += 1
    print(count[r - 1] - count[l - 1])

Buggy submission (verdict: Runtime Error):
N,Q =map(int,input().strip().split())
#=int(input().strip())
#=list(map(int,input().strip().split()))
S = input()

count = [0]
for i in range(0,N ):
    if S[i] == "A" and S[i + 1] == "C":
        count.append(count[i] + 1)
    else:
        count.append(count[i])


for i in range(0,Q):
    l,r = map(int,input().strip().split())
    if r > len(count):
        r = len(count)
    if l == 0:
        l += 1
    print(count[r - 1] - count[l - 1])
Problem p03095 (python)

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

words = {}

for s in S:
    if s in words.keys():
        words[s] += 1
    else:
        words[s] = 2

res = 1
for k in words.keys():
    res *= words[k]

print((res - 1) % 1000000007)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input().strip()
S += "aaaa"

def tree(N,s,index):
  if N <= index:
      if len(s) > 0:
          return 1
      else:
          return 0

  if S[index] in s:
      return tree(N,s, index + 1)
  else:
      return tree(N,s, index + 1) + tree(N,s + S[index], index + 1)


print(tree(N,"",0) % 1000000007)

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

def tree(N,s,index):
  if N <= index:
      if len(s) > 0:
          return 1
      else:
          return 0

  if S[index] in s:
      return tree(N,s, index + 1)
  else:
      return tree(N,s, index + 1) + tree(N,s + S[index], index + 1)


print(tree(N,"",0) % 1000000007)

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

def tree(N,s,index):
  if N <= index:
      if len(s) > 0:
          return 1
      else:
          return 0

  if S[index] in s:
      return tree(N,s, index + 1)
  else:
      return tree(N,s, index + 1) + tree(N,s + S[index], index + 1)


print(tree(N,"",0) % 1000_000_007)

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

def tree(N,s,index):
  if N <= index:
      if len(s) > 0:
          return 1
      else:
          return 0

  if S[index] in s:
      return tree(N,s, index + 1)
  else:
      return tree(N,s, index + 1) + tree(N,s + S[index], index + 1)


print(tree(N,"",0))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
S = input().strip()

def tree(N,s,index):
  if N == index:
      if len(s) > 0:
          return 1
      else: return 0

  if S[index] in s:
      return tree(N,s, index + 1)
  else:
      return tree(N,s, index + 1) + tree(N,s + S[index], index + 1)


print(tree(N,"",0))
Problem p03150 (python)

Fixed submission:
S = input().strip()

T = "keyence"

if S.startswith(T) or S.endswith(T):
    print("YES")
    exit()

count = 0
j = 0
is_last = False
for i in range(0,len(S)):
    if j >= len(T):
        print("NO")
        exit()
    if T[j] == S[i]:
        j += 1
        continue
    elif T[j] != S[i]:
        print("YES" if S.endswith(T[j:]) else "NO")
        exit()

if j == len(T):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
S = input().strip()

T = "keyence"

count = 0
j = 0
is_last = False
for i in range(0,len(S)):
    if count == 0 and T[j] == S[i]:
        j += 1
        continue
    elif count > 0 and T[j] == S[i]:
        is_last = True
        j += 1
    elif is_last and T[j] != S[i]:
        print("NO")
        exit()
    elif T[j] != S[i]:
        count += 1

if j == len(T):
    print("YES")
else:
    print("NO")
Problem p03200 (python)

Fixed submission:
S = input()

B_num = S.count("B")
W_num = S.count("W")

B_start = W_num # 一番左のBがいていいindex

res = 0
for i in range(B_start + 1):
    if i == len(S):
        break
    if S[i] == "B":
        res += B_start - i
        B_start += 1
        while(B_start < len(S) and S[B_start] == "B"):
            B_start += 1

print(res)

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

B_num = S.count("B")
W_num = S.count("W")

B_start = W_num # 一番左のBがいていいindex

res = 0
for i in range(B_start + 1):
    if S[i] == "B":
        res += B_start - i
        B_start += 1
        while(B_start < len(S) and S[B_start] == "B"):
            B_start += 1

print(res)
Problem p03240 (python)

Fixed submission:
N = int(input().strip())

points = []

for i in range(0,N):
    points.append(list(map(int, input().strip().split())))

for cx in range(0,101):
    for cy in range(0,101):
        for p in points:
            if p[2] > 0:
                target = p
                break
        H = (target[2] + abs(target[0] - cx) + abs(target[1] - cy))
        if all([points[i][2] == max(H - (abs(points[i][0] - cx) + abs(points[i][1] - cy)),0) for i in range(0,N)]):
            res = [cx,cy,H]
            break


print(res[0],res[1],res[2])

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

points = []

for i in range(0,N):
    points.append(list(map(int, input().strip().split())))

for cx in range(0,101):
    for cy in range(0,101):
        H = (points[0][2] + abs(points[0][0] - cx) + abs(points[0][1] - cy))
        if all([points[i][2] == max(H - (abs(points[i][0] - cx) + abs(points[i][1] - cy)),0) for i in range(1,N)]):
            res = [cx,cy,H]
            break


print(res[0],res[1],res[2])

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

points = []

for i in range(0,N):
    points.append(list(map(int, input().strip().split())))

for cx in range(0,101):
    for cy in range(0,101):
        H = (points[0][2] + abs(points[0][0] - cx) + abs(points[0][1] - cy))
        if all([points[i][2] == H - (abs(points[i][0] - cx) + abs(points[i][1] - cy)) for i in range(1,N)]):
            res = [cx,cy,H]
            break


print(res[0],res[1],res[2])