Harryxun/stf_run huggingface dataset:
from scipy.sparse.csgraph import csgraph_from_dense,dijkstra,floyd_warshall
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)
N,M,L =LI()
s = []
t = []
dp = [[inf] * (N) for _ in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    dp[a-1][b-1] = c
    dp[b-1][a-1] = c
Q = I()
for i in range(Q):
    a,b = LI()
    s.append(a-1)
    t.append(b-1)

for i in range(N):
    dp[i][i] = 0

#print(warshall_floyd(N,dp))
#d1 = [[0] * (N) for _ in range(N)]
#d1 = warshall_floyd(N,dp)
G = csgraph_from_dense(dp)
d1 = floyd_warshall(G)

newdp = [[inf] * (N) for _ in range(N)]
for i in range(N):
    for j in range(i+1,N):
        if d1[i][j]<=L:
            newdp[i][j] = 1
            newdp[j][i] = 1

for i in range(N):
    newdp[i][i] = 0
#print(newdp)
#print(warshall_floyd(N,newdp))
#d2 = [[0] * (N) for _ in range(N)]
#d2 = warshall_floyd(N,newdp)
G2 = csgraph_from_dense(newdp)
d2 = floyd_warshall(G2)

for i in range(Q):
    ans = d2[s[i]][t[i]]-1
    if ans!= inf:
        print(int(ans))
    else:
        print("-1")

### FIXED CODE ###

#################################
##ワーシャルフロイド法 n~3
#################################
def warshall_floyd(n,d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
##############################
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)
N,M,L =LI()
s = []
t = []
dp = [[inf] * (N) for _ in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    dp[a-1][b-1] = c
    dp[b-1][a-1] = c
Q = I()
for i in range(Q):
    a,b = LI()
    s.append(a-1)
    t.append(b-1)

for i in range(N):
    dp[i][i] = 0

#print(warshall_floyd(N,dp))
d1 = [[0] * (N) for _ in range(N)]
d1 = warshall_floyd(N,dp)

newdp = [[inf] * (N) for _ in range(N)]
for i in range(N):
    for j in range(i+1,N):
        if d1[i][j]<=L:
            newdp[i][j] = 1
            newdp[j][i] = 1

for i in range(N):
    newdp[i][i] = 0
#print(newdp)
#print(warshall_floyd(N,newdp))
d2 = [[0] * (N) for _ in range(N)]
d2 = warshall_floyd(N,newdp)

for i in range(Q):
    ans = d2[s[i]][t[i]]-1
    if ans!= inf:
        print(ans)
    else:
        print("-1")
n= int(input())

T=[[0 for j in range(13)]for m in range(4)]
format(T)

for i in range(n):
    a,b = input().split()
    b=int(b)
    
    if a=='S':
      T[0][b-1] = 1
    elif a=='H':
      T[1][b-1] = 1
    elif a=='C':
      T[2][b-1] = 1
    else:
      T[3][b-1] = 1

for j in range(4):
  for i in range (13):
    if T[j][i] == 0:
      if c==0:
        K = "S"
      elif c==1:
        K = "H"
      elif c==2:
        K = "C"
      else:
        K = "D"
    print(K,d+1)


### FIXED CODE ###

#ITP1_6_B


n= int(input())

T=[[0 for j in range(13)]for m in range(4)]
format(T)

for i in range(n):
    a,b = input().split()
    b=int(b)
    
    if a=='S':
      T[0][b-1] = 1
    elif a=='H':
      T[1][b-1] = 1
    elif a=='C':
      T[2][b-1] = 1
    else:
      T[3][b-1] = 1
for c in range(4):
  for d in range (13):
    if T[c][d] == 0:
      if c==0:
        K = "S"
      elif c==1:
        K = "H"
      elif c==2:
        K = "C"
      else:
        K = "D"
      print(K,d+1)
    else:
      pass
n = int(input())
l = [list() for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)

dep = [n]*n
def dfs(v,t,p):
  dep[v] = t
  for x in l[v]:
    if x == p:
      continue
    dfs(x,t+1,v)
  return

dfs(0,0,-1)
p = dep.index(max(dep))
dep = [n]*n
dfs(p,0,-1)
q = max(dep)-1
print("First" if q%3 else "Second") 

### FIXED CODE ###

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

def dfs(p):
  dep = [None]*n
  dep[p] = 0
  q = [p]
  while q:
    v = q.pop()
    for x in l[v]:
      if dep[x] is None:
        dep[x] = dep[v] + 1
        q.append(x)
  return dep
      
dep = dfs(0)
p = dep.index(max(dep))
dep = dfs(p)
q = max(dep)-1
print("First" if q%3 else "Second")
import heapq

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[[i,0] for i in range(1,m+1)]
arr.extend(arr2)
arr=sorted(arr,reverse=True,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
tmp=arr[0][0]
q=[]
ans=0
pos=0
while 1:
  a,b=arr[pos]
  if a>m:
    break
  if a==arr[pos+1][0]:
    heapq.heappush(q,-b)
  else:
    heapq.heappush(q,-b)
    ans-=heapq.heappop(q)
  pos+=1
print(ans)

### FIXED CODE ###

import heapq

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[[i,0] for i in range(1,m+5)]
arr.extend(arr2)
arr=sorted(arr,reverse=True,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
tmp=arr[0][0]
q=[]
ans=0
pos=0
while 1:
  a,b=arr[pos]
  if a>m:
    break
  if a==arr[pos+1][0]:
    heapq.heappush(q,-b)
  else:
    heapq.heappush(q,-b)
    ans-=heapq.heappop(q)
  pos+=1
print(ans)
n,m = map(int,input().split())
a_list = []
for i in range(m):
    a_list.append(int(input()))
    
mod = 1000000007

dp = [0]*n
dp[0] = 1
dp[1] = 1
if 1 in a_list:
    dp[0] = 0
if 2 in a_list:
    dp[1] = 0
for i in range(2,n):
    if (i+1) in a_list:
        continue
    else:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])

### FIXED CODE ###

n,m = map(int,input().split())
dp = [0]*n

for i in range(m):
    dp[int(input())-1] = 10**12
    
if dp[0] == 10**12:
    dp[0] = 0
else:
    dp[0] = 1

if n == 1:
    print(dp[0])
else:
    if dp[1] == 10**12:
        dp[1] = 0
    else:
        dp[1] = 1+ dp[0]

    mod = 1000000007

    for i in range(2,n):
        if dp[i] == 10**12:
            dp[i] = 0
        else:
            dp[i] = dp[i-1] + dp[i-2]
            dp[i] %= mod
    print(dp[-1])
a,b,k = input().strip().split
a,b,k = [int(a), int(b), int(k)]

if k < a:
	a = a-k
elif k >= a+b:
	a = 0
	b = 0
elif a+b > k > a:
	b = b-(k-a)
	a = 0

print('{} {}'.format(a,b))

### FIXED CODE ###

s,t = input().split()
print(t + s)
import sys
input = sys.stdin.readline
N,M=map(int, input().split())
L=[ [] for _ in range(N)]

X=[]
for _ in range(M):
    a,b = input().split()
    a=int(a)
    b=int(b)
    L[a-1].append(b)
    X.append({a:b})
Y=[ (sorted(L[_])) for _ in range(N) ]
for i in range(M) :
    for k,v in X[i].items():
        z='%06d' % 
        Z='%06d' % k
        print('%06d%06d' % (k,(Y[k-1].index(v)+1)))


### FIXED CODE ###

N,M = map(int,input().split())
L = []
for i in range(M):
    l = list(map(int,input().split()))+[i]
    L.append(l)
cnt = 0
tmp = []
M = sorted(L,key = lambda x: (x[0],x[1]))
for x in M:
    if tmp == x[0]:
        x.append(cnt+1)
        cnt += 1
    else:
        tmp = x[0]
        cnt = 0
        x.append(cnt)
M = sorted(L,key = lambda x:x[2])
#print(M)
for x in M:
    st = str(x[0]).zfill(6)
    st += str(x[3]+1).zfill(6)
    print(st)
n = int(input())

path = [[] for i in range(n)]

for _ in range(n-1):
    u,v,w = list(map(int,input().split()))
    path[u-1].append((v-1, w))
    path[v-1].append((u-1, w))

global dist
dist = [-1 for i in range(n)]
dist[0] = 0

def dfs(now):
    for v,w in path[now]:
        if dist[v] == -1:
            dist[v] = w + dist[now]
            dfs(v)
    
dfs(0)

for i in dist:
    print(i%2)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

n = int(input())

path = [[] for i in range(n)]

for _ in range(n-1):
    u,v,w = list(map(int,input().split()))
    path[u-1].append((v-1, w))
    path[v-1].append((u-1, w))

global dist
dist = [-1 for i in range(n)]
dist[0] = 0

def dfs(now):
    for v,w in path[now]:
        if dist[v] == -1:
            dist[v] = w + dist[now]
            dfs(v)
    
dfs(0)

for i in dist:
    print(i%2)
array= list(map(int,input().split()))
if a[1] - a[0] >d or a[2] - a[1] :
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b,c,d = map(int,input().split())
if abs(a-b) > d or abs(b-c)> d :
    if abs (a-c) >d:
        print('No')
    else:
        print('Yes')
else:
    print('Yes')
x = input()
a = []
a = map(int, raw_input().split())
b = []
d = {}
for i in range(len(a)):
    if a[i] in d:
        d[a[i]]+=1
    else:
        d[a[i]] = 1
g = []
for key in d:
    if d[key]>=2:
        b.append(key)
    if d[key]>=4:
        g.append(key)
b.sort()
g.sort()
if len(b)<2 and len(g) == 0:
    print 0
else:
    print max(b[len(b)-1]*b[len(b)-2], g[len(g)-1]*g[len(g)-1])

### FIXED CODE ###

x = input()
a = []
a = map(int, raw_input().split())
b = []
d = {}
for i in range(len(a)):
    if a[i] in d:
        d[a[i]]+=1
    else:
        d[a[i]] = 1
g = []
for key in d:
    if d[key]>=2:
        b.append(key)
    if d[key]>=4:
        g.append(key)
b.sort()
g.sort()
if len(b)<2 and len(g) == 0:
    print 0
else:
    if len(b)<2:
        b.append(0)
        b.append(0)
    if len(g)==0:
        g.append(0)
    print max(b[len(b)-1]*b[len(b)-2], g[len(g)-1]*g[len(g)-1])
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

for i in range(h):
  for j in range(w):
    if j > 0 and a[i][j-1] != "." and a[i][j] = "#":
      a[i][j] = "*"
    elif j < w - 1 and a[i][j+1] != "." and a[i][j] = "#":
      a[i][j] = "*"
    elif i > 0 and a[i-1][j] != "." and a[i][j] = "#":
      a[i][j] = "*"
    elif i < h - 1 and a[i+1][j] != "." and a[i][j] = "#":
      a[i][j] = "*"

print("No" if sum([row.count("#") for row in a]) else "Yes")


### FIXED CODE ###

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

for i in range(h):
  for j in range(w):
    if j > 0 and a[i][j-1] != "." and a[i][j] == "#":
      a[i][j] = "*"
    elif j < w - 1 and a[i][j+1] != "." and a[i][j] == "#":
      a[i][j] = "*"
    elif i > 0 and a[i-1][j] != "." and a[i][j] == "#":
      a[i][j] = "*"
    elif i < h - 1 and a[i+1][j] != "." and a[i][j] == "#":
      a[i][j] = "*"

print("No" if sum([row.count("#") for row in a]) else "Yes")
n = int(input())
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0

for i in range(n - 2):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
dp[n - 1] = min(dp[n - 1], dp[n - 2] + abs(h[n - 2] - h[i + 1]))
print(dp[n - 1])

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
inf = 10 ** 8 + 1
dp = [inf] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[n - 1])
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

K = int(stdin.readline().rstrip())
a = list(range(1,10))
b = []
attack = 100000
while attack > 0:
    go = a.pop(0)
    ue = go*10
    shimo = go%10
    b.append(go)
    if shimo == 0:
        a.append(ue)
        a.append(ue+1)
    elif shimo == 9:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
    else:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
        a.append(ue+shimo+1)
    attack -= 1

print(b[K-1])

### FIXED CODE ###

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

print(c,a,b)
a, b = map(int, input().split)
if (a * b) % 2 == 0:
  print("Even")
else:
  print("Odd")


### FIXED CODE ###

a, b = map(int, input().split())
if (a * b) % 2 == 0:
  print("Even")
else:
  print("Odd")
from fractions import gcd


a, b, c, d = map(int, input().split())
lcm = int(c * d / gcd(c, d))
A = a - 1
l_cd = A - A // c - A // d + A // lcm
r_cd = b - b // c - b // d + b // lcm
print(r_cd - l_cd)


### FIXED CODE ###

n, k = map(int, input().split())
s = input()
t = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        t += 1
print(min([n - 1, t + 2 * k]))
N,Q = map(int,input().split())
S = input()

for i in range(Q):
    lq,rq = map(int,input().split())
    s = S[lq-1:rq]
    count = 0
    while(s.find('A') != -1):
        j = s.find('A')
        if(s[j+1] == 'C'):
            count+=1
            s = s[j+2:]
        else:
            s = s[j+1:]
    print(count)



### FIXED CODE ###

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

for i in range(Q):
    lq,rq = map(int,input().split())
    s = S[lq-1:rq]
    count = 0
    while(s.find('A') != -1):
        j = s.find('A')
        if(s[j:j+2] == 'AC'):
            count+=1
            s = s[j+2:]
        else:
            s = s[j+1:]
    print(count)
"""
#愚直なやり方だとTLEになってしまう。
#累積和とよばれるテクニックを使う
#https://qiita.com/drken/items/56a6b68edef8fc605821#問題-3-atcoder-abc-122-c---get-ac

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

#区間配列
a = [0] * len(S)
#累積和配列
s = [0] * (len(S) +1)

#左がAである文字Cは何番目にあるか求める
for i in range(len(S)):
    if S[i] == 'C':
        if S[i-1] == 'A':
            a[i] = 1 #i番目に'AC'のCがある (添字が0から始まるため実際にはi-1番目 i番目は'A')

#累積和を計算する
for i in range(1,len(a)+1):
    s[i] = s[i-1] + a[i-1]

#区間内にその文字があるか求める

for i in range(Q):
    lq,rq = map(int,input().split())
    print(s[rq] - s[lq])
S = input()
count = 0
for i in range(i, len(S) - 4):
    for j in range(i+4, len(S)):
        if int(S[i:j]) // 2019 == 0:
            count += 1
print(count)

### FIXED CODE ###

S = input()
mod = 2019

cs_mods = {0:1}
cumsum = 0
count = 0
for i, s in enumerate(S[::-1]):
    cumsum = (cumsum + int(s) * pow(10, i, mod)) % mod
    cs_mods.setdefault(cumsum, 0)
    # count += cs_mods[cumsum]
    cs_mods[cumsum] += 1

# count = 0
for k, v in cs_mods.items():
    count += v*(v-1)//2

print(count)
n,h,w = list(map(int, input().split()))
cnt = 0
for i in range(n):
    a, b = list(map(int, input().split()))
    if a>=h and b>=w:
        cnt += 1
        
print(cnt)

### FIXED CODE ###

n,h,w = list(map(int, input().split()))
cnt = 0
for i in range(n):
    a, b = list(map(int, input().split()))
    if a>=h and b>=w:
        cnt += 1
        
print(cnt)
a,b=map(int,imput().split())
print(a//b+(1-int(a%b==0)))

### FIXED CODE ###

a,b=map(int,input().split())
print(a//b+(1-int(a%b==0)))
import sys
input = sys.stdin.readline
N = int(input())
node = [[0,i] for i in range(N)]
ab = []
neigh = [[0 for i in range(N)] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1
def dfs(neighbor,start,visited,c):
    global k
    if sum(visited) == N:
        return ans
    for i in range(N):
        if visited[i] == 0 and neighbor[start][i] == 1:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            dfs(neighbor,i,visited,c)

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1][0] += 1
    node[bi-1][0] += 1
    neigh[ai-1][bi-1] = 1
    neigh[bi-1][ai-1] = 1
    ab.append([ai-1,bi-1])
c = list(map(int,input().split()))
c.sort(reverse=True)
node.sort(key=lambda x:x[0],reverse=True)
m = max([node[i][0] for i in range(N)])
max_node = [node[i][1] for i in range(N) if node[i][0] == m]

nn = max_node[0]
can = 0
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn,visited,c)
ans2 = ' '.join([str(ans[i]) for i in range(N)])
print(sum(c)-max(c))
print(ans2)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            try:
                dfs(neighbor,i)
            except RuntimeError:
                flag = True
                return 0




m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn)
"""
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)
A = int(input())
B = int(input())

