Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import factorial

N, K = map(int, input().split())
mod = 10 ** 9 + 7

for i in range(1, K+1):
    ans = factorial(N - K + 1)
    ans //= factorial(N - K + 1 - i)
    ans //= factorial(i)
    ans *= factorial(K - 1)
    ans //= factorial(K - i)
    ans //= factorial(i - 1)
    print(ans % mod)


Fixed submission:
from operator import mul
from functools import reduce

MOD = 10 ** 9 + 7

def cmb(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(mul, range(n, n - r, -1))
    denom = reduce(mul, range(1, r + 1))
    return numer // denom % MOD
N, K = map(int, input().split())

for i in range(1, K + 1):
    print(cmb(K - 1, i - 1) * cmb(N - K + 1, i) % MOD)

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

N, K = map(int, input().split())
mod = 10 ** 9 + 7

for i in range(1, K+1):
    ans = factorial(N - K + 1)
    ans *= factorial(K - 1)
    ans //= factorial(N - K + 1 - i)
    ans //= factorial(i)
    ans //= factorial(K - i)
    ans //= factorial(i - 1)
    print(ans % mod)


Fixed submission:
from operator import mul
from functools import reduce

MOD = 10 ** 9 + 7

def cmb(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(mul, range(n, n - r, -1))
    denom = reduce(mul, range(1, r + 1))
    return numer // denom % MOD
N, K = map(int, input().split())

for i in range(1, K + 1):
    print(cmb(K - 1, i - 1) * cmb(N - K + 1, i) % MOD)

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

N, K = map(int, input().split())
mod = 10 ** 9 + 7

for i in range(1, K+1):
    ans = factorial(N - K + 1) * factorial(K - 1) / factorial(N - K + 1 - i) / factorial(i) / factorial(K - i) / factorial(i - 1) % mod
    print(int(ans))


Fixed submission:
from operator import mul
from functools import reduce

MOD = 10 ** 9 + 7

def cmb(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(mul, range(n, n - r, -1))
    denom = reduce(mul, range(1, r + 1))
    return numer // denom % MOD
N, K = map(int, input().split())

for i in range(1, K + 1):
    print(cmb(K - 1, i - 1) * cmb(N - K + 1, i) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

XOR_A = [0] * (N+1)
SUM_A = [0] * (N+1)
for i in range(1, N+1):
    XOR_A[i] = XOR_A[i-1] ^ A[i-1]
    SUM_A[i] = SUM_A[i-1] + A[i-1]

ans = N
for i in range(N):
    for j in range(i+1, N):
        if XOR_A[j+1] ^ XOR_A[i] == SUM_A[j+1] - SUM_A[i]:
            ans += 1
print(ans)


Fixed submission:
from collections import deque

N = int(input())
A = list(map(int, input().split()))

ans = 0
tmp = 0
buf = deque()

for a in A:
    while tmp & a:
        item = buf.popleft()
        tmp ^= item
    buf.append(a)
    tmp |= a
    ans += len(buf)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H, W, D = map(int, input().split())
A = {}

for i in range(H):
    row = list(map(int, input().split()))
    for j in range(W):
        A[row[j]] = [i+1, j+1]

Q = int(input())

for _ in range(Q):
    L, R = map(int, input().split())
    ans = 0
    while L != R:
        ans += abs(A[L+D][0] - A[L][0]) + abs(A[L+D][1] - A[L][1])
        L += D
    print(ans)


Fixed submission:
H, W, D = map(int, input().split())
A = {}

for i in range(H):
    row = list(map(int, input().split()))
    for j in range(W):
        A[row[j]] = [i+1, j+1]

Q = int(input())
ANS = [0] * (H * W + 1)

for i in range(D+1, H * W +1):
    ANS[i] = ANS[i-D] + abs(A[i][0] - A[i-D][0]) + abs(A[i][1] - A[i-D][1])

for _ in range(Q):
    L, R = map(int, input().split())
    print(ANS[R] - ANS[L])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] * (N+1)

for i in range(1, N+1):
    A[i] = int(input())

sorted_A = sorted(A)

cnt = 0
for i in range(1, N+1):
    ind = sorted_A.index(A[i])
    if ind % 2 != i % 2:
        cnt += 1

print(cnt // 2)


Fixed submission:
N = int(input())
A = [0] * (N+1)

for i in range(1, N+1):
    A[i] = int(input())

sorted_A = sorted(A)
sorted_dict_A = { sorted_A[i]: i for i in range(1, N+1) }

cnt = 0
for i in range(1, N+1):
    ind = sorted_dict_A[A[i]]
    if ind % 2 != i % 2:
        cnt += 1

print(cnt // 2)

Buggy python submission (verdict: Time Limit Exceeded):
def sort_with_three(a):
    changed = True
    while True:
        if not changed:
            break
        changed = False
        for i in range(1, N+1-2):
            if a[i] > a[i+2]:
                a[i], a[i+2] = a[i+2], a[i]
                changed = True
    return a

def sort_once(a):
    for i in range(1, N):
        if a[i] > a[i+1]:
            a[i], a[i+1] = a[i+1], a[i]
            break
    return a

N = int(input())
A = [0] * (N+1)

for i in range(1, N+1):
    A[i] = int(input())

sorted_A = sorted(A)

ans = 0
while True:
    A = sort_with_three(A)
    if A == sorted_A:
        break
    ans += 1
    A = sort_once(A)

print(ans)


Fixed submission:
N = int(input())
A = [0] * (N+1)

for i in range(1, N+1):
    A[i] = int(input())

sorted_A = sorted(A)
sorted_dict_A = { sorted_A[i]: i for i in range(1, N+1) }

cnt = 0
for i in range(1, N+1):
    ind = sorted_dict_A[A[i]]
    if ind % 2 != i % 2:
        cnt += 1

print(cnt // 2)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if(a * b) % 2 == 0:
  print("Even")
  
  else:
    print("Odd")

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

if(a * b)%2 == 0:
  print("Even")
  
else:
  print("Odd")
Buggy python submission (verdict: Runtime Error):
a, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
  if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += i
print(ans)    

Fixed submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
  if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += i
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

step = 0
while True:
  flag = False
  for i range(N):
    if A[i] % 2 ==0:
      A[i] = A[i] / 2
      else:
        flag =True
        break
        
        if flag:
          break
          step +=1
          
print(step)          

Fixed submission:
s = input()

cnt = 0

for c in s:
  if c == "1":
    cnt += 1

print(cnt)

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

step = 0
while True:
  flag = False
  for i in range(N):
    if A[i] %2 == 0:
      A[i] = A[i]/2
      else:
        flag = True
        break
        
        if flag:
          break
          step +=1

print(step)         

Fixed submission:
s = input()

cnt = 0

for c in s:
  if c == "1":
    cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
a = input()
n = list(map(int, input().split()))
ans = float("inf")
for i in a:
  ans = min(ans, len(bin(i)) - bin(i).rfind("1")-1)
print(round(ans))  

Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

Buggy python submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i a:
  ans = min(ans, len(bin(i)) - bin(i).rfind("1")-1)
  print(round(ans))

Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

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

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

ans = float("inf")

for i a:
  ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
  
  print(round(ans))

Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

Buggy python submission (verdict: Runtime Error):
def hmtd(n):
  ans = 0
  while n % 2 == 0:
    n /= 2
    and += 1
  return ans

n = int(input())
a = map(int, input().split())
ans = min(map(hmtd, a))

print(ans)

Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = [int(x) for x in input().strip().split()]
H = [int(x) for x in input().strip().split()]

inf = int(10e9 + 7)
dp = [inf] * n
dp[0] = 0
for i in range(n):
    for j in range(i+1,min(n,i+k+1)):
        dp[j] = min (dp[j], dp[i] + abs(H[i] - H[j]))
print (dp[-1])

Fixed submission:
n,k = [int(x) for x in input().strip().split()]
H = [int(x) for x in input().strip().split()]

inf = int(10e9 + 7)
dp = [inf] * n
dp[0] = 0
for i in range(n):
    for j in range(i+1,min(n,i+k+1)):
        dp[j] = min (dp[j], dp[i] + abs(H[i] - H[j]))
print (dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = (int(v) for v in input().split(" "))
for _ in range(k):
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 1
  else:
    break
print(a, b)

Fixed submission:
a, b, k = map(int, input().split(" "))
 
if a >= k:
  a -= k
else:
  a -= k
  b += a
  if b < 0:
    b = 0
  a = 0
 
print(a, b)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = (int(v) for v in input().split(" "))
for _ in range(k):
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 1
  else:
    break
print(a, b)

Fixed submission:
a, b, k = map(int, input().split(" "))
 
if a >= k:
  a -= k
else:
  a -= k
  b += a
  if b < 0:
    b = 0
  a = 0
 
print(a, b)
Buggy python submission (verdict: Runtime Error):
def is_prime(x, i):
  if i*i > x:
    return True
  elif x % i == 0:
    return False
  else:
    is_prime(x, i+1)
  
def gen_prime(x):
  if is_prime(x, 2):
    return x
  else:
    gen_prime(x+1)
    
if __name__ == "__main__":
  import sys
  sys.setrecursionlimit(10240)
  x = int(input())
  print(gen_prime(x))


Fixed submission:
def is_prime(x, i):
  if i*i > x:
    return True
  elif x % i == 0:
    return False
  else:
    return is_prime(x, i+1)
  
def gen_prime(x):
  if is_prime(x, 2):
    return x
  else:
    return gen_prime(x+1)
    
if __name__ == "__main__":
  import sys
  sys.setrecursionlimit(10240)
  x = int(input())
  print(gen_prime(x))

Buggy python submission (verdict: Runtime Error):
def is_prime(x, i):
  if i*i > x:
    return True
  elif x % i == 0:
    return False
  else:
    is_prime(x, i+1)
  
def gen_prime(x):
  if is_prime(x, 2):
    return x
  else:
    gen_prime(x+1)
    
if __name__ == "__main__":
  x = int(input())
  print(gen_prime(x))

Fixed submission:
def is_prime(x, i):
  if i*i > x:
    return True
  elif x % i == 0:
    return False
  else:
    return is_prime(x, i+1)
  
def gen_prime(x):
  if is_prime(x, 2):
    return x
  else:
    return gen_prime(x+1)
    
if __name__ == "__main__":
  import sys
  sys.setrecursionlimit(10240)
  x = int(input())
  print(gen_prime(x))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
if n%2 != 0 or n == 1:
  prtin("No")
elif s[:int(n/2)] == s[int(n/2):]:
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
s = input()
if n%2 != 0 or n == 1:
  print("No")
elif s[:int(n/2)] == s[int(n/2):]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
if n%2 != 0.0:
  prtin("No")
elif s[:int(n/2)] == s[int(n/2):]:
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
s = input()
if n%2 != 0 or n == 1:
  print("No")
elif s[:int(n/2)] == s[int(n/2):]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
if n%2 != 0:
  prtin("No")
elif s[:int(n/2)] == s[int(n/2):]:
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
s = input()
if n%2 != 0 or n == 1:
  print("No")
elif s[:int(n/2)] == s[int(n/2):]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
if n%2 != 0:
  prtin("No")
elif s[int(:n/2)] == s[int(n/2):]:
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
s = input()
if n%2 != 0 or n == 1:
  print("No")
elif s[:int(n/2)] == s[int(n/2):]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())
for i in range(K):
    if A != 0:
        A -= 1
    elif B != 0:
        B -= 1
    else:
        break
print('{} {}'.format(A, B))

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

if A <= K:
    print('{} {}'.format(0, max(B - (K - A), 0)))
else:
    print('{} {}'.format(A - K, B))
Buggy python submission (verdict: Runtime Error):
import math

def process_smaller_index(K, min_index):
    if min_index == 0:
        return 0
    else:
        return math.ceil(min_index / K)

def process_larger_index(last_index, K, min_index):
    if min_index == last_index:
        return 0
    else:
        return math.ceil((last_index - min_index) / K)

N, K = map(int, input().split())
A = [int(i) for i in input().split()]
min_index = A.index(1)
print(process_smaller_index(K - 1, min_index) + process_larger_index(len(A)-1, K - 1, min_index))

Fixed submission:
S = input()
count = 0
for i in S:
    if i == '+':
        count += 1
    elif i == '-':
        count -= 1
print(count)
Buggy python submission (verdict: Runtime Error):
s,t=input().split()
print=(t+S)

Fixed submission:
s,t=input().split()
print(t+s)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
for x in range(k):
    if a >= 1:
         a -= 1
    elif a == 0 and b >=1:
        b = b - 1
    elif a == 0 and b==0:
        pass
print(a, b)

Fixed submission:
a, b, k = map(int, input().split())
if a + b >= k:
    if a > k:
        print(a-k,b)
    elif k >= a and a+b >= k:
        print(0,a + b -k)
else:
    print(0,0)

Buggy python submission (verdict: Runtime Error):
 a, b, k = map(int, input().split())
for x in range(k):
    if a >= 1:
         a -= 1
    elif a == 0 and b >=1:
        b = b - 1
    elif a == 0 and b==0:
        pass
print(a, b)

Fixed submission:
a, b, k = map(int, input().split())
if a + b >= k:
    if a > k:
        print(a-k,b)
    elif k >= a and a+b >= k:
        print(0,a + b -k)
else:
    print(0,0)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = input().split()
a = int(a)
b= int(b)
c = int(c)
d = int(d)
s = b-a+1

cd = c*d // math.gcd(c,d)
a_ = ((a-1)//c + (a-1)//d) - ((a-1)//cd)
b_ = (b//c + b//d) - (b//cd)
s_ = b_- a_
print(s-s_)

Fixed submission:
import fractions as fr
a,b,c,d = input().split()
a = int(a)
b= int(b)
c = int(c)
d = int(d)
s = b-a+1

cd = c*d // fr.gcd(c,d)
a_ = ((a-1)//c + (a-1)//d) - ((a-1)//cd)
b_ = (b//c + b//d) - (b//cd)
s_ = b_- a_
print(s-s_)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = input().split()
a = int(a)
b= int(b)
c = int(c)
d = int(d)
s = b-a+1

cd = c*d // math.gcd(c,d)
a_ = ((a-1)//c + (a-1)//d) - ((a-1)//cd)
b_ = (b//c + b//d) - (b//cd)
s_ = b_- a_
print(s-s_)

Fixed submission:
import fractions as fr
a,b,c,d = input().split()
a = int(a)
b= int(b)
c = int(c)
d = int(d)
s = b-a+1

cd = c*d // fr.gcd(c,d)
a_ = ((a-1)//c + (a-1)//d) - ((a-1)//cd)
b_ = (b//c + b//d) - (b//cd)
s_ = b_- a_
print(s-s_)
Buggy python submission (verdict: Runtime Error):
n = int(input())
dic = {}
for x in range(n):
  dic[x+1] = input().split()
ls = sorted(dic.items(), key=lambda x:x[1][0])

for y in range(1,n-1):
  
  if ls[y][1][0] == ls[y+1][1][0]:
    
    if ls[y][1][1] < ls[y+1][1][1]:
      
      ls[y+1],ls[y] = ls[y],ls[y+1]
    
    
for b in range(len(ls)):
  print(ls[b][0])


Fixed submission:
a,p = map(int,input().split())
print((3*a+p)//2)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
lm = list(map(int,input().split()))
ln = []
for _ in range(m):
    ln.append(list(map(int,input().split())))
for a in range(m):
    for b in range(ln[a][0]):
        if  ln[a][1] > min(lm) :
            c = min(lm)
            lm[lm.index(c)] =  ln[a][1] 
    print('aa')
print(sum(lm))

Fixed submission:
a,b = map(int,input().split())
if a <= 5:
    print(0)
elif 6 <= a <= 12:
    print(int(b*0.5))
else:
    print(b)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
lm = list(map(int,input().split()))
ln = []
for _ in range(m):
    ln.append(list(map(int,input().split())))


Fixed submission:
a,b = map(int,input().split())
if a <= 5:
    print(0)
elif 6 <= a <= 12:
    print(int(b*0.5))
else:
    print(b)
Buggy python submission (verdict: Time Limit Exceeded):
n,m  =map(int,input().split())
lm = []
for _ in range(n):
    lm.append(list(map(int,input().split())))
s = 0
mon = 0
lm.sort()
 
while s + lm[0][1] < m:
    s += lm[0][1]
    mon += lm[0][1]*lm[0][0]
    lm = lm[1::]
if s +lm[0][1] >= m:
    mon += lm[0][0]*(m-s)
    
print(mon)

Fixed submission:
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]
 
AB.sort()
Ans = 0
for i in AB:
  if i[1] >= M:
    Ans += i[0] * M
    break
  else:
    Ans += i[0] * i[1]
    M -= i[1]
 
print(Ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m  =map(int,input().split())
lm = []
for _ in range(n):
    lm.append(list(map(int,input().split())))
s = 0
mon = 0
lm.sort(key = lambda x:x[0])
 
while s + lm[0][1] < m:
    s += lm[0][1]
    mon += lm[0][1]*lm[0][0]
    lm = lm[1::]
if s +lm[0][1] >= m:
    mon += lm[0][0]*(m-s)
    
print(mon)

Fixed submission:
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]
 
AB.sort()
Ans = 0
for i in AB:
  if i[1] >= M:
    Ans += i[0] * M
    break
  else:
    Ans += i[0] * i[1]
    M -= i[1]
 
print(Ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m  =map(int,input().split())
lm = []
for _ in range(n):
    lm.append(list(map(int,input().split())))
s = 0
mon = 0
lm.sort(key = lambda x:x[0])

while s + lm[0][1] < m:
    s += lm[0][1]
    mon += lm[0][1]*lm[0][0]
    lm = lm[1::]
while s < m:
    s += 1
    mon += lm[0][0]
    lm[0][1] -= 1
    
print(mon)

Fixed submission:
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]
 
AB.sort()
Ans = 0
for i in AB:
  if i[1] >= M:
    Ans += i[0] * M
    break
  else:
    Ans += i[0] * i[1]
    M -= i[1]
 
print(Ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m  =map(int,input().split())
lm = []
for _ in range(n):
    lm.append(list(map(int,input().split())))
s = 0
mon = 0
lm.sort(key = lambda x:x[0])
while s < m:
    s += 1
    mon += lm[0][0]
    lm[0][1] -= 1
    if lm[0][1] == 0:
        lm = lm[1::]
print(mon)

Fixed submission:
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]
 
AB.sort()
Ans = 0
for i in AB:
  if i[1] >= M:
    Ans += i[0] * M
    break
  else:
    Ans += i[0] * i[1]
    M -= i[1]
 
print(Ans)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
print(T + S)


Fixed submission:
s,t = input().split()
ans = t + s
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
A, B, C, X, Y = map(int,input().split())
 
minf = sys.maxsize
X1 = X
Y1 = Y
 
for i in range(0, max(X,Y)+1):
    price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C 
print(min(price))

Fixed submission:
A, B, C, X, Y = map(int, input().split())

## min(Ax + By + Cz) = min((A+0.5C)x + (B+0.5C)y)
# Xyen = Ai + 2Cj, Yyen = Bk + 2Cj, X = i +2j, Y = k + 2j
# Xyen + Yyen = AX + BY + 2(C-A)j + 2(C-B)j, jを求めればok?

# l = []
# for j in range(max(X,Y)+1):
#     if j <= X+Y:
#         l.append(A*X + B*Y + (C-A*0.5-B*0.5)*j)

# print(int(min(l)))

X1 = X
Y1 = Y
price = []
for i in range(0, max(X,Y)+1):
    price.append(max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C) 
print(min(price))

Buggy python submission (verdict: Runtime Error):
import sys
A, B, C, X, Y = map(int,input().split())
 
minf = sys.maxsize
X1 = X
Y1 = Y
 
 
for i in range(0, max(X,Y)+1):
    price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C
 
 
print(min(price))

Fixed submission:
A, B, C, X, Y = map(int, input().split())

## min(Ax + By + Cz) = min((A+0.5C)x + (B+0.5C)y)
# Xyen = Ai + 2Cj, Yyen = Bk + 2Cj, X = i +2j, Y = k + 2j
# Xyen + Yyen = AX + BY + 2(C-A)j + 2(C-B)j, jを求めればok?

# l = []
# for j in range(max(X,Y)+1):
#     if j <= X+Y:
#         l.append(A*X + B*Y + (C-A*0.5-B*0.5)*j)

# print(int(min(l)))

X1 = X
Y1 = Y
price = []
for i in range(0, max(X,Y)+1):
    price.append(max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C) 
print(min(price))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

betweenLength = []
for i in range(len(s)):
    if s[i] == 'A':
        for j in range(len(s)):
            if i < j and s[j] == 'Z':
                betweenLength.append(len(s[0:j]) + 1 - len(s[0:i]))

print(max(betweenLength))


Fixed submission:
s = input()

## 正答
print(s.rfind('Z') - s.find('A') + 1)

## 下記は正答だが処理時間が長すぎたケース
# betweenLength = []
# for i in range(len(s)):
#     if s[i] == 'A':
#         for j in range(len(s)):
#             if i < j and s[j] == 'Z':
#                 betweenLength.append(len(s[0:j]) + 1 - len(s[0:i]))

# print(max(betweenLength))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

ways = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                ways += 1

print(ways)

Fixed submission:
K, S = map(int, input().split())

ways = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            ways += 1

print(ways)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

ways = 0

for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                ways += 1


print(ways)

Fixed submission:
K, S = map(int, input().split())

ways = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            ways += 1

print(ways)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
nums = [1, 2, 3]

for n in nums:
  if((a != n) and (b != n):
     print(n)


Fixed submission:
a = input()
b = input()
choices = '123'
for c in choices:
  if((c != a) and (c != b)):
    print(c)

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
choices = '123'
for c in choises:
  if((c != a) and (c != b)):
    print(c)


Fixed submission:
a = input()
b = input()
choices = '123'
for c in choices:
  if((c != a) and (c != b)):
    print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s, t = input().split()

r = []
for i in range(len(s)):
  str.append(s[i])
  str.append(t[i])

print(''.join(r))


Fixed submission:
n = int(input())
s, t = input().split()

r = []
for i in range(n):
    r.append(s[i])
    r.append(t[i])

print(''.join(r))
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print(a * b // math.gcd(a, b))

Fixed submission:
a, b = map(int, input().split())
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a
print(a * b // gcd(a, b))

Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b = map(int, input().split())
print(a * b // gcd(a, b))

Fixed submission:
a, b = map(int, input().split())
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a
print(a * b // gcd(a, b))

Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b = map(int, input().split())
print(a * b // gcd(a, b))

Fixed submission:
a, b = map(int, input().split())
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a
print(a * b // gcd(a, b))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a < 10) && (b < 10):
    print(a * b)
else:
    print(-1)


Fixed submission:
a, b = map(int, input().split())
if (a < 10) and (b < 10):
    print(a * b)
else:
    print(-1)