Harryxun/stf_run huggingface dataset:
import itertools
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s

def bitadd(BIT,i,x):
  while i<=2**n:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

def tentou(X):
  ret=0
  BIT=[0]*64
  BIT.insert(0,0)
  for i1 in range(n):
    x=X[i1]+1
    ret+=i1-bitsum(BIT,x)
    bitadd(BIT,x,1)
  return ret
N=[int(i) for i in range(n)]
nn=2**n
ans=float("inf")
for _ in range(n//2+1):
  for com in itertools.combinations(N,2*_):
    E,O=[],[]
    for j in range(n):
      if j not in com:
        if j%2==0:
          E.append(A[j]*100+j)
        else:
          O.append(A[j]*100+j)
      else:
        if j%2==0:
          O.append(B[j]*100+j)
        else:
          E.append(B[j]*100+j)
    if len(E)!=(n+1)//2:
      continue
    else:
      E.sort()
      O.sort()

      chk=True
      C=[E[0]%100]
      prev=E[0]//100
      for i in range(1,n):
        ii=i//2
        if i%2==0:
          C.append(E[ii]%100)
          if E[ii]//100<prev:
            chk=False
            break
          else:
            prev=E[ii]//100
        else:
          C.append(O[ii]%100)
          if O[ii]//100<prev:
            chk=False
            break
          else:
            prev=O[ii]//100
    
    if chk:
      ans=min(ans,tentou(C))
print(-1 if ans==float("inf") else ans)



### FIXED CODE ###

import itertools
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s

def bitadd(BIT,i,x):
  while i<=64:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

def tentou(X):
  ret=0
  BIT=[0]*64
  BIT.insert(0,0)
  for i1 in range(n):
    x=X[i1]+1
    ret+=i1-bitsum(BIT,x)
    bitadd(BIT,x,1)
  return ret
N=[int(i) for i in range(n)]
nn=2**n
ans=float("inf")
for _ in range(n//2+1):
  for com in itertools.combinations(N,2*_):
    i=0
    for ura in com:
      i+=2**ura
    E,O=[],[]
    for j in range(n):
      if i&(1<<j)==0:
        if j%2==0:
          E.append(A[j]*100+j)
        else:
          O.append(A[j]*100+j)
      else:
        if j%2==0:
          O.append(B[j]*100+j)
        else:
          E.append(B[j]*100+j)
    if len(E)!=(n+1)//2:
      continue
    else:
      E.sort()
      O.sort()

      chk=True
      C=[E[0]%100]
      prev=E[0]//100
      for i in range(1,n):
        ii=i//2
        if i%2==0:
          C.append(E[ii]%100)
          if E[ii]//100<prev:
            chk=False
            break
          else:
            prev=E[ii]//100
        else:
          C.append(O[ii]%100)
          if O[ii]//100<prev:
            chk=False
            break
          else:
            prev=O[ii]//100
    
    if chk:
      ans=min(ans,tentou(C))
print(-1 if ans==float("inf") else ans)
N,m = list(map(int,input().split()))
data = {}
for i in range(N):
	a,b = list(map(int,input().split()))
	data[a] = b
sortedData = sorted(data.items())
cost = 0
for i in range(N):
	v = sortedData[i][1]
	if m > v:
		cost += sortedData[i][0] * v
		m -= v
	else:
		cost += sortedData[i][0] * m
		print(cost)
		break

### FIXED CODE ###

N,m = list(map(int,input().split()))
data = [[0,0] for i in range(N)]
for i in range(N):
	data[i] = list(map(int,input().split()))
data.sort()
cost = 0
for i in range(N):
	prices,nums = data[i]
	if m > nums:
		cost += prices * nums
		m -= nums
	else:
		cost += prices * m
		print(cost)
		break
import numpy as np
import sys

def main():
    rule = {1:[0, 10], 2:[10, 100], 3:[100, 1000]}
    args = input().rstrip().split(' ')
    N, M = int(args[0]), int(args[1])
    query = []
    for i in range(M):
        args = input().rstrip().split(' ')
        query.append([int(args[0]), int(args[1])])
        
    for i in range(rule[N][0], rule[N][1]):
        if(N==1):
            val = np.array([i, -1,-1, -1, -1])
        elif(N==2):
            val = np.array([int(i/10), i%10, -1, -1, -1])
        else:
            val = np.array([int(i/100), int(i%100/10), i%10, -1, -1])
        
        flag = True
        for q in query:
            if(val[q[0]] != q[1]):
                flag = False
                break
        if(flag == True):
            print(i)
            sys.exit(1)
    print('-1')
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

import numpy as np

def main():
    rule = {1:[0, 10], 2:[10, 100], 3:[100, 1000]}
    args = input().rstrip().split(' ')
    N, M = int(args[0]), int(args[1])
    query = []
    for i in range(M):
        args = input().rstrip().split(' ')
        query.append([int(args[0]), int(args[1])])
        
    global_flag = False
    for i in range(rule[N][0], rule[N][1]):
        if(N==1):
            val = np.array([i, -1,-1, -1, -1])
        elif(N==2):
            val = np.array([int(i/10), i%10, -1, -1, -1])
        else:
            val = np.array([int(i/100), int(i%100/10), i%10, -1, -1])
        
        flag = True
        for q in query:
            if(val[q[0]-1] != q[1]):
                flag = False
                break
        if(flag == True):
            print(i)
            global_flag = True
            break
    if(global_flag == False):
        print('-1')
    
if __name__ == "__main__":
    main()
from collections import deque

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

links = [[] for _ in range(N + 1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)

result = [-1] * (N + 1)
q = deque([1])
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))

### FIXED CODE ###

num_town, num_move = map(int, input().split())
teleports = list(map(lambda x: int(x) - 1, input().split()))

current = 0
memo = {}
for i in range(num_move):
    if memo.get(current) == 2:
        break
    if not memo.get(current):
        memo[current] = 1
    else:
        memo[current] += 1
    destination = teleports[current]
    current = destination

loop = {k:v for k,v in memo.items() if v==2}
minus = {k:v for k,v in memo.items() if v==1}

new_move_count = 0
if len(loop) == 0:
    current = 0
    new_move_count = num_move
else:
    new_move_count = (num_move - len(minus)) % len(loop)

for i in range(new_move_count):
    destination = teleports[current]
    current = destination

print(current + 1)
code = input()

num = (str)code

if num[0] == num[1]:
    print('Bad')
elif num[1] == num[2]:
    print('Bad')
elif num[2] == num[3]:
    print('Bad')
else:
    print('Good')

### FIXED CODE ###

num = input()
#num = str(code)

if num[0] == num[1] or num[1] == num[2] or num[2] == num[3]:
    print('Bad')
else:
    print('Good')
import re
for e in sys.stdin:
    s=any([len(x)>1 and x[0]=='X' for x in re.split('[+=]',e)])
    for i in '0123456789'[s:]:
        if eval(e.replace('X',i).replace('=','==')):print(i);break
    else:print('NA')


### FIXED CODE ###

import sys
p,t='+X'
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*(e[1]!=p)or('+X'in e)*('+X='not in e):]:
  l,r=e.replace(t,i).split('=')
  if sum(map(int,l.split(p)))==int(r):print(i);break
 else:print('NA')
