Problem p02845 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
rbg = [0, 0, 0]
ans = 1
A = [int(a) for a in input().strip().split()]
for a in A:
    if rbg.count(a) == 0:
        print(0)
        exit()
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
rbg = [0, 0, 0]
ans = 1
A = [int(a) for a in input().strip().split()]
if A[0] != 0:
    print(0)
    exit()
for a in A:
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
rbg = [0, 0, 0]
ans = 1
for a in [int(a) for a in input().strip().split()]:
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] = rbg[rbg.index(a)] + 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
rbg = [0, 0, 0]
ans = 1
for a in [int(a) for a in input().strip().split()]:
    ans = (ans * rbg.count(a))
    rbg[rbg.index(a)] += 1

print(ans % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
rbg = [0, 0, 0]
ans = 1
for a in [int(a) for a in input().strip().split()]:
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
rbg = [0, 0, 0]
ans = 1
for a in [int(a) for a in input().strip().split()]:
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
rbg = [0, 0, 0]
ans = 1
for a in [int(a) for a in input().strip().split()]:
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
A = 

rbg = [1, 0, 0]
ans = 1
for a in [int(a) for a in input().strip().split()]:
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans * 3 % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
A = [int(a) for a in input().strip().split()]

rbg = [1, 0, 0]
ans = 1
for a in A[1:]:
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans * 3 % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
A = [int(a) for a in input().strip().split()]

rbg = [1, 0, 0]
ans = 1
multi = 1
for a in A[1:]:
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

if rbg.count(0) == 2:
    print(ans % (10 ** 9 + 7))
else:
    print(ans * 3 % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
A = [int(a) for a in input().strip().split()]

rbg = [1, 0, 0]
ans = 1
multi = 1
for a in A[1:]:
    ans *= rbg.count(a)
    rbg[rbg.index(a)] += 1

if rbg.count(0) == 2:
    print(ans % (10 ** 9 + 7))
else:
    print(ans * 3 % (10 ** 9 + 7))