Harryxun/stf_run huggingface dataset:
import numpy as np

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


class Node:
    def __init__(self, index):
        self.index = index
        self.leaf = set()
        self.score = 0

    def set_parent(self, parent):
        self.leaf.remove(parent)
        for l in self.leaf:
            tree[l].set_parent(self.index)

    def add_score(self, score):
        self.score += score
        for l in self.leaf:
            tree[l].add_score(score)


tree = {1: Node(1)}
tree[1].leaf.add(1)
for i in [tuple(map(int, input().split())) for _ in range(N-1)]:
    n1, n2 = i[0], i[1]
    if n1 not in tree:
        tree[n1] = Node(n1)
    if n2 not in tree:
        tree[n2] = Node(n2)
    tree[n1].leaf.add(n2)
    tree[n2].leaf.add(n1)

tree[1].set_parent(1)

for p, x in [tuple(map(int, input().split())) for _ in range(Q)]:
    tree[p].add_score(x)

print(' '.join([str(t.score) for t in tree.values()]))


### FIXED CODE ###

from collections import defaultdict

N, Q = map(int, input().split())
d = defaultdict(list)

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

c = defaultdict(int)

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

ans = [0 for i in range(N)]
que = [(1, 0, -1)]
while len(que) > 0:
    tmp = []
    for v, x, par in que:
        x += c[v]
        ans[v - 1] = str(x)
        for w in d[v]:
            if w != par:
                tmp.append((w, x, v))
    que = tmp

print(*ans)
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
stack1=deque(G[0])
stack2=deque(G[N-1])
X=[-1]*N
X[0]=1
X[N-1]=0
while(stack1 or stack2):
    Stack1=deque()
    for i in stack1:
        if X[i]==-1:
            X[i]=1
            for j in G[i]:
                if X[j]==-1:
                    Stack1.append(j)
    stack1=Stack1
    Stack2=deque()
    for i in stack2:
        if X[i]==-1:
            X[i]=0
            for j in G[i]:
                if X[j]==-1:
                    Stack2.append(j)
    stack2=Stack2
f,s=0,0
for i in range(N):
    if X[i]==1:
        f+=1
    else:
        s+=1
if f>s:
    print("Fennec")
else:
    print("Sunuke")


### FIXED CODE ###

from collections import deque
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
stack1=deque(G[0])
stack2=deque(G[N-1])
X=[-1]*N
X[0]=1
X[N-1]=0
while(stack1 or stack2):
    Stack1=deque()
    for i in stack1:
        if X[i]==-1:
            X[i]=1
            for j in G[i]:
                if X[j]==-1:
                    Stack1.append(j)
    stack1=Stack1
    Stack2=deque()
    for i in stack2:
        if X[i]==-1:
            X[i]=0
            for j in G[i]:
                if X[j]==-1:
                    Stack2.append(j)
    stack2=Stack2
f,s=0,0
for i in range(N):
    if X[i]==1:
        f+=1
    else:
        s+=1
if f>s:
    print("Fennec")
else:
    print("Snuke")
from operator import itemgetter
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
 
#print(listA)
 
listB = sorted(listA)
#print(listB)
listC = sorted(listB, key=itemgetter(1))
#print(listC)
flag = 0
time = 0
 
for i in range(N):
	time += listC[i][0]
	#print(time)
	listC.pop(0)
	if time > listC[i][1]:
		flag = 1
		break
 
if flag==0:
	print('Yes')
elif flag==1:
	print('No')

### FIXED CODE ###

from operator import itemgetter
import sys
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
 
#print(listA)
 
listB = sorted(listA)
la = sorted(listB, key=itemgetter(1))
 
t = 0
for i in range(N):
	s = la[i][1]
	t += la[i][0]
	if t > s:
		print("No")
		sys.exit()
 
print('Yes')
n, m = [int(x) for x in input().split()]
img_a = []
img_b = []

for i in range(n):
    img_a.append(input())

for i in range(m):
    img_b.append(input())

