Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n,m = map(int,input().split())
p = [0] * m
y = [0] * m
for i in range(m):
    p[i],y[i] = map(int,input().split())

certificate = [[] for _ in range(n)]

for i in range(m):
    certificate[p[i]-1].append(y[i])

for i in range(len(certificate)):
    certificate[i].sort()

for i in range(m):
    number = ""
    number += str(p[i]).zfill(6)
    number += str(certificate[p[i]-1].index(y[i])+1).zfill(6)
    print(number)


Fixed submission:
# -*- coding: utf-8 -*-

x,y = map(int,input().split())
print(int(x + y / 2))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n,m = map(int,input().split())
p = [0] * m
y = [0] * m
for i in range(m):
    p[i],y[i] = map(int,input().split())

certificate = [[] for _ in range(n)]

for i in range(m):
    certificate[p[i]-1].append(y[i])

for i in range(len(certificate)):
    certificate[i].sort()

for i in range(m):
    number = ""
    number += str(p[i]).zfill(6)
    number += str(certificate[p[i]-1].index(y[i])+1).zfill(6)
    print(number)


Fixed submission:
# -*- coding: utf-8 -*-

x,y = map(int,input().split())
print(int(x + y / 2))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a = list(map(int,print().split()))

a.list()

print(+a[i+2]- a[i])
# -*- coding: utf-8 -*-

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

a.list()

print(+a[i+2]- a[i])

Fixed submission:
# -*- coding: utf-8 -*-

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

a.sort()

print(a[2]- a[0])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a = list(map(int,print().split()))

a.list()

print(+a[i+2]- a[i])


Fixed submission:
# -*- coding: utf-8 -*-

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

a.sort()

print(a[2]- a[0])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

cnt = 0

for i in range(n):
    while(True):
        if a[i] % 2 != 0:
            break
        else:
            a[i] = int(a[i] / 2)
            cnt += 1

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-

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

if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

if a >= 8 o r b >= 8:
    print(":(")
else:
    print("Yay!")


Fixed submission:
# -*- coding: utf-8 -*-

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

if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))
af = [[]]

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

for i in range(n):
    af.append(factorize(a[i]))
del af[0]

cnt = 0

for i in range(len(af)):
    for j in range(len(af[i])):
        if af[i][j] == 2:
            cnt += 1

print(cnt)

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

cnt = 0

for i in range(n):
    while(True):
        if a[i] % 2 != 0:
            break
        else:
            a[i] = int(a[i] / 2)
            cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

ans = float("inf")
for i in range(n):
    cnt = 0
    for j in range(n):
        if j < i and s[j] == "W":
            cnt += 1
        if i < j and s[j] == "E":
            cnt += 1
    ans = min(ans,cnt)

print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
s = list(input())
w = [0] * n
e = [0] * n

cntw = 0
cnte = 0
for i in range(n):
    if s[i] == "W":
        cntw += 1
        w[i] = cntw
    else:
        w[i] = cntw
    if s[i] == "E":
        cnte += 1
        e[i] = cnte
    else:
        e[i] = cnte

ans = float("inf")

