Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = int(input())
parity = True
for i in range(N):
  query = input().split()
  if query[0] == "1":
    if parity == True:
      parity = False
    else:
      parity = True
  if query[0] == "2":
    if parity:
      if query[1] == "1":
        S = query[2] + S
      else:
        S = S + query[2]
    else:
      if query[1] == "1":
        S = S + query[2]
      else:
        S = query[2] + S

if parity == False:
  S = S[::-1]
print(S)

Fixed submission:
import collections
S = collections.deque(list(input()))
N = int(input())
parity = True
for i in range(N):
  query = input().split()
  if query[0] == "1":
    if parity == True:
      parity = False
    else:
      parity = True
  if query[0] == "2":
    if parity:
      if query[1] == "1":
        S.appendleft(query[2])
      else:
        S.append(query[2])
    else:
      if query[1] == "1":
        S.append(query[2])
      else:
        S.appendleft(query[2])

Sstr = ""
if parity:
  for i in range(len(S)):
    Sstr = Sstr + S.popleft()
else:
  for i in range(len(S)):
    Sstr = Sstr + S.pop()
print(Sstr)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = int(input())
parity = True
for i in range(N):
  query = input().split()
  if query[0] == "1":
    if parity == True:
      parity = False
    else:
      parity = True
  if query[0] == "2":
    if parity:
      if query[1] == "1":
        S = query[2] + S
      else:
        S = S + query[2]
    else:
      if query[1] == "1":
        S = S + query[2]
      else:
        S = query[2] + S

if parity == False:
  S = S[::-1]
print(S)

Fixed submission:
import collections
S = collections.deque(list(input()))
N = int(input())
parity = True
for i in range(N):
  query = input().split()
  if query[0] == "1":
    if parity == True:
      parity = False
    else:
      parity = True
  if query[0] == "2":
    if parity:
      if query[1] == "1":
        S.appendleft(query[2])
      else:
        S.append(query[2])
    else:
      if query[1] == "1":
        S.append(query[2])
      else:
        S.appendleft(query[2])

Sstr = ""
if parity:
  for i in range(len(S)):
    Sstr = Sstr + S.popleft()
else:
  for i in range(len(S)):
    Sstr = Sstr + S.pop()
print(Sstr)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = int(input())
for i in range(N):
  query = input().split()
  if query[0] == "1":
    S = S[::-1]
  if query[0] == "2":
    if query[1] == "1":
      S = query[2] + S
    else:
      S = S + query[2]
print(S)

Fixed submission:
import collections
S = collections.deque(list(input()))
N = int(input())
parity = True
for i in range(N):
  query = input().split()
  if query[0] == "1":
    if parity == True:
      parity = False
    else:
      parity = True
  if query[0] == "2":
    if parity:
      if query[1] == "1":
        S.appendleft(query[2])
      else:
        S.append(query[2])
    else:
      if query[1] == "1":
        S.append(query[2])
      else:
        S.appendleft(query[2])

Sstr = ""
if parity:
  for i in range(len(S)):
    Sstr = Sstr + S.popleft()
else:
  for i in range(len(S)):
    Sstr = Sstr + S.pop()
print(Sstr)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for i in range(N)]
count_dict = {}
for s in S:
  if not s in count_dict.keys():
    count_dict[s] = 1
  else:
    count_dict[s] += 1
count_dict = dict(filter(lambda x: x[1] == max(count_dict.values()), count_dict.items()))
ans = list(count_dict.keys())
ans.sort()
for s in ans:
  print(s)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
count_dict = {}
for s in S:
  if not s in count_dict.keys():
    count_dict[s] = 1
  else:
    count_dict[s] += 1
maxnum = max(count_dict.values())
count_dict = dict(filter(lambda x: x[1] == maxnum, count_dict.items()))
ans = list(count_dict.keys())
ans.sort()
for s in ans:
  print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for i in range(N)]
count_dict = {}
for s in S:
  if not s in count_dict.keys():
    count_dict[s] = 1
  else:
    count_dict[s] += 1
count_dict = dict(filter(lambda x: x[1] >= max(count_dict.values()), count_dict.items()))
ans = list(count_dict.keys())
ans.sort()
for s in ans:
  print(s)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
