Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n,k = map(int, input().split())
H = np.array([0]+list(map(int, input().split())))
dp = np.array([float("inf")]*(n+1))
dp[0] = 0
dp[1] = 0

for i in range(1, n):
  for k_i in range(1, k+1):
    if i+k_i<=n:
      dp[i+k_i] = min(dp[i+k_i], dp[i]+abs(H[i+k_i]-H[i]))
      
print(int(dp[-1]))

Fixed submission:
n,k = map(int, input().split())
H = [0]+list(map(int, input().split()))
dp = [float("inf")]*(n+1)
dp[0] = 0
dp[1] = 0

for i in range(1, n):
  for k_i in range(1, k+1):
    if i+k_i<=n:
      dp[i+k_i] = min(dp[i+k_i], dp[i]+abs(H[i+k_i]-H[i]))
      
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
H = [0]+list(map(int, input().split()))
dp = [float("inf")]*(n+1)
dp[0] = 0
dp[1] = 0

for i in range(1, n):
  for k_i in range(1, k+1):
    if i+k_i<=n:
      dp[i+k_i] = min(dp[i+k_i], dp[i]+abs(H[i+k_i]-H[i]))
      
print(dp[-1])

Fixed submission:
n,k = map(int, input().split())
H = [0]+list(map(int, input().split()))
dp = [float("inf")]*(n+1)
dp[0] = 0
dp[1] = 0

for i in range(1, n):
  for k_i in range(1, k+1):
    if i+k_i<=n:
      dp[i+k_i] = min(dp[i+k_i], dp[i]+abs(H[i+k_i]-H[i]))
      
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
H = [0]+list(map(int, input().split()))
dp = [float("inf")]*(n+1)
dp[0] = 0
dp[1] = 0

for i in range(n):
  for k_i in range(1, k+1):
    if i+k_i<=n:
      dp[i+k_i] = min(dp[i+k_i], dp[i]+abs(H[i+k_i]-H[i]))
      
print(dp[-1])

Fixed submission:
n,k = map(int, input().split())
H = [0]+list(map(int, input().split()))
dp = [float("inf")]*(n+1)
dp[0] = 0
dp[1] = 0

for i in range(1, n):
  for k_i in range(1, k+1):
    if i+k_i<=n:
      dp[i+k_i] = min(dp[i+k_i], dp[i]+abs(H[i+k_i]-H[i]))
      
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
m,w = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(m)]

dp = [[0]*(w+1) for _ in range(m+1)]

# 初期値を調整
for w_i in range(1, w+1):
  dp[0][w_i] = float("-inf")
  
for w_i in range(w+1):
  for m_i in range(1, m+1):
    if w_i-WV[m_i-1][0]>=0:
      dp[m_i][w_i] = max(dp[m_i-1][w_i], dp[m_i-1][w_i-WV[m_i-1][0]]+WV[m_i-1][1])
    else:
      dp[m_i][w_i] = dp[m_i-1][w_i]

      
print(max(dp[-1]))

Fixed submission:
m,w = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(m)]

dp = [[0]*(w+1) for _ in range(m+1)]

# 初期値を調整
for w_i in range(1, w+1):
  dp[0][w_i] = float("-inf")
  
for w_i in range(w+1):
  for m_i in range(1, m+1):
    if w_i-WV[m_i-1][0]>=0:
      dp[m_i][w_i] = max(dp[m_i-1][w_i], dp[m_i-1][w_i-WV[m_i-1][0]]+WV[m_i-1][1])
    else:
      dp[m_i][w_i] = dp[m_i-1][w_i]

      
