-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tpl
More file actions
44 lines (33 loc) · 687 Bytes
/
main.tpl
File metadata and controls
44 lines (33 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"bufio"
"fmt"
"io"
"os"
"strconv"
"strings"
)
func solve(reader io.Reader, writer io.Writer) {
// your code goes here
t, _ := strconv.Atoi(readLine(reader))
fmt.Fprintf(writer, "%d\n", t)
}
func main() {
reader := bufio.NewReaderSize(os.Stdin, 1024*1024)
stdout, err := os.Create(os.Getenv("OUTPUT_PATH"))
if err != nil {
panic(err)
}
defer stdout.Close()
writer := bufio.NewWriterSize(stdout, 1024*1024)
solve(reader, writer)
writer.Flush()
}
func readLine(reader io.Reader) string {
r := bufio.NewReader(reader)
str, _, err := r.ReadLine()
if err == io.EOF {
return ""
}
return strings.TrimRight(string(str), "\r\n")
}