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

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    M = 7368792

    def f(m, n):
        g = [None] * M
        i = m
        while True:
            if g[i] is None:
                if n == 0:
                    return i
                else:
                    n -= 1
                for j in range(i,M,i):
                    g[j] = 1
            i += 1

    while True:
        m,n = LI()
        if m == 0 and n == 0:
            break
        rr.append(f(m,n))

    return '\n'.join(map(str,rr))




print(main())



### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class Prime():
    def __init__(self, m):
        self.M = m + 1
        self.A = a = [True] * self.M
        a[0] = a[1] = 0
        self.T = t = []
        sq = int(math.sqrt(self.M))
        q = 0
        for i in range(2, sq + 1):
            if not a[i]:
                a[i] = q
                continue
            t.append(i)
            a[i] = q
            q += 1
            for j in range(i*i,m,i):
                a[j] = False

        for i in range(sq + 1, self.M):
            if a[i]:
                a[i] = q
                q += 1
                t.append(i)
            else:
                a[i] = q

    def is_prime(self, n):
        return self.A[n]


def main():
    rr = []

    M = 7368792
    pr = Prime(M)

    def f(m, n):
        nn = n
        g = [None] * (m*m)
        for i in range(m, m*m):
            if not g[i]:
                if n == 0:
                    return i
                n -= 1
                for j in range(i, m*m, i):
                    g[j] = 1
        d = pr.A[m*m]
        return pr.T[d+n]

    while True:
        m,n = LI()
        if m == 0 and n == 0:
            break
        rr.append(f(m,n))

    return '\n'.join(map(str,rr))




print(main())
### BUGGY CODE ###

# coding: utf-8

import sys
input=sys.stdin.readline

h=int(input())
cnt1=0
cnt2=1

while True:
    h=h//2
    cnt2*=2
    cnt1 += cnt2//2
    if h==1:
        break

print(cnt1+cnt2)

### FIXED CODE ###

# coding: utf-8

import sys
input=sys.stdin.readline

h=int(input())
cnt1=1
cnt2=0

while h>1:
    h=h//2
    cnt1*=2
    cnt2 += cnt1//2

print(cnt1+cnt2)
### BUGGY CODE ###

n, m = map(int, input().split())
passed = 0
failed = 0
dicto = {}
for i in range(m):
    key, status = input().split()
    if key not in dicto.keys():
        dicto[key] = []
        dicto[key].append(status)
    else:
        if 'AC' not in dicto[key]:
            dicto[key].append(status)
for item in dicto:
    if 'AC' in dicto[item]:
        failed += dicto[item].count('WA')
        passed += 1
print(passed, failed)


### FIXED CODE ###

n, m = map(int, input().split())
passed = 0
failed = 0
dicto = {}

for i in range(1, n+1):
    dicto[i] = [False, 0]

for i in range(m):
    key, status = input().split()
    key = int(key)
    if status == 'WA' and not dicto[key][0]:
        dicto[key][1] += 1
    else:
        dicto[key][0] = True

for i in dicto:
    if dicto[i][0]:
        failed += dicto[i][1]
        passed += 1

print(passed, failed)
### BUGGY CODE ###

from collections import deque

def deqreverse(deq):
    newdeq = deque()
    for _ in range(len(deq)):
        c = deq.pop()
        newdeq.append(c)
    
    return newdeq

S = deque(list(input()))
Q = int(input())
Query = []
for _ in range(Q):
    Query.append([x for x in input().split()])

i = 0
while i < Q:
    if i != Q-1:
        temp = Query[i+1][0]
        if Query[i][0] == '1':
            if temp != '1':
                S = deqreverse(S)
            else:
                i += 1
        else:
            if Query[i][1] == '1':
                S.appendleft(Query[i][2])
            else:
                S.append(Query[i][2])
    else:
        if Query[i][0] == '1':
            S = deqreverse(S)
        else:
            if Query[i][1] == '1':
                S.appendleft(Query[i][2])
            else:
                S.append(Query[i][2])
    i += 1
        
