codeparrot/codecomplex huggingface dataset:
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long x = in.nextLong();
            long k = in.nextLong();
            long max2 = (((x % 1_000_000_007) * (pb(k))) % 1_000_000_007) % 1_000_000_007;
            long min2 = ((((x - 1) % 1_000_000_007) * pb(k)) % 1_000_000_007 + 1) % 1_000_000_007;
            if (x == 0) min2 = 0;
            out.println((max2 + min2) % 1_000_000_007);
        }

        long pb(long a) {
            if (a == 0) return 1;
            if (a == 1) return 2;
            long tmp = pb(a / 2);
            if (a % 2 == 0) return (tmp * tmp) % 1_000_000_007;
            return (((tmp * tmp) % 1_000_000_007) * 2) % 1_000_000_007;
        }

    }

    static class InputReader {
        private StringTokenizer tokenizer;
        private BufferedReader reader;

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

        private void fillTokenizer() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }

        public String next() {
            fillTokenizer();
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Solution {
    
    private static final long MODULUS = 1000000007;
    private static final boolean DEBUG = false;

    private static long modularPow(long base, long exponent, long modulus) {
        long result = 1;
        while (exponent > 0) {
            if (exponent % 2 == 1) {
               result = (result * base) % modulus;
            }
            exponent >>= 1;
            base = (base * base) % modulus;
        }
        return result;
    }

    public static void main(String[] args) throws FileNotFoundException {
        long beginTime = System.nanoTime();
        InputStream is = DEBUG ? new FileInputStream("resources/codeforcesedu43/ProblemC-1.in") : System.in;
        try (Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(is)))) {
            long x = scanner.nextLong();
            long k = scanner.nextLong();
            if (x != 0) {
                x = (2 * x - 1) % MODULUS;
                long twoPowK = modularPow(2, k, MODULUS);
                x = (x * twoPowK + 1) % MODULUS;
            }
            System.out.println(x % 1000000007);
        }
        System.err.println( "Done in " + ((System.nanoTime() - beginTime) / 1e9) + " seconds.");
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Contest {

	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s=br.readLine().split(" ");
		BigInteger x = new BigInteger(s[0]);
		BigInteger k = new BigInteger(s[1]);

		BigInteger mod = new BigInteger(String.valueOf((int) (Math.pow(10, 9) + 7)));

		BigInteger two = new BigInteger("2");
		BigInteger interm = two.modPow(k, mod);

		BigInteger res = interm.multiply(x).add(interm.multiply(x)).subtract(interm).add(BigInteger.ONE).mod(mod);

		if(x.equals(BigInteger.ZERO)) {
			System.out.println("0");
			return;
		}
		System.out.println(res);
	}

}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import javax.swing.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class A {

    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        long x = scanner.nextLong();
        long k = scanner.nextLong();
        if (x==0) {
            System.out.println("0");
            return;
        }
        BigInteger M = BigInteger.valueOf(1000_000_000L+7);
        BigInteger modus = BigInteger.valueOf(x).multiply(BigInteger.valueOf(2)).subtract(BigInteger.ONE).mod(M);
        BigInteger operandi = BigInteger.valueOf(2).modPow(BigInteger.valueOf(k), M);
        BigInteger result = modus.multiply(operandi).mod(M).add(BigInteger.ONE).mod(M);
        System.out.println(result);
    }

    public static long gcd(long a, long b) {
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static long lcm(long a, long b, long gcd) {
        return a * (b / gcd);
    }


    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.awt.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;


public class main {
	
	static long d,x,y;
	public static void main(String[] args) {
		FastScanner in = new FastScanner();
	    
		long x = in.nextLong(), k = in.nextLong();
		
		long mod = 1000000007;
		
		long one = pow(2,k,mod);
		
		one %= mod;
		
		long two = (2*x)%mod-1;
		
		two %= mod;
		
		long ans = (one*two)%mod+1;
		
		ans %= mod;
		
		if(ans<0)
			ans += mod;
		
		if(x==0)
			System.out.println("0");
		else
			System.out.println(ans);
	        
	}
	private static long pow(long a, long b, long mod) {
		if(b==0) return 1;
		
		if(b==1)
			return a;
		
		if(b%2==0)
			return pow((a*a)%mod,b/2,mod);
		else
			return (a*pow((a*a)%mod,(b-1)/2,mod))%mod;
		
	}
	
	

	

}










class FastScanner {
	BufferedReader br;
	StringTokenizer st;
	
	public FastScanner() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
	
	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}
	
	int nextInt() {
		return Integer.parseInt(next());
	}
	
	long nextLong() {
		return Long.parseLong(next());
	}
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn

import java.util.Scanner;

public class CF489_C {
	static long mod = 1000000007;

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long x = s.nextLong(), k = s.nextLong();
		if (x == 0) {
			System.out.println(0);
			return;
		}
		long max = x % mod;
		long temp = power(2, k, mod);
		temp %= mod;
		max = (max % mod) * (temp % mod);
		max %= mod;
		long min = max % mod;
		min = mod(min - (temp - 1));
		min %= mod;
		long num = mod(max - min + 1);
		long n = num % mod;
		n = (n % mod) * (min % mod + max % mod);
		n = n % mod;
		n %= mod;
		long ans = n % mod * modInverse(num, mod);
		System.out.println(ans % mod);

	}

	static long modInverse(long a, long m) {
		long m0 = m;
		long y = 0, x = 1;

		if (m == 1)
			return 0;

		while (a > 1) {
			// q is quotient
			long q = a / m;
			long t = m;

			// m is remainder now, process same as
			// Euclid's algo
			m = a % m;
			a = t;
			t = y;

			// Update y and x
			y = x - q * y;
			x = t;
		}

		// Make x positive
		if (x < 0)
			x += m0;

		return x;
	}

	static long mod(long val) {
		val %= mod;
		if (val < 0)
			val += mod;
		return val;
	}

	static long power(long x, long y, long p) {
		// Initialize result
		long res = 1;

		// Update x if it is more
		// than or equal to p
		x = x % p;

		while (y > 0) {
			// If y is odd, multiply x
			// with result
			if ((y & 1) == 1)
				res = (res * x) % p;

			// y must be even now
			// y = y / 2
			y = y >> 1;
			x = (x * x) % p;
		}
		return res;
	}

}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.*;
import java.util.StringTokenizer;

