Harryxun/stf_run huggingface dataset:
road_par = []
road_rank = []
rail_par = []
rail_rank = []
c1 = []
c2 = []

def init(par, rank, c, n):
    for i in range(n):
        par.append(i)
        rank.append(0)
        c.append(0)


def find(par,x):
    if par[x] == x:
        return x
    par[x] = find(par, par[x])
    return par[x]


def unite(par, rank, x, y):
    x = par[x]; y = par[y]
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    elif rank[y] < rank[x]:
        par[y] = x
    else:
        par[y] = x
        rank[x] += 1


def same(par, x, y):
    if find(par, x) == find(par, y):
        return True
    else:
        return False


N, K, L = map(int, input().split())
init(road_par, road_rank, c1, N)
init(rail_par, rail_rank, c2, N)

for i in range(K):
    f, t = map(int, input().split())
    unite(road_par, road_rank, f-1, t-1)

for i in range(L):
    f,t = map(int, input().split())
    unite(rail_par, rail_rank, f-1, t-1)

for i in range(N):
    c1[find(road_par, i)] += 1
    c2[find(rail_par, i)] += 1

for i in range(N):
    if c1[i] == 1:
        road_par[i] = -1
    if c2[i] == 1:
        rail_par[i] = -1

ans = [0 for i in range(N)]
for i in range(N):
    if road_par[i] != -1:
        ans[i] +=1
    if rail_par[i] != -1:
        ans[i] += 1

