Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

s = input()[::-1]
n = len(s)
counts = [0] * 2019
counts[0] = 1
current = 0
d = 1

for c in s:
    current += int(c) * d
    d *= 10
    current %= 2019
    counts[current] += 1

ans = 0
for count in counts:
    if count > 1:
        # print(i)
        ans += count * (count-1) //2
print(ans)


### FIXED CODE ###

s = input()[::-1]

sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    cnts[sum_of_digits] += 1

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC105 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    b = list(accumulate(a[i:]))
    b = list(map(lambda x:x%m,b))
    b.sort()
    ans += bisect.bisect_right(b,0) 
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC105 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(accumulate(a))
b = list(map(lambda x:x % m,a))
b = list(Counter(b).items())

ans = 0
for i,j in b:
    if j >= 2:
        #nC2
        ans += j*(j-1)//2
    if i == 0:
        ans += j
print(ans)
### BUGGY CODE ###

from heapq import heapify, heappop, heappush
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
input = sys.stdin.readline
 
H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1
S = [input().rstrip() for _ in [0]*H]
 
INF = 10**10
D = [[INF]*W for _ in [0]*H]
used = set()
 
q = []
heappush(q, (0, Ch*W+Cw))
 
dirs = [(-1, 0), (1, 0), (0, 1), (0, -1)]
wps = [
    [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -1), (-1, 1)],
    [(2, 2), (2, -1), (2, 0), (2, 1), (2, 2), (1, -1), (1, 1)],
    [(-2, 2), (-1, 2), (0, 2), (1, 2), (2, 2), (-1, 1), (1, 1)],
    [(-2, -2), (-1, -2), (0, -2), (1, -2), (2, -2), (-1, -1), (1, -1)]
]
 
while q:
    d, ij = heappop(q)
    i, j = divmod(ij, W)
    used.add((i, j))
    if D[i][j] > d:
        D[i][j] = d
    else:
        continue
    if i == Dh and j == Dw:
        break
 
    for k, (di, dj) in enumerate(dirs):
        _i = i + di
        _j = j + dj
        if 0 <= _i < H and 0 <= _j < W:
            if (_i, _j) in used:
                continue
            if S[_i][_j] == '.':
                used.add((_i, _j))
                heappush(q, (d, _i*W+ _j))
            else:
                for di, dj in wps[k]:
                    _i = i + di
                    _j = j + dj
                    if 0 <= _i < H and 0 <= _j < W and (_i, _j) not in used and S[_i][_j] == '.':
                        heappush(q, (d+1, _i*W+ _j))
 
ans = D[Dh][Dw]
print(ans if ans < INF else -1)

### FIXED CODE ###

from heapq import heapify, heappop, heappush
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
input = sys.stdin.readline

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1
S = [input().rstrip() for _ in [0]*H]

INF = 10**10
D = [[INF]*W for _ in [0]*H]
used = set()

q = []
heappush(q, (0, Ch*W+Cw))


while q:
    d, ij = heappop(q)
    i, j = divmod(ij, W)

    for di in range(-2, 3):
        for dj in range(-2, 3):
            if di == dj == 0:
                continue
            I = i+di; J = j+dj
            if 0 <= I < H and 0 <= J < W and S[I][J] == '.':
                if abs(di)+abs(dj) == 1:
                    if D[I][J] <= d:
                        continue
                    D[I][J] = d
                    heappush(q, (d, I*W+J))
                else:
                    if D[I][J] <= d+1:
                        continue
                    D[I][J] = d+1
                    heappush(q, (d+1, I*W+J))

ans = D[Dh][Dw]
print(ans if ans < INF else -1)
### BUGGY CODE ###

import sys
from itertools import permutations

def checker(x):
    if not x: return 1
    if x[0] != '(' or x[-1] != ')': return 0

    l = x[1:-1].count('(')
    r = len(x[1:-1]) - l
    if l != r: return 0

    return 1

def main():
    readline = sys.stdin.readline
    n = int(readline())
    s = tuple(readline().strip() for i in range(n))
    comb_s = tuple(set(permutations(s)))

    for i in comb_s:
        jud = checker(''.join(i))
        if jud == 1:
            print('Yes')
            return

    print('No')
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

from sys import stdin

