ZhenlongDai/ACPR huggingface dataset:
Problem: p02813
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

all_pattern = list(itertools.permutations([i for i in range(1,N+1)]))
print(all_pattern)

for i, node in enumerate(all_pattern):
  print(node)
  if node == P:
    p = i
  if node ==  Q:
    q = i
    
    
print(abs(p-q))


Failing test case input:
3
1 3 2
3 1 2

Expected output:
3

Actual output:
[(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)]
(1, 2, 3)
(1, 3, 2)
(2, 1, 3)
(2, 3, 1)
(3, 1, 2)
(3, 2, 1)
3


Fixed submission (verdict: Accepted):
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

all_pattern = list(itertools.permutations([i for i in range(1,N+1)]))


for i, node in enumerate(all_pattern):
  
  if node == P:
    p = i
  if node ==  Q:
    q = i
    
    
print(abs(p-q))

Problem: p02813
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

s = []
for i in range(N):
  s.append(i)
p_list = list(itertools.permutations(s))

p_n = 0
q_n = 0
for i in range(len(p_list)):
  if p == p_list[i]:
    p_n = i
  if q == p_list[i]:
    q_n = i
    
print(p_n - q_n) if p_n >= q_n else print(q_n - p_n)


Failing test case input:
3
1 3 2
3 1 2

Expected output:
3

Actual output:
0


Fixed submission (verdict: Accepted):
import itertools
N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

s = []
for i in range(N):
  s.append(i+1)
p_list = list(itertools.permutations(s))

p_n = 0
q_n = 0
for i in range(len(p_list)):
  if p == p_list[i]:
    p_n = i
  if q == p_list[i]:
    q_n = i
    
print(p_n - q_n) if p_n >= q_n else print(q_n - p_n)

Problem: p02813
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))


pos = 0
pos_p = 0
pos_q = 0
for i in itertools.permutations(range(1,4)):
    pos += 1
    print(type(i), i)
    if i == P:
        pos_p = pos
    if i == Q:
        pos_q = pos

print(abs(pos_p - pos_q))



Failing test case input:
3
1 3 2
3 1 2

Expected output:
3

Actual output:
<class 'tuple'> (1, 2, 3)
<class 'tuple'> (1, 3, 2)
<class 'tuple'> (2, 1, 3)
<class 'tuple'> (2, 3, 1)
<class 'tuple'> (3, 1, 2)
<class 'tuple'> (3, 2, 1)
3


Fixed submission (verdict: Accepted):
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))


pos = 0
pos_p = 0
pos_q = 0
for i in itertools.permutations(range(1,N + 1)):
    pos += 1
    if i == P:
        pos_p = pos
    if i == Q:
        pos_q = pos

print(abs(pos_p - pos_q))
Problem: p02813
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())
p = [x for x in stdin.readline().rstrip().split()]
q = [x for x in stdin.readline().rstrip().split()]

x = ()
y = ()
for pp in p:
    x = x + (pp,)
for qq in q:
    y = y + (qq,)

print(x)

c = []
for i in itertools.permutations([str(j) for j in range(1,n+1)]):
    c.append(i)

print(c)

a = c.index(x)
b = c.index(y)

print (abs(b-a))

Failing test case input:
3
1 3 2
3 1 2

Expected output:
3

Actual output:
('1', '3', '2')
[('1', '2', '3'), ('1', '3', '2'), ('2', '1', '3'), ('2', '3', '1'), ('3', '1', '2'), ('3', '2', '1')]
3


Fixed submission (verdict: Accepted):
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())
p = [x for x in stdin.readline().rstrip().split()]
q = [x for x in stdin.readline().rstrip().split()]

x = ()
y = ()
for pp in p:
    x = x + (pp,)
for qq in q:
    y = y + (qq,)

c = []
for i in itertools.permutations([str(j) for j in range(1,n+1)]):
    c.append(i)
    
a = c.index(x)
b = c.index(y)

print (abs(b-a))
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def read():
    return int(input())

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

k,a,b=reads()
k2 = 0
if (b-a)/2 <= 1:
    print(1+k)
else:
    k2 = k-a+1
    if k2 >= 2:
        if k2 % 2 == 0:
            print(int(a + (b-a)*k2/2)+3)
        else:
            print(int(a + (b-a)*(k2-1)/2 + 1))
    else:
        print(1 + k)

Failing test case input:
1111 0 3

Expected output:
1668


Actual output:
1671


Fixed submission (verdict: Accepted):
def read():
    return int(input())

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

k,a,b=reads()
k2 = 0
if (b-a)/2 <= 1:
    print(1+k)
