Harryxun/stf_run huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
C = sum(A)
D = [0]*(10**5)
for n in range(N):
    D[A[n]] += 1
Q = int(input())
Z = []
for q in range(Q):
    x, y = map(int, input().split())
    if D[x]:
        C = C - x*D[x]
        C = C + y*D[x]
        Z.append(C)
        D[y] += 1*D[x]
        D[x] = 0
    else:
        Z.append(C)
for z in Z:
    print(z)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = [0]*(N+1)
for n in range(N):
    B[n+1] = B[n] + A[n]
C = B.pop()

Z = {}
for n in range(N):
    Z[A[n]] = 0
for n in range(N):
    Z[A[n]] += 1

D = []
Q = int(input())
for q in range(Q):
    x, y = map(int, input().split())
    if x in Z:
        C = C - x*Z[x]
        C = C + y*Z[x]
        D.append(C)
        if x == y:
            continue
        if y in Z:
            Z[y] += 1*Z[x]
        else:
            Z[y] = Z[x]
        Z.pop(x)
    else:
        D.append(C)
for d in D:
    print(d)
#!/usr/bin python3
# -*- coding: utf-8 -*-

# 二分グラフ

N = int(input())
M = N-1
graph = [[] for _ in range(N)]
seen = [False]*N
color = [-1]*N

# 隣接リストの作成
for i in range(M):
    a, b, w = map(int, input().split())
    a -= 1
    b -= 1
    w %= 2
    graph[a].append((b,w))
    graph[b].append((a,w))

# 深さ優先探索
def dfs(g,v,c):
    seen[v] = True
    color[v] = c
    for nv, w in g[v]:
        # すでに隣接の色が確定していて同じ色となっている場合終了
        if seen[nv] == True:
            continue
        # 隣接の色が確定していていない場合、先に進めた結果を返す
        nc = c if w==0 else 1-c
        if not dfs(g,nv,nc):
            return False
    return True

def main():
    ret = dfs(graph, 0, 1)
    for i in color:
        print(i)

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

# 二分グラフ
N = int(input())
graph = [[] for _ in range(N)]
color = [-1]*N

# 隣接リストの作成
for i in range(N-1):
    a, b, w = map(int, input().split())
    a -= 1
    b -= 1
    w %= 2
    graph[a].append((b,w))
    graph[b].append((a,w))

next_q = [(0, 0)]
while len(next_q)>0:
    nw, nc = next_q.pop()
    color[nw] = nc
    for nxt, nl in graph[nw]:
        if color[nxt]==-1:
            next_q.append((nxt,(nl+nc)%2))
for i in color:
    print(i)
import scipy as sp

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

tree = [int(input()) for i in range(N)]

tree.sort()

print(min(tree[N-K+i] - tree[i] for i in range(N-K+1)))
    

### FIXED CODE ###

N = int(input())

string = ["Christmas", "Eve", "Eve", "Eve"]
ans = []

for i in range(26-N):
    ans.append(string.pop(0))
print(" ".join(ans))
from collections import defaultdict
MOD = 998244353

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

cnt = defaultdict(int)
m = 0
for i in range(n):
    cnt[d[i]] += 1
    m = max(d[i], m)

if d[0] != 0 or dd[0] != 1:
    ans = 0
else:
    ans = 1
    for i in range(1, m + 1):
        ans *= cnt[i - 1]**cnt[i]
        ans %= MOD

print(ans)


### FIXED CODE ###

n = int(input())
d = list(map(int, input().split()))
MOD = 998244353

if d[0] != 0:
    ans = 0
else:
    d.sort()
    d.append(d[-1] + 1)
    if d[1] == 0:
        ans = 0
    else:
        x = 1
        cnt_prev = 1
        cnt = 0
        ans = 1
        for i in range(1, n + 1):
            if d[i] == x:
                cnt += 1
            elif d[i] == x + 1:
                # print(x, cnt, cnt_prev)
                ans *= cnt_prev**cnt
                ans %= MOD
                cnt_prev = cnt
                cnt = 1
                x += 1
            else:
                ans = 0
                break

