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

import queue

h, w = list(map(int, input().split()))
smat = [input() for _ in range(h)]

def bfs(x0, y0):
    visited = set()
    q = queue.Queue()
    q.put((x0, y0, -1))

    mx = 0
    while not q.empty():
        x, y, d = q.get()
        nd = d + 1
        visited.add((x, y))
        mx = max(mx, nd)

        for dx, dy in [(-1, 0), (0, -1), (+1, 0), (0, +1)]:
            nx = x + dx
            ny = y + dy
            if not (0 <= nx < h) or not (0 <= ny < w):
                # bound check
                continue
            if smat[nx][ny] == '#':
                # cell attr check
                continue
            if (nx, ny) in visited:
                # already visited
                continue
            v = (nx, ny, nd)
            q.put(v)
    
    return mx

mxall = 0
for x0 in range(h):
    for y0 in range(w):
        if smat[x0][y0] == '.':
            mx = bfs(x0, y0)
            mxall = max(mxall, mx)
print(mxall)


### FIXED CODE ###

import collections

h, w = list(map(int, input().split()))
smat = [input() for _ in range(h)]

def bfs(x0, y0):
    visited = [[0 for _ in range(w)] for _ in range(h)]
    deq = collections.deque()
    deq.append((x0, y0, -1))

    mx = 0
    while len(deq) > 0:
        x, y, d = deq.popleft()
        nd = d + 1
        visited[x][y] = 1
        mx = max(mx, nd)

        for dx, dy in [(-1, 0), (0, -1), (+1, 0), (0, +1)]:
            nx = x + dx
            ny = y + dy
            if not (0 <= nx < h) or not (0 <= ny < w):
                # bound check
                continue
            if smat[nx][ny] == '#':
                # cell attr check
                continue
            if visited[nx][ny] == 1:
                # already visited
                continue
            v = (nx, ny, nd)
            deq.append(v)
    
    return mx

if all(all(col == '.' for col in row) for row in smat):
    print((w - 1) + (h - 1))
else:
    mxall = 0
    for x0 in range(h):
        for y0 in range(w):
            if smat[x0][y0] == '.':
                mx = bfs(x0, y0)
                mxall = max(mxall, mx)
    print(mxall)
### BUGGY CODE ###

n, k , q = map(int, input().split())
qlist = [int(input()) for _ in range(q)]

for i in range(1, n+1):
    damage = q - qlist.count(i)
    if damage < k:
        print('Yes')
    elif damage >= k:
        print('No')

### FIXED CODE ###

from collections import Counter
n, k , q = map(int, input().split())
qlist = [int(input()) for _ in range(q)]
count = Counter(qlist)

for i in range(1, n+1):
    damage = q - count[i]
    if damage < k:
        print('Yes')
    elif damage >= k:
        print('No')
### BUGGY CODE ###

N, M = map(int, input().split())

L, R = map(int, input().split())
hoge = list(range(L, R+1))
hoge = set(hoge)

for i in range(1, M):
    L, R = map(int, input().split())
    fuga = list(range(L, R+1))
    hoge = hoge & set(fuga)

print(len(hoge))


### FIXED CODE ###

N, M = map(int, input().split())

L, R = map(int, input().split())

for i in range(1, M):
    hoge, fuga = map(int, input().split())
    L = max(L, hoge)
    R = min(R, fuga)


if L > R:
    print(0)
else:
    print(R-L+1)
### BUGGY CODE ###

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
  for j in range(W+1):
    if j - wv[i][0] >= 0:
      dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]]+wv[i][1])
    else:
      dp[i+1][j] = dp[i][j]

print(max(dp[N]))

### FIXED CODE ###

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
  for j in range(W+1):
    if j - wv[i][0] >= 0:
      dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]]+wv[i][1])
    else:
      dp[i+1][j] = dp[i][j]

print(max(dp[N]))
### BUGGY CODE ###

n = int(input())
a_lst = list(map(int, input().split()))

c = 0

for i in a_lst:
    if i == 0:
        print(0)
        c = 1
        break
        
    if i > 1000000000000000000:
        print('-1')
        c = 1
        break
        
if c != 1:
    for i, alst in enumerate(a_lst):
        if i == 0:
            b = alst
        else:
            b = b * alst
    
    if b > 1000000000000000000:
        print('-1')
    else:
        print(b)

