Harryxun/stf_run huggingface dataset:
N, M = list(map(int, input().split(' ')))
r = [ None for i in range(N) ]
duplicated = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None:
	duplicated = True
    break
  r[s-1] = c

if not duplicated:
  for i in range(N):
    if r[i] is None:
      r[i] = 0
  v = sum(r[i] * 10**i for i in range(N))
  print(v)
else:
  print(-1)


### FIXED CODE ###

N, M = list(map(int, input().split(' ')))
r = [ None for i in range(N) ]

illegal = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None and r[s-1] != c:
    illegal = True
    break
  r[s-1] = c

v = -1
if not illegal:
  for i in range(N):
    if r[i] is None:
      if i == 0 and N != 1:
        r[i] = 1
      else:
        r[i] = 0
  v = sum(r[i] * 10**(N-1-i) for i in range(N))
  if v < 10**(N-1) and not (N == 1 and v == 0):
    v = -1

print(v)
a,b=map(int,input().split())
X = int(a + b)
Y = int(a - b)
Z = int(a * b)
print(max[X,Y,Z])

### FIXED CODE ###

a,b=map(int,input().split())
X = int(a + b)
Y = int(a - b)
Z = int(a * b)
ans = [X,Y,Z]
print(max(ans))
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
b=[0]*(n-1)
def f(x,y):
    r=1
    for (i,j) in a[x]:
        if r==y:
            r+=1
        b[j]=r
        f(i,r)
        r+=1
f(0,0)
print(max(b))
for i in b:
    print(i)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)
from math import log2


def action(nums, start=0):
    if any([e % 2 == 0 for e in nums]):
        return max([action(convert(nums, i), start+1) for i, e in enumerate(nums) if e % 2 == 0])
    else:
        return start

def convert(nums, i):
    alt_nums = nums[:]
    alt_nums[i] = nums[i] // 2
    return alt_nums

def main():
    _n = int(input())
    nums = [int(x) for x in input().split()]

    print(action(nums))

if __name__ == '__main__':
    main()

### FIXED CODE ###

from math import log2


def action(n):
    count = 0
    while n % 2 == 0:
        n //= 2
        count += 1
    else:
        return count

def main():
    _n = int(input())
    nums = [int(x) for x in input().split()]

    print(sum([int(action(e)) for e in nums if e % 2 == 0]))

if __name__ == '__main__':
    main()
n, k = map(int, input().split())
a = list(map(int, input().split()))

# 各桁について、"1"の数が n // 2 以下だったら "1"、 そうでなければ "0"

from math import log2
num = int(log2(k))
box = [0] * (num + 1)
for i in a:
  l = bin(i)[2:][::-1]
  for itr, val in enumerate(l):
    box[itr] += int(val)

X = 0
for itr, val in enumerate(box[::-1]):
  if val <= n // 2 and X + 2 ** (num - itr) <= k:
    X += 2 ** (num - itr)

ans = 0
for i in a:
  ans += X ^ i
  
print(ans)
    

### FIXED CODE ###

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

# 各桁について、"1"の数が n // 2 以下だったら "1"、 そうでなければ "0"

from math import log2
num = int(log2(10**12) + 1)
box = [0] * (num + 1)
for i in a:
  l = bin(i)[2:][::-1]
  for itr, val in enumerate(l):
    box[itr] += int(val)

X = 0
for itr, val in enumerate(box[::-1]):
  if val <= n // 2 and X + 2 ** (num - itr) <= k:
    X += 2 ** (num - itr)

ans = 0
for i in a:
  ans += X ^ i
  
print(ans)
import sys

X,N = map(int,input().split())
P = list(map(int,input().split()))
if X < 1 or 100 < X:
    sys.exit()
if N < 0 or 100 < N:
    sys.exit()
if N == 0:
    print(X)
    sys.exit()

P_number = len(P)
if P_number < 1 or 100 < P_number:
    sys.exit()

res1 = 100
res2 = 100
res0 = 0
i = 0
j = 0
while i < N:
    if (X - i) not in P:
        res1 = (X - i)
    i += 1
