qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for x in range(N + 1)]
def ok(sec4):
  for i in range(4):
    tem = sec4
    if i >= 1:
      tem[i - 1], tem[i] = tem[i], tem[i - 1]  
    if tem[:3] == "AGC" or tem[1:] == "AGC":
      return False
  return True
def dfs(cur, last3):
  if last3 in memo[cur]:
    return memo[cur][last3]
  if cur == N:
    return 1
  ret = 0
  for s in "AGCT":
    if ok(last3 + s):
      ret = ret + dfs(cur + 1, last3[1:] + s)
  memo[cur][last3] = ret
  return ret
print(dfs(0, "TTT") % MOD)

Fixed code:
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for x in range(N + 1)]
def ok(sec4):
  for i in range(4):
    tem = list(sec4)
    if i >= 1:
      tem[i - 1], tem[i] = tem[i], tem[i - 1]
    tem2 = "".join(tem)  
    if tem2[:3] == "AGC" or tem2[1:] == "AGC":
      return False
  return True
def dfs(cur, last3):
  if last3 in memo[cur]:
    return memo[cur][last3]
  if cur == N:
    return 1
  ret = 0
  for s in "AGCT":
    if ok(last3 + s):
      ret = ret + dfs(cur + 1, last3[1:] + s)
  memo[cur][last3] = ret
  return ret
print(dfs(0, "TTT") % MOD)
Buggy code:
def dfs(index, last, string, memo):
    mod = 10 ** 9 + 7
    if string in memo[index]:
        return memo[index][string]
    if index == last:
        return 1

    ret = 0
    for s in "ACGT":
        if check(string + s):
            ret = (ret + dfs(index + 1, last, string[1:] + s, memo)) % mod
    memo[index][string] = ret
    return ret


def check(string):
    for i in range(4):
        s_list = list(string)
        if i >= 1:
            s_list[i-1], s_list[i] = s_list[i], s_list[i-1]
        if "".join(s_list).count("AGC") >= 1:
            return False
    return True


def main():
    n = int(input())
    memo = [{} for _ in range(n+1)]

    ans = dfs(0, n, "TTT", memo)
    print(memo)
    print(ans)


if __name__ == "__main__":
    main()

Fixed code:
def dfs(index, last, string, memo):
    mod = 10 ** 9 + 7
    if string in memo[index]:
        return memo[index][string]
    if index == last:
        return 1

    ret = 0
    for s in "ACGT":
        if check(string + s):
            ret = (ret + dfs(index + 1, last, string[1:] + s, memo)) % mod
    memo[index][string] = ret
    return ret


def check(string):
    for i in range(4):
        s_list = list(string)
        if i >= 1:
            s_list[i-1], s_list[i] = s_list[i], s_list[i-1]
        if "".join(s_list).count("AGC") >= 1:
            return False
    return True


def main():
    n = int(input())
    memo = [{} for _ in range(n+1)]

    ans = dfs(0, n, "TTT", memo)
    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
def ok(last4):
	for i in range(4):
		t = list(last4)
		if i >= 1:
			t[i], t[i - 1] = t[i - 1], t[i]
		if ''.join(t).count('AGC') >= 1:
			return False
	return True

def dfs(cur, last3):
	if last3 in memo[cur]:
		return memo[cur][last3]
	if cur == n:
		return 1
	ret = 0
	for c in "AGCT":
		if ok(last3 + c):
			ret = ret + dfs(cur + 1, last3[1:] + c) % mod
	memo[cur][last3] = ret
	return ret


n = int(input())
mod = 10 ** 9 + 7
memo = [{} for i in range(n + 1)]

print(dfs(0, 'TTT'))

