Harryxun/stf_run huggingface dataset:
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
A.sort()
bc=[]
for i in range(m):
    b,c=map(int, input().split())
    bc.append([b,c])
bc.sort(key = lambda x:x[1], reverse=True)
count=0
for i in bc:
    for j in range(i[0]):
        if A[count]<i[1]:
            A[count]=i[1]
            count+=1
        else:
            break
        if count==n:
            break
print(sum(A))


### FIXED CODE ###

n,m=map(int, input().split())
A=[int(i) for i in input().split()]
tmp = min(A)
A.sort()
ab=[]
for i in range(m):
    b,c=map(int, input().split())
    if not c<tmp:
        ab.append([b, c])
ab.sort(key=lambda x:x[1], reverse = True)
f=False
a = 0
for i in range(len(ab)):
    for j in range(min(ab[i][0], n)):
        if A[a]>ab[i][1]:
            f=True
            break
        A[a]=ab[i][1]
        a+=1
        if a==n:
            f=True
            break
    if f==True:break
print(sum(A))
n,a,b=[int(i) for i in input().split()]
x=A*N
if x>=B:
  print(str(B))
else ;
  print(str(x))


### FIXED CODE ###

n,a,b=map(int,input().split())
print(min(n*a,b))
k = int(input())
total = 0

for a in range(1, k + 1):
    for b in range(1, k + 1):
        if gcd(a, b) == 1:
            total += 1 * k
            continue
        else:
            for c in range(1, k + 1):
                total += gcd(a, b, c)
print(total)

### FIXED CODE ###

import math
from functools import reduce

k = int(input())
total = 0

def gcd(*numbers):
    numbers = numbers
    return reduce(math.gcd, numbers)

for a in range(1, k + 1):
    for b in range(1, k + 1):
        if gcd(a, b) == 1:
            total += 1 * k
            continue
        else:
            for c in range(1, k + 1):
                total += gcd(a, b, c)
print(total)
N=input()
count=0
for i in range(N):
  	count+=input()%2
if count>0:
	print("first")
else:
  	print("second")

### FIXED CODE ###

N=int(input())
count=0
for i in range(N):
    count+=int(input())%2
if count>0:
    print("first")
else:
    print("second")
import math
from functools import reduce

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

print(reduce(math.gcd, a))

### FIXED CODE ###

from fractions import gcd
from functools import reduce

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

print(reduce(gcd, a))
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(H: int, W: int, s: "List[str]"):
    n = [[0]*(W+2) for _ in range(H+2)]
    for i in range(H):
        for j in range(W):
            if s[i][j] == "#":
                n[i+1][j+1] = 1  # 外枠を作りつつ

    flag = True
    for i in range(1, H+1):
        for i in range(1, W+1):
            if n[i][j] == 1 and n[i-1][j]+n[i+1][j]+n[i][j-1]+n[i][j+1] == 0:
                flag = False
                break
        if flag == False:
            break
    if flag == False:
        no()
    else:
        yes()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(W)]  # type: "List[str]"
    solve(H, W, s)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(H: int, W: int, s: "List[str]"):
    n = [[0]*(W+2) for _ in range(H+2)]
    for i in range(H):
        for j in range(W):
            if s[i][j] == "#":
                n[i+1][j+1] = 1  # 外枠を作りつつ

    flag = True
    for i in range(1, H+1):
        for j in range(1, W+1):
            # print(i, j)
            if n[i][j] == 1 and n[i-1][j]+n[i+1][j]+n[i][j-1]+n[i][j+1] == 0:
                flag = False
                break
        if flag == False:
            break
    if flag == False:
        no()
    else:
        yes()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(H)]  # type: "List[str]"
    solve(H, W, s)


if __name__ == '__main__':
    main()
s = input().split()
N = int(s[0])
K = int(s[1])

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

H_s = sorted(H, reverse=True)
H_s[:N] = 0

print(sum(H_s))


### FIXED CODE ###

s = input().split()
N = int(s[0])
K = int(s[1])

H = list(map(int, input().split()))
H_s = sorted(H, reverse=True)

print(sum(H_s[K:]))
def resolve():
    n, m = map(int, input().split())

    penalties = 0
    wa_counts = [0] * n
    ac_flags = [0] * n

    for _ in range(m):
        line = input().split()
        q = int(line[0])
        r = line[1]

        if ac_flags[q-1] == 0:
            if r == 'WA':
                wa_counts[q-1] += 1

            else:
                ac_flags[q-1] = 1
                penalties += wa_counts[q-1]

    print(sum(ac_flags), penalties)