ans = "No"
for a in range(n - m + 1):
    dup_a = img_a.copy()
    dup_b = img_b.copy()
    while True:
        for b in range(m):
            if dup_b[b] in dup_a[b+a]:
                if b == 0:
                    index = dup_a[a].index(dup_b[0])
                current_index = dup_a[b+a].index(dup_b[b])
                
                if current_index > index:
                    for line in dup_a:
                        del line[:current_index]
                        break
                elif current_index < index:
                    for line in dup_a:
                        del line[:index]
                        break
        
            else:   # if not substring in string.
                break
        else: # if not loop broken.
            ans = "Yes"
            break
        if not dup_b[b] in dup_a[b+a]:
            break

print(ans)

### FIXED CODE ###

n, m = [int(x) for x in input().split()]
img_a = []
img_b = []

for i in range(n):
    img_a.append(input())

for i in range(m):
    img_b.append(input())

ans = "No"
for a in range(n - m + 1):
    border = 0
    flag = True
    while flag:
        for b in range(m):
            if img_b[b] in img_a[b+a][border:]:
                if b == 0:
                    index = img_a[a].index(img_b[0], border)
                current_index = img_a[b+a].index(img_b[b], border)
                if current_index == index:
                    continue
                elif current_index > index:
                    border = current_index
                    break
                else:
                    border = index
                    break
            else:   # if not substring in string.
                flag = False
                break

        else: # if not loop broken.
            ans = "Yes"
            break
        

print(ans)
def resolve():
  H, W = map(int, input().split(" "))
  s = []
  dp = [[0] * W for i in range(H)]
  for _ in range(W):
    s.append([x == "." for x in list(input())])

  for h in range(H):
    for w in range(W):
      if h == 0 and w == 0:
        if not s[0][0]:
          dp[0][0] = 1

      elif h == 0:
        dp[0][w] = dp[0][w-1]
        if s[0][w-1] and not s[0][w]:
          dp[0][w] += 1

      elif w == 0:
        dp[h][0] = dp[h-1][0]
        if s[h-1][0] and not s[h][0]:
          dp[h][0] += 1

      else:
        # 左側と上側を見て、操作回数が最小になるようにする。
        # 上だけをみる
        temp_up = dp[h-1][w]
        if s[h-1][w] and not s[h][w]:
          temp_up += 1

        # 左だけを見る
        temp_left = dp[h][w-1]
        if s[h][w-1] and not s[h][w]:
          temp_left += 1

        dp[h][w] = min(temp_up, temp_left)

  print(dp[H-1][W-1])
  
if __name__ == "__main__":
  resolve()

### FIXED CODE ###

def resolve():
  H, W = map(int, input().split(" "))
  s = []
  dp = [[0] * W for i in range(H)]
  for _ in range(H):
    s.append([x == "." for x in list(input())])

  for h in range(H):
    for w in range(W):
      if h == 0 and w == 0:
        if not s[0][0]:
          dp[0][0] = 1

      elif h == 0:
        dp[0][w] = dp[0][w-1]
        if s[0][w-1] and not s[0][w]:
          dp[0][w] += 1

      elif w == 0:
        dp[h][0] = dp[h-1][0]
        if s[h-1][0] and not s[h][0]:
          dp[h][0] += 1

      else:
        # 左側と上側を見て、操作回数が最小になるようにする。
        # 上だけをみる
        temp_up = dp[h-1][w]
        if s[h-1][w] and not s[h][w]:
          temp_up += 1

        # 左だけを見る
        temp_left = dp[h][w-1]
        if s[h][w-1] and not s[h][w]:
          temp_left += 1

        dp[h][w] = min(temp_up, temp_left)

  print(dp[H-1][W-1])

if __name__ == "__main__":
  resolve()
N = int(input())
score = 0

for i in range(N,0,-1):
    s = i
    c=0
    while (i % 2 == 0) :
        i /= 2
        c += 1
    if score < c:
        score = c
        ans = s
    #カウントが更新されたらスコア配列に格納
print(ans)
    
    
    
    

### FIXED CODE ###

N = int(input())
score = 0
ans = 0
if N == 1:
    print(1)
else:
    for i in range(N,0,-1):
        s = i
        c=0
        while (i % 2 == 0) :
            i /= 2
            c += 1
        if score < c:
            score = c
            ans = s
        #カウントが更新されたらスコア配列に格納
    print(ans)
