Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python
def modpow(x, y, mod):
    ret = 1
    z = x
    n = len(bin(y)) - 2
    for i in range(n):
        if ((y >> i) & 1):
            ret = ret * z % mod
        z = z * z % mod
    return ret

def modinv(x, mod):
    return modpow(x, mod-2, mod)

def main():
    n, m, k = map(int, input().split())
    mod = 998244353

    c1 = 1
    for i in range(1, n):
        c1 = c1 * i % mod
        if i == k:
            c2 = modinv(c1, mod)
    c3 = modinv(c1, mod)
    c3_list = [0] * (k+1)
    c3_list[k] = c3
    for i in range(k-1, -1, -1):
        c3 = c3 * (n-(k-i)) % mod
        c3_list[i] = c3
    comb = (c1 * c2 % mod) * c3_list[0] % mod

    x = m * modpow(m-1, n-k-1, mod) % mod

    ret = x * comb % mod

    for i in range(1, k+1):
        c2 =c2 * (k-i+1) % mod
        comb = (c1 * c2 % mod) * c3_list[i] % mod
        x = x * (m-1) % mod

        ret += x * comb % mod
        ret %= mod

    print(ret)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python
def modpow(x, y, mod):
    ret = 1
    z = x
    n = len(bin(y)) - 2
    for i in range(n):
        if ((y >> i) & 1):
            ret = ret * z % mod
        z = z * z % mod
    return ret

def modinv(x, mod):
    return modpow(x, mod-2, mod)

def main():
    n, m, k = map(int, input().split())
    mod = 998244353

    c1 = 1
    c2 = 1
    for i in range(1, n):
        c1 = c1 * i % mod
        if i == k:
            c2 = modinv(c1, mod)
    c3 = modinv(c1, mod)
    c3_list = [0] * (k+1)
    c3_list[k] = c3
    for i in range(k-1, -1, -1):
        c3 = c3 * (n-(k-i)) % mod
        c3_list[i] = c3
    comb = (c1 * c2 % mod) * c3_list[0] % mod

    x = m * modpow(m-1, n-k-1, mod) % mod

    ret = x * comb % mod

    for i in range(1, k+1):
        c2 =c2 * (k-i+1) % mod
        comb = (c1 * c2 % mod) * c3_list[i] % mod
        x = x * (m-1) % mod

        ret += x * comb % mod
        ret %= mod

    print(ret)


if __name__ == '__main__':
    main()
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

if abs(A - B) < 2
	print("Brown")
else:
	print("Alice")

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

if abs(A - B) < 2:
	print("Brown")
else:
	print("Alice")
s=input()
k=int(input())
it=int(-1)
sum=int(0)
for i in s:
    if i == '1':
        sum+=1
    else:
        it=i

if k<=it:
    print(1)
elif it is -1:
    print(1)
else:
    print(s[it])

### FIXED CODE ###

s=input()
k=int(input())
it=int(-1)
sum=int(0)
for i in s:
    if i == '1':
        sum+=1
    else:
        it=sum
        break

if k<=int(it):
    print(1)
elif it == int(-1):
    print(1)
else:
    nex=int(it)+int(1)
    print(s[it:nex])
bimport math
n=int(input())
miti= list([int(input()) for i in range(5)])
print(4+math.ceil(n/min(miti)))


### FIXED CODE ###

import math
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
miti=[a,b,c,d,e]
mini=min(miti)
retu=math.ceil(n/mini)
print(4+retu)
# -*- coding: utf-8 -*-

from math import log2, floor

L = int(input())

N = floor(log2(L)) + 1
edge = []

# 長さ0の辺
for i in range(1, N):
    edge.append((i, i+1, 0))

# 長さ2**(i-1)の辺
for i in range(1, N):
    edge.append((i, i+1, 2**(i-1)))

# ここまでで長さ0,...,X-1のパスが完成
X = 2 ** (N-1)

# 残りの辺
while L > X:
    r = floor(log2(L - X))
    edge.append((r + 1, N, X))
    X += 2 ** r

# 出力
M = len(edge)
print(N, M)
for e in edge:
    print(' '.join(map(str, e)))

