Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ab = sorted(ab,key=lambda x: x[0],reverse=True)
b = [i[1] for i in ab]
b_set = list(set(b))
d = {}
for i in b_set:
    d[i] = []
for i in ab:
    d[i[1]].append(i[0])
dk = sorted(list(d.keys()),reverse=True)
ans = 0
for i in range(1,m+1):
    x = 0
    for j in dk:
        if d[j]:
            if d[j][-1] <= i:
                y = d[j].pop(-1)
                x = j
                break
    ans += x
print(ans)

Fixed submission:
import heapq

n,m = map(int,input().split())
ab = [tuple(map(int,input().split())) for i in range(n)]
ab = sorted(ab,key=lambda x: x[0],reverse=True)
heap = []
ans = 0
for i in range(1,m+1):
    while True:
        if not ab:
            break
        elif ab[-1][0] <= i:
            x = ab.pop(-1)
            heapq.heappush(heap,x[1]*-1)
        else:
            break
    if heap:
        y = heapq.heappop(heap)
        ans += y*-1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = [int(input()) for i in range(n)]
a_max = max(a)
for i in range(n):
    if a_max == a[i]:
        a_ = copy.deepcopy(a)
        del a_[i]
        print(max(a_))
    else:
        print(a_max)


Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_sorted = sorted(a)
a_max = a_sorted[-1]
a_sec = a_sorted[-2]
for i in range(n):
    if a_max == a[i]:
        print(a_sec)
    else:
        print(a_max)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = []
temp = [0]*80
for i in range(n):
    x = n-i
    y = 0
    for j in range(n):
        if x*(j+2) <= n:
            if temp[x*(j+2)-1] == 1:
                y += 1
        else:
            break
    if not y%2 == a[x-1]:
        ans.append(x)
        temp[x-1] += 1
s = len(ans)
print(s)
if s > 0:
    print(" ".join([str(i) for i in ans]))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = []
temp = [0]*n
for i in range(n):
    x = n-i
    y = 0
    for j in range(n):
        if x*(j+2) <= n:
            if temp[x*(j+2)-1] == 1:
                y += 1
        else:
            break
    if not y%2 == a[x-1]:
        ans.append(x)
        temp[x-1] += 1
s = len(ans)
print(s)
if s > 0:
    print(" ".join([str(i) for i in ans]))
Buggy python submission (verdict: Runtime Error):
        n = int(input())
        s = []
        for i in range(n):
          s.append(input())
         
        ab = 0
        ab_ = 0
        a = 0
        b = 0
        for i in s:
          ab += i.count("AB")
          if i[0] == "B" and i[-1] == "A":
            ab_ += 1
          if i[0] == "B":
            b += 1
          if i[-1] == "A":
            a += 1
        if ab_ == a and ab_ == b and not ab_ == 0:
          print(ab+ab_-1)
        else:
          print(ab+min([a,b]))

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s.append(input())
     
ab = 0
ab_ = 0
a = 0
b = 0
for i in s:
  ab += i.count("AB")
  if i[0] == "B" and i[-1] == "A":
    ab_ += 1
  if i[0] == "B":
    b += 1
  if i[-1] == "A":
    a += 1
if ab_ == a and ab_ == b and not ab_ == 0:
  print(ab+ab_-1)
else:
  print(ab+min([a,b]))

Buggy python submission (verdict: Runtime Error):
    n = int(input())
    s = []
    for i in range(n):
      s.append(input())
     
    ab = 0
    ab_ = 0
    a = 0
    b = 0
    for i in s:
      ab += i.count("AB")
      if i[0] == "B" and i[-1] == "A":
        ab_ += 1
      if i[0] == "B":
        b += 1
      if i[-1] == "A":
        a += 1
    if ab_ == a and ab_ == b and not ab_ == 0:
      print(ab+ab_-1)
    else:
      print(ab+min([a,b]))

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s.append(input())
     
ab = 0
ab_ = 0
a = 0
b = 0
for i in s:
  ab += i.count("AB")
  if i[0] == "B" and i[-1] == "A":
    ab_ += 1
  if i[0] == "B":
    b += 1
  if i[-1] == "A":
    a += 1