from numba import jit
@jit
n,k=map(int,input().split())
h=list(map(int,input().split()))
cost=[0]
for i in range(1,n):
  wk=[]
  for j in range(1,min(k,i)+1):
    wk.append(cost[i-j]+abs(h[i]-h[i-j]))
  cost.append(min(wk))
print(cost[n-1])

### FIXED CODE ###

from numba import jit
n,k=map(int,input().split())
h=list(map(int,input().split()))
@jit
def jitcalc(n,k,h):
  cost=[0]
  for i in range(1,n):
    wk=[]
    for j in range(1,min(k,i)+1):
      wk.append(cost[i-j]+abs(h[i]-h[i-j]))
    cost.append(min(wk))
  print(cost[n-1])
jitcalc(n,k,h)
[n,m] = [int(i) for i in input().split()]
a=[]
import math
for i in range(1,math.floor(m**(1/2))):
    if m % i == 0 and i <= m//n:
        a.append(i)

print(a[len(a)-1])


### FIXED CODE ###

[n,m] = [int(i) for i in input().split()]
if n == 1:
    print(m)
else:
    ans = -1
    #a1は高々この値
    a1_max = m // n
    for i in range(a1_max,0,-1):
        if (m - i) % i == 0 and (m - i)//i >= (n-1):
            ans = max(ans,i)
    print(ans)
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

x = 0
for i in range(n):
    x += a[i]
    a[i] = x

x = 0
for i in range(m):
    x += b[i]
    b[i] = x

x = 0
for i in range(n):
    x = a[i]
    if x > k:
        x = a[i-1]
        ans = i
        j = i-1
        break
    if i + 1 == n:
        ans = n
        j = i

y = 0
for i in range(m):
    y = b[i]
    if x + y > k:
        while x + y > k and j != -1:
            x = b[j]
            j -= 1
    if x + y <= k:
        ans = max(ans,i+j+2)

print(ans)

### FIXED CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [0]*(n+1)
d = [0]*(m+1)
for i in range(n):
    c[i+1] = a[i]+c[i]
for i in range(m):
    d[i+1] = b[i]+d[i]
for i in range(m+1)[::-1]:
    if d[i] <= k:
        x = i
        break
ans = x
for i in range(1,n+1):
    while c[i] + d[x] > k:
        if x >= 1:
            x -= 1
        else:
            break
    if c[i] + d[x] <= k:
        ans = max(ans,i+x)
print(ans)
from itertools import combinations

N = int(input())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

A = factorize(N)

list = []
c = 1
for a in A:
    c *= a
    b = N // c
    maxi = max((len(str(b)), len(str(c))))
    list.append(maxi)

ans = min(list)

print(ans)

### FIXED CODE ###

from itertools import combinations

N = int(input())

def int_len(n):
    return len(str(n))

a = i = 1
list = []
while a <= N:
    if N % i == 0:
        b = N // i
        c = N // b
    list.append(max(int_len(b), int_len(b)))
    
    i += 1
    a = i ** 2

ans = min(list)
print(ans)
#Grid Repainting 2

#初期化
S = []
p = []
flag = True

#入力
H,W = map(int, input().split())
for i in range(W):
	s = input()
	s_list = list(s)
	S.append(s_list)

#枠外を白に塗りつぶす
for  i in range(H+2):
	p.append(".")

S.insert(0,p)
S.insert(W+1,p)

for i in range(1,W+1,1):
	S[i].insert(0,".")
	S[i].insert(H+2,".")

#計算
for i in range(1, W+1, 1):
	for j in range(1, H+1, 1):
		if S[i][j] == "#" and S[i+1][j] == "." and S[i][j+1] == "."  and S[i-1][j] == "." and S[i][j-1] == "." :
			flag = False
		#print("{}".format(S[i][j]))

#出力
if flag == True:
	print("Yes")

else:
	print("No")


### FIXED CODE ###

#Grid Repainting 2

#初期化
S = []
p = []
flag = True

#入力
H,W = map(int, input().split())
for i in range(H):
	s = input()
	s_list = list(s)
	S.append(s_list)

#計算
for i in range(0, H-1, 1):
	for j in range(0, W-1, 1):
		if S[i][j] == "#" and S[i+1][j] == "." and S[i][j+1] == "."  and S[i-1][j] == "." and S[i][j-1] == "." :
			flag = False
		