resolve()

### FIXED CODE ###

def resolve():
    a = input()

    print(chr(ord(a) + 1))
    
resolve()
K = int(input())
A = list(map(int,input().split()))[::-1] + [1]

# 切り上げ
def ceil(a, b):
    return -(-a//b)

# [a, b) に含まれるcの倍数のうち最小,最大のものを返す
def query(a, b, c):
    l = c * ceil(a, c)
    r = c * (ceil(b, c) - 1)
    if l <= r:
        return True, l, r
    else:
        return False, -1, -1

cand = [2,2]
for i in range(K):
    s, m = cand
    cand = []
    fs, ls, rs = query(s, s+A[i], A[i+1])
    fm, lm, rm = query(m, m+A[i], A[i+1])
    if fs:
        cand.append(ls)
    if fm:
        cand.append(rm)
    if len(cand) == 0:
        print(-1)
        exit()

s, m = cand
print(s, m)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

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

def ceil(a, b):
    return -(-a // b)

def floor(a, b):
    return a // b

def L(i):
    if i == K:
        return 2
    return ceil(L(i+1), A[i]) * A[i]

def R(i):
    if i == K:
        return 2
    return floor(R(i+1), A[i]) * A[i] + A[i] - 1

L0 = L(0); R0 = R(0)
if L0 <= R0:
    print(L0, R0)
else:
    print(-1)
print(f"A{["B", "R"][input()[1] == "B"]}C")

### FIXED CODE ###

print(f"A{['B', 'R'][input() == 'ABC']}C")
def main():
    import sys
    sys.setrecursionlimit(3000000)

    N = int(input())
    A = [[0]*(N)]
    for _ in range(N):
        A.append([0]+list(map(int,input().split())))

    #選手iにとって、選手jが何番目の相手かを逆引きするメモを用意しておく。
    reverseMemo = {i:{} for i in range(1,N+1)}
    for i in range(1,N+1):
        for j in range(1,N):
            a = A[i][j]
            reverseMemo[i][a] = j

    dp = [[0]+[None]*N for _ in range(N+1)]

    def f(i,j,cnt):
        #iとjの試合が最速でいつできるかを返す。
        if cnt > N*N:
            print(-1)
            exit()
        if dp[i][j] == None and dp[j][i] == None:
            #iの一つ前の試合がいつおわるかを調べる。
            pre = A[i][reverseMemo[i][j]-1]
            tmp1 = f(i,pre,cnt+1)
            
            #jの一つ前の試合がいつおわるかを調べる。
            pre = A[j][reverseMemo[j][i]-1]
            tmp2 = f(j,pre,cnt+1)

            dp[i][j] = max(tmp1,tmp2)+1

        elif dp[i][j] == None and dp[j][i] != None:
            dp[i][j] = dp[j][i]
        elif dp[i][j] != None and dp[j][i] != None:
            dp[j][i] = dp[i][j]
        return dp[i][j]

    ans = 0
    cnt = 0
    for i in range(1,N+1):
        for j in range(1,N):
            cnt += 1
            if cnt > 500:
                print("good")
            a = A[i][j]
            ans = max(ans,f(i,a,0))
    print(ans)
main()

### FIXED CODE ###

"""
最長経路問題として解く。

各試合のノードを作成。
各試合ノードごとに、「この試合が終わったら、次はこの試合ができるようになる。」という対応関係を作っていく。
"""
def main():
    import sys
    sys.setrecursionlimit(1000000)
    input = sys.stdin.readline

    N = int(input())

    A = [[0]*(N)]
    for i in range(N):
        A.append([0]+list(map(int,input().split())))
    
    #選手iにとって、選手jが何番目の相手かを逆引きするメモを用意しておく。
    reverseMemo = [[-1]*(N+1) for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(1,N):
            a = A[i][j]
            reverseMemo[i][a] = j
    edges = {}
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            match = (i,j)
            edges[match] = []
            if reverseMemo[i][j] != N-1:
                nx = A[i][reverseMemo[i][j]+1]
                edges[match].append((min(i,nx),max(i,nx)))
            if reverseMemo[j][i] != N-1:
                nx = A[j][reverseMemo[j][i]+1]
                edges[match].append((min(j,nx),max(j,nx)))
    
    del reverseMemo
    del A
    
    stepMemo = {}
    def dfs(i,j,path):
        #i,jの試合日を含めて、あと何日必要なのかを返す。
        if (i,j) not in stepMemo:
            if (i,j) in path:
                print(-1)
                exit()
            else:
                path.add((i,j))
            res = 1
            for a,b in edges[(i,j)]:
                res = max(res,dfs(a,b,path)+1)
            stepMemo[(i,j)] = res
        return stepMemo[(i,j)]

    ans = 0
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if (i,j) not in stepMemo:
                ans = max(ans,dfs(i,j,set()))
    print(ans)
main()
import re
s = imput()

if re.match("(dreamer|dream|eraser|erase)+dreamer",s):
  print("YES")
else:
  print("NO")

### FIXED CODE ###

import re
s = input()

if re.match("(dreamer|dream|eraser|erase)+$",s):
  print("YES")
else:
  print("NO")
mport sys
input = sys.stdin.readline

#input
N, M = map(int, input().split())
s = [0] * M
t = [0] * M
for i in range(M):
    s[i], t[i] = map(int, input().split())

#output
#（便宜的に地点から-1としておく）
u = [[]] * N
for v in s:
    u[v-1] = [t-1 for i, t in enumerate(t) if s[i] == v]

#地点vにたどり着く確率をp[v]とする。
p = [0] * N
p[0] = 1
for i, t in enumerate(u):
    for s in t:
        p[s] += p[i]/len(t)

#期待値をゴールから逆順に求めていく。点vからゴールまでの移動距離の期待値をq[v]とする。
q = [0] * N
q[N-1] = 0
for v in reversed(range(N)):
    for i in u[v]:
        q[v] += (1 + q[i])/len(u[v])

v = [0] * N
for i in range(N):
    a = len(u[i])
    if a > 1:
        b = max([q[c] for c in u[i]])
        v[i] = p[i]*(q[i] - (1+b))/(a-1)

print(q[0]+min(v))


### FIXED CODE ###

import sys
input = sys.stdin.readline

#input
N, M = map(int, input().split())
u = [[] for i in range(N-1)]
#（便宜的に地点から-1としておく）
for i in range(M):
    s, t = map(int, input().split())
    u[s-1].append(t-1)

#output
#地点vにたどり着く確率をp[v]とする。
p = [0] * N
p[0] = 1
for x, y in enumerate(u):
    for z in y:
        p[z] += p[x]/len(y)

#期待値をゴールから逆順に求めていく。点vからゴールまでの移動距離の期待値をq[v]とする。
q = [0] * N
q[N-1] = 0
for x, y in list(enumerate(u))[::-1]:
    q[x] = sum(q[z] for z in y)/len(y) + 1

v = [0] * N
for i in range(N-1):
    a = len(u[i])
    if a > 1:
        b = max(q[c] for c in u[i])
        v[i] = p[i]*(q[i] - (1+b))/(a-1)

print(q[0]+min(v))
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr
 
    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0
 
    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right
n=input()
S=map(int,input().split())
S=quick_sort(S)
word=int(int(n)/2)
s=int(S[word])-int(S[word-1])
s2=int(S[word+1])-int(S[word])
print(s)

### FIXED CODE ###

import numpy as np
n=input()
S=[]
for i in input().split():
    S.append(int(i))
S=np.array(S)
word=int(int(n)/2)
asa=S.argsort()
s=int(S[asa[word]])-int(S[asa[word-1]])
print(s)
I = input()
K = ['Sunny', 'Cloudy,''Rainy', 'Sunny']
Idx = K.index(I)
print(K[idx+1])


### FIXED CODE ###

I = input()
K = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']
Idx = K.index(I)
print(K[Idx+1])
n,w = map(int,input().split())
wv=[]
for i in range(n):
  w,v=map(int,input().split())
  wv.append([w,v])

dp=[[0 for i in range(w+1)]for j in range(n+1)]
for i in range(1,n+1):
  for j in range(1,w+1):
    if j-h[i]<0:
      dp[i][w]=dp[i-1][w]
    else:
      dp[i][w]=max(dp[i-1][w-wv[i][0]],dp[i-1][w])

print(dp[n][w])

### FIXED CODE ###

n,w=map(int,input().split())
P=[]
for _ in range(n):
  iw,iv=map(int,input().split())
  P.append([iw,iv])
INF=float('inf')
 
dp=[[0 for i in range(w+1)] for j in range(n+1)]
 
for i in range(1,n+1):
  for j in range(1,w+1):
    if j-P[i-1][0]>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-P[i-1][0]]+P[i-1][1])
    else:
      dp[i][j]=dp[i-1][j]
print(dp[n][w])
l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!max:
  if l[i]<l[i+1]:
    pass
  else:
    d=d+abs(l[i+1]-l[i])
  i=i+1
r=i
else:
  for b in range(r,len(l)):
    d=d+(u-l[b])
print(d)


### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!=u:
  if l[i]>l[i+1]:
    d=d+abs(l[i+1]-l[i])
    l[i+1]=l[i] 
  i=i+1
r=i
for b in range(r,n):
    d=d+(u-l[b])
print(d)
n = int(input())
ac, wa, tle, re = 0, 0, 0, 0
for i in range(n):
	a = input().strip()
    if a == 'AC': ac+=1
    elif a == 'WA': wa += 1
    elif a == 'TLE': tle += 1
    elif a == 'RE': re += 1
print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}")