else:
    k2 = k-a+1
    if k2 >= 2:
        print(int(a + (b-a)*(k2-k2%2)
    else:
        print(1 + k)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, a, b = map(int, input().split())
if a >= b - 2 or a > k:
  print(int(k+1))
elif (k-a+1)%2 == 0:
  print(int((b-a)*(k-a+1)/2+a))
else:
  print(int((b-a)*(k-a)/2+1+a))

Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938096


Fixed submission (verdict: Accepted):
k, a, b = map(int, input().split())
if a >= b - 2 or a > k:
  print(int(k+1))
elif (k-a+1)%2 == 0:
  print(int((b-a)*(k-a+1)
else:
  print(int((b-a)*(k-a)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K,A,B = map(int,input().split())
K += 1
if K >= A + 1 and A + 1 < B:
  ans = int((K - A) / 2) * (B - A) + A + (1 if K % 2 == 1 else 0)
  print(ans)
else:
  ans = K
  print(ans)

Failing test case input:
0100 -1 2

Expected output:
152


Actual output:
153


Fixed submission (verdict: Accepted):
K,A,B = map(int,input().split())
K += 1
if K >= A + 1 and A + 2 < B:
  ans = int((K - A) / 2) * (B - A) + A + (1 if (K - A) % 2 == 1 else 0)
  print(ans)
else:
  ans = K
  print(ans)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0

if K < A + 1 or B - A <  A  or B - A < 3 :
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)


Failing test case input:
407766107 9307229 14836778

Expected output:
1101648954500241


Actual output:
407766108


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k,a,b = map(int,input().split())
if a >= b+2:
  print(k+1)
else:
  d = k-(a-1)
  e = a
  e += (b-a)*d
  e += d%2
  print(e)

Failing test case input:
407766107 9307229 25447105

Expected output:
3215538450316794


Actual output:
6431076907466234


Fixed submission (verdict: Accepted):
k,a,b = map(int,input().split())
if a >= b-2:
  print(k+1)
else:
  d = k-(a-1)
  e = a
  e += (b-a)*(d
  e += d%2
  print(e)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, a, b = map(int, input().split())

money = 0
cookie = 0
move = k

if a + 2 < b:
    action = int((k-(a-1))/2)
    cookie += b
    if action > 1:
        cookie += (action-1)*(b-a)
    if ((k-(a-1))/2) - action > 0:
        cookie += 1
else:
    cookie = k + 1


print('{}'.format(cookie))

Failing test case input:
3 3 6

Expected output:
4


Actual output:
7


Fixed submission (verdict: Accepted):
k, a, b = map(int, input().split())

cookie = 0

if a + 2 >= b or k + 1 < a:
    cookie = k + 1
else:
    action = int((k-(a-1))/2)
    cookie = a
    if action >= 1:
        cookie += action*(b-a)
    if (k-(a-1))/2 - action > 0:
        cookie += 1

print('{}'.format(cookie))

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k,a,b = map(int,input().split())
counter = k
x = 1
s = 0

if a >= b or (a < b and b - a <= 2) or counter < a - 1:
    x = 1+k
elif a < b and b - a > 2:
    counter -= a-1
    x += a-1
    if counter > 1 and counter % 2 == 0:
        z = int(counter/2)
        x += int((b-a)*z)
    elif counter > 1 and counter % 2 == 1:
        z = int(counter/2)
        x += int((b-a)*(z + 1))
    elif counter == 1:
        x += 1


print(x)

Failing test case input:
407766107 9307229 14836778

Expected output:
1101648954500241


Actual output:
1101648960029789


Fixed submission (verdict: Accepted):
k,a,b = map(int,input().split())
counter = k
x = 1
s = 0

if a >= b or (a < b and b - a <= 2) or counter < a - 1:
    x = 1+k
elif a < b and b - a > 2:
    counter -= a-1
    x += a-1
    if counter > 1 and counter % 2 == 0:
        z = int(counter/2)
        x += int((b-a)*z)
    elif counter > 1 and counter % 2 == 1:
        z = int(counter/2)
        x += int((b-a)*z + 1)
    elif counter == 1:
        x += 1


print(x)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K, A, B = map(int, input().split())

if (B - A) / 2 <= 1 or K < A + 2: 
    ans = (K + 1)
else: 
    n = (K - A - 1)
    if n % 2 == 0:
        ans = (B + (B-A)*n/2)
    else:
        ans = (B + (B-A)*int(n/2) + 1)

if ans < (10**15):
    print(ans)
else:
    print('{0}{1}'.format(int(ans/(10**15)), int(ans % (10**15))))





Failing test case input:
0011 0 4

Expected output:
24


Actual output:
24.0


Fixed submission (verdict: Accepted):
K, A, B = map(int, input().split())

if (B - A) / 2 <= 1 or K < A + 1: 
    ans = (K + 1)
else: 
    n = (K - A - 1)
    if n % 2 == 0:
        ans = (B + (B-A)*int(n/2))
    else:
        ans = (B + (B-A)*int(n/2) + 1)

print(ans)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys



def solve(lines):
    K,A,B = map(int, lines.pop(0).split(' '))
    if A >= B:
        print(K+1)
        sys.exit(0)
    elif B - A <= 2:
        print(K+1)
        sys.exit(0)

    if K < A+1:
        print(K+1)
        sys.exit(0)
    elif K == A+1 and K > B:
        print(K+1)
        sys.exit(0)

    K -= A+1
    res = B

    n = int(K / 2)
    res += n*(B-A)
    K -= n

    if K == 1:
        res += 1

    print(res)




lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

Failing test case input:
407766107 9307229 14836778

Expected output:
1101648954500241


Actual output:
1101648954500240


Fixed submission (verdict: Accepted):

import sys



def solve(lines):
    K,A,B = map(int, lines.pop(0).split(' '))
    if A >= B:
        print(K+1)
        sys.exit(0)
    elif B - A <= 2:
        print(K+1)
        sys.exit(0)

    if K < A+1:
        print(K+1)
        sys.exit(0)
    elif K == A+1 and K > B:
        print(K+1)
        sys.exit(0)

    K -= A+1
    res = B

    n = int(K / 2)
    res += n*(B-A)
    K -= 2 * n

    if K == 1:
        res += 1

    print(res)




lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

Problem: p03131
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
arr = input().split()
K = int(arr[0])
A = int(arr[1])
B = int(arr[2])

n = 1 + K

x = B
K -= A+1

temp = int(K / 2)

x += temp * (B-A)
K -= temp * 2

while K > 0:
	K -= 1
	x += 1

print(max(x, n))


Failing test case input:
10710598 31853258 3849

Expected output:
10710599


Actual output:
336690612847819


Fixed submission (verdict: Accepted):
arr = input().split()
K = int(arr[0])
A = int(arr[1])
B = int(arr[2])

n = 1 + K
x = 1
if K > A:
	x = B
	K -= A+1

	temp = int(K / 2)

	x += temp * (B-A)
	K -= temp * 2

	while K > 0:
		K -= 1
		x += 1

print(max(x, n))

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K, A, B = input().split()
K = int(K)
A = int(A)
B = int(B)
N = 1

if A+2 > B:
    N = N + K
else:
    
    if K > (A + 1):
        
        K = K - (A + 1)
        N = B
        
        if K % 2 == 0:
            N = N + (B*K/2) - (A*K/2)
        else:
            K = K - 1
            N = N + (B*K/2) - (A*K/2) + 1
    else:
        N = N + K
print(int(N))

Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938096


Fixed submission (verdict: Accepted):
K, A, B = input().split()
K = int(K)
A = int(A)
B = int(B)
N = 1

if A+2 > B:
    N = N + K
else:
    
    if K > A:
        
        K = K - (A + 1)
        N = B
        if K > 0:
            
            if K % 2 == 0:
                N = N + (B*K
            else:
                K = K - 1
                N = N + (B*K
    else:
        
        N = N + K
print(N)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
In = list(map(int, input().split()))
K = In[0]
A = In[1]
B = In[2]

if A >= B:
    print(1 + K)
elif A + 1 == B:
    print(1 + K)
elif A + 2 == B:
    print(1 + K)
else:
    n = A - 1 
    if (K - n) % 2 == 0:
        print(A + (B - A) * (K - n) / 2)
    else:
        print(A + (B - A) * int((K - n)/2) + 1)

Failing test case input:
1010 1 4

Expected output:
1516


Actual output:
1516.0


Fixed submission (verdict: Accepted):
In = list(map(int, input().split()))
K = In[0]
A = In[1]
B = In[2]

if A >= B:
    print(1 + K)
elif A + 1 == B:
    print(1 + K)
elif A + 2 == B:
    print(1 + K)
else:
    n = A - 1 
    if (K - n) % 2 == 0:
        print(A + (B - A) * (K - n) 
    else:
        num = 1 + A + (B - A) * (K - n - 1) 
        print(num)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

K, A, B = map(int, input().split())

need_turns = A + 1 + 1  
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  
    print(1 + K)
    exit()

ans = B  
K -= (need_turns - 1)



while K >= 0:
    if ans >= A and K >= 2:
        ans += (B - A) * K / 2
        K = 0
        
    else:
        ans += 1
        K -= 1
        

Failing test case input:
1011 1 4

Expected output:
1517


Actual output:

Fixed submission (verdict: Accepted):
K, A, B = map(int, input().split())

need_turns = A + 1 + 1  
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  
    print(1 + K)
    exit()

ans = B  
K -= (need_turns - 1)



while K > 0:
    if ans >= A and K >= 2:
        ans += (B - A) * int(K / 2)
        K = K % 2
    else:
        ans += 1
        K -= 1

print(ans)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def read():
    return int(input())

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

k,a,b=reads()
k2 = 0
if (b-a)/2 <= 1:
    print(1+k)
else:
    k2 = k-a+1
    if k2 >= 2:
        if k2 % 2 == 0:
            print(int(a + (b-a)*k2/2)+3)
        else:
            print(int(a + (b-a)*(k2-1)/2 + 1))
    else:
        print(2+k)


Failing test case input:
0100 -1 2

Expected output:
152


Actual output:
155


Fixed submission (verdict: Accepted):
def read():
    return int(input())

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

k,a,b=reads()
k2 = 0
if (b-a)/2 <= 1:
    print(1+k)
else:
    k2 = k-a+1
    if k2 >= 2:
        print(int(a + (b-a)*(k2-k2%2)
    else:
        print(1 + k)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, a, b = [int(i) for i in input().split()]

sum = 0
if a >= b:
    
    sum = k + 1
else:
    
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    else:
        
        k = 1 + k - a
        if k % 2 == 0:
            sum = a + ((diff) * (k / 2))
        else:
            
            sum = a + ((diff) * ((k - 1) / 2)) + 1

print(sum)


Failing test case input:
1011 0 3

Expected output:
1518


Actual output:
1518.0


Fixed submission (verdict: Accepted):
k, a, b = [int(i) for i in input().split()]

sum = 0
if a >= b:
    
    
    sum = k + 1
else:
    
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    elif diff >= 3:
        
        rest = 1 + k - a

        if rest >= 0:
            if rest % 2 == 0:
                sum = a + ((diff) * int(rest / 2))


            else:
                
                sum = a + ((diff) * int((rest - 1) / 2)) + 1


        else:
            sum = k + 1
                
print(int(sum))

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def read():
    return int(input())

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

k,a,b=reads()
k2 = 0
if (b-a)/2 <= 1:
    print(1+k)
else:
    k2 = k-a+1
    if k2 >= 2:
        if k2 % 2 == 0:
            print(int(a + (b-a)*k2/2))
        else:
            print(int(a + (b-a)*(k2-1)/2 + 1))
    else:
        print(1 + k)

Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938096


Fixed submission (verdict: Accepted):
def read():
    return int(input())

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

k,a,b=reads()
k2 = 0
if (b-a)/2 <= 1:
    print(1+k)
else:
    k2 = k-a+1
    if k2 >= 2:
        print(int(a + (b-a)*(k2-k2%2)
    else:
        print(1 + k)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def calc_max_biscuit(K,A,B):
    
    hit_only = 1+K
    sell_and_buy = 0
    if B-A<1:
        print(hit_only)
    else:
        K -= A-1
        sell_and_buy = int(K/2)*(B-A)
        print(max(sell_and_buy, hit_only))
        
K, A, B = list(map(int, input().split()))
calc_max_biscuit(K,A,B)

Failing test case input:
1110 0 4

Expected output:
2221


Actual output:
2220


Fixed submission (verdict: Accepted):
def calc_max_biscuit(K,A,B):
    
    hit_only = 1+K
    sell_and_buy = 0
    if B-A<1:
        print(hit_only)
    else:
        K -= (A-1)
        if K%2==0:
            sell_and_buy = A + int(K/2)*(B-A)
        else:
            sell_and_buy = A + int(K/2)*(B-A)+1
        print(max(sell_and_buy, hit_only))
        
K, A, B = list(map(int, input().split()))
calc_max_biscuit(K,A,B)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0
 
if K < A + 1 or B - A <  A + 1 or B - A < 2:
    print(K + 1)
 
else:
    cookie = B
    K = K-A-1
 
    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Failing test case input:
407766107 9307229 14836778

Expected output:
1101648954500241


Actual output:
407766108


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0

if K < A + 1 or B - A <  A + 2 or B - A < 3 :
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)


Failing test case input:
5 3 6

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0

if K < A + 2 or B - A <  A  or B - A < 2:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)


Failing test case input:
407766107 9307229 14836778

Expected output:
1101648954500241


Actual output:
407766108


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0
 




cookie = B
K = K-A-1

if K%2==0:
    cookie += (B-A)* math.floor(K/2)
    print(cookie)
else:
    cookie += (B-A)*math.floor((K-1)/2)
    print(cookie + 1)


Failing test case input:
5043377 14592 21

Expected output:
5043378


Actual output:
-36637205811


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K,A,B = (int(x) for x in input().split())
total = 0
if(B-A<3):
    print(K+1)
else:
    if((K-(A+1))%2 == 0):
        total = B + ((B-A)*((K-A-1)/2))
    else:
        total = B + ((B-A)*(int((K-A-1)/2))) + 1
    print(int(total))



Failing test case input:
3 3 6

Expected output:
4


Actual output:
7


Fixed submission (verdict: Accepted):
K,A,B = (int(x) for x in input().split())
total = 0
if(B-A<3):
    print(K+1)
    exit()
else:
    if((K-(A+1))%2 == 0):
        print(B + (K-(A+1))
    else:
        print(B + (K-(A+1))

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if B - A <= 2:
        print(K + 1)
    else :
        if K <= A - 1:
            print (1 + K)
        else:
            K -= A - 1
            if K % 2 == 0:
                print (int(A + (K / 2) * (B - A)))
            else:
                print (int(A + ((K - 1) / 2) * (B - A) + 1))

Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938096


Fixed submission (verdict: Accepted):
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if B - A <= 2:
        print(K + 1)
    else :
        
        if K <= A-1:
            print(1 + K)
        else:
            
            rest = K - (A - 1)
            if rest < 2:
                print(1 + K)
            else:
                q,r = divmod(rest,2)
                print(A + q * (B - A) + r)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if A > B:
        print(1 + K)
    elif B - A == 1:
        print(1 + K)
    else :
        if K < A - 1:
            print (1 + K)
        else:
            K -= A - 1
            if K % 2 == 0:
                print (A + (K / 2) * (B - A))
            else:
                print (A + ((K - 1) / 2) * (B - A) + 1)

Failing test case input:
1110 0 4

Expected output:
2221


Actual output:
2221.0


Fixed submission (verdict: Accepted):
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if B - A <= 2:
        print(K + 1)
    else :
        
        if K <= A-1:
            print(1 + K)
        else:
            
            rest = K - (A - 1)
            if rest < 2:
                print(1 + K)
            else:
                q,r = divmod(rest,2)
                print(A + q * (B - A) + r)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if A >= B:
        print(1 + K)
    elif B - A == 1:
        print(1 + K)
    else :
        if K < A - 1:
            print (1 + K)
        else:
            K -= A - 1
            if K % 2 == 0:
                print (int(A + (K / 2) * (B - A)))
            else:
                print (int(A + ((K - 1) / 2) * (B - A) + 1))

Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938096


Fixed submission (verdict: Accepted):
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if B - A <= 2:
        print(K + 1)
    else :
        
        if K <= A-1:
            print(1 + K)
        else:
            
            rest = K - (A - 1)
            if rest < 2:
                print(1 + K)
            else:
                q,r = divmod(rest,2)
                print(A + q * (B - A) + r)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K, A, B = list(map(int, input().split()))

cnt = 1

if K < A + 1:
    cnt += K + 1
    print(cnt)
    exit()

rest = K - (A - 1)
cnt += (A - 1)

if (B - A) > 2:
    if (rest%2 == 0):
        cnt += (B - A) * int(rest / 2)
    else:
        cnt += (B - A) * (int(rest - 1) / 2)
        cnt += 1
else:
    cnt += rest

print(int(cnt))


Failing test case input:
5989273 13033115 38769

Expected output:
5989274


Actual output:
5989275


Fixed submission (verdict: Accepted):
K, A, B = list(map(int, input().split()))

if (A + 2 >= B):
    print(K + 1)
elif (A >= K):
    print(K + 1)
else:
    rest = K - (A - 1)
    if (rest%2 == 0):
        print((B - A) * int(rest / 2) + A)
    else:
        print((B - A) * int(rest / 2) + A + 1)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k,a,b=map(int,input().split())

if (b-a)/2<=1:
    print(k+1)
else:
    s=k-a-1
    if s%2==0:
        print(int((s/2+1)*b-(s*a)/2))
    else:
        s1=s-1
        print(int((s1/2+1)*b-(s1*a)/2+1))

Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938096


Fixed submission (verdict: Accepted):
k,a,b=map(int,input().split())

if (b-a)/2<=1:
    print(k+1)
else:
    s=k-a-1
    if s%2==0:
        print(int((s
    else:
        s1=s-1
        print(int((s1

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K, A, B = map(int, input().split())

if (B - A) / 2 <= 1 or K < A + 2: 
    print(K + 1)
else: 
    n = (K - A - 1)
    if n % 2 == 0:
        print(B + (B-A)*n/2)
    else:
        print(B + (B-A)*int(n/2) + 1)

Failing test case input:
1010 1 4

Expected output:
1516


Actual output:
1516.0


Fixed submission (verdict: Accepted):
K, A, B = map(int, input().split())

if (B - A) / 2 <= 1 or K < A + 1: 
    ans = (K + 1)
else: 
    n = (K - A - 1)
    if n % 2 == 0:
        ans = (B + (B-A)*int(n/2))
    else:
        ans = (B + (B-A)*int(n/2) + 1)

print(ans)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

K, A, B = map(int, input().split())

need_turns = A + 1 + 1  
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  
    print(1 + K)
    exit()

ans = B  
K -= (need_turns - 1)



while K >= 0:
    if ans >= A and K >= 2:
        ans += (B - A) * K / 2
        K = 0
    else:
        ans += 1
        K -= 1

print(ans)

Failing test case input:
1110 0 3

Expected output:
1666


Actual output:
1667.5


Fixed submission (verdict: Accepted):
K, A, B = map(int, input().split())

need_turns = A + 1 + 1  
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  
    print(1 + K)
    exit()

ans = B  
K -= (need_turns - 1)



while K > 0:
    if ans >= A and K >= 2:
        ans += (B - A) * int(K / 2)
        K = K % 2
    else:
        ans += 1
        K -= 1

print(ans)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, a, b = map(int, input().split())
if a >= b - 2 or a > k:
  print(int(k+1))
elif (k-a+1)%2 == 0:
  print((b-a)*(k-a+1)/2+a)
else:
  print((b-a)*(k-a)/2+1+a)

Failing test case input:
1011 1 4

Expected output:
1517


Actual output:
1517.0


Fixed submission (verdict: Accepted):
k, a, b = map(int, input().split())
if a >= b - 2 or a > k:
  print(int(k+1))
elif (k-a+1)%2 == 0:
  print(int((b-a)*(k-a+1)
else:
  print(int((b-a)*(k-a)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K,A,B = [int(i) for i in input().split()]

if (B-A < 2+A):
    print(K+1)
    exit(0)

else:
    t = int((K-A+1)/2)
    ans = t * (B-A) + A + ((K-A+1)%2)
    print(ans)


Failing test case input:
407766107 9307229 14836778

Expected output:
1101648954500241


Actual output:
407766108


Fixed submission (verdict: Accepted):
K,A,B = [int(i) for i in input().split()]

if (B-A <= 2):
    print(K+1)
else:
    t = int((K-A+1)/2)
    ans = t * (B-A) + A + ((K-A+1)%2)
    print(ans)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if A > B:
        print(1 + K)
    elif B - A == 1:
        print(1 + K)
    else :
        if K < A - 1:
            print (1 + K)
        else:
            K -= A - 1
            if K % 2 == 0:
                print (int(A + (K / 2) * (B - A)))
            else:
                print (int(A + ((K - 1) / 2) * (B - A) + 1))

Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938096


Fixed submission (verdict: Accepted):
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if B - A <= 2:
        print(K + 1)
    else :
        
        if K <= A-1:
            print(1 + K)
        else:
            
            rest = K - (A - 1)
            if rest < 2:
                print(1 + K)
            else:
                q,r = divmod(rest,2)
                print(A + q * (B - A) + r)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K,A,B = map(int,input().split())

if B <= A+2:
  print(K+1)
  exit(0)
  
K -= A - 1
p,q = divmod(K,2)
ans = B * p + q
print(ans)


Failing test case input:
0100 -1 2

Expected output:
152


Actual output:
102


Fixed submission (verdict: Accepted):
K,A,B = map(int,input().split())

if K < A+1 or B <= A+2:
  print(K+1)
  exit(0)
  
K -= A - 1
ans = A
p,q = divmod(K,2)
ans += (B-A) * p + q
print(ans)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, a, b = map(int,input().split())

def f(k,a,b):
    bsk = 1
    if (a+1)>=b or (k<(a+1)):
        bsk += k
        print(bsk)
        return
    else:
        k -= (a-1)
        bsk = a
    
    if k>=2:
        if k%2==0:
            bsk += (b-a)*(k/2)
        else:
            bsk += (b-a)*((k-1)/2)+1
    
        print(int(bsk))
        return
    else:
        bsk +=k
        print(int(bsk))
        return
    
    
f(k,a,b)

Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938096


Fixed submission (verdict: Accepted):
k, a, b = map(int,input().split())

def f(k,a,b):
    bsk = 1
    if (a+1)>=b or (k<(a+1)):
        bsk += k
        print(bsk)
        return
    else:
        k -= (a-1)
        bsk = a

    if k>=2:
        if k%2==0:
            bsk += (b-a)*(k
        else:
            bsk += (b-a)*((k-1)
    
    print(int(bsk))
    
    
f(k,a,b)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


k, a, b = map(int, input().split())
n=1

if b-a>2|k<=a:
    print(k+1)
else:
    s=k-a+1
    print(int(s/2)*(b-a)+a+(s%2))
    


Failing test case input:
12206205 8894870 631

Expected output:
12206206


Actual output:
-14725898001782


Fixed submission (verdict: Accepted):


k, a, b = map(int, input().split())
n=1

if ((b-a)<=2)|(k<=a):
    print(k+1)
else:
    s=k-a+1
    print(int(s/2)*(b-a)+a+(s%2))
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0

if K < A -1 or B - A < 2 + A - 1:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)


Failing test case input:
5 3 6

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Problem: p03131
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
K,A,B = map(int,input().split())
if A+2 >= B:
    print(1+K)
else:
    beatC,m = divmod((K - (A-1)),2)
    print(beatC*(B-A)+(K - 2 * beatC))


Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938098


Fixed submission (verdict: Accepted):
K,A,B = map(int,input().split())
if A+2 >= B:
    print(1+K)
else:
    beatC,m = divmod((K - (A-1)),2)
    print(beatC*(B-A)+(K - 2 * beatC)+1)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, a, b = [int(i) for i in input().split()]
sum = 0
if a >= b:
    
    
    sum = k + 1
else:
    
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    else:
        
        rest = 1 + k - a
        if rest >= 0:
            if rest % 2 == 0:
                sum = a + ((diff) * (rest / 2))
            else:
                
                sum = a + ((diff) * ((rest - 1) / 2)) + 1
        else:
            sum = k + 1
                
print(int(sum))


Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938096


Fixed submission (verdict: Accepted):
k, a, b = [int(i) for i in input().split()]

sum = 0
if a >= b:
    
    
    sum = k + 1
else:
    
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    elif diff >= 3:
        
        rest = 1 + k - a

        if rest >= 0:
            if rest % 2 == 0:
                sum = a + ((diff) * int(rest / 2))


            else:
                
                sum = a + ((diff) * int((rest - 1) / 2)) + 1


        else:
            sum = k + 1
                
print(int(sum))

Problem: p03131
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k, a, b = map(int, input().split()) 
biscet = 1

rate = (b-a)/2

if ( rate > 1):
    k-=(a-1)
    biscet+=(a-1)
    biscet += int(k/2) * (b-a)
    biscet += k%2
    
else:
    biscet += k    

Failing test case input:
1111 0 3

Expected output:
1668


Actual output:

Fixed submission (verdict: Accepted):
k, a, b = map(int, input().split()) 
biscet = 1

rate = (b-a)/2

if ( rate > 1):
    k-=(a-1)
    biscet+=(a-1)
    biscet += int(k/2) * (b-a)
    biscet += k%2
    
else:
    biscet += k    

print(biscet)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0

if K < A - 1 or B - A <  A + 1 or B - A < 2:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Failing test case input:
5 3 6

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, a, b = [int(i) for i in input().split()]

sum = 0
if a >= b:
    
    sum = k + 1
else:
    
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    else:
        
        k = 1 + k - a
        if k % 2 == 0:
            sum = a + ((diff) * (k / 2))
        else:
            
            sum = a + ((diff) * ((k - 1) / 2)) + 1

print(int(sum))


Failing test case input:
314159265 35897932 384626433

Expected output:
48518828981938099

Actual output:
48518828981938096


Fixed submission (verdict: Accepted):
k, a, b = [int(i) for i in input().split()]

sum = 0
if a >= b:
    
    
    sum = k + 1
else:
    
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    elif diff >= 3:
        
        rest = 1 + k - a

        if rest >= 0:
            if rest % 2 == 0:
                sum = a + ((diff) * int(rest / 2))


            else:
                
                sum = a + ((diff) * int((rest - 1) / 2)) + 1


        else:
            sum = k + 1
                
print(int(sum))

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K,A,B=map(int,input().split())
bis=1
if K==1:
  bis+=1
elif A>=B-1 or K-A+1<=0:
  bis+=K
else:
  if (K-(A-1))%2==0:
    bis=A+(B-A)*(K-(A-1))
  else:
    bis=A+(B-A)*(K-(A-1))
print(int(bis))

Failing test case input:
5 3 6

Expected output:
7


Actual output:
12


Fixed submission (verdict: Accepted):
K,A,B=map(int,input().split())
bis=1
if K==1:
  bis+=1
elif A>=B-1 or K-A+1<=0:
  bis+=K
else:
  if (K-(A-1))%2==0:
    bis=A+(B-A)*((K-(A-1))
  else:
    bis=A+(B-A)*((K-(A-1))
print(bis)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k,a,b = map(int,input().split())
if b-a <= 2:
  print(k+1)
elif  a+2 >= k:
  print(k+1)
else:
  ans = a+int((k+1-a)/2)*(b-a)
  if (k+1-a)%2 == 1:
    ans+=1
  print(ans)


Failing test case input:
5 3 6

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
k,a,b = map(int,input().split())
if b-a <= 2:
  print(k+1)
elif  a >= b:
  print(k+1)
else:
  ans = a+int((k+1-a)/2)*(b-a)
  if (k+1-a)%2 == 1:
    ans+=1
  print(ans)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K,A,B = map(int, input().split(" "))


bis = 1

kaisu = 0

en = 0

if B <= A +  1:
    bis = bis + K
elif K+1 <= A:
    bis = bis + K
else:
    K = K - (A - 1)
    bis = A
    K = K - 2
    bis = B
    
        
        
    
    
    if K % 2 == 0:
        w1 = int(K /2)
        w2 = B-A
        bis = bis + w1*w2
    else:
        w1 = int(K /2)
        w2 = B-A
        bis = bis + w1*w2 
        bis = bis +1


print(bis)

Failing test case input:
3 3 6

Expected output:
4


Actual output:
7


Fixed submission (verdict: Accepted):
K,A,B = map(int, input().split(" "))


bis = 1

kaisu = 0

en = 0

if B <= A +  1:
    bis = bis + K
elif K <= A:
    bis = bis + K
else:
    K = K - (A - 1)
    bis = A
    K = K - 2
    bis = B
    
        
        
    
    
    if K % 2 == 0:
        
        w1 = int(K /2)
        w2 = B-A
        bis = bis + w1*w2
    else:
        
        w1 = int(K /2)
        w2 = B-A
        bis = bis + w1*w2 
        bis = bis +1


print(bis)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k,a,b = map(int,input().split())
bis = 1
if k<= 1 or b <= a + 2 or k - (a + 1) < 0:
    print(1+k)
    exit()
else:
    bis = b
    k = k - (a + 1)
    if not k == 0:
        bis += int(k/2)+(b-a)+k%2
print(bis)

Failing test case input:
513602852 9307229 25447105

Expected output:
4069634428658541


Actual output:
293734792


Fixed submission (verdict: Accepted):

k,a,b = map(int,input().split())

bis = 1

if k <= 1 or b <= a + 2 or k < a + 1:
    print(1 + k)
    exit()
else:
    bis = b
    k = k - ( a + 1)
    if not k == 0:
        bis += int(k / 2) * (b - a) + k % 2

print(bis)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0

if K <= A or B - A < 2 + A - 1:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)


Failing test case input:
407766107 9307229 14836778

Expected output:
1101648954500241


Actual output:
407766108


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0

if K <= A -1 or B - A < 2 + A - 1:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)


Failing test case input:
407766107 9307229 14836778

Expected output:
1101648954500241


Actual output:
407766108


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, a, b = map(int, input().split())

cookie = 0

if a + 2 >= b or k + 1 < a:
    cookie = k + 1 
else:
    action = int((k-(a-1))/2)
    if action >= 1:
        cookie = b + (action-1)*(b-a)
    if (k-(a-1))/2 - action > 0:
        cookie += 1

print('{}'.format(cookie))

Failing test case input:
3 3 6

Expected output:
4


Actual output:
1


Fixed submission (verdict: Accepted):
k, a, b = map(int, input().split())

cookie = 0

if a + 2 >= b or k + 1 < a:
    cookie = k + 1
else:
    action = int((k-(a-1))/2)
    cookie = a
    if action >= 1:
        cookie += action*(b-a)
    if (k-(a-1))/2 - action > 0:
        cookie += 1

print('{}'.format(cookie))

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k,a,b = map(int,input().split())
print(int(k + 1 if a + 1>= b else b + ((k - (a + 1)) % 2) +  (b - a) * int((k - (a + 1)) / 2)))

Failing test case input:
3 3 6

Expected output:
4


Actual output:
7


Fixed submission (verdict: Accepted):
k,a,b = map(int,input().split())
print(k + 1 if a + 1>= b or k < a + 1 else b + ((k - (a + 1)) % 2) +  (b - a) * int((k - (a + 1)) / 2))

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


k, a, b = map(int, input().split())
n=1

if a+2>b|k<=a+1:
    print(k+1)
else:
    s=k-a+1
    print(int(s/2)*(b-a)+a+(s%2))
    


Failing test case input:
1472 13 0

Expected output:
1473


Actual output:
-9477


Fixed submission (verdict: Accepted):


k, a, b = map(int, input().split())
n=1

if ((b-a)<=2)|(k<=a):
    print(k+1)
else:
    s=k-a+1
    print(int(s/2)*(b-a)+a+(s%2))
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K, A, B = list(map(int, input().split()))

cnt = 1

if K < A:
    cnt += K + 1
    print(cnt)
    exit()

rest = K - (A - 1)
cnt += (A - 1)

if (B - A) > 2:
    if (rest%2 == 0):
        cnt += (B - A) * (rest / 2)
    else:
        cnt += (B - A) * ((rest - 1) / 2)
        cnt += 1
else:
    cnt += rest

print(int(cnt))


Failing test case input:
0001 14 -1

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
K, A, B = list(map(int, input().split()))

if (A + 2 >= B):
    print(K + 1)
elif (A >= K):
    print(K + 1)
else:
    rest = K - (A - 1)
    if (rest%2 == 0):
        print((B - A) * int(rest / 2) + A)
    else:
        print((B - A) * int(rest / 2) + A + 1)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K, A, B = map(int, input().split())

need_turns = A + 1 + 1  
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  
    print(1 + K)
    exit()

ans = B  
K -= (need_turns - 1)



while K > 0:
    if ans >= A and K >= 2:
        ans += (B - A) * K / 2
        K = K % 2
    else:
        ans += 1
        K -= 1

print(ans)


Failing test case input:
296771207 9307229 25447105

Expected output:
2319816489000594


Actual output:
2319816497070532.0


Fixed submission (verdict: Accepted):
K, A, B = map(int, input().split())

need_turns = A + 1 + 1  
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  
    print(1 + K)
    exit()

ans = B  
K -= (need_turns - 1)



while K > 0:
    if ans >= A and K >= 2:
        ans += (B - A) * int(K / 2)
        K = K % 2
    else:
        ans += 1
        K -= 1

print(ans)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = map(int,input().split())
kaisuu = int((a-(b-1))/2)
amari = (a-(b-1))%2
if b >= (c-2):
        print(a+1)
else:
        if amari == 1:
                print(kaisuu*c+1)
        else:
                print(kaisuu*c)

Failing test case input:
407766107 9307229 14836778

Expected output:
1101648954500241


Actual output:
2955922957507543


Fixed submission (verdict: Accepted):
a,b,c = map(int,input().split())
kaisuu = int((a-(b-1))/2)
amari = (a-(b-1))%2
if b >= (c-2):
        print(a+1)
else:
        if amari == 1:
                print(kaisuu*(c-b)+1+b)
        else:
                print(kaisuu*(c-b)+b)
Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0

if K > A  or B - A >  A :
    
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)
else:
    print(K + 1)

Failing test case input:
12064693 156468 3767

Expected output:
12064694


Actual output:
-909198852745


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K,A,B = map(int, input().split())
cookie = 0

if K < A + 1 or B - A <  A + 1 or B - A < 3 :
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)


Failing test case input:
0010 6 12

Expected output:
19


Actual output:
11


Fixed submission (verdict: Accepted):
import math
K,A,B = map(int, input().split())
cookie = 0

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Problem: p03131
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, a, b = map(int, input().split())

if a + 2 >= b:
    cookie = k + 1 
else:
    action = int((k-(a-1))/2)
    cookie = b
    if action > 1:
        cookie += (action-1)*(b-a)
    if ((k-(a-1))/2) - action > 0:
        cookie += 1

Failing test case input:
2585 13 -2

Expected output:
2586


Actual output:

Fixed submission (verdict: Accepted):
k, a, b = map(int, input().split())

cookie = 0

if a + 2 >= b or k + 1 < a:
    cookie = k + 1
else:
    action = int((k-(a-1))/2)
    cookie = a
    if action >= 1:
        cookie += action*(b-a)
    if (k-(a-1))/2 - action > 0:
        cookie += 1

print('{}'.format(cookie))