Harryxun/stf_run huggingface dataset:
class Union_Find():
  def __init__(self, n):
    self.par = [-1] * n
  def root(self, x):
    if self.par[x] < 0:
      return x
    else:
      self.par[x] = root(par[x])
      return self.par[x]
  def unite(self, x, y):
    root_x = self.root(x)
    root_y = self.root(y)
    if root_x == root_y:
      pass
    else:
      self.par[root_x] = root_y
  def same(self, x, y):
    root_x = self.root(x)
    root_y = self.root(y)
    return root_x == root_y
  def count_size(self, x):
    # 根を共有している要素の数を数える。
    return self.par.count(self.root(x))
 
N, M = list(map(int, input().split()))
uf = Union_Find(N)
bridge_list = []
inconv_list = [0] * (M + 1)
inconv_list[0] = N * (N - 1) //2
for _ in range(M):
  a, b = list(map(int, input().split()))
  bridge_list.append((a-1, b-1))
bridge_list.reverse()
for i in range(M):
  x, y = bridge_list[i]
  if uf.same(x, y):
    inconv_list[i+1] = inconv_list[i]
  else:
    Nx = uf.count_size(x)
    Ny = uf.count_size(y)
    inconv_list[i+1] = inconv_list[i] - Nx * Ny
    uf.unite(x, y)
 
inconv_list.sort()  
 
for i in range(1, M+1):
  print(inconv_list[i])

### FIXED CODE ###