### FIXED CODE ###

import sys; input = sys.stdin.readline
n = int(input())
ac, wa, tle, re = 0, 0, 0, 0
for i in range(n):
    a = input().strip()
    if a == 'AC': ac+=1
    elif a == 'WA': wa += 1
    elif a == 'TLE': tle += 1
    elif a == 'RE': re += 1
print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}")
import sys
from heapq import heappush, heappop
n,q=map(int,input().split())
a=sorted(((s-x, t-x, x) for _ in range(n) for s, t, x in (map(int, sys.stdin.readline().split()),)), reverse=True)
heap=[]
ans=[]
z=list(map(int,sys.stdin))
for d in z:
  d=int(input())
  while a and a[-1][0]<=d:
    e=a.pop()
    heappush(heap,(e[2],e[1]))
  while heap and heap[0][1]<=d:
    heappop(heap)
  if heap:
    ans.append(heap[0][0])
  else:
    ans.append(-1)

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



### FIXED CODE ###

import sys
from heapq import heappush, heappop
n,q=map(int,input().split())
a=sorted(((s-x, t-x, x) for _ in range(n) for s, t, x in (map(int, sys.stdin.readline().split()),)), reverse=True)
heap=[]
ans=[]
for i in range(q):
  d=int(input())
  while a and a[-1][0]<=d:
    e=a.pop()
    heappush(heap,(e[2],e[1]))
  while heap and heap[0][1]<=d:
    heappop(heap)
  if heap:
    ans.append(heap[0][0])
  else:
    ans.append(-1)

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

