codeparrot/codecomplex huggingface dataset:
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer tok;
    static boolean hasNext()
    {
        while(tok==null||!tok.hasMoreTokens())
            try{
                tok=new StringTokenizer(in.readLine());
            }
            catch(Exception e){
                return false;
            }
        return true;
    }
    static String next()
    {
        hasNext();
        return tok.nextToken();
    }
    static long nextLong()
    {
        return Long.parseLong(next());
    }
    static int nextInt()
    {
        return Integer.parseInt(next());
    }
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String args []){
        long x = nextLong();
        long a = 2, b = nextLong(), c = 1000000000+7;
        long res = 1;
        a %= c;
        if (x==0){
            out.println(0);
            out.flush();
            return;
        }
        for (; b != 0; b /= 2) {
            if (b % 2 == 1)
                res = (res * a) % c;
            a = (a * a) % c;
        }
        BigInteger r = new BigInteger(String.valueOf(res));
        BigInteger y = new BigInteger(String.valueOf(x));
        BigInteger ans = y.multiply(new BigInteger("2")).subtract(new BigInteger("1")).multiply(r).add(new BigInteger("1")).mod(new BigInteger(String.valueOf(c)));
        out.println(ans);
        out.flush();
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {
	
	static long MOD = (long) 1e9 + 7;
	static long[][] identity = {{1, 0}, {0, 1}};
	
	public static void main(String[] args) {
		FastScanner input = new FastScanner(System.in);
		
		long x = input.nextLong();
		long k = input.nextLong();
		
		long[][] matrix = {
			{2, MOD - 1},
			{0, 1}
		};
		
		if (x == 0)
			System.out.println(0);
		else if (k == 0) {
			System.out.println((x * 2) % MOD);
		} else {
			x %= MOD;
			matrix = matrixexpo(k, matrix);
			long low = (x * matrix[0][0] + matrix[0][1]) % MOD;
			long hi = x * mathpow(k, 2) % MOD;
			System.out.println((low + hi) % MOD);
		}
	}
	
	static long mathpow(long k, long x) {
		if (k == 0)
			return 1L;
		else return mathpow(k / 2, (x * x) % MOD) * (k % 2 == 1 ? x : 1) % MOD;
	}
	
	static long[][] matrixexpo(long k, long[][] matrix) { 
		if (k == 0)
			return identity;
		if (k % 2 == 0)
			return matrixexpo(k / 2, multiply(matrix, matrix));
		else
			return multiply(matrix, matrixexpo(k / 2, multiply(matrix, matrix)));
	}
	
	static long[][] multiply(long[][] arr, long[][] brr) { 
		int n = arr.length, m = arr[0].length, p = brr[0].length;
		
		long[][] product = new long[n][p];
		
		for (int i = 0; i < n; i++)
			for (int j = 0; j < p; j++)
				for (int k = 0; k < m; k++)
					product[i][j] = (product[i][j] + arr[i][k] * brr[k][j]) % MOD;
		return product;
	}
	
	// Matt Fontaine's Fast IO
	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

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

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

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

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

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

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn


import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Test5{

    static long mod=1000000007;

    public static void main(String[] z) throws Exception{
        Scanner s = new Scanner(System.in);
        long a = s.nextLong(), b=s.nextLong(), c=(a*2-1)%mod, i=binpow(2,b)%mod;
        System.out.println(a<1 ? a : (c*i+1)%mod);
    }

    static long binpow(long c, long step){
        if(step==0) return 1;
        if(step==1) return c%mod;
        if(step%2<1){
            return binpow(((c%mod)*(c%mod))%mod, step/2)%mod;
        }
        else{
            return (c%mod)*(binpow(c%mod, step-1)%mod);
        }
    }

    static class PyraSort {

        private static int heapSize;

        public static void sort(int[] a) {
            buildHeap(a);
            while (heapSize > 1) {
                swap(a, 0, heapSize - 1);
                heapSize--;
                heapify(a, 0);
            }
        }

        private static void buildHeap(int[] a) {
            heapSize = a.length;
            for (int i = a.length / 2; i >= 0; i--) {
                heapify(a, i);
            }
        }

        private static void heapify(int[] a, int i) {
            int l = 2 * i + 2;
            int r = 2 * i + 1;
            int largest = i;
            if (l < heapSize && a[i] < a[l]) {
                largest = l;
            }
            if (r < heapSize && a[largest] < a[r]) {
                largest = r;
            }
            if (i != largest) {
                swap(a, i, largest);
                heapify(a, largest);
            }
        }

        private static void swap(int[] a, int i, int j) {
            a[i] ^= a[j] ^= a[i];
            a[j] ^= a[i];
        }
    }
}
// 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.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CNastyaAndAWardrobe {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long mod = (long) (1e9 + 7);
            long n = in.nextLong();
            long k = in.nextLong();
            if (n == 0) {
                out.println(0);
                return;
            }
            long c = (((2 * n - 1) % mod) * pow(2L, k, mod)) % mod + 1;
            c %= mod;
            out.println(c);
        }

        public long pow(long a, long b, long mod) {
            long result = 1;
            while (b > 0) {
                if (b % 2 != 0) {
                    result *= a;
                    result %= mod;
                    b--;
                }
                a *= a;
                a %= mod;
                b /= 2;
            }

            return result % mod;

        }

    }

    static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.util.*;
public class prob
{
		
