Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1, N+1):
  cnt = 0
  for x in range(1, 101):
    for y in range(1, 101):
      for z in range(1, 101):
        if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
          cnt += 1
  print(cnt)


Fixed submission:
# ans

N = int(input())

ans = [0] * (N + 1)
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      n = x * x + y * y + z * z + x * y + y * z + z * x
      if n <= N:
        ans[n] += 1

for i in range(1, len(ans)):
  print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1, N+1):
  cnt = 0
  for x in range(1, 51):
    for y in range(1, 51):
      for z in range(1, 51):
        if (x + y + z) ** 2 - (x * y) - (y * z) - (z * x) == n:
          cnt += 1
  print(cnt)

Fixed submission:
# ans

N = int(input())

ans = [0] * (N + 1)
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      n = x * x + y * y + z * z + x * y + y * z + z * x
      if n <= N:
        ans[n] += 1

for i in range(1, len(ans)):
  print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1, N+1):
  cnt = 0
  for x in range(1, 100):
    for y in range(1, 100):
      for z in range(1, 100):
        if (x + y + z) ** 2 - (x * y) - (y * z) - (z * x) == n:
          cnt += 1
  print(cnt)

Fixed submission:
# ans

N = int(input())

ans = [0] * (N + 1)
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      n = x * x + y * y + z * z + x * y + y * z + z * x
      if n <= N:
        ans[n] += 1

for i in range(1, len(ans)):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
D = int(input())
clist = list(map(int, input().split()))
slist = [list(map(int, input().split())) for _ in range(D)]
tlist = [int(input()) for _ in range(D)]

print(sum(clist))

for i in range(D):
  print(slist[i][tlist[i]] - sum(clist))

Fixed submission:
D = int(input())
clist = list(map(int, input().split()))
slist = [list(map(int, input().split())) for _ in range(D)]
tlist = [int(input()) for _ in range(D)]
zlist = []
dlist = [0] * 26
ans = 0
'''
print(sum(clist))
print('--------------')
print(slist[0][0])
print(slist[1][16])
print(clist[16])

print('--------------')
'''
for i in range(D):
  #print(slist[i],tlist[i]-1)
  zlist.append(clist[tlist[i]-1] * ((i+1) - dlist[tlist[i]-1]))
  dlist[tlist[i]-1] = i+1
  ans += slist[i][tlist[i]-1] - ((i+1) * sum(clist)) + sum(zlist)
  print(ans)
Buggy python submission (verdict: Runtime Error):
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100000
for i in A:
  cnt[i] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0
  

Fixed submission:
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100001
for i in A:
  cnt[i] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0

Buggy python submission (verdict: Runtime Error):
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100000
for i in range(N):
  cnt[A[i]] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0

Fixed submission:
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100001
for i in A:
  cnt[i] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0

Buggy python submission (verdict: Runtime Error):
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100000
for i in range(N):
  cnt[i] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0

Fixed submission:
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100001
for i in A:
  cnt[i] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0

Buggy python submission (verdict: Runtime Error):
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100000
for i in range(A):
  cnt[i] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0

Fixed submission:
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100001
for i in A:
  cnt[i] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

for i in range(Q):
  B, C = map(int, input().split())
  A = [C if i == B else i for i in A]
  print(sum(A))

Fixed submission:
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100001
for i in A:
  cnt[i] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0
Buggy python submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if (B-A) % abs(V-W) == 0 and V > W:
  print('YES')
else:
  print('NO')

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

if abs(A - B) <= (V - W) * T:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = A[0]

for i in range(1,N):
  ans *= A[i]

if ans > 10 ** 18:
  print(-1)
else:
  print(ans)

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

if 0 in A:
  print(0)
  exit()

ans = A[0]

for i in range(1,N):
  ans *= A[i]
  if ans > 10 ** 18:
    print(-1)
    exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
H1, M1, H2, M2, K = map(int, input())
print((H2-H1) * 60 - K)

Fixed submission:
H1, M1, H2, M2, K = map(int, input().split())
print((H2 - H1) * 60 + (M2 -M1) - K)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