ans_tmp = (B-1)/(A-1)

if ans_tmp > 1 and ans_tmp < 2:
    print(int(ans_tmp) + 1)
elif ans_tmp < 1:
    print(1)
else:
    print(int(ans_tmp))

### FIXED CODE ###

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

ans = 0
outlet = 1

while outlet < B:
  outlet += A - 1
  ans += 1
  
print(ans)
n,m=map(int, input().split())
a=list(map(int, input().split()))

a.sort(reverse=True)

if a[m]<sum(a)/4/m:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

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

a.sort(reverse=True)
b=sum(a)/4/m
if a[m-1]<b:
    print('No')
else:
    print('Yes')
import sys
a,b,x = map(int,input().split())

def bisect(M,m):
    while(abs(M-m)>1):
        mid = (M+m)//2
        if a*mid + b*len(str(mid)) <= x:
            m = mid
        else:
            M = mid
            
    return m
print(bisect(10**9+1,0))

### FIXED CODE ###

s = input()
l = ['SUN','MON','TUE','WED','THU','FRI','SAT']
i = 7-l.index(s)
print(i)
a = []
while True:
    b = list(map(int,input().split()))
    if b[0] == "0" and b[1]=="0":
        break
    a.append(b.sort())


for i in a:
	print(i[0],i[1])