if ab_ == a and ab_ == b and not ab_ == 0:
  print(ab+ab_-1)
else:
  print(ab+min([a,b]))

Buggy python submission (verdict: Runtime Error):
    n = int(input())
    s = []
    for i in range(n):
      s.append(input())
     
    ab = 0
    ab_ = 0
    a = 0
    b = 0
    for i in s:
      ab += i.count("AB")
      if i[0] == "B" and i[-1] == "A":
        ab_ += 1
      if i[0] == "B":
        b += 1
      if i[-1] == "A":
        a += 1
    if ab_ == a and ab_ == b and not ab_ == 0:
      print(ab+ab_-1)
    else:
      print(ab+min([a,b]))

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s.append(input())
     
ab = 0
ab_ = 0
a = 0
b = 0
for i in s:
  ab += i.count("AB")
  if i[0] == "B" and i[-1] == "A":
    ab_ += 1
  if i[0] == "B":
    b += 1
  if i[-1] == "A":
    a += 1
if ab_ == a and ab_ == b and not ab_ == 0:
  print(ab+ab_-1)
else:
  print(ab+min([a,b]))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if n<=m:
  print(0)
else:
  d=[]
  for j in range(n-1):
    d.append(x[i+1]-x[i])
  d=sorted(d)
  print(sum(d[:m]))

Fixed submission:
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if m<=n:
  print(0)
else:
  d=[]
  for i in range(m-1):
    d.append(x[i+1]-x[i])
  d=sorted(d)
  print(sum(d[:m-n]))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
x=10**9
for i in range(n-k+1):
  x=min(x,h[i+k]-h[i])
print(x)

Fixed submission:
n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
x=10**9
for i in range(n-k+1):
  x=min(x,h[i+k-1]-h[i])
print(x)
Buggy python submission (verdict: Runtime Error):
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  divisors.append(n)
  return divisors
n,x=map(int,input().split())
y=list(map(int,input().split()))
y.append(x)
y.sort()
z=[]
for i in range(n-1):
  z.append(y[i+1]-y[i])
z.sort()
p=make_divisors(z[0])
a=[]
for i in p:
  for j in z:
    if j%i:
      break
  else:
    a.append(i)
print(max(a))

Fixed submission:
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  divisors.append(n)
  return divisors
n,x=map(int,input().split())
y=list(map(int,input().split()))
y.append(x)
y.sort()
z=[]
for i in range(n):
  z.append(y[i+1]-y[i])
z.sort()
p=make_divisors(z[0])
a=[]
for i in p:
  for j in z:
    if j%i:
      break
  else:
    a.append(i)
print(max(a))
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
s=sorted(x)
p,q=s[n//2],s[n//2+1]
for i in x:
  if i<=p:
    print(q)
  else:
    print(p)

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
s=sorted(x)
p,q=s[n//2-1],s[n//2]
for i in x:
  if i<=p:
    print(q)
  else:
    print(p)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
x = a.pop(-1)
kj = [1,1]
for i in range(2,x+1):
  kj.append(kj[-1]*i)
ans_val = []
ans_list = []
for i in a:
  ans_val.append(kj[x]/(kj[x-i]*kj[i]))
  ans_list.append(i)
print(x,ans_list[ans_val.index(max(ans_val))])

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
x = a.pop(-1)
x2 = x/2
ans = a[0]
t = abs(x2-ans)
for i in a:
  if abs(x2-i) < t:
    ans = i
    t = abs(x2-ans)
print(x,ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[0]
a.extend(list(map(int,input().split())))
a.append([0])
s=0
for i in range(n+1):
  s+=abs(a[i+1]-a[i])
for i in range(1,n+1):
  print(s-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1]))

Fixed submission:
n=int(input())
a=[0]
a.extend(list(map(int,input().split())))
a.append(0)
s=0
for i in range(n+1):
  s+=abs(a[i+1]-a[i])
for i in range(1,n+1):
  print(s-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1]))