#出力
if flag == True:
	print("Yes")

else:
	print("No")
K, N = map(int, input().split())
A = list(map(int, input().split()))

diff = K + A[0] - A[-1]

for i in range(N-1):
    diff = max(diff , A[i+1]-A[i])

print(K-diff)


### FIXED CODE ###



s = input()

if s[2] == s[3] and s[4] == s[5]:
  print('Yes')
else:
  print('No')
import sys
def color(x):
  if x<400:return('灰')
  elif 399<x<800:return('茶')
  elif 799<x<1200:return('緑')
  elif 1199<x<1600:return('水')
  elif 1599<x<2000:return('青')
  elif 1999<x<2400:return('黄')
  elif 2399<x<2800:return('橙')
  elif 2799<x<3200:return('赤')
  else:return('*')
input()
l=list(map(int,input().split()))
l=[color(i) for i in l]
v=l.count('*')
l=len(set(l))
if v==0:
  print(' '.join([l]*2))
  sys.exit()
elif v>len(l):print(v,end=' ')
else: print(l,end=' ')
print(max(l+v,8))


### FIXED CODE ###

import sys
def color(x):
  if x<400:return('灰')
  elif 399<x<800:return('茶')
  elif 799<x<1200:return('緑')
  elif 1199<x<1600:return('水')
  elif 1599<x<2000:return('青')
  elif 1999<x<2400:return('黄')
  elif 2399<x<2800:return('橙')
  elif 2799<x<3200:return('赤')
  else:return('*')
input()
l=list(map(int,input().split()))
l=[color(i) for i in l]
v=l.count('*')
c=v==len(l)
l=len(set(l))
if v==0:
  print(' '.join([str(l)]*2))
  sys.exit()
else:
  if c:v-=1
  else:l-=1
  print(l,end=' ')
print(l+v)
import fractions
def lcm(a,b):
  return int(a*b/fractions.gcd(a,b))
N=int(input())
T=[int(input()) for i in range(N)]
ans=1
for i in range(N):
  ans=lcm(ans,T[i])
print(ans)

### FIXED CODE ###

import fractions
def lcm(a,b):
  return a*b//fractions.gcd(a,b)
N=int(input())
T=[int(input()) for i in range(N)]
ans=1
for i in range(N):
  ans=lcm(ans,T[i])
print(ans)
N, A, B = int(input())

