Harryxun/stf_run huggingface dataset:
import bisect


def preliminary(k, aaa):
    dp = [False] * k
    dp[0] = True
    curr_max = 0
    fwd = {}
    pa = aaa[0]
    pdp, ppdp = dp[:], None
    for a in aaa:
        if pa != a:
            fwd[pa] = ppdp
        for i in range(min(curr_max, k - a - 1), -1, -1):
            if dp[i]:
                dp[i + a] = True
        curr_max += a
        pa = a
        ppdp = pdp
        pdp = dp[:]
    fwd[pa] = ppdp

    dp = [False] * k
    dp[0] = True
    curr_max = 0
    bwd = {}
    pa = 0
    pdp = []
    for a in reversed(aaa):
        if pa != a:
            bwd[a] = [i for i, v in enumerate(pdp) if v][1:]
        for i in range(min(curr_max, k - a - 1), -1, -1):
            if dp[i]:
                dp[i + a] = True
        curr_max += a
        pa = a
        pdp = dp[:]

    return fwd, bwd


def get_judge(k, aaa):
    fwd, bwd = preliminary(k, aaa)
    cache = [None] * k

    def judge(m):
        am = aaa[m]
        if cache[am] is None:
            dp = fwd[am]
            ndp = dp[:]
            for i in bwd[am]:
                for j in range(k - i - 1, -1, -1):
                    if dp[j]:
                        ndp[i + j] = True
            cache[am] = any(ndp[-am:])
        return cache[am]

    return judge


def solve(k, aaa):
    if sum(aaa) < k:
        return n

    aaa.sort()
    aaa = aaa[:bisect.bisect_left(aaa, k)]

    judge = get_judge(k, aaa)

    l = 0
    r = len(aaa) - 1
    m = (l + r) // 2
    while l <= r:
        if judge(m):
            r = m - 1
        else:
            l = m + 1
        m = (l + r) // 2

    return l


n, k = map(int, input().split())
aaa = list(map(int, input().split()))
print(solve(k, aaa))


### FIXED CODE ###

import bisect


def solve(k, aaa):
    aaa = aaa[:bisect.bisect_left(aaa, k)]

    dp = [False] * k
    dp[0] = True
    curr_max = 0
    ans = len(aaa)
    for i, a in reversed(list(enumerate(aaa))):
        if curr_max + a >= k:
            ans = i
        f = True
        for j in range(min(curr_max, k - a - 1), -1, -1):
            if dp[j]:
                dp[j + a] = True
                if f:
                    curr_max = max(curr_max, j + a)
                    f = False
    return ans


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

print(solve(k, aaa))
N = int(input())
L = list(map(int, input().split()))
maxL = max(L)
L.pop(maxL)
if maxL > sum(L):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

import numpy as np


N = int(input())
L = list(map(int, input().split()))
maxL = max(L)
argmaxL = np.argmax(L)
L.pop(argmaxL)
if maxL < sum(L):
  print('Yes')
else:
  print('No')
from functools import lru_cache
import sys
sys.setrecursionlimit(100000000)
N = int(input())
def main():
    a = list(map(int, input().split()))
    d = {0:0, 1:0, 2:0, 3:0}
    for i in a:
        d[i] += 1
    print(dfs(d[1],d[2],d[3]))
@lru_cache(maxsize=None)
def dfs(a, b, c):
    if a + b + c == 0:
        return 0
    t1 = t2 = t3 = 0
    total = a + b + c
    if a > 0:
        t1 = (a/total) * dfs(a-1, b, c)
    if b > 0:
        t2 = (b/total) * dfs(a+1, b-1, c)
    if c > 0:
        t3 = (c/total) * dfs(a, b+1, c-1)
    return N/total + t1 + t2 + t3
main()



### FIXED CODE ###