import sys 
import math

a, b = map(int, input().split(" "))
if N == 100:
     print(100**a*b+1)
else:
    print(100**a*b)

### FIXED CODE ###

import sys 
import math

a, b = map(int, input().split(" "))
if b == 100:
    print(100**a*b+100**a)
else:
    print(100**a*b)
def bfs(maze):
    d = [[0] * 70 for i in range(70)]
    d[1][1] = 1
    que = [(1, 1)]
    while 0 < len(que):
        new_que = []
        for x, y in que:
            if x == 2 * w - 1 and y == 2 * h - 1:
                return d[y][x]
            for dx, dy in ((0, 1), (-1, 0), (0, -1), (1, 0)):
                mx, my = x + dx, y + dy
                nx, ny = mx + dx, my + dy
                if nx < 0 and w < nx and ny < 0 and h < ny:
                    continue
                if maze[my][mx] == 0 and d[ny][nx] == 0:
                    new_que.append((nx, ny))
                    d[ny][nx] = d[y][x] + 1
        que = new_que
    return 0

while True:
    w, h = map(int, input().split())
    maze = [[0] * (w * 2) for i in range(h * 2)]
    if w == h == 0:
        break
    for x in range(w * 2 + 1):
        maze[0][x] = maze[h * 2][x] = 1
    for y in range(h * 2 + 1):
        maze[y][0] = maze[y][w * 2] = 1

    for y in range(1, h * 2):
        a = [int(i) for i in input().split()]
        if y % 2 == 1:
            for x in range(w - 1):
                maze[y][2 * x + 2] = a[x]
        else:
            for x in range(w):
                maze[y][2 * x + 1] = a[x]

    print(bfs(maze))

