Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))

v_even = [0]*100000
v_odd = [0]*100000

for i in range(n):
  if i%2==0:
    v_even[v[i]] += 1 
  else:
    v_odd[v[i]] += 1
    
res1 = max(v_even)
res2 = max(v_odd)
if v_even.index(res1) == v_odd.index(res2):
  if res1 >= res2:
    v_odd[v_odd.index(res2)] = 0
    res2 = max(v_odd)
  else:
    v_even[v_even.index(res1)] = 0
    res1 = max(v_even)
print(n//2-res1 + n//2-res2)

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

v_even = [0]*100000
v_odd = [0]*100000

for i in range(n):
  if i%2==0:
    v_even[v[i]-1] += 1 
  else:
    v_odd[v[i]-1] += 1
    
res1 = max(v_even)
res2 = max(v_odd)
if v_even.index(res1) == v_odd.index(res2):
  if res1 > res2:
    v_odd[v_odd.index(res2)] = 0
    res2 = max(v_odd)
  elif res2 > res1:
    v_even[v_even.index(res1)] = 0
    res1 = max(v_even)
  elif res1 == res2:
    v_odd[v_odd.index(res2)] = 0
    v_even[v_even.index(res1)] = 0
    res3 = max(v_even)
    res4 = max(v_odd)
    if res3 > res4:
      res1 = res3
    else:
      res2 = res4
      
print(n//2-res1 + n//2-res2)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
res = 0
  
if s[0] == 'A':
  if s.find('C') >= 2 and s.find('C') < n-2:
    s.lower(0)
    s.lower(s.find('C'))
    if s == s.lower():
      print('AC')
    else:
      print('WA')
  else:
    print('WA')
else:
  print('WA')

Fixed submission:
s = input()
a = s.lower()
l = len(s)
c = 0
n = 0

if s[0] == 'A':
  for i in range(2 , l-1):
    if s[i] == 'C':
      c += 1
  if c == 1:
    for i in range(1,l):
      if s[i] != a[i]:
        n += 1
    if n == 1:
      print('AC')
      exit()
print('WA')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

b = [(a[i]-i-1) for i in range(n)]
#print(b)

s = sum(b)
m = int(s/n)
ans = float('inf')
if m<0:
  m = m-1
  for i in range(m, 1, 1):
    res = 0
    for j in range(n):
      res += abs(b[j]-i)
    ans = min(ans, res)
else:
  m = m+1
  for i in range(m+1):
    res = 0
    for j in range(n):
      res += abs(b[j]-i)
    ans = min(ans, res)
  
print(ans)

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

b = [(a[i]-i-1) for i in range(n)]
b = sorted(b)

if n % 2 == 1:
  res = b[(n-1)//2]
else:
  res = (b[n//2-1] + b[n//2])//2
  
print(sum(map(abs, [b[i]-res for i in range(n)])))

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

b = [(a[i]-i-1) for i in range(n)]
#print(b)

res1 = min(b)
res2 = max(b)
ans = float('inf')
for j in range(res1, res2+1, 1):
  res = 0
  for i in range(n):
    res += abs(b[i]-j)
    
  ans = min(ans, res)
  
print(ans)

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

b = [(a[i]-i-1) for i in range(n)]
b = sorted(b)

if n % 2 == 1:
  res = b[(n-1)//2]
else:
  res = (b[n//2-1] + b[n//2])//2
  
print(sum(map(abs, [b[i]-res for i in range(n)])))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = []
for i in range(n):
  res = 0
  if 1<=i<=n-2:
    for j in range(i):
      if s[j] == 'W':
        res += 1
    for k in range(i+1, n):
      if s[k] == 'E':
        res += 1
    ans.append(res)
    
  
  elif i == 0:
    if s[0] == 'E':
      res = s.count('E')-1
    else:
      res = s.count('E')
    ans.append(res)
      
  elif i == n-1:
    if s[n-1] == 'W':
      res = s.count('W')-1
    else:
      res = s.count('W')
    ans.append(res)
print(min(ans))

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

ans = [0]*(n+1)
for i in range(n):
  if s[i] == 'E':
    ans[i+1] = ans[i] + 1
  else:
    ans[i+1] = ans[i]
    
print(min(i-ans[i]+ans[n]-ans[i+1] for i in range(n)))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = n
for i in range(n):
  res = 0
  res += s[:i].count('W')
  res += s[i+1:n].count('E')
  ans = min(ans, res)
  
print(ans)

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

ans = [0]*(n+1)
for i in range(n):
  if s[i] == 'E':
    ans[i+1] = ans[i] + 1
  else:
    ans[i+1] = ans[i]
    
print(min(i-ans[i]+ans[n]-ans[i+1] for i in range(n)))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = n
for i in range(n):
  res = 0
  for j in range(i):
    if s[j] == 'W':
      res += 1
  for k in range(i+1, n):
    if s[k] == 'E':
      res += 1
  ans = min(ans, res)
print(ans)


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

ans = [0]*(n+1)
for i in range(n):
  if s[i] == 'E':
    ans[i+1] = ans[i] + 1
  else:
    ans[i+1] = ans[i]
    
print(min(i-ans[i]+ans[n]-ans[i+1] for i in range(n)))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = n
for i in range(n):
  res = 0
  res += s[:i].count('W')
  res += s[i+1:n].count('E')
  ans = min(ans, res)
  
print(ans)

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

ans = [0]*(n+1)
for i in range(n):
  if s[i] == 'E':
    ans[i+1] = ans[i] + 1
  else:
    ans[i+1] = ans[i]
    
print(min(i-ans[i]+ans[n]-ans[i+1] for i in range(n)))

Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())
s = input()

ans = n
for i in range(n):
  res = 0
  for j in range(i):
    if s[j] == 'W':
      res += 1
  for k in range(i+1, n):
    if s[k] == 'E':
      res += 1
  ans = min(ans, res)
print(ans)

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

ans = [0]*(n+1)
for i in range(n):
  if s[i] == 'E':
    ans[i+1] = ans[i] + 1
  else:
    ans[i+1] = ans[i]
    
print(min(i-ans[i]+ans[n]-ans[i+1] for i in range(n)))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=list(map(int,input().split()))
m=n//2

for i in range(n):
  data=x[:i]+x[i+1:]
  data.sort()
  print(data[m-1])

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

res1 = x[n//2]
res2 = x[n//2 -1]

for i in range(n):
  if X[i] >= res1:
    print(res2)
  elif X[i] <= res2:
    print(res1)

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

for i in X:
  x = sorted(X)
  p = x.index(i)
  x.pop(p)
  print(x[n//2- 1])

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

res1 = x[n//2]
res2 = x[n//2 -1]

for i in range(n):
  if X[i] >= res1:
    print(res2)
  elif X[i] <= res2:
    print(res1)

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

for i in X:
  x = sorted(X)
  x.pop(i)
  print(x[n//2- 1])

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

res1 = x[n//2]
res2 = x[n//2 -1]

for i in range(n):
  if X[i] >= res1:
    print(res2)
  elif X[i] <= res2:
    print(res1)

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

for i in X:
  t = x.index(i)
  if t < n//2:
    print(x[n//2])
  else:
    print(x[n//2 -1])

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

res1 = x[n//2]
res2 = x[n//2 -1]

for i in range(n):
  if X[i] >= res1:
    print(res2)
  elif X[i] <= res2:
    print(res1)
Buggy python submission (verdict: Time Limit Exceeded):
import math


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

ans = []
for i in range(n-1):
  for j in range(i+1, n):
    if a[j] > a[i]:
      res = math.factorial(a[j])//(math.factorial(a[i])*math.factorial(a[j-i]))
      ans.append((res, a[j], a[i]))
#print(max(ans))
print(max(ans)[1], max(ans)[2])

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

ans = a[1]
for i in range(1, n-1):
  if abs(a[0]/2 - a[i]) > abs(a[0]/2 - a[i+1]):
    ans = a[i+1]
  else:
    break
print(a[0], ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
d=[i for i in range(a,b+1)]
n=len(d)
if n>=2*k:
  ans=[0]*(2*k)
  for i in range(k):
    ans[i]=d[i]
    ans[2*k-1-i]=d[n-1-i]
  for j in ans:
    print(j)
  exit()
elif n<2*k:
  for i in range(n):
    print(d[i])
  exit()
    


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

if b-a <= k:
  for i in range(a, b+1):
    print(i)
else:
  ans = []
  for i in range(a, a+k):
    if i not in ans:
      ans.append(i)
      print(i)
  for j in range(b-k+1, b+1):
    if j not in ans:
      print(j)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
d=[i for i in range(a,b+1)]
ans=[]
n=len(d)
if n>=2*k:
  for i in range(k):
    ans.append(d[i])
    ans.append(d[n-1-i])
elif n<2*k:
  for i in range(n):
    print(d[i])
  exit()
    
ans.sort()
for i in ans:
  print(i)

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

if b-a <= k:
  for i in range(a, b+1):
    print(i)
else:
  ans = []
  for i in range(a, a+k):
    if i not in ans:
      ans.append(i)
      print(i)
  for j in range(b-k+1, b+1):
    if j not in ans:
      print(j)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
d=[i for i in range(a,b+1)]
ans=[]
n=len(d)
if n>=2*k:
  for i in range(k):
    ans.append(d[i])
    ans.append(d[n-1-i])
elif k<=n<2*k:
  for i in range(k):
    ans.append(d[i])
  for j in range(n-k):
    ans.append(d[n-1-j])
elif n<k:
  for i in range(n):
    print(d[i])
  exit()
    
ans.sort()
for i in ans:
  print(i)

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

if b-a <= k:
  for i in range(a, b+1):
    print(i)
else:
  ans = []
  for i in range(a, a+k):
    if i not in ans:
      ans.append(i)
      print(i)
  for j in range(b-k+1, b+1):
    if j not in ans:
      print(j)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
d=[i for i in range(a,b+1)]
ans=[]
n=len(d)
if n>=2*k:
  for i in range(k):
    ans.append(d[i])
    ans.append(d[n-1-i])
elif k<=n<2*k:
  for i in range(k):
    ans.append(d[i])
  for j in range(n-k):
    ans.append(d[n-1-j])
elif n<k:
  for i in range(n):
    ans.append(d[i])
    
ans.sort()
for i in ans:
  print(i)

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

if b-a <= k:
  for i in range(a, b+1):
    print(i)
else:
  ans = []
  for i in range(a, a+k):
    if i not in ans:
      ans.append(i)
      print(i)
  for j in range(b-k+1, b+1):
    if j not in ans:
      print(j)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())

ans = []
for i in range(a, b+1):
  if i <= a+k-1 or i>=b-k+1:
    if i not in ans:
      ans.append(i)
      print(i)

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

if b-a <= k:
  for i in range(a, b+1):
    print(i)
else:
  ans = []
  for i in range(a, a+k):
    if i not in ans:
      ans.append(i)
      print(i)
  for j in range(b-k+1, b+1):
    if j not in ans:
      print(j)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
for i in range(1,n+1):
  data=a[:i]+a[i+1:]
  ans=0
  for j in range(n):
    ans+=abs(data[j]-data[j+1])
  print(ans)

Fixed submission:
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
data=[]
for i in range(n+1):
  data.append(abs(a[i]-a[i+1]))
s=sum(data)
for i in range(n):
  print(s-data[i]-data[i+1]+abs(a[i]-a[i+2]))
Buggy python submission (verdict: Runtime Error):
from collections import deque


def bfs():
  d = [[float('inf')]* w for i in range(h)]
  
  dx = [1, 0, -1, 0]
  dy = [0, 1, 0, -1]
  
  que = deque([])
  que.append((sx, sy))
  d[sx][sy] = 0
  
  while que:
    p = que.popleft()
    if p[0] == gx and p[1] == gy:
      break
    for i in range(4):
      nx = p[0] + dx[i]
      ny = p[1] + dy[i]
      
      if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != '#' and d[nx][ny] == float('inf'):
        que.append((nx, ny))
        d[nx][ny] = d[p[0]][p[1]] + 1
        
  return d[gx][gy]
  
  
h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
sx, sy = 0, 0
gx, gy = h-1, w-1

white = 0
for i in range(h):
  for j in range(w):
    if maze[i][j] == '.':
      white += 1
      
res = bfs()
if 0 < res < float('inf'):
  print(white - res - 1)
else:

Fixed submission:
from collections import deque


def bfs():
  d = [[float('inf')]* w for i in range(h)]
  
  dx = [1, 0, -1, 0]
  dy = [0, 1, 0, -1]
  
  que = deque([])
  que.append((sx, sy))
  d[sx][sy] = 0
  
  while que:
    p = que.popleft()
    if p[0] == gx and p[1] == gy:
      break
    for i in range(4):
      nx = p[0] + dx[i]
      ny = p[1] + dy[i]
      
      if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != '#' and d[nx][ny] == float('inf'):
        que.append((nx, ny))
        d[nx][ny] = d[p[0]][p[1]] + 1
        
  return d[gx][gy]
  
  
h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
sx, sy = 0, 0
gx, gy = h-1, w-1

white = 0
for i in range(h):
  for j in range(w):
    if maze[i][j] == '.':
      white += 1
      
res = bfs()
if 0 < res < float('inf'):
  print(white - res - 1)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
n=len(s)
set=set(s)
m=len(set)
a=s.count('a')
b=s.count('b')
c=s.count('c')
if m==1:
  if n==1:
    print('YES')
  else:
    print('NO')
elif m==2:
  if c==0:
    if a==b:
      print('YES')
    else:
      print('NO')
  elif b==0:
    if a==c:
      print('YES')
    else:
      print('NO')
  else:
    if b==c:
      print('YES')
    else:
      print('NO')
else:
  d=n//m
  res=0
  if a<=d:
    res+=1
  if b<=d:
    res+=1
  if c<=d:
    res+=1
  if res<=1:
    print('YES')
  else:
    print('NO')

Fixed submission:
s=input()
n=len(s)
set=set(s)
m=len(set)
a=s.count('a')
b=s.count('b')
c=s.count('c')
if m==1:
  if n==1:
    print('YES')
  else:
    print('NO')
elif m==2:
  if n==2:
    print('YES')
  else:
    print('NO')
else:
  if n%3==0:
    if a==b==c:
      print('YES')
    else:
      print('NO')
  elif n%3==2:
    if (a==n//3+1 and b==n//3+1) or (c==n//3+1 and b==n//3+1) or (a==n//3+1 and c==n//3+1):
      print('YES')
    else:
      print('NO')
  else:
    if (a==n//3 and b==n//3) or (c==n//3 and b==n//3) or (a==n//3 and c==n//3):
      print('YES')
    else:
      print('NO')

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
set=set(s)
m=len(set)
a=s.count('a')
b=s.count('b')
c=s.count('c')
if m==1:
  if n==1:
    print('YES')
  else:
    print('NO')
elif m==2:
  if (a==b or b==a+1 or a=b+1) or (c==b or b==c+1 or c=b+1) or (a==c or c==a+1 or a=c+1):
    print('YES')
  else:
    print('NO')
else:
  d=n//m
  res=0
  if a<=d:
    res+=1
  if b<=d:
    res+=1
  if c<=d:
    res+=1
  if res>=d:
    print('YES')
  else:
    print('NO')

Fixed submission:
s=input()
n=len(s)
set=set(s)
m=len(set)
a=s.count('a')
b=s.count('b')
c=s.count('c')
if m==1:
  if n==1:
    print('YES')
  else:
    print('NO')
elif m==2:
  if n==2:
    print('YES')
  else:
    print('NO')
else:
  if n%3==0:
    if a==b==c:
      print('YES')
    else:
      print('NO')
  elif n%3==2:
    if (a==n//3+1 and b==n//3+1) or (c==n//3+1 and b==n//3+1) or (a==n//3+1 and c==n//3+1):
      print('YES')
    else:
      print('NO')
  else:
    if (a==n//3 and b==n//3) or (c==n//3 and b==n//3) or (a==n//3 and c==n//3):
      print('YES')
    else:
      print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
d.sort()
t.sort()
D=set(d)
T=set(t)
for i in T:
  if i not in D:
    print('NO')
    exit()
  else:
    if t.count(i)>d.count(i):
      print('NO')
      exit()
print('YES')

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
if n<m:
  print('NO')
  exit()
d.sort()
t.sort()
i=0
j=0
while i<n and j<m:
  if d[i]==t[j]:
    i+=1
    j+=1
  else:
    i+=1
if j==m:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
for i in range(m):
  if t[i] in d:
    d.remove(t[i])
  else:
    print('NO')
    exit()
print('YES')

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
if n<m:
  print('NO')
  exit()
d.sort()
t.sort()
i=0
j=0
while i<n and j<m:
  if d[i]==t[j]:
    i+=1
    j+=1
  else:
    i+=1
if j==m:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
di={}
ti={}
for i in range(m):
  if t[i] not in ti:
    ti[t[i]]=1
  else:
    ti[t[i]]+=1
  if t[i] not in di:
    di[t[i]]=d.count(t[i])
for i in ti:
  if ti[i]>di[i]:
    print('NO')
    exit()
print('YES')

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
if n<m:
  print('NO')
  exit()
d.sort()
t.sort()
i=0
j=0
while i<n and j<m:
  if d[i]==t[j]:
    i+=1
    j+=1
  else:
    i+=1
if j==m:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
s=set(t)
S=set(d)
if len(s)>len(S):
  print('NO')
  exit()
for i in s:
  if d.count(i)<t.count(i):
    print('NO')
    exit()
print('YES')

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
if n<m:
  print('NO')
  exit()
d.sort()
t.sort()
i=0
j=0
while i<n and j<m:
  if d[i]==t[j]:
    i+=1
    j+=1
  else:
    i+=1
if j==m:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
s=set(t)
for i in s:
  if d.count(i)<t.count(i):
    print('NO')
    exit()
print('YES')

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
if n<m:
  print('NO')
  exit()
d.sort()
t.sort()
i=0
j=0
while i<n and j<m:
  if d[i]==t[j]:
    i+=1
    j+=1
  else:
    i+=1
if j==m:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
data=[0]*10**6
ans=0
for i in a:
  data[i-1]+=1
  if data[i-1]%2==0:
    ans-=1
  else:
    ans+=1
print(ans)

Fixed submission:
n=int(input())
a={}
for i in range(n):
  a_=int(input())
  if a_ not in a:
    a[a_]=1
  else:
    a[a_]+=1
ans=0
for i in a:
  if a[i]%2==1:
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
s=set(a)
ans=0
for i in s:
  if a.count(i)%2==1:
    ans+=1
print(ans)

Fixed submission:
n=int(input())
a={}
for i in range(n):
  a_=int(input())
  if a_ not in a:
    a[a_]=1
  else:
    a[a_]+=1
ans=0
for i in a:
  if a[i]%2==1:
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

if n == 1:
  print(1)
else:
  ans = a.count(0) + a.count(1)
  for x in range(1, max(a)):
    res = a.count(x) + a.count(x+1) + a.count(x-1)
    ans = max(ans, res)
    
  print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for x in range(min(a), max(a)+1):
  res = c[x] + c[x+1] + c[x-1]
  ans = max(ans, res)
print(ans)

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

if n == 1:
  print(1)
else:
  ans = 0
  for i in range(1, max(a)):
    res = a.count(i) + a.count(i+1) + a.count(i-1)
    ans = max(ans, res)
    
  print(ans

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for x in range(min(a), max(a)+1):
  res = c[x] + c[x+1] + c[x-1]
  ans = max(ans, res)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
data=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    if b not in data:
      data.append(b)
    else:
      print('POSSIBLE')
      exit()
  elif b==n:
    if a not in data:
      data.append(a)
    else:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')

Fixed submission:
n,m=map(int,input().split())
data=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    data[b-1]+=1
    if data[b-1]==2:
      print('POSSIBLE')
      exit()
  if b==n:
    data[a-1]+=1
    if data[a-1]==2:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
data=[]
res=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    data.append(b)
  elif b==n:
    res.append(a)
for i in data:
  if i in res:
    print('POSSIBLE')
    exit()
print('IMPOSSIBLE')

Fixed submission:
n,m=map(int,input().split())
data=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    data[b-1]+=1
    if data[b-1]==2:
      print('POSSIBLE')
      exit()
  if b==n:
    data[a-1]+=1
    if data[a-1]==2:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[int(input()) for i in range(n)]
ans=0
for i in range(2**n):
  res=0
  for j in range(n):
    if i&(1<<j):
      res+=s[j]
  if res%10==0:
    res=0
  ans=max(res,ans)
print(ans)

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s_ = int(input())
  s.append(s_)

s.sort() 
total = sum(s)
t = [i for i in s if i % 10 != 0]
if total % 10 != 0:
  print(total)
elif len(t) > 0:
  print(total - t[0])
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = []
b = []
for i in range(n):
  a_, b_ = map(int, input().split())
  a.append(a_)
  b.append(b_)

res = []
for i in range(n):
  for _ in range(b[i]):
    res.append(a[i])
#print(res)
res.sort()
#print(res)
print(res[k-1])

Fixed submission:
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
#print(ab)
ab.sort()
#print(ab)
for i in range(n):
  k = k-ab[i][1]
  if k <= 0:
    print(ab[i][0])
    exit()
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
data=[0]*(n-1)
for i in range(n-1):
  data[i]=a[i+1]-a[i]
for i in range(1,n-2):
  if data[i]<0:
    if data[i-1]>0 or data[i+1]>0:
      ans+=1
if data[0]<0:
  if data[1]>0:
    ans+=1
if data[n-2]<0:
  if data[n-3]>0:
    ans+=1
print(ans+1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
i=1
up=0
down=0
while i<n:
  if up==down:
    if a[i]>a[i-1]:
      up+=1
      down=0
    elif a[i]<a[i-1]:
      down+=1
      up=0
    elif a[i]==a[i-1]:
      up+=1
      down+=1
  elif up==0 and down!=0:
    if a[i]<=a[i-1]:
      down+=1
    else:
      ans+=1
      down=0
  elif down==0 and up!=0:
    if a[i]>=a[i-1]:
      up+=1
    else:
      ans+=1
      up=0
  i+=1
print(ans+1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n):
  a.pop(0)
  a.pop(-1)
  ans+=a.pop(-1)
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
lb=0
ub=3*n-1
ans=0
for i in range(n):
  lb+=1
  ub-=1
  ans+=a[ub]
  ub-=1
print(ans)