jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
"use strict";

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }

function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }

function main(input) {
  var lines = input.split('\n');
  var s = parseInt(lines[0]);
  var memo = new Set();
  var a = s;
  var index = 1;

  while (true) {
    if (memo.has(a)) {
      console.log(index);
      return;
    }

    memo.add(a);
    index++;
    a = a % 2 === 0 ? a / 2 : 3 * a + 1;
  }
}

var P = 1e9 + 7;
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return (Array.isArray(line) ? line : line.split(/\s+/)).map(function (n) {
    return parseInt(n);
  });
}
/**
 * Iterates over integers in [start, end).
 */


function* range(start, end) {
  for (var i = start; i < end; i++) {
    yield i;
  }
}
/**
 * Iterates over integers in [end, start) in desc order.
 */


function* rangeRev(start, end) {
  for (var i = start - 1; i >= end; i--) {
    yield i;
  }
}
/**
 * Runs a recursive function expressed as a generator function.
 */


function runRecursive(func) {
  // 最終結果を受け取るオブジェクトを用意
  var rootCaller = {
    lastReturnValue: null
  }; // 自前のコールスタックを用意

  var callStack = []; // 最初の関数呼び出しを追加

  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    args[_key - 1] = arguments[_key];
  }

  callStack.push({
    iterator: func.apply(void 0, args),
    lastReturnValue: null,
    caller: rootCaller
  });

  while (callStack.length > 0) {
    var stackFrame = callStack[callStack.length - 1];
    var iterator = stackFrame.iterator,
        lastReturnValue = stackFrame.lastReturnValue,
        caller = stackFrame.caller; // 関数の実行を再開

    var _iterator$next = iterator.next(lastReturnValue),
        value = _iterator$next.value,
        done = _iterator$next.done;

    if (done) {
      // 関数がreturnしたので親に返り値を記録
      caller.lastReturnValue = value;
      callStack.pop();
    } else {
      // 関数がyieldした（valueは再帰呼び出しの引数リスト）
      callStack.push({
        iterator: func.apply(void 0, _toConsumableArray(value)),
        lastReturnValue: null,
        caller: stackFrame
      });
    }
  }

  return rootCaller.lastReturnValue;
}
//  [javascript]
"use strict";

function f(x) {
  if (x % 2 === 0) {
    return x/2;
  } else {
    return x * 3 + 1;
  }
}

function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");

  let s = Number(inputs[0]);
  let set = {}

  let current = s;
  let count = 1;
  while(set[current] !== true) {
    set[current] = true;
    current = f(current);
    count++;
  }

  console.log(count);

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import "fmt"

func main() {
	var s int
	fmt.Scan(&s)
	fmt.Println(col(s))
}

func col(s int) int {
	num := make([]int, 1000000)
	var next, ans int
	num[0] = s
	for i := 1; i < 1000000; i++ {
		if s%2 == 0 {
			next = s / 2
		} else {
			next = 3*s + 1
		}
		for _, v := range num {
			if next == v {
				ans = i + 1
			}
		}
		if ans != 0 {
			break
		}
		num[i] = next
		s = next
	}
	return ans
}
//  [go]
// ProblemURL : https://atcoder.jp/contests/abc116/tasks/abc116_b
// ---------------------------------------------
package main

import "fmt"

func main() {
	var s int
	fmt.Scan(&s)
	f := func(n int) int {
		if n%2 == 0 {
			return n / 2
		}
		return n*3 + 1
	}
	as := make([]int, 1000001)
	as[0] = s
	for i := 1; i < 1000000; i++ {
		as[i] = f(as[i-1])
	}
	mp := make(map[int]int, 1000001)
	ans := -1
	for i := range as {
		if _, exist := mp[as[i]]; exist {
			ans = i
			break
		}
		mp[as[i]]++
	}
	fmt.Println(ans + 1)
}
//  [go]
package main

import (
	"fmt"
)

func cal(n int) int {
	if n%2 == 0 {
		n /= 2
	} else {
		n = n*3 + 1
	}
	return n
}