while j < N:
    if (X + j) not in P:
        res2 = (X + j)
    j += 1
if res2 > res1:
    res0 = res1
elif res1 > res2:
    res0 = res2
elif res2 == res1:
    res0 = res1
print(res0+X)


### FIXED CODE ###

X = list(map(int, input().split()))
count = 1
for I in X:
  if I == 0:
    print(count)
    exit
  count += 1
s = int(input())
print("{0}:{1}:{2}".format(tuple(map(int, [s/3600, s%3600/60, s%60]))))

### FIXED CODE ###

s = int(input())
print("{0}:{1}:{2}".format(*map(int, [s/3600, s%3600/60, s%60])))
import numpy as np
n, w = list(map(int, input().split()))
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
dp = np.zeros((n + 1,w + 1))
for i in range(n):
    for j in range(w+1):
        if data[i][0] > j:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - data[i][0]] + data[i][1])
print(int(dp[n - 1][w]))

### FIXED CODE ###

n, W = list(map(int, input().split()))
w = [0 for i in range(n + 1)]
v = [0 for i in range(n + 1)]
for i in range(n):
    w[i + 1], v[i + 1] = list(map(int, input().split()))
dp = [[0 for i in range(W+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(1,W+1):
        if w[i] > j:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i])
print(int(dp[n][W]))
n=int(input())
alist = [int(i) for i in input().split()]
ans=0
 
for i in range(n-1):
	if alist[i]==i+1:
		temp=alist[i+1]
		alist[i+1]=alist[i]
		alist[i]=temp
		ans+=1
if alist[n-1]=n:
	ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
alist = [int(i) for i in input().split()]
ans=0
 
for i in range(n-1):
	if alist[i]==i+1:
		temp=alist[i+1]
		alist[i+1]=alist[i]
		alist[i]=temp
		ans+=1
if alist[n-1]==n:
	ans+=1
print(ans)
a,b,c = map(int, raw_input().split())
if a < b && b < c :
    print "Yes"
else
    print "No"

### FIXED CODE ###

a,b,c = map(int, raw_input().split())
if a < b < c :
    print "Yes"
else :
    print "No"
get = input()
for i in range(len(get)):
    print("x".end="")


### FIXED CODE ###


get = input()
print(''.join('x' for i in range(len(get))))
n,m,x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
anytassei = False

# bit = [0 for _ in range(n)]
mincost = 0
cost = 0
learn = [0 for _ in range(n)]
for i in range(n):
	mincost += ca[i][0]

for cnt in range(2**n):
	cost = 0
	learn = [0 for _ in range(n)]

	# bit膳探索
	for i in range(n):
		# bit[i] = (cnt//2**i)%2
		if (cnt//2**i)%2 == 1:
			cost += ca[i][0]
			for j in range(m):
				learn[j] += ca[i][1+j]
	# print(bit)

	# 理解度達成しているか判定
	tassei = True
	for j in range(m):
		if learn[j] < x: tassei = False

	# 達成している and 最小コスト更新している
	if tassei and cost <= mincost:
		mincost = cost
		anytassei = True

if anytassei: print(mincost)
else: print(-1)


### FIXED CODE ###

n,m,x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
anytassei = False

# bit = [0 for _ in range(n)]
mincost = 0
cost = 0
learn = [0 for _ in range(n)]
for i in range(n):
	mincost += ca[i][0]

for cnt in range(2**n):
	cost = 0
	learn = [0 for _ in range(m)]

	# bit膳探索
	for i in range(n):
		# bit[i] = (cnt//2**i)%2
		if (cnt//2**i)%2 == 1:
			cost += ca[i][0]
			for j in range(m):
				learn[j] += ca[i][1+j]
	# print(bit)

	# 理解度達成しているか判定
	tassei = True
	for j in range(m):
		if learn[j] < x: tassei = False

	# 達成している and 最小コスト更新している
	if tassei and cost <= mincost:
		mincost = cost
		anytassei = True

if anytassei: print(mincost)
else: print(-1)
import math
def nroot(a, n, x=1.0, eps=1e-7):
    while abs(a - x**n) > eps:
        x = ( (n-1)*x + a/(x**(n-1)) ) / n
    return x
a,b,c=map(int,input().split())



if math.sqrtl(a)+math.sqrtl(b) < math.sqrtl(c):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

a,b,c=map(int,input().split())
if a+b<c and 4*a*b<(c-a-b)**2:
    print("Yes")
else:
    print("No")
K, X = map(int, input())

print("Yes" if 500*K >= X else "No")


### FIXED CODE ###

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

print("Yes" if 500*K >= X else "No")
W,H,x,y,r = input().split()
w = int()
H = int()
x = int()
y = int()
r = int()
if x - r >= 0 and y - r >= 0 and x + r <= w and y + r <= h:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

w,h,x,y,r = input().split()
w = int(w)
h = int(h)
x = int(x)
y = int(y)
r = int(r)
if x - r >= 0 and y - r >= 0 and x + r <= w and y + r <= h:
    print("Yes")
else:
    print("No")
s=list(map(int,input().split()))
    print(s[0]-s[1]+1)

### FIXED CODE ###

N, i = [int(x) for x in input().split()]
print(N - i + 1)
n=int(input())
p = list(map(int, input().split()))
sort(p)
sum=0
for i in range(n):
  if i==n-1:
    sum+=p[i]/2
  else:
    sum+=p[i]
print(sum)


### FIXED CODE ###

n=int(input())
p = []
for _ in range(n):
    p.append(int(input()))
p.sort()
sum=0
for i in range(n):
  if i==n-1:
    sum=p[i]//2+sum
  else:
    sum=p[i]+sum
print(sum)
n, m, d = map(int, input().split())
if d == 0:
    print(f'{n * (m - 1) / (n * n):.10f}')
else:
    print(f'{2 * (n - d) * (m - 1) / (n * n):.10f}')


### FIXED CODE ###

n, m, d = map(int, input().split())
if d == 0:
    ans = n * (m - 1) / (n * n)
else:
    ans = 2 * (n - d) * (m - 1) / (n * n)
print('{0:.10f}'.format(ans))
a=input()
import math
print(math.factorial(n)%(10**9+7))

### FIXED CODE ###

import math
n=int(input())
print(math.factorial(n)%1000000007)
n = int(input())
edges = [[] for i in range(2*10**5)]
for i in range(n):
    xi, yi = map(int, input().split())
    xi -= 1
    yi = yi - 1 + 10**5
    edges[xi].append(yi)
    edges[yi].append(xi)

already = set([])
def dfs(x, y, node):
    if node in already:
        return x, y
    if node < 10**5:
        x += 1
    else:
        y += 1
    already.add(node)
    for next_node in edges[node]:
        x, y = dfs(x, y, next_node)
    return x, y

num = 0
for i in range(10**5):
    x, y = dfs(0, 0, i)
    num += x * y
print(num-n)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n = int(input())
edges = [[] for i in range(2*10**5)]
for i in range(n):
    xi, yi = map(int, input().split())
    xi -= 1
    yi = yi - 1 + 10**5
    edges[xi].append(yi)
    edges[yi].append(xi)

already = set([])
def dfs(x, y, node):
    if node in already:
        return x, y
    if node < 10**5:
        x += 1
    else:
        y += 1
    already.add(node)
    for next_node in edges[node]:
        x, y = dfs(x, y, next_node)
    return x, y

num = 0
for i in range(10**5):
    x, y = dfs(0, 0, i)
    num += x * y
print(num-n)
N = int(input())
ans = ''
while N > 0:
    N -= 1
    ans += chr(ord('a' + N % 26))
    N //= 26
print(ans[::-1])


### FIXED CODE ###

n = int(input())
ans = ''
i = 1
while n > 0 :
    x = n % 26
    if x != 0:
        ans += chr(x+96)
    else:
        ans += 'z'
        n -= 1
    n = n//26
print(ans[::-1])
N = int(input())
names_dic = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
FIRST = ('M', 'A', 'R', 'C', 'H')
for _ in range(N):
  nams = input()
  if name[0] in FIRST:
    names_dic[name[0]] += 1
ans = 0
for i in range(5):
  for j in range(i+1, 5):
    for k in range(j+1, 5):
      ans += names_dic[FIRST[i]]*names_dic[FIRST[j]]*names_dic[FIRST[k]]
print(ans)

### FIXED CODE ###

N = int(input())
names = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
FIRST = ('M', 'A', 'R', 'C', 'H')
for _ in range(N):
  name = input()
  if name[0] in FIRST:
    names[name[0]] += 1
ans = 0
for i in range(5):
  for j in range(i+1, 5):
    for k in range(j+1, 5):
      ans += names[FIRST[i]]*names[FIRST[j]]*names[FIRST[k]]
print(ans)
N = int(input())
e = list()
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)
# https://atcoder.jp/contests/abc145/tasks/abc145_d

X, Y = map(int, input().split())

if (2*Y- X) % 3 or (2*X- Y) % 3:
    print(0)
    exit()

x = (2*Y - X) // 3
y = (2*X - Y) // 3

n = x + y
r = x


mod = 10**9 + 7
f = 1
fac = [f]
for i in range(1, n + 1):
    f = f*i % mod
    fac.append(f)
f = pow(f, mod-2, mod)
facinv = [f]
for i in range(n, 0, -1):
    f = f*i % mod
    facinv.append(f)

print(fac[n] * facinv[r] * facinv[n - r] % mod)

### FIXED CODE ###

# https://atcoder.jp/contests/abc145/tasks/abc145_d


class Combination:                                      # 計算量は O(n_max + log(mod))
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):                     # 階乗(= n_max !)の逆元を生成
            f = f * i % mod                             # 動的計画法による階乗の高速計算
            fac.append(f)                               # fac は階乗のリスト
        f = pow(f, mod-2, mod)                          # 階乗から階乗の逆元を計算。フェルマーの小定理より、　a^-1 = a^(p-2) (mod p) if p = prime number and p and a are coprime
                                                        # python の pow 関数は自動的に mod の下での高速累乗を行ってくれる
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):                   # 上記の階乗の逆元から階乗の逆元のリストを生成（＝ facinv ）
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def C(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

X, Y = map(int, input().split())

if (2*Y- X) % 3 or (2*X- Y) % 3:
    print(0)
    exit()

x = (2*Y - X) // 3
y = (2*X - Y) // 3

n = x + y
r = x


mod = 10**9 + 7
f = 1
for i in range(1, n + 1):
    f = f*i % mod
fac = f
f = pow(f, mod-2, mod)
facinv = [f]
for i in range(n, 0, -1):
    f = f*i % mod
    facinv.append(f)
facinv.append(1)

comb = Combination(n)
print(comb.C(n,r))
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p=[int(j) for j in input().split()]
    l[p[1]-1].append(p[0]-1)

dp=[-1 for i in range(n+1)]
from functools import lru_cache
@lru_cache(maxsize=1000000)
def f(v):
    if dp[v]!=-1:
        return dp[v]
    p=0
    for i in l[v]:
        p=max(p,f(i)+1)
    dp[v]=p
    return dp[v]

for i in range(n):
    f(i)

print(max(dp))

### FIXED CODE ###

n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p=[int(j) for j in input().split()]
    l[p[1]-1].append(p[0]-1)

dp=[-1]*n
import sys
sys.setrecursionlimit(10**6)
def f(v):
    if dp[v]!=-1:
        return dp[v]
    p=0
    for i in l[v]:
        p=max(p,f(i)+1)
    dp[v]=p
    return dp[v]

for i in range(n):
    f(i)

print(max(dp))
from math import gcd
class SegmentTree(object):
    def __init__(self, sequence, function, identity):
        N = len(sequence)
        self.length = (1 << (N - 1)).bit_length()
        self.data = [identity] * (self.length << 1)
        self.function = function
        self.identity = identity
        for i in range(N):
            self.data[i + self.length - 1] = sequence[i]
        for i in range(self.length - 2, -1, -1) :
            self.data[i] = self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2])

    def update(self, idx, x):
        idx += self.length - 1
        self.data[idx] = x
        while idx:
            idx = (idx - 1) >> 1
            self.data[idx] = self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2])

    def query(self, p, q):
        if q <= p:
            return self.identity
        p += self.length - 1
        q += self.length - 2
        res = self.identity
        while q - p > 1:
            if not p & 1:
                res = self.function(res, self.data[p])
            if q & 1:
                res = self.function(res, self.data[q])
                q -= 1
            p >>= 1
            q = (q - 1) >> 1
        return self.function(res, self.data[p]) if p == q else self.function(self.function(res, self.data[p]), self.data[q])

