Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02623 (python)

Fixed submission:
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cumsumA = [0] + list(accumulate(A))
    cumsumB = [0] + list(accumulate(B))

    res = 0

    for i in range(N+1):
        if i == 0:
            for j in range(M, -1, -1):
                if cumsumB[j] <= K:
                    max_j = j
                    res = max(res, i + j)
                    break
        else:
            for j in range(max_j, -1, -1):
                time = cumsumA[i] + cumsumB[j]
                if  time <= K:
                    max_j = j
                    res = max(res, i + j)
                    break
    
    print(res)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N, M, K = map(int, input().split())
    A = deque(list(map(int, input().split())))
    B = deque(list(map(int, input().split())))

    time = 0
    res = 0
    same_flag = False

    while True:
        if len(A) != 0:
            tmp1 = A[0]
        else:
            tmp1 = 10 ** 10
        
        if len(B) != 0:
            tmp2 = B[0]
        else:
            tmp2 = 10 ** 10
        
        if time + tmp1 > K and time + tmp2 > K:
            break

        if tmp1 == 10 ** 10 and tmp2 == 10 ** 10:
            break
        elif tmp1 < tmp2:
            tmp_time = A.popleft()
            time += tmp_time
            res += 1
        elif tmp1 == tmp2:
            sumA = sum(A[1:])
            sumB = sum(B[1:])

            if same_flag:
                tmp_time = A.popleft()
                time += tmp_time
                res += 1
            elif sumA < sumB:
                tmp_time = A.popleft()
                time += tmp_time
                res += 1
            elif sumA > sumB:
                tmp_time = B.popleft()
                time += tmp_time
                res += 1
            else:
                tmp_time = A.popleft()
                time += tmp_time
                res += 1
                same_flag = True
        else:
            tmp_time = B.popleft()
            time += tmp_time
            res += 1
        
        if time > K:
            time -= tmp_time
            res -= 1
            break
    
    print(res)

if __name__ == '__main__':
    main()
Problem p02754 (python)

Fixed submission:
# ABC158 B

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