### FIXED CODE ###

a = []
while True:
	b = list(map(int,input().split()))
	if b[0] == 0 and b[1]==0:
		break
	b.sort()
	a.append(b)

for i in a:
	print(i[0],i[1])
def main():
    n , m = map(int, input().split())
    con = list(set([tuple(map(int, input().split())) for i in range(m)]))
    if (len(con) > n) or (n != 1 and con[0] == (1,0)):
        print(-1)
        return
    ans = 10**(n-1)
    tmp = -1
    for s,c in con:
        if (s == tmp):
            print(-1)
            return
        else:
            tmp = s
        if (s==1):
            ans += (c-1)*10**(n-1)
        else:
            ans += c*10**(n-s)
    print(ans)
main()   

### FIXED CODE ###

def main():
    n , m = map(int, input().split())
    con = list(set([tuple(map(int, input().split())) for i in range(m)]))
    if (len(con) > n) or (m != 0 and n != 1 and con[0] == (1,0)):
        print(-1)
        return
    if (n == 1 and m == 0):
        print(0)
        return
    ans = 10**(n-1)
    if (m == 0):
        print(ans)
        return
    tmp = -1
    for s,c in con:
        if (s == tmp):
            print(-1)
            return
        else:
            tmp = s
        if (s==1):
            ans += (c-1)*10**(n-1)
        else:
            ans += c*10**(n-s)
    print(ans)