print(ans)
r = input()

menseki = 3 * r * r
print(menseki)

### FIXED CODE ###

r = int(input())

menseki = 3 * r * r
print(menseki)
from functools import lru_cache

import sys
sys.setrecursionlimit(10**9)

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

M = 10 ** 9 + 7

@lru_cache(maxsize=10**9)
def combinations(n, r):
    if n == 0 or r == 0: return 1
    return int((combinations(n, r-1) * (n-r+1)) / r)

def f(i):
    return (combinations(N - K + 1, i) % M) * (combinations(K - 1, i - 1) % M)

for i in range(1, K + 1):
    print(f(i) % M)


### FIXED CODE ###

from functools import lru_cache

import sys
sys.setrecursionlimit(10**9)

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

M = 10 ** 9 + 7

@lru_cache(maxsize=10**9)
def combinations(n, r):
    if n == 0 or r == 0: return 1
    return int((combinations(n, r-1) * (n-r+1)) // r)

def f(i):
    return (combinations(N - K + 1, i) % M) * (combinations(K - 1, i - 1) % M)

for i in range(1, K + 1):
    print(f(i) % M)
import dicimal 

N=int(input())
A=[int(i) for i in input().split()]

A.sort(reverse=True)

x=0
y=0
for i in range(N):
      if A[0]==A[1]:
          x=A[0]
          A.remove(x)
          A.remove(x)
          break
      else:
          A.remove(A[0])

for i in range(len(A)):
    if A[0]==A[1]:
        y=A[0]
        break
    else:
        A.remove(A[0])

print(dicimal(x*y))

### FIXED CODE ###

N=int(input())
A=[int(i) for i in input().split()]

A.sort(reverse=True)

x=0
y=0
for i in range(N-1):
      if A[0]==A[1]:
          x=A[0]
          A.remove(x)
          A.remove(x)
          break
      else:
          A.remove(A[0])
if len(A)>=2:
    for i in range(len(A)-1):
        if A[0]==A[1]:
            y=A[0]
            break
        else:
            A.remove(A[0])

print(x*y)
import numpy as np
n=int(input())
a=np.array([int(i) for i in input().split()])
a = 1/a
print(1/(sum(a))

### FIXED CODE ###

import numpy as np
n=int(input())
a=np.array([int(i) for i in input().split()])
a = 1/a
print(1/sum(a))
N = int(input())
A=list(map(int, input().split()))

ans=1
c=0

while c<N:
    if A[c]==0:
        ans=0 break;
    else if ans*A[c]>10000000000000000:
        ans=10000000000000001
    else :
        ans=ans*A[c]
    
    c+=1
    
if ans>10000000000000000: print(-1)
else: print(ans)

### FIXED CODE ###

N = int(input())
A=list(map(int, input().split()))
 
ans=1
c=0
 
while c<N:
    if A[c]==0:
        ans=0
    elif ans*A[c]>1000000000000000000:
        ans=1000000000000000001
    else :
        ans=ans*A[c]
    
    c+=1
    
if ans>1000000000000000000: print(-1)
else: print(ans)
import sys
sys.setrecursionlimit(10000)

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

def dp(i):

    if i == 0:
        return 0
    elif i == 1:
        return abs(h[1] - h[0])
    elif 2 <= i:
        return min(dp(i-1) + abs(h[i]-h[i-1]), dp(i-2) + abs(h[i] - h[i-2]))
    else:
        return 100000000

print(dp(n-1))


### FIXED CODE ###

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

dp = [100000] * n

dp[0] = 0

for i in range(0, n):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = abs(h[i-1] - h[i])
    else:
        a = dp[i-1] + abs(h[i] - h[i-1])
        b = dp[i-2] + abs(h[i] - h[i-2])
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])
a, b, c, k = map(int, input().split())

if k =< a:
  print(1 * k)
elif a < k and k <= (a+b):
  print(a)
else:
  print(a - ((k -(a+b)) * -1))

### FIXED CODE ###

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

if k <= a:
    print(1 * k)
elif a < k and k <= (a + b):
    print(a)