for i in range(1, N+1):
  print(A.count(i))

Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))
cnt = collections.Counter(A)
for i in range(1, N+1):
    print(cnt[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

for i in range(1, N+1):
  print(A.count(i))

Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))
cnt = collections.Counter(A)
for i in range(1, N+1):
    print(cnt[i])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
min = N

while True:
  N = abs(N-K)
  min = N
  if min <= 2:
    break  
    
print(min)

Fixed submission:
N, K = map(int, input().split())
print(min(N % K, K - N % K))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, M = map(int, input().split())
# items
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# discount
d = [list(map(int,input().split())) for i in range(M)]

list = []

for i in range(M):
  if min(a) + min(b) > a[d[i][0] - 1] + b[d[i][1] - 1] - d[i][2]:
    list.append(a[d[i][0] - 1] + b[d[i][1] - 1] - d[i][2])

if len(list) != 0:
  print(min(list))
else:
  print(min(a) + min(b))

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min = min(a) + min(b)

for i in range(M):
  x, y, c = list(map(int, input().split()))
  tmp = a[x - 1] + b[y - 1] - c
  if min > tmp:
    min = tmp

print(min)

Buggy python submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
# items
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# discount
d = [list(map(int,input().split())) for i in range(M)]

list = []

for i in range(M):
  if min(a) + min(b) > a[d[i][0] - 1] + b[d[i][1] - 1] - d[i][2]:
    list.append(a[d[i][0] - 1] + b[d[i][1] - 1] - d[i][2])

print(min(list))

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min = min(a) + min(b)

for i in range(M):
  x, y, c = list(map(int, input().split()))
  tmp = a[x - 1] + b[y - 1] - c
  if min > tmp:
    min = tmp

print(min)
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
str = ''

if A == 0:
  print(0)
  exit()
  
for _ in range(N):
  for i in range(A):
    if len(str) < N:
      str += 'b'
  for j in range(B):
    if len(str) < N:
      str += 'r'

print(str.count('b'))