for i in range(n):
    num = 0
    if i-1 >= 0:
        num += w[i-1]
    num += e[-1] - e[i]
    ans = min(num,ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
s = list(input())
k = int(input())

part = [[]]

for i in range(len(s)):
    for j in range(1,len(s)+1):
        if i + j > len(s):
            break
        part.append(s[i:i+j])
del part[0]

part.sort()

delete = []

for i in range(1,len(part)):
    if part[i-1] == part[i]:
        delete.append(i)

diff = 0
for i in range(len(delete)):
    del part[delete[i] - diff]
    diff += 1

print("".join(part[k-1]))


Fixed submission:
# -*- coding: utf-8 -*-
s = list(input())
k = int(input())

part = [[]]

for i in range(len(s)):
    for j in range(1,k+1):
        if i + j > len(s):
            break
        part.append(s[i:i+j])
del part[0]

part.sort()

delete = []

for i in range(1,len(part)):
    if part[i-1] == part[i]:
        delete.append(i)

diff = 0
for i in range(len(delete)):
    del part[delete[i] - diff]
    diff += 1

print("".join(part[k-1]))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n=int(input())
l=list(map(int,input().split()))
sl=l[:]
sl.sort()
a=sl[n//2-1]
b=sl[n//2]
for i in l:
  if i<=a:
    print(b)
  else:
    print(a)


Fixed submission:

# -*- coding: utf-8 -*-

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

if a <= x <= a + b:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import itertools

n = int(input())
s = [[] for _ in range(n)]
for i in range(n):
    s[i] = list(input())

delete = []

for i in range(n):
    if s[i][0] == "M" or s[i][0] == "A" or s[i][0] == "R" or s[i][0] == "C" or s[i][0] == "H":
        pass
    else:
        delete.append(i)

diff = 0
for i in range(len(delete)):
    del s[delete[i] - diff]
    diff += 1

cand = list(itertools.combinations(s,3))

ans = 0
for i in range(len(cand)):
    if cand[i][0][0] != cand[i][1][0] and cand[i][1][0] != cand[i][2][0] and cand[i][2][0] != cand[i][0][0]:
        ans += 1

print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

import itertools

n = int(input())
s = [[] for _ in range(n)]
for i in range(n):
    s[i] = list(input())

delete = []

for i in range(n):
    if s[i][0] == "M" or s[i][0] == "A" or s[i][0] == "R" or s[i][0] == "C" or s[i][0] == "H":
        pass
    else:
        delete.append(i)

diff = 0
for i in range(len(delete)):
    del s[delete[i] - diff]
    diff += 1

cand = [0,0,0,0,0]
for i in range(len(s)):
    if s[i][0] == "M":
        cand[0] += 1
    if s[i][0] == "A":
        cand[1] += 1
    if s[i][0] == "R":
        cand[2] += 1
    if s[i][0] == "C":
        cand[3] += 1
    if s[i][0] == "H":
        cand[4] += 1

ans = 0

for i in range(5):
    for j in range(5):
        if i == j:
            break
        for k in range(5):
            if i == k:
                break
            if j == k:
                break
            ans += int(cand[i] * cand[j] * cand[k])

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = input()
a = input()

if n % 500 <= a:
    print("Yes")
else:
    print("No")


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a = int(input())

if n % 500 <= a:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
t = [0] * n
x = [0] * n
y = [0] * n
for i in range(n):
    t[i],x[i],y[i] = map(int,input().split())

def travel(x,y,t):
    if t == t_st:
        if x == x_st and y == y_st:
            return True
        else:
            return False
    if travel(x-1,y,t-1) or travel(x,y-1,t-1) or travel(x+1,y,t-1) or travel(x,y+1,t-1):
        return True
    else:
        return False

t_st = 0
x_st = 0
y_st = 0

ans = travel(x[0],y[0],t[0])

for i in range(1,n):
    x_st = x[i-1]
    y_st = y[i-1]
    t_st = t[i-1]
    if travel(x[i],y[i],t[i]):
        pass
    else:
        ans = False

if ans:
    print("Yes")
else:
    print("No")


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
t = [0] * n
x = [0] * n
y = [0] * n
for i in range(n):
    t[i],x[i],y[i] = map(int,input().split())

def travel(x,y,t):
    if abs(t-t_st) >= abs(x-x_st) + abs(y-y_st) and abs(t-t_st) % 2 == (abs(x-x_st) + abs(y-y_st)) % 2:
        return True
    else:
        return False

t_st = 0
x_st = 0
y_st = 0

ans = travel(x[0],y[0],t[0])

for i in range(1,n):
    x_st = x[i-1]
    y_st = y[i-1]
    t_st = t[i-1]
    if travel(x[i],y[i],t[i]):
        pass
    else:
        ans = False

if ans:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
t = [0] * n
x = [0] * n
y = [0] * n
for i in range(n):
    t[i],x[i],y[i] = map(int,input().split())

def travel(x,y,t):
    if t == t_st:
        if x == x_st and y == y_st:
            return True
        else:
            return False
    if travel(x-1,y,t-1) or travel(x,y-1,t-1) or travel(x+1,y,t-1) or travel(x,y+1,t-1):
        return True
    else:
        return False

t_st = 0
x_st = 0
y_st = 0

ans = travel(x[0],y[0],t[0])

for i in range(1,n):
    x_st = x[i-1]
    y_st = y[i-1]
    t_st = t[i-1]
    if travel(x[i],y[i],t[i]):
        pass
    else:
        ans = False

if ans:
    print("Yes")
else:
    print("No")


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
t = [0] * n
x = [0] * n
y = [0] * n
for i in range(n):
    t[i],x[i],y[i] = map(int,input().split())

def travel(x,y,t):
    if abs(t-t_st) >= abs(x-x_st) + abs(y-y_st) and abs(t-t_st) % 2 == (abs(x-x_st) + abs(y-y_st)) % 2:
        return True
    else:
        return False

t_st = 0
x_st = 0
y_st = 0

ans = travel(x[0],y[0],t[0])

for i in range(1,n):
    x_st = x[i-1]
    y_st = y[i-1]
    t_st = t[i-1]
    if travel(x[i],y[i],t[i]):
        pass
    else:
        ans = False

if ans:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

set_a = set(a)
a.sort()
k = 0
p = 0
ans = 0
for a_ in set_a:
    s = a[k]
    while True:
        if k<len(a) and a[k]==s:
            k+=1
            p+=1
        else:
            if p>=s:
                ans+=p-s
            else:
                ans+=p
            p=0
            break
print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

import math

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

print(math.ceil((a+b)/2))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

def check(ar):
    b = True
    for i in range(len(ar)):
        if ar[i] % 2 != 0:
            b = False
            break
    return b

answer = 0

for i in range(1000000000):
    if check(a) == True:
        for j in range(len(a)):
            a[j] = int(a[j]/2)
        answer += 1

print(answer)


Fixed submission:
# -*- coding: utf-8 -*-

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

def check(ar):
    b = True
    for i in range(len(ar)):
        if ar[i] % 2 != 0:
            b = False
            break
    return b

answer = 0

for i in range(1000000000):
    if check(a) == True:
        for j in range(len(a)):
            a[j] = int(a[j]/2)
        answer += 1
    else:
        break;

print(answer)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

s = list(input())
t = list(input())

slen = len(s)
tlen = len(t)

cand = []
for i in range(slen - tlen + 1):
    match = True
    for j in range(tlen):
        if s[i + j] == "?" or s[i + j] == t[j]:
            pass
        else:
            match = False
    if match:
        cand.append(i)

if len(cand) != 0:
    cand.reverse()
    ans = ""
    for i in range(slen):
        if not (cand[0] <= i <= cand[0] + tlen):
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
        else:
            ans += t[i - cand[0]]        
    print(ans)
else:
    print("UNRESTORABLE")

Fixed submission:
S = list(input())
T = list(input())
LS = len(S)
LT = len(T)
a = ""
for i in reversed(range(LS - LT + 1)):
    for j in range(LT):
        if S[i + j] != T[j] and S[i + j] != "?":
            break
        if j == LT - 1:
            for k in range(LT):
                S[i + k] = T[k]
            #print("".join(S))
            s = str("".join(S)).replace("?", "a")
            print(s)
            exit()
# S = S.replace("?", "a")
print("UNRESTORABLE")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

s = list(input())
t = list(input())
a = []

for i in range(len(t)-1,len(s)):
    lock = True
    for j in range(len(t)):
        if s[i-len(t)+j+1] == "?":
            pass
        elif s[i-len(t)+j+1] != t[j]:
            lock = False
    if lock:
        a.append(s[:i-len(t)+1] + t[:])

if len(a) == 0:
    print("UNRESTORABLE")
else:
    a.sort()
    for i in range(len(a[0])):
        if a[0][i] == "?":
            a[0][i] = "a"

answer = "".join(a[0])

print(answer)


Fixed submission:
S = list(input())
T = list(input())
LS = len(S)
LT = len(T)
a = ""
for i in reversed(range(LS - LT + 1)):
    for j in range(LT):
        if S[i + j] != T[j] and S[i + j] != "?":
            break
        if j == LT - 1:
            for k in range(LT):
                S[i + k] = T[k]
            #print("".join(S))
            s = str("".join(S)).replace("?", "a")
            print(s)
            exit()
# S = S.replace("?", "a")
print("UNRESTORABLE")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a,b,c,d,e,f = map(int,input().split())

max_water = f // 100 * a
max_sugar = f // c

water = []
for i in range(max_water):
    for j in range(max_water):
        water.append(100*a*i+100*b*j)

sugar = []
for i in range(max_sugar):
    for j in range(max_sugar):
        sugar.append(c*i+d*j)

answer = 0
anssugar = 0
answater = 0

for i in range(len(water)):
    for j in range(len(sugar)):
        if water[i] == 0 and sugar[j] == 0:
            continue
        con = 100 * sugar[j] / (water[i] + sugar[j])
        if answer < con and con <= e and sugar[j] + water[i] <= f :
            answer = con
            anssugar = sugar[j]
            answater = water[i]

print(answater+anssugar,anssugar)


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a = int(input())

print(n*n-a)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input(n))
a = int(input(a))

print(n*n-a)


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a = int(input())

print(n*n-a)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = input(n)
a = input(a)

print(n*n-a)


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a = int(input())

print(n*n-a)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target


a.sort()
a = array_count(a)

b= []

for i in range(len(a)):
    if a[i][1] >= 2:
        b.append(a[i][0])
    if a[i][1] >= 4:
        b.append(a[i][0])

b.sort()
b.reverse()

if len(b) <= 1:
    print(0)
else:
    print(b[0]*b[1])


Fixed submission:
# -*- coding: utf-8 -*-

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

if abs(x-a) < abs(x-b):
    print("A")
else:
    print("B")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = list(int(input()))

def digit_list(num):
    num = str(num)
    num = list(num)
    num = list(map(int,num))
    return num

n = digit_list(n)

if n[0] == n[-1]:
    print("Yes")
else:
    print("No")


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())

def digit_list(num):
    num = str(num)
    num = list(num)
    num = list(map(int,num))
    return num

n = digit_list(n)

if n[0] == n[-1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
a = [int(i) for i in input().split()]
b = []
for x in a:
    num = 0
    if x%2 == 0:
        x = x//2
        num += 1
        if x%2 == 0:
            num += 1
    b.append(num)
if b.count(0) <= b.count(2):
    print('Yes')
else:
    if b.count(0) == b.count(2)+1 and len(b) == b.count(0)+b.count(2):
        print('Yes')
    else:
        print('No')

Fixed submission:
# -*- coding: utf-8 -*-

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

print(max(0,(n-1)*(m-1)))
Buggy python submission (verdict: Runtime Error):
import sys
import os

f = open("C:/Users/user/Documents/atCoderProblem/import.txt","r")
sys.stdin = f

# -*- coding: utf-8 -*-

n = input()

print("ABC" + n)


Fixed submission:
# -*- coding: utf-8 -*-

n = input()

print("ABC" + n)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

X = sum(a)
x = sum(a[:1])

minsum = 10000000000

for i in range(1,n):
    x = sum(a[:i])
    minsum = min(minsum,abs(X-2*x))

print(minsum)


Fixed submission:
# -*- coding: utf-8 -*-

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

X = sum(a)

minsum = 10000000000

cnt = 0

for i in range(1,n):
    cnt += a[i-1]
    minsum = min(minsum,abs(X-2*cnt))

print(minsum)

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

X = sum(a)
x = sum(a[:1])

minsum = 10000000000

for i in range(1,n):
    x = sum(a[:i])
    minsum = min(minsum,abs(X-2*x))

print(minsum)


Fixed submission:
# -*- coding: utf-8 -*-

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

X = sum(a)

minsum = 10000000000

cnt = 0

for i in range(1,n):
    cnt += a[i-1]
    minsum = min(minsum,abs(X-2*cnt))

print(minsum)
Buggy python submission (verdict: Runtime Error):

n = int(input())
a = list(map(int,input().split()))
b = ["A" for i in range(1000001)]

for i in range(n):
    if i % 2 != 0:
        b.append(a[i])
    else:
        b[1000000-i] = a[i]

while b[0] == "A" :
    del b[0]

while "A" in b:
    b.remove("A")

if n % 2 != 0:
    pass
else:
    b.reverse()

for i in range(len(b)):
    if i == len(b) - 1:
        print(b[i])
        break
    print(b[i],end = " ")

Fixed submission:
# -*- coding: utf-8 -*-

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

print(min(a+b,b+c,c+a))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))
b = ["A" for i in range(1000001)]

for i in range(n):
    if i % 2 != 0:
        b.append(a[i])
    else:
        b[1000000-i] = a[i]

while "A" in b:
    b.remove("A")

if n % 2 != 0:
    pass
else:
    b.reverse()

for i in range(len(b)):
    if i == len(b) - 1:
        print(b[i])
        break
    print(b[i],end = " ")


Fixed submission:
# -*- coding: utf-8 -*-

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

print(min(a+b,b+c,c+a))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))
b = []

for i in range(n):
    if i % 2 != 0:
        b.append(a[i])
    else:
        c = [0] + b[:]
        c[0] = a[i]
        b = c

if n % 2 != 0:
    pass
else:
    b.reverse()

for i in range(len(b)):
    if i == len(b) - 1:
        print(b[i])
        break
    print(b[i],end = " ")


Fixed submission:
# -*- coding: utf-8 -*-

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

print(min(a+b,b+c,c+a))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))
b = []

for i in range(n):
    if i % 2 != 0:
        b.append(a[i])
    else:
        c = [0] + b[:]
        c[0] = a[i]
        b = c

if n % 2 != 0:
    pass
else:
    b.reverse()

for i in range(len(b)):
    if i == len(b) - 1:
        print(b[i])
        break
    print(b[i],end = " ")


Fixed submission:
# -*- coding: utf-8 -*-

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

