Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N - M + 1):
  for j in range(N - M + 1):
    ok = True
    if A[i + k][j:j + M] != B[k]:
      ok = False
      break
    if ok:
      print("Yes")
      exit()
print("No")

### FIXED CODE ###

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = "No"

for i in range(N - M + 1):
  for j in range(N - M + 1):
    if [a[j:j+M] for a in A[i:i+M]] == B:
      ans = "Yes"
print(ans)
l = raw_input().split()
print((float(l[0])-float(l[2]))/(float(l[1])+float(l[2])))

### FIXED CODE ###

l = raw_input().split()
print((int(l[0])-int(l[2]))/(int(l[1])+int(l[2])))
str = input()
str[3] = '8'
print(str)

### FIXED CODE ###

str = input()
print(str.replace('7', '8', 1))
a,b=map(int,input().split)
if a<= 8 and b<= 8:
    print('Yay!')
else:
    print(':(')

### FIXED CODE ###

a,b=map(int,input().split())
if a<= 8 and b<= 8:
    print('Yay!')
else:
    print(':(')
import sys
input = sys.stdin.readline

def main():
    n , m = map( int, input().split() )
    Sets = []

    Dicto = [ -1 for i in range(n + 1)]

    for i in range( m ):
        a , b = map( int , input().split() )
        if Dicto[a] == -1 and Dicto[b] == -1:
            Sets.append( set( [a,b] ) )
            x_i = len(Sets)
            Dicto[ a ] = x_i - 1
            Dicto[ b ] = x_i - 1
        elif Dicto[ a ] != -1 and Dicto[ b ] == -1:
            Sets[ Dicto[a] ].add( b )
            Dicto[ b ] = Dicto[a]
        elif Dicto[ b ] != -1 and Dicto[ a ] == -1:
            Sets[ Dicto[b] ].add( a )
            Dicto[ a ] = Dicto[b]
        elif Dicto[ b ] != -1 and Dicto[ a ] != -1:
            if Dicto[ b ] > Dicto[ a ]:
                set_x = Sets.pop( Dicto[b] )
                Sets[ Dicto[a] ] |= ( set_x )
                l_set_x = list( set_x )
                for j in l_set_x:
                    Dicto[j] = Dicto[a]

            else:
                set_x = Sets.pop( Dicto[a] )
                Sets[ Dicto[b] ] |= ( set_x )
                Dicto[a] = Dicto[b]

    #print(Sets)
    #print(Dicto)

    max_len = 1

    for i in range( len(Sets) ):
        if max_len < len( Sets[i] ):
            max_len = len( Sets[i] )

    print(max_len)


main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n , m = map( int, input().split() )
    Sets = []

    Dicto = [ -1 for i in range(n + 1)]

    for i in range( m ):
        a , b = map( int , input().split() )
        if Dicto[a] == -1 and Dicto[b] == -1:
            Sets.append( set( [a,b] ) )
            x_i = len(Sets)
            Dicto[ a ] = x_i - 1
            Dicto[ b ] = x_i - 1
        elif Dicto[ a ] != -1 and Dicto[ b ] == -1:
            Sets[ Dicto[a] ].add( b )
            Dicto[ b ] = Dicto[a]
        elif Dicto[ b ] != -1 and Dicto[ a ] == -1:
            Sets[ Dicto[b] ].add( a )
            Dicto[ a ] = Dicto[b]
        elif Dicto[ b ] != -1 and Dicto[ a ] != -1 and Dicto[ a ] != Dicto[ b ]:
            if Dicto[ b ] > Dicto[ a ]:
                set_x = Sets[Dicto[b]]
                Sets[ Dicto[a] ] |= ( set_x )
                l_set_x = list( set_x )
                for j in l_set_x:
                    Dicto[j] = Dicto[a]

            else:
                set_x = Sets[Dicto[a]]
                Sets[ Dicto[b] ] |= ( set_x )
                l_set_x = list( set_x )
                for j in l_set_x:
                    Dicto[j] = Dicto[b]

    #print(Sets)
    #print(Dicto)

    max_len = 1

    for i in range( len(Sets) ):
        if max_len < len( Sets[i] ):
            max_len = len( Sets[i] )

    print(max_len)