def main():
    N = int(input())
    p = list(map(float, input().split()))
    a = [[0] * (N + 1) for _ in range(N)]
    a[0][1] = p[0]
    a[0][0] = 1 - p[0]
    for i in range(1, N):
        a[i][0] = a[i - 1][0] * (1 - p[i])
        for j in range(1, i + 2):
            a[i][j] = a[i - 1][j - 1] * p[i] + a[i - 1][j]* (1 - p[i])
    print(sum(a[-1][(N+1)//2:]))
main()
N, K = list(map(lambda n: int(n), input().split(" ")))
h = list(map(lambda x: int(n), input().split(" ")))
print(len(list(filter(lambda height: height >= K, h))))

### FIXED CODE ###

N, K = list(map(lambda n: int(n), input().split(" ")))
h = list(map(lambda x: int(x), input().split(" ")))
print(len(list(filter(lambda height: height >= K, h))))
s = list(input())
k = int(input())
ans = 0
for i in range(1, len(s)):
    if s[i] == s[i -1]:
        ans += 1
        s[i] = ""
j = 0
if s[-1] == s[0]:
    if s[-1] != s[-2]:
        j = 1

print(ans*k - j*(k - 1))

### FIXED CODE ###

s = list(input())
k = int(input())
n = len(s)

if s == [s[0]]*n:
    print(n*k//2)
else:
    ss = s*2
    ans1 = 0
    for i in range(1, n):
        if s[i] == s[i -1]:
            s[i] = ""
            ans1 += 1
    ans2 = 0
    for i in range(1, 2*n):
        if ss[i] == ss[i - 1]:
            ss[i] = ""
            ans2 += 1
    j = ans2 - ans1
    print(ans1 + j*(k - 1))
if R<1200:
    print("ABC")
elif R<2800:
    print("ARC")
else:
    print("AGC")


### FIXED CODE ###

R=int(input())
if R<1200:
    print("ABC")
elif R<2800:
    print("ARC")
else:
    print("AGC")
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
A -= np.arange(1, N+1)
answer = 10 ** 15
B = np.abs(np.subtract.outer(A, A))
answer = np.min(B.sum(axis=1))
print(answer)


### FIXED CODE ###

import numpy as np
import statistics

N = int(input())
A = np.array(list(map(int, input().split())))
R = np.array([x+1 for x in range(N)])

med = int(np.median((A-R)))
print(abs(A-R-med).sum())
,b = map(int,input().split())
s = 0
if a <= b:
    for i in range(0,b):
        s += a*(10**i)

else:
    for i in range(0,a):
        s += b*(10**i)

print(s)

### FIXED CODE ###

a,b = map(int,input().split())
s = 0
if a <= b:
    for i in range(0,b):
        s += a*(10**i)

else:
    for i in range(0,a):
        s += b*(10**i)

print(s)
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
k=0
for i in range(n):
    if a[i]<b[i]:
        p=b[i]-a[i]
        a[i]+=(p+1)//2*2
        while p>0 and k<n:
            if a[k]-b[k]>p:
                b[k]+=p
                p=0
            elif a[k]-b[k]>0:
                b[k]=a[k]
                p-=a[k]-b[k]
            k+=1
            # print(a,b,k,p,i)

# print(a,b)
if a==b and p==0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c,d=0,0
for i in range(n):
    if a[i]>b[i]:
        c+=a[i]-b[i]
    else:
        d+=(b[i]-a[i])//2
if d>=c:
    print("Yes")
else:
    print("No")
#bin/usr/env python3

n,m = map(int, input().split())
mod = 10**9+7

br = [0 for i in range(n+1)]
for i in range(m):
    a = int(input())
    br[a] = 1

can = [0 for i in range(n+1)]

can[1] = 1
can[2] = 2

if br[1] == 1:
    can[1] = 0
    can[2] = 1
if br[2] == 1:
    can[1] = 1
    can[2] = 0

for i in range(3, n+1):
    if br[i]!=1 :
        can[i] = (can[i-1] + can[i-2])%mod
    
    else:
        can[i] = 0

print(can[n])




### FIXED CODE ###

#bin/usr/env python3

n,m = map(int, input().split())
mod = 10**9+7

br = [0 for i in range(n+2)]
for i in range(m):
    a = int(input())
    br[a] = 1

can = [0 for i in range(n+2)]

can[1] = 1
can[2] = 2

if br[1] == 1:
    can[1] = 0
    can[2] = 1
if br[2] == 1:
    can[1] = 1
    can[2] = 0
if br[1] == 1 and br[2] == 1:
    can[1] = 0
    can[2] = 0

for i in range(3, n+1):
    if br[i]!=1 :
        can[i] = (can[i-1] + can[i-2])%mod
    
    else:
        can[i] = 0

print(can[n])
n,k = map(int,input().split())
s = input()
 
if s[k-1] == "A":
  s=s[0:k-1]+"a"+s[k:n]
elif s[k] == "B":
  s=s[0:k-1]+"b"+s[k:n]
else:
  s=s[0:k-1]+"c"+s[k:n]
print(s)

### FIXED CODE ###

n,k = map(int,input().split())
s = input()
 
if s[k-1] == "A":
  s=s[0:k-1]+"a"+s[k:n]
elif s[k-1] == "B":
  s=s[0:k-1]+"b"+s[k:n]
else:
  s=s[0:k-1]+"c"+s[k:n]
print(s)
def cloth(a):
    n=len(a)
    r=[0]*3
    for i in range(n):
        r[0]+=a[i][0]
        r[1]+=a[i][1]
        r[2]+=a[i][2]
    return r
a,b,c=map(int,input().split())
d=[]
for i in range(a):
    n=list(map(int,input().split()))
    d.append(n)

m=[]
q=[]

for i in range(2**a):
    score=[]
    total=0
    for j in range(a):
        if ((i>>j)&1):
            score.append(d[j][1:b+1])
            total+=d[j][0]
    m.append([score,total])

large=len(m)
決勝=[]
n=0
q=0
while True:
    q=len(m[n][0])
    if q==a:
        break
    r=cloth(m[n][0])
    n+=1
    if r[0]<c or r[1]<c or r[2]<c:
        continue
    else:
        決勝.append(m[n-1][1])

u=cloth(m[-1][0])
if len(決勝)==0 and len([i for i in u if i>=c])==3:
    print(m[-1][1])

elif len(決勝)==0:
    print(-1)
else:
    print(min(決勝))
                
    




### FIXED CODE ###

a,b,c=map(int,input().split())
d=[]
for i in range(a):
    n=list(map(int,input().split()))
    d.append(n)
ans=[]
q=len(d)
for i in range(2**q):
    score=[0]*b
    total=0
    n=0
    for j in range(q):
        if ((i>>j)&1):
            for m in range(b):
                score[m]+=d[j][m+1]
            total+=d[j][0]
    for mm in range(b):
        if score[mm]>=c:
            n+=1
    if n==b:
        ans.append(total)

if ans==[]:
    print(-1)
else:
    print(min(ans))
s= int(input())
print(0,0,10**9,1,-s%10**9,(s+(-s%10**9))//v)

### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys, math, bisect, random, itertools
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A(s):
    def pri(n, x):
        if n == 0:
            return [0, 0]
        if n == 1:
            return [1, 1]
        if n == 2:
            return [2, 1]
        for i in range(2, int(math.sqrt(n))):
            if n % i == 0 and n // i <= x:
                return [i, n // i]
        return [1, n]
    x = int(math.sqrt(s))
    if s < 10 ** 9:
        print(0, 0, 0, s, 1, 0)
        return
    while 1:
        X = x ** 2
        if X - s < 0:
            x += 1
            continue
        b = pri(X - s, x)
        if b:
            print(0, 0, x, int(b[0]), int(b[1]), x)
            if x > 10 ** 9 or b[0] > 10 ** 9 or b[1] > 10 ** 9:
                print(s)
                quit()
            return
        x += 1
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return



#Solve
if __name__ == '__main__':
    A(II())
While True:
    nums= input(),split()
    a = int(nums[0])
    op = int(nums[1])
    b = int(nums[2])

    if op == '?':
        break

    if op == '+':
        i = a + b
        print(i)

    if op == '-':
        i = a - b
        print(i)

    if op == '*':
        i = a * b
        print(i)

    if op == '/':
        i = a / b
        round(i)
        print(i)

### FIXED CODE ###

while True:
    (a, op, b) = [int(i) if i.isdigit() else i for i in input().split()]

    if op == '?':
        break

    if op == '+':
        print(a + b)

    if op == '-':
        print(a - b)

    if op == '*':
        i = a * b
        print(a * b)

    if op == '/':
        print(a // b)
import sys
sys.setrecursionlimit(10**6)

n = int(input())

readline = sys.stdin.readline

MAX_N = 10**9+5
w = [0]*MAX_N

for _ in range(n):
    a,b = [int(i) for i in readline().split()]
    w[b] += a

s = 0
for i in range(MAX_N):
    if w[i]:
        s += w[i]
        if s > i:
            print('No')
            break
else:
    print('Yes')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n = int(input())

readline = sys.stdin.readline

d = {}

for _ in range(n):
    a,b = [int(i) for i in readline().split()]
    d[b] = d.get(b, 0) + a

d_sorted = sorted(d.items(), key=lambda x:x[0])

s = 0
for t, w in d_sorted:
    s += w
    if s > t:
        print('No')
        break
else:
    print('Yes')
a,b = map(int, input().split(" "))
b = b -1
if b==0:
  print("YES")
if (a-1)//b >=2:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

a,b = map(int, input().split(" "))
b = b -1
if b==0:
  print("YES")
elif (a-1)//b >=2:
  print("YES")
else:
  print("NO")
from math import ceil
from collections import deque

n, d, a = map(int, input().split())
m = sorted([list(map(int, input().split())) for _ in range(n)])
m = [[x, ceil(h / A)] for x, h in m]

acc_damage = 0
que = deque()
ans = 0
for x, h in m:
    while que and x > que[0][0]:
        limit, damage = que.popleft()
        acc_damage -= damage

    need = max(0, h - acc_damage)
    ans += need
    acc_damage += need

    if need:
        que.append([x + 2 * d, need])

print(ans)

### FIXED CODE ###

from math import ceil
from collections import deque
N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
Monsters = [[x, ceil(h / A)] for x, h in Monsters]


acc_damage = 0
que = deque([])

ans = 0
for x, h in Monsters:
    while que and x > que[0][0]:
        limit, damage = que.popleft()
        acc_damage -= damage

    need = max(0, h - acc_damage)
    ans += need
    acc_damage += need

    if need:
        que.append([x + 2 * D, need])

print(ans)
n = int(input())
for number in n:
  taro_string, hanako_string = raw_input().split()
  if taro_string > hanako_string:
    taro += 3
  elif hanako_string > taro_string:
    hanako += 3
  else:
    taro += 1
    hanako += 1
print taro, hanako 

### FIXED CODE ###

n = input()
taro, hanako = 0, 0
for number in range(n):
  taro_string, hanako_string = raw_input().split()
  if taro_string > hanako_string:
    taro += 3
  elif hanako_string > taro_string:
    hanako += 3
  else:
    taro += 1
    hanako += 1
print taro, hanako
import pi

r = int(input())

x = 2 * r * pi

print(x)

### FIXED CODE ###

R = int(input())
print(2 * R * 3.14)
# gcd
def gcd(a, b):
	return gcd(b, a % b) if b != 0 else a

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

max_gcd = L[0]

for i in range(1, N):
    max_gcd = gcd(max_gcd, L[i])

print(max_gcd)


### FIXED CODE ###

# gcd
def gcd(a, b):
	return gcd(b, a % b) if b != 0 else a

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

max_gcd = L[0]

for i in range(1, N):
    max_gcd = gcd(max_gcd, L[i])

print(max_gcd)
num_n = input()
N = map(int, raw_input())
num_m = input()
M = map(int, raw_input())

def solve(i, m):
   if m == 0:
      return True
   if i >= num_n:
      return False
   res = solve(i + 1, m) or solve(i + 1,m - N[i])
   return res
 
for m in M:
   if solve(0, m):
      print "yes"
   else:
      print "no"

### FIXED CODE ###

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

def exSearch(i, m):
    if m == 0:
        return True
    if i >= len(hoge) or m > sum(hoge):
        return False
    res = exSearch(i+1, m) or exSearch(i+1, m-hoge[i])
    return res

if __name__ == '__main__':
    
    for val in (int(x) for x in input().split()):
        if exSearch(0, val):
            print ('yes')
        else:
            print ('no')
n = int(input())
ans = math.ceil(n/2)-1
print(ans)

### FIXED CODE ###

import math
n = int(input())
ans = math.ceil(n/2) - 1
print(ans)
N = int(input())
S, T = input().split()
 
for i in range(N):
    A += S[i]
    A += T[i]
    
print(A)

### FIXED CODE ###

A = int(input())
B = int(input())
 
print(6-A-B)	#和から誤答を引けば正答
# -*- coding:utf-8 -*-
import sys
def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym):
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1,0,1,0]
DY = [0,-1,0,1]
sys.setrecursionlimit(10**7)
while True:
	line = input()
	if " " in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(N)] for j in range(M)]
	else:
		tile[counter-1] = list(line)
	if N is 0 and M is 0:
		break
	if counter is M:
		solve()
		counter = 0
	counter += 1

### FIXED CODE ###

# -*- coding:utf-8 -*-
import sys
def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym):
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1,0,1,0]
DY = [0,-1,0,1]
sys.setrecursionlimit(10**7)
while True:
	line = input()
	if " " in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(M)] for j in range(N)]
	else:
		tile[counter-1] = list(line)
	if N is 0 and M is 0:
		break
	counter += 1
	if counter-1 is N:
		solve()
		counter = 0
