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

#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    # ACがある場所を記録する
    buf = None
    mem = []
    for i, c in enumerate(S):
        if buf is None and c == 'A':
            buf = 'A'
        elif buf == 'A' and c == 'C':
            mem.append(i-1)
            buf = None
    for i in range(Q):
        tot = 0
        for m in mem:
            if l[i]-1 <= m and m < r[i]-1:
                tot += 1
        print(tot)

    return


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
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# import random

# tc_1 = "".join([random.choice("ACGT") for x in range(100)])
# tc_q = sorted([random.choice(range(100)) for _ in range(2)])
# print(tc_1[tc_q[0]-1:tc_q[1]])
# print(tc_1[tc_q[0]-1:tc_q[1]].count("AC"))
# print(solve(1, 1, tc_1, [tc_q[0]], [tc_q[1]]))


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    # ACがある場所を記録する
    buf = None
    mem = []
    tot = 0
    for i, c in enumerate(S):
        if c == 'A':
            buf = 'A'
        elif buf == 'A' and c == 'C':
            tot += 1
            buf = None
        elif buf == 'A':
            buf = None
        mem.append(tot)
    # print(mem)
    for i in range(Q):
        print(mem[r[i]-1]-mem[l[i]-1])

    return


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
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)


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

def main():
  import sys
  from heapq import heappush, heappop, heapify
  _int = int
  n = _int(input())
  a = [_int(e) for e in input().split()]
  b = [_int(e) for e in input().split()]
  result = 0
  hq = [(-b[i], i) for i in range(n) if b[i] != a[i]]
  heapify(hq)
  while len(hq) != 0:
    _, i = heappop(hq)
    if i == 0 or i == n - 1:
      j = b[(n + i - 1) % n] + b[(n + i + 1) % n]
    else:
      j = b[i - 1] + b[i + 1]
    if j > b[i]:
      print(-1)
      sys.exit() 
      k = (b[i] - a[i]) // j
      result += k
      b[i] -= j * k
    if a[i] > b[i]:
      print(-1)
      sys.exit()
    if a[i] != b[i]:
      heappush(hq, (-b[i], i))
  print(result)
main()

### FIXED CODE ###

def main():
  import sys
  _int = int
  n = _int(input())
  a = [_int(e) for e in input().split()]
  b = [_int(e) for e in input().split()]
  result = 0
  q = [i for i in range(n) if b[i] != a[i]]
  while len(q) != 0:
    nq = []
    c = 0
    for i in q:
      if i == 0 or i == n - 1:
        j = b[(n + i - 1) % n] + b[(n + i + 1) % n]
      else:
        j = b[i - 1] + b[i + 1]
      if j > b[i] - a[i]:
        nq.append(i)
        continue
      c += 1
      k = (b[i] - a[i]) // j
      result += k
      b[i] -= j * k
      if a[i] != b[i]:
        nq.append(i)
    if c == 0 and len(nq) != 0:
      print(-1)
      sys.exit()
    q = nq
  print(result)
main()
### BUGGY CODE ###

import math

while True:
    try:
        n = int(input())
        prime_cnt = 0

        for i in range(2, n+1):
            cnt = 0
            
            for j in range(2,i):
                if i % j == 0:
                    cnt = cnt + 1
                    break
                    
            if cnt == 0:
                #?´???°
                prime_cnt = prime_cnt + 1
                

        print(str(prime_cnt))
    except:
        break
    

### FIXED CODE ###

#init
max_num = 1000000
is_prime_num = [True for i in range (max_num+1)]

#0, 1 --- not prime number
is_prime_num[0] = False
is_prime_num[1] = False
end = int(max_num ** .5)

for i in range(2, end+1):
    if is_prime_num[i]:
        for j in range(i*i, max_num+1, i):
            is_prime_num[j] = False


while True:
    try:
        n = int(input())
        prime_cnt = 0
        for i in range(1, n+1):
            if is_prime_num[i]:
                prime_cnt = prime_cnt + 1
                   
   
        print(str(prime_cnt))
    except:
        break