Fixed code:
n = int(input())
mod = 10**9+7
memo = [{} for _ in range(n+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i],t[i-1] = t[i-1],t[i]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur,last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == n:
        return 1
    ret = 0
    for i in 'ACGT':
        if ok(last3 + i):
            ret = (ret + dfs(cur+1,last3[1:]+i)) % mod
    memo[cur][last3] = ret
    return ret

print(dfs(0,'TTT'))
Buggy code:
n = int(input())
dp = [[[[0 for i in range(4)] for i in range(4)] for i in range(4)] for i in range(n+1)]

#A=0, C=1, G=2, T=3
for i in range(4):
    for j in range(4):
        for k in range(4):
            dp[3][i][j][k] = 1

dp[3][0][2][1] = 0
dp[3][0][1][2] = 0
dp[3][2][0][1] = 0

for i in range(4, n+1):
    for a in range(4):
        for b in range(4):
            for c in range(4):
                for d in range(4):
                    if [b,c,d] not in ([0,2,1],[2,0,1],[0,1,2]):
                        if [a,c,d] != [0,2,1] and [a,b,d] != [0,2,1]:
                                dp[i][b][c][d] += dp[i-1][a][b][c]
                                
count = 0
for i in range(4):
    for j in range(4):
            count += sum(dp[n][i][j]) % (10**9+7)
print(count)

Fixed code:
n = int(input())
dp = [[[[0 for i in range(4)] for i in range(4)] for i in range(4)] for i in range(n+1)]

#A=0, C=1, G=2, T=3
for i in range(4):
    for j in range(4):
        for k in range(4):
            dp[3][i][j][k] = 1

dp[3][0][2][1] = 0
dp[3][0][1][2] = 0
dp[3][2][0][1] = 0

for i in range(4, n+1):
    for a in range(4):
        for b in range(4):
            for c in range(4):
                for d in range(4):
                    if [b,c,d] not in ([0,2,1],[2,0,1],[0,1,2]):
                        if [a,c,d] != [0,2,1] and [a,b,d] != [0,2,1]:
                                dp[i][b][c][d] += dp[i-1][a][b][c]
                                
count = 0
for i in range(4):
    for j in range(4):
            count = (count + sum(dp[n][i][j])) % (10**9+7)
print(count)
Buggy code:
N=int(input())
dp=[[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4) ]for _ in range(N+1)]
P=10**9+7

dp[0][3][3][3]=1

for len in range(N):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for a in range(4):
                    if j==0 and k==2 and a==1:continue
                    if j==0 and k==1 and a==2:continue
                    if j==2 and k==0 and a==1:continue
                    if i==0 and k==2 and a==1:continue
                    if i==0 and j==2 and a==1:continue
                    dp[len+1][j][k][a]+=dp[len][i][j][k]%P

ans=0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans+=dp[N][i][j][k]
print(ans)

Fixed code:
N=int(input())
dp=[[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4) ]for _ in range(N+1)]
P=10**9+7

dp[0][3][3][3]=1

for len in range(N):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for a in range(4):
                    if j==0 and k==2 and a==1:continue
                    if j==0 and k==1 and a==2:continue
                    if j==2 and k==0 and a==1:continue
                    if i==0 and k==2 and a==1:continue
                    if i==0 and j==2 and a==1:continue
                    dp[len+1][j][k][a]+=dp[len][i][j][k]
                    dp[len+1][j][k][a]%=P

ans=0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans+=dp[N][i][j][k]
            ans%=P
print(ans)
Buggy code:
a=b=c=d=e=f=0;g=1;exec('a,b,c,d,e,f,g=b,e,e-d,f,g,g-c,(g*4-b-c-d-a*3))%(10**9+7);'*int(input()));print(g)

Fixed code:
a=b=c=d=e=f=0;g=1;exec('a,b,c,d,e,f,g=b,e,e-d,f,g,g-c,(g*4-(b+c+d+a*3))%(10**9+7);'*int(input()));print(g)
Buggy code:
a,g,a_,a__,ac,ga,al=[0]*6+[1]
for i in range(int(input())):
    a__,a_,ac,ga,a,g,al=a_,a,a-ga,g,al,al-ac,(al*4-(ag+ac+ga+a__*3))%(pow(10,9)+7)
print(al)


Fixed code:
a,g,a_,a__,ac,ga,al=[0]*6+[1]
for i in range(int(input())):
    a__,a_,ac,ga,a,g,al=a_,a,a-ga,g,al,al-ac,(al*4-(a_+ac+ga+a__*3))%(pow(10,9)+7)
print(al)
Buggy code:
n = int(input())
dp = [[[[0 for _ in range(4)]for _ in range(4)]for _ in range(4)]for _ in range(n+1)]
dp[0][3][3][3]=1
for i in range(1,n+1):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for m in range(4):
                    if m==0 and l==1 and k==2: continue
                    elif k==0 and l==2 and m==1: continue
                    elif k==0 and l==1 and m==2: continue
                    elif j==0 and l==2 and m==1: continue
                    elif j==0 and k==2 and m==1: continue
                    else: dp[i][k][l][m]+=dp[i-1][j][k][l]
ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[-1][i][j][k]
print(ans%(10**9+7))

