Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = input()
    A = map(int,raw_input().split())
    q = input()
    M = map(int,raw_input().split())

    for m in M:
        for j in range(n):
            w = rec(m,A[j:])

            if w:
                break
        if w:
            print "yes"
        else:
            print "no"

def rec(m,A):
    m_new = m
    if m_new == 0:
        r1 = True
    elif m_new < 0:
        r1 = False
    else:
        if len(A) == 1:
            r1 = False
        else:
            r1 = rec(m_new,A[1:])

    m_new = m - A[0]
    if m_new == 0:
        r2 = True
    elif m_new < 0:
        r2 = False
    else:
        if len(A) == 1:
            r2 = False
        else:
            r2 = rec(m_new,A[1:])

    if r1 or r2:
        return True
    else:
        return False

if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = input()
    A = map(int,raw_input().split())
    q = input()
    M = map(int,raw_input().split())

    for m in M:
        for j in range(n):
            w = rec(m,A[j:])
            if w:
                break
        if w:
            print "yes"
        else:
            print "no"

def rec(m,A):
    r1 = rec1(m,A)
    r2 = rec1(m-A[0],A)

    if r1 or r2:
        return True
    else:
        return False

def rec1(m_new,A):
    if m_new == 0:
        return True
    elif m_new < 0:
        return False
    else:
        if len(A) == 1:
            return False
        else:
            return rec(m_new,A[1:])
    

if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

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

    for m in M:
        qA = deque(A)
        for j in range(n):
            w = rec(m,A)
            if w:
                break
            qA.popleft()
            
        if w:
            print "yes"
        else:
            print "no"

def rec(m,A):
    Ac = deque(list(A)[:])
    Ad = deque(list(A)[:])
    r1 = rec1(m,Ac)
    r2 = rec1(m-A[0],Ad)

    if r1 or r2:
        return True
    else:
        return False

def rec1(m_new,A):
    #print A
    if m_new == 0:
        return True
    elif m_new < 0:
        return False
    else:
        if len(A) == 1:
            return False
        else:
            A.popleft()
            return rec(m_new,A)
    

if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

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

    for m in M:
        w = sub(m,n,A)
        print w
        
def sub(m,n,A):
    qA = deque(A)
    for j in range(n):
        w = rec(m,qA)
        if w:
            break
        qA.popleft()            
    if w:
        return "yes"
    else:
        return "no"
    
def rec(m,A):
    Ac = deque(list(A)[:])
    Ad = deque(list(A)[:])
    r1 = rec1(m,Ac)
    r2 = rec1(m-A[0],Ad)

    if r1 or r2:
        return True
    else:
        return False

def rec1(m_new,A):
    #print A
    if m_new == 0:
        return True
    elif m_new < 0:
        return False
    else:
        if len(A) == 1:
            return False
        else:
            A.popleft()
            return rec(m_new,A)
    

if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

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

    W = map(lambda m:sub(m,n,A), M)
    for w in W:
        print w
        
def sub(m,n,A):
    qA = deque(A)
    for j in range(n):
        w = rec(m,qA)
        if w:
            break
        qA.popleft()            
    if w:
        return "yes"
    else:
        return "no"
    
def rec(m,A):
    Ac = deque(list(A)[:])
    Ad = deque(list(A)[:])
    r1 = rec1(m,Ac)
    r2 = rec1(m-A[0],Ad)

    if r1 or r2:
        return True
    else:
        return False

def rec1(m_new,A):
    #print A
    if m_new == 0:
        return True
    elif m_new < 0:
        return False
    else:
        if len(A) == 1:
            return False
        else:
            A.popleft()
            return rec(m_new,A)
    

if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

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

    W = map(lambda m:sub(m,n,A), M)
    for w in W:
        print w
        
def sub(m,n,A):
    qA = deque(A)
    for j in range(n):
        w = rec(m,qA)
        if w:
            break
        qA.popleft()            
    if w:
        return "yes"
    else:
        return "no"
    