print(min(a+b,b+c,c+a))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())

cnt = 0
lit = 0

while lit != 1 and (lit != 0 or cnt == 0):
    lit = a[lit] - 1
    cnt += 1

if lit == 1:
    print(cnt)
else:
    print(-1)


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
i = 0
done = {a - 1: False for a in A}
num = 0
while True:
    i = A[i] - 1
    num += 1
    if i == 1:
        print(num)
        exit()
    if done[i]:
        print(-1)
        exit()
    done[i] = True
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

color = [0,0,0,0,0,0,0,0,0]

for i in range(n):
    if 1 <= a[i] <= 399:
        color[0] += 1
    elif 400 <= a[i] <= 799:
        color[1] += 1
    elif 800 <= a[i] <= 1199:
        color[2] += 1
    elif 1200 <= a[i] <= 1599:
        color[3] += 1
    elif 1600 <= a[i] <= 1999:
        color[4] += 1
    elif 2000 <= a[i] <= 2399:
        color[5] += 1
    elif 2400 <= a[i] <= 2799:
        color[6] += 1
    elif 2800 <= a[i] <= 3199:
        color[7] += 1
    elif 3200 <= a[i]:
        color[8] += 1


min_col = color[:]
min_cnt = 0
del min_col[-1]
for i in range(len(min_col)):
    if min_col[i] != 0:
        min_cnt += 1

