codeparrot/codecomplex huggingface dataset:
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.*;
import java.util.*;


public class test {
    static boolean DEBUG_FLAG = false;
    int INF = (int)1e9;
    long MOD = 1000000007;
    
    static void debug(String s) {
        if(DEBUG_FLAG) {
            System.out.print(s);
        }
    }
    
    long pow(long a, long n, long mod) {
        if (n == 0) {
            return 1;
        }
        long rs = 1;
        while (n != 0) {
            if (n % 2 == 1) {
                rs *= a;
            }
            rs %= mod;
            n >>= 1;
            a *= a;
            a %= mod;
        }
        return rs;
    }
    
    void solve(InputReader in, PrintWriter out) throws IOException {
        long x = in.nextLong();
        long k = in.nextLong();
        if(x==0) {
            out.println(0);
            return;
        }
        long a = (2 * x - 1) % MOD;
        long b = pow(2, k, MOD);
        a = (a * b) % MOD;
        a += 1;
        a %= MOD;
        out.println(a);
    }
    
    
    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new test().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                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());
        }
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Dummy {
  private static long mod = 1000000007;
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String[] strs = reader.readLine().split(" ");
    long x = Long.parseLong(strs[0]);
    long k = Long.parseLong(strs[1]);
    long twoPK = modPow(2, k);
    long twoPK_1 = (twoPK * 2) % mod;
    long res = ((twoPK_1 * (x % mod)) % mod - (twoPK - 1) + mod) % mod;
    System.out.println(x == 0? x: res);
  }

  private static long modPow(long base, long pow) {
    long res = 1;
    while(pow != 0) {
      if((pow & 1) != 0) {
        res = (res % mod * base % mod)%mod;
      }
      base = (base % mod * base % mod) % mod;
      pow >>= 1;
    }
    return res;
  }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.*;
import java.util.*;

public class A992{
	
	long mod = 1000000007L;
	
	private void solve() throws Exception {
		long x = nextLong();
		long k = nextLong();
		if(x == 0) {
			out.println(0);
			return;
		}
		x = x%mod;
		long res = (((x*pow(2,k+1))%mod + (mod-pow(2,k))%mod)%mod+1)%mod;    
		out.println(res);
	}
	
	long pow(long m, long n){
	    long res = 1;
	    while(n > 0){
	        if(n % 2 == 1)res = (res*m)%mod;
	        m = (m*m)%mod;
	        n = n/2;
	    }
	    return res;
	} 
	
	public static void main(String[] args) {
		(new A992()).run();
	}

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private float nextFloat() throws IOException {
		return Float.parseFloat(nextToken());
	}

	private String nextLine() throws IOException {
		return new String(in.readLine());
	}

	private String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(in.readLine());
		}
		return tokenizer.nextToken();
	}


}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
//package CF489; //comment this line

import java.io.*;
import java.util.*;
import java.math.*;
public class B
{
    private static long MOD=1000000007;
    private static BigInteger m=new BigInteger(1000000007+"");
    
    private static long pow(long x, long a)
    {
        if(a==0)
        return 1;
        
        long ans=pow(x,a/2);
        
        ans=(ans*ans)%MOD;
        
        if(a%2==1)
        ans=(ans*x)%MOD;
        
        return ans%MOD;
    }
    public static void main(String args[]) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        
        long N,K,ans;
        
        //System.out.println(); //comment this line
        String s[]=br.readLine().trim().split(" ");
        
        N=Long.parseLong(s[0]);
        K=Long.parseLong(s[1]);
        
        BigInteger bi=new BigInteger(N+"");
        BigInteger a=new BigInteger(N+"");
        BigInteger two=new BigInteger(2+"");
        
        if(N==0)
        {
            System.out.println(0);
            System.exit(0);
        }
        if(K==0)
        {
            a=a.multiply(two);
            a=a.mod(m);
            
            System.out.println(a);
            System.exit(0);
        }
        
        long p=pow(2,K);
        
        BigInteger p2=new BigInteger(p+"");
        BigInteger tmp=p2.subtract(BigInteger.ONE);
        tmp=tmp.mod(m);
        
        p2=p2.multiply(two);
        p2=p2.mod(m);
        
        a=a.multiply(p2);
        a=a.mod(m);
        
        a=a.subtract(tmp);
        a=a.mod(m);
        
        if(!(a.signum()==1)&&!(a.signum()==0))
        a.add(m);
        