### FIXED CODE ###

def bfs(maze):
    d = [[0] * 65 for i in range(65)]
    d[1][1] = 1
    que = [(1, 1)]
    while que:
        x, y = que.pop(0)
        if x == 2 * w - 1 and y == 2 * h - 1:
            return d[y][x]
        for dx, dy in ((0, 1), (-1, 0), (0, -1), (1, 0)):
            mx, my = x + dx, y + dy
            nx, ny = mx + dx, my + dy
            if nx < 0 and w < nx and ny < 0 and h < ny:
                continue
            if maze[my][mx] == 0 and d[ny][nx] == 0:
                que.append((nx, ny))
                d[ny][nx] = d[y][x] + 1
    return 0

while True:
    w, h = map(int, input().split())
    maze = [[0] * 65 for i in range(65)]
    if w == h == 0:
        break
    for x in range(w * 2 + 1):
        maze[0][x] = maze[h * 2][x] = 1
    for y in range(h * 2 + 1):
        maze[y][0] = maze[y][w * 2] = 1

    for y in range(1, h * 2):
        a = [int(i) for i in input().split()]
        if y % 2 == 1:
            for x in range(w - 1):
                maze[y][2 * x + 2] = a[x]
        else:
            for x in range(w):
                maze[y][2 * x + 1] = a[x]

    print(bfs(maze))
# -*- coding: utf-8 -*-

asset = []

for b in range(1,1000):
    for p in range(2,100):
        tmp = pow(b, p)
        if tmp < 1001:
            if tmp not in asset:
                asset.append(tmp)

#print(asset)

x = int(input())

new_asset = []
for i in range(len(asset)):
    if asset[i] < x:
        new_asset.append(asset[i])

print(max(new_asset))

### FIXED CODE ###

# -*- coding: utf-8 -*-

x = int(input())

kk = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000]

ans = [i for i in kk if (i <= x)]
print(ans[-1])
N = int(input())
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
  A = [a / 2]
  count += 1
print(count)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
 
i = 0
odd = 0
while odd == 0:
    for n in range(N):
        if a[n] % 2 == 0:
            a[n] /= 2
        else:
            odd = 1
            break
    if odd == 0:
        i += 1
print(i)
N, Y=map(int,input().split())
flag=False

for i in range(0,N+1):
    for j in range(0, N+1):
        if Y==10000*(N-i-j)+5000*i+1000*j and i+j=<N:
            flag=True
            print(N-i-j, i, j)
            break
    if flag:
        break
else:
    print('-1 -1 -1')

### FIXED CODE ###

N, Y=map(int,input().split())
flag=False

for i in range(0,N+1):
    for j in range(0, N+1):
        if Y==10000*(N-i-j)+5000*i+1000*j and i+j<=N:
            flag=True
            print(N-i-j, i, j)
            break
    if flag:
        break
