TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = int(input())
h = int(input())

s = (a + b)*h/2
print(s)

Fixed, accepted submission:
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2)
Problem:
You are parking at a parking lot. You can choose from the following two fee plans:    * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.   * Plan 2: The fee will be B yen, regardless of the duration.  Find the minimum fee when you park for N hours.

Incorrect submission (verdict: Wrong Answer):
n, a, b = map(int, input().split())
print(max(a*n, b))

Fixed, accepted submission:
n, a, b = map(int, input().split())
print(min(a*n, b))
Problem:
It is September 9 in Japan now.  You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?

Incorrect submission (verdict: Wrong Answer):
n = list(input())
print('YES' if '9' in n else 'NO')

Fixed, accepted submission:
n = list(input())
print('Yes' if '9' in n else 'No')
Problem:
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.  Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.  Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.

Incorrect submission (verdict: Wrong Answer):
n=int(input())

g=[[0,i,-1,[]] for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    ga=g[a-1]
    ga[0]+=1
    ga[3].append(b-1)
    g[a-1]=ga

    gb=g[b-1]
    gb[0]+=1
    gb[3].append(a-1)
    g[b-1]=gb
g.sort()

c=1
ans=[-1 for _ in range(n)]
for i in range(n):
    nextto=g[i][3]
    while(True):
        nextc=[]
        for j in nextto:
            nextc.append(g[j][2])
        nextc=list(set(nextc))
        if(c not in nextc):
            g[i][2]=c
            ans[g[i][1]]=c
            break
        else:
            c+=1

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

Fixed, accepted submission:
from collections import deque
n=int(input())
g=[[] for _ in range(n+1)]
e=[]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    e.append(b-1)

q=deque([0])

color=[0 for _ in range(n)]
while(len(q)>0):
    ei=q.popleft()
    c=1
    for x in g[ei]:
        if c == color[ei]:
            c+=1

        color[x]=c
        c+=1
        q.append(x)

print(max(color))
for i in e:
    print(color[i])
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

Incorrect submission (verdict: Wrong Answer):
s1s2s3=input()
s1s2s3.count("1")

Fixed, accepted submission:
s1s2s3=input()
print(s1s2s3.count("1"))
Problem:
Joisino is working as a receptionist at a theater.  The theater has 100000 seats, numbered from 1 to 100000.  According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).  How many people are sitting at the theater now?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))

Fixed, accepted submission:
N = int(input())
ans = 0
for _ in range(N):
  l, r = map(int, input().split())
  ans += r-l+1
print(ans)
Problem:
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them.  He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).  Find the minimum total cost to achieve his objective.

Incorrect submission (verdict: Wrong Answer):
#4
n=int(input())
a=list(map(int,input().split()))
mini=[]

for i in range(n):
    mini.append(int(0))
    for j in range(n):
        mini[i]=mini[i]+(a[i]-a[j])**2
        if min(mini)<mini[i]:
            break

print(min(mini))


Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
mini=[]

for i in range(max(a)-min(a)+1):
    mini.append(int(0))
    for j in range(n):
        mini[i]=mini[i]+(i+min(a)-a[j])**2
        if min(mini)<mini[i]:
            break

print(min(mini))
Problem:
We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N).  In particular, any integer sequence is similar to itself.  You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N.  How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]

ans = 2**N
tmp = 1
for a in A:
  if a%2==0:
    tmp *= 2
print(ans - tmp)

Fixed, accepted submission:
N = int(input())
A = [int(i) for i in input().split()]

ans = 3**N
tmp = 1
for a in A:
  if a%2==0:
    tmp *= 2
print(ans - tmp)
Problem:
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.   Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.   Here, both the x\- and y-coordinates before and after each movement must be integers.   He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).   Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).   Under this condition, find a shortest path for him.

Incorrect submission (verdict: Wrong Answer):
sx,sy,tx,ty = map(int,input().split())
ans = ""
ans += "U" * (ty-sy)
ans += "R" * (tx-sx)
ans += "D" * (ty-sy)
ans += "L" * (tx-sx)
print(ans)

Fixed, accepted submission:
sx,sy,tx,ty = map(int,input().split())
ans = ""
ans += "U" * (ty-sy)
ans += "R" * (tx-sx)
ans += "D" * (ty-sy)
ans += "L" * (tx-sx)
ans += "L"
ans += "U" * (ty-sy+1)
ans += "R" * (tx-sx+1)
ans += "D"
ans += "R"
ans += "D" * (ty-sy+1)
ans += "L" * (tx-sx+1)
ans += "U"
print(ans)
Problem:
You are given three integers, A, B and C.   Among them, two are the same, but the remaining one is different from the rest.   For example, when A=5,B=7,C=5, A and C are the same, but B is different.   Find the one that is different from the rest among the given three integers.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())
if a == b:
    print("C")
elif a == c:
    print("B")
else:
    print("A")

Fixed, accepted submission:
a, b, c = map(int, input().split())
if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

Incorrect submission (verdict: Wrong Answer):
import sys

def main():
    argv = input().split()
    a = int(argv[0])
    b = int(argv[1])
    print(oddeven(a*b))

def oddeven(n):
    return 'Even' if n%2==1 else 'Odd'

if __name__ == '__main__':
    main()


Fixed, accepted submission:
import sys

def main():
    argv = input().split()
    a = int(argv[0])
    b = int(argv[1])
    print(oddeven(a*b))

def oddeven(n):
    return 'Odd' if n%2==1 else 'Even'

if __name__ == '__main__':
    main()
Problem:
Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.

Incorrect submission (verdict: Wrong Answer):
import math

def solve(a,b,c,d,e,f):
	x = - (d*(f**2+e**2-b**2-a**2) + b*(-f**2-e**2) + b**2*f + a**2*f + d**2*(b-f) + c**2*(b-f)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a-2*e))
	y = (c*(f**2+e**2-b**2-a**2) + a*(-f**2-e**2) + b**2*e + a**2*e + d**2*(a-e) + c**2*(a-e)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a - 2*e))
	r = math.hypot(x-a, y-b) 
	return x,y,r

n = int(input())
for _ in range(n):
	a,b,c,d,e,f = map(float, input().split())
	x,y,r = solve(a,b,c,d,e,f)
	x += 0.0005
	y += 0.0005
	r += 0.0005
	print("{:.3f} {:.3f} {:.3f}".format(x, y, r))

Fixed, accepted submission:
import math

def solve(a,b,c,d,e,f):
	x = - (d*(f**2+e**2-b**2-a**2) + b*(-f**2-e**2) + b**2*f + a**2*f + d**2*(b-f) + c**2*(b-f)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a-2*e))
	y = (c*(f**2+e**2-b**2-a**2) + a*(-f**2-e**2) + b**2*e + a**2*e + d**2*(a-e) + c**2*(a-e)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a - 2*e))
	r = math.hypot(x-a, y-b) 
	return x,y,r

n = int(input())
for _ in range(n):
	a,b,c,d,e,f = map(float, input().split())
	x,y,r = solve(a,b,c,d,e,f)
	print("{:.3f} {:.3f} {:.3f}".format(x, y, r))
Problem:
M-kun has the following three cards:    * A red card with the integer A.   * A green card with the integer B.   * A blue card with the integer C.  He is a genius magician who can do the following operation at most K times:    * Choose one of the three cards and multiply the written integer by 2.  His magic is successful if both of the following conditions are satisfied after the operations:    * The integer on the green card is **strictly** greater than the integer on the red card.   * The integer on the blue card is **strictly** greater than the integer on the green card.  Determine whether the magic can be successful.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(int,input().split())
k=int(int())

t=0
while a >= b:
  b *= 2
  t += 1
while b >= c:
  c *= 2
  t += 1
if k >= t:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
a,b,c=map(int,input().split())
k=int(input())

t=0
while a >= b:
  b *= 2
  t += 1
while b >= c:
  c *= 2
  t += 1
if k >= t:
  print('Yes')
else:
  print('No')
Problem:
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?

Incorrect submission (verdict: Wrong Answer):
#coding: utf-8

a, b, x = map(int, input().split())
upper = 0
lower = 0

upper = b // x
lower = a // x

ans = int(upper - lower)

print(ans)

Fixed, accepted submission:
#coding: utf-8

