TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
# C - Make a Rectangle


from collections import Counter

n = int(input())
A = list(map(int, input().split()))

C = sorted(list(Counter(A).items()), key=lambda x: -x[0])

print(C)

ans = 0
for k, v in C:
  if v >= 4:
    if ans == 0:
      print(k ** 2)
    else:
      print(ans * k)
    exit()
  else:
    if v >= 2:
      if ans == 0:
        ans = k
      else:
        print(ans * k)
        exit()

print(0)

# C - Make a Rectangle


from collections import Counter

n = int(input())
A = list(map(int, input().split()))

C = sorted(list(Counter(A).items()), key=lambda x: -x[0])

ans = 0
for k, v in C:
  if v >= 4:
    if ans == 0:
      print(k ** 2)
    else:
      print(ans * k)
    exit()
  else:
    if v >= 2:
      if ans == 0:
        ans = k
      else:
        print(ans * k)
        exit()

print(0)

Verdicts: Wrong Answer

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
x=[0]*(1e9+10)
edge=[0]*2
for i in a:
  x[i]+=1
  if x[i]==2:
    edge.append(i)
    x[i]=0
edge.sort(reverse=True)
print(edge[0]*edge[1])

n=int(input())
a=list(map(int,input().split()))
x={}
edge=[0]*2
for i in a:
  if i in x:
    x[i]+=1
    if x[i]==2:
      edge.append(i)
      x[i]=0
  else:
    x[i]=1
edge.sort(reverse=True)
print(edge[0]*edge[1])

Verdicts: Runtime Error

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
N=int(input())
import collections
A=list(map(int,input().split()))

table=collections.defaultdict(int)
for x in A:
  table[x]+=1
table=list(table.items())
table=[table[i][0] for  i in range(N) if table[i][1]>1]
table.append(0)
table.append(0)
table.sort(reverse=True)
print(table[0]*table[1])
      

import heapq
import collections
N = int(input())
A = list(map(int, input().split()))

table = collections.defaultdict(int)
hq = [0, 0]
for x in A:
    table[x] += 1
    if table[x] == 2:
        heapq.heappush(hq, -x)
        table[x] = 0
print(heapq.heappop(hq) * heapq.heappop(hq))


Verdicts: Runtime Error

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
input()
a=sorted(list(map(int,input().split())))
e=[1 for x in range(10**9+1)]
r=[]
for i in a:
  if e[i]:
    e[i]=0
  else:
    e[i]=1
    r.append(i)
print(0 if len(r) < 2 else r[-1] * r[-2])

input()
a=sorted(list(map(int,input().split())))
e={}
r=[]
for i in a:
  if not e.get(i):
    e[i]=1
  else:
    e[i]=0
    r.append(i)
print(0 if len(r) < 2 else r[-1] * r[-2])

Verdicts: Time Limit Exceeded

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a = Counter(a)
b = []
for i,j in a:
    if j >=4:
        b.append(i)
        b.append(i)
    elif j >= 2:
        b.append(i)
b.sort()
if len(b)>=2:
    print(b[-1]*b[-2])
else:
    print(0)

from collections import Counter
n = int(input())
l = list(map(int,input().split()))
a = Counter(l)
b = a.most_common()
c = []
for i,j in b:
    if j>=4:
        c.append(i)
        c.append(i)
    elif j>=2:c.append(i)
c.sort()
print(c[-1]*c[-2] if len(c)>=2 else 0)

Verdicts: Runtime Error

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
# Make a Rectangle
n = int(input())
a = list(map(int, input().split()))

sorted(a, reverse = True)
a.append(0)
a.append(0)
a.append(0)
a.append(0)
#print(a)

i = 0
s = 1
cnt=0
while i<n-1 and cnt <2:
    if (a[i]==a[i+1]):
        s*=a[i]
        i+=2
        cnt+=1
    else:
        i+=1
print(s)

# Make a Rectangle
n = int(input())
a = list(map(int, input().split()))

sorted(a, reverse = True)
a.append(0)
a.append(0)
a.append(0)
a.append(0)
#print(a)

i = 0
s = 1
cnt=0
while i<n-1 and cnt <2:
    if (a[i]==a[i+1]):
        s*=a[i]
        i+=2
        cnt+=1
    else:
        i+=1
print(s)

#Make a Rectangle
N = int(input())
A = list(map(int, input().split()))

a = sorted(A, reverse=True)
b = []

i = 0
while i<N-1:
    if ( a[i]==a[i+1] ):
        b+=[a[i]]
        i+=2
    else:
        i+=1
    if (len(b)>1):
        break