else:
    print('-1 -1 -1')
S = input()
T = input()

for i in range(len(S)):
    j = 0
    cnt = 0
    moji = []

    while j < len(T) and i+len(T)-1 < len(S):
        if S[i+j] == T[j] or S[i+j] == '?':
            cnt += 1
    if cnt == len(T):
        moji0 = S[0:i]+T+S[i+len(T)]
        moji1 = moji0.replace('?', 'a')
        moji.append(moji1)

    
print(min(moji))

### FIXED CODE ###

S = input()
T = input()

moji = []

for i in range(len(S)):
    j = 0
    cnt = 0
    
    while j < len(T) and i+len(T)-1 < len(S):
        if S[i+j] == T[j] or S[i+j] == '?':
            cnt += 1

        else:
            break
        j += 1
    
    if cnt == len(T):
        moji0 = ''
        if i == 0: moji0 = T+S[i+len(T):len(S)]
        elif i+len(T) > len(S)-1: 
            moji0 = S[0:i]+T
        else:
            moji0 = S[0:i]+T+S[i+len(T):len(S)]

        
        moji1 = moji0.replace('?', 'a')
        moji.append(moji1)

print(min(moji) if moji != [] else "UNRESTORABLE")
n,m = (int(i) for i in input().split())
res = list([] for i in range(n))
p,y = [],[]
for i in range(m):
    tmp = list(int(i) for i in input().split())
    p.append(tmp[0])
    y.append(tmp[1])
    res[tmp[0]-1].append(tmp[1])

for i in range(n):
    res[i] = sorted(res[i])

for i in range(n):
    print("{0:06d}{1:06d}".format(p[i], res[p[i]-1].index(y[i])+1))


### FIXED CODE ###

N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]

cs = [[] for i in range(N+1)]
for i,(p,y) in enumerate(src):
    cs[p].append((y,i))
for cc in cs:
    cc.sort()

ans = [None] * M
for p in range(len(cs)):
    for i,(_,j) in enumerate(cs[p]):
        s = str(p).zfill(6) + str(i+1).zfill(6)
        ans[j] = s
print(*ans, sep='\n')
import math
n,m=map(int(input().split()))
a=list(map(int,inpit().split()))
ans=0

for i in range(m):
  a=sorted(a,reverse=True)
  a[0]=math.floor(a[0]/2)
     
for j in range(n):
  ans+=a[j]
    
print(ans)

### FIXED CODE ###

import heapq as hq
n,m=map(int,input().split())
a=[-int(x) for x in input().split()]
hq.heapify(a)
for i in range(m):
    x=hq.heappop(a)
    x=-x//2
    hq.heappush(a,-x)
 
print(sum(a)*-1)
#D
import math
a,b = map(int,input().split())

gcd = math.gcd(a,b)

def prime_factorize(n):
    result = []
    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            n //= i
            result.append(i)
    if n != 1:
        result.append(n)
    return result

ans = len(set(prime_factorize(gcd)))

print(ans+1)

### FIXED CODE ###

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

gcd = fractions.gcd(a,b)

def prime_factorize(n):
    result = []
    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            n //= i
            result.append(i)
    if n != 1:
        result.append(n)
    return result

ans = len(set(prime_factorize(gcd)))

print(ans+1)
A,B,C = (input() for i in range(3))
count_A=1
count_B=0
count_C=0
arr = A[0]
for i in range(len(A)+len(B)+len(C)-1):
    arr = A[count_A] if arr=='a' else B[count_B] if arr=='b' else C[count_C]
    if arr=='a':
        count_A+=1
    elif arr=='b':
        count_B+=1
    else:
        count_C+=1
    if count_A==len(A):
        print('A')
        break
    elif count_B==len(B):
        print('B')
        break
    elif count_C==len(C):
        print('C')
        break
    else:
        continue

### FIXED CODE ###