func main() {
	var first, num, ans int

	fmt.Scan(&first)
	sequence := make([]int, 1000000)
	exsits := make(map[int]bool, 1000000)

	sequence[0] = first
	exsits[first] = true

	for i := 1; ; i++ {
		num = cal(sequence[i-1])

		if exsits[num] {
			ans = i + 1
			break
		}
		sequence[i] = num
		exsits[num] = true
	}

	fmt.Println(ans)
}
//  [ruby]
s = gets.to_i

def fn (n)
  if n.even?
    n/2
  else
    3*n+1
  end
end

m = 0
a = Array.new(1000001, 0)
a[1] = s
2.upto(1000000) do |i|
  result = fn(a[i-1])
  if a.include?(result)
    m = i
    break
  else
    a[i] = result
  end
end

puts m
//  [ruby]
s = gets.to_i
N = 10 ** 6

arr = []
for i in 1..N do
  if i == 1 then
    arr[i-1] = s
  elsif arr[i-2] % 2 == 0 then
    arr[i-1] = arr[i-2] / 2
  else
    arr[i-1] = 3 * arr[i-2] + 1
  end
end
    
deja = []
for i in 1..N do
  deja[i-1] = false
end
    
m = 1
loop do
  num = arr[m-1]
  if deja[num-1] then
    puts m
    break
  else
    deja[num-1] = true
  end
  m += 1
end
//  [ruby]
s = gets.to_i

def f n
  return (n%2==0)? n/2 : n*3+1
end

a = [s]
1000000.times{
  a.push(f(a[-1]))
}

h = {}

a.each.with_index{|x,i|
  if h[x]
    p i+1
    exit
  else
    h[x] = 1
  end
}
//  [rust]
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        s: i64,
    }

    let mut map = HashMap::new();
    let mut i = 0;
    let mut a = s;
    while map.insert(a, i).is_none() {
        i += 1;
        a = if a % 2 == 0 { a / 2 } else { 3 * a + 1 };
    }
    println!("{}", i + 1);
}
//  [rust]
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let s = get!(i64);
    let mut v = vec![0; 100000];
    v[1] = s;
    for i in 2..v.len() {
        if v[i - 1] % 2 == 0 {
            v[i] = v[i - 1] / 2;
        } else {
            v[i] = v[i - 1] * 3 + 1;
        }
    }
    //eprintln!("{:?}", v);
    let mut ans = v[1];
    'outer: for i in 1..v.len() {
        let tmp = v[i];
        let n = v.iter().filter(|&&x| x == tmp).count();
        //eprintln!("n:{}", n);
        if 2 <= n {
            let mut count = 0;
            for j in 1..v.len() {
                if v[j] == tmp {
                    count += 1;
                    if count == 2 {
                        ans = j as i64;
                        break 'outer;
                    }
                }
            }
        }
    }
    println!("{}", ans);
}
//  [rust]
use proconio::{input, fastout};

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        s: usize,
    }

    let mut cnt = 0;
    let mut a: Vec<usize> = Vec::new();
    a.push(s);
    loop {
        if a[a.len()-1]%2==0 {
            a.push(a[a.len()-1]/2);
        } else {
            a.push(a[a.len()-1]*3+1);
        }
        for i in 0..a.len()-1 {
            if a[a.len()-1]==a[i] {
                println!("{}", a.len());
                return;
            }
        }
    }

}
//  [swift]
var s = Int(readLine()!)!
var seq: [Int] = [s]
var res: Int = 1
while !seq.dropLast().contains(s) {
    res += 1
    s = s%2==0 ? s/2 : 3*s + 1
    seq.append(s)
}
print(res)
//  [swift]
import Foundation

var s = Int(readLine()!)!
var a: [Int] = []

while a.indexOf(s) == nil {
    a.append(s)
    if s % 2 == 0 {
        s /= 2
    } else {
        s = 3 * s + 1
    }
}
print(a.count + 1)
//  [typescript]
((input: string): void => {
    let hoge: number[] = [Number(input)];
    const hEnd = (): number => { return hoge.slice(-1)[0]; }
    while (new Set(hoge).size == hoge.length) {
        let piyo: boolean = hEnd() % 2 == 0;
        hoge.push(piyo ? hEnd()/2 : (hEnd()*3)+1);
    }
    console.log(hoge.length);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }
  const f: (n: number) => number = (n: number) => {
    return n % 2 === 0 ? n / 2 : 3 * n + 1;
  };

  async function slove() {
    const sc = new Scanner();
    const s: number = +(await sc.getLine());
    const prog: number[] = [];
    let ans = -1;
    prog.push(s);
    let a = s;
    for (let i = 1; i <= 1000000; i++) {
      let b: number = f(a);
      if (prog.filter((x) => b === x).length > 0) {
        ans = i + 1;
        break;
      }
      prog.push(b);
      a = b;
    }
    console.log(ans);
    sc.close();
  }
  slove();
}
//  [typescript]
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let n=t.n()
  let nr=[n]
  let owari=false,i=1
  while(!owari){
    nr.push(nr[i-1]%2==0?nr[i-1]/2:3*nr[i-1]+1)
    i++
    for(let j=0;j<nr.length-1;j++){
      if(nr[j]==nr[nr.length-1]){
        t.o(i)
        return;
      }
    }
  }
}
main()
//  [python]
num = int(input())
num2 = int(input())

calc = 1
for i in range(num):
    if num2 > calc:
        calc *= 2
    else:
        calc += num2
print(calc)
//  [python]
N = int(input())
K = int(input())
num = 1

for n in range(N):
    if 2*num > num+K:
        num = num+K
    else:
        num = 2*num

print(num)
//  [python]
n = int(input())
k = int(input())
a = 1
for _ in range(n):
    if a < k:
        a *= 2
    else:
        a += k
print(a)
//  [python]
# coding: utf-8
# Here your code !
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np
N = int(input())
K = int(input())

a = 1
for i in range(N) : 
    if a > K : a = a + K
    else : a = 2*a
print(a)
//  [python]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    k = I()
    r = 1
    for _ in range(n):
        r = min(r*2,r+k)

    return r


print(main())
//  [python]
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
k = inp()
now = 1
for _ in range(n):
    now = min(now+k, now*2)
print(now)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            int k = Integer.parseInt(br.readLine());
            int ans = 1;
            for (int i = 0; i < n; i++) {
                int tmp1 = ans * 2;
                int tmp2 = ans + k;
                if (tmp1 > tmp2) {
                    ans = tmp2;
                } else {
                    ans = tmp1;
                }
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
//  [java]
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 Sanket Makani
 */
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);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader sc, PrintWriter w) {

            int n = sc.nextInt();
            int k = sc.nextInt();

            int curr = 1;

            while (n-- > 0) {
                if (curr <= k)
                    curr *= 2;
                else
                    curr += k;
            }
            w.println(curr);
        }

    }

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

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

        public 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++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            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);

        }

    }
}
//  [java]
import java.util.*;

class Main{           
 