        System.out.println(a);
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.*;
import java.util.*;
import java.math.*;



public class C
{


   
   
      
   


            
            
      



      
	

	
    public static void main(String[] args) 
    {
        Scanner sc = new Scanner(System.in);
        BigInteger x = sc.nextBigInteger();
        BigInteger k = sc.nextBigInteger();
        BigInteger zero = new BigInteger("0");
        BigInteger one = new BigInteger("1");
        BigInteger two = new BigInteger("2");
        BigInteger modulo = new BigInteger("1000000007");
        BigInteger ans = two.modPow(k.add(one),modulo);
        ans = ans.multiply(x);
        ans = ans.subtract(two.modPow(k,modulo));
        ans = ans.add(one);
        ans = ans.mod(modulo);
        if (x.equals(zero))
        {
         System.out.println(0);
         }
         else
         {
        System.out.println(ans);
        }
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.util.*;
import java.io.*;

public class R489C {
	
	static long m = (long)(1e9+7);
	/*
	1000000000000000000
	 */

	public static void main(String[] args) {
		JS scan = new JS();
		long n = scan.nextLong();
		long k = scan.nextLong();
		if(n == 0) {
			System.out.println(0);
			return;
		}
		if(k == 0) {
			long ans = (n%m)*(2%m)%m;
			System.out.println(ans%m);
			return;
		}
		//System.out.println(2+" "+(k+1)+" "+m);
		long coeff = power(2L, k+1, m);
		//System.out.println(coeff);
		long r = (coeff%m)*(n%m)%m;
		//System.out.println(r);
		long x = power(2L, k, m)%m-1;
		if(x < 0) x += m;
		long ans = r-x;
		if(ans < 0) ans += m;
		System.out.println(ans%m);
	}
	
	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%p * x%p) % p;
    
            // y must be even now
            // y = y / 2
            y = y >> 1; 
            x = (x%p * x%p) % p; 
        }
        return res;
    }
	
	/*
	1000000000000000000 1000000000000000000
	 */
	
	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}				
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn

import java.util.*;
import java.io.*;

public class Solution1 {

    private void solve() throws IOException {
        long MOD = 1_000_000_007;
        long x = in.nextLong();
        long k = in.nextLong();
        if (x == 0) {
            System.out.println(0);
            return;
        }
        long val = binpow(2, k + 1, MOD) % MOD;
        long kek = (binpow(2, k, MOD) - 1 + MOD) % MOD;
        x = (val % MOD) * (x % MOD) % MOD;
        long ans = (x % MOD - kek % MOD + MOD) % MOD;
        System.out.println(ans % MOD);
    }

    private long binpow(long a, long n, long mod) {
        long res = 1;
        while (n > 0) {
            if (n % 2 == 1)
                res = (res % mod) * (a % mod) % mod;
            a = (a % mod) * (a % mod) % mod;
            n >>= 1;
        }
        return res % mod;
    }



    private PrintWriter out;
    private MyScanner in;

    private void run() throws IOException {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    private class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() throws IOException {
            this.br = new BufferedReader(new InputStreamReader(System.in));
        }

        public MyScanner(String fileTitle) throws IOException {
            this.br = new BufferedReader(new FileReader(fileTitle));
        }

        public String nextLine() throws IOException {
            String s = br.readLine();
            return s == null ? "-1" : s;
        }

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

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

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

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

        public void close() throws IOException {
            this.br.close();
        }
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Solution1().run();
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.util.*;
import java.io.*;
public class A{
	static long mod = 1000000000+7;
	static int arr[];
	static HashMap<Long,Long> map = new HashMap<>();
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long k = scan.nextLong();
		if(x == 0)
		{
			System.out.println(0);
			return;
		}
		x = x%mod;
		long power = pow(2,k + 1)%mod;
		power = (power*x)%mod;
		long num = (pow(2,k) - 1 + mod)%mod;
		long ans = (power - num + mod)%mod;
		System.out.println((ans));
	}
	public static long pow(long a,long b)
	{
		if(b == 0)
			return 1;
		if(b == 1)
			return a;
		long x1,x2;
		if(map.containsKey(b - b/2))
			x1 = map.get(b - b/2);
		else
		{
			x1 = pow(a,b - b/2)%mod;
			map.put(b - b/2,x1);
		}
		if(map.containsKey(b/2))
			x2 = map.get(b/2);
		else
		{
			x2 = pow(a,b/2)%mod;
			map.put(b/2,x2);
		}
		return (x1*x2)%mod;
	}
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.*;
import java.util.*;

public class C
{	
	static long mod=(long)(1e9+7);
	public static long powMod(long e,long b)
	{
		/*e=e%mod;*/
		long res=1;
		
		while(e>0)
		{
			if(e%2==1)
				res=res*b%mod;
			e/=2;
			b=b*b%mod;
		}
		return res;
	}

		public static void main(String[] args) throws IOException 
		{
			Scanner sc=new Scanner(System.in);
			PrintWriter pw=new PrintWriter(System.out);
			long x=sc.nextLong(),k=sc.nextLong();
			if(x==0)
			{
				System.out.println(0);
				return;
			}
			
			if(k==0)
			{
				pw.println((2*x)%mod);
				
				
				pw.close();return;
			}
			
			long ans=2*x-1;
			ans=ans%mod;
			
			long b=powMod(k,2);
			ans=((ans*b)+1)%mod;
			
			
			pw.println(ans);
			
			pw.close();
		
			
		}
		
		
	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 double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(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.lang.*;
import java.io.*;
public class C{
	public static void main (String[] args) throws java.lang.Exception{
		Scanner scan=new Scanner(System.in);
		long x=scan.nextLong(), k=scan.nextLong();
		long MOD = 1000000007;
		if(x==0){
			System.out.println("0");
			return;
		}
		x %= MOD;
		long ans= (((new myC()).fastPow(2L, k+1)*x)%MOD - (new myC()).fastPow(2L, k) + MOD + 1)% MOD;
		ans %= MOD;
		System.out.println(ans);
	}
}

class myC{
	long MOD = 1000000007;
	long fastPow(long x, long k){
		long bb=x%MOD, ans=1;
		while(k > 0){
			if((k&1)==1){
				ans=(ans*bb)%MOD;
			}
			bb=(bb*bb)%MOD;
			k>>=1;
		}
		return ans;
	}
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Div2_489C {

	static final long MOD = 1_000_000_007;

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer inputData = new StringTokenizer(reader.readLine());
		long st = Long.parseLong(inputData.nextToken());
		if(st == 0) {
			printer.println(0);
			printer.close();
			return;
		}
		st %= MOD;
		long years = Long.parseLong(inputData.nextToken());
		long[][] res = exp(years);
		long ans = (res[0][0] * st % MOD * 2 % MOD + res[0][1] * (-1 + MOD) % MOD) % MOD;
		printer.println(ans);
		printer.close();
	}

	static long[][] exp(long pow) {
		long[][] cBase = base;
		long[][] res = { { 1, 0 }, { 0, 1 } };

		while (pow != 0) {
			if ((pow & 1) != 0) {
				res = mult(res, cBase);
			}
			cBase = mult(cBase, cBase);
			pow >>= 1;
		}
		return res;
	}

	static long[][] base = { { 2, 1 }, { 0, 1 } };

	static long[][] mult(long[][] a, long[][] b) {
		long[][] res = new long[2][2];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				res[i][j] = (a[i][0] * b[0][j] % MOD + a[i][1] * b[1][j] % MOD) % MOD;
			}
		}
		return res;
	}

}
// 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.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kanak893
 */
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 fi, PrintWriter out) {
			long n, k;
			n = fi.nextLong();
			k = fi.nextLong();
			long ans = 2 * n;
			long mod = (long) Math.pow(10, 9) + 7;

			if (k > 0) {
				ans = (modulus(modulus(pow(2, k + 1, mod), mod) * modulus(n, mod), mod));
				long temp = modulus(pow(2, k, mod) - 1, mod);
				ans = modulus(modulus(ans, mod) - modulus(temp, mod), mod);

			}
			if (n == 0) {
				ans = 0;
			}
			ans=ans%mod;
			out.println(ans);
		}

