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

N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
  ans *= a
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
  print(0)
  exit()
for a in A:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()

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

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
mod_cnt = [0] * 2019
mod_cnt[0] = 1
power = 1
remain = 0
answer = 0
for i in range(len(S)-1, -1, -1):
    remain += int(S[i]) * power
    remain %= 2019
    power *= 10
    answer += mod_cnt[remain]
    mod_cnt[remain] += 1

print(answer)


### FIXED CODE ###

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
mod_cnt = [0] * 2019
mod_cnt[0] = 1
power = 1
remain = 0
answer = 0
for i in range(len(S)-1, -1, -1):
    remain += int(S[i]) * power
    remain %= 2019
    power *= 10; power %= 2019
    answer += mod_cnt[remain]
    mod_cnt[remain] += 1

print(answer)
### BUGGY CODE ###

# D
# Multiple of 2019
import itertools

s = input()

d = len(s)

_list = [None]*d
_map = [0]*2019

ans = 0

for i in range(d):
    _tmp = int(s[i:])%2019
    _list[i] = _tmp
    if _tmp == 0:
        ans += 1
    elif _map[_tmp] ==1:
        ans += 1
    _map[_tmp] = 1
        
print(ans)

### FIXED CODE ###

# D
# Multiple of 2019
import itertools

s = input()[::-1]

d = len(s)

# _list = [None]*d
_map = [0]*2019
_map[0] = 1

ans = 0
j,_ = 1,0

for i in s:
    _ += int(i) * j
    _tmp = _ % 2019
    j = (j*10)%2019
    _map[_tmp] += 1
    
for _l in _map:
    ans += _l * (_l - 1) / 2
    
print(int(ans))
### BUGGY CODE ###

import itertools
N=int(input())
L=list(map(int,input().split()))
 
p=itertools.combinations(L,3)
q=itertools.combinations(L,2)
d={}
for i in q:
  if i not in d:
    d[i]=i[0]+i[1]
s=0
for i in p:
  x=d[i[0],i[1]]
  y=d[i[1],i[2]]
  z=d[i[0],i[2]]
  if i[0]<y and i[1]<z and i[2]<x:
    s += 1
 
print(s)

### FIXED CODE ###

from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):#一番短い棒
  for j in range(i+1,n):#二番目に短い棒
    #1+2番目の棒の長さより短く、2番目に短い棒より長い棒の範囲を探す
    ans += bisect_left(l,l[i]+l[j])-(j+1)
print(ans)
### BUGGY CODE ###

num = int(input())
numList = list(map(int, input().split()))
max = 1000000000000000000
flg = True
result = 1

if 0 in numList:
    print(0)
else:
    for i in range(num):
        result *= numList[i]
    
    if result > max:
        flg = False
    if flg:
        print(result)
    else:
        print(-1)


### FIXED CODE ###

num = int(input())
numList = list(map(int, input().split()))
max = 1000000000000000000
flg = True
result = 1

if 0 in numList:
    print(0)
else:
    for i in range(num):
        result *= numList[i]
        if result > max:
            flg = False
            break
    if flg:
        print(result)
    else:
        print(-1)
### BUGGY CODE ###

N,M,K = map(int, input().split())
import math

counter =0

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def painting(length,color_num):
    return color_num*(color_num-1)**(length-1)

for k in range(K+1):
    counter += combinations_count(N-1,k)*painting(N-k,M)



all = counter 
print(all%998244353)


### FIXED CODE ###

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

p = 998244353

factorial = [1]
counter = 0
for i in range(1,N+1):
    factorial.append(factorial[i-1]*i%p)



for k in range(K+1):
    counter += factorial[N-1]*pow(factorial[k],p-2,p)*pow(factorial[N-k-1],p-2,p)*M*pow(M-1,N-1-k,p)
print(counter%p)
### BUGGY CODE ###

import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[list(map(int,input().split())) for i in range(m)]

# print(a)
for i in range(m):
    bi=bisect.bisect_left(a,bc[i][1])
    # print(bi)
    for j in range(min(bi,bc[i][0])):
        a[j]=bc[i][1]
    a.sort()
    # print(a)

