#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int power(int a, int b){
  if(b == 0) return 1;
  if(b == 1) return a % mod;
  if(b % 2 == 0){
    int y = power(a, b / 2);
    return y * y % mod;
  }else return power(a, b - 1) * a % mod;
}
void solve()
{
  int n, k; cin >> n >> k;
  auto rec = [&](auto&& rec, int i, int j) -> int{
    if(i == 1) return 1;
    if(j % 2) return rec(rec, i - 1, j / 2 + 1);
    else return (rec(rec, i - 1, j / 2) + power(2, i - 1)) % mod;
  };
  cout << rec(rec, n, k);
}
 
signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int t = 1; //cin >> t;
  while(t--){
    solve();
    cout << endl;
  }
  return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |