Problem:


Score : 200 points

Problem Statement

Square1001 has seen an electric bulletin board displaying the integer 1.
He can perform the following operations A and B to change this value:

Operation A: The displayed value is doubled.

Operation B: The displayed value increases by K.

Square1001 needs to perform these operations N times in total.
Find the minimum possible value displayed in the board after N operations.

Constraints

1 \leq N, K \leq 10

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
K

Output

Print the minimum possible value displayed in the board after N operations.

Sample Input 1

4
3

Sample Output 1

10

The value will be minimized when the operations are performed in the following order: A, A, B, B.

In this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.  

Sample Input 2

10
10

Sample Output 2

76

The value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.

In this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.  

By the way, this contest is AtCoder Beginner Contest 076.



Sample input:
4
3


Sample output:
10

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

ans = 1
for i in range(n):
    if ans > k:
        ans += k
    else:
        ans *= 2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
result = 1

for i in range(N):
  if result*2 >= result+K:
    result += K
  else:
    result *= 2

print(result)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
x = 1
for i in range(n):
  if x<k:
    x*=2
  else:
    x+=k
print(x)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

answer = 1
for i in range(n):
  if answer < k:
    answer *= 2
  else :
    answer += k

print(answer)

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
K = int(input())

def solve(n):
    if n == N:
        return 1

    v = solve(n + 1)
    return min(v * 2, v + K)

print(solve(0))

Submission status: Accepted

Solution code:
import math;n,k=int(input()),int(input());c=int(math.log2(k))+1;d=min(n,c);print(2**d+(n-d)*k)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
num=1
for i in range(n):
  num=min(num*2,num+k)
print(num)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

num = 1

def ope_a(num_local):
    num_local = 2 * num_local
    return num_local

def ope_b(x):
    x = x + k
    return x

i = 0
while i < n:
    if ope_a(num) <= ope_b(num):
        num = ope_a(num)
        i += 1
    else:
        num = ope_b(num)
        i += 1

print(num)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
flg = True
ans = 1
for i in range(n):
    if flg:
        if ans * 2 < ans + k:
            ans *= 2
        else:
            ans += k
            flg = False
    else:
        ans += k
print(ans)

Submission status: Accepted

Solution code:
import sys
N = int(input())
K = int(input())

if not ( 1 <= N <= 10 and 1 <= K <= 10 ):
    sys.exit()

start = 1
for I in range(N):
    if start < K:
        start = start * 2
    else:
        start = start + K

print(start)

Submission status: Accepted

Solution code:
n = int (input())
k = int (input())

num = 1
for i in range(n):
  num = num * 2 if num <= k else num + k
  
print (num)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
num = 1
while N>0:
  if num > K:
    num += K
  else:
    num *=2
  N-=1
print(num)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
n = 1
for i in range(N):
    n = min(n * 2, n + K)
print(n)

Submission status: Accepted

Solution code:
def main():
  n,k = [int(input()) for i in range(2)]
  ans=1
  for i in range(0,n):
    if ans>k:
      ans+=k
    else:
      ans*=2
  print(ans)
main()

Submission status: Accepted

Solution code:
N=int(input())
K=int(input())
ans=1
for i in range(N):
  if 2*ans>=K+ans:
    ans+=K
  else:
    ans*=2
print(ans)

Submission status: Accepted

Solution code:
N =int(input())
K =int(input())
a =1
for i in range(N):
    a += min(a,K)
print(a)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
sum = 1
for i in range(n):
  sum = min(sum*2,sum+k)    
print(sum)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
a=1
for n in range(n):
  a+=min(a,k)
print(a)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
a = 1

for n in range(N):
  a+=min(a,K)

print(a)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
a = 1

for n in range(N):
  a=min(a+K,2*a)

print(a)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
ans = 1
for i in range(N):
	ans = min(ans*2,ans+K)
print(ans)

Submission status: Accepted

Solution code:
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = ii()
    K = ii()
    ans = 1
    for i in range(N):
        ans = min(ans+K, 2*ans)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
p = 1
for i in range(n):
    if p * 2 < p + k:
        p *= 2
    else:
        p += k

print(p)

Submission status: Accepted

Solution code:
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
k = int(input())
ans = 1
for i in range(n):
    ans = min(ans*2, ans+k)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
start=1
for i in range(n):
  start=min(start*2,start+k)
print(start)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

ans = 1
for i in range(n):
    ans = min(2 * ans, ans + k)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
result = 1
for i in range(n):
    if result*2 > result+k:
        result += k
    else:
        result += result

print(result)

Submission status: Accepted

Solution code:
x = 1
n = int(input())
k = int(input())

for i in range(n):
    if x*2 > x+k:
        x += k
    else:
        x *= 2
print(x)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
m = 1
for i in range(n):
  m += min(m, k)
print(m)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
a = 1

for i in range(N):
    if a*2 > a+K:
        a += K
    else:
        a *= 2

print(a)

Submission status: Accepted

Solution code:
q = 1
N = int(input())
K = int(input())
for i in range(N):
    q = min(2 * q, q + K)
print(q)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
ans = 1
for i in range(n):
    if ans*2 >= ans+k:
        ans += k
    else:
        ans = ans*2
print(ans)

Submission status: Accepted

Solution code:
from math import log2
n = int(input())
k = int(input())
temp = min(int(log2(k)) + 1, n)
print(2 ** temp + k * (n - temp))

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
ans = 1
for _ in range(n):
    ans += ans if ans < k else k
print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    K = int(input())

    ans = 1
    for _ in range(N):
        if 2 * ans < ans + K:
            ans *= 2
        else:
            ans += K

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())

sum = 1
for i in range(N):
    sum = min(sum * 2, sum + K)
print(sum)

Submission status: Accepted

Solution code:
N=int(input()) 
K=int(input()) 

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

print(num)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

i = 0
ans = 1
while True:
    if i == n:
        print (ans)
        exit ()
    else:
        i += 1
        if ans*2 < ans+k:
            ans *= 2
        else:
            ans += k

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n =int(input())
    k =int(input())
    count =1

    for i in range(n):
        if count > k:
            count +=k
        else:
            count =count*2

    print(count)

Submission status: Accepted

Solution code:
a = 1
n = int(input())
k = int(input())
for _ in range(n):
    a = min(a + k, a * 2)
print(a)

Submission status: Accepted

Solution code:
N,K=int(input()),int(input());n=1
for i in range(N):
  n=min(n*2,n+K)
print(n)

Submission status: Accepted

Solution code:
N,K=int(input()),int(input())
num=1
for i in range(N):
  num=min(num*2,num+K)
print(num)

Submission status: Accepted

Solution code:
N,K=int(input()),int(input())
num = 1
for i in range(N):
  if num < K:
    num *= 2
  else:
    num += K
print(num)

Submission status: Accepted

Solution code:
N=int(input())
K=int(input())
cur_val=1
for i in range(0,N):
  cur_val=min(cur_val*2,cur_val+K)
print(cur_val)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
num = 1
for x in range(N):
    if num * 2 < num + K:
        num *= 2
    else:
        num += K
print(num)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())

c=0
x=1
for i in range(n):
    if x>k:
        break
    else:
        x=x*2
        c+=1
for j in range(n-c):
    x+=k

print(x)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
a = 1
for i in range(n):
    a = min(a*2, a+k)
print(a)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())

ans = 1
for i in range(N):
    ans = min(ans*2, ans+K)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
s=1
for i in range(n):
    s=min(s*2,s+k)
print(s)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())

tmp=1
num=1
while n>0:
    if tmp<k:
        num*=2
        tmp*=2
    else:
        num+=k
    n-=1

print(num)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())

now = 1
for i in range(N):
    if now <= K:
        now *= 2
    else:
        now+=K
print(now)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

i = 0
m = 1
while True:
  if m < k:
    m = m*2
    i += 1
  else:
    break
    
if i <= n :
  print(2**i + k * (n-i))
else :
  print(2**n)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    K = int(input())
    ans = 1
    for i in range(N):
        if ans < K:
            ans *= 2
        else:
            ans += K
    print(ans)
resolve()

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
x=1
for i in range(n):
  if x<k:
    x*=2
  else:
    x+=k
print(x)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
a = 1
for i in range(n):
    if a*2<a+k:
        a *= 2
    else :
        a += k
print(a)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())

ans=1

for i in range(n):
  ans=min(ans*2,ans+k)
  
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
a = 1
for i in range(N):
  if a < K:
    a *= 2
  else:
    a += K
print(a)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
ans = 1

for _ in range(n):
  ans = min(ans +k, ans*2)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
K=int(input())
ans=1
for i in range(N):
  ans=min(ans+K,ans*2)
print(ans)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    K = int(readline())
    a = 1
    for _ in range(N):
        a = min(a+K, a*2)
    print(a)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
tmp = 1
i = 0
while True:
  a = 0
  b = 0
  if i == n:
    break
  else:
    a = tmp * 2
    b = tmp + k
    tmp = min(a,b)
    #print(tmp)
    i += 1
print(tmp)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
now = 1
for i in range(N):
  if now <= K:
    now *= 2
  else:
    now += K
print(now)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

ans = 1
while n > 0:
    a = ans * 2;
    b = ans + k
    ans = min(a, b)
    n -= 1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())

ans=1
for i in range(n):
  if ans<k:
    ans*=2
  else:
    ans+=k
    
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
ans=1
for i in range(n):
    multi=ans*2
    add=ans+k
    ans=min(multi,add)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
ans = 1
for i in range(n):
  ans = min(ans * 2, ans + k)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
ans = 1000000000000
for i in range(2 ** N):
    num = 1
    for j in range(N):
        if i & (1 << j):
            num *= 2
        else:
            num += K
    ans = min(ans, num)
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    K = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    c=1
    for _ in range(N):
        c=min(c+K,c*2)
    print(c)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from itertools import combinations_with_replacement

N = int(input())
K = int(input())


def times_two(n):
    return 2 * n


def plus_k(n):
    return n + K


ans = []
for funcs in combinations_with_replacement((times_two, plus_k), N):
    value = 1
    for func in funcs:
        value = func(value)
    ans.append(value)
print(min(ans))

Submission status: Accepted

Solution code:
from itertools import product

n = int(input())
k = int(input())

li = [0,1]

lin = list(product(li, repeat=n))
mi = 10**18

for i in lin:
    point = 1
    for j in i:
        if j == 0:
            point *= 2
        else:
            point += k
    mi = min(point,mi)

print(mi)

Submission status: Accepted

Solution code:
def main():
    N, K = (int(input()) for _ in range(2))

    x = 1
    for _ in range(N):
        x += min(K, x)
    print(x)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    k=int(input())
    ans=1
    for i in range(n):
        ans=min(ans+k,ans*2)
    print(ans)
resolve()

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
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 i in range(n):
    now = min(now+k, now*2)
print(now)

Submission status: Accepted

Solution code:
#import collections
n=int(input())
#a,b=map(int,input().split())
#a=list(map(int,input().split()))
#n=int(input())
#s=input()
#mod=10**9+7

k=int(input())
ans=1
for i in range(n):
  if ans>k:
    ans+=k
  else:
    ans=2*ans
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())

ans = 1

for i in range(N):
    if ans*2-ans < K:
        ans *= 2
    else:
        ans += K
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
num = 1
for i in range(N):
    if num > K:
        num += K
    else:
        num = num*2
print(num)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
now = 1
for i in range(N):
  now = min(now+K,now*2)
print(now)

Submission status: Accepted

Solution code:
def resolve():
  n = int(input())
  k = int(input())
  ans = 1
  for i in range(n):
    if ans * 2 < ans + k:
      ans *= 2
    else:
      ans += k
  print(ans)
  return

if __name__ == "__main__":
  resolve()

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
ans = 1
for i in range(n):
    if ans > k:
        ans += k
    else:
        ans *= 2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())

MIN = 10**18
for i in range(2**N):
    s = 1
    for j in range(N):
        if ((i >> j) & 1):
            s *= 2
        else:
            s += K
    MIN = min(s,MIN)
print(MIN)

Submission status: Accepted

Solution code:
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
k = int(input())
ans = 1
for i in range(n):
    if ans+k < ans*2:
        ans = ans+k
    else:
        ans = ans*2
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
v=1
for i in range(n):
  v=min(v*2,v+k)
