Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

S = input()
K = int(input())
N = len(S)

dp = [[[0 for _ in range(K+1)] for _ in range(N)] for _ in range(N)]
for i in range(N):
    for k in range(K+1):
        dp[i][i][k] = 1

for _j in range(1, N):
    for i in range(N):
        j = i + _j
        if j < N:
            for k in range(K+1):
                dp[i][j][k] = max(dp[i][j][k], dp[i+1][j][k], dp[i][j-1][k])
                if _j == 1:
                    if S[i] == S[j]:
                        dp[i][j][k] = 2
                    else:
                        if k+1 <= K:
                            dp[i][j][k+1] = 2
                else:
                    if S[i] == S[j]:
                        dp[i][j][k] = max(dp[i][j][k], dp[i+1][j-1][k] + 2)
                    else:
                        if k+1 <= K:
                            dp[i][j][k+1] = max(dp[i][j][k], dp[i+1][j-1][k] + 2)

print(max(dp[0][N-1]))



### FIXED CODE ###

S = input()
K = int(input())
N = len(S)

# MLE対策
if K * 2 >= N-1:
    print(N)
    exit()

dp = [[[0 for _ in range(K+1)] for _ in range(N)] for _ in range(N)]
for i in range(N):
    for k in range(K+1):
        dp[i][i][k] = 1

for _j in range(1, N):
    for i in range(N):
        j = i + _j
        if j < N:
            for k in range(K+1):
                dp[i][j][k] = max(dp[i][j][k], dp[i+1][j][k], dp[i][j-1][k])
                if _j == 1:
                    if S[i] == S[j]:
                        dp[i][j][k] = 2
                    else:
                        if k+1 <= K:
                            dp[i][j][k+1] = 2
                else:
                    if S[i] == S[j]:
                        dp[i][j][k] = max(dp[i][j][k], dp[i+1][j-1][k] + 2)
                    else:
                        if k+1 <= K:
                            dp[i][j][k+1] = max(dp[i][j][k], dp[i+1][j-1][k] + 2)

print(max(dp[0][N-1]))
### BUGGY CODE ###

n=int(input())
p=1
for i in range(1,n+1):
  p*=i
print(p%(10**9+7))

### FIXED CODE ###

n=int(input())
p=1
for i in range(1,n+1):
  p=p*i%(10**9+7)
print(p)
### BUGGY CODE ###

#!/usr/bin/pypy
N, K =map(int, raw_input().split())
AN = map(int, raw_input().split())
FN = map(int, raw_input().split())

AN.sort()
FN.sort(reverse=True)

CN=[]
for i in range(N):
    CN.append([i,AN[i] * FN[i]])

for i in range(K):
    CN.sort(key=lambda x: x[1], reverse=True)

    if AN[CN[0][0]] < 0:
        break
    AN[CN[0][0]] -= 1
    CN[0][1] = AN[CN[0][0]] * FN[CN[0][0]]

CN.sort(key=lambda x: x[1], reverse=True)
print (str(CN[0][1]))

### FIXED CODE ###

#!/usr/bin/pypy
import math
import sys
N, K =map(int, raw_input().split())
AN = map(int, raw_input().split())
FN = map(int, raw_input().split())

AN.sort()
FN.sort(reverse=True)

CN=[]
for i in range(N):
    CN.append(AN[i] * FN[i])

s = 0
e = max(CN) + 1
while True:
    m = (s + e) / 2
    tk = K
    for i in xrange(len(CN)):
        if CN[i] > m:
            tk -= math.ceil(1.0 * (CN[i] - m) / FN[i])
            if tk < 0:
                # fail
                if m == s:
                    print str(e)
                    sys.exit(0)
                s = m
                break
    else:
        if m == s:
            print str(0)
            sys.exit(0)
        e = m
### BUGGY CODE ###

import sys
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

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

# cl = [0 for i in range(n)]
cl = []
ll = [x for x in set(l) if l.count(x) > 1]

# print(ll)

if not ll:
    for i in range(n):
        print(0)
    sys.exit()

