Problem p02841 (python)

Fixed submission:
# -*- coding: utf-8 -*-
m_1, d_1 = map(int, input().split())
m_2, d_2 = map(int, input().split())

if m_1 == m_2:
  print(0)
else:
  print(1)

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

x = 0
y = 0
z = 0
ans = 1
mod = 10 ** 9 + 7

for a in A:
  if a == x:
    if x == y:
      if y == z:
        ans *= 3
      else:
        ans *= 2
    x += 1
  elif a == y:
    if y == z:
      ans *= 2
    y += 1
  else:
    z += 1
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
 
hats = [0, 0, 0]
count = 1
mod = 1000000007
 
for a in map(int, input().split()):
  count *= hats.count(a)
  count %= mod
  try:
    hats[hats.index(a)] += 1
  except ValueError:
    count = 0
    break
  
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
 
mod = int(1e+9 + 7)
L = [0, 0, 0]
pi = 1
for i in range(N):
  j = 0
  while L[j] != A[i]:
    j += 1
    if j == 3:
      break
  n = 0
  for k in range(3):
    if L[k] == A[i]:
      n += 1
  if j != 3:
    L[j] += 1
  pi *= n
  pi %= mod
print(pi)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1
mod = 1000000007
for i in range(n): #1文字目
  if a[i] == x:
    if x == y:
      if x == z:
        ans *= 3
        ans %= mod
      else:
        ans *= 2
        ans %= mod
    x += 1
  elif a[i] == y:
    if y == z:
      ans *= 2
      ans %= mod
    y += 1
  else:
  	z += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input()) #長さ
a = input().split() #帽子の数
x = 0
y = 0
z = 0
ans = 1
mod = 1000000007
for i in range(n): #1文字目
  if a[i] == str(x):
    if x == y and x == z:
      ans *= 3
      ans %= mod
    elif x == y:
      ans *= 2 
      ans %= mod
    x = x + 1
  elif a[i] == str(y):
    if y == z:
      ans *= 2
      ans %= mod
    y += 1
  else:
    z += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input()) #長さ
a = input().split() #帽子の数
x = 0
y = 0
z = 0
ans = 1
 
for i in range(n): #1文字目
  if a[i] == str(x):
    if x == y and x == z:
      ans *= 3
    elif x == y:
      ans *= 2
    x = x + 1
  elif a[i] == str(y):
    if y == z:
      ans *= 2
    y += 1
  else:
    z += 1
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1
mod = 10**9+7
for i in range(n): #1文字目
  if a[i] == x:
    x = x + 1
    if x-1 == y:
      if x-1 == z:
        ans = ans * 3
      else:
        ans = ans * 2
  elif a[i] == y:
    y = y + 1
    if y-1 == z:
      ans = ans * 2
  else:
  	z = z + 1
print(ans % mod)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1 
for i in range(n): #1文字目
  if a[i] == x:
    x = x + 1
    if x-1 == y:
      if x-1 == z:
        ans = ans * 3
      else:
        ans = ans * 2
  elif a[i] == y:
    y = y + 1
    if y-1 == z:
      ans = ans * 2
  else:
  	z = z + 1
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1
for i in range(n): #1文字目
  if a[i] == x:
    if x == y == z:
      ans = ans * 3
    elif x == y != z:
      ans = ans * 2
    x = x + 1
  elif a[i] == y:
    if y == z:
      ans = ans * 2
  	y = y + 1
  else:
  	z = z + 1
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1 
for i in range(n): #1文字目
  if a[i] == x:
    if x == y == z:
      ans = ans * 3
    elif x == y != z:
      ans = ans * 2
    x = x + 1
  elif a[i] == y:
    if y == z:
      ans = ans * 2
    y = y + 1
  else:
  	z = z + 1
print(ans % 1000000007)