d = int(input())

if d = 22:
    print("Christmas Eve Eve Eve")
elif d = 23:
    print("Christmas Eve Eve")
elif d = 24:
    print("Christmas Eve")
else:
    print("Christmas")

### FIXED CODE ###

d = int(input())

if d == 22:
    print("Christmas Eve Eve Eve")
elif d == 23:
    print("Christmas Eve Eve")
elif d == 24:
    print("Christmas Eve")
else:
    print("Christmas")
h,w = map(int,input().split())
m = []

for i in range(h):
    m.append(list(input()))


#行に着目
dl = []

for i in range(h):
    if all(j =='.' for j in m[i]):
        dl.append(int(i))

if dl:
    for i in dl:
        del m[i]

#転置して同様
m = list(zip(*m)) 
if m:
    dl = []
    for i in range(w):
        if all(j =='.' for j in m[i]):
            dl.append(int(i))

    if dl:
        for i in range(len(dl)):
            del m[dl[len(dl)-i-1]]
            


#転置して元に戻す
m = list(zip(*m))


#出力
for i in range(len(m)):
    m[i] = ''.join(m[i])
    print(m[i])

### FIXED CODE ###

h,w = map(int,input().split())
m = []

for i in range(h):
    m.append(list(input()))


#行に着目
dl = []