### BUGGY CODE ###

if __name__ == '__main__':
    inputList = input().split()

    A = int(inputList[0])
    B = int(inputList[1])
    C = int(inputList[2])
    K = int(inputList[3])
    limit = pow(10, 18)

    for num in range(K):
        _A = B + C
        _B = A + C
        _C = A + B

        A = _A
        B = _B
        C = _C

        if A - B > limit:
            break

    result = A - B

    if result > limit:
        result = "Unfair"

    print(result)


### FIXED CODE ###

if __name__ == '__main__':
    inputList = input().split()

    A = int(inputList[0])
    B = int(inputList[1])
    C = int(inputList[2])
    K = int(inputList[3])
    limit = pow(10, 18)

    if K % 2 == 0:
        result = A - B
    else:
        result = B - A

    if result > limit:
        result = "Unfair"

    print(result)
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	nn=II()
	A=LI()
	ans="pairwise coprime"

	n = 1000000
	primes = set(range(2, n+1))
	for i in range(2, int(n**0.5+1)):
		primes.difference_update(range(i*2, n+1, i))
	primes=set(primes)

	#print(primes)


	B=set(range(1,10**6+1))
	C=set()
	for i in A:
		a=set()
		while i%2==0:
			a.add(2)
			i//=2
		f=3
		while f*f<=i:
			if i in primes:
				break
			elif i%f==0:
				a.add(f)
				i//=f
			else:
				f+=2
		if i!=1:
			a.add(i)
		B&=a
		if C&a:
			ans="setwise coprime"
		C|=a

	if B:
		ans="not coprime"

	print(ans)





















if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	nn=II()
	A=LI()
	ans="pairwise coprime"

	n = 500005
	primes = set(range(2, n+1))
	for i in range(2, int(n**0.5+1)):
		primes.difference_update(range(i*2, n+1, i))
	primes=set(primes)

	#print(primes)


	B=set(range(1,5*10**5+5))
	C=set()
	for i in A:
		a=set()
		while i%2==0:
			a.add(2)
			i//=2
		f=3
		while f*f<=i:
			if i in primes:
				break
			elif i%f==0:
				a.add(f)
				i//=f
			else:
				f+=2
		if i!=1:
			a.add(i)
		B&=a
		if C&a:
			ans="setwise coprime"
		C|=a

	if B:
		ans="not coprime"

	print(ans)





















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

class Node:
	elm = None
	next = None
	prev = None

class MyList:
	head = tail = None
	lookup = {}

	def insert(self, x):
		n = Node()
		n.elm = x
		if self.head == None:
			self.head = self.tail = n
		else:
			n.next = self.head
			self.head.prev = n
			self.head = n
		self.lookup[x] = n

	def delete(self, x):
		if x in self.lookup:
			n = self.lookup[x]
			del self.lookup[x]
		else:
			n = self.head
			while n and n.elm != x:
				n = n.next
		if n: 
			self.__delete_node(n)

	def deleteFirst(self):
		x = self.head.elm
		if x in self.lookup:
			del self.lookup[x] 
		self.__delete_node(self.head)

	def deleteLast(self):
		x = self.tail.elm
		if x in self.lookup and self.tail == self.lookup[x]:
			del self.lookup[x]
		self.__delete_node(self.tail)

	def __delete_node(self, n):
		if n == self.head:
			self.head = n.next
		if n == self.tail:
			self.tail = n.prev
		if n.prev:
			n.prev.next = n.next
		if n.next:
			n.next.prev = n.prev

	def print_all(self):
		n = self.head
		while n:
			print n.elm,
			n = n.next

myList = MyList()
n = int(raw_input())
for _ in xrange(n):
	line = raw_input()
	if line[0]=='i':
		myList.insert(line[7:])
	elif line[6]=='F':
		myList.deleteFirst()
	elif line[6]=='L':
		myList.deleteLast()
	else:
		myList.delete(line[7:])
myList.print_all()

### FIXED CODE ###