print("".join(S))

### FIXED CODE ###

from collections import deque

def reversedeq(deq):
    newdeq = deque()
    for _ in range(len(deq)):
        c = deq.pop()
        newdeq.append(c)
    
    return newdeq


S = deque(list(input()))
Q = int(input())
reverse_state = False

for _ in range(Q):
    Query = [x for x in input().split()]
    if len(Query) == 1:
        reverse_state = reverse_state ^ 1
    else:
        if reverse_state:
            if Query[1] == '1':
                S.append(Query[2])
            else:
                S.appendleft(Query[2])
        else:
            if Query[1] == '1':
                S.appendleft(Query[2])
            else:
                S.append(Query[2])

if reverse_state:
    S = reversedeq(S)

print("".join(S))
### BUGGY CODE ###

import itertools

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

sum=0
for v in itertools.combinations(A, 2):
    sum +=v[0]*v[1]
    sum = sum %(10**9 +7)
print(sum)

### FIXED CODE ###

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

mod= 10**9+7

A = sum(a)

ans=0

for i in a:
  A -= i
  A%=mod
  ans += A*i
  ans%=mod
print(ans)
### BUGGY CODE ###

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

ans = 1
for n in range(N):
    ans *= A[n]

if ans>10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

a=int(input())
b=input().split(" ")
sum1=1
 
if "0" in b:
    print("0")
else:
    for i in range(a):
        sum1=sum1*int(b[i])
        if sum1>10**18:
            sum1=-1
            break
    print(sum1)
### BUGGY CODE ###

import numpy as np
N = int(input())
a = list(map(int, input().split()))
s = sum(a)
b = np.array([a[0]])
for i in range(1,N-1):
    b = np.append(b, [b[i-1]+a[i]])
print(min(abs(2 * b -s )))

### FIXED CODE ###

def calc(x,y):
    z = x+y
    b.append(z)
    return z
from functools import reduce
import numpy as np
N = int(input())
a = list(map(int, input().split()))
s = sum(a)
b = [a[0]]
reduce(calc ,a)
print(min(abs(2 * np.array(b[0:N-1]) -s )))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b =sorted(a)

for y in b:
    for x in a:
        if y == x:
            print(a.index(x)+1, end=' ')

### FIXED CODE ###

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

l = []
for i, x in enumerate(a, 1):
    l.append((x, i))

y = sorted(l)
for z, i in y:
    print(i, end=' ')
### BUGGY CODE ###

a=input()
num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a[::-1]:
    tmp=int(i)*(tens%2019)
    Sn=(Sn+tmp%2019)%2019
    mod=Sn
    tens*=10
    mod_list[mod]+=1

res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)


### FIXED CODE ###

a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = list(input())
n = len(s)
s = s[::-1]
dp = [[0]*13 for _ in range(n)]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
for i in range(1,n):
    x = (10**i) % 13
    if s[i] == '?':
        for j in range(10):
            for k in range(13):
                dp[i][(k+(j*x) % 13) % 13] += dp[i-1][k]
                dp[i][(k+(j*x) % 13) % 13] %= mod
    else:
        y = int(s[i])
        for j in range(13):
            dp[i][(j+(y*x) % 13) % 13] += dp[i-1][j]
            dp[i][(j+(y*x) % 13) % 13] %= mod
print(dp[-1][5])


### FIXED CODE ###

#!/usr/bin/env python3
#ABC135 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

s = list(input())
s = s[::-1]
l = len(s)
#dp[i][j] := 先頭i文字として考えられるもののうち、13で割ったあまりがjであるもの
dp = [[0]*13 for _ in range(l)]
remain = 1
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1

for i in range(1,l):
    remain = (remain * 10) % 13
    if s[i] == '?':
        for k in range(10):
            for j in range(13):
                dp[i][(j + remain * k) % 13] += dp[i-1][j]
                dp[i][(j + remain * k) % 13] %= mod
    else:
        for j in range(13):
            dp[i][(j + remain * int(s[i])) % 13] += dp[i-1][j]