a, b, x = map(int, input().split())
upper = 0
lower = 0

upper = b // x
lower = a // x

if(a % x == 0):
    lower -= 1

ans = int(upper - lower)

print(ans)
Problem:
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int, input().split())
if a == b and b == c:
    count=0
    print(count)
    exit(0)
    
ls = [a,b,c]
ls.sort(reverse=True)
count = 0
print(ls)
print(ls[0])

if (ls[1]-ls[2])%2 != 0:
    ls[2] = ls[2]+1
    ls[0] = ls[0]+1
    count +=1

while ls[1] - ls[2] >= 2:
    ls[2] += 2
    count += 1

if ls[1] - ls[2] == 1:
    ls[2] += 1
    count +=1

dif = ls[0] - ls[1]
count = count + dif

print(count)

Fixed, accepted submission:
import sys
a,b,c = map(int, input().split())
if a == b and b == c:
    count=0
    print(count)
    sys.exit()
    
ls = [a,b,c]
ls.sort(reverse=True)
count = 0

if (ls[1]-ls[2])%2 != 0:
    ls[2] = ls[2]+1
    ls[0] = ls[0]+1
    count +=1

while ls[1] - ls[2] >= 2:
    ls[2] += 2
    count += 1

if ls[1] - ls[2] == 1:
    ls[2] += 1
    count +=1

dif = ls[0] - ls[1]
count = count + dif

print(count)
Problem:
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.  She will concatenate all of the strings in some order, to produce a long string.  Among all strings that she can produce in this way, find the lexicographically smallest one.  Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds:    * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.   * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Incorrect submission (verdict: Wrong Answer):
n, l = map(int, input().split())
"".join(sorted([input() for _ in range(n)]))

Fixed, accepted submission:
n, l = map(int, input().split())
print("".join(sorted([input() for _ in range(n)])))
Problem:
You are given an H × W grid.   The squares in the grid are described by H strings, S_1,...,S_H.   The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W).   `.` stands for an empty square, and `#` stands for a square containing a bomb.  Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square.   (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.)   He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square.  Print the strings after the process.

Incorrect submission (verdict: Wrong Answer):
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            cnt = 0
            for di in [-1,0,1]:
                for dj in [-1,0,1]:
                    if di == 0 and dj == 0:
                        continue
                    ni = i + di; nj = j + dj
                    if not(0 <= ni <= H-1 and 0 <= nj <= W-1):
                        continue
                    if S[ni][nj] == "#":
                        cnt += 1
            S[i][j] = cnt

for line in S:
    print(*line)

Fixed, accepted submission:
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            cnt = 0
            for di in [-1,0,1]:
                for dj in [-1,0,1]:
                    if di == 0 and dj == 0:
                        continue
                    ni = i + di; nj = j + dj
                    if not(0 <= ni <= H-1 and 0 <= nj <= W-1):
                        continue
                    if S[ni][nj] == "#":
                        cnt += 1
            S[i][j] = str(cnt)

for line in S:
    print("".join(line))
Problem:
Snuke has an empty sequence a.  He will perform N operations on this sequence.  In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1).  You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.

Incorrect submission (verdict: Wrong Answer):
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

N = int(input())
max = 0
b = [int(x) for x in input().split()]
flag = [0 for x in range(N)]
for i in b:
    if i > max:
        max = i
submax = max
ans = []
while b != []:
    if ((submax) == my_index(b,submax-1)):
        ans.append(b.pop(submax-1))
        submax = max
    else :
        submax = submax-1
        if b[0] != 1:
            print(-1)
            exit()

for x in range(len(ans)):
    print(ans.pop(len(ans)-1))

Fixed, accepted submission:
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

N = int(input())
max = 0
b = [int(x) for x in input().split()]
flag = [0 for x in range(N)]
for i in b:
    if i > max:
        max = i
submax = max
ans = []
while b != []:
    if ((submax-1) == my_index(b,submax)):
        ans.append(b.pop(submax-1))
        submax = max
    else :
        submax = submax-1
        if b[0] != 1:
            print(-1)
            exit()

for x in range(len(ans)):
    print(ans.pop(len(ans)-1))
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().rstrip().split(" "))