if (len(b)<2):
    print(0)
else:
    print(b[0]*b[1])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
a = int(input())
ar = list(map(int,input().split(" ")))
ar = sorted(ar,reverse=True)
A = 0
B = 0
j = 0
while True:
    if A != 0 and B != 0:
        break
    if j == a - 1:
        break
    if ar[j] == ar[j+1] and A == 0:
        A = ar[j]
        j += 1
    elif ar[j] == ar[j+1] and A != 0:
        B = ar[j]
        j += 1
    j += 1
    print(ar[j])
print(A * B)

import collections
a = int(input())
ar = list(map(int,input().split(" ")))
br = collections.Counter(ar)
cr = []
for k,v in br.items():
    if v >= 4:
        cr.append(k)
        cr.append(k)
    elif v >= 2:
        cr.append(k)
cr = sorted(cr,reverse=True)
if len(cr) < 2:
    print(0)
else:
    print(cr[0] * cr[1])

Verdicts: Runtime Error

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
from collections import Counter


N = int(input())
c = Counter(map(int, input().split()))
usables = sorted([(k, v) for k, v in c.items() if v >= 2])
if len(usables) <= 1:
    print(0)
else:
    if usables[-1][2] >= 4:
        print(usables[-1][1] ** 2)
    else:
        print(usables[-1][1] * usables[-2][1])


from collections import Counter


def solve():
    N = int(input())
    c = Counter(map(int, input().split()))
    usables = sorted([k for k, v in c.items() if v > 1])

    if len(usables) == 0:
        return 0
    else:
        ans = usables[-1]
        if c[ans] > 3:
            return ans ** 2
        elif len(usables) > 1:
            usables.pop()
            return ans * usables[-1]
        else:
            return 0


print(solve())


Verdicts: Runtime Error

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
N = int(input(()))
A = list(map(int, input().split()))

A.sort(reverse=True)
tmp = 0
tate = 0
yoko = 0
cnt = 0
for i in A:
    if tmp == i and cnt == 0:
        tate = i
        cnt += 1
        tmp = 0
        continue
    if tmp == i and cnt == 1:
        yoko = i
        cnt += 1
    if cnt == 2:
        break
    tmp = i
print(tate*yoko)

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

A.sort(reverse=True)
tmp = 0
tate = 0
yoko = 0
cnt = 0
for i in A:
    if tmp == i and cnt == 0:
        tate = i
        cnt += 1
        tmp = 0
        continue
    if tmp == i and cnt == 1:
        yoko = i
        cnt += 1
        break
    tmp = i
print(tate*yoko)

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

A.sort(reverse=True)
tmp = 0
tate = 0
yoko = 0
cnt = 0
for i in A:
    if tmp == i and cnt == 0:
        tate = i
        cnt += 1
        tmp = 0
        continue
    if tmp == i and cnt == 1:
        yoko = i
        cnt += 1
        break
    tmp = i

print(tate*yoko)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
a=list(map(int,input().split()))
from collections import Counter
ac=Counter(a)
v=sorted(ac.items(),reverse=1)
ans=[]
ans1=[]

for i in range(len(ac)):
  if v[i][1]>=2:
    ans.append(v[i][0])
  if v[i][1]>=4:
    ans1.append(v[i][0])
if len(ans)>=2:
  if len(ans1)>=1:
      print(max(ans[0]*ans[1],ans1[0]**2))
  else:
      print(ans[0]*ans[1])
else:
  if len(ans1)>=1:
      print(max(0,ans1[0]**2))
  else:
      print(0)


n=int(input())
a=list(map(int,input().split()))
from collections import Counter
ac=Counter(a)
v=sorted(ac.items(),reverse=1)
ans=[]
ans1=[]

for i in range(len(ac)):
  if v[i][1]>=2:
    ans.append(v[i][0])
  if v[i][1]>=4:
    ans1.append(v[i][0])
if len(ans)>=2:
  if len(ans1)>=1:
      print(max(ans[0]*ans[1],ans1[0]**2))
  else:
      print(ans[0]*ans[1])
else:
  if len(ans1)>=1:
      print(max(0,ans1[0]**2))
  else:
      print(0)

Verdicts: Wrong Answer

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
ans_lis = []
count = 1
before = A[0]
for i in range(1,N):
  tmp = A[i]
  if tmp == before:
    count += 1
  else:
    if count == 2 or count == 3:
      ans_lis.append(before)
    elif count >= 4 and len(ans_lis) == 0:
      ans_lis.append(before)
      ans_lis.append(before)
    count = 1
  if len(ans_lis) == 2:
    break
  before = tmp