Fixed code:
n = int(input())
dp = [[[[0 for _ in range(4)]for _ in range(4)]for _ in range(4)]for _ in range(n+1)]
dp[0][3][3][3]=1
for i in range(n):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for m in range(4):
                    if k==0 and l==2 and m==1: continue
                    elif k==2 and l==0 and m==1: continue
                    elif k==0 and l==1 and m==2: continue
                    elif j==0 and l==2 and m==1: continue
                    elif j==0 and k==2 and m==1: continue
                    else: dp[i+1][k][l][m]+=dp[i][j][k][l]
ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[n][i][j][k]
print(ans%(10**9+7))
Buggy code:
N = int(input())

mod = 10 ** 9 + 7

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

dp[0][3][3][3] = 1

print(dp)
for i in range(N):
    for j in range(4):
        for k in range(4):
            for m in range(4):
                if dp[i][j][k][m] == 0:
                    continue
                for l in range(4):
                    if l == 2 and j == 1 and k == 0:
                        continue
                    if l == 2 and j == 0 and k == 1:
                        continue
                    if l == 1 and j == 2 and k == 0:
                        continue
                    if l == 2 and j == 1 and m == 0:
                        continue
                    if l == 2 and k == 1 and m == 0:
                        continue
                    dp[i + 1][l][j][k] += dp[i][j][k][m]
                    dp[i + 1][l][j][k] %= mod

ans = 0
print(dp)
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[N][i][j][k]
            ans %= mod
print(ans)


Fixed code:
mod = 10**9+7
N = int(input())
dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
dp[0][3][3][3] = 1

for i in range(N):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                if(dp[i][j][k][l] == 0): continue
                for a in range(4):
                    if(a == 2 and l == 1 and k == 0): continue
                    if(a == 1 and l == 2 and k == 0): continue
                    if(a == 2 and l == 0 and k == 1): continue
                    if(a == 2 and l == 1 and j == 0): continue
                    if(a == 2 and k == 1 and j == 0): continue
                    dp[i+1][k][l][a] += dp[i][j][k][l]
                    dp[i+1][k][l][a] %= mod
ans = 0
for j in range(4):
    for k in range(4):
        for l in range(4):
            ans += dp[N][j][k][l]
            ans %= mod

print(ans)
Buggy code:
import numpy as np
N = int(input())
mod = 10**9+7

dp = np.zeros((N+1, 4, 4, 4))
dp[0][3][3][3] = 1

for i in range(N):
  for c1 in range(4):
    for c2 in range(4):
      for c3 in range(4):        
        for new in range(4):
          if new == 2 and c1 == 1 and c2 == 0:
            continue
          if new == 2 and c1 == 0 and c2 == 1:
            continue
          if new == 1 and c1 == 2 and c2 == 0:
            continue
          if new == 2 and c1 == 1 and c3 == 0:
            continue
          if new == 2 and c2 == 1 and c3 == 0:
            continue
          dp[i+1][new][c1][c2] += dp[i][c1][c2][c3]

res = 0
for c1 in range(4):
  for c2 in range(4):
    for c3 in range(4):        
      res += dp[N][c1][c2][c3]

print(int(res%mod))

Fixed code:
import numpy as np
N = int(input())
mod = 10**9+7
 
dp = np.zeros((N+1, 4, 4, 4))
dp[0][3][3][3] = 1
 
for i in range(N):
  for c1 in range(4):
    for c2 in range(4):
      for c3 in range(4):        
        for new in range(4):
          if new == 2 and c1 == 1 and c2 == 0:
            continue
          if new == 2 and c1 == 0 and c2 == 1:
            continue
          if new == 1 and c1 == 2 and c2 == 0:
            continue
          if new == 2 and c1 == 1 and c3 == 0:
            continue
          if new == 2 and c2 == 1 and c3 == 0:
            continue
          dp[i+1][new][c1][c2] += dp[i][c1][c2][c3]
          dp[i+1][new][c1][c2] %= mod


res = 0

for c1 in range(4):
  for c2 in range(4):
    for c3 in range(4):        
      res += dp[N][c1][c2][c3]
 