def main():
    readline = stdin.readline
    n = int(readline())
    s = tuple(readline().strip() for _ in range(n))

    plus, minus = [], []
    for c in s:
        if 2 * c.count('(') - len(c) > 0:
            plus.append(c)
        else:
            minus.append(c)

    plus.sort(key = lambda x: x.count(')'))
    minus.sort(key = lambda x: x.count('('), reverse = True)
    plus.extend(minus)
    sum = 0
    for v in plus:
        for vv in v:
            sum = sum + (1 if vv == '(' else -1)
            if sum < 0 : return print('No')
    if sum != 0:
        return print('No')

    return print('Yes')

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
from collections import deque
n, *lst = map(int, read().split())

def convert(A):
    return [x ^ y for x, y in zip(A, A[1:])] + [A[-1] ^ A[0]]


al = lst[:n]
bl = lst[n:]
a = convert(al)
b = convert(bl)

alal, aa = al + al, a + a
for k in range(n):
    tmp = aa[k:n + k]
    if tmp == b:
        x = alal[k] ^ bl[0]
        print(k, x)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())

A = list(map(int, readline().split()))
B = list(map(int, readline().split()))


def convert(A):
    return [x ^ y for x, y in zip(A, A[1:])] + [A[-1] ^ A[0]]


C = convert(A)
D = convert(B)


def Z_algorithm(S):
    # 共通接頭辞の長さを返す
    N = len(S)
    arr = [0] * N
    arr[0] = N
    i, j = 1, 0
    while i < N:
        while i + j < N and S[j] == S[i + j]:
            j += 1
        arr[i] = j
        if not j:
            i += 1
            continue
        k = 1

        while i + k < N and k + arr[k] < j:
            k += 1
        i += k
        j -= k

    return arr


Z = Z_algorithm(D + [-1] + C + C)[N + 1:N + N + 1]

K = [i for i, x in enumerate(Z) if x == N]
X = [A[k] ^ B[0] for k in K]

print('\n'.join('{} {}'.format(k, x) for k, x in zip(K, X)))
### BUGGY CODE ###

n, k, q = map(int, input().split())
ls_a = [int(input()) for _ in range(q)]

ls_p = [k] * n

for i in range(n):
    num = 0
    num = ls_a.count(i+1)
    ls_p[i] += (num - q)

for j in range(n):
    if ls_p[j] > 0:
        print("Yes")
    elif ls_p[j] <= 0:
        print("No")

### FIXED CODE ###

n, k, q = map(int, input().split())
ls_a = [int(input()) for _ in range(q)]

ls_p = [k] * n
ls_c = [0] * n

for i in range(q):
    ls_c[ls_a[i] - 1] += 1

for j in range(n):
    ls_p[j] += ls_c[j] - q

for l in range(n):
    if ls_p[l] > 0:
        print("Yes")
    elif ls_p[l] <= 0:
        print("No")
### BUGGY CODE ###

N, X, Y = map(int, input().split())
l = [0] * N
for i in range(1,N):
    for j in range(i+1,N+1):
        #i j
        ij = j - i
        #i x y j
        ixyj = abs(X - i) + 1+ abs(Y -j)
        #i y x j
        iyxj = abs(Y - i) + 1 + abs(X- j)
        length = min(min(ij,ixyj),iyxj)
        l[length] +=1
for i in range(1,N):
    print(l[i])

### FIXED CODE ###

N, X, Y = map(int, input().split())
l = [0] * N
for i in range(1,N):
    for j in range(i+1,N+1):
        #i j
        ij = j - i
        #i x y j
        ixyj = abs(X - i) + 1+ abs(Y -j)
        #i y x j
        iyxj = abs(Y - i) + 1 + abs(X- j)
        length = min(min(ij,ixyj),iyxj)
        l[length] +=1
for i in range(1,N):
    print(l[i])
### BUGGY CODE ###

H,N = map(int,input().split())
A = []
for i in range(N):
    a,b = map(int,input().split())
    A.append((a,b))
A.sort()
MAXH = H+10**4
DP = [float("inf")]*(MAXH)
DP[0] = 0
for i in range(MAXH):
    for j in range(N):
        if i+A[j][0]>MAXH-1:break
        DP[i+A[j][0]] = min(DP[i]+A[j][1],DP[i+A[j][0]])
print(min(DP[H:]))

### FIXED CODE ###

H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH-a):
        if j>H+a:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))
### BUGGY CODE ###

INF = 10**10
n,m,R = map(int,input().split())
r=list(map(int,input().split()))
for i in range(R):
	r[i]-=1
d = [[INF]*n for i in range(n)] 
# 入力
for i in range(m):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    d[a][b] = c
    d[b][a] = c # 無向グラフ
