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

import re

s = input()

def trans_word(text):
    replacements = {'01': '', '10': ''}
    return re.sub('({})'.format('|'.join(map(re.escape, replacements.keys()))), lambda m: replacements[m.group()], text)

ans = 0
flag = True

while flag:
    s_tmp = s
    s = trans_word(s)
    ans += (len(s_tmp) - len(s))
    flag = len(s_tmp) - len(s)

print(ans)

### FIXED CODE ###

import re

s = input()

c0, c1 = 0, 0
for i in s:
    if i=='0':
        c0 += 1
    else:
        c1 += 1

print(min(c0, c1)*2)

"""TLE
def trans_word(text):
    replacements = {'01': '', '10': ''}
    return re.sub('({})'.format('|'.join(map(re.escape, replacements.keys()))), lambda m: replacements[m.group()], text)

ans = 0
flag = True

while flag:
    s_tmp = s
    s = trans_word(s)
    ans += (len(s_tmp) - len(s))
    flag = len(s_tmp) - len(s)

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

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

CONV = [1]
ans = 0

for i in range(1, N):
  CONV.append(CONV[-1] * (N-i) // i)

for k in range(K+1):
  # M x (N-1)Ck x (M-1) ^ (N - 1 - k)
  ans += (CONV[k] * pow(M-1, N-1-k, MOD)) % MOD
  
print(ans * M % MOD)

### FIXED CODE ###

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

ans = 0

class combination():
    def __init__(self, n):
        self.fact = [1] * (n+1)
        self.ifact = [1] * (n+1)
        for i in range(1, n+1):
            self.fact[i] = self.fact[i-1]*i % MOD
        self.ifact[n] = pow(self.fact[n], MOD-2, MOD)
        for i in range(n, 0, -1):
            self.ifact[i-1] = self.ifact[i]*i % MOD
    def comb(self, n, k):
        if k < 0 or k > n: return 0
        comb = self.fact[n]*self.ifact[k]*self.ifact[n-k] %MOD
        return comb
comb = combination(N)

  
for k in range(K+1):
  # M x (N-1)Ck x (M-1) ^ (N - 1 - k)
  ans += (comb.comb(N-1, k) * pow(M-1, N-1-k, MOD)) % MOD
  
print(ans * M % MOD)
### BUGGY CODE ###

import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
BC = [list(map(int,input().split())) for _ in range(q)]
A = np.array(A)
 
def main(A,BC):
    for bc in BC:
      A = np.where(A==bc[0],bc[1],A)
      print(sum(A))
        
if __name__ == '__main__':
    main(A,BC)

### FIXED CODE ###

import numpy as np
from numba import njit

n = int(input())
A = list(map(int,input().split()))
q = int(input())
BC = [list(map(int,input().split())) for _ in range(q)]
A = np.array(A)

ans = sum(A)

#aの個数を管理するlist a_num
a_num = [0]*10**5
for  a in A:
    a_num[a-1]+=1

for bc in BC:
    change = bc[1]-bc[0]
    ans += change*a_num[bc[0]-1]
    a_num[bc[1]-1] += a_num[bc[0]-1]
    a_num[bc[0]-1] = 0
    print(ans)
### BUGGY CODE ###

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False


def main():
    R, G, B, N = map(float, input().split())
    cnt = 0

    for r in range(0, 3000 // int(R) + 1):
        for g in range(0, 3000 // int(G) + 1):
            b = (N - R * r - G * g) / B
            # print(b)
            if b >= 0 and is_integer_num(b):
                # print(r, g, b)
                cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False


def main():
    R, G, B, N = map(float, input().split())
    cnt = 0

    for r in range(0, 3000 // int(R) + 1):
        for g in range(0, 3000 // int(G) + 1):
            b = (N - R * r - G * g) / B
            # print(b)
            if b >= 0 and is_integer_num(b):
                # print(r, g, b)
                cnt += 1

    print(cnt)


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

def main():
    # n:人数, a:身長リスト
    n = int(input())
    a = list(map(int, input().split()))
    # Li=i+Ai, Ri=i-Aiを満たすL,Rを作成
    L = [(i+a[i]) for i in range(n)]
    R = [(i-a[i]) for i in range(n)]
    # Li=X=Rj,i<jを満たす組が存在する時count+=1
    count = 0
    for i,Li in enumerate(L):
        if (Li in R[(i+1):n]):
            count += len([idx for idx,x in enumerate(R[(i+1):n]) if x==Li])

    print(count)

main()


### FIXED CODE ###

from collections import Counter

def main():
    # n:人数, a:身長リスト
    n = int(input())
    a = list(map(int, input().split()))
    # Li=i+Ai, Ri=i-Aiを満たすL,Rを作成
    L = [0]*n
    R = [0]*n
    for i,ai in enumerate(a):
        L[i] = i+ai
        R[i] = i-ai
    # Li=X=Rj,i<jを満たす組が存在する時count+=1
    count = 0
    c = Counter(R)
    for Li in L:
        count += c.get(Li,0)

    print(count)

main()
### BUGGY CODE ###

N = int(input())
ls = [sorted(list(input())) for i in range(N)]

hoge = 0
for i in range(N):
    hoge += sum([1 if x==ls[i] else 0 for x in ls[i:len(ls)]]) - 1

print(hoge)

### FIXED CODE ###

N = int(input())
s = [''.join(sorted(input().rstrip())) for _ in range(N)]

memo = {}
for x in s:
    if x not in memo:
        memo[x] = 1
    else:
        memo[x] += 1

print(sum(x*(x-1)//2 for x in memo.values()))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    S=str(input())
    R=[]
    G=[]
    B=[]
    for i in range(N):
        if S[i]=='R':
            R.append(i)
        if S[i]=='G':
            G.append(i)
        if S[i]=='B':
            B.append(i)
    lr=len(R)
    lg=len(G)
    ans=lr*lg*(N-lr-lg)

    for i in R:
        for j in G:
            for k in B:
                L=sorted([i,j,k])
                if L[-1]-L[1]==L[1]-L[0]:
                    ans-=1
    print(ans)




resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    S=str(input())
    R=[]
    G=[]
    B=[]
    for i in range(N):
        if S[i]=='R':
            R.append(i)
        if S[i]=='G':
            G.append(i)
        if S[i]=='B':
            B.append(i)
    lr=len(R)
    lg=len(G)
    ans=lr*lg*(N-lr-lg)

    cnt=0
    for i in range(N):
        for j in range(i+1,N):
            k=2*j-i
            if k>=N:
                continue
            else:
                if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                    cnt+=1
    print(ans-cnt)




resolve()
### BUGGY CODE ###

import numpy as np

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = np.array(list(map(int, input().split(' '))))

counta = 0
for i in range(N):
    counta += np.all((P >= P[i])[:i+1])
print(counta)


### FIXED CODE ###

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = list(map(int, input().split(' ')))

p_min = P[0]
ans = 0
for p in P:
    if p <= p_min:
        p_min = p
        ans += 1
print(ans)
### BUGGY CODE ###

import collections

N = int(input())
cnt_dic = collections.defaultdict(int)

for _ in range(N):
  s = input()
  cnt_dic[s] += 1

cnt_dic = {k: v for k, v in cnt_dic.items() if v == max(cnt_dic.values())}

for s in sorted(cnt_dic.keys()):
  print(s)


### FIXED CODE ###

import collections

N = int(input())
cnt_dic = collections.defaultdict(int)

for _ in range(N):
  s = input()
  cnt_dic[s] += 1

max_v = max(cnt_dic.values())

ans_lis = [k for k, v in cnt_dic.items() if v == max_v]

for s in sorted(ans_lis):
  print(s)
### BUGGY CODE ###

N, point, Q = map(int, input().split())
ans = [int(input()) for i in range( Q)]
ans = [n-1 for n in ans]
participants = [i for i in range(N)]
points = [point for i in range(N)]

for i in ans:
    points = [n-1 for n in points]
    points[i] += 1

for i in range(N):
    if points[i] > 0:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

N, point, Q = map(int, input().split())
ans = [int(input()) for i in range(Q)]
ans = [n-1 for n in ans]
# participants = [i for i in range(N)]
points = [point for i in range(N)]

points = [n-len(ans) for n in points]

for i in ans:
    points[i] += 1

#print(N, point, Q, ans, points)

for i in range(N):
    if points[i] > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

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

import sys
sys.setrecursionlimit(10 ** 7)


class UnionFind:

    def __init__(self, n):
        # parent[x] < 0 means x is root and abs(parent[x]) == size[x]
        self.parent, self.depth = [-1] * (n + 1), [0] * (n + 1)

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)

        if self.depth[x] > self.depth[y]:
            self.parent[x] += self.parent[y]
            self.parent[y] = x
        else:
            self.parent[y] += self.parent[x]
            self.parent[x] = y
            if self.depth[x] == self.depth[y]:
                self.depth[y] += 1

    def count(self, x):
        return - self.parent[self.find(x)]


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

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

groups = UnionFind(N)
ans = [N * (N - 1) // 2]
for i in range(M):
    if groups.isSame(AB[i][0], AB[i][1]):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - groups.count(AB[i][0]) * groups.count(AB[i][1]))
        groups.unite(AB[i][0], AB[i][1])

for i in range(M):
    print(ans[::-1][i + 1])


### FIXED CODE ###

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

from scipy.misc import comb
import sys
sys.setrecursionlimit(1000000000)


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n + 1)]
        self.depth = [1] * (n + 1)
        self.count = [1] * (n + 1)

    def find(self, x):
        if self.parent[x] == x:
            if self.depth[x] > 2:
                self.depth[x] = 2
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            self.depth[x], self.count[x] = 0, 0
            return self.parent[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x, y = self.find(x), self.find(y)

        if self.depth[x] < self.depth[y]:
            self.parent[x] = self.parent[y]
            self.count[y] += self.count[x]
            self.depth[x], self.count[x] = 0, 0
        else:
            self.parent[y] = self.parent[x]
            self.count[x] += self.count[y]
            self.depth[y], self.count[y] = 0, 0
            if self.depth[x] == self.depth[y]:
                self.depth[x] += 1


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

A, B = [], []
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.reverse()
B.reverse()

groups = UnionFind(N)
ans = [comb(N, 2, exact=True)]
for i in range(M):
    tmp = ans[-1]
    if not groups.isSame(A[i], B[i]):
        nA, nB = groups.count[groups.find(
            A[i])], groups.count[groups.find(B[i])]
        tmp -= nA * nB
        groups.union(A[i], B[i])
    ans.append(tmp)

for i in range(M):
    print(ans[-(i + 2)])
### BUGGY CODE ###

N,K=map(int,input().split())
mod=7+10**9
ans=0
l=range(0,N+1)
for i in range(K,N+2):
    ans+=(sum(l[-(i%(N+1)):])-sum(l[:i])+1)%mod
print(ans%mod)



### FIXED CODE ###

N,K=map(int,input().split())
mod=7+10**9
ans=0
l=list(range(0,N+1))
for i in range(1,N+1):
    l[i]+=l[i-1]
for i in range(K,N+2):
    ans+=(l[-1]-l[-((1+i)%(N+2))]-l[i-1]+1)%mod
print(ans%mod)
### BUGGY CODE ###

from heapq import heappush,heappop
n,*t=map(int,open(0).read().split())
a=t[:n]
b=t[n:]
B=[]
for i,j in enumerate(b):heappush(B,(-j,i))
c=0
d=0
while B and d<10**7:
    d+=1
    y,i=heappop(B)
    x,z=b[(i-1)%n],b[(i+1)%n]
    t=(b[i]-a[i])//(x+z)
    b[i]-=t*(x+z)
    c+=t
    if b[i]>a[i]:
        heappush(B,(-b[i],i))
print([-1,c][a==b])

### FIXED CODE ###

from heapq import heappush,heappop
n,*t=map(int,open(0).read().split())
a=t[:n]
b=t[n:]
B=[]
for i,j in enumerate(b):heappush(B,(-j,i))
c=0
d=0
while B and d<2*10**6:
    d+=1
    y,i=heappop(B)
    x,z=b[(i-1)%n],b[(i+1)%n]
    t=(b[i]-a[i])//(x+z)
    b[i]-=t*(x+z)
    c+=t
    if b[i]>a[i]:
        heappush(B,(-b[i],i))
print([-1,c][a==b])
### BUGGY CODE ###

first_int = int(input())
secound_list = [int(k) for k in input().split()]

for k in range(first_int):
  if secound_list.count(secound_list[k]) >= 2:
    print('NO')
    break
  if k == first_int-1:
    print('YES')

### FIXED CODE ###

first_int = int(input())
secound_list = [int(k) for k in input().split()]

def has_duplicates(seq):
    return len(seq) != len(set(seq))

if has_duplicates(secound_list) == False:
  print('YES')
else:
  print('NO')
### BUGGY CODE ###

import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(25), 17)

    def test_2(self):
        self.assertEqual(think(1), 1)

    def test_3(self):
        self.assertEqual(think(100), 108)

    def test_4(self):
        self.assertEqual(think(2020), 40812)

    def test_5(self):
        self.assertEqual(think(200000), 400000008)


def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n):
    count = 0
    for i in range(1, n + 1):
        first_digit = first_digit_of(i)
        for j in range(first_digit, n + 1, 10):
            count += 1 if satisfies_condition(i, j) else 0
    return count


def write(result):
    print(result)


def satisfies_condition(a, b):
    str_a, str_b = str(a), str(b)
    return str_a[-1] == str_b[0]


def first_digit_of(a):
    return int(str(a)[0])


if __name__ == '__main__':
    # unittest.main()
    solve()

### FIXED CODE ###

import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(25), 17)

    def test_2(self):
        self.assertEqual(think(1), 1)

    def test_3(self):
        self.assertEqual(think(100), 108)

    def test_4(self):
        self.assertEqual(think(2020), 40812)

    def test_5(self):
        self.assertEqual(think(200000), 400000008)


def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n):
    count = 0
    dp = [[0 for last_digit in range(10)] for first_digit in range(10)]
    for i in range(1, n + 1):
        first_digit = first_digit_of(i)
        last_digit = last_digit_of(i)
        dp[first_digit][last_digit] += 1
    for first_digit in range(10):
        for last_digit in range(10):
            count += dp[first_digit][last_digit] * dp[last_digit][first_digit]
    return count


def write(result):
    print(result)


def first_digit_of(a):
    return int(str(a)[0])


def last_digit_of(a):
    return int(str(a)[-1])


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

from itertools import combinations
import numpy as np
n, k = map(int, input().split())
hs = []
for i in range(n):
    hs.append(int(input()))
print(min(np.array(list(map(max, list((combinations(hs, k)))))) - np.array(list(map(min, list((combinations(hs, k))))))))

### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
hs = []
for i in range(n):
    hs.append(int(input()))

if list(np.diff(hs)) == list(np.zeros(n-1, dtype=int)):
    print('0')
else:
    sorted_hs = np.sort(hs)
    try:
        print(min([min(np.diff(sorted_hs[i::k-1])) for i in range(k) if not len(sorted_hs[i::k-1]) == 1]))
    except:
        print('0')
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
b = [0] * n
twins = []
now = 1
while now <= a[-1]:
    now *= 2
    twins.append(now)
for i in range(len(a) - 1, 0, -1):
    tmpa = 0
    if b[i] != 0:
        continue
    for j in range(len(twins) - 1, -1, -1):
        if twins[j] <= a[i]:
            break
        tmpa = twins[j] - a[i]
    for j in range(i - 1, -1, -1):
        if a[j] == tmpa and b[j] == 0:
            b[i] = 1
            b[j] = 1
            break
        elif a[j] < tmpa:
            break
print(b.count(1) // 2)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
b = {}
for i in range(len(a)):
    if a[i] in b:
        b[a[i]] += 1
    else:
        b[a[i]] = 1
twins = []
now = 1
while now <= a[-1]:
    now *= 2
    twins.append(now)
for i in range(len(a) - 1, -1, -1):
    tmpa = 0
    if  b[a[i]] == 0:
        continue
    for j in range(len(twins) - 1, -1, -1):
        if twins[j] <= a[i]:
            break
        tmpa = twins[j] - a[i]
    if tmpa == a[i]:
        if b[tmpa] >= 2:
            b[tmpa] -= 2
    elif tmpa in b and b[tmpa] != 0:
        b[tmpa] -= 1
        b[a[i]] -= 1
countb = 0
for i in b:
    countb += b[i]
print((n - countb) // 2)
### BUGGY CODE ###

import collections
q=collections.deque()
h,w=map(int,input().split())
arr=[[] for _ in range(h+2)]
for i in range(w+2):
  arr[0].append(True)
for i in range(h):
  arr[i+1].append(True)
  for j in input():
    if j=='#':
      arr[i+1].append(True)
    else:
      arr[i+1].append(False)
  arr[i+1].append(True)
for i in range(w+2):
  arr[h+1].append(True)
dx=[-1,0,1,0]
dy=[0,-1,0,1]
for i in range(1,h+1):
  for j in range(1,w+1):
    if arr[i][j]:
      q.append([i,j,0])
while 1:
  y,x,cnt=q.popleft()
  for i in range(4):
    if not arr[y+dy[i]][x+dx[i]]:
      q.append([y+dy[i],x+dx[i],cnt+1])
      arr[y+dy[i]][x+dx[i]]=True
  if len(q)==0:
    print(cnt)
    break

### FIXED CODE ###

import collections
q=collections.deque()
h,w=map(int,input().split())
arr=[[] for _ in range(h+2)]
for i in range(w+2):
  arr[0].append('#')
for i in range(h):
  arr[i+1].append('#')
  for j in input():
    arr[i+1].append(j)
  arr[i+1].append('#')
for i in range(w+2):
  arr[h+1].append('#')
dx=[-1,0,1,0]
dy=[0,-1,0,1]
for i in range(1,h+1):
  for j in range(1,w+1):
    if arr[i][j]=='#':
      q.append([i,j,0])
while 1:
  y,x,cnt=q.popleft()
  for i in range(4):
    if arr[y+dy[i]][x+dx[i]]=='.':
      q.append([y+dy[i],x+dx[i],cnt+1])
      arr[y+dy[i]][x+dx[i]]='#'
  if len(q)==0:
    print(cnt)
    break
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

data = []
for i in range(M):
  a,b = IL()
  if a == 1:
    if b in data:
      print("POSSIBLE")
      break
    else:
      data.append(b)
  if b == N:
    if a in data:
      print("POSSIBLE")
      break
    else:
      data.append(a)
else:
  print("IMPOSSIBLE")


### FIXED CODE ###

import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

data = [0]*N
for i in range(M):
  a,b = IL()
  if a == 1:
    if data[b]==1:
      print("POSSIBLE")
      break
    else:
      data[b]=1
  if b == N:
    if data[a]==1:
      print("POSSIBLE")
      break
    else:
      data[a]=1
else:
  print("IMPOSSIBLE")
### BUGGY CODE ###

import numpy as np
inputs = open(0).readlines()

h, w, k = map(int, inputs[0].split())
cake = np.zeros((h, w), dtype=np.int)
count = 0
coords = {}
for i, s in enumerate(inputs[1:]):
    for j, c in enumerate(s):
        if c == '#':
            count += 1
            cake[i, j] = count
            coords[count] = (j, i)
            
for i in range(1, count+1):
    x, y = coords[i]
    x0, y0 = x-1, y-1
    x1, y1 = x+1, y+1
    while 0 <= x0 and cake[y, x0] == 0:
        cake[y, x0] = i
        x0 -= 1
    x0 += 1
    while x1 < w and cake[y, x1] == 0:
        cake[y, x1] = i
        x1 += 1
    while 0 <= y0 and np.all(cake[y0, x0:x1] == 0):
        cake[y0, x0:x1] = i
        y0 -= 1
    while y1 < h and np.all(cake[y1, x0:x1] == 0):
        cake[y1, x0:x1] = i
        y1 += 1

for rows in cake:
    print(*rows)

### FIXED CODE ###

import numpy as np
inputs = open(0).readlines()

def main(inputs):
    h, w, k = map(int, inputs[0].split())
    cake, count, coords = np.zeros((h, w), dtype=np.uint), 0, {}
    for i, s in enumerate(inputs[1:]):
        for j, c in enumerate(s):
            if c == '#':
                count += 1
                cake[i, j] = count
                coords[count] = (j, i)
    empty_rows = {i for i, rows in enumerate(cake) if not np.any(rows)}

    for i in range(1, count+1):
        x, y = coords[i]
        x0, y0 = x-1, y-1
        x1, y1 = x+1, y+1
        while 0 <= x0 and cake[y, x0] == 0:
            cake[y, x0] = i
            x0 -= 1
        x0 += 1
        while x1 < w and cake[y, x1] == 0:
            cake[y, x1] = i
            x1 += 1
        while 0 <= y0 and y0 in empty_rows:
            cake[y0, x0:x1] = i
            y0 -= 1
        while y1 < h and y1 in empty_rows:
            cake[y1, x0:x1] = i
            y1 += 1

    for rows in cake:
        print(*rows)

main(inputs)
### BUGGY CODE ###

mNM = map(int, input().split())
lNM = list(mNM)

mWay = [map(int, input().split()) for i in range(lNM[1])]
lWay = [list(mWay[i]) for i in range(lNM[1])]

maps = [-1 for i in range(lNM[0])]
deep = [-1 for i in range(lNM[0])]
ways = [[] for i in range(lNM[0])]

for i in range(lNM[1]):
    ways[lWay[i][0] - 1].append(lWay[i][1])
    ways[lWay[i][1] - 1].append(lWay[i][0])

maps[0] = 0
deep[0] = 0

for i in range(lNM[0]):
    try:
        index = [n for n, v in enumerate(deep) if v == i]
        for x in index:
            for w in ways[x]:
                if(deep[w - 1] == -1):
                    deep[w - 1] = i + 1
                    maps[w - 1] = x + 1
        
    except:
        pass
    
if(-1 in maps):
    print('No')
else:
    print('Yes')
    for i in maps[1:]:
        print(i)

### FIXED CODE ###

mNM = map(int, input().split())
lNM = list(mNM)

mWay = [map(int, input().split()) for i in range(lNM[1])]
lWay = [list(mWay[i]) for i in range(lNM[1])]

maps = [-1 for i in range(lNM[0])]
deep = [-1 for i in range(lNM[0])]
ways = [[] for i in range(lNM[0])]

for i in range(lNM[1]):
    ways[lWay[i][0] - 1].append(lWay[i][1])
    ways[lWay[i][1] - 1].append(lWay[i][0])

maps[0] = 0
deep[0] = 0
nexts = [0]

for i in range(lNM[0]):
    try:
        index = nexts     
        nexts = []
        
        for x in index:
            for w in ways[x]:
                if(deep[w - 1] == -1):
                    deep[w - 1] = i + 1
                    maps[w - 1] = x + 1
                    nexts.append(w - 1)
        
    except:
        pass
    
if(-1 in maps):
    print('No')
else:
    print('Yes')
    for i in maps[1:]:
        print(i)