print(N//(A+B)*B + max(N%(A+B)-A, 0))


### FIXED CODE ###

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

if A==B==0:
    print(0)
else:
    print(N//(A+B)*A + min(N%(A+B), A))
n,*a = map(int,open(0).read().split())
am = []
ap = []
amap = am.append
apap = ap.append
for i in a:
  if i >= 0:
    apap(i)
  else:
    amap(i)
ans = []
ansap = ans.append
while len(am + ap) >1:
  if ap == []:
    x = max(am)
    y = min(am)
    am.remove(x)
    am.remove(y)
    apap(x-y)
  elif am == []:
    x = min(ap)
    y = max(ap)
    ap.remove(x)
    ap.remove(y)
    amap(x-y)
  elif len(ap) > len(am):
    x = am.pop()
    y = ap.pop()
    amap(x-y)
  else:
    x = ap.pop()
    y = am.pop()
    apap(x-y)
  ansap(" ".join((str(x),str(y))))

print(ap[0])
for i in ans:
  print(i)

### FIXED CODE ###

n= int(input())
a = list(map(int,input().split()))
xy = []
xyap = xy.append
ap = max(a)
a.remove(ap)
am = min(a)
a.remove(am)
for i in a:
  if i>0:
    xyap((am,i))
    am -= i
  else:
    xyap((ap,i))
    ap -= i
xyap((ap,am))
print(ap-am)
for i in xy:
  print(*i)
import math

a, b = map(int, input().split())
x=a*b//(math.gcd(a,b))
print(x)

### FIXED CODE ###

import fractions

a, b = map(int, input().split())
x=a*b//(fractions.gcd(a,b))
print(x)
a,b=map(input().split())
if a==b:
    print(3)
elif a!=b:
    print(0)
elif a[0]=b[0] and a[1]=b[1] and a[2]!=b[2]:
    print(2)
elif a[0]=b[0] and a[1]!=b[1] and a[2]=b[2]:
    print(2)
elif a[0]!=b[0] and a[1]=b[1] and a[2]=b[2]:
    print(2)
else:
    print(1)  
     

### FIXED CODE ###

S=input()
T=input()
ans=0
for i in range(3):
 if S[i]==T[i]:
     ans+=1
print(ans)
n=int(input())
u=str(n)
t=len(u)
if t<4:
  print(1000-n)
else:
  k,p=u[0],u[1]
  if p!=0:
    print((k+1)*1000-n)
  else:
    print(0)

### FIXED CODE ###

n=input()
t=len(n)
if t<4:
  print(1000-int(n))
else:
  k=int(n[0])
  if int(n)>k*10**(t-1):
    print((k+1)*1000-int(n))
  else:
    print(0)
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = getList()

ans = A[0]
for i in range(1, N):
    ans = math.gcd(ans, A[i])
print(ans)

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = getList()

ans = A[0]
for i in range(1, N):
    ans = fractions.gcd(ans, A[i])
print(ans)
from collections import defaultdict

data = {}


def gcv(a, b):
    global data
    # if a >= b:
    #     a, b = b, a
    if data.get('{}:{}'.format(a, b), None):
        return data['{}:{}'.format(a, b)]
    elif data.get('{}:{}'.format(b, a), None):
        return data['{}:{}'.format(b, a)]

    if b == 0:
        data['{}:{}'.format(a, b)] = a
        return a
    else:
        # print(a, b)
        data['{}:{}'.format(a, b)] = gcv(b, a % b)

        return data['{}:{}'.format(a, b)]


def solve(n, a):
    if n == 2 and a[0] == a[1]:
        return a[0]
    n_dict = defaultdict(int)
    for i in range(len(a) - 1):
        for j in range(len(a) - i -  1):
            # print(i, j + i + 1)
            n_dict[gcv(a[i], a[j + i + 1])] += 1
    n_new = sorted(n_dict.items(), key=lambda x: x[1], reverse=True)
    if n_new[0][0] == 1:
        try:

            return n_new[1][0]
        except:
            return n_new[0][0]
    if n_new[1][1] == n-2:
        return n_new[1][0]
    return n_new[0][0]



def input_from_console():
    n = int(input())
    a = list(map(int, input().split()))
    return n, a


def main():
    n, a_list = input_from_console()
    print(solve(n, a_list))


if __name__ == "__main__":
    main()


### FIXED CODE ###


def gcd(a, b):
    if b == 0:
        return a
    elif a == 0:
        return b
    else:
        return gcd(b, a % b)


def solve(n, a):
    l, r = [], []
    l = [0 for i in range(n + 1)]
    r = [0 for i in range(n + 1)]
    r[n] = 0

    for i in range(0, n):
        if i == 0:
            l[0] = 0
        else:
            l[i] = gcd(l[i - 1], a[i - 1])

    for i in range(n, 0, -1):

        if i == n:
            r[i] = 0
        else:
            r[i] = gcd(r[i+1], a[i])
    m = 0
    for i in range(n):
        # print('m', m)
        m = max(m, gcd(l[i], r[i + 1]))
    return m


def input_from_console():
    n = int(input())
    a = list(map(int, input().split()))
    return n, a


def main():
    n, a_list = input_from_console()
    print(solve(n, a_list))


if __name__ == "__main__":
    main()
a ,b ,c = map(int(input().spilt()))
if a == b and a !=c:
    print("Yes")
elif b == c and b != c:
    print("Yes")
elif c == a and c != b:
    pritn("Yes")
else:
    print("No")

### FIXED CODE ###

a,b,c=map(int,input().split())
if a==b and a!=c:
  print('Yes')
elif a==c and a!=b:
  print('Yes')
elif b==c and b!=a:
  print('Yes')
else:
  print('No')
import math

a,b,x,y = list(map(int, input().split()))

z = x * y // math.gcd(x,y)

def num(u,v,k):
    ww=v//k - (u-1)//k
    return ww

print((b-a+1)-(num(a,b,x)+num(a,b,y)-num(a,b,z)))



### FIXED CODE ###

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

a,b,x,y = list(map(int, input().split()))

z = x * y // gcd(x,y)

def num(u,v,k):
    ww=v//k - (u-1)//k
    return ww

print((b-a+1)-(num(a,b,x)+num(a,b,y)-num(a,b,z)))
n = int(input())
a = list(map(int,input().split()))

ans = [1 for i in range(n+1)]; ans[0] = 0
for i in range(n+1):
    s = 0
    for j in range(i,n+1,i): s += ans[j]
    if (s - a[i-1])%2 == 0: pass
    else: ans[i] = 0

print(sum(ans))
anss = []
for i in range(n+1):
    if ans[i] == 1: anss.append(i)
print(*anss)




### FIXED CODE ###

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

ans = [0 for i in range(n+1)]
for i in range(n,0,-1):
    s = 0
    for j in range(i*2,n+1,i): s += ans[j]
    if (s - a[i-1])%2 == 0: pass
    else: ans[i] = 1

print(sum(ans))
anss = []
for i in range(n+1):
    if ans[i] == 1: anss.append(i)
print(*anss)
N, M = map(int, input().split())
s = []
c = []
num = [0] * N

def judge():
    for i in range(M):
        s1, c1 = map(int, input().split())
        s.append(s1)
        c.append(c1)

    for i in range(M):
        for j in range(M):
            if s[i] == s[j] and i != j and c[i] != c[j]:
                print(-1)
                return

    if N == 3:        
        for i in range(M):
            if s[i] - 1 < 0 or s[i] - 1 > 2:
                print(-1)
                return
            num[s[i] - 1] = c[i]
    elif N == 2:
        for i in range(M):
            if s[i] < 1 or s[i] > 2:
                print(-1)
                return
            num[s[i] - 1 + 1] = c[i]
    else:
        if s[i] != 2:
                print(-1)
                return
        num[s[i] - 1 + 2] = c[i] 



    if num[0] == 0:
        if num[1] == 0:
            if num[2] == 0:
                print(-1)
                return
            print(num[2])
        print("{0}{1}".format(num[1], num[2]))
        return
    else:
        print("{0}{1}{2}".format(num[0], num[1], num[2]))
        return

judge()


### FIXED CODE ###

N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

max_damage = max(damage for damage, cost in magic)
dp = [0] * (H + max_damage)

for x in range(1, H + max_damage):
    dp[x] = min(dp[x - damage] + cost for damage, cost in magic)

ans = min(dp[H:])

print(ans)


### FIXED CODE ###

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

ans = (H + (A - 1)) // A

print(ans)
import numpy as np

a, b, x = map(int, input().split())

bottom = 2 * x / a**2 - b
if bottom > 0:
    tan =  a / (b -  bottom)
    
else:
    bottom = 2 / (a * b) * x
    tan = bottom / b
    
theta = np.arctan(tan)
ret = 90 - np.rad2deg(theta)

print(ret)

### FIXED CODE ###

import numpy as np

a, b, x = map(int, input().split())

bottom = 2 * x / a**2 - b

if bottom == b:
    print(0)

else:    
    if bottom > 0:
        tan =  a / (b -  bottom)

    else:
        bottom = 2 / (a * b) * x
        tan = bottom / b

    theta = np.arctan(tan)
    ret = 90 - np.rad2deg(theta)

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

A.sort()
ans=0

if A[0]!=A[1]:
    ans=1

for i in range(1,N):
    if A[i]==A[i-1]:            
        continue
    for j in range(i):
        if A[i]%A[j]==0:
            break
        if j==i-1:
            ans+=1

print(ans)

### FIXED CODE ###

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

i=0

while True:
    if X-i in A and X+i in A:
        i+=1
    elif X-i in A:
        print(X+i)
        exit()
    else:
        print(X-i)
        exit()
D, N = map(int, input().split())
ans = 0
if N == 100 and D = 0:
	ans = pow(100, D + 1) + 1
elif N == 100 and D >= 1:
	ans = pow(100, D + 1) 
else:
	for i in range(1, N + 1):
			ans = pow(100, D) * i
print(ans)

### FIXED CODE ###

D, N = map(int, input().split())
ans = 0
if N == 100:
	ans = pow(100, D + 1) +  pow(100, D)
else:
	for i in range(1, N + 1):
			ans = pow(100, D) * i
print(ans)