for i in range(n):
    d[i][i] = 0

def FW():
    for i in range(n):
        for j in range(n):
            for k in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
FW()

from itertools import permutations, combinations

ans=10**10
for v in permutations(r):
    tmp=0
    for i in range(R-1):
        tmp+=d[v[i]][v[i+1]]
    ans=min(ans,tmp)
print(ans)

### FIXED CODE ###

INF = 10**10
n,m,R = map(int,input().split())
r=list(map(int,input().split()))
for i in range(R):
    r[i]-=1
d = [[INF]*n for i in range(n)] 
# 入力
for i in range(m):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    d[a][b] = c
    d[b][a] = c # 無向グラフ
for i in range(n):
    d[i][i] = 0

def FW():
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
FW()
from itertools import permutations, combinations
ans=INF
for v in permutations(r):
    tmp=0
    for i in range(R-1):
        tmp+=d[v[i]][v[i+1]]
    ans=min(ans,tmp)
print(ans)
### BUGGY CODE ###

import itertools

NLinput = input()
NLinput = [int(x) for x in NLinput.split()]

N = NLinput[0]
L = NLinput[1]

S_list = []
for i in range(N):
    temp = input()
    S_list.append(temp)

perm = list(itertools.permutations(range(N)))
result = []
for i in perm:
    str_temp = ''
    for j in i:
        str_temp += S_list[j]
    result.append(str_temp)
result = sorted(result)
print(result[0])

### FIXED CODE ###

import itertools

NLinput = input()
NLinput = [int(x) for x in NLinput.split()]

N = NLinput[0]
L = NLinput[1]

S_list = []
for i in range(N):
    temp = input()
    S_list.append(temp)

S_list = sorted(S_list)
str_temp = ''
for i in S_list:
    str_temp += i
print(str_temp)
### BUGGY CODE ###

import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
input=sys.stdin.readline
h,w=map(int,input().split())
a=[list(map(str,input())) for _ in range(h)]
b=deque()
n=[-1]*(h*w)
c=0
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
             b.append((i,j))
             n[i*w+j]=0
        else:
            continue
while b:
    i,j=b.popleft()
    
    if i<h-1 and a[i+1][j]=="." and n[(i+1)*w+j]==-1:
      n[(i+1)*w+j]=n[i*w+j]+1
      c=max(c,n[i*w+j]+1)
      b.append(((i+1),j))
      f=True
    if i>0 and a[i-1][j]=="." and n[(i-1)*w+j]==-1:
      n[(i-1)*w+j]=n[i*w+j]+1
      c=max(c,n[i*w+j]+1)
      b.append(((i-1),j))
      f=True
    if j<w-1 and a[i][j+1]=="." and n[i*w+(j+1)]==-1:
      f=True
      n[i*w+(j+1)]=n[i*w+j]+1
      c=max(c,n[i*w+j]+1)
      b.append((i,(j+1)))
    if j>0 and a[i][j-1]=="."  and n[i*w+(j-1)]==-1:
      f=True
      n[i*w+(j-1)]=n[i*w+j]+1
      c=max(c,n[i*w+j]+1)
      b.append((i,(j-1)))
   
print(c)
        

### FIXED CODE ###

import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
input=sys.stdin.readline
h,w=map(int,input().split())
a=[list(map(str,input())) for _ in range(h)]
b=deque()
n=[-1]*(h*w)
c=0
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
             b.append((i,j))
             n[i*w+j]=0
        else:
            continue
p = [(1,0),(-1,0),(0,1),(0,-1)]

while b:
    i,j=b.popleft()
    for s,t in p:
      if 0 <= i+s <= h-1 and 0 <= j+t <= w-1:
        if n[(i+s)*w+(j+t)]==-1:
          n[(i+s)*w+(j+t)]=n[i*w+j]+1
          c=max(c,n[i*w+j]+1)
          b.append(((i+s),(j+t)))
    
print(c)
### BUGGY CODE ###