for i in range(N):
    print(ans[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

road_par = []
road_rank = []
rail_par = []
rail_rank = []
c1 = []
c2 = []

def init(par, rank, c, n):
    for i in range(n):
        par.append(i)
        rank.append(0)
        c.append(0)


def find(par,x):
    if par[x] == x:
        return x
    par[x] = find(par, par[x])
    return par[x]


def unite(par, rank, x, y):
    x = find(par, x); y = find(par, y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    elif rank[y] < rank[x]:
        par[y] = x
    else:
        par[y] = x
        rank[x] += 1


N, K, L = map(int, input().split())
init(road_par, road_rank, c1, N)
init(rail_par, rail_rank, c2, N)


for i in range(K):
    f, t = map(int, input().split())
    unite(road_par, road_rank, f-1, t-1)

for i in range(L):
    f,t = map(int, input().split())
    unite(rail_par, rail_rank, f-1, t-1)

for i in range(N):
    c1[find(road_par, i)] += 1
    c2[find(rail_par, i)] += 1

ans = [0 for i in range(N)]

"""
for i in range(N):
    for j in range(N):
        if find(road_par, i) == find(road_par, j) and find(rail_par, i) == find(rail_par, j):
            ans[i] += 1
"""
from collections import defaultdict
ans = defaultdict(int)
for i in range(N):
    ans[(find(road_par, i), find(rail_par, i))] += 1

for i in range(N):
    print(ans[(find(road_par, i), find(rail_par, i))], end=' ')
print('')
import math
N = int(input())
a = list(map(int, input().split()))


def lcm(m, n):
    return (m // math.gcd(m, n)) * n


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(int(ans % int(1e9+7)))


### FIXED CODE ###

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


def lcm(m, n):
    return (m // fractions.gcd(m, n)) * n


mod = 10**9+7
lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(ans % mod)
H,W = input().split()
H,W = int(H),int(W)
nodes = [list(input()) for i in range(H)]


if H == 1 and W == 1 and nodes[0][0] == ".":
    print("No")
    quit()
if H == 1 and W == 1 and nodes[0][0] == "#":
    print("Yes")
    quit()


for i in range(H):
    for j in range(W):
        if nodes[i][j] == "#":
            flag = False
            if i - 1 >= 0:
                if nodes[i-1][j] == "#":
                    flag = True
            if i + 1 < H:
                if nodes[i+1][j] == "#":
                    flag = True
            if j - 1 >= 0:
                if nodes[i][j-1] == "#":
                    flag = True
            if j + 1 < W:
                if nodes[i][j+1] == "#":
                    flag = True

            if flag == False:
                print("No")
                quit()

print("Yes")

### FIXED CODE ###

a,b = input().split()
a = int(a)
b = int(b)
ans = 0
if a <= b:
    ans = a
else:
    ans = a - 1
print(ans)
A, B C = map(int,input().split())

if (A-B)>=C:
  print(C)
else:
  print(A-B)

### FIXED CODE ###

A, B ,C = map(int,input().split())
 
if (A-B)>=C:
  print(0)
else:
  print(C-(A-B))
a, b = input().split()
print(int(a*b))

### FIXED CODE ###

a, b = map(int, input().split())
print(a*b)
n=input()
s1,s2=input()      
nm=0
nm1=0
cnt=s1+s2
for i in cnt:
      if i=='A' or i=='B':
              nm+=1
              nm1=max(nm1,nm)
      else:
              nm=0
print(nm1)

### FIXED CODE ###

N = int(input())
c1 = 0
c2 = 0
c3 = 0
count = 0
for i in range(N):
  s = input()
  count += s.count('AB')
  if s[0] == 'B' and s[-1] == 'A':
    c1 += 1
  elif s[0] == 'B' and s[-1] != 'A':
    c2 += 1
  elif s[0] != 'B' and s[-1] == 'A':
    c3 += 1
  else:
    pass

if c1 == 0:
  print(count + min(c2,c3))
else:
  if c2 > 0 or c3 > 0:
    print(count + c1 + min(c2,c3))
  else:
    print(count + c1-1)
N = input()

for char in N:
  if char = '7':
    print('Yes')

print('No')

### FIXED CODE ###

N = input()

flag = False

for char in N:
  if char == '7':
    print('Yes')
    flag = True
    break

if flag == False:   
  print('No')
N = int(input())
S = list(input())

ans = 0
for i in range(N-2):
    if S[i] == "#" and S[i+1] == "#" and S[i+2] == ".":
        ans += 1
        S[i+2] = "#"
    elif S[i] == "#" and S[i+1] == "." and S[i+2] == ".":
        ans += 1
        S[i] = "."
    elif S[i] == "#" and S[i+1] == "." and S[i+2] == "#":
        ans += 1
        S[i] = "."
if S[-2] == "#" and S[-1] == ".":
    ans += 1

print(ans)


### FIXED CODE ###

from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    s = input()
    black = s.count("#")
    white = len(s) - black
    ans = min(black, white)
    
    b,w = 0,0
    for i in range(len(s)):
        if s[i] == "#":
            b += 1
        else:
            w += 1
        
        ans = min(ans, b + (white - w))
    print(ans)

if __name__ == '__main__':
    main()
S = input()
count = 0
for i in range(int(len(S)/2)):
  if S[i] != S[len(S)-i]:
    count += 1
print(count)

### FIXED CODE ###

S = input()
count = 0
for i in range(int(len(S)/2)):
  if S[i] != S[len(S)-i-1]:
    count += 1
print(count)
N, M = map(int, input().split())
Bridge= [[int(i) for i in input().split()] for _ in range(M)]
Parent = [int(i) for i in range(N)]
Rank = [1] * N
 
def find(x):
    if x == Parent[x]: return x
    else:
        Parent[x] = y = find(Parent[x])
        return y
 
def unite(x, y, Total):
    rx, ry = find(x), find(y)
    if rx == ry: return Total
    else:
    	Total -= Rank[rx] * Rank[ry]
        if rx > ry:
    		Parent[rx] = ry
    		Rank[ry] += Rank[rx]
        else:
          Parent[ry] = rx
          Rank[rx] += Rank[ry]
    	return Total
 
Total = N * (N - 1) // 2
Ans = str(Total)
for i in reversed(range(1, M)):
    A, B = Bridge[i]
    A -= 1
    B -= 1
    Total = unite(A, B, Total)
    Ans = str(Total) + "\n" + Ans  
 
print(Ans)

### FIXED CODE ###

N, M = map(int, input().split())
Bridge= [[int(i) for i in input().split()] for _ in range(M)]
Parent = [int(i) for i in range(N)]
Rank = [1] * N
 
def find(x):
    if x == Parent[x]: return x
    else:
        Parent[x] = y = find(Parent[x])
        return y
 
def unite(x, y, Total):
    rx, ry = find(x), find(y)
    if rx == ry: return Total
    else:
      Total -= Rank[rx] * Rank[ry]
      if Rank[rx] < Rank[ry]:
        Parent[rx] = ry
        Rank[ry] += Rank[rx]
      else:
        Parent[ry] = rx
        Rank[rx] += Rank[ry]
      return Total
 
Total = N * (N - 1) // 2
Ans = [Total] * M
for i in reversed(range(1, M)):
    A, B = Bridge[i]
    Total = unite(A-1, B-1, Total)
    Ans[i-1] = Total  
 
print("\n".join(map(str, Ans)))
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
      return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
ans = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod 
if ans < 0:
  ans += mod
print(ans)


### FIXED CODE ###

def pow(a,b,c):
    ans = 1
    while b > 0:
        if b & 1:
            ans = ans*a % c
        a = a*a % c
        b = b >> 1
    return ans
def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(n-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num*pow(den,c-2,c) % c
mod = 10**9+7
n,a,b = map(int,input().split())
ans  = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod
if ans < 0:
    ans = ans + mod
print(ans)
a=int(input())
s=set(a)
i=1
while True:
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|=｛a｝
  i+=1
print(i)

### FIXED CODE ###

a=int(input())
s={a}
i=1
while True:
  i+=1
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|={a}
print(i)
import math
for i in range(input()):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
    if y2==y1 or y3==y1:
        if y2==y1:
            a2=-(x3-x1)/(y3-y1)
            b2=((y3+y1)-a2*(x1+x3))/2
            a,b,c,d,e,f=0,1,(x1+x2)/2,-a2,1,b2
        else:
            a1=-(x2-x1)/(y2-y1)
            b1=((y2+y1)-a2*(x1+x2))/2
            a,b,c,d,e,f=-a1,1,b1,0,1,(x1+x3)/2
    else:
        a1=-(x2-x1)/(y2-y1)
        a2=-(x3-x1)/(y3-y1)
        b1=((y2+y1)-a1*(x1+x2))/2
        b2=((y3+y1)-a2*(x1+x3))/2
        a,b,c,d,e,f=-a1,1,b1,-a2,1,b2
    py=(a*f-c*d)/(a*e-b*d)
    px=(c*e-f*b)/(a*e-b*d)
    r=math.sqrt((px-x1)**2 + (py-y1)**2)
    print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r)

### FIXED CODE ###

import math
for i in range(input()):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
    if y2==y1 or y3==y1:
        if y2==y1:
            a2=-(x3-x1)/(y3-y1)
            b2=((y3+y1)-a2*(x1+x3))/2.0
            a,b,c,d,e,f=1.0,0.0,(x1+x2)/2.0,-a2,1.0,b2
        else:
            a1=-(x2-x1)/(y2-y1)
            b1=((y2+y1)-a1*(x1+x2))/2.0
            a,b,c,d,e,f=-a1,1.0,b1,1.0,0.0,(x1+x3)/2.0
    else:
        a1=-(x2-x1)/(y2-y1)
        a2=-(x3-x1)/(y3-y1)
        b1=((y2+y1)-a1*(x1+x2))/2.0
        b2=((y3+y1)-a2*(x1+x3))/2.0
        a,b,c,d,e,f=-a1,1.0,b1,-a2,1.0,b2
    py=(a*f-c*d)/(a*e-b*d)
    px=(c*e-f*b)/(a*e-b*d)
    r=math.sqrt((px-x1)**2 + (py-y1)**2)
    print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r)
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b=input().split("")

if a==b:
	print("H")
else:
	print("D")
	

### FIXED CODE ###

import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b=input().split()

if a==b:
	print("H")
else:
	print("D")
# -*- coding: utf-8 -*-

import sys

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def slope(p1, p2):
    return (p2.y-p1.y)/(p2.x-p1.x) if p2.x != p1.x else sys.intmax

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    p4 = Point_Class(x4, y4)
    print "YES" if slope(p1, p2) == slope(p3, p4) else "NO"

### FIXED CODE ###

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

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split())
    print "YES" if abs(((y2-y1)*(x4-x3) - (x2-x1)*(y4-y3))) < 1e-10 else "NO"
# E - Multiplication 4
import heapq
N, K = map(int, input().split())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7

# N = K の時
if N == K:
    ans = 1
    for a in A:
        ans = (ans * a) % MOD

else:
    pos = []
    neg = []
    for a in A:
        if a >= 0:
            pos.append(a)
        else:
            neg.append(a)

    # 必ずマイナスになる時＝全てがマイナスの値であり、
    # かつKが奇数の時
    if len(neg) == N and K&1 == 1:
        neg.sort(reverse=True)
        ans = 1
        for i in range(K):
            ans = (ans * neg[i]) % MOD

    # それ以外のプラスになるケース
    # プラスの要素とマイナスの要素を絶対値の大きい順にソートし、
    # Kが奇数であれば、プラスのリストから1つ選び、
    # 残りの偶数個のKに対して、２つずつを選んだ時の
    # 大きい方から取得していく
    else:
        pos.sort(reverse=True)
        pos2 = []
        ans = 1
        ini = 0
        rem = K
        if K&1 == 1:
            ans = (ans * pos[0]) % MOD
            ini = 1
            rem -= 1
        for i in range(ini, len(pos)//2, 2):
            heapq.heappush(pos2, (pos[i] * pos[i+1])*-1)
        neg.sort()
        neg2 = []
        for i in range(0, len(neg)//2, 2):
            heapq.heappush(neg2, (neg[i] * neg[i+1]) * -1)
        while rem > 0:
            if (pos2 != [] and neg2 != [] and pos2[0] <= neg2[0]) or (pos2 != [] and neg2 == []):
                tmp = heapq.heappop(pos2) * -1
            else:
                tmp = heapq.heappop(neg2) * -1
            ans = (ans * tmp) % MOD
            rem -= 2

print(ans)

### FIXED CODE ###

# E - Multiplication 4
import heapq
N, K = map(int, input().split())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7

# N = K の時
if N == K:
    ans = 1
    for a in A:
        ans = (ans * a) % MOD

else:
    pos = []
    neg = []
    for a in A:
        if a >= 0:
            pos.append(a)
        else:
            neg.append(a)

    # 必ずマイナスになる時＝全てがマイナスの値であり、
    # かつKが奇数の時
    if len(neg) == N and K&1 == 1:
        neg.sort(reverse=True)
        ans = 1
        for i in range(K):
            ans = (ans * neg[i]) % MOD

    # それ以外のプラスになるケース
    # プラスの要素とマイナスの要素を絶対値の大きい順にソートし、
    # Kが奇数であれば、プラスのリストから1つ選び、
    # 残りの偶数個のKに対して、２つずつを選んだ時の
    # 大きい方から取得していく
    else:
        pos.sort(reverse=True)
        pos2 = []
        ans = 1
        ini = 0
        rem = K
        if K&1 == 1:
            ans = (ans * pos[0]) % MOD
            ini = 1
            rem -= 1
        for i in range(0, (len(pos)-ini)//2):
            heapq.heappush(pos2, (pos[i*2+ini] * pos[i*2+ini+1])*-1)
        neg.sort()
        neg2 = []
        for i in range(0, len(neg)//2):
            heapq.heappush(neg2, (neg[i*2] * neg[i*2+1]) * -1)
        while rem > 0:
            if (pos2 != [] and neg2 == []) or (pos2 != [] and neg2 != [] and pos2[0] <= neg2[0]):
                tmp = heapq.heappop(pos2) * -1
            else:
                tmp = heapq.heappop(neg2) * -1
            ans = (ans * tmp) % MOD
            rem -= 2

print(ans)
s = input()
a = 's'
if s[-1] == 's':
    a = 'es'
s.append(a)

### FIXED CODE ###

s = input()
a = 's'
if s[-1] == 's':
    a = 'es'
s = s + a
print(s)
while True:
	ans = 0
	n = int(raw_input())
	for i in xrange(10):
		for j in xrange(10):
			for k in xrange(10):
				for l in xrange(10):
					if i+j+k+l == n:
						ans += 1
	print ans

### FIXED CODE ###

while True:
	try:
		ans = 0
		n = int(raw_input())
		for i in xrange(10):
			for j in xrange(10):
				for k in xrange(10):
					for l in xrange(10):
						if i+j+k+l == n:
							ans += 1
		print ans
	except EOFError:
		break
import math
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
print(math.ceil(N/min(A,B,C,D,E)+4)


### FIXED CODE ###

import math
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
print(math.ceil(N/min(A,B,C,D,E)+4))
print(int(input())*6.3)


### FIXED CODE ###

print(int(input())*6.3)
N, K = map(int, input())

ans = 1
while 1:
  if N >= K ** ans:
    ans += 1
    continue
  else:
    print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
 
ans = 1
while 1:
  if N >= K ** ans:
    ans += 1
    continue
  else:
    print(ans)
    break
import itertools

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

cnt = 0

K = list(range(K + 1))

for i, j in itertools.product(K, repeat=2):
    if 0 <= S - i - j <= K:
        cnt += 1

print(cnt)


### FIXED CODE ###

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

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j <= K:
            cnt += 1

print(cnt)
s = input()
t = '2018'

for i in range(len(s))
  if i > 3:
    print(s[i],sep='',end='')
  else:
    print(t[i],sep='',end='')

### FIXED CODE ###

s = input()
t = '2018'

for i in range(len(s)):
  if i > 3:
    print(s[i],sep='',end='')
  else:
    print(t[i],sep='',end='')
from numpy import*
from itertools import*
n=int(input())
s=input()
t=s.count("#")
r=s.count(".")

x=[len(list(v))for k,v in groupby(s)if k=="#"]
y=[len(list(v))for k,v in groupby(s)if k=="."]
if len(x)>len(y):
    y=[0]+y
elif len(x)<len(y):
    x=[0]+x
else:
    if s[0]=="#":
        y=[0]+y
        x=x+[0]
    else:
        y=y+[0]
        x=[0]+x
 
x=array([0]+list(accumulate(x)))
y=array(list(accumulate(y[::-1]))[::-1]+[0])
print(min(x+y,t,r))

### FIXED CODE ###

n=int(input())
s=input()
r=s.count(".")
ans=[r]
for i in s:
    if i=="#":
        r+=1
    else:
        r-=1
    ans.append(r)
print(min(ans))
N, M = map(int, input().split())
PS = []
for i in range(M):
    p, s = input().split()
    PS += [(int(p),s)]

CA = 0
PN = 0
l = [True]*N
for i in range(len(PS)):
    if l[PS[i][0]]:
        if PS[i][1] == "WA":
            PN += 1
        elif PS[i][1] == "AC":
            CA += 1
            l[PS[i][0]] = False

print(CA, PN)

### FIXED CODE ###

N, M = map(int, input().split())
P = []
S = []
for i in range(M):
    p, s = input().split()
    P += [int(p)]
    S += [s]

CA = 0
PN = 0
d = {key:0 for key in P}
for i in range(len(P)):
    if d[P[i]] >= 0:
        if S[i] == "WA":
            d[P[i]] += 1
        elif S[i] == "AC":
            PN += d[P[i]]
            CA += 1
            d[P[i]] = -1

print(CA, PN)
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
H = readInts()
ma = H[0]
for i in range(1,n):
    if ma < H[i]:
        A[i] -= 1
    if ma <= H[i]:
        ma =  H[i]
    else:
        print('No')
        exit()
print('Yes')


### FIXED CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    H = readInts()
    ma_ = H[0]
    for i in range(1,n):
        if ma_ < H[i]:
            H[i] -=1
        if ma_ <= H[i]:
            #もし1段下げた場合に、その時の最大よりも大きい
            #（または等しい)ければよい
            ma_ = H[i]
        else:
            print('No')
            exit()
    print('Yes')



if __name__ == '__main__':
  main()
# -*- coding: utf-8 -*-
N = str(input())
a=[]
for i in range(N):
  S = int(N[i])
  a.append(S)
T = sum(S)
if int(N) % T == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
N = str(input())
a=[]
for i in range(len(N)):
  S = int(N[i])
  a.append(S)
T = sum(a)
if int(N) % T == 0:
  print("Yes")
else:
  print("No")
while True:
    N = int(input())
    if N == 0:
        break
    a = list(map(int, input().split()))

    dp = [[0 for j in range(21)] for i in range(N-1)]

    dp[0][a[0]] = 1
    for i in range(1, N-1):
        for j in range(21):
            if (j - a[i]) in range(21):
                dp[i][j] += dp[i-1][j-a[i]]
            if (j + a[i]) in range(21):
                dp[i][j] += dp[i-1][j+a[i]]
            
    print(dp[N-2][a[N-1]])

### FIXED CODE ###

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

## dp[i][j]: i???????????°????????§??§j????????????????????°
dp = [[0 for j in range(21)] for i in range(N-1)]

dp[0][a[0]] = 1
for i in range(1, N-1):
    for j in range(21):
        if (j - a[i]) in range(21):
            dp[i][j] += dp[i-1][j-a[i]]
        if (j + a[i]) in range(21):
            dp[i][j] += dp[i-1][j+a[i]]
        
print(dp[N-2][a[N-1]])
import math
A,B,C,D = map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0

if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
    last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
    last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)


### FIXED CODE ###

A,B,C,D = map(int,input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0
ans = 0
if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def no():
    print("No")
    exit()

def main():
    def ok(dir):
        goal = abs(xy[dir])
        over=total[dir]-goal
        if over<0 or over%2:
            return False
        if over==0:
            return True
        over//=2
        dp = [False] * (over + 1)
        dp[0] = True
        for d in dd[dir]:
            for i in range(d, goal + 1):
                dp[i] |= dp[i - d]
            if dp[-1]: return True
        return False

    s = input()[:-1]
    xy = list(map(int, input().split()))

    dd = [[], []]
    total=[0,0]
    dir = 0
    cnt = 0
    first = True
    for c in s:
        if c == "F":
            cnt += 1
        if c == "T":
            if first:
                xy[0] -= cnt
                first = False
            else:
                if cnt: dd[dir].append(cnt)
                total[dir]+=cnt
            dir = 1 - dir
            cnt = 0
    if first:
        xy[0] -= cnt
    else:
        if cnt: dd[dir].append(cnt)
        total[dir] += cnt
    #print(xy, dd)

    for dir in range(2):
        if not ok(dir): no()
    print("Yes")

main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def no():
    print("No")
    exit()

def main():
    def ok(dir):
        goal = abs(xy[dir])
        over=total[dir]-goal
        if over<0 or over%2:
            return False
        if over==0:
            return True
        over//=2
        dp = [False] * (over + 1)
        dp[0] = True
        for d in dd[dir]:
            for i in range(d, over + 1):
                dp[i] |= dp[i - d]
            if dp[-1]: return True
        return False

    s = input()[:-1]
    xy = list(map(int, input().split()))

    dd = [[], []]
    total=[0,0]
    dir = 0
    cnt = 0
    first = True
    for c in s:
        if c == "F":
            cnt += 1
        if c == "T":
            if first:
                xy[0] -= cnt
                first = False
            else:
                if cnt: dd[dir].append(cnt)
                total[dir]+=cnt
            dir = 1 - dir
            cnt = 0
    if first:
        xy[0] -= cnt
    else:
        if cnt: dd[dir].append(cnt)
        total[dir] += cnt
    #print(xy, dd)

    for dir in range(2):
        if not ok(dir): no()
    print("Yes")

main()