Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
while '01' in s or '10' in s:
    # print('yes')
    if '01' in s:
        s = s.replace('01', '', 1)
        ans += 2
    if '10' in s:
        s = s.replace('10', '', 1)
        ans += 2
    # print(s, ans)

print(ans)

Fixed submission:
s = input()
# ans = 0
# while '01' in s or '10' in s:
#     # print('yes')
#     if '01' in s:
#         s = s.replace('01', '', 1)
#         ans += 2
#     if '10' in s:
#         s = s.replace('10', '', 1)
#         ans += 2
#     # print(s, ans)

# # print(ans)

ans = min(s.count('0'), s.count('1'))*2
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
# h = list(map(int, input().split()))
h = [0]
for _ in range(N):
    h.append(int(input()))
answer = 0
for i in range(1, N+1):
    answer += max(H[i] - H[i-1], 0)

print(answer)

Fixed submission:
N = int(input())
H = [0] + [int(a) for a in input().split()]
# for _ in range(N):
#     h.append(int(input()))
answer = 0
for i in range(1, N+1):
    answer += max(H[i] - H[i-1], 0)

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, (input().split()))
h = list(map(int, input().split()))
# print(N, h)

# dpの最小値を変更する関数
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# 無限大の値
f_inf = float('inf')

# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10 ** 5 + 10)

# 初期条件
dp[0] = 0

# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, N):
    for j in range(1, K + 1):
        if i - j >= 0:
            dp[i] = chmin(dp[i], dp[i-j] + abs(h[i] - h[i - j]))

print(dp[N - 1])

Fixed submission:
N, K = map(int, (input().split()))
h = list(map(int, input().split()))
# print(N, h)

# dpの最小値を変更する関数
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# 無限大の値
f_inf = float('inf')

# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10 ** 5 + 10)

# 初期条件
dp[0] = 0

# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, N):
    for j in range(1, K + 1):
        if i - j >= 0:
            dp[i] = chmin(dp[i], dp[i-j] + abs(h[i] - h[i - j]))