		static long pow(long x, long y, long mod) {
			if (y == 0) return 1 % mod;
			if (y == 1) return x % mod;
			long res = 1;
			x = x % mod;
			while (y > 0) {
				if ((y % 2) != 0) {
					res = (res * x) % mod;
				}
				y = y / 2;
				x = (x * x) % mod;
			}
			return res;
		}

		static long modulus(long a, long mod) {
			return (a % mod + mod) % mod;
		}

	}

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[8192];
		private int curChar;
		private int snumChars;
		private InputReader.SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);

		}

	}
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	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=(new Num()).pow(2L,k+1);
		long b=(new Num()).pow(2L,k);
		long res=(a*x)%MOD-b+1;
		if(res<0){res+=MOD;}
		System.out.println(res%MOD);
	}
}

class Num{
	long MOD=1000000007;
	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;
	}
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	static BigInteger tow=new BigInteger("2"),mod=new BigInteger("1000000007");
	static BigInteger pow(BigInteger a,BigInteger b) {
		if(b.equals(BigInteger.ZERO))return BigInteger.ONE;
		BigInteger x=pow(a,b.divide(tow));
		if(b.mod(tow).equals(BigInteger.ZERO)) 
			return x.mod(mod).multiply(x.mod(mod)).mod(mod);
		else 
			return x.mod(mod).multiply(x.mod(mod)).mod(mod).multiply(a).mod(mod);
	}
	public static void main(String[] args) throws IOException {
		BigInteger x=in.RB(),k=in.RB();
		if(k.equals(BigInteger.ZERO))System.out.println(x.multiply(tow).mod(mod));
		else if(x.equals(BigInteger.ZERO))System.out.println(0);
		else {
			BigInteger x1=tow.multiply(x).subtract(BigInteger.ONE);
			x1=x1.mod(mod);
			BigInteger x2=pow(tow,k);
			x2=x2.mod(mod);
			System.out.println(x1.multiply(x2).add(BigInteger.ONE).mod(mod));
			
		}
	}
}


class in{
	static StringTokenizer st=new StringTokenizer("");
	static BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
	static String next() throws IOException {
		while(!st.hasMoreTokens())st=new StringTokenizer(bf.readLine());
		return st.nextToken();
	}
	static int RI() throws IOException {
		return Integer.parseInt(next());
	}
	static BigInteger RB() throws IOException {
		return new BigInteger(next());
	}
}