print(sum(a))

### FIXED CODE ###

import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=sorted([list(map(int,input().split())) for i in range(m)], key=lambda x:x[1], reverse=True)

# print(bc)
# print(a)
tmp=[]
count=0
for i in range(m):
    for j in range(bc[i][0]):
        if count==n:
            break
        tmp.append(bc[i][1])
        count+=1


change=tmp[:n]
# print(tmp)
# print(change)

for i in range(len(change)):
    if change[i]>a[i]:
        a[i]=change[i]
    else:
        break
print(sum(a))
### BUGGY CODE ###

import sys
import math 
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    p  = 0
    def mul(A):
        m = 1
        for i in range(len(A)):
            m*=A[i]
        return m
        
    score = []
    for i in range(K-1,N):
        lst = A[i-K+1:i+1]
        p = mul(lst)
        if i != K-1:
            if p <= prev:
                print('No')
            else:
                print('Yes')
        prev = p
    
        

if __name__ == "__main__":
    main()
    

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    p  = 0
 
    for i in range(K-1,N):
        #lst= A[i-K+1:i+1]
        #p = sum(lst)
        #p = mul(lst)
        #p = functools.reduce(operator.mul,lst)
        if i != K-1:
            if A[i] <= A[i-K]:
                print('No')
            else:
                print('Yes')
        
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

R,G,B,N = map(int,input().split())
count = 0
for a in range(0,N+1,R):
    for b in range(0,N-a+1,G):
        c = N-a-b
        if a%R == 0 and b%G == 0 and c%B == 0:
            count +=1
print(count)

### FIXED CODE ###

R,G,B,N = map(int,input().split())
count = 0
for a in range(0,N+1,R):
    if a%R == 0:
        for b in range(0,N-a+1,G):
            if b%G == 0:
                c = N-a-b
                if c%B == 0:
                    count +=1
print(count)
### BUGGY CODE ###

H, W = map(int, input().split())
S = [input() for _ in range(H)]

# そのマスを含めてLeft, Right, Up, Downにそれぞれ何マス分明かりを照らせるかを配列に記録
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]

for i in range(H):
	for j in range(W):
		if S[i][j] == ".":
			if j == 0:
				L[i][j] = 1
			else:
				L[i][j] = L[i][j - 1] + 1

for i in range(H):
	for j in range(W - 1, -1, -1):
		if S[i][j] == ".":
			if j == W - 1:
				R[i][j] = 1
			else:
				R[i][j] = R[i][j + 1] + 1

for j in range(W):
	for i in range(H - 1, -1, -1):
		if S[i][j] == ".":
			if i == H - 1:
				D[i][j] = 1
			else:
				D[i][j] = D[i + 1][j] + 1

for j in range(W):
	for i in range(H):
		if S[i][j] == ".":
			if i == 0:
				U[i][j] = 1
			else:
				U[i][j] = U[i - 1][j] + 1


ans = 0
X = [[0] * W for _ in range(H)]
for i in range(H):
	for j in range(W):
		X[i][j] = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
	ans = max(ans, max(X[i]))

print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
s = [input() for _ in range(h)]
sy = [0] * w
ret = 0
for y in range(h):
    seqx = 0
    seqy = 0
    for x in range(w):
        if s[y][x] == '.':
            if sy[x] == 0:
                yy = y
                while yy < h and s[yy][x] != '#':
                    yy += 1
                sy[x] = yy - y
            seqx += 1
            seqy = max(seqy, sy[x])
            ret = max(ret, seqx + seqy - 1)
        else:
            seqx = 0
            seqy = 0
            sy[x] = 0
print(ret)
### BUGGY CODE ###