count_dict = {}
for s in S:
  if not s in count_dict.keys():
    count_dict[s] = 1
  else:
    count_dict[s] += 1
maxnum = max(count_dict.values())
count_dict = dict(filter(lambda x: x[1] == maxnum, count_dict.items()))
ans = list(count_dict.keys())
ans.sort()
for s in ans:
  print(s)
Buggy python submission (verdict: Runtime Error):
A, B, K = [int(s) for s in input().split()]
if K <= A:
  print(str(A-K)+' '+str(B))
else
  print(str(0)+' '+str(A+B-K))

Fixed submission:
A, B, K = [int(s) for s in input().split()]
X = A+B
if K <= A:
  print(str(A-K)+' '+str(B))
elif K <= X:
  print(str(0)+' '+str(X-K))
else:
  print(str(0)+' '+str(0))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(s) for s in input().split()]

minimum = sum(A)
for i, l in enumerate(A):
  a = sum(A[:i])
  b = sum(A[i:])
  minimum = min(minimum, abs(a-b))
print(minimum)

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

minimum = sum(A)
a = 0
b = minimum
for i, l in enumerate(A):
  a += l
  b -= l
  minimum = min(minimum, abs(a-b))
print(minimum)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(s) for s in input().split()]

minimum = sum(A)
for i, l in enumerate(A):
  a = sum(A[:i])
  b = sum(A[i:])
  minimum = min(minimum, abs(a-b))
print(minimum)

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

minimum = sum(A)
a = 0
b = minimum
for i, l in enumerate(A):
  a += l
  b -= l
  minimum = min(minimum, abs(a-b))