print(max(dp[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
counter = 0

while s.count('BW'):
  counter += s.count('BW')
  s = s.replace('BW', 'WB')
  
print(counter)

Fixed submission:
s=input()

b_count = 0
ans = 0

for s_i in s:
  if s_i=='W':
    ans += b_count
  elif s_i=='B':
    b_count += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
info = [[i] + list(map(int, input().split())) for i in range(1, m+1)]
city = sorted(set([info_i[0] for info_i in info]))

sorted_info = sorted(info, key=lambda x:x[1])

print(sorted_info)

counter = 0

p = city.pop(0)

for i in range(m):
  if sorted_info[i][1] == p:
    counter += 1
    sorted_info[i].append(counter)
  else:
    p =  city.pop(0)
    counter = 1
    sorted_info[i].append(counter)

result = sorted(sorted_info, key=lambda x:x[0])

for res_i in result:
  print(str(res_i[1]).zfill(6) + str(res_i[3]).zfill(6))


Fixed submission:
from collections import defaultdict
from bisect import bisect

n,m = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(m)]

a = defaultdict(list)

for p_i in sorted(p):
  a[p_i[0]].append(p_i[1])
  
for p_i in p:
  x = p_i[0]
  y = bisect(a[x], p_i[1])
  
  print(str(x).zfill(6), str(y).zfill(6), sep='')

Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
info = [[i] + list(map(int, input().split())) for i in range(1, m+1)]
city = sorted(set([info_i[0] for info_i in info]))

sorted_info = sorted(info, key=lambda x: [x[1], x[2]])
counter = 0

p = city.pop(0)

for i in range(m):
  if sorted_info[i][1] == p:
    counter += 1
    sorted_info[i].append(counter)
  else:
    p =  city.pop(0)
    counter = 1
    sorted_info[i].append(counter)

result = sorted(sorted_info, key=lambda x:x[0])

for res_i in result:
  print(str(res_i[1]).zfill(6) + str(res_i[3]).zfill(6))

Fixed submission:
from collections import defaultdict
from bisect import bisect

n,m = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(m)]

a = defaultdict(list)

for p_i in sorted(p):
  a[p_i[0]].append(p_i[1])
  
for p_i in p:
  x = p_i[0]
  y = bisect(a[x], p_i[1])
  
  print(str(x).zfill(6), str(y).zfill(6), sep='')
Buggy python submission (verdict: Time Limit Exceeded):
import fractions

n,m = map(int,input().split())
s = input()
t = input()

temp = n*m//fractions.gcd(n,m)
s_step = temp//n
t_step = temp//m

s_index = [1+s_step*i for i in range(n)]
t_index = [1+t_step*i for i in range(m)]

index = set(s_index)&set(t_index)

ans = temp

if len(index):
  for i in index:
    if t[t_index.index(i)] != s[s_index.index(i)]:
      ans = -1
    
print(ans)

Fixed submission:
import fractions

n,m = map(int, input().split())
s = input()
t = input()

gcd = fractions.gcd(n,m)

print(n*m//gcd if all([s[i*n//gcd]==t[i*m//gcd] for i in range(gcd)]) else -1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())

print('Hello World' if n==1 else a+b)


Fixed submission:
n = int(input())

print('Hello World' if n==1 else int(input())+int(input()))
Buggy python submission (verdict: Runtime Error):
import bisect

n,k = map(int, input().split())
X = list(map(int, input().split()))

init_pos = bisect.bisect_left(X, 0)
ans = 10**8

for pos_i in [init_pos-1, init_pos]:
  temp_ans = abs(X[pos_i])
  left_case = 10**8
  right_case = 10**8
  if pos_i-k+1>=0:
    left_case = abs(X[pos_i-k+1]-X[pos_i])
  if pos_i+k-1<=n-1:
    right_case = abs(X[pos_i+k-1]-X[pos_i])
  temp_ans += min(left_case, right_case)
  
  ans = min(ans, temp_ans)

print(ans)

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

# print(X)

time = float('inf')
for n_i in range(n-k+1):
  r_side = X[n_i+k-1]
  l_side = X[n_i]
  time = min(time, min(abs(r_side), abs(l_side)) + abs(r_side-l_side))
  
print(time)
Buggy python submission (verdict: Runtime Error):
print((int(input()) - 1)*(int(input()) - 1))

Fixed submission:
a, b = map(int, input().split())
print((a-1)*(b-1))
Buggy python submission (verdict: Runtime Error):
import heapq

n = int(input())
max_i = 0

while n>6**max_i:
  max_i+=1
  
cand_list = list(set([-6**i for i in range(max_i)] + [-9**i for i in range(max_i)]))

heapq.heapify(cand_list)
counter = 0

while n > 0:
  cand_n = -1 * heapq.heappop(cand_list)
  while n >= cand_n:
    n -= cand_n
    counter += 1
  
print(counter)

Fixed submission:
n = int(input())

counter_min = n

for i in range(n+1):
  counter = 0
  n_six = i
  n_nine = n-i

  # 6
  j = 1
  while True:
    if  n_six >= 6**j:
      j += 1
    else:
      div_n = 6**(j-1)
      break
  
  while n_six > 0:
    counter += n_six // div_n
    n_six %= div_n
    div_n //= 6 
    
  # 9
  j = 1
  while True:
    if  n_nine >= 9**j:
      j += 1
    else:
      div_n = 9**(j-1)
      break
        
  while n_nine > 0:
    counter += n_nine // div_n
    n_nine %= div_n
    div_n //= 9
  
  counter_min = min(counter, counter_min)

print(counter_min)

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

n = int(input())
max_i = 0

while n>6**max_i:
  max_i+=1
  
cand_list = list(set([-6**i for i in range(max_i)] + [-9**i for i in range(max_i)]))

heapq.heapify(cand_list)
counter = 0

while n > 0:
  cand_n = -1 * heapq.heappop(cand_list)
  if n >= cand_n:
    n -= cand_n
    counter += 1
  
print(counter)

Fixed submission:
n = int(input())

counter_min = n

for i in range(n+1):
  counter = 0
  n_six = i
  n_nine = n-i

  # 6
  j = 1
  while True:
    if  n_six >= 6**j:
      j += 1
    else:
      div_n = 6**(j-1)
      break
  
  while n_six > 0:
    counter += n_six // div_n
    n_six %= div_n
    div_n //= 6 
    
  # 9
  j = 1
  while True:
    if  n_nine >= 9**j:
      j += 1
    else:
      div_n = 9**(j-1)
      break
        
  while n_nine > 0:
    counter += n_nine // div_n
    n_nine %= div_n
    div_n //= 9
  
  counter_min = min(counter, counter_min)

print(counter_min)
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
print('YES' if a<=c and x-a<=b else 'NO')

Fixed submission:
a, b, x = map(int, input().split())
print('YES' if a<=x and x-a<=b else 'NO')
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int, input().split())
target = [i for i in range(a,b+1)]
print(*sorted(set(target[:k]+target[len(target)-k:])), sep='\n')

Fixed submission:
a, b, k = map(int, input().split())
list_1 = [i for i in range(a, a+k) if i<=b]
list_2 = [i for i in range(b-k+1, b+1) if a<=i]
list_1.extend(list_2)
print(*sorted(set(list_1)), sep = '\n')

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
result_list = [i for i in range(a, b+1) if (i < a+k) or (i > b-k)]

for res in result_list:
  print(res)

Fixed submission:
a, b, k = map(int, input().split())
list_1 = [i for i in range(a, a+k) if i<=b]
list_2 = [i for i in range(b-k+1, b+1) if a<=i]
list_1.extend(list_2)
print(*sorted(set(list_1)), sep = '\n')

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
result_list = [i for i in range(a, b+1) if (i < a+k) or (i > b-k)]

for res in result_list:
  print(res)

Fixed submission:
a, b, k = map(int, input().split())
list_1 = [i for i in range(a, a+k) if i<=b]
list_2 = [i for i in range(b-k+1, b+1) if a<=i]
list_1.extend(list_2)
print(*sorted(set(list_1)), sep = '\n')

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
print(*[i for i in range(a, b+1) if (i < a+k) or (i > b-k)], sep = '\n')

Fixed submission:
a, b, k = map(int, input().split())
list_1 = [i for i in range(a, a+k) if i<=b]
list_2 = [i for i in range(b-k+1, b+1) if a<=i]
list_1.extend(list_2)
print(*sorted(set(list_1)), sep = '\n')

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
print(*[i for i in range(a, b+1) if (i < a+k) or (i > b-k)], sep = '\n')

Fixed submission:
a, b, k = map(int, input().split())
list_1 = [i for i in range(a, a+k) if i<=b]
list_2 = [i for i in range(b-k+1, b+1) if a<=i]
list_1.extend(list_2)
print(*sorted(set(list_1)), sep = '\n')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [0] + list(map(int, input().split())) + [0]

D = [abs(A[i+1]-A[i]) for i in range(len(A)-1)]

for i in range(n):
  print(sum(D)-D[i]-D[i+1]+abs(A[i+2]-A[i]))

Fixed submission:
n = int(input())
A = [0] + list(map(int, input().split())) + [0]

D = [abs(A[i+1]-A[i]) for i in range(len(A)-1)]
base = sum(D)

for i in range(n):
  print(base-D[i]-D[i+1]+abs(A[i+2]-A[i]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

A.append(0)

def calc_total_amount(a_list, k):
  
  pos = 0
  total_amount = 0
  
  for i in range(n+1):
    if i == k: continue
  
    total_amount += abs(a_list[i] - pos)
    pos = a_list[i]

  return(total_amount)

for i in range(n):
  print(calc_total_amount(A, i))

Fixed submission:
n = int(input())
A = [0] + list(map(int, input().split())) + [0]

D = [abs(A[i+1]-A[i]) for i in range(len(A)-1)]
base = sum(D)

for i in range(n):
  print(base-D[i]-D[i+1]+abs(A[i+2]-A[i]))
Buggy python submission (verdict: Runtime Error):
import collections

n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]

s_dict = collections.Counter(s_list)
t_dict = collections.Counter(t_list)

s_t_dict = (s_dict - t_dict).values()
print(max(s_t_dict))

Fixed submission:
n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]

cand_str_set = set(s_list)

calced_list = [(s_list.count(str_i) - t_list.count(str_i)) for str_i in cand_str_set]
calced_list.append(0)

print(max(calced_list))
Buggy python submission (verdict: Runtime Error):
l1, l2, l3 = input() for _ in range(3)
print(l1[0]+l2[1]+l3[2])


Fixed submission:
l1, l2, l3 = input(), input(), input()
print(l1[0]+l2[1]+l3[2])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
S = []

for _ in range(n):
  s = input()
  if s[0] in set(['M','A','R','C','H']):
    S.append(s[0]) 
  
print(sum([1 for pattern_i in combinations(S, 3) if len(set(pattern_i))==3]))

Fixed submission:
from itertools import combinations
from collections import Counter

n = int(input())
c = Counter()

for _ in range(n):
  c[input()[0]]+= 1
  
ans = sum([c[pattern_i[0]]*c[pattern_i[1]]*c[pattern_i[2]] for pattern_i in combinations(['M','A','R','C','H'], 3)])
print(ans)
Buggy python submission (verdict: Runtime Error):
_ = input()
card_list = sorted(input().split())[::-1]
print(sum(card_list[::2])-sum(card_list[1::2]))

Fixed submission:
_ = input()
card_list = sorted(map(int, input().split()))[::-1]
print(sum(card_list[::2])-sum(card_list[1::2]))
Buggy python submission (verdict: Runtime Error):
print('Even' if eval(input().replace('', '*')+'%2==0') else 'Odd')

Fixed submission:
print('Even' if eval(input().replace(' ', '*')+'%2==0') else 'Odd')
Buggy python submission (verdict: Runtime Error):
n =  input()
print('No' int(n) % sum(map(int, n)) else 'Yes')

Fixed submission:
n =  input()
print('No' if int(n) % sum(map(int, n)) else 'Yes')
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
print('>' if x>y else '<' if x<y else '=')

Fixed submission:
x, y = input().split()
print('>' if x>y else '<' if x<y else '=')
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())

