package main import ( "bufio" "os" ) func main() { rbuf := make([]byte, 5_000_000+2) wbuf := make([]byte, 5_000_000+2) rlen, _ := os.Stdin.Read(rbuf[:]) last := byte(' ') wlen := 0 for _, b := range rbuf[:rlen] { if last != b { wbuf[wlen] = b wlen++ } last = b if b == '\n' { break } } wr := bufio.NewWriter(os.Stdout) wr.Write(wbuf[:wlen]) wr.Flush() }