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

from collections import Counter
import re
import sys

s=input()
checked=[]
for i in range(len(s)):
    suffix=s[i:]
    f_len=len(suffix)
    for j in range(f_len):
        if(j==0):
            fact=suffix
        elif(j>0):
            fact=fact[:-1]
        if(fact in checked):
            continue
        count=Counter(fact)
        count_max=max(count.values())
        moji=[moji for moji,j in count.items() if j==count_max]
        moji=moji[0]
        if(count[moji]>len(fact)/2 and len(fact)>1):
            span=(re.search(fact,s).span())
            print(span[0]+1,span[1])
            sys.exit()
        checked.append(fact)
print(-1,-1)

### FIXED CODE ###

arr = list(input())
tmp1 = arr[0]
tmp2 = arr[1]
 
i = 2
flg = True
if (tmp1 != tmp2):
    while i < len(arr):
        tmp3 = arr[i]
        if (tmp3 == tmp2):
            print(str(i) + " " + str(i + 1))
            flg = False
            break
        if (tmp3 == tmp1):
            print(str(i - 1) + " " + str(i + 1))
            flg = False
            break
 
        tmp1 = arr[i - 1]
        tmp2 = arr[i]
        i = i + 1
else:
    print("1 2")
    flg = False
 
if (flg):
    print("-1 -1")
### BUGGY CODE ###

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

min_num = N
for i in range(N):
    min_num = min([min_num, S[:i].count('W') + S[i + 1:].count('E')])

print(min_num)


### FIXED CODE ###

N = int(input())
S = input()
total = [0] * (N + 1)
for i in range(N):
    if S[i] == 'W':
        total[i + 1] = total[i] + 1
    else:
        total[i + 1] = total[i]

min_num = min(total[i] + (N - i - 1) - (total[N] - total[i + 1]) for i in range(N))

print(min_num)
### BUGGY CODE ###

n, m = list(map(int, input().split()))
a = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1

if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1
  
for i in range(2, n+1):
  if i in a:
    dp[i] = 0
  else:
    dp[i] = (dp[i-1] + dp[i-2])%1000000007
  
print(dp[n]%1000000007)


### FIXED CODE ###

n, m = list(map(int, input().split()))
a = [int(input()) for _ in range(m)]
a.append(0)

dp = [0] * (n+1)
dp[0] = 1
acounter = 0
if a[0] == 1:
  dp[1] = 0
  acounter = 1
else:
  dp[1] = 1

for i in range(2, n+1):
  if i == a[acounter]:
    dp[i]=0
    acounter+=1
  else:
    dp[i] = (dp[i-1]%1000000007 + dp[i-2]%1000000007)%1000000007
  
print(dp[n]%1000000007)
### BUGGY CODE ###

s=str(input())
K=int(input())
l=len(s)
a=[]
for i in range(0,l):
    for j in range(i,l):
        a.append(s[i:j+1])
a=sorted(list(set(a)))
print(a[K-1])

### FIXED CODE ###

s=str(input())
K=int(input())
l=len(s)
a=[]
for i in range(0,l):
    for j in range(i,min(l,i+5)):
        a.append(s[i:j+1])
a=sorted(list(set(a)))
print(a[K-1])
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

arr = [0] * 60
for a in A:
    for i in range(60):
        if a&(1<<i):
            arr[i] += 1

ans = 0
for i,a in enumerate(arr):
    b = N-a
    ans += a*b * 2**i
    ans %= MOD
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

arr = [0] * 60
for a in A:
    for i in range(60):
        if a&(1<<i):
            arr[i] += 1

ans = 0
for i,a in enumerate(arr):
    b = N-a
    ans += a*b * 2**i
    ans %= MOD
print(ans)
### BUGGY CODE ###

def binary_search(A,n):
    l = len(A)
    if l==0:
        return False
    elif A[l/2] > n: 
        return binary_search(A[:l/2],n)
    elif A[l/2] == n:
        return True
    elif A[l/2]<n:
        return binary_search(A[(l/2)+1:],n)

n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
cnt = 0
for i in xrange(len(T)):
    if binary_search(S,T[i]): cnt += 1
print cnt

### FIXED CODE ###