from collections import deque
import bisect
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    graph = [[] for _ in range(n+1)]

    A = [0]+list(map(int, input().split()))

    for i in range(n-1):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)

    dist = [-1] * (n+1)
    dist[0] = 0
    dist[1] = 1

    d = deque()
    d.append((1, [0, A[1]]))

    while d:
        v, dp = d.popleft()
        for index, i in enumerate(graph[v],1):
            if dist[i] != -1:
                continue
            if index==len(graph[v]):
                if dp[-1] < A[i]:
                    dp.append(A[i])
                else:
                    bis = bisect.bisect_left(dp, A[i])
                    dp[bis] = A[i]
                dist[i] = len(dp)-1
                d.append((i, dp))
            else:
                ndp=dp.copy()
                if dp[-1] < A[i]:
                    ndp.append(A[i])
                else:
                    bis = bisect.bisect_left(ndp, A[i])
                    ndp[bis] = A[i]
                dist[i] = len(ndp)-1
                d.append((i, ndp))

    print(*dist[1:], sep="\n")

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import deque
import sys
import bisect
def input(): return sys.stdin.readline().rstrip()

n=int(input())
A=[0]+list(map(int, input().split()))

graph = [[] for _ in range(n+1)]

for i in range(n-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

visited = [-1] * (n+1)
visited[0] = 0
visited[1] = 1

d = deque()
d.append(1)
dp=[10**10]*(n+1)
dp[0]=0
dp[1]=A[1]
update_task=[() for _ in range(n+1)]
update_task[1]=(1,0)
while d:
    v = d[-1]
    if graph[v] == []:
        d.pop()
        index,atai=update_task[v]
        dp[index]=atai
    else:
        i = graph[v].pop()
        if visited[i] != -1:
            continue
        bis = bisect.bisect_left(dp, A[i])
        update_task[i]=(bis,dp[bis])
        dp[bis] = A[i]
        visited[i] = bisect.bisect_left(dp, 10**10-100)-1
        d.append(i)

print(*visited[1:], sep="\n")
### BUGGY CODE ###

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

N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

# 昇順ソート
A_list.sort()
B_list.sort()
C_list.sort()

ans = 0
for i in range(N):
    for j in range(N):
        # 下段 <= 中段 になったらもうやらない
        if C_list[i] <= B_list[j]:
            break
        for k in range(N):
            # 中段 <= 下段 になったらもうやらない
            if B_list[j] <= A_list[k]:
                break
            ans += 1
print(ans)

### FIXED CODE ###

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

# 2分検索ライブラリを使う
import bisect

N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

# 昇順ソート
A_list.sort()
C_list.sort()

ans = 0
for i in range(N):
    # 同じ値があった時に、leftは先頭、rightは最後尾のindexを返す
    ab = bisect.bisect_left(A_list, B_list[i])
    bc = N - bisect.bisect_right(C_list, B_list[i])
    # 返されたindexから、候補となるABとBCの数が分かるので、合計していく
    ans += ab * bc
print(ans)
### BUGGY CODE ###

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

N = int(input().strip())
from itertools import combinations
nodes = list(combinations(range(N), 2))
graph = {i:[] for i in nodes}
for x in range(N):
  l = list(map(int,input().split()))
  y = l[0]-1
  prev = (min(x,y),max(x,y))
  for y in l[1:]:
    y -= 1
    now = (min(x,y),max(x,y))
    graph[prev].append(now)
    prev = now

d = {k:1 for k in nodes}
f = {k:0 for k in nodes}
in_cnt = {k:0 for k in nodes}
for x in nodes:
  for y in graph[x]:
    in_cnt[y] += 1
ret = []
q = deque([i for i in nodes if not in_cnt[i]])
if not q:
  print(-1)
  exit()
ans = 0
while q:
  x = q.popleft()
  ret.append(x)
  f[x] = 1
  for y in graph[x]:
    if f[y]:
      print(-1)
      exit()
    d[y] = max(d[y],d[x]+1)
    ans = max(ans,d[y])
    in_cnt[y] -= 1
    if not in_cnt[y]:
      q.append(y)
if [i for i in nodes if in_cnt[i]]:
  print(-1)
  exit()

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input().strip())
M = N*(N-1)//2

graph = [[] for i in range(M)]
in_cnt = [0 for i in range(M)]
for x in range(1,N+1):
  l = list(map(int,input().split()))
  y = l[0]
  b,s = max(x,y),min(x,y)
  prev = (b-1)*(b-2)//2+s-1
  for y in l[1:]:
    b,s = max(x,y),min(x,y)
    now = (b-1)*(b-2)//2+s-1
    graph[prev].append(now)
    in_cnt[now] += 1 
    prev = now