	public static long ans(long x, long y, long p)
    {
        long r = 1;     
        x = x % p;
        while (y > 0)
        {
            if((y & 1)==1)
                r = (r * x) % p;
            y = y >> 1; 
            x = (x * x) % p; 
        }
        return r;
    }
	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 v = 1000000007L;
		if(x>0){
			long p = ((2*x)-1)%v;
			long a = ans(2L,k,v);
			long b = (p*a)%v;
			System.out.println((b+1)%v);
		}
		else{
			System.out.println(0);
		}
	}
}
// 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.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vadim Semenov
 */
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 final class TaskC {
        private static final int MODULO = 1_000_000_000 + 7;

        public void solve(int __, InputReader in, PrintWriter out) {
            long qty = in.nextLong();
            long months = in.nextLong();
            if (qty == 0) {
                out.println(0);
                return;
            }
            qty %= MODULO;
            long pow = pow(2, months + 1);
            qty = (qty * pow) % MODULO;
            long sub = (pow - 2 + MODULO) % MODULO * pow(2, MODULO - 2) % MODULO;
            qty = (qty - sub + MODULO) % MODULO;
            out.println(qty);
        }

        private long pow(long base, long power) {
            long result = 1;
            while (power > 0) {
                if ((power & 1) != 0) {
                    result = (result * base) % MODULO;
                }
                base = (base * base) % MODULO;
                power >>>= 1;
            }
            return result;
        }

    }

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

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

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

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

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class C {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());

        long n = Long.parseLong(st.nextToken());
        long k = Long.parseLong(st.nextToken());
        int mod = 1000000007;

        if(n == 0) {
          out.println(0);
          out.close(); System.exit(0);
        }
        n %= mod;

        long ans = exp(2, (int)((k+1) % (mod-1)), mod);
        ans = (1L*ans * n) % mod;
        ans = ans + mod + 1 - exp(2, (int)((k) % (mod-1)), mod);
        ans %= mod;
        out.println(ans);
        // int n = scan.nextInt();

        out.close(); System.exit(0);
    }
    public static int exp(int base, int e, int mod) {
      if(e == 0) return 1;
      if(e == 1) return base;
      int val = exp(base, e/2, mod);
      int ans = (int)(1L*val*val % mod);
      if(e % 2 == 1)
        ans = (int)(1L*ans*base % mod);
      return ans;
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	private void solve() throws IOException {

		out.println(solve(nl()));
		out.close();

	}

	private long solve(long n) throws IOException {
		if (n > 0) {
			n <<= 1;
			long k = nl();
			n--;
			int M = 1000000007;
			long p = power(2, k, M);
			// Helper.tr(n * p + 1);
			n = (n % M * p + 1) % M;
		}
		return n;
	}

	long power(long a, long b, long mod) {
		long x = 1, y = a;
		while (b > 0) {
			if (b % 2 != 0) {
				x = (x * y) % mod;
			}
			y = (y * y) % mod;
			b /= 2;
		}
		return x % mod;
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

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

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}
// 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.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vadim Semenov
 */
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 final class TaskC {
        private static final int MODULO = 1_000_000_000 + 7;

        public void solve(int __, InputReader in, PrintWriter out) {
            long qty = in.nextLong();
            long months = in.nextLong();
            if (qty == 0) {
                out.println(0);
                return;
            }
            qty %= MODULO;
            long pow = pow(2, months + 1);
            qty = (qty * pow) % MODULO;
            long sub = (pow - 2 + MODULO) % MODULO * pow(2, MODULO - 2) % MODULO;
            qty = (qty - sub + MODULO) % MODULO;
            out.println(qty);
        }

        private long pow(long base, long power) {
            long result = 1;
            while (power > 0) {
                if ((power & 1) != 0) {
                    result = (result * base) % MODULO;
                }
                base = (base * base) % MODULO;
                power >>>= 1;
            }
            return result;
        }

    }

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

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

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

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

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn

import java.util.Scanner;

public class Main {

	public static long power(long a, long b, long c){
		if(b == 0){
			return 1;
		}
		a %= c;
		if(b % 2 == 0){
			return power((a % c * a % c) % c, b / 2, c);
		}else{
			return (a % c * power((a % c * a % c) % c, b / 2, c) % c) % c;
		}
	}
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long x = s.nextLong(), k = s.nextLong() + 1, mod = (long)Math.pow(10, 9) + 7;
		long ans;
		if(x == 0){
			System.out.println(0);
			return;
		}
//		if(x != 0){
			ans = ((power(2, k % (mod - 1), mod) % mod) * (x % mod)) % mod; 
	/*	}else{
			ans = 0;
		}
		*/ans = (ans - power(2, (k - 1) % (mod - 1), mod) % mod + 2 * mod) % mod;
		System.out.println((ans + 1) % mod);

	}

}
// 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(two.multiply(x).subtract(BigInteger.ONE)).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 java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kessido
 */
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 MOD = MathExtentions.DEFAULT_MOD;
            long x = in.NextLong();
            long k = in.NextLong();
            if (x == 0) {
                out.println(0);
                return;
            }
            x %= MOD;
            long res = x * MathExtentions.powerMod(2, k + 1, MOD);
            res %= MOD;
            res -= MathExtentions.powerMod(2, k, MOD) - 1;
            res %= MOD;
            while (res < 0) res += MOD;
            while (res >= MOD) res -= MOD;
            out.println(res);

        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }

    static class MathExtentions {
        public static final long DEFAULT_MOD = 1_000_000_007;

        public static long powerMod(final long x, final long y, final long m) {
            if (y == 0)
                return 1;

            long p = powerMod(x, y / 2, m) % m;
            p = (p * p) % m;

            if (y % 2 == 0)
                return p;
            else
                return (x * p) % m;
        }

    }
}