class MyList:
	head = tail = None

	def insert(self, x):
		n = [x, None, None]
		if self.head == None:
			self.head = self.tail = n
		else:
			n[2] = self.head
			self.head[1] = n
			self.head = n

	def delete(self, x):
		n = self.head
		while n and n[0] != x:
			n = n[2]
		if n: 
			self.__delete_node(n)

	def deleteFirst(self):
		self.__delete_node(self.head)

	def deleteLast(self):
		self.__delete_node(self.tail)

	def __delete_node(self, n):
		if n == self.head:
			self.head = n[2]
		if n == self.tail:
			self.tail = n[1]
		if n[1]:
			n[1][2] = n[2]
		if n[2]:
			n[2][1] = n[1]

	def print_all(self):
		n = self.head
		while n:
			print n[0],
			n = n[2]

myList = MyList()
n = int(raw_input())
for _ in xrange(n):
	line = raw_input()
	if line[0]=='i':
		myList.insert(line[7:])
	elif line[6]=='F':
		myList.deleteFirst()
	elif line[6]=='L':
		myList.deleteLast()
	else:
		myList.delete(line[7:])
myList.print_all()
### BUGGY CODE ###

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

A = list(map(lambda x: int(x), input().split(' ')))
A.sort(reverse=True)

for _ in range(M):
    A[0] = A[0] // 2
    for i in range(N-1):
        if A[i] < A[i+1]:
            A[i+1], A[i] = A[i:i+2]
        else:
            break

print('{}'.format(sum(A)))

### FIXED CODE ###

import heapq
 
N, M = list(map(int, input().split()))
A = input().split(" ")
neg_A = [-int(a) for a in A]
 
heapq.heapify(neg_A)
 
for t in range(M):
    heapq.heappush(neg_A, -(-heapq.heappop(neg_A)//2))
print(-sum(neg_A))
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
N = int(input())
a = list(map(int,input().split()))
dp = [[[0.0]*(N+1) for _ in range(N+1)] for _ in range(N+1)]
def rec(i,j,k):
    #global res
    if dp[i][j][k] > 0.0:
        return dp[i][j][k]
    if i == 0 and j == 0 and k == 0:
        return 0.0
    res = 0.0

    if i > 0.0: res += rec(i-1,j,k)*i
    if j > 0.0: res += rec(i+1,j-1,k)*j
    if k > 0.0: res += rec(i,j+1,k-1)*k
    res += N
    res *= 1.0/(i+j+k)
    dp[i][j][k] = res
    return res

one = a.count(1)
two = a.count(2)
three = a.count(3)

#print(dp)
print(rec(one,two,three))
#print(dp)


### FIXED CODE ###

N=int(input())
A=[int(i) for i in input().split()]
I,J,K=0,0,0
for a in A:
    if a==1:
        I+=1
    if a==2:
        J+=1
    if a==3:
        K+=1
L=I+J+K
M=J+K



dp=[[[0.0]*(K+1) for i in range(M+1)] for i in range(L+1)]
for n in range(1,L+1):
    for m in range(min(n,M)+1):#m=j+k
        for k in range(min(m,K)+1):
            j=m-k
            i=n-m
            #print(i,j,k)
            ret=N/(i+j+k)
            if i>0:
                ret+=dp[i-1][j][k]*(i/(i+j+k))
            if j>0:
                ret+=dp[i+1][j-1][k]*(j/(i+j+k))
            if k>0:
                ret+=dp[i][j+1][k-1]*(k/(i+j+k))
            dp[i][j][k]=ret
print(dp[I][J][K])
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

### FIXED CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

def cur(x):
    for i in neighbor[x]:
        ans[i]+=ans[x]
        neighbor[i].remove(x)
        cur(i)

n,q=map(int,input().split())
neighbor=[[]  for _ in range(n+1)]
parent=[-1]*(n+1)
ans=[0]*(n+1)
for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)


for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

cur(1)
for i in range(1,n):
    print(ans[i],end=" ")
print(ans[n])

### FIXED CODE ###

n,q=map(int,input().split())
neighbor=[[]  for _ in range(n+1)]
ans=[0]*(n+1)

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


for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

visit=[True]*(n+1)
tmp=[1]
for x in tmp:
    visit[x]=False
    for y in neighbor[x]:
        if visit[y]:
            tmp.append(y)
            ans[y]+=ans[x]

print(*ans[1:])
### BUGGY CODE ###

n = int(input())
ln = input()
sec_set = set()

for first in range(n):
    for second in range(first+1,n):
        for third in range(second+1,n):
            sec_set.add(ln[first]+ln[second]+ln[third])

print(len(sec_set))

### FIXED CODE ###

n = input()
ln = input()

n=int(n)
sec_set = set()

for i in range(10):
    first = ln.find(str(i))
    if first == -1:
        continue
    for j in range(10):
        second = ln[(first+1):].find(str(j))
        if second == -1:
            continue
        for k in range(10):
            third = ln[(first + second+2):].find(str(k))
            if third == -1:
                continue
            else:
                sec_set.add(str(i)+str(j)+str(k))
print(len(sec_set))
### BUGGY CODE ###

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


wv=[list(map(int, input().split())) for i in range(n)]
dp=[[0]*(w+1) for _ in range(n)]


for i in range(n):
    for j in range(w+1):
        if i==0:
            if j>=wv[i][0]:
                dp[i][j]=wv[i][1]
        else:
            if j< wv[i][0]:
                dp[i][j]=dp[i-1][j]
            else:
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wv[i][0]]+wv[i][1])