Fixed submission:
N, A, B = map(int, input().split())
print((N // (A + B) * A) + min(A, N % (A + B)))

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
blue = 'b' * A
red = 'r' * B
str = ''

while len(str) < N:
  str += blue
  str += red

print(str[:N].count('b'))

Fixed submission:
N, A, B = map(int, input().split())
print((N // (A + B) * A) + min(A, N % (A + B)))

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
blue = 'b' * A
red = 'r' * B
str = ''

while len(str) < N:
  str += blue
  if len(str) < N:
    str += red

print(str[:N].count('b'))

Fixed submission:
N, A, B = map(int, input().split())
print((N // (A + B) * A) + min(A, N % (A + B)))

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
blue = 'b' * A
red = 'r' * B
str = ''

for _ in range(N):
  for i in range(A):
    if len(str) < N:
      str += blue
  for j in range(B):
    if len(str) < N:
      str += red

print(str.count('b'))

Fixed submission:
N, A, B = map(int, input().split())
print((N // (A + B) * A) + min(A, N % (A + B)))

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
str = ''

if A == 0:
  print(0)
  exit()
  
for _ in range(N):
  for i in range(A):
    if len(str) < N:
      str += 'b'
  for j in range(B):
    if len(str) < N:
      str += 'r'

print(str.count('b'))

Fixed submission:
N, A, B = map(int, input().split())
print((N // (A + B) * A) + min(A, N % (A + B)))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
S = [input() for i in range(N)]
clist = Counter(S)
tmp = 0
rlist = []

for i in range(len(clist)):
	if tmp <= int(clist.most_common()[i][1]):
		tmp = int(clist.most_common()[i][1])
		rlist.append(clist.most_common()[i][0])

rlist.sort(reverse=False)

for i in range(len(rlist)):
  print(rlist[i])


Fixed submission:
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
clist = Counter(S)
M = max(clist.values())
rlist = []

for i in clist.keys():
    if clist[i] == M:
        rlist.append(i)

rlist.sort(reverse=False)

for i in range(len(rlist)):
  print(rlist[i])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
S = [input() for i in range(N)]
clist = Counter(S)
tmp = 0
rlist = []

for i in range(len(clist)):
	if tmp <= int(clist.most_common()[i][1]):
		tmp = int(clist.most_common()[i][1])
		rlist.append(clist.most_common()[i][0])

rlist.sort(reverse=False)

for i in range(len(rlist)):
  print(rlist[i])


Fixed submission:
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
clist = Counter(S)
M = max(clist.values())
rlist = []

for i in clist.keys():
    if clist[i] == M:
        rlist.append(i)

rlist.sort(reverse=False)

for i in range(len(rlist)):
  print(rlist[i])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
S = [input() for i in range(N)]
S.sort(reverse=False)
clist = Counter(S)
tmp = 0
rlist = []

for i in range(len(clist)):
	if tmp <= int(clist.most_common()[i][1]):
		tmp = int(clist.most_common()[i][1])
		rlist.append(clist.most_common()[i][0])

rlist.sort(reverse=False)

for i in range(len(rlist)):
  print(rlist[i])

Fixed submission:
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
clist = Counter(S)
M = max(clist.values())
rlist = []

for i in clist.keys():
    if clist[i] == M:
        rlist.append(i)

rlist.sort(reverse=False)

for i in range(len(rlist)):
  print(rlist[i])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
monsters = list(map(int, input().split()))
monsters.sort(reverse=True)
count = 0

while K > count:
  count += 1
  try:
    monsters.pop(0)
  except IndexError:
    pass

print(sum(monsters))

Fixed submission:
from collections import deque

N, K = map(int,input().split())
monsters = list(map(int, input().split()))
monsters.sort(reverse=True)
monsters = deque(monsters)
count = 0

while K > count:
  count += 1
  try:
    monsters.popleft()
  except IndexError:
    pass

print(sum(monsters))
Buggy python submission (verdict: Runtime Error):
str = input()

print chr(ord(str) + 1)

Fixed submission:
str = input()

print(chr(ord(str) + 1))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

wa = [0] * N
pnt = [0] * N
ac = [False] * N

for _ in range(M):
    tmp = 0
    p, s = list(map(str, input().split()))
    if s == 'WA':
      wa[int(p)] += 1
    elif s == 'AC' and not (ac[int(p)]):
      ac[int(p)] = not (ac[int(p)])
      pnt[int(p)] += wa[int(p)]

print(ac.count(True), sum(pnt))

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

wa = [0] * N
pnt = [0] * N
ac = [False] * N

for _ in range(M):
    p, s = list(map(str, input().split()))
    if s == 'WA':
      wa[int(p) - 1] += 1
    elif s == 'AC' and not (ac[int(p) - 1]):
      ac[int(p) - 1] = not (ac[int(p) - 1])
      pnt[int(p) - 1] += wa[int(p) - 1]

print(ac.count(True), sum(pnt))

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

wa = [0] * N
pnt = [0] * N
ac = [False] * N

for _ in range(M):
    tmp = 0
    p, s = list(map(str, input().split()))
    if s == 'WA':
      wa[int(p)] += 1
    elif s == 'AC' and not (ac[int(p)]):
      ac[int(p)] = not (ac[int(p)])
      pnt[int(p)] += wa[int(p)]

print(ac.count(True), sum(pnt))

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

wa = [0] * N
pnt = [0] * N
ac = [False] * N

for _ in range(M):
    p, s = list(map(str, input().split()))
    if s == 'WA':
      wa[int(p) - 1] += 1
    elif s == 'AC' and not (ac[int(p) - 1]):
      ac[int(p) - 1] = not (ac[int(p) - 1])
      pnt[int(p) - 1] += wa[int(p) - 1]

print(ac.count(True), sum(pnt))

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

ac = 0
wr = 0
list = []

for _ in range(M):
    tmp = 0
    p, s = list(map(str, input().split()))
    if not(tmp == int(p)) and s == 'AC' and not int(p) in list:
      tmp = int(p)
      list.append(int(p))
      ac += 1
    elif s == 'WA' and not int(p) in list and tmp == 1:
      wr += 1

print(ac, wr)

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

wa = [0] * N
pnt = [0] * N
ac = [False] * N

for _ in range(M):
    p, s = list(map(str, input().split()))
    if s == 'WA':
      wa[int(p) - 1] += 1
    elif s == 'AC' and not (ac[int(p) - 1]):
      ac[int(p) - 1] = not (ac[int(p) - 1])
      pnt[int(p) - 1] += wa[int(p) - 1]

print(ac.count(True), sum(pnt))
Buggy python submission (verdict: Runtime Error):
S = input().split()
 
print(sum(S))

Fixed submission:
S,T = input().split()
print(T+S)

Buggy python submission (verdict: Runtime Error):
S,T = input().split()

puts S + T

Fixed submission:
S,T = input().split()
print(T+S)
Buggy python submission (verdict: Runtime Error):
M1, D1 = int(input())
M2, D2 = int(input())

if D2 == 1:
  print(1)
else:
  print(0)

Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()

if a => 3200:
	print(s)
else:
	print('red')

Fixed submission:
a = int(input())
s = input()

if a >= 3200:
	print(s)
else:
	print('red')
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

if H == 1:
  print('Yes')
  exit()

if H == 2 and H[0] <= H[1]:
  print('Yes')
  exit()
elif H == 2 and H[0] > H[1]:
  print('No')
  exit()

for i in range(1, N-1):
  # 4,4,4(4,4,5 4,5,5 5,5,5) or 4,5,4
  if H[i-1] <= H[i] <= H[i+1] or H[i-1] <= H[i] - 1 <= H[i+1]:
    pass
  # 5,4,4 or 5,5,4
  elif H[i-1] - 1 <= H[i] <= H[i+1] or H[i-1] - 1 <= H[i] - 1 <= H[i+1]:
    passz
  # 5,4,5
  elif H[i-1] - 1 <= H[i] <= H[i+1] - 1:
    pass 
  else:
    print('No')
    exit()

print('Yes')

Fixed submission:
# ans

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

if H == 1:
  print('Yes')
  exit()

for i in range(1, N):
  if H[i-1] == H[i]:
    pass
  elif H[i-1] < H[i]:
    H[i] -= 1
  else:
    print('No')
    exit()

print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)

for i in range(N):
  if i == A.index(max(A)):
    print(B[1])
  else:
    print(B[0])

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)
x = B[1]
y = B[0]
m = A.index(max(A))

for i in range(N):
  if i == m:
    print(x)
  else:
    print(y)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)

for i in range(N):
  if i == A.index(max(A)):
    print(B[1])
  else:
    print(B[0])

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)
x = B[1]
y = B[0]
m = A.index(max(A))

for i in range(N):
  if i == m:
    print(x)
  else:
    print(y)
Buggy python submission (verdict: Runtime Error):
import sys,math
input = sys.stdin.readline

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

print(X)

for i in range(1,N):
  for j in range(1,D):
      num += pow(abs(X[i-1][j-1] - X[i][j]) ,2)
      print(X[i-1][j-1],X[i][j])
  if int(math.sqrt(num)):
    print(math.sqrt(num))
    ans += 1

print(ans)

Fixed submission:
import sys,math
input = sys.stdin.readline

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

for i in range(N):
  for j in range(N):
    num = 0
    if i < j:
      for k in range(D):
        num += pow(abs(X[i][k] - X[j][k]) ,2)
      if math.floor(math.sqrt(num)) ** 2 == num:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
# ans

import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()

print(d[N//2 + 1] - (d[N//2] - 1))

Fixed submission:
# ans

import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()

print(d[N // 2] - d[N // 2 - 1])

Buggy python submission (verdict: Runtime Error):
# ans

import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()

print(d[N//2 + 1] - (d[N//2] - 1))

Fixed submission:
# ans

import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()

print(d[N // 2] - d[N // 2 - 1])

Buggy python submission (verdict: Runtime Error):
# ans

import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()

print(d[N/2] - (d[N/2] - 1))

Fixed submission:
# ans

import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()

print(d[N // 2] - d[N // 2 - 1])
Buggy python submission (verdict: Runtime Error):
S = input()
max = 0
ans = 0

for i in range(10):
  if S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G':
    ans += 1
  else:
    if ans >= max:
      max = ans
    else:
      ans = 0

print(max)

Fixed submission:
S = input()
max = 0
ans = 0

for i in range(len(S)):
  if S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G':
    ans += 1
    if ans > max:
      max = ans
  else:
    ans = 0

print(max)
Buggy python submission (verdict: Runtime Error):
import sys, re
input = sys.stdin.readline().rstrip()

S = input()

if S == 'keyence' or re.fullmatch(r'[a-z]+keyence', S) or re.fullmatch(r'k[a-z]+eyence', S) or re.fullmatch(r'ke[a-z]+yence', S) or re.fullmatch(r'key[a-z]+ence', S) or re.fullmatch(r'keye[a-z]+nce', S) or re.fullmatch(r'keyen[a-z]+ce', S) or re.fullmatch(r'keyenc[a-z]+e', S) or re.fullmatch(r'keyence[a-z]+', S):
  print('YES')
else:
  print('NO')

Fixed submission:
import re

S = input()

if S == 'keyence' or re.fullmatch(r'[a-z]+keyence', S) or re.fullmatch(r'k[a-z]+eyence', S) or re.fullmatch(r'ke[a-z]+yence', S) or re.fullmatch(r'key[a-z]+ence', S) or re.fullmatch(r'keye[a-z]+nce', S) or re.fullmatch(r'keyen[a-z]+ce', S) or re.fullmatch(r'keyenc[a-z]+e', S) or re.fullmatch(r'keyence[a-z]+', S):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, K = map(int, input().split())
H = [int(input()) for i in range(N)]

ans = float("inf")

for s in itertools.permutations(H, K):
  s = list(s)
  s.sort()
  ans = min(ans, s[K-1] - s[0])
  
print(ans)

Fixed submission:
# ans

N, K = map(int, input().split())
H = [int(input()) for i in range(N)]
H.sort()

print(min(H[i+K-1] - H[i] for i in range(N-K+1)))
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
G = []

for i in range(H):
  line = input()
  if line != '.' * W:
    G.append(line)

H = len(G)
ans = []

for i in range(W):
  flg = False
  tmp = ''
  for j in range(H):
    if G[j][i] == '.':
      flg = False
    else:
      flg = True
    tmp += G[j][i]
  if tmp != '.' * H:
    ans.append(tmp)

for i in range(len(ans[0])):
  tmp = ''
  for j in range(H):
    tmp += ans[j][i]
  print(tmp)

Fixed submission:
H, W = map(int, input().split())
G = []

for i in range(H):
  line = input()
  if line != '.' * W:
    G.append(line)

H = len(G)
ans = []

for i in range(W):
  flg = False
  tmp = ''
  for j in range(H):
    if G[j][i] == '.':
      flg = False
    else:
      flg = True
    tmp += G[j][i]
  if tmp != '.' * H:
    ans.append(tmp)

for i in range(H):
  tmp = ''
  for j in range(len(ans)):
    tmp += ans[j][i]
  print(tmp)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

if S[0] != '1':
  print(S[0])
elif S[0] == '1' and K >= 1:
  print(S[1])
else:
  print(1)

Fixed submission:
# ans

S = input()
K = int(input())

if S[0:K].count('1') == K:
  print(1)
  exit()
  
for i in range(K):
  if S[i] != '1':
    print(S[i])
    exit()

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

if S[0] != 1:
  print(S[1])
else:
  print(1)

Fixed submission:
# ans

S = input()
K = int(input())

if S[0:K].count('1') == K:
  print(1)
  exit()
  
for i in range(K):
  if S[i] != '1':
    print(S[i])
    exit()
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

if N % K != 0
	print(N // K - N % K)
else:
	print(N % K)

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

if N % K != 0:
	print(1)
else:
	print(0)