main()
input = int(input())
nums = []
max = 0
total = 0
for x in range(input):
  nums.append(int(input()))
  if(input > max):
    max = input
  total += input
print(total-max + max/2)


### FIXED CODE ###

N = int(input())
p = []
for _ in range(N):
    p.append(int(input()))
 
pmax = max(p)
ans = int(sum(p)-pmax/2)
print(ans)
A, B = list(map(int, input()))

x = -1
for i in range(100):
  if (int(i*1.08) == A) and (int(i*1.1) == B):
    x = i
    break
  
print(x)

### FIXED CODE ###

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

x = -1
for i in range(10100):
  if (int(i*0.08) == A) and (int(i*0.1) == B):
    x = i
    break
  
print(x)
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

S = input()
ls = list(S)
ls = [int(x) for x in ls]
offset = 0
count = 0
while True:
    if ls[offset] == ls[offset +1]:
        del ls[offset:offset +2]
        count += 2
    elif offset +1 ==len(ls):
        break
    else:
        offset += 1

print(count)

### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

S = input()
ls = list(S)
ls = [int(x) for x in ls]

ans = min(ls.count(0),ls.count(1))
print(ans*2)
a,b,c,x=map(int,input().split())
i=0
for s in range(1,a+1):
    foe t in range(1,b+1):
         for r in range(1,c+1):
            if 500*a+100*b+50*c==x:
                i+=1
