Buggy python submission (verdict: Runtime Error):
def solve(l):
    for i in range(l,L):
        if S[i] == '1': return (2*solve(i+1) + pow(3,L-1-i,mod)) %mod
    return 1
mod = 10**9+7
S = input()
L = len(S)
print(solve(0))


Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7

def solve(l):
    tmp = 0
    tmpS = ''
    for i in range(l,L):
        if S[i] == '1':
            return (2*solve(i+1) + pow(3,L-1-i,mod))%mod
    else:
        return 1

S = input()
L = len(S)
print(solve(0)%mod)

Buggy python submission (verdict: Runtime Error):
def solve(l):
    for i in range(l,L):
        if S[i] == '1': return 2*solve(i+1) + pow(3,L-1-i,mod) %mod
    return 1
mod = 10**9+7
S = input()
L = len(S)
print(solve(0))


Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7

def solve(l):
    tmp = 0
    tmpS = ''
    for i in range(l,L):
        if S[i] == '1':
            return (2*solve(i+1) + pow(3,L-1-i,mod))%mod
    else:
        return 1

S = input()
L = len(S)
print(solve(0)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = input()


def solve(S,L):
    tmp = 0
    tmpS = ''
    for i,s in enumerate(S):
        if s == '1':
            tmpS = S[i+1:]
            tmp =  L - 1 - i
            break
    else:
        return 1

    return (2*solve(tmpS,tmp) + solve_bin(tmp))%mod

def solve_bin(b):
    return pow(3,b,mod)

print(solve(S,len(S))%mod)


Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7

def solve(l):
    tmp = 0
    tmpS = ''
    for i in range(l,L):
        if S[i] == '1':
            return (2*solve(i+1) + pow(3,L-1-i,mod))%mod
    else:
        return 1

S = input()
L = len(S)
print(solve(0)%mod)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = input()


def solve(S):
    tmp = 0
    tmpS = ''
    for i,s in enumerate(S):
        if s == '1':
            tmpS = S[i+1:]
            tmp =  L - 1 - i
            break
    else:
        return 1

    return (2*solve(tmpS) + solve_bin(tmp))%mod

def solve_bin(b):
    return pow(3,b,mod)

print(solve(S)%mod)


Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7

def solve(l):
    tmp = 0
    tmpS = ''
    for i in range(l,L):
        if S[i] == '1':
            return (2*solve(i+1) + pow(3,L-1-i,mod))%mod
    else:
        return 1

S = input()
L = len(S)
print(solve(0)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = input()

def solve(S):
    L = len(S)

    tmp = 0
    tmpS = ''
    for i in range(L):
        if S[i] == '1':
            tmpS = S[i+1:]
            tmp =  L - 1 - i
            break
    else:
        return 1

    return (2*solve(tmpS) + solve_bin(tmp))%mod

def solve_bin(b):
    return pow(3,b,mod)

print(solve(S)%mod)


Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7

def solve(l):
    tmp = 0
    tmpS = ''
    for i in range(l,L):
        if S[i] == '1':
            return (2*solve(i+1) + pow(3,L-1-i,mod))%mod
    else:
        return 1

S = input()
L = len(S)
print(solve(0)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = input()

def solve(S):
    L = len(S)
    if L == 0 or int(S) == 0:
        return 1

    tmp = 0
    tmpS = ''
    for i in range(L):
        if S[i] == '1':
            tmpS = S[i+1:]
            tmp =  L - 1 - i
            break


    return (2*solve(tmpS) + solve_bin(tmp))%mod

def solve_bin(b):
    return pow(3,b,mod)

print(solve(S)%mod)


Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7

def solve(l):
    tmp = 0
    tmpS = ''
    for i in range(l,L):
        if S[i] == '1':
            return (2*solve(i+1) + pow(3,L-1-i,mod))%mod
    else:
        return 1

S = input()
L = len(S)
print(solve(0)%mod)