   public static void main(String[] args){
      
      Scanner sc = new Scanner(System.in);
            
      int start = 1;

      int N = sc.nextInt();

      int K = sc.nextInt();
                  
      for(int i = 0;i < N;i++){
         start = Math.min(start*2,start+K);                    
      }      
      
      System.out.println(start);
      
      
                                                
   }   
 }
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class IO {
    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static String[] buffers = new String[1];
    private static int cur=1;

    static BufferedReader getBr() {
        return br;
    }

    static String next() {
        String res = null;
        try {
            res = br.readLine();
            cur = buffers.length;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return res;
    }

    static int nextInt() {
        if(buffers.length == cur) {
            buffers = next().split(" ");
            cur = 0;
        }
        return Integer.parseInt(buffers[cur++]);
    }

    static long nextLong() {
        if(buffers.length == cur) {
            buffers = next().split(" ");
            cur = 0;
        }
        return Long.parseLong(buffers[cur++]);
    }

    static double nextDouble() {
        if(buffers.length == cur) {
            buffers = next().split(" ");
            cur = 0;
        }
        return Double.parseDouble(buffers[cur++]);
    }

    static void out(Object... obj) {
        if(obj==null || obj.length==0) {
            System.out.println();
            return ;
        } else if(obj.length == 1) {
            System.out.println(obj[0]);
            return ;
        }
        StringBuilder sb = new StringBuilder();
        for(Object o:obj) {
            sb.append(o);
        }
        System.out.println(sb);
    }

    static void outs(Object... obj) {
        if(obj==null || obj.length==0) {
            System.out.println();
            return ;
        } else if(obj.length == 1) {
            System.out.println(obj[0]);
            return ;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(obj[0]);
        for(int i=1; i<obj.length; i++) {
            sb.append(" ").append(obj[i]);
        }
        System.out.println(sb);
    }
}

public class Main {

    public static void main(String[] args) {
        int N = IO.nextInt(), K = IO.nextInt();
        int ans = 1;
        for(int i=0; i<N; i++) {
            ans += Math.min(ans, K);
        }
        IO.out(ans);
    }
}
//  [cpp]
#include <cstdio>

int main() {
	int n, k, ans = 1;
	scanf("%d %d", &n, &k);

	for(int i = 0; i < n; i++) {
		if(ans < k) {
			ans *= 2;
		}
		else {
			ans += k;
		}
	}

	printf("%d\n", ans);
	return 0;
}
//  [cpp]

#include "stdio.h"

int main()
{
	int n, k;
	scanf("%d", &n);
	scanf("%d", &k);
	int num = 1;
	for (int i = 1;i <= n;i++)
	{
		if (num > k)
			num += k;
		else
			num = num * 2;
	}
	printf("%d\n", num);
	return 0;
}
//  [cpp]
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
int main()
{
	int a, b;
	while(scanf("%d\n %d", &a, &b)!=EOF)
	{
		int x = 1;
		for(int i = 1; i <= a; i++)
		{
			x = 2 * x;
			if(x >= (x / 2 + b))
			{
				x = x / 2;
				x = x + b;
			}
		}
		printf("%d\n", x);
	}
	return 0;
}
//  [cpp]
#include<bits/stdc++.h>

using namespace std;

int main()
{
    int a,b,ans=1;
    cin>>a>>b;
    while(a){
        ans*=2;
        --a;
        if(ans>=b) break;
//        cout<<ans;
    }
    while(a){ans+=b; --a;}
    cout<<ans<<endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n,k;

    cin >> n >> k;

    int a = 1;

    for(int i = 0;i < n;i++)
    {
        a = min(a*2,a+k);
    }

    cout << a;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
int main(){

    int n, k; cin >> n >> k;
    int ans = 1;
    while(n--){
        if( ans < k ) ans<<=1;
        else ans+=k;
    } cout << ans << '\n';

}
//  [c]
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int n,k,o;
  scanf("%d\n%d", &n, &k);
  o = 1;
  for (size_t i = 0; i < n; i++) {
    if (o * 2 <= o + k) {
      o *= 2;
    } else {
      o += k;
    }
  }
  printf("%d\n", o);
  return 0;
}
//  [c]
#include <stdio.h>
int main() 
{
	int N,K,i,n = 1;
	scanf("%d",&N);
	scanf("%d",&K);
	for(i = 0;i < N;i++)
	{
		if(n < K)
		n = 2*n;
		else
		n = n + K;
	}
	printf("%d\n",n);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N, K, ans = 1, i;
	scanf("%d%d", &N, &K);
	for(i = 0; i < N; i++){
		if(ans < K){
			ans *= 2;
		}
		else{
			ans += K;
		}
	}
	printf("%d\n", ans);
	return 0;
}
//  [c]
#include <stdio.h>

int main() {
	
	int n, k, x=1, y=1, hasil;
	
	scanf("%d", &n);
	scanf("%d", &k);
	
	for(int i=0; i<n; i++){
		if(x*2<=x+k){
			x*=2;
		}
		else if(x*2>x+k){
			x+=k;
		}
	}
	
	printf("%d", x);
	return 0;
}
//  [c]
#include <stdio.h>


int main() {
	int n = 0, k = 0, x = 1;
	scanf("%d\n%d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		if (2 * x <= x + k)
		{
			x *= 2;
		}
		else
		{
			x += k;
		}
	}
	printf("%d\n", x);
}
//  [c]
#include <stdio.h>
#include <string.h>
//AC, WA, TLE, RE,

int main() {
    int n, k, sum = 1;
    scanf("%d %d", &n, &k);

    for (int i = 0; i < n; i++)
    {
        if ((sum * 2) < (sum + k))
        {
            sum *= 2;
        }
        else
        {
            sum += k;
        }
    }
    printf("%d\n",  sum);

    return 0;
}
//  [javascript]
function Main (input) {
  input = input.split("\n").map(Number);
  var N = input[0];
  var K = input[1];
  var ans = 1;

  for (var i = 0; i < N; i++) {
    if (ans*2 > ans + K) {
      ans += K;
    }
    else if (ans*2 < ans + K) {
      ans *= 2;
    }
    else if (ans*2 == ans + K) {
      ans *= 2;
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'
const inputs = require('fs').readFileSync(0, 'utf8').split('\n')
const N = parseInt(inputs[0], 10)
const K = parseInt(inputs[1], 10)
if (N === 1) console.log(2)
else if (K === 1) console.log(1+N)
else if (K === 2) console.log(2+2*(N-1))
else if (N === 2) console.log(4)
else if (K <= 4) console.log(4+K*(N-2))
else if (N === 3) console.log(8)
else if (K <= 8) console.log(8+K*(N-3))
else console.log(16+K*(N-4))
//  [javascript]
function Main(input) {
  var N = parseInt(input.split("\n")[0]);
  var K = parseInt(input.split("\n")[1]);
  var output = 1;
  for(var i = 0; i < N; i++){
    if((output * 2 -  output) <= K){
       output = output * 2;
    }else{
      output += K;
    }
    
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input){
    var tmp = input.split(/\r\n|\r|\n/);
    var N = Number(tmp[0]);
    var K = Number(tmp[1]);

    var res = 1;
    var tmp2;
    for(var i=0; i<N; i++){
        tmp2 = res*2;
        res += K;
        if(tmp2<res){
            res = tmp2;
        }
    }

    console.log(res);

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var n = parseInt(input[0], 10);
    var k = parseInt(input[1], 10);

    var ans = 1;
    for (var i = 0; i < n; i++) {
        if (ans < k) {
            ans *= 2;
        }
        else {
            ans += k;
        }
    }

    console.log(ans);

    return 0;
}
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がline1, 2行目がline2, …に入る
  var tmp = input.split("\n");
  var line0 = tmp[0].split(" ");
  var line1 = tmp[1].split(" ");
  //var line2 = tmp[2].split(" ");
  //var line3 = tmp[3].split(" ");

  var n = Number(line0[0]);
  var k = Number(line1[0]);
//  var b = Number(line0[2]);

  var ans = 1;

  //console.log( n+" "+ k +" "+ " hoge ")
  
  for(var i=1; i <=n; i++){
    if(ans < k) ans *= 2;
    else ans += k;
  }

  console.log(ans);
  
  


}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	ans := 1
	for i := 0; i < N; i++ {
		ans = MinOf(ans+K, ans*2)
	}
	fmt.Println(ans)
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()

	ans := math.MaxInt64
	n := 1 << uint(N)
	for i := 0; i < n; i++ {
		cnt := 1
		for j := 0; j < N; j++ {
			if (i>>uint(j))%2 == 0 {
				cnt *= 2
			} else {
				cnt += K
			}
		}
		ans = min(ans, cnt)
	}

	out(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()

	fmt.Println(dfs(n, k, 1))
}

func dfs(remain int, k int, now int) int {
	if remain == 0 {
		return now
	}

	return int(math.Min(float64(dfs(remain-1, k, now*2)), float64(dfs(remain-1, k, now+k))))
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	k := iScan()
	ans := 1
	for i := 0; i < n; i++ {
		ans = smaller(ans+k, ans*2)
	}
	fmt.Println(ans)
}
//  [go]
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	num := 1
	for i := 0; i < n; i++  {
		a := num * 2
		b := num + k
		if a > b {
			num = b
			continue
		}
		num = a
	}
	fmt.Println(num)
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for B - Addition and Multiplication
	var N, K int
	fmt.Scanf("%d\n%d", &N, &K)

	var answer int = 1
	for i := 0; i < N; i++ {
		answer = int(math.Min(float64(answer*2), float64(answer+K)))
	}
	fmt.Println(answer)
}
//  [ruby]
n = gets.to_i
k = gets.to_i
answer = 1

(1..n).each do |number|
  answer * 2 >= answer + k ? answer += k : answer *= 2
end

puts answer
//  [ruby]
n = gets.chomp.to_i
k = gets.chomp.to_i

a = 1
b = 2
(1..n).each do |i|
   a = [a*b,a+k].min
end
puts a
//  [ruby]
n = gets.to_i
k = gets.to_i

res = 1
n.times do |_|
  if res < k
    res *= 2
  else
    res += k
  end
end

puts res
//  [ruby]
N = gets.to_i
K = gets.to_i
ans = 1
N.times {
  if ans*2 <= ans+K
    ans *= 2
  else
    ans += K
  end
}
puts ans
//  [ruby]
n,k=`dd`.split.map &:to_i
m=1
n.times{m=[m*2,m+k].min}
p m
//  [ruby]
n = gets.to_i
k = gets.to_i

ans = 1

n.times do
  ans = ans <= k ? ans * 2 : ans + k
end

puts ans
//  [rust]
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let K = read!(usize);

    let mut x = 1;
    for _ in 0..N {
        x = min(x * 2, x + K);
    }
    println!("{}", x)
}
//  [rust]
#[allow(dead_code)]
fn main() {
    let (n,k) = i::u2();
    let mut ans = 1;
    for _ in 0..n {
        if ans < k {
            ans *= 2;
        } else {
            ans += k;
        }
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn u4() -> (usize, usize, usize, usize) {
        (read(), read(), read(), read())
    }

    pub fn u5() -> (usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read())
    }

    pub fn u6() -> (usize, usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn iv3(n: usize) -> Vec<(i64, i64, i64)> {
        (0..n).map(|_| iv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv4(n: usize) -> Vec<(usize, usize, usize, usize)> {
        (0..n)
            .map(|_| uv(4))
            .map(|a| (a[0], a[1], a[2], a[3]))
            .collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}
//  [rust]
use std::io;
use std::cmp::min;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let v:Vec<i32> = procon_read();
	let k = v[0];
	let mut ret = 1;
	for i in 0..n {
		ret = min(2*ret, ret+k)
	}
	println!("{}", ret);
}
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        k: usize,
    }

    let mut x = 1;
    let mut ans = 0;
    for i in 0..(1<<n) {
        for j in 0..n {
            if ((i>>j) & 1)==1 {
                x *= 2;
            } else {
                x += k;
            }
        }
        if i==0 {
            ans = x;
        } else {
            ans = min(ans, x);
        }
        // debug!(ans);
        x = 1;
    }
    println!("{}", ans);
}
//  [rust]
use std::cmp;
use proconio::{input,fastout};

#[fastout]
fn main() {
    input! {
        n: i32,
        k: i32,
    }
    let mut ans = 1;
    for _ in 0..n {
        ans = cmp::min(ans+k, ans*2);
    }
    println!("{}", ans);
}
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        N: usize,
        K: i64,
    }

    let mut ans: i64 = 1;

    for i in 0..N {
        if ans > K {
            ans += K
        } else {
            ans *= 2;
        }
    }

    println!("{}", ans);
}
//  [swift]
let i=(Int(readLine()!)!,Int(readLine()!)!);print((0..<i.0).reduce(1){$0.0+min($0.0,i.1)})
//  [swift]
let N=Int(readLine()!)!,K=Int(readLine()!)!;print((0..<N).reduce(1){i,_ in i+min(i,K)})
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let N = readInt()!
let K = readInt()!
var ans = 1
for i in 0..<N {
    ans += min(ans, K)
}
print(ans)
//  [swift]
let n = Int(readLine()!)!
let k = Int(readLine()!)!
var ans = 1
for _ in 0..<n {
  if ans < k {
    ans *= 2
  } else {
    ans += k
  }
}
print(ans)
//  [swift]
let N=Int(readLine()!)!,K=Int(readLine()!)!
print((0..<N).reduce(1){$0.0+min($0.0,K)})
//  [swift]
let N=Int(readLine()!)!,K=Int(readLine()!)!;print((0..<N).reduce(1){$0.0+min($0.0,K)})
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};
let [N,K]=tnn(2)
const dfs=(n,k)=>{
  if(n==0)return k
  k = min(dfs(n-1,k*2),dfs(n-1,k+K))
  return k
}
const main=()=>{
  to(dfs(N,1))
}
main()
//  [typescript]
function Main(input) {
	const [n, k] = input.split("\n").map(n => Number(n));
  	let result = 1;
  	for (let i = 0; i < n; i++) {
		result += Math.min(result, k);
    }
  	console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);
  const K = Number(input[1][0]);

  let answer = 1;

  for (let i = 0; i < N; i++) {
    answer = Math.min(answer * 2, answer + K);
  }

  return answer;
};