def Z_algorithm(s):
    N = len(s)
    Z_alg = [0]*N

    Z_alg[0] = N
    i = 1
    j = 0
    while i < N:
        while i+j < N and s[j] == s[i+j]:
            j += 1
        Z_alg[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < N and k + Z_alg[k]<j:
            Z_alg[i+k] = Z_alg[k]
            k += 1
        i += k
        j -= k
    return Z_alg

import sys

sys.setrecursionlimit(1000000)

s=input()
t=input()
n=len(s)
m=len(t)

s=(m//n+2)*s
data=Z_algorithm(t+'?'+s)
bool=[False for i in range(0,n)]
flag=[True for i in range(0,n)]
for i in range(m+1,m+1+n):
    if data[i]==m:
        bool[i-m-1]=True


for i in range(0,n):
    if flag[i]:
        flag[i]=False
        if bool[i]:
            x=(i+m)%n
            while x!=i:
                if not bool[x] or not flag[x]:
                    break
                else:
                    x=(x+m)%n
                flag[x]=False
            else:
                print(-1)
                exit()


memo=[-1 for i in range(0,n)]
def dfs(num):
    if memo[num]!=-1:
        return memo[num]

    if not bool[num]:
        memo[num]=0
        return memo[num]
    else:
        ans=1+dfs((num+m)%n)
        memo[num]=ans
        return memo[num]

ans=0
for i in range(0,n):
    ans=max(ans,dfs(i))
print(ans)

### FIXED CODE ###

def Z_algorithm(s):
    N = len(s)
    Z_alg = [0]*N

    Z_alg[0] = N
    i = 1
    j = 0
    while i < N:
        while i+j < N and s[j] == s[i+j]:
            j += 1
        Z_alg[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < N and k + Z_alg[k]<j:
            Z_alg[i+k] = Z_alg[k]
            k += 1
        i += k
        j -= k
    return Z_alg

import sys
from fractions import gcd

sys.setrecursionlimit(1500000)

s=input()
t=input()
n=len(s)
m=len(t)
if n!=m:
    s=(m//n+2)*s
    data=Z_algorithm(t+'?'+s)
    bool=[False for i in range(0,n)]
    for i in range(m+1,m+1+n):
        if data[i]==m:
            bool[i-m-1]=True

    g=gcd(n,m)
    for i in range(0,g):
        for j in range(0,n//g):
            if not bool[i+j*g]:
                break
        else:
            print(-1)
            exit()

    ans=[[] for i in range(0,g)]
    for i in range(0,g):
        ans[i].append(bool[i])
        x=(i+m)%n
        while x!=i:
            ans[i].append(bool[x])
            x=(x+m)%n

    from itertools import groupby
    answer=0
    for i in range(0,g):
        a=groupby(ans[i])
        d=[]
        for key,group in a:
            g=len(list(group))
            d.append([key,g])
        if d:
            if d[0][0] and d[-1][0]:
                d[-1][1]+=d[0][1]
        for j in range(len(d)):
            if d[j][0]:
                answer=max(answer,d[j][1])
    print(answer)


else:
    s=2*s
    data=Z_algorithm(t+'?'+s)
    for i in range(m+1,n+m+1):
        if data[i]==m:
            print(-1)
            break
    else:
        print(0)
### BUGGY CODE ###

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

if A == 0 or B == 0:
  print('IMPOSSIBLE')
else:
  for i in range(1, 1000000000):
    qw = abs(A - i)
    qe = abs(B - i)
    if qw == qe:
      print(i)
      break
    

### FIXED CODE ###

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

b = a[0] + a[1]

if b % 2 == 0:
  print(b//2)
else:
  print('IMPOSSIBLE')
### BUGGY CODE ###

n = int(input())
s = [input() for i in range(n)]
ss = sorted(set(s))
d = []
for i in ss:
    d.append([i,0])
for i in s:
    d[ss.index(i)][1]+=1
d = sorted(d, key = lambda x:(-x[1],x[0]))
for i in d:
    if i[1]==d[0][1]:
        print(i[0])
    else:
        break

### FIXED CODE ###

import collections
n = int(input())
l = []
s = collections.Counter([input() for i in range(n)])
mn = 0
for i in s.most_common():
    if i[1] >= mn:
        mn = i[1]
        l.append(i[0])
    else:
        break
for i in sorted(l):
        print(i)
### BUGGY CODE ###

s = input()

a = ''
ss = ''
b = ''
for i in range(len(s)):
    ss += s[-1-i]
    if s[i]!='x':
        a+=s[i]
        b = s[i]+b

if a!=b:
    print(-1)
else:
    i = 0
    ans = 0
    while s!=ss:
        if i>=len(s):
            ans += len(ss)-i
            break
        elif i>= len(ss):
            ans += len(s)-i
            break
        if s[i]!=ss[i]:
            if s[i]=='x':
                ss = ss[:i]+'x'+ss[i:]
            else:
                s = s[:i]+'x'+s[i:]
            ans += 1
        i+=1
    print(ans//2)



### FIXED CODE ###

s = input()

a = ''
for i in range(len(s)):
    if s[i]!='x':
        a+=s[i]

b = ''
for i in range(len(a)):
    b+=a[-1-i]

if a!=b:
    print(-1)
else:
    ss = ''
    for i in range(len(s)):
        ss += s[-1-i]
    i = 0
    j=0
    ans = 0
    while True:
        if i>=len(s):
            ans += len(ss)-j
            break
        elif j>=len(ss):
            ans += len(s)-i
            break
        if s[i]!=ss[j]:
            if s[i]=='x':
                i+=1
            else:
                j+=1
            ans += 1
        else:
            i+=1
            j+=1
    print(ans//2)
### BUGGY CODE ###

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

res = 0
cnt = [False] * a[-1]
for i in range(n):
    j = 1
    while j * j <= a[i]:
        if a[i] % j == 0 and (cnt[j-1] or cnt[a[i]//j-1]):
            res += 1
            break
        j += 1
    if j * j > a[i] and i + 1 < n and a[i] == a[i+1]:
        res += 1
    cnt[a[i]-1] = True

print(n - res)

### FIXED CODE ###

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

used = [False] * a[-1]
res = 0
for i in range(n):
    if used[a[i]-1]:
        continue
    if i == n - 1 or a[i] != a[i+1]:
        res += 1
    for j in range(a[i], a[-1]+1, a[i]):
        used[j-1] = True

print(res)
### BUGGY CODE ###

n = int(input())
x = input()

num_of_1 = x.count("1")

first = int(x, 2)

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

if num_of_1 == 1:
    for i in range(n):
        if x[i] == '1':
            print(0)
        elif i == n-1:
            print(2)
        else:
            print(1)
    exit()

for i in range(n):
    temp_num_of_1 = num_of_1 + 1 if x[i] == "0" else num_of_1 - 1

    ans = 0

    a = first + 2 ** (n - i - 1) if x[i] == "0" else first - 2 ** (n - i - 1)

    a = a % temp_num_of_1

    ans += 1 + f(a)

    print(ans)

### FIXED CODE ###

n = int(input())
x = input()

num_of_1 = x.count("1")

first = int(x, 2)

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

if num_of_1 == 1:
    for i in range(n):
        if x[i] == '1':
            print(0)
        elif i == n-1:
            print(2)
        else:
            print(1)
    exit()

first_one, first_zero = first % (num_of_1 - 1), first % (num_of_1 + 1)

for i in range(n):
    if x[i] == "0":
        print(1 + f((first_zero + pow(2, n-i-1, num_of_1 + 1)) % (num_of_1 + 1)))
    else:
        print(1 + f((first_one - pow(2, n-i-1, num_of_1 - 1)) % (num_of_1 - 1)))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
  n=int(input())
  a=list(map(int,input().split()))
  mod=pow(10,9)+7
  ans=0
  bit=[0]*61 #bit[i]:2^iの位が1である物の個数
  for ai in a:
    for j in range(61):
      if ((ai>>j) & 1):
        bit[j]+=1
  for i in range(61):
    ans+=(pow(2,i)%mod)*bit[i]*(n-bit[i])
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
  n=int(input())
  a=list(map(int,input().split()))
  mod=pow(10,9)+7
  ans=0
  bit=[0]*61 #bit[i]:2^iの位が1である物の個数
  for ai in a:
    for j in range(61):
      if ((ai>>j) & 1):
        bit[j]+=1
  for i in range(61):
    ans+=(pow(2,i)%mod)*bit[i]*(n-bit[i])
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, D: "List[int]", M: int, T: "List[int]"):
    
    D.sort()
    T.sort()

    from bisect import bisect_left, bisect_right

    if M > N:
        print(NO)
        exit()
        

    for i in range(M):
        lf = bisect_left(D, T[i])
        ri = bisect_right(D, T[i])
        if lf != ri:
            D.pop(lf)
        else:
            print(NO)
            exit()

    print(YES)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    M = int(next(tokens))  # type: int
    T = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, D, M, T)

if __name__ == '__main__':
    main()


### FIXED CODE ###

n = int(input())
d_li = list(map(int,input().split()))
m = int(input())
t_li = list(map(int,input().split()))

d_li.sort()
t_li.sort()

check = 0

for i in range(n):
    if d_li[i] == t_li[check]:
        check += 1
        
    if check == m:
        print("YES")
        exit()
else:
    print("NO")