d = [1 for k in range(M)]
q = [i for i in range(M) if not in_cnt[i]]

if not q:
  print(-1)
  exit()
ans = 0
while q:
  x = q.pop()
  for y in graph[x]:
    d[y] = max(d[y],d[x]+1)
    ans = max(ans,d[y])
    in_cnt[y] -= 1
    if not in_cnt[y]:
      q.append(y)
if [i for i in range(M) if in_cnt[i]]:
  print(-1)
  exit()

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

from collections import deque

H, W = map(int, input().split())
C_h, C_w = map(int, input().split())
D_h, D_w = map(int, input().split())

S = [input() for _ in range(H)]
dist = [[float("inf") for i in range(W)] for j in range(H)]
dist[C_h-1][C_w-1] = 0

d = deque([[C_h-1, C_w-1, 0]])

def check_movable(h, w):
    if h < 0 or h >= H or w < 0 or w >= W:
        return False
    if S[h][w] == "#":
        return False
    else:
        return True

def check_appnendable(h, w, cost):
    if not check_movable(h,w):
        return False
    if dist[h][w] > cost:
        return True
    else:
        return False

dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
while d:
    h, w, cost = d.pop()
    for dh, dw in zip(dx, dy):
        if check_appnendable(h+dh, w+dw, cost) and dist[h+dh][w+dw] > cost:
            d.append([h+dh, w+dw, cost])
            dist[h+dh][w+dw] = cost
    for dh in range(-2, 3):
        for dw in range(-2, 3):
            if check_appnendable(h+dh, w+dw, cost+1) and dist[h+dh][w+dw] > cost + 1:
                d.appendleft([h+dh, w+dw, cost+1])
                dist[h+dh][w+dw] =cost+1

if dist[D_h-1][D_w-1] < float("inf"):
    print(dist[D_h-1][D_w-1])
else:
    print(-1)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
C_h, C_w = map(int, input().split())
D_h, D_w = map(int, input().split())

S = [input() for _ in range(H)]
dist = [[float("inf") for i in range(W)] for j in range(H)]
dist[C_h-1][C_w-1] = 0

d = deque([[C_h-1, C_w-1, 0]])

def check_movable(h, w):
    if h < 0 or h >= H or w < 0 or w >= W:
        return False
    if S[h][w] == "#":
        return False
    else:
        return True

def check_appnendable(h, w, cost):
    if not check_movable(h,w):
        return False
    if dist[h][w] > cost:
        return True
    else:
        return False

dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
while d:
    h, w, cost = d.pop()
    for dh, dw in zip(dx, dy):
        if check_appnendable(h+dh, w+dw, cost):
            d.append([h+dh, w+dw, cost])
            dist[h+dh][w+dw] = cost
    for dh in range(-2, 3):
        for dw in range(-2, 3):
            if check_appnendable(h+dh, w+dw, cost+1):
                d.appendleft([h+dh, w+dw, cost+1])
                dist[h+dh][w+dw] =cost+1

if dist[D_h-1][D_w-1] < float("inf"):
    print(dist[D_h-1][D_w-1])
else:
    print(-1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))
import math

N, K = mi()
A = li()

if K == 0:
    print(max(A))
    exit()

left = 0
right = max(A)

def count(num):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / num) - 1
    return cnt

while True:
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        exit()
    tmp = count(mid)
    if right - left <= 1:
        mid = right
        break
    elif tmp > K:
        left = mid
    else:
        right = mid

right = mid

while True:
    tmp = count(mid)
    if tmp == K and tmp != count(mid-1):
        print(mid)
        break
    elif tmp == K:
        right = mid
    else:
        #if left == mid:
            #print(mid+1)
            #break
        left = mid
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        break

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))
import math

N, K = mi()
A = li()

if K == 0:
    print(max(A))
    exit()

left = 0
right = max(A)

def count(num):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / num) - 1
    return cnt

while True:
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        exit()
    tmp = count(mid)
    if right - left <= 1:
        mid = right
        break
    elif tmp > K:
        left = mid
    else:
        right = mid

