package main import ( "bufio" "fmt" "os" "strconv" ) func check(text string) bool { value, err := strconv.Atoi(text) if err != nil { return false } if value < 0 || value > 12345 { return false } if len(text) > 1 { if text[0] == '0' { return false } } return true } func main() { fsc := NewFastScanner() A := fsc.Next() B := fsc.Next() if check(A) && check(B) { fmt.Println("OK") } else { fmt.Println("NG") } } //template type FastScanner struct { r *bufio.Reader buf []byte p int } func NewFastScanner() *FastScanner { rdr := bufio.NewReaderSize(os.Stdin, 1024) return &FastScanner{r: rdr} } func (s *FastScanner) Next() string { s.pre() start := s.p for ; s.p < len(s.buf); s.p++ { if s.buf[s.p] == ' ' { break } } result := string(s.buf[start:s.p]) s.p++ return result } func (s *FastScanner) NextLine() string { s.pre() start := s.p s.p = len(s.buf) return string(s.buf[start:]) } func (s *FastScanner) NextInt() int { v, _ := strconv.Atoi(s.Next()) return v } func (s *FastScanner) NextInt64() int64 { v, _ := strconv.ParseInt(s.Next(), 10, 64) return v } func (s *FastScanner) pre() { if s.p >= len(s.buf) { s.readLine() s.p = 0 } } func (s *FastScanner) readLine() { s.buf = make([]byte, 0) for { l, p, e := s.r.ReadLine() if e != nil { panic(e) } s.buf = append(s.buf, l...) if !p { break } } } func IntMax(a, b int) int { if a < b { return b } return a } func Int64Max(a, b int64) int64 { if a < b { return b } return a } func Float64Max(a, b float64) float64 { if a < b { return b } return a } func IntMin(a, b int) int { if a > b { return b } return a } func Int64Min(a, b int64) int64 { if a > b { return b } return a } func Float64Min(a, b float64) float64 { if a > b { return b } return a }