print(max(dp[-1]))


### FIXED CODE ###

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


wv=[list(map(int, input().split())) for i in range(n)]
dp=[[0]*(w+1) for _ in range(n)]


for i in range(n):
    for j in range(w+1):
        if i==0:
            if j>=wv[i][0]:
                dp[i][j]=wv[i][1]
        else:
            if j< wv[i][0]:
                dp[i][j]=dp[i-1][j]
            else:
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wv[i][0]]+wv[i][1])



print(dp[n-1][w])
### BUGGY CODE ###

n,m = map(int,input().split())
a = [input().rstrip() for i in range(n)]
b = list(zip(*a))
for i in range(m):
  b[i] = "".join(b[i])
ans = 0
for i in range(m-1):
  b1 = b[i]
  b2 = b[i+1]
  ct1 = [[0 for k in range(n-j+1)] for j in range(n+1)]
  ct2 = [[0 for k in range(n-j+1)] for j in range(n+1)]
  for j in range(n+1):
    for k in range(n-j):
      if b1[k+j] == b2[k]:
        ct1[j][k+1] += ct1[j][k]+1
      else:
        ct1[j][k+1] += ct1[j][k]
      if b2[k+j] == b1[k]:
        ct2[j][k+1] += ct2[j][k]+1
      else:
        ct2[j][k+1] += ct2[j][k]
  dp = [[10**6 for i in range(n+1)] for j in range(n+1)]
  dp[0][0] = 0
  for i in range(n+1):
    for j in range(n+1):
      if i <= j:
        cost = ct2[j-i][n-j]
      else:
        cost = ct1[i-j][n-i]
      if i < n:
        dp[i+1][j] = min(dp[i+1][j],dp[i][j]+cost)
      if j < n:
        dp[i][j+1] = min(dp[i][j+1],dp[i][j]+cost)
  ans += dp[-1][-1]
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
a = [input().rstrip() for i in range(n)]
b = list(zip(*a))
for i in range(m):
  b[i] = "".join(b[i])
