Language: C++

use proconio::input;

const MOD:i64 = 1_000_000_007;

enum Tree {
    Node {
        left:Box<Tree>,
        right:Box<Tree>,
        val:i64
    },
    Leaf
}

use Tree::{Node,Leaf};

impl Tree {

    fn add_impl(&mut self,v:usize,l:usize,r:usize,vtar:usize,x:i64) -> i64{
        match self {
            Leaf => {
                *self = Node {
                    left: Box::new(Leaf),
                    right: Box::new(Leaf),
                    val:0
                };
            }
            _ => {}
        };
        if r-l==1 {
            if let Node{left:_,right:_,val} = self {
                *val = (*val + x*v as i64)%MOD;
            }
            (x*v as i64)%MOD
        }
        else {
            let tmp = {
                if let Node{left,right,val:_} = self {
                    let mid = (l+r)/2;
                    if vtar<mid {
                        left.add_impl(v*2,l,mid,vtar,x)
                    }
                    else {
                        right.add_impl(v*2+1,mid,r,vtar,x)
                    }
                }
                else {
                    panic!()
                }
            };
            if let Node{left:_,right:_,val} = self {                
                *val = (*val + tmp*v as i64)%MOD;
            };
            (tmp*v as i64)%MOD
        }
    }

    fn add(&mut self,h:usize,vtar:usize,x:i64) {
        self.add_impl(1,0,1<<(h-1),vtar,x);
    }

    fn dfs_impl(&self,i:usize,dep:usize,l:usize,r:usize,xs:&Vec<i64>) -> i64{
        match self{
            Node{left,right,val} => {
                // eprintln!("$$ {} {} {}",i,l,r);
                if i<l {
                    // eprintln!("$#$ {} {} {}",i,val,xs[dep]);
                    val*xs[dep]%MOD
                }
                else if r<=i+1 {
                    0
                }
                else {
                    let mid = (l+r)/2;
                    let ansl = left.dfs_impl(i,dep+1,l,mid,xs);
                    let ansr = right.dfs_impl(i,dep+1,mid,r,xs);
                    (ansl+ansr)%MOD
                }
            }
            Leaf => 0
        }
    }
    fn dfs(&self,i:usize,h:usize,xs:&Vec<i64>) -> i64 {
        self.dfs_impl(i,0,0,1<<(h-1),xs)
    }

    
}

fn main() {
    input! {
        h:usize,
        p:[usize;1<<(h-1)]
    };


    let mut tr = Vec::new();
    for _ in 0..(1<<h) {
        tr.push(Leaf)
    }


    let l = 1<<(h-1);

    for i in 0..l {
        let y = l+p[i]-1;
        let mut z = y;
        let mut r = 1;
        while z>1 {
            r=(r*z as i64)%MOD;
            tr[z].add(h,i,r);
            z/=2;
        }
    }

    let mut ans = 0;
    for i in 0..l {
        let x = l+i;
        let y = l+p[i]-1;

        let xs = {
            let mut xs = vec![0;h+1];
            xs[h] = x as i64;
            let mut x= x;
            for i in (1..h).rev() {
                x/=2;
                xs[i] = xs[i+1]*x as i64%MOD;
            }
            xs
        };

        let mut z = y;
        let mut r = y as i64;
        // println!("# {} {} {} {:?}",i,x,y,xs);
        while z>1 {
            let par = z/2;
            r=(r*par as i64)%MOD;
            let sc = r*tr[z^1].dfs(i,h,&xs);
            // println!("{} {} {}",i,z,ans);
            ans = (ans+sc)%MOD;
            z = par;
        }
    }

    println!("{}",ans);

}

Compiler output:
a.cc:97:14: error: too many decimal points in number
   97 |     for _ in 0..(1<<h) {
      |              ^~~
a.cc:104:14: error: too many decimal points in number
  104 |     for i in 0..l {
      |              ^~~~
a.cc:116:14: error: too many decimal points in number
  116 |     for i in 0..l {
      |              ^~~~
a.cc:124:23: error: too many decimal points in number
  124 |             for i in (1..h).rev() {
      |                       ^~~~
a.cc:1:1: error: 'use' does not name a type
    1 | use proconio::input;
      | ^~~
a.cc:3:10: error: found ':' in nested-name-specifier, expected '::'
    3 | const MOD:i64 = 1_000_000_007;
      |          ^
      |          ::
a.cc:3:7: error: 'MOD' does not name a type
    3 | const MOD:i64 = 1_000_000_007;
      |       ^~~
a.cc:6:10: error: expected '}' before '{' token
    6 |     Node {
      |          ^
a.cc:5:11: note: to match this '{'
    5 | enum Tree {
      |           ^
a.cc:6:10: error: expected unqualified-id before '{' token
    6 |     Node {
      |          ^
a.cc:10:6: error: expected unqualified-id before ',' token
   10 |     },
      |      ^
a.cc:12:1: error: expected constructor, destructor, or type conversion before '}' token
   12 | }
      | ^
a.cc:12:1: error: expected declaration before '}' token
a.cc:14:1: error: 'use' does not name a type
   14 | use Tree::{Node,Leaf};
      | ^~~
a.cc:16:1: error: 'impl' does not name a type
   16 | impl Tree {
      | ^~~~
a.cc:89:1: error: 'fn' does not name a type
   89 | fn main() {
      | ^~