if len(ans_lis) < 2:
  print(0)
else:
  print(ans_lis[0] * ans_lis[1])
  


N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
ans_lis = []
count = 1
before = A[0]
for i in range(1,N):
  tmp = A[i]
  if tmp == before:
    count += 1
  else:
    if count == 2 or count == 3:
      ans_lis.append(tmp)
    elif count >= 4 and len(ans_lis) == 0:
      ans_lis.append(tmp)
      ans_lis.append(tmp)
    count = 0
  if len(ans_lis) == 2:
    break
  before = tmp
if len(ans_lis) < 2:
  print(0)
else:
  print(ans_lis[0] * ans_lis[1])
  


N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
ans_lis = []
count = 1
before = A[0]
for i in range(1,N):
  tmp = A[i]
  if tmp == before:
    count += 1
  else:
    if count == 2 or count == 3:
      ans_lis.append(before)
    elif count >= 4 and len(ans_lis) == 0:
      ans_lis.append(before)
      ans_lis.append(before)
    elif count >= 4 and len(ans_lis) != 0:
      ans_lis.append(before)
    count = 1
  if len(ans_lis) == 2:
    break
  before = tmp
if len(ans_lis) < 2:
  print(0)
else:
  print(ans_lis[0] * ans_lis[1])
  


N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
ans_lis = []
count = 1
before = A[0]
for i in range(1,N):
  tmp = A[i]
  if tmp == before:
    count += 1
  else:
    if count == 2 or count == 3:
      ans_lis.append(tmp)
    elif count == 4 and len(ans_lis) == 0:
      ans_lis.append(tmp)
      ans_lis.append(tmp)
    count = 0
  if len(ans_lis) == 2:
    break
  before = tmp
if len(ans_lis) < 2:
  print(0)
else:
  print(ans_lis[0] * ans_lis[1])
  

N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
ans_lis = []
count = 1
before = A[0]
for i in range(1,N):
  tmp = A[i]
  if tmp == before:
    count += 1
  else:
    if count == 2 or count == 3:
      ans_lis.append(before)
    elif count >= 4 and len(ans_lis) == 0:
      ans_lis.append(before)
      ans_lis.append(before)
    elif count >= 4 and len(ans_lis) != 0:
      ans_lis.append(before)
    count = 1
  if len(ans_lis) == 2:
    break
  before = tmp
if len(ans_lis) == 0:
  if A[N-1] == A[N-2] and A[N-2] == A[N-3] and A[N-3] == A[N-4]:
    ans_lis.append(A[N-1])
    ans_lis.append(A[N-1])
elif len(ans_lis) == 1:
  if A[N-1] == A[N-2]:
    ans_lis.append(A[N-1])
if len(ans_lis) < 2:
  print(0)
else:
  print(ans_lis[0] * ans_lis[1])
  


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
N = int(input())
A = sorted(list(map(int, input().split())))
L = [0 for i in range(max(A) + 1)]
res = []
for a in A:
    L[a] += 1

for i, l in enumerate(L):
    if l > 4:
        res.append(i)
        res.append(i)
        break
    elif l > 2:
        res.append(i)
    else:
        res.append(0)

result = 1
for i in range(2):
    result *= sorted(res, reverse=True)[i]

print(result)


N = int(input())
A = sorted(list(map(int, input().split())) + [0, 0, 0, 0], reverse=True)

res = []
tmp = -1
for a in A:
    if a == tmp:
        res.append(a)
        tmp = -1
    else:
        tmp = a
    if len(res) >= 2:
        break

res = sorted(res, reverse=True)

result = 1
for i in range(2):
    result *= res[i]

print(result)


Verdicts: Wrong Answer

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
A = Counter(A).most_common()
A = sorted(A)[::-1]
cnt = 0
l = []
ans = [0]
for i, v in A:
  if v >= 4:
    ans.append(i*i)
  if 2<=v:
    cnt += 1
    l.append(i)
    if cnt == 2:
      ans.append(l[0]*l[1])
print(ans)  

from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
A = Counter(A).most_common()
A = sorted(A)[::-1]
cnt = 0
l = []
ans = [0]
for i, v in A:
  if v >= 4:
    ans.append(i*i)
  if 2<=v:
    cnt += 1
    l.append(i)
    if cnt == 2:
      ans.append(l[0]*l[1])
print(max(ans))  

Verdicts: Wrong Answer

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
A_dic = Counter(A)

if A_dic.most_common()[0][0] == 1:
    print(0)
    exit()