a = input()
b = input()
c = input()
win = 'a'
while len(a)>=0 and len(b)>=0 and len(c)>=0:
    if win == 'a':
        if len(a)==0:
            break
        win = a[0]
        a = a[1:]
    elif win == 'b':
        if len(b)==0:
            break
        win = b[0]
        b = b[1:]
    else:
        if len(c)==0:
            break
        win = c[0]
        c = c[1:]
print('A' if win == 'a' else 'B' if win == 'b' else 'C')
a, b = map(int, input().split())

cnt = 0
p = 1

while p < b:
    p += a - 1
    cnt += 1
    
print(cnt)

### FIXED CODE ###

a=input()
b=input()

cnt=0

for i, j in zip(a, b):
  if i==j:
    cnt+=1
    
print(cnt)
import sys
import collections
n=int(raw_input())
ans=collections.deque()
while n:
    n-=1
    s=sys.stdin.readline().rstrip().split(' ')
    if s[0][0]=='i':
        ans.appendleft(s[1])
    elif s[0][-3]=='r':
        ans.popleft()
    elif s[0][-3]=='a':
        ans.pop()
    else:
        ans.remove(s[1])
sys.stdout.write(' '.join(ans))
print

### FIXED CODE ###

import sys
import collections
n=int(raw_input())
ans=collections.deque()
while n:
    n-=1
    s=sys.stdin.readline().rstrip().split(' ')
    if s[0][0]=='i':
        ans.appendleft(s[1])
    elif s[0][-3]=='r':
        ans.popleft()
    elif s[0][-3]=='a':
        ans.pop()
    else:
        try:
            ans.remove(s[1])
        except:
            pass
sys.stdout.write(' '.join(ans))
print
#include<stdio.h>
#include <string>

int main(){
    char *s;
    scanf("%s",s);
    s[0] = '2';
    s[1] = '0';
    s[2] = '1';
    s[3] = '8';
    printf("%s" ,s);
    return 0;
}

### FIXED CODE ###

# -*- coding: utf-8 -*-
s = input()
print("2018" + s[4:len(s)])
import math
import functools

N = int(input())
A = [int(_) for _ in input().split()]
p = set([])

y = functools.reduce(math.gcd, A)
pairwise = True

for a in A:
    if a == 1:
        continue
    if pairwise is False:
        break
    for k in range(2, int(math.sqrt(a)) + 2):
        if a % k == 0:
            if k in p:
                pairwise = False
                break
            p.add(k)
            while a % k == 0:
                a //= k
    if pairwise and a > 1:
        p.add(a)

if pairwise:
    print("pairwise coprime")
elif y == 1:
    print("setwize coprime")
else:
    print("not coprime")


### FIXED CODE ###