A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

ans = 0

for a in A:
  i = bisect.bisect_right(B, a)
  for b in B[i:]:
    j = bisect.bisect_right(C, b)
    ans += n-j
    
print(ans)

Fixed submission:
import bisect

n = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0

for b_i in B:
  top_n = bisect.bisect_left(A, b_i)
  bottom_n = n-bisect.bisect_right(C, b_i)
  ans += top_n*bottom_n
  
print(ans)
Buggy python submission (verdict: Runtime Error):
import re

s = input().replace('?', '.')
t = input()

for i in range(len(s)-len(t)+1):
  check_str = s[len(s)-len(t)-i:len(s)-i]
  if re.match(check_str, t):
    break

if i==len(s)-len(t):
  print('UNRESTORABLE')
else:
  ans = s[:len(s)-len(t)-i] + t + s[len(s)-i:]
  ans = ans.replace('.', 'a')
  print(ans)

Fixed submission:
import re

s = input().replace('?', '.')
t = input()

if len(t)>len(s):
  print('UNRESTORABLE')
elif len(t)==len(s):
  if re.match(s, t):
    print(t)
  else:
    print('UNRESTORABLE')
else:
  for i in range(len(s)-len(t)+1):
    check_str = s[len(s)-len(t)-i:len(s)-i]
    if re.match(check_str, t):
      break

  if i==len(s)-len(t):
    print('UNRESTORABLE')
  else:
    ans = s[:len(s)-len(t)-i] + t + s[len(s)-i:]
    ans = ans.replace('.', 'a')
    print(ans)
Buggy python submission (verdict: Runtime Error):
print(max(int(input())-t, 0))

Fixed submission:
x, t = map(int, input().split())
print(max(x-t, 0))
Buggy python submission (verdict: Runtime Error):
s = set(input())
alpha = set(map(chr, range(97, 123)))

print(sorted(s^alpha)[0])

Fixed submission:
s = input()
target = 'None'
for chr_i in range(ord('a'), ord('z')+1):
  if chr(chr_i) not in s:
    target = chr(chr_i)
    break

print(target)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
cand_path = [tuple(map(int, input().split())) for _ in range(m)]

ans = 'IMPOSSIBLE'

for i in range(2, n):
  if (1, i) in cand_path and (i, n) in cand_path:
    ans = 'POSSIBLE'
    break
  
print(ans)

Fixed submission:
n, m = map(int, input().split())
all_cand = [tuple(map(int, input().split())) for _ in range(m)]

start_path_end = set([path[1] for path in all_cand if path[0]==1])
end_path_start = set([path[0] for path in all_cand if path[1]==n])

print('POSSIBLE' if start_path_end&end_path_start else 'IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
cand_path = [tuple(map(int, input().split())) for _ in range(m)]

ans = 'IMPOSSIBLE'

for i in range(2, n):
  path = [1, i, n]
  if len([True for x in zip(path, path[1:]) if x in cand_path])==2:
    ans = 'POSSIBLE'
    break
    
print(ans)

Fixed submission:
n, m = map(int, input().split())
all_cand = [tuple(map(int, input().split())) for _ in range(m)]

start_path_end = set([path[1] for path in all_cand if path[0]==1])
end_path_start = set([path[0] for path in all_cand if path[1]==n])

print('POSSIBLE' if start_path_end&end_path_start else 'IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
cand_path = [tuple(map(int, input().split())) for _ in range(m)]

ans = 'IMPOSSIBLE'

for i in range(2, n):
  path = [1, n]
  path.insert(1, i)
  if len([True for x in zip(path, path[1:]) if x in cand_path])==2:
    ans = 'POSSIBLE'
    break
    
print(ans)

Fixed submission:
n, m = map(int, input().split())
all_cand = [tuple(map(int, input().split())) for _ in range(m)]

start_path_end = set([path[1] for path in all_cand if path[0]==1])
end_path_start = set([path[0] for path in all_cand if path[1]==n])

print('POSSIBLE' if start_path_end&end_path_start else 'IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
cand_path = [tuple(map(int, input().split())) for _ in range(m)]

ans = 'IMPOSSIBLE'

for i in range(2, n):
  path = [1, n]
  path.insert(1, i)
  if len([True for x in zip(path, path[1:]) if x in cand_path])==2:
    ans = 'POSSIBLE'
    
print(ans)

Fixed submission:
n, m = map(int, input().split())
all_cand = [tuple(map(int, input().split())) for _ in range(m)]

start_path_end = set([path[1] for path in all_cand if path[0]==1])
end_path_start = set([path[0] for path in all_cand if path[1]==n])

print('POSSIBLE' if start_path_end&end_path_start else 'IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input())
print(sorted(map(int, input().split()), key = lambda x:-x)[0:k])

Fixed submission:
n, k = map(int, input().split())
print(sum(sorted(map(int, input().split()), key = lambda x:-x)[0:k]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
b_list = []

for a_i in a_list:
  b_list.append(a_i)
  b_list = b_list[::-1]
  
print(*b_list)

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

print(*a_list[::-2], end = ' ')
print(*a_list[n%2::2])
Buggy python submission (verdict: Runtime Error):
x, a, b = map(int, input().split())
print('delicious' if a-b>=0 else 'safe' a+x-b>=0 else 'dangerous')

Fixed submission:
x, a, b = map(int, input().split())
print('delicious' if a-b>=0 else 'safe' if a+x-b>=0 else 'dangerous')
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

print('GREATER' if a>b else if 'LESS' if a<b else 'EQUAL')


Fixed submission:
a = int(input())
b = int(input())

print('GREATER' if a>b else 'LESS' if a<b else 'EQUAL')

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

print('GREATER' if a>b else if 'LESS' if a<b else 'EQUAL')

Fixed submission:
a = int(input())
b = int(input())

print('GREATER' if a>b else 'LESS' if a<b else 'EQUAL')
Buggy python submission (verdict: Runtime Error):
print((int(input())+int(input()))%24)

Fixed submission:
a, b = map(int, input().split())
print((a+b)%24)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print('Draw' if a==b else 'Alice' if (a==1)or(b!=1 and a>b)) else 'Bob')

Fixed submission:
a, b = map(int, input().split())
print('Draw' if a==b else 'Alice' if (a==1)or(b!=1 and a>b) else 'Bob')
Buggy python submission (verdict: Runtime Error):
_ = input()
S = input()
max_n = 0
temp = 0

for s in S:
  temp += 1 if s == 'I' else temp -= 1
  if max_n < temp:
    max_n = temp
    
print(max_n)

Fixed submission:
_ = input()
S = input()
max_n = 0
temp = 0

for s in S:
  if s == 'I':
    temp += 1 
  else:
    temp -= 1
  
  if max_n < temp:
    max_n = temp
    
print(max_n)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
result = [i_1+i_2+i_3 for i_1 in range(k+1) for i_2 in range(k+1) for i_3 in range(k+1) if i_1+i_2+i_3==s]
print(len(result))

Fixed submission:
k, s = map(int, input().split())
result = [i_1+i_2 for i_1 in range(k+1) for i_2 in range(k+1) if 0<=s-i_1-i_2<=k]
print(len(result))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
set_A = set(A)

ans = 1

if n%2==0:
  for a_i in set_A:
    if A.count(a_i)!=2:
      ans = 0
      break
else:
  if A.count(0)!=1:
    ans = 0
  
  set_A.remove(0)
  for a_i in set_A:
    if A.count(a_i)!=2:
      ans = 0
      break
      
if ans!=0:
  ans = 2**(len(set_A))

print(ans%(10**9+7))

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
set_A = set(A)

ans = 1

if n%2==0:
  if n//2 != len(set(A)):
    ans = 0
else:
  if A.count(0)!=1:
    ans = 0
  
  set_A.remove(0)
  if (n-1)//2 != len(set_A):
    ans = 0
      
if ans!=0:
  ans = 2**(len(set_A))

print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
print(input()[0]+input()[0]+input()[0])

Fixed submission:
print('A{}C'.format(input().split()[1][0]))

Buggy python submission (verdict: Runtime Error):
print('A{}C'.format(input().split()[1][1]))


Fixed submission:
print('A{}C'.format(input().split()[1][0]))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int, input().split())
print(len([i for i in range(a,b+1) if i%x==0]))

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

if x*(b//x)<a:
  print(0)
elif x*(a//x)<a and x*(a//x+1)<a:
  print(0)
else:
  if x*(a//x)<a:
    min_n=a//x+1
  else:
    min_n=a//x
  
  max_n=b//x
  print(max_n-min_n+1)
Buggy python submission (verdict: Runtime Error):
a,b,h = map(int, input().split())
print((a+b)*h//2)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())

print((a+b)*h//2)
Buggy python submission (verdict: Runtime Error):
S = input()
stack = []

for s in S:
  if s == 'B':
    stack.pop()
  else:
    stack.append(s)
    
    
print(*stack, sep = '')

Fixed submission:
s = input()
ans = ''

for str_i in s:
  if str_i == '0':
    ans += '0'
  elif str_i == '1':
    ans += '1'
  elif str_i == 'B':
    ans = ans[:len(ans)-1]
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().strip().split())

prev = None

n = n % k
print(min(n, k % n))


Fixed submission:
n, k = map(int, input().strip().split())

min_n = 1000000000000000000000000000
for i in range(1000):
    if n > k:
        n %= k
    n = abs(n - k)
    min_n = min(min_n, n)

print(min_n)

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

print(min(n % k, k % n))


Fixed submission:
n, k = map(int, input().strip().split())

min_n = 1000000000000000000000000000
for i in range(1000):
    if n > k:
        n %= k
    n = abs(n - k)
    min_n = min(min_n, n)

print(min_n)