language stringclasses 5
values | dataset stringclasses 1
value | code stringlengths 26 25k | id stringlengths 10 10 | test_IO listlengths 1 1 |
|---|---|---|---|---|
Go | codenet | package main
import (
"fmt"
)
func main() {
var A, B int
fmt.Scanln(&A, &B)
var ans int
if 6 <= A && A <= 12 {
ans = B / 2
} else if 12 < A {
ans = B
}
fmt.Println(ans)
}
| s909858822 | [
{
"input": "30 100\n",
"output": "100\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
const d = 1000000007
func main() {
var n, p int
fmt.Scan(&n)
fmt.Scan(&p)
mdans := map[int64]int64{}
for index := 0; index < p; index++ {
var n1 int64
fmt.Scan(&n1)
mdans[n1] = n1
}
dp := make([]int64, n+1, n+1)
dp[0] = 1
dp[1] = 1
if _, ok := mdans[1]; ok {
dp[1] ... | s658739453 | [
{
"input": "6 1\n3\n",
"output": "4\n"
}
] |
Go | codenet | package main
import (
"fmt"
"sort"
)
func main() {
var N int
fmt.Scanf("%d", &N)
values := make([]float64, N)
for i := 0; i < N; i++ {
fmt.Scanf("%f", &values[i])
}
sort.Sort(sort.Float64Slice(values))
var generated float64
for i := 0; i < N-1; i++ {
generated = (values[i] + values[i+1]) / 2
values[... | s876981782 | [
{
"input": "2\n3 4\n",
"output": "3.5\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"sort"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
ns := make([]int, 4)
scanner.Scan()
fmt.Sscanf(scanner.Text(), "%d %d %d %d", &ns[0], &ns[1], &ns[2], &ns[3])
sort.Sort(sort.IntSlice(ns))
if ns[0] == 1 && ns[1] == 4 && ns[2] == 7 && ns[3] == 9 {
fmt.P... | s385901297 | [
{
"input": "1 7 9 4\n",
"output": "YES\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var n int
fmt.Scan(&n)
as := make([]int, n)
ps := make(map[int]int)
for i := 0; i < n; i++ {
fmt.Scan(&as[i])
ns := primeFactorize(as[i])
for k, v := range ns {
ps[k] = max(ps[k], v)
}
}
x := 1
for k, v := range ps {
for i := 1; i <= v; i++ {
x = ... | s823623405 | [
{
"input": "3\n2 3 4\n",
"output": "13\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func gcd(a int, b int) int {
if b == 0 {
return a
}
return gcd(b, a%b)
}
func main() {
var k, a, b, c int
ans := 0
fmt.Scan(&k)
for a = 1; a <= k; a++ {
for b = 1; b <= k; b++ {
for c = 1; c <= k; c++ {
ans += gcd(a, gcd(b, c))
}
}
}
fmt.Println(ans)
}
| s513492399 | [
{
"input": "2\n",
"output": "9\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var s, t string
fmt.Scan(&s, &t)
fmt.Println(t + s)
}
| s430241485 | [
{
"input": "oder atc\n",
"output": "atcoder\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func min(n ...int) int {
if len(n) == 0 {
panic("len == 0")
}
r := n[0]
for i := 1; i < len(n); i++ {
if n[i] <= r {
r = n[i]
}
}
return r
}
func main() {
var H, N, A, B int
fmt.Scan(&H, &N)
dp := make([]int, H+10001)
for l := 1; l < H+10001; l++ {
dp[l] = 21000000... | s257493016 | [
{
"input": "9 3\n8 3\n4 2\n2 1\n",
"output": "4\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
)
func nextInt(sc *bufio.Scanner) int {
sc.Scan()
t, _ := strconv.Atoi(sc.Text())
return t
}
type point struct {
x, l, r int
}
type ps []point
func (p ps) Len() int {
return len(p)
}
func (p ps) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}
func (p ... | s252511058 | [
{
"input": "4\n2 4\n4 3\n9 3\n100 5\n",
"output": "3\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
"strings"
)
func main() {
n := nextInt()
rt := int(math.Sqrt(float64(n)))
minf := 100
for i := 1; i < rt+1; i++ {
if n%i == 0 {
b := n / i
ndigit := 0
for b > 0 {
b /= 10
ndigit++
}
minf = min(minf, ndigit)
}
}
fmt.Printl... | s129617956 | [
{
"input": "10000\n",
"output": "3\n"
}
] |
Go | codenet | package main
import (
"fmt"
"sort"
)
func main() {
var n int
fmt.Scan(&n)
a := make([]float64, n)
for i := 0; i < n; i++ {
fmt.Scan(&a[i])
}
for i := 0; i+1 < n; i++ {
sort.Sort(sort.Float64Slice(a))
na := make([]float64, 0)
for j := 2; j < len(a); j++ {
na = append(na, a[j])
}
na = append(na, ... | s030204253 | [
{
"input": "2\n3 4\n",
"output": "3.5\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var s string
fmt.Scan(&s)
max_tmp := 0
max := 0
for i := 0; i < len(s); i++ {
flag := false
switch string(s[i]) {
case "A", "C", "T", "G":
max_tmp++
default:
flag = true
}
if i == len(s)-1 {
flag = true
}
if flag == true {
if max < max_tm... | s001472496 | [
{
"input": "ATCODER\n",
"output": "3\n"
}
] |
Go | codenet | package main
import (
"bufio"
"container/heap"
"fmt"
"os"
)
const Inf = 1 << 60
func main() {
H, W, K := ReadInt(), ReadInt(), ReadInt()
x1, y1, x2, y2 := ReadInt()-1, ReadInt()-1, ReadInt()-1, ReadInt()-1
x1, y1 = y1, x1
x2, y2 = y2, x2
c := make([]string, H)
for y := 0; y < H; y++ {
c[y] = ReadString()... | s940441641 | [
{
"input": "3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n",
"output": "5\n"
}
] |
Go | codenet | package main
import (
"fmt"
"sort"
"strings"
)
type city struct {
prefecture int
position int
year int
}
type cities []*city
type cMap map[int]cities
func main() {
var (
n, m int
)
fmt.Scanf("%d %d\n", &n, &m)
h := make(cMap)
for i := 0; i < m; i++ {
var x, y int
fmt.Scanf("%d %d\n", &x, &... | s865387202 | [
{
"input": "2 3\n1 32\n2 63\n1 12\n",
"output": "000001000002\n000002000001\n000001000001\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
sc := NewScanner()
A, B := sc.NextInt(), sc.NextInt()
mx := max(A+B, A-B)
mx = max(mx, A*B)
fmt.Println(mx)
}
func max(a int, b int) int {
if a < b {
return b
}
return a
}
type Scanner struct {
r *bufio.Reader
buf []byte
p int
... | s913685556 | [
{
"input": "-13 3\n",
"output": "-10\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
sc := newScanner()
S := sc.next()
if strings.HasPrefix(S, "YAKI") {
fmt.Println("Yes")
} else {
fmt.Println("No")
}
}
func min(a, b int) int {
if a > b {
return b
}
return a
}
func max(a, b int) int {
if a > b {
retu... | s048939108 | [
{
"input": "YAKINIKU\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
)
type Scanner struct {
sc *bufio.Scanner
}
func NewScanner() *Scanner {
sc := bufio.NewScanner(os.Stdin)
sc.Split(bufio.ScanWords)
sc.Buffer(make([]byte, 1024), int(1e+9))
return &Scanner{sc}
}
func (s *Scanner) nextStr() string {
s.sc.Scan()
re... | s512742019 | [
{
"input": "3 3 2\n1 2\n5 4\n9 2\n",
"output": "2\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var a, b int
fmt.Scan(&a, &b)
fmt.Println(a*b, (a+b)*2)
}
| s102334995 | [
{
"input": "3 5\n",
"output": "15 16\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func nextInt() int {
sc.Scan()
i, e := strconv.Atoi(sc.Text())
if e != nil {
panic(e)
}
return i
}
func main() {
sc.Split(bufio.ScanWords)
appleNum := nextInt()
pieceNum := nextInt()
pieceNumMadeFromApples := app... | s822496038 | [
{
"input": "1 3\n",
"output": "3\n"
}
] |
Go | codenet | package main
import (
"fmt"
"math"
)
func walkOnMultiplicationTable(num int) int {
div := 0
for i := int(math.Sqrt(float64(num))); i > 1; i-- {
if num%i == 0 {
div = i
break
}
}
if div == 0 {
return num - 1
}
return div + num/div - 2
}
func main() {
var a int
fmt.Scan(&a)
fmt.Println(walkOnM... | s363337466 | [
{
"input": "10\n",
"output": "5\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var a, b int
fmt.Scan(&a, &b)
if product := a * b; product%2 == 0 {
fmt.Println("Even")
} else {
fmt.Println("Odd")
}
}
| s150867340 | [
{
"input": "3 4\n",
"output": "Even\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func read() string {
sc.Scan()
return sc.Text()
}
func main() {
sc.Split(bufio.ScanWords)
a, _ := strconv.Atoi(read())
b, _ := strconv.Atoi(read())
ret := a + b
if ret < (a - b) {
ret = a - b
}
if ret < (a * b)... | s577481826 | [
{
"input": "3 1\n",
"output": "4\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
)
func check(e error) {
if e != nil {
log.Fatalf("error: %v", e)
}
}
func main() {
stdin := bufio.NewScanner(os.Stdin)
stdin.Scan()
sage := stdin.Text()
switch sage {
case "1":
fmt.Println("Hello World")
case "2":
var sum int
for i := 0; ... | s141943854 | [
{
"input": "1\n",
"output": "Hello World\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var a, b, c int
fmt.Scan(&a, &b, &c)
if c >= a && c <= b {
fmt.Println("Yes")
} else {
fmt.Println("No")
}
}
| s870102598 | [
{
"input": "1 3 2\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func getScanner(fp *os.File) *bufio.Scanner {
scanner := bufio.NewScanner(fp)
scanner.Split(bufio.ScanWords)
scanner.Buffer(make([]byte, 500001), 500000)
return scanner
}
func getNextString(scanner *bufio.Scanner) string {
scanner.Scan()
retur... | s050367086 | [
{
"input": "abcabab\nab\n",
"output": "3\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func next() string {
sc.Scan()
return sc.Text()
}
func nextInt() int {
sc.Scan()
i, _ := strconv.Atoi(sc.Text())
return i
}
func nextFloat64() float64 {
f, _ := strconv.ParseFloat(next(), 64)
return f
}
func nextIn... | s596502954 | [
{
"input": "50 100 120\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import (
"fmt"
"unicode"
)
func main() {
var s string
fmt.Scan(&s)
l := len(s)
ans := "AC"
if s[0] != 'A' {
ans = "WA"
}
cnt := 0
for i := 1; i < l; i++ {
if unicode.IsUpper(rune(s[i])) {
if i == 1 || i == l-1 || s[i] != 'C' {
ans = "WA"
}
cnt++
}
}
if cnt != 1 {
ans = "W... | s192968897 | [
{
"input": "AtCoder\n",
"output": "AC\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func nextLine() string {
sc.Scan()
return sc.Text()
}
func main() {
sc.Split(bufio.ScanWords)
var a, _ = strconv.Atoi(nextLine())
var b, _ = strconv.Atoi(nextLine())
if a*b%2 != 0 {
fmt.Println("Odd")
} else {
f... | s255858499 | [
{
"input": "3 4\n",
"output": "Even\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var a, b int
fmt.Scan(&a, &b)
if b%a == 0 {
fmt.Println(a + b)
} else {
fmt.Println(b - a)
}
}
| s969060017 | [
{
"input": "4 12\n",
"output": "16\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
num, _ := strconv.Atoi(scanString())
return num
}
func scanString() string {
sc.Scan()
return sc.Text()
}
func scanInts(n int) []int {
sl := make([]int, n)
for i := range sl {
sl[i] = scanInt()... | s187065108 | [
{
"input": "2 10 20\n",
"output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func min(nums ...int) int {
min := nums[0]
for _, v := range nums {
if v < min {
min = v
}
}
return min
}
func main() {
var n, a, b int
fmt.Scan(&n, &a, &b)
fmt.Println(min(n*a, b))
}
| s984400335 | [
{
"input": "7 17 120\n",
"output": "119\n"
}
] |
Go | codenet | package main
import (
"fmt"
"strings"
)
func main() {
var n int
var s string
fmt.Scan(&n, &s)
fmt.Println(strings.Count(s, "ABC"))
}
| s695527706 | [
{
"input": "10\nZABCDBABCQ\n",
"output": "2\n"
}
] |
Go | codenet | package main
import (
"bufio"
"bytes"
"fmt"
"os"
"strconv"
"strings"
)
type node struct {
key int32
prev *node
next *node
}
func (n *node) rPrint(buf *bytes.Buffer) {
buf.WriteString(fmt.Sprint(n.key))
if n.next != nil {
buf.WriteString(" ")
n.next.rPrint(buf)
}
return
}
func (n *node) Delete(firs... | s269502139 | [
{
"input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n",
"output": "6 1 2\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
input := Input{bufio.NewReaderSize(os.Stdin, 1000000)}
n := input.NextInt()
s := input.NextIntArray()
u := make([]bool, n)
var m, f int64
for c := 1; c < n-1; c++ {
f = 0
for k := 0; c < n-1-k*c; k++ {
u[k*c] = true
if u... | s447509781 | [
{
"input": "5\n0 2 5 1 0\n",
"output": "3\n"
}
] |
Go | codenet | package main
import (
"fmt"
"math"
)
func main() {
var N, M int
var ans int
fmt.Scan(&N, &M)
if N == 1 && M == 1 {
ans += 1
} else if 1 < N && 1 < M {
ans += (N - 2) * (M - 2)
} else {
ans += (N * M) - 2
}
fmt.Println(ans)
}
func max(x ...int) int {
var res int = x[0]
for i := 1; i < len(x); i++ {... | s870655271 | [
{
"input": "2 2\n",
"output": "0\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
)
type deque struct {
front, back []byte
}
func (deq *deque) isEmptyFront() bool {
return len(deq.front) == 0
}
func (deq *deque) isEmptyBack() bool {
return len(deq.back) == 0
}
func (deq *deque) pushBack(v byte) {
deq.back = append(deq.back, v)
}
func (deq *deque) p... | s323794848 | [
{
"input": "a\n4\n2 1 p\n1\n2 2 c\n1\n",
"output": "cpa\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var data int
fmt.Scan(&data)
var result = data * data * data
fmt.Printf("%d\n", result)
}
| s136583229 | [
{
"input": "2\n",
"output": "8\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var a, b, h int
fmt.Scan(&a, &b, &h)
fmt.Println((a + b) * h / 2)
}
| s589878052 | [
{
"input": "3\n4\n2\n",
"output": "7\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func getNextWord(scanner *bufio.Scanner) string {
scanner.Scan()
return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
i, _ := strconv.Atoi(getNextWord(scanner))
return i
}
func main() {
fp := os.Stdin
if len(os.Args) > 1 {
fp, _ = os.... | s546282715 | [
{
"input": "6 1\n3\n",
"output": "4\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var s string
fmt.Scan(&s)
price := 700
for _, c := range s {
if c == 'o' {
price += 100
}
}
fmt.Println(price)
}
| s774791701 | [
{
"input": "oxo\n",
"output": "900\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
const mod = 1000000007
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
sc := bufio.NewScanner(os.Stdin)
sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
sc.Split(bufio.ScanWords)
return sc
}()
func next() string {
sc.Scan()
ret... | s464350089 | [
{
"input": "10 3\n4 5 6\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var n, k int
fmt.Scanf("%d %d\n", &n, &k)
if k <= (n+n%2)/2 {
fmt.Println("YES")
} else {
fmt.Println("NO")
}
}
| s584033358 | [
{
"input": "3 2\n",
"output": "YES\n"
}
] |
Go | codenet | package main
import (
_ "bufio"
"fmt"
_ "os"
_ "strconv"
)
func main() {
var x, a, b int
fmt.Scan(&x, &a, &b)
switch {
case b-a <= 0:
fmt.Println("delicious")
break
case b-a <= x:
fmt.Println("safe")
break
default:
fmt.Println("dangerous")
break
}
}
| s693332680 | [
{
"input": "4 3 6\n",
"output": "safe\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func comp(x, a int) int {
if x < a {
return 0
}
return 10
}
func main() {
var x, a int
fmt.Scan(&x, &a)
fmt.Println(comp(x, a))
}
| s506882149 | [
{
"input": "3 5\n",
"output": "0\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
)
const (
initialBufSize = 10000
maxBufSize = 1000000
mod = 1e9 + 7
)
var (
sc *bufio.Scanner = func() *bufio.Scanner {
sc := bufio.NewScanner(os.Stdin)
buf := make([]byte, initialBufSize)
sc.Buffer(buf, maxBufSize)
sc.Split(bu... | s824350268 | [
{
"input": "10\n",
"output": "5\n"
}
] |
Go | codenet | package main
import (
"bufio"
"container/heap"
"fmt"
"math"
"os"
"strconv"
)
const (
initialBufSize = 10000
maxBufSize = 1000000
mod = 1e9 + 7
)
var (
sc *bufio.Scanner = func() *bufio.Scanner {
sc := bufio.NewScanner(os.Stdin)
buf := make([]byte, initialBufSize)
sc.Buffer(buf, maxBufS... | s633919449 | [
{
"input": "16\n",
"output": "pon\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
"strings"
"flag"
"runtime"
"runtime/pprof"
)
var magic = 1000000007
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
var memprofile = flag.String("memprofile", "", "write mem profile to file")
var N int
var p [200000]int
... | s601720340 | [
{
"input": "6 5\n4 7 10 6 5\n",
"output": "8\n"
}
] |
Go | codenet | package main
import (
"fmt"
"sort"
)
func main() {
var n int
fmt.Scan(&n)
a := make([]int, n)
for i := 0; i < n; i++ {
fmt.Scan(&a[i])
}
b := make([]int, 0, n)
for _, v := range a {
x := sort.Search(len(b), func(i int) bool {
return b[i] < v
})
if x == len(b) {
b = append(b, v)
} else {
... | s558200435 | [
{
"input": "5\n2\n1\n4\n5\n3\n",
"output": "2\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var x1, y1, x2, y2 int
fmt.Scan(&x1, &y1, &x2, &y2)
a := x2 - x1
b := y2 - y1
x3 := x2 - b
y3 := y2 + a
x4 := x1 - b
y4 := y1 + a
fmt.Println(x3, y3, x4, y4)
}
| s554832295 | [
{
"input": "0 0 0 1\n",
"output": "-1 1 -1 0\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
"strings"
"unsafe"
)
func main() {
AB := sc.nextInts()
A := AB[0]
B := AB[1]
if (A+B)%2 == 0 {
fmt.Println((A + B) / 2)
return
}
fmt.Println("IMPOSSIBLE")
}
var (
sc scanner
)
func init() {
sc = scanner{
buf: make([]string, 0, 0),
cur... | s789498198 | [
{
"input": "2 16\n",
"output": "9\n"
}
] |
Go | codenet | package main
import (
"bufio"
"bytes"
"fmt"
"io"
"os"
"sort"
"strconv"
"strings"
)
func ReadLongLines(times int) ([]string, error) {
result := make([]string, times)
reader := bufio.NewReader(os.Stdin)
buffer := bytes.NewBuffer(make([]byte, 0))
readBytes := int64(2)
for i := 0; i < times; i++ {
for {
... | s227655384 | [
{
"input": "7\n1 2 3 4 5 6 7\n4\n2 4 6 8\n",
"output": "1\n3\n5\n7\n8\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
sc.Split(bufio.ScanWords)
n := nextInt()
a := nextInts(n)
ans := 0
for i := 0; i < n; i++ {
l, r := i, i+1
for r+1 < n && (a[r]-a[l])*(a[r+1]-a[r]) >= 0 {
r++
}
ans++
i = r
}
puts(ans)
wt.Flush()
}
var (
sc = bufio.NewScan... | s240914668 | [
{
"input": "6\n1 2 3 2 2 1\n",
"output": "2\n"
}
] |
Go | codenet | package main
import "fmt"
const size = 100001
func main() {
var n, t int
var l, r int
var mem [size]int
fmt.Scan(&n)
fmt.Scan(&t)
for i := 0; i < n; i++ {
fmt.Scan(&l)
fmt.Scan(&r)
mem[l] += 1
mem[r] -= 1
}
ans := mem[0]
for i := 1; i < t+1; i++ {
mem[i] += mem[i-1]
if ans < mem[i] {
ans = me... | s097554686 | [
{
"input": "6 10\n0 2\n1 3\n2 6\n3 8\n4 10\n5 10\n",
"output": "4\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func next() string {
sc.Scan()
return sc.Text()
}
func nextInt() int {
sc.Scan()
i, _ := strconv.Atoi(sc.Text())
return i
}
func nextFloat64() float64 {
f, _ := strconv.ParseFloat(next(), 64)
return f
}
func nextIn... | s225883945 | [
{
"input": "4 3\n2 3 1 4\n",
"output": "2\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var r, d, x int
fmt.Scanf("%d %d %d", &r, &d, &x)
for i := 0; i < 10; i++ {
x = r*x - d
fmt.Println(x)
}
}
| s502485201 | [
{
"input": "2 10 20\n",
"output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"sort"
)
func main() {
m := make(map[int]int)
N, M := ReadInt(), ReadInt()
for i := 0; i < N; i++ {
m[ReadInt()]++
}
for i := 0; i < M; i++ {
B, C := ReadInt(), ReadInt()
m[C] += B
}
ints := make([]int, len(m))
for i, _ := range m {
ints = append(ints, i)
... | s982630782 | [
{
"input": "3 2\n5 1 4\n2 3\n1 5\n",
"output": "14\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var n int
fmt.Scan(&n)
var s []byte
fmt.Scan(&s)
ns := make([]int, n)
for i := range s {
switch s[i] {
case 'R':
ns[i] = 0
case 'G':
ns[i] = 1
case 'B':
ns[i] = 2
}
}
rgb := make([][]int, n+1)
rgb[0] = make([]int, 3)
for i := 1; i <= n; i++ {
... | s724499011 | [
{
"input": "4\nRRGB\n",
"output": "1\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"math"
"os"
"sort"
"strconv"
"strings"
)
func main() {
io := NewIo()
defer io.Flush()
n := io.Int()
aa := make([]int, n)
for i := 0; i < n; i++ {
aa[i] = io.Int()
}
cumsum := CumSum(aa)
ans := 2020202020
for i := 1; i < len(cumsum)-1; i++ {
ans = Min(ans, A... | s846000843 | [
{
"input": "3\n2 4 3\n",
"output": "3\n"
}
] |
Go | codenet | package main
import (
"bufio"
"errors"
"fmt"
"io"
"math"
"os"
"sort"
"strconv"
)
const (
MOD = 1000000000 + 7
ALPHABET_NUM = 26
INF_INT64 = math.MaxInt64
INF_BIT60 = 1 << 60
INF_INT32 = math.MaxInt32
INF_BIT30 = 1 << 30
NIL = -1
WHITE = 0
GRAY = 1
BLACK = 2
)
func init() {
... | s040219730 | [
{
"input": "4 3\n1 2 1 3\n1 3\n2 4\n3 3\n",
"output": "2\n3\n1\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var a, b, c, x, sum int
fmt.Scan(&a, &b, &c, &x)
for i := 0; i <= a; i++ {
for j := 0; j <= b; j++ {
for k := 0; k <= c; k++ {
if 500*i+100*j+50*k == x {
sum++
}
}
}
}
fmt.Println(sum)
}
| s141561537 | [
{
"input": "2\n2\n2\n100\n",
"output": "2\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
"strings"
)
var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)
var N, ss, ans, A, B, C int
func main() {
X := strings.Split(nextLine(), " ")
N, _ = strconv.Atoi(X[0])
A, _ = strconv.Atoi(X[1])
B, _ = strconv.Atoi(X[2])
C, _ ... | s617271364 | [
{
"input": "5 100 90 80\n98\n40\n30\n21\n80\n",
"output": "23\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var N, M int
fmt.Scan(&N, &M)
Inf := 1 << 62
a := make([]int, M)
b := make([]int, M)
c := make([]int, M)
for i := 0; i < M; i++ {
fmt.Scan(&a[i], &b[i], &c[i])
c[i] = -c[i]
}
dist := make([]int, N)
for i := 0; i < N; i++ {
dist[i] = Inf
}
dist[0] = 0
f... | s984936225 | [
{
"input": "3 3\n1 2 4\n2 3 3\n1 3 5\n",
"output": "7\n"
}
] |
Go | codenet | package main
import (
"fmt"
"strings"
)
func main() {
var s string
fmt.Scanf("%s", &s)
ans := "No"
if strings.Index(s, "C") < strings.LastIndex(s, "F") {
ans = "Yes"
}
if strings.Index(s, "C") < 0 {
ans = "No"
}
fmt.Printf("%s\n", ans)
}
| s494300734 | [
{
"input": "CODEFESTIVAL\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var A, B, C int
fmt.Scanf("%d %d %d", &A, &B, &C)
if C-A+B < 0 {
fmt.Println("0")
} else {
fmt.Printf("%d\n", C-A+B)
}
}
| s452291224 | [
{
"input": "6 4 3\n",
"output": "1\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
sc := NewScanner()
n := sc.NextInt()
ans := 0.0
for i := 0; i < n; i++ {
tmp := 1 / float64(sc.NextInt())
ans += tmp
}
fmt.Printf("%v\n", 1/ans)
}
type Scanner struct {
r *bufio.Reader
buf []byte
p int
}
func NewScanner() *Sca... | s940795037 | [
{
"input": "2\n10 30\n",
"output": "7.5\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
"strings"
)
var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)
func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a, _ := strconv.Atoi(scanS... | s436101574 | [
{
"input": "?tc????\ncoder\n",
"output": "atcoder\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var S string
fmt.Scan(&S)
for i := 2; i <= len(S); i = i + 2 {
if S[0:(len(S)-i)/2] == S[(len(S)-i)/2:len(S)-i] {
fmt.Println((len(S) - i))
break
}
}
}
| s225932846 | [
{
"input": "abaababaab\n",
"output": "6\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"io"
"os"
"strconv"
)
type Scanner struct {
sc *bufio.Scanner
}
func NewScanner() *Scanner {
sc := bufio.NewScanner(os.Stdin)
sc.Split(bufio.ScanWords)
sc.Buffer(make([]byte, 10240), int(1e+9))
return &Scanner{sc}
}
func (s *Scanner) nextStr() string {
s.sc.Scan()
ret... | s731620136 | [
{
"input": "4\nRRGB\n",
"output": "1\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var s string
fmt.Scan(&s)
if len(s) >= 4 && s[0:4] == "YAKI" {
fmt.Println("Yes")
} else {
fmt.Println("No")
}
}
| s861455616 | [
{
"input": "YAKINIKU\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
)
func solve() {
n := getInt()
as := getIntSlice(n)
xs := make([]int, n)
for i, a := range as {
xs[i] = a - i + 1
}
sort.Ints(xs)
b := xs[n/2]
ans := 0
for _, x := range xs {
ans += abs(x - b)
}
fmt.Fprintln(wr, ans)
}
func abs(n int) in... | s521372598 | [
{
"input": "5\n2 2 3 5 5\n",
"output": "2\n"
}
] |
Go | codenet | package main
import (
"bufio"
"errors"
"fmt"
"io"
"math"
"os"
"strconv"
)
const (
MOD = 1000000000 + 7
ALPHABET_NUM = 26
INF_INT64 = math.MaxInt64
INF_BIT60 = 1 << 60
INF_INT32 = math.MaxInt32
INF_BIT30 = 1 << 30
NIL = -1
WHITE = 0
GRAY = 1
BLACK = 2
)
func init() {
... | s069675863 | [
{
"input": "FTFFTFFF\n4 2\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import "fmt"
import "math"
func max(lhs, rhs int) int {
return int(math.Max(float64(lhs), float64(rhs)))
}
func main() {
var (
N, M int
)
fmt.Scanf("%d %d", &N, &M)
values := make([]int, N)
weights := make([]int, N)
for i := 0; i < N; i++ {
fmt.Scanf("%d %d", &weights[i], &values[i])
}
dp ... | s794438584 | [
{
"input": "3 8\n3 30\n4 50\n5 60\n",
"output": "90\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"io"
"math"
"os"
"strconv"
)
type scanner struct{ *bufio.Scanner }
func newScanner(r io.Reader) *scanner {
s := bufio.NewScanner(r)
s.Split(bufio.ScanWords)
s.Buffer(nil, 100000000)
return &scanner{s}
}
func (s *scanner) Int() int {
s.Scan()
n, _ := strconv.Atoi(s.Tex... | s458415155 | [
{
"input": "4\n10 30 40 20\n",
"output": "30\n"
}
] |
Go | codenet | package main
import (
"bufio"
"errors"
"fmt"
"math"
"os"
"strconv"
"strings"
)
var sc = bufio.NewScanner(os.Stdin)
func NextLine() string {
sc.Scan()
return sc.Text()
}
func NextIntsLine() []int {
ints := []int{}
intsStr := NextLine()
tmp := strings.Split(intsStr, " ")
for _, s := range tmp {
integer... | s617302278 | [
{
"input": "6\n",
"output": "3\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var a int
fmt.Scan(&a)
fmt.Println(a + a*a + a*a*a)
}
| s566920420 | [
{
"input": "2\n",
"output": "14\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"log"
"math"
"math/rand"
"os"
"strconv"
"time"
)
var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1, 0}
var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1, 0}
var inf = math.MaxInt64
var next = newScanner()
func init() {
log.SetFlags(log.Lshortfile)
rand.Seed(time.Now().UnixNano())
... | s940603045 | [
{
"input": "12\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
var (
a []int
ans = 0
)
func dfs(left, i, res int) {
if left == 0 {
ans += res
return
}
for j := i; j < len(a); j++ {
dfs(left-1, j+1, res*a[j])
}
}
func main() {
io := newIo()
n := io.nextInt()
dic := map[rune]int{}
for range ma... | s058450440 | [
{
"input": "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n",
"output": "2\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func main() {
sc.Split(bufio.ScanWords)
n := nextInt()
ar := make([]int, 3*n)
for i := range ar {
ar[i] = nextInt()
}
sort.Ints(ar)
sum := 0
for i := 0; i < n; i++ {
sum += ar[3*n-(i+1)*2]
}
fmt.Println... | s144285625 | [
{
"input": "2\n5 2 8 5 1 5\n",
"output": "10\n"
}
] |
Go | codenet | package main
import (
"fmt"
)
func main() {
var a int
fmt.Scan(&a)
fmt.Println(3 * a * a)
}
| s143950643 | [
{
"input": "4\n",
"output": "48\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var s string
fmt.Scan(&s)
for i := 0; i < len(s); i++ {
fmt.Print("x")
}
fmt.Println("")
}
| s682653189 | [
{
"input": "sardine\n",
"output": "xxxxxxx\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func nextInt(sc *bufio.Scanner) int {
sc.Scan()
t, _ := strconv.Atoi(sc.Text())
return t
}
func reva(b []int) {
for i := 0; i < len(b)/2; i++ {
b[i], b[len(b)-1-i] = b[len(b)-1-i], b[i]
}
}
func main() {
sc := bufio.NewScanner(os.Stdin)
sc.Split(bufi... | s525290130 | [
{
"input": "8\n1 2 3 4 5 6 7 8\n2\n1 6\n3 8\n",
"output": "1 6 5 8 7 2 3 4\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var n string
fmt.Scan(&n)
for i := 0; i < 3; i++ {
if n[i] == '7' {
fmt.Println("Yes")
return
}
}
fmt.Println("No")
}
| s863302171 | [
{
"input": "117\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
)
func out(x ...interface{}) {
fmt.Println(x...)
}
var sc = bufio.NewScanner(os.Stdin)
func getInt() int {
sc.Scan()
i, e := strconv.Atoi(sc.Text())
if e != nil {
panic(e)
}
return i
}
func getString() string {
sc.Scan()
return sc.Text()
}
f... | s725956217 | [
{
"input": "2 5\n4 9\n2 4\n",
"output": "12\n"
}
] |
Go | codenet | package main
import (
"fmt"
"sort"
)
func main() {
var n int
fmt.Scan(&n)
var ws works = make([]work, n)
for i := 0; i < n; i++ {
var a, n int
fmt.Scan(&a, &n)
ws[i] = work{a, n}
}
sort.Sort(ws)
sum := int64(0)
for _, w := range ws {
sum += int64(w.time)
if sum > int64(w.limit) {
fmt.Println(... | s851255999 | [
{
"input": "5\n2 4\n1 9\n1 8\n4 9\n3 12\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func getScanner(fp *os.File) *bufio.Scanner {
scanner := bufio.NewScanner(fp)
scanner.Split(bufio.ScanWords)
scanner.Buffer(make([]byte, 500001), 500000)
return scanner
}
func getNextString(scanner *bufio.Scanner) string {
scanner.Scan()
return scanner.T... | s129530281 | [
{
"input": "3 3\n2 13 8\n",
"output": "9\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
)
func main() {
S, T := ReadString(), ReadString()
max := 0
for i := 0; i <= len(S)-len(T); i++ {
c := 0
for j := 0; j < len(T); j++ {
if S[i+j] == T[j] {
c++
}
}
if max < c {
max = c
}
}
fmt.Println(len(T) - max)
}
var reader = bufio.NewReader(... | s118500787 | [
{
"input": "cabacc\nabc\n",
"output": "1\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
s := bufio.NewScanner(os.Stdin)
s.Scan()
s.Scan()
ds := s.Text()
dd := strings.Split(ds, " ")
dn := make([]int, len(dd))
for i, d := range dd {
dn[i], _ = strconv.Atoi(d)
}
sum := 0
for i := 0; i < len(dn); i++ {
for j :... | s692569558 | [
{
"input": "3\n3 1 2\n",
"output": "11\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
const MX = 10000
sieve := make([]int, MX)
primes := make([]int, 0, MX)
for i := 2; i < MX; i++ {
if sieve[i] != 0 {
continue
}
primes = append(primes, i)
for j := i + i; j < MX; j += i {
sieve[j] = i
}
}
var n int
fmt.Scan(&n)
ans := 0
for i := 0; i < ... | s803744887 | [
{
"input": "5\n2\n3\n4\n5\n6\n",
"output": "3\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
)
func main() {
log.SetFlags(log.Lshortfile)
sc := newScanner()
x := sc.nextInt()
y := sc.nextInt()
var xt, yt int
a := [3][]int{{1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11}, {2}}
for i, t := range a {
for _, n := range t {
if x == n {
xt = i
... | s554024899 | [
{
"input": "1 3\n",
"output": "Yes\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
sc := NewScanner()
H, W, N := sc.NextInt(), sc.NextInt(), sc.NextInt()
A := max(H, W)
fmt.Println((N + A - 1) / A)
}
func max(a int, b int) int {
if a < b {
return b
}
return a
}
type Scanner struct {
r *bufio.Reader
buf []byte
... | s918723842 | [
{
"input": "3\n7\n10\n",
"output": "2\n"
}
] |
Go | codenet | package main
import "fmt"
var N, K int
var d, a int
func main() {
fmt.Scan(&N, &K)
as := make(map[int]int)
for i := 1; i <= N; i++ {
as[i] = 0
}
for i := 0; i < K; i++ {
fmt.Scan(&d)
for j := 0; j < d; j++ {
fmt.Scan(&a)
as[a]++
}
}
ans := 0
for _, v := range as {
if v == 0 {
ans++
}
}
... | s382986061 | [
{
"input": "3 2\n2\n1 3\n1\n3\n",
"output": "1\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
type bufReader struct {
r *bufio.Reader
buf []byte
i int
}
var reader = &bufReader{
bufio.NewReader(os.Stdin),
make([]byte, 0),
0,
}
func (r *bufReader) readLine() {
if r.i < len(r.buf) {
return
}
r.buf = make([]byte, 0)
r.i = 0
fo... | s541050824 | [
{
"input": "3\n2 3\n1 1\n3 2\n",
"output": "10\n"
}
] |
Go | codenet | package main
import "fmt"
func main() {
var x, y int
fmt.Scan(&x, &y)
fmt.Println(x + y/2)
}
| s784695632 | [
{
"input": "81 58\n",
"output": "110\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func getScanner(fp *os.File) *bufio.Scanner {
scanner := bufio.NewScanner(fp)
scanner.Split(bufio.ScanWords)
scanner.Buffer(make([]byte, 500001), 500000)
return scanner
}
func getNextString(scanner *bufio.Scanner) string {
scanner.Scan()
return scanner.T... | s168401731 | [
{
"input": "2\n1\n2\n",
"output": "first\n"
}
] |
Go | codenet | package main
import (
"bufio"
"bytes"
"fmt"
"io"
"os"
"strconv"
)
var DEBUG = false
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)
var OutputBuffer *bufio.Writer
var OutputWriter io.Writer
func SetInteractive(w io.Writer, r io.Reader) {
SetUnbufferedInput(r)
OutputBuffer = nil
O... | s294436820 | [
{
"input": "2 3 2\n..#\n###\n",
"output": "5\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
)
func main() {
R := nextInt()
G := nextInt()
B := nextInt()
N := nextInt()
var ans int
for x := 0; x <= N; x++ {
for y := 0; y <= N; y++ {
tmp := N - R*x - G*y
if tmp >= 0 && tmp%B == 0 {
ans++
}
}
}
fmt.Println(ans)
}
var sc ... | s497500962 | [
{
"input": "1 2 3 4\n",
"output": "4\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
)
func main() {
sc := bufio.NewScanner(os.Stdin)
sc.Scan()
s := sc.Text()
d := 'a' - 'A'
for _, r := range s {
rr := r
if 'A' <= r && r <= 'Z' {
rr = r + d
} else if 'a' <= r && r <= 'z' {
rr = r - d
}
fmt.Printf("%c", rr)
}
fmt.Println()
}
| s057401371 | [
{
"input": "fAIR, LATER, OCCASIONALLY CLOUDY.\n",
"output": "Fair, later, occasionally cloudy.\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func out(x ...interface{}) {
fmt.Println(x...)
}
var sc = bufio.NewScanner(os.Stdin)
func getInt() int {
sc.Scan()
i, e := strconv.Atoi(sc.Text())
if e != nil {
panic(e)
}
return i
}
func getString() string {
sc.Scan()
return sc.Text()
}
type Node... | s236040683 | [
{
"input": "4 3\n1 2\n2 3\n1 4\n",
"output": "2\n2\n1\n1\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func readInt() int {
sc.Scan()
i, err := strconv.Atoi(sc.Text())
if err != nil {
panic(err)
}
return i
}
func readFloat64() float64 {
sc.Scan()
f, err := strconv.ParseFloat(sc.Text(), 64)
if err != nil {
panic(e... | s197768810 | [
{
"input": "41 2\n5 6\n",
"output": "30\n"
}
] |
Go | codenet | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func getScanner(fp *os.File) *bufio.Scanner {
scanner := bufio.NewScanner(fp)
scanner.Split(bufio.ScanWords)
scanner.Buffer(make([]byte, 500001), 500000)
return scanner
}
func getNextString(scanner *bufio.Scanner) string {
scanner.Scan()
return scanner.T... | s953070177 | [
{
"input": "3\n3 5 -1\n",
"output": "12\n8\n10\n"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.