Harryxun/stf_run huggingface dataset:
import sys
s = input()
n = int(input())
if n == 1:
	print(s[0])
	sys.exit()
if 
for i in s:
	if i != '1':
		print(i)
		sys.exit()
print(1)

### FIXED CODE ###

import sys
s = input()
n = int(input())
cnt = 0
if n == 1:
	print(s[0])
	sys.exit()
for i in s:
	if i == '1':
		cnt += 1
	else:
		break
if n <= cnt:
	print(1)
	sys.exit()
	
for i in s:
	if i != '1':
		print(i)
		sys.exit()
print(1)
a = int(input())
b = int(input())

product = a * b

if product % 2 == 0:
    print('Even')
else:
    print('Odd')

### FIXED CODE ###

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

product = a * b

if product % 2 == 0:
    print('Even')
else:
    print('Odd')
def resolve():
    l=[list(map(int, input().split()) )for i in range(3)]
    n=int(input())
    b=[int(input()) for i in range(n)]
    bingo='No'
    for i in range(3):
        if l[i][0] in b and l[i][1] in b and l[i][2] in b:
           bingo='Yes'
        if l[0][i] in b and l[1][i] in b and l[2][i] in b:
            bingo='Yes'
    if (l[0][0] in b and l[1][1] in b and l[2][2] in b) or (l[2][0] in b and l[[1][1] in b and l[0][2] in b]):
        bingo='Yes'
    print(bingo)
resolve()

### FIXED CODE ###

def resolve():
    a11,a12,a13=map(int, input().split())
    a21,a22,a23=map(int, input().split())
    a31,a32,a33=map(int, input().split())
    n=int(input())
    lyo1=[a11,a12,a13]
    lyo2=[a21,a22,a23]
    lyo3=[a31,a32,a33]
    lta1=[a11,a21,a31]
    lta2=[a12,a22,a32]
    lta3=[a13,a23,a33]
    lna1=[a11,a22,a33]
    lna2=[a13,a22,a31]
    yo1=0
    yo2=0
    yo3=0
    ta1=0
    ta2=0
    ta3=0
    na1=0
    na2=0
    b=[int(input()) for i in range(n)]
    for x in range(n):
        if b[x] in lyo1:
            yo1+=1
        if b[x] in lyo2:
            yo2+=1
        if b[x] in lyo3:
            yo3+=1
        if b [x] in lta1:
            ta1+=1
        if b[x] in lta2:
            ta2+=1
        if b[x] in lta3:
            ta3+=1
        if b[x] in lna1:
            na1+=1
        if b[x] in lna2:
            na2+=1

    if yo1==3 or yo2==3 or yo3==3 or ta1==3 or ta2==3 or ta3==3 or na1==3 or na2==3:
        print('Yes')
    else:
        print('No')
resolve()
import numpy as np
s=np.array(list(input()))
t=np.array(list(input()))
is_eq=np.array(s[:,None]==t[None,])
# is_eq[i][j]:sのi文字目とtのj文字目が等しいかどうか
# print(is_eq)
ns=len(s)
nt=len(t)
dp=np.zeros((ns+1,nt+1),np.int64)
print(dp.shape)
print(is_eq.shape)

# dp[i+1][j+1]:sのi文字目までとtのj文字目までで最長の部分裂の長さ
# dp[0][j]=0,dp[i][0]=0,
for i in range(ns): #sのi文字目までの文字列で調査
    dp[i+1][1:]=np.maximum(dp[i][:-2]+is_eq[i],dp[i+1][:-1],dp[i][1:])
print(dp)
print(is_eq)


### FIXED CODE ###

import numpy as np
s=np.array(list(input()))
t=np.array(list(input()))
is_eq=np.array(s[:,None]==t[None,])
# is_eq[i][j]:sのi文字目とtのj文字目が等しいかどうか
# print(is_eq)
ns=len(s)
nt=len(t)
dp=np.zeros((ns+1,nt+1),np.int64)