print(dp[-1][5])
### BUGGY CODE ###

S = input()[::-1]
mod = [i for i in range(10)]
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
for i in range(len(S)):
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
                dp[i+1][(j+mod[k])%13] += (dp[i][j])%(10**9+7)
        else:
            dp[i+1][(j+mod[int(S[i])])%13] = (dp[i][j])%(10**9+7)
    mod = [(10*x)%13 for x in mod]
print(dp[-1][5]%(10**9+7))

### FIXED CODE ###

S = input()[::-1]
mod = [i for i in range(10)]
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
for i in range(len(S)):
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
                dp[i+1][(j+mod[k])%13] += (dp[i][j])%(10**9+7)
        else:
            dp[i+1][(j+mod[int(S[i])])%13] = (dp[i][j])%(10**9+7)
    mod = [(10*x)%13 for x in mod]
print(dp[-1][5]%(10**9+7))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
a.sort()
q=int(input())

x=[0]*(10**5)
for i in range(n):
    x[i]=a.count(i+1)*(i+1)


for _ in range(q):
    b,c=map(int,input().split())
    if x[b-1]!=0:
        x[c-1]+=x[b-1]//b*c
        x[b-1]=0
        print(sum(x))
    else:
        print(sum(x))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
q=int(input())

ans=sum(a)

x=[0]*(10**5+10)
for i in a:
    x[i]+=1


for _ in range(q):
    b,c=map(int,input().split())
    ans+=x[b]*c-x[b]*b
    print(ans)
    x[c]+=x[b]
    x[b]=0
### BUGGY CODE ###

N=int(input())
H=list(map(int,input().split()))

for i in range(N-1):
        for j in range(i,N):
                if H[i]-H[j]>=2:
                        print('No')
                        exit()
print('Yes')

### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))

now=H[0]
for i in H:
        if i>now:
                now=i
        elif now>i+1:
                print('No')
                exit()

print('Yes')
### BUGGY CODE ###

#coding:utf-8
import sys
import bisect
import math
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    n, k = LMIIS()
    a = LMIIS()
    f = LMIIS()
    a.sort(reverse=True)
    f.sort()


    max_ = 10**12
    min_ = 0

    while True:
        x = (max_ + min_) // 2
        shugyo = 0
        for i in range(n):
            shugyo += max(0, a[i] - x // f[i])

        if shugyo <= k:
            max_ = x
        else:
            min_ = x


        if max_ == min_ + 1:
            if x == min_:
                x += 1
            if sum(a) <= k:
                x = 0
            break
    print(x)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    n, k = LMIIS()
    aa = LMIIS()
    ff = LMIIS()
    aa.sort(reverse=True)
    ff.sort()
    a = tuple(aa)
    f = tuple(ff)


    max_ = 10**12
    min_ = 0

    while max_ != min_ + 1:
        x = (max_ + min_) // 2
        shugyo = 0
        for i in range(n):
            shugyo += max(0, a[i] - x // f[i])

        if shugyo <= k:
            max_ = x
        else:
            min_ = x


    if x == min_:
        x += 1
    if sum(a) <= k:
        x = 0
    print(x)

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

n, q = map(int, input().split())
s = input()
ac_list = []

for i in range(n-1):
  if s[i:i+2]=='AC':
    ac_list.append(1)
  else:
    ac_list.append(0)

for _ in range(q):
  l, r = map(int, input().split())
  print(sum(ac_list[l-1:r-1]))

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])
### BUGGY CODE ###

import bisect


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

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

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


N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort()
X, H = zip(*XH)

bit = BinaryIndexTree(N)

ans = 0
for i in range(N):
    x = X[i]
    h = H[i]
    h -= bit.sum(i+1)
    if h <= 0:
        continue
    atk = (h + A - 1) // A
    ans += atk
    damage = atk * A
    bit.add(i+1, damage)
    pos = bisect.bisect_right(X, x+2*D)
    pos = min(N + 1, pos)
    bit.add(pos+1, -damage)

print(ans)