print(i)

### FIXED CODE ###

a,b,c,x=[int(input()) for i in range(4)]
i=0
for _ in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*_+100*j+50*k==x:
                i+=1
print(i)
a,b,c,x,y = map(int,input().split())
if x > y:
	z = a
else:
	z = b

ans1 = min(x,y) * min(a + b,c*2),abs(x-y) * z
ans2 = c * max(x,y)
print(min(ans1,ans2)

### FIXED CODE ###

a,b,c,x,y = map(int,input().split())
if x > y:
	z = a
else:
	z = b

ans1 = min(x,y) * min(a + b,c*2) + abs(x-y) * z
ans2 = c * max(x,y) * 2
print(min(ans1,ans2))
line = input()
A, B, C, K = [int(u) for u in line.split()]
u = max(A,B,C)
print(A+B+C+(2**K-1)*u)

### FIXED CODE ###

line = input()
numbers = [int(n) for n in line.split()]
numbers.sort()
K = int(input())
N = numbers[-1]
for _ in range(K):
    N*=2
for num in numbers[:2]:
    N+=num
print(N)
n = int(input())

ln = []

for i in range(1:10):
  for j in range(1:10):
    ln.append(i*j)
    
print("Yes" if n in ln else "No")

### FIXED CODE ###

n = int(input())

ln = []

for i in range(1,10):
  for j in range(1,10):
    ln.append(i*j)
    
print("Yes" if n in ln else "No")
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = int(input()).split()
  test[a] = b
  print(sum(test))

### FIXED CODE ###

a = input().split()

if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))
N, M = map(int, input().split())