# dp[i+1][j+1]:sのi文字目までとtのj文字目までで最長の部分列
# dp[0][j]=0,dp[i][0]=0,dp[n+1][w+1]の値がsとtで最長の部分列の長さ
for i in range(ns): #sのi文字目までの文字列で調査
    dp[i+1][1:]=np.maximum(dp[i][:-1]+is_eq[i],dp[i][1:])#左上からの更新、真上からの更新
    dp[i+1]=np.maximum.accumulate(dp[i+1])#左からの更新
i=ns
j=nt
ans=['']
while i>0 and j>0:
      if dp[i][j]==dp[i-1][j]:
            i-=1
      elif dp[i][j]==dp[i][j-1]:
            j-=1
      else:
            ans.append(s[i-1])
            i-=1
            j-=1
a=''
for _ in range(len(ans)):
      a+=ans.pop()
print(a)
from collections import defaultdict

S = defaultdict(int)
for i in input():
    S[i] += 1

a, b, *_ = S.values()
if a == b == 2:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

from collections import defaultdict

S = defaultdict(int)
for i in input():
    S[i] += 1

if len(S.values()) == 2:
    a, b = S.values()
    if a == b == 2:
        print('Yes')
        exit()
print('No')
N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)

ret = [letter for letter,count in S.most_common() if count == S.most_common()[0][1]]
print(ret)

### FIXED CODE ###

n=int(input())
arr=[input() for _ in range(n)]
dic={}
for i in range(n): #各単語の出現回数を数える
 if arr[i] not in dic:
   dic[arr[i]]=1
 else:
   dic[arr[i]]+=1
largest=max(dic.values()) #最大の出現回数を求める
ans=[]
for keys in dic.keys():
 if dic[keys]==largest: #出現回数が最も多い単語を集計する
   ans.append(keys)
ans=sorted(ans) #単語を辞書順に並べ替えて出力する
for words in ans:
 print(words)
N=int(input())
A=[[]for i in range(N)]
X=[list(map(int, input().split())) for _ in range(N-1)]
for i in range(N-1):
  a=X[i][0]
  b=X[i][1]
  a-=1
  b-=1
  A[a].append(b)
  A[b].append(a)
D=list(map(int, input().split()))
D=sorted(D)[::-1]
from collections import deque
d=deque(D)
E=[-1]*N
def f(now,pre):
  for i in A[now]:
    if i!=pre and E[i]==-1:
      E[i]=d.popleft()
      f(i,now)
E[0]=d.popleft()
f(0,0)
print(sum(D[1:]))
print(*E)

### FIXED CODE ###

import sys 
sys.setrecursionlimit(10**6)
N=int(input())
A=[[]for i in range(N)]
X=[list(map(int, input().split())) for _ in range(N-1)]
for i in range(N-1):
  a=X[i][0]
  b=X[i][1]
  a-=1
  b-=1
  A[a].append(b)
  A[b].append(a)
D=list(map(int, input().split()))
D=sorted(D)[::-1]
from collections import deque
d=deque(D)
E=[-1]*N
def f(now,pre):
  for i in A[now]:
    if i!=pre and E[i]==-1:
      E[i]=d.popleft()
      f(i,now)
E[0]=d.popleft()
f(0,0)
print(sum(D[1:]))
print(*E)
n = int(input())
A = list(map(int, input().split()))
cnt = 0

for i in range(n):
    for j in range(i+1, n):
        if A[i] > A[j]:
            cnt++

print(cnt)

### FIXED CODE ###

def merge(A, left, mid, right):

    n1 = mid-left
    n2 = right-mid
    #L = [0 for i in range(n1+1)]
    #R = [0 for i in range(n2+1)]
    #for i in range(n1):
    #    L[i] = A[left+i]
    #for i in range(n2):
    #    R[i] = A[mid+i]
    L = A[left:mid]
    l = len(L)
    R = A[mid:right]
    L.append(float('inf'))
    R.append(float('inf'))
    i = 0
    j = 0
    global cnt

    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i+1
        
        else:
            A[k] = R[j]
            j = j+1
            cnt += l-i

def mergeSort(A, left, right):
    if left+1 < right:
         mid = (left+right) // 2
         mergeSort(A, left, mid)
         mergeSort(A, mid, right)
         merge(A, left, mid, right)
    else:
        return 0

n = input()
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, len(A))
#print(*A)
print(str(cnt))
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))

