Buggy python submission (verdict: Time Limit Exceeded):
l=input()
mod=pow(10,9)+7
import sys
sys.setrecursionlimit(10**7)

def func(li):
  if '0' not in li:
    return pow(3,len(li),mod)
  elif len(li)==1:
    if li=='1':
      return 3
    else:
      return 1
  elif li[0]=='0':
    return func(li[1:])%mod
  else:
    ret=(2*func(li[1:]))%mod
    ret+=pow(3,len(li)-1,mod)
    return ret%mod
print(func(l))


Fixed submission:
l=input()
n=len(l)
mod=pow(10,9)+7
import sys
sys.setrecursionlimit(10**7)
#dp1,dp2=[0]*n,[0]*n
dp1,dp2=0,1
for i in range(n):
  if l[i]=='0':
    dp1*=3
  else:
    dp1*=3
    dp1+=dp2
    dp2*=2
  dp1%=mod
  dp2%=mod
print((dp1+dp2)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
l=input()
mod=pow(10,9)+7
import sys
sys.setrecursionlimit(10**7)

def func(li):
  if '0' not in li:
    return pow(3,len(li),mod)
  elif len(li)==1:
    if li=='1':
      return 3
    else:
      return 1
  elif li[0]=='0':
    return func(li[1:])%mod
  else:
    ret=(2*func(li[1:]))%mod
    ret+=func('1'*(len(li)-1))%mod
    return ret%mod
print(func(l))


Fixed submission:
l=input()
n=len(l)
mod=pow(10,9)+7
import sys
sys.setrecursionlimit(10**7)
#dp1,dp2=[0]*n,[0]*n
dp1,dp2=0,1
for i in range(n):
  if l[i]=='0':
    dp1*=3
  else:
    dp1*=3
    dp1+=dp2
    dp2*=2
  dp1%=mod
  dp2%=mod
print((dp1+dp2)%mod)

Buggy python submission (verdict: Runtime Error):
l=input()
mod=pow(10,9)+7

def func(li):
  if '0' not in li:
    return pow(3,len(li),mod)
  elif len(li)==1:
    if li=='1':
      return 3
    else:
      return 1
  elif li[0]=='0':
    return func(li[1:])%mod
  else:
    ret=(2*func(li[1:]))%mod
    ret+=func('1'*(len(li)-1))%mod
    return ret%mod
print(func(l))


Fixed submission:
l=input()
n=len(l)
mod=pow(10,9)+7
import sys
sys.setrecursionlimit(10**7)
#dp1,dp2=[0]*n,[0]*n
dp1,dp2=0,1
for i in range(n):
  if l[i]=='0':
    dp1*=3
  else:
    dp1*=3
    dp1+=dp2
    dp2*=2
  dp1%=mod
  dp2%=mod
print((dp1+dp2)%mod)

Buggy python submission (verdict: Runtime Error):
l=input()
mod=pow(10,9)+7

def func(li):
  if '0' not in li:
    return pow(3,len(li),mod)
  elif len(li)==1:
    if li=='1':
      return 3
    else:
      return 1
  elif li[0]=='0':
    return func(li[1:])%mod
  else:
    ret=(2*func(li[1:]))%mod
    ret+=func('1'*(len(li)-1))%mod
    return ret%mod
print(func(l))


Fixed submission:
l=input()
n=len(l)
mod=pow(10,9)+7
import sys
sys.setrecursionlimit(10**7)
#dp1,dp2=[0]*n,[0]*n
dp1,dp2=0,1
for i in range(n):
  if l[i]=='0':
    dp1*=3
  else:
    dp1*=3
    dp1+=dp2
    dp2*=2
  dp1%=mod
  dp2%=mod
print((dp1+dp2)%mod)

Buggy python submission (verdict: Runtime Error):
l=input()
mod=pow(10,9)+7

def func(li):
  if '0' not in li:
    return pow(3,len(li),mod)
  if len(li)==1:
    if li=='1':
      return 3
    else:
      return 1
  if li[0]=='0':
    return func(li[1:])
  else:
    ret=(2*func(li[1:]))%mod
    ret+=func('1'*(len(li)-1))
    return ret%mod
print(func(l))


Fixed submission:
l=input()
n=len(l)
mod=pow(10,9)+7
import sys
sys.setrecursionlimit(10**7)
#dp1,dp2=[0]*n,[0]*n
dp1,dp2=0,1
for i in range(n):
  if l[i]=='0':
    dp1*=3
  else:
    dp1*=3
    dp1+=dp2
    dp2*=2
  dp1%=mod
  dp2%=mod
print((dp1+dp2)%mod)