for i in range(h):
    if all(j =='.' for j in m[i]):
        dl.append(int(i))
# print(dl)
if dl:
    for i in dl:
        del m[i-dl.index(i)]
h = len(m)
# print(m)

dl = []
for i in range(w):
    s = ''
    for j in range(h):
        s = s + m[j][i]
    if all(j == '.' for j in list(s)):
        dl.append(int(i))
# print(dl)
if dl:
    for i in range(h):
        for j in dl:
            del m[i][j-dl.index(j)]

# print(m)
for i in range(h):
    print(''.join(m[i]))

#転置して同様
# m = list(zip(*m)) 
# if m:
#     dl = []
#     for i in range(w):
#         if all(j =='.' for j in m[i]):
#             dl.append(int(i))

#     if dl:
#         for i in range(len(dl)):
#             del m[dl[len(dl)-i-1]]
            


# #転置して元に戻す
# m = list(zip(*m))


# #出力
# for i in range(len(m)):
#     m[i] = ''.join(m[i])
#     print(m[i])
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

## BFS

#入力受け取り
N, Q = mi()
x = li2(N-1)

cnt = [0]*N
for i in range(Q):
    p0, p1 = mi()
    cnt[p0-1] += p1

#隣接リスト作成
adj = [[] for i in range(N)]
for i in range(N-1):
    x[i][0] -= 1
    x[i][1] -= 1
    adj[x[i][0]].append(x[i][1])
    adj[x[i][1]].append(x[i][0])