main()
packs = list(map(int, input().split()).sort()
if packs[2] - packs[1] == packs[0]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

packs = sorted(list(map(int, input().split())))
if packs[2] - packs[1] == packs[0]:
    print("Yes")
else:
    print("No")
s = list(input())
k = int(input())
flag = False
for i in range(k):
    if s[i]!='1':
        ans = s[i]
        break
    else:
        continue
        
    if i==k-1:
        flag = True
print(1 if flag==True else ans)

### FIXED CODE ###

s = list(input())
k = int(input())
flag = False
for i in range(k):
    if s[i]!='1':
        ans = s[i]
        break
        
    if i==k-1:
        flag = True
print(1 if flag==True else ans)
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, y = map(int, input().split())
    if x < y:
        if 0 < y and 0 < x:
            print(y - x)
        elif 0 < x and 0 < y:
            print(y - abs(x) + 1)
        elif y == 0:
            print(-x)
        elif x == 0:
            print(y)
        else:
            print(y - x)
    else:
        if 0 < y and 0 < x:
            print(x * 2 - (x - y) + 1)
        elif y < 0 and 0 < x:
            print(x - abs(y) + 1)
        elif y == 0:
            print(x + 1)
        elif x == 0:
            print(-y + 1)
        else:
            print((x - y) + 2)

if __name__ == '__mai

### FIXED CODE ###

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, y = map(int, input().split())
    if x < y:
        if y == 0:
            print(-x)
        elif x == 0:
            print(y)
        elif 0 < x and 0 < y:
            print(y - x)
        elif x < 0 and 0 < y:
            print(abs(y - abs(x)) + 1)
        else:
            print(y - x)
    else:
        if y == 0:
            print(x + 1)
        elif x == 0:
            print(-y + 1)
        elif 0 < y and 0 < x:
            print(x - y + 2)
        elif y < 0 and 0 < x:
            print(abs(x - abs(y)) + 1)
        else:
            print((x - y) + 2)

if __name__ == '__main__':
    main()
N = input()
for i in N:
	A = [int(i) for i in input().split()]
P=round(sum(A)/N)
B=0
for i in N:
	B=B+(A[i]-P)**2
print(B)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split())) 
P=round(sum(A)/N)
B=0
for i in range(N):
    B=B+(A[i]-P)**2
print(B)
# cording:utf-8
n,t = (int(x) for x in input().split())
cost_list = list()
time_list = list()
while n >= 1:
    c,tn = (int(x) for x in input().split())
    if tn >= t:
        cost_list.append(c)
        time_list.append(tn)
        n = n - 1
    else:
        n = n - 1
best_time = min(time_list)
if best_time <= t:
    best_time_number = time_list.index(best_time)
    print(cost_list[best_time_number])
else:
    print('TLE')

### FIXED CODE ###

# cording:utf-8
n,t_limit = (int(x) for x in input().split())
cost_list = list()
time_list = list()
while n >= 1:
    c,tn = (int(x) for x in input().split())
    if tn <= t_limit:
        cost_list.append(c)
        time_list.append(tn)
        n = n - 1
    else:
        n = n - 1
if not time_list:
    print('TLE')
else:
    best_cost = min(cost_list)
    print(best_cost)
import sys
for e in sys.stdin:
 e=int(e);x=range(10);ff=0
ff+=1 for a in x for b in x for c in x for d in x if a+b+c+d==e
print (ff)


### FIXED CODE ###

import sys
for e in sys.stdin:
 e=int(e);x=range(10)
 print(sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==e]))
n,x = map(int,input().split())
l = list(map(int,input().split()))
count = 1
x1 = 0
for i in range(n):
  if x1 + l[i] <= x:
    count += 1
    x1 += l[i]
  else:
    print(count)
    exit()
print(count)  


### FIXED CODE ###

x,a = map(int,input().split())
print(0 if x < a else 10)
h=S/3600
m=(S%3600)/60
s=(S%3600)%60
print str(h)+':'+str(m)+':'+str(s)

### FIXED CODE ###