else:
    print(a - ((k - (a + b)) * 1))
#!/usr/bin/env python3
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a_idx = a.index(min(a))
b_idx = b.index(min(b))
#print(a_idx,b_idx)

ans = min(a)+min(b)
for i in range(m):
    x,y,c = map(int,input().split())
    if x-1 != a_idx or y-1 != b_idx:
        ans = min(ans,a[x-1]+b[x-1]-c)
    if x-1 == a_idx and y-1 == b_idx:
        ans = min(ans,a[x-1]+b[x-1]-c)
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a_idx = a.index(min(a))
b_idx = b.index(min(b))
#print(a_idx,b_idx)

ans = min(a)+min(b)
for i in range(m):
    x,y,c = map(int,input().split())
    if x-1 != a_idx or y-1 != b_idx:
        ans = min(ans,a[x-1]+b[y-1]-c)
    if x-1 == a_idx and y-1 == b_idx:
        ans = min(ans,a[x-1]+b[y-1]-c)
print(ans)
program hi;
var 
    a, b, c, k, i, ans: longint;
    r: array[1..200] of longint;

procedure aswap(var x: longint; var y: longint);
var tmp: longint;
begin
    if x > y then begin
        tmp := x;
        x := y;
        y := tmp;
    end;
end;

function gcd(x: longint; y: longint): longint;
var i: longint;
begin
    aswap(x, y);
    for i := 1 to y do 
        if (x mod i = 0) and (y mod i = 0) then
            gcd := i;
end;

begin
    readln(k);
    for i := 1 to k do 
        r[i] := i;
    ans := 0;
    for c := 1 to k do 
        for b := 1 to k do 
            for a := 1 to k do 
                ans := ans + gcd(gcd(r[a], r[b]), r[c]);
    writeln(ans);
end.

### FIXED CODE ###

from math import*
r = range(1, int(input()) + 1)
print(sum(gcd(gcd(a, b), c) for a in r for b in r for c in r))
s=list(input())
k=int(input())
s[k-1]=s[k-1].lower()
print(*s,sep="")

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
s[k-1]=s[k-1].lower()
print(*s,sep="")
N, K = map(int, input().split())

if K == 1:
    print(0)

elif N == K:
    print(0)

elif N % 2 == 0 and K % 2 == 0 and N > K and K % N == 0:
    print(0)
elif N % 2 == 0 and K % 2 == 0 and N > K and K % N != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break


elif N % 2 == 0 and K % 2 == 0 and N < K and K % N == 0:
    print(N)
elif N % 2 == 0 and K % 2 == 0 and N < K and K % N != 0:
    if abs(N - K) > N:
        print(N)
    else:
        print(abs(N - K))


elif N % 2 == 1 and K % 2 == 1 and N > K and K % N == 0:
    print(0)
elif N % 2 == 1 and K % 2 == 1 and N > K and K % N != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10**18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break


elif N % 2 == 0 and K % 2 == 0 and N < K and K % N == 0:
    print(N)
elif N % 2 == 0 and K % 2 == 0 and N < K and K % N != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break


elif N % 2 == 0 and K % 2 == 1 and N > K and N % K != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break
elif N % 2 == 0 and K % 2 == 1 and N > K and N % K == 0:
    print(0)


elif N % 2 == 0 and K % 2 == 1 and N < K and N % K != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break
elif N % 2 == 0 and K % 2 == 1 and N < K and N % K == 0:
    print(0)


elif N % 2 == 1 and K % 2 == 0 and N > K and N % K != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break
elif N % 2 == 1 and K % 2 == 0 and N > K and N % K == 0:
    print(0)


elif N % 2 == 1 and K % 2 == 0 and N < K and N % K != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break
elif N % 2 == 1 and K % 2 == 0 and N < K and N % K == 0:
    print(N)

else:
    print("NG")



### FIXED CODE ###

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

print(min(N % K, abs(K - N % K)))
n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in rnage(m)]     

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][l] = int(a[i][k])*int(b[k][j])
for i in range(n):
    print(*c)


