Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
import sys
import numpy as np
import math

def solve(N: int, X: "List[int]"):
    place = np.mean(X)
    place = round(place)
    result = 0
    for i in range(N):
        result += (X[i]-place) ** 2
    print(int(result))
    return


# 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():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    count = 0
    while True:
        N = N // K
        if N >= 1:
            count += 1
        else:
            break
    print (count+1)
    return


# 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():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()
l, r, d = input().split()
print(r//d -(l-1)//d)

### FIXED CODE ###

l, r, d = map(int, input().split())
print(r//d - (l-1)//d)
A, B, K = map(int, input().split())
if A>=K:
    print(A-K, B)
else:
    print(0, max(0, B-(K-A)))

### FIXED CODE ###

S, T = input().split()
print(T+S)
N,K,M = map(int,input().split())
a = list(map(int,input().split()))
now = sum(a)
goal = N*M
if now + K >= goal:
  if now >= goal:
    print(0)
  else:
    print(goal-now)
else:
  print(-1)

### FIXED CODE ###

C=input()
N=ord(C)+1
M=chr(N)
print(M)
num =int(input())
value = list(map(int, input().split()))
value.sort()
if num == 2:
  answer = value[1]
else:
  cnt = 0
  for i in range(0, num):
      if value[i]%(value[1])!=0:
        cnt += 1
        if cnt == 2:
          break
  if cnt == 1:
    answer = value[1]
  elif cnt == 0:
    answer = value[0]
  else:
    for i in range (0, value[0]):
      cnt = 0
      for j in range(0, num):
        if value[j]%(value[0]-i)!=0:
          cnt += 1
          if cnt == 2:
            break
      if cnt == 1:
        answer = value[0] - i
        break
print(answer)

### FIXED CODE ###

num =int(input())
value = list(map(int, input().split()))
value.sort()
if num == 2:
  answer = value[1]
else:
  cnt = 0
  for i in range(0, num):
      if value[i]%(value[1])!=0:
        cnt += 1
        if cnt == 2:
          break
  if cnt == 1:
    answer = value[1]
  elif cnt == 0:
    answer = value[0]
  else:
    for i in range (0, value[0]):
      cnt = 0
      for j in range(0, num):
        if value[j]%(value[0]-i)!=0:
          cnt += 1
          if cnt == 2:
            break
      if cnt == 1 or cnt == 0:
        answer = value[0] - i
        break
print(answer)
n=input()
n=del n[0]
n=list(n)
print(len(n))

### FIXED CODE ###

n=int(input())
print(len(list(set([int(input()) for x in range(n)]))))
N, M =map(int, input().split())
Ps =[]
Ys =[]
dic = {}
for i in range(M):
    p, y = map(int, input().split())
    Ps.append(p)
    Ys.append(y)
    ls = dic.get(p, [])
    ls.append(y)
for p in Ps:
    ls = dic[p]
    ls.sort()
    dic[p] = ls
for i in range(M):
    p = Ps[i]
    y = Ys[i]
    number = dic[p].index(y) + 1
    strp = str(p)
    strn = str(number)
    print(strp.zfill(6) + strn.zfill(6))


### FIXED CODE ###

N, M =map(int, input().split())
ls = []
pcount =[]
for i in range(N):
    pcount.append(0)
for i in range(M):
    p, y = map(int, input().split())
    ls.append([i, p, y])
ls.sort(key = lambda x:x[2])

for l in ls:
    pcount[l[1]-1] += 1
    l.append(pcount[l[1]-1])
ls.sort(key = lambda x:x[0])
for l in ls:
    print(str(l[1]).zfill(6) + str(l[3]).zfill(6))
S = input()
flag = True

if S[0] != 'A':
    flag = False

for i in range(2, len(S)-1):
    if S[i] == 'C':
        break
else:
    flag = False

if flag:
    copy = []
    for j in range(1, len(S)):
        if j == i:
            continue
        copy += S[j]

if not(''.join(copy).islower()):
    flag = False

print("AC" if flag else "WA")

### FIXED CODE ###

S = input()
N = len(S)
flag = False

for i, charS in enumerate(S):
    if charS == "C" and (1 < i and i < N-1):
        flag = True
        numC = i
        break

if S[0] != "A":
    flag = False

if flag:
    text = [S[j] for j in range(N) if j != 0 and j != numC]
    text = ''.join(text)
    if not(text.islower()):
        flag = False

print("AC" if flag else "WA")
def main():
    import numpy as np
    n, K = map(int, input().split())
    H = list(map(int, input().split()))
    s = np.array(sorted(set(H+[0])))
    d = {i: j for j, i in enumerate(s)}
    l = len(s)
    a = max(s)-s
    dp = np.full((K+1, l), 10**13, dtype=np.int64)
    dp[0, 0] = 0
    for h in H:
        dh = d[h]
        dp2 = np.full((K+1, l), 10**13, dtype=np.int64)
        t = np.zeros((K, l), dtype=np.int64)
        s_plus_a = a+dp
        min_s = np.array([[j for j in i] for i in dp[:-1]], dtype=np.int64)
        for j in range(l-2, -1, -1):
            min_s[:, j] = np.minimum(min_s[:, j+1], min_s[:, j])
        for j in range(1, l):
            s_plus_a[:, j] = np.minimum(s_plus_a[:, j-1], s_plus_a[:, j])
        t = s_plus_a[:-1] - a
        dp2[1:, :] = np.minimum(min_s, t)
        for j in range(l):
            dp2[:, dh] = np.minimum(dp2[:, dh], dp[:, j]+max(h-s[j], 0))
        dp = dp2
    print(np.min(dp))


main()

### FIXED CODE ###

def main():
    n, K = map(int, input().split())
    H = list(map(int, input().split()))
    s = sorted(set(H+[0]))
    d = {i: j for j, i in enumerate(s)}
    l = len(s)
    m = max(s)
    a = [m-i for i in s]
    dp = [[10**13]*l for _ in range(K+1)]
    dp[0][0] = 0
    for h in H:
        dh = d[h]
        dp2 = [[0]*l for _ in range(K+1)]
        dp2[0] = [10**13]*l
        t = [[0]*l for _ in range(K)]
        for i in range(K):
            for j in range(l):
                t[i][j] = dp[i][j]+a[j]
        min_s = [[10**13]*l for i in range(K+1)]

        for i in range(K):
            for j in range(l-2, -1, -1):
                min_s[i][j] = min(dp[i][j+1], min_s[i][j])
            for j in range(1, l):
                t[i][j] = min(t[i][j-1], t[i][j])
            for j in range(l):
                t[i][j] = t[i][j]-a[j]

        for i in range(K):
            for j in range(l):
                dp2[i+1][j] = min(min_s[i][j], t[i][j])

        for i in range(K+1):
            temp = 10**13
            for j in range(l):
                temp = min(temp, dp[i][j]+max(h-s[j], 0))
            dp2[i][dh] = min(dp2[i][dh], temp)
        dp = dp2
    print(min([min(i) for i in dp]))


main()
N,K=map(int,input().split())
h=[int(input() for i in range(N))]
count=0
for a in range(1,N+1):
  if a<=K:
    count+=1
  else:
    pass
print(count)

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
count = 0
for i in h:
    if i >= K:
      count+=1
print(count)
K, S = map(int,input()split())

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

### FIXED CODE ###

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

c = 0
for i in range(K+1):
  for j in range(K+1):
    z = S - i - j
    if 0 <= z and z <= K:
      c += 1
print(c)
def main():
    n, k = map(int, input().split())
    s = input()
    
    arr = []
    if s[0] == '0':
        arr.append(0)
    cnt = 1
    i = 1
    while i != n:
        if s[i] != s[i - 1]:
            arr.append(cnt)
            cnt = 1
        else:
            cnt += 1
        i += 1
    arr.append(cnt)
    if s[-1] == '0':
        arr.append(0)
    
    ans = 0
    curr = arr[0]
    j = 1
    if len(arr) - 1 <= 2 * k:
        print(n)
        return 0
    for i in range(1, len(arr), 2):
        curr += arr[i] + arr[i + 1]
        if i - j == 2 * k:
            curr -= arr[j] + arr[j - 1]
            j += 2
        ans = max(ans, curr)
    print(ans)
    return 0
main()

### FIXED CODE ###

def main():
    a, b = map(int, input().split())
    ans = 0
    if a > b:
        ans += a
        a -= 1
    else:
        ans += b
        b -= 1
    print(ans + max(a, b))
    return 0
main()
import sys

input = sys.stdin.readline

n_k = list(map(int, input().split()))
n = n_k[0]
k = n_k[1]
a = list(map(int, input().split()))
a_pos = list(filter(lambda v: v >= 0, a))
a_neg = list(filter(lambda v: v < 0, a))

a_pos.sort(reverse=True)
a_neg.sort()

mod = 10**9+7

ans = 1
if n == k:
    for a_i in a:
        ans = ans * a_i % mod
elif len(a_pos) == 0 and k % 2 == 1:
    for i in reversed(range(len(a_neg) - k, len(a_neg))):
        ans = ans * a_neg[i] % mod
else:
    i_p = 0
    i_n = 0
    i = 0
    while i < k:
        if i == k - 1 or i_n+1 >= len(a_neg) or a_pos[i_p] * (a_pos[i_p+1] if i_p+1 < len(a_pos) else 1) > a_neg[i_n] * a_neg[i_n+1]:
            ans = ans * a_pos[i_p] % mod
            i_p += 1
            i += 1
        else:
            ans = ans * a_neg[i_n] % mod * a_neg[i_n+1] % mod
            i_n += 2
            i += 2
print(ans)

### FIXED CODE ###

import sys

input = sys.stdin.readline

n_k = list(map(int, input().split()))
n = n_k[0]
k = n_k[1]
a = list(map(int, input().split()))
a_pos = list(filter(lambda v: v >= 0, a))
a_neg = list(filter(lambda v: v < 0, a))

a_pos.sort(reverse=True)
a_neg.sort()

mod = 10**9+7

ans = 1
if n == k:
    for a_i in a:
        ans = ans * a_i % mod
elif len(a_pos) == 0 and k % 2 == 1:
    for i in reversed(range(len(a_neg) - k, len(a_neg))):
        ans = ans * a_neg[i] % mod
else:
    i_p = 0
    i_n = 0
    i = 0
    while i < k:
        if i_p < len(a_pos) and (i == k - 1 or i_n+1 >= len(a_neg) or a_pos[i_p] * (a_pos[i_p+1] if i_p+1 < len(a_pos) else 1) > a_neg[i_n] * a_neg[i_n+1]):
            ans = ans * a_pos[i_p] % mod
            i_p += 1
            i += 1
        else:
            ans = ans * a_neg[i_n] % mod * a_neg[i_n+1] % mod
            i_n += 2
            i += 2
print(ans)
n=int(input())
a=list(map(int,input().split()))
not_two=0
yes_four=0
for i in a:
  if a%2!=0:
    not_two+=1
  if a%4==0:
    yes_four+=1
if yes_four-not_two>=1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
not_two=0
yes_four=0
for i in a:
  if i%2!=0:
    not_two+=1
  if i%4==0:
    yes_four+=1
if yes_four-not_two>=0:
  print('Yes')
elif yes_four+not_two==n and yes_four-not_two==-1:
  print('Yes')
else:
  print('No')
n = int(input())
T = [int(input()) for i in range(n)]

def gcd(x, y):
    while x != 0 and y != 0:
        x, y = max(x, y), min(x, y)
        x %= y
    return max(x, y)

ans = 1
for i in range(n):
    ans = ans * T[i] / gcd(ans, T[i])
    ans = int(ans + 0.1)
print(int(ans))

### FIXED CODE ###

from decimal import *

n = int(input())
T = [int(input()) for i in range(n)]

for i in range(n):
    T[i] = Decimal(T[i])

def gcd(x, y):
    while x != 0 and y != 0:
        x, y = max(x, y), min(x, y)
        x %= y
    return max(x, y)

ans = Decimal(1)
for i in range(n):
    if ans % T[i] != 0:
        ans = ans * T[i] / gcd(ans, T[i])
    #ans = int(ans + 0.1)
    #print(ans)
print(int(ans))
N = int(input())
L,R = map(int,input().split())

if L-R > 672:
    print(0)
else:
    minMod = 100000000
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if minMod > tmp:
                minMod = tmp
                
            else if tmp == 0:
                minMod = 0 
                break
    print(minMod)


### FIXED CODE ###

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

if R-L > 672:
    print(0)
else:
    minMod = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if tmp == 0:
                minMod = 0
                break
            minMod = min(tmp,minMod)
    print(minMod)
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

for i in range(len(stack) - 1):
    for r1, r2 in zip(stack[::1], stack[i::1]):
        candidate.append(r2 - r1)
    candidate = [max(candidate)]

print(candidate[0])

### FIXED CODE ###

n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)
D,T,S =(int(x) for x in input().split(","));

if (D<=T*S):
    print("Yes");
else:
    print("No");


### FIXED CODE ###

D,T,S =(int(x) for x in input().split())

if (D<=T*S):
    print("Yes")
else:
    print("No")
a = input()
print('A' a.isupper() else 'a')

### FIXED CODE ###

a = input()
print('A' if a.isupper() else 'a')
x, y, z = int(input().split())
if (x + y + z >= 22):
  print('bust)
else:
  print('win')

### FIXED CODE ###

A1, A2, A3 = map(int, input().split())
if A1 + A2 + A3 >= 22:
    print('bust')
else:
    print('win')
def main():
    s = input()
    for i in range(len(s)):
        if s[i]=="C":
            idx = i
            break

    for j in range(idx,len(s)):
        if s[j]=="F":
            print("Yes")
            exit()

    print("No")

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    s = list(input())
    for i in range(len(s)):
        for j in range(i+1,len(s)):
            if s[i]=="C" and s[j]=="F":
                print("Yes")
                exit()
    print("No")

if __name__ == '__main__':
    main()
while True:
    N=int(input())
    for i in range(N):
        x1,y1,r1,x2,y2,r2=map(float,input().split())
        d=((x1-x2)**2+(y1-y2)**2)**0.5
        if r1-r2>d:
            if r1==r2+d:
                print("1")
            else:
                print("2")
        elif r2-r1>d:
            if r2==r1+d:
                print("1")
            else:
                print("-2")
        elif d<r1+r2:
            print("1")
        elif r1+r2==d:
            print("1")
        elif d>r1+r2:
            print("0")



### FIXED CODE ###

N=int(input())
for i in range(N):
    x1,y1,r1,x2,y2,r2=map(float,input().split())
    d=((x1-x2)**2+(y1-y2)**2)**0.5
    if r1-r2>d:
        if r1==r2+d:
            print("1")
        else:
            print("2")
    elif r2-r1>d:
        if r2==r1+d:
            print("1")
        else:
            print("-2")
    elif d<r1+r2:
        print("1")
    elif r1+r2==d:
        print("1")
    elif d>r1+r2:
        print("0")
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

for i in range(N):
    if B[i] > A[i]:
        kill_1 = A[i]
        if B[i] - kill_1 > A[i+1]:
            kill_2 = A[i+1]
        else:
            kill_2 = B[i] - kill_1
    else:
        kill_1 = B[i]
        
    ans += kill_1 + kill_2
    B[i] -= kill_1 - kill_2
    A[i] -= kill_1
    A[i+1] -= kill_2
    
print(ans)

### FIXED CODE ###

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

count = 0
for i in range(N):
  if A[i] < B[i]:
    count += A[i]
    B[i] -= A[i]
    if A[i+1] < B[i]:
      count += A[i+1]
      A[i+1] = 0
    else:
      count += B[i]
      A[i+1] -= B[i]
  else:
    count += B[i]

print(count)
import numpy as np

N,K = map(int,input().split())
p = list(map(int,input().split()))
E = sum(p[0:K])
a = E
for i in range (0,N-K):
  E = E - p[i] + p[i+K]
  if E == max(a,E):
    a = E
    
print((a+K)/2)
  

### FIXED CODE ###

N,K = map(int,input().split())
p = list(map(int,input().split()))
E = sum(p[0:K])
a = E
for i in range (0,N-K):
  E = E - p[i] + p[i+K]
  if E == max(a,E):
    a = E
    
print((a+K)/2)
N, M = map(int, input().split())
A = list(map(int,input().split()))
def waribiki():
    global M
    A[-1]=A[-1]//2
    M-=1
    if A[-2]<A[-1]:
        waribiki()
while M>0:
    A.sort()
    waribiki()
print(sum(A))

### FIXED CODE ###

N, M= map(int, input().split())
A = list(map(int,input().split()))
A=[-1*a for a in A]
import heapq
import math
hq=heapq.heapify(A)
for m in range(M):
    X=heapq.heappop(A)
    heapq.heappush(A,math.ceil(X/2))
print(sum(A)*-1)
s = input()
s[4:5]='8'
print(s)

### FIXED CODE ###

s = input()
print(s[:3]+'8'+s[4:])
A = int(input())
B = int(input())

if A+B <= 16 and A < 9 and B < 9:
    print("Yay!")
else :
    print(":(")


### FIXED CODE ###

A,B = map(int,input().split())
if A<9 and B<9:
    print("Yay!")
else:
    print(":(")
a = int(input())
b = input()

import math

def nCr(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)


R = 0
G = 0
B = 0
for i in b:
    if i == "R":
        R += 1
    elif i == "G":
        G += 1
    else:
        B += 1

res = 0
for i in range(0, len(b)):
    for k in range(i + 1, len(b)):
        if (i + k) % 2 == 0:
            if b[i] != b[k] and b[i] != b[(i + k) //2] and b[k] != b[(i + k) //2]:
                res += 1

print(nCr(R, 1) * nCr(G, 1) * nCr(B, 1) - res)

### FIXED CODE ###

a = int(input())
b = input()

import math

def nCr(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)


R = 0
G = 0
B = 0
for i in b:
    if i == "R":
        R += 1
    elif i == "G":
        G += 1
    else:
        B += 1


if R == 0 or G == 0 or B == 0:
    print(0)
else:
    res = 0
    for i in range(0, len(b)):
        for k in range(i + 1, len(b)):
            if (i + k) % 2 == 0:
                if b[i] != b[k] and b[i] != b[(i + k) //2] and b[k] != b[(i + k) //2]:
                    res += 1

    print(nCr(R, 1) * nCr(G, 1) * nCr(B, 1) - res)
N = int(input())
S = input("")
result = ""
size = len(S)
for i in range(size):
    if i + N < size:
        result += S[i + N]
    else:
        result += S[i + N - size]
print(result)

### FIXED CODE ###

alph_list= ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
N = int(input())
S = input("")
ans = str()
for i in range(len(S)):
    t = alph_list.index(S[i]) + N
    if t < len(alph_list):
        ans += alph_list[t]
    else:
        ans += alph_list[t - len(alph_list)]
print(ans)
S = list(input())
if(S[0]=='A' and 'C' in S[2:-1]):
    del S[0]
    S[2:-1].remove('C')
    if [s for s in S if s.isupper()] == []:
        print("AC")
    else:
        print("WA")
else:
    print("WA")

### FIXED CODE ###

S = input()
count = 0
if( S[0] == 'A' and S[2:-1].count('C') == 1):
    for i in range(len(S)):
        if S[i].isupper():
            count += 1
            if count == 3:
                print("WA")
                exit()
    print("AC")
else:
    print("WA")
import math
import collections
N = int(input())
A = [int(i) for i in input().split()]

def trial_division(n):
    Num = n
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return [Num]
    else:
        factor.append(n)
        return factor


List = [[] for i in range(N)]
for i in range(N):
    tmp = trial_division(A[i])
    tmp = collections.Counter(tmp)
    List[i] = tmp[2]

cnt0,cnt1,cnt2 = 0,0,0
for i in range(len(List)):
    if List[i]==1 and List[i+1]!=1:
        cnt0 += 1

    if List[i]==0:
        cnt0+=1
        
    elif List[i]==1:
        cnt1+=1
        
    else:
        cnt2 += 1
        


if cnt2+1>=cnt0:
    print('YES')
else:
    print('NO')



### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]

cnt4,cnt2,cnt = 0,0,0

for i in A:
    if i%4==0:
        cnt4 += 1
    elif i%2==0:
        cnt2 += 1
    else:
        cnt += 1
cnt += cnt2%2

if cnt4+1>=cnt:
    print('Yes')
else:
    print('No')
import math
n=input().split()
x=int(n[2])-int(n[0])
y=int(n[3])-int(n[1])

print(math.sqrt(x**2+y**2))



### FIXED CODE ###

import math
n=input().split()
x=float(n[2])-float(n[0])
y=float(n[3])-float(n[1])

print(math.sqrt(x**2+y**2))
print(math.factorial(int(input())))

### FIXED CODE ###

import math


def main():
    N = int(input())
    ans = math.factorial(N)
    mod = 10**9 + 7
    print(ans % mod)


if __name__ == "__main__":
    main()
N = int(input())
e = list(map(int,input().split()))
for i in range(N):
    x = int(input())
    e.append(x)
e.sort()
for i in range(N - 1):
    a = e.pop(0)
    b = e.pop(0)
    e.insert(0, (a+b)/2)
ans = e[0]
print(ans)

### FIXED CODE ###

N = int(input())
e = list(map(int,input().split()))
e.sort()
for i in range(N - 1):
    a = e.pop(0)
    b = e.pop(0)
    e.insert(0, (a+b)/2)
ans = e[0]
print(ans)
a = []
i = 0

s = int(input())

a.append(s)

while True:
    if(a[i] % 2 == 0):
        ans = int(a[i] / 2)
        if ans in a:
            print(str(i + 2))
            break
       	a.append(ans)
    else:
        anss = int(a[i] * 3 + 1)
        if anss in a:
            print(str(i + 2))
            break
        a.append(anss)

    i += 1

### FIXED CODE ###

AB, BC, CA = map(int, input().split())

a = int(AB * BC / 2)

print(str(a))
N,K = map(int,raw_input().split())
src = map(int,raw_input().split())

def solve():
  if N == 1: return src[0] == K
  mx = max(src)
  if K > mx: return False
  g = src[0]
  for i in range(1,N):
    g = gcd(g, src[i])
    if g == 1:
      return True
  return K % g == 0

print ('POSSIBLE' if solve() else 'IMPOSSIBLE')

### FIXED CODE ###

N,K = map(int,raw_input().split())
src = map(int,raw_input().split())

def gcd(a,b):
  a,b = max(a,b),min(a,b)
  if b == 0:
    return a
  return gcd(b, a%b)

def solve():
  if N == 1: return src[0] == K
  mx = max(src)
  if K > mx: return False
  g = src[0]
  for i in range(1,N):
    g = gcd(g, src[i])
    if g == 1:
      return True
  return K % g == 0

print ('POSSIBLE' if solve() else 'IMPOSSIBLE')
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)

n = int(input())
s = input()
q = int(input())

bit = [BIT(n) for i in range(26)]
for i in range(n):
    bit[ord(s[i])-97].add(i+1, 1)
s = list(s)
for _ in range(q):
    query, i, c = input().split()
    if query == "1":
        i = int(i)
        c = ord(c)-97
        if bit[c].get(i) == 0:
            bit[c].add(i, 1)
            bit[ord(s[i])-97].add(i, -1)
            s[i] = chr(c+97)
            print(s)
    else:
        ans = 0
        for k in range(26):
            if bit[k].get(int(i)-1, int(c)) >= 1:
                ans += 1
        print(ans)


### FIXED CODE ###

#1indexed
class BIT():
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n+1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += i & -i

n = int(input())
s = input()
q = int(input())

bit = [BIT(n+1) for i in range(26)]
for i in range(n):
    bit[ord(s[i])-97].add(i+1, 1)


s = list(s)
for _ in range(q):
    query, a, b = input().split()
    if query == "1":
        i = int(a)
        c = ord(b)-97
        bit[ord(s[i-1])-97].add(i, -1)
        bit[c].add(i, 1)
        s[i-1] = b
    else:
        ans = 0
        for k in range(26):
            if bit[k].sum(int(b))-bit[k].sum(int(a)-1) >= 1:
                ans += 1
        print(ans)