### FIXED CODE ###

from collections import deque
N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort()

que = deque([])
ans = 0
total = 0

for i in range(N):
    x, h = XH[i]
    if h <= 0:
        continue
    while que and XH[i][0] > que[0][0]:
        _, tmp = que.popleft()
        total -= tmp

    h -= total
    if h > 0:
        atk = (h + A - 1) // A
        damage = atk * A
        ans += atk
        total += damage
        que.append((x+2*D, damage))

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

N = int(input())
L = [i for i in map(int, input().split())]

L = sorted(L)[::-1] # descending order

def binary_search(descend_list, threshold):
    # 閾値を超えている要素の数を返す
    length = len(descend_list)
    
    # 最小の数が閾値を超えればリストの長さを返す
    if descend_list[-1] > threshold:
        return length
    
    # 最大の数が閾値を超えなければ0を返す
    if descend_list[0] <= threshold:
        return 0
    
    # 二分探索する 少なくとも一つはthresholdを超える要素があり、少なくとも一つはthresholdを超えない要素がある場合
    upper_bound = length
    lower_bound = 0
    index = (upper_bound - lower_bound) // 2
    
    while upper_bound > lower_bound + 1:
        if descend_list[index] > threshold:
            lower_bound = index
        else:
            upper_bound = index
        
        index = (upper_bound + lower_bound) // 2
    
    return lower_bound + 1

i = 0
ret = 0

while i < N - 2:
    edge1 = L[i]
    for j in range(i + 1, N-1):
        edge2 = L[j]
        _ret = binary_search(L[j+1:], edge1 - edge2)
        if _ret == 0:
            break
        else:
            ret += _ret
    
    i += 1

print(ret)

### FIXED CODE ###

N = int(input())
L = [i for i in map(int, input().split())]

L = sorted(L)[::-1] # descending order

def binary_search(descend_list, threshold):
    # 閾値を超えている要素の数を返す
    length = len(descend_list)
    
    # 最小の数が閾値を超えればリストの長さを返す
    if descend_list[-1] > threshold:
        return length
    
    # 最大の数が閾値を超えなければ0を返す
    if descend_list[0] <= threshold:
        return 0
    
    # 二分探索する 少なくとも一つはthresholdを超える要素があり、少なくとも一つはthresholdを超えない要素がある場合
    upper_bound = length
    lower_bound = 0
    index = (upper_bound - lower_bound) // 2
    
    while upper_bound > lower_bound + 1:
        if descend_list[index] > threshold:
            lower_bound = index
        else:
            upper_bound = index
        
        index = (upper_bound + lower_bound) // 2
    
    return lower_bound + 1

i = 0
ret = 0

while i < N - 2:
    edge1 = L[i]
    for j in range(i + 1, N-1):
        edge2 = L[j]
        _ret = binary_search(L[j+1:], edge1 - edge2)
        if _ret == 0:
            break
        else:
            ret += _ret
    
    i += 1

print(ret)
### BUGGY CODE ###

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

all_mount = sum(A)
mounts = []
for i in range(N):
  mount = all_mount
  for j in range(0, N-1, 2):
    mount -= 2 * A[(i+j+1)%N]
  mounts.append(mount)
    
print(" ".join(map(str,mounts)))

### FIXED CODE ###

N = int(input())
A = list(map(lambda x: 2 * int(x), input().split()))

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(map(str, mounts)))
### BUGGY CODE ###

def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B = a * B // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()



### FIXED CODE ###

def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


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

import numpy as np
N, K = map(int, input().split())
p = input().split()
p = [int(i) for i in p]
arr_1d = np.array(p)
SUM_P = []
for i in range(N-K+1):
    SUM_P.append(np.sum(p[i:i+K]))
print((max(SUM_P)+K)/2)

### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
SUM_P=sum(p[0:K])
all_sum_p=[SUM_P]
for i in range(N-K):
    SUM_P=SUM_P-p[i]+p[i+K]
    all_sum_p.append(SUM_P)