print(int(res%mod))
Buggy code:
N = int(input())
mod = 10 ** 9 + 7
D = [[[[0] * 4 for i in range(4)] for i in range(4)] for i in range(101)]

D[0][3][3][3] = 1
for i in range(N):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for x in range(4):
                    if k == 0 and l == 1 and x == 2:
                        continue
                    if k == 0 and l == 2 and x == 1:
                        continue
                    if k == 1 and l == 0 and x == 2:
                        continue
                    if j == 0 and l == 1 and x == 2:
                        continue
                    if j == 0 and k == 1 and x == 2:
                        continue
                    D[i + 1][k][l][x] += D[i][j][k][l] % mod
                    D[i + 1][k][l][x] %= mod
                    
ans = 0
for j in range(4):
    for k in range(4):
        for l in range(4):
            ans += D[N][j][k][l]
                    
print(ans)

Fixed code:
N = int(input())
mod = 10 ** 9 + 7
D = [[[[0] * 4 for i in range(4)] for i in range(4)] for i in range(101)]

D[0][3][3][3] = 1
for i in range(100):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for x in range(4):
                    if k == 0 and l == 1 and x == 2:
                        continue
                    if k == 0 and l == 2 and x == 1:
                        continue
                    if k == 1 and l == 0 and x == 2:
                        continue
                    if j == 0 and l == 1 and x == 2:
                        continue
                    if j == 0 and k == 1 and x == 2:
                        continue
                    D[i + 1][k][l][x] += D[i][j][k][l] % mod
                    D[i + 1][k][l][x] %= mod
                    
ans = 0
for j in range(4):
    for k in range(4):
        for l in range(4):
            ans += D[N][j][k][l]
            ans %= mod
                    
print(ans)
Buggy code:
N = int(input())
mod = 10 ** 9 + 7
D = [{} for i in range(N + 1)]

def check(last4):
    t = list(last4)
    for i in range(4):
        if i >= 1:
            t[i], t[i - 1] = t[i - 1], t[i]
        if ''.join(t).count('AGC') == 1:
            return False
    return True
    
def dfs(cur, last3):
    if last3 in D[cur]:
        return D[cur][last3]
    if cur == N:
        return 1
    res = 0
    for c in 'ACGT':
        if check(last3 + c):
            res = (res + dfs(cur + 1, last3[1:] + c)) % mod
    D[cur][last3] = res
    return res
    
print(dfs(0, '000'))

Fixed code:
N = int(input())
mod = 10 ** 9 + 7
D = [{} for i in range(N + 1)]