ans = [0]*N

global ans
def dfs(fr, nx):
    ans[nx] += ans[fr] + c[nx]
    for v in adj[nx]:
        if v != fr:
            dfs(nx, v)

dfs(0, 0)

for k in ans:
    print(k, '', end='')

### FIXED CODE ###

import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
'''
from collections import deque
N, Q = mi()
D = li2(N-1)
px = li2(Q)
que = deque()

adj = [[] for i in range(N+1)]

for i in range(N-1):
    adj[D[i][0]].append(D[i][1])

ans = [0]*(N+1)
for j in range(Q):
    ind, a = px[j][0], px[j][1]
    que.append(ind)
    while(que!=deque()):
        v = que.popleft()
        ans[v] += a
        for e in adj[v]:
            que.append(e)


for i in range(1, N+1):
    print(ans[i], ' ', end='')
'''

from collections import deque
sys.setrecursionlimit(10**9)

#入力受け取り
N, Q = mi()
x = li2(N-1)
#p = li2(Q)

cnt = [0]*N
for i in range(Q):
    p0, p1 = mi()
    cnt[p0-1] += p1

#隣接リスト作成
adj = [[] for i in range(N)]
for i in range(N-1):
    x[i][0] -= 1
    x[i][1] -= 1
    adj[x[i][0]].append(x[i][1])
    adj[x[i][1]].append(x[i][0])