def rec(m,A):
    Ac = deque(list(A)[:])
    Ad = deque(list(A)[:])
    m_new = m
    if m_new == 0:
        r1 = True
    elif m_new < 0:
        r1 = False
    else:
        if len(A) == 1:
            r1 = False
        else:
            Ac.popleft()
            r1 = rec(m_new,Ac)
    m_new = m - Ad[0]
    if m_new == 0:
        r2 = True
    elif m_new < 0:
        r2 = False
    else:
        if len(A) == 1:
            r2 = False
        else:
            Ad.popleft()
            r2 = rec(m_new,Ad)
    if r1 or r2:
        return True
    else:
        return False

if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

class MyClass():    
    def load(self):
        self.n = input()
        self.A = map(int,raw_input().split())
        self.q = input()
        self.M = map(int,raw_input().split())

    def main(self):
        self.load()
        W = map(self.solve,self.M)
        for w in W:
            print w

    def solve(self,m):
        qA = deque(self.A)
        for j in range(self.n):
            w = self.rec(m,qA)
            if w:
                break
            qA.popleft()            
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        Ac = deque(list(A))
        Ad = deque(list(A))
        m_new = m
        if m_new == 0:
            r1 = True
        elif m_new < 0:
            r1 = False
        else:
            if len(A) == 1:
                r1 = False
            else:
                Ac.popleft()
                r1 = self.rec(m_new,Ac)
        m_new = m - Ad[0]
        if m_new == 0:
            r2 = True
        elif m_new < 0:
            r2 = False
        else:
            if len(A) == 1:
                r2 = False
            else:
                Ad.popleft()
                r2 = self.rec(m_new,Ad)
        if r1 or r2:
            return True
        else:
            return False

if __name__ == "__main__":
    MC = MyClass()
    MC.main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

class MyClass():    
    def load(self):
        self.n = input()
        self.A = map(int,raw_input().split())
        self.q = input()
        self.M = map(int,raw_input().split())

    def main(self):
        self.load()
        W = map(self.solve,self.M)
        for w in W:
            print w

    def solve(self,m):
        qA = deque(self.A)
        for j in range(self.n):
            w = self.rec(m,qA)
            if w:
                break
            qA.popleft()            
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        Ac = deque(list(A))
        Ad = deque(list(A))
        m_new = m
        if m_new < 0:
            r1 = False
        elif m_new == 0:
            r1 = True
        else:
            if len(A) == 1:
                r1 = False
            else:
                Ac.popleft()
                r1 = self.rec(m_new,Ac)
        m_new = m - Ad[0]
        if m_new < 0:
            r2 = False
        elif m_new == 0:
            r2 = True
        else:
            if len(A) == 1:
                r2 = False
            else:
                Ad.popleft()
                r2 = self.rec(m_new,Ad)
        if r1 or r2:
            return True
        else:
            return False
if __name__ == "__main__":
    MC = MyClass()
    MC.main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

class MyClass():    
    def load(self):
        self.n = input()
        self.A = map(int,raw_input().split())
        self.q = input()
        self.M = map(int,raw_input().split())

    def main(self):
        self.load()
        W = map(self.solve,self.M)
        for w in W:
            print w

    def solve(self,m):
        qA = deque(self.A)
        for j in range(self.n):
            w = self.rec(m,list(qA))
            if w:
                break
            qA.popleft()            
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        m_new = m
        if m_new < 0:
            r1 = False
        elif m_new == 0:
            r1 = True
        else:
            if len(A) == 1:
                r1 = False
            else:
                r1 = self.rec(m_new,A[1:])
        m_new = m - A[0]
        if m_new < 0:
            r2 = False
        elif m_new == 0:
            r2 = True
        else:
            if len(A) == 1:
                r2 = False
            else:
                r2 = self.rec(m_new,A[1:])
        if r1 or r2:
            return True
        else:
            return False

if __name__ == "__main__":
    MC = MyClass()
    MC.main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