# AB = [list(map(int, input().split)) for _ in range(M)]

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

ans = [-1] * N
visited = [0] * N

from collections import deque
queue = deque()

def bfs():
    queue.append(0)
    while len(queue) > 0:

        if all(visited):
            break
        now = queue.popleft()

        for c in nei_L[now]:
            if not visited[c]:
                ans[c] = now
                queue.append(c)
                visited[c] = 1

bfs()

if -1 in visited[1:]:
    print("No")
else:
    for i in range(N):
        if i == 0:
            print("Yes")
        else:
            print(ans[i] + 1)

### FIXED CODE ###

from collections import deque

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

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

ans = [-1] * N
queue = deque()


def bfs():
    queue.append(0)
    while queue:
        now = queue.popleft()

        for c in nei_L[now]:
            if ans[c] == -1:
                ans[c] = now
                queue.append(c)


bfs()

if -1 in ans[1:]:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)
n, m = map(int,input().split())

# sc = [list(map(int,input().split())) for _ in range(m)]

a = [""]*3
rep = []
ans = 0

for i in range(m):
    s,c = input().split()
    if s in rep:
        if c != a[int(s)-1]:
            ans = -1
    rep.append(s)
    a[int(s)-1] = c
    
print(a)

if ans == -1:
    print(ans)
else:
    if a[0] == "":
        if a[1] == "":
            print(int(a[2]))
        elif a[2]=="":
            a[2]="0"
            print("".join(a))
    else:
        if a[1] == "":
            print(0)
        elif a[2]=="":
            a[2]="0"
            print("".join(a))
            

### FIXED CODE ###

n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

ans = -1

for i in range(1000):
    s_i = str(i)
    if len(s_i) == n and all(int(s_i[s-1])==c for s,c in sc):
        ans = i
        break

print(ans)