N, *A = map(int, open(0).read().split())
seg_tree = SegmentTree(A, gcd, 0)
ans = 0
for i in range(N):
    seg_tree.update(i, 0)
    ans = max(ans, seg_tree.query(0, N))
    seg_tree.update(i, A[i])
print(ans)

### FIXED CODE ###

from fractions import gcd

n = int(input())
list_ = list(map(int, input().strip().split()))

gcd_from_left = [0]
gcd_from_right = [0]
for i in range(n):
    gcd_from_left.append(gcd(gcd_from_left[i], list_[i]))
    gcd_from_right.append(gcd(gcd_from_right[i], list_[-(i + 1)]))

gcd_from_left.insert(0, 0)
gcd_from_right.insert(0, 0)
gcd_from_right.reverse()

print(max(gcd(gcd_from_left[i], gcd_from_right[i]) for i in range(n + 2)))
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
xy = []
for _ in range(n):
    xy.append(tuple(list(li())))

consis = True    
odev = (xy[0][0] + xy[0][1]) % 2
for x,y in xy[1:]:
    if (x+y)%2 != odev:
        consis = False
        
if consis:
    m = 0
    if odev == 1:
        m = 39
    else:
        m = 40
        
    print(m)
    print(" ".join(["1" for _ in range(m)]))
    for x,y in xy:
        nomove = (m - (abs(x)+abs(y))) // 2
        ans = "RL"*nomove
        if x<0:
            ans = ans + "L"*abs(x)
        else:
            ans = ans + "R"*abs(x)
            
        if y<0:
            ans = ans + "D"*abs(y)
        else:
            ans = ans + "U"*abs(y)
            
        print(ans)

