Harryxun/stf_run huggingface dataset:
S = str(input())
s_len = len(S)
ans = [0 for _ in range(s_len)]

def L_checker(n):
    if n+1 == s_len:
        return s_len
    for i in range(n+1,s_len):
        if S[i]=='R':
            return i
    return s_len


def check(n, r_count):
    if S[n]=='R':
        check(n+1, r_count+1)
    else:
        next_r = L_checker(n)
        total = r_count+next_r-n
        if (total)%2==0:
            ans[n-1]=int((total)/2)
            ans[n]=int((total)/2)
        elif r_count%2==1:
            ans[n-1]=int((total)//2)+1
            ans[n]=int((total)//2)
        else:
            ans[n-1]=int((total)//2)
            ans[n]=int((total)//2)+1
        if next_r == s_len:
            print(*ans)
        else:
            check(next_r,0)

check(0,0)

### FIXED CODE ###

S = str(input())
s_len = len(S)
ans = [0 for _ in range(s_len)]
r_count = 0
l_count = 0
before = 0
switch = 'R'


for i in range(s_len):
    if S[i]==switch:
        if switch == 'R':
            r_count += 1
        else:
            l_count += 1
    else:
        if switch == 'L':
            switch = 'R'
            if (r_count+l_count)%2 == 0:
                ans[before] = (r_count+l_count)//2
                ans[before-1] = (r_count+l_count)//2
            elif r_count%2 == 0:
                ans[before] = (r_count+l_count)//2+1
                ans[before-1] = (r_count+l_count)//2
            else:
                ans[before] = (r_count+l_count)//2
                ans[before-1] = (r_count+l_count)//2+1
            r_count = 1
            l_count = 0
        else:
            switch = 'L'
            before = i
            l_count = 1


if (r_count+l_count)%2 == 0:
    ans[before] = (r_count+l_count)//2
    ans[before-1] = (r_count+l_count)//2
elif r_count%2 == 0:
    ans[before] = (r_count+l_count)//2+1
    ans[before-1] = (r_count+l_count)//2
else:
    ans[before] = (r_count+l_count)//2
    ans[before-1] = (r_count+l_count)//2+1

print(*ans)
import math
MOD = 10**9+7
x, y = map(int, input().split())
if (x+y)%3 != 0 or 3*x < x+y or 3*y < x+y:
    print(0)
    exit()
n = (x+y)//3
x -= n
y -= n
factN = 1
for i in range(1,n+1):
    factN *= i
    if i == x: factX = factN
    if i == y: factY = factN
c = factN // factX // factY
print(c%MOD)


### FIXED CODE ###

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

MOD = 10**9+7
x, y = map(int, input().split())
if (x+y)%3 != 0 or 3*x < x+y or 3*y < x+y:
    print(0)
    exit()
n = (x+y)//3
x -= n
y -= n
fact = [1, 1]
for i in range(2,n+1):
    fact.append(fact[i-1] * i % MOD)
factX = fact[x]
factY = fact[y]
factN = fact[n]
# print(x,y,n)
# print(factX,factY,factN)

c = factN * modinv(factX, MOD) * modinv(factY, MOD)
c %= MOD
print(c)
from math import sin,cos,pi
def main():
    #入力
    readline=stdin.readline
    A,B,H,M=map(int,readline().split())

    s=M*pi/30
    t=(H/6)*pi+(M/360)*pi
    x_A=A*sin(t)
    y_A=A*cos(t)

    x_B=B*sin(s)
    y_B=B*cos(s)

    print(((x_A-x_B)**2+(y_A-y_B)**2)**0.5)
if __name__=="__main__":
    main()

### FIXED CODE ###

from sys import stdin
from math import sin,cos,pi
def main():
    #入力
    readline=stdin.readline
    A,B,H,M=map(int,readline().split())

    s=M*pi/30
    t=(H/6)*pi+(M/360)*pi
    x_A=A*sin(t)
    y_A=A*cos(t)

    x_B=B*sin(s)
    y_B=B*cos(s)

    print(((x_A-x_B)**2+(y_A-y_B)**2)**0.5)
    
if __name__=="__main__":
    main()
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += (1 + p[i]) / 2

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print(f'{M:.12f}')


### FIXED CODE ###

n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += (1 + p[i]) / 2

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print('{:.12f}'.format(M))
(n, x) =  [int(i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    for a in range(1, n+1):
        for b in range(a+1, n+1):
            for c in range(b+1, n+1):
                if (a + b + c) == x:
                    count += 1
                elif (a + b + c) > x:
                    break
    print(count)
~                 

### FIXED CODE ###

while True:
    (n, x) =  [int(i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    for a in range(1, n+1):
        for b in range(a+1, n+1):
            for c in range(b+1, n+1):
                if (a + b + c) == x:
                    count += 1
                elif (a + b + c) > x:
                    break
    print(count)
"""everything has a cost!"""

from math import *
import random
import functools
import collections
import sys

__author__ = 'p7x'


# sys.stdin = open('in.txt', 'r')
# sys.stdout = open('out.txt', 'w')
# sys.stderr = open('err.txt', 'w')
    
i, j = 0, 0
n, m = 0, 0
a = []
b = []


# @functools.lru_cache(maxsize=None, typed=False)
def read(ti: int, tj: int) -> int:
    global n, m, i, j, a, b
    if (ti < n and (tj == m or a[ti] < b[tj])):
        return 1
    elif (tj < m and (ti == n or b[tj] < a[ti])):
        return 2
    elif (ti < n and tj < m and a[ti] == b[tj]):
        return read(ti+1, tj+1)
    else:
        if (ti == i and tj == j):
            return 3
        elif (ti == i):
            return 2
        else:
            return 1


if __name__ == '__main__':
    # global n, m, i, j, a, b
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    mins = 0
    while (mins < k):
        v = read(i, j)
        if (v == 1):
            mins += a[i]
            i += 1
        elif (v == 2):
            mins += b[j]
            j += 1
        else:
            break
    if mins > k:
        print(i+j-1)
    else:
        print(i+j)


### FIXED CODE ###

"""everything has a cost!"""

from math import *
import random, functools, collections, sys

__author__ = 'p7x'


# sys.stdin = open('in.txt', 'r')
# sys.stdout = open('out.txt', 'w')
# sys.stderr = open('err.txt', 'w')


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

    for i in range(1,len(a)):
        a[i] += a[i-1]
    for i in range(1,len(b)):
        b[i] += b[i-1]

    j = len(b)-1
    while j > -1 and b[j] > k:
        j -= 1
    ans = j+1
    i = len(a)-1
    while i > -1 and a[i] > k:
        i -= 1
    ans = max(i+1,ans)

    for inx in range(i+1):
        while j > -1 and a[inx] + b[j] > k:
            j -= 1
        ans = max(inx+j+2,ans)
    print(ans)
n = int(input())
a = input().split(" ")
order = ""
j = 1
for i in a:
  b = {j=>i}
print(b)
'''  
order.rstrip()
print(order)  
'''

### FIXED CODE ###

import numpy as np
n = int(input())
a = list(map(int,input().split(" ")))
b = [0]*n
order = ""
for i in range(n):
	b[a[i]-1]= i+1
for i in b:
  order += str(i) + " "
order.rstrip
print(order)
#include <bits/stdc++.h>
#include <algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }

  int INF = pow(10, 9);

  vector<int> dp(N, INF);
  dp[0] = 0;
  
  for (int j = 1; j < N; j++) {
  	for (int i = max(0, j - K); i < j; i++) {
        dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
    }
  }
  cout << dp[N - 1] << endl;
}


### FIXED CODE ###

INF = 10 ** 10

N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [INF for _ in range(N)]
dp[0] = 0
# 0-indexed

for i in range(1, N):
    for k in range(1, K + 1):
        if i - k >= 0:
            dp[i] = min(dp[i], dp[i - k] + abs(h[i] - h[i - k]))

print(dp[N - 1])
s = str(input())
m = abs(753,s[0]*100+s[1]*10+s[2])
for i in range(1,len(s)-2):
  a = s[i]*100+s[i+1]*10+s[i+2]
  m = min(m,abs(753,a))
  
print(m)
  


### FIXED CODE ###

s = str(input())
m = abs(753-int(s[0])*100-int(s[1])*10-int(s[2]))
for i in range(1,len(s)-2):
  a = int(s[i])*100+int(s[i+1])*10+int(s[i+2])
  m = min(m,abs(753-a))
  
print(m)
N = int(input())
d = []
d.append([])
d.append([".",",","!","?"])
d.append(["a","b","c"])
d.append(["d","e","f"])
d.append(["g","h","i"])
d.append(["j","k","l"])
d.append(["m","n","o"])
d.append(["p","q","r","s"])
d.append(["t","u","v"])
d.append(["w","x","y","z"])
for _ in range(N):
    nn = input()
    output = ""
    b = 0
    c = 0
    for n in nn:
        n = int(n)
        if n == 0:
            output += d[b][c]
            c = 0
        b = n
            


### FIXED CODE ###

def solve(mm, cmd):
	bf = cmd[0]
	c = 0
	ans = ""
	for s in cmd[1::]:
			if bf == s:
				c += 1
			else:
				if s == '0':
					ans += mm[bf][c%len(mm[bf])]
				c = 0
				bf = s
	return ans

def main():
	N = int(input())
	cc = [
		[".",",","!","?"," "],
		["a","b","c"],
		["d","e","f"],
		["g","h","i"],
		["j","k","l"],
		["m","n","o"],
		["p","q","r","s"],
		["t","u","v"],
		["w","x","y","z"]]
	mm = dict(zip(
		[str(i) for i in range(1,10)],
		cc
	))
	for _ in range(N):
		cmd = input()
		print(solve(mm,cmd))

if __name__ == '__main__':
	main()
a=int(input())

if a == 7 or a == 5 or a == 3:
  pritn("YES")
else:
  print("NO")

### FIXED CODE ###

a=int(input())
 
if a == 7 or a == 5 or a == 3:
  print("YES")
else:
  print("NO")
import sys
[Alice, Bob] = sys.argv[1].split()
if Alice == Bob:
	print 'Draw'
	return 0
if Alice == '1':
	print 'Alice'
	return 0
if Bob == '1':
	print 'Bob'
	return 0
if int(Alice) < int(Bob):
	print 'Bob'
else:
	print 'Alice'

### FIXED CODE ###

import sys
[Alice, Bob] = sys.stdin.readline().split()
if Alice == Bob:
	print('Draw')
	sys.exit()
if Alice == '1':
	print('Alice')
	sys.exit()
if Bob == '1':
	print('Bob')
	sys.exit()
if int(Alice) < int(Bob):
	print('Bob')
else:
	print('Alice')
def dfs(string):
    can = ["dream", "dreamer", "erase", "eraser"]
    stack = []
    stack.append("dream")
    stack.append("dreamer")
    stack.append("erase")
    stack.append("eraser")
    while stack:
        judge = stack.pop()
        if judge == string:break
        for temp in can:
            ans = judge + temp
            print(ans)
            if ans == string[:len(ans)]:
                stack.append(ans)
    return "YES" if judge == string else "NO"

if __name__ == '__main__':
    s = input()
    print(dfs(s))

### FIXED CODE ###

def judge(s):
    flag = True
    s = s[::-1]
    ans = ""
    pivot = 0
    while pivot < len(s):
        if s[pivot] == "m":
            ans += "maerd"
            pivot += 5
        elif s[pivot] == "e":
            ans += "esare"
            pivot += 5
        elif s[pivot:pivot+3] == "rem":
            ans += "remaerd"
            pivot += 7
        elif s[pivot:pivot+3] == "res":
            ans += "resare"
            pivot += 6
        else:
            flag = False
            break
    if flag == False:
        return "NO"
    elif s == ans:
        return "YES"
    else:
        return "NO"

if __name__ == '__main__':
    s = input()
    print(judge(s))
def CanIGetEnoughSkills(SkillPoints,M,X):
    for _ in range(M):
        if SkillPoints[_]<X:
            return False
        else:
            pass
    return True


N,M,X=map(int(input()).split())
books=[input() for _ in range (N)]

BookCost=[]
GetSkillPoints=[]
for i in range (N):
    BookCost.append(books[i][0])
    GetSkillPoints.append(books[i][1:])

temp_cost=10**9

for Cart in range (2**len(GetSkillPoints)):
    TotalCost=0
    SkillPoints=[0]*M

    for book in range(len(GetSkillPoints)):
        if (Cart>>book)&1==0:
            continue
        TotalCost+= BookCost[book]
        for skillelement in range(M):
            SkillPoints[skillelement]+=GetSkillPoints[book][skillelement]

    # print(TotalCost,SkillPoints)
    if CanIGetEnoughSkills(SkillPoints,M,X)== True:
        temp_cost=min(temp_cost,TotalCost)

Answer=temp_cost
if Answer==10**9:
    Answer=-1
    
print(Answer)

### FIXED CODE ###

def CanIGetEnoughSkills(SkillPoints,M,X):
    for _ in range(M):
        if SkillPoints[_]<X:
            return False
        else:
            pass
    return True


N,M,X=map(int,input().split())
books=[]
for n in range(N):
    array= list(map(int,input().split()))
    books.append(array)
# print(books)

BookCost=[]
GetSkillPoints=[]
for i in range (N):
    BookCost.append(int(books[i][0]))
    GetSkillPoints.append(books[i][1:])

temp_cost=10**9

for Cart in range (2**len(GetSkillPoints)):
    TotalCost=0
    SkillPoints=[0]*M
    
    for book in range(len(GetSkillPoints)):
        if (Cart>>book)&1==0:
            continue
        TotalCost+= BookCost[book]
        for skillelement in range(M):
            SkillPoints[skillelement]+=GetSkillPoints[book][skillelement]

    # print(TotalCost,SkillPoints)
    if CanIGetEnoughSkills(SkillPoints,M,X)== True:
        temp_cost=min(temp_cost,TotalCost)

Answer=temp_cost
if Answer==10**9:
    Answer=-1
    
print(Answer)
# AtCoder Beginner Contest 157
# E - Simple String Queries
# https://atcoder.jp/contests/abc157/tasks/abc157_e
from bisect import bisect_left, insort_left
import sys
input = sys.stdin.readline
OFS = ord('a')
_ = input()
S = list(input()[:-1])

D = [[] for _ in [0]*26]
for i, s in enumerate(S):
    D[s].append(i)

for _ in [0]*int(input()):
    Q = input()[:-1].split()
    if Q[0] == '1':
        i, c = int(Q[1])-1, Q[2]

        D[s].pop(bisect_left(D[S[i]], i))
        insort_left(D[ord(c)-OFS], i)
        S[i] = c

    else:
        l, r = int(Q[1])-1, int(Q[2])-1

        cnt = 0
        for L in D:
            i = bisect_left(L, l)
            if i < len(L) and L[i] <= r:
                cnt += 1

        print(cnt)


### FIXED CODE ###

# AtCoder Beginner Contest 157
# E - Simple String Queries
# https://atcoder.jp/contests/abc157/tasks/abc157_e
from bisect import bisect_left, insort_left
import sys
input = sys.stdin.readline
OFS = ord('a')
_ = input()
S = list(input()[:-1])

D = [[] for _ in [0]*26]
for i, s in enumerate(S):
    D[ord(s)-OFS].append(i)

for _ in [0]*int(input()):
    Q = input()[:-1].split()
    if Q[0] == '1':
        i, c = int(Q[1])-1, Q[2]

        if S[i] != c:
            s = ord(S[i])-OFS
            D[s].pop(bisect_left(D[s], i))
            insort_left(D[ord(c)-OFS], i)
            S[i] = c

    else:
        l, r = int(Q[1])-1, int(Q[2])-1

        cnt = 0
        for L in D:
            i = bisect_left(L, l)
            if i < len(L) and L[i] <= r:
                cnt += 1

        print(cnt)
n1 = int(input())

n2 = [int(i) for i in input().split()]

n3 = []
n4 = []
for i1 in range(n1):
    if i1 % 2 == 0:
        n3.append(n2[i1])
    else:
        n4.append(n2[i1])

n3.sort()
n4.sort()

t1 = 0
c1 = 0
n5 = []

for i2 in range(len(n3)):
    if n3[i2] == t1:
        c1 += 1
        if i2 == len(n3) - 1:
            n5.append([t1, c1])
    else:
        if i2 != 0:
            n5.append([t1, c1])
        t1 = n3[i2]
        c1 = 1
        if i2 == len(n3) - 1:
            n5.append([t1, c1])

t1 = 0
c1 = 0
n6 = []
for i3 in range(len(n4)):
    if n4[i3] == t1:
        c1 += 1
        if  i3 == len(n4) - 1:
            n6.append([t1, c1])
    else:
        if i3 != 0:
            n6.append([t1, c1])
        t1 = n4[i3]
        c1 = 1
        if  i3 == len(n4) - 1:
            n6.append([t1, c1])

n5.sort(key=lambda x:x[1], reverse=True)
n6.sort(key=lambda x:x[1], reverse=True)

t2 = 0
t2 = 0

r1 = 0

for i4 in range(n1 // 2):
    if i4 == (n1 // 2) - 1:
        r1 = n1 // 2
        break
    if n5[i4][0] == n6[i4][0]:
        if n5[i4][1] > n6[i4][1]:
            r1 = n1 - n5[i4][1] - n6[i4 + 1][1]
            break
        elif n5[i4][1] < n6[i4][1]:
            r1 = n1 - n5[i4 + 1][1] - n6[i4][1]
            break
    else:
        r1 = n1 - n5[i4][1] - n6[i4][1]
        break

print(r1)


### FIXED CODE ###

n1 = int(input())

n2 = [int(i) for i in input().split()]

n3 = []
n4 = []
for i1 in range(n1):
    if i1 % 2 == 0:
        n3.append(n2[i1])
    else:
        n4.append(n2[i1])

n3.sort()
n4.sort()

t1 = 0
c1 = 0
n5 = []

for i2 in range(len(n3)):
    if n3[i2] == t1:
        c1 += 1
        if i2 == len(n3) - 1:
            n5.append([t1, c1])
    else:
        if i2 != 0:
            n5.append([t1, c1])
        t1 = n3[i2]
        c1 = 1
        if i2 == len(n3) - 1:
            n5.append([t1, c1])

t1 = 0
c1 = 0
n6 = []
for i3 in range(len(n4)):
    if n4[i3] == t1:
        c1 += 1
        if  i3 == len(n4) - 1:
            n6.append([t1, c1])
    else:
        if i3 != 0:
            n6.append([t1, c1])
        t1 = n4[i3]
        c1 = 1
        if  i3 == len(n4) - 1:
            n6.append([t1, c1])

n5.sort(key=lambda x:(x[1],x[0]), reverse=True)
n6.sort(key=lambda x:(x[1],x[0]), reverse=True)

r1 = 0

if len(n5) == 1 and len(n6) == 1 and n5[0][0] == n6[0][0]:
     r1 = n1 // 2
else:
    if n5[0][0] != n6[0][0]:
        r1 = n1 - n5[0][1] - n6[0][1]
    else:
        if len(n5) == 1:
            r1 = n1 - n5[0][1] - n6[1][1]
        elif len(n6) == 1:
            r1 = n1 - n5[1][1] - n6[0][1]
        else:
            if (n1 - n5[0][1] - n6[1][1]) >= (n1 - n5[1][1] - n6[0][1]):
                r1 = r1 = n1 - n5[1][1] - n6[0][1]
            else:
                r1 = n1 - n5[0][1] - n6[1][1]

print(r1)
s,t=map(input().split())
print(t+s)

### FIXED CODE ###

s,t=input().split()
print(t+s)
n = input()
R = []
for i in range(0, n-1):
   R.append(int(raw_input()))

maxv = R[1] - R[0]
minv = R[0]

for v in range(1, n):
   if minv > R[v]:
      minv = R[v]
   if maxv < R[v] - minv:
      maxv = R[v] - minv
print maxv   

### FIXED CODE ###

n = input()
R = []
for i in range(0, n):
   R.append(int(raw_input()))

maxv = R[1] - R[0]
minv = R[0]

for v in range(1, n):
   if minv > R[v]:
      minv = R[v]
   elif maxv < R[v] - minv:
      maxv = R[v] - minv
print maxv
N = input()
a = [110]
for i in range(N):
  a[1] = input()
a.sort(reverse=True)

int Alis = 0
int Bob = 0
for j in range(N):
  if j % 2 == 0:
    Alis += a[j]
  else:
    Bob += [j]

print(Alis-Bob)
    

### FIXED CODE ###

N = int(input())
a = [110]
a = list(map(int, input().split()))
a.sort(reverse=True)
 
Alis = 0
Bob = 0
for j in range(N):
  if j % 2 == 0:
    Alis += a[j]
  else:
    Bob += a[j]
    
print(Alis-Bob)
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
S = list(input())

left = 0
right = N - 1

ans = 0
while right - left > 1:
    while left < N and S[left] == 'R':
        left += 1
    while right > left and S[right] == 'W':
        right -= 1
    S[left], S[right] = S[right], S[left]
    ans += 1
    left += 1
    right -= 1

for i in range(right):
    if S[i] == 'W':
        S[i] = 'R'
        ans += 1
print(ans)


### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
S = list(input())

goal = sorted(S)

ans = 0
for i in range(N):
    if S[i] != goal[i]:
        ans += 1
print(ans // 2)
L,R,d = map(int,input().split())

ans = 0
for i in range(L,R+1):
    if i%d == 0
    ans += 1

print(ans)

### FIXED CODE ###

L,R,d = map(int,input().split())

ans = 0
for i in range(L,R+1):
    if i%d == 0:
        ans += 1

print(ans)
k = input()
s = input()
i = 0
l = int(k)
p = None

while i < l:
    p = p + s[i]
    i = i + 1

print(p)

### FIXED CODE ###

k = input()
s = input()
i = 0
l = int(k)
p = str()
 
while i < l and len(s) > l:
    p = p + s[i]
    i = i + 1
while i < len(s) and len(s) <=l:
    p = p + s[i]
    i = i + 1
if len(s) > l:
	print(p + '...')
else:
	print(p)
from scipy.sparse.csgraph import dijkstra
import numpy as np

n, m = map(int, input().split())
e = np.zeros((n, n))
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    e[a][b] = 1
    e[b][a] = 1
dist, predecessor = dijkstra(e, directed=False, return_predecessors=True)
for v in predecessor[0][1:]:
    print(v+1)


### FIXED CODE ###

from collections import deque

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

dist = [1000000] * n
ans = [None]*n
not_visited = set(range(n))
not_visited.remove(0)
vs = deque([0])
dist[0] = 0
while vs:
    v = vs.popleft()
    for other_side in e[v]:
        if other_side in not_visited:
            vs.append(other_side)
            not_visited.remove(other_side)
            if dist[other_side] > dist[v] + 1:
                dist[other_side] = dist[v] + 1
                ans[other_side] = v

print("Yes")
for i in ans[1:]:
    print(i+1)
MOD = 10 ** 9 + 7
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
broken = [False for _ in range(N+1)]

dp = [0 for _ in range(N + 1)]
dp[0] = 1
for _ in range(M):
	broken[int(input())] = True
for i in range(1, N+1):
	if broken[i]:
		continue
	if i == 1:
		dp[i] = dp[i-1]
	else:
		dp[i] = dp[i-1] + dp[i-2]
		dp[i] %= MOD
print(dp[N])


### FIXED CODE ###

MOD = 10 ** 9 + 7

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

broken = [False for _ in range(N+1)]
for _ in range(M):
	broken[int(input())] = True

dp = [0 for _ in range(N + 1)]
dp[0] = 1
if(broken[1] == False):
  dp[1] = 1

for i in range(2, N+1):
	if broken[i]:
		continue
	else:
		dp[i] = dp[i-1] + dp[i-2]
		dp[i] %= MOD
print(dp[N])
def main():
    n, k = map(int, input().split())
    sushi = [list(map(int, input().split())) for _ in range(n)]
    sushi = sorted(sushi, key=lambda x: x[1], reverse=True)

    first = set()
    second = []
    point = 0
    for s in sushi[:k]:
        if s[0] not in first:
            first.add(s[0])
        else:
            second.append(s)
        point += s[1]
    point += len(first) ** 2
    ans = point

    for s in sushi[k:]:
        if s[0] not in first:
            point = point + s[1] - second.pop()[1] + \
                (len(first) + 1) ** 2 - len(first) ** 2
            first.add(s[0])
            ans = max(ans, point)
    print(ans)


main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    sushi = [list(map(int, input().split())) for _ in range(n)]
    sushi = sorted(sushi, key=lambda x: x[1], reverse=True)

    first = set()
    second = []
    point = 0
    for s in sushi[:k]:
        if s[0] not in first:
            first.add(s[0])
        else:
            second.append(s)
        point += s[1]
    point += len(first) ** 2
    ans = point

    for s in sushi[k:]:
        if len(second) == 0:
            break
        if s[0] not in first:
            point = point + s[1] - second.pop()[1] + \
                (len(first) + 1) ** 2 - len(first) ** 2
            first.add(s[0])
            ans = max(ans, point)
    print(ans)


main()
def q3():
import math
    k = int(input())
    sum_n = 0
    gcd_2_dict = {}
    def gcd(n1, n2):
        if n1 < n2:
            sorted_nums = tuple([n1, n2])
        else:
            sorted_nums = tuple([n2, n1])
        if sorted_nums in gcd_2_dict:
            return gcd_2_dict[sorted_nums]
        gcd_num = math.gcd(n1, n2)
        gcd_2_dict[sorted_nums] = gcd_num
        return gcd_num

    for a in range(1, k + 1):
        for b in range(1, k + 1):
            for c in range(1, k + 1):
                sorted_nums = sorted([a, b, c])
                sum_n += gcd(gcd(sorted_nums[0], sorted_nums[1]), sorted_nums[2])

    print(sum_n)

q3()

### FIXED CODE ###


from math import gcd

K = int(input())

a = 0
for ai in range(1, K + 1):
  for bi in range(1, K + 1):
    gcd_ab = gcd(ai, bi)
    for ci in range(1, K + 1):
      a += gcd(gcd_ab, ci)

print(a)