### FIXED CODE ###

N = int(input())
A= list(map(int, input().split()))
result=1
if 0 in A:
    result = 0
else:
    for t in range(N):
        result *= A[t]
        if result > 10 ** 18:
            result = -1
            break
print(result)
### BUGGY CODE ###

n,m = map(int, input().split())
a = [int(input()) for _ in range(m)]
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(2, n+1):
    dp[i] = (dp[i-1]+dp[i-2])%mod if i not in a else 0 #かけたところは0にしとこう、ってことか…
print(dp[n])

### FIXED CODE ###

n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(2, n+1):
    dp[i] = (dp[i-1]+dp[i-2])%mod if i not in a else 0 #かけたところは0にしとこう、ってことか…
print(dp[n])
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))

from bisect import bisect_left, bisect

ans = 0
for i in range(N):
    b = B[i]
    a = bisect_left(A,b)
    c = bisect(C,b)
    #print(b,A[:a],C[c:])
    ans += len(A[:a])*len(C[c:])
print(ans)

### FIXED CODE ###

from bisect import bisect_left, bisect

n=int(input())
la=sorted(list(map(int,input().split())))
lb=list(map(int,input().split()))
lc=sorted(list(map(int,input().split())))
ans=0
for i in lb:
    ans+=bisect_left(la,i)*(len(lc)-bisect(lc,i)) #iの挿入点つまりiより小さい値の数×(Cの総数-
print(ans)
### BUGGY CODE ###

INF = 10000
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f

dp = [[INF for i in range(N)] for j in range(1 << N)]

for i in range(N):
    dp[1 << i][i] = i

for i in range(1 << N):
    for j in range(N):
        if i >> j & 1:
            if (popcount(i) - j) % 2 != 0:
                num = A[j]
            else:
                num = B[j]
            cnt = 0
            for k in range(N):
                if not (i >> k & 1):
                    if (popcount(i) - k) % 2 == 0:
                        num2 = A[k]
                    else:
                        num2 = B[k]
                    if num <= num2:
                        dp[i | 1 << k][k] = min(dp[i | 1 << k][k], dp[i][j] + cnt)
                    cnt += 1

ans = INF
for i in range(N):
    ans = min(ans, dp[(1 << N) - 1][i])

if ans == INF:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

INF = 10000
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f

dp = [[INF for i in range(N)] for j in range(1 << N)]

for i in range(N):
    dp[1 << i][i] = i

for i in range(1 << N):
    for j in range(N):
        if i >> j & 1:
            if (popcount(i) - j) % 2 != 0:
                num = A[j]
            else:
                num = B[j]
            cnt = 0
            for k in range(N):
                if not (i >> k & 1):
                    if (popcount(i) - k) % 2 == 0:
                        num2 = A[k]
                    else:
                        num2 = B[k]
                    if num <= num2:
                        dp[i | 1 << k][k] = min(dp[i | 1 << k][k], dp[i][j] + cnt)
                    cnt += 1

ans = INF
for i in range(N):
    ans = min(ans, dp[(1 << N) - 1][i])

if ans == INF:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

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

ss = []
pre = S[0]
num = 0
if S[0]=='0':ss.append(0)
  
for i in range(1, N):
    if S[i]!=pre:
        ss.append(len(S[num:i]))
        num = i
        pre = S[i]
ss.append(len(S[num: N]))

ans = 0

for i in range(0,len(ss), 2):
    ans = max(ans, sum(ss[i:i+2*K+1]))
    if i+2*K+1> len(ss):break

print(ans)
  


### FIXED CODE ###

N, K = map(int,input().split())
S = input()
s = []
if S[0]=='0':s = [0]
for x in S.replace('01', '0,1').replace('10','1,0').split(','):
    s.append(len(x))
M = len(s)
ans = [0] * M
ans[0] = sum(s[:2*K+1])

for i in range(2, M, 2):
    ans[i] = ans[i-2] - s[i-2] - s[i-1] + sum(s[min(i+2*K-1,M):i+2*K+1])
print(max(ans))
### BUGGY CODE ###

import numpy as np
import fractions 
#from functools import reduce
import functools

MOD = 10**9+7