sum = 0
for i in ll:
    m = l.count(i)
    nc = combinations_count(m, 2)
    sum += nc
    # print(nc)
    # cl[i-1] = nc - int(nc*(m-2)/m)
    cl.append(nc - int(nc * (m - 2) / m))

# print(sum)
# print(cl)

def my_index(l, x, default=n):
    if x in l:
        return l.index(x)
    else:
        return default

for i in l:
    # print(sum - cl[i-1])
    idx = my_index(ll, i)
    if idx == n:
        print(sum)
    else:
        print(sum - cl[idx])


### FIXED CODE ###

import collections

def combinations_count(n, r):
    return n * (n-1) // r


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

l1 = []
l2 = []
c = collections.Counter(l)

total = sum([combinations_count(i, 2) for i in c.values()])

for a in l:
    print(total-combinations_count(c[a], 2)+combinations_count(c[a]-1, 2))
### BUGGY CODE ###

import heapq
import math
x1, y1, x2, y2 = [int(i) for i in input().split()]
n = int(input())

xy = [[x1, y1,0]]
for _ in range(n):
    xy.append([int(i) for i in input().split()])
xy.append([x2, y2,0])

def dif(x, y):
    return max(0, math.sqrt((x[0] - y[0])** 2 + (x[1] - y[1])** 2) - x[2] - y[2])


que = [[0, 0]]
heapq.heapify(que)
mi = [10 ** 16] * (n + 2)
mi[0] = 0

while que:
    w, x = heapq.heappop(que)
    for i in range(n + 2):
        if i == x:
            continue
        cost = dif(xy[x], xy[i])
        if w + cost < mi[i]:
            mi[i] = w + cost
            heapq.heappush(que,[w + cost, i])
print(mi[-1])

    

### FIXED CODE ###

import math
x1, y1, x2, y2 = [int(i) for i in input().split()]
n = int(input())

xy = [[x1, y1, 0]]
for _ in range(n):
    xy.append([int(i) for i in input().split()])
xy.append([x2, y2, 0])


