package main import ( "bufio" "fmt" "os" ) func main() { s := readLine() n := []rune(s) lenn := len(n) max := s for i := 0; i < lenn-1; i++ { for j := i; j < lenn; j++ { n[i], n[j] = n[j], n[i] if max < string(n){ max = string(n) } n[j], n[i] = n[i], n[j] } } fmt.Println(max) } var rdr = bufio.NewReaderSize(os.Stdin, 1000000) func readLine() string { buf := make([]byte, 0, 1000000) for { l, p, e := rdr.ReadLine() if e != nil { panic(e) } buf = append(buf, l...) if !p { break } } return string(buf) }