public class C {

    static final int MOD = (int)1e9 + 7;

    public static void main(String[] args) throws IOException {

        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        long x = sc.nextLong(), k = sc.nextLong();
        if(x == 0)
            out.println(0);
        else
            out.println(((x % MOD * 2 - 1 + MOD) % MOD * modPow(2, k) % MOD + 1) % MOD);
        out.close();
    }

    static long modPow(long b, long e) {
        long res = 1;
        while(e > 0) {
            if((e & 1) == 1)
                res = res * b % MOD;
            b = b * b % MOD;
            e >>= 1;
        }

        return res;
    }

    static class Scanner
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}

        public long nextLong() throws IOException {return Long.parseLong(next());}

        public double nextDouble() throws IOException { return Double.parseDouble(next()); }

        public String nextLine() throws IOException {return br.readLine();}

        public boolean ready() throws IOException { return br.ready(); }

    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.util.*;
import java.io.*;

// Solution

public class Main 
{    
  public static void main (String[] argv) 
  {
	  new Main();
  } 
     
     
  
  boolean test = false;  
  int n;
  
  long mod = 1000000007;
  public Main() {
	  FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
	  //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in")));
      long x = in.nextLong();
      long k = in.nextLong();
      
      if (x == 0) {
          System.out.println(0);
          return;
      }
      
      if (k == 0) {
          x %= mod;
          System.out.println((2*x%mod));
          return;
      }
      
      x %= mod;
      
      long f = pow(2, k);
      long ans = ((2 * f * x % mod - f + 1) % mod + mod) % mod;
      
      System.out.println(ans);
     
  }
  
  private long pow(long x, long y) {
      long ans = 1;
      while (y > 0) {
          if (y % 2 == 1) 
              ans = ans * x % mod;
          x = x * x % mod;
          y /= 2;
      }
      return ans;
  }
  
  private long gcd(long x, long y) {
      if (y == 0) return x;
      return gcd(y, x % y);
  }
  private int max(int a, int b) {
      return a >  b ? a : b;
  }
  
  private int min(int a, int b) {
      return a >  b ? b : a;
  }
  
  
  static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader(BufferedReader in)
        {            
            br = in;
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    String line = br.readLine();
                    if (line == null || line.length() == 0) return "";
                    st = new StringTokenizer(line);
                }
                catch (IOException  e)
                {
                    return "";
                    //e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                return "";
                //e.printStackTrace();
            }
            return str;
        }
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn

public class Main {


  private static void solve() {
    long x = nl();
    long k = nl();
    long mod = 1000000000 + 7;
    
    if (x == 0) {
      System.out.println(0);
    } else if (k == 0) {
      System.out.println(x * 2 % mod);
      
    } else {
      //x > 0, n > 0
      x %= mod;

      long a;
      a = (x - 1 + mod) * pow(2, k, mod) + 1;
      a %= mod;

      long b = x * pow(2, k, mod);
      b %= mod;
      
      System.out.println((a + b) % mod);
    }
  }

  public static long pow(long a, long n, long mod)
  {
//    a %= mod;
      long ret = 1; // 1%mod if mod=1,n=0
      int x = 63-Long.numberOfLeadingZeros(n);
      for(;x >= 0;x--){
          ret = ret * ret % mod;
          if(n<<~x<0)ret = ret * a % mod;
      }
      return ret;
  }
  
  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.util.*;
import java.io.*;

public class virtual1{

    static InputReader in = new InputReader();
    static PrintWriter out = new PrintWriter(System.out);
    
    public static void main(String[] args) {
            long x = in.nextLong();
            long k = in.nextLong();
            long mod = (long)1e9+7l;
            //out.println(mod);
            long mul1 = 1;
            long mul2 = 2*x-1;
            mul2 = mul2%mod;
            long pow = k;
            long to = 2;
            while(pow>0l){
                if(pow%2l==1l){
                    mul1 = mul1*to;
                    mul1%=mod;
                }
                to=to*to;
                to%=mod;
                pow = pow/2l;
            }
            mul1 = mul1*mul2;
            mul1%=mod;
            mul1+=1;
            if(x!=0)
            out.println(mul1%mod);
            else
            out.println(0);
        
        out.close();    
    }

    static class InputReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public InputReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.util.*;
public class algo93
{
    public static void main(String args[])
    {
        Scanner ex=new Scanner(System.in);
        long x=ex.nextLong();
        long k=ex.nextLong();
        long mod=1000000007;
        if(k==0)
        System.out.println((2*x)%mod);
        else if(x==0)
        System.out.println("0");
        else
        {
            long pow=power(2,k);
            long pow1=(2*pow)%mod;
            long ans=(pow1*(x%mod))-pow+1;
            if(ans<0)
            ans=ans+mod;
            ans=ans%mod;
            System.out.println(ans);
        }
    }
    public static long power(long x,long y)
    {
        if (y == 0)
        return 1;
        long mod=1000000007;
        long pow=power(x,y/2);
        pow=(pow*pow)%mod;
        if(y%2==0)
        return pow;
        else
        return ((x%mod)*pow)%mod;
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.*;
import java.util.StringTokenizer;

public class Test {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1024 * 48);
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String str = br.readLine();
        StringTokenizer st = new StringTokenizer(str, " ");
        long x = Long.parseLong(st.nextToken());
        long k = Long.parseLong(st.nextToken());
        if (x == 0) {
            bw.write(0 + "\n");
        } else {
            int power = power(k, 1000000007);
            long answer = (((power * 2) % 1000000007) * (x % 1000000007)) % 1000000007;
            answer -= power - 1;
            answer = (answer + 1000000007) % 1000000007;
            bw.write(answer + "\n");
        }
        bw.flush();
    }

    public static int power(long a, int m) {
        if (a == 0) {
            return 1;
        }
        long pow = power(a / 2, m);
        if (a % 2 == 1) {
            return (int)(((pow * pow) % m) * 2) % m;
        } else {
            return (int)((pow * pow) % m);
        }
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	static long MOD=1000000007;
	public static long pow(long x,long k){
		long base=x%MOD;
		long res=1;
		while(k>0){
			if((k&1)==1){
				res=(res*base)%MOD;
			}
			base=(base*base)%MOD;
			k>>=1;
		}
		return res;
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan=new Scanner(System.in);
		long x=scan.nextLong();
		long k=scan.nextLong();
		long MOD=1000000007;
		if(x==0){System.out.println(0);return;}
		x %= MOD;
		long a=pow(2L,k+1);
		long b=pow(2L,k);
		long res=(a*x)%MOD-b+1;
		if(res<0){res+=MOD;}
		System.out.println(res%MOD);
	}
}