else:
    print(-1)

### FIXED CODE ###

import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
xy = []
for _ in range(n):
    xy.append(tuple(list(li())))

# 偶奇が一致しているか判定
consis = True    
odev = (xy[0][0] + xy[0][1]) % 2
for x,y in xy[1:]:
    if (x+y)%2 != odev:
        consis = False
        
if consis:
    # x+yが奇数なら2**31～2**0, x+yが偶数なら2**31～2**0,2**0の腕を用意
    m = 0
    if odev == 1:
        m = 32
        ds = [2**i for i in range(31,-1,-1)]
    else:
        m = 33
        ds = [2**i for i in range(31,-1,-1)] + [1]
        
    print(m)
    print(" ".join([str(d) for d in ds]))
    
    # それぞれのx,yをu-v座標に変換
    for x,y in xy:
        u = x+y
        v = x-y
        
        # res=0 から target=uに至るまでの足し算を考える
        us = []
        res = 0
        target = u
        for d in ds:
            if target > res:
                us.append(1)
                res += d
            else:
                us.append(-1)
                res -= d
           
        # res=0 から target=vに至るまでの足し算を考える
        vs = []
        res = 0
        target = v
        for d in ds:
            if target > res:
                vs.append(1)
                res += d
            else:
                vs.append(-1)
                res -= d
                
        # ( u, v) : command
        # (-1,-1) :   L
        # ( 1, 1) :   R
        # (-1, 1) :   D
        # ( 1,-1) :   U
        ans = []
        for u,v in zip(us, vs):
            if u==-1 and v==-1:
                ans.append("L")
            elif u==1 and v==1:
                ans.append("R")
            elif u==-1 and v==1:
                ans.append("D")
            elif u==1 and v==-1:
                ans.append("U")
            
        print("".join(ans))