from collections import deque
a = deque([x for x in a])
b = deque([x for x in b])
a.append(10**10)
b.append(10**10)
ans = 0
def cnt(a,b,time):
  global ans
  #print(ans, time,a,b)
  if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):
    if a[0] < b[0]:
      time += a[0]
      a.popleft()
    else:
      time += b[0]
      b.popleft()
    if time <= k:
      ans += 1
      cnt(a,b,time)

cnt(a,b,0)
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] * (n + 1)
sb = [0] * (m + 1)
for i in range(n):
  sa[i + 1] = sa[i] + a[i]
for i in range(m):
  sb[i + 1] = sb[i] + b[i]
r = m
ans = 0
for i in range(n + 1):
  if sa[i] > k:
    break
  while sa[i] + sb[r] > k:
    r -= 1
  ans = max(ans, i + r)
print(ans)
a = [input().split() for l in range(3)]
a = [[int(item) for item in row] for row in a]
N = int(input())
b = [input() for i in range(N)]
A[[1,1,1],[1,1,1],[1,1,1]]
x = 1
for i in range(N):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        A[j][k] = 0
for i in range(3):
  if A[i][0]*A[i][1]*A[i][2] == 0 | A[0][i]*A[1][i]*A[2][i] == 0:
    x = 0
if A[0][0]*A[1][1]*A[2][2] == 0 | A[0][2]*A[1][1]*A[2][0] == 0:
  x = 0
if x:
  print('No')
else:
  print('Yes')
  

### FIXED CODE ###

a = [input().split() for l in range(3)]
n = int(input())
b = [input() for i in range(n)]
c = [a[0][0],a[1][1],a[2][2]]
d = [a[0][2],a[1][1],a[2][0]]
tate1 = len(set(a[0]) & set(b))
tate2 = len(set(a[1]) & set(b))
tate3 = len(set(a[2]) & set(b))
yoko1 = len(set([x[0] for x in a]) & set(b))
yoko2 = len(set([x[1] for x in a]) & set(b))
yoko3 = len(set([x[2] for x in a]) & set(b))
naname1 = len(set(c) & set(b))
naname2 = len(set(d) & set(b))
bingo = [tate1,tate2,tate3,yoko1,yoko2,yoko3,naname1,naname2]
if 3 in bingo:
  print("Yes")
else:
  print("No")
# 初期入力
from itertools import permutations
import math
import numpy as np 
import sys
input = sys.stdin.readline
N,M,X = (int(x) for x in input().split())
C = [list(map(int, input().split())) for i in range(N)]
all_per =[i for i in range(N)]

price_list =[]
price_sum=0
N_fact = math.factorial(N)
k=0
for t in permutations(all_per): #参考書を買う順番を全列挙
    understanding =np.zeros((N ,M),dtype=int)
    understanding_method =np.zeros(M,dtype=int)
    price_sum=0
    k=0
    for i in t:
        price_sum           +=C[i][0]
        understanding[k]    =C[i][1:]
        understanding_method = np.sum(understanding, axis=0)
        k +=1
        if np.all(X <= understanding_method ): #アルゴリズム理解度が全て目標値X以上か
            price_list.append(price_sum)
            break
print(min(price_list))

### FIXED CODE ###

from itertools import combinations
import numpy as np
        #買う本
N, M, X = map(int, input().split())
items = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)
all_book= [i for i in range(N)]  
out = 10**18
#for c in itertools.product([False, True], repeat=N):
for num in range(1,N+1): #1冊からN冊まで
    for t in combinations(all_book,num): #参考書を買う組合せ、全列挙
        book_buy        =np.array(t,dtype=int) 
        understand_now  = items[book_buy] 
        tmp             = np.sum(understand_now, axis=0)
        if np.all(tmp[1:] >= X):
            out = min(out, tmp[0])

if out == 10**18:
  print(-1)
else:
  print(out)
a1, a2, a3 = int(input().split())

if a1+a2+a3 >= 22:
    print("bust")
else:
    print("win")


### FIXED CODE ###

a1, a2, a3 = (int(x) for x in input().split())

if a1+a2+a3 >= 22:
    print("bust")
else:
    print("win")
