Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = input()
MOD = 10**9 + 7
dp = [0] * 3  # num of ..A, ..AB, ..ABC
pp = [0] * 3
nq = 0
for s in S:
    pp = dp
    dp = pp.copy()
    if s == 'A':
        dp[0] += pow(3, nq, MOD)
    elif s == 'B':
        dp[1] += pp[0]
    elif s == 'C':
        dp[2] += pp[1]
    else:
        dp[0] += pp[0]*2 + pow(3, nq, MOD)
        dp[1] += pp[1]*2 + pp[0]
        dp[2] += pp[2]*2 + pp[1]
        nq += 1
    dp[0] %= MOD
    dp[1] %= MOD
    dp[2] %= MOD
print(dp[2])

Fixed submission:
S = input()
MOD = 10**9 + 7
dp = [0] * 3  # num of ..A, ..AB, ..ABC
pp = [0] * 3
nq = 0
for s in S:
    pp = dp
    dp = pp.copy()
    if s == 'A':
        dp[0] += pow(3, nq, MOD)
    elif s == 'B':
        dp[1] += pp[0]
    elif s == 'C':
        dp[2] += pp[1]
    else:
        dp[0] += pp[0]*2 + pow(3, nq, MOD)
        dp[1] += pp[1]*2 + pp[0]
        dp[2] += pp[2]*2 + pp[1]
        nq += 1
    dp[0] %= MOD
    dp[1] %= MOD
    dp[2] %= MOD
print(dp[2])
Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())