def dif(x, y):
    return max(0, math.sqrt((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2) - x[2] - y[2])




q = set([i for i in range(n + 2)])
mi = [10 ** 16] * (n + 2)
mi[0] = 0

while q:
    u = -1
    mm = 10**16
    for i in q:
        if mm > mi[i]:
            mm = mi[i]
            u = i
    
    q.remove(u)
    for i in q:
        mi[i] = min(mi[i], mi[u] + dif(xy[i], xy[u]))

print(mi[-1])
### BUGGY CODE ###

n, p = [int(i) for i in input().split()]
max_x = int(p**(1/n))+1
ans = 1
for i in range(max_x, 0, -1):
    if p % (i**n) == 0:
        ans = i
        break
print(ans)

### FIXED CODE ###

n, p = [int(i) for i in input().split()]
tmp = p**(1/n)
if tmp - int(tmp) > 0.999:
    max_x = int(tmp) + 1
else:
    max_x = int(tmp)
ans = 1
for i in range(max_x, 1, -1):
    if p % pow(i,n) == 0:
        ans = i
        break
print(ans)
### BUGGY CODE ###

from heapq import *

n,m,s,t=map(int,input().split())
s-=1
t-=1
INF=float("inf")
Gyen=[[]for i in range(n)]
Gsnu=[[]for i in range(n)]
for i in range(m):
  u,v,a,b=map(int,input().split())
  u-=1
  v-=1
  Gyen[u].append([v,a])
  Gyen[v].append([u,a])
  Gsnu[u].append([v,b])
  Gsnu[v].append([u,b])

def dijkstra(G,s):
  d=[INF]*n
  d[s]=0
  visited={s}
  que=[[0,s]]
  while(que):
    p=heappop(que)
    v=p[1]
    visited.add(v)
    for node,cost in G[v]:
      if (node not in visited) and d[node]>d[v]+cost:
        d[node]=d[v]+cost
        heappush(que,[d[node],node])
  return d

yen=dijkstra(Gyen,s)
snu=dijkstra(Gsnu,t)
ans=10**15
ans_list=[]
for i in reversed(range(n)):
  ans=min(ans,yen[i]+snu[i])
  ans_list.append(10**15-ans)
print(*ans_list[::-1], sep='\n')


### FIXED CODE ###

from heapq import *

n,m,s,t=map(int,input().split())
s-=1
t-=1
INF=10**19
Gyen=[[]for i in range(n)]
Gsnu=[[]for i in range(n)]
for i in range(m):
  u,v,a,b=map(int,input().split())
  u-=1
  v-=1
  Gyen[u].append([v,a])
  Gyen[v].append([u,a])
  Gsnu[u].append([v,b])
  Gsnu[v].append([u,b])

def dijkstra(G,s):
  que=[]
  d=[INF]*n
  d[s]=0
  visited={s}
  heappush(que,[0,s])
  while(que):
    p=heappop(que)
    v=p[1]
    visited.add(v)
    for node,cost in G[v]:
      if (node not in visited) and d[node]>d[v]+cost:
        d[node]=d[v]+cost
        heappush(que,[d[node],node])
  return d

yen=dijkstra(Gyen,s)
snu=dijkstra(Gsnu,t)
ans=10**15
ans_list=[]
for i in reversed(range(n)):
  ans=min(ans,yen[i]+snu[i])
  ans_list.append(10**15-ans)
print(*ans_list[::-1], sep='\n')
### BUGGY CODE ###

N = int(input())
dic = {}

for i in range (N):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1


x = [ i[0] for i in dic.items() if i[1] == max(dic.values())]

x.sort()

for i in range(len(x)):
  print(x[i])

### FIXED CODE ###

N = int(input())
dic = {}

for i in range (N):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1

sai = max(dic.values())

for j in sorted(k for k in dic if dic[k] == sai):
  print(j)
### BUGGY CODE ###

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

cnt = 0
for i in range(1000):
  c = [i // 100, (i // 10) % 10, i % 10]
  f = 0
  for j in range(N):
    if int(S[j]) == c[f]:
      f += 1
    if f == 3:
      break
  if f == 3:
    cnt += 1
print(cnt)


### FIXED CODE ###

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

cnt = 0
for i in range(1000):
  c = str(i).zfill(3)
  if c[0] in S:
        index1 = S.index(c[0])
        if c[1] in S[index1+1:]:
            index2 = index1 + 1 + S[index1+1:].index(c[1])
            if c[2] in S[index2+1:]:
                cnt+=1
print(cnt)
### BUGGY CODE ###

N=int(input())
import math
count = 0
for C in range(1,N):
    NC = N-C
    NCP = math.sqrt(NC)
    NN = math.floor(NCP)
    for i in range(1,NN+1):
        
        if NC%i == 0:
            count += 2
            if i == NCP:
                count -=1
print(count)
    

### FIXED CODE ###

N = int(input())
count=0
for i in range(1,N+1):
    for j in range(1,N+1):
            
        if i*j >=N:
            count += j-1
            break
print(count)
### BUGGY CODE ###



if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    data=[list(map(int,input().split())) for i in range(N)]
    dp=[[None] for i in range(M+1) for j in range(N+1)]
    import itertools
    ans=0
    for combination in itertools.combinations(data,M):
        temp1=0
        temp2=0
        temp3=0
        for cake in combination:
            temp1+=cake[0]
            temp2+=cake[1]
            temp3+=cake[2]
        ans=max(abs(temp1)+abs(temp2)+abs(temp3),ans)
    print(ans)







### FIXED CODE ###

power=[1,2]

if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    data=[list(map(int,input().split())) for i in range(N)]
    ans=0
    for i in power:
        for j in power:
            for k in power:
                temp=[]
                for cake in data:
                    temp.append(cake[0]*(-1)**i+cake[1]*(-1)**j+cake[2]*(-1)**k)
                temp.sort()
                temp2=temp[-M:]
                ans=max(ans,sum(temp2))

    if M==0:
        print(0)
    else:
        print(ans)
### BUGGY CODE ###

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    print(max(A[1:]))

    for i in range(1, N - 1):
        print(max(max(A[:i]), max(A[i + 1 :])))

    print(max(A[:N]))

    return


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    max_value = max(A)
    max_index = A.index(max_value)

    for i in range(N):
        if i != max_index:
            print(max_value)
        else:
            if i == 0:
                print(max(A[1:]))
            elif i == N - 1:
                print(max(A[: N - 1]))
            else:
                print(max(max(A[:i]), max(A[i + 1 :])))

    return


if __name__ == "__main__":
    main()
### BUGGY CODE ###

characteristic=10**9+7
def plus(input1,input2):
    return (input1+input2)%characteristic
def minus(input1,input2):
    return (input1-input2)%characteristic
def times(input1,input2):
    return (input1*input2)%characteristic
def exponen(input1,input2):
    binaryl=list(str(bin(input2))[2:])
    binarysize=len(binaryl)
    binarylist=[int(binaryl[binarysize-1-i]) for i in range(binarysize)]
    modlist=[0 for i in range(binarysize)]
    modlist[0]=input1
    for i in range(1,binarysize):
        modlist[i]=times(modlist[i-1],modlist[i-1])
    answer=1
    for i in range(binarysize):
        if binarylist[i]==1:
            answer=times(answer,modlist[i])
    return answer
def divide(input1,input2):
    return times(input1,exponen(input2,characteristic-2))
N=int(input())
Fact=[1 for i in range(N+1)]
for i in range(1,N+1):
    Fact[i]=times(i,Fact[i-1])
ans=0
def C(A,B):
    return divide(Fact[A],times(Fact[B],Fact[A-B]))
SGL=[0 for i in range(N)]
for K in range(N):
    if 2*K-N<0:
        continue
    F=times(Fact[K],Fact[N-1-K])
    G=C(K-1,N-1-K)
    SGL[K]=(times(F,G))
for K in range(1,N):
    ans=plus(ans,times(SGL[K]-SGL[K-1],K))
print(ans)


### FIXED CODE ###

P=10**9+7
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,P)[0]
N=int(input())
Fact=[0 for i in range(N+1)]
Finv=[0 for i in range(N+1)]
Fact[0]=1
Finv[0]=1
for i in range(N):
    Fact[i+1]=((i+1)*Fact[i])%P
    Finv[i+1]=(Finv[i]*inv(i+1))%P
SGN=[0 for i in range(N)]
ans=0
for k in range(N):
    if 2*k-N>=0:
        SGN[k]=(((Fact[k-1]*Fact[k])%P)*Finv[2*k-N])%P
        ans=(ans+k*(SGN[k]-SGN[k-1]))%P
print(ans)
### BUGGY CODE ###

X,K,D=map(int,input().split())

def valid(value1, value2, diff):
    if diff%2==0:
        return value1
    else:
        return value2

tmp = [abs(X)]
min_score = abs(X)
for i in range(K):
    if abs(X-D)>abs(X+D):
        X = X+D
    else:
        X = X-D
    if min_score > abs(X):
        min_score=abs(X)
    else:
        a = min([abs(X-D), abs(X+D)])
        min_score = valid(a, abs(X), K-i)
        break

    if abs(X) in tmp:
        a = min([abs(X-D), abs(X+D)])
        min_score = valid(a, min_score, K-i)
        break
    tmp.append(abs(X))
print(min_score)


### FIXED CODE ###

X,K,D=map(int,input().split())

def valid(value1, value2, diff):
    if diff%2==0:
        return value1
    else:
        return value2

if abs(X)>K:
    tmp = abs(X)//D
    if tmp>K:
        tmp=K
    if X < 0:
        X += tmp*D
    else:
        X -= tmp*D
    K -= tmp

min_score = abs(X)
for i in range(K):
    if abs(X-D)>abs(X+D):
        X = X+D
    else:
        X = X-D
    if min_score > abs(X):
        min_score=abs(X)
    else:
        a = min([abs(X-D), abs(X+D)])
        min_score = valid(a, abs(X), K-i)
        break
print(min_score)
### BUGGY CODE ###

def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    N = int(input())
    S = input().strip()
    R = [0] * N
    G = [0] * N
    B = [0] * N
    rcnt = 0
    gcnt = 0
    bcnt = 0
    rgb = {
        ('R', 'G'):'B',
        ('G', 'R'):'B',
        ('R', 'B'):'G',
        ('B', 'R'):'G',
        ('G', 'B'):'R',
        ('B', 'G'):'R'
    }
    for i, s in enumerate(S):
        if s == 'R':
            rcnt += 1
        elif s == 'G':
            gcnt += 1
        elif s == 'B':
            bcnt += 1
        R[i] = rcnt
        G[i] = gcnt
        B[i] = bcnt
    # print(R, rcnt)
    # print(G, gcnt)
    # print(B, bcnt)
    ans = 0
    for i in range(N-1):
        for j in range(i+1, N):
            # print('i = {}:{}, j = {}:{}'.format(i, S[i], j, S[j]), end=', ')
            if S[i] == S[j]:
                # print('S[i] == S[j] == {}'.format(S[i]))
                continue
            s = rgb[S[i], S[j]]
            if s == 'R':
                ans += rcnt - R[j]
                # print('ans += {}'.format(rcnt - R[j]))
            elif s == 'G':
                ans += gcnt - G[j]
                # print('ans += {}'.format(gcnt - G[j]))
            elif s == 'B':
                ans += bcnt - B[j]
                # print('ans += {}'.format(bcnt - B[j]))
            tn = j + (j-i)
            if tn < N and S[tn] == s:
                ans -= 1

    print(ans)




if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    N = int(input())
    S = input().strip()
    R = [0] * N
    G = [0] * N
    B = [0] * N
    rcnt = 0
    gcnt = 0
    bcnt = 0
    rgb = {
        ('R', 'G'):'B',
        ('G', 'R'):'B',
        ('R', 'B'):'G',
        ('B', 'R'):'G',
        ('G', 'B'):'R',
        ('B', 'G'):'R'
    }
    for i, s in enumerate(S):
        if s == 'R':
            rcnt += 1
        elif s == 'G':
            gcnt += 1
        elif s == 'B':
            bcnt += 1
        R[i] = rcnt
        G[i] = gcnt
        B[i] = bcnt
    # print(R, rcnt)
    # print(G, gcnt)
    # print(B, bcnt)
    ans = 0
    for i in range(N-1):
        for j in range(i+1, N):
            # print('i = {}:{}, j = {}:{}'.format(i, S[i], j, S[j]), end=', ')
            if S[i] == S[j]:
                # print('S[i] == S[j] == {}'.format(S[i]))
                continue
            s = rgb[S[i], S[j]]
            if s == 'R':
                ans += rcnt - R[j]
                # print('ans += {}'.format(rcnt - R[j]))
            elif s == 'G':
                ans += gcnt - G[j]
                # print('ans += {}'.format(gcnt - G[j]))
            elif s == 'B':
                ans += bcnt - B[j]
                # print('ans += {}'.format(bcnt - B[j]))
            tn = j + (j-i)
            if tn < N and S[tn] == s:
                ans -= 1

    print(ans)




if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
mod = 10**9+7
s = list(input())[:-1]

s = s[::-1]

ls = len(s)

mod_13_list = [ (10**i) % 13 for i in range(6) ]

dp_list = [ 0 for i in range(13) ]
if  s[0] != "?":
    p = int(s[0])
    dp_list[p] += 1
else:
    for i in range(10):
        dp_list[i] += 1

t = 1
for i in range(1,ls):
    r = mod_13_list[t]
    t = ( t + 1 ) % 6
    new_dp_list = [ 0 for i in range(13) ]
    if s[i] != "?":
        p = int(s[i])
        q = ( p * r ) % 13
        for j in range(13):
            new_dp_list[(j+q)%13] += dp_list[j]
    
    else:
        for k in range(10):
            q = (k * ( 10 ** i) ) % 13
            for j in range(13):
                new_dp_list[(j+q)%13] += dp_list[j]
    
    dp_list = [ i % mod for i in new_dp_list ]

print(dp_list[5])

### FIXED CODE ###

import sys
input = sys.stdin.readline
mod = 10**9+7
s = list(input())[:-1]

s = s[::-1]

ls = len(s)

mod_13_list = [ (10**i) % 13 for i in range(6) ]

dp_list = [ 0 for i in range(13) ]
if  s[0] != "?":
    p = int(s[0])
    dp_list[p] += 1
else:
    for i in range(10):
        dp_list[i] += 1

t = 1
for i in range(1,ls):
    r = mod_13_list[t]
    t = ( t + 1 ) % 6
    new_dp_list = [ 0 for i in range(13) ]
    if s[i] != "?":
        p = int(s[i])
        q = ( p * r ) % 13
        for j in range(13):
            new_dp_list[(j+q)%13] += dp_list[j]
    
    else:
        for k in range(10):
            q = (k * r ) % 13
            for j in range(13):
                new_dp_list[(j+q)%13] += dp_list[j]
    
    dp_list = [ i % mod for i in new_dp_list ]

print(dp_list[5])
### BUGGY CODE ###

N , K = map(int,input().split())
h = list(map(int,input().split()))
inf = float('inf')
dp = [inf] * N
if K == 1:
    ans = 0
    for i in range(N - 1):
        ans += abs(h[i + 1] - h[i])
    print(ans)
    exit()

for i in range(N):
    if i == 0:
        min_cost = 0
    elif i == 1:
        min_cost = abs(h[1] - h[0])
    # elif i == 2:
    #     min_cost = min(abs(h[2] - h[0]) + dp[0], abs(h[2] - h[1]) + dp[1])
    else:
        tmp_min = min(abs(h[i] - h[i - K]) + dp[i - K] , abs(h[i] - h[i - K + 1]) + dp[i - K + 1])
        for j in range(K - 2):
            tmp_min = min(abs(h[i] - h[i - K + 2 + j]) + dp[i - K + 2 + j], tmp_min)
        min_cost = tmp_min
    dp[i] = min_cost
#print(dp)
print(dp[N - 1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
N , K = map(int,input().split())
h = list(map(int,input().split()))
inf = float('inf')
dp = [inf] * N
if K == 1:
    ans = 0
    for i in range(N - 1):
        ans += abs(h[i + 1] - h[i])
    print(ans)
    exit()

for i in range(N):
    if i == 0:
        min_cost = 0
    elif i == 1:
        min_cost = abs(h[1] - h[0])
    else:
        current = h[i]
        tmp_min = min(abs(current - h[i - K]) + dp[i - K] , abs(current - h[i - K + 1]) + dp[i - K + 1])
        for j in range(K - 2):
            tmp_min = min(abs(current - h[i - K + 2 + j]) + dp[i - K + 2 + j], tmp_min)
        min_cost = tmp_min
    dp[i] = min_cost
#print(dp)
print(dp[N - 1])
### BUGGY CODE ###

S = [input() for _ in range(int(input()))]
T = set(S)
cnt =0
ans = dict()
for t in T:
    li = S.count(t)
    ans[t] = li
    cnt = max(cnt,li)
ans = sorted(ans.items(),reverse=True, key=lambda x:x[1])
key = sorted([k for k,v in ans if v == cnt])
for a in key:print(a)

### FIXED CODE ###

S = [input() for _ in range(int(input()))]
from collections import Counter
ctr = Counter(S)
n = ctr.most_common()[0][1]#一番頻度の高い
ans = []

for k,v in ctr.items():
    if v == n:ans.append(k)
ans.sort()
print(*ans,sep="\n")
### BUGGY CODE ###

num = int(input())
numbers = input().split()
sum = 1
for i in range(num):
  numbers[i] = int(numbers[i])
  sum = sum*numbers[i]
if (sum>(10**18)):
  print ('-1')
else :
  print (sum)

### FIXED CODE ###

num = int(input())
numbers = list(map(int,input().split()))
sum = 1
for i in range(num):
  sum *=numbers[i]
  if (sum>(10**18)):
    sum = -1
    break
if 0 in numbers:
  sum = 0
print (sum)
### BUGGY CODE ###

import collections
S = input()
Smod = [0] * 2019
Smod[0] = 1
ans = 0
for i in range(len(S)-1, -1, -1):
  S_i = int(S[i:])
  ans += Smod[S_i%2019]
  Smod[S_i%2019] += 1

print(ans)

### FIXED CODE ###

S = input()
Smod = [0] * 2019
Smod[0] = 1
ans = 0
S_i = 0
prevmod = 0
k = 1
for i in range(len(S)-1, -1, -1):
  S_i = (int(S[i]) * k + prevmod) % 2019
  ans += Smod[S_i]
  Smod[S_i] += 1
  prevmod = S_i
  k = (k * 10) % 2019
print(ans)
### BUGGY CODE ###

def find_min_fuka_idx(lst, x):
  ok = -1
  ng = len(lst)
  while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if x>=lst[mid]:
      ok = mid
    else:
      ng = mid
  return ng

a,b,q = map(int, input().split())
s = [-10**18]
s_mid = [int(input()) for i in range(a)]
s.extend(s_mid)
s.append(10**18)
  
t = [-10**18]
t_mid = [int(input()) for i in range(b)]
t.extend(t_mid)
t.append(10**18)

for i in range(q):
  x = int(input())
  si = find_min_fuka_idx(s, x)
  tj = find_min_fuka_idx(t, x)
  ssi = s[si]
  ssi1 = s[si-1]
  ttj = t[tj]
  ttj1 = t[tj-1]
  print(min(abs(x-ssi)+abs(ssi-ttj),\
            abs(x-ssi)+abs(ssi-ttj1),\
           abs(x-ttj)+abs(ttj-ssi),\
            abs(x-ttj)+abs(ttj-ssi1),\
            abs(x-ssi1)+abs(ssi1-ttj),\
            abs(x-ssi1)+abs(ssi1-ttj1),\
           abs(x-ttj1)+abs(ttj1-ssi),\
            abs(x-ttj1)+abs(ttj1-ssi1)))


### FIXED CODE ###

import bisect
def find_min_fuka_idx(lst, x):
  ok = -1
  ng = len(lst)
  while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if x>=lst[mid]:
      ok = mid
    else:
      ng = mid
  return ng

a,b,q = map(int, input().split())
s = [-10**18]
s_mid = [int(input()) for i in range(a)]
s.extend(s_mid)
s.append(10**18)

t = [-10**18]
t_mid = [int(input()) for i in range(b)]
t.extend(t_mid)
t.append(10**18)

for i in range(q):
  x = int(input())
  si = bisect.bisect_right(s, x)
  tj = bisect.bisect_right(t, x)
  print(min(abs(x-s[si])+abs(s[si]-t[tj]),\
            abs(x-s[si])+abs(s[si]-t[tj-1]),\
           abs(x-t[tj])+abs(t[tj]-s[si]),\
            abs(x-t[tj])+abs(t[tj]-s[si-1]),\
            abs(x-s[si-1])+abs(s[si-1]-t[tj]),\
            abs(x-s[si-1])+abs(s[si-1]-t[tj-1]),\
           abs(x-t[tj-1])+abs(t[tj-1]-s[si]),\
            abs(x-t[tj-1])+abs(t[tj-1]-s[si-1])))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
k, s = map(int,input().split())
count = 0
if k == s/3:
  print(1)
  exit()
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x + y + z == s:
        #print(x,y,z)
        count += 1
print(count)


### FIXED CODE ###

# -*- coding: utf-8 -*-
k, s = map(int,input().split())
count = 0
if k == s/3:
  print(1)
  exit()
for x in range(k+1):
  for y in range(k+1):
    z = s - x -y
    if (z >= 0 and z <= k):
      #print(x,y,z)
      count += 1
print(count)