### FIXED CODE ###

L = int(input())

def decompose(L):
    if L < 3:
        return [L]
    r = L % 3
    return [r] + decompose((L - r) // 3)

dec = decompose(L)

N = len(dec) + 1
edge = []

for w in range(dec[-1]):
    edge.append((N-1, N, w))

base = dec[-1]
for i in range(len(dec) - 2, -1, -1):
    for w in range(3):
        edge.append((i+1, i+2, w * base))
    base = 3 * base
    for w in range(dec[i]):
        edge.append((i+1, N, base + w))
    base += dec[i]

M = len(edge)
print(N, M)
for e in edge:
    print(' '.join(map(str, e)))
t=input().split()
n=int(t.pop(0))
t.sort()
p=0
for i in range(n-1):
    if t[i]==t[i+1]:
        p+=1
        
if p>0:
    print("NO")
else:
    print("YES")

### FIXED CODE ###

n=int(input())
t=input().split()
if len(set(t))==n:
    print("YES")
else:
    print("NO")
A, P = int( x ) for x in input()
print( ( A * 3 + P ) // 2 )


### FIXED CODE ###

A, P = map( int, input().split() )
print( ( A * 3 + P ) // 2 )
import math
A,B=map(int,input().split())
print(A*B/gcd(A,B))

### FIXED CODE ###

import fractions
A,B=map(int,input().split())
print(int(A*B/fractions.gcd(A,B)))
data = int(input())
list = data.split(" ")

list.sort()

print("{0} {1} {2}".format(list[0], list[1], list[2]))

### FIXED CODE ###

num = list(map(int, input().split()))
num.sort()
print(num[0], num[1], num[2])
# coding: utf-8

import sys
from collections import deque

n = int(input())

task_name = (
    "insert",
    "delete",
    "deleteFirst",
    "deleteLast"
)

tasks = deque(map(lambda x: x if x in task_name else x.split(), sys.stdin.readlines()))

a = deque()

for task in tasks:
    #deleteFirst,deleteLast
    if len(task) == 1:
        if task == "deleteFirst":
            a.popleft()
        else:
            a.pop()
    #insert,delete
    else:
        t, item = task.split()
        if t == "insert":
            a.appendleft(item)
        elif item in a:
            a.remove(item)

print(*a)

### FIXED CODE ###

# coding: utf-8

import sys
from collections import deque

n = int(input())

task_name = (
    "insert",
    "delete",
    "deleteFirst",
    "deleteLast",
)

a = deque()

for task in map(lambda x: [x] if x in task_name else x.split(), sys.stdin.readlines()):
    #deleteFirst,deleteLast
    if len(task) == 1:
        if task[0] == "deleteFirst":
            a.popleft()
        else:
            a.pop()

    #insert,delete
    else:
        if task[0] == "insert":
            a.appendleft(task[1])
        elif task[1] in a:
            a.remove(task[1])

print(*a)
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    B[i] = B[i-1]+A[i-1]
C = A[:]
for i in range(N-1):
    for j in range(i+1,N):
        C.append(B[j+1]-B[i])
C = sorted(C,reverse=True)
n = math.ceil(math.log2(C[0]))
Cb = []
for i in range(len(C)):
    x = bin(C[i])[2:]
    k = len(x)
    x = "0"*(n-k)+x
    Cb.append(x)
inds = [i for i in range(len(C))]
nlow = 0
while len(inds)>K:
    for j in range(nlow,n):
        E = []
        cnt = 0
        for i in inds:
            if Cb[i][j]=="1":
                E.append(i)
                cnt += 1
        if cnt>=K:
            inds = E[:]
            nlow = j+1
            break
    if cnt<K:break
cnt = int("1"*n,2)
for i in inds: 
    cnt = cnt&C[i]
print(cnt)

### FIXED CODE ###

import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    B[i] = B[i-1]+A[i-1]
C = A[:]
for i in range(N-1):
    for j in range(i+1,N):
        C.append(B[j+1]-B[i])
C = sorted(C,reverse=True)
n = math.ceil(math.log2(C[0]))
Cb = []
for i in range(len(C)):
    x = bin(C[i])[2:]
    k = len(x)
    x = "0"*(n-k)+x
    Cb.append(x)
inds = [i for i in range(len(C))]
nlow = 0
while len(inds)>K:
    for j in range(nlow,n):
        E = []
        cnt = 0
        for i in inds:
            if Cb[i][j]=="1":
                E.append(i)
                cnt += 1
        if cnt>=K:
            inds = E[:]
            nlow = j+1
            break
    if cnt<K:break
cnt = int("1"*n,2)
for i in inds: 
    cnt = cnt&C[i]
print(cnt)
n = int(input()[-1])

if  in [2, 4, 5, 7, 9]:
  print("hon")
elif n in [0, 1, 6, 8]:
  print("pon")
else:
  print("bon")

### FIXED CODE ###

n = int(input()[-1])

if n in [2, 4, 5, 7, 9]:
  print("hon")
elif n in [0, 1, 6, 8]:
  print("pon")
else:
  print("bon")
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    s = INPUT()
    t = INPUT()

    s = [ord(i) for i in sorted(s)]
    t = [ord(i) for i in sorted(t)]
    t.reverse()

    cnt = 0
    for x in s:
        if x < t[cnt]:
            print("Yes")
            sys.exit()
        elif x > t[cnt]:
            print("No")
            sys.exit()
        else:
            cnt += 1

    print("Yes" if len(s) < len(t) else "No")


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    s = INPUT()
    t = INPUT()

    s = [ord(i) for i in sorted(s)]
    t = [ord(i) for i in sorted(t)]
    t.reverse()

    cnt = 0
    for x in s:
        if x < t[cnt]:
            print("Yes")
            sys.exit()
        elif x > t[cnt]:
            print("No")
            sys.exit()
        else:
            cnt += 1
            if cnt == len(t):
                print("No")
                sys.exit()

    print("Yes" if len(s) < len(t) else "No")


if __name__ == '__main__':
    main()
n=str(input())
if n[-1]=="7" or n[-3]=="7" or n[-2]=="7"
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n=str(input())
if n[-1]=="7" or n[-3]=="7" or n[-2]=="7":
    print("Yes")
else:
    print("No")
N=int(input())
T=list(map(int,input().split()))
M=int(input())
for i in range(M):
  P[i],X[i]=int(input().split())
  
T_ALL=sum(T)
  
for i in range():
  ans=T_ALL+X[P[i]]-T[i]
  print(ans)
  

### FIXED CODE ###

N=int(input())
T=list(map(int,input().split()))
T_ALL=sum(T)
M=int(input())

for i in range(M):
  P,X=map(int,input().split())
  ans=T_ALL+X-T[P-1]
  print(ans)
#!/usr/bin/env python
# coding: utf-8

# In[55]:


S, T = list(input().split())
s = len(S)
t = len(T)
l1 = [] 
l2 = []
n = 0


for i in range(n, s-t+1): 
    ss = S[n:t + n]
    n += 1
    m = 0
    for x in ss:
        
        if x == T[m]:
            l1.append(1)
            m +=1
        else:
            l1.append(0)
            m +=1
    
    l2.append(sum(l1))
    l1 = []
    
print(t - max(l2))


# In[ ]:






### FIXED CODE ###

S = input()
T = input()
s = len(S)
t = len(T)
l1 = [] 
l2 = []
n = 0
for i in range(n, s-t+1): 
    ss = S[n:t + n]
    n += 1
    m = 0
    for x in ss:       
        if x == T[m]:
            l1.append(1)
            m +=1
        elif x != T[m]:
            l1.append(0)
            m +=1   
    l2.append(sum(l1))
    l1 = [ ]
print(t - max(l2))
# coding: utf-8

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

while True:
    elif a == b and b == c and c == a :
        count = -1 if a % 2 == 1 else 0
        break
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0 :
        a, b, c = (b+c)/2, (c+a)/2, (a+b)/2
        count += 1
    else:
        break
print(count)

### FIXED CODE ###

# coding: utf-8

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

while True:
    if a == b and b == c and c == a :
        count = -1 if a % 2 == 0 else 0
        break
    elif a % 2 == 0 and b % 2 == 0 and c % 2 == 0 :
        a, b, c = (b+c)/2, (c+a)/2, (a+b)/2
        count += 1
    else:
        break
print(count)
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N, M = map(int, input().split())
    graph = defaultdict(list)
    route = []
    for _ in range(M):
        A, B = map(int, input().split())
        if not route:
            route += [A, B]
        graph[A].append(B)
        graph[B].append(A)

    while True:
        start, end = route[0], route[-1]
        start_ok = True
        for n in graph[start]:
            if n not in route:
                start_ok = False
                route = [n] + route
                break

        end_ok = True
        for n in graph[end]:
            if n not in route:
                end_ok = False
                route.append(n)
                break

        if start_ok and end_ok:
            break

    print(len(route))
    print(*route, sep=" ")


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    a_list = list(map(int, input().split()))

    ans = 0
    state = None
    for i in range(N - 1):
        if a_list[i] == a_list[i + 1]:
            continue

        now = a_list[i] < a_list[i + 1]
        if state is None:
            state = now
            continue
        if state != now:
            ans += 1
            state = None

    print(ans + 1)


if __name__ == '__main__':
    main()
def solve():
  weather_dictionary = {
    'Sunny': 'Cloudy',
    'Coludy': 'Rainy',
    'Rainy': 'Sunny'
  }

  print(weather_dictionary[input()])
  

if __name__ == '__main__':
  solve()


### FIXED CODE ###

weather_forecast = {
	'Sunny': 'Cloudy',
	'Cloudy': 'Rainy',
	'Rainy': 'Sunny'
}
 
print(weather_forecast[input()])
d = int(input())
if(d == 22):
  print(Christmas Eve Eve Eve)
elif(d == 23):
  print(Christmas Eve Eve)
elif(d == 24):
  print(Christmas Eve)
else:
  print(Christmas)


### FIXED CODE ###

d = int(input())
if(d == 22):
  print('Christmas Eve Eve Eve')
elif(d == 23):
  print('Christmas Eve Eve')
elif(d == 24):
  print('Christmas Eve')
else:
  print('Christmas')
a=int(input())
if a[0]==a[1] or a[1]==a[2] or a[2]==a[3]:
    print('Bad')
else:
    print('Good')

### FIXED CODE ###

a=input()
if a[0]==a[1] or a[1]==a[2] or a[2]==a[3]:
    print('Bad')
else:
    print('Good')
import sys
sys.setrecursionlimit(10**6)


def f(n):
    p = n % (bin(n).count('1'))
    if p == 0:
        return 1
    else:
        return f(p) + 1


def main(input, print):
    N = int(input())
    X = list(input())
    for i in range(N):
        a = X[:]
        a[i] = "1" if a[i] == "0" else "0"
        b = int(''.join(a), 2)
        print(f(b))


if __name__ == '__main__':
    main(sys.stdin.readline, print)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)


def f(n):
    if n == 0:
        return 1
    p = n % (bin(n).count('1'))
    return f(p) + 1


def main(input, print):
    N = int(input())
    X = list(map(int, list(input().strip())))
    ans = [0] * N

    pcnt = 0
    for i in range(N):
        if X[i] == 1:
            pcnt += 1
    for is_up in range(2):
        current_pcnt = pcnt
        if is_up:
            current_pcnt -= 1
        else:
            current_pcnt += 1
        if current_pcnt <= 0:
            continue
        total = 0
        for i in range(N):
            total = (total*2) % current_pcnt
            total += X[i]
        current_mask = 1
        for i in reversed(range(N)):
            if(X[i] == is_up):
                current_total = total
                if is_up:
                    current_total = (current_total-current_mask+current_pcnt) % current_pcnt
                else:
                    current_total = (current_total+current_mask) % current_pcnt
                ans[i] = f(current_total)
            current_mask = current_mask * 2 % current_pcnt

    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main(sys.stdin.readline, print)
s=input()
N=int(input())
l=len(s)
for scope in range(1,1+l):
  for first in range(1+l-scope):
    if not s[fist:first+scope] in li:
      li.append(s[first:first+scope])
li.sort()   
print(li[N-1])

### FIXED CODE ###

str=input()
K=int(input())
s=set()
for scope in range(1,K+1):
    for f in range(len(str)-scope+1):
        s.add(str[f:f+scope])
print(sorted([x for x in s])[K-1])
a,b,c=[int(x) for x input().split()]
print(b//a,c)

### FIXED CODE ###

a,b,c=[int(x) for x in input().split()]
print(min(b//a,c))
class BigCombination(object):
    __slots__ = ["mod", "factorial", "inverse"]

    def __init__(self, mod: int  10**9+7, max_n: int  10**6):
        fac, inv = [1], []
        fac_append, inv_append = fac.append, inv.append

        for i in range(1, max_n+1):
            fac_append(fac[-1] * i % mod)

        inv_append(pow(fac[-1], mod-2, mod))

        for i in range(max_n, 0, -1):
            inv_append(inv[-1] * i % mod)

        self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

    def get_combination(self, n, r):
        return self.factorial[n] * self.inverse[r] * self.inverse[n-r] % self.mod

    def get_permutation(self, n, r):
        return self.factorial[n] * self.inverse[n-r] % self.mod

N = int(input())
A = [int(x) for x in input().split()]
se = []
c = sum(A) - N * (N + 1) / 2
for i in range(len(A)):
    if A[i] == c:
        se.append(i)
l = se[0]
r = se[1]
import math

Big = BigCombination()
print(N)
for i in range(2,N+2):
    k = Big.get_combination(N+1, i) 
    t = Big.get_combination(l+N-r,i-1)
    print(l+N-r,i-1)
    if l+N-r == 0 :t = 0
    res  = k -t
    print(res)

### FIXED CODE ###

mod = 10**9+7
N = int(input())
A = [int(x) for x in input().split()]
se = []
c = sum(A) - N * (N + 1) / 2
for i in range(len(A)):
    if A[i] == c:
        se.append(i)
l = se[0]
r = se[1]
import math

print(N)

factorial = [1]
inverse = [1]
for i in range(1, N + 2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append((pow(factorial[-1], mod - 2, mod)))


def nCr(n, r):
    if n < r or n == 0 or r == 0:
        return 0
    return factorial[n] * inverse[r] * inverse[n - r] % mod



for i in range(2,N+2):
    k = nCr(N+1, i)
    
    t = nCr(l+N-r,i-1)
    res  = k -t
    print(res % mod)
import numpy as np

n, a, b, c, d = map(lambda x:int(x)-1,input().split())
n += 1
S = [1 if s == "." else 0 for s in input()]

ok = True
overtake = False

if a<b and c<d:
    overtake= True
if b<a and d<c:
    overtake = True
    
groups = []
tmp = 0
zeros = 0
for n in S:
    if n == 1:
        if zeros != 0:#直前まで０だったとき
            groups.append(zeros)
            zeros = 0#リセット
        tmp += 1
    elif n == 0:
        if tmp != 0:#直前まで１だったとき
            groups.append(tmp)
            tmp = 0#リセット
        zeros -= 1
if tmp != 0:
    groups.append(tmp)
if zeros != 0:
    groups.append(zeros)

now = 0
for i in range(len(groups)):
    if now+abs(groups[i]) >= max(a,b):
        ind = i
        break
    now += abs(groups[i])

for i in range(ind+1,len(groups)):
    if groups[i] >= 3:
        overtake = True
    if groups[i] <= -2:
        ok = False

if now+groups[ind]-max(a,b) >= 2:
    overtake= True
if now+groups[ind]-max(a,b) >= 1 and max(a,b)-now >= 1:
    overtake = True

if overtake and ok:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

n, a, b, c, d = map(lambda x:int(x)-1,input().split())
n += 1
S = input()

ok = True
overtake = False

if c < d:
    overtake = True
    
for i in range(a,d):
    if S[i] == "#" and S[i+1] == "#":
        ok = False

for i in range(b,min(d+1,n-1)):
    if S[i] == "." and S[i-1] == "." and S[i+1] == ".":
        overtake = True
        
if ok and overtake:
    print('Yes')
else:
    print('No')
N = int(input())
S = input()

ans = 0
for i in range(N):
    ans = max(ans,len(set(s[:i])) & set(s[i:]))
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = 0
for i in range(N):
    ans = max(ans,len(set(S[:i]) & set(S[i:])))
print(ans)
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

K = int(stdin.readline().rstrip())
a = list(range(1,10))
b = []
attack = 100000
while attack > 0:
    go = a.pop(0)
    ue = go*10
    shimo = go%10
    b.append(go)
    if shimo == 0:
        a.append(ue)
        a.append(ue+1)
    elif shimo == 9:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
    else:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
        a.append(ue+shimo+1)
    attack -= 1

print(b[K-1])

### FIXED CODE ###

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

N,K = [int(x) for x in stdin.readline().rstrip().split()]
ans1 = N % K
ans2 = (ans1 - K) * -1
# print(ans1,ans2)
print(min(ans1,ans2))
n = int(input())
t = list(map(int,input().split()))
m = int(input())
res = sum(t)
px = [list(map(int,input().split()))for _ in range(m)]
for i in range(m):
    p = px[i][0]-1
    x = px[i][1]
    ans = res -t[i]+x
    print(ans)
    

### FIXED CODE ###

n = int(input())
t = list(map(int,input().split()))
m = int(input())
res = sum(t)
px = [list(map(int,input().split()))for _ in range(m)]
for i in range(m):
    p = px[i][0]-1
    x = px[i][1]
    ans = res -t[p]+x
    print(ans)
d = int(input())
if d=25:
    print("Christmas")
if d=24:
    print("Christmas Eve")
if d=23:
    print("Christmas Eve Eve")
if d=22:
    print("Christmas Eve Eve Eve")

### FIXED CODE ###

d = int(input())
if d==25:
    print("Christmas")
if d==24:
    print("Christmas Eve")
if d==23:
    print("Christmas Eve Eve")
if d==22:
    print("Christmas Eve Eve Eve")
print(["error",eval(input().replace(" ","+"))],[eval(input().replace(" ","+"))<10])


### FIXED CODE ###

A,B=map(int,input().split())
if A+B<10:
    print(A+B)
else:
    print("error")
str = input().split()
a1 = int(str[0])
a2 = int(str[1])
diff = abs(a1-a2)
if diff > a2 :
    larger = diff
    smaller = a2
else:
    larger = a2
    smaller = diff
print(larger%smaller)

### FIXED CODE ###

str = input().split()
n = int(str[0])
k = int(str[1])
t = n%k
other = abs(k-t)
print(min(t,other))
n,y = list(map(int, input().split()))
a = 0
b = 0
c = 0
if 10000*(n-1)+5000 < y:
  print("-1 -1 -1")
else:
  for i in range(n+1):
    for j in range(n+1):
      for k in range(n+1):
        if 10000*i+5000*j+1000*k == y:
          a = i
          b = j
          c = k
          break
print("% % %" %(a, b, c))

### FIXED CODE ###

n, y = map(int, input().split())
y //= 1000
D = y-n
for a in range(D//9 + 1):
  D2 = D-9*a
  if D2%4:
    continue
  else:
    b = D2//4
    if n-a-b >= 0:
      print(a, b, (n-a-b))
      exit()
print(-1,-1,-1)
n=int(input())
a=list(map(int,input().split()))
a.sort()
i=0
check=[0]*8
while i<n and a[i]<3200:
    a_i=a[i]
    for j in range(8):
        if check[j]==0 and a_i>=400*j and a_i<400*(j+1):
            check[j]=1
            break
    i+=1
if sum(check)==0:
    ans_min=1
    ans_max_=n
else:
    ans_min=sum(check)
    ans_max=ans_min+n-i
print(ans_min,ans_max)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
i=0
check=[0]*8
while i<n and a[i]<3200:
    a_i=a[i]
    for j in range(8):
        if check[j]==0 and a_i>=400*j and a_i<400*(j+1):
            check[j]=1
            break
    i+=1
if sum(check)==0:
    ans_min=1
    ans_max=n
else:
    ans_min=sum(check)
    ans_max=ans_min+n-i
print(ans_min,ans_max)