class MyClass():    
    def load(self):
        self.n = input()
        self.A = map(int,raw_input().split())
        self.q = input()
        self.M = map(int,raw_input().split())

    def main(self):
        self.load()
        W = map(self.solve,self.M)
        for w in W:
            print w

    def solve(self,m):
        qA = deque(self.A)
        for j in range(self.n):
            w = self.rec(m,list(qA))
            if w:
                break
            qA.popleft()
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        if len(A) == 1:
            r1 = False
        else:
            r1 = self.rec(m,A[1:])
        m_new = m - A[0]
        if m_new < 0:
            r2 = False
        elif m_new == 0:
            r2 = True
        else:
            if len(A) == 1:
                r2 = False
            else:
                r2 = self.rec(m_new,A[1:])
        if r1 or r2:
            return True
        else:
            return False

if __name__ == "__main__":
    MC = MyClass()
    MC.main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

class MyClass():    
    def load(self):
        self.n = input()
        self.A = map(int,raw_input().split())
        self.q = input()
        self.M = map(int,raw_input().split())

    def main(self):
        self.load()
        W = map(self.solve,self.M)
        for w in W:
            print w

    def solve(self,m):
        qA = deque(self.A)
        for j in range(self.n):
            w = self.rec(m,list(qA))
            if w:
                break
            qA.popleft()
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        if len(A) == 0:
            return False
        else:
            r1 = self.rec(m,A[1:])
            m_new = m - A[0]
            if m_new < 0:
                r2 = False
            elif m_new == 0:
                r2 = True
            else:
                r2 = self.rec(m_new,A[1:])
            
            if r1 or r2:
                return True
            else:
                return False

if __name__ == "__main__":
    MC = MyClass()
    MC.main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
class MyClass():
    def main(self):
        self.n = input()
        self.A = map(int,raw_input().split())
        self.q = input()
        self.M = map(int,raw_input().split())
        
        W = map(self.solve,self.M)
        for w in W:
            print w

    def solve(self,m):
        w = self.rec(m,self.A)
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        if len(A) == 1:
            r1 = False
        else:
            r1 = self.rec(m,A[1:])
        
        m_new = m - A[0]
        if m_new < 0:
            r2 = False
        elif m_new == 0:
            r2 = True
        elif len(A) == 1:
            r2 = False
        else:
            r2 = self.rec(m_new,A[1:])
        
        if r1 or r2:
            return True
        else:
            return False

if __name__ == "__main__":
    MC = MyClass()
    MC.main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
class MyClass():
    def main(self):
        self.n = input()
        self.A = map(int,raw_input().split())
        self.q = input()
        self.M = map(int,raw_input().split())
        
        W = map(self.solve,self.M)
        for w in W:
            print w

    def solve(self,m):
        w = self.rec(m,self.A)
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        if len(A) == 1:
            r1 = False
        else:
            r1 = self.rec(m,A[1:])
        
        m_new = m - A[0]
        if m_new < 0:
            r2 = False
        elif m_new == 0:
            r2 = True
        elif m_new < min(A[1:]) or len(A) == 1:
            r2 = False
        else:
            r2 = self.rec(m_new,A[1:])
        
        if r1 or r2:
            return True
        else:
            return False
    
if __name__ == "__main__":
    MC = MyClass()
    MC.main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
class MyClass():
    def main(self):
        self.n = input()
        self.A = map(int,raw_input().split())
        self.q = input()
        self.M = map(int,raw_input().split())
        
        W = map(self.solve,self.M)
        for w in W:
            print w

    def solve(self,m):
        w = self.rec(m,self.A)
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        if len(A) == 1:
            r1 = False
        else:
            r1 = self.rec(m,A[1:])
        
        m_new = m - A[0]
        if m_new < 0:
            r2 = False
        elif m_new == 0:
            r2 = True
        elif len(A) == 1 or m_new < min(A[1:]):
            r2 = False
        else:
            r2 = self.rec(m_new,A[1:])
        
        if r1 or r2:
            return True
        else:
            return False
    
if __name__ == "__main__":
    MC = MyClass()
    MC.main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from collections import deque
import numpy as np

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    a = np.array([0])
    p = rec(a,A)

    for m in M:
        print "yes" if m in p else "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        a = np.append(a,a+A.popleft())
        return rec(a,A)

if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from collections import deque
import numpy as np

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    a = np.array([0])
    p = rec(a,A)

    for m in M:
        print "yes" if m in p else "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        a = np.append(a,a+A.popleft())
        return rec(a,A)

if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()