time=input()
h=time/3600
m=(time%3600)/60
s=(time%3600)%60
print str(h)+':'+str(m)+':'+str(s)
def dis_func(n, x, y):
    dis = [round(0, 6) for i in range(n+1)]
    for x, y in zip(x, y):
        tmp = abs(x - y)
        dis[0] += tmp
        dis[1] += (tmp ** 2)
        dis[2] += (tmp ** 3)
        dis[3] = max(dis[3], tmp)

    dis[1] = dis[1] ** (1/2)
    dis[2] = dis[2] ** (1/3)
    print('\n'.join(list(map(str, dis))))


if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    dis_func(n, x, y)

### FIXED CODE ###



def dis_func(x, y):
    dis = [round(0, 6) for i in range(4)]
    for x, y in zip(x, y):
        tmp = abs(x - y)
        dis[0] += tmp
        dis[1] += (tmp ** 2)
        dis[2] += (tmp ** 3)
        dis[3] = max(dis[3], tmp)

    dis[1] = dis[1] ** (1/2)
    dis[2] = dis[2] ** (1/3)
    print('\n'.join(list(map(str, dis))))


if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    dis_func(x, y)
5
1 2
1 3
1 4
1 5
3141 59 26 53 59

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

N = int(input())
edge = [[] for _ in range(N)]
cnt = [[0,i] for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    edge[a].append(b)
    edge[b].append(a)
    cnt[a][0] += 1
    cnt[b][0] += 1


cnt.sort(reverse=True)
start = cnt[0][1]
C = list(map(int, input().split()))
C.sort(reverse=True)
nodes = [0] * N

#print(nodes)
cidx = -1
ans = []
def dfs(v, pv, w):
    global cidx
    cidx += 1
    nodes[v] = C[cidx]
    ans.append(min(w, C[cidx]))
    for nv in edge[v]:
        if pv == nv: continue
        dfs(nv, v, C[cidx])

dfs(start, 0, 0)
print(sum(ans))
print(*nodes, sep=" ")
import copy
N=int(input())
G=[[] for n in range(N)]
E=[]
for n in range(N-1):
    a,b=map(int,input().split())
    E.append((a-1,b-1))
    G[a-1].append(b-1)
    G[b-1].append(a-1)

deg=[len(v) for v in G]
K=max(deg)
Q=copy.copy(G[0])
X=[0]
C=[0]*N
color_map={}
while Q!=[]:
    v=Q.pop(0)
    X.append(v)
    colors=list(range(1,K+1))
    for u in G[v]:
        if C[u] in colors:
            colors.remove(C[u])
        for w in G[u]:
            if C[w] in colors:
                colors.remove(C[w])
        if u not in X:
            Q.append(u)
    color=copy.copy(colors[0])
    C[v]=color
    p=list(set(X)&set(G[v]))[0]
    color_map[(min(p,v),max(p,v))]=color

print(K)
for e in E:
    print(color_map[e])


### FIXED CODE ###

from collections import deque

N=int(input())
G=[[] for n in range(N)]
E=[]
for n in range(N-1):
    a,b=map(int,input().split())
    E.append((a-1,b-1))
    G[a-1].append(b-1)
    G[b-1].append(a-1)
K=max([len(v) for v in G])

P=[-1]*N
Q=[0]
X=[]
count=0
while Q:
    v=Q.pop()
    X.append(v)
    for u in G[v]:
        if u==P[v]:
            continue
        P[u]=v
        Q.append(u)

C={}
for v in X:
    color=0
    try:
        p_color=C[tuple(sorted((v,P[v])))]
    except:
        p_color=-1
    for u in G[v]:
        if u==P[v]:
            continue
        if color==p_color:
            color+=1
        C[tuple(sorted((u,v)))]=color
        color+=1

print(K)
for e in E:
    print(C[e]+1)
from math import gcd

n = int(input())
k = list(map(int, input().split()))
ans = k[0]

for i in k:
    ans = gcd(ans, i)

print(ans)

### FIXED CODE ###

from fractions import gcd

n = int(input())
k = list(map(int, input().split()))
ans = k[0]

for i in k:
    ans = gcd(ans, i)

print(ans)
a,b=map(int,input().split())

eightper = 0.08
tenper = 0.1
ans = -1
for i in range(1,100*(1+tenper)+1):
    if int(i*eightper)==a:
        if int(i*tenper)==b:
            ans=i
            break
print(ans)

### FIXED CODE ###

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

eightper = 0.08
tenper = 0.1
ans = -1
for i in range(1,1000+1):
    if int(i*eightper)==a:
        if int(i*tenper)==b:
            ans=i
            break
print(ans)
import math
import copy
from functools import reduce

N = int(input())
nums = [int(i) for i in input().split()]
nums2 = copy.copy(nums)
ans = []

def gcds(numlist):
    return reduce(math.gcd, numlist)


for i in range(N):
   nums.pop(i)
   ans.append(gcds(nums))
   nums = copy.copy(nums2)

print(max(ans))


### FIXED CODE ###

from fractions import gcd

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

fort = [nums[0], gcd(nums[0], nums[1])]
back = [nums[N-1], gcd(nums[N-1], nums[N-2])]
ans = []

for i in range(N-2):
    fort.append(gcd(fort[i+1], nums[i+2]))
                
for i in range(N-2):
    back.append(gcd(back[i+1], nums[N-(i+3)]))
    
for i in range(1, N-1):
    ans.append(gcd(fort[i-1], back[N-2-i]))

ans.append(fort[N-2])
ans.append(back[N-2])

print(max(ans))
result = 0
for b in range(K + 1, N + 1):
    result += (N // b) * (b - K) + max(N - (N // b) * b - max(K - 1, 0), 0)
print(result)

### FIXED CODE ###

result = 0
N, K = list(map(int , input().split()))
for b in range(K + 1, N + 1):
    result += (N // b) * (b - K) + max(N - (N // b) * b - max(K - 1, 0), 0)
print(result)
n = int(input())
s = [input() for i in range(n)]

status = ["AC","WA","TLE","RE"]
ans  = [0]*n

for i in range(len(status)):
    ans[i] = len([j for j in s if status[i] in s])

print("AC x {}".format(ans[0]))
print("WA x {}".format(ans[1]))
print("TLE x {}".format(ans[2]))
print("RE x {}".format(ans[3]))


### FIXED CODE ###

n = int(input())

change = 1000 - n % 1000
if n % 1000 == 0:
    change = 0
print(change)
_n = int(raw_input())
_a = [int(x) in x for raw_input.split()]

_flg = 1
cnt = 0

while _flg:
    _flg = 0
    for i in reversed(range(1, _n)):
        if _a[i] < _a[i-1]:
            _a[i], _a[i-1] = _a[i-1], _a[i]
            cnt += 1
            _flg = 1

print(" ".join(_a))
print(cnt)

### FIXED CODE ###

_n = int(raw_input())
_a = [int(x) for x in raw_input().split()]

_flg = 1
cnt = 0

while _flg:
    _flg = 0
    for i in reversed(range(1, _n)):
        if _a[i] < _a[i-1]:
            _a[i], _a[i-1] = _a[i-1], _a[i]
            cnt += 1
            _flg = 1

print(" ".join([str(x) for x in _a]))
print(cnt)
S = input()
import re
def appear(i, j)
 T = S[i:j+1]
 T.count('AC')

### FIXED CODE ###

n, q = map(int, input().split())
S = input()
 
counts = [0 for i in range(n)]
cnt = 0
 
for i in range(n):
  if S[i-1:i+1] == "AC":
    cnt += 1
  counts[i] = cnt
    
for i in range(q):
    l, r = map(int, input().split())
    print(counts[r-1] - counts[l-1])
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  dp=[inf]*10
  dp[0]=0
  dp[1]=0
  dp[2]=abs(l[1]-l[0])

  for i in range(2,n):
    dp[i+1]=min(dp[i-1]+abs(l[i]-l[i-2]),dp[i]+abs(l[i]-l[i-1]))

  return dp[n]

print(main())


### FIXED CODE ###

class struct:
  def __init__(self,a,b):
    self.a=a
    self.b=b

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

l2=[struct(0,0) for _ in range(n)]
l2[0].a=l[0]
l2[1].a=l[1]
l2[1].b=abs(l[0]-l[1])

i=2
for x in l[2:]:
  l2[i].a=x
  l2[i].b=min(abs(l2[i-2].a-x)+l2[i-2].b,
    abs(l2[i-1].a-x)+l2[i-1].b)
  i+=1

print(l2[-1].b)
a = int(input())
p = 100
c = 0
while p != a:
    p = p + int(p/100)
    c += 1
print(c)

### FIXED CODE ###

x = int(input())
p = 100
t , si= 0, 0
while(p < x):
    si = p//100
    p += si
    t += 1
print(t)
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
size=len(Counter(A).most_common())
if K >= size:
    print(0)
else:
    values, counts = zip(*Counter(A).most_common()[::-1])
    ans=0
    for i in range(size-K):
        ans += counts[i]
print(ans)

### FIXED CODE ###

from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
size=len(Counter(A).most_common())
if K >= size:
    print(0)
else:
    values, counts = zip(*Counter(A).most_common()[::-1])
    ans=0
    for i in range(size-K):
        ans += counts[i]
    print(ans)
def gcd_t(s):
    if(len(s)==1):    return s[0]
    if(s[-2]==0):    return s[-1]
    else:
        if(len(s)==2):
            return gcd(s[-1],s[-2])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
gcd_list=[]
for i in range(N):
    gcd_list.append(X-x[i])
    
print(abs(gcd_t(gcd_list)))

### FIXED CODE ###

def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
ans=abs(X-x[0])
for i in range(N):
    ans=gcd(ans,abs(x[i]-X))

print(ans)
x, y, z, k = map(int, input().split())
A = list(sorted(list(map(int, input().split())), reverse=True))
B = list(sorted(list(map(int, input().split())), reverse=True))
C = list(sorted(list(map(int, input().split())), reverse=True))
D = [A[a] + B[b] + C[c] for a in range(x) for b in range(y) for c in range(z) if a + b + c + 3 <= k]
D.sort(reverse=True)
for i in range(k):
    print(D[i])

### FIXED CODE ###

x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
AB = [x + y for x in A for y in B]
AB.sort(reverse=True)
ABC = [x + y for x in AB[:min(len(AB), k)] for y in C[:min(len(C), k)]]
ABC.sort(reverse=True)
for i in range(k):
    print(ABC[i])
cnt = 0
base = 0
MOD = 2019
s = input()

for d in s:
    base *= 10
    base += int(d)
    tmp = base
    while tmp:
        if tmp % MOD == 0:
            cnt += 1
        tmp //= 10
print(ans)

### FIXED CODE ###

s = input().rstrip()
tmp = 0
pw = 1
from collections import Counter
c = Counter()
c[0] += 1

for d in s[::-1]:
    tmp += int(d) * pw
    tmp %= 2019
    pw *= 10
    pw %= 2019
    c[tmp] += 1

print(sum([v*(v-1)//2 for v in c.values() if v > 1]))
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    def dfs(node):
        for adjnode in edges[node]:
            if colors[adjnode[0]] == -1:
                if adjnode[1] % 2 == 0:
                    colors[adjnode[0]] = colors[node]
                else:
                    colors[adjnode[0]] = colors[node] ^ 1
                dfs(adjnode[0])
    # input
    n = int(input())
    edges = {e: [] for e in range(n)}
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        edges[u].append((v, w))
        edges[v].append((u, w))
    # process
    colors = [-1] * n
    colors[0] = 0
    dfs(0)
    # output
    print(*colors, sep='\n')


if __name__ == '__main__':
    main()

### FIXED CODE ###

from copy import deepcopy
from collections import deque
def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def roots():
        return [i for i, x in enumerate(par) if x < 0]

    n = int(input())
    par = [-1] * n
    uvw = {e:[] for e in range(n)}

    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        uvw[u].append((u, v, w))
        uvw[v].append((v, u, w))
        unite(u, v)
    root_node = roots()[0]
    color = [-1] * n
    color[root_node] = 0
    node_next = deque()
    node_next.append(root_node)
    node_next_next = deque()
    node_seen = set()

    while len(node_seen) < n:
        while node_next:
            node_togo = node_next.popleft()
            if node_togo in node_seen:
                continue
            else:
                node_seen.add(node_togo)
            # 次の層のノード群情報を取得し、「次にみるノードlist」にいれる。
            node_adj = uvw[node_togo]
            node_next_next += [i[1] for i in node_adj]
            # 次の層を処理＝色塗りする
            for adj in node_adj:
                if adj[1] in node_seen or color[adj[1]] != -1:
                    continue
                if adj[2] % 2 == 0:
                    color[adj[1]] = color[node_togo]
                else:
                    color[adj[1]] = color[node_togo] ^ 1
        node_next = deepcopy(node_next_next)
        node_next_next = deque()
    print(*color, sep='\n')


if __name__ == '__main__':
    main()
S=int(input())

def f(n): 
      
    # single line to find factorial 
    return 1 if (n==1 or n==0) else n * factorial(n - 1);

possibles=0
biggest_sub=S//3
for i in range(1,biggest_sub+1):
	possibles=f(biggest_sub-3*i)/f(r)/f(biggest_sub-4*r)
n=10**9+7
print(possibles%n)

### FIXED CODE ###

#import sys
#input = sys.stdin.readline
Q = 10**9+7
def cmb(n,r):
    if n-r < r: r = n-r
    if r == 0: return 1
    denominator = 1                       #分母
    numerator = 1                         #分子
    for i in range(r):
        numerator *= n-i
        numerator %= Q
        denominator *= i+1
        denominator %= Q
    return numerator*pow(denominator, Q-2, Q)%Q
 
def main():
    S = int( input())
    ans = 0
    for i in range(1, S//3+1):
        t = S - i*3
        ans += cmb(t+i-1,i-1)
        ans %= Q
    print(ans)
        
if __name__ == '__main__':
    main()
N, X = map(int, input().split())
x = list(map(int, input().split()))
x = list(map(lambda x: abs(X - int(x)), x))
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

D = gcd(x[0], x[1])
for i in range(2, N):
    D = gcd(D, x[2])

print(D)


### FIXED CODE ###

N, X = map(int, input().split())
x = list(map(int, input().split()))
x = list(map(lambda x: abs(X - int(x)), x))

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
        
if len(x) < 2:
    print(x[0])
else:
    D = gcd(x[0], x[1])
    for i in range(2, N):
        D = gcd(D, x[i])

    print(D)
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    kind = set(a_list)
    # 0 0 0
    # 1 0 1 1 0 1
    # 1 2 3
    if len(kind) not in (1, 2, 3):
        print("No")
        return
    if len(kind) == 1 and 0 in kind:
        print("Yes")
        return
    if n % 3 != 0:
        return "No"
    if len(kind) == 3:
        if len(set([a_list.count(k) for k in kind])) != 1:
            print("No")
            return
        kind = list(kind)
        if kind[0] ^ kind[1] ^ kind[2] == 0:
            print("Yes")
        else:
            print("No")
    else:
        a, b = kind
        a_c, b_c = a_list.count(a), a_list.count(b)
        if 0 not in kind:
            print("No")
            return
        elif n / 3 != a_list.count(0):
            print("No")
        else:
            print("Yes")


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)
    if len(kind) > 3:
        return False
    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        a, b, c = kind
        return nums.count(a) == nums.count(b) == nums.count(c) and a ^ b ^ c == 0
    else:
        return 0 in kind and n / 3 == nums.count(0)


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")
    # 0 0 0
    # 1 0 1 1 0 1
    # 1 2 3


if __name__ == "__main__":
    main()
n = int(input())
ablist = [[] for _ in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  ablist[a-1].append((b-1, c))
  ablist[b-1].append((a-1, c))

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

def dfs(v, p, d):
  depth[v] = d
  for to, c in ablist[v]:
    if to == p:
      continue
    dfs(to, v, d + c)

dfs(k-1, -1, 0)
for _ in range(q):
  x, y = map(int, input().split())
  print(depth[x-1] + depth[y-1])


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

n = int(input())
ablist = [[] for _ in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  ablist[a-1].append((b-1, c))
  ablist[b-1].append((a-1, c))

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

def dfs(v, p, d):
  depth[v] = d
  for to, c in ablist[v]:
    if to == p:
      continue
    dfs(to, v, d + c)

dfs(k-1, -1, 0)
for _ in range(q):
  x, y = map(int, input().split())
  print(depth[x-1] + depth[y-1])