v = 0
def solve():
    for x in range(N+1):
        if Y // 10000 < x:
            return [-1,-1,-1]
        r = Y - 10000 * x
        for y in range(0, r // 5000 + 1):
            rr = r - 5000 * y
            z = rr // 1000
            if x + y + z == N:
                return [x, y, z]

print(' '.join(map(str, solve())))


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

v = 0
def solve():
    for x in range(N+1):
        if Y // 10000 < x:
            return [-1,-1,-1]
        r = Y - 10000 * x
        for y in range(0, r // 5000 + 1):
            rr = r - 5000 * y
            z = rr // 1000
            if x + y + z == N:
                return [x, y, z]
    return [-1,-1,-1]

print(' '.join(map(str, solve())))
Buggy python submission (verdict: Runtime Error):
n, k = (int(i) for i in input().split())
balls = list(int(i) for i in input().split())
ball_set = set(balls)
freqs = list(balls.count(i) for i in ball_set)
freqs.sort()
print(sum(freqs[k:]))


Fixed submission:
s = input()
print(s.count('1'))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = (int(i) for i in input().split())
balls = list(int(i) for i in input().split())
ball_set = set(balls)
freqs = list(balls.count(i) for i in ball_set)
freqs.sort(reverse=True)
print(sum(freqs[k:]))


Fixed submission:
n, k = (int(i) for i in input().split())
balls = (int(i) for i in input().split())
freqs = {}
for ball in balls:
    freqs[ball] = freqs[ball] + 1 if ball in freqs else 1
freq_hist = list(freqs.values())
freq_hist.sort(reverse=True)
print(sum(freq_hist[k:]))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
sum = 0
for i in range(1, N):
    for j in range(1, M):
        sum += (X[i] - X[i-1]) * (Y[j] - Y[j-1]) * i * (N - i) * j * (M - j)
        sum %= MOD

print(sum)


Fixed submission:
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7

xsum, ysum = 0, 0
for i in range(1, N):
    xsum += (X[i] - X[i-1]) * i * (N - i)
    xsum %= MOD
for j in range(1, M):
    ysum += (Y[j] - Y[j-1]) * j * (M - j)
    ysum %= MOD

print((xsum * ysum) % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
sum = 0
for i in range(1, N):
    for j in range(1, M):
        sum += (X[i] - X[i-1]) * (Y[j] - Y[j-1]) * i * (N - i) * j * (M - j)
        sum %= MOD

print(sum)


Fixed submission:
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7

xsum, ysum = 0, 0
for i in range(1, N):
    xsum += (X[i] - X[i-1]) * i * (N - i)
    xsum %= MOD
for j in range(1, M):
    ysum += (Y[j] - Y[j-1]) * j * (M - j)
    ysum %= MOD

print((xsum * ysum) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

sm = 1
for i in range(K):
    sm *= A[i]

before = sm
for i in range(K, N):
    sm /= A[i-K]
    sm *= A[i]
    if sm > before:
        print('Yes')
    else:
        print('No')
    before = sm

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

sm = 1
for i in range(K):
    sm += A[i]

before = sm
for i in range(K, N):
    sm -= A[i-K]
    sm += A[i]
    if sm > before:
        print('Yes')
    else:
        print('No')
    before = sm

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

sm = 1
for i in range(K):
    sm *= A[i]

before = sm
for i in range(K, N):
    sm /= A[i-K]
    sm *= A[i]
    if sm > before:
        print('Yes')
    else:
        print('No')
    before = sm

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

sm = 1
for i in range(K):
    sm += A[i]

before = sm
for i in range(K, N):
    sm -= A[i-K]
    sm += A[i]
    if sm > before:
        print('Yes')
    else:
        print('No')
    before = sm
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
idx = 0
tmp = s[1]
idx = 1
ans = 1
if n == 1:
    print(1)
else:
    while(idx<n):
        if s[idx]==tmp:
            idx += 1
        else:
            tmp = s[idx]
            idx += 1
            ans +=1
    print(ans)


Fixed submission:
n = int(input())
s = input()
idx = 0
idx = 1
ans = 1
if n == 1:
    print(1)
else:
    tmp = s[0]
    while(idx<n):
        if s[idx]==tmp:
            idx += 1
        else:
            tmp = s[idx]
            idx += 1
            ans +=1
    print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
idx = 0
tmp = s[1]
idx = 1
ans = 1
while(idx<n):
    if s[idx]==tmp:
        idx += 1
    else:
        tmp = s[idx]
        idx += 1
        ans +=1
print(ans)


Fixed submission:
n = int(input())
s = input()
idx = 0
idx = 1
ans = 1
if n == 1:
    print(1)
else:
    tmp = s[0]
    while(idx<n):
        if s[idx]==tmp:
            idx += 1
        else:
            tmp = s[idx]
            idx += 1
            ans +=1
    print(ans)
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()

if len(a)>len(b):
    print("GREATER")
elif len(a)<len(b):
    print("LESS")
else:
    for i in range(len(a)):
        if a[i]>b[i]:
            print("GRATER")
            exit()
        elif a[i]<b[i]:
            print("LESS")
            exit()
print("EQUAL")

Fixed submission:
a,b,c=input().split()
print(a[0].upper()+b[0].upper()+c[0].upper())
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a_list=[input() for _ in range(n)]
b_list=[input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        f=True
        for k in range(m):
            for l in range(m):
                if a_list[i+k][j+l]!=b_list[k][l]:
                    f=false
                    break
            if not f:
                break
        if f:
            print("Yes")
            exit()
print("No")

Fixed submission:
n,m=map(int,input().split())
a_list=[input() for _ in range(n)]
b_list=[input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        f=True
        for k in range(m):
            for l in range(m):
                if a_list[i+k][j+l]!=b_list[k][l]:
                    f=False
                    break
            if not f:
                break
        if f:
            print("Yes")
            exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i+j+l==s:
                ans+=1
                
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
       if(i+j<=s and s-(i+j)<=k):
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
ls = map(int,input().split())
ls.sort()
ls.reverse()
ans=0
t = 1
for i in range(n) :
 ans += t * ls[i]
 t *= -1
print(ans)

Fixed submission:
n=int(input())
ls = list(map(int,input().split()))
ls.sort()
ls.reverse()
ans=0
t = 1
for i in range(n) :
 ans += t * ls[i]
 t *= -1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())

start = tuple(map(lambda x:x - 1, map(int,input().split())))
goal = tuple(map(lambda x:x - 1, map(int,input().split())))

S = [input() for i in range(H)]

from collections import deque
q = deque([])

# 頂点, コスト
q.append([start[0], start[1], 0])
INF = 10 ** 10
cost = [[INF] * W for i in range(H)]

while q:
  y,x,c = q.popleft()
  if S[y][x] == "#":
    continue
  if cost[y][x] <= c:
    continue
  cost[y][x] = c
  for i in range(-2,3):
    for j in range(-2,3):
      if i == 0 and j == 0:
        continue
      if 0 <= y + i < H and 0 <= x + j < W:
        if abs(i) + abs(j) == 1:
          q.appendleft([y + i, x + j, c])
        else:
          q.append([y + i, x + j, c + 1])

if cost[goal[0]][goal[1]] == INF:
  print(-1)
else:
  print(cost[goal[0]][goal[1]])


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

start = tuple(map(lambda x:x - 1, map(int,input().split())))
goal = tuple(map(lambda x:x - 1, map(int,input().split())))

S = [input() for i in range(H)]

from collections import deque
q = deque([])

# 頂点, コスト
q.append([start[0], start[1], 0])
INF = 10 ** 10
cost = [[INF] * W for i in range(H)]

while q:
  y,x,c = q.popleft()
  if S[y][x] == "#":
    continue
  if cost[y][x] <= c:
    continue
  cost[y][x] = c
  for i in range(-2,3):
    for j in range(-2,3):
      if i == 0 and j == 0:
        continue
      if 0 <= y + i < H and 0 <= x + j < W:
        if abs(i) + abs(j) == 1:
          q.appendleft([y + i, x + j, c])
        else:
          q.append([y + i, x + j, c + 1])

if cost[goal[0]][goal[1]] == INF:
  print(-1)
else:
  print(cost[goal[0]][goal[1]])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

# 全ての組み合わせ数
allcnt = S.count("R") * S.count("G") * S.count("B")

# 除外するものチェック
rem = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    k = j + (j - i)
    if k >= N:
      break
    if len(set([S[i],S[j],S[k]])) == 3:
      rem += 1
print(allcnt - rem)


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

# 全ての組み合わせ数
allcnt = S.count("R") * S.count("G") * S.count("B")

# 除外するものチェック
rem = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    k = j + (j - i)
    if k >= N:
      break
    if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      rem += 1
print(allcnt - rem)

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

# 全ての組み合わせ数
allcnt = S.count("R") * S.count("G") * S.count("B")

# 除外するものチェック
rem = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    k = j + (j - i)
    if k >= N:
      continue
    if len(set([S[i],S[j],S[k]])) == 3:
      rem += 1
print(allcnt - rem)


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

# 全ての組み合わせ数
allcnt = S.count("R") * S.count("G") * S.count("B")

# 除外するものチェック
rem = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    k = j + (j - i)
    if k >= N:
      break
    if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      rem += 1
print(allcnt - rem)
Buggy python submission (verdict: Runtime Error):
import numpy as np

H,N = map(int,input().split())
INF = 10 ** 10
dp = [INF] * (H + 1)
dp[0] = 0

for i in range(N):
  attack,magic = map(int,input().split())
  for j in range(len(dp)):
    if dp[j] == INF:
      continue
    target = j + attack
    if j + attack > H:
      target = H
    if dp[target] > dp[j] + magic:
      dp[target] = dp[j] + magic
      
print(dp[-1])

Fixed submission:
H,N = map(int,input().split())
INF = 10 ** 10
dp = [INF] * (H + 1)
dp[0] = 0

for i in range(N):
  attack,magic = map(int,input().split())
  for j in range(len(dp)):
    if dp[j] == INF:
      continue
    target = j + attack
    if j + attack > H:
      target = H
    if dp[target] > dp[j] + magic:
      dp[target] = dp[j] + magic
      
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H,N = map(int,input().split())
INF = 10 ** 10
dp = [INF] * (H + 1)
dp[0] = 0

for i in range(N):
  attack,magic = map(int,input().split())
  for j in range(len(dp)):
    if dp[j] == INF:
      continue
    target = j + attack
    if j + attack > H:
      target = H
    if dp[target] > dp[j] + magic:
      dp[target] = dp[j] + magic
      
print(dp[-1])

Fixed submission:
H,N = map(int,input().split())
INF = 10 ** 10
dp = [INF] * (H + 1)
dp[0] = 0

for i in range(N):
  attack,magic = map(int,input().split())
  for j in range(len(dp)):
    if dp[j] == INF:
      continue
    target = j + attack
    if j + attack > H:
      target = H
    if dp[target] > dp[j] + magic:
      dp[target] = dp[j] + magic
      
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
# TLE実装　O(N^2)

N,K,Q = map(int,input().split())

scores = [K] * N

for i in range(Q):
  a = int(input())
  for j in range(N):
    if j != a - 1:
      scores[j] -= 1

for s in scores:
  print(("No","Yes")[s > 0])


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

scores = [K - Q] * N

for i in range(Q):
  a = int(input())
  scores[a - 1] += 1

for s in scores:
  print(("No","Yes")[s > 0])
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())

graph = [[] for i in range(N)]

for i in range(M):
  u,v = map(int,input().split())
  graph[u - 1].append(v - 1)

S,T = map(int,input().split())
S -= 1
T -= 1

from collections import deque
q = deque([])
q.append([S, 0, 0])

seen = set()

while q:
  v,cost,step = q.popleft()
  if step == 0:
    if v == T:
      print(cost)
      break
    if v in seen:
      continue
    seen.add(v)
    cost += 1
    step = 3
  for u in graph[v]:
    q.append([u, cost, step - 1])
else:
  print(-1)

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

graph = [[] for i in range(N)]

for i in range(M):
  u,v = map(int,input().split())
  graph[u - 1].append(v - 1)

S,T = map(int,input().split())
S -= 1
T -= 1

from collections import deque
q = deque([])
q.append([S, 0, 0])

seen = [[False] * 3 for i in range(N)]

while q:
  v,cost,step = q.popleft()
  if seen[v][step]:
    continue
  seen[v][step] = True
  if step == 0:
    if v == T:
      print(cost)
      break
    cost += 1
    step = 3
  for u in graph[v]:
    q.append([u, cost, step - 1])
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 * 5 + 1)
N,M = map(int,input().split())

G = [[] for i in range(N)]
for i in range(M):
  x,y = map(int,input().split())
  G[x - 1].append(y - 1)

dp = [-1] * N # dp[i] = 頂点iから進むことが出来る深さ
def search(v):
  if dp[v] != -1:
    return dp[v]
  max_depth = 0
  for child in G[v]:
    max_depth = max(max_depth, search(child) + 1)
    
  dp[v] = max(dp[v], max_depth)
  return dp[v]

for i in range(N):
  search(i)

print(max(dp))


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 5 + 1)
N,M = map(int,input().split())

G = [[] for i in range(N)]
for i in range(M):
  x,y = map(int,input().split())
  G[x - 1].append(y - 1)

dp = [-1] * N # dp[i] = 頂点iから進むことが出来る深さ
def search(v):
  if dp[v] != -1:
    return dp[v]
  max_depth = 0
  for child in G[v]:
    max_depth = max(max_depth, search(child) + 1)
    
  dp[v] = max(dp[v], max_depth)
  return dp[v]

for i in range(N):
  search(i)

print(max(dp))

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

G = [[] for i in range(N)]
for i in range(M):
  x,y = map(int,input().split())
  G[x - 1].append(y - 1)

dp = [-1] * N # dp[i] = 頂点iから進むことが出来る深さ
def search(v):
  if dp[v] != -1:
    return dp[v]
  max_depth = 0
  for child in G[v]:
    max_depth = max(max_depth, search(child) + 1)
    
  dp[v] = max(dp[v], max_depth)
  return dp[v]

for i in range(N):
  search(i)

print(max(dp))


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 5 + 1)
N,M = map(int,input().split())

G = [[] for i in range(N)]
for i in range(M):
  x,y = map(int,input().split())
  G[x - 1].append(y - 1)

dp = [-1] * N # dp[i] = 頂点iから進むことが出来る深さ
def search(v):
  if dp[v] != -1:
    return dp[v]
  max_depth = 0
  for child in G[v]:
    max_depth = max(max_depth, search(child) + 1)
    
  dp[v] = max(dp[v], max_depth)
  return dp[v]

for i in range(N):
  search(i)

print(max(dp))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(float,input().split()))

