Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
print(' '.join(str(W * H / 2.0), '1' if (W//2 == x) and (H//2 == y) else '0'))

Fixed submission:
W, H, x, y = map(int, input().split())
print(' '.join((str(W * H / 2.0), '1' if (W/2 == x) and (H/2 == y) else '0')))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
P = [0] * (N + 1)
p = 10 ** 9 + 7
B = int(input())
M -= 1
P[0] = 1
P[1] = 1
if B == 1:
  P[1] = 0
  if M > 0:
    B = int(input())
    M -= 1
for i in range(2, N + 1):
  P[i] = (P[i - 1] + P[i - 2]) % p
  if i == B:
    P[i] = 0
    if M > 0:
      B = int(input())
      M -= 1
print(P[N])

Fixed submission:
N, M = map(int, input().split())
P = [0] * (N + 1)
p = 10 ** 9 + 7
B = 0
if M > 0:
  B = int(input())
  M -= 1
P[0] = 1
P[1] = 1
if B == 1:
  P[1] = 0
  if M > 0:
    B = int(input())
    M -= 1
for i in range(2, N + 1):
  P[i] = (P[i - 1] + P[i - 2]) % p
  if i == B:
    P[i] = 0
    if M > 0:
      B = int(input())
      M -= 1
print(P[N])
Buggy python submission (verdict: Time Limit Exceeded):
L = input()
p = 10 ** 9 + 7
l = len(L)
ones = 0
cnt = 1
for i, b in enumerate(L):
  if b == '1':
    left = 2 ** ones % p
    right = (3 ** (l - 1 - i) + 1) % p
    cnt += left * right
    cnt %= p
    ones += 1
print(cnt)

Fixed submission:
L = input()
p = 10 ** 9 + 7
l = len(L)
ones = 0
cnt = 1
two = [1] * l
three = [1] * l
for i in range(1, l):
  two[i] = two[i - 1] * 2 % p
  three[i] = three[i - 1] * 3 % p
for i, b in enumerate(L):
  if b == '1':
    left = two[ones]
    right = (three[l - 1 - i] + 1) % p
    cnt += left * right
    cnt %= p
    ones += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
L = input()
p = 10 ** 9 + 7
l = len(L)
ones = 0
cnt = 1
for i, b in enumerate(L):
  if b == '1':
    left = 2 ** ones % p
    right = (3 ** (l - 1 - i) + 1) % p
    cnt += left * right
    cnt %= p
    ones += 1
print(cnt)

Fixed submission:
L = input()
p = 10 ** 9 + 7
l = len(L)
ones = 0
cnt = 1
two = [1] * l
three = [1] * l
for i in range(1, l):
  two[i] = two[i - 1] * 2 % p
  three[i] = three[i - 1] * 3 % p
for i, b in enumerate(L):
  if b == '1':
    left = two[ones]
    right = (three[l - 1 - i] + 1) % p
    cnt += left * right
    cnt %= p
    ones += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
L = input()
p = 10 ** 9 + 7
ans = 0
b = 0
n = len(L)
while n > 0:
  ans += (3 ** (n - 1)) * (2 ** b)
  ans %= p
  n -= 1
  b += 1
  if n == 0:
    break
  while n and L[len(L) - n] == '0':
    n -= 1
ans += 2 ** b
ans %= p
print(ans)

Fixed submission:
L = input()
p = 10 ** 9 + 7
l = len(L)
ones = 0
cnt = 1
two = [1] * l
three = [1] * l
for i in range(1, l):
  two[i] = two[i - 1] * 2 % p
  three[i] = three[i - 1] * 3 % p
for i, b in enumerate(L):
  if b == '1':
    left = two[ones]
    right = (three[l - 1 - i] + 1) % p
    cnt += left * right
    cnt %= p
    ones += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
L = input()
p = 10 ** 9 + 7
ans = 0
b = 0
while len(L) > 0:
  ans += (3 ** (len(L) - 1)) * (2 ** b)
  ans %= p
  L = L[1:]
  b += 1
  if L == '':
    break
  while L and L[0] == '0':
    L = L[1:]
ans += 2 ** b
ans %= p
print(ans)

Fixed submission:
L = input()
p = 10 ** 9 + 7
l = len(L)
ones = 0
cnt = 1
two = [1] * l
three = [1] * l
for i in range(1, l):
  two[i] = two[i - 1] * 2 % p
  three[i] = three[i - 1] * 3 % p
for i, b in enumerate(L):
  if b == '1':
    left = two[ones]
    right = (three[l - 1 - i] + 1) % p
    cnt += left * right
    cnt %= p
    ones += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
print(S[:K - 1] + S[K - 1].lower() + S[K])

Fixed submission:
N, K = map(int, input().split())
S = input()
print(S[:K - 1] + S[K - 1].lower() + S[K:])
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = [''] * H
M = [[0 for w in range(W)] for h in range(H)]
for i in range(H):
  S[i] = input()
  n = H * W
  for j in range(W):
    if S[i][j] == '#':
      M[i][j] = 0
      n = 0
    else:
      n += 1
      M[i][j] = n
  n = H * W
  for j in range(W - 1, -1, -1):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
for j in range(W):
  n = H * W
  for i in range(H):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
  n = H * W
  for i in range(H - 1, -1, -1):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
print(max([max(m) for m in M]))

Fixed submission:
H, W = map(int, input().split())
S = [''] * H
M = [[0 for w in range(W)] for h in range(H)]
for i in range(H):
  S[i] = input()
  n = H * W
  for j in range(W):
    if S[i][j] == '#':
      M[i][j] = 0
      n = 0
    else:
      n += 1
      M[i][j] = n
  n = H * W
  for j in range(W - 1, -1, -1):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
for j in range(W):
  n = H * W
  for i in range(H):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
  n = H * W
  for i in range(H - 1, -1, -1):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
print(max([max(m) for m in M]))
Buggy python submission (verdict: Runtime Error):
A, B, T = map(int, input())
print((T // A) * B)

Fixed submission:
A, B, T = map(int, input().split())
print((T // A) * B)
Buggy python submission (verdict: Runtime Error):
A = [0] * 5
for i in range(5):
  A[i] = int(input())
A.sort(reversed=True, key=lambda x: x % 10)
t = 0
for a in A[:4]:
  a += 9
  t += a - a % 10
print(t + a[4])

Fixed submission:
A = [0] * 5
for i in range(5):
  A[i] = int(input())
A.sort(reverse=True, key=lambda x: x % 10)
for i in range(5):
  if A[4] % 10 == 0:
    A = [A[4]] + A[:4]
  else:
    break
t = 0
for a in A[:4]:
  a += 9
  t += a - a % 10
print(t + A[4])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
p = 10 ** 9 + 7
C = [0] * (N + 1)
D = defaultdict(list)
DP = [[0, 0] for i in range(N + 1)]
DP[0] = [1, 0]
LC = 0
LP = -1
for i in range(1, N + 1):
  C[i] = int(input())
  DP[i][0] = sum(DP[i - 1]) % p
  if C[i] != C[i - 1]:
    for d in D[C[i]]:
      DP[i][1] += DP[d][0]
    D[C[i]] += [i]
print(sum(DP[N]) % p)

Fixed submission:
from collections import defaultdict
N = int(input())
p = 10 ** 9 + 7
C = [0] * (N + 1)
D = defaultdict(lambda: -1)
DP = [[0, 0] for i in range(N + 1)]
DP[0] = [1, 0]
for i in range(1, N + 1):
  C[i] = int(input())
  DP[i][0] = sum(DP[i - 1]) % p
  if C[i] != C[i - 1]:
    DP[i][1] = sum(DP[D[C[i]]]) if D[C[i]] != -1 else 0
    D[C[i]] = i
print(sum(DP[N]) % p)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
p = 10 ** 9 + 7
C = [0] * (N + 1)
D = defaultdict(list)
DP = [[0, 0] for i in range(N + 1)]
DP[0] = [1, 0]
LC = 0
LP = -1
for i in range(1, N + 1):
  C[i] = int(input())
  DP[i][0] = sum(DP[i - 1]) % p
  if C[i] != C[i - 1]:
    for d in D[C[i]]:
      DP[i][1] += DP[d][0]
    D[C[i]] += [i]
print(sum(DP[N]) % p)
    

Fixed submission:
from collections import defaultdict
N = int(input())
p = 10 ** 9 + 7
C = [0] * (N + 1)
D = defaultdict(lambda: -1)
DP = [[0, 0] for i in range(N + 1)]
DP[0] = [1, 0]
for i in range(1, N + 1):
  C[i] = int(input())
  DP[i][0] = sum(DP[i - 1]) % p
  if C[i] != C[i - 1]:
    DP[i][1] = sum(DP[D[C[i]]]) if D[C[i]] != -1 else 0
    D[C[i]] = i
print(sum(DP[N]) % p)
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
AB = A ^ B
if bin(AB)[2:].count('1') != 1:
  print('NO')
else:
  print('YES')
  C = [0] * (1 << N)
  C[0] = str(A)
  pos = 0
  while AB % 2 == 0:
    pos += 1
    AB >>= 1
  for i in range(1, 1 << N):
    k = 0
    b = i
    while b % 2 == 0:
      k += 1
      b >>= 1
    A ^= 1 << ((pos + k + 1) % N)
    C[i] = str(A)
print(' '.join(C))

Fixed submission:
N, A, B = map(int, input().split())
AB = A ^ B
D = bin(AB)[2:].count('1')
if D % 2 == 0:
  print('NO')
else:
  print('YES')
  C = [0] * (2 ** N)
  C[0] = str(A)
  P = []
  for i in range(N):
    if AB % 2:
      P = P + [i]
    else:
      P = [i] + P
    AB >>= 1
  for i in range(1, 2 ** N):
    k = 0
    b = i
    while b % 2 == 0:
      k += 1
      b >>= 1
    A ^= 1 << P[k]
    C[i] = str(A)
  k = 0
  for i in range(D // 2):
    k += 1 / (4 ** (i + 1))
    K = int(2 ** N * (1 - k))
    C = C[:K-1] + C[K+1:] + C[K-1:K+1][::-1]
  print(' '.join(C))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, Q = map(int, input().split())
S = [0] * A
T = [0] * B
for i in range(A):
  S[i] = int(input())
for i in range(B):
  T[i] = int(input())
def lr_find(x, Y):
  if x < Y[0]:
    return [0, Y[0]]
  if x >= Y[-1]:
    return [Y[-1], 0]
  l, r = 0, len(Y) - 1
  while r - l > 1:
    m = (l + r) // 2
    if x < Y[m]:
      r = m
    else:
      l = m
  return [Y[l], Y[r]]
for q in range(Q):
  x = int(input())
  D = [lr_find(x, S), lr_find(x, T)]
  ans = 10 ** 12
  for i in range(8):
    s = D[0][i % 2]
    t = D[1][(i // 2) % 2]
    if s and t:
      dist = abs(s - t) + abs(x - [s, t][(i // 4) % 2])
      ans = min(dist, ans)
  print(ans)

Fixed submission:
A, B, Q = map(int, input().split())
S = [0] * A
T = [0] * B
for i in range(A):
  S[i] = int(input())
for i in range(B):
  T[i] = int(input())
def lr_find(x, Y):
  if x < Y[0]:
    return [0, Y[0]]
  if x >= Y[-1]:
    return [Y[-1], 0]
  l, r = 0, len(Y) - 1
  while r - l > 1:
    m = (l + r) // 2
    if x < Y[m]:
      r = m
    else:
      l = m
  return [Y[l], Y[r]]
for q in range(Q):
  x = int(input())
  D = [lr_find(x, S), lr_find(x, T)]
  ans = 10 ** 12
  for i in range(8):
    s = D[0][i % 2]
    t = D[1][(i // 2) % 2]
    if s and t:
      dist = abs(s - t) + abs(x - [s, t][(i // 4) % 2])
      ans = min(dist, ans)
  print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in range(N):
  if int(input)() % 2:
    print('first')
    break
else:
  print('second')

Fixed submission:
N = int(input())
for i in range(N):
  if int(input()) % 2:
    print('first')
    break
else:
  print('second')
Buggy python submission (verdict: Runtime Error):
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2])
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h and abs(cx - x) + abs(cy - y) + h != _H:
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

Fixed submission:
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2], reverse=True)
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h != max(_H - abs(cx - x) - abs(cy - y), 0):
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

Buggy python submission (verdict: Runtime Error):
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2])
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if abs(cx - x) + abs(cy - y) + h != _H:
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

Fixed submission:
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2], reverse=True)
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h != max(_H - abs(cx - x) - abs(cy - y), 0):
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)
Buggy python submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
_M = M
primes = [1]
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
devides[1] = 1
for prime in primes:
  _devides = [d for d in devides]
  for i in range(N):
    if devides[i]:
      if i * prime < N:
        _devides[i * prime] = 1
      else:
        ans = max(M // i // prime, ans)
  devides = _devides
print(ans)

Fixed submission:
import math
N, M = map(int, input().split())
_M = M
primes = [1]
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
if N > 1:
  devides[1] = 1
  for prime in primes:
    _devides = [d for d in devides]
    for i in range(N):
      if devides[i]:
        if i * prime < N:
          _devides[i * prime] = 1
        else:
          ans = max(M // i // prime, ans)
    devides = _devides
else:
  ans = M
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
_M = M
primes = []
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
devides[1] = 1
for prime in primes:
  _devides = [d for d in devides]
  for i in range(N):
    if devides[i]:
      if i * prime < N:
        _devides[i * prime] = 1
      else:
        ans = max(M // i // prime, ans)
  devides = _devides
print(ans)

Fixed submission:
import math
N, M = map(int, input().split())
_M = M
primes = [1]
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
if N > 1:
  devides[1] = 1
  for prime in primes:
    _devides = [d for d in devides]
    for i in range(N):
      if devides[i]:
        if i * prime < N:
          _devides[i * prime] = 1
        else:
          ans = max(M // i // prime, ans)
    devides = _devides
else:
  ans = M
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print('Yes' A % 2 and B % 2 else 'No')

Fixed submission:
A, B = map(int, input().split())
print('Yes' if A % 2 and B % 2 else 'No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
def n_aray_notation(N, n):
  if N == 0:
    return '0'
  else:
    s = ''
    while N:
      s = str(N % abs(n)) + s
      N -= N % abs(n)
      N //= n
    return s
print(n_array_notation(N, -2))

Fixed submission:
N = int(input())
str2N = bin(abs(N))[2:]
S = ''
inc = 0
for i, s in enumerate(str2N[::-1]):
  S += str((int(s) + inc) % 2)
  if N > 0:
    if i % 2 == 0:
      inc = (int(s) + inc) // 2
    else:
      inc = 1 if (int(s) + inc) else 0
  else:
    if i % 2 == 0:
      inc = 1 if (int(s) + inc) else 0
    else:
      inc = (int(s) + inc) // 2
S += str(inc)
if abs(N) > 0:
  S = S[::-1][S[::-1].find('1'):]
  if N > 0:
    if len(S) % 2 == 0:
      S = '1' + S
  else:
    if len(S) % 2 != 0:
      S = '1' + S
  print(S)
else:
  print('0')
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [0] * N
cnt = 0
for i, x in enumerate(input().split()):
  A[i] = int(x) % M
  if A[i] == 0:
    cnt += 1
for i in range(N):
  sumA = A[i]
  for j in range(i + 1, N):
    sumA += A[j]
    sumA %= M
    if sumA == 0:
      cnt += 1
print(cnt)

Fixed submission:
N, M = map(int, input().split())
A = [0] * N
cnt = 0
for i, x in enumerate(input().split()):
  A[i] = int(x) % M
sumA = 0
for i in range(N):
  sumA += A[i]
  sumA %= M
  A[i] = sumA
A += [0]
index = {}
for i in set(set(A)):
  index[i] = 0
for a in A:
  index[a] += 1
for i in index.values():
  cnt += i * (i - 1) // 2
print(cnt)
Buggy python submission (verdict: Runtime Error):
A = map(int, input().split())
print(max(A) - min(A))

Fixed submission:
A = map(int, input().split())
A = sorted(A)
print(A[2] - A[0])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
I = [N + 1 for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  I[a - 1] = min(I[a - 1], b - 1)
cut = 0
for i in range(N):
  if I[i] == i + 1:
    cut += 1
  else:
    I[i + 1] = min(I[i + 1], I[i])
print(cut)

Fixed submission:
N, M = map(int, input().split())
A = []
for i in range(M):
  a, b = map(int, input().split())
  A.append([a - 1, b - 1])
A = sorted(A, key=lambda a: a[0])
cut = 1
b_min = N
for a in A:
  if a[0] >= b_min:
    cut += 1
    b_min = N
  b_min = min(b_min, a[1])
print(cut)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A < 9 and B < 9:
  print('Yay!')
else:
  print(':(')

Fixed submission:
[A, B] = [int(x) for x in input().split()]
if A < 9 and B < 9:
  print('Yay!')
else:
  print(':(')

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A < 9 and B < 9:
  print('Yay!')
else:
  print(':(')

Fixed submission:
[A, B] = [int(x) for x in input().split()]
if A < 9 and B < 9:
  print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Runtime Error):
import functools
[N,M] = [int(x) for x in input().split()]
XYZ = []
for i in range(N):
  XYZ.append([int(x) for x in input().split()])
result = 0
for x in range(-1, 2, 2):
  for y in range(-1, 2, 2):
    for z in range(-1, 2, 2):
      contribute = [x, y, z]
      score = [functools.reduce(lambda a, b: a + b, [xyz[i] * contribute[i] for i in range(3)]) for xyz in XYZ]
      score.sort(reverse=True)
      result = max(result, functools.reduce(lambda a, b: a + b, score[:M]))
print(result)

Fixed submission:
import functools
[N, M] = [int(x) for x in input().split()]
XYZ = []
for i in range(N):
  XYZ.append([int(x) for x in input().split()])
result = 0
for x in range(-1, 2, 2):
  for y in range(-1, 2, 2):
    for z in range(-1, 2, 2):
      contribute = [x, y, z]
      score = [functools.reduce(lambda a, b: a + b, [xyz[i] * contribute[i] for i in range(3)]) for xyz in XYZ]
      score.sort(reverse=True)
      S = functools.reduce(lambda a, b: a + b, score[:M]) if M else 0
      result = max(result, S)
print(result)
Buggy python submission (verdict: Runtime Error):
import math
def divide(A,B,C,D,E):
  F = [B,C,D,E]
  F.sort()
  tail = F[-1]
  F = F[:-1]
  G = 1
  for i in range(A-tail):
    G *= A - i
  for f in F:
    G /= f
  return G
N,A,B,K = map(int, input().split())
count = 0
Nf = math.factorial(N)
P = []
c = 0
while c < N:
  if K % B == 0:
    if K//B <= N:
      print((c, K//B))
      P.append([c, K//B])
  K -= A
  c += 1
for p in P:
  for G in range(min(p[0],p[1]) + 1):
    W = N - p[0] - p[1] + G
    if W >= 0:
      #divider = math.factorial(p[0]-G) * math.factorial(p[1]-G) * math.factorial(G) * math.factorial(W)
      pattern = divide(Nf, math.factorial(p[0]-G), math.factorial(p[1]-G), math.factorial(G), math.factorial(W))
      count += pattern
count *= 10 ** k
if count > 998244353:
  count = count % 998244353
print(count)

Fixed submission:
def fib(n, p):
  F = [1] * (n + 1)
  for i in range(2, n + 1):
    F[i] = F[i - 1] * i % p
  return F
def finv(F, p):
  N = len(F) - 1
  Finv = list(F)
  Finv[-1] = pow(F[-1], p - 2, p)
  for i in range(N - 1, -1, -1):
    Finv[i] = Finv[i + 1] * (i + 1) % p
  return Finv
def comb(F, Finv, n, a, p):
  return F[n] * Finv[a] * Finv[n - a] % p
N, A, B, K = map(int, input().split())
p = 998244353
F = fib(N, p)
Finv = finv(F, p)
cnt = 0
for a in range(min(N + 1, K // A + 1)):
  _A = A * a
  if _A > K:
    continue
  if (K - _A) % B > 0:
    continue
  b = (K - _A) // B
  if b > N:
    continue
  cnt += comb(F, Finv, N, a, p) * comb(F, Finv, N, b, p)
  cnt %= p
print(cnt)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b= [int(x) for x in input().split()]
c = a
for s in range(a):
  d = b[s]
  e = b[s]
  for t in b[s+1::]:
    d = d ^ t
    e = e + t
    if d == e:
      c += 1
    else:
      break
print(c)

Fixed submission:
import functools
a = int(input())
S = input()
l = [0] * (a+1)
r = [0] * (a+1)
for i, s in enumerate(S):
  l[i+1] = l[i] + 1 if s=="W" else l[i]
for i,s in enumerate(S[::-1]):
  r[i+1] = r[i] + 1 if s=="E" else r[i]
b = [l[i]+r[a-1-i] for i in range(a)]
c = functools.reduce(lambda x, y: min(x, y), b)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b= [int(x) for x in input().split()]
c = a
for s in range(a-1):
  d = b[s]
  for t in range(s+1,a):
    if b[t]==0:
      c += 1
    elif d & b[t]:
      break
    else:
      d = d ^ b[t]
      c += 1
print(c)

Fixed submission:
N = int(input())
A= [int(x) for x in input().split()]
A.append(0)
count = N
s = 0
t = 1
xor = A[0]
while s < N - 1:
  while t < N:
    if not A[t] or not (xor & A[t]):
      xor ^= A[t]
      t += 1
    else:
      break
  count += t - s - 1
  while s < t:
    xor ^= A[s]
    s += 1
    if xor & A[t]:
      count += t - s - 1
      continue
    else:
      break
  if s == t:
    xor = A[s]
    t += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b= [int(x) for x in input().split()]
c = a
for s in range(a-1):
  d = b[s]
  for t in range(s+1,a):
    if b[t]==0:
      d = d ^ b[t]
      c += 1
    elif d & b[t]:
      break
    else:
      d = d ^ b[t]
      c += 1
print(c)

Fixed submission:
N = int(input())
A= [int(x) for x in input().split()]
A.append(0)
count = N
s = 0
t = 1
xor = A[0]
while s < N - 1:
  while t < N:
    if not A[t] or not (xor & A[t]):
      xor ^= A[t]
      t += 1
    else:
      break
  count += t - s - 1
  while s < t:
    xor ^= A[s]
    s += 1
    if xor & A[t]:
      count += t - s - 1
      continue
    else:
      break
  if s == t:
    xor = A[s]
    t += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b= [int(x) for x in input().split()]
c = a
for s in range(a):
  d = b[s]
  e = b[s]
  for t in b[s+1::]:
    d = d ^ t
    e = e + t
    if d == e:
      c += 1
    else:
      break
print(c)

Fixed submission:
N = int(input())
A= [int(x) for x in input().split()]
A.append(0)
count = N
s = 0
t = 1
xor = A[0]
while s < N - 1:
  while t < N:
    if not A[t] or not (xor & A[t]):
      xor ^= A[t]
      t += 1
    else:
      break
  count += t - s - 1
  while s < t:
    xor ^= A[s]
    s += 1
    if xor & A[t]:
      count += t - s - 1
      continue
    else:
      break
  if s == t:
    xor = A[s]
    t += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b= [int(x) for x in input().split()]
c = a
for s in range(a-1):
  d = b[s]
  e = b[s]
  for t in range(s+1, a):
    d = d ^ b[t]
    e = e + b[t]
    if d == e:
      c += 1
    else:
      break
print(c)

Fixed submission:
N = int(input())
A= [int(x) for x in input().split()]
A.append(0)
count = N
s = 0
t = 1
xor = A[0]
while s < N - 1:
  while t < N:
    if not A[t] or not (xor & A[t]):
      xor ^= A[t]
      t += 1
    else:
      break
  count += t - s - 1
  while s < t:
    xor ^= A[s]
    s += 1
    if xor & A[t]:
      count += t - s - 1
      continue
    else:
      break
  if s == t:
    xor = A[s]
    t += 1
print(count)
Buggy python submission (verdict: Runtime Error):
import re
s = input()
K = int(input())
def finddict(s, sub, dic):
  for _sub in sorted(set(re.findall(sub+'.', s))):
    dic.append(_sub)
    dic = finddict(s, _sub, dic)
    if len(dic) >= K:
      break
  return dic
dic = []
for i in range(26):
  if s.find(chr(97 + i)) >= 0:
    dic += finddict(s, chr(97 + i), [chr(97 + i)])
  if len(dic) >= K:
    print(dic[K - 1])
    break

Fixed submission:
s = input()
K = int(input())
subs = []
for i in range(len(s)):
  for k in range(K):
    subs.append(s[i: i + 1 + k])
print(sorted(set(subs))[K - 1])