def main():
    N = int(input())
    A = list(map(int, input().split()))
    # for a in A:
    #     print(a)

    x = 1
    ans = 0
    # for a in A:
    #     tmp = gcd(x, a)
    #     # ans += (i) * A[i] // tmp + A[i] * x //tmp  
    #     x = (x * a) // tmp

    def lcm(x, y):
        return x * y // fractions.gcd(x, y)
        
    
    x = functools.reduce(lcm, A, 1)
        
    b = sum(x//a for a in A)
    print(b%MOD)
main()


### FIXED CODE ###

import fractions 
#from functools import reduce
import functools

MOD = 10**9+7


def main():
    # N = int(input())
    # A = list(map(int, input().split()))
    N, *A = map(int, open(0).read().split())
            
    x = 1
    for a in A:
        x *= a //  fractions.gcd(x, a)
        
    b = sum(x//a for a in A)
    print(b%MOD)
    
if __name__== "__main__":
    main()
### BUGGY CODE ###

N, M = map(int, input().split())
tmp = []
PY = [[] for _ in range(N + 1)]
PY_sorted = [[] for _ in range(N + 1)]

for i in range(M):
    p, y = map(int, input().split())
    tmp.append([p, y])
    PY[p].append(y)
    PY[p] = sorted(PY[p])

for prefecture, year in tmp:
    text = ""
    text += "%06d" % prefecture
    text += "%06d" % (PY[prefecture].index(year) + 1)
    print(text)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
PY = [[] for _ in range(N + 1)]

for i in range(M):
    p, y = map(int, input().split())
    PY[p].append((y, i))

ans = []

for pre_id, info in enumerate(PY):
    info.sort()
    for i in range(len(info)):
        ans.append((info[i][1], "%06d" % pre_id, "%06d" % (i + 1)))

ans.sort()
for i, x, y in ans:
    print(str(x) + str(y))
### BUGGY CODE ###

def main():
    platform_count, jumping_power = [int(x) for x in input().split()]
    platforms = [int(x) for x in input().split()]
    dp = [0]
    for i in range(1, platform_count):
        indexes = (i - x for x in range(1, jumping_power + 1) if i - x >= 0)
        dp.append(
            min(abs(platforms[i] - platforms[before]) + dp[before]
                for before in indexes))
    print(dp[platform_count - 1])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    platform_count, jumping_power = [int(x) for x in input().split()]
    platforms = [int(x) for x in input().split()]
    dp = [0]
    for i in range(1, platform_count):
        indexes = (i - x for x in range(1, jumping_power + 1) if i - x >= 0)
        dp.append(
            min(abs(platforms[i] - platforms[before]) + dp[before]
                for before in indexes))
    print(dp[platform_count - 1])


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

import bisect
import math
 
N=int(input())
a1=0
a2=0
b1=0
b2=0
c1=0
c2=0
c3=0
 
ans=0
 
A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B)
B.append(math.inf)
C=list(map(int, input().split()))
C=sorted(C)
C.append(math.inf)
for i in range(len(A)):
  a1=A[i]
  b2=bisect.bisect_right(B,a1)
  for j in range(b2,len(B)-1):
    b1=B[j]
    c2=bisect.bisect_right(C,b1)
    c3=len(C)-c2-1
    ans += c3

print(ans)

### FIXED CODE ###

import bisect
 
N=int(input())
b1=0
d=0

ans=0
 
A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B, reverse=True)
C=list(map(int, input().split()))
C=sorted(C)
D=[]
E=[]

for b in B:
  d=d+len(C)-bisect.bisect_right(C,b)
  D.append(d)

D=sorted(D, reverse= True)  
B=sorted(B)

for a in A:
  if 0 <= bisect.bisect_right(B,a) <= len(D)-1:
    ans += D[bisect.bisect_right(B,a)]
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
h = [int(x) for x in input().split()]

dp = [float('inf')] * N
dp[0] = 0

Func = min
for i in range(N-1):
    for j in range(i+1, i+K+1):
        if j >= N:
            break
        dp[j] = Func(dp[j], dp[i] + abs(h[i] - h[j]))

print(dp[N-1])

### FIXED CODE ###

N, K = map(int, input().split())
h = [int(x) for x in input().split()]

dp = [float('inf')] * N
dp[0] = 0

for i in range(N-1):
    for j in range(i+1, i+K+1):
        if j >= N:
            break
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))

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

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

