Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# abc111_c_new

from collections import Counter


def solve(n, seq):
    odd = seq[::2]  # odd numbers of the seq
    even = seq[1::2]  # even numbers of the seq

    # print(odd)
    # print(even)

    # odd = Counter(odd).most_common()  # example -> returns [(1, 5), (2, 5)]
    # even = Counter(even).most_common()
    odd = sorted([(k, v) for k, v in Counter(odd).items()], key=lambda x: x[1], reverse=True)
    even = sorted([(k, v) for k, v in Counter(even).items()], key=lambda x: x[1], reverse=True)

    # print(odd)
    # print(even)

    sol = 0
    if odd[0][0] == even[0][0]:
        if len(odd) == 1 and len(even) == 1:  # seq [1, 1, 1, 1]  (special case)
            sol = int(n // 2)  # [1, 1, 1, 1] sol = N / 2
        else:
            if odd[0][1] > even[1][1]:
                # sol = n - odd[0][1] - even[1][1] ==
                sol = (n // 2 - odd[0][1]) + (n // 2 - even[1][1])
            else:
                # sol = n - odd[1][1] - even[0][1] ==
                sol = (n // 2 - odd[1][1]) + (n // 2 - even[0][1])
    else:
        # sol = n - odd[0][1] - even[0][1] ==
        sol = (n // 2 - odd[0][1]) + (n // 2 - even[0][1])

    return sol


if __name__ == "__main__":
    n = int(input())
    seq = list(map(int, input("").split(" ")))
    print(solve(n, seq))


Fixed submission:
# abc_111_a

def transform (bango):
    if bango == "1":
        return "9"
    elif bango == "9":
        return "1"
    else:
        return bango

def solve(string):
    return "".join(list(map(transform, string)))

if __name__ == "__main__":
    string = input("")
    print (solve(string))

Buggy python submission (verdict: Runtime Error):
# abc111_c_new


from collections import Counter


def solve(n, seq):
    odd = seq[::2]                      # odd numbers of the seq
    even = seq[1::2]                    # even numbers of the seq

    odd = Counter(odd).most_common()    # example -> returns [(1, 5), (2, 5)]
    even = Counter(even).most_common()

    sol = 0
    if odd[0][0] == even[0][0]:
        if len(odd) == 1 and len(even) == 1:
            sol = int(n / 2)
        else:
            if odd[1][1] > even[1][1]:
                sol = n - odd[1][1] - even[0][1]
            else:
                sol = n - odd[0][1] - even[1][1]
    else:
        sol = n - odd[0][1] - even[0][1]

    return sol


if __name__ == "__main__":
    n = int(input())
    seq = list(map(int, input("").split(" ")))
    print(solve(n, seq))


Fixed submission:
# abc_111_a

def transform (bango):
    if bango == "1":
        return "9"
    elif bango == "9":
        return "1"
    else:
        return bango

def solve(string):
    return "".join(list(map(transform, string)))

if __name__ == "__main__":
    string = input("")
    print (solve(string))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(i) for i in input().split()]

x = [[0 for _ in range(m)] for i in range(n)]
for i in range(m):
    l, r = [int(i) for i in input().split()]
    for j in range(l-1, r):
        x[j][i] = 1

counter = 0
for i in range(n):
    if sum(x[i]) == m:
        counter += 1

print(counter)

Fixed submission:
n, m = [int(i) for i in input().split()]

ll = []
rr = []
for i in range(m):
    l, r = [int(i) for i in input().split()]
    ll.append(l)
    rr.append(r)

ans = min(rr) - max(ll) + 1
if ans < 0:
    ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
s = list(input())
s[k] = s[k].lower()
print("".join(s))

Fixed submission:
n, k = list(map(int, input().split()))
k = k - 1
s = input()

s = s[:k] + s[k].lower() + s[k+1:]

print(s)
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(2000)

n = int(input())

p = [[] for i in range(n)]

for i in range(n-1):
    u, v, w = list(map(int, input().split()))
    u = u-1
    v = v-1
    p[u].append((v, w))
    p[v].append((u, w))

c = [-1 for i in range(n)]

def dfs(num, zo):
    if c[num] != -1:
        return
    else:
        c[num] = zo
    for v, w in p[num]:
        if w % 2 == 0:
            dfs(v, zo)
        else:
            dfs(v, not zo)
dfs(0, 0)

for i in range(n):
    print(1 if c[i] else 0)

Fixed submission:
import sys

sys.setrecursionlimit(10**5)

n = int(input())

p = [[] for i in range(n)]

for i in range(n-1):
    u, v, w = list(map(int, input().split()))
    u = u-1
    v = v-1
    p[u].append((v, w))
    p[v].append((u, w))

c = [-1 for i in range(n)]

def dfs(num, zo):
    if c[num] != -1:
        return
    else:
        c[num] = zo
    for v, w in p[num]:
        if w % 2 == 0:
            dfs(v, zo)
        else:
            dfs(v, not zo)
dfs(0, 0)

for i in range(n):
    print(1 if c[i] else 0)

Buggy python submission (verdict: Runtime Error):
n = int(input())

p = [[] for i in range(n)]

for i in range(n-1):
    u, v, w = list(map(int, input().split()))
    u = u-1
    v = v-1
    p[u].append((v, w))
    p[v].append((u, w))

c = [-1 for i in range(n)]

def dfs(num, zo):
    if c[num] != -1:
        return
    else:
        c[num] = zo
    for v, w in p[num]:
        if w % 2 == 0:
            dfs(v, zo)
        else:
            dfs(v, -1*(zo-1))
dfs(0, 0)

for i in range(n):
    print(c[i])

Fixed submission:
import sys

sys.setrecursionlimit(10**5)

n = int(input())

p = [[] for i in range(n)]

for i in range(n-1):
    u, v, w = list(map(int, input().split()))
    u = u-1
    v = v-1
    p[u].append((v, w))
    p[v].append((u, w))

c = [-1 for i in range(n)]

def dfs(num, zo):
    if c[num] != -1:
        return
    else:
        c[num] = zo
    for v, w in p[num]:
        if w % 2 == 0:
            dfs(v, zo)
        else:
            dfs(v, not zo)
dfs(0, 0)

for i in range(n):
    print(1 if c[i] else 0)
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**5)

n, m = list(map(int, input().split()))

counter = 0
c = [-1 for i in range(n)]
p = [[] for n in range(n)]

for i in range(m):
    x, y, z = list(map(int, input().split()))
    x -= 1
    y -= 1
    p[x].append(y)
    p[y].append(x)

def dfs(num, depth):
    if c[num] != -1:
        return
    else:
        c[num] = depth
    for i in p[num]:
        dfs(i, depth)

for i in range(n):
    if c[i] == -1:
        counter += 1
        dfs(i, counter)

print(max(c))

Fixed submission:
import sys

sys.setrecursionlimit(10**6)

n, m = list(map(int, input().split()))

counter = 0
c = [-1 for i in range(n)]
p = [[] for n in range(n)]

for i in range(m):
    x, y, z = list(map(int, input().split()))
    x -= 1
    y -= 1
    p[x].append(y)
    p[y].append(x)

def dfs(num, depth):
    if c[num] != -1:
        return
    else:
        c[num] = depth
    for i in p[num]:
        dfs(i, depth)

for i in range(n):
    if c[i] == -1:
        counter += 1
        dfs(i, counter)

print(max(c))

Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))