print((max(all_sum_p)+K)/2)
### BUGGY CODE ###

N = int(input())
S = [input() for i in range(N)]
y = []
N = 0
while S!=[]:
    if N < S.count(S[0]):
        N = S.count(S[0])
        y.clear()
        y.append(S[0])
    elif N == S.count(S[0]):
        y.append(S[0])
    S = [i for i in S if i != S[0]]
for i in sorted(y):
    print(i)

### FIXED CODE ###

N = int(input())
d = {}
for i in range(N):
    s = input()
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1
Max = max(d.values())
keys = [k for k, v in d.items() if v == Max]
keys.sort()
for k in keys:
    print(k)
### BUGGY CODE ###

N = int(input())
a = [int(i) for i in input().split()]
res = []
for i in range(1,len(a)):
    res.append(abs(sum(a[:i])-sum(a[i:])))

print(min(res))


### FIXED CODE ###

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

l = [0] * (N+1)
r = [0] * (N+1)

for i in range(N):
    l[i+1] = l[i] + a[i]

for i in range(N-1,-1,-1):
    r[i] = r[i+1] + a[i]

res = []

for i in range(1,len(l)-1):
    res.append(abs(l[i]-r[i]))

print(min(res))
### BUGGY CODE ###

import sys,random
from math import gcd
input=sys.stdin.readline
n=int(input())
*a,=map(int, input().split())
random.shuffle(a)
tmp=a[0]
for i in range(1,n):
    tmp=gcd(tmp,a[i])
if tmp>1:
    print('not coprime')
    exit()

# pairwize coprime なら素因数が2度現れることはない

def f(x):
    res=set()
    for i in range(2,int(x**(1/2))+3):
        if x%i==0:
            while x%i==0:
                x//=i
            res.add(i)
    if x>1:
        res.add(x)
    return res,x
tmp=set()
tmp2=set()
for ai in a:
    for p in tmp:
        if ai%p==0:
            print('setwise coprime')
            exit()
    pp,x=f(ai)
    tmp|=pp 
    if x>1 and x in tmp2:
        print('setwise coprime')
        exit()
    tmp2.add(x)
    
        
print('pairwise coprime')



### FIXED CODE ###

import sys,random
from math import gcd
input=sys.stdin.readline
n=int(input())
*a,=map(int, input().split())
random.shuffle(a)
tmp=a[0]
for i in range(1,n):
    tmp=gcd(tmp,a[i])
if tmp>1:
    print('not coprime')
    exit()

# pairwize coprime なら素因数が2度現れることはない

def f(x):
    res=set()
    for i in range(2,int(x**(1/2))+3):
        if x%i==0:
            while x%i==0:
                x//=i
            res.add(i)
    return res,x
tmp=set()
tmp2=set()
for ai in a:
    for p in tmp:
        if ai%p==0:
            print('setwise coprime')
            exit()
    pp,x=f(ai)
    tmp|=pp 
    if x>1 and x in tmp2:
        print('setwise coprime')
        exit()
    tmp2.add(x)
    
        
print('pairwise coprime')
### BUGGY CODE ###

def mapping(string):
    return 1 if string == "L" else -1


n, k = map(int, input().split())
s = list(map(mapping, input()))

left = 0
right = n - 1


for loop in range(k):
    for i in range(left, n - 1):
        if s[i] != s[i+1]:
            left = i + 1
            break

    else:
        break

    for i in range(right - 1, left, -1):
        if s[i] != s[i+1]:
            right = i + 1
            break
    else:
        right = n

    for i in range(left, right):
        s[i] *= -1

tmp = 0
for i in range(n - 1):
    if s[i] != s[i+1]:
        tmp += 1

print(n - tmp - 1)


### FIXED CODE ###

def mapping(string):
    return 1 if string == "L" else -1


n, k = map(int, input().split())
s = list(map(mapping, input()))

flips = []
for i in range(n - 1):
    if s[i] != s[i + 1]:
        flips.append(i + 1)

print(min(n - 1, n - 1 - len(flips) + 2 * k))