right = mid

while True:
    tmp = count(mid)
    if right - left <= 1:
        print(right)
        break
    elif tmp == K:
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        break
### BUGGY CODE ###

from collections import Counter
n = int(input())
s = [Counter(input()) for i in range(n)]
count = 0
for i in range(n-1):
    for j in range(i+1, n):
        if s[i] == s[j]:
            count += 1
print(count)

### FIXED CODE ###

from collections import Counter
n = int(input())
s = [str(sorted(input())) for i in range(n)]
d = dict()
for el in s:
    if d.get(el) == None:
        d[el] = 1
    else:
        d[el] += 1
count = 0
for el in d.values():
    count += el*(el-1)//2
print(count)
### BUGGY CODE ###

import collections
n = int(input())
moji = []
moji_s = [[0 for i in range(26)] for j in range(n)]
for i in range(n):
    m = input()
    ans = dict(collections.Counter(m))
    moji.append(ans)
    for j in ans:
        moji_s[i][ord(j)-97] = ans[j]
#ここまででそれぞれの文字列の文字の出現回数を辞書型にまとめたものがリストに格納された
count = 0
count_ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        if moji_s[i]==moji_s[j]:
            count +=1
print(count)

### FIXED CODE ###

n = int(input())
res = dict()
for i in range(n):
    m = input()
    m = sorted(m)
    m = ''.join(m)
    if m in res:
        res[m] += 1
    else:
        res[m] = 1

for i in res:
  res[i] = res[i]*(res[i]-1)//2
print(sum(res.values()))
### BUGGY CODE ###

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
  
def gcd3(a,b,c):
    return gcd(gcd(a,b),c)
    
k= int(input())    
total = 0
for i in range(1,k+1):
    for ii in range(1,k+1):
        for iii in range(1,k+1):
            total += gcd3(i,ii,iii)

print(total)   

### FIXED CODE ###

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
  
def gcd3(a,b,c):
    return gcd(gcd(a,b),c)
    
k= int(input())    
total = 0
for i in range(1,k+1):
    for ii in range(1,k+1):
        for iii in range(1,k+1):
            total += gcd3(i,ii,iii)
 
print(total)
### BUGGY CODE ###

import heapq

N,K=map(int,input().split())
A=list(map(int,input().split()))
h=[]
heapq.heapify(h)
for i in range(N-1):
  a=A[i]
  for j in range(i+1,N):
    heapq.heappush(h,a*A[j])
for _ in range(K-1):
  heapq.heappop(h)
print(heapq.heappop(h))

### FIXED CODE ###

N,K=map(int,input().split())
A=sorted(map(int,input().split()))
x=0
r=10**18+1
l=-(10**18)
while l+1<r:
    x=(l+r)//2
    k=0
    for a in A:
        if a<0:
            ll,rr=-1,N
            while ll+1<rr:
                c=(rr+ll)//2
                if x>a*A[c]:
                    rr=c
                else:
                    ll=c
            k+=N-rr
        else:
            ll,rr=-1,N
            while ll+1<rr:
                c=(rr+ll)//2
                if x>a*A[c]:
                    ll=c
                else:
                    rr=c
            k+=rr
        if x>a**2:
            k-=1
    k//=2
    if k<K:
        l=x
    else:
        r=x
print(l)
### BUGGY CODE ###

N = int(input())
l = list(map(int,input().split()))
m = [0]*N

for i in range(N):
  m[i] = l.index(i+1)+1
  
print(*m)


### FIXED CODE ###

N = int(input())
l = list(map(int,input().split()))
m = [0]*N

for i in range(N):
  m[l[i]-1] = i+1
  
print(*m)
### BUGGY CODE ###

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

sum_XOR = A
for i in range(A+1, B+1):
    sum_XOR = sum_XOR ^ i

print(sum_XOR)

### FIXED CODE ###

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

if A%2 == 0 and B%2 == 1:
    if (B - A - 1) % 4 == 0:
        print("1")
    else:
        print("0")
elif A%2 == 0 and B%2 == 0:
    if (B-A) % 4 == 0:
        print(B)
    else:
        print(B ^ 1)