res1 = a * (n // (a+b))

if a > n % (a+b):
    res2 = n % (a+b)
else:
    res2 = a

print(res1 + res2)

Buggy submission (verdict: Runtime Error):
# ABC158 B

N, A, B = map(int, input().split())

column = ""

for i in range(10**100):
    if len(column) >= N:
        break
    column = column + ("b" * A) + ("r" * B)

print(column[:N].count("b"))
Problem p02831 (python)

Fixed submission:
# ABC148 C

import fractions

A, B = map(int, input().split())

print(A * B // fractions.gcd (A, B))

Buggy submission (verdict: Runtime Error):
# ABC148 C

import math

A, B = map(int, input().split())

print(A * B // math.gcd (A, B))
Problem p03038 (python)

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

lis = sorted(list(map(int, input().split())))

query = []
for i in range(m):
    b, c = map(int, input().split())
    query.append([c, b])

query.sort(reverse = 1)

i = 0
for j in query:
    for k in range(j[-1]):
        if i < n:
            if lis[i] < j[0]:
                lis[i] = j[0]
                i += 1 
            else:
                break
        else:
            break
        
print(sum(lis))

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

lis = sorted(list(map(int, input().split())))

query = []
for i in range(m):
    b, c = map(int, input().split())
    query.append([c, b])

query.sort(reverse = 1)

i = 0
for j in query:
    for k in range(j[-1]):
        if lis[i] < j[0]:
            lis[i] = j[0]
            i += 1 
        else:
            break

print(sum(lis))
Problem p02577 (python)

Fixed submission:
N = list(input())

n = [int(s) for s in N]
if sum(n) % 9 == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

ans = 0
a = A.index(max(A))
l = A[a+1:]
for i in range(1,N):
    bf = A[i-1]
    af = A[i]
    if a <= i:
        ans += max(A)*len(l)-sum(l)
        break
    elif bf > af:
        ans += bf-af

print(ans)
Problem p02729 (python)

Fixed submission:
from math import factorial

n, m = map(int, input().split())
if n in [0, 1] and m in [0, 1]:
    ans = 0
elif n in [0, 1]:
    ans = factorial(m) // (factorial(m - 2) * factorial(2))
elif m in [0, 1]:
    ans = factorial(n) // (factorial(n - 2) * factorial(2))
else:
    ans = factorial(n) // (factorial(n - 2) * factorial(2))
    ans += factorial(m) // (factorial(m - 2) * factorial(2))
print(ans)

Buggy submission (verdict: Runtime Error):
from math import factorial

n, m = map(int, input().split())
if n == 1 and m == 1:
    ans = 0
elif n == 1:
    ans = factorial(m) // (factorial(m - 2) * factorial(2))
elif m == 1:
    ans = factorial(n) // (factorial(n - 2) * factorial(2))
else:
    ans = factorial(n) // (factorial(n - 2) * factorial(2))
    ans += factorial(m) // (factorial(m - 2) * factorial(2))
print(ans)
Problem p02790 (python)

Fixed submission:
a, b = input().split()
a_w = a * int(b)
b_w = b * int(a)

if a > b:
  print(b_w)
else:
  print(a_w)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a_w = a * int(b)
b_w = b * int(a)

if a => b:
  print(b_w)
else:
  print(a_w)
Problem p02933 (python)

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

if(a >= 3200):
    print(s)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()

if(a => 3200):
    print(s)
else:
    print('red')
Problem p02623 (python)

Fixed submission:
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
i=0
mx=0
lol=0
while i<n and a[i]<=k:
    k-=a[i]
    i+=1
    mx+=1
    lol=1
j=0
while j<m and b[j]<=k:
    k-=b[j]
    j+=1
    mx+=1
cou=mx

i-=1
while i>=0 and j<m:
    k+=a[i]
    i-=1
    cou-=1
    while j<m and b[j]<=k:
        k-=b[j]
        cou+=1
        j+=1
    mx=max(cou,mx)
print(mx)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
i=0
kk=k
mx=0
while i<n and a[i]<=k:
    k-=a[i]
    i+=1
    mx+=1
j=0
while j<m and b[j]<=k:
    k-=b[j]
    j+=1
    mx+=1
cou=mx
while i>=0 and j<m:
    k+=a[i]
    i-=1
    cou-=1
    while j<m and b[j]<=k:
        j+=1
        k-=b[j]
        cou+=1
    mx=max(cou,mx)
print(mx)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
i=0
kk=k
mx=0
while a[i]<=k:
    k-=a[i]
    i+=1
    mx+=1
j=0
while b[j]<=k:
    k-=b[j]
    j+=1
    mx+=1
cou=mx
while i>=0 and j<m:
    k+=a[i]
    i-=1
    cou-=1
    while j<m and b[j]<=k:
        j+=1
        k-=b[j]
        cou+=1
    mx=max(cou,mx)
print(mx)
Problem p02627 (python)

Fixed submission:
S=input()
if S.isupper()==True:
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans=sum(A)
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  #Bの数だけ（C-B)足す、BはCに置き換わるのでLB＝０になおす。
  key=L[B]
  L[C]+=key
  ans+=key*(C-B)
  L[B]=0
  print(ans)
Problem p02819 (python)

Fixed submission:
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.floor(x)
  for i in range(X,(key+1)**2):
    l.append(i)
    
for n in range(2,key+1):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Buggy submission (verdict: Runtime Error):
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.ceil(x)
  if X<=50000:
    for i in range(X,2*X):
      l.append(i)
  else:
    for i in range(X,100000):
      l.append(i)
    
for n in range(2,key+1):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Buggy submission (verdict: Runtime Error):
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.ceil(x)
  if X<=50000:
    for i in range(X,key**2):
      l.append(i)
  else:
    for i in range(X,key**2):
      l.append(i)
    
for n in range(2,key):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Buggy submission (verdict: Runtime Error):
X=int(input())
l=list()
if X<=50000:
  for i in range(X,2*X):
    l.append(i)
else:
  for i in range(X,100000):
    l.append(i)
    
for n in range(2,317):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])
Problem p02989 (python)

Fixed submission:
N=int(input())
L=list(map(int,input().split()))
l=sorted(L)
if N%2==0:
  n=int(N/2)
  a=l[n-1]
  b=l[n]
  if a==b:
    print('0')
  else:
    print(b-a)
    
else:
  print('0')

Buggy submission (verdict: Runtime Error):
N=int(input())
L=list(map(int,input().split())
M=list[]
m=list[]
for i in range(N):
  for x in range(N):
    if L[x]<i:
      L[x].append(M)
    else:
      L[x].append(m)
  if len(M)=len(m):
    ans+=1

print(ans)
Problem p02682 (python)

Fixed submission:
A, B, C, K = map(int, input().split())

if K<=A:
    print(K)
elif (A<=K)&(K<=A+B):
    print(A)
else:
    print(A-(K-B-A))

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())

l = [1]*A + [0]*B + [-1]*C
print(sum(l[:K]))
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()

if len(S) > K:
  print(S[:K] + "...")
else:
  print(S)

Buggy submission (verdict: Runtime Error):
40
ferelibenterhominesidquodvoluntcredunt
Problem p03013 (python)

Fixed submission:
import bisect
M = 1000000007

# def dfs(i):
#     if i >= n - 1:
#         return 1
#     if dp[i] is not None:
#         return dp[i]
#     if i <= maxv and a[bisect.bisect_left(a, i)] == i:
#         dp[i] = 0
#         return 0
#     r = (dfs(i + 1) + dfs(i + 2)) % M
#     dp[i] = r
#     return r

n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
a.sort()
maxv = m and max(a) or -1
# dp = [None] * n
# print(dfs(0) % M)

dp = [1] * (n + 2)
dp[-1] = 0
for i in range(n - 1, -1, -1):
    if i <= maxv and a[bisect.bisect_left(a, i)] == i:
        dp[i] = 0
    else:
        dp[i] = (dp[i + 1] + dp[i + 2]) % M

print(dp[0] % M)

Buggy submission (verdict: Runtime Error):
import bisect
M = 1000000007

# def dfs(i):
#     if i >= n - 1:
#         return 1
#     if dp[i] is not None:
#         return dp[i]
#     if i <= maxv and a[bisect.bisect_left(a, i)] == i:
#         dp[i] = 0
#         return 0
#     r = (dfs(i + 1) + dfs(i + 2)) % M
#     dp[i] = r
#     return r

n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
a.sort()
maxv = max(a)
# dp = [None] * n
# print(dfs(0) % M)

dp = [1] * (n + 2)
for i in range(n - 2, -1, -1):
    if i <= maxv and a[bisect.bisect_left(a, i)] == i:
        dp[i] = 0
    else:
        dp[i] = (dp[i + 1] + dp[i + 2]) % M

print(dp[0] % M)
Problem p03208 (python)

Fixed submission:
import numpy as np
n, k = map(int, input().split())
a = [int(input()) for x in range(n)]
a.sort()
a = np.array(a)
print(np.min(a[k - 1:] - a[:n - k + 1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n, k = map(int, input().split())
a = [int(input()) for x in range(n)]
a.sort()
a = np.array(a)
print(np.min(a[k - 1:] - a[:k]))
Problem p03242 (python)

Fixed submission:
print(1110 - int(input()))

Buggy submission (verdict: Runtime Error):
a = input()
for i in a:
    print(i == "1" and "9" or "1" end="")
Problem p03250 (python)

Fixed submission:
a = list(map(int, input().split()))
print(max(a) * 9 + sum(a))

Buggy submission (verdict: Runtime Error):
prin
Problem p03265 (python)

Fixed submission:
import numpy as np
a = list(map(int, input().split()))
p1, p2 = a[:2], a[2:]

h1, h2 = p2[0] - p1[0], p2[1] - p1[1]
print(p2[0] - h2, p2[1] + h1, p1[0] - h2, p1[1] + h1)

Buggy submission (verdict: Runtime Error):
import numpy as np
a = np.array(list(map(int, input().split())))
p1, p2 = a[:2], a[2:]

h1, h2 = p2 - p1
print(*(p2 + [-h2, h1]), *(p1 + [-h2, h1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
a = np.array(list(map(int, input().split())))
p1, p2 = a[:2], a[2:]

h1, h2 = p2 - p1
print(*p2 + [-h2, h1], *p1 + [-h2, h1])

Buggy submission (verdict: Runtime Error):
import numpy as np
a = np.array(list(map(int, input().split())))
p1, p2 = np.split(a, 2)

h1, h2 = p2 - p1
print(*p2 + [-h2, h1], *p1 + [-h2, h1])
Problem p03804 (python)

Fixed submission:
import numpy as np
n, m = map(int, input().split())

img = np.array([list(input()) for i in range(n)])
w = img.shape[-1]
template = np.array([list(input()) for i in range(m)])
tw = template.shape[-1]

for y in range(n - m + 1):
    for x in range(w - tw + 1):
        if np.all(img[y:y + m, x:x + tw] == template):
            print("Yes")
            exit()
print("No")

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

img = [input() for i in range(n)]
template = [input() for i in range(m)]

for i in range(n - m + 1):
    if len({v.index(t) for v, t in zip(img[i:i + m], template)}) == 1:
        print("Yes")
        break
else:
    print("No")
Problem p03805 (python)

Fixed submission:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for x in range(m)]

abmap = {}
for a, b in ab:
    atarget = abmap.get(a)
    if atarget == None:
        abmap[a] = []
    abmap[a].append(b)

    btarget = abmap.get(b)
    if btarget == None:
        abmap[b] = []
    abmap[b].append(a)

que = [[1, abmap[1], []]]
ends = []
while que:
    now, nextnodes, visited = que.pop()
    ends.append(visited)
    visited.append(now)
    for node in nextnodes:
        if node in visited:
            continue
        mvisited = visited[:]
        que.append([node, abmap[node], mvisited])

print(len(list(filter(lambda x: len(x) == n, ends))))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for x in range(m)]

abmap = {}
for a, b in ab:
    atarget = abmap.get(a)
    if atarget == None:
        abmap[a] = []
    abmap[a].append(b)

    btarget = abmap.get(b)
    if btarget == None:
        abmap[b] = []
    abmap[b].append(a)

que = [[1, abmap[1], []]]
ends = []
while que:
    now, nextnodes, visited = que.pop()
    ends.append(visited)
    visited.append(now)
    for node in nextnodes:
        if node in visited:
            continue
        mvisited = visited[:]
        que.append([node, abmap[node], mvisited])

print(len(filter(lambda x: len(x) == n, ends)))
Problem p03986 (python)

Fixed submission:
s = raw_input()
T = S = 0
for i in s:
    if i == "T":
        if S: S -= 1
        else: T += 1
    elif i == "S":
        S += 1
print T + S

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

def resolve(a):
    target = N
    result = 0
    for i in a:
        if target > i: target = i
        result += target
    return result

print(sum([resolve(a[x:]) for x in range(N)]))

Buggy submission (verdict: Runtime Error):
s = input()
while 1:
    result = s.replace("ST", "")
    if result != s:
        s = result
        break
    else: s = result
print len(s)
Problem p02831 (python)

Fixed submission:
import fractions

a, b = map(int, input().split())
c = fractions.gcd(a, b)
print(a * b // c)

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
c = math.gcd(a, b)
print(a * b // c)
Problem p02832 (python)

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

if not 1 in a:
    print(-1)
else:
    cnt = 1
    for i in range(n):
        if a[i] == cnt:
            cnt += 1

    print(n - cnt + 1)

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

if not 1 in a:
    print(-1)
else:
    cnt = 1
    for i in range(n):
        if a[i] == cnt:
            cnt += 1

	print(n - cnt + 1)

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

if not 1 in a:
    print(-1)
else:
    cnt = 1
    for i in range(n):
        if a[i] == cnt:
            cnt += 1

	print(n - cnt + 1)

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

if not 1 in a:
    print(-1)
else:
    cnt = 1
    for i in range(n):
        if a[i] == cnt:
            cnt += 1

print(n - cnt + 1)
Problem p02862 (python)

Fixed submission:
x, y = map(int, input().split())
mod = 10 ** 9 + 7

if (x + y) % 3 != 0:
    print(0)
else:
    time = (x + y) // 3
    if time > x or time > y:
        print(0)
    else:
        move_time = sorted([x - time, y - time])
        
        if move_time[0] == 0:
            print(1)
        else:
            ans = 1
            for i in range(2, time+1):
                ans *= i
                ans %= mod
            
            const = 1
            for i in range(1, move_time[1]+1):
                const *= i
                const %= mod
                
                if i == move_time[0]:
                    inv0 = pow(const, mod-2, mod)
                
            inv1 = pow(const, mod-2, mod)
        
            print((ans * inv0 * inv1) % mod)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
mod = 10 ** 9 + 7

if (x + y) % 3 != 0:
    print(0)
else:
    time = (x + y) // 3
    if time > x or time > y:
        print(0)
    else:
        move_time = sorted([x - time, y - time])
        
        ans = 1
        for i in range(2, time+1):
            ans *= i
            ans %= mod
        
        const = 1
        for i in range(1, move_time[1]+1):
            const *= i
            const %= mod
            
            if i == move_time[0]:
                inv0 = pow(const, mod-2, mod)
            
        inv1 = pow(const, mod-2, mod)
    
        print((ans * inv0 * inv1) % mod)
Problem p02597 (python)

Fixed submission:
n = int(input())
s = input()
l = list(s)
#n = len(l)
i = 0
j = n-1
cnt = 0
while(i < j):
    if l[i] == "W" and l[j] == "R":
        l[j] = 'W'
        l[i] = 'R'
        i = i+1
        j = j-1
        cnt = cnt+1
        continue

    if l[i] == "R":
        i = i+1

    if l[j] == "W":
        j = j-1


while(len(l) > 0):
    if l[-1] == "W":
        l.pop()
        continue

    if l[-1] == "R":
        break

k = "".join(l)
print(k.count("W")+cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
l = list(s)
#n = len(l)
i = 0
j = n-1
cnt = 0
while(i < j):
    if l[i] == "W" and l[j] == "R":
        l[j] = 'W'
        l[i] = 'R'
        i = i+1
        j = j-1
        cnt = cnt+1
        continue

    if l[i] == "R":
        i = i+1

    if l[j] == "W":
        j = j-1

f = 0
while(len(l) > 0):
    if l[-1] == "W":
        l.pop()

    if l[-1] == "R":
        break

k = "".join(l)
print(k.count("W")+cnt)
Problem p02623 (python)

Fixed submission:
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i]+A[i])

for i in range(m):
    b.append(b[i]+B[i])

i = 0
ans = 0
j = m
while(i < len(a)):
    if a[i] > k:
        break

    else:
        while(b[j] > k-a[i]):
            j = j-1

        ans = max(ans,i+j)

    i = i+1

print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
cnt = 0
while(min(a[-1],b[-1]) <= k):
    if a[-1] == min(a[-1],b[-1]):
        k = k-min(a[-1],b[-1])
        a.pop()

    else:
        k = k-min(a[-1],b[-1])
        b.pop()

    cnt = cnt+1

print(cnt)
Problem p02659 (python)

Fixed submission:
a,b = map(float,input().split())
a = int(a)
b = round(float(b)*100)
print((a*b)//100)

Buggy submission (verdict: Runtime Error):
a,b = map(input().split())
a = int(a)
b = int(b*100)
print((a*b)//100)

Buggy submission (verdict: Runtime Error):
a,b = map(input().split())
a = int(a)
b = float(b)
b = b*100
s = (a*b)//100
print(int(s))
Problem p02725 (python)

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

A.append(A[0]+K)

tmp = 0
for i in range(0,N):
    tmp = max(tmp,A[i+1]-A[i])
print(K-tmp)

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

ans = [0,0,0,0,0,0,0,0]
tmp = 0

for i in range(0,N):
    if A[i]//400 >= 8:
        tmp += 1
    else:
        ans[A[i]//400] = 1

print(max(1,sum(ans)),min(8,sum(ans)+tmp))
Problem p03137 (python)

Fixed submission:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M = map(int, input().split())
X = list(map(int, input().split()))


X.sort()

ans = X[M-1] - X[0]
tmp = []

if N==1:
    print(ans)
    sys.exit()


for i in range(1,M):
    tmp2 = X[i] - X[i-1]
    if len(tmp) < N-1:
        tmp.append(tmp2)
    else:
        tmp3 = min(tmp)
        if tmp3 < tmp2:
            tmp.remove(tmp3)
            tmp.append(tmp2)

print(ans - sum(tmp))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()

ans = X[M-1] - X[0]
tmp = []

for i in range(1,M):
    tmp2 = X[i] - X[i-1]
    if len(tmp) < N-1:
        tmp.append(tmp2)
    else:
        tmp3 = min(tmp)
        if tmp3 < tmp2:
            tmp.remove(tmp3)
            tmp.append(tmp2)

print(ans - sum(tmp))