counter = 0
c = [-1 for i in range(n)]
p = [[] for n in range(n)]

for i in range(m):
    x, y, z = list(map(int, input().split()))
    x -= 1
    y -= 1
    p[x].append(y)
    p[y].append(x)

def dfs(num, depth):
    if c[num] != -1:
        return
    else:
        c[num] = depth
    for i in p[num]:
        dfs(i, depth)

for i in range(n):
    if c[i] == -1:
        counter += 1
        dfs(i, counter)

print(max(c))

Fixed submission:
import sys

sys.setrecursionlimit(10**6)

n, m = list(map(int, input().split()))

counter = 0
c = [-1 for i in range(n)]
p = [[] for n in range(n)]

for i in range(m):
    x, y, z = list(map(int, input().split()))
    x -= 1
    y -= 1
    p[x].append(y)
    p[y].append(x)

def dfs(num, depth):
    if c[num] != -1:
        return
    else:
        c[num] = depth
    for i in p[num]:
        dfs(i, depth)

for i in range(n):
    if c[i] == -1:
        counter += 1
        dfs(i, counter)

print(max(c))
Buggy python submission (verdict: Runtime Error):
a, b, t = [int(i) for i in input().split()]
print(b * (c // a))

Fixed submission:
a, b, t = (int(i) for i in input().split())

print(t // a * b)
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = list(map(int, input().split()))

left = [a[0]]
right = [a[-1]]

from math import gcd

for i in range(n):
    left.append(gcd(left[i], a[i]))
    right.append(gcd(right[i], a[-1-i]))

ans = [right[-2]]

for l, r in zip(left[2:-1], list(reversed(right[1:]))[2:]):
    ans.append(gcd(l, r))

ans.append(left[-2])

print(max(ans))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

import sys
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd

l = [0, a[0]]
r = [0, a[-1]]
for i in range(1, n):
    l.append(gcd(a[i], l[i]))
    r.append(gcd(a[n-i-1], r[i]))
counter = 0
for i in range(n):
    num = gcd(l[i], r[n-i-1])
    if counter < num:
        counter = num

print(counter)
Buggy python submission (verdict: Runtime Error):
a, b = (map(int, input()))
if a == b:
    print(a * 2)
else:
    c = max(a, b)
    print(c * 2 - 1)

Fixed submission:
a, b = (map(int, input().split()))
if a == b:
    print(a * 2)
else:
    c = max(a, b)
    print(c * 2 - 1)

Buggy python submission (verdict: Runtime Error):
a, b = (map(int, input()))
if a == b:
    print(a * 2)
else:
    c = max(a, b)
    print(c * (c - 1))

Fixed submission:
a, b = (map(int, input().split()))
if a == b:
    print(a * 2)
else:
    c = max(a, b)
    print(c * 2 - 1)
Buggy python submission (verdict: Runtime Error):
list_num = [int(i) for i in input().split()]

players = list_num[0:1]
k = list_num[-1]

for i in range(k):
    players[i%2] = int(players[i%2]/2)
    players[(i+1)%2] += players[i%2]

for i in range(2):
    print(players[i], end="")

print("")

Fixed submission:
list_num = [int(i) for i in input().split()]

players = list_num[0:2]
k = list_num[-1]

for i in range(k):
    players[i%2] = players[i%2]//2
    players[(i+1)%2] += players[i%2]

print(players[0], players[1])
Buggy python submission (verdict: Runtime Error):
def checker():
    s = input()
    if s[0] != "A":
        return 0
    if s[2:-1].count("C") != 1:
        return 0
    s.pop(0)
    s.pop(s.index("C"))
    if s != s.lower():
        return 0
    return 1

l = ["WA", "AC"]

print(l[checker()])

Fixed submission:
def checker():
    s = input()
    if s[0] != "A":
        return 0
    if s[2:-1].count("C") != 1:
        return 0
    num = s.index("C")
    s = s[1:num] + s[num+1:]
    if s != s.lower():
        return 0
    return 1

l = ["WA", "AC"]

print(l[checker()])

Buggy python submission (verdict: Runtime Error):
def checker():
    s = input()
    if s[0] != "A":
        return 0
    if "C" in s[2:-1]:
        s[2:-1].pop(s[2:-1].index("C"))
        if "C" in s[2:-1]:
            return 0
        else:
            return 1
    return 1

l = ["WA", "AC"]

print(l[checker()])

Fixed submission:
def checker():
    s = input()
    if s[0] != "A":
        return 0
    if s[2:-1].count("C") != 1:
        return 0
    num = s.index("C")
    s = s[1:num] + s[num+1:]
    if s != s.lower():
        return 0
    return 1

l = ["WA", "AC"]

print(l[checker()])
Buggy python submission (verdict: Runtime Error):
def main():
    n = [int(i) for i in input().split()]
    bridge = set()
    counter = 0
    reqs = [[int(j) for j in input().split()] for i in range(n[1])]
    reqs.sort(key=lambda x:(x[0],x[1]))
    
    preset = 0
    for i in range(1, n[0]+1):
        if i in bridge:
            bridge = []
            counter += 1
        for j in range(preset, len(reqs)):
            if reqs[j][0] == i:
                bridge.add(reqs[j][1])
            else:
                preset = j
                break
    
    print(counter)

main()


Fixed submission:
def main():
    cost_list = input().split()
    for i in range(len(cost_list)):
        cost_list[i] = int(cost_list[i])
    cost_list.sort()
    counter = 0
    for i in range(len(cost_list) - 1):
        counter += cost_list[i+1] - cost_list[i]
    print(counter)

main()

Buggy python submission (verdict: Runtime Error):
def main():
    n = [int(i) for i in input().split()]
    bridge = [0 for i in range(n[0]-1)]
    reqs = [[int(j) for j in input().split()] for i in range(n[1])]
    reqs.sort(key=lambda x:(x[1]-x[0]))

    for req in reqs:
        if 1 not in bridge[req[0]-1:req[1]-1]:
            bridge[req[1] - 2] = 1
    print(bridge.count(1))

main()

Fixed submission:
def main():
    cost_list = input().split()
    for i in range(len(cost_list)):
        cost_list[i] = int(cost_list[i])
    cost_list.sort()
    counter = 0
    for i in range(len(cost_list) - 1):
        counter += cost_list[i+1] - cost_list[i]
    print(counter)

main()
Buggy python submission (verdict: Runtime Error):
import math

def func(x, y):
    return (x * y) // math.gcd(x, y)

def main():
    input()
    lcm = 1
    num_list = [int(i) for i in input().split()]
    for i in range(len(num_list)):
        lcm = func(num_list[i], lcm)
    lcm -= 1

    counter = 0
    for i in num_list:
        counter += (lcm % i)
    
    print(counter)

main()

Fixed submission:
def main():
    input()
    lcm = 1
    num_list = [int(i) for i in input().split()]
    for i in range(len(num_list)):
        lcm = num_list[i] * lcm
    lcm -= 1

    counter = 0
    for i in num_list:
        counter += (lcm % i)
    
    print(counter)

main()

Buggy python submission (verdict: Runtime Error):
import math

def func(x, y):
    return (x * y) // math.gcd(x, y)

def main():
    input()
    lcm = 1
    num_list = [int(i) for i in input().split()]
    for i in range(len(num_list)):
        lcm = func(num_list[i], lcm)
    lcm -= 1

    counter = 0
    for i in num_list:
        counter += (lcm % i)
    
    print(counter)

main()

Fixed submission:
def main():
    input()
    lcm = 1
    num_list = [int(i) for i in input().split()]
    for i in range(len(num_list)):
        lcm = num_list[i] * lcm
    lcm -= 1

    counter = 0
    for i in num_list:
        counter += (lcm % i)
    
    print(counter)

main()
Buggy python submission (verdict: Runtime Error):
A , B = map(int,input().split())
if A => 13:
  print(B)
elif 6 =< A => 12:
  print(B / 2)
else:
  print(0)

Fixed submission:
A , B = map(int,input().split())
if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(int(B / 2))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
S = input()
S = list(S)
S[K-1] = S[K-1].lower()
print(''.join(S)

Fixed submission:
N, K = map(int,input().split())
S = input()
S = list(S)
S[K-1] = S[K-1].lower()
print(''.join(S))

Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
S = input()
S = list(S)
S[K] = S[K].lower()
print(S)

Fixed submission:
N, K = map(int,input().split())
S = input()
S = list(S)
S[K-1] = S[K-1].lower()
print(''.join(S))

Buggy python submission (verdict: Runtime Error):
N, K = input().split()
N = list(N)
N[int(K)] = N[int(K)].lower()
print(''.join(N))


Fixed submission:
N, K = map(int,input().split())
S = input()
S = list(S)
S[K-1] = S[K-1].lower()
print(''.join(S))

Buggy python submission (verdict: Runtime Error):
N, K = input().split()
N = list(N)
N[int(K)] = N[int(K)].lower()
print(str(N))


Fixed submission:
N, K = map(int,input().split())
S = input()
S = list(S)
S[K-1] = S[K-1].lower()
print(''.join(S))

Buggy python submission (verdict: Runtime Error):
N, K = input().split()
N = list(N)
N[int(K)] = N[int(K)].lower()
print(N)


Fixed submission:
N, K = map(int,input().split())
S = input()
S = list(S)
S[K-1] = S[K-1].lower()
print(''.join(S))

Buggy python submission (verdict: Runtime Error):
N, K = input().split()
N[int(K)] = N[int(K)].lower()
print(N)


Fixed submission:
N, K = map(int,input().split())
S = input()
S = list(S)
S[K-1] = S[K-1].lower()
print(''.join(S))

Buggy python submission (verdict: Runtime Error):
N, K = input().split()
N[K] = N[K].lower()
print(N)


Fixed submission:
N, K = map(int,input().split())
S = input()
S = list(S)
S[K-1] = S[K-1].lower()
print(''.join(S))
Buggy python submission (verdict: Runtime Error):
def henkan(str):
    for s in str:
        print('1' if s = '9' else '9',end='')
        print('')
henkan(input())

Fixed submission:
def henkan(str):
    for s in str:
        print('1' if s == '9' else '9',end='')
    print('')
henkan(input())

Buggy python submission (verdict: Runtime Error):
def henkan(str)
    for s in str:
        print('1' if s = '9' else '9',end='')
        print('')
henkan(input())

Fixed submission:
def henkan(str):
    for s in str:
        print('1' if s == '9' else '9',end='')
    print('')
henkan(input())
Buggy python submission (verdict: Runtime Error):
X = int(input())
Y = int(input())

Z = X + (Y/2)

print(int(Z))

Fixed submission:
x,y = map(int,input().split())

ans = x+y/2

print(int(ans))

Buggy python submission (verdict: Runtime Error):
X = int(input())
Y = int(input())

Z = X + (Y/2)

print(Z)

Fixed submission:
x,y = map(int,input().split())

ans = x+y/2

print(int(ans))
Buggy python submission (verdict: Runtime Error):
def prob(n):
    n = str(n)
    sn = 0
    for i in n:
        sn += int(i)
    n = int(n)
    print('Yes') if not n % sn else ('No')

n = input()
prob(n)

Fixed submission:
s = input()
num = 0

for i in range(len(s)):
    num = num + 1 if  s[i] == '+' else num - 1

print(num)

Buggy python submission (verdict: Runtime Error):
s = input()
num = 0
for _ in range(len(s)):

    if s == '+':
        num += 1
    else:


Fixed submission:
s = input()
num = 0

for i in range(len(s)):
    num = num + 1 if  s[i] == '+' else num - 1

print(num)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
l, m = map(int, input().split())
for _ in range(M-1):
    new_l, new_r = map(int, input().split())
    if l < new_l:
        l = new_l
    if new_r < r:
        r = new_r

print(r-l+1)


Fixed submission:
N, M = map(int, input().split())
l, r = map(int, input().split())
for _ in range(M-1):
    new_l, new_r = map(int, input().split())
    if l < new_l:
        l = new_l
    if new_r < r:
        r = new_r

score = r-l+1
if score > 0:
    print(score)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
li = {i+1 for i in range(N)}
# print(li)
box = []
for _ in range(M):
    l, r = map(int, input().split())
    # print(l, r)
    for i in li:
        # print(i)
        if l <= i and i <= r:
            box.append(i)
    li = list(set(li) & set(box))
    box.clear()
    # print(li)
print(len(li))


Fixed submission:
N, M = map(int, input().split())
l, r = map(int, input().split())
for _ in range(M-1):
    new_l, new_r = map(int, input().split())
    if l < new_l:
        l = new_l
    if new_r < r:
        r = new_r

score = r-l+1
if score > 0:
    print(score)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import sys
import bisect
Q = int(input().rstrip())
#queries = []
#for _ in range(Q):
#    queries.append(list(map(int, input().rstrip().split(" "))))

bias = 0
vs = []

qi = 0
#for query in queries:
#    if len(query) == 3:
#        _, v, b = query
for _ in range(Q):
    query = input()
    if query[0] == "1":
        v, b = map(int, query[2:].split(" "))
        qi += 1
        bisect.insort_left(vs, v)
        bias += b
        if qi == 1:
            abs_sum = 0
            med = v
            medp = 0
        else:
            if qi % 2 == 0:
                if v <= med:
                    # * ^ + -> v * ^ + -> v ^ + +
                    #       -> * v ^ + -> * ^ + +
                    # medp -> same
                    # med -> new
                    # abs_sum -> += abs(new_med - med) + abs(new_med - v) = (med - new_med) + (new_med - v) = med - v
                    abs_sum += med - v
                    med = vs[medp]
                else:
                    # * ^ + -> * ^ + v
                    #       -> * ^ v +
                    # medp -> same
                    # med -> same
                    # abs_sum -> += abs(med - v) = v - med
                    abs_sum += v - med
            else:
                if v <= med:
                    # * ^ + + -> v * ^ + +
                    #         -> * v ^ + +
                    # ^ + -> v ^ +
                    # medp -> += 1
                    # med -> same
                    # abs_sum -> += abs(med - v) = med - v
                    abs_sum += med - v
                    medp += 1
                else:
                    # * ^ + + -> * ^ + + v -> * * ^ + v
                    #         -> * ^ v + + -> * * ^ + +
                    # medp -> += 1
                    # med -> new
                    # abs_sum -> += abs(new_med - v) = v - new_med
                    medp += 1
                    med = vs[medp]
                    abs_sum += v - med
    else:
        print(med, abs_sum+bias)



Fixed submission:
A, B = map(int, input().rstrip().split())
if A >= 13:
  print(B)
elif A >= 6:
  print(B//2)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
r, d, x = map(int, input().strip())
for i in range(10):
  x = r * x - d
  print(x)


Fixed submission:
r, d, x = map(int, input().split())
for i in range(10):
  x = r * x - d
  print(x)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input().strip())
D = list(map(int, input().strip().split(" ")))
print(N, len(D), file=sys.stderr)

M = int(input().strip())
T = list(map(int, input().strip().split(" ")))
print(M, len(T), file=sys.stderr)

for t in T:
    if t not in D:
        print("NO")
        exit(0)
    D.remove(t)
print("YES")
exit(0)


Fixed submission:
import sys
N = int(input().strip())
D = list(map(int, input().strip().split(" ")))
print(N, len(D), file=sys.stderr)

import collections
Dd = collections.defaultdict(int)
for d in D:
    Dd[d] += 1

M = int(input().strip())
T = list(map(int, input().strip().split(" ")))
print(M, len(T), file=sys.stderr)
Td = collections.defaultdict(int)
for t in T:
    Td[t] += 1

for k,v in Td.items():
    if Dd[k] < v:
        print("NO")
        exit(0)
print("YES")
exit(0)
Buggy python submission (verdict: Runtime Error):
s = input().split()
N = int(s[0])
M = int(s[1])

AB = {}
for i in range(N):
  data = input().split()
  AB[int(data[0])] = int(data[1])

money = 0
num = 0
for A,B in sorted(AB.items()):
  if num+B < M:
    money += A*B
  	num += B
  else:
    money += A*(M-num)
    break
  
print(money)

Fixed submission:
s = input().split()
N = int(s[0])
M = int(s[1])
 
AB = {}
for i in range(N):
  data = input().split()
  if int(data[0]) in AB.keys():
    AB[int(data[0])] += int(data[1])
  else:
    AB[int(data[0])] = int(data[1])
AB = sorted(AB.items())
money = 0
num = 0
for A,B in AB:
  for b in range(B):
    num += 1
    money += A
    if num == M:
      break
      
  if num == M:
    break
  
print(int(money))
Buggy python submission (verdict: Time Limit Exceeded):
s = input().split()
K = int(s[0])
A = int(s[1])
B = int(s[2])

import time

bis = 1

if float(B/A) > 2:
  change = 1
else:
  change = 0

if change == 0:
  bis = bis + K
  time.sleep(10000)
else:
  i = A -1
  bis  = A
  k = K - i
  bis += (k//2)*(B-A)
  bis += k %2
print(bis)

Fixed submission:
s = input().split()
K = int(s[0])
A = int(s[1])
B = int(s[2])
 
bis = 1
 
if B-A >  2:
  change = 1
else:
  change = 0
 
if change == 0:
  bis = bis + K
else:
  i = A - 1
  bis  = A
  k = K - i
  bis += (k//2)*(B-A)
  bis += k %2
print(bis)

Buggy python submission (verdict: Time Limit Exceeded):
s = input().split()
K = int(s[0])
A = int(s[1])
B = int(s[2])

bis = 1
money = 0

if float(B/A) > 2:
  change = 1
else:
  change = 0

for i in range(K):
  if change == 1:
    if bis >= A and i+1 < K:
      bis = bis - A
      money += 1
      continue
    if money >= 1:
      bis += B
      money -= 1
      continue
 
  bis = bis+1
 
print(bis)

Fixed submission:
s = input().split()
K = int(s[0])
A = int(s[1])
B = int(s[2])
 
bis = 1
 
if B-A >  2:
  change = 1
else:
  change = 0
 
if change == 0:
  bis = bis + K
else:
  i = A - 1
  bis  = A
  k = K - i
  bis += (k//2)*(B-A)
  bis += k %2
print(bis)