set_A = sorted((set(A)), reverse=True)
tmp = 0
for a in set_A:
    if A_dic[a] >= 4:
        print(a * a)
        exit()
    if A_dic[a] >= 2:
        ans = tmp * a
        if ans != 0:
            print(ans)
            exit()
        tmp = a

from collections import Counter

n = int(input())
A = list(map(int, input().split()))
A_dic = Counter(A)

set_A = sorted((set(A)), reverse=True)
tmp = 0
for a in set_A:
    if A_dic[a] >= 4:
        print(max(tmp*a, a*a))
        exit()
    if A_dic[a] >= 2:
        ans = tmp * a
        if ans != 0:
            print(ans)
            exit()
        tmp = a
print(0)


Verdicts: Wrong Answer

Accepted
Problem: We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Submission attempts (in order):
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
c_l = c.most_common()
if c_l[0][1] >= 2 and c_l[1][1] >= 2:
    ans1 = max(c_l[0][0],c_l[1][0])
    ans2 = min(c_l[0][0],c_l[1][0])
    for e in c_l:
        if e[0] > ans1:
            ans2 = ans1
            ans1 = e[0]
        elif e[0] > ans2:
            ans2 = e[0]
    print(ans1*ans2)
else:
    print(0)

from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)
op = []
for a, cnt in c.items():
    for _ in range(cnt // 2):
        op.append(a)
op.sort(reverse=True)
if len(op) < 2:
    print(0)
else:
    print(op[0]*op[1])

Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
import sys
n = int(input())
s1 = list(input())
s2 = list(input())

li = []
tmp = 1
if n == 1:
    print(3)
    sys.exit()
for i,s in enumerate(s1):
    
    if i == len(s1) - 1:
        break
    
    if s != s1[i+1]:
        li.append(tmp)
        tmp = 1
    
    else:
        tmp = 2
# print(li)
# [1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 
#  2, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2]
#print(li)
if s1[-1] == s1[-2]:
    li.append(2)
else:
    li.append(1)
#print(li)
#print(sum(li))
all_count = 1
for j,l in enumerate(li):
    if j == 0:
        all_count *= 3
        continue
    if l == 2 and li[j-1] == 2:
        all_count *= 3
    elif l == 1 and li[j-1] == 2:
        all_count *= 1
    else:
        all_count *= 2
print(all_count%1000000007)
#print(958681902)

import sys
n = int(input())
s1 = list(input())
s2 = list(input())

li = []
tmp = 1
if n == 1:
    print(3)
    sys.exit()
for i,s in enumerate(s1):
    
    if i == len(s1) - 1:
        break
    
    if s != s1[i+1]:
        li.append(tmp)
        tmp = 1
    
    else:
        tmp = 2
# print(li)
# [1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 
#  2, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2]
#print(li)
if s1[-1] == s1[-2]:
    li.append(2)
else:
    li.append(1)
#print(li)
#print(sum(li))
all_count = 1
for j,l in enumerate(li):
    if j == 0:
        if li[0] == 2: 
            all_count *= 6
        else:
            all_count *= 3
        continue
    if l == 2 and li[j-1] == 2:
        all_count *= 3
    elif l == 1 and li[j-1] == 2:
        all_count *= 1
    else:
        all_count *= 2
print(all_count%1000000007)
#print(958681902)




Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
MOD = pow(10,9)+7
N = int(input())
S = str(input())
T = str(input())
if N == 1:
  print(3)
  exit()
now = 0
if S[now] != T[now]: 
  now = 2
  ans = 6
  Flag = True
else: 
  now = 1
  ans = 3
  Flag = False

while now <= N-1:
  if S[now] != T[now]: 
    if Flag:
      ans = 3*ans%MOD
    else:
      Flag = True
    now += 2
  else: 
    now += 1
    ans = 2*ans%MOD
    Flag = False
print(ans)

MOD = pow(10,9)+7
N = int(input())
S = str(input())
T = str(input())
if N == 1:
  print(3)
  exit()
now = 0
if S[now] != T[now]: 
  now = 2
  ans = 6
  Flag = True
else: 
  now = 1
  ans = 3
  Flag = False

while now <= N-1:
  if S[now] != T[now]: 
    if Flag: 
      ans = 3*ans%MOD
    else: 
      ans = 2*ans%MOD
    Flag = True
    now += 2
  else: 
    if Flag: 
      ans *= 1
    else: 
      ans = 2*ans%MOD
    Flag = False
    now += 1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
N=int(input())
S1=input()
S2=input()
dominos=[]
index=0
while index<N:
    if S1[index]==S2[index]:
        dominos.append(0)
        index+=1
    else:
        dominos.append(1)
        index+=2
start=3
for k,c in enumerate(dominos):
    if k==0:continue
    elif dominos[k-1]==0:
        start*=2
    elif c:start*=3
    start%=10**9+7
print(start)

N=int(input())
S1=input()
S2=input()
dominos=[]
index=0
while index<N:
    if S1[index]==S2[index]:
        dominos.append(0)
        index+=1
    else:
        dominos.append(1)
        index+=2
if dominos[0]==0:start=3
else:start=6
for k,c in enumerate(dominos):
    if k==0:continue
    elif dominos[k-1]==0:
        start*=2
    elif c:start*=3
    start%=10**9+7
print(start)

Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
n = int(input())
s1 = input() + " "
s2 = input() + " "

mod = 1000000007

num = 1
i = 0
b = 0
tmp_t = -1
while(b + i < n):
    if s1[i + b] == s2[i + b]: # t 0
        if tmp_t == 0:
            num = (num * 2) % mod
        elif tmp_t == 1:
            num = (num * 2) % mod
        else:
            num = 3
        tmp_t = 0
    else: # t 1
        if tmp_t == 0:
            num = (num * 1) % mod
        elif tmp_t == 1:
            num = (num * 3) % mod
        else:
            num = 6
        tmp_t = 1
        b += 1
    i += 1

print(num)


n = int(input())
s1 = input() + " "
s2 = input() + " "
 
mod = 1000000007
 
num = 1
i = 0
b = 0
tmp_t = -1
while(b + i < n):
    if s1[i + b] == s2[i + b]: # t 0
        if tmp_t == 0:
            num = (num * 2) % mod
        elif tmp_t == 1:
            num = (num * 1) % mod
        else:
            num = 3
        tmp_t = 0
    else: # t 1
        if tmp_t == 0:
            num = (num * 2) % mod
        elif tmp_t == 1:
            num = (num * 3) % mod
        else:
            num = 6
        tmp_t = 1
        b += 1
    i += 1
 
print(num)

Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
N = int(input())
S1 = input()
S2 = input()
mod = 10**9+7

if S1[0] != S2[0]:
  ans = 6
else:
  ans = 3
  
i=1
while i<N:
  if S1[i] != S2[i]:
    if S1[i-1] != S2[i-1]:
      ans *= 3
    else:
      ans *= 2
    i += 2
    
  else:
    if S1[i-1] != S2[i-1]:
      pass
    else:
      ans *= 2
    i += 1
  ans = ans%mod
  
print(ans)

N = int(input())
S1 = input()
S2 = input()
mod = 10**9+7

if S1[0] != S2[0]:
  ans = 6
  i = 2
else:
  ans = 3
  i = 1
  
while i<N:
  if S1[i] != S2[i]:
    if S1[i-1] != S2[i-1]:
      ans *= 3
    else:
      ans *= 2
    i += 2
    
  else:
    if S1[i-1] != S2[i-1]:
      pass
    else:
      ans *= 2
    i += 1
  ans = ans%mod
  
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
n = int(input())
s1 = input()
s2 = input()
l = []
m = 3
mod = 10**9 + 7

after = False
for i in range(n):
	if i == n-1:
		if after:
			pass
		else:
			l.append(0)
	else:
		if after:
			after = False
			pass
		else:
			if s1[i] == s1[i+1]:
				l.append(1)
				after = True
			else:
				l.append(0)

print(l)

for i, x in enumerate(l):
	if i == 0:
		pass
	else:
		if x == 0 and l[i-1] == 0:
			m = m * 2
		elif x == 0 and l[i-1] == 1:
			m = m * 2
		elif x == 1 and l[i-1] == 0:
			pass
		else:
			m = m * 3

print(m % mod)

n = int(input())
s1 = input()
s2 = input()
l = []
m = 1
mod = 10**9 + 7

after = False
for i in range(n):
	if i == n-1:
		if after:
			pass
		else:
			l.append(0)
	else:
		if after:
			after = False
			pass
		else:
			if s1[i] == s1[i+1]:
				l.append(1)
				after = True
			else:
				l.append(0)

for i, x in enumerate(l):
	if i == 0:
		if x == 0:
			m = 3
		else:
			m = 6 
	else:
		if x == 0 and l[i-1] == 0:
			m = m * 2
			m = m % mod
		elif x == 0 and l[i-1] == 1:
			m = m * 2
			m = m % mod
		elif x == 1 and l[i-1] == 0:
			pass
		else:
			m = m * 3
			m = m % mod

print(m)

n = int(input())
s1 = input()
s2 = input()
l = []
m = 1
mod = 10**9 + 7

after = False
for i in range(n):
	if i == n-1:
		if after:
			pass
		else:
			l.append(0)
	else:
		if after:
			after = False
			pass
		else:
			if s1[i] == s1[i+1]:
				l.append(1)
				after = True
			else:
				l.append(0)

for i, x in enumerate(l):
	if i == 0:
		if x == 0:
			m = 3
		else:
			m = 6 
	else:
		if x == 0 and l[i-1] == 0:
			m = m * 2
			m = m % mod
		elif x == 1 and l[i-1] == 0:
			m = m * 2
			m = m % mod
		elif x == 0 and l[i-1] == 1:
			pass
		else:
			m = m * 3
			m = m % mod

print(m)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
N=int(input())
S=list(input())
T=list(input())
state=[]
lim=1000000007
i=0
while i<=N:
    if S[i] == T[i]:
        state.append(0)
        i+=1
    else:
        state.append(1)
        i+=2
ans=3    
for i in range(1,len(state)):
    if state[i] == 1 and state[i-1] == 1:
        ans = (ans * 3) % lim
    elif state[i] == 1 and state[i-1] == 0:
        ans = (ans * 2) % lim
    elif state[i] == 0 and state[i-1] == 1:
        pass
    elif state[i] == 0 and state[i-1] == 0: 
        ans = (ans * 2) % lim
print(ans)

N=int(input())
S=list(input())
T=list(input())
state=[]
lim=1000000007
i=0
while i<N:
    if S[i] == T[i]:
        state.append(0)
        i+=1
    else:
        state.append(1)
        i+=2
ans=3    
for i in range(1,len(state)):
    if state[i] == 1 and state[i-1] == 1:
        ans = (ans * 3) % lim
    elif state[i] == 1 and state[i-1] == 0:
        ans = (ans * 2) % lim
    elif state[i] == 0 and state[i-1] == 1:
        pass
    elif state[i] == 0 and state[i-1] == 0: 
        ans = (ans * 2) % lim
print(ans)

N=int(input())
S=list(input())
T=list(input())
state=[]
lim=1000000007
i=0
while i<N:
    if S[i] == T[i]:
        state.append(0)
        i+=1
    else:
        state.append(1)
        i+=2
ans=3    
for i in range(1,len(state)):
    if state[i] == 1 and state[i-1] == 1:
        ans = (ans * 3) % lim
    elif state[i] == 1 and state[i-1] == 0:
        ans = (ans * 2) % lim
    elif state[i] == 0 and state[i-1] == 1:
        pass
    elif state[i] == 0 and state[i-1] == 0: 
        ans = (ans * 2) % lim
print(ans)

N=int(input())
S=list(input())
T=list(input())
state=[]
lim=1000000007
i=0
while i<N:
    if S[i] == T[i]:
        state.append(0)
        i+=1
    else:
        state.append(1)
        i+=2
if state[0]==0:
    ans=3
else:
    ans=6
for i in range(1,len(state)):
    if state[i] == 1 and state[i-1] == 1:
        ans = (ans * 3) % lim
    elif state[i] == 1 and state[i-1] == 0:
        ans = (ans * 2) % lim
    elif state[i] == 0 and state[i-1] == 1:
        pass
    elif state[i] == 0 and state[i-1] == 0: 
        ans = (ans * 2) % lim
print(ans)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
from itertools import*
input()
mod=10**9+7
x=[[s,len(list(t))]for s,t in groupby(len(list(v))for k,v in groupby(input()))]
#print(x)
if x[0][0]==1:
    ans=3
else:
    ans=6
for s,t in x:
    if s==1:
        ans*=2**(t-1)%mod
    else:
        ans*=2*3**(t-1)%mod

print(ans%mod)

from itertools import*
input()
mod=10**9+7
x=[[s,len(list(t))]for s,t in groupby(len(list(v))for k,v in groupby(input()))]
#print(x)
if x[0][0]==1:
    ans=3
else:
    ans=6
for s,t in x:
    if s==1 and t>1:
        ans*=2**(t-1)%mod
    elif s==2:
        ans*=2*3**(t-1)%mod
print(ans%mod)

from itertools import*
input()
mod=10**9+7

x=[len(list(v))for k,v in groupby(input())]
if x[0]==1:
    ans=3
else:
    ans=6
if len(x)==1:
    print(ans)
else:
    for i in range(1,len(x)):
        if x[i-1]==1 and x[i]==1:
            ans*=2%mod
        elif x[i-1]==2 and x[i]==2:
            ans*=3%mod
        elif x[i-1]==1 and x[i]==2:
            ans*=2%mod
    print(ans%mod)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
N = int(input())
S1 = input()
S2 = input()
ans = 1
mod = 10**9+7
cnt = 0
former = 0 

if S1[0] == S2[0]:
    cnt += 1
    ans = 3
else:
    cnt += 2
    ans = 6

while cnt < N:
    if S1[cnt] == S2[cnt]:
        if former:
            ans *= 1
        else:
            ans *= 2
        ans %= mod
        former = 0
        cnt += 1
    else:
        if former:
            ans *= 3
        else:
            ans *= 2
        former = 1
        cnt += 2
        ans %= mod
print(ans)

N = int(input())
S1 = input()
S2 = input()
ans = 1
mod = 10**9+7
cnt = 0
former = 0 
 
if S1[0] == S2[0]:
    cnt += 1
    ans = 3
    former = 0
else:
    cnt += 2
    ans = 6
    former = 1
 
while cnt < N:
    if S1[cnt] == S2[cnt]:
        if former:
            ans *= 1
        else:
            ans *= 2
        ans %= mod
        former = 0
        cnt += 1
    else:
        if former:
            ans *= 3
        else:
            ans *= 2
        former = 1
        cnt += 2
        ans %= mod
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
n=int(input())
s1=input()
s2=input()
mod=10**9+7

def rle(string):
    rle_str = string[0]
    rle_cnt = 1
    ans_l = []
    for i in range(1, len(string)):
        if rle_str == string[i]:
            rle_cnt += 1
        else:
            ans_l.append([rle_str, rle_cnt])
            rle_str = string[i]
            rle_cnt = 1
    ans_l.append([rle_str, rle_cnt])
    return ans_l

rle_s=rle(s1)

if rle_s[0][1]==1:
    ans=3
    left=1
elif rle_s[0][1]==2:
    ans=6
    left=1

for s, i in rle_s[1:]:
    if left==1 and i==1:
        ans*=2
    elif left==1 and i==2:
        ans*=2
    elif left==2 and i==1:
        ans*=1
    elif left==2 and i==2:
        ans*=3
    left=i

print(ans%mod)


n=int(input())
s1=input()
s2=input()
mod=10**9+7

def rle(string):
    rle_str = string[0]
    rle_cnt = 1
    ans_l = []
    for i in range(1, len(string)):
        if rle_str == string[i]:
            rle_cnt += 1
        else:
            ans_l.append([rle_str, rle_cnt])
            rle_str = string[i]
            rle_cnt = 1
    ans_l.append([rle_str, rle_cnt])
    return ans_l

rle_s=rle(s1)

if rle_s[0][1]==1:
    ans=3
    left=1
elif rle_s[0][1]==2:
    ans=6
    left=2

for s, i in rle_s[1:]:
    if left==1 and i==1:
        ans*=2
    elif left==1 and i==2:
        ans*=2
    elif left==2 and i==1:
        ans*=1
    elif left==2 and i==2:
        ans*=3
    left=i

print(ans%mod)


Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
def pop_when_x():
    S1.pop(0)
    S2.pop(0)
    global left_state
    left_state = "X"


def pop_when_y():
    S1.pop(0)
    S1.pop(0)
    S2.pop(0)
    S2.pop(0)
    global left_state
    left_state = "Y"


if __name__ == '__main__':
    N = int(input())
    S1 = list(input())
    S2 = list(input())

    if S1[0] == S2[0]:
        cases = 3
        left_state = "X"
        pop_when_x()
    else:
        cases = 6
        left_state = "Y"
        pop_when_y()

    while len(S1) != 0:
        print("".join(S1))
        print("".join(S2))
        if S1[0] == S2[0]:
            state = "X"
        else:
            state = "Y"
        print("left_state:" + left_state)
        print("state:" + state)
        if left_state == "X" and state == "X":
            cases *= 2
            pop_when_x()
        elif left_state == "X" and state == "Y":
            cases *= 2
            pop_when_y()
        elif left_state == "Y" and state == "X":
            cases *= 1
            pop_when_x()
        elif left_state == "Y" and state == "Y":
            cases *= 3
            pop_when_y()

    print(cases)


def pop_when_x():
    S1.pop(0)
    S2.pop(0)
    global left_state
    left_state = "X"


def pop_when_y():
    S1.pop(0)
    S1.pop(0)
    S2.pop(0)
    S2.pop(0)
    global left_state
    left_state = "Y"


if __name__ == '__main__':
    N = int(input())
    S1 = list(input())
    S2 = list(input())

    if S1[0] == S2[0]:
        cases = 3
        left_state = "X"
        pop_when_x()
    else:
        cases = 6
        left_state = "Y"
        pop_when_y()

    while len(S1) != 0:
        # print("".join(S1))
        # print("".join(S2))
        # print(cases)
        if S1[0] == S2[0]:
            state = "X"
        else:
            state = "Y"
        # print("left_state:" + left_state)
        # print("state:" + state)
        if left_state == "X" and state == "X":
            cases *= 2
            pop_when_x()
        elif left_state == "X" and state == "Y":
            cases *= 2
            pop_when_y()
        elif left_state == "Y" and state == "X":
            cases *= 1
            pop_when_x()
        elif left_state == "Y" and state == "Y":
            cases *= 3
            pop_when_y()

    print(cases % 1000000007)


Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
n=int(input())
s1=list(input())
s2=list(input())

ans=3
for i in range(n-1):
    if s1[i]==s2[i]:
        ans*=2
    else:
        if s1[i]==s1[i+1]:
            continue
        else:
            if s1[i+1]!=s2[i+1]:
                ans*=3
            else:
                ans*=1
print(ans%1000000007)

n=int(input())
s1=list(input())
s2=list(input())
ans=0
if s1[0]==s2[0]:
    ans=3
else:
    ans=6
for i in range(n-1):
    if s1[i]==s2[i]:
        ans*=2
    else:
        if s1[i]==s1[i+1]:
            continue
        else:
            if s1[i+1]!=s2[i+1]:
                ans*=3
            else:
                ans*=1
print(ans%1000000007)

Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
N = int(input())
s1 = input()
s2 = input()
ans = 1
being_horizontal = False
was_horizontal = False
was_vertical = False
MOD = 10**9+7
for i in range(N):

    if not was_horizontal and not being_horizontal and not was_vertical: 
        ans *= 3
        if s1[i] != s2[i]:
            being_horizontal = True
        else:
            was_vertical = True
    elif being_horizontal:
        being_horizontal = False
        was_horizontal = True
    elif was_horizontal and s1[i] == s2[i]:
        was_vertical = True
    elif was_horizontal and s1[i] != s2[i]:
        ans *= 3
        being_horizontal = True
        was_horizontal = False
    elif was_vertical and s1[i] == s2[i]:
        ans *= 2
        was_vertical = True
    elif was_vertical and s1[i] != s2[i]:
        ans *= 3
        was_vertical = False
        being_horizontal = True
    ans %= MOD
print(ans)

N = int(input())
s1 = input()
s2 = input()
ans = 1
being_horizontal = False
was_horizontal = False
was_vertical = False
MOD = 10**9+7
for i in range(N):

    if not was_horizontal and not being_horizontal and not was_vertical: 
        if s1[i] != s2[i]:
            ans *= 6
            being_horizontal = True
        else:
            ans *= 3
            was_vertical = True
    elif being_horizontal:
        being_horizontal = False
        was_horizontal = True
    elif was_horizontal and s1[i] == s2[i]:
        was_horizontal = False
        was_vertical = True
    elif was_horizontal and s1[i] != s2[i]:
        ans *= 3
        being_horizontal = True
        was_horizontal = False
    elif was_vertical and s1[i] == s2[i]:
        ans *= 2
        was_vertical = True
    elif was_vertical and s1[i] != s2[i]:
        ans *= 2
        was_vertical = False
        being_horizontal = True
    ans %= MOD
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.  Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.  Find the number of such ways to paint the dominoes, modulo 1000000007.  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:    * Each domino is represented by a different English letter (lowercase or uppercase).   * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Submission attempts (in order):
n = int(input())
a = input()
b = input()

ans = 3
i = 0
if a[0] != b[0]:
    i += 1

while i < n-1:
    if a[i]==b[i]:
        if a[i+1]==b[i+1]:
            ans *= 2
        else:
            ans *= 2
            i += 1
    else:
        if a[i+1]==b[i+1]:
            ans *= 1
        else:
            ans *= 3
            i += 1
    i += 1
    ans %= 1000000007
print(ans)


n = int(input())
a = input()
b = input()

ans = 3
i = 0
if a[0] != b[0]:
    i += 1
    ans += 3

while i < n-1:
    if a[i]==b[i]:
        if a[i+1]==b[i+1]:
            ans *= 2
        else:
            ans *= 2
            i += 1
    else:
        if a[i+1]==b[i+1]:
            ans *= 1
        else:
            ans *= 3
            i += 1
    i += 1
    ans %= 1000000007
print(ans)



Verdicts: Wrong Answer

Accepted