print(dp[N - 1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える
for i in range(N):
	for j in range(W + 1):
		# 品物(w[i],v[i])を選ぶとき、j-w[i]>=0に限って、価値v[i]が加算される
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
		# 品物(w[i],v[i])を選ばないとき、何も加算しない
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える
for i in range(N):
	for j in range(W + 1):
		# 品物(w[i],v[i])を選ぶとき、j-w[i]>=0に限って、価値v[i]が加算される
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
		# 品物(w[i],v[i])を選ばないとき、何も加算しない
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
x = int(input())
if x == 3 or x == 5 or x == 7:
    print('YES')
else:
    pritn('NO')

Fixed submission:
x = int(input())
if x == 3 or x == 5 or x == 7:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
div = N // K
if K % 2 == 1:
    print(div**3)
else:
    if div * N + K // 2 <= N:
        print(div**3 + (div + 1)**3)
    else:
        print(2 * div**3)

Fixed submission:
N = int(input())
if N % 2 == 0:
    answer = (N // 2)**2
else:
    answer = (N // 2) * (N // 2 + 1) 

print(answer)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
OK = True
for i in range(K):
    if S[i] != '1':
        OK = False
if OK:
    print('1')
    exit()
for i in range(len(S)):
    if S[i] != '1':
        print(S[i])
        exit()

Fixed submission:
S = input()
K = int(input())
OK = True
for i in range(min(K, len(S))):
    if S[i] != '1':
        OK = False
if OK:
    print('1')
    exit()
for i in range(len(S)):
    if S[i] != '1':
        print(S[i])
        exit()
Buggy python submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())
X = [[0 for _ in range(N+1)] for _ in range(N+1)]
for i in range(M):
    L, R = map(int, input().split())
    X[L][R] = 1

# for i in range(N):
#     for j in range(N):
#         X[i+1][j+1] += X[i][j+1] + X[i+1][j]
# print(*X, sep='\n')
# print('')

for i in range(N+1):
    for j in range(N):
        X[i][j+1] += X[i][j]
# print(*X, sep='\n')

for i in range(N+1):
    for j in range(N):
        # print(i, j)
        X[j+1][i] += X[j][i]
ans = []
for _ in range(Q):
    p, q = map(int, input().split())
    ans.appned(X[q][q] - X[q][p-1] - X[p-1][q] + X[p-1][p-1])
    # print(ans)
# print(*X, sep='\n')
print(*ans, sep='\n')

Fixed submission:
N, M, Q = map(int, input().split())
X = [[0 for _ in range(N+1)] for _ in range(N+1)]
for i in range(M):
    L, R = map(int, input().split())
    X[L][R] += 1

# for i in range(N):
#     for j in range(N):
#         X[i+1][j+1] += X[i][j+1] + X[i+1][j]
# print(*X, sep='\n')
# print('')

for i in range(N+1):
    for j in range(N):
        X[i][j+1] += X[i][j]

for i in range(N+1):
    for j in range(N):
        X[j+1][i] += X[j][i]
# print(*X, sep='\n')

ans = []
for _ in range(Q):
    p, q = map(int, input().split())
    ans.append(X[q][q] - X[q][p-1] - X[p-1][q] + X[p-1][p-1])

print(*ans, sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
answer = 0
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

for ai in a:
    # print(prime_decomposition(ai))
    # # if 2 in prime_decomposition:
    # #     print('Yes')
    # print(prime_decomposition(ai).count(2))
    answer += prime_decomposition(ai).count(2)

print(answer)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
answer = 0
# def prime_decomposition(n):
#   i = 2
#   table = []
#   while i * i <= n:
#     while n % i == 0:
#       n /= i
#       table.append(i)
#     i += 1
#   if n > 1:
#     table.append(n)
#   return table
def count2(n):
    count = 0
    while True:
        if n % 2 == 0:
            n //= 2
            count += 1
        else:
            break
    return count  

for ai in a:
    # print(prime_decomposition(ai))
    # print(prime_decomposition(ai).count(2))
    answer += count2(ai)

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
answer = float('inf')
for i in range(N):
    count = 0
    left = list(S[:i])
    right = list(S[i+1:])
    for j in range(len(left)):
        if 'W' in left[j]:
            count += 1
    for j in range(len(right)):
        if 'E' in right[j]:
            count += 1
    if answer >= count:
        answer = count

    # print(left, right)

print(answer)

Fixed submission:
N = int(input())
s = input()
numE = s.count('E')
numW = 0
answer = numE
for i in range(N):
    if s[i] == 'W':
        answer = min(answer, numE + numW)
        numW += 1
    else:
        numE -= 1
        answer= min(answer, numE + numW)
 
print(answer)
Buggy python submission (verdict: Runtime Error):
A, B, C, X, Y = map(int, input().split())
ans = float('inf')
for i in range(10**5 + 1):
    price = 2*C*i + A*max(0, X - i) + B*max(0, Y - i)
    if ans > price:
        ans = price

print(ans)

Fixed submission:
S = input()
price = 700
if S[0] == 'o':
    price += 100
if S[1] == 'o':
    price += 100
if S[2] == 'o':
    price += 100

print(price)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
X = list(map(int, input().split()))
XX = sorted(X)
for i in range(N):
    delX = copy.copy(XX)
    delX.remove(X[i])
    # print(delX)
    print(delX[N // 2 - 1])


Fixed submission:
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
for x in X:
    if x <= Y[N // 2 - 1]:
        print(Y[N // 2])
    else:
        print(Y[N // 2 - 1])

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
X = list(map(int, input().split()))
for i in range(N):
    delX = copy.copy(X)
    delX.remove(X[i])
    delX.sort()
    print(delX[N // 2 - 1])
    # print(delX)
# print(N, X)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
for x in X:
    if x <= Y[N // 2 - 1]:
        print(Y[N // 2])
    else:
        print(Y[N // 2 - 1])
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    answer = 0
    del_A = copy.copy(A)
    del_A.remove(A[i])
    answer += abs(del_A[0])
    for j in range(1, N-1):
        answer += abs(del_A[j] - del_A[j-1])
    answer += abs(del_A[-1])
    print(answer)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
all = abs(A[0]) + abs(A[N-1])
for i in range(1, N):
    all += abs(A[i] - A[i-1])

for i in range(N):
    answer = all
    if i == 0:
        prev = 0
    else:
        prev = A[i-1]
    if i == N-1:
        next = 0
    else:
        next = A[i+1]
    curr = A[i]
    if prev > curr and curr < next:
        if prev >= next:
            answer -= abs(curr - next) * 2
        else:
            answer -= abs(curr - prev) * 2
    elif prev < curr and curr > next:
        if prev >= next:
            answer -= abs(curr - prev) * 2
        else:
            answer -= abs(curr - next) * 2
    print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    answer = 0
    del_A = copy.copy(A)
    del_A.remove(A[i])
    # del_A.sort()
    # print(del_A)
    answer += abs(del_A[0])
    for j in range(1, N-1):
        answer += abs(del_A[j] - del_A[j-1])
    answer += abs(del_A[-1])
    # MIN = min(0, del_A[0])
    # MAX = max(0, del_A[-1])
    # # print(MIN, MAX)
    # answer = abs(MAX - MIN) * 2
    print(answer)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
all = abs(A[0]) + abs(A[N-1])
for i in range(1, N):
    all += abs(A[i] - A[i-1])

for i in range(N):
    answer = all
    if i == 0:
        prev = 0
    else:
        prev = A[i-1]
    if i == N-1:
        next = 0
    else:
        next = A[i+1]
    curr = A[i]
    if prev > curr and curr < next:
        if prev >= next:
            answer -= abs(curr - next) * 2
        else:
            answer -= abs(curr - prev) * 2
    elif prev < curr and curr > next:
        if prev >= next:
            answer -= abs(curr - prev) * 2
        else:
            answer -= abs(curr - next) * 2
    print(answer)
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
name = [0]*n
s = []
for i in range(n):
    st = input()
    if st[0] == 'M':
        name[0] += 1
    elif st[0] == 'A':
        name[1] += 1
    elif st[0] == 'R':
        name[2] += 1
    elif st[0] == 'C':
        name[3] += 1
    elif st[0] == 'H':
        name[4] += 1
    s.append(st)

ans = 0
for v in itertools.combinations(name, 3):
    # print(v)
    ans += v[0]*v[1]*v[2]

print(ans)

Fixed submission:
import itertools
N = int(input())
S_num = [0] * 5
answer = 0
for _ in range(N):
    S = input()
    if S[0] == 'M':
        S_num[0] += 1
    elif S[0] == 'A':
        S_num[1] += 1
    elif S[0] == 'R':
        S_num[2] += 1
    elif S[0] == 'C':
        S_num[3] += 1
    elif S[0] == 'H':
        S_num[4] += 1

for v in itertools.combinations(S_num, 3):
    answer += v[0] * v[1] * v[2]
print(answer)
Buggy python submission (verdict: Runtime Error):
print(-1

Fixed submission:
from collections import deque
h, w = map(int, input().split())
s = [input() for _ in range(h)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
table = [[float('inf') for _ in range(w)] for _ in range(h)]
table[0][0] = 0
def bfs():
    que = deque([[0, 0]])
    # print(que)
    used = [[0 for _ in range(w)] for _ in range(h)]
    used[0][0] = 1
    while que:
        # print(que.popleft())
        y, x = que.popleft()
        for k in range(4):
            if 0 <= y+dy[k] < h and 0 <= x+dx[k] < w:
                if s[y+dy[k]][x+dx[k]] == '#':
                    continue
                if used[y+dy[k]][x+dx[k]] == 0:
                    table[y+dy[k]][x+dx[k]] = min(table[y+dy[k]][x+dx[k]], table[y][x]+1)
                    used[y+dy[k]][x+dx[k]] = 1
                    que.append((y+dy[k], x+dx[k]))
    
    # print(*table, sep='\n')
    return table[h-1][w-1]

c = bfs()
if c == float('inf'):
    print(-1)
else:
    white = 0
    for i in range(h):
        white += s[i].count('.')
    ans = white - (c+1)
    print(ans)
Buggy python submission (verdict: Runtime Error):
n, H = map(int, input().split())
a = []
b = []
for i in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)

ans = 0
amax = max(a)
b.sort(reverse=True)
# print(amax, b)
i = 0
while H > 0:
    if amax < b[i]:
        H -= b[i]
        ans += 1
        i += 1
    else:
        ans += H//amax
        if H%amax != 0:
            ans += 1
        break

print(ans)

Fixed submission:
n, H = map(int, input().split())
a = []
b = []
for i in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)

ans = 0
amax = max(a)
b.sort(reverse=True)
# print(amax, b)
i = 0
while H > 0:
    if i < n:
        if amax < b[i]:
            H -= b[i]
            ans += 1
            i += 1
        else:
            ans += H//amax
            if H%amax != 0:
                ans += 1
            break
    else:
        ans += H//amax
        if H % amax != 0:
            ans += 1
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
Q = int(input())

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(n**0.5)+1):
        if n % k == 0:
            return 0
    return n

prime_numbers = [is_prime(i) for i in range(2, 10**5 + 1) if is_prime(i) != 0]
same = [0]*(10**5 + 1)
for n in prime_numbers:
    if (n+1) // 2 in prime_numbers:
        same[n] += 1

for i in range(10**5):
    same[i+1] += same[i]

ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    N = same[r] - same[l-1]
    ans.append(N)

print(*ans, sep='\n')


Fixed submission:
m=int(input())
print(48-m)
Buggy python submission (verdict: Runtime Error):
import collections
s = input()
cnt = collections.Counter(s)
cnt = cnt.most_common()
# print(cnt)
if len(s) == 1:
    print('YES')
    exit()
if len(cnt) == 2:
    if len(s) == 2:
        print('YES')
    else:
        print('NO')
    exit()

if cnt[1][1] > cnt[-1][1] + 1:
    print('NO')
else:
    print('YES')


Fixed submission:
import collections
s = input()
cnt = collections.Counter(s)
cnt = cnt.most_common()
# print(cnt)
if len(cnt) == 1:
    if len(s) == 1:
        print('YES')
    else:
        print('NO')
    # print('YES')
    exit()
if len(cnt) == 2:
    if len(s) == 2:
        print('YES')
    else:
        print('NO')
    exit()

if cnt[0][1] > cnt[-1][1] + 1:
    print('NO')
else:
    print('YES')
Buggy python submission (verdict: Runtime Error):
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 i in range(N):
    upi = bisect.bisect_left(A, B[i])
    dwi = bisect.bisect_left(C, B[i])
    if C[dwi] == B[i]:
        dwi = bisect.bisect_left(C, B[i] + 1)
    ans += upi*(N - dwi)

print(ans)

Fixed submission:
from bisect import bisect_right
from bisect import bisect_left
 
n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))
cnt = 0
bn = []
for i in range(n):
    x1 = bisect_left(a, b[i])
    x2 = bisect_right(c, b[i])
    cnt += x1*(n-x2)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [] 
numbers = []
for _ in range(N):
    A.append(int(input()))

for i in range(N):
    if A[i] in numbers:
        numbers.remove(A[i])
    else:
        numbers.append(A[i])

print(len(numbers))

Fixed submission:
import collections
N = int(input())
A = [] 
for _ in range(N):
    A.append(int(input()))
answer = 0
numbers = collections.Counter(A)

for i in numbers.values():
    answer += i % 2

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
numbers = []
for _ in range(N):
    A = int(input())
    if A in numbers:
        numbers.remove(A)
    else:
        numbers.append(A)

print(len(numbers))

Fixed submission:
import collections
N = int(input())
A = [] 
for _ in range(N):
    A.append(int(input()))
answer = 0
numbers = collections.Counter(A)

for i in numbers.values():
    answer += i % 2

print(answer)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
answer = [[0] * W] * H
# True_answer = []
input_list = []
for i in range(1, N+1):
    for _ in range(a[i-1]):
        input_list.append(i)

for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            # print('2')
            answer[i][j] = input_list[5 * i + j]
            # print(answer[0], answer[1], answer[2])
        else:
            # print('not2')
            answer[i][W-j-1] = input_list[5 * i + j]
            # print(answer)
        if (j+1) % W == 0:
            # True_answer[i] += answer[i]
            print(*answer[i])



# print(input_list)
# print(answer)
# print(True_answer)


Fixed submission:
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
answer = [[0] * W] * H
# True_answer = []
input_list = []
for i in range(1, N+1):
    for _ in range(a[i-1]):
        input_list.append(i)

for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            # print('2')
            answer[i][j] = input_list[W * i + j]
            # print(answer[0], answer[1], answer[2])
        else:
            # print('not2')
            answer[i][W-j-1] = input_list[W * i + j]
            # print(answer)
        if (j+1) % W == 0:
            # True_answer[i] += answer[i]
            print(*answer[i])



# print(input_list)
# print(answer)
# print(True_answer)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(' '.join(map(str, b)))

Fixed submission:
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque()
for i in range(n):
    if i % 2 == n % 2:
        b.append(a[i])
    else:
        b.appendleft(a[i])

print(*list(b))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))
x = 1
visited = set([1])
answer = 0

while True:
    x = a[x]
    if x in visited:
        answer = -1
        break
    visited.add(x)
    answer += 1
    if x == 2:
        break

print(answer)

Fixed submission:
N = int(input())
a = [0]
for _ in range(N):
    a.append(int(input()))
x = 1
visited = set([1])
answer = 0

while True:
    x = a[x]
    if x in visited:
        answer = -1
        break
    visited.add(x)
    answer += 1
    if x == 2:
        break

print(answer)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = []
count = [1]
answer = 1
for _ in range(N):
    a.append(int(input()))

def search(A):
    answer += 1
    if A in count or answer > N:  # ループ処理
        print(-1)
        exit()
    count.append(A)
    print(count)
    if A == 2:
        print(len(count) - 1)
        exit()

    search(a[A-1])

search(a[0])

Fixed submission:
N = int(input())
a = [0]
for _ in range(N):
    a.append(int(input()))
x = 1
visited = set([1])
answer = 0

while True:
    x = a[x]
    if x in visited:
        answer = -1
        break
    visited.add(x)
    answer += 1
    if x == 2:
        break

print(answer)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = []
count = [1]
answer = 0
for _ in range(N):
    a.append(int(input()))

def search(A):
    if A in count:  # ループ処理
        print(-1)
        exit()
    count.append(A)
    # print(count)
    if A == 2:
        print(len(count) - 1)
        exit()
        
    search(a[A-1])

search(a[0])

Fixed submission:
N = int(input())
a = [0]
for _ in range(N):
    a.append(int(input()))
x = 1
visited = set([1])
answer = 0

while True:
    x = a[x]
    if x in visited:
        answer = -1
        break
    visited.add(x)
    answer += 1
    if x == 2:
        break

print(answer)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
colors = [0] * 9
for i in range(N):
    if 1 <= a[i] and a[i] <= 399:
        colors[0] = 1
    elif 400 <= a[i] and a[i] <= 799:
        colors[1] = 1
    elif 800 <= a[i] and a[i] <= 1199:
        colors[2] = 1
    elif 1200 <= a[i] and a[i] <= 1599:
        colors[3] = 1
    elif 1600 <= a[i] and a[i] <= 1999:
        colors[4] = 1
    elif 2000 <= a[i] and a[i] <= 2399:
        colors[5] = 1
    elif 2400 <= a[i] and a[i] <= 2799:
        colors[6] = 1
    elif 2800 <= a[i] and a[i] <= 3199:
        colors[7] = 1
    else:
        colors[8] += 1
if sum(colors[0:8] == 0) and colors[9] >= 1:
    MIN = 1
else:
    MIN = sum(colors[0:8])
MAX = sum(colors)

print(MIN, MAX)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
colors = [0] * 9
for i in range(N):
    if 1 <= a[i] and a[i] <= 399:
        colors[0] = 1
    elif 400 <= a[i] and a[i] <= 799:
        colors[1] = 1
    elif 800 <= a[i] and a[i] <= 1199:
        colors[2] = 1
    elif 1200 <= a[i] and a[i] <= 1599:
        colors[3] = 1
    elif 1600 <= a[i] and a[i] <= 1999:
        colors[4] = 1
    elif 2000 <= a[i] and a[i] <= 2399:
        colors[5] = 1
    elif 2400 <= a[i] and a[i] <= 2799:
        colors[6] = 1
    elif 2800 <= a[i] and a[i] <= 3199:
        colors[7] = 1
    else:
        colors[8] += 1

if sum(colors[0:8]) == 0 and colors[8] >= 1:
    MIN = 1
else:
    MIN = sum(colors[0:8])
MAX = sum(colors)

print(MIN, MAX)