class Union_Find():
  def __init__(self, n):
    self.par = list(range(n))
    self.size = [-1] * n
    self.rank = [0] * n
  def root(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  def unite(self, x, y):
    root_x = self.root(x)
    root_y = self.root(y)
    if root_x == root_y:
      pass
    else:
      if self.rank[root_x] > self.rank[root_y]:
        self.par[root_y] = root_x
        self.rank[root_x] += 1
        self.size[root_x] += self.size[root_y]
      else:
        self.par[root_x] = root_y
        self.rank[root_y] += 1
        self.size[root_y] += self.size[root_x]
        
        
  def same(self, x, y):
    root_x = self.root(x)
    root_y = self.root(y)
    return root_x == root_y
  def count_size(self, x):
    # 根を共有している要素の数を数える。
    return self.size[self.root(x)]
 
N, M = list(map(int, input().split()))
uf = Union_Find(N)
bridge_list = []
inconv_list = [0] * (M + 1)
inconv_list[0] = N * (N - 1) //2
for _ in range(M):
  a, b = list(map(int, input().split()))
  bridge_list.append((a-1, b-1))
bridge_list.reverse()
for i in range(M):
  x, y = bridge_list[i]
  if uf.same(x, y):
    inconv_list[i+1] = inconv_list[i]
  else:
    Nx = uf.count_size(x)
    Ny = uf.count_size(y)
    inconv_list[i+1] = inconv_list[i] - Nx * Ny
    uf.unite(x, y)
 
inconv_list.sort()  
 
for i in range(1, M+1):
  print(inconv_list[i])
n1, n2, n3 = map(int, input().split())
n = [n1, n2, n3]
if 7 in n:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = list(input())
n = list(map(int, n))
if 7 in n:
    print('Yes')
else:
    print('No')
def factors(z):
    ret = []
    for i in range(2, int(z**(1/2))+1):
        if z%i == 0:
            ret.append(i)
            while z%i == 0:
                z //= i
    if z != 1:
        ret.append(z)
    return ret

def eratosthenes(N):
    from collections import deque
    work = [True] * (N+1)
    work[0] = False
    work[1] = False
    ret = []
    for i in range(N+1):
        if work[i]:
            ret.append(i)
            for j in range(2* i, N+1, i):
                work[j] = False
    return ret

N = int( input())
A = [ int( input()) for _ in range(N+1)]
Primes = eratosthenes(N)
ANS = []
F = factors( abs(A[0]))
for f in F:
    if f >= N+1:
        Primes.append(f)
for p in Primes:
    if p >= N+1:
        check = 1
        for i in range(N+1): # f が恒等的に 0 であるかどうかのチェック
            if A[i]%p != 0:
                check = 0
                break
        if check == 1:
            ANS.append(p)
    else:
        poly = [0]*(p-1)
        for i in range(N+1): # フェルマーの小定理
            poly[(N-i)%(p-1)] = (poly[(N-i)%(p-1)] + A[i])%p
        check = 0
        if sum(poly) == 0 and A[N]%p == 0: # a_0 が 0 かつ、g が恒等的に 0 であることをチェックしている
            check = 1
        if check == 1:
            ANS.append(p)
for ans in ANS:
    print(ans)

### FIXED CODE ###

def factors(z):
    ret = []
    for i in range(2, int(z**(1/2))+1):
        if z%i == 0:
            ret.append(i)
            while z%i == 0:
                z //= i
    if z != 1:
        ret.append(z)
    return ret

def eratosththenes(N):
    if N == 0:
        return [0]
    work = [True] * (N+1)
    work[0] = False
    work[1] = False
    for i in range(N+1):
        if work[i]:
            for j in range(2* i, N+1, i):
                work[j] = False
    return work


N = int( input())
A = [ int( input()) for _ in range(N+1)]
E = eratosththenes(N)
Primes = [ i for i in range(N+1) if E[i] == 1]
ANS = []
F = factors( abs(A[0]))
for f in F:
    if f >= N+1:
        Primes.append(f)
for p in Primes:
    if p >= N+1:
        check = 1
        for i in range(N+1):
            if A[i]%p != 0:
                check = 0
                break
        if check == 1:
            ANS.append(p)
    else:
        poly = [0]*(p-1)
        for i in range(N+1):
            poly[(N-i)%(p-1)] = (poly[(N-i)%(p-1)] + A[i])%p
        check = 1
        if sum(poly) != 0 or A[N]%p != 0:
            check = 0
        if check == 1:
            ANS.append(p)
for ans in ANS:
    print(ans)
n = int(input())


queueList = []
oldList = []
for i in range(1,10):
	queueList.append(i)
# print(queueList)
if n < len(queueList):
	print(queueList[n-1])
	exit()
while(True):
	headElement = queueList[0]
	queueList.pop(0)
	oldList.append(headElement)
	for i in range(-1,2):
		newElement = headElement % 10 + i
		if newElement < 0 or 9 < newElement:
			continue
		if not (headElement*10 + newElement in oldList or headElement*10 + newElement in queueList):
			queueList.append(headElement*10 + newElement)
	if len(oldList) == n:
		break
print(oldList[-1])
# print(queueList[0])





### FIXED CODE ###

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

print("{} {} {}".format(c,a,b))
mod=10**9+7
N,K=map(int,input().split())
gcd=[0]*(K+1)
ans=0
multipleNumber=0
for i in reversed(range(1,K+1)):
    multipleNumber=K//i
    totalNumber=multipleNumber**N%mod
    minus=range(2*i,K+1,i)
    for j in minus:
        totalNumber-=gcd[j]
        totalNumber%=mod
    gcd[i]=totalNumber
    ans+=i*gcd[i]
print(ans%a)

### FIXED CODE ###

mod=10**9+7
N,K=map(int,input().split())
d=[0]*(K+1)
ans=0
for i in range(1,K+1):
    d[i]=pow(K//i,N,mod)
for i in range(K,0,-1):
    for j in range(2*i,K+1,i):
        d[i]-=d[j]
        d[i]%=mod
    ans+=d[i]*i
    ans%=mod
print(ans)
# coding: UTF-8
import math
N=int(input())
a=int(input())
for i in range(N-1):
    b=int(input())
    c=math.gcd(a, b)
    a=a*b/c
print(int(a))

### FIXED CODE ###

# coding: UTF-8
from fractions import gcd
N=int(input())
a=int(input())
for i in range(N-1):
    b=int(input())
    a=a*b//gcd(a, b)
print(int(a))
N=int(input())
temp=input().split()
A=[int(temp[i]) for i in range(N)]

A=[A[-1]]+A[:-1]
result=[]
for i in range(N):
  result.append(mean(A[i:i+2]))
  
print(result)

### FIXED CODE ###

N=int(input())
temp=input().split()
A=[int(temp[i]) for i in range(N)]
As=[]
As.append(sum([A[i]*pow(-1, i) for i in range(N)]))
for i in range(1, N):
  As.append(A[i-1]-As[i-1])

x1=As[0]/2
print(int(2*x1), end=' ')

for i in range(1, N):
  print(2*int(As[i]-x1*pow(-1, i)), end=' ')
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'



int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
//     int t;
//      cin >> t;

//      while(t--){



// }
     uint64_t linf = 1e18;
  	int n;
  	cin >> n;
  	int arr[n];
  	fo(i,0,n)cin >> arr[i];
  	sort(arr,arr+n);
  	uint64_t res = 1;
  	int flag = 1;
  	fo(i,0,n){
  		if(res*arr[i] > linf){
  			flag = 0;
  			break;
  		}
  		res = res*arr[i];
  	}
  	if(flag)cout << res << endl;
  	else cout << -1 << endl;


return 0;
}




### FIXED CODE ###

n = int(input())
arr = list(map(int,input().split()))
res = 1
flag = 1
arr.sort()
inf = int(1e18)
for i in range(n):
  res = res*arr[i]
  if(res > inf):
    flag = 0
    break
 
if(flag == 0):
  print(-1)
else:
  print(res)
import sys
import collections
import math
import sympy

def main():

    input = sys.stdin.readline

    N = int(input())
    A = sorted(list(map(int,input().split())))[::-1]

    ans = A[0]

    count = 2

    for i in range(1,N):
        count += 1
        ans += A[i]

        if count >= N:
            break

        count += 1
        ans += A[i]

        if count >= N:
            break

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def main():

    input = sys.stdin.readline

    N = int(input())
    A = sorted(list(map(int,input().split())))[::-1]

    ans = A[0]

    count = 2

    if count >= N:
        print(ans)
        return


    for i in range(1,N):
        count += 1
        ans += A[i]

        if count >= N:
            break

        count += 1
        ans += A[i]

        if count >= N:
            break

    print(ans)

if __name__ == "__main__":
    main()
N,T=list(map(int, input().split()))
a=10**5
for _ in range(N):
  c,t=list(map(int, input().split()))
  if t<=T:
    a=min(c.a)
if a==10**5:
  print('TLE')
else:
  print(c)

### FIXED CODE ###

N,T=list(map(int, input().split()))
a=10**5
for _ in range(N):
  c,t=list(map(int, input().split()))
  if t<=T:
    a=min(c,a)
if a==10**5:
  print('TLE')
else:
  print(a)
a=input()
b=input()
print(max(a-b,0))

### FIXED CODE ###

a, b = map(int, raw_input().split())
print max(a - b, 0)
_,b,_=input().split('/')
print("Heisei"if b<5 else"TBD")

### FIXED CODE ###

_,b,_=input().split('/')
print("Heisei"if int(b)<5 else"TBD")
import itertools
N, a, b, c = [int(_) for _ in input().split()]
L = [int(input()) for _ in range(N)]
ans = 10**10
for K in itertools.product(range(4), repeat=N):
    A = [[] for _ in range(N)]
    for i in range(N):
        A[K[i]] += [L[i]]
    if len(A[1]) and len(A[2]) and len(A[3]):
        cost = 10 * (N - len(A[0]) - 3)
        cost += abs(a - sum(A[1]))
        cost += abs(b - sum(A[2]))
        cost += abs(c - sum(A[3]))
        ans = min(cost, ans)
print(ans)


### FIXED CODE ###

import itertools
N, a, b, c = [int(_) for _ in input().split()]
L = [int(input()) for _ in range(N)]
ans = 10**10
for K in itertools.product(range(4), repeat=N):
    A = [[] for _ in range(4)]
    for i in range(N):
        A[K[i]] += [L[i]]
    if len(A[1]) and len(A[2]) and len(A[3]):
        cost = 10 * (N - len(A[0]) - 3)
        cost += abs(a - sum(A[1]))
        cost += abs(b - sum(A[2]))
        cost += abs(c - sum(A[3]))
        ans = min(cost, ans)
print(ans)
N, T = map(int, input().split())
mn = 1000
for i in range(N):
  c,t = map(int, input().split())
  if t <= T:
	mn = min(c,mn)
print(mn)

### FIXED CODE ###

N, T = map(int, input().split())
mn = 1001
for i in range(N):
  c,t = map(int, input().split())
  if t <= T:
    mn = min(c,mn)
print(mn if mn < 1001 else 'TLE')
x = input()

y = x**3

print int(y)

### FIXED CODE ###

x = input()
print(int(x) ** 3)
a,b = list(map(int,input().split()))
print(a*a-b)

### FIXED CODE ###

a = int(input())
b = int(input())
print(a*a-b)
c = int(input())
print("vowel" if c in "aiueo" else "consonant")


### FIXED CODE ###

c = input()
if c in 'aiueo':
  print('vowel')
else:
  print('consonant')
import math
n, k = map(int, input().split())
ans = 0
for i in range(n):
    a = max(math.ceil(math.log2(k/(i+1))), 0)
    ans += 1/(n*2**a)
print(ans)


### FIXED CODE ###

import math
n, k = map(int, input().split())
ans = 0
for i in range(n):
    a = max(math.ceil(math.log2(k/(i+1))), 0)
    ans += 0.5**a
print(ans/n)
## coding: UTF-8
#from math import gcd 旧環境でこれを有効化するとREを吐きます
 
H,W = map(int,input().split())

c = []
#c.append(['w']*(W+2))
for i in range(H):
    c.append(list(input()))
#c.append(['w']*(W+2))
 
 
 
 
#queue = [start]
next_list = [] #次の歩数で探すものを格納しておく
step = 1
#mode = 0
#answer_mode = 0
status = True #ゴール判定でゴールについていたらFalseにする
#answer = -1
 
queue = []
for i in range(H+2):
    for j in range(W+2):
        if(c[i][j] == '#'):
            queue.append([i, j])

print(-1)

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    h,w = map(int,input().split())
    a = []
    for i in range(h):
        inp = list(input())
        a.append(inp)
    
    dp = [[10**9]*w for i in range(h)]
    
    for i in range(h):
        for j in range(w):
            if a[i][j] == '.' and [i,j] != [0,0]:
                if i >= 1:
                    dp[i][j] = dp[i-1][j]+1
                    if j >= 1:
                        dp[i][j] = min(dp[i][j],dp[i][j-1]+1)
                else:
                    dp[i][j] = dp[i][j-1]+1
            elif a[i][j] == '#':
                dp[i][j] = 0
    for i in range(h):
        for j in range(w-1,-1,-1):
            if a[i][j] == '.' and [i,j] != [0,w-1]:
                if i >= 1:
                    dp[i][j] = min(dp[i-1][j]+1,dp[i][j])
                    if j+1 <= w-1:
                        dp[i][j] = min(dp[i][j],dp[i][j+1]+1)
                else:
                    dp[i][j] = min(dp[i][j+1]+1,dp[i][j])
    for i in range(h-1,-1,-1):
        for j in range(w):
            if a[i][j] == '.' and [i,j] != [h-1,0]:
                if i+1 <= h-1:
                    dp[i][j] = min(dp[i+1][j]+1,dp[i][j])
                    if j >= 1:
                        dp[i][j] = min(dp[i][j],dp[i][j-1]+1)
                else:
                    dp[i][j] = min(dp[i][j-1]+1,dp[i][j])
    for i in range(h-1,-1,-1):
        for j in range(w-1,-1,-1):
            if a[i][j] == '.' and [i,j] != [h-1,w-1]:
                if i+1 <= h-1:
                    dp[i][j] = min(dp[i+1][j]+1,dp[i][j])
                    if j+1 <= w-1:
                        dp[i][j] = min(dp[i][j],dp[i][j+1]+1)
                else:
                    dp[i][j] = min(dp[i][j+1]+1 ,dp[i][j])
        
    res = -1
    for i in range(h):
        for j in range(w):
            res = max(res,dp[i][j])

    print(res)



if __name__ == '__main__':
    main()
import sys
input = sys.stdin.readline

N = int(input())
C = [int(input()) for _ in range(N)]+[-1]
l = []

for i in range(N):
    if C[i]!=C[i+1]:
        l.append(C[i])

dp = [0]*(len(l))
acc = [0]*(2*10**5+100)
dp[0] = 1
acc[l[0]] = 1
acc[l[1]] = 1
MOD = 10**9+7

for i in range(1, len(l)):
    dp[i] = acc[l[i]]
    
    if i<len(l)-1:
        acc[l[i+1]] += dp[i]
        acc[l[i+1]] %= MOD

print(dp[-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
C = [int(input()) for _ in range(N)]+[-1]
l = []

for i in range(N):
    if C[i]!=C[i+1]:
        l.append(C[i])

if len(l)==1:
    print(1)
    exit()
    
dp = [0]*(len(l))
acc = [0]*(2*10**5+100)
dp[0] = 1
acc[l[0]] = 1
acc[l[1]] = 1
MOD = 10**9+7

for i in range(1, len(l)):
    dp[i] = acc[l[i]]
    
    if i<len(l)-1:
        acc[l[i+1]] += dp[i]
        acc[l[i+1]] %= MOD

print(dp[-1])
N = int(input())
S = input()
if N%2 == 1: print("No")
elif S[:N/2] == S[N/2:]:print("Yes")
else: print("No")

### FIXED CODE ###

N = int(input())
S = input()
if N%2 == 1: print("No")
else:
    n=int(N/2)
    if S[:n]==S[n:] :print("Yes")
    else:print("No")
N = int(input())
s = 0
while N//10 > 0
    a = N % 10
    s += a
    N = N // 10
if N % s == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())
n = N
s = 0
for i in range(10):
    a = n % 10
    s += a
    if n // 10 == 0:
        break
    else:
        n = n // 10
if N % s == 0:
    print("Yes")
else:
    print("No")
s = input()
ans = 0
alst = []
for i in s:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        ans += 1
    else:
        alst.append(ans)
        ans = 0
        continue

print(max(alst))

### FIXED CODE ###

s = input()
a = 0
b = 0
for i in s:
    if i in 'ATGC':
        a += 1
    else:
        b = max(a, b)
        a = 0
print(max(a, b))
n=int(input())
s=[int(x) for x in input().split()]
s.sort()
a=s[0]
b=s[-1]
m=9999999999999
for i in range(a,b+1):
    sum=0    
    for j in s:
        sum+=(j-i)**2
    if sum < m:
        m=sum
        
print(m)

### FIXED CODE ###

n=int(input())
print(n*(n+1)//2)
a=int(input().split())
b=int(input().split())
c=int(input().split())

print(int((a+b)*c/2))

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())

print(int((a+b)*c/2))
a = input().strip().split()
ans = []
for i in range(3):
    ans.append(a[i][i])
re = "".join(ans)
print(re)

### FIXED CODE ###

ans = []
for i in range(3):
    a = input()
    ans.append(a[i])
re = "".join(ans)
print(re)
from math import factorial
import bisect
def cmb(n,r):
  if n<0 or r<0:
    return 0
  else:
    return factorial(n)//factorial(n-r)//factorial(r)
n,a,b=map(int,input().split())
x = list(map(int,input().split()))
ans=0
x.sort(reverse=True)
print(sum(x[:a])/a)
if x[0]==x[a]:
  for i in range(n):
    if x[0] != x[i]:
      k=i
      break
  else:
    k=n
  for i in range(a,b+1):
    ans+=cmb(k,i)
  print(ans)
elif x[a-1] == x[a]:
  y=sorted(x)
  x1=bisect.bisect_left(y,x[a])
  x2=bisect.bisect_right(y,x[a])
  print(cmb(x2-x1,a-(n-x2)))
else:
  print(1)

### FIXED CODE ###

from math import factorial
import bisect
def cmb(n,r):
  if n<0 or r<0:
    return 0
  else:
    return factorial(n)//factorial(n-r)//factorial(r)
n,a,b=map(int,input().split())
x = list(map(int,input().split()))
ans=0
x.sort(reverse=True)
print(sum(x[:a])/a)
if n==a:
  print(1)
elif x[0]==x[a]:
  for i in range(n):
    if x[0] != x[i]:
      k=i
      break
  else:
    k=n
  for i in range(a,min(k+1,b+1)):
    ans+=cmb(k,i)
  print(ans)
elif x[a-1] == x[a]:
  y=sorted(x)
  x1=bisect.bisect_left(y,x[a])
  x2=bisect.bisect_right(y,x[a])
  print(cmb(x2-x1,a-(n-x2)))
else:
  print(1)
a,b,c=map(int, input().split())
list = [a,b,c]
s = 0
for i in range (3):
	if list[i] == 1:
		s += 1
print(s)

### FIXED CODE ###

print(list(input()).count("1"))
N, K = map(int, input().split())

d = []
l = []
i = 0

while i <= 2*K:
  i += 1
  if i % 2 == 1:
    d.append(input())
  else:
    l.appemd(input())

L = set(l)
print(K - len(L))

### FIXED CODE ###

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

d = []
l = []
i = 0

while i < 2*K:
  i += 1
  if i % 2 == 0:
    l.extend([int(x) for x in input().split()])
  else:
    d.append(int(input()))

L = list(set(l))
print(N - len(L))
def resolve():
    n = int(input())
    heights = list(map(int, input().split()))
    dp = [-1] * n
    dp[0] = 0

    print(jump(n - 1, heights, dp))

# i番目の足場にたどり着いたときの、コストの最小値を返す関数
def jump(i, heights, dp):
    # 足場 0 のコスト
    if i <= 0:
        return 0

    else:
        if dp[i] != -1:
            return dp[i]
        res = jump(i - 1, heights, dp) + abs(heights[i] - heights[i - 1])
        
        if i > 1:
            res = min(res, jump(i - 2, heights, dp) + abs(heights[i] - heights[i - 2]))
        dp[i] = res
        
        return res

resolve()

### FIXED CODE ###

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

dp = [float('inf')] * n

dp[0] = 0

for i in range(1, n):

  dp[i] = min(dp[i], dp[i-1] + abs(li[i] - li[i-1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i-2] + abs(li[i] - li[i-2]))

print(dp[n - 1])
N = 10000 - int(input())
if N % 1000 == 0:
    print(0)
ans = [str(x) for x in list(str(N))]
print(ans[-3]+ans[-2]+ans[-1])

### FIXED CODE ###

N = int(input())
if N % 1000 == 0:
    print(0)
else:
    print(1000 - (N % 1000))
n,m,k = map(int, input().split())
mod = 998244353

def modconb(n,k,mod):
    # テーブルを作る
    fac = [0]*(n+1)
    finv = [0]*(n+1)
    inv = [0]*(n+1)  

    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,n+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] %mod
    # 計算
    if n<k: return 0
    if n<0 or k<0: return 0
    
    modcombs = [1]
    for k in range(1,n+1):
        modcombs.append(fac[n]*(finv[k]*finv[n-k]%mod)%mod)
    return modcombs

mods = modconb(n-1,n-1,mod)
# print(mods)
cnt = 0
for i in range(k+1):
    cnt += m*mods[i]*pow(m-1,n-i-1,mod)
    cnt %= mod
print(cnt)

### FIXED CODE ###

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

def modconb(n,k,mod):
    # テーブルを作る
    fac = [0]*(n+1)
    finv = [0]*(n+1)
    inv = [0]*(n+1)  

    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,n+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] %mod
    # 計算
    if n<k: return 0
    if n<0 or k<0: return 0
    
    modcombs = [1]
    for k in range(1,n+1):
        modcombs.append(fac[n]*(finv[k]*finv[n-k]%mod)%mod)
    return modcombs

if n == 1:
    print(m)
    exit()

mods = modconb(n-1,n-1,mod)
cnt = 0
for i in range(k+1):
    cnt += m*mods[i]*pow(m-1,n-i-1,mod)
    cnt %= mod
print(cnt)


# cnt = 100
# for i in range(99):
#     cnt *= 99
#     cnt %= mod

# print(cnt)
k,s = map(int,input().split())
counter = 0
for i in range(k+1):
  for m in range(k+1):
	if 0 <= s -i- m <= k:
      counter+= 1
print(counter)


### FIXED CODE ###

k,s = map(int,input().split())
counter = 0
for i in range(k+1):
  for m in range(k+1):
    if 0 <= s-i-m <= k:
      counter += 1
print(counter)
def binarySearch(list_a, key):
    left = 0
    right = len(list_a)
    while left < right:
        mid = (left + right) // 2
        if list_a[mid] == key:
            return mid
            break
        elif key < list_a[mid]:
            right = mid
        else:
            left = mid+1
    else:
        return "NOT_FOUND"

def merge(list_a, left, mid, right):
    import math
    n1 = mid - left
    n2 = right - mid
    list_l = []
    list_r = []
    for i in range(0,n1):
        list_l.append(list_a[left + i])
    for i in range(0,n2):
        list_r.append(list_a[mid + i])
    list_l.append(math.inf)
    list_r.append(math.inf)
    i = 0
    j = 0
    for k in range(left,right):
        if list_l[i] <= list_r[j]:
            list_a[k] = list_l[i]
            i += 1
        else:
            list_a[k] = list_r[j]
            j += 1

def mergeSort(list_a, left, right):
    if left + 1 < right:
        mid = (left + right) //2
        mergeSort(list_a, left, mid)
        mergeSort(list_a, mid, right)
        merge(list_a, left, mid, right)


n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

mergeSort(list_d, 0, n)
mergeSort(list_t, 0, m)
for number in list_t:
    ind = binarySearch(list_d, number)
    if ind != "NOT_FOUND":
        del list_d[ind]
    else:
        print("NO")
        break
else:
    print("YES")


### FIXED CODE ###

n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

dict_d = {}
dict_t = {}
for number in set(list_d):
    dict_d[number] = 0
for number in set(list_t):
    dict_d[number] = 0
for number in list_d:
    dict_d[number] += 1

for number in set(list_t):
    dict_t[number] = 0
for number in list_t:
    dict_t[number] += 1

for number,value in dict_t.items():
    if dict_d[number] < value:
        print("NO")
        break
    else:
        pass
else:
    print("YES")