Language: C++

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s1;
string s2;
int n;
const int inf = 1000000007;
int ans;
int prev;
void same()
{
    if(prev == 1){
        ans = ans * 2;
    }
    if(prev == 0){
        ans = ans * 3;
    }
    prev = 1;
    s1.erase(s1.size() - 1, 1);
    s2.erase(s2.size() - 1, 1);
    ans = ans % inf;
}

void dif()
{
    if(prev == 2){
        ans = ans * 3;
    }
    if(prev == 1){
        ans = ans * 2;
    }
    if(prev == 0){
        ans = ans * 6;
    }
    prev = 2;
    s1.erase(s1.size() - 1, 1);
    s1.erase(s1.size() - 1, 1);
    s2.erase(s2.size() - 1, 1);
    s2.erase(s2.size() - 1, 1);
    ans = ans % inf;
}
    

int main()
{
    prev = 0;
    ans = 1;
    cin >> n >> s1 >> s2;
    while(s1.size() != 0){
        if(s1[s1.size() - 1] == s2[s2.size() - 1])
        {
            same();
        } else {
            dif();
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void same()':
a.cc:13:8: error: reference to 'prev' is ambiguous
   13 |     if(prev == 1){
      |        ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:10:5: note:                 'int prev'
   10 | int prev;
      |     ^~~~
a.cc:16:8: error: reference to 'prev' is ambiguous
   16 |     if(prev == 0){
      |        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:10:5: note:                 'int prev'
   10 | int prev;
      |     ^~~~
a.cc:19:5: error: reference to 'prev' is ambiguous
   19 |     prev = 1;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:10:5: note:                 'int prev'
   10 | int prev;
      |     ^~~~
a.cc: In function 'void dif()':
a.cc:27:8: error: reference to 'prev' is ambiguous
   27 |     if(prev == 2){
      |        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:10:5: note:                 'int prev'
   10 | int prev;
      |     ^~~~
a.cc:30:8: error: reference to 'prev' is ambiguous
   30 |     if(prev == 1){
      |        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:10:5: note:                 'int prev'
   10 | int prev;
      |     ^~~~
a.cc:33:8: error: reference to 'prev' is ambiguous
   33 |     if(prev == 0){
      |        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:10:5: note:                 'int prev'
   10 | int prev;
      |     ^~~~
a.cc:36:5: error: reference to 'prev' is ambiguous
   36 |     prev = 2;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:10:5: note:                 'int prev'
   10 | int prev;
      |     ^~~~
a.cc: In function 'int main()':
a.cc:47:5: error: reference to 'prev' is ambiguous
   47 |     prev = 0;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:10:5: note:                 'int prev'
   10 | int prev;
      |     ^~~~