elif A%2 == 1 and B%2 == 1:
    if (B-A) % 4 == 0:
        print(A)
    else:
        print(A ^ 1)
else:
    if (B - A - 1) % 4 == 0:
        print(A ^ B)
    else:
        print(A ^ B ^ 1)
### BUGGY CODE ###

import re

pattern = "AC"
N, Q = map(int, input().split(" "))
S = input()
for i in range(Q) :
    l, r = map(int, input().split(" "))
    results = re.findall(pattern, S[l-1:r], re.S)
    print(len(results))


### FIXED CODE ###

N, Q = map(int, input().split(" "))
S = input()

ACIndex = [0] * (N+1)
for i in range(N) :
    ACIndex[i+1] = ACIndex[i] + (1 if S[i:i+2] == "AC" else 0)

for i in range(Q) :
    l,r = map(int, input().split(" "))
    print(ACIndex[r-1] - ACIndex[l-1])
### BUGGY CODE ###

h, n = (int(x) for x in input().split())
w = []
v = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    w.append(a)
    v.append(b)
dp = [[float('inf')] * (h) for _ in range(n + 1)]
for i in range(n):
    for j in range(h):
        if j < w[i]:
            dp[i + 1][j] = min(dp[i][j], v[i])
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - w[i]] + v[i])
print(dp[n][h - 1])

### FIXED CODE ###

h, n = (int(x) for x in input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
max_a = max(a for a, _ in ab)
dp = [0] * (h + max_a)
for i in range(1, h + 1):
    dp[i] = min(dp[i - a] + b for a, b in ab)
print(dp[h])
### BUGGY CODE ###

import bisect

s = input()
t = input()

if not all(i in s for i in t):
    print(-1)
    exit()

n = len(t)
t = [[t[i],[]] for i in range(n)]

t = t[::-1]

for i in range(n):
    t[i][1] = sorted([j for j,x in enumerate(s) if x == t[i][0]])

rep = 0
ans = t[0][1][0]

tmp = t[0][1][0]

for i in range(1,n):
    x = bisect.bisect_left(t[i][1],tmp)
    if x == 0:
        rep += 1
        tmp = t[i][1][-1]
    else:
        tmp = t[i][1][x-1]

print(rep*len(s) + ans+1)
    
    




### FIXED CODE ###

import bisect

s = input()
t = input()

sset = set(s)
tset = set(t)

if not all(i in sset for i in tset):
    print(-1)
    exit()

d = {}

for x in tset:
    d[x] = sorted([j for j,y in enumerate(s) if x == y])

rep = 0
tmp = d[t[0]][0]

n = len(t)

for i in range(1,n):
    k = d[t[i]]
    x = bisect.bisect_right(k,tmp)
    if x == len(k):
        rep += 1
        tmp = k[0]
    else:
        tmp = k[x]

print(rep*len(s) + tmp +1)
### BUGGY CODE ###

n, m, k = map(int, input().split(' '))
ans = 0

a_ls = [0] + list(map(int, input().split(' ')))
b_ls = [0] + list(map(int, input().split(' ')))

for i in range(1, n+1):
    a_ls[i] += a_ls[i-1]
for i in range(1, m+1):
    b_ls[i] += b_ls[i-1]

for a_cnt in range(0, n+1):
    if a_ls[a_cnt] > k:
        continue
    b_cnt = m
    while a_ls[a_cnt] + b_ls[b_cnt] > k:
        b_cnt -= 1
    ans = max(ans, a_cnt + b_cnt)

print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split(' '))
ans = 0

a_ls = [0] + list(map(int, input().split(' ')))
b_ls = [0] + list(map(int, input().split(' ')))

for i in range(1, n+1):
    a_ls[i] += a_ls[i-1]
for i in range(1, m+1):
    b_ls[i] += b_ls[i-1]

b_cnt = m
for a_cnt in range(0, n+1):
    if a_ls[a_cnt] > k:
        continue
    while a_ls[a_cnt] + b_ls[b_cnt] > k:
        b_cnt -= 1
    ans = max(ans, a_cnt + b_cnt)

print(ans)