print(v)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
ans = 1
for i in range(N):
  if ans <= K:
    ans *= 2
  else:
    ans += K
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

ans = 1
for _ in range(n):
    ans = min(ans * 2, ans + k)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
ans = 1
for i in range(n):
    ans = min(ans*2, ans+k)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())

ans = 1
for _ in range(N):
    if ans <= K:
        ans *= 2
    else:
        ans += K
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

N = ni()
K = ni()


def solve():
    x = 1
    for i in range(N):
        x = min(2 * x, x + K)
    return x


print(solve())

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    k = int(input())

    res = 1
    for _ in range(n):
        if res < k:
            res *= 2
        else:
            res += k

    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())

a = 1
for i in range(N):
    if a*2 < a+K:
        a *= 2
    else:
        a += K
print(a)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

a = 1
for i in range(n):
    a = min(a * 2, a + k)
print(a)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

for i in range(5):
    a = 2**i
    if a >= k:
        b = i
        break

res = 1

res = res*(2**(min(n,b))) + k*max(0,(n-b))
print(res)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())

now = 1
for i in range(N):
  now = min(now*2, now+K)

print(now)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
ans = float('inf')

for i in range(2**N):
  now = 1
  for j in range(N):
    if i>>j & 1:
      now *= 2
    else:
      now += K
  ans = min(ans, now)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    k = ii()
    num = 1
    for _ in range(n):
        num = min(num * 2, num + k)
    print(num)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
K=int(input())
number=1
for _ in range(N):
    if number*2>number+K:
        number=number+K
    else:
        number=number*2
print(number)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
m = 1
for i in range(n):
    if m >= k:
        m += k
    else:
        m *= 2
print(m)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

ans = 1
for i in range(n):
    ans = min(ans * 2, ans + k)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
s = 1

while n > 0:
    if s > k:
        while n > 0:
            s += k
            n -= 1
    else:
        s *= 2
        n -= 1
print(s)

Submission status: Accepted

Solution code:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

def main():
    n = II()
    k = II()
    ans = 1
    for i in range(n):
        if ans < k:
            ans *= 2
        else:
            ans += k
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import queue

N = int(input())
K = int(input())

que = queue.Queue()
que.put((1, 0))

min = -1
while (True):
    if que.empty():
        break
    test = que.get()
    # print(test)
    num = test[0]
    count = test[1]
    if count == N:
        if min == -1 or min > test[0]:
            min = test[0]
        continue
    que.put((num * 2, count + 1))
    que.put((num + K, count + 1))
print(min)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
ans = 1
for i in range(n):
    ans += min(ans, k)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
ans = 1

for i in range(1,N+1):
  if 2**(i-1) < K:
    ans = ans + 2**(i-1)
  else:
    ans = ans + K
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

ans = 1

for _ in range(n):
    ans = min(ans*2, ans+k)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())

ans = 1
for _ in range(N):
    if ans < K:
        ans *= 2
    else:
        ans += K
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())

ans = 10**18
for state in range(1 << N):
    now = 1
    for d in range(N):
        if (state & (1 << d)) == 0:
            now *= 2
        else:
            now += K
    ans = min(ans, now)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

ans = 1
for i in range(n):
    ans += min(ans*2-ans, k)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
K=int(input())
d=1
for i in range(N):
	d=min(d*2,d+K)
print(d)

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

temp = 1
for _ in range(n):
    temp = min(temp + k, temp * 2)


print(temp)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    K = ii()

    ret = 1
    for i in range(N):
        if ret * 2 > ret + K:
            ret += K
        else:
            ret *= 2
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())

l = list()

for bit in range((1 << n)+1):
    num = 1
    for i in range(n):
        if bit & (1 << i):
            num *= 2
        else:
            num += k
    l.append(num)

print(min(l))

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
sum=1
for i in range(n):
    if sum+k > sum*2:
        sum*=2
    else:
        sum += k
print(sum)

Submission status: Accepted

Solution code:
N=int(input())
K=int(input())
ans=1
for i in range(N):
    ans=min(ans*2,ans+K)
print(ans)