ans = 0
ct1 = [[0 for k in range(n-j+1)] for j in range(n+1)]
ct2 = [[0 for k in range(n-j+1)] for j in range(n+1)]
dp = [[10**5 for i in range(n+1)] for j in range(n+1)]
for i in range(m-1):
  b1 = b[i]
  b2 = b[i+1]
  for j in range(n+1):
    ct1[j][0] = 0
    ct2[j][0] = 0
    for k in range(n-j):
      ct1[j][k+1] = ct1[j][k]
      ct2[j][k+1] = ct2[j][k]
      if b1[k+j] == b2[k]:
        ct1[j][k+1] += 1
      if b2[k+j] == b1[k]:
        ct2[j][k+1] += 1
  dp[0][0] = 0
  for i in range(n+1):
    if i < n:
      dp[i+1][0] = 10**6
    for j in range(n+1):
      if i == 0 and j < n:
        dp[i][j+1] = 10**6
      if i <= j:
        cost = ct2[j-i][n-j]
      else:
        cost = ct1[i-j][n-i]
      if j < n:
        dp[i][j+1] = min(dp[i][j+1],dp[i][j]+cost)
      if i < n:
        dp[i+1][j] = dp[i][j]+cost
  ans += dp[-1][-1]
print(ans)
### BUGGY CODE ###

n = int(input())
alist = sorted([int(input()) for _ in range(n)])[::-1]
blist = sorted([int(input()) for _ in range(n)])[::-1]

a = alist.pop()
b = blist.pop()
aset, bset = 0, 0
ans = 1
while len(alist) > 0 or len(blist) > 0:
  if a < b:
    if bset > 0:
      ans *= bset
      bset -= 1
    else:
      aset += 1
    if alist:
      a = alist.pop()
    else:
      a = pow(10, 9) + 7
  else:
    if aset > 0:
      ans *= aset
      aset -= 1
    else:
      bset += 1
    if blist:
      b = blist.pop()
    else:
      b = pow(10, 9) + 7
print(ans % (pow(10, 9) + 7))


### FIXED CODE ###

n = int(input())
alist = list(reversed(sorted([int(input()) for _ in range(n)])))
blist = list(reversed(sorted([int(input()) for _ in range(n)])))
INF = pow(10, 9) + 7
a = alist.pop()
b = blist.pop()
aset, bset = 0, 0
ans = 1
while len(alist) > 0 or len(blist) > 0:
  if a < b:
    if bset > 0:
      ans = (ans * bset) % INF
      bset -= 1
    else:
      aset += 1
    a = INF
    if len(alist) > 0:
      a = alist.pop()
  else:
    if aset > 0:
      ans = (ans * aset) % INF
      aset -= 1
    else:
      bset += 1
    b = INF
    if len(blist) > 0:
      b = blist.pop()
print(ans % INF)
### BUGGY CODE ###