import numpy as np

n, m=map(int, input().split())
ab = [["",""] for _ in range(n)]
for i in range(n):
    ab[i]=list(map(int, input().split()))

sec_sort = lambda val: val[1]
ab.sort(key = sec_sort, reverse=True)
#print(ab)

abs = [[] for _ in range(4)]

for i in range(n):
    abs[0].append(i) 
    abs[1].append(ab[i][0]) 
    abs[2].append(ab[i][1]) 
    abs[3].append(0) 

np_abs = np.array(abs)
#print(np_abs)

sum = 0
for dayLeft in range(1,m+1):

    CanWork = (np_abs[1] <= dayLeft) #日数がA以内
    isWorkLeft = (np_abs[3] == 0)
    isCandidate = np.logical_and(CanWork, isWorkLeft)
#    print(isCandidate)

    #候補が1以降ならば
    if np.any(isCandidate == True):
        index = np.min(np_abs[0][isCandidate]) #日数がA以内かつソート昇順最初のindex
#        print(index)
        sum += np_abs[2][index] #indexのBを取得して足しこむ
        np_abs[3][index] = 1 #0→1に

    #候補がなければ次のdayLeftへ
    else:
        continue

print(sum)

### FIXED CODE ###

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

import heapq

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

work = [[] for _ in range(10**5+1)]
for i in range(n):
    ta, tb = map(int, input().split())
    work[ta].append(tb)

total = 0
cand = []

for d in range(1, m+1):
    for w in work[d]:
        #後で最大値を取り出したいので-1倍して追加
        #（複数の要素も一気にpush）
        heapq.heappush(cand, -w) 
        
    if len(cand) > 0:
        #-1倍して最大値として取得
        total += heapq.heappop(cand)*(-1) 
        
print(total)
### BUGGY CODE ###

A,B,C=map(int,input().split())
ABC=0
while(1):
    if C>0:
        ABC+=1
        C-=1
    if C>0 and A==0 and B==0:
        break
    if B>0:
        ABC+=1
        B-=1
    elif A>0:
        A-=1
print(ABC)

### FIXED CODE ###

A,B,C=map(int,input().split())
Z = C-A-B
if Z>1:
    print(B*2+A+1)
else:
    print(B+C)
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline


def bfs(table, i, j):
    dq = deque()
    seen = set()
    if table[i][j] == "#":
        return -1
    h = len(table)
    w = len(table[0])
    ans = 0
    dq.append((i, j, 0))  # x,y,distance
    while dq:
        x, y, dis = dq.popleft()
        ans = max(ans, dis)
        seen.add((x, y))
        if x > 0 and (x - 1, y) not in seen and table[x - 1][y] != "#":
            dq.append((x - 1, y, dis + 1))
        if x < h - 1 and (x + 1, y) not in seen and table[x + 1][y] != "#":
            dq.append((x + 1, y, dis + 1))
        if y > 0 and (x, y - 1) not in seen and table[x][y - 1] != "#":
            dq.append((x, y - 1, dis + 1))
        if y < w - 1 and (x, y + 1) not in seen and table[x][y + 1] != "#":
            dq.append((x, y + 1, dis + 1))
    del(seen)
    return ans


def main():
    h, w = [int(i) for i in input().strip().split()]
    grid = [list(input().strip()) for _ in range(h)]
    ans = -1
    for i in range(h):
        for j in range(w):
            if grid[i][j] == ".":
                max_path = bfs(grid, i, j)
                ans = max(ans, max_path)

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque
 
def main():
    H,W=map(int,input().split())
    S=[]
    for i in range(H):
        s=input()
        S.append(s)
 
    G=[]
    for i in range(H):
        for j in range(W):
            tmp=[]
            if S[i][j]=="#":
                G.append(tmp)
                continue
            if i-1>=0:
                if S[i-1][j]==".":
                    tmp.append((i-1)*W+j)
            if i+1<=H-1:
                if S[i+1][j]==".":
                    tmp.append((i+1)*W+j)
            if j-1>=0:
                if S[i][j-1]==".":
                    tmp.append(i*W+j-1)
            if j+1<=W-1:
                if S[i][j+1]==".":
                    tmp.append(i*W+j+1)
            G.append(tmp)
 
    res=0
 
    for start in range(H*W):
        dist = 0
        v = [-1 for _ in range(H * W)]
        que=deque([])
        que.append(start)
        v[start]=dist
        while len(que)>0:
            next_index=que.popleft()
            next=G[next_index]
            for i in next:
                if v[i]==-1:
                    que.append(i)
                    v[i]=v[next_index]+1
 
        if max(v)>=res:
            res=max(v)
 
    print(res)
 
 