print(" ".join([str(i) for i in sorted([int(w) for w in input().split()])])

### FIXED CODE ###

print(" ".join([str(i) for i in sorted([int(w) for w in input().split()])]))
def main(n):
    cnt=0
    for i in range(1,n+1):
        i_list=list(str(i))
        for j in range(1,n+1):
            j_list=list(str(j))
            if i_list[1]==j_list[-1] and i_list[-1]==j_list[1]:
                cnt+=1
    print(cnt)        
        

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

### FIXED CODE ###

def main(n):
    c=[[0]*10 for _ in range(10)]
    for k in range(1,n+1):
        n=str(k)
        i = int(n[0])
        j = int(n[-1])
        c[i][j] += 1
    ans =0
    for i in range(10):
        for j in range(10):
            ans+=c[i][j]*c[j][i]
    print(ans)
             
if __name__=='__main__':
    main(int(input()))
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3
#sys.setrecursionlimit(int(1e+6))
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

# random_denseがTLE, 他はAC
def main_tle():
    N, Q = i2nn()
    STX = ii2nnn(N) # 座標 X で時刻 [S, T) が工事
    D = ii2nn(Q)    # 昇順ソート済み
    E = [-1] * Q
    STX.sort(key=lambda v: v[2])
    for s, t, x in STX:
        a = bisect_left(D, s-x)
        b = bisect_left(D, t-x)
        for i in range(a, b):
            if E[i] == -1:
                E[i] = x
    for e in E:
        print(e)

def main():
    N, Q = i2nn()
    STX = ii2nnn(N) # 座標 X で時刻 [S, T) が工事
    D = ii2nn(Q)    # 昇順ソート済み

    events = []
    for s, t, x in STX:
        events.append(('S', (s-x-0.5), x))
        events.append(('T', (t-x-0.5), x))
    for i, d in enumerate(D):
        events.append(('D', d, i))
    
    ans = [-1] * Q
    events.sort(key=lambda v: v[1])
    xset = set()
    xmin = None
    for event, time, xi in events:
        if event == 'S':
            xset.add(xi)
            if xmin is None or xmin > xi:
                xmin = xi
        elif event == 'T':
            xi = xi
            xset.remove(xi)
            if xmin == xi:
                xmin = None
        elif event == 'D' and xset:
            if xmin is None:
                xmin = min(xset)
            ans[xi] = xmin

    for n in ans:
        print(n)

main()


### FIXED CODE ###

import sys;input=sys.stdin.readline

n,q=map(int, input().split())
event=[]
for _ in range(n):
    s,t,x=map(int,input().split())
    event.append((s-x-0.5,1,x))
    event.append((t-x-0.5,-1,x))
for i in range(q):
    event.append((int(input()),0,i))

event.sort()
is_stop=False
stop=set()
minstop=float('inf')
ans=[-1]*q
for t,e,x in event:
    if e > 0:
        stop.add(x)
        if x<minstop:
            minstop=x
            is_stop=True
    elif e<0:
        stop.remove(x)
        if minstop==x:
            is_stop=False
    elif len(stop)>0:
        if not is_stop:
             minstop=min(stop)
             is_stop=True
        ans[x]=minstop

print('\n'.join(map(str, ans)))
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = list(input())

if S[0]!='B' or S[-1]!='B':
    print(0)
    exit()

mod = 10**9 + 7
cnt_l = 1
cnt_r = 0
pre_s = 'B'
pre_d = 1 #1がleft
ans = 1

for i in range(1,N*2):
    s = S[i]

    if pre_s==s:
        if pre_d==1:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
        else:
            d = 1
            cnt_l += 1
    else:
        if pre_d==1:
            d = 1
            cnt_l += 1
        else:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
    pre_s = s
    pre_d = d

for i in range(1,N+1):
    ans *= i
    ans %= mod
if cnt_l!=N:
    print(0)
    exit()

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
M,D = map(int,input().split(' '))

cnt = 0
for i in range(1,M+1):
    for j in range(1,D+1):
        dd = j // 10
        d  = j % 10
        if dd>=2 and d>=2 and d*dd==i:
            cnt += 1
print(cnt)
import math
from functools import reduce
from fractions import gcd
#import math
#import itertools
#import statistics
#import numpy as np
#import collections
#n = int(input())
a, b, c, d = list(map(int, input().split()))
#b = list(map(int, input().split()))

#10 11  13 14 15  17  19 20 21 22 23  25 26 27 28 29 
# 31  33 34 35  37 38 39  
lcm = a*b/gcd(a, b)
diff = b-a+1
d1 = (b//c - a//c)
d2 = (b//d - a//d)
a1 =  int((b//lcm-a//lcm))

print(diff-d1-d2+a1)


### FIXED CODE ###


S = list(input())
count = 0
bad = False

for i in range(len(S)-1):
    if S[i]==S[i+1]:
        bad = True


#print(bad)

if bad:
    print("Bad")
else:
    print("Good")
S = list(input())
T = list(input())


for i in range(0, len(S)-1):
    if (S[i] != T[i]):
        print('No')
    else :
		if(len(S)+1 == len(T)):
    		print('Yes')
		elif(len(S)>=len(T)):
    		print('No')
		elif(len(S)+1 < len(T)):
    		print('No')

### FIXED CODE ###

S = list(input())
T = list(input())
ans = 0

for i in range(0, len(S)):
    if (S[i] != T[i]):
        ans = 0
        break    
    else :
      if(len(S)+1 == len(T)):
        ans = 1
      elif(len(S)>=len(T)):
        ans = 2
      elif(len(S)+1 < len(T)):
        ans = 3

if(ans == 1):
    print('Yes')
else:
    print('No')
o = input()
e = input()
n = len(e)
ans = ''
for i in range(n)
	ans += o[i]
  	ans += e[i]
    
if len(o)%2==1:
  ans += o[-1]

print(ans)  
  
  

### FIXED CODE ###

o = input()
e = input()

n = len(e)
ans = ''
for i in range(n):
  ans += o[i]
  ans += e[i]
    
if len(o)>n:
  ans += o[-1]

print(ans)
num = list(range(100))
num[0] = 2
num[1] = 1
n = int(input())

for i in range(2,n+1):
    num[i] = num[i-2] + num[i-1]

print(num[n])


### FIXED CODE ###

a,b,c,d = input()

if (a == b and b == c) or (b == c and c == d):
    print("Yes")
else:
    print("No")
list = [1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
firstInputText = input()
print(textList[int(firstInputText) - 1])


### FIXED CODE ###

list = [1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
firstInputText = input()
print(list[int(firstInputText) - 1])
# -*- coding: utf-8 -*-
import numpy as np


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

bom_cord = np.empty((m, 2), dtype=int)
h_cnt = np.zeros(h, dtype=int)
w_cnt = np.zeros(w, dtype=int)
bom_cord = set()
for i in range(m):
    hi, wi = map(lambda x: int(x) - 1, input().split())
    bom_cord.add((hi, wi))
    h_cnt[hi] += 1
    w_cnt[wi] += 1

w_max = w_cnt.max()

h_argsort = h_cnt.argsort()[::-1]
w_argsort = w_cnt.argsort()[::-1]

bomber = 0
for hi in h_argsort:
    if h_cnt[hi] + w_max < bomber:
        break
    
    for wi in w_argsort:
        if h_cnt[hi] + w_cnt[wi] < bomber:
            break

        if (hi, wi) in bom_cord:
            bomber = max(bomber, h_cnt[hi] + w_cnt[wi] - 1)
        else:
            bomber = max(bomber, h_cnt[hi] + w_cnt[wi])

print(bomber)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np


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

h_cnt = np.zeros(h, dtype=int)
w_cnt = np.zeros(w, dtype=int)
bom_cord = set()
for i in range(m):
    hi, wi = map(lambda x: int(x) - 1, input().split())
    bom_cord.add((hi, wi))
    h_cnt[hi] += 1
    w_cnt[wi] += 1

w_max = w_cnt.max()

h_argsort = h_cnt.argsort()[::-1]
w_argsort = w_cnt.argsort()[::-1]

bomber = 0
for hi in h_argsort:
    if h_cnt[hi] + w_max <= bomber:
        break
    
    for wi in w_argsort:
        if h_cnt[hi] + w_cnt[wi] <= bomber:
            break

        if (hi, wi) in bom_cord:
            bomber = max(bomber, h_cnt[hi] + w_cnt[wi] - 1)
        else:
            bomber = max(bomber, h_cnt[hi] + w_cnt[wi])

print(bomber)
d = min(m)
print(N + (X - sum(m)) // d)

### FIXED CODE ###

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


d = min(m)
print(N + (X - sum(m)) // d)
,d = map(int,input().split())

a = d * 2 + 1

b=n/a
b = int(b)
c=n%a
if c>0:
    b = b + 1
    
print(b)

### FIXED CODE ###

n,d = map(int,input().split())

a = d * 2 + 1

b=n/a
b = int(b)
c=n%a
if c>0:
    b = b + 1
    
print(b)
import fractions
N = int(input())
As = list(map(int, input().split()))
As.sort()
ans = 1
odd = 0
even = 0
for a in As:
    if a%2 == 0:
        even += 1
    else:
        odd += 1
if even >= 2 and odd >= 2:
    print(1)
elif even == 1:
    c = 0
    for b in As:
        if b % 2 == 1:
            c = b
            break
    for a in As:
        if a % 2 == 1:
            c = fractions.gcd(c, a)
    print(c)
elif odd == 1:
     c = 0
    for b in As:
        if b % 2 == 0:
            c = b
            break
    for a in As:
        if a % 2 == 0:
            c = fractions.gcd(c, a)
    print(c)
    
else:
    
    for i in range(N):
        flag = True
        if i == 0:
            a = As[1]
        else:
            a = As[0]
        for j in range(N):
            if j != i:
                a = fractions.gcd(a, As[j])
                if a <= ans:
                    flag = False
                    break
        if flag:  
            ans = a
    print(ans)

### FIXED CODE ###

import fractions
import collections
N = int(input())
As = list(map(int, input().split()))
lgcd = [As[0]]
rgcd = collections.deque([As[-1]])
l = As[0]
r = As[-1]
for i in range(1, N):
    l = fractions.gcd(l, As[i])
    r = fractions.gcd(r, As[-(i+1)])
    lgcd.append(l)
    rgcd.appendleft(r)
ans = [lgcd[N-2], rgcd[1]]
for i in range(1, N-1):
    ans.append(fractions.gcd(lgcd[i-1], rgcd[i+1]))
print(max(ans))
n=int(inpyt())
k=int(inpyt())
sp_p=int(inpyt())
n_p=int(inpyt())
sum = 0

for i in k:
    sum += sp_p

for j in n-k:
    sum += n_p

print(sum)

### FIXED CODE ###

all_days=int(input())
days1=int(input())
sp_p=int(input())
n_p=int(input())
ans = 0

if all_days <= days1:
    ans = sp_p * all_days
else:
    ans = days1 * sp_p + (all_days-days1) * n_p

print(ans)
#FT robot
s=input()
gx,gy=map(int,input().split())
lists=list(s.split("T"))
xlist=[]
ylist=[]
if s[0]=="T":
    for i in range(len(lists)):
        if i%2==0:
            xlist.append(len(lists[i]))
        else:
            ylist.append(len(lists[i]))
elif s[0]=="F":
    for i in range(len(lists)):
        if i%2==0:
            xlist.append(len(lists[i]))
        else:
            ylist.append(len(lists[i]))
    gx-=xlist[0]
    del xlist[0]
Xsum=sum(xlist)
Ysum=sum(ylist)
if (Xsum+gx)%2!=0 or (Ysum+gy)%2!=0:
    print("No")   
else:
    gx1=(Xsum+gx)//2
    gx2=(Xsum-gx)//2
    gy1=(Ysum+gy)//2
    gy2=(Ysum-gy)//2
    dpx=[[False for i in range(Xsum+2)] for i in range(len(xlist)+2)]
    dpy=[[False for i in range(Ysum+2)] for j in range(len(ylist)+2)]
    #dpx[i][j]でi番目のカードまでを足して、値ｊを取れるか判定する
    dpx[0][0]=True
    dpy[0][0]=True
    for i in range(len(xlist)):
        for j in range(Xsum+2):
            dpx[i+1][j]=dpx[i][j-xlist[i]] or dpx[i][j]
    for i in range(len(ylist)):
        for j in range(Ysum+2):
            dpy[i+1][j]=dpy[i][j-ylist[i]] or dpy[i][j]        
    if (dpy[len(ylist)][gy1] or dpy[len(ylist)][gy2]) and (dpx[len(xlist)][gx1] or dpx[len(xlist)][gx2]):
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

      #FT robot
s=input()
gx,gy=map(int,input().split())
lists=list(s.split("T"))
xlist=[]
ylist=[]
if s[0]=="T":
    for i in range(len(lists)):
        if i%2==0:
            xlist.append(len(lists[i]))
        else:
            ylist.append(len(lists[i]))
elif s[0]=="F":
    for i in range(len(lists)):
        if i%2==0:
            xlist.append(len(lists[i]))
        else:
            ylist.append(len(lists[i]))
    gx-=xlist[0]
    del xlist[0]
Xsum=sum(xlist)
Ysum=sum(ylist)


if (Xsum+gx)%2!=0 or (Ysum+gy)%2!=0:
    print("No")   
else:
    gx1=(Xsum+gx)//2
    gx2=(Xsum-gx)//2
    gy1=(Ysum+gy)//2
    gy2=(Ysum-gy)//2
    dpx=[[False for i in range(Xsum+2)] for j in range(len(xlist)+2)]
    dpy=[[False for i in range(Ysum+2)] for j in range(len(ylist)+2)]
    #dpx[i][j]でi番目のカードまでを足して、値ｊを取れるか判定する
    dpx[0][0]=True
    dpy[0][0]=True
    for i in range(len(xlist)):
        for j in range(Xsum+2):
            dpx[i+1][j]=dpx[i][j-xlist[i]] or dpx[i][j]
    for i in range(len(ylist)):
        for j in range(Ysum+2):
            dpy[i+1][j]=dpy[i][j-ylist[i]] or dpy[i][j]    
    #ここまではあってそうなことがわかった
    flag1=False
    if 0<= gy1<= Ysum:   
        if dpy[len(ylist)][gy1]:
            flag1=True
    flag2=False
    if 0<=gy2<= Ysum :
        if dpy[len(ylist)][gy2]:
            flag2=True
    flag3=False
    if 0<=gx1<= Xsum:
        if dpx[len(xlist)][gx1]:
            flag3=True
    flag4=False
    if 0<=gx2<= Xsum:
        if dpx[len(xlist)][gx2]:
            flag4=True
    if (flag1 or flag2) and (flag3 or flag4):
        print("Yes")
    else:
        print("No")
def mx(ls,i):
    rls = ls[:]
    if i == 0 or len(rls) == 0: return 0
    else     : return (i+1)*rls.pop()+ mx(rls,i-1)

def cns(ls,m,sm):
    global n, s
    count = 0
    if m == n:
        if sm == s: return 1
        else      : return 0
    elif s-mx(ls,n-m) <= sm <= s:
        for i in range(9-m+1):
            rls = ls[:]
            k = rls.pop(i)
            count += cns(rls,m+1,sm+(m+1)*k)
        return count
    else: return 0

ls = [0,1,2,3,4,5,6,7,8,9]
while True:
    n, s = map(int, raw_input().split())
    if s > mx(ls,n): print 0
    else        : print cns(ls,0,0)

### FIXED CODE ###

def mxmn(ls,m):
	global n
	s1,s2 = 0, 0
	for i in range(m):
		s1 += (n-i)*ls[-i-1]
		s2 += (n-i)*ls[i]
	return s1,s2

def f(ls,m,s):
	global n
	count = 0
	if m > 0:
		mx,mn = mxmn(ls,m)
		if mx < s or mn > s: return 0
		elif mx == s or mn == s: return 1
		for i in range(len(ls)):
			lls = ls[:]
			a = (n-m+1)*lls.pop(i)
			if s-a < 0:	break
			else: count += f(lls,m-1,s-a)
		return count
	else:
		return 1 if s == 0 else 0
			
ls = [i for i in range(10)]
while True:
	try:
		n,s = map(int, raw_input().split())
		print f(ls,n,s)
	except:
		break