def check(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True
    
def dfs(cur, last3):
    if last3 in D[cur]:
        return D[cur][last3]
    if cur == N:
        return 1
    res = 0
    for c in 'ACGT':
        if check(last3 + c):
            res = (res + dfs(cur + 1, last3[1:] + c)) % mod
    D[cur][last3] = res
    return res
    
print(dfs(0, '000'))
Buggy code:
N = int(input())
mod = 1000000000+7

import numpy as np
dp=np.zeros((N+1, 4, 4, 4), dtype=np.int64)

dp[0,3,3,3] = 1
for length in range(N):
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                if dp[length, c1, c2, c3]==0:
                    continue
                for a in range(4):
                    if a==2 and c1==1 and c2==0:
                        continue
                    if a==2 and c1==0 and c2==1:
                        continue
                    if a==1 and c1==2 and c2==0:
                        continue
                    if a==2 and c1==1 and c3==0:
                        continue
                    if a==2 and c2==1 and c3==0:
                        continue     
                    dp[length+1, a, c1, c2] += dp[length, c1, c2, c3] 
                    dp[length+1, a, c1, c2] %= mod
print(dp[N].sum())

Fixed code:
N = int(input())
mod = 1000000000+7

import numpy as np
dp=np.zeros((N+1, 4, 4, 4), dtype=np.int64)

dp[0,3,3,3] = 1
for length in range(N):
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                if dp[length, c1, c2, c3]==0:
                    continue
                for a in range(4):
                    if a==2 and c1==1 and c2==0:
                        continue
                    if a==2 and c1==0 and c2==1:
                        continue
                    if a==1 and c1==2 and c2==0:
                        continue
                    if a==2 and c1==1 and c3==0:
                        continue
                    if a==2 and c2==1 and c3==0:
                        continue     
                    dp[length+1, a, c1, c2] += dp[length, c1, c2, c3] 
                    dp[length+1, a, c1, c2] %= mod
print(dp[N].sum()%mod)
Buggy code:
iimport re
import functools

N = int(input())
MOD = 10 ** 9 + 7


@functools.lru_cache(maxsize=2**13)
def dfs(cur, last3):
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if not re.match('.AGC|.ACG|.GAC|A.GC|AG.C', last3 + c):
            ret += dfs(cur + 1, last3[1:] + c)
    return ret % MOD


print(dfs(0, 'TTT'))

Fixed code:
import re
import functools

N = int(input())
MOD = 10 ** 9 + 7


@functools.lru_cache(maxsize=None)
def dfs(cur, last3):
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if not re.match('.AGC|.ACG|.GAC|A.GC|AG.C', last3 + c):
            ret += dfs(cur + 1, last3[1:] + c)
    return ret % MOD


print(dfs(0, 'TTT'))
Buggy code:
n = int(input())
p = 10**9 + 7
def check(L4):
  for i in range(4):
    t = list(L4)
    if i > 0:
      t[i], t[i-1] = t[i-1], t[i]
    if "".join(t).count("AGC") >= 1:
      return False
  return True
def dfs(d, L3):
  if d >= n:
    return 1
  ret = 0
  for L in list("ACGT"):
    L4 = "".join([L3, L])
    if check(L4):
      ret += dfs(d + 1, L4[1:])
  return ret
    
  
  
print(dfs(0, "TTT"))

Fixed code:
n = int(input())
p = 10**9 + 7
memo = [{} for _ in range(n+1)]
def check(L4):
  for i in range(4):
    t = list(L4)
    if i > 0:
      t[i], t[i-1] = t[i-1], t[i]
    if "".join(t).count("AGC") >= 1:
      return False
  return True
def dfs(d, L3):
  if L3 in memo[d]:
    return memo[d][L3]
  if d >= n:
    return 1
  ret = 0
  for L in list("ACGT"):
    L4 = L3 + L
    if check(L4):
      ret += dfs(d + 1, L4[1:]) 
    memo[d][L3] = ret
  return ret % p
    
  
  
print(dfs(0, "TTT"))
Buggy code:
n=int(input())

def swap(a,b):
    c=[i for i in a]
    c[b],c[b+1]=c[b+1],c[b]
    return "".join(c)

def ok(a):
    if "AGC" in swap(a,0) or "AGC" in swap(a,1) or "AGC" in swap(a,2) or "AGC" in a:
        return False
    return True

if n==1:
    print(4)
elif n==2:
    print(16)
else:
    a={}
    for i in "ACGT":
        for j in "ACGT":
            for k in "ACGT":
                if not i+j+k in ["AGC","ACG","CGA"]:
                    a[i+j+k]=1
    for q in range(n-3):
        b={}
        for i in a:
            for j in "ACGT":
                if ok(i+j):
                    w=i[1:]+j
                    if w in b:
                        b[w]+=a[i]
                    else:
                        b[w]=a[i]
        a=dict(b)
    al=0
    for i in a:
        al+=a[i]
    print(al%(10**9+7))


Fixed code:
n=int(input())

def swap(a,b):
    c=[i for i in a]
    c[b],c[b+1]=c[b+1],c[b]
    return "".join(c)

def ok(a):
    if "AGC" in swap(a,0) or "AGC" in swap(a,1) or "AGC" in swap(a,2) or "AGC" in a:
        return False
    return True

if n==1:
    print(4)
elif n==2:
    print(16)
else:
    a={}
    for i in "ACGT":
        for j in "ACGT":
            for k in "ACGT":
                if not i+j+k in ["AGC","ACG","GAC"]:
                    a[i+j+k]=1
    for q in range(n-3):
        b={}
        for i in a:
            for j in "ACGT":
                if ok(i+j):
                    w=i[1:]+j
                    if w in b:
                        b[w]+=a[i]
                    else:
                        b[w]=a[i]
        a=dict(b)
    al=0
    for i in a:
        al+=a[i]
    print(al%(10**9+7))
Buggy code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip())
MOD =10**9+7
MEMO = [{} for _ in range(N+1)]
ACGT = "ACGT"
ACG = ["ACG","AGC","CAG","ATCG","ACTG","ACCG"]