if __name__=="__main__":
    main()
### BUGGY CODE ###

import math
 
sum = 0
k = int(input())
for a in range(1, k + 1):
  for b in range(1, k + 1):
    for c in range(1, k + 1):
      ab = math.gcd(a, b)
      sum += math.gcd(ab, c)
print(sum)    

### FIXED CODE ###

import math

k = int(input())
list = [0]*201
for b in range(1, k + 1):
    for c in range(1, k + 1):
        list[math.gcd(b, c)] += 1
list_2 = [0]*201
for i in range(k):
    for a in range(1, k + 1):
        list_2[i + 1] += math.gcd(i + 1, a)*list[i + 1]
print(sum(list_2))
### BUGGY CODE ###

import sys
from math import sqrt, ceil

n, p = [int(i) for i in input().split()]

if n == 1:
    print(p)
    sys.exit()

if p == 1:
    print(1)
    sys.exit()

ans = []
for i in range(1, p):
    if i ** n > p:
        break

    if p % (i ** n) == 0:
        ans.append(i)

# print(ans)
print(max(ans))


### FIXED CODE ###

from math import sqrt, floor, log


def is_prime(num):
    if num <= 1:
        return False

    for i in range(2, floor(num / 2) + 1):
        if i == num:
            break
        if num % i == 0:
            return False
    return True


def get_divisors3(num):
    ans = []
    value = num
    i = 2
    while (i * i) <= num:
        count = 0
        while value % i == 0:
            count += 1
            value = value // i

        if count != 0:
            ans.append((i, count))
        i += 1
    return ans


def main():
    n, p = [int(i) for i in input().split()]
    if n == 1:
        print(p)
    elif p == 1:
        print(1)
    else:
        ds = get_divisors3(p)
        ans = 1
        for d in ds:
            if d[1] >= n:
                ans *= d[0] ** (d[1] // n)
        print(int(ans))


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

a, b, c, d = map(int, input().split())
m=0
for i in range(a,b+1):
    if (i%c == 0 or i%d == 0):
        continue
    m += 1
print(m)

### FIXED CODE ###

from fractions import gcd
a, b, c, d = map(int, input().split())

e = (c*d)//gcd(c,d)

def calc(x):
    return x - (x//c)-(x//d)+(x//e)

print(calc(b)-calc(a-1))
### BUGGY CODE ###

N, WW = map(int, input().split())
W, V = [], []
for _ in range(N):
    _w, _v = list(map(int, input().split()))
    if _w > WW:
        continue
    W.append(_w)
    V.append(_v)

# dp = [[0] * (WW+1) for _ in range(N+1)]
dp = [[0] * (N+1) for _ in range(WW+1)]
for j in range(WW+1):
    # アイテムの数だけ探索する
    for i in range(1, N+1):
        w = W[i-1]
        v = V[i-1]
        if j+w > WW:
            continue
        dp[j+w][i] = max(dp[j+w][i-1], max(dp[j][:i]) + v)

# import numpy as np
# print(np.array(dp))
print(max(dp[WW]))


### FIXED CODE ###

N, WW = map(int, input().split())
W, V = [], []
for _ in range(N):
    _w, _v = list(map(int, input().split()))
    if _w > WW:
        continue
    W.append(_w)
    V.append(_v)

dp = [[0] * (WW+1) for _ in range(N+1)]
for i in range(1, N+1):
    # i := 1...N
    for j in range(1, WW+1):
        # j := 0...WW
        
        wi = W[i-1]
        vi = V[i-1]
        if j-wi < 0:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wi] + vi)

print(dp[N][WW])
### BUGGY CODE ###

s=set()
l = [0] * ( 10 ** 5 + 1 )
N = int(input())
A = list(map(int, input().split()))
for i in range(len(A)):
    l[A[i]] += 1
    s.add(A[i])
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    if l[B] > 0:
        s.add(C)
        l[C] += l[B]
        l[B] = 0
        s.discard(B)
    sum=0
    for i in s:
        sum += i * l[i]
    print(sum)