else:
    print(-1)
A,B = input().split()
print(int(A) * float(B)*100)//100)


### FIXED CODE ###

A,B = input().split()
print(int(A) * int(float(B)*1000)//1000)
a = map(float, input().split())
print(f'{a * a * 3.1415926} {2 * a * 3.1415926}')



### FIXED CODE ###

r = float(input())
p = 3.141592653589
print(p*r*r, 2*p*r)
import itertools
def all_passwords(chars,length):
    b = []
    c= 0
    for i in itertools.product(int(chars), repeat=length):
        a = ''.join(i)
        b.append(a)
    return b
print (all_passwords(12,2))


### FIXED CODE ###

import math
a = int(input())
b = 0
for i in range(1,a+1):
    for j in range(1,a+1):
        c = math.gcd(i,j)
        for k in range(1,a+1):
            d = math.gcd(c,k)
            b +=d
print (b)
N = int(input())
A = list(map(int,input().split()))

c = [0]*3

a = 1

for i in A:
    a *= c.count(i)
    c[c.index(i)] += 1
    
print(a%1000000007)    

### FIXED CODE ###

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

c = [0]*3

a = 1

for i in A:
    if c.count(i) != 0:
        a *= c.count(i)
        c[c.index(i)] += 1
    
    else:
        print(0)
        break
else:
    print(a%1000000007)
N = int(input())

coords = [list(map(int, input().split(' '))) for _ in range(N)]

coords.sort(key=lambda x: x[2], reverse=True)

# 全探索
def search():
    for Cx in range(101):
        for Cy in range(101):
            x, y, h = coords[0]
            H = h + abs(Cx - x) + abs(Cy - y)
            for x, y, h in coords:
                if max(H - abs(Cx - x) - abs(Cy - y), 0) != h:
                    break
            else:
                return (Cx, Cy, H)

print("{} {} {}".format(search()))

### FIXED CODE ###

N = int(input())

coords = [list(map(int, input().split(' '))) for _ in range(N)]

coords.sort(key=lambda x: x[2], reverse=True)

# 全探索
def search():
    for Cx in range(101):
        for Cy in range(101):
            x, y, h = tuple(coords[0])
            H = h + abs(Cx - x) + abs(Cy - y)
            for x, y, h in coords:
                if max(H - abs(Cx - x) - abs(Cy - y), 0) != h:
                    break
            else:
                return Cx, Cy, H

x, y, h = search()
print("{} {} {}".format(x, y, h))
a,b,c=num(int,input().split())

print(c,a,b)

### FIXED CODE ###

num=input()
num=num.split()

print(num[2]+" "+num[0]+" "+num[1])
import fractions


def P(n, r):
    return fractions.factorial(n)//fractions.factorial(n-r)

def C(n, r):
    return P(n, r)//fractions.factorial(r)

n = int(input())
str_list = []
for i in range(n):
    str_list.append(list(sorted(input())))
str_list=sorted(str_list)
str_list.append("a")

ans=0
cnt=0
for i in range(n):
    if str_list[i]==str_list[i+1]:
        cnt+=1
    else:
        if cnt==1:
            ans+=1
            cnt = 0
        else:
            ans+=C(cnt+1,2)
            cnt=0

print(ans)


### FIXED CODE ###

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

n = int(input())
s = [''.join(sorted(input())).strip() for _ in range(n)]
c = Counter(s)
ans=sum(map(lambda x: x*(x-1)//2, c.values()))
print(ans)
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))

    is_break = False
    seen = []
    for a in A:
        if a not in seen:
            seen.append(a)
        else:
            is_break = True
            break:
    
    if is_break:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split(' ')))

    is_break = False
    seen = set()
    for a in A:
        if a not in seen:
            seen.add(a)
        else:
            is_break = True
            break
    
    if is_break:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    main()
a,b=map(int, input().split())
if (a+b)%2==1:
  print('IMPOSSIBLE')
else:
  print(int(a+b)/2))

### FIXED CODE ###

a,b=map(int, input().split())
if (a+b)%2==1:
  print('IMPOSSIBLE')
else:
  k=int((a+b)/2)
  print(k)