n = int(input())
a = [int(input()) for i in range(n)]
b = heapq.nlargest(2, set(a))
c = [i for i, x in enumerate(a) if x == b[0]] #最大値の位置

for i in range(n):
    if i in c: #最大値だったら
        print(b[1]) #最大値から2番目を出力
    else: #そうでなければ
        print(b[0]) #最大値を出力

### FIXED CODE ###

import heapq

n = int(input())
a = [int(input()) for i in range(n)]
b = heapq.nlargest(2, set(a))
c = a.count(b[0])

if len(b) == 1 or c > 1: #bの長さが1または、最大値が2回以上存在するなら
    for i in range(n):
        print(b[0]) #最大値のみを表示

else: #bの長さが2以上なら
    for i in range(n):
        if a[i] == b[0]: #i番目が最大値だったら
            print(b[1]) #2番目に大きい値を出力
        else: #そうでなければ
            print(b[0]) #最大値を出力
n = int(input())
num = [int(i) for i in input().split()]
print("{} {} {}".format(mix(num),max(num),sum(num))



### FIXED CODE ###

n = int(input())
s=0
num = [int(i) for i in input().split()]
mx = num[0]
mn = num[0]
for i in range(n):
        s = s+num[i]
        if(mx < num[i]):
            mx = num[i]
        if(mn > num[i]):
            mn = num[i]
print("{} {} {}".format(mn,mx,s))
def main():
    with open('./input/input.txt') as f:
        W, H, x, y = map(int, f.input().split())
    ans = W * H / 2
    num = 1 if (2*x == W and 2*y == H) else 0
    print(ans, num)

  
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    W, H, x, y = map(int, input().split())
    ans = W * H / 2
    num = 1 if (2*x == W and 2*y == H) else 0
    print(ans, num)
if __name__ == '__main__':
    main()
N,K = int(input().split())
h = [int(input()) for i in range(N)]
r = 0
for j in range(N):
  if h[j] >= K:
    r += 1
print(r)

### FIXED CODE ###

N,K = list(map(int, input().split()))
h = list(map(int, input().split()))
r = 0
for j in range(N):
  if int(h[j]) >= K:
    r += 1
print(r)
import functools
import math

n, x = map(int, input().split())
a = [int(i) for i in input().split()]

a.append(x)
a.sort()

for i in range(len(a)):
  a[i] = abs(a[i] - x)

gcd = functools.reduce(math.gcd, a)
print(gcd)

### FIXED CODE ###

import functools
import fractions

n, x = map(int, input().split())
a = [int(i) for i in input().split()]

a.append(x)
a.sort()

for i in range(len(a)):
  a[i] = abs(a[i] - x)

gcd = functools.reduce(fractions.gcd, a)
print(gcd)
S = int(input())
h = 46979 / 3600
m = 46979 % 3600 /60
s = 46979 % 3600 % 60
print(h,m,s,sep=':' end='')

### FIXED CODE ###

S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 3600 % 60
print(h,m,s,sep=':')
S = list(set(list(input())))
S.sort()
al = 'abcdefghijklmnopqrstuvwxyz'
if len(S)==26:
  ans = 'None'
else:
  for i in range(len(al)):
    if al[i] != S[i]:
      ans = al[i]
      break
print(ans)

### FIXED CODE ###

S = list(set(list(input())))
S.sort()
al = 'abcdefghijklmnopqrstuvwxyz'
if len(S)==26:
  ans = 'None'
else:
  for i in range(len(S)):
    if al[i] != S[i]:
      ans = al[i]
      break
    else:
      ans = al[len(S)]
print(ans)
from math import gcd
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
    
    
a, b = map(int,input().split())
a_d = make_divisors(a)
b_d = make_divisors(b)

yakusu = []

for i in a_d:
    if i in b_d:
        yakusu.append(i)

ans = [yakusu.pop(0)]
for i in yakusu:
    flg=0
    tmp = 0
    for j,num in enumerate(ans):
        if gcd(num,i) != 1:
            ans[j] = min(i,num)
            flg = 1
            break
    if flg == 0:
        ans.append(i)

print(len(ans))



### FIXED CODE ###

from fractions import gcd
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
    
    
a, b = map(int,input().split())
a_d = make_divisors(a)
b_d = make_divisors(b)

yakusu = []

for i in a_d:
    if i in b_d:
        yakusu.append(i)

ans = [yakusu.pop(0)]
for i in yakusu:
    flg=0
    tmp = 0
    for j,num in enumerate(ans):
        if gcd(num,i) != 1:
            ans[j] = min(i,num)
            flg = 1
            break
    if flg == 0:
        ans.append(i)

print(len(ans))
import copy
n,hp=map(int,input().split(" "))
la=[0 for i in range(n)]
lb=[0 for i in range(n)]
for i in range(n):
    la[i],lb[i]=map(int,input().split(" "))
cnt=0
ma=max(la)
lma=[i for i ,x in enumerate(la)  if x==ma]
mib=10**9
for i in lma:
    if lb[i]<mib:
        mib=lb[i]
        k=i
tmp=copy.deepcopy(lb)
while max(tmp)>ma:
    hp-=max(tmp)
    tmp.remove(max(tmp))
    cnt+=1
    if hp<0:
        print(cnt)
        exit(0)
if lb[k]>ma:
    hp+=lb[k]
if lb[k]>ma:
    hp-=lb[k]
    cnt+=1
if hp%ma==0:
    print(cnt+int(hp/ma))
else:
    print(cnt+int(hp/ma)+1)

### FIXED CODE ###

N,H=map(int,input().split())
ab=[]
a=[]
b=[]

for i in range(N):
    ab.append(list(map(int,input().split())))
    a.append(ab[i][0])
    b.append(ab[i][1])

a.sort(reverse=True)
b.sort(reverse=True)
k=0
cnt=0

while a[0]<b[k]:
    H-=b[k]
    cnt+=1
    if H<=0:
        break
    k+=1
    if k==len(b):
        break

#print(cnt,H)
H=max(H,0)

if H%a[0]==0:
    cnt+=H//a[0]
else:
    cnt+=H//a[0]+1

print(cnt)
a,b,k = map(int,input().split())
n = list(range(a,b+1))
n.sort
if 2*k >= len(n):
    for i in n:
        print(i)
else:
    a = []
    a.extend(n[:k])
    a.extend(n[-k:])
    for i in a:
        print(i)

### FIXED CODE ###

a,b,k = map(int,input().split())
ans = []
if 2*k <= b-a+1:
    for i in range(k):
        ans.append(a+i)
        ans.append(b-i)
    ans = list(set(ans))
    ans = sorted(ans)
    for i in ans:
        print(i)
else:
    for i in range(a,b+1):
        print(i)
N=int(input())
A=list(map(int,input().split()))
B=A.copy()
counter=0
for num in range(N):
  if A[num] in B:
    counter+=1
    while A[num] in B:
      B.remove(A[num])
print(counter)

### FIXED CODE ###

N=int(input())
z=[]
for num in range(101):
  z.append(0)
counter=0
while counter < N:
  d=int(input())
  z[d]=1
  counter+=1
result=sum(z)
print(result)
N = int(input())
lst = []
for i in range(1,10):
	for k in range(1, 10):
		m = i * k
    	lst.append(m)
if N in lst:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

N = int(input())
lst = []
for m in range(1, 10):
	for n in range(1, 10):
		q = m * n
		lst.append(q)
if N in lst:
	print('Yes')
else:
	print('No')
k = int(input())
s = input()
if len(s) <= k:
  print(s)
else:
  ns = s[:k]
  print(ns + "...")

### FIXED CODE ###

n = list(input())
l = n[-1]
if l == "3":
  print("bon")
elif l == "0" or l == "6" or l == "1" or l == "8":
  print("pon")
else:
  print("hon")
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np
 
DIV_NUM = 1000000000 + 7
 
INPUT_NUMS = list(map(int, input().split()))
N=int(INPUT_NUMS[0])
K=int(INPUT_NUMS[1])
 
A = [int(x) for x in input().split()]
AA = np.array(A)
if N==1:
    print(0)
    exit()
 
tree = np.array([0] * (N+1) )
 
# https://atcoder.jp/contests/chokudai_S001/submissions/6789704
def BIT_update(tree,x):
    while x <= N:
        tree[x] += 1
        y = int(x)
        x += y&(-y)
def BIT_sum(tree,x):
    s = 0
    while x:
        s += tree[x]
        y = int(x)
        x -= y&(-y)
    return s
 
answer = N*(N-1)//2
for x in AA:
    answer -= BIT_sum(tree,int(x))
    BIT_update(tree,int(x))
 
B = sorted(A)
 
q=0
p=B[0]
r=0
for i in range(1,N):
    if B[i]>p:
        p=B[i]
        r=i
    q += r
 
# print(answer,K)
answer = answer % DIV_NUM
answer = int(answer)
answer = (answer * K) % DIV_NUM
q = q % DIV_NUM
answer = answer + q * K * (K-1) // 2
answer = answer % DIV_NUM
print(answer)
 

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

DIV_NUM = 1000000000 + 7

INPUT_NUMS = list(map(int, input().split()))
N=int(INPUT_NUMS[0])
K=int(INPUT_NUMS[1])

A = [int(x) for x in input().split()]
AA = np.array(A)
if N==1:
    print(0)
    exit()

# https://kira000.hatenadiary.jp/entry/2019/02/23/053917
def bubble_sort(A):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(A)-1, i, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
    return cnt

answer = bubble_sort(AA)

B = sorted(A)
q=0
p=B[0]
r=0
for i in range(1,N):
    if B[i]>p:
        p=B[i]
        r=i
    q += r

# print(answer,K)
answer = answer % DIV_NUM
answer = int(answer)
answer = (answer * K) % DIV_NUM
q = q % DIV_NUM
answer = answer + q * K * (K-1) // 2
answer = answer % DIV_NUM
print(answer)
cnds = [int(i) for i in input().split()]

posX = [int(i) for i in input().split()]
posY = [int(i) for i in input().split()]
posX.sort()
posY.sort()

max_x = posX[-1]
min_y = posY[0]
if cnds[2] < cnds[3]:
    if max_x < max_y:
        print('No War')
    else:
        print('War')
else:
    print('War')





### FIXED CODE ###

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

posX = [int(i) for i in input().split()]
posY = [int(i) for i in input().split()]
posX.sort()
posY.sort()

max_x = posX[-1]
min_y = posY[0]
if cnds[2] < cnds[3]:
    if max_x < min_y and cnds[2] < min_y and max_x < cnds[3]:
        print('No War')
    else:
        print('War')
else:
    print('War')