# coding: utf-8
# Here your code !
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
C = 0

def binary_search(A,n):
    """no recursion version"""
    l = len(A)
    left = l/2
    right = l-1
    while A[left] != n:
        if left == right and A[left] != n:
            #print left,right,"if"
            return False
        elif A[left] > n: # n????????????????????´???
            right = left
            left = left/2
            #print left,right,"elif1"
        elif A[left] < n: # n????????????????????´???
            right = right
            left = (left + right-1)/2 + 1
            #print left,right,"elif2"
    else:
        return True

for item in T:
    if binary_search(S,item):
        C += 1
print C
### BUGGY CODE ###

def main():
    from itertools import accumulate as ac
    from bisect import bisect_left as bl
    from bisect import bisect_right as br
    from sys import stdin
    input=stdin.readline
    def b_search(a,b,value):
        while a+1<b:
            med=(a+b)//2
            if value(med):b=med
            else:a=med+1
        if value(a):return a
        else:return b
    
    n,q=map(int,input().split())
    a=list(map(int,input().split()))
    x=[int(input()) for _ in [0]*q]
    aac=[0]+list(ac(a))
    aac2=[0]+list(ac(a[(n+1)%2::2]))

    def check(k):
        dist=a[-k-1]-ini
        if dist<0:
            dist=abs(dist)
            b=br(a,ini+dist)-bl(a,ini-dist)-1
        else:
            b=br(a,ini+dist)-bl(a,ini-dist)
        return k>=b

    for i in x:
        ini=i
        k=b_search(1,n//2+1,check)
        print(aac[-1]-aac[-k-1]+aac2[-k-1])
main()

### FIXED CODE ###

def main():
    from itertools import accumulate as ac
    from bisect import bisect_left as bl
    from bisect import bisect_right as br
    from sys import stdin
    input=stdin.readline

    def check(k):
        dist=a[-k-1]-ini
        if dist<0:
            dist=abs(dist)
            return k>=br(a,ini+dist)-bl(a,ini-dist)-1
        else:
            return k>=br(a,ini+dist)-bl(a,ini-dist)
    
    n,q=map(int,input().split())
    nn=n//2+1
    a=list(map(int,input().split()))
    x=[int(input()) for _ in [0]*q]
    ix=sorted([[i,j] for i,j in enumerate(x)],key=lambda x:x[1])
    ans=[0]*q
    aac=[0]+list(ac(a))
    aac2=[0]+list(ac(a[(n+1)%2::2]))
    k=nn

    for i,ini in ix:
        l=1
        u=k
        while l+1<u:
            med=(l+u)//2
            if check(med):u=med
            else:l=med+1
        if check(l):k=l
        else:k=u
        ans[i]=aac[-1]-aac[-k-1]+aac2[-k-1]
    for i in ans:
        print(i)
main()
### BUGGY CODE ###

def resolve():
	modu = 1000000007
	n, m = map(int, input().split())
	a = [False]*n
	for _ in range(m):
		a[int(input())] = True
	dp = [0]*(n+1)
	dp[0], dp[1] = 1, 1
	for i in range(2, n+1):
		if i in a:
			continue
		multi = []
		if not a[i-1]:
			multi.append(dp[i-1])
		if not a[i-2]:
			multi.append(dp[i-2])
		dp[i] = sum(multi) % modu
	print(dp[-1])
resolve()

### FIXED CODE ###

def resolve():
	modu = 1000000007
	n, m = map(int, input().split())
	a = [False]*n
	for _ in range(m):
		a[int(input())] = True
	dp = [0]*(n+1)
	dp[0], dp[1] = 1, 1
	for i in range(2, n+1):
		if i < n and a[i]:
			continue
		multi = []
		if not a[i-1]:
			multi.append(dp[i-1])
		if not a[i-2]:
			multi.append(dp[i-2])
		dp[i] = sum(multi) % modu
	print(dp[-1])
resolve()
### BUGGY CODE ###

n = int(input())
st = list()
for i in range(n):
    st.append(list(input()))
    st[i].sort()
cnt =0
for i in range(n-1):
    for j in range(i+1,n):
        if st[i] == st[j]:
            cnt +=1
print(cnt)

### FIXED CODE ###

n = int(input())
st = dict()
cnt = 0
for i in range(n):
    stx="".join(sorted(list(input())))
    if stx not in st:
        st[stx] = 0
    else:
        st[stx] +=1
        cnt += st[stx]
print(cnt)
### BUGGY CODE ###

#%%
A = list(input())
B = list(input())
C = list(input())
tmp = 'a'
check = 0

while check == 0 :
    if tmp == 'a':
        if len(A) != 0:
            tmp = A[0]
            A.pop(0)
        else:
            ans = 'A'
            check = 1
    elif tmp == 'b':
        if len(B) != 0:
            tmp = B[0]
            B.pop(0)
        else:
            ans = 'B'
            ckeck = 1
    elif tmp == 'c':
        if len(C) != 0:
            tmp = C[0]
            C.pop(0)
        else:
            ans = 'C'
            check =1

print(ans)




#%%


### FIXED CODE ###

#%%
A = list(input())
B = list(input())
C = list(input())
tmp = 'a'
check = 0

while check == 0 :
    if tmp == 'a':
        if len(A) != 0:
            tmp = A[0]
            A.pop(0)
        else:
            ans = 'A'
            check = 1
    elif tmp == 'b':
        if len(B) != 0:
            tmp = B[0]
            B.pop(0)
        else:
            ans = 'B'
            check = 1
    elif tmp == 'c':
        if len(C) != 0:
            tmp = C[0]
            C.pop(0)
        else:
            ans = 'C'
            check =1

print(ans)




#%%
### BUGGY CODE ###

class UnionFind():
  def __init__(self,n):
    self.parents = [-1]*n
  
  def find(self,x):
    if self.parents[x] < 0:
      return x
    
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.parents[x]>self.parents[y]:
      x,y=y,x
      
    self.parents[x] += self.parents[y]
    self.parents[y] = x


import numpy as np
 
N,M=map(int,input().split())
uf = UnionFind(N+1)

ans=[]
L = [[int(x) for x in input().split()] for _ in range(M)]
ans_max=(N)*(N-1)//2

for a,b in L[::-1]:
  temp=np.array(uf.parents) 
  temp_sum=ans_max-sum(abs(temp[temp<0])*(abs(temp[temp<0])-1)//2)
  ans.append(temp_sum)
  uf.union(a,b)



for answer in ans[::-1]:
  print(answer)
  


### FIXED CODE ###

class UnionFind():
  def __init__(self,n):
    self.parents = list(range(n))
    self.size = [1]*n
  
  def find(self,x):
    if self.parents[x] == x:
      return x
	
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.size[x]<self.size[y]:
      x,y=y,x
	
    self.size[x]+=self.size[y]
    self.parents[y] = x
  
  def same(self,x,y):
    return self.find(x) == self.find(y)
  
  def sizeofset(self,x):
    return self.size[self.find(x)]


N,M=map(int,input().split())
uf = UnionFind(N+1)

cnt=(N)*(N-1)//2
L=[[int(x) for x in input().split()] for _ in range(M)]
ans=[]

for a,b in L[::-1]:
  ans.append(cnt)
  if not uf.same(a,b):
    cnt -= uf.sizeofset(a)*uf.sizeofset(b)
    uf.union(a,b)

for x in ans[::-1]:
  print(x)
### BUGGY CODE ###

#abc142C_go to school
N = int(input())
A = list(map(int, input().split()))
for i in range(1,N+1):
    print(A.index(i)+1,end=' ')

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
L = [[] for i in range(N)]
for i in range(N):
    L[i] = [A[i], i+1]
L.sort()
ans = [0 for i in range(N)]
for i in range(N):
    ans[i] = L[i][1]
print(*ans)
### BUGGY CODE ###

h,w,m = list(map(int,input().split()))
t = [list(map(int,input().split())) for _ in range(m)]
from collections import Counter

x,y = zip(*t)
xcnt = Counter(x)
ycnt = Counter(y)

xcmax = max( xcnt.values() )
ycmax = max( ycnt.values() )
xlist = [k for k,v in xcnt.items() if v == xcmax]
ylist = [k for k,v in ycnt.items() if v == ycmax]
rest = [i for i in t if (i[0] in xlist) and (i[1] in ylist)]

if len( rest ) == len(xlist) * len(ylist):
  print( xcmax + ycmax -1 )
else:
  print( xcmax + ycmax )

### FIXED CODE ###

h,w,m = list(map(int,input().split()))
t = [list(map(int,input().split())) for _ in range(m)]
from collections import Counter
 
x,y = zip(*t)

xcnt = Counter(x)
ycnt = Counter(y)
 
xcmax = max( xcnt.values() )
ycmax = max( ycnt.values() )
xlist = [k for k,v in xcnt.items() if v == xcmax]
ylist = [k for k,v in ycnt.items() if v == ycmax]
if len(xlist) * len(ylist) > m:
  print( xcmax + ycmax )
else:
  xylist = { i*(10**6)+j for i in xlist for j in ylist }
  tlist = { i[0]*(10**6) + i[1] for i in t }
  if len( xylist - tlist ) == 0:
    print( xcmax + ycmax -1 )
  else:
    print( xcmax + ycmax )
### BUGGY CODE ###

import math
N = int(input())
A = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
LCM = A[0]
for i in range(N - 1):
    LCM = (LCM * A[i + 1]) // math.gcd(LCM, A[i + 1])
ans = 0
for i in range(N):
    ans = ans + (LCM // A[i])
    ans = ans % mod
print(ans)

### FIXED CODE ###

import math
from collections import defaultdict, Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
A = [int(i) for i in input().split()]
v_list = []
mod = 10 ** 9 + 7
LCM_dict = defaultdict(int)
for i in range(N):
    prime_cnt = Counter(prime_factorize(A[i]))
    for k, v in prime_cnt.items():
        LCM_dict[k] = max(LCM_dict[k], v)
    v_list.append(prime_cnt)
ans = 0
for i in range(N):
    prime_cnt = v_list[i]
    tmp_value = 1
    for k, v in LCM_dict.items():
        cnt = 0 if k not in prime_cnt.keys() else prime_cnt[k]
        tmp_value = pow(k, v - cnt) * tmp_value
        tmp_value = tmp_value % mod
    ans += tmp_value
    ans = ans % mod
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

k, q = map(int, (input().split()))
d = list(map(int, (input().split())))

for qi in range(q):
    n, x, m = map(int, input().split())
    last = x
    eq = 0
    for i in range(k):
        num = (n-1-i+k-1)//k
        last += (d[i]%m) * num
        if d[i]%m == 0: eq += num
    ans = (n-1) - (last//m - x//m) - eq
    print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

k, q = map(int, (input().split()))
d = list(map(int, (input().split())))

for qi in range(q):
    n, x, m = map(int, input().split())
    last = x
    eq = 0
    for i in range(k):
        num = ((n-1-i)+(k-1))//k
        last += (d[i]%m) * num
        if d[i]%m == 0: eq += num
    ans = (n-1) - (last//m - x//m) - eq
    print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
ticket_num = m
a_sorted = sorted(a, reverse=True)

if n > 1:
    while ticket_num > 0:
        first = a_sorted[0]
        second = a_sorted[1]
        fi_bin = bin(first)
        se_bin = bin(second)
        sa = len(fi_bin)-len(se_bin)
        if sa == 0:
            sa = 1
        first = first >> sa
        ticket_num -= sa
        if first == second:
            first = first >> 1
            ticket_num -= 1
        a_sorted[0] = first
        a_sorted.sort(reverse=True)
else:
    a_sorted[0] = a_sorted[0]>>m

print(sum(a_sorted))

### FIXED CODE ###

import heapq
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
ticket_num = m
heapq.heapify(a)

if n > 1:
    for i in range(m):
        MAX = heapq.heappop(a)
        MAX = math.ceil(MAX / 2)
        heapq.heappush(a,MAX)
        
else:
    MAX = heapq.heappop(a)
    MAX = math.ceil(MAX / (2**m))
    heapq.heappush(a,MAX)

print(sum(a)*(-1))
### BUGGY CODE ###

from operator import mul
from functools import reduce

#while True:
N = int(input())
#	if N>=2 and N<=10**5:break

if 2 <= N <= 10**5:
	num = list(map(int, input().split()))
	ans = reduce(mul,num)
if ans > 10**18:
	print(-1)
else:
	print(ans)

### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int,input().split()))
    if 0 in a: 
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    
if __name__ =="__main__":
    main()
### BUGGY CODE ###

s = input()
rev = False
for _ in range(int(input())):
  t = input()
  if t == "1":
    rev = not rev
  else:
    t = t.split()
    if (t[1] == "1" and not rev) or (t[1] == "2" and rev):
      s = t[2] + s
    else:
      s += t[2]
if rev:
  print(s[::-1])
else:
  print(s)

### FIXED CODE ###

S = input()
len_s = len(S)
rev = False
max_ = 2*10**5
index = max_ + len_s
rev_index = max_ - 1
s = ["." for _ in range(max_*2 + len_s)]
for i in range(len_s):
    s[max_+i] = S[i]
for _ in range(int(input())):
  t = input()
  if t == "1":
    rev = not rev
  else:
    t = t.split()
    if (t[1] == "1" and not rev) or (t[1] == "2" and rev):
      s[rev_index] = t[2]
      rev_index -= 1
    else:
      s[index] = t[2]
      index += 1
if rev:
  for i in range((max_ + max_ + len_s - 1), 0, -1):
    if s[i] != ".":
      print(s[i], end="")
else:
  for i in range((max_ + max_ + len_s)):
    if s[i] != ".":
      print(s[i], end="")
### BUGGY CODE ###

import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
val=(n-1)//2

arr=list(map(int, arr_data[1]))

#print(arr)

cnt = 0
while cnt < n:
      
    arr_temp=arr.copy()  
    
    arr_temp.pop(cnt)
    
    arr02 = sorted(arr_temp)
    print(arr02[val])
    
    cnt += 1
    
    

### FIXED CODE ###

import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

val = (n-1) // 2

arr = list(map(int, arr_data[1]))

arr_sort = sorted(arr)

val1 = arr_sort[(n // 2)-1]
val2 = arr_sort[(n // 2)]

for v in arr:
    
    if v<=val1:
        
        print(val2)
        
    else:
        
        print(val1)
### BUGGY CODE ###

amount = int(input())

numbers = [int(input()) for i in range(amount)]

max_profit = -1 * (numbers[0] - numbers[1])

for i in range(amount - 1):
    for j in range(i + 1, amount):
        if (-1 * (numbers[i] - numbers[j])) >= max_profit:
            max_profit = -1 * (numbers[i] - numbers[j])

print(max_profit)

### FIXED CODE ###

maxv = -2 * 10 ** 9
minv = 2 * 10 ** 9

n = int(input())
for i in range(n):
    x = int(input())
    maxv = max(x - minv, maxv)
    minv = min(x, minv)

print(maxv)
### BUGGY CODE ###

n =int(input())
s = [input() for i in range(n)]
z = list(set(s))
ans = []
x = 0
for i in z:
    sc = s.count(i)
    if sc > x:
        ans = [i]
        x = sc
    elif sc == x:
        ans.append(i)
for i in sorted(ans):
    print(i)


### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
  s.append(input())
s.sort()
k = 0
f = s
mk = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    k = k+1
    if k == mk :
      mk = k
      f.append(s[i])
    elif k > mk :
      mk = k
      f = [s[i]]
  else:
    k = 0
for i in range(len(f)):
  print(f[i])
### BUGGY CODE ###

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

from itertools import permutations

colors = tuple(i for i in range(C))
lst = tuple(permutations(colors, 3))

table = [[0 for i in range(C)] for j in range(3)]
for color in colors:
    for col in range(N):
        for row in range(N):
            table[(col+row)%3][color]+=D[c[col][row]-1][color]
            
ans = 10**9    
for i, j, k in lst:
    ans = min(ans, table[0][i]+table[1][j]+table[2][k])

print(ans)

### FIXED CODE ###

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

from itertools import permutations

colors = tuple(i for i in range(C))

table = [[0 for i in range(C)] for j in range(3)]
for color in colors:
    for col in range(N):
        for row in range(N):
            table[(col+row)%3][color]+=D[c[col][row]-1][color]
            
ans = 10**9    
for i, j, k in permutations(colors, 3):
    ans = min(ans, table[0][i]+table[1][j]+table[2][k])

print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import bisect

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    S = list(input())
    Q = int(input())

    alphabets = [chr(i) for i in range(ord("a"), ord("a")+26)]

    L = {x:[] for x in alphabets} # i番目のリストは、アルファベットが現れるインデックスのリストを持つ。
    for idx, s in enumerate(S):
        L[s].append(idx)

    for _ in range(Q):
        row = input().split()
        if row[0] == '1':
            x, y, z = int(row[0]), int(row[1])-1, row[2]
        elif row[0] == '2':
            x, y, z = int(row[0]), int(row[1]) - 1, int(row[2]) - 1

        if x == 1:
            target = S[y]
            idx_del = bisect.bisect_left(L[target], y)
            if idx_del < len(L[target]):
                del L[target][idx_del]
            bisect.insort(L[z], y)
            S[y] = z
        elif x == 2:
            answer = 0
            for alphabet in alphabets:
                left = bisect.bisect_left(L[alphabet], y)
                if left < len(L[alphabet]) and y <= L[alphabet][left] <= z:
                    answer += 1
            print(answer)

    # Failed to predict input format
    pass

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import bisect

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    S = list(input())
    Q = int(input())

    L = [[] for x in range(26)] # i番目のリストは、アルファベットが現れるインデックスのリストを持つ。

    for idx, s in enumerate(S):
        L[ord(s)-ord("a")].append(idx)

    for _ in range(Q):
        row = input().split()
        if row[0] == '1':
            y, z = int(row[1])-1, row[2]
            if S[y] != z:
                idx_target = ord(S[y]) - ord("a")
                idx_del = bisect.bisect_left(L[idx_target], y)
                if idx_del < len(L[idx_target]):
                    L[idx_target].pop(idx_del)
                bisect.insort(L[ord(z) - ord("a")], y)
                S[y] = z

        elif row[0] == '2':
            y, z = int(row[1]) - 1, int(row[2]) - 1
            answer = 0
            for idx_alphabet in range(26):
                left = bisect.bisect_left(L[idx_alphabet], y)
                if left < len(L[idx_alphabet]) and y <= L[idx_alphabet][left] <= z:
                    answer += 1
            print(answer)

    # Failed to predict input format
    pass

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

import fractions
import functools
 
 
n = int(input())
a = list(map(int, input().split()))
nl = set(range(n))
gcd_list = [0]
for i in nl:
    tmp, a[i] = a[i], 0
    gcd_list.append(functools.reduce(fractions.gcd, a))
    a[i] = tmp
ans = max(gcd_list)
print(ans)

### FIXED CODE ###

import fractions


n = int(input())
a = list(map(int, input().split()))
nl = set(range(n))
l = [0]
r = [0]
m = []
for i in nl:
    l.append(fractions.gcd(l[i], a[i]))
    r.append(fractions.gcd(r[i], a[-i-1]))
r.reverse()
for i in nl:
    m.append(fractions.gcd(l[i], r[i+1]))
ans = max(m)
print(ans)
### BUGGY CODE ###

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

def binaly_serch(ls,k):#lsはリスト、kが求めたいもの
    ls.sort()
    n = len(ls)
    s = 0
    e = n#あえてls から一つ出たのにしておく。このおかげでk = ls[n-1]の時でも探索できる
    while int(e - s) >= 1:#intでcastして繰り下がった方を見て、e = bという条件にしてるからこれで全部探せる
        b = int((s+e)/2)
        if ls[b] == k:
            return True
        elif ls[b] < k:
            s = b + 1
        else:
            e = b
    return False
ans = 0
kls = [i for i in range(K+1)]
for i in range(K+1):
    for j in range(K+1):
        if binaly_serch(kls,S-(i+j)):
            ans += 1

print(ans)



### FIXED CODE ###

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

ans = 0
for i in range(K+1):
    for j in range(K+1):
        z = S-(i+j)
        if 0<= z and z <= K:
            ans += 1
print(ans)