max_cnt = min(min_cnt + color[8])
min_cnt = max(1,min_cnt)

print(min_cnt, max_cnt)

Fixed submission:
# -*- coding: utf-8 -*-

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

color = [0,0,0,0,0,0,0,0,0]

for i in range(n):
    if 1 <= a[i] <= 399:
        color[0] += 1
    elif 400 <= a[i] <= 799:
        color[1] += 1
    elif 800 <= a[i] <= 1199:
        color[2] += 1
    elif 1200 <= a[i] <= 1599:
        color[3] += 1
    elif 1600 <= a[i] <= 1999:
        color[4] += 1
    elif 2000 <= a[i] <= 2399:
        color[5] += 1
    elif 2400 <= a[i] <= 2799:
        color[6] += 1
    elif 2800 <= a[i] <= 3199:
        color[7] += 1
    elif 3200 <= a[i]:
        color[8] += 1


min_col = color[:]
min_cnt = 0
del min_col[-1]
for i in range(len(min_col)):
    if min_col[i] != 0:
        min_cnt += 1

max_cnt = min_cnt + color[8]
min_cnt = max(1,min_cnt)

print(min_cnt, max_cnt)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
s = [0]*n
for i in range(n):
    s[i] = list(input())

def list_intersection(a,b):
    c = []
    for i in range(len(a)):
        for j in range(len(b)):
            if a[i] == b[j]:
                c.append(a[i])
                a[i] = "_"
                b[j] = "&"
    return c

if n == 1:
    ans = s[0].sort()
elif n == 2:
    ans = list_intersection(s[0],s[1])
    ans.sort()
else:
    ans = list_intersection(s[0],s[1])
    for i in range(2,n):
        ans = list_intersection(ans,s[2])
    ans.sort()

print("".join(ans))


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
s = [0]*n
for i in range(n):
    s[i] = list(input())

def list_intersection(a,b):
    c = []
    for i in range(len(a)):
        for j in range(len(b)):
            if a[i] == b[j]:
                c.append(a[i])
                a[i] = "_"
                b[j] = "&"
    return c

if n == 1:
    ans = s[0]
    ans.sort()
elif n == 2:
    ans = list_intersection(s[0],s[1])
    ans.sort()
else:
    ans = list_intersection(s[0],s[1])
    for i in range(2,n):
        ans = list_intersection(ans,s[i])
    ans.sort()

print("".join(ans))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

x = input()

a = 0
z = 0

for i in range(len(x)):
    if x[i] == "A":
        a = i
        break

for i in range(len(x)):
    if x[-(i+1)] == "Z":
        z = len(x) - i
        break

print(len(x[a:z])


Fixed submission:
# -*- coding: utf-8 -*-

x = input()

a = 0
z = 0

for i in range(len(x)):
    if x[i] == "A":
        a = i
        break

for i in range(len(x)):
    if x[-(i+1)] == "Z":
        z = len(x) - i
        break

print(len(x[a:z]))