def acg_check(last4):
  for acg in ACG:
    if acg in last4:
      return False
  return True

def func(length, last3):
  if last3 in MEMO[length]:
    return MEMO[length][last3]
  if length == N:
    return 1

  ans = 0
  for c in ACGT:
    if len(last3)==3:
      if acg_check(last3+c):
        ans += func(length+1,last3[1:]+c)%MOD
    else:
      if acg_check(last3+c):
        ans += func(length+1,last3+c)%MOD
  MEMO[length][last3] = ans
  return ans

print(func(0,""))

Fixed code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip())
MOD =10**9+7
MEMO = [{} for _ in range(N+1)]
ACGT = "ACGT"
ACG = ["ACG","AGC","CAG","ATCG","ACTG","ACCG"]

def acg_check(last4):
  for acg in ACG:
    if acg in last4:
      return False
  return True

def func(length, last3):
  if last3 in MEMO[length]:
    return MEMO[length][last3]
  if length == N:
    return 1

  ans = 0
  for c in ACGT:
    if len(last3)==3:
      if acg_check(last3+c):
        ans += func(length+1,last3[1:]+c)%MOD
    else:
      if acg_check(last3+c):
        ans += func(length+1,last3+c)%MOD
  MEMO[length][last3] = ans
  return ans

print(func(0,"")%MOD)
Buggy code:
#x=int(input())
n=int(input())
m=102
chars=['A','T','C','G']
mo=10**9+7
d4=set()
for i in chars:
    for j in chars:
        for k in chars:
            for l in chars:
                d4.add(i+j+k+l)
                
kinsoku4=set()
kinsoku3=['AGC','ACG','GAC']
for y in chars:
    kinsoku4.add('AG'+y+'C')
    kinsoku4.add('A'+y+'GC')
    for z in kinsoku3:
        kinsoku4.add(y+z)
        kinsoku4.add(z+y)


dp=[dict() for i in range(m)]
cnt=[0]*m
for s in d4:
    dp[3][s]=1
    

t=101
for i in range(4,t):
    for ch in chars:
        for p in dp[i-1].keys():
            if p[1:4]+ch not in kinsoku4:
                if p[1:4]+ch in dp[i]:
                    dp[i][p[1:4]+ch]+=dp[i-1][p]%mo
                else:
                    dp[i][p[1:4]+ch]=dp[i-1][p]%mo
for i in range(t):
    for x in d4:
        if x not in kinsoku4 and x in dp[i]:
            cnt[i]+=dp[i][x]%mo
    cnt[i]%=mo

#print(len(kinsoku4),kinsoku4)
#print(dp)

#for x in cnt:
    #print(x%mo)

if n==3:
    ans=63
    print(ans)
else:
    print(cnt[n-1])
#print(cnt)



Fixed code:
#x=int(input())
n=int(input())
m=102
chars=['A','T','C','G']
mo=10**9+7
d3=set()
d4=set()
for i in chars:
    for j in chars:
        for k in chars:
            d3.add(i+j+k)
            for l in chars:
                d4.add(i+j+k+l)
        
kinsoku4=set()
kinsoku3=['AGC','ACG','GAC']

for y in chars:
    kinsoku4.add('AG'+y+'C')
    kinsoku4.add('A'+y+'GC')
    for z in kinsoku3:
        kinsoku4.add(y+z)
        kinsoku4.add(z+y)


dp=[dict() for i in range(m)]
cnt=[0]*m
for i in d4:
    if i not in kinsoku4:
        dp[4][i]=1
    

t=101
for i in range(4,t):
    for ch in chars:
        for p in dp[i-1].keys():
            if p[1:4]+ch not in kinsoku4:
                if p[1:4]+ch in dp[i]:
                    dp[i][p[1:4]+ch]+=dp[i-1][p]%mo
                else:
                    dp[i][p[1:4]+ch]=dp[i-1][p]%mo
for i in range(t):
    for x in d4:
        if x not in kinsoku4 and x in dp[i]:
            cnt[i]+=dp[i][x]%mo
    cnt[i]%=mo

#print(len(kinsoku4),kinsoku4)
#print(dp)

#for x in cnt:
    #print(x%mo)

if n==3:
    ans=61
    print(ans)
else:
    print(cnt[n])