print(2*(a+b), a*b)

Fixed, accepted submission:
a, b = map(int, input().rstrip().split(" "))

print(a*b, 2*(a+b))
Problem:
Summer vacation ended at last and the second semester has begun. You, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom. The barricade will be built just before the start of the A-th class and removed by Kyoto University students just before the start of the B-th class. All the classes conducted when the barricade is blocking the entrance will be cancelled and you will not be able to attend them. Today you take N classes and class i is conducted in the t_i- th period. You take at most one class in each period. Find the number of classes you can attend.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())
ans = 0
for i in range(a):
    n = int(input())
    if n < b:
        ans += 1
print(ans)

Fixed, accepted submission:
a, b, c = map(int, input().split())
ans = 0
for i in range(a):
    n = int(input())
    if n < b or n >= c:
        ans += 1
print(ans)
Problem:
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.  The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it.  Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.  Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.

Incorrect submission (verdict: Wrong Answer):
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


N = I()
a = [I() for _ in range(N)]
a = list(map(lambda x:x-1,a))

ans = -1


route = [0]

visited = set([0])
next = a[0]

while True:
    if next in visited:
        loopStart = route.index(next)
        break
    else:
        route.append(next)
        visited.add(next)
        next = a[next]
        
print(route)

if 1 in visited:
    ans = route.index(1)

print(ans)

Fixed, accepted submission:
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


N = I()
a = [I() for _ in range(N)]
a = list(map(lambda x:x-1,a))

ans = -1


route = [0]

visited = set([0])
next = a[0]

while True:
    if next in visited:
        loopStart = route.index(next)
        break
    else:
        route.append(next)
        visited.add(next)
        next = a[next]
        
# print(route)

if 1 in visited:
    ans = route.index(1)

print(ans)
Problem:
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())
print((b - a) % c)



Fixed, accepted submission:
a, b, c = map(int, input().split())
z = 0
for i in range(a, min(b + 1, c + 1)):
    if c % i == 0:
        z += 1

print(z)
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

Incorrect submission (verdict: Wrong Answer):
a,b = map(int,input().strip().split())
print("%d %d" % ((2*(a+b)),(a*b)))

Fixed, accepted submission:
a,b = map(int,input().strip().split())
c = (a+b)*2
s = a*b
print("%d %d" % (s,c))
Problem:
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second.  He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.

Incorrect submission (verdict: Wrong Answer):
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

a = B-A
v = V-W
v2 = v*T

if(a<=v2):
    print("Yes")
else:
    print("No")


Fixed, accepted submission:
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

a = abs(B-A)
v = V-W
v2 = v*T

if(a<=v2):
    print("YES")
else:
    print("NO")
Problem:
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.  Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list.

Incorrect submission (verdict: Wrong Answer):
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

l = input().split()
l = [int(s) for s in l]
a = 0
for i in range(0,len(l)):
    if ( is_prime(l[i]) == True):
        a += 1
print(a)



Fixed, accepted submission:
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

N = input()
N = int(N)
l = [int(input()) for i in range(N)]
a = 0
for i in range(0,len(l)):
    if is_prime(l[i]) == True:
         a += 1
print(a)
Problem:
Snuke has a favorite restaurant.  The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.  So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
x = 800 * N
y = 0

for i in range(N):
	if i % 15 == 0:
  		y += 200
print (x - y)

Fixed, accepted submission:
N=int(input())
print(800*N - (int)(N/15)*200)
Problem:
There is a hotel with the following accommodation fee:    * X yen (the currency of Japan) per night, for the first K nights   * Y yen per night, for the (K+1)-th and subsequent nights  Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.

Incorrect submission (verdict: Wrong Answer):
total_nights = int(input())
first_nights = int(input())
first_rate = int(input())
extra_rate = int(input())

total = (first_nights * first_rate) + ((total_nights - first_nights) * extra_rate)

Fixed, accepted submission:
total_nights = int(input())
first_nights = int(input())
first_rate = int(input())
extra_rate = int(input())

if total_nights <= first_nights:
  total = total_nights * first_rate
else:
  total = (first_nights * first_rate) + ((total_nights - first_nights) * extra_rate)
print(total)