### FIXED CODE ###

s=set()
l = [0] * ( 10 ** 5 + 1 )
sum=0
N = int(input())
A = list(map(int, input().split()))
for i in range(len(A)):
    l[A[i]] += 1
    s.add(A[i])
    sum += A[i]
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    if l[B] > 0:
        s.add(C)
        sum = sum + l[B] * ( C - B )
        l[C] += l[B]
        l[B] = 0
        s.discard(B)
    print(sum)
### BUGGY CODE ###

K,S = map(int,input().split())
cnt = 0
for l in range(K+1):
  for m in range(K+1):
    for n in range(K+1):
      if l+m+n == S:
        cnt +=1
print(cnt)        


### FIXED CODE ###

K,S = map(int,input().split())
one = 0
three = 0
six = 0
if S%3==0:
    one = 1
else:
    one = 0
for l in range(K+1):
    if (S-l)%2==0 and (S-l)//2 <= K and (S-l)>=0:
        three += 1
for m in range(K-1):
    for n in range(m+1,K):
        rest = S-(m+n)
        if rest>n and rest<=K:
          six += 1
print(one+3*(three-one)+6*six)
### BUGGY CODE ###

num = int(input())

count_max = 0
for i in range(num):
  tmp = i
  count = 0
  while tmp % 2 == 0:
    tmp = tmp / 2
    count += 1
  if conut > count_max:
    count_max = count


### FIXED CODE ###

num = int(input())

count_max = 0
num_max = 0
for i in range(1, num+1):
  tmp = i
  count = 0
  while tmp % 2 == 0:
    tmp = tmp / 2
    count += 1
  if count >= count_max:
    count_max = count
    num_max = i

if num == 1:
  print(1)
else:
  print(num_max)
### BUGGY CODE ###

h, n = map(int, input().split())
magics = sorted([list(map(int, input().split())) for _ in range(n)])
max_cost = max(magic[1] for magic in magics)

dp = [float('inf')] * (h+max_cost)

dp[0] = 0
for i in range(len(dp)):
    for at, cost in magics:
        if at <= i:
            dp[i] = min(dp[i], dp[i-at] + cost)
        else:
            break
print(min(dp[h:]))



### FIXED CODE ###

h, n = map(int, input().split())
magics = sorted(list(map(int, input().split())) for _ in range(n))
max_cost = max(magic[1] for magic in magics)

dp = [float('inf')] * (h+max_cost)
dp[0] = 0
for i in range(h+max_cost):
    for at, cost in magics:
        if at <= i:
            dp[i] = min(dp[i], dp[i-at] + cost)
        else:
            break
print(min(dp[h:]))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""

N,W=map(int,input().split())

dp=dict()
dp[0]=[0]*(W+1)
for i in range(1,N+1):
    #print(dp)
    dp[i]=[0]*(W+1)
    w,v=map(int,input().split())
    for j in range(w):
        dp[i][j]=dp[i-1][j]
    for j in range(w,W+1):
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v)
   
print(max(dp[N]))

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""


N,W=map(int,input().split())
dp=[0]*(W+1)
L = sorted([list(map(int,input().split())) for i in range(N)])
s=0

for w, v in L:
    s+=w
    for j in range(min(W,s),w-1,-1):
        if dp[j-w]+v > dp[j]: dp[j]=dp[j-w]+v
    
print(max(dp))
### BUGGY CODE ###

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

mod = 10 ** 9 + 7
comb_i = pow(26, K, mod)
ans = comb_i
for i in range(1, K + 1):
  comb_i = (comb_i * (N - 1 + i) * pow(i, -1, mod)) % mod
  comb_i = (comb_i * 25 * pow(26, -1, mod)) % mod
  ans = (ans + comb_i) % mod
  
print(ans)

### FIXED CODE ###

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

mod = 10 ** 9 + 7
div = pow(26, -1, mod)
comb_i = pow(26, K, mod)
ans = comb_i
for i in range(1, K + 1):
  comb_i = (comb_i * (N - 1 + i) * pow(i, -1, mod)) % mod
  comb_i = (comb_i * 25 * div) % mod
  ans = (ans + comb_i) % mod
  
print(ans)