from collections import deque
n,x,y = map(int,input().split())
route=[[10**10]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  q=deque([i])
  j=i
  route[i][j]=0
  while q:
    j=q.pop()
    if j == y:
      if route[i][j]+1 < route[i][x]:
        route[i][x]=route[i][j]+1
        q.append(x)
    if j == x:
      if route[i][j]+1 < route[i][y]:
        route[i][y]=route[i][j]+1
        q.append(y)
    if 1 < j:#-1
      if route[i][j]+1 < route[i][j-1]:
        route[i][j-1]=route[i][j]+1
        q.append(j-1)
    if j < n:#+1
      if route[i][j]+1 < route[i][j+1]:
        route[i][j+1]=route[i][j]+1
        q.append(j+1)
ans=[0]*(n+1)
for i in range(1,n+1):
  for j in range(i+1,n+1):
    ans[route[i][j]]+=1
for i in range(1,n):
  print(ans[i])


### FIXED CODE ###

import itertools
from collections import deque,Counter
n,x,y = map(int,input().split())
route=[[10**10]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  q=deque([i])
  j=i
  route[i][j]=0
  while q:
    j=q.pop()
    if j == y:
      if route[i][j]+1 < route[i][x]:
        route[i][x]=route[i][j]+1
        q.append(x)
    if j == x:
      if route[i][j]+1 < route[i][y]:
        route[i][y]=route[i][j]+1
        q.append(y)
    if 1 < j:#-1
      if route[i][j]+1 < route[i][j-1]:
        route[i][j-1]=route[i][j]+1
        q.append(j-1)
    if j < n:#+1
      if route[i][j]+1 < route[i][j+1]:
        route[i][j+1]=route[i][j]+1
        q.append(j+1)

ans=Counter(list(itertools.chain.from_iterable(route)))
for i in range(1,n):
  print(ans[i]//2)
### BUGGY CODE ###

s=input()
t=input()
S=[[] for i in range(len(s))]
T=[[] for i in range(len(t))]
c=0
d=0
for i in range(len(s)):
    if S[i]==[]:
        S[i]=[s.count(s[i])]
        c=s.count(s[i])
        for j in range(i,len(s)):
            if s[j]==s[i]:
                S[j]=[c]
for i in range(len(t)):
    if T[i]==[]:
        T[i]=[t.count(t[i])]
        d=t.count(t[i])
        for j in range(j,len(t)):
            if t[j]==t[i]:
                T[j]=[d]            
if S==T:
    print('Yes')
else:print('No')

### FIXED CODE ###

#アルファベットの1対1置換が存在すればYes
S=input()
T=input()
#dは、アルファベットの置換、置換は辞書で書く
d={}
#Sを順にみていって、d内になかったらSのi番目とdのi番目が置換関係にある
for i in range(len(S)):
    if S[i] not in d:
        d[S[i]]=T[i] 
    else:
      #1対1の置換でないと判明したらNoを出力
        if d[S[i]]!=T[i]:
            print('No')
            exit()
d={}
for i in range(len(T)):
    if T[i] not in d:
        d[T[i]]=S[i]
    else:
        if d[T[i]]!=S[i]:
            print('No')
            exit()
print('Yes')
### BUGGY CODE ###

#ABC061C
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(N):
    for _ in range(ab[i][1]):
        ans.append(ab[i][0])
ans.sort()
print(ans[K-1])

### FIXED CODE ###

#ABC061C
import sys
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
now = 0
ab.sort()
for a, b in ab:
    now += b
    if now >= K:
            print(a)
            sys.exit()
### BUGGY CODE ###

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

def lcs(s, t):
    ls, lt = len(s), len(t)
    dp = [[0] * (lt+1) for _ in range(ls+1)]
    for i in range(ls):
        for j in range(lt):
            #prev = dp[i+1][j+1]
            if s[i] == t[j]:
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])
    return dp[ls][lt]


ans = 0
for i in range(1, len(s)):
    l = lcs(s[:i], s[i:])
    ans = max(ans, l)
    #print(l, s[:i], s[i:])
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
"""
def lcs(s, t):
    ls, lt = len(s), len(t)
    dp = [[0] * (lt+1) for _ in range(ls+1)]
    for i in range(ls):
        for j in range(lt):
            #prev = dp[i+1][j+1]
            if s[i] == t[j]:
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])
    return dp[ls][lt]
"""
def z_algorithm(s):
    ls = len(s)
    Z = [0] * ls
    Z[0] = ls
    i, j = 1, 0
    while i < ls:
        while i + j < ls and s[j] == s[i+j]:
            j += 1
        Z[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < ls and k + Z[k] < j:
            Z[i + k] = Z[k]
            k += 1
        i += k
        j -= k
    return Z

ans = 0
for i in range(n):
    #print(s[i:])
    z = z_algorithm(s[i:])
    for j, zj in enumerate(z):
        if j+1 > zj:
            ans = max(ans, zj)
    #print(z)
print(ans)
### BUGGY CODE ###

n = int(input())
k = 0
A =input().split()
i = 1
k = 0
for a in A:
    if a in A[i:]:
        k = 1
        break
    else:
        i+=1
        pass
if k == 0:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

import numpy as np
n = int(input())
k = 0
A =[int(a) for a in input().split()]
A.sort()
A = np.array(A)
AC = [0]*n
AC = np.array(AC)
AC[1:] =A[:n-1]
AA = A - AC
if 0 in AA:
    print("NO")
elif A[n-2] == A[n-1]:
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

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

result = 1
for i in Ai:
	result *= i

if result > 10**18:
  result = '-1'

print(result)

### FIXED CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
    sys.exit()
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        sys.exit()
print(ans)