console.log(main(read()));
//  [typescript]
"use strict";

main(require("fs").readFileSync("/dev/stdin", "utf8"));

function main(input) {
  const [n, k] = input.trim().split("\n").map(Number);

  let ans = 1;
  for (let i = 0; i < n; i++) {
    if (ans <= k) {
      ans *= 2;
    } else {
      ans += k;
    }
  }
  console.log(ans);
}
//  [typescript]
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let N = parseInt(xs[0]);
   let K = parseInt(xs[1]);
   let ans = 1;
   for(let i=0; i<N; i++){
    ans = Math.min(ans*2,ans+K);
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [python]
import numpy as np


a,b = map(int,input().split())
large = max(a,b)
small = min(a,b)
diff = large-small
if diff %2 == 1:
    print("IMPOSSIBLE")
else:
    print(small+diff//2)
//  [python]
import sys
import numpy as np
from scipy.misc import comb
sys.setrecursionlimit(1000000)
 
a,b = map(int,input().split())

if abs(a-b) % 2 == 1:
    print("IMPOSSIBLE")
else:
    if a == b:
        print(0)
    elif a < b:
        print(int(abs(a-b) // 2 + a))
    else:
        print(int(abs(a-b) // 2 + b))
//  [python]
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
a,b  =ips()
if (a+b)%2:
    print("IMPOSSIBLE")
else:print((a+b)//2)
//  [java]
import java.util.*;

public class Main{

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();

    long a1,a2=0,b1,b2=0;

    for(long i = 0;i < 1000000000;i++) {

      a1 = a-i;
      a2 = Math.abs(a1);
      b1 = b-i;
      b2 = Math.abs(b1);

      if(a2 == b2) {
        System.out.println(i);
        break;
      }

    }

    if(a2 != b2) {
      System.out.println("IMPOSSIBLE");
    }

  }

}
//  [java]
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    boolean flg=false;
    long k;
    for(k=0;k<1000000000;k++){
      if(Math.abs(a-k)==Math.abs(b-k)){
        flg=true;
        break;
      }
    }
    if(flg){
      System.out.println(k);
    }else{
      System.out.println("IMPOSSIBLE");
    }
  }
}
//  [java]
import java.util.Scanner;

public class Main {
    static long max = (long) Math.pow(10, 9);

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            for (long i = 0L; i < max; i++) {
                if (Math.abs(a - i) == Math.abs(b - i)) {
                    System.out.println(i);
                    return;
                }
            }
            System.out.println("IMPOSSIBLE");
        }
    }
}