class UnionFind:
    def __init__(self, N):
        self.root = [-1 for _ in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        while self.root[x] >= 0:
            x = self.root[x]
        return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.root[x] = y
            self.size[y] += self.size[x]
        else:
            self.root[y] = x
            self.size[x] += self.size[y]

N, M = [int(_) for _ in input().split()]

uf = UnionFind(N)
for m in range(M):
    A, B = [int(_) - 1 for _ in input().split()]
    uf.union(A, B)

print(max(uf.size))
from itertools import permutations

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

Matrix = [[False for i in range(N)] for j in range(N)] #隣接行列

for i in range(N) :
    Matrix[i][i] = True

for i in range(N) :
    row,column = map(int,input().split())
    Matrix[row-1][column-1] = True
    Matrix[column-1][row-1] = True
    
arange = list(range(2,N+1))
ans = 0
for pm in permutations(arange) :
    P = [1] + list(pm)
    for row,column in zip(P,P[1:]) :
        if not Matrix[row-1][column-1] :
            break
    else :
        ans += 1
print(ans)


### FIXED CODE ###

from itertools import permutations

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

L = [[False for i in range(N)] for j in range(N)]

for i in range(N) :
    L[i][i] = True
for i in range(M) :
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    L[a][b] = True
    L[b][a] = True

arange = range(2,N+1)

res = 0
for P in permutations(arange) :
    P = [1] + list(P)
    for S,G in zip(P,P[1:]) :
        if not L[S-1][G-1] :
            break
    else :
        res += 1
print(res)
n = int(input())
l = []
for i in range(1, 10):
  for j in range(1, 10):
    l.appned(i, j)

if n in l:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
l = []
for i in range(1, 10):
  for j in range(1, 10):
    l.append(i*j)

if n in l:
  print("Yes")
else:
  print("No")
import sys

# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def parse(args, *params):
    return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
    print(*v, file=sys.stderr)

# エントリーポイント
def main(args):
    N, M = parse(args, int, int)
    A = map(int, next(args).split())

    #       1  2  3  4  5  6  7  8  9
    nums = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    dp = [[]] + [[] for _ in range(N)]
    for a in A:
        na = nums[a - 1]
        def chmax(c):
            nl = sorted(dp[c - na] + [a], reverse=True)
            if len(nl) < len(dp[c]):
                return dp[c]
            if len(dp[c]) < len(nl):
                return nl
            return max(nl, dp[c])
        dp[na] = chmax(na)
        for c in range(na + 1, N + 1):
            if dp[c - na]:
                dp[c] = chmax(c)
    for i, v in enumerate(dp, start=0):
        debug(i, v)
    print(*dp[N], sep="")

if __name__ == '__main__':
    main(iter(sys.stdin.read().split("\n")))


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))

costs = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]

# 優先度：桁数, [要素(降順)]
dp = [[0, []] for _ in range(N + 1)]
for a in A:
	cost = costs[a]
	for n in range(N):
		if n != 0 and dp[n][0] == 0:
			continue
		ni = n + cost
		if N < ni:
			break
		np = [dp[n][0] + 1, sorted(dp[n][1] + [a], reverse=True)]
		if dp[ni] < np:
			dp[ni] = np

print(*sorted(dp[N][1], reverse=True), sep="")
#素因数分解
def prime_factorization(N):
    n=N
    a=2
    prime_factor=[]
    while a**2<=n:
        while n%a==0:
            prime_factor.append(a)
            n//=a
        a+=1
    if n>1:
        prime_factor.append(n)
    return prime_factor


# N=100
N=int(input())

a=1
b=N//a
dis=abs(a-b)

Li=prime_factorization(N)
# print(Li)

if len(Li)>=6:
    math.random()
    


for p in range(2**len(Li)):
    bit=[]
    for e in range(len(Li)):
        if (p>>e)&1==1:
            bit.append(1)
        else:
            bit.append(0)
    # print(bit)
        proindex=[]
        for _ in range(len(bit)):
            if bit[_] ==1:
                proindex.append(_)
        _a=1
        for j in range(len(Li)):
            if proindex.count(j)==1:
                _a*=Li[j]
        _b=N//_a
        _dis=abs(_a-_b)
        if _dis<dis:
            a=_a
            b=_b
            dis=_dis
# print(a,b)


print(a-1+b-1)

### FIXED CODE ###

N=int(input())

a=1
b=N//a
dis=abs(b-a)

for i in range(1,int(N**0.5)+1):
    if N%i==0:
        _a=i
        _b=N//i
        _dis=abs(_b-_a)
        if _dis<dis:
            a=_a
            b=_b
            dis=_dis

print(a-1+b-1)
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i,m):
  if m == 0:
    return True
  if i >= n:
    return False
  res = solve(i,m) or solve(i, m - A[i])
  return res

for m in M:
    if solve(0, m):
      print 'yes'
    else:
      print 'no'

### FIXED CODE ###

n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

min = min(A)
sum = sum(A)

def solve(i,m):
  if sum < m:
    return False
  if m == 0:
    return True
  if i >= n:
    return False
  res = solve(i+1,m) or solve(i+1, m - A[i])
  return res
 
for m in M:
    if solve(0, m):
      print 'yes'
    else:
      print 'no'