dp = [0] * (N + 1)
dp[0] = 1

for i in range(len(P)):
  for j in range(len(dp) - 1, -1, -1):
    if j != 0:
      dp[j] = dp[j] * (1 - P[i]) + dp[j - 1] * P[i]
    else:
      dp[j] = dp[j] * (1 - P[i])
      
ans = 0
for i in range(N // 2 + 1, len(dp)):
  ans += dp[i]
  
print(ans)

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

dp = [[0] * (N + 1) for i in range(N + 1)]
dp[0][0] = 1

for i in range(len(P)):
  for j in range(i + 2):
    if j - 1 >= 0:
      dp[i + 1][j] = dp[i][j] * (1 - P[i]) + dp[i][j - 1] * P[i]
    else:
      dp[i + 1][j] = dp[i][j] * (1 - P[i])
  
ans = 0
for i in range(N // 2 + 1, len(dp)):
  ans += dp[N][i]
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

B = []

rev = False

for i in range(N):
  if rev:
    B = [A[i]] + B
  else:
    B = B + [A[i]]
  rev ^= True
  
if rev:
  B = B[::-1]
    
print(*B)


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

from collections import deque

q = deque([])

for i in range(N):
  if i % 2:
    q.appendleft(A[i])
  else:
    q.append(A[i])
    
if N % 2:
  q = list(q)[::-1]
  
print(*q)

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

B = []

for i in range(N):
  B.append(A[i])
  B = B[::-1]
    
print(*B)

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

from collections import deque

q = deque([])

for i in range(N):
  if i % 2:
    q.appendleft(A[i])
  else:
    q.append(A[i])
    
if N % 2:
  q = list(q)[::-1]
  
print(*q)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = [0 for _ in range(len(s))]
temp = 0
start = 0
for i in range(len(s) - 1):
    if s[i] == "R" and s[i + 1] == "L":
        pivot = i
    if s[i] == "L" and s[i + 1] == "R":
        temp += 1
        s[pivot] = s[pivot + 1] = temp // 2
        if temp % 2 == 1:
            s[pivot] = s[pivot + 1] = temp // 2
            if (pivot - start) % 2 == 1:
                s[pivot + 1] += 1
            else:
                s[pivot] += 1
        temp = -1
        start = i + 1
    temp += 1
s[pivot] = s[pivot + 1] = temp // 2
if temp % 2 == 1:
    s[pivot] = s[pivot + 1] = temp // 2
    if (pivot - start) % 2 == 1:
        s[pivot + 1] += 1
    else:
        s[pivot] += 1
for a in s:
    print(a, end = "")


Fixed submission:
s = input()
ans = [0 for _ in range(len(s))]
temp = 0
start = 0
for i in range(len(s) - 1):
    if s[i] == "R" and s[i + 1] == "L":
        pivot = i
    if s[i] == "L" and s[i + 1] == "R":
        temp += 1
        ans[pivot] = ans[pivot + 1] = temp // 2
        if temp % 2 == 1:
            if (pivot - start) % 2 == 1:
                ans[pivot + 1] += 1
            else:
                ans[pivot] += 1
        temp = -1
        start = i + 1
    temp += 1
temp += 1
ans[pivot] = ans[pivot + 1] = temp // 2
if temp % 2 == 1:
    if (pivot - start) % 2 == 1:
        ans[pivot + 1] += 1
    else:
        ans[pivot] += 1
for a in ans:
    print(str(a) + " ", end = "")
Buggy python submission (verdict: Runtime Error):
s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == "0":
    zeroc++
  if i == "1":
    onec++
print(min(zeroc,onec)*2)


Fixed submission:
s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == "0":
    zeroc+=1
  if i == "1":
    onec+=1
print(min(zeroc,onec)*2)

Buggy python submission (verdict: Runtime Error):
s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == 0:
    zeroc++
  if i == 1:
    onec++
print(min(zeroc,onec)*2)


Fixed submission:
s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == "0":
    zeroc+=1
  if i == "1":
    onec+=1
print(min(zeroc,onec)*2)

Buggy python submission (verdict: Runtime Error):
s = input()
s=list()
zeroc=0
onec=0
for i in s:
  if i == 0:
    zeroc++
  if i == 1:
    onec++
print(min(zeroc,onec)*2)

Fixed submission:
s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == "0":
    zeroc+=1
  if i == "1":
    onec+=1
print(min(zeroc,onec)*2)
Buggy python submission (verdict: Runtime Error):
s = int(input())
memo = [-1]
memo.append(s)
def a(n):
    if memo[n-1] % 2 == 0:
        pre = memo[n-1]/2
        for i in memo:
            if i == pre:
                return n
            else:
                memo.append(pre)
                return a(n+1)
    else:
        pre = 3 * memo[n-1] + 1
        for i in memo:
            if i == pre:
                return n
            else:
                memo.append(pre)
                return a(n+1)

print(a(2))

Fixed submission:
s = int(input())
memo = [-1]
memo.append(s)
def a(n):
    if memo[n-1] % 2 == 0:
        pre = memo[n-1]/2
        for i in memo:
            if i == pre:
                return n
        memo.append(pre)
        return a(n+1)
    else:
        pre = 3 * memo[n-1] + 1
        for i in memo:
            if i == pre:
                return n
        memo.append(pre)
        return a(n+1)

print(a(2))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
if n == 1:
    print(m - 2)
    return
if m == 1:
    print(n - 2)
    return
print((n - 2) * (m - 2))


Fixed submission:
n, m = map(int, input().split())
if n == 1:
    if m == 1:
        ans = 1
    else:
        ans = m - 2
elif m == 1:
    ans = n - 2
else:
    ans = (n - 2) * (m - 2)
print(ans)
Buggy python submission (verdict: Runtime Error):
judge = False
N, Y = map(int, input().split())
x = 0
while x <= N and (not judge):
    y = 0
    x += 1
    #print('x:' + str(x))
    rest = Y - x * 10000
    if rest <= 0:
        if rest == 0 and x == N:
            judge = True
        break
    while x + y <= N and Y - x * 10000 - y * 5000 >= 0:
        z = (Y - x * 10000 - y * 5000) // 1000
        #print('y:' + str(y) + 'z:' + str(z))
        if x + y + z == N:
            judge = True
            break
        y += 1
if judge:
    print(str(x) + ' ' + str(y) + ' ' + str(z))
else:
    print('-1 -1 -1')


Fixed submission:
judge = False
N, Y = map(int, input().split())
x = -1
while x <= N and (not judge):
    x += 1
    y = z = 0
   # print('x:' + str(x))
    rest = Y - x * 10000
    if rest <= 0:
        if rest == 0 and x == N:
            judge = True
        break
    while x + y <= N and Y - x * 10000 - y * 5000 >= 0:
        z = (Y - x * 10000 - y * 5000) // 1000
      #  print('y:' + str(y) + 'z:' + str(z))
        if x + y + z == N:
            judge = True
            break
        y += 1
if judge:
    print(str(x) + ' ' + str(y) + ' ' + str(z))
else:
    print('-1 -1 -1')