Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int
D = dict()

def powmod(a, n, m):
    L = [1 for _ in range(n+1)]
    for i in range(n):
        L[i+1] = L[i] * a % m
    return L

def solve(L: str):
    p = len(L)
    pm = powmod(3, p, MOD)
    
    D['0'] = 1
    D['1'] = 3
    s = ''
    for i, c in enumerate(L[::-1]):
        s_next = c + s
        if len(s_next) == 1:
            s = s_next
            continue
        if c == '0':
            D[s_next] = D[s]
        else:
            D[s_next] = (pm[i] + D[s] * 2) % MOD
        s = s_next
    print(D[L])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)  # type: int
    solve(L)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def powmod(a, n, m):
    L = [1 for _ in range(n+1)]
    for i in range(n):
        L[i+1] = L[i] * a % m
    return L

def solve(L: str):
    p = len(L)
    pm = powmod(3, p, MOD)
    
    s = ''
    for i, c in enumerate(L[::-1]):
        if i == 0:
            if c == '1':
                res = 3
            else:
                res = 1
            continue
        
        if c == '0':
            res = res
        else:
            res = (pm[i] + res * 2) % MOD
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)  # type: int
    solve(L)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int
D = dict()


def solve(L: str):
    p = len(L)
    
    D['0'] = 1
    D['1'] = 3
    s = ''
    for i, c in enumerate(L[::-1]):
        s_next = c + s
        if len(s_next) == 1:
            s = s_next
            continue
        if c == '0':
            D[s_next] = D[s]
        else:
            D[s_next] = (pow(3, i, MOD) + D[s] * 2) % MOD
        s = s_next
    print(D[L])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)  # type: int
    solve(L)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def powmod(a, n, m):
    L = [1 for _ in range(n+1)]
    for i in range(n):
        L[i+1] = L[i] * a % m
    return L

def solve(L: str):
    p = len(L)
    pm = powmod(3, p, MOD)
    
    s = ''
    for i, c in enumerate(L[::-1]):
        if i == 0:
            if c == '1':
                res = 3
            else:
                res = 1
            continue
        
        if c == '0':
            res = res
        else:
            res = (pm[i] + res * 2) % MOD
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)  # type: int
    solve(L)

if __name__ == '__main__':
    main()