print(minimum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = [int(s) for s in input().split()]

if D[0] != 0:
  print(0)
  exit()
  
max_distance = [i+1 for i in range(max(D))]
stock = 1
for i in max_distance:
  count_1 = D.count(i-1)
  count_2 = D.count(i)
  if count_1 == 0 or count_2 == 0:
    stock = 0
    break
  stock *= count_1**count_2

print(stock%998244353)

Fixed submission:
N = int(input())
D = [int(s) for s in input().split()]

maximum = max(D)
max_distance = [i+1 for i in range(maximum)]
count_list = [0 for i in range(maximum+1)]
for i in D:
  count_list[i] += 1
if D[0] != 0 or count_list[0] != 1:
  print(0)
  exit()

stock = 1
for i in max_distance:
  count_1 = count_list[i-1]
  count_2 = count_list[i]
  if count_1 == 0 or count_2 == 0:
    stock = 0
    break
  stock *= count_1**count_2

print(stock%998244353)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = [int(s) for s in input().split()]

if D[0] != 0 or D.count(0) != 1:
  print(0)
  exit()
  
max_distance = [i+1 for i in range(max(D))]
stock = 1
for i in max_distance:
  count_1 = D.count(i-1)
  count_2 = D.count(i)
  if count_1 == 0 or count_2 == 0:
    stock = 0
    break
  stock *= count_1**count_2

print(stock%998244353)

Fixed submission:
N = int(input())
D = [int(s) for s in input().split()]

maximum = max(D)
max_distance = [i+1 for i in range(maximum)]
count_list = [0 for i in range(maximum+1)]
for i in D:
  count_list[i] += 1
if D[0] != 0 or count_list[0] != 1:
  print(0)
  exit()

stock = 1
for i in max_distance:
  count_1 = count_list[i-1]
  count_2 = count_list[i]
  if count_1 == 0 or count_2 == 0:
    stock = 0
    break
  stock *= count_1**count_2

print(stock%998244353)
Buggy python submission (verdict: Runtime Error):
A, B = [int(s) for s in input().split()]
def gcd(x, y):
  while y != 0:
    x, y = y, x%y
  return x
def divisors(n):
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

gcd_divisors = divisors(gcd(A, B))
N = len(gcd_divisors)
count = 0
for i in range(N):
  flg = False
  for j in range(N-1-i-1):
    if gcd(gcd_divisors[N-1-i], gcd_divisors[j]) != 1:
      flg = True
      break
  if flg == False:
    count += 1
print(count)

Fixed submission:
N = int(input())
if (N==1):
  print(1.0)
elif(N%2==0):
  print((N//2)/N)
else:
  print(((N//2+1)/N))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(s) for s in input().split()]
ans = sorted(range(len(A)), key=lambda k: A[k])
ans = [str(i+1) for i in ans]

print(' '.join(ans))

Fixed submission:
N = int(input())
if (N==1):
  print(1.0)
elif(N%2==0):
  print((N//2)/N)
else:
  print(((N//2+1)/N))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(s) for s in input().split()]
ans = sorted(range(len(A)), key=lambda k: A[k])
ans = [str(i+1) for i in ans]

print(' '.join(ans))

Fixed submission:
N = int(input())
if (N==1):
  print(1.0)
elif(N%2==0):
  print((N//2)/N)
else:
  print(((N//2+1)/N))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(s) for s in input().split()]
ans = sorted(range(len(A)), key=lambda k: A[k])
ans = [i+1 for i in ans]

print(' '.join(ans))

Fixed submission:
N = int(input())
if (N==1):
  print(1.0)
elif(N%2==0):
  print((N//2)/N)
else:
  print(((N//2+1)/N))
Buggy python submission (verdict: Runtime Error):
# run-length encoding, decoding
def rle_encode(data):
    encoding = ''
    prev_char = ''
    count = 1

    if not data: return ''

    for char in data:
        # If the prev and current characters
        # don't match...
        if char != prev_char:
            # ...then add the count and character
            # to our encoding
            if prev_char:
                encoding += str(count) + prev_char + ' '
            count = 1
            prev_char = char
        else:
            # Or increment our counter
            # if the characters do match
            count += 1
    else:
        # Finish off the encoding
        encoding += str(count) + prev_char + ' '
        return encoding

N, K = [int(s) for s in input().split()]
S = input()
S_rle = rle_encode(S).split()
total = 0
for i, bunch in enumerate(S_rle):
  total += int(list(bunch)[0]) - 1

if len(S_rle) >= 2*K+3:
  print(total+2*K)
elif len(S_rle) >= 2*K:
  print(total+2*K-1)
else:
  print(N-1)

Fixed submission:
N = int(input())
print(N*N*N)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
print(sum(range(N)))

Fixed submission:
N = int(input())
print(sum(range(N)))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
all = []
count = []
nsame = 0
for i in range(N):
  tmp = collections.Counter(list(input()))
  if i >= 1:
    for j in range(i):
      if count[j] == tmp:
        nsame = nsame + 1
  count.append(tmp)
print(nsame)

Fixed submission:
N = int(input())
alldict = {}
nsame = 0
for i in range(N):
  tmp = list(input())
  tmp.sort()
  if ''.join(tmp) in alldict:
    alldict[''.join(tmp)] = alldict[''.join(tmp)] + 1
  else:
    alldict[''.join(tmp)] = 1

from operator import mul
from functools import reduce
def cmb(n,r):
    if n == 1:
        return 0
    r = min(n-r,r)
    if r == 0:
        return 1
    ov = reduce(mul, range(n, n-r, -1))
    un = reduce(mul, range(1, r+1))
    return ov // un

print(sum([cmb(i, 2) for i in alldict.values()]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
all = []
count = []
for i in range(N):
  count.append(collections.Counter(list(input())))
nsame = 0
for i in range(N):
  for j in range(i+1, N):
    if count[i] == count[j]:
      nsame = nsame + 1
print(nsame)

Fixed submission:
N = int(input())
alldict = {}
nsame = 0
for i in range(N):
  tmp = list(input())
  tmp.sort()
  if ''.join(tmp) in alldict:
    alldict[''.join(tmp)] = alldict[''.join(tmp)] + 1
  else:
    alldict[''.join(tmp)] = 1

from operator import mul
from functools import reduce
def cmb(n,r):
    if n == 1:
        return 0
    r = min(n-r,r)
    if r == 0:
        return 1
    ov = reduce(mul, range(n, n-r, -1))
    un = reduce(mul, range(1, r+1))
    return ov // un

print(sum([cmb(i, 2) for i in alldict.values()]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
all = []
count = []
for i in range(N):
  tmp = list(input())
  all.append(tmp.copy())
  count.append(collections.Counter(tmp))
nsame = 0
for i in range(N):
  for j in range(i+1, N):
    if count[i] == count[j]:
      nsame = nsame + 1
print(nsame)

Fixed submission:
N = int(input())
alldict = {}
nsame = 0
for i in range(N):
  tmp = list(input())
  tmp.sort()
  if ''.join(tmp) in alldict:
    alldict[''.join(tmp)] = alldict[''.join(tmp)] + 1
  else:
    alldict[''.join(tmp)] = 1

from operator import mul
from functools import reduce
def cmb(n,r):
    if n == 1:
        return 0
    r = min(n-r,r)
    if r == 0:
        return 1
    ov = reduce(mul, range(n, n-r, -1))
    un = reduce(mul, range(1, r+1))
    return ov // un

print(sum([cmb(i, 2) for i in alldict.values()]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = [int(s) for s in input().split()]
if N == 1:
  print('Yes')
else:
  Hc = H.copy()
  Hc[0] = Hc[0]-1
  flg = 'Yes'
  for i in range(N-1):
    if Hc[i+1] - Hc[i] >= 1:
      Hc[i+1] = Hc[i+1] - 1
    elif Hc[i+1] - Hc[i] < 0:
      flg = 'No'
  print(flg)

Fixed submission:
N = int(input())
H = [int(s) for s in input().split()]
if N == 1:
  print('Yes')
else:
  Hc = H.copy()
  Hc[0] = Hc[0]-1
  flg = 'Yes'
  for i in range(N-1):
    if Hc[i+1] - Hc[i] >= 1:
      Hc[i+1] = Hc[i+1] - 1
    elif Hc[i+1] - Hc[i] < 0:
      flg = 'No'
  print(flg)
Buggy python submission (verdict: Runtime Error):
r_str = r_str.split()
r = [int(s) for s in r_str]
a = 'Yes'
 
if r[0] <= r[1]:
    if r[0] <= r[2] and r[2] <= r[1]:
        a = 'Yes'
    else:
        a = 'No'
else:
    if r[1] <= r[2] and r[2] <= r[0]:
        a = 'Yes'
    else:
        a = 'No'
 
print(a)

Fixed submission:
r_str = input()
r_str = r_str.split()
r = [int(s) for s in r_str]
a = 'Yes'
 
if r[0] <= r[1]:
    if r[0] <= r[2] and r[2] <= r[1]:
        a = 'Yes'
    else:
        a = 'No'
else:
    if r[1] <= r[2] and r[2] <= r[0]:
        a = 'Yes'
    else:
        a = 'No'
 
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for i in range(q):
    query = input().split()
    if query[0] == '1':
        s = s[::-1]
        continue
    if query[1] == '1':
        s = query[2] + s
        continue
    s = s + query[2]
print(s)


Fixed submission:
s = input()
q = int(input())

conv = 0
pre = []
pos = []
for i in range(q):
    query = input().split()
    if query[0] == '1':
        conv += 1
        continue
    if (int(query[1])+conv) %2 == 1:
        pre.append(query[2])
        continue
    pos.append(query[2])
if conv % 2 == 0:
    pre = ''.join(pre[::-1])
    pos = ''.join(pos[::1])
    s = pre + s + pos
else:
    pre = ''.join(pre[::1])
    pos = ''.join(pos[::-1])
    s = s[::-1]
    s = pos + s + pre
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ['']*n
for i in range(n):
    s[i] = ''.join(sorted(input()))
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        if s[i] == s[j]:
            ans += 1
print(ans)


Fixed submission:
n = int(input())
dic = {}
for i in range(n):
    tmp = ''.join(sorted(input()))
    if tmp in dic:
        dic[tmp] = dic[tmp]+1
    else:
        dic.setdefault(tmp, 0)
ans = 0
for i in dic:
    ans += 1/2 * dic[i] * (dic[i]+1)
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ['']*n
for i in range(n):
    s[i] = ''.join(sorted(input()))
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        if s[i] == s[j]:
            ans += 1
print(ans)


Fixed submission:
n = int(input())
dic = {}
for i in range(n):
    tmp = ''.join(sorted(input()))
    if tmp in dic:
        dic[tmp] = dic[tmp]+1
    else:
        dic.setdefault(tmp, 0)
ans = 0
for i in dic:
    ans += 1/2 * dic[i] * (dic[i]+1)
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

ans = [0]*(n+1)
for i in range(0, a[0]*2+1, 2):
    ans[0] = i
    for j in range(n):
        ans[j+1] = (a[j] - ans[j]//2) *2
    if ans[0] == ans[n]:
        print(' '.join(map(str, ans[0:len(ans)-1])))
        exit(0)


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

ans = [0]*(n+1)
#for i in range(0, a[0]*2+1, 2):
#    ans[0] = i
while True:
    for j in range(n):
        ans[j+1] = (a[j] - ans[j]//2) *2
    if ans[0] == ans[n]:
        print(' '.join(map(str, ans[0:len(ans)-1])))
        exit(0)
    else:
        ans[0] += ans[n]//2
Buggy python submission (verdict: Runtime Error):
import math

MOD = 10 ** 9 + 7

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

for i in range(1, k+1):
    c = comb(n-k+1, i) % MOD
    d = comb(k-1, i-1) % MOD
    print((c * d) % MOD )


Fixed submission:
import math

MOD = 10 ** 9 + 7

def comb(n, r):
    if n - r < 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

for i in range(1, k+1):
    c = comb(n-k+1, i) % MOD
    d = comb(k-1, i-1) % MOD
    print((c * d) % MOD )
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
lr = []
for i in range(q): lr.append(list(map(int, input().split())))
ac = ['1' if 'AC'==s[i-1:i+1] else '0' for i in range(1,len(s))]
for i in lr: print(ac[i[0]-1:i[1]-1].count('1'))

Fixed submission:
import itertools
n,q = map(int,input().split())
s = input()
lr = []
for i in range(q): lr.append(list(map(int, input().split())))
ac = [1 if i!=0 and 'AC'==s[i-1:i+1] else 0 for i in range(0,len(s))]
acc = list(itertools.accumulate(ac))
for i in lr: print(acc[i[1]-1]-acc[i[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re

n,q = map(int,input().split())
s = input()
lr = []
for i in range(q): lr.append(list(map(int, input().split())))
for i in lr: print(len(re.findall('AC', s[i[0]-1:i[1]])))

Fixed submission:
import itertools
n,q = map(int,input().split())
s = input()
lr = []
for i in range(q): lr.append(list(map(int, input().split())))
ac = [1 if i!=0 and 'AC'==s[i-1:i+1] else 0 for i in range(0,len(s))]
acc = list(itertools.accumulate(ac))
for i in lr: print(acc[i[1]-1]-acc[i[0]-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
start = now = len(s)
while True:
    s = s.replace('01','').replace('10','')
    if now == len(s):
        break
    now = len(s)
print(start - now)

Fixed submission:
s = input()

print(2 * min(s.count('0'),s.count('1')))

Buggy python submission (verdict: Time Limit Exceeded):
import re
s = input()

start = now = len(s)
while True:
    s = s.replace('01','').replace('10','')
    if now == len(s):
        break
    now = len(s)
print(start - now)


Fixed submission:
s = input()

print(2 * min(s.count('0'),s.count('1')))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math

K = int(input())
nums = [i for i in range(1, K+1)]
product = itertools.product(nums, repeat=3)
ans = 0
for comb in product:
    m = min(comb)
    for i in range(3):
        m = math.gcd(m, comb[i])
    ans += m
print(ans)

Fixed submission:
import itertools
import math

K = int(input())
nums = [i for i in range(1, K+1)]
product = itertools.product(nums, repeat=3)
ans = 0
for comb in product:
    m = min(comb)
    if m == 1:
        ans += m
    else:
        for i in range(0, 3):
            m = math.gcd(m, comb[i])
        ans += m
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
q, mod = divmod(N, K)
if mod == 0:
    print(0)
else:
    while True:
        sub = abs(N-K)
        if sub < N:
            N = sub
        else:
            print(min(sub, N))
            break

Fixed submission:
N, K = map(int, input().split())
q, mod = divmod(N, K)
if mod == 0:
    print(0)
else:
    if mod*2 > K:
        print(abs(mod-K))
    else:
        print(mod)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
q, mod = divmod(N, K)
if mod == 0:
    print(0)
else:
    while True:
        sub = abs(N-K)
        if sub < N:
            N = sub
        else:
            print(min(sub, N))
            break

Fixed submission:
N, K = map(int, input().split())
q, mod = divmod(N, K)
if mod == 0:
    print(0)
else:
    if mod*2 > K:
        print(abs(mod-K))
    else:
        print(mod)
Buggy python submission (verdict: Runtime Error):
K = int(input())
cand = [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
for _ in range(4):
    tmp = []
    for v in cand[-1]:
        if v%10 != 0:
            tmp.append(v*10 + (v%10-1))
        tmp.append(v*10 + (v%10))
        if v%10 != 9:
            tmp.append(v*10 + (v%10+1))
    cand.append(tmp)
ans = []
for i in range(len(cand)):
    for v in cand[i]:
        ans.append(v)
ans = sorted(ans)
print(ans[K-1])

Fixed submission:
K = int(input())
cand = [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
for _ in range(9):
    tmp = []
    for v in cand[-1]:
        if v%10 != 0:
            tmp.append(v*10 + (v%10-1))
        tmp.append(v*10 + (v%10))
        if v%10 != 9:
            tmp.append(v*10 + (v%10+1))
    cand.append(tmp)
ans = []
for i in range(len(cand)):
    for v in cand[i]:
        ans.append(v)
ans = sorted(ans)
print(ans[K-1])
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = N // (A+B) * A
rem = n % (A+B)
ans += min(rem, A)
print(ans)

Fixed submission:
N, A, B = map(int, input().split())
ans = N // (A+B) * A
rem = N % (A+B)
ans += min(rem, A)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
sum_a = sum(a)
for i in range(n):
    if a[i] > sum_a/(4*m): 
        ans = i
# print(sum_a/(4*m))
if ans >=m:
    print("Yes")
else:
    print("No")



Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
sum_a = sum(a)
# print(a)
ans = 0
for i in range(n):
    if a[i] >= sum_a/(4*m): 
        ans = i+1
# print(ans)
# print(sum_a/(4*m))
if ans >=m:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
from collections import Counter

def flatten_2dim(array):
    return [item for sublist in array for item in sublist]

n,x,y = map(int,input().split())

# l = [[0,1,0,0,0],[1,0,1,1,0],[0,1,0,1,0],[0,1,1,0,1],[0,0,0,1,0]]

l = [[0]*n for i in range(n)]
for i in range(n-1):
    l[i][i+1] = 1
    l[i+1][i] = 1 
l[x-1][y-1] = 1
l[y-1][x-1] = 1
# l.append([x,y])

a = np.array(l)
ans = shortest_path(a)
ans_counter = Counter(flatten_2dim(ans))
# values = ans_counter.values()
# print(l)
# print(ans)
for i in range(1,n):
    print(int(ans_counter[i]/2))

Fixed submission:
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
from collections import Counter

def flatten_2dim(array):
    return [item for sublist in array for item in sublist]

n,x,y = map(int,input().split())

# l = [[0,1,0,0,0],[1,0,1,1,0],[0,1,0,1,0],[0,1,1,0,1],[0,0,0,1,0]]

l = [[0]*n for i in range(n)]
for i in range(n-1):
    l[i][i+1] = 1
    l[i+1][i] = 1 
l[x-1][y-1] = 1
l[y-1][x-1] = 1
# l.append([x,y])

a = np.array(l)
ans = shortest_path(a,method ="D")
ans_counter = Counter(flatten_2dim(ans))
# values = ans_counter.values()
# print(l)
# print(ans)
for i in range(1,n):
    print(int(ans_counter[i]/2))

# print(ans_counter[1])
# print(values)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
n,m = map(int,input().split())
ans = comb(n,2,exact=True)+comb(m,2,exact=True)

print(ans)

Fixed submission:
n,m = map(int,input().split())
a = int(n*(n-1)/2)
b = int(m*(m-1)/2)
print(a+b)