### FIXED CODE ###

n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in range(m)]     
c = [[0]*l for _ in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += int(a[i][k])*int(b[k][j])
            
for i in range(n):
    print(*c[i])
n = int(input())

if n % 2 == 0:
  print(n)
else:
  print(2*n

### FIXED CODE ###

n = int(input())

if n % 2 == 0:
  print(n)
else:
  print(2*n)
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

E = [set() for _ in range(N)]
for a,b in AB:
  a -= 1
  b -= 1
  E[a].add(b)
  E[b].add(a)

visited = [0] * N
def dfs(u,v,count):
  visited[u] = count
  count += 1
  res = False
  for t in E[u]:
    if t != v:
      #print(t,u,visited[t],count)
      if visited[t] == 1:
        if count == M + 1:
          return True
        else:
          return False
      res |= dfs(t,u,count)
  return res

print('YES' if dfs(AB[0][0],-1,1) else 'NO')


### FIXED CODE ###

N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

V = {}
v = [0,0]
for v[0],v[1] in AB:
  for i in range(2):
    if v[i] in V:
      V[v[i]] += 1
    else:
      V[v[i]] = 1
for val in V.values():
  if val % 2 == 1:
    print('NO')
    exit()
print('YES')
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
manzoku = 0
prev = 0
 
for a in A:
  manzoku += B[a-1]
  if prev == a and prev != N:
    manzoku += C[prev-1]
  prev = a
print(manzoku)

### FIXED CODE ###

N = int(input())
print(N*N*N)
N=int(input())
l=["a","b","c","d","e","f","g","h","i","j","k","l","m",
   "n","o","p","q","r","s","t","u","v","w","x","y","z"]
Ans=[]
s=0
for i in range(10):
    s+=26**i
    S=s+26**(i+1)
    if s<=N<S:
        I=i
        break
while I>=0:
    for i in range(1,27):
        n=N-26**I*i
        if n<26**I:
            Ans.append(l[i-1])
            N=n
            I-=1
            break
print("".join(Ans))

### FIXED CODE ###

N=int(input())
l=["a","b","c","d","e","f","g","h","i","j","k","l","m",
   "n","o","p","q","r","s","t","u","v","w","x","y","z"]
Ans=[]
s=0
for i in range(11):
    s+=26**i
    S=s+26**(i+1)
    if s<=N<S:
        I=i
        break
for i in range(I+1):
    N-=26**i
while I>=0:
    for i in range(0,26):
        n=N-26**I*i
        if n<26**I:
            Ans.append(l[i])
            N=n
            I-=1
            break
print("".join(Ans))
n,m=map(int,input().split())
edges=[[]for i in range(n)]
visited=[False]*n
cnt=0
def dfs(u):
  global visited
  global cnt
  visited[u]=True
  if visited[-1]==True:
    return cnt,visited
  cnt+=1
  for v in edges[u]:
    if visited[v]==False:
      dfs(v)
  return cnt,visited

for i in range(m):
  a,b=map(int,input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)

cnt,visited=dfs(0)
if visited[-1]==True and cnt==2:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

### FIXED CODE ###

n,m=map(int,input().split())
edges=[[]for i in range(n)]


for i in range(m):
  a,b=map(int,input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)

for v in edges[-1]:
  if 0 in edges[v]:
    print('POSSIBLE')
    exit()
print('IMPOSSIBLE')
n,k = map(int, input().split())

print(min(n%k, abs(n%k-k)))


### FIXED CODE ###

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

A,B = B,A
A,C = C,A

print(A,B,C)
import collections
N, M = map(int, input().split())
G = [set() for i in range(N)]
L = [-1]*N


def solve(x, r):
    if L[x] >= 0:
        return(L[x])
    res = 0
    for z in G[x]:
        if r[z]:
            r[z] = False
            res = max(res, solve(z, r) + 1)
        else:
            res = max(res, L[z]+1)
    L[x] = res
    return(res)


for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1

    G[x].add(y)

r = [True]*N

for i in range(N):
    # print(L)
    if r[i]:
        L[i] = solve(i, r)
print(max(L))

# print(L)


### FIXED CODE ###

import collections
import sys
sys.setrecursionlimit(10**5)
N, M = map(int, input().split())
G = [set() for i in range(N)]
L = [-1]*N


def solve(x, r):
    if L[x] >= 0:
        return(L[x])
    res = 0
    for z in G[x]:
        if r[z]:
            r[z] = False
            res = max(res, solve(z, r) + 1)
        else:
            res = max(res, L[z]+1)
    L[x] = res
    return(res)


for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1

    G[x].add(y)

r = [True]*N

for i in range(N):
    # print(L)
    if r[i]:
        L[i] = solve(i, r)
print(max(L))

# print(L)
import math

N,M=map(int,input().split())
a=[-1]+[int(input()) for i in range(M)]+[N+1]
ans=1

for i in range(M+1):
    dist=a[i+1]-a[i]-2
    if dist<0 and a[i]!=-1 and a[i+1]!=N+1:
        ans=0
        break
    
    val=0
    cnt1=dist%2
    cnt2=dist//2
    while cnt2 >= 0:
        val+=math.factorial(cnt1+cnt2)/math.factorial(cnt1)/math.factorial(cnt2)
        cnt2-=1
        cnt1+=2
    ans*=val
    print(dist,val)

print(ans%1000000007)

### FIXED CODE ###

N,M=map(int,input().split())
dp=[0]*(N+3)
dp[0]=1
a=[0]*(N+3)
for i in range(M):
    a[int(input())]=1
mod=10**9+7

for i in range(N+1):
    if a[i+1] != 1:
        dp[i+1]+=dp[i]
        dp[i+1]%=mod
    if a[i+2] != 1:
        dp[i+2]+=dp[i]
        dp[i+2]%=mod

print(dp[N])
#C
import math
a, b, c, d = map(int, input().split())
a-=1
cd=c*d//math.gcd(c,d)
ans = b - (b // c) - (b // d) + (b // cd)
ans -= a - (a // c) - (a // d) + (a // cd)

print(ans)

### FIXED CODE ###

#C
import math
a, b, c, d = map(int, input().split())

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y != 0:
        x, y = y, x % y
    return x

s = b - a + 1
cc = b // c - (a - 1) // c
dd = b // d - (a - 1) // d
cd = c * d // gcd(c, d)
cd = b // cd - (a - 1) // cd
s -= cc + dd - cd
print(s)
x = input()
a = input()
b = input()
print (x - a) % b

### FIXED CODE ###

x = input()
a = input()
b = input()
print (x - a) % b
N, Q = map(int, input().split())
S = input()
Sum = [0]*(N+1)
for i in range(N):
	if S[i] == 'A' and S[i+1] == 'C':
		Sum[i+1] = Sum[i] + 1
	else:
		Sum[i+1] = Sum[i]

for i in range(Q):
	l, r = map(int, input().split())
	print(Sum[r-1] - Sum[l-1])
	

### FIXED CODE ###

N, Q = map(int, input().rstrip().split())
S = [i for i in input()]

list_lr = [list(map(int, input().rstrip().split())) for i in range(Q)]

t = [0]
ct = 0
for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
        ct += 1
    t.append(ct)

for i in list_lr:
    l, r = i[0], i[1]
    print(t[r-1]-t[l-1])
N,K,Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
B = [0 for i in range(N)]
for i in range(Q):
    j=A[i]-1
    B[j]+=1
for j in range(N):
    if K - Q + B[i]>0:
        print('Yes')
    else :
        print('NO')

### FIXED CODE ###

N, K, Q = map(int, input().split(" "))    # N:人数, K:初期スコア, Q:問題数
A = [int(input()) for i in range(Q)]    # 正解者のリスト
B = [0 for i in range(N)]    # 各人の正解数

for i in range(Q):
    num_ans_person = A[i] - 1
    B[num_ans_person] += 1

# 得点は, 最初の点数 - 他人の正解数
# 他人の正解数は, 問題数 - 自分の正解数
# 得点は, 最初の点数 - 問題数 + 自分の正解数
# 得点 > 0 であれば, "Yes"
for i in range(N):
    if K - Q + B[i] > 0:
        print("Yes")
    else:
        print("No")
from functools import lru_cache

N = int(input())
X = input()
x = int(X, 2)
y = X.count('1')
x1 = x % (y+1)
x2 = x % (y-1)

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

for i in range(N):
    if x >>(N - i - 1) & 1:
        print(f(x-pow(2, N-i-1)))
        # print(f((x1 - pow(2, N - i - 1, y-1)) % (y-1)) + 1)
    else:
        print(f(x+pow(2, N-i-1)))
        # print(f((x2 + pow(2, N - i - 1, y+1)) % (y+1)) + 1)

### FIXED CODE ###

from functools import lru_cache

N = int(input())
X = input()
x = int(X, 2)
y = X.count('1')
if y == 1:
    x2 = 0
else:
    x2 = x % (y-1)
x1 = x % (y+1)

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

d = [0] * (2*10**5+5)
for i in range(2*10**5+5):
    d[i] = f(i)

for i in range(N):
    if x >>(N - i - 1) & 1:
        # print(f(x-pow(2, N-i-1)))
        if y - 1 == 0:
            print(0)
        else:
            print(d[(x2 - pow(2, N - i - 1, y-1)) % (y-1)] + 1)
    else:
        # print(f(x+pow(2, N-i-1)))
        print(d[(x1 + pow(2, N - i - 1, y+1)) % (y+1)] + 1)
def main():
    n = int(input())
    rate_count = [0] * 9
    a = tuple(map(int, input().split()))
    for ae in a:
        rank = ae // 400
        rate_count[rank] += 1

    reds =  rate_count[8]
    rate_count[8] = 0
    res = 0
    for i1 in range(8):
        res += rate_count[i1] > 0
    r_min = max(res, 1)
    r_max = min(8, res + reds)
    print(r_min, r_max)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    rate_count = [0] * 13
    a = tuple(map(int, input().split()))
    for ae in a:
        rank = ae // 400
        rate_count[rank] += 1

    reds = sum(rate_count[8:])
    res = 0
    for i1 in range(8):
        res += rate_count[i1] > 0
    r_min = max(res, 1)
    r_max = res + reds
    print(r_min, r_max)

if __name__ == '__main__':
    main()
H, W = map(int, input().split())

a = [None]
for i in range(H):
    a.append([None] + list(map(int, input().split())))


def is_odd(i, j):
    return a[i][j] % 2 == 1


def next_cell(i, j):
    if i % 2 == 1:
        if j < W:
            return i, j + 1
    else:
        if 0 < j:
            return i, j - 1
    if i < H:
        return i + 1, j
    return None, None


def move(i, j):
    ni, nj = next_cell(i, j)
    if ni is None:
        return None
    a[i][j] -= 1
    a[ni][nj] += 1
    return "{} {} {} {}".format(i, j, ni, nj)


ans = []
for j in range(1, W + 1):
    for i in range(1, H + 1):
        if is_odd(i, j):
            res = move(i, j)
            if res is not None:
                ans.append(res)


print(len(ans))
for line in ans:
    print(line)


### FIXED CODE ###

H, W = map(int, input().split())

a = [None]
for i in range(H):
    a.append([None] + list(map(int, input().split())))


def is_odd(i, j):
    return a[i][j] % 2 == 1


def next_cell(i, j):
    if i % 2 == 1:
        if j < W:
            return i, j + 1
    else:
        if 1 < j:
            return i, j - 1
    if i < H:
        return i + 1, j
    return None, None


def move(i, j):
    ni, nj = next_cell(i, j)
    if ni is None:
        return None
    a[i][j] -= 1
    a[ni][nj] += 1
    return "{} {} {} {}".format(i, j, ni, nj)


ans = []
i, j = 1, 1
while True:
    if is_odd(i, j):
        res = move(i, j)
        if res is not None:
            ans.append(res)
    i, j = next_cell(i, j)
    if i is None:
        break

print(len(ans))
for line in ans:
    print(line)