Buggy python submission (verdict: Runtime Error):
x,y,z=map(int,input())
print((x-1)//(y+z))

Fixed submission:
x,y,z=map(int,input().split())
print((x-z)//(y+z))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input(),split())
print(min([a+b,b+c,c+a]))

Fixed submission:
a,b,c = map(int,input().split())
print(min([a+b,b+c,c+a]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[(i,int(input())-1) for i in range(n)]
c,x=0,0
for i in range(n):
  x=a[x]
  if x==2:
    print(i+1)
    break
else:
  print(-1)

Fixed submission:
n=int(input())
a=[int(input())-1 for i in range(n)]
c,x=1,0
for i in range(n):
  x=a[x]
  if x==1:
    print(i+1)
    break
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[int(input()) for _ in range(n)]
x=sum(s)
if x%10:
  print(x)
else:
  a=[]
  for i in s:
    if i%10:
      a.appned(i)
  if a:
    print(x-min(a))
  else:
    print(0)
  

Fixed submission:
n=int(input())
s=[int(input()) for _ in range(n)]
x=sum(s)
if x%10:
  print(x)
else:
  a=[]
  for i in s:
    if i%10:
      a.append(i)
  if a:
    print(x-min(a))
  else:
    print(0)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input())
print("#"*(w+2))
for _ in range(h):
  print("#"+input()+"#")
print("#"*(w+2))

Fixed submission:
h,w=map(int,input().split())
print("#"*(w+2))
for _ in range(h):
  print("#"+input()+"#")
print("#"*(w+2))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input())
s=set()
while True:
  x=a%b
  if x==c:
    print("YES")
    break
  elif x in s:
    print("NO")
    break
  else:
    s.add(x)

Fixed submission:
a,b,c=map(int,input().split())
a_=a
s=set()
while True:
  x=a_%b
  if x==c:
    print("YES")
    break
  elif x in s:
    print("NO")
    break
  else:
    s.add(x)
  a_+=a
Buggy python submission (verdict: Runtime Error):
n,t=map(int,input().split())
x=list(map(int,input().split()))
a=t
for i in range(n-1):
  a.append(min(x[i+1]-x[i],t))
print(a)

Fixed submission:
n,t=map(int,input().split())
x=list(map(int,input().split()))
a=t
for i in range(n-1):
  a+=min(x[i+1]-x[i],t)
print(a)
Buggy python submission (verdict: Runtime Error):
o,e=input(),input()
ans=[]
for i in range(len(o)):
  ans.append(o[i])
  if e:
    ans.append(e[i])
print("".join(ans))

Fixed submission:
o,e=input(),input()
ans=[]
for i in range(len(o)):
  ans.append(o[i])
  if i<len(e):
    ans.append(e[i])
print("".join(ans))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
ans=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    p,q=a[i]
    r,s=c[j]
    d=abs(p-r)+abs(q-s)
    ans[i].append((d,j+1))
  ans[i]=sorted(ans[i])
for i in ans:
  print(ans[0][1])

Fixed submission:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
ans=[[] for _ in range(n)]
for i in range(n):
  p,q=a[i]
  for j in range(m):
    r,s=c[j]
    d=abs(p-r)+abs(q-s)
    ans[i].append((d,j+1))
  ans[i]=sorted(ans[i])
for i in ans:
  print(i[0][1])
Buggy python submission (verdict: Runtime Error):
if eval(input().replace(" ","==")):
  print("H")
else:
  print("D")

Fixed submission:
a,b=input().split()
if a==b:
  print("H")
else:
  print("D")
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
if a==b:
  print("Draw")
elif a==1:
  print("Alice")
elif b==1:
  print("Bob")
elif a>b:
  print("Alice")
else:
  print("Bob")

Fixed submission:
a,b = map(int,input().split())
if a==b:
  print("Draw")
elif a==1:
  print("Alice")
elif b==1:
  print("Bob")
elif a>b:
  print("Alice")
else:
  print("Bob")
Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split())
a=0
for i in range(k+1):
  for j in range(k+1):
    if s-i-j <=k and s-i-j >=0:
      a+=1
print(ans)

Fixed submission:
k,s=map(int,input().split())
a=0
for i in range(k+1):
  for j in range(k+1):
    if s-i-j <=k and s-i-j >=0:
      a+=1
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    def dijkstra_back(s,t):
        prev = [s] * n
        d = [float("inf")] * n
        used = [False] * n
        d[s] = 0
        while True:
            v = -1
            for i in range(n):
                if (not used[i]) and (v == -1):
                   v = i
                elif (not used[i]) and d[i] < d[v]:
                    v = i
            if v == -1:
                   break
            used[v] = True
            for i in range(n):
                if d[i] > d[v] + cost[v][i]: 
                    d[i] = d[v] + cost[v][i]
                    prev[i] = v
        path = [t]
        while prev[t] != s:
            path.append(prev[t])
            prev[t] = prev[prev[t]]
        path.append(s)
        path = path[::-1]
        return path
    
    n,m = map(int,input().split())
    route = [tuple(map(int,input().split())) for _ in range(m)]
    INF = float('inf')
    cost = [[INF for i in range(n)] for i in range(n)] 
    for i in route:
        cost[i[0]-1][i[1]-1] = i[2]
        cost[i[1]-1][i[0]-1] = i[2]
    
    used_ways = set([])
    for i in range(n):
        for j in range(n):
            if i < j:
                way = dijkstra_back(i,j)
                for k in range(len(way)-1):
                    used_ways.add(tuple(sorted([way[k],way[k+1]])))
    route_set = set([])
    for i in route:
        route_set.add(tuple(sorted([i[0]-1,i[1]-1])))
    print(len(route_set-used_ways))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    def dijkstra_back(s,t):
        prev = [s] * n
        d = [float("inf")] * n
        used = [False] * n
        d[s] = 0
        while True:
            v = -1
            for i in range(n):
                if (not used[i]) and (v == -1):
                   v = i
                elif (not used[i]) and d[i] < d[v]:
                    v = i
            if v == -1:
                   break
            used[v] = True
            for i in range(n):
                if d[i] > d[v] + cost[v][i]: 
                    d[i] = d[v] + cost[v][i]
                    prev[i] = v
        path = [t]
        while prev[t] != s:
            path.append(prev[t])
            prev[t] = prev[prev[t]]
        path.append(s)
        path = path[::-1]
        return path
    
    n,m = map(int,input().split())
    route = [tuple(map(int,input().split())) for _ in range(m)]
    INF = float('inf')
    cost = [[INF for i in range(n)] for i in range(n)] 
    for i in route:
        cost[i[0]-1][i[1]-1] = i[2]
        cost[i[1]-1][i[0]-1] = i[2]
    
    used_ways = set([])
    for i in range(n):
        for j in range(n):
            if i < j:
                way = dijkstra_back(i,j)
                for k in range(len(way)-1):
                    used_ways.add(tuple(sorted([way[k],way[k+1]])))
    route_set = set([])
    for i in route:
        route_set.add(tuple(sorted([i[0]-1,i[1]-1])))
    print(len(route_set-used_ways))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
w,h,n=map(int,input().split())
p,s,r,s=0,w,0,h
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    p=max(p,x)
  elif a==2:
    q=min(q,x)
  elif a==3:
    r=max(r,y)
  elif a==4:
    s=min(s,y)
print((p-q)*(r-s))
    

Fixed submission:
w,h,n=map(int,input().split())
p,q,r,s=0,w,0,h
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    p=max(p,x)
  elif a==2:
    q=min(q,x)
  elif a==3:
    r=max(r,y)
  elif a==4:
    s=min(s,y)
print(max(0,q-p)*max(0,s-r))
Buggy python submission (verdict: Runtime Error):
print((int(input()+int(input())*(int(input())//2))

Fixed submission:
print((int(input())+int(input()))*(int(input())//2))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
s=list(input())
d=defaultdict(0)
for i in s:
  d[i]+=1
for i in d.values():
  if i%2:
    print("No")
    break
else:
  print("Yes")

Fixed submission:
from collections import defaultdict
s=list(input())
d=defaultdict(int)
for i in s:
  d[i]+=1
for i in d.values():
  if i%2:
    print("No")
    break
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
import matplotlib.pyplot as plt

#def main(S, b):
if __name__ == '__main__':
    a = input()
    b = a.upper()

    if (a == b):
        print('A')
    else:
        print("a")


Fixed submission:
if __name__ == '__main__':
    a = input()
    b = a.upper()

    if (a == b):
        print('A')
    else:
        print("a")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

#a, b = map(int, input().split())
N = int(input())

#map(int, input().split())

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

cnt = 1

for i in range(1, N):
    if P[i] < min(P[:i]):
        cnt += 1
print(cnt)
        


Fixed submission:
import numpy as np

#a, b = map(int, input().split())
N = int(input())

#map(int, input().split())

# def bubble_sort(lst):
#     cnt = 0
#     for i in range(len(lst)-1):
#         for j in range(len(lst)-1, i, -1):
#             if lst[j-1] > lst[j]:
#                 tmp = lst[j]
#                 lst[j] = lst[j-1]
#                 lst[j-1] = tmp
#                 cnt += 1
#     return cnt

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

cnt = 1

tmp = P[0]
for i in range(1, N):    
    if P[i] < tmp:
        tmp = P[i]
        cnt += 1
        
            
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
MOD = 10 **9 + 7
 
ni = [0 for _ in range(60)]
for i in range(N):
    tmp = A[i]
    count = 0
    while(True):
        if tmp % 2 == 1:
            ni[count] += 1
        count += 1
        tmp = tmp // 2
        if tmp == 0:
            break
ans = 0
for j in range(60):
    ans += (ni[j] * (N-ni[j])) * 2 ** j 
 
print(ans%MOD)

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

if a+b+c>=22:
    print("bust")
else:
    print("win")

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
MOD = 10 **9 + 7
 
ni = [0 for _ in range(60)]
for i in range(N):
    tmp = A[i]
    count = 0
    while(True):
        if tmp % 2 == 1:
            ni[count] += 1
        count += 1
        tmp = tmp // 2
        if tmp == 0:
            break
ans = 0
for j in range(60):
    ans += (ni[j] * (N-ni[j])) * 2 ** j 
 
print(ans%MOD)

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

if a+b+c>=22:
    print("bust")
else:
    print("win")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
MOD = 10 **9 + 7

ni = [0 for _ in range(60)]
for i in range(N):
    tmp = A[i]
    count = 0
    while(True):
        if tmp % 2 == 1:
            ni[count] += 1
        count += 1
        tmp = tmp // 2
        if tmp == 0:
            break
ans = 0
for j in range(60):
    ans += (ni[j] * (N-ni[j])) * 2 ** j 

print(ans%MOD)


    


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
MOD = 10 **9 + 7
 
ni = [0 for _ in range(60)]
for i in range(N):
    tmp = A[i]
    count = 0
    while(True):
        if tmp % 2 == 1:
            ni[count] += 1
        count += 1
        tmp = tmp // 2
        if tmp == 0:
            break
ans = 0
for j in range(60):
    ans += (ni[j] * (N-ni[j])) * 2 ** j 
 
print(ans%MOD)
Buggy python submission (verdict: Runtime Error):
import math

S = input()
K = int(input())
#print(S)
cnt = 1
ans = 0
for i in range(1,len(S)):
    if S[i] == S[i-1]:
        cnt += 1
    else:
        ans += cnt //2 
        cnt = 1
ans += cnt //2 
#print("ans", ans)    
ans *= K
#print("ans*K",ans)
if S[0] == S[-1]:
    cntf = 1
    cnte = 1
    for i in range(1,len(S)):
        #print(S[i], S[i-1] )
        if S[i] == S[i-1]:
            cntf += 1
        else:
            break
    #print("---------------")
    for i in range(1,len(S)):
        #print(S[-i], S[-i+1] )
        if S[-i-1] == S[-i]:
            cnte += 1
        else:
            break
    #print(cnte, cntf)
    if cnte % 2 ==1 and cntf % 2 ==1:
        #print("bbbb")
        ans += (K-1)  

if cnte == len(S):
    ans = len(S) * K // 2
print(ans)




Fixed submission:
import math

S = input()
K = int(input())
#print(S)
cnt = 1
ans = 0
for i in range(1,len(S)):
    if S[i] == S[i-1]:
        cnt += 1
    else:
        ans += cnt //2 
        cnt = 1
ans += cnt //2 
#print("ans", ans)    
ans *= K
#print("ans*K",ans)

if S[0] == S[-1]:
    cntf = 1
    cnte = 1
    for i in range(1,len(S)):
        #print(S[i], S[i-1] )
        if S[i] == S[i-1]:
            cntf += 1
        else:
            break
    #print("---------------")
    for i in range(1,len(S)):
        #print(S[-i], S[-i+1] )
        if S[-i-1] == S[-i]:
            cnte += 1
        else:
            break
    #print(cnte, cntf)
    if cnte % 2 ==1 and cntf % 2 ==1:
        #print("bbbb")
        ans += (K-1)  

    if cnte == len(S):
        #print("aaa")
        ans = len(S) * K // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

AA = np.argsort(A) + 1

print(AA.to_list())


Fixed submission:
import numpy as np
 
N = int(input())
A = list(map(int, input().split()))
A = np.array(A)
 
AA = np.argsort(A) + 1

print(*AA)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
S = list(input())

l = -1
r = -1

for k in range(K):
    for i in range(1, N):
        if S[i] != S[i-1]:
            if l < 0:
                l = i
            else:
                r = i
                for s in range(l, r):
                    if S[s] == "L":
                        S[s] = "R"
                    else:
                        S[s] = "L"
                l = -1
                r = -1
                break
        elif i == N-1 and l >= 0:
            for s in range(l, N):
                if S[s] == "L":
                    S[s] = "R"
                else:
                    S[s] = "L"
            l = -1
            break
ans = 0
for i in range(1, N):
    if S[i] == S[i-1]:
        ans += 1

print(ans)


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

l = -1
r = -1

k = 0
while k < K:
    for i in range(1, N):
        #print(i, l, "l")
        if S[i] != S[i-1]:
            if l < 0:
                l = i
            else:
                #print("a", l, i)
                r = i
                for s in range(l, r):
                    if S[s] == "L":
                        S[s] = "R"
                    else:
                        S[s] = "L"
                l = -1
                r = -1
                k += 1
                if k == K:
                    break
    l = -1
    r = -1
    # elif i == N-1 and l >= 0:
    #     for s in range(l, N):
    #         if S[s] == "L":
    #             S[s] = "R"
    #         else:
    #             S[s] = "L"
    #     l = -1
    #     k += 1
    #     if k == K:
    #         break
    if l < 0:
        break
ans = 0
#print(len(set(S)), k, K)
if len(set(S)) == 2 and k < K:
    ans += 1
for i in range(1, N):
    if S[i] == S[i-1]:
        ans += 1
# print(S)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
A = map(int, raw_input().split(' '))
B = map(int, raw_input().split(' '))

count = 0
zan_A_i = A[N]

for i in range(N):
    zan_B_i = B[N-1-i] - zan_A_i

    if zan_B_i < 0:
        #count += zan_B_i #A_i res
        zan_B_i = 0
    zan_A_i = A[N-1-i] - zan_B_i
    if zan_A_i < 0:
        count += zan_A_i 
        zan_A_i = 0

print(sum(B)+count)


Fixed submission:
A,B = map(int, raw_input().split(' '))


if (A+B) % 2 == 1:
      print("IMPOSSIBLE")
else:
      print((A+B)/2)
Buggy python submission (verdict: Runtime Error):
N, A, B = int(raw_input().split(' '))

print(min(int(A) * int(N), int(B)))


Fixed submission:
N, A, B = raw_input().split(' ')
 
print(min(int(A) * int(N), int(B)))