que = deque()
ans = [0]*N

#for a in range(N):
que.append((0, 0))
num = 0
while que!=deque():
    v = que.popleft()
    ans[v[1]] = ans[v[0]] + cnt[v[1]]
    for next in adj[v[1]]:
        if next != v[0]:
            que.append((v[1], next))

for k in ans:
    print(k, '', end='')
S = input()

s = list(S)

s.reverse()

#print (s)

lis = [0] * 13
lis[0] = 1

for i in range(len(S)):

    nlis = [0] * 13

    if s[i] == "?":

        for j in range(10):

            for k in range(13):

                nlis[ (k + (j * (10**i))) % 13] += lis[k]

    else:

        now = int(s[i])

        for k in range(13):

            nlis[ (k + (now * (10 ** i))) % 13 ] += lis[k]

    #print (nlis)
    lis = nlis.copy()

#print (lis)
print (lis[5] % (10**9 + 7))


### FIXED CODE ###


S = input()

s = list(S)

s.reverse()

#print (s)

lis = [0] * 13
lis[0] = 1
keta = 1

for i in range(len(S)):

    nlis = [0] * 13



    for j in range(10):

        for k in range(13):

            if s[i]== "?" or j == int(s[i]):
                nlis[ (k + (j * keta)) % 13] += lis[k]

    keta *= 10
    keta = keta % 13
    for j in range(13):
        lis[j] = nlis[j] % (10**9 + 7)

#print (lis)
print (lis[5] % (10**9 + 7))
import math

n, a, b, c, d = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for m in range(m)]
#light = [int(i) for i in input().split()]
s = input()
list = list(s)

#print(n, m)
#print(table)
#print(light)

flag = 1



#A-C B-Dまでの間に岩が2個並んでいたらアウト

for i in range(a-1, c-1) :
    if ( list[i] == '#') :
        if ( list[i+1] == "#") :
            flag = 0

for i in range(b-1, d-1) :
    if ( list[i] == "#") :
        if ( list[i+1] == "#") :
            flag = 0

# D < C　のとき、A-Cまでの間に、3個以上空白がなければアウト

if (d < c) :
    flag = 0
    for i in range(a-1, d) :
        if (list[i] == '.' and list[i+1] == '.' and list[i+2] == '.') :
            flag = 1

if (flag == 1) :
    print("Yes")
else :
    print("No")

### FIXED CODE ###

import math

n, a, b, c, d = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for m in range(m)]
#light = [int(i) for i in input().split()]
s = input()
list = list(s)

#print(n, m)
#print(table)
#print(light)

flag = 1



#A-C B-Dまでの間に岩が2個並んでいたらアウト

for i in range(a-1, c-1) :
    if ( list[i] == '#') :
        if ( list[i+1] == "#") :
            flag = 0

for i in range(b-1, d-1) :
    if ( list[i] == "#") :
        if ( list[i+1] == "#") :
            flag = 0

# D < C　のとき、B-Dまでの間に、3個以上空白がなければアウト

if (d < c) :
    flag = 0
    for i in range(b-2, d-1) :
        if (list[i] == '.' and list[i+1] == '.' and list[i+2] == '.') :
            flag = 1

if (flag == 1) :
    print("Yes")
else :
    print("No")
A = input()
B = input()

ans = 6 - (A+B)
print(ans)

### FIXED CODE ###

A = int(input())
B = int(input())

ans = 6 - (A+B)
print(ans)