{"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar r, x, y, nx, ny int64\n\tfmt.Scanf(\"%d %d %d %d %d\", &r, &x, &y, &nx, &ny)\n\ts := (x-nx)*(x-nx) + (y-ny)*(y-ny)\n\tr *= 2\n\tvar i int64\n\tfor i = 0; i*i*r*r < s; i++ {\n\n\t}\n\tfmt.Println(i)\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "c2b8099f1894f2dcf3b4bbb575f06631", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n \"math\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n r, x1, y1, x2, y2 := getI(), getI(), getI(), getI(), getI()\n d := math.Sqrt(float64((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)))\n result := int(math.Ceil(d / float64(2*r)))\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "826648f7c1083c1d4e7a48400e832ed7", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar r, x, y, x1, y1 float64\n\tfmt.Scan(&r, &x, &y, &x1, &y1)\n\tfmt.Println(math.Ceil(math.Hypot(x-x1, y-y1) * .5 / r))\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "fd4d25bb0ce7ba36a13bf223d2f9dabe", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int64\n\tfor I(&n, \"\\n\") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int64) {\n\tvar s []byte\n\tI(&s, \"\\n\")\n\ta, b := make([]int, len(s)/2), make([]int, len(s)/2)\n\tfor i, v := range s[:len(s)/2] {\n\t\ta[i] = int(v)\n\t}\n\tfor i, v := range s[len(s)/2:] {\n\t\tb[i] = int(v)\n\t}\n\tsort.Ints(a)\n\tsort.Ints(b)\n\taa := false\n\tbb := false\n\tfor i := 0; i < len(a); i++ {\n\t\tif a[i] > b[i] {\n\t\t\taa = true\n\t\t} else if a[i] < b[i] {\n\t\t\tbb = true\n\t\t} else {\n\t\t\taa = true\n\t\t\tbb = true\n\t\t}\n\t}\n\tif aa && bb {\n\t\tO(\"NO\", \"\\n\")\n\t} else {\n\t\tO(\"YES\", \"\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "d3d804ab176f01827b9a45d590050578", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n int\n var s string\n fmt.Scan(&n)\n fmt.Scan(&s)\n left := make([]int,n)\n for i := 0; i < n; i++ {\n left[i] = int(s[i])\n }\n sort.Ints(left)\n right := make([]int,n)\n for i := n; i < (2*n); i++ {\n right[i-n] = int(s[i])\n }\n sort.Ints(right)\n ans := true\n if left[0] == right[0] {\n ans = false\n } else {\n for i := 1; i < n; i++ {\n if ((left[i] >= right[i]) && (left[i-1] <= right[i-1])) || ((left[i] <= right[i]) && (left[i-1] >= right[i-1])) {\n ans = false\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "ba1312c25b9456ff1bf25bbde1a305ba", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n int\n var s string\n fmt.Scan(&n)\n fmt.Scan(&s)\n left := make([]int,n)\n for i := 0; i < n; i++ {\n left[i] = int(s[i])\n }\n sort.Ints(left)\n right := make([]int,n)\n for i := n; i < (2*n); i++ {\n right[i-n] = int(s[i])\n }\n sort.Ints(right)\n ans := true\n if left[0] == right[0] {\n ans = false\n } else {\n for i := 1; i < n; i++ {\n if ((left[i] >= right[i]) && (left[i-1] <= right[i-1])) || ((left[i] <= right[i]) && (left[i-1] >= right[i-1])) {\n ans = false\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "6a131031a070d92b47eca4d406d992ff", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tif n%5 == 0 {\n\t\tfmt.Print(n / 5)\n\t\treturn\n\t}\n\tfmt.Print(n/5 + 1)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "0c6054857bda0b8870649c00240c09e1", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x uint32\n\tfmt.Scanf(\"%d\\n\", &x)\n\tif x%5 > 0 {\n\t\tx = x/5 + 1\n\t} else {\n\t\tx = x / 5\n\t}\n\tfmt.Println(x)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "99e5bd3b1223b1e59c2adc6650fb29ac", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tvar n uint32\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tfmt.Println(math.Ceil(float64(n) / 5))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "87e1ea58207c1e0dadd9ce9d44c5dde8", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\ntype sortRunes []rune\n\nfunc (s sortRunes) Less(i, j int) bool {\n\treturn s[i] < s[j]\n}\n\nfunc (s sortRunes) Swap(i, j int) {\n\ts[i], s[j] = s[j], s[i]\n}\n\nfunc (s sortRunes) Len() int {\n\treturn len(s)\n}\n\nfunc need_automaton(input1 string, input2 string) bool {\n\tinput1Bytes := []rune(input1)\n\tinput2Bytes := []rune(input2)\n\n\tif len(input2Bytes) > len(input1Bytes) {\n\t\treturn false\n\t}\n\n\ti, j := 0, 0\n\n\tfor {\n\t\tif i >= len(input2Bytes) || j >= len(input1Bytes) {\n\t\t\tbreak\n\t\t}\n\n\t\tif input2Bytes[i] == input1Bytes[j] {\n\t\t\ti++\n\t\t\tj++\n\t\t} else {\n\t\t\tj++\n\t\t}\n\t}\n\n\tif i == len(input2Bytes) {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}\n\nfunc need_array(input1 string, input2 string) bool {\n\tif len(input1) != len(input2) {\n\t\treturn false\n\t}\n\n\tinput1Bytes := []rune(input1)\n\tinput2Bytes := []rune(input2)\n\n\tsort.Sort(sortRunes(input1Bytes))\n\tsort.Sort(sortRunes(input2Bytes))\n\n\tfor i := 0; i < len(input1Bytes); i++ {\n\t\tif input1Bytes[i] != input2Bytes[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc need_both(input1 string, input2 string) bool {\n\tinput1Bytes := []rune(input1)\n\tinput2Bytes := []rune(input2)\n\n\tsort.Sort(sortRunes(input1Bytes))\n\tsort.Sort(sortRunes(input2Bytes))\n\n\tif len(input2Bytes) > len(input1Bytes) {\n\t\treturn false\n\t}\n\n\ti, j := 0, 0\n\n\tfor {\n\t\tif i >= len(input2Bytes) || j >= len(input1Bytes) {\n\t\t\tbreak\n\t\t}\n\n\t\tif input2Bytes[i] == input1Bytes[j] {\n\t\t\ti++\n\t\t\tj++\n\t\t} else if input2Bytes[i] > input1Bytes[j] {\n\t\t\tj++\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif i == len(input2Bytes) {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}\n\nfunc main() {\n\tvar word1, word2 string\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tif scanner.Scan() {\n\t\tword1 = scanner.Text()\n\t}\n\n\tif scanner.Scan() {\n\t\tword2 = scanner.Text()\n\t}\n\n\tif need_array(word1, word2) {\n\t\tfmt.Println(\"array\")\n\t} else if need_automaton(word1, word2) {\n\t\tfmt.Println(\"automaton\")\n\t} else if need_both(word1, word2) {\n\t\tfmt.Println(\"both\")\n\t} else {\n\t\tfmt.Println(\"need tree\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "a6d0a1c87f47d6e34b801bfc4f2d08f1", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader= bufio.NewReader(os.Stdin)\nvar writer= bufio.NewWriter(os.Stdout)\nvar cnt[33]int\nvar dp[105][105]int\nvar s string\nvar t string\n\nfunc max(a int, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\tfor i := 0; i < len(s); i++ {\n\t\tcnt[int(s[i] - 'a')]++\n\t}\n\tfmt.Fscanf(reader, \"%s\\n\", &t)\n\tfor i := 0; i < len(t); i++ {\n\t\tcnt[int(t[i] - 'a')]--\n\t}\n\n\tvar neg = 0\n\tvar pos = 0\n\n\tfor i := 0; i < 26; i++ {\n\t\tif cnt[i] > 0 {\n\t\t\tpos++\n\t\t}\n\t\tif cnt[i] < 0 {\n\t\t\tneg++\n\t\t}\n\t}\n\n\tif neg > 0 {\n\t\tfmt.Fprintf(writer, \"need tree\")\n\t\treturn\n\t}\n\n\tif pos == 0 {\n\t\tfmt.Fprintf(writer, \"array\")\n\t\treturn\n\t}\n\n\tvar n = len(s)\n\tvar m = len(t)\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := 1; j <= m; j++ {\n\t\t\tif s[i - 1] == t[j - 1] {\n\t\t\t\tdp[i][j] = dp[i - 1][j - 1] + 1\n\t\t\t} else {\n\t\t\t\tdp[i][j] = max(dp[i - 1][j], dp[i][j - 1])\n\t\t\t}\n\t\t}\n\t}\n\n\tif dp[n][m] == m {\n\t\tfmt.Fprintf(writer, \"automaton\")\n\t} else {\n\t\tfmt.Fprintf(writer, \"both\")\n\t}\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "61da3a4522cfef07f9f1dfa50bfc9e75", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tre := regexp.MustCompile(`\\r?\\n`)\n\n\tst := [2]string{}\n\n\tfor i := 0; i < 2; i++ {\n\t\tif _in, err := reader.ReadString('\\n'); err != nil {\n\t\t\tif err != io.EOF {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tst[i] = re.ReplaceAllString(_in, \"\")\n\t\t}\n\t}\n\n\ts := st[0]\n\tt := st[1]\n\n\tif len(s) < len(t) {\n\t\tfmt.Println(\"need tree\")\n\t} else {\n\t\tj := 0\n\t\tauto := true\n\t\tfor i := 0; i < len(t); i++ {\n\t\t\tif !auto {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tfor true {\n\t\t\t\tif j >= len(s) {\n\t\t\t\t\tauto = false\n\t\t\t\t\tbreak\n\t\t\t\t} else if s[j] == t[i] {\n\t\t\t\t\tj++\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tj++\n\t\t\t}\n\t\t}\n\t\tif auto {\n\t\t\tfmt.Println(\"automaton\")\n\t\t\treturn\n\t\t}\n\n\t\tsm := make(map[rune]int)\n\t\tfor i := 0; i < len(s); i++ {\n\t\t\tsm[rune(s[i])] += 1\n\t\t}\n\t\tfor j := 0; j < len(t); j++ {\n\t\t\tsm[rune(t[j])] -= 1\n\t\t}\n\n\t\tremain := 0\n\t\thas_neg := false\n\t\tfor _, v := range sm {\n\t\t\tif v < 0 {\n\t\t\t\thas_neg = true\n\t\t\t}\n\t\t\tremain += v\n\t\t}\n\t\tif has_neg {\n\t\t\tfmt.Println(\"need tree\")\n\t\t} else if remain == 0 {\n\t\t\tfmt.Println(\"array\")\n\t\t} else {\n\t\t\tfmt.Println(\"both\")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "88d27bb0bf8227b67dde6c3da120a446", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 140A\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, r, x int\n\tvar c float64\n\tfmt.Scan(&n, &r, &x)\n\tif n == 1 {\n\t\tif x > r {\n\t\t\tfmt.Println(\"NO\")\n\t\t} else {\n\t\t\tfmt.Println(\"YES\")\n\t\t}\n\n\t} else {\n\t\tc = float64(x)/math.Sin(float64(3.14159)/float64(n)) + float64(x)\n\t\tc = c - float64(r)\n\t\tif c > 0.00001 {\n\t\t\tfmt.Println(\"NO\")\n\t\t} else {\n\t\t\tfmt.Println(\"YES\")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "a283fb58f48f01520c5680146c1e77ec", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 140A-mic\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc no() { fmt.Println(\"NO\") }\nfunc yes() { fmt.Println(\"YES\") }\n\nfunc main() {\n\tvar n, R, r int\n\tfmt.Scan(&n, &R, &r)\n\tif n == 1 {\n\t\tif R < r {\n\t\t\tno()\n\t\t} else {\n\t\t\tyes()\n\t\t}\n\t\treturn\n\t}\n\tif 2*r > R {\n\t\tno()\n\t\treturn\n\t}\n\tif 2*r == R {\n\t\tif n == 2 {\n\t\t\tyes()\n\t\t} else {\n\t\t\tno()\n\t\t}\n\t\treturn\n\t}\n\ta := math.Asin((float64(r)) / float64((R - r)))\n\tif a*float64(n)*2 > 0.000000001+math.Asin(1)*4 {\n\t\tno()\n\t} else {\n\t\tyes()\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "02656be7c66b078cfd0aab41eede4992", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//140A\npackage main\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, r, R int\n\tvar a float32\n\tfmt.Scan(&n, &R, &r)\n\tif R < r {\n\t\tfmt.Println(\"NO\")\n\t} else if R == r {\n\t\tif n == 1 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t} else {\n\t\tif float64(r) > float64(R/2) {\n\t\t\tif n == 1 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t}\n\t\t} else {\n\t\t\ta = float32(3.14159265358/(math.Asin(float64(float64(r)/float64(R-r)))))\n\t\t\tif a < float32(n) {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t}\n\t\t}\t\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "22db8cf411cd4ca1497cc67a2952458b", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar program string\n\n\tfmt.Scanln(&program)\n\n\tif outputs(program) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc outputs(program string) bool {\n\tfor _, letter := range program {\n\t\tif letter == 'H' || letter == 'Q' ||\n\t\t\tletter == '9' {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "9c3a3d6ba94422945dc90716bc4223e0", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n s := getS()\n for _, ch := range s {\n if ch == 'H' || ch == 'Q' || ch == '9' {\n writer.WriteString(\"YES\\n\")\n return\n }\n }\n writer.WriteString(\"NO\\n\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2aa72c53bf561ffe5de97c94b8a59a53", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t\"unicode/utf8\"\n)\n\nfunc main() {\n\tvar counter int\n\tcounter = 0\n\tvar input string\n\tfmt.Scan(&input)\n\tlen := utf8.RuneCountInString(input)\n\n\tfor i:=0; i0 {\n\t\tfmt.Println(\"YES\")\n\t} else {fmt.Println(\"NO\")}\n}\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e24a9be8462dd8c67a4b503a67b0e548", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t\"unicode/utf8\"\n)\n\nfunc main() {\n\tvar counter int\n\tcounter = 1\n\tvar input string\n\tvar cek bool\n\tcek = false\n\tfmt.Scan(&input)\n\tlen := utf8.RuneCountInString(input)\n\n\tfor i:=1; i= possByReqSymb {\n\t\tfmt.Println(possByReqSymb)\n\t} else {\n\t\tfmt.Println(possBySum)\n\t}\n}", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "c4553c6b555e185bb10173f58ec49da1", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int\n\tvar digits []byte\n\tfor {\n\t\tif _, err := fmt.Fscan(reader, &n, &digits); err != nil {\n\t\t\tbreak\n\t\t}\n\t\tsolve(n, digits)\n\t}\n}\n\nfunc solve(n int, digits []byte) {\n\tcnt := bytes.Count(digits, []byte(\"8\"))\n\tfor x := cnt; x >= 0; x-- {\n\t\tif (n-x)/10 >= x {\n\t\t\tfmt.Println(x)\n\t\t\tbreak\n\t\t}\n\t}\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "805cbd0fe72b0a2b7852a3fead59e493", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar n int\nvar digits []byte\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tfor {\n\t\tif _, err := fmt.Fscan(reader, &n, &digits); err != nil {\n\t\t\tbreak\n\t\t}\n\t\tsolve()\n\t}\n}\n\nfunc solve() {\n\tcnt := bytes.Count(digits, []byte(\"8\"))\n\tfor x := cnt; x >= 0; x-- {\n\t\tif (n-x)/10 >= x {\n\t\t\tfmt.Println(x)\n\t\t\tbreak\n\t\t}\n\t}\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "0d7208398eea3a38fb5b75038147db46", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Buffer(make([]byte, 2048*2048), 2048*2048)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tm, _ := strconv.Atoi(scanner.Text())\n\n\t// answer\n\tans := make([]int, n)\n\n\ts := make([]int, m)\n\td := make([]int, m)\n\tsd := make([]int, m)\n\tc := make([]int, m)\n\tfor i := 0; i < m; i++ {\n\t\tscanner.Scan()\n\t\ts[i], _ = strconv.Atoi(scanner.Text())\n\t\tscanner.Scan()\n\t\td[i], _ = strconv.Atoi(scanner.Text())\n\t\tsd[i] = d[i]\n\t\tscanner.Scan()\n\t\tc[i], _ = strconv.Atoi(scanner.Text())\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tex := nextExam(s, d, c, i+1)\n\t\tif ex == -1 {\n\t\t\tans[i] = 0\n\t\t\tcontinue\n\t\t}\n\t\tif d[ex] == i+1 {\n\t\t\tif c[ex] != 0 {\n\t\t\t\tfmt.Println(-1)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tans[i] = m + 1\n\t\t\tcontinue\n\t\t}\n\t\tans[i] = ex + 1\n\t\tc[ex]--\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Printf(\"%d \", ans[i])\n\t}\n\tfmt.Println()\n}\n\nfunc nextExam(s, d, c []int, today int) int {\n\tminVal := -1\n\tm := len(d)\n\tfor i := 0; i < m; i++ {\n\t\tif d[i] < today {\n\t\t\tcontinue\n\t\t}\n\t\tif d[i] == today {\n\t\t\treturn i\n\t\t}\n\t\tif c[i] == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif s[i] > today {\n\t\t\tcontinue\n\t\t}\n\t\tif minVal == -1 || d[i] < d[minVal] {\n\t\t\tminVal = i\n\t\t}\n\t}\n\treturn minVal\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "e6de4459b0fc6e0ed35f097cc7ef3499", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF978G(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\ttype pair struct{ i, d int }\n\n\tvar n, m, s, d int\n\tFscan(in, &n, &m)\n\tpr := make([]int, m)\n\ttodo := make([][]pair, n+1)\n\thas := make([]bool, n+1)\n\tfor i := range pr {\n\t\tFscan(in, &s, &d, &pr[i])\n\t\tfor j := s; j < d; j++ {\n\t\t\ttodo[j] = append(todo[j], pair{i, d})\n\t\t}\n\t\tif has[d] {\n\t\t\tFprint(out, -1)\n\t\t\treturn\n\t\t}\n\t\thas[d] = true\n\t}\n\tvar ans []interface{}\no:\n\tfor i := 1; i <= n; i++ {\n\t\tif has[i] {\n\t\t\tans = append(ans, m+1)\n\t\t\tcontinue\n\t\t}\n\t\tsort.Slice(todo[i], func(j, k int) bool { return todo[i][j].d < todo[i][k].d })\n\t\tfor _, p := range todo[i] {\n\t\t\tif pr[p.i] > 0 {\n\t\t\t\tpr[p.i]--\n\t\t\t\tans = append(ans, p.i+1)\n\t\t\t\tcontinue o\n\t\t\t}\n\t\t}\n\t\tans = append(ans, 0)\n\t}\n\tfor _, left := range pr {\n\t\tif left > 0 {\n\t\t\tFprint(out, -1)\n\t\t\treturn\n\t\t}\n\t}\n\tFprint(out, ans...)\n}\n\nfunc main() { CF978G(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "88997a11b17b14dc4570e96872b57f00", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nconst (\n\tMaxN = 128\n)\n\ntype exam struct {\n\ts, d, c, index int\n}\n\nvar n, m int\nvar e [MaxN]exam\nvar s [MaxN]int\n\nfunc main() {\n\tfmt.Scanf(\"%d %d\\n\", &n, &m)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scanf(\"%d %d %d\\n\", &e[i].s, &e[i].d, &e[i].c)\n\t\te[i].index = i + 1\n\t}\n\tsort.Slice(e[:m], func(i, j int) bool {\n\t\treturn e[i].d < e[j].d\n\t})\n\tfor i := 0; i < m; i++ {\n\t\ts[e[i].d] = m + 1\n\t}\n\tfor i := 0; i < m; i++ {\n\t\tstart := e[i].s\n\t\tfor ;start <= n; start++ {\n\t\t\tif s[start] == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif start == n+1 || start > e[i].d {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t}\n\t\tfor counter := 0; counter < e[i].c; {\n\t\t\tif s[start + counter] != 0 {\n\t\t\t\tif start + counter == e[i].d {\n\t\t\t\t\tfmt.Println(-1)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tstart++\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\ts[start + counter] = e[i].index\n\t\t\tcounter++\n\t\t}\n\t}\n\tfor i := 1; i <= n; i++ {\n\t\tfmt.Printf(\"%d \", s[i])\n\t}\n}", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "216847fb464512ff3573f499c2993980", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n\tvar s string\n\tfmt.Scan(&s)\n\tif s[0]!='-' {\n\t\tfmt.Print(s)\n\t\treturn\n\t}\n\tn:=len(s)\n\tif (n==3) && (s[0]=='-') && (s[2]=='0') {\n\t\tfmt.Print(0)\n\t\treturn\n\t}\n\t\n\tif s[n-1]= 0 {\n fmt.Println(n)\n }else if x > y {\n fmt.Println(x)\n } else {fmt.Println(y)\n }\n \n }", "lang_cluster": "Go", "tags": ["implementation", "number theory"], "code_uid": "89f15be8455d2f197dc8a457ce095681", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math/rand\"\n\t\"os\"\n)\n\nconst INF = 1000000001\n\ntype Pair struct {\n\tfirst, second int\n}\n\nfunc sort(arr []Pair) []Pair {\n\tif len(arr) < 2 {\n\t\treturn arr\n\t}\n\tleft := 0\n\tright := len(arr) - 1\n\tpivot := rand.Int() % len(arr)\n\n\tarr[pivot], arr[right] = arr[right], arr[pivot]\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i].first > arr[right].first {\n\t\t\tarr[i], arr[left] = arr[left], arr[i]\n\t\t\tleft++\n\t\t}\n\t}\n\n\tarr[left], arr[right] = arr[right], arr[left]\n\n\tsort(arr[:left])\n\tsort(arr[left+1:])\n\treturn arr\n}\n\nfunc sort2(arr []int) []int {\n\tif len(arr) < 2 {\n\t\treturn arr\n\t}\n\tleft := 0\n\tright := len(arr) - 1\n\tpivot := rand.Int() % len(arr)\n\n\tarr[pivot], arr[right] = arr[right], arr[pivot]\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i] < arr[right] {\n\t\t\tarr[i], arr[left] = arr[left], arr[i]\n\t\t\tleft++\n\t\t}\n\t}\n\n\tarr[left], arr[right] = arr[right], arr[left]\n\n\tsort2(arr[:left])\n\tsort2(arr[left+1:])\n\treturn arr\n}\n\nfunc gcd (a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd (b, a % b);\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc solution(reader io.Reader, writer io.Writer) {\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\", &n)\n\tif n >= 0 {\n\t\tfmt.Println(n)\n\t} else {\n\t\tn = -n\n\t\ta := n % 10\n\t\tn /= 10\n\t\tb := n % 10\n\t\tn /= 10\n\t\tn *= 10\n\t\tfmt.Println((n + min(a, b)) * -1)\n\t}\n}\n\nfunc main() {\n\n\t//stdin, err := os.Open(\"file.in\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdin.Close()\n\tstdin := os.Stdin\n\treader := bufio.NewReaderSize(stdin, 1024*1024)\n\n\t//stdout, err := os.Create(\"file.out\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdout.Close()\n\tstdout := os.Stdout\n\twriter := bufio.NewWriterSize(stdout, 1024*1024)\n\tdefer writer.Flush()\n\n\tsolution(reader, writer)\n}", "lang_cluster": "Go", "tags": ["implementation", "number theory"], "code_uid": "bba945e54291c14f85cc0d8e089c0e20", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar s,p,r string\nfunc main(){\n fmt.Scanf(\"%s\\n%s\", &s, &p)\n ls := len(s)\n response:= \"NO\"\n if ls == len(p) {\n for i:=0; i < len(s); i++{\n r = string(s[i]) + r \n }\n if (r==p){\n response = \"YES\"\n }\n }\n fmt.Println(response)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "b0afa169118592fbca25d420daa0df70", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n// spec lets us assume ascii\nfunc test(w1, w2 string) bool {\n\tlw := len(w1)\n\tif lw != len(w2) {\n\t\treturn false\n\t}\n\tfor i := 0; i < lw; i++ {\n\t\tif w1[i] != w2[lw-1-i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n\n}\nfunc main() {\n\tvar word1 string\n\tvar word2 string\n\n\tfmt.Scan(&word1)\n\tfmt.Scan(&word2)\n\n\tif test(word1, word2) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "227c9ee845e82da0acd7d12fe7df4a96", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s,t string\n fmt.Scan(&s,&t)\n var ans bool\n if (len(s) != len(t)) {\n ans = false\n } else {\n ans = true\n len := len(s)\n for i := 0; i < len; i++ {\n if s[i] != t[len-i-1] {\n ans = false\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "eac0e0af7fad4256f8c2e9d0386d5f03", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar y int\n\tfmt.Scanf(\"%v\", &y)\n\tfor i := y + 1; i <= 999999999; i++ {\n\t\tif check(i) {\n\t\t\tfmt.Println(i)\n\t\t\tbreak\n\t\t}\n\t}\n}\n\nfunc check(num int) bool {\n\tvar cache [128]bool\n\tfor num > 0 {\n\t\td := num % 10\n\t\tif cache[d] {\n\t\t\treturn false\n\t\t}\n\t\tcache[d] = true\n\t\tnum /= 10\n\t}\n\treturn true\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "65a4e1a56dfb405bac14b3d2512a1bb7", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\nimport \"strconv\"\n\nfunc tst(n int) (res bool) {\n\tst := strconv.Itoa(n)\n\ts := make([]int, len(st))\n\tfor i, c := range st {\n\t\ts[i] = int(c)\n\t}\n\tsort.Ints(s)\n\tres = false\n\tfor i := 0; i < len(s)-1; i++ {\n\t\tif s[i] == s[i+1] {\n\t\t\tres = true\n\t\t}\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar y int\n\n\tfmt.Scan(&y)\n\n\tn := y + 1\n\tfor ; tst(n); n++ {\n\t}\n\tfmt.Println(n)\n}", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "d7aebc9bed204b60aa437cbbb47d31e8", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar year int\n\tvar beautiful int\n\n\tfmt.Scanln(&year)\n\n\tbeautiful = year + 1\n\tfor !isBeautiful(strconv.Itoa(beautiful)) {\n\t\tbeautiful++\n\t}\n\n\tfmt.Println(beautiful)\n}\n\nfunc isBeautiful(number string) bool {\n\tvar distinctDigits = distinct(number)\n\n\tif len(distinctDigits) == len(number) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc distinct(str string) string {\n\tvar uniqueChars []rune\n\n\tfor _, letter := range str {\n\t\tif !contains(uniqueChars, letter) {\n\t\t\tuniqueChars = append(uniqueChars, letter)\n\t\t}\n\t}\n\n\treturn string(uniqueChars)\n}\n\nfunc contains(slice []rune, char rune) bool {\n\tfor _, element := range slice {\n\t\tif element == char {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "c7bb2f21e0a4c4d551693df2876fc0ba", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"text/scanner\"\n)\n\nfunc check(e error) {\n\tif e != nil {\n\t\tpanic(e)\n\t}\n}\n\nfunc main() {\n\tvar w, y int // first inputs to the problem\n\n\tdat, err := ioutil.ReadAll(os.Stdin)\n\tcheck(err)\n\tvar str_data string = string(dat);\n\n\treader := strings.NewReader(str_data)\n\t\n\tvar scn scanner.Scanner\n\tscn.Init(reader)\n\n scn.Scan()\n\tvar text string = scn.TokenText();\n\t\n\tw, err = strconv.Atoi(text)\n\tcheck(err)\n\n\tscn.Scan()\n\ttext = scn.TokenText();\n\t\n\ty, err = strconv.Atoi(text)\n\tcheck(err)\n\n\tvar max int\n\tif w > y {\n\t\tmax = w\n\t} else {\n\t\tmax = y\n\t}\n\n\t// if max is 6, numerator is 1\n\t// if max is 1, numerator is 6\n\tvar numerator int = 6 - max + 1\n\n\t// now let's reduce if we can\n\tif numerator == 6 {\n\t\tfmt.Print(\"1/1\");\n\t} else if numerator == 4 {\n\t\tfmt.Print(\"2/3\")\n\t} else if numerator == 3 {\n\t\tfmt.Print(\"1/2\")\n\t} else if numerator == 2 {\n\t\tfmt.Print(\"1/3\")\n\t} else if numerator == 1 {\n\t\tfmt.Print(\"1/6\")\n\t} else {\n\t\tfmt.Print(\"5/6\")\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "probabilities"], "code_uid": "ac49159c49026cd7fd77699300a65d85", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// http://codeforces.com/problemset/problem/9/A\n// A. Die Roll\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\ty, w int32\n\t)\n\n\tans := [...]string{\"0/1\", \"1/6\", \"1/3\", \"1/2\", \"2/3\", \"5/6\", \"1/1\"}\n\n\tfmt.Scan(&y)\n\tfmt.Scan(&w)\n\tif y > w {\n\t\tw = y\n\t}\n\tfmt.Println(ans[6-w+1])\n\n}\n", "lang_cluster": "Go", "tags": ["math", "probabilities"], "code_uid": "9979b3aadd12deba72a4754971d7fe14", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar y, w int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &y, &w); err != nil {\n\t\treturn\n\t}\n\n\twin := 6 - max(y, w) + 1\n\tif win == 0 { // Impossible here\n\t\tfmt.Println(\"0/1\")\n\t} else if win == 6 {\n\t\tfmt.Println(\"1/1\")\n\t} else {\n\t\tg := gcd(win, 6)\n\t\tfmt.Printf(\"%d/%d\\n\", win/g, 6/g)\n\t}\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc gcd(x, y int) int {\n\tif x < y {\n\t\tx, y = y, x\n\t}\n\tif y == 0 {\n\t\treturn x\n\t} else {\n\t\treturn gcd(y, x%y)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "probabilities"], "code_uid": "791f42966a4a6bf06bfa38c7d55d6231", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\n\n\n\nfunc main() {\n\tvar v, y, d int\n\tb := 6\n\tfmt.Scan(&v, &y)\n\tif v >= y{\n\t\td = b+1 - v\n\t}else{\n\t\td = b+1 - y\n\t}\n\tif d % 2 == 0{\n\t\td /= 2\n\t\tb /= 2\n\t}\n\tif d % 3 == 0{\n\t\td /= 3\n\t\tb /= 3\n\t}\n\tfmt.Printf(\"%d/%d\", d, b)\n}", "lang_cluster": "Go", "tags": ["math", "probabilities"], "code_uid": "1268703994fac7218893af31bec51140", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := readInt()\n\tb := readInt()\n\tif a < b {\n\t\ta = b\n\t}\n\n\tar := []string{\"0/1\", \"1/1\", \"5/6\", \"2/3\", \"1/2\", \"1/3\", \"1/6\"}\n\tfmt.Println(ar[a])\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n", "lang_cluster": "Go", "tags": ["math", "probabilities"], "code_uid": "864b1014c644f9f22d640f45abb4a49c", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc GCD(a,b int) int { if b == 0 { return a } else { return GCD(b,a%b) } }\nfunc max(a,b int) int { if a > b { return a } else { return b } }\n\nfunc main() {\n var Y,W int\n fmt.Scan(&Y,&W)\n n, d := 6-max(Y,W)+1, 6\n gcd := GCD(n,d)\n n /= gcd\n d /= gcd\n fmt.Printf(\"%d/%d\\n\",n,d)\n}\n", "lang_cluster": "Go", "tags": ["math", "probabilities"], "code_uid": "6dbf4b0719bf87e628f5facceabcdabb", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tvar mx int = a\n\tif b > a {\n\t\tmx = b\n\t}\n\tif mx == 6 {\n\t\tfmt.Print(1, \"/\", 6)\n\t} else if mx == 5 {\n\t\tfmt.Print(1, \"/\", 3)\n\t} else if mx == 4 {\n\t\tfmt.Print(1, \"/\", 2)\n\t} else if mx == 3 {\n\t\tfmt.Print(2, \"/\", 3)\n\t} else if mx == 2 {\n\t\tfmt.Print(5, \"/\", 6)\n\t} else {\n\t\tfmt.Print(1, \"/\", 1)\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["math", "probabilities"], "code_uid": "e223be3cf1d7f48e72f94d4899dfd39e", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n \nimport \"fmt\"\n \nfunc main() {\n\tvar yScore int\n\tfmt.Scan(&yScore)\n\tvar wScore int\n\tfmt.Scan(&wScore)\n\tvar maxNo int\n\t\n\tif yScore > wScore {\n\t\tmaxNo = yScore\n\t} else if yScore < wScore{\n\t\tmaxNo = wScore\n\t} else {\n\t\tmaxNo = wScore\n\t}\n\tmaxNo = 7 - maxNo\n\t\n\tif maxNo == 0 {\n\t\tmaxNo = 1 \n\t}\n\n\tif 6 % maxNo == 0 {\n\t\ttheDenominator := 6 / maxNo\n\t\tfmt.Printf(\"1/%d\", theDenominator)\n\t} else if 6 % maxNo == 2 {\n\t\ttheNumerator := maxNo / 2 \n\t\tfmt.Printf(\"%d/3\", theNumerator)\n\t} else {\n\t\ttheNumerator := maxNo\n\t\tfmt.Printf(\"%d/6\", theNumerator)\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "probabilities"], "code_uid": "4bbc17c7e00123f4811cde00bbce8483", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar p, y int\n\tr := RapidReader()\n\tfmt.Fscan(r, &p, &y)\n\tfor i := y; i >= 2 && i >= y-1000; i-- {\n\t\tif i <= p {\n\t\t\tcontinue\n\t\t}\n\t\tundivisible := true\n\t\tfor k := 2; k <= p && k < 31623; k++ {\n\t\t\tif i%k == 0 {\n\t\t\t\tundivisible = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif undivisible {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n\nfunc RapidReader() io.Reader {\n\tb, _ := ioutil.ReadAll(os.Stdin)\n\treturn bytes.NewReader(b)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "67bedaf2b67a0b407396a17f50238c41", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner\nvar t [1e6 + 1]bool\n\nfunc init_scanner() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024 * 20\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tscanner.Scan()\n\tval, _ := strconv.Atoi(scanner.Text())\n\treturn val\n}\n\nfunc is_prime(x int) bool {\n\tfor i := 2; i*i <= x; i++ {\n\t\tif x%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc divides(x int, s []int) bool {\n\tfor _, i := range s {\n\t\tif x%i == 0 {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tinit_scanner()\n\tp, y := readInt(), readInt()\n\n\tvar s []int\n\tfor i := 2; i <= int(math.Min(float64(p), math.Floor(math.Sqrt(float64(y))))); i++ {\n\t\tif is_prime(i) {\n\t\t\ts = append(s, i)\n\t\t}\n\t}\n\n\tans := -1\n\tfor i := y; i > int(math.Max(float64(p), float64(y-100000))); i-- {\n\t\tif !divides(i, s) {\n\t\t\tans = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "abd4f7853a768363820acb27e67a84f2", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/937/B\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tp, y int\n)\n\nfunc main() {\n\tp, y = ReadInt2()\n\n\tfor i := y; i > p; i-- {\n\t\tmemo := TrialDivision(i)\n\t\tok := true\n\t\tfor k := range memo {\n\t\t\tif k <= p {\n\t\t\t\tok = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif ok {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n\n// TrialDivision returns the result of prime factorization of integer N.\nfunc TrialDivision(n int) map[int]int {\n\tvar i, exp int\n\tp := map[int]int{}\n\n\tif n <= 1 {\n\t\tpanic(errors.New(\"[argument error]: TrialDivision only accepts a NATURAL number\"))\n\t}\n\n\tfor i = 2; i*i <= n; i++ {\n\t\texp = 0\n\t\tfor n%i == 0 {\n\t\t\texp++\n\t\t\tn /= i\n\t\t}\n\n\t\tif exp == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tp[i] = exp\n\t}\n\tif n > 1 {\n\t\tp[n] = 1\n\t}\n\n\treturn p\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "a9c4f2a1b86805130fc7ba4cdd03d1f9", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn, m, a, b := int64(0), int64(0), int64(0), int64(0)\n\tfmt.Fscanf(in, \"%d %d\\n\", &n, &m)\n\tfmt.Fscanf(in, \"%d %d\\n\", &a, &b)\n\tmin := int64(n * m)\n\tmax := int64(0)\n\tall := int64(n * m)\n\tfor i := int64(0); i < n; i++ {\n\t\tnextS := int64(i)*int64(m) + int64(b)\n\t\tl := nextS - int64(a)\n\t\tif l <= 0 {\n\t\t\tl += all\n\t\t}\n\t\tgcdS := gcd(l, all)\n\t\ttmp := all / gcdS\n\t\tif tmp > max {\n\t\t\tmax = tmp\n\t\t}\n\t\tif tmp < min {\n\t\t\tmin = tmp\n\t\t}\n\t\tnextS = int64(i)*int64(m) + int64(m) - int64(b)\n\t\tl = nextS - int64(a)\n\t\tif l <= 0 {\n\t\t\tl += all\n\t\t}\n\t\tgcdS = gcd(l, all)\n\t\ttmp = all / gcdS\n\t\tif tmp > max {\n\t\t\tmax = tmp\n\t\t}\n\t\tif tmp < min {\n\t\t\tmin = tmp\n\t\t}\n\t}\n\ta = m - a\n\tfor i := int64(0); i < n; i++ {\n\t\tnextS := int64(i)*int64(m) + int64(b)\n\t\tl := nextS - int64(a)\n\t\tif l <= 0 {\n\t\t\tl += all\n\t\t}\n\t\tgcdS := gcd(l, all)\n\t\ttmp := all / gcdS\n\t\tif tmp > max {\n\t\t\tmax = tmp\n\t\t}\n\t\tif tmp < min {\n\t\t\tmin = tmp\n\t\t}\n\t\tnextS = int64(i)*int64(m) + int64(m) - int64(b)\n\t\tl = nextS - int64(a)\n\t\tif l <= 0 {\n\t\t\tl += all\n\t\t}\n\t\tgcdS = gcd(l, all)\n\t\ttmp = all / gcdS\n\t\tif tmp > max {\n\t\t\tmax = tmp\n\t\t}\n\t\tif tmp < min {\n\t\t\tmin = tmp\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d %d\\n\", min, max)\n\treturn\n}\n\nfunc gcd(a, b int64) int64 {\n\tif a%b == 0 {\n\t\treturn b\n\t}\n\treturn gcd(b, a%b)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "ef87d69f2114540b247858f97659c095", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"bytes\"\n \"fmt\"\n \"os\"\n)\n\ntype Prob struct {\n in *bufio.Reader\n}\n\nfunc (prob *Prob) NextLine() string {\n line, _, _ := prob.in.ReadLine()\n return string(line[:])\n}\n\nfunc (prob *Prob) NextByte() byte {\n bt, _ := prob.in.ReadByte()\n return bt\n}\n\nfunc (prob *Prob) Next() string {\n var buff bytes.Buffer\n bt := prob.NextByte()\n for bt == '\\n' || bt == ' ' {\n bt = prob.NextByte()\n }\n for bt != '\\n' && bt != ' ' {\n buff.WriteByte(bt)\n bt = prob.NextByte()\n }\n return buff.String()\n}\n\nfunc (prob *Prob) NextInt() int {\n var x int\n bt := prob.NextByte()\n for bt > '9' || bt < '0' {\n if bt == '-' {\n return -prob.NextInt()\n }\n bt = prob.NextByte()\n }\n for bt >= '0' && bt <= '9' {\n x = x * 10 + int(bt - '0')\n bt = prob.NextByte()\n }\n return x\n}\n\nfunc gcd(a int64, b int64) int64 {\n if a == 0 {\n return b\n }\n return gcd(b % a, a)\n}\n\nfunc (prob Prob) Solve() {\n n := int64(prob.NextInt())\n k := int64(prob.NextInt())\n a := int64(prob.NextInt())\n b := int64(prob.NextInt())\n\n ma := int64(-1)\n mi := int64(-1)\n s1 := a\n s2 := (k - a) % k\n for i := int64(1); i <= n; i++ {\n t1 := i * k + b\n t2 := i * k + (k - b) % k\n r1 := n * k / gcd(n * k, t1 - s1)\n if ma == -1 || ma < r1 {\n ma = r1\n }\n if mi == -1 || mi > r1 {\n mi = r1\n }\n r1 = n * k / gcd(n * k, t1 - s2)\n if ma == -1 || ma < r1 {\n ma = r1\n }\n if mi == -1 || mi > r1 {\n mi = r1\n }\n r1 = n * k / gcd(n * k, t2 - s1)\n if ma == -1 || ma < r1 {\n ma = r1\n }\n if mi == -1 || mi > r1 {\n mi = r1\n }\n r1 = n * k / gcd(n * k, t2 - s2)\n if ma == -1 || ma < r1 {\n ma = r1\n }\n if mi == -1 || mi > r1 {\n mi = r1\n }\n }\n\n fmt.Printf(\"%d %d\\n\", mi, ma)\n}\n\n\nfunc main() {\n Prob{in: bufio.NewReader(os.Stdin)}.Solve()\n}", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "6db95225e10115775c644dc160b3c4b4", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t// \"math/big\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc p(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc pln(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc scan(a ...interface{}) { fmt.Fscan(reader, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc gcd(a, b int64) int64 {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc posMod(a, mod int64) int64 {\n\ta = a % mod\n\tif a <= 0 {\n\t\ta += mod\n\t}\n\treturn a\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tvar n, k, a, b, g, nk int64\n\tvar x1, x2, y1, y2 int64\n\tvar l1, l2, l3, l4 int64\n\tvar mn, mx int64\n\tscan(&n, &k)\n\tscan(&a, &b)\n\n\tnk = n * k\n\n\tmn, mx = nk, 1\n\n\tfor i := int64(0); i < n; i++ {\n\t\tx1, x2 = posMod(1-a, nk), posMod(1+a, nk)\n\t\ty1, y2 = posMod(i*k+1-b, nk), posMod(i*k+1+b, nk)\n\t\t// pln(i, \"---------------------------------------------------\")\n\t\t// pln(x1, x2, y1, y2)\n\n\t\tl1, l2, l3, l4 = posMod(y1-x1, nk), posMod(y2-x1, nk), posMod(y1-x2, nk), posMod(y2-x2, nk)\n\n\t\tg = gcd(l1, nk)\n\t\t// pln(i, l1, g)\n\t\tmn = min(mn, nk/g)\n\t\tmx = max(mx, nk/g)\n\n\t\tg = gcd(l2, nk)\n\t\t// pln(i, l2, g)\n\t\tmn = min(mn, nk/g)\n\t\tmx = max(mx, nk/g)\n\n\t\tg = gcd(l3, nk)\n\t\t// pln(i, l3, g)\n\t\tmn = min(mn, nk/g)\n\t\tmx = max(mx, nk/g)\n\n\t\tg = gcd(l4, nk)\n\t\t// pln(i, l4, g)\n\t\tmn = min(mn, nk/g)\n\t\tmx = max(mx, nk/g)\n\t}\n\t// pln(\"RESULT = \", mn, mx)\n\tpln(mn, mx)\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "9d329b8e7dde7309b0f411eacb5b74c2", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc Solve(input io.Reader) (result string) {\n\tvar n int\n\tfmt.Fscan(input, &n)\n\tn += 2\n\tarray := make([]int, n)\n\tfor i := 1; i < n-1; i++ {\n\t\tfmt.Fscan(input, &(array[i]))\n\t}\n\tindex := 1\n\tfor ; index < n; index++ {\n\t\tif array[index] <= array[index-1] {\n\t\t\tbreak\n\t\t}\n\t}\n\tfor ; index < n; index++ {\n\t\tif array[index] != array[index-1] {\n\t\t\tbreak\n\t\t}\n\t}\n\tfor ; index < n; index++ {\n\t\tif array[index] >= array[index-1] {\n\t\t\tbreak\n\t\t}\n\t}\n\tif index < n {\n\t\treturn \"NO\\n\"\n\t}\n\treturn \"YES\\n\"\n}\n\nfunc main() {\n\tfmt.Print(Solve(os.Stdin))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ae0b77db26a2a75db5af9ba10f246cc0", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tvar n int\n\tfor I(&n) == nil {\n\t\tsolve(n)\n\t}\n\tw.Flush()\n}\n\nfunc solve(n int) {\n\tin := make([]int, n)\n\tfor i := range in {\n\t\tI(&in[i])\n\t}\n\tvar o int\n\tfor o < n-1 && in[o] < in[o+1] {\n\t\to++\n\t}\n\tfor o < n-1 && in[o] == in[o+1] {\n\t\to++\n\t}\n\tfor o < n-1 && in[o] > in[o+1] {\n\t\to++\n\t}\n\tif o == n-1 {\n\t\tO(\"YES\\n\")\n\t} else {\n\t\tO(\"NO\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d3160f8be8988dd8df05e40f08d6d391", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\ta := make([]int, n)\n\tfreq := make([]int, 1002)\n\tstart := make([]int, 1002)\n\tend := make([]int, 1002)\n\tup := 0\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = readInt()\n\t\tif freq[a[i]] == 0 {\n\t\t\tstart[a[i]] = i\n\t\t}\n\t\tfreq[a[i]]++\n\t\tend[a[i]] = i\n\t\tup = max(up, a[i])\n\t}\n\tindex := up\n\tfor i := 1; i <= start[index]; i++ {\n\t\tif a[i] <= a[i-1] {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfor i := start[index]; i <= end[index]; i++ {\n\t\tif a[i] != index {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfor i := end[index] + 1; i < len(a); i++ {\n\t\tif a[i] >= a[i-1] {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"YES\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "80fb9f253d5a8cf4ccea8adad93d601d", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n,m,k int\n\tfmt.Scan(&n)\n\tfmt.Scan(&m)\n\tfmt.Scan(&k)\n\n if m==n&&n==k&&k==m {\n\t fmt.Println(\"Yes\")\n\t return\n\t}\n\tfor n>0{\n\t\tn--\n\t\tm--\n\t\tk--\n\t}\n\tif m>=0&&k>=0 {\n\t\tfmt.Println(\"Yes\")\n\t}else{\n\t\tfmt.Println(\"No\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4b0557a4773ab5a3036213278b44e701", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n) \n\nfunc main () {\n\tvar n, m, k int\n\tvar count int = 0\n\tfmt.Scan(&n, &m, &k)\n\tif m>=n {\n\t\tcount++\n\t} else {\n\t\tcount = 0\n\t}\n\tif k>=n {\n\t\tcount++\n\t} else {\n\t\tcount = 0\n\t}\n\tif count==2 {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "6d74c176173ee898e3f660a342a1dee7", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, k int\n\tfmt.Scan(&n, &m, &k)\n\tif n <= m && n <= k {\n\t\tfmt.Print(\"Yes\")\n\t} else {\n\t\tfmt.Print(\"No\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "75a53bee10b348cb178766ff7ac001fd", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,d int\n\ts :=0\n\tm :=true\n\tfmt.Scan(&n)\n\tfor n!=0 {\n\t\td = n%10\n\t\tn/=10\n\t\tif d==1 {\n\t\t\ts=0\n\t\t} else if d==4 && s<2 {\n\t\t\ts++\n\t\t} else {\n\t\t\tm=false\n\t\t}\n\t}\n\tif s!=0 {\n\t\tm=false\n\t}\n\tif m==true {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\tfmt.Println(\"NO\")\n\t}\n}\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "b5a859cfa9a6490132ae1ad63ff13014", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n ans, in := true, 0\n for in < len(s) {\n if s[in] == '1' {\n in++\n if in < len(s) {\n if s[in] == '4' { in++ }\n if in < len(s) {\n if s[in] == '4' { in++ }\n }\n }\n } else {\n ans = false\n break\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "37a5bb0dd8d9264a1a3624a403c36523", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar num string\n\tfmt.Scan(&num)\n\n\tfor _, v := range []string{\"144\", \"14\", \"1\"} {\n\t\tnum = strings.Replace(num, v, \" \", -1)\n\t}\n\tnum = strings.Replace(num, \" \", \"\", -1)\n\n\tif len(num) > 0 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "dfb92723c94f3e44ad199c8550253a57", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scanf(\"%d\\n%d\\n%d\", &a, &b, &c)\n\tif a == 1 && b != 1 && c != 1 {\n\t\tfmt.Println((a + b) * c)\n\t}\n\tif a != 1 && b != 1 && c == 1 {\n\t\tfmt.Println(a * (b + c))\n\t}\n\tif b == 1 && a != 1 && c != 1 {\n\t\tif a > c {\n\t\t\tfmt.Println(a * (b + c))\n\t\t} else {\n\t\t\tfmt.Println((a + b) * c)\n\t\t}\n\t}\n\tif a == 1 && b == 1 && c == 1 {\n\t\tfmt.Println(a + b + c)\n\t}\n\tif a != 1 && b != 1 && c != 1 {\n\t\tfmt.Println(a * b * c)\n\t}\n\tif a == 1 && b != 1 && c == 1 {\n\t\tfmt.Println(a + b + c)\n\t}\n\tif a == 1 && b == 1 && c != 1 {\n\t\tfmt.Println((a + b) * c)\n\t}\n\tif a != 1 && b == 1 && c == 1 {\n\t\tfmt.Println(a * (b + c))\n\t}\n}", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "9a47d60774884a66e324be609c87ce4f", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n \nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\tif a != 1 && b != 1 && c != 1 {\n\t\tfmt.Print(a * b * c)\n\t\treturn\n\t}\n\tvar ans []int\n ans = append(ans, (a + b) * c)\n\tans = append(ans, a * (b + c))\n ans = append(ans, a + b + c)\n\tsort.Ints(ans)\n\tfmt.Print(ans[2])\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "674df638d897da92780c8ab1203e069d", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nvar in *bufio.Reader = bufio.NewReader(os.Stdin)\nvar out *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc f(x, y, z int, c chan int) {\n\tc <- x + y + z\n\tc <- x + y * z\n\tc <- (x + y) * z\n\tc <- x * y + z\n\tc <- x * (y + z)\n\tc <- x * y * z\n\tclose(c)\n}\n\nfunc max(x, y int) int {\n\tif (x < y) {\n\t\treturn y\n\t} else {\n\t\treturn x\n\t}\n}\n\nfunc main() {\n\tdefer out.Flush()\n\n\tvar a, b, c int\n\tfmt.Fscan(in, &a, &b, &c)\n\n\tch := make(chan int)\n\tgo f(a,b,c, ch)\n\n\tvar res int\n\tfor i := range ch {\n\t\tres = max(res, i)\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "9666d1dbbd994ddc97a19aa8d3c525c0", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main(){\n\tvar n,m,K,len,pos int32\n\tfmt.Scanf(\"%d%d%d\\n\",&n,&m,&K)\n\tm--\n\tlen,pos= 123456789,123456789\n\tvar i int32\n\tfor i=0;i0&& price<=K{\n\t\t\tif int32(math.Abs(float64(m-i)))< len{\n\t\t\t\tlen,pos=int32(math.Abs(float64(m-i))),i\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d\\n\",int32(math.Abs(float64(pos-m)))*10)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "cce7e25b72eb93e696b94055bfee6691", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tm := readInt() - 1\n\tk := readInt()\n\tans := math.MaxInt32\n\tfor i := 0; i < n; i++ {\n\t\ta := readInt()\n\t\tif a != 0 && a <= k {\n\t\t\tif ans > 10*abs(i-m) {\n\t\t\t\tans = 10 * abs(i-m)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "e2c91a3cee022c6e2859cc2d2e0cd644", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main(){\n\tvar n,m,K,len,pos int32\n\tfmt.Scanf(\"%d%d%d\\n\",&n,&m,&K)\n\tm--\n\tlen,pos= 123456789,123456789\n\tvar i int32\n\tfor i=0;i0&& price<=K{\n\t\t\tif int32(math.Abs(float64(m-i)))< len{\n\t\t\t\tlen,pos=int32(math.Abs(float64(m-i))),i\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d\\n\",int32(math.Abs(float64(pos-m)))*10)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "1c6d5ac2de0053cae019c26376bdd064", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"flag\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\t\"runtime/pprof\"\n\t\"strconv\"\n\t\"math\"\n)\n\nfunc run(s *InOut) {\n\ta, b, c := s.Next(), s.Next(), s.Next()\n\tif (a + b + c) % 2 > 0 {\n\t\ts.Println(\"Impossible\")\n\t\treturn\n\t}\n\tfor x := 0; x <= min(a, b); x++ {\n\t\ty := b - x\n\t\tz := (a + b + c) / 2 - x - y\n\t\tif a == x + z && b == x + y && c == y + z {\n\t\t\ts.Println(x, \" \", y, \" \", z)\n\t\t\treturn\n\t\t}\n\t}\n\ts.Println(\"Impossible\")\n}\n\nfunc min(a... int) int {\n\tr := math.MaxInt32;\n\tfor _, e := range a {\n\t\tif r > e {\n\t\t\tr = e\n\t\t}\n\t}\n\n\treturn r\n}\n\nfunc main() {\n\tflag.Parse()\n\tif *cpuprofile != \"\" {\n\t\tf, err := os.Create(*cpuprofile)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tpprof.StartCPUProfile(f)\n\t\tdefer pprof.StopCPUProfile()\n\t}\n\ts := NewInOut(os.Stdin, os.Stdout)\n\tdefer s.Flush()\n\n\trun(s)\n}\n\nvar cpuprofile = flag.String(\"cpuprofile\", \"\", \"write cpu profile to file\")\n\ntype InOut struct {\n\t*bufio.Reader\n\t*bufio.Writer\n}\n\nfunc NewInOut(r io.Reader, w io.Writer) *InOut {\n\treturn &InOut{bufio.NewReader(r), bufio.NewWriter(w)}\n}\n\n// Get Next Integer\nfunc (s *InOut) Next() (r int) {\n\tb, _ := s.ReadByte()\n\tp := 1\n\tfor (b < '0' || '9' < b) && b != '-' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tif b == '-' {\n\t\tp = -1\n\t\tb, _ = s.ReadByte()\n\t}\n\tfor '0' <= b && b <= '9' {\n\t\tr = 10*r + int(b-'0')\n\t\tb, _ = s.ReadByte()\n\t}\n\treturn r * p\n}\n\nfunc (s *InOut) NextInt64() (r int64) {\n\tb, _ := s.ReadByte()\n\tp := int64(1)\n\tfor (b < '0' || '9' < b) && b != '-' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tif b == '-' {\n\t\tp = -1\n\t\tb, _ = s.ReadByte()\n\t}\n\tfor '0' <= b && b <= '9' {\n\t\tr = 10*r + int64(b-'0')\n\t\tb, _ = s.ReadByte()\n\t}\n\treturn r * p\n}\n\n// Get Next Line String\nfunc (s *InOut) NextLine() (r string) {\n\tb, _ := s.ReadByte()\n\tfor b == '\\r' || b == '\\n' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tbuf := make([]byte, 0)\n\tfor ; b != '\\r' && b != '\\n'; b, _ = s.ReadByte() {\n\t\tbuf = append(buf, b)\n\t}\n\treturn string(buf)\n}\n\n// Get Next String using delimiter whitespace\nfunc (s *InOut) NextStr() (r string) {\n\treturn string(s.NextBytes())\n}\n\n// Get Next String using delimiter whitespace\nfunc (s *InOut) NextBytes() (r []byte) {\n\tb, _ := s.ReadByte()\n\tfor b == '\\n' || b == ' ' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tbuf := make([]byte, 0)\n\tfor ; b != '\\n' && b != ' '; b, _ = s.ReadByte() {\n\t\tbuf = append(buf, b)\n\t}\n\treturn buf\n}\n\n// Print Strings using the suitable way to change type\nfunc (s *InOut) Print(os ...interface{}) {\n\tfor _, o := range os {\n\t\tswitch o.(type) {\n\t\tcase byte:\n\t\t\ts.WriteByte(o.(byte))\n\t\tcase string:\n\t\t\ts.WriteString(o.(string))\n\t\tcase int:\n\t\t\ts.WriteString(strconv.Itoa(o.(int)))\n\t\tcase int64:\n\t\t\ts.WriteString(strconv.FormatInt(o.(int64), 10))\n\t\tdefault:\n\t\t\ts.WriteString(fmt.Sprint(o))\n\t\t}\n\t}\n}\n\n// Print Strings using the suitable way to change type with new line\nfunc (s *InOut) Println(os ...interface{}) {\n\tfor _, o := range os {\n\t\ts.Print(o)\n\t}\n\ts.Print(\"\\n\")\n}\n\n// Print immediately with new line (for debug)\nfunc (s *InOut) PrintlnNow(o interface{}) {\n\tfmt.Println(o)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "graphs"], "code_uid": "6563cb84e979c25a759757aad9f1adf5", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 344B-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n [3]int\n fmt.Scan(&n[0], &n[1], &n[2])\n b := n[0] + n[1] + n[2]\n if b%2 == 0 && n[0] <= n[1]+n[2] && n[1] <= n[0]+n[2] && n[2] <= n[0]+n[1] {\n fmt.Print((n[0] + n[1] - n[2]) / 2)\n fmt.Print(\" \")\n fmt.Print((n[2] + n[1] - n[0]) / 2)\n fmt.Print(\" \")\n fmt.Print((n[0] + n[2] - n[1]) / 2)\n fmt.Println()\n } else {\n fmt.Println(\"Impossible\")\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "graphs"], "code_uid": "6ae8ac71e40a06128a20f963c482785d", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var x, y, z int\n fmt.Scan(&x, &y, &z)\n if (x + y + z)%2 == 1 {\n fmt.Println(\"Impossible\")\n return\n }\n b := (y + z - x)/2\n a := y - b\n c := z - b\n if a < 0 || b < 0 || c < 0 {\n fmt.Println(\"Impossible\")\n } else {\n fmt.Println(a, b, c)\n }\n}\n\n", "lang_cluster": "Go", "tags": ["brute force", "math", "graphs"], "code_uid": "b3d8b3d5bfdd4dd692e0cffa3be50e82", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n)\n\nfunc main() {\n\tvar x, y, z, g, p, b int\n\tfor {\n\t\tif _, err := fmt.Scan(&x, &y, &z, &g, &p, &b); err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif x > g || y > g+p-x || z > g+p+b-x-y {\n\t\t\tfmt.Println(\"NO\")\n\t\t} else {\n\t\t\tfmt.Println(\"YES\")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "13c9b3346049b0ffe538f423d1dd6f56", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\n\nfunc main() {\n var x,y,z,a,b,c int;\n fmt.Scan(&x,&y,&z,&a,&b,&c);\n\t\ty += x; b+= a;\n\t\tz += y; c+= b;\n\t\tif a >= x && b >= y && c>=z {\n\t\t\tfmt.Println(\"YES\");\n\t\t} else {\n\t\t\tfmt.Println(\"NO\");\n\t\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "571934410eaf4150a8efdedb0737c70f", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc eval(a, d, m, g, p, b int) bool {\n\tif a > g {\n\t\treturn false\n\t}\n\tg -= a\n\tif d > (g + p) {\n\t\treturn false\n\t}\n\trest := g + p - d\n\tif m > (rest + b) {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc main() {\n\tvar a, d, m int\n\tfmt.Scanf(\"%d %d %d\\n\", &a, &d, &m)\n\n\tvar g, p, b int\n\tfmt.Scanf(\"%d %d %d\\n\", &g, &p, &b)\n\n\tif eval(a, d, m, g, p, b) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "5ddf68ce7892580cc381f4fca72a5ba4", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n)\n\n// HelpfulSum sorts numbers in a string in non-increasing order.\nfunc HelpfulSum(s string) string {\n\tnums := strings.Split(s, \"+\")\n\tsort.StringSlice(nums).Sort()\n\treturn strings.Join(nums, \"+\")\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tfmt.Println(HelpfulSum(scanner.Text()))\n}\n", "lang_cluster": "Go", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "b27d0c24108b8c8fccd8abbde9420cc7", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar input string\n\tfmt.Scan(&input)\n\trecord := make([]int, 3)\n\tfor _, ch := range input {\n\t\tswitch ch{\n\t\tcase '1':\n\t\t\trecord[0] += 1\n\t\tcase '2':\n\t\t\trecord[1] += 1\n\t\tcase '3':\n\t\t\trecord[2] += 1\n\t\tdefault:\n\t\t\tcontinue\n\t\t}\n\t}\n\tvar prefix bool\n\tfor offset, v := range record {\n\t\tif v == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tif offset != 0 && prefix {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\n\t\tfor i := 0; i < v; i++ {\n\t\t\tfmt.Print(offset + 1)\n\t\t\tif i != v - 1 {\n\t\t\t\tfmt.Print(\"+\")\n\t\t\t}\n\t\t}\n\n\t\tprefix = true\n\t}\n}\n", "lang_cluster": "Go", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "3d8529b8df87c6da58170bda05541a84", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math/rand\"\n\t\"os\"\n\t\"strings\"\n)\n\nconst INF = 1000000001\n\ntype Pair struct {\n\tfirst, second int\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\nfunc sort(arr []int) []int {\n\tif len(arr) < 2 {\n\t\treturn arr\n\t}\n\tleft := 0\n\tright := len(arr) - 1\n\tpivot := rand.Int() % len(arr)\n\n\tarr[pivot], arr[right] = arr[right], arr[pivot]\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i] < arr[right] {\n\t\t\tarr[i], arr[left] = arr[left], arr[i]\n\t\t\tleft++\n\t\t}\n\t}\n\n\tarr[left], arr[right] = arr[right], arr[left]\n\n\tsort(arr[:left])\n\tsort(arr[left+1:])\n\treturn arr\n}\n\nfunc solution(reader io.Reader, writer io.Writer) {\n\tvar s string\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\n\ta := strings.Split(s, \"+\")\n\tb := make([]int, len(a))\n\n\tfor i := 0; i < len(a); i++ {\n\t\tfmt.Sscanf(a[i], \"%d\", &b[i])\n\t}\n\n\tb = sort(b)\n\n\tfor i := 0; i < len(b); i++ {\n\t\tfmt.Fprintf(writer, \"%d\", b[i])\n\t\tif i < len(b) - 1 {\n\t\t\tfmt.Fprintf(writer, \"+\")\n\t\t}\n\t}\n\n}\n\nfunc main() {\n\n\t//stdin, err := os.Open(\"file.in\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdin.Close()\n\tstdin := os.Stdin\n\treader := bufio.NewReaderSize(stdin, 1024*1024)\n\n\t//stdout, err := os.Create(\"file.out\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdout.Close()\n\tstdout := os.Stdout\n\twriter := bufio.NewWriterSize(stdout, 1024*1024)\n\tdefer writer.Flush()\n\n\tsolution(reader, writer)\n}", "lang_cluster": "Go", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "52010e8017c6362e48c5260a69fa74b6", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n// @snippet \nimport \"fmt\"\nimport \"io\"\nimport \"os\"\nimport \"strings\"\nimport \"text/scanner\"\n// @snippet \ntype Int int64\ntype IntSlice []Int\n// @snippet \nvar sc scanner.Scanner\n\nfunc ReadInt(n *Int) bool {\n tok := sc.Scan()\n if tok != scanner.EOF {\n fmt.Sscan(sc.TokenText(), &n)\n return true\n } else {\n return false\n }\n}\n\nfunc ReadString(s *string) bool {\n tok := sc.Scan()\n if tok != scanner.EOF {\n *s = sc.TokenText()\n return true\n } else {\n return false\n }\n}\n// @snippet \nfunc Stdin() io.Reader {\n return os.Stdin\n}\n\nfunc Strin(s string) io.Reader {\n return strings.NewReader(s)\n}\n// @snippet \n\nfunc min(a rune, b rune) rune {\n if a < b {\n return a\n } else {\n return b\n }\n}\n\nfunc findMin(s string) string {\n res := \"\"\n for i, c := range s {\n if i == 0 && c == '9' {\n res += \"9\"\n } else {\n res += string(min(c, '9' - c + '0'))\n }\n }\n return res\n}\n\nfunc main() {\n sc.Init(Stdin())\n var s string\n for ReadString(&s) {\n fmt.Println(findMin(s))\n }\n}\n\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "27ef8665ce1bb4ee5a2f8cfdb1114368", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar s string\n\tfor I(&s, \"\\n\") == nil {\n\t\tsolve(s)\n\t}\n}\n\nfunc solve(s string) {\n\ta := []byte(s)\n\tfor i := 0; i < len(a); i++ {\n\t\tif i != 0 || (i == 0 && a[i] != '9') {\n\t\t\tif a[i] >= '5' {\n\t\t\t\ta[i] = '0' + '9' - a[i]\n\t\t\t}\n\t\t}\n\t}\n\tO(string(a), \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "295b6d923738cedec615014e4b93fba0", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc minInvert(t int) int {\n\tinv := 9 - t\n\tif t < inv {\n\t\treturn t\n\t}\n\treturn inv\n}\n\nfunc main() {\n\tvar S string\n\tfmt.Scan(&S)\n\tfor i, r := range S {\n\t\tt := minInvert(int(r - '0'))\n\t\tif i == 0 && t == 0 {\n\t\t\tt = 9\n\t\t}\n\t\tfmt.Printf(\"%d\", t)\n\t}\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "10cb69d210cb340922add70834ab5897", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n/*\n\tTo solve this problem we need to tinker a bit with the mechanism\n\tof mod & power. If we just use naive approach we will have overflow\n\tsince the number of n is very large.\n\n\tSo basically in this operation we want to get the remainder of m / (2^n)\n\twithout computing the result of 2^n first.\n\n\tSo my approach is we divide m with 2 one by one up until n. Thus\n\tfollowing conditions will happen:\n\t- if m could be divided completely by all 2s, then the remainder is 0\n\t since this means m could be completely divided by 2^n\n\t- if could not be divided completey by all 2, there are 2 conditions:\n\t * the remaining value of m is smaller than remaining 2s, if this happens\n\t\treturns m since this means m cannot be divided more by 2. It's just like\n\t\t5 / 20, the remainder would be 5, right?\n\t * the remaining value of m is bigger than remaining 2s, then we need to get\n\t\tthe remainder from it, after that multiply with all 2s we already used so\n\t\tfar then we could get the true remainder for m / (2^n). The example of this\n\t\tcondition is 42 / (2^4), if we simplify this we will get 21 / (2^3) which\n\t\thas remainder 5, notice that the true reminder of 42 / (2^4) is 10 which is\n\t\tremainder of (21 / (2^3)) * 2. This yield true for 84 / (2^5) which has true\n\t\treminder 20. So you could already see the connection here.\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, m int64\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%d\\n%d\", &n, &m)\n\tfmt.Println(solve(m, n))\n}\n\nfunc solve(m int64, n int64) int64 {\n\ttmp := m\n\tsteps := 0\n\tfor tmp%2 == 0 && n > 0 {\n\t\ttmp /= 2\n\t\tsteps++\n\t\tn--\n\t}\n\t// m is completely divisible by 2^n\n\tif n == 0 {\n\t\treturn 0\n\t}\n\t// check if tmp is smaller than remaining 2s progressively\n\tvar mul int64 = 1\n\tfor n > 0 {\n\t\tmul *= 2\n\t\tif mul > tmp {\n\t\t\t// tmp is smaller\n\t\t\treturn m\n\t\t}\n\t\tn--\n\t}\n\t// tmp is bigger\n\tremainder := tmp % mul\n\tfor i := 0; i < steps; i++ {\n\t\tremainder *= 2\n\t}\n\treturn remainder\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "2ee096c90058c1eaa7edfd70cdb43be8", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\n\nfunc main() {\n var n ,m, result, i float64\n fmt.Scanf(\"%f\\n%f\", &n, &m)\n i = math.Pow(2, n)\n result = math.Mod(m, i)\n fmt.Printf(\"%.0f\\n\", result)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c016c2abccf94febbb4ea22794a5e992", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n,m int32\n\tfmt.Scan(&n,&m)\n\tif n>=30 {\n\t\tfmt.Print(m)\n\t}else{\n\t\tfmt.Print(m % int32((math.Pow(2.0,float64(n)))))\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "d134b8c5eefdef7189b75f2ed5f5213c", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n m,num := make(map[int]bool),0\n for i := 0 ; i < 4 ; i++ {\n fmt.Scan(&num)\n m[num] = true\n }\n fmt.Println(4 - len(m))\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "30bf25ea51440c203a25c748b6650970", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar num int\n\tvar numMap map[int]int\n\tvar buy int\n\n\tbuy = 0\n\tnumMap = make(map[int]int, 4)\n\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Scanf(\"%d\", &num)\n\t\tnumMap[num]++\n\t\tif numMap[num] > 1 {\n\t\t\tbuy++\n\t\t}\n\t}\n\tfmt.Println(buy)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cc3de02b0b6654c941d56c0afac46a48", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\txm := make(map[uint32]uint32)\n\tvar s1, s2, s3, s4 uint32\n\n\tfmt.Fscanf(in, \"%d %d %d %d\\n\", &s1, &s2, &s3, &s4)\n\t\n\txm[s1] = s1\n\txm[s2] = s2\n\txm[s3] = s3\n\txm[s4] = s4\n\n\tfmt.Println(4 - len(xm))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e71f67777502f0805050cfa8a840807b", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tvar h1, m1, h2, m2 int\n\tscanf(\"%d:%d\\n%d:%d\\n\", &h1, &m1, &h2, &m2)\n\tm := ((h1+h2)*60 + m1 + m2) / 2\n\tprintf(\"%02d:%02d\\n\", m/60, m%60)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "45197b94898458471a4a6965716a5b53", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tvar h1, m1, h2, m2 int\n\tscanf(\"%d:%d\\n%d:%d\\n\", &h1, &m1, &h2, &m2)\n\tm := ((h1+h2)*60 + m1 + m2) / 2\n\tprintf(\"%02d:%02d\\n\", m/60, m%60)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "264b2bf36855a85105c04cea7faf06b7", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var h1, m1, h2, m2 int\n fmt.Scanf(\"%d:%d\\n%d:%d\", &h1, &m1, &h2, &m2)\n \n t1, t2 := h1 * 60 + m1, h2 * 60 + m2\n t3 := t1 + (t2 - t1) / 2\n \n h3, m3 := t3 / 60, t3 % 60\n if h3 < 10 {\n fmt.Printf(\"0%d\", h3)\n } else {\n fmt.Printf(\"%d\", h3)\n }\n fmt.Printf(\":\")\n if m3 < 10 {\n fmt.Printf(\"0%d\", m3)\n } else {\n fmt.Printf(\"%d\", m3)\n }\n \n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b686c45041ddc097b6bdb0a1f6c731c7", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\"fmt\")\n\n\n\nfunc max(x,y int) int {\n if (x>y){\n \treturn x\n } else{\n \treturn y\n }\n}\n\nfunc min(x,y int) int {\n if (xy){\n \treturn x\n } else{\n \treturn y\n }\n}\n\nfunc min(x,y int) int {\n if (x c) && ((a+c) > b) && ((b+c) > a) {\n return 2\n } else if ((a+b) >= c) && ((a+c) >= b) && ((b+c) >= a) {\n return 1\n } else {\n return 0\n }\n}\n\nfunc max(a... int) (max int) {\n max = a[0]\n for _, v := range a {\n if max < v { max = v }\n }\n return\n}\n\nfunc main() {\n var a,b,c,d int\n fmt.Scan(&a,&b,&c,&d)\n ans := max(f(a,b,c),f(a,b,d),f(a,c,d),f(b,c,d))\n if ans == 2 {\n fmt.Println(\"TRIANGLE\")\n } else if ans == 1 {\n fmt.Println(\"SEGMENT\")\n } else {\n fmt.Println(\"IMPOSSIBLE\")\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "geometry"], "code_uid": "04672aa7567042f5d0ad32bc21a6ae4f", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l [4]int\n\tif _, err := fmt.Scanf(\"%d %d %d %d\\n\", &l[0], &l[1], &l[2], &l[3]); err != nil {\n\t\treturn\n\t}\n\n\tsegment := false\n\n\tvar t [3]int\n\tfor i := 0; i < 4; i++ {\n\t\tk := 0\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tif j != i {\n\t\t\t\tt[k] = l[j]\n\t\t\t\tk++\n\t\t\t}\n\t\t}\n\t\ts := triangle(t)\n\t\tif s == 1 { // triangle\n\t\t\tfmt.Println(\"TRIANGLE\")\n\t\t\treturn\n\t\t} else if s == 2 { // Degenerate triangle\n\t\t\tsegment = true\n\t\t}\n\t}\n\n\tif segment {\n\t\tfmt.Println(\"SEGMENT\")\n\t} else {\n\t\tfmt.Println(\"IMPOSSIBLE\")\n\t}\n}\n\nfunc triangle(t [3]int) int {\n\tsum := 0\n\tmax := 0\n\tfor i := 0; i < 3; i++ {\n\t\tsum += t[i]\n\t\tif t[i] > max {\n\t\t\tmax = t[i]\n\t\t}\n\t}\n\n\tif sum-max == max {\n\t\treturn 2\n\t} else if sum-max > max {\n\t\treturn 1\n\t} else {\n\t\treturn 0\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "geometry"], "code_uid": "d8bc9fc0debb57a629f9bfafb8a08ea0", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\n\nfunc triangle(L []int, diff int) bool {\n\tfor i := 0; i < 4; i++ {\n\t\tfor j := i + 1; j < 4; j++ {\n\t\t\tfor k := j + 1; k < 4; k++ {\n\t\t\t\tif (L[i] + L[j] - L[k]) >= diff {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar L = make([]int, 4)\n\t_, _ = fmt.Scanf(\"%d %d %d %d\", &L[0], &L[1], &L[2], &L[3])\n\tsort.Ints(L)\n\tif triangle(L, 1) {\n\t\tfmt.Println(\"TRIANGLE\")\n\t} else if triangle(L, 0) {\n\t\tfmt.Println(\"SEGMENT\")\n\t} else {\n\t\tfmt.Println(\"IMPOSSIBLE\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "geometry"], "code_uid": "8df53b57112b26fb77962bfd5e5fd4a7", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1068/B\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tb int64\n)\n\nfunc main() {\n\tb = ReadInt64()\n\n\tmemo := Divisors(b)\n\tfmt.Println(len(memo))\n}\n\n// Divisors returns the divisors of an argument integer as map[int]int.\nfunc Divisors(n int64) map[int64]int64 {\n\tvar l int64\n\tres := make(map[int64]int64)\n\n\tfor l = 1; l*l <= n; l++ {\n\t\tif n%l == 0 {\n\t\t\tres[l] = 1\n\t\t\tres[n/l] = 1\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "c4aa68305551dbb46a11bd3ac64009e6", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar b, res int64 = 0, 1\n\tfmt.Scan(&b)\n\tif b > 1 {\n\t\t// Count 1 and b itself.\n\t\tres++\n\t\t// Why Ceil instead of Floor? Example: 12\n\t\tsqrtB := int64(math.Ceil(math.Sqrt(float64(b))))\n\t\tif sqrtB*sqrtB == b {\n\t\t\tres++\n\t\t}\n\n\t\tfor i := int64(2); i < sqrtB; i++ {\n\t\t\tif b%i == 0 {\n\t\t\t\tres += 2\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "365a3f9ebc5b8bd436ed9c557a49890a", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"math\"\n)\n\nvar (\n in *bufio.Reader\n out *bufio.Writer\n)\n\nfunc main() {\n in = bufio.NewReader(os.Stdin)\n out = bufio.NewWriter(os.Stdout)\n var b int64\n fmt.Fscanln(in, &b)\n var count int64 = 0\n for i:=int64(1);i<=int64(math.Sqrt(float64(b)));i++ {\n if (b%i == 0) {\n if (i*i == b) {\n count++\n } else {\n count+=2\n }\n }\n }\n fmt.Println(count)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "0bcdac950ff6241fbf1da75e0a3460f2", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar (\n\t\ta, b, x, y int64\n\t)\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\ta, _ = strconv.ParseInt(scanner.Text(), 10, 64)\n\n\tscanner.Scan()\n\tb, _ = strconv.ParseInt(scanner.Text(), 10, 64)\n\n\tscanner.Scan()\n\tx, _ = strconv.ParseInt(scanner.Text(), 10, 64)\n\n\tscanner.Scan()\n\ty, _ = strconv.ParseInt(scanner.Text(), 10, 64)\n\n\tg := gcd(x, y)\n\n\tx /= g\n\ty /= g\n\n\tf, s := a/x, b/y\n\n\tres := min(f, s)\n\tfmt.Println(res)\n}\n\nfunc min(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t}\n\n\treturn y\n}\n\nfunc gcd(a, b int64) int64 {\n\tfor b != 0 {\n\t\ta %= b\n\t\ta, b = b, a\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int64) int64 {\n\treturn a / gcd(a, b) * b\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "4598b027117809ab088bbf70125762d1", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a, b uint64) uint64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\n\nfunc main() {\n\tvar a, b, x, y uint64\n\tfmt.Scanf(\"%d %d %d %d\", &a, &b, &x, &y)\n\n\td := gcd(x, y)\n\tx /= d\n\ty /= d\n\n\tif a/x > b/y {\n\t\tfmt.Println(b / y)\n\t\treturn\n\t}\n\n\tfmt.Println(a / x)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "b538e5910979aed4a4cc94a42db4901c", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\nvar (\n\tr *bufio.Scanner\n\tw *bufio.Writer\n)\n\nconst ISDEBUG = false\n\nfunc readLine() string {\n\tr.Scan()\n\treturn r.Text()\n}\n\nfunc readInt() int {\n\tr.Scan()\n\tx, _ := strconv.Atoi(r.Text())\n\treturn x\n}\n\nfunc readInts(n int) []int {\n\tvar res []int\n\tfor i:=0; i 0 { ok = true }\n r -= ans; g -= ans; b -= ans;\n ans += r/3; ans += g/3; ans += b/3\n if ok && (((r%3 == 2) && (g%3 == 2)) || ((r%3 == 2) && (b%3 == 2)) || ((g%3 == 2) && (b%3 == 2))) {\n ans++\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "d2f9abb2e467538933046b7fa21ffc8a", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/322/B\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc min(arr []int64) int64 {\n\tminElem := arr[0]\n\tfor _, elem := range arr {\n\t\tif elem < minElem {\n\t\t\tminElem = elem\n\t\t}\n\t}\n\treturn minElem\n}\n\nfunc Solve(r, g, b int64) int64 {\n\tresult := int64(0)\n\tm := min([]int64{r, g, b})\n\tfor i := int64(0); i <= min([]int64{2, m}); i++ {\n\t\tcurr := i + (r-i)/3 + (b-i)/3 + (g-i)/3\n\t\tif curr > result {\n\t\t\tresult = curr\n\t\t}\n\t}\n\treturn result\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar r, g, b int64\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &r, &g, &b)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(r, g, b))\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "e833b0d4a31d5eb82dbce01e7501edcd", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a,b int) int { if a < b { return a } else { return b } }\n\nfunc main() {\n var r,g,b int\n ok := false\n fmt.Scan(&r,&g,&b)\n ans := min(r,min(g,b))\n if ans > 0 { ok = true }\n r -= ans; g -= ans; b -= ans;\n ans += r/3; ans += g/3; ans += b/3\n if ok && (((r%3 == 2) && (g%3 == 2)) || ((r%3 == 2) && (b%3 == 2)) || ((g%3 == 2) && (b%3 == 2))) {\n ans++\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "14c68f2f5db18e818982fff9d75a5339", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar t int\n\tfmt.Scan(&t)\n\tvar x, a, b, c int\n\tfor ; t > 0; t-- {\n\t\tfmt.Scan(&x)\n\t\tfmt.Scan(&a, &b, &c)\n\t\tswitch v := a + b + c; {\n\t\tcase a == 1 || b == 2 || c == 3:\n\t\t\tfmt.Println(\"NO\")\n\t\tcase v == 3 && c == 0:\n\t\t\tfmt.Println(\"NO\")\n\t\tcase v == 4 && b == 0:\n\t\t\tfmt.Println(\"NO\")\n\t\tcase v == 5 && a == 0:\n\t\t\tfmt.Println(\"NO\")\n\t\tdefault:\n\t\t\tfmt.Println(\"YES\")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "32185f7a33aaf18786c35488661342a4", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"fmt\"\r\n)\r\n\r\nfunc main() {\r\n\r\n\tvar j int\r\n\r\n\tfmt.Scan(&j)\r\n\r\n\tfor z := 0; z < j; z++ {\r\n\t\tvar key int\r\n\r\n\t\tfmt.Scan(&key)\r\n\r\n\t\tvar doors [3]int\r\n\r\n\t\tfor i := 0; i < 3; i++ {\r\n\t\t\tfmt.Scan(&doors[i])\r\n\t\t}\r\n\r\n\t\topened := 3\r\n\r\n\t\tvar answer bool = true\r\n\r\n\t\tfor opened > 0 {\r\n\t\t\tkey = doors[key-1]\r\n\t\t\topened--\r\n\r\n\t\t\tif (key == 0) && (opened > 0) {\r\n\t\t\t\tanswer = false\r\n\t\t\t\tbreak\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tswitch answer {\r\n\t\tcase true:\r\n\t\t\tfmt.Println(\"YES\")\r\n\r\n\t\tcase false:\r\n\t\t\tfmt.Println(\"NO\")\r\n\t\t}\r\n\t}\r\n\r\n}\r\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "81004ff0f69e98f3666cc7d1dfd270b4", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar t int\n\tif _, err := fmt.Scanf(\"%d\\n\", &t); err != nil {\n\t\tfmt.Println(\"err1\")\n\t\treturn\n\t}\n\n\tvar x int\n\tkey := make([]int, 4)\n\n\tfor i := 0; i < t; i++ {\n\t\tif _, err := fmt.Scanf(\"%d\\n%d%d%d\\n\", &x, &key[1], &key[2], &key[3]); err != nil {\n\t\t\tfmt.Println(\"err2\")\n\t\t\treturn\n\t\t}\n\n\t\tif key[1] == 1 || key[2] == 2 || key[3] == 3 {\n\t\t\tfmt.Println(\"NO\")\n\t\t} else if key[x] == 0 || key[key[x]] == 0 {\n\t\t\tfmt.Println(\"NO\")\n\t\t} else {\n\t\t\tfmt.Println(\"YES\")\n\t\t}\n\n\t}\n\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "f5b383babd55dcf64aa1ab9dd4c4172a", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tvar n int\n\tfor I(&n) == nil {\n\t\tsolve(n)\n\t}\n\tw.Flush()\n}\n\nfunc solve(n int) {\n\ta := 1\n\tb := n\n\tans := 0\n\tfor a < b {\n\t\to := (a + b) % (n + 1)\n\t\tif o == 0 {\n\t\t\ta++\n\t\t} else {\n\t\t\tb--\n\t\t\tans++\n\t\t}\n\t}\n\tO(ans, \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms"], "code_uid": "93ea7fba1a6bbd1656c19096a48c6cba", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Solve(io *FastIO) {\n\tio.Println((io.NextInt() - 1) / 2)\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tSolve(&io)\n\tio.FlushOutput()\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms"], "code_uid": "1143994006389827166f945422a6019e", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tvar ans int\n\tif n%2 == 0 {\n\t\tans = n/2 - 1\n\t} else {\n\t\tans = n / 2\n\t}\n\tfmt.Println(ans)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms"], "code_uid": "11df57398a907799d13f157d00e39f26", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \t\"fmt\"\n\t\nfunc main(){\n\tvar m,n,temp,a int64\n fmt.Scanf(\"%d\", &m)\n\tfmt.Scanf(\"%d\", &n)\n\tfmt.Scanf(\"%d\", &a)\n\ttemp = (m+a-1)/a\n\ttemp *= (n+a-1)/a\n\tfmt.Println(temp)\t\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "2742d92fdedd38eccd76582d9b0761b3", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main(){\n\tvar m,n,a int\n\t_,er1 := fmt.Scan(&m)\n\t_,er2 := fmt.Scan(&n)\n\t_,er3 := fmt.Scan(&a)\n\tif er1 != nil || er2 != nil|| er3 != nil {\n\t\tos.Exit(1)\n\t}\n\tmTiles := uint64(math.Ceil( float64(m) / float64(a)))\n\tnTiles := uint64(math.Ceil( float64(n) / float64(a)))\n\tfmt.Print(mTiles * nTiles)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "81fd591d348ad320b2d1c5bd79f3d74c", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, a int64\n\tfmt.Scan(&n, &m, &a)\n\tfmt.Print(((n + a - 1) / a) * ((m + a - 1) / a))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "69e4817e7ce216eeae97b824839bf262", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// cf999a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, s int\n\tfmt.Scan(&n, &s)\n\tm := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&m[i])\n\t}\n\tc := 0\n\tl, r := 0, n-1\n\tfor i := 0; i < n && l <= r; i++ {\n\n\t\tif m[l] <= s {\n\t\t\tc++\n\t\t\tl++\n\t\t}\n\t\tif m[r] <= s && l < r {\n\t\t\tc++\n\t\t\tr--\n\t\t}\n\n\t}\n\tfmt.Println(c)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "00420097c15fbed57d99c15933106071", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n,&k)\n\ta := make([]int,n)\n\tfor i:=0;i=0;i-- {\n\t\t\tif a[i]<=k {\n\t\t\t\tr++\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(r)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "3c54b6a61373764aba397ef32e381d45", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k, l int\n\tfmt.Scan(&n, &k)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tfmt.Scan(&a[i])\n\t}\n\tfor len(a) > 0 && a[0] <= k {\n\t\tl++\n\t\ta = a[1:]\n\t}\n\tfor len(a) > 0 && a[len(a)-1] <= k {\n\t\ta = a[0 : len(a)-1]\n\t\tl++\n\t}\n\tfmt.Println(l)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "7f770126d9290ea93b706ca4e1a1c40b", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar mmap = make(map[uint8][]string)\n\nfunc recur(str string, l int) int {\n\tif l == 0 {\n\t\treturn 1\n\t}\n\tif l < 0 {\n\t\treturn 0\n\t}\n\tret := 0\n\tfor _, s := range mmap[str[0]] {\n\t\tret += recur(s+str[1:], l-1)\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tvar n, q int\n\tfmt.Scanf(\"%d %d\\n\", &n, &q)\n\tfor i := 0; i < q; i++ {\n\t\tvar k, v string\n\t\tfmt.Scanf(\"%s %s\\n\", &k, &v)\n\t\tks := v[0]\n\t\tmmap[ks] = append(mmap[ks], k)\n\t}\n\tfmt.Print(recur(\"a\", n-1))\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "strings", "dp", "brute force"], "code_uid": "7b50e652b65678386abc91766335e5b9", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\tS := io.NextLine()\n\n\tfreq := make(map[string]int)\n\tbest := \"\"\n\tfor i := 2; i <= N; i++ {\n\t\tk := S[i-2:i]\n\t\tfreq[k]++\n\t\tif freq[k] > freq[best] {\n\t\t\tbest = k\n\t\t}\n\t}\n\tio.Println(best)\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "9ac97e2d5e7824ddab6bb31170b39bdd", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport.\"fmt\"\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tn,s,m:=0,\"\",\"\"\n\tScan(&n,&s)\n\tc := map[string]int{}\n\tfor i := 2; i <= n; i++ {\n\t\tt:=s[i-2:i]\n\t\tif c[t]++;c[t]>c[m] {\n\t\t\tm=t\n\t\t}\n\t}\n\tPrint(m)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "b190bb6586576f0352c9fa8a9fb9ccc9", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n _, _ = reader.ReadString('\\n')\n input, _ := reader.ReadString('\\n')\n\n ma := make(map[string]int)\n ar := []string{}\n for i, c := range input {\n if i == len(input) - 1 {\n break\n }\n\n cu := string(c) + string(input[i + 1])\n ar = append(ar, cu)\n\n if _, ok := ma[cu]; ok {\n ma[cu] += 1\n } else {\n ma[cu] = 1\n }\n }\n\n max := -999999999\n ret := ar[0]\n for _, m := range ar {\n if ma[m] > max {\n max = ma[m]\n ret = m\n }\n }\n\n fmt.Println(ret)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "31a2ba0d8c3a0e238715fee73b864d66", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, x int32\n\tfmt.Scanf(\"%d %d\\n\", &n, &x)\n\n\tans := int32(0)\n\tfor i := int32(1); i*i <= x; i++ {\n\t\tif x%i == 0 {\n\t\t\tresult := x / i\n\t\t\tif result <= n {\n\t\t\t\tans += 2\n\t\t\t\tif result == i {\n\t\t\t\t\tans--\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation", "number theory"], "code_uid": "bd95e540d7df39f32ca3efde0d5b096a", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var n, x, i uint\n fmt.Scan(&n, &x)\n\n result := 0\n for i = 1; i <= n; i++ {\n if x % i == 0 && x / i <= n {\n result++\n }\n }\n\n fmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["implementation", "number theory"], "code_uid": "871eeff64bcba14f13ec604eb083cb1c", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a... interface{}) {\n\tfmt.Fscanf(reader, f, a...)\n}\n\nfunc printf(f string, a... interface{}) {\n\tfmt.Fprintf(writer, f, a...)\n}\n\nfunc main() {\n\tvar T, x, result, i, j uint64\n\tscanf(\"%d %d\\n\", &T, &x)\n\t\n\tresult = 0\n\n\tif x <= T {\n\t\tresult++\n\t}\n\tfor i=2; i<=T; i++ {\n\t\tif x % i == 0 {\n\t\t\tfor j=1; j<=T; j++ {\n\t\t\t\tif x == i * j {\n\t\t\t\t\tresult++\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n\tfmt.Println(result)\n\t\n}\n\n", "lang_cluster": "Go", "tags": ["implementation", "number theory"], "code_uid": "a91f454789160fc41aeeb512b4252d19", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc canDeal(a, b, c int, checked map[int]bool) bool {\n\tif c < a && c < b {\n\t\treturn false\n\t}\n\tif c%a == 0 || c%b == 0 {\n\t\treturn true\n\t}\n\tdefer func() { checked[c] = true }()\n\tif !checked[c] {\n\t\treturn canDeal(a, b, c-a, checked) || canDeal(a, b, c-b, checked)\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\tchecked := make(map[int]bool, c)\n\tif canDeal(a, b, c, checked) {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "da7600a2b309551b0a0cc80990b134bb", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\n\tfor i := 0; i <= 10000; i++ {\n\t\tif (c-i*b)%a == 0 && (c-i*b)/a >= 0 {\n\t\t\tfmt.Printf(\"Yes\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Printf(\"No\\n\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "dee4972e583e8b49a272487d5ea97682", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\n\tans := false\n\tfor x := 0; a*x <= c; x++ {\n\t\tif (c-a*x)%b == 0 {\n\t\t\tans = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ans {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "21a5ebd5d3f718139f80e73d81787a84", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\n\tvar arr = make([]int, n)\n\tvar count int\n\n\tfor i:=0; i < n ; i++ {\n\t\tfmt.Scan(&arr[i])\n\t}\n\n\tfor _, value := range arr{\n\t\tif value >= arr[k-1] && value != 0 {\n\t\t\tcount++\n\t\t}\n\t}\n\n\tfmt.Println(count)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ed4522d7fb7bee7f4aeebb4a58a15a1a", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scanf(\"%d %d\\n\", &n, &k)\n\n\tvar participants []int = make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &participants[i])\n\t}\n\n\tvar kthScore int = participants[k-1]\n\n\tvar count int = 0\n\n\tfor _, element := range participants {\n\t\tif element >= kthScore && (element != 0) {\n\t\t\tcount++\n\t\t}\n\t}\n\n\tfmt.Println(count)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "100233a90e141b0f976ef89212af1ba5", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// CalcAdvancers returns the number of advancers to the next round.\nfunc CalcAdvancers(n, k int, ranks []int) int {\n\tpos := k - 1\n\tpts := ranks[pos]\n\tnext := func(in int) int { return in + 1 }\n\tprev := func(in int) int { return in - 1 }\n\tif pts == 0 {\n\t\tnext, prev = prev, next\n\t}\n\n\tfor pos >= 0 && pos < n {\n\t\tif ranks[pos] < pts {\n\t\t\treturn pos\n\t\t}\n\t\tif pts == 0 && ranks[pos] > pts {\n\t\t\treturn pos + 1\n\t\t}\n\t\tpos = next(pos)\n\t}\n\n\tif pos < 0 {\n\t\treturn 0\n\t}\n\n\treturn pos\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tk, _ := strconv.Atoi(scanner.Text())\n\n\tranks := make([]int, 0)\n\tfor scanner.Scan() {\n\t\tnext, _ := strconv.Atoi(scanner.Text())\n\t\tranks = append(ranks, next)\n\t}\n\n\tfmt.Printf(\"%d\\n\", CalcAdvancers(n, k, ranks))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "babf93d3c3561b35c51ad60886c885f3", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\n\nvar debug = false\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tn, m := getLine2Int2()\n\tresult := 1\n\tif result < m {\n\t\tresult = m\n\t}\n\tn -= m\n\tif result > n {\n\t\tresult = n\n\t}\n\tprintf(\"%d\\n\", result)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "b3f3adbd5300c8cf1fa690500c565ea5", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, m float64\n\tfmt.Scanf(\"%f %f\", &n, &m)\n\n\tif m == 0 {\n\t\tfmt.Print(1)\n\t\treturn\n\t}\n\tfmt.Print(int(math.Min(m, n-m)))\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "a5d6e863711ffe1ae44b3b72e6804ece", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n, m int\n fmt.Scanf(\"%d %d\",&n, &m)\n res := 1\n if m <= 1 {\n res = 1\n } else {\n if m <= n/ 2 {\n res = m\n } else {\n res = n / 2\n if n % 2 == 1 {\n n--;\n m--;\n }\n res -= m - n / 2\n }\n }\n fmt.Println(res)\n}", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "318f9492cf3238ab4fa70b749a85fe91", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar writer *bufio.Writer\nvar scanner *bufio.Scanner\n\ntype MySlice [][2]int\n\nfunc (slice MySlice) Len() int { return len(slice) }\nfunc (slice MySlice) Less(i, j int) bool { return slice[i][1] < slice[j][1] }\nfunc (slice MySlice) Swap(i, j int) {\n\tslice[i], slice[j] = slice[j], slice[i]\n}\n\nfunc main() {\n\tini()\n\tdefer writer.Flush()\n\n\td1 := scanInt()\n\td2 := scanInt()\n\td3 := scanInt()\n\n\tresult := min(d1 + d2 + d3, min(2 * (d1 + d2), min(2 * (d2 + d3), 2 * (d1 + d3))))\n\twriter.WriteString(strconv.Itoa(result))\n\n\treturn\n}\n\nfunc binSearch(a []int, key int) int {\n\tl := -1\n\tr := len(a)\n\tfor l < r-1 {\n\t\tm := (l + r) / 2\n\t\tif a[m] < key {\n\t\t\tl = m\n\t\t} else {\n\t\t\tr = m\n\t\t}\n\t}\n\n\tif a[r] != key {\n\t\treturn -1\n\t}\n\n\treturn r\n}\n\nfunc ini() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc min(a int, b int) int {\n\tif a > b {\n\t\treturn b\n\t} else {\n\t\treturn a\n\t}\n}\n\nfunc scanInt() int {\n\tscanner.Scan()\n\ti, _ := strconv.Atoi(scanner.Text())\n\treturn i\n}\n\nfunc scanString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b441d10d10c3a4368554030eff973438", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\td := []int{0, 0, 0}\n\tfmt.Scanf(\"%d %d %d \\n\", &d[0], &d[1], &d[2])\n\tsort.Ints(d)\n\tr := d[0] + d[1] + min(d[2], d[0]+d[1])\n\tfmt.Print(r)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "75899cd983a659eb72b766af29b10702", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar d1, d2, d3 int\n\tfmt.Scanf(\"%d %d %d\", &d1, &d2, &d3)\n\n\tret := min(d1 + min(d1 + 2 * d2, d3 + min(d2, d3 + d1)),\n\t\t\t d2 + min(d2 + 2 * d1, d3 + min(d1, d3 + d2)))\n\tfmt.Printf(\"%d\", ret)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cdb4f198777c0d235e57eaf74d5cd2cf", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar line, answer string\n\tfmt.Scanln(&line)\n\tvar allUpper bool = strings.ToUpper(line[1:]) == line[1:]\n\tif (allUpper) {\n\t\tif line[:1] == strings.ToUpper(line[:1]) {\n\t\t\tanswer = strings.ToLower(line)\n\t\t} else {\n\t\t\tanswer = strings.ToUpper(line[:1]) + strings.ToLower(line[1:])\n\t\t}\n\t} else {\n\t\tanswer = line\n\t}\n\tfmt.Println(answer)\n}\n\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "c4e212cc8a7b61e7764e4b3b811c384b", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tvar ok = true\n\tfor i := 1; i < len(s); i++ {\n\t\tif 'a' <= s[i] && s[i] <= 'z' {\n\t\t\tok = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif ok {\n\t\tvar buffer bytes.Buffer\n\t\tif 'a' <= s[0] && s[0] <= 'z' {\n\t\t\tbuffer.WriteRune(unicode.ToUpper(rune(s[0])))\n\t\t} else {\n\t\t\tbuffer.WriteRune(unicode.ToLower(rune(s[0])))\n\t\t}\n\n\t\tbuffer.WriteString(strings.ToLower(s[1:]))\n\t\tfmt.Print(buffer.String())\n\t\treturn\n\t}\n\tfmt.Print(s)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "d169b4181a797aee2ea4bb6802973448", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"strings\"\n)\n\nfunc isCaps(c byte) bool {\n return c >= 'A' && c <= 'Z' \n}\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n \n rule1, rule2 := false, true\n if !isCaps(s[0]) {\n rule1 = true\n } \n\n for i, _ := range s {\n if i == 0 {\n continue\n }\n if !isCaps(s[i]) {\n rule2 = false\n } \n }\n if rule1 && rule2 {\n fmt.Println(strings.Title(strings.ToLower(s))) \n return\n } \n if rule2 {\n fmt.Println(strings.ToLower(s)) \n return\n } \n fmt.Println(s) \n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "26cfcb45da9be9edc8d30bc448865f9f", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n\t// STDOUT MUST BE FLUSHED MANUALLY!!!\n\tdefer writer.Flush()\n\n\tvar a, b, r int\n\tscanf(\"%d %d\\n\", &a, &b)\n\tfor a < b+1 {\n\t\ta = a * 3\n\t\tb = b * 2\n\t\tr++\n\t}\n\t//CODE HERE\n\tprintf(\"%d\\n\", r)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "6eaa2bafcf3518ce4377a902567c24f2", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar limanWeight, bobWeight int\n\tfmt.Scan(&limanWeight)\n\tfmt.Scan(&bobWeight)\n\tvar yearsCount int\n\tfor limanWeight <= bobWeight {\n\t\tyearsCount++\n\t\tlimanWeight *= 3\n\t\tbobWeight *= 2\n\t}\n\tfmt.Println(yearsCount)\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "8f8a5e6265edc1339ee81a9909dddf2a", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y int\n\n\tfmt.Scanf(\"%d%d\", &x, &y)\n\n\tcnt := 0\n\tfor x <= y {\t\t\n\t\tx = x * 3\n\t\ty = y *2\n\t\tcnt++\n\t}\n\tfmt.Println(cnt)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "275d3ac25cee82c5eced4cef8d538869", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc calc(arr []int) int{\n\tsort.Ints(arr)\n\tcount := 0\n\tfor i:=0;i 0 {\n\t\t\tfmt.Printf(\"-%s\", exp[scr%10])\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "e3f6dd20592ca9aa6752f9ce8cc75e04", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar tab map[int][]string = map[int][]string{\n\t0: {\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\"},\n\t1: {\"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\"},\n\t2: {\"twenty\"}, 3: {\"thirty\"}, 4: {\"forty\"}, 5: {\"fifty\"}, 6: {\"sixty\"}, 7: {\"seventy\"}, 8: {\"eighty\"}, 9: {\"ninety\"},\n}\n\nfunc main() {\n\tvar s int\n\tfmt.Scanf(\"%d\", &s)\n\td := s / 10\n\tu := s % 10\n\tn := \"\"\n\tswitch {\n\tcase d == 0 || d == 1:\n\t\tn = tab[d][u]\n\tcase u == 0:\n\t\tn = tab[d][0]\n\tdefault:\n\t\tn = fmt.Sprintf(\"%s-%s\", tab[d][0], tab[0][u])\n\t}\n\tfmt.Printf(\"%s\\n\", n)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "6c4dd81097cffac9b3950d7da7c228b7", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport(\n \"fmt\"\n \"os\"\n)\n\nvar print = fmt.Println\n\nfunc main(){\n var a,b,c,d int;\n\n fmt.Fscan(os.Stdin, &a,&b,&c,&d);\n\n if(a + b == c + d || a + c == d + b || a + d == b + c || a + b + c == d || a + b + d == c || a + c + d == b || b + c + d == a){\n print(\"YES\");\n }else {\n print(\"NO\");\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "1634eaac6f8b17aa324cc15daccf806a", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main(){\n\n\t\ta := [] int { 1, 2, 3, 4 }\n\t\tfor i := 0; i < 4; i++{\n\t\t\tfmt.Scanf(\"%d\", &a[i] )\n\t\t}\n\t\tsort.Ints( a )\n\t\tif ( a[0] + a[1] + a[2] == a[3] ) || ( a[0] + a[3] == a[1] + a[2] ){\n\t\t\tfmt.Print(\"YES\")\n\t\t} else {\n\t\t\tfmt.Print(\"NO\")\n\t\t}\n\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "ff903ec42058d6f9f99b4e6cc899944b", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar arr = []int{0, 0, 0, 0}\n\tfmt.Scanf(\"%d %d %d %d\", &arr[0], &arr[1], &arr[2], &arr[3])\n\n\tsort.Ints(arr)\n\n\tif ((arr[0] + arr[3]) == (arr[1] + arr[2])) || ((arr[0] + arr[1] + arr[2]) == arr[3]) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "6dc83bb416cd2bf80c75ab7d861f3c52", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"strings\"\n)\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n lowerCount, upperCount := 0, 0\n for i := 0; i < len(s); i++ {\n if s[i] <= 'Z' { upperCount++ } else { lowerCount++ }\n }\n if lowerCount >= upperCount {\n s = strings.ToLower(s)\n } else {\n s = strings.ToUpper(s)\n }\n fmt.Println(s)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "985b167851214e402519731d3e5f444a", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nfunc main() {\n\tvar input string\n\tfmt.Scanf(\"%s\\n\", &input)\n\tcount := 0\n\tfor _, v := range input {\n\t\tif unicode.IsUpper(v) {\n\t\t\tcount++\n\t\t}\n\t}\n\tif count > len(input)-count {\n\t\tfmt.Println(strings.ToUpper(input))\n\t} else {\n\t\tfmt.Println(strings.ToLower(input))\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "95116bb082d4cbe65bc5cb160de125ff", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n \"fmt\"\n \"unicode\"\n \"strings\"\n)\nfunc main() {\n\tvar a string\n\tvar ct int\n\tfmt.Scanln(&a)\n\t for _,i := range a {\n\t if(unicode.IsUpper(i)){\n\t ct++\n\t }\n\t }\n\t\n\tif ct > len(a)-ct {\n\t\tfmt.Println(strings.ToUpper(a))\n\t} else {\n\t\tfmt.Println(strings.ToLower(a))\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "36ee6c8365926d33fec2d40320cc298a", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\n\tsums := make([]int, n+1, n+1)\n\tfor i := 1; i <= n; i++ {\n\t\tsums[i] = i + sums[i-1]\n\t}\n\n\tif m >= sums[n] {\n\t\tm %= sums[n]\n\t}\n\n\tfor i := 1; i <= n; i++ {\n\t\tif m < sums[i] {\n\t\t\tm -= sums[i-1]\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfmt.Println(m)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "f8498fae4fe42cbd0057c773b52f45dc", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"unicode/utf8\"\n)\n\nfunc main() {\n\tvar m,n int\n\tfmt.Scan(&n,&m)\n\tm%=(n*(n+1)/2)\n\tfor i:=1;i<=m;i++ {\n\t\tm-=i\n\t}\n\tfmt.Println(m)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "1f76ae9464068b8e1f0d05f5317cbb17", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,m int\n fmt.Scan(&n,&m)\n m %= n*(n+1)/2\n for i := 1; m > 0; i++ {\n if m >= i {\n m -= i\n } else {\n break\n }\n }\n fmt.Println(m)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "1e04e148b039557f0247e8d4e3755afb", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar DIV int64 = 1000000007\n\nfunc culc(a, n int64) int64 {\n\tif n == 0 {\n\t\treturn 1\n\t}\n\n\tif n == 1 {\n\t\treturn a\n\t}\n\n\tif n%2 == 1 {\n\t\treturn culc(a, n-1) * a % DIV\n\t}\n\n\tsum := culc(a, n/2)\n\treturn sum * sum % DIV\n}\n\nfunc main() {\n\n\treader := bufio.NewReader(os.Stdin)\n\n\tvar n, m int64\n\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &m)\n\n\tsum := culc(2, m) - 1\n\tsum = culc(sum, n)\n\n\tfmt.Printf(\"%d\\n\", sum)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "23f9b49f49cc1b66288873f2244df285", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc pow(a, b int64) int64 {\n\tas := make([]int64, 2);\n\tbs := make([]int64, 2);\n\tas[1] = a;\n\tbs[1] = 1;\n\tfor b > bs[len(bs)-1] {\n\t\tas = append(as, (as[len(as)-1] * as[len(as)-1]) % 1000000007)\n\t\tbs = append(bs, 2*bs[len(bs)-1])\n\t}\n\n\tvar ans int64 = 1\n\tfor i := len(bs)-1; i > 0; i-- {\n\t\tif b >= bs[i] {\n\t\t\tans = (ans * as[i]) % 1000000007\n\t\t\tb -= bs[i]\n\t\t}\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin);\n\tout := bufio.NewWriter(os.Stdout);\n\tdefer out.Flush();\n\n\tvar n, m int64;\n\tfmt.Fscan(in, &n, &m);\n\n\tfirst := pow(2, m) - 1\n\tsecond := pow(first, n)\n\tfmt.Fprint(out, second)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "f06159790084d3f731c43f89746ef8dd", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\"fmt\"\n\"math/big\"\n)\n\nconst mod = 1000000007;\n\nfunc main() {\n\tvar n, m int64\n\n\tfmt.Scan(&n, &m)\n\n\tvar tmp big.Int\n\n\tvar t = tmp.Exp(big.NewInt(2), big.NewInt(m), big.NewInt(mod));\n\tt = tmp.Sub(t, big.NewInt(1))\n\tt = t.Exp(t, big.NewInt(n), big.NewInt(mod))\n\n\tfmt.Print(t)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "cd2ebb087de8dd6cc0e2a8a9beb6b3df", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport(\n\t\"fmt\"\n\t// \"strings\"\n\t// \"os\"\n\t// \"bufio\"\n)\n\nfunc main() {\n\t// reader := bufio.NewReader(os.Stdin)\n\t// reader.ReadLine()\n\t// fmt.Scanf(\"%d\", &N)\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\tres := 0\n\tl := len(s)\n\tfor i := 0; i < l/2; i++ {\n\t\tif s[i] != s[l-1-i] {\n\t\t\tres += 1\n\t\t}\n\t}\n\n\tif res == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else if res == 0 && l%2 == 1{\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["brute force", "strings", "constructive algorithms"], "code_uid": "c6d7312544fb680a41b706152cbb3a89", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\t\n\tS := io.NextLine()\n\tN := len(S)\n\n\tmisses := 0\n\n\tfor i, j := 0, N - 1; i < j; i, j = i + 1, j - 1 {\n\t\tif S[i] != S[j] {\n\t\t\tmisses++\n\t\t}\n\t}\n\n\tif (N % 2 == 0 && misses == 1) || (N % 2 == 1 && misses <= 1) {\n\t\tio.Printf(\"YES\\n\")\n\t} else {\n\t\tio.Printf(\"NO\\n\")\n\t}\n\t\n\tio.FlushOutput()\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "constructive algorithms"], "code_uid": "2d9971f45de03729bea55444003fdff6", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\t\n\tS := io.NextLine()\n\tN := len(S)\n\n\tmisses := 0\n\n\tfor i, j := 0, N - 1; i < j; i, j = i + 1, j - 1 {\n\t\tif S[i] != S[j] {\n\t\t\tmisses++\n\t\t}\n\t}\n\t\n\tif N % 2 == 0 {\n\t\tif misses == 1 {\n\t\t\tio.Printf(\"YES\\n\")\n\t\t} else {\n\t\t\tio.Printf(\"NO\\n\")\n\t\t}\n\t} else {\n\t\tif misses <= 1 {\n\t\t\tio.Printf(\"YES\\n\")\n\t\t} else {\n\t\t\tio.Printf(\"NO\\n\")\n\t\t}\n\t}\n\t\n\tio.FlushOutput()\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "constructive algorithms"], "code_uid": "dc96bc4c1df85f31a2b411c76a216fcc", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\n\tvar n int\n\tvar s string\n\n\tfmt.Fscanf(in, \"%d\\n%s\", &n)\n\tfmt.Fscanf(in, \"%s\\n\", &s)\n\tfmt.Println(betweenTheOffices(n, s))\n}\n\nfunc betweenTheOffices(n int, s string) string {\n\tvar count int\n\tfor i := 0; i < n-1; i++ {\n\t\tif s[i] == 'F' && s[i+1] == 'S' {\n\t\t\tcount--\n\t\t} else if s[i] == 'S' && s[i+1] == 'F' {\n\t\t\tcount++\n\t\t}\n\t}\n\n\tif count > 0 {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "59ba7cb74310a1f38c09f8bec2fd2219", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n \nfunc main(){\n\tvar len int\n\tvar way string\n\tfmt.Scan(&len)\n\tfmt.Scan(&way)\n\tS := strings.Count(way,\"SF\")\n\tSF := strings.Count(way,\"FS\")\n\tif S > SF{\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n \n \n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "161038cf75c5c320f116d172072253de", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nfunc main() {\n\tvar a int\n\tolChar := \"abcd\"\n\tfromStoF := 0\n\tfromFtoS := 0\n \n\tfmt.Scanln(&a)\n \n\tvar inp string\n\tfmt.Scan(&inp)\n \n\tfor _, char := range inp {\n\t\tcharNew := string(char)\n\t\tif olChar != \"abcd\" {\n\t\t\tif charNew == \"S\" && charNew != olChar {\n\t\t\t\tfromFtoS++\n\t\t\t} else if charNew == \"F\" && charNew != olChar {\n\t\t\t\tfromStoF++\n\t\t\t}\n\t\t}\n\t\tolChar = charNew\n\t}\n \n\tif fromStoF > fromFtoS {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "69e14c2e69aea0d389074697c4a59722", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tluckyNum := []int{4, 7}\n\ts := 0\n\tfor i := 0; i < 2; i++ {\n\t\ttp := len(luckyNum)\n\t\tfor _, num := range luckyNum[s:] {\n\t\t\tluckyNum = append(luckyNum, num*10+4, num*10+7)\n\t\t}\n\t\ts = tp\n\t}\n\tvar n int\n\tfmt.Scan(&n)\n\tfor _, num := range luckyNum {\n\t\tif n%num == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "number theory"], "code_uid": "bdc222cd110c9cecc8d9e17151d26f26", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar inp int\n\tvar flag bool\n\tvar lst [12]int = [12]int{4, 7, 44, 47, 74, 77, 444, 447, 477, 744, 747, 777}\n\tfmt.Scan(&inp)\n\tfor i := 0; i < len(lst); i++ {\n\t\tif inp%lst[i] == 0 {\n\t\t\tflag = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "number theory"], "code_uid": "95f35639eb446d83d73d50b09927698a", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc generateLuckyNumberList(maximum int) []int {\n nums := []int{4, 7}\n lastEnd := 0\n for nums[len(nums)-1] < maximum {\n curEnd := len(nums)\n for i := lastEnd; i < curEnd; i++ {\n nums = append(nums, nums[i]*10+4)\n nums = append(nums, nums[i]*10+7)\n }\n lastEnd = curEnd\n }\n return nums\n}\n\nfunc main() {\n lucky := generateLuckyNumberList(1000)\n\n var n int\n fmt.Scanf(\"%d\", &n)\n for i := 0; lucky[i] <= n && i < len(lucky); i++ {\n if n%lucky[i] == 0 {\n fmt.Println(\"YES\")\n return\n }\n }\n fmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "number theory"], "code_uid": "ae6121e3a37e917d963ee0394cf22eef", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar S, n int32\n\tfmt.Scan(&n, &S)\n\tresult := (S + n - 1) / n\n\tfmt.Println(result)\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "b4ef58ef269d4bb605962533e17e3c95", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s, n int\n\tfmt.Scanf(\"%d%d\", &n, &s)\n\tfmt.Printf(\"%d\\n\", (s+n-1)/n)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "2533580ac858f47bc3bcce5d272e495f", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main(){\n\n\tbuf := bufio.NewReader(os.Stdin)\n\n\tvar n int\n\tvar s int\n\tfmt.Fscanf(buf, \"%d %d\\n\", &n,&s)\n\tvar ans int = s/n\n\tif s%n != 0{\n\t\tans++\n\t}\n\tfmt.Print(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "c8db76b833381963c73990434a7a0316", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar x1, y1 float64\n\tvar x2, y2 float64\n\tfmt.Scanf(\"%f %f\\n\", &x1, &y1)\n\tfmt.Scanf(\"%f %f\\n\", &x2, &y2)\n\n\txDiff := math.Abs(x1 - x2)\n\tyDiff := math.Abs(y1 - y2)\n\n\tres := int(math.Max(xDiff, yDiff))\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "f9a59ed8a1b199f773d7555920a46f0f", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\n\nfunc init() {\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc scanString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc scanBytes() []byte {\n\tscanner.Scan()\n\treturn scanner.Bytes()\n}\n\nfunc scanInt64() int64 {\n\tscanner.Scan()\n\tv, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn v\n}\n\nfunc scanInt() int {\n\tscanner.Scan()\n\tv, _ := strconv.Atoi(scanner.Text())\n\treturn v\n}\n\nfunc scanInts(n int) []int {\n\tl := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanner.Scan()\n\t\tl[i], _ = strconv.Atoi(scanner.Text())\n\t}\n\n\treturn l\n}\n\nfunc scanInts64(n int64) []int64 {\n\tl := make([]int64, n)\n\tfor i := int64(0); i < n; i++ {\n\t\tscanner.Scan()\n\t\tl[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)\n\t}\n\n\treturn l\n}\n\nfunc scanBool() bool {\n\tscanner.Scan()\n\tv, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn v == 1\n}\n\nfunc scanBools(n int64) []bool {\n\tl := make([]bool, n)\n\tfor i := int64(0); i < n; i++ {\n\t\tscanner.Scan()\n\t\tv, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\t\tl[i] = v == 1\n\t}\n\n\treturn l\n}\n\nfunc scanUint64() uint64 {\n\tscanner.Scan()\n\tv, _ := strconv.ParseUint(scanner.Text(), 10, 64)\n\treturn v\n}\n\ntype ByO []int\n\nfunc (a ByO) Len() int { return len(a) }\nfunc (a ByO) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ByO) Less(i, j int) bool { return a[i] > a[j] }\n\nvar glasn = map[byte]bool{\n\t'a': true,\n\t'e': true,\n\t'i': true,\n\t'o': true,\n\t'u': true,\n}\n\nfunc main() {\n\tx1, y1 := scanInt64(), scanInt64()\n\tx2, y2 := scanInt64(), scanInt64()\n\n\td := max64(abs64(x2-x1), abs64(y2-y1))\n\tfmt.Println(d)\n}\n\nfunc abs64(a int64) int64 {\n\tif a >= 0 {\n\t\treturn a\n\t}\n\n\treturn -a\n}\n\nfunc abs(a int) int {\n\tif a >= 0 {\n\t\treturn a\n\t}\n\n\treturn -a\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc max64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "5a467bbde19042aaaf7c6016f061589a", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces problem 620A\npackage main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strconv\"\n \"strings\"\n)\nfunc Abs(x int) int {\n if x < 0 {\n return -x\n }\n return x\n}\nfunc Max(x int, y int) int {\n if x < y {\n return y\n }\n return x\n}\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n // read x1, y1\n s, _ := reader.ReadString('\\n')\n ss := strings.Split(strings.TrimSpace(s), \" \")\n x1,_ := strconv.Atoi(ss[0])\n y1,_ := strconv.Atoi(ss[1])\n // read x2, y2\n s, _ = reader.ReadString('\\n')\n ss = strings.Split(strings.TrimSpace(s), \" \")\n x2,_ := strconv.Atoi(ss[0])\n y2,_ := strconv.Atoi(ss[1])\n // calculkate dist\n dx := Abs(x2-x1)\n dy := Abs(y2-y1)\n dist := Max(dx,dy)\n fmt.Println(dist)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "eead90290e82df0455576419e79c1210", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t_ \"math\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) {\n\tfmt.Fscanf(reader, f, a...)\n}\nfunc printf(f string, a ...interface{}) {\n\tfmt.Fprintf(writer, f, a...)\n}\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\nfunc print(a ...interface{}) {\n\tfmt.Fprint(writer, a...)\n}\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc main() {\n\t_main()\n\twriter.Flush()\n}\n// head\nvar n int\nvar s string\nvar m int\nvar valid []int\nfunc _main() {\n scan(&n, &s)\n\tm = len(s)\n\n\tvalid = append(valid, 0)\n\tfor i := 1; i < n; i ++ {\n\t\tsuccess := true\n\t\tfor j := 0; j < m; j ++ {\n\t\t\tk := (i + j) % n\n\t\t\tif k < m && s[k] != s[j] {\n\t\t\t\tsuccess = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif success {\n\t\t\tvalid = append(valid, i)\n\t\t}\n\t}\n\n\t//println(\"valid =\", valid)\n\tdp := make([]int64, n)\n\tdp[0] = 1\n\tvar ans int64\n for _, i := range valid {\n \t//println(\"i = \", i)\n\t\tfor _, j := range valid {\n\t\t\tk := (i + j) % n\n\t\t\tif k >= i {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t//println(\"\\tk = \", k)\n\t\t\tdp[i] -= dp[k] << uint(max(0, i - k -m))\n\n\t\t}\n ans += dp[i] * int64(n - i) << (uint)(max(0, n - m - i))\n\t}\n\tprintln(ans)\n}\n", "lang_cluster": "Go", "tags": ["strings", "dp"], "code_uid": "60bb4b03948a3cd55690feb2740e7982", "src_uid": "0034806908c9794086736a2d07fc654c", "difficulty": 2900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// var input, inputerr = os.Open(\"./input\")\n// var output, outputerr = os.Create(\"./output\")\n// var reader = bufio.NewReader(input)\n// var writer = bufio.NewWriter(output)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scan(a ...interface{}) { fmt.Fscan(reader, a...) }\n\nfunc min(a ...int) int {\n\tmin := -1\n\tfor _, val := range a {\n\t\tif val < min {\n\t\t\tmin = val\n\t\t}\n\t}\n\treturn min\n}\n\nfunc max(a ...int) int {\n\tmax := -1\n\tfor _, val := range a {\n\t\tif val > max {\n\t\t\tmax = val\n\t\t}\n\t}\n\treturn max\n}\n\nfunc tr(n int) int {\n\tfor n%10 == 0 {\n\t\tn = n / 10\n\t}\n\treturn n\n}\n\nfunc main() {\n\tdefer writer.Flush() // STDOUT MUST BE FLUSHED MANUALLY!!!\n\tvar n int\n\tscan(&n)\n\tcnt := 0\n\tm := map[int]bool{}\n\n\tfor {\n\t\tif m[n] == false {\n\t\t\tm[n] = true\n\t\t\tcnt++\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t\tn++\n\t\tn = tr(n)\n\t}\n\tprint(cnt)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "caa865223435c796c88d6b27d9ed5daa", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x int\n\t_, _ = fmt.Scanf(\"%d\", &x)\n\n\tres := 1\n\n\tnumbers := map[int]bool{x: true}\n\n\tfor {\n\t\tx += 1\n\n\t\tfor x % 10 == 0 {\n\t\t\tx = x / 10\n\t\t}\n\n\t\tif _, ok := numbers[x]; ok {\n\t\t\tbreak\n\t\t}\n\n\t\tnumbers[x] = true\n\t\tres += 1\n\t}\n\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d48967f821ff7010e38732cb09bd4449", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc solve(n int) int {\n\tm := map[int]bool{}\n\tm[n] = true\n\n\tfor ok := false; !ok; {\n\n\t\tn++\n\n\t\tfor n > 0 && n%10 == 0 {\n\t\t\tn /= 10\n\t\t}\n\n\t\tok = m[n]\n\t\tm[n] = true\n\t}\n\n\treturn len(m)\n}\n\nfunc main() {\n\tvar n int\n\n\tfmt.Scan(&n)\n\n\tans := solve(n)\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e1039fb9e1567d68ab0e4a847f158b32", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n\t// your code goes here\n\tvar w int\n\tfmt.Scan(&w)\n\tresult := \"NO\"\n\tif w > 2 && w % 2 == 0 {\n\t\tresult = \"YES\"\n\t}\n\tfmt.Println(result)\n}", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "69b4f18a50f1d3fe007d117defa15882", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\n\n\nfunc main() {\n\n var w int\n fmt.Scan(&w)\n \n for i := 1; i < w; i++ {\n other := w-i\n if other % 2 == 0 && w % 2 == 0 {\n fmt.Print(\"YES\")\n return\n }\n }\n fmt.Print(\"NO\")\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "86c608c53e7b95ae9c452624e3802f19", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar cont int\n\tfmt.Scanf(\"%d\", &n)\n\tfor i := 1; i <= n; i++ {\n\t\tif i%2 == 0 {\n\t\t\tif n%i == 0 {\n\t\t\t\tcont++\n\t\t\t}\n\t\t}\n\t}\n\tif cont >= 2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "ab38ade49801e84e8c92d95815649ca3", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar n, k int\n\t_, _ = fmt.Scan(&n, &k)\n\n\tfor i := 0; i < k; i++ {\n\t\tif n%10 == 0 {\n\t\t\tn /= 10\n\t\t} else {\n\t\t\tn--\n\t\t}\n\t}\n\n\tfmt.Println(n)\n\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "55e7a7d5e47f0eb9a06853c6f45d73dd", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport . \"fmt\"\n\nfunc main() {\n\tvar n, k int\n\tfor Scan(&n, &k); k > 0; k-- {\n\t\tif n%10 > 0 {\n\t\t\tn--\n\t\t} else {\n\t\t\tn /= 10\n\t\t}\n\t}\n\tPrint(n)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "43cf222a9ef653ab4491115a37f89a0a", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\tvar line []string\n\tvar n, k int\n\n\tscanner = bufio.NewScanner(os.Stdin)\n\n\tif scanner.Scan() {\n\t\tline = strings.Fields(scanner.Text())\n\t\tn, _ = strconv.Atoi(line[0])\n\t\tk, _ = strconv.Atoi(line[1])\n\n\t\tfor i := 0; i < k; i++ {\n\t\t\tn = tanya(n)\n\t\t}\n\n\t\tfmt.Println(n)\n\t}\n}\n\nfunc tanya(number int) int {\n\tif number%10 == 0 {\n\t\treturn number / 10\n\t}\n\treturn number - 1\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "80467de4eefdedae9a334953e29ef357", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"regexp\"\n\t\"strings\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc p(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc pln(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc scan(a ...interface{}) { fmt.Fscan(reader, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar s string\n\tscan(&s)\n\n\ts = regexp.MustCompile(\"(WUB)+\").ReplaceAllLiteralString(s, \" \")\n\ts = strings.Trim(s, \" \")\n\t// wub_removed := strings.ReplaceAll(s, \"WUB\", \" \")\n\t// words := strings.Fields(wub_removed)\n\t// original_string := strings.Join(words, \" \")\n\tpln(s)\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["strings"], "code_uid": "d47a45993ca15fcf4257660ea40e67d8", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"fmt\"\n \"bufio\"\n \"regexp\"\n \"strings\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n defer writer.Flush()\n\n var str string\n scanf(\"%str\\n\", &str)\n \n str = regexp.MustCompile(\"(WUB)+\").ReplaceAllLiteralString(str, \" \")\n str = strings.Trim(str, \" \")\n \n printf(\"%s\\n\", str)\n}", "lang_cluster": "Go", "tags": ["strings"], "code_uid": "5493e869066670665e207a47cade99f0", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport s \"strings\"\nimport \"fmt\"\n\nfunc main (){\n\tvar x string\n\tfmt.Scanf(\"%s\", &x)\n\tc := s.ReplaceAll(x, \"WUB\", \" \")\n\tfmt.Println(s.Trim(c, \" \"))\n\t\n}", "lang_cluster": "Go", "tags": ["strings"], "code_uid": "101d3aff5db8ccad92a4d6b1e303ce6c", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var r, c int\n fmt.Scan(&r, &c)\n\n rs := 0\n cx := make([]bool, c, c)\n for i := 0; i < r; i++ {\n var line string\n fmt.Scan(&line)\n find := false\n for j := 0; j < c; j++ {\n if line[j] == 'S' {\n find = true\n cx[j] = true\n }\n }\n if find {\n rs++\n }\n }\n\n cs := 0\n for i := 0; i < c; i++ {\n if cx[i] {\n cs++\n }\n }\n\n fmt.Println(r*c - rs*cs)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "e99f654354c12488e1b609567d66912d", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar r,c, h_hewtee, h_bosoo uint\n\tvar s []string\n\t\n\tvar so string\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(in, \"%d %d\\n\", &r, &c)\n\tfor i := uint(0); i < r; i++{\n\t\tfmt.Fscanf(in, \"%s\\n\", &so)\n\t\ts = append(s, so)\n\t}\n\tfor i:=uint(0); i < r; i++{\n\t\tfor j:=uint(0); j < c; j++{\n\t\t\tif string(s[i][j]) == \"S\"{\n\t\t\t\th_hewtee++\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println()\n\tfor i:=uint(0); i < c; i++{\n\t\tfor j:=uint(0); j < r; j++{\n\t\t\tif string(s[j][i]) == \"S\"{\n\t\t\t\th_bosoo++\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(r*c - h_bosoo * h_hewtee)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "025f04e58faa1ed639dd54bd490a1b6c", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = NewMyScanner()\n\nfunc solve() int {\n\tr, c := sc.Int(), sc.Int()\n\tm := sc.Map2D(r, c)\n\n\tanyInRow, anyInCol := make([]bool, r), make([]bool, c)\n\tfor y := range m {\n\t\tfor x := range m[0] {\n\t\t\tif m[y][x] == byte('S') {\n\t\t\t\tanyInRow[y] = true\n\t\t\t\tanyInCol[x] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tans := 0\n\tfor y := range m {\n\t\tfor x := range m[0] {\n\t\t\tif !anyInRow[y] || !anyInCol[x] {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\treturn ans\n}\n\ntype MyScanner struct {\n\t*bufio.Scanner\n\tjustScanned bool\n}\n\nfunc NewMyScanner() *MyScanner {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\treturn &MyScanner{sc, false}\n}\n\nfunc (sc *MyScanner) Has() bool {\n\tsc.justScanned = true\n\treturn sc.Scan()\n}\n\nfunc (sc *MyScanner) Int() int {\n\tif !sc.justScanned {\n\t\tsc.Scan()\n\t}\n\tsc.justScanned = false\n\n\tx, _ := strconv.Atoi(sc.Text())\n\treturn x\n}\n\nfunc (sc *MyScanner) Bool() bool {\n\tif !sc.justScanned {\n\t\tsc.Scan()\n\t}\n\tsc.justScanned = false\n\n\treturn sc.Bytes()[0] == byte('1')\n}\n\n// sc.justScanned should be false\nfunc (sc *MyScanner) Map2D(r, c int) [][]byte {\n\tm := make([][]byte, r)\n\tfor y := range m {\n\t\tsc.Scan()\n\t\tm[y] = append(m[y], sc.Bytes()...)\n\t}\n\treturn m\n}\n\nfunc main() {\n\tfmt.Println(solve())\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "7cdcbefd9725d067333b1b6400f12a07", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\tscanner = bufio.NewScanner(os.Stdin)\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\ts := \"\"\n\tw, b := 0, 0\n\n\tfor line := 0; line < 8; line++ {\n\t\ts = next()\n\n\t\tfor i := 0; i < len(s); i++ {\n\t\t\tswitch s[i] {\n\t\t\tcase 'Q':\n\t\t\t\tw += 9\n\t\t\tcase 'R':\n\t\t\t\tw += 5\n\t\t\tcase 'B', 'N':\n\t\t\t\tw += 3\n\t\t\tcase 'P':\n\t\t\t\tw += 1\n\t\t\tcase 'q':\n\t\t\t\tb += 9\n\t\t\tcase 'r':\n\t\t\t\tb += 5\n\t\t\tcase 'b', 'n':\n\t\t\t\tb += 3\n\t\t\tcase 'p':\n\t\t\t\tb += 1\n\t\t\t}\n\t\t}\n\t}\n\t// println(w, b)\n\tif w == b {\n\t\tprintln(\"Draw\")\n\t} else if w > b {\n\t\tprintln(\"White\")\n\t} else {\n\t\tprintln(\"Black\")\n\t}\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "97fbd36542b43648487f9cf7f5ddbbf3", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar s string\n\tvar score int\n\treader := bufio.NewReader(os.Stdin)\n\tfor i := 0; i < 8; i++ {\n\t\tline, _ := reader.ReadString('\\n')\n\t\ts = s + line\n\t}\n\tfor _, i := range s {\n\t\tswitch i {\n\t\tcase 'q':\n\t\t\tscore += 9\n\t\tcase 'r':\n\t\t\tscore += 5\n\t\tcase 'b':\n\t\t\tscore += 3\n\t\tcase 'n':\n\t\t\tscore += 3\n\t\tcase 'p':\n\t\t\tscore += 1\n\t\tcase 'Q':\n\t\t\tscore -= 9\n\t\tcase 'R':\n\t\t\tscore -= 5\n\t\tcase 'B':\n\t\t\tscore -= 3\n\t\tcase 'N':\n\t\t\tscore -= 3\n\t\tcase 'P':\n\t\t\tscore -= 1\n\t\tdefault:\n\t\t\tcontinue\n\t\t}\n\t}\n\tif score == 0 {\n\t\tfmt.Println(\"Draw\")\n\t} else if score > 0 {\n\t\tfmt.Println(\"Black\")\n\t} else {\n\t\tfmt.Println(\"White\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5a83598b8488ac656a8caa729c7e9013", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar s string\n\tvar black, white int\n\treader := bufio.NewReader(os.Stdin)\n\tfor i := 0; i < 8; i++ {\n\t\tline, _ := reader.ReadString('\\n')\n\t\ts = s + line\n\t}\n\tfor _, i := range s {\n\t\tswitch i {\n\t\tcase 'q':\n\t\t\tblack += 9\n\t\tcase 'r':\n\t\t\tblack += 5\n\t\tcase 'b':\n\t\t\tblack += 3\n\t\tcase 'n':\n\t\t\tblack += 3\n\t\tcase 'p':\n\t\t\tblack += 1\n\t\tcase 'Q':\n\t\t\twhite += 9\n\t\tcase 'R':\n\t\t\twhite += 5\n\t\tcase 'B':\n\t\t\twhite += 3\n\t\tcase 'N':\n\t\t\twhite += 3\n\t\tcase 'P':\n\t\t\twhite += 1\n\t\tdefault:\n\t\t\tcontinue\n\t\t}\n\t}\n\tif black == white {\n\t\tfmt.Println(\"Draw\")\n\t} else if black > white {\n\t\tfmt.Println(\"Black\")\n\t} else {\n\t\tfmt.Println(\"White\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a854fa5956acc49d71628a04542c5049", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n// https://codeforces.com/problemset/problem/263/A\n\nimport \"fmt\"\n\nconst dimension = 5\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc task_solution(a [][]int) int {\n\tfor i, line := range a {\n\t\tfor j, elem := range line {\n\t\t\tif elem == 1 {\n\t\t\t\treturn abs(len(a)/2-i) + abs(len(line)/2-j)\n\t\t\t}\n\t\t}\n\t}\n\tpanic(\"unexpected behavior\")\n}\n\nfunc main() {\n\ta := [][]int{}\n\tfor i := 0; i < dimension; i += 1 {\n\t\tline := []int{}\n\t\tfor j := 0; j < dimension; j += 1 {\n\t\t\tvar n int\n\t\t\tif _, err := fmt.Scan(&n); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tline = append(line, n)\n\t\t}\n\t\ta = append(a, line)\n\t}\n\n\tfmt.Println(task_solution(a))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b5bab55798ab8a1b8399eb41573cdd1c", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)\n\tix, jx := 0, 0\n\tfor i :=0; i < 5; i++ {\n\t\tout := strings.Split(readLine(reader), \" \")\n\t\tfor j, c := range out {\n\t\t\tif c == \"1\" {\n\t\t\t\tix = i\n\t\t\t\tjx = j\n\t\t\t\tfmt.Println(math.Abs(float64(2-ix)) + math.Abs(float64(2-jx)))\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc readLine(reader *bufio.Reader) string {\n\tstr, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\n\treturn strings.TrimRight(string(str), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "26f30842e4dfcc44b02221d25e8961a7", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc abs(n int) int {\n\tif n < 0 {\n\t\treturn -n\n\t}\n\treturn n\n}\n\nfunc main() {\n\n\tvar n int\n\tmoves := 0\n\n\tfor i := 1; i <= 5; i++ {\n\t\tfor j := 1; j <= 5; j++ {\n\t\t\tfmt.Scan(&n)\n\t\t\tif n == 1 {\n\t\t\t\tmoves = abs(i-3) + abs(j-3)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(moves)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "73d2cb2e8855cb693f1944ee02cb5f42", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\ntype contest struct {\n\tin io.Reader\n\tout io.Writer\n}\n\nfunc (con *contest) Scan(a ...interface{}) (int, error) {\n\treturn fmt.Fscan(con.in, a...)\n}\nfunc (con *contest) Scanln(a ...interface{}) (int, error) {\n\treturn fmt.Fscanln(con.in, a...)\n}\nfunc (con *contest) Scanf(f string, a ...interface{}) (int, error) {\n\treturn fmt.Fscanf(con.in, f, a...)\n}\nfunc (con *contest) Print(a ...interface{}) (int, error) {\n\treturn fmt.Fprint(con.out, a...)\n}\nfunc (con *contest) Println(a ...interface{}) (int, error) {\n\treturn fmt.Fprintln(con.out, a...)\n}\nfunc (con *contest) Printf(f string, a ...interface{}) (int, error) {\n\treturn fmt.Fprintf(con.out, f, a...)\n}\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tcon := &contest{in: in, out: out}\n\tcon.main()\n}\n\nfunc (con *contest) main() error {\n\tvar T int\n\tcon.Scan(&T)\nnext:\n\tfor testcase := 0; testcase < T; testcase++ {\n\t\tvar n int\n\t\tcon.Scan(&n)\n\t\tfor i := 2; i*i <= n; i++ {\n\t\t\tif n%i == 0 {\n\t\t\t\ta := n / i\n\t\t\t\tcon.Println(a, n-a)\n\t\t\t\tcontinue next\n\t\t\t}\n\t\t}\n\t\tcon.Println(1, n-1)\n\t}\n\treturn nil\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "f16bedd40305a3a2791c3728e2f11e93", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar t, n int\n\tfmt.Scan(&t)\n\n\tfor t > 0 {\n\t\tt--\n\n\t\tfmt.Scan(&n)\n\n\t\tval := 1\n\t\tfor i := 2; i <= int(math.Sqrt(float64(n))); i++ {\n\t\t\tif n%i == 0 {\n\t\t\t\tval = i\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif val == 1 {\n\t\t\tfmt.Println(1, n-1)\n\t\t} else {\n\t\t\tx := n / val\n\t\t\tfmt.Println(x, x*(val-1))\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "b38a7b34babfc069a34c9b49c1b88158", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\nvar in *bufio.Reader\nvar out *bufio.Writer\n\nfunc printf(x string, a ...interface{}) (n int, err error) {\n\treturn fmt.Fprintf(out, x, a...)\n}\n\nfunc scanf(x string, a ...interface{}) (n int, err error) {\n\treturn fmt.Fscanf(in, x, a...)\n}\n\ntype priorityQueue [][2]int\n\nfunc (pq priorityQueue) Len() int {\n\treturn len(pq)\n}\n\nfunc (pq priorityQueue) Less(i, j int) bool {\n\treturn pq[i][1] > pq[j][1]\n}\n\nfunc (pq priorityQueue) Swap(i, j int) {\n\tpq[i], pq[j] = pq[j], pq[i]\n}\n\nfunc (pq *priorityQueue) Push(x interface{}) {\n\t*pq = append(*pq, x.([2]int))\n}\n\nfunc (pq *priorityQueue) Pop() (res interface{}) {\n\tres = (*pq)[len(*pq)-1]\n\t*pq = (*pq)[:len(*pq)-1]\n\treturn res\n}\n\nvar err error\n\nfunc NextInt() (n int) {\n\tfor {\n\t\t_, err = scanf(\"%v\", &n)\n\t\tif err == nil {\n\t\t\treturn n\n\t\t}\n\t\tif err.Error() == \"EOF\" {\n\t\t\treturn 0\n\t\t}\n\t}\n}\n\nfunc NextLong() (n int64) {\n\tfor {\n\t\t_, err = scanf(\"%v\", &n)\n\t\tif err == nil {\n\t\t\treturn n\n\t\t}\n\t\tif err.Error() == \"EOF\" {\n\t\t\treturn 0\n\t\t}\n\t}\n}\nfunc Euclid(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\tgcd, s1, s2 := Euclid(b, a%b)\n\treturn gcd, s2, s1 - s2*(a/b)\n}\n\nfunc main() {\n\tout = bufio.NewWriterSize(os.Stdout, 8192)\n\tdefer out.Flush()\n\tif false {\n\t\tfile, err := os.Open(\"in\")\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tin = bufio.NewReaderSize(file, 8192)\n\t} else {\n\t\tin = bufio.NewReaderSize(os.Stdin, 8192)\n\t}\nouter:\n\tfor cases := NextInt(); cases > 0; cases-- {\n\t\tn := NextInt()\n\t\tfor i := 2; i*i <= n; i++ {\n\t\t\tif n%i == 0 {\n\t\t\t\tprintf(\"%d %d\\n\", n/i, n-n/i)\n\t\t\t\tcontinue outer\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d %d\\n\", 1, n-1)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "80874802b6552ed62eea66920fe55047", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tn, m := readTwoNums(reader)\n\tres := solve(n, m)\n\tfmt.Println(res)\n}\n\nfunc normalize(s string) string {\n\n\tfor i := len(s); i > 0; i-- {\n\t\tif s[i-1] >= 'a' && s[i-1] <= 'z' {\n\t\t\treturn s[:i]\n\t\t}\n\t}\n\treturn \"\"\n}\n\nfunc readInt(bytes []byte, from int, val *int) int {\n\ti := from\n\tsign := 1\n\tif bytes[i] == '-' {\n\t\tsign = -1\n\t\ti++\n\t}\n\ttmp := 0\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + int(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp * sign\n\treturn i\n}\n\nfunc readNum(reader *bufio.Reader) (a int) {\n\tbs, _ := reader.ReadBytes('\\n')\n\treadInt(bs, 0, &a)\n\treturn\n}\n\nfunc readTwoNums(reader *bufio.Reader) (a int, b int) {\n\tres := readNNums(reader, 2)\n\ta, b = res[0], res[1]\n\treturn\n}\n\nfunc readThreeNums(reader *bufio.Reader) (a int, b int, c int) {\n\tres := readNNums(reader, 3)\n\ta, b, c = res[0], res[1], res[2]\n\treturn\n}\n\nfunc readNNums(reader *bufio.Reader, n int) []int {\n\tres := make([]int, n)\n\tx := 0\n\tbs, _ := reader.ReadBytes('\\n')\n\tfor i := 0; i < n; i++ {\n\t\tfor x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {\n\t\t\tx++\n\t\t}\n\t\tx = readInt(bs, x, &res[i])\n\t}\n\treturn res\n}\n\nfunc readUint64(bytes []byte, from int, val *uint64) int {\n\ti := from\n\n\tvar tmp uint64\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + uint64(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp\n\n\treturn i\n}\n\nconst MOD = 998244353\nconst MAX_N = 2021*2 + 10\n\nvar F [MAX_N]int\nvar I [MAX_N]int\n\nfunc modAdd(a int, b int) int {\n\ta += b\n\tif a >= MOD {\n\t\ta -= MOD\n\t}\n\treturn a\n}\n\nfunc modMul(a int, b int) int {\n\tres := int64(a) * int64(b)\n\tres %= MOD\n\treturn int(res)\n}\n\nfunc pow(a, b int) int {\n\tr := 1\n\tfor b > 0 {\n\t\tif b&1 == 1 {\n\t\t\tr = modMul(r, a)\n\t\t}\n\t\ta = modMul(a, a)\n\t\tb >>= 1\n\t}\n\treturn r\n}\n\nfunc init() {\n\tF[0] = 1\n\tfor i := 1; i < MAX_N; i++ {\n\t\tF[i] = modMul(i, F[i-1])\n\t}\n\tI[MAX_N-1] = pow(F[MAX_N-1], MOD-2)\n\tfor i := MAX_N - 2; i >= 0; i-- {\n\t\tI[i] = modMul(i+1, I[i+1])\n\t}\n}\n\nfunc nCr(n int, r int) int {\n\tres := F[n]\n\tres = modMul(res, I[r])\n\tres = modMul(res, I[n-r])\n\treturn res\n}\n\nfunc solve(n int, m int) int {\n\t// must be dp, but how?\n\tif n < m {\n\t\tn, m = m, n\n\t}\n\tvar ans int\n\tfor r := 1; r < n; r++ {\n\t\tvar f int\n\t\tfor c := m - 1; c >= 1; c-- {\n\t\t\tf = modAdd(f, modMul(nCr(n-r+m-c-1, n-r), nCr(c+n-r-1, n-r-1)))\n\t\t\tans = modAdd(ans, modMul(nCr(r+c-1, r), modMul(nCr(m-c+r-1, r-1), f)))\n\t\t}\n\t}\n\n\tn, m = m, n\n\n\tfor r := 1; r < n; r++ {\n\t\tvar f int\n\t\tfor c := m - 1; c >= 1; c-- {\n\t\t\tans = modAdd(ans, modMul(nCr(r+c-1, r), modMul(nCr(m-c+r-1, r-1), f)))\n\t\t\tf = modAdd(f, modMul(nCr(n-r+m-c-1, n-r), nCr(c+n-r-1, n-r-1)))\n\t\t}\n\t}\n\n\treturn modMul(ans, 2)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "652c5cd33a7f5b136b837ffef9e470f0", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n\t// your code goes here\n\tvar n, k int\n\tfmt.Scan(&n)\n\tfmt.Scan(&k)\n\t\n\toutput := (n / 2) * k\n\tif n % 2 > 0 {\n\t\toutput += (k / 2)\n\t}\n\tfmt.Println(output)\n}", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "6d8371156b9f8d6bba84498a29ab40d2", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// URL: http://codeforces.com/contest/50/problem/A\n// PROBLEM RESTATEMENT\n// Given a rectangular board of M x N squares, and 2 x 1 dominoes,\n// determine the maximum number of dominoes that can be placed s.t:\n// * Each domino covers two squares.\n// * No two dominoes overlap.\n// * Each domino lies entirely inside the board.\n// APPROACH\n// (1) Color the board like a chessboard.\n// (2) Each domino covers exactly 1 black and 1 white square.\n// (3) The maximum number of dominoes that can be placed is equal to the\n// min(white, black) squares in the board.\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar m, n int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &m, &n)\n\tfmt.Fprintf(writer, \"%d\\n\", m * n / 2)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "25ff17294808c5bbd76919e4a4481fda", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar m, n int\n\tfmt.Scan(&m, &n)\n\tfmt.Println(m * n >> 1)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "adf5e6b607e0cc36e009cd3209b137d1", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// A. Love \"A\"\n/*\nAlice has a string 𝑠. She really likes the letter \"a\".\nShe calls a string good if strictly more than half of the characters in\nthat string are \"a\"s. For example \"aaabb\", \"axaa\" are good strings,\nand \"baca\", \"awwwa\", \"\" (empty string) are not.\n\nAlice can erase some characters from her string 𝑠. She would like to know\nwhat is the longest string remaining after erasing some characters\n(possibly zero) to get a good string. It is guaranteed that the string has\nat least one \"a\" in it, so the answer always exists.\n\nInput\nThe first line contains a string 𝑠(1≤|𝑠|≤50) consisting of lowercase\nEnglish letters. It is guaranteed that there is at least one \"a\" in 𝑠.\n\nOutput\nPrint a single integer, the length of the longest good string\nthat Alice can get after erasing some characters from 𝑠.\n\nExamples\nInput\nxaxxxxa\n\nOutput\n3\n\nInput\naaabaa\n\nOutput\n6\n\nNote\nIn the first example, it's enough to erase any four of the \"x\"s.\nThe answer is 3 since that is the maximum number of characters that can remain.\n\nIn the second example, we don't need to erase any characters.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\n\tsol1146A(strings.TrimSpace(input))\n}\n\nfunc sol1146A(s string) {\n\ttotal, c := len(s), 0\n\n\tfor _, v := range s {\n\t\tif v == 'a' {\n\t\t\tc++\n\t\t}\n\t}\n\n\tif c > total/2 {\n\t\tfmt.Println(total)\n\t} else {\n\t\tfmt.Println(c*2 - 1)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "94afce904faffe62bacec4eca14aa6f0", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport \"fmt\"\n\nfunc main() {\n\tvar str string\n\tfmt.Scan(&str)\n\ta, l := 0, len(str)\n\tfor _, r := range str {if r == 'a' {a++}}\n\tif a > (l/2) {fmt.Println(l)} else {fmt.Println(l-(l-a-a+1))}\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "05dce53c453cdc03f0e25c19eade8b8d", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\n\tvar s string\n\tfmt.Fscanf(in, \"%s\\n\", &s)\n\tfmt.Println(loveA(s))\n}\n\nfunc loveA(s string) int {\n\tlenS := len(s)\n\tlenA := strings.Count(s, \"a\")\n\n\tif lenA > lenS/2 {\n\t\treturn lenS\n\t}\n\n\treturn lenS - (lenS - 2*lenA + 1)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "b1364cc018dd4df0de46462a01965c84", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar r = bufio.NewReader(os.Stdin)\nvar w = bufio.NewWriter(os.Stdout)\n\nfunc l(x uint64) int {\n\tcnt := 0\n\tfor x != 0 {\n\t\tx /= 10\n\t\tcnt++\n\t}\n\treturn cnt\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int\n\tvar x uint64\n\tfmt.Fscan(r, &n, &x)\n\tif l(x) > n {\n\t\tfmt.Fprintln(w, \"-1\")\n\t\treturn\n\t} else if l(x) == n {\n\t\tfmt.Fprintln(w, \"0\")\n\t\treturn\n\t}\n\tvar dfs func(x uint64, used int) int\n\tans := 100\n\treme := make(map[uint64]int)\n\tdfs = func(x uint64, used int) int {\n\t\tcnt := 0\n\t\thash := map[int]bool{}\n\t\ty := x\n\t\tfor x != 0 {\n\t\t\thash[int(x%10)] = true\n\t\t\tx /= 10\n\t\t\tcnt++\n\t\t}\n\t\tret := 100\n\t\tif cnt >= n {\n\t\t\tret = 0\n\t\t} else {\n\t\t\tfor k := range hash {\n\t\t\t\tif k == 0 || k == 1 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tnext := uint64(k)*y\n\t\t\t\tif u, ok := reme[next]; ok {\n\t\t\t\t\tret = min(ret, u)\n\t\t\t\t} else {\n\t\t\t\t\tret = min(ret, dfs(next, used+1))\n\t\t\t\t}\n\t\t\t}\n\t\t\tret++\n\t\t}\n\t\treme[y] = ret\n\t\tans = min(ans, used + ret)\n\t\treturn ret\n\t}\n\tdfs(uint64(x), 0)\n\tif ans == 100 {\n\t\tfmt.Fprintln(w, -1)\n\t\treturn\n\t}\n\tfmt.Fprintln(w, ans)\n}\n\nfunc min(a, b int) int {if a < b {return a} else {return b}}", "lang_cluster": "Go", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "4c2e8a0f64c4a8beb52801937a762759", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1681D(in io.Reader, out io.Writer) {\r\n\tvar n, ans int\r\n\tq := []int64{0}\r\n\tFscan(in, &n, &q[0])\r\n\tfor ; len(q) > 0; ans++ {\r\n\t\ttmp := q\r\n\t\tq = nil\r\n\t\tinq := map[int64]bool{}\r\n\t\tfor _, v := range tmp {\r\n\t\t\tcnt := 0\r\n\t\t\tfor x := v; x > 0; x /= 10 {\r\n\t\t\t\tcnt++\r\n\t\t\t\td := x % 10\r\n\t\t\t\tif d > 1 && !inq[v*d] {\r\n\t\t\t\t\tinq[v*d] = true\r\n\t\t\t\t\tq = append(q, v*d)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif cnt == n {\r\n\t\t\t\tFprint(out, ans)\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tFprint(out, -1)\r\n}\r\n\r\nfunc main() { CF1681D(os.Stdin, os.Stdout) }\r\n", "lang_cluster": "Go", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "a8134b803fe459abc52e21f27b3d49a2", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t. \"fmt\"\r\n\t\"math\"\r\n\t\"os\"\r\n)\r\n\r\nvar ans int\r\n\r\ntype pair struct{ x, y int64 }\r\n\r\nfunc BFS(n int, x int64) {\r\n\tmp := make(map[int64]bool, int(1e7))\r\n\tque := make(chan pair, int(1e7))\r\n\tm := int64(math.Pow10(n - 1))\r\n\tque <- pair{x, 0}\r\n\tfor {\r\n\t\tif len(que) == 0 {\r\n\t\t\tbreak\r\n\t\t}\r\n\t\tp := <-que\r\n\t\t//println(p.x, p.y)\r\n\t\tif _, xx := mp[p.x]; xx {\r\n\t\t\tcontinue\r\n\t\t}\r\n\t\tmp[p.x] = true\r\n\t\tif p.x >= m {\r\n\t\t\tans = int(p.y)\r\n\t\t\treturn\r\n\t\t}\r\n\t\ta := make([]int, 10)\r\n\t\ttx := p.x\r\n\t\tfor tx > 0 {\r\n\t\t\ta[tx%10] = 1\r\n\t\t\ttx /= 10\r\n\t\t}\r\n\t\tfor i := 2; i < 10; i++ {\r\n\t\t\tif a[i] == 1 {\r\n\t\t\t\tque <- pair{p.x * int64(i), p.y + 1}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunc Solve() {\r\n\tn := ri()\r\n\tvar x int64\r\n\tscan(&x)\r\n\tans = 114514\r\n\tBFS(n, x)\r\n\tif ans == 114514 {\r\n\t\tans = -1\r\n\t}\r\n\tprintln(ans)\r\n}\r\n\r\nfunc main() {\r\n\tT := 1 // 如果是单组样例,请讲 T := 0 改为 T := 1\r\n\tin, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\r\n\tif T == 0 {\r\n\t\tscan(&T)\r\n\t}\r\n\tfor t := 0; t < T; t++ {\r\n\t\tSolve()\r\n\t}\r\n\tout.Flush()\r\n}\r\n\r\nvar in *bufio.Reader\r\nvar out *bufio.Writer\r\n\r\n// ri 将直接读入并返回一个 int\r\nfunc ri() (x int) {\r\n\tscan(&x)\r\n\treturn x\r\n}\r\n\r\n//rs 将直接读入并返回一个 string\r\nfunc rs() (s string) {\r\n\tscan(&s)\r\n\treturn s\r\n}\r\n\r\n//scan 用法与 fmt.scan() 相似,可以传入多个变量的地址进行读入操作\r\nfunc scan(a ...interface{}) { Fscan(in, a...) }\r\n\r\n//print 用法与 fmt.print() 相似,可以传入多个变量进行输出。注意,这个函数不会换行,多个变量之间有空格\r\nfunc print(a ...interface{}) { Fprint(out, a...) }\r\n\r\n//println 用法与 fmt.println() 相似,可以传入多个变量进行输出。这个函数会换行,多个变量之间有空格\r\nfunc println(a ...interface{}) { Fprintln(out, a...) }\r\n\r\n//min 可以传入多个 int 变量,求出这些变量的最小值\r\nfunc min(a ...int) int {\r\n\tans := a[0]\r\n\tfor i := 1; i < len(a); i++ {\r\n\t\tif a[i] < ans {\r\n\t\t\tans = a[i]\r\n\t\t}\r\n\t}\r\n\treturn ans\r\n}\r\n\r\n//max 可以传入多个 int 变量,求出这些变量的最大值\r\nfunc max(a ...int) int {\r\n\tans := a[0]\r\n\tfor i := 1; i < len(a); i++ {\r\n\t\tif a[i] > ans {\r\n\t\t\tans = a[i]\r\n\t\t}\r\n\t}\r\n\treturn ans\r\n}\r\n\r\n//sum 可以传入多个 int 变量,求出这些变量的总和,并返回总和。\r\n//你可以使用 ... 运算符打散数组,使得 sum 函数可以求出数组的和。\r\nfunc sum(a ...int) int {\r\n\tans := 0\r\n\tfor _, x := range a {\r\n\t\tans += x\r\n\t}\r\n\treturn ans\r\n}\r\n", "lang_cluster": "Go", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "24174a629900f60dffdfe83317063d40", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n\t\"sort\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1681D(in io.Reader, out io.Writer) {\r\n\tvar n, ans int\r\n\tvar x int64\r\n\tFscan(in, &n, &x)\r\n\tq := []int64{x}\r\n\tfor ; len(q) > 0; ans++ {\r\n\t\ttmp := q\r\n\t\tq = nil\r\n\t\tfor _, v := range tmp {\r\n\t\t\tcnt := 0\r\n\t\t\tfor x := v; x > 0; x /= 10 {\r\n\t\t\t\tcnt++\r\n\t\t\t\td := x % 10\r\n\t\t\t\tif d > 1 {\r\n\t\t\t\t\tq = append(q, v*d)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif cnt == n {\r\n\t\t\t\tFprint(out, ans)\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tsort.Slice(q, func(i, j int) bool { return q[i] > q[j] })\r\n\t\tif len(q) > 10000 {\r\n\t\t\tq = q[:10000]\r\n\t\t}\r\n\t}\r\n\tFprint(out, -1)\r\n}\r\n\r\nfunc main() { CF1681D(os.Stdin, os.Stdout) }\r\n", "lang_cluster": "Go", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "5a2277c54d8642ad7aa9de1555a0b7c5", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"container/heap\"\n\t\"container/list\"\n\t. \"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\ntype Int int64\n\nconst (\n\tINF = 3e5 + 10\n\tL0 = Int(0)\n\tL1 = Int(1)\n)\n\nfunc lengthOf(x Int) int {\n\tres := 0\n\n\tfor x > 0 {\n\t\tres++\n\t\tx /= 10\n\t}\n\treturn res\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\n\tvar n int\n\tvar x Int\n\n\tFscan(in, &n, &x)\n\n\tma := make(map[Int]int)\n\n\tqueue := list.New()\n\n\tqueue.PushBack(x)\n\n\tfind := false\n\tfor queue.Len() > 0 && !find {\n\n\t\tnq := list.New()\n\n\t\tfor it := queue.Front(); it != nil && !find; it = it.Next() {\n\t\t\tcur := it.Value.(Int)\n\n\t\t\tcnt := ma[cur]\n\n\t\t\ttmp := cur\n\t\t\tfor tmp > 0 {\n\t\t\t\tmo := tmp % 10\n\t\t\t\ttmp /= 10\n\t\t\t\tif mo < 2 {\n\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tnCur := cur * mo\n\t\t\t\tif ma[nCur] == 0 {\n\t\t\t\t\tcLen := lengthOf(nCur)\n\t\t\t\t\tif cLen < n {\n\t\t\t\t\t\tnq.PushBack(cur * mo)\n\t\t\t\t\t\tma[nCur] = cnt + 1\n\t\t\t\t\t} else {\n\t\t\t\t\t\tFprintln(out, cnt+1)\n\t\t\t\t\t\tfind = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tqueue = nq\n\t}\n\tif !find {\n\t\tFprintln(out, -1)\n\t}\n\n}\n\nfunc MakeGrid(h, w int) [][]Int {\n\tindex := make([][]Int, h)\n\tdata := make([]Int, h*w)\n\tfor i := 0; i < h; i++ {\n\t\tindex[i] = data[i*w : (i+1)*w]\n\t}\n\treturn index\n}\n\nfunc Abs(x Int) Int {\n\tif x > 0 {\n\t\treturn x\n\t}\n\treturn -x\n}\n\nfunc Min(nums ...Int) Int {\n\treturn nums[MinIdx(nums...)]\n}\n\nfunc MinIdx(nums ...Int) Int {\n\tmaxNumIdx := L0\n\tfor i, num := range nums {\n\t\tif num < nums[maxNumIdx] {\n\t\t\tmaxNumIdx = Int(i)\n\t\t}\n\t}\n\treturn maxNumIdx\n}\n\nfunc Max(nums ...Int) Int {\n\treturn nums[MaxIdx(nums...)]\n}\n\nfunc MaxIdx(nums ...Int) Int {\n\tmaxNumIdx := L0\n\tfor i, num := range nums {\n\t\tif num > nums[maxNumIdx] {\n\t\t\tmaxNumIdx = Int(i)\n\t\t}\n\t}\n\treturn maxNumIdx\n}\n\nvar (\n\tmod Int\n\tfmod func(Int) Int = doNothing\n)\n\n// SetMod sets the mod. It must be called first.\nfunc SetMod(newMod Int) {\n\tmod = newMod\n\tfmod = dynamicMod\n}\n\nfunc dynamicMod(m Int) Int {\n\tm %= mod\n\tif m < 0 {\n\t\treturn m + mod\n\t}\n\treturn m\n}\n\nfunc doNothing(m Int) Int {\n\treturn m\n}\n\n// Mod returns m % mod.\nfunc (m Int) Mod() Int {\n\treturn fmod(m)\n}\n\n// Inv returns modular multiplicative inverse\nfunc (m Int) Inv() Int {\n\treturn m.Pow(Int(0).Sub(2))\n}\n\n// Pow returns m^n\nfunc (m Int) Pow(n Int) Int {\n\tp := Int(1)\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tp.MulAs(m)\n\t\t}\n\t\tm.MulAs(m)\n\t\tn >>= 1\n\t}\n\treturn p\n}\n\n// Add returns m+x\nfunc (m Int) Add(x Int) Int {\n\treturn (m + x).Mod()\n}\n\n// Sub returns m-x\nfunc (m Int) Sub(x Int) Int {\n\treturn (m - x).Mod()\n}\n\n// Mul returns m*x\nfunc (m Int) Mul(x Int) Int {\n\treturn (m * x).Mod()\n}\n\n// Div returns m/x\nfunc (m Int) Div(x Int) Int {\n\treturn m.Mul(x.Inv())\n}\n\n// AddAs assigns *m + x to *m and returns m\nfunc (m *Int) AddAs(x Int) *Int {\n\t*m = m.Add(x)\n\treturn m\n}\n\n// SubAs assigns *m - x to *m and returns m\nfunc (m *Int) SubAs(x Int) *Int {\n\t*m = m.Sub(x)\n\treturn m\n}\n\n// MulAs assigns *m * x to *m and returns m\nfunc (m *Int) MulAs(x Int) *Int {\n\t*m = m.Mul(x)\n\treturn m\n}\n\n// DivAs assigns *m / x to *m and returns m\nfunc (m *Int) DivAs(x Int) *Int {\n\t*m = m.Div(x)\n\treturn m\n}\n\nfunc (m *Int) MaxAs(x ...Int) *Int {\n\t*m = Max(append(x, *m)...)\n\treturn m\n}\n\nfunc (m *Int) MinAs(x ...Int) *Int {\n\t*m = Min(append(x, *m)...)\n\treturn m\n}\n\ntype Void struct{}\n\nvar void Void\n\ntype HashSet struct {\n\tma map[Int]Void\n}\n\nfunc NewHashSet() *HashSet {\n\treturn &HashSet{\n\t\tma: make(map[Int]Void),\n\t}\n}\n\nfunc (s *HashSet) add(x Int) bool {\n\t_, exists := s.ma[x]\n\tif !exists {\n\t\ts.ma[x] = void\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}\n\nfunc (s *HashSet) del(x Int) {\n\tdelete(s.ma, x)\n}\n\nfunc (s *HashSet) exist(x Int) bool {\n\t_, exists := s.ma[x]\n\treturn exists\n}\n\n// An Item is something we manage in a priority queue.\ntype Item struct {\n\tvalue Int // The value of the item; arbitrary.\n\tpriority Int // The priority of the item in the queue.\n\tindices Int\n\t// The index is needed by update and is maintained by the heap.Interface methods.\n\tindex int // The index of the item in the heap.\n}\n\n// A PriorityQueue implements heap.Interface and holds Items.\ntype PriorityQueue []*Item\n\nfunc NewItem(value, priority Int) *Item {\n\treturn &Item{\n\t\tvalue: value,\n\t\tpriority: priority,\n\t\tindex: -1,\n\t}\n\n}\n\nfunc (pq PriorityQueue) Len() int { return len(pq) }\n\nfunc (pq PriorityQueue) Less(i, j int) bool {\n\t// We want Pop to give us the highest, not lowest, priority so we use greater than here.\n\treturn pq[i].priority < pq[j].priority\n}\n\nfunc (pq PriorityQueue) Swap(i, j int) {\n\tpq[i], pq[j] = pq[j], pq[i]\n\tpq[i].index = i\n\tpq[j].index = j\n}\n\nfunc (pq *PriorityQueue) Push(x interface{}) {\n\tn := len(*pq)\n\titem := x.(*Item)\n\titem.index = n\n\t*pq = append(*pq, item)\n}\n\nfunc (pq *PriorityQueue) Pop() interface{} {\n\told := *pq\n\tn := len(old)\n\titem := old[n-1]\n\told[n-1] = nil // avoid memory leak\n\titem.index = -1 // for safety\n\t*pq = old[0 : n-1]\n\treturn item\n}\n\n// update modifies the priority and value of an Item in the queue.\nfunc (pq *PriorityQueue) update(item *Item, value Int, priority Int) {\n\titem.value = value\n\titem.priority = priority\n\theap.Fix(pq, item.index)\n}\n\ntype SegTree struct {\n\tst []Segment\n}\n\ntype Segment struct {\n\tl, r, val, add, minIndex Int\n}\n\nfunc newSegTree(n Int) SegTree {\n\tsegTree := SegTree{make([]Segment, n<<2)}\n\tsegTree.Build(1, 1, n)\n\treturn segTree\n}\n\nfunc (segTree SegTree) Build(x, l, r Int) {\n\tsegTree.st[x].l = l\n\tsegTree.st[x].r = r\n\tif l == r {\n\t\tsegTree.st[x].minIndex = l\n\t\treturn\n\t}\n\tmid := (l + r) >> 1\n\tsegTree.Build(x<<1, l, mid)\n\tsegTree.Build(x<<1|1, mid+1, r)\n}\n\nfunc (segTree SegTree) push(x Int) {\n\tif segTree.st[x].add != 0 {\n\t\tsegTree.modifyOne(x<<1, segTree.st[x].add)\n\t\tsegTree.modifyOne(x<<1|1, segTree.st[x].add)\n\t\tsegTree.st[x].add = 0\n\t}\n}\n\nfunc (segTree SegTree) update(x Int) {\n\tif segTree.st[x<<1].val < segTree.st[x<<1|1].val {\n\t\tsegTree.st[x].val = segTree.st[x<<1].val\n\t\tsegTree.st[x].minIndex = segTree.st[x<<1].minIndex\n\t} else {\n\t\tsegTree.st[x].val = segTree.st[x<<1|1].val\n\t\tsegTree.st[x].minIndex = segTree.st[x<<1|1].minIndex\n\t}\n}\n\nfunc (segTree SegTree) modifyOne(x, add Int) {\n\tsegTree.st[x].val += add\n\tif segTree.st[x].l != segTree.st[x].r {\n\t\tsegTree.st[x].add += add\n\t}\n}\n\nfunc (segTree SegTree) Modify(x, l, r, add Int) {\n\tif segTree.st[x].l >= l && segTree.st[x].r <= r {\n\t\tsegTree.modifyOne(x, add)\n\t\treturn\n\t}\n\tsegTree.push(x)\n\tmid := (segTree.st[x].l + segTree.st[x].r) >> 1\n\tif mid >= l {\n\t\tsegTree.Modify(x<<1, l, r, add)\n\t}\n\tif mid < r {\n\t\tsegTree.Modify(x<<1|1, l, r, add)\n\t}\n\tsegTree.update(x)\n}\n\nfunc updateRes(cRes, cIndex, res, index Int) (Int, Int) {\n\tif cRes > res {\n\t\treturn res, index\n\t}\n\treturn cRes, cIndex\n}\n\nfunc (segTree SegTree) Query(x, l, r Int) (Int, Int) {\n\tres := Int(math.MaxInt64)\n\tresInd := -L1\n\tif segTree.st[x].l >= l && segTree.st[x].r <= r {\n\t\tres, resInd = updateRes(res, resInd, segTree.st[x].val, segTree.st[x].minIndex)\n\t\treturn res, resInd\n\t}\n\tmid := (segTree.st[x].l + segTree.st[x].r) >> 1\n\tif mid >= l {\n\t\tsonRes, sonInd := segTree.Query(x<<1, l, r)\n\t\tres, resInd = updateRes(res, resInd, sonRes, sonInd)\n\t}\n\tif mid < r {\n\t\tsonRes, sonInd := segTree.Query(x<<1|1, l, r)\n\t\tres, resInd = updateRes(res, resInd, sonRes, sonInd)\n\t}\n\treturn res, resInd\n}\n\ntype Graph struct {\n\tnodeSize Int\n\tedges []Edge\n\thead []Int\n\tdis []Int\n\tvis []bool\n\tnCnt Int\n\tans []Int\n}\n\ntype Edge struct {\n\tu, v, c, indices, next Int\n}\n\nfunc NewGraph(nodeSize Int) *Graph {\n\treturn &Graph{\n\t\tnodeSize: nodeSize,\n\t\tedges: make([]Edge, (2e5+10)<<2),\n\t\thead: make([]Int, nodeSize+100),\n\t\tdis: make([]Int, nodeSize+100),\n\t\tvis: make([]bool, nodeSize+100),\n\t\tnCnt: L1,\n\t\tans: make([]Int, nodeSize),\n\t}\n}\n\nfunc (g *Graph) addEdge(u Int, v Int, cost Int, indices Int) {\n\tg.nCnt++\n\tg.edges[g.nCnt] = Edge{u, v, cost, indices, g.head[u]}\n\tg.head[u] = g.nCnt\n}\n\nfunc (g *Graph) Dijkstra(begin Int) {\n\tfor i := L1; i <= g.nodeSize; i++ {\n\t\tg.dis[i] = math.MaxInt64\n\t}\n\tpq := make(PriorityQueue, 0)\n\theap.Init(&pq)\n\n\tg.dis[begin] = 0\n\theap.Push(&pq, &Item{begin, 0, -1, -1})\n\n\tid := L0\n\n\tfor len(pq) > 0 {\n\t\tit := heap.Pop(&pq).(*Item)\n\t\tu := it.value\n\t\tif g.vis[u] {\n\t\t\tcontinue\n\t\t}\n\t\tg.vis[u] = true\n\n\t\tif it.indices != -1 && id < g.nodeSize-1 {\n\t\t\tg.ans[id] = it.indices\n\t\t\tid++\n\t\t}\n\n\t\tfor i := g.head[u]; i != 0; i = g.edges[i].next {\n\t\t\tv := g.edges[i].v\n\t\t\tif g.dis[v] > g.dis[u]+g.edges[i].c {\n\t\t\t\tg.dis[v] = g.dis[u] + g.edges[i].c\n\n\t\t\t\theap.Push(&pq, &Item{v, g.dis[v], g.edges[i].indices, -1})\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "6052055db3d3d6f16afaeefa7c9843fc", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar output map[int]string = map[int]string{\n\t0: \"O-|-OOOO\",\n\t1: \"O-|O-OOO\",\n\t2: \"O-|OO-OO\",\n\t3: \"O-|OOO-O\",\n\t4: \"O-|OOOO-\",\n\t5: \"-O|-OOOO\",\n\t6: \"-O|O-OOO\",\n\t7: \"-O|OO-OO\",\n\t8: \"-O|OOO-O\",\n\t9: \"-O|OOOO-\",\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\n\tswitch n {\n\tcase 0:\n\t\tfmt.Println(output[0])\n\tdefault:\n\t\tfor n > 0 {\n\t\t\tfmt.Println(output[n%10])\n\t\t\tn /= 10\n\t\t}\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "aaa8956873c1d9b2674374fe8430d61e", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 363A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var str string\n fmt.Scan(&str)\n var i int64\n for i = int64(len(str) - 1); i >= 0; i-- {\n switch str[i] {\n case '0':\n fmt.Printf(\"O-|-OOOO\\n\")\n case '1':\n fmt.Printf(\"O-|O-OOO\\n\")\n case '2':\n fmt.Printf(\"O-|OO-OO\\n\")\n case '3':\n fmt.Printf(\"O-|OOO-O\\n\")\n case '4':\n fmt.Printf(\"O-|OOOO-\\n\")\n case '5':\n fmt.Printf(\"-O|-OOOO\\n\")\n case '6':\n fmt.Printf(\"-O|O-OOO\\n\")\n case '7':\n fmt.Printf(\"-O|OO-OO\\n\")\n case '8':\n fmt.Printf(\"-O|OOO-O\\n\")\n case '9':\n fmt.Printf(\"-O|OOOO-\\n\")\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "6de81377f7a58e9b0830f78acd4ac438", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n \n var high = [2]string{\"O-|\", \"-O|\"}\n var low = [5]string{\"-OOOO\", \"O-OOO\", \"OO-OO\", \"OOO-O\", \"OOOO-\"}\n var num int\n fmt.Scan(&num)\n if num == 0 {\n fmt.Printf(high[0] + low[0])\n } else {\n for num != 0 {\n var div int = num % 10\n fmt.Printf(\"%s%s\\n\", high[div / 5], low[div % 5])\n num /= 10\n }\n }\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "acbe07cf1889caa585787fbc7096f648", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strconv\"\n)\n\nfunc GetScanner() func(a ...*int) {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n\n ScanInts := func(a ...*int) {\n for i := 0; i < len(a); i++ {\n scanner.Scan()\n *(a[i]), _ = strconv.Atoi(scanner.Text())\n }\n }\n return ScanInts\n}\n\nfunc main() {\n scan := GetScanner()\n var n int\n var arr [10][10]int\n\n for i := 0; i < 10; i++ {\n arr[0][i] = 1\n arr[i][0] = 1\n }\n for i := 1; i < 10; i++ {\n for j := 1; j < 10; j++ {\n arr[i][j] = arr[i-1][j] + arr[i][j-1]\n }\n }\n ans := 1\n scan(&n)\n for i := 0; i < n; i++ {\n for j := 0; j < n; j++ {\n if arr[i][j] > ans {\n ans = arr[i][j]\n }\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "f02325fa28d19be62aac258802c4e612", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n n := getI()-1\n m := 2*n\n result := 1\n for i := m; i != n; i-- {\n result *= i\n result /= m+1-i\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "bbf6eacb4bdcf37df3b8d6a7f5ea7b5f", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n int\n\tvar a[10][10] int\n\tfmt.Scanf(\"%d\", &n);\n\tfor i := 0; i < n; i++{\n\t\ta[i][0] = 1\n\t\ta[0][i] = 1\n\t}\n\tfor i := 1; i < n; i++{\n\t\tfor j := 1; j <= i; j++{\n\t\t\ta[i][j] = a[i-1][j] + a[i][j-1]\n\t\t\ta[j][i] = a[i][j]\n\t\t}\n\t}\n\tfmt.Println(a[n-1][n-1])\n}\n\t\n\t\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "783c98466d049a4abe67abcafbe99811", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc f(n int64) int64 {\n\treturn (n - 1) * n / 2\n}\n\nfunc min_pairs(n, m int64) int64 {\n\tq := n / m\n\tmod := n % m\n\treturn f(q)*(m-mod) + f(q+1)*mod\n}\n\nfunc max_pairs(n, m int64) int64 {\n\treturn f(n - (m - 1))\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar n, m int64\n\tfmt.Fscanf(reader, \"%d %d\", &n, &m)\n\tfmt.Fprintf(writer, \"%d %d\\n\", min_pairs(n, m), max_pairs(n, m))\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "372a2f5fd0c6d5bb247833d8758d1340", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadInt64() int64 {\n scanner.Scan()\n ans, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n n := ReadInt64()\n m := ReadInt64()\n free := n - m\n\n max := (free + 1) * free / 2\n x := n / m\n y := n % m\n\n min := y*(x+1)*x/2 + (m-y)*x*(x-1)/2\n writer.WriteString(strconv.FormatInt(min, 10) + \" \" + strconv.FormatInt(max, 10) + \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "3a6b2ff0cb1fad68bbc94843844e3315", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc pair(x int64) int64 {\n\treturn x * (x - 1) / 2\n}\n\nfunc main() {\n\tvar n, m, min, max int64\n\tfmt.Scan(&n, &m)\n\tmax = pair(n - m + 1)\n\tmin = pair(n/m+1)*(n%m) + pair(n/m)*(m-n%m)\n\tfmt.Println(min, max)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "2b2e1522409f1aa89a6e0e3016f672a1", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\tA = 1\n\tB = 3\n\tC = 2\n\tD = 0\n)\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan() \n\ttext := scanner.Text()\n\tnum, _ := strconv.Atoi(text)\n\tswitch num % 4 {\n\tcase A:\n\t\tfmt.Println(\"0 A\")\n\tcase B:\n\t\tfmt.Println(\"2 A\")\n\tcase C:\n\t\tfmt.Println(\"1 B\")\n\tcase D:\n\t\tfmt.Println(\"1 A\")\n\tdefault:\n\t\tfmt.Println(\"0 A\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "b69c201250854331c6a7d5f99d79f083", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc abs(a int) int{\n\tif a < 0{\n\t\treturn -a\n\t} else{\n\t\treturn a\n\t}\n}\n\nfunc min(a, b int) int{\n\tif a < b{\n\t\treturn a\n\t} else{\n\t\treturn b\n\t}\n}\n\nfunc main(){\n\tvar n int\n\tfmt.Scanln(&n)\n\tswitch n%4{\n\tcase 1:\n\t\tfmt.Println(\"0 A\")\n\tcase 2:\n\t\tfmt.Println(\"1 B\")\n\tcase 3:\n\t\tfmt.Println(\"2 A\")\n\tcase 0:\n\t\tfmt.Println(\"1 A\")\n\t}\n}", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "6d6f08e2c9b6c761cd08d7238da32894", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tn := 0\n\tfmt.Scanf(\"%d\", &n)\n\tm := map[int]string{1: \"A\", 3: \"B\", 2: \"C\", 0: \"D\"}\n\tif m[n%4] < m[(n+1)%4] && m[n%4] < m[(n+2)%4] {\n\t\tfmt.Println(0, m[n%4])\n\t} else if m[(n+1)%4] < m[n%4] && m[(n+1)%4] < m[(n+2)%4] {\n\t\tfmt.Println(1, m[(n+1)%4])\n\t} else {\n\t\tfmt.Println(2, m[(n+2)%4])\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "f6f1d548a533195c6f369d01ec768577", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": " package main\n\n import (\n \t\"fmt\"\n \t\"math\"\n )\n\n func main() {\n \tvar x,y,z,t float64\n \tfmt.Scan(&x,&y,&z)\n \tt= math.Sqrt(x*y*z)\n \tt= t/x+t/y+t/z\n \tt*=4\n \t\tfmt.Println(t)\n }\n", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "d301ab751f1fdb4a522bc7c6eaabb7a0", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var a,b,c int\n fmt.Scan(&a,&b,&c)\n y := int(math.Sqrt(float64((a*c)/b)))\n x := (y*b)/c\n z := b/x\n fmt.Println(4*(x+y+z))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "8c1b0494fb47d3f40deee75f17256dc8", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar x, y, z int\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &x, &y, &z); err != nil {\n\t\treturn\n\t}\n\n\ta := math.Sqrt(float64(x * z / y))\n\tb := math.Sqrt(float64(x * y / z))\n\tc := math.Sqrt(float64(y * z / x))\n\n\tfmt.Println(4 * int32(a+b+c))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "5ed9410f019c779c7931b5bbb39c3303", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var a,b,c int\n fmt.Scan(&a,&b,&c)\n\n ok := func(t int) bool {\n d := t*b\n for i := 0; i < c; i++ {\n d += b\n if d < a { return false }\n d -= a\n }\n return true\n }\n\n l, r := 0, int(math.Ceil(float64(a*c)/float64(b)))\n for l != r {\n m := (l+r)/2\n if ok(m) {\n r = m\n } else {\n l = m+1\n }\n }\n fmt.Println(r)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search"], "code_uid": "45afa0505414f3807e82eb6ed12b4156", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar scanner = bufio.NewScanner(os.Stdin)\n\tvar dataPerSec int\n\tvar downloadPerSec int\n\tvar videoLengthInSec int\n\n\tdataPerSec, downloadPerSec, videoLengthInSec = takeInput(scanner)\n\ttotalDownloadTime := calcTotalDownloadTime(\n\t\tcalcTotalData(dataPerSec, videoLengthInSec),\n\t\tdownloadPerSec)\n\tfmt.Println(int(totalDownloadTime) - videoLengthInSec)\n}\n\nfunc takeInput(scanner *bufio.Scanner) (int, int, int) {\n\tvar inputParameters []int\n\n\tscanner.Scan()\n\tinput := strings.Split(scanner.Text(), \" \")\n\tfor _, param := range input {\n\t\tconvertedParam, _ := strconv.Atoi(param)\n\t\tinputParameters = append(inputParameters, convertedParam)\n\t}\n\treturn inputParameters[0], inputParameters[1], inputParameters[2]\n}\n\nfunc calcTotalData(dataPerSec int, videoLength int) int {\n\treturn videoLength * dataPerSec\n}\n\nfunc calcTotalDownloadTime(totalData int, downloadPerSec int) float64 {\n\treturn math.Ceil(float64(totalData) / float64(downloadPerSec))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search"], "code_uid": "61949b6aada3621e14a3bb85f028fe96", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 195A-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\n\tfor i := 1; ; i++ {\n\t\tp := true\n\t\tsum := i * b\n\t\tfor j := 0; j < c; j++ {\n\t\t\tsum += b\n\t\t\tsum -= a\n\n\t\t\tif sum < 0 {\n\t\t\t\tp = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif p {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search"], "code_uid": "eded574f334dff0e2c44a512511a8958", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"math/big\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc run(_r io.Reader, _w io.Writer) {\n\tp := func(n int) bool { return big.NewInt(int64(n)).ProbablyPrime(0) }\n\tvar n int\n\tif Fscan(_r, &n); p(n) {\n\t\tFprint(_w, 1)\n\t} else if n%2 == 0 || p(n-2) {\n\t\tFprint(_w, 2)\n\t} else {\n\t\tFprint(_w, 3)\n\t}\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "bad334381552cc033ec5803769890c2a", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n \"math\"\n)\n\nfunc isPrime(n int) bool {\n sq := int(math.Sqrt(float64(n))+3)\n for i := 2; i < sq && i < n; i++ {\n if n%i == 0 {\n return false\n }\n }\n return true\n}\n\nfunc tax(n int) int {\n if isPrime(n) {\n return 1\n } else if isPrime(n-2) || n%2 == 0 {\n return 2\n }\n return 3\n}\n\nfunc solve() {\n n := readInt()\n fmt.Println(tax(n))\n}\n\n// Helpers\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\n// Sort\n\ntype Ints64 []int64\n\nfunc (a Ints64) Len() int { return len(a) }\nfunc (a Ints64) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a Ints64) Less(i, j int) bool { return a[i] < a[j] }\n\n/* Sort tempalte\nfunc (a ) Len() int { return len(a) }\nfunc (a ) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ) Less(i, j int) bool { return }\n*/\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "dedcde3bb46fa183046da4185fd87c32", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/735/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn int64\n)\n\nfunc main() {\n\tn = ReadInt64()\n\n\tif IsPrime(n) {\n\t\tfmt.Println(1)\n\t\treturn\n\t}\n\n\tif n%2 == 0 {\n\t\tfmt.Println(2)\n\t\treturn\n\t}\n\n\tif IsPrime(n - 2) {\n\t\tfmt.Println(2)\n\t\treturn\n\t}\n\n\tfmt.Println(3)\n}\n\n// func main() {\n// \tn = readInt64()\n\n// \t// ans := 0\n// \tA := []int64{}\n// \tfor {\n// \t\t// ans++\n// \t\tif IsPrime(n) {\n// \t\t\tA = append(A, n)\n// \t\t\tbreak\n// \t\t}\n\n// \t\tp := sub(n - 2)\n// \t\tn -= p\n// \t\tA = append(A, p)\n// \t}\n// \t// fmt.Println(ans)\n// \tfmt.Println(len(A))\n// }\n\n// n以下の最大の素数を返す\nfunc sub(n int64) int64 {\n\tfor i := n; i >= 2; i-- {\n\t\tif IsPrime(i) {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn 1\n}\n\n// IsPrime judges whether an argument integer is a prime number or not.\nfunc IsPrime(n int64) bool {\n\tvar i int64\n\n\tif n == 1 {\n\t\treturn false\n\t}\n\n\tfor i = 2; i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "911b8376e4e44d4f694bce5cbb1a4bb1", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar n int\n\tfmt.Scan(&n)\n\tvar cnt [3]int\n\tfor i := 0; i < n; i++ {\n\t\tvar x int\n\t\tfmt.Scan(&x)\n\t\tcnt[i%3] += x\n\t}\n\tif cnt[0] > cnt[1] && cnt[0] > cnt[2] {\n\t\tfmt.Println(\"chest\")\n\t} else if cnt[1] > cnt[0] && cnt[1] > cnt[2] {\n\t\tfmt.Println(\"biceps\")\n\t} else {\n\t\tfmt.Println(\"back\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fecc049a88cacedc3f943bd61bdd87ab", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,a,ans int\n var cnt [3]int\n fmt.Scan(&n)\n for i := 0; i < n; i++ {\n fmt.Scan(&a)\n cnt[i%3] += a\n if cnt[ans] < cnt[i%3] { ans = i%3 }\n }\n if ans == 0 {\n fmt.Println(\"chest\")\n } else if ans == 1 {\n fmt.Println(\"biceps\")\n } else {\n fmt.Println(\"back\")\n }\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "15f1ac71f3ba908bf2aab89d92912484", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// cf255a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tz := make([]int, 3)\n\tfor i := 0; i < n; i++ {\n\t\tvar r int\n\t\tfmt.Scan(&r)\n\t\tz[i%3] += r\n\t}\n\tif z[0] >= z[1] && z[0] >= z[2] {\n\t\tfmt.Println(\"chest\")\n\t} else if z[1] >= z[0] && z[1] >= z[2] {\n\t\tfmt.Println(\"biceps\")\n\t} else {\n\t\tfmt.Println(\"back\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d4dabf06c95b2713fcb3fc7b0c057b72", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\ts := \"\"\n\tfmt.Scanln(&s)\n\tw := []rune{'h', 'e', 'l', 'l', 'o'}\n\tlenw := len(w)\n\tnext := 0\n\tfor _, c := range s {\n\t\tif next >= lenw {\n\t\t\tbreak\n\t\t}\n\t\tif c == w[next] {\n\t\t\tnext++\n\t\t}\n\t}\n\tif next >= lenw {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["greedy", "strings"], "code_uid": "09330435a54577158fc1c68112ffb3d9", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc find(wanted, word string) bool {\n\tvar first string\n\tfor len(wanted) > 0 && len(word) > 0 {\n\t\tfirst, wanted = string(wanted[0]), wanted[1:]\n\t\tindex := strings.Index(word, first)\n\t\tif index == -1 {\n\t\t\treturn false\n\t\t}\n\t\tword = word[index+1:]\n\t}\n\treturn len(wanted) == 0\n}\n\nfunc main() {\n\tvar word string\n\n\twanted := \"hello\"\n\n\tfmt.Scan(&word)\n\tif find(wanted, word) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["greedy", "strings"], "code_uid": "4ed08c2e08a344e56d2183d80305c14f", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"regexp\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\n\tvar hello = regexp.MustCompile(`h.*e.*l.*l.*o`)\n\n\tif hello.MatchString(s) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}", "lang_cluster": "Go", "tags": ["greedy", "strings"], "code_uid": "7ee59284537547bb87f492b4eac5c115", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n,m,d int\n\tfmt.Scan(&n,&m)\n\tnum := make([]int,m)\n\n\tfor i:=0;i f[i+n-1] - f[i] {\n result = f[i+n-1] - f[i]\n }\n }\n\n fmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "417760c380b87ef943406522e6bfc97f", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 337A-mic\npackage main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n, m, dif, min int\n fmt.Scan(&n, &m)\n a := make([]int, m)\n for i := range a {\n fmt.Scan(&a[i])\n }\n sort.Sort(sort.IntSlice(a))\n //fmt.Println(a)\n min = a[m-1] - a[0]\n //fmt.Println(min)\n for b := 0; b <= m-n; b++ {\n dif = a[b+n-1] - a[b]\n if dif < min {\n min = dif\n }\n }\n fmt.Println(min)\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "deee049a2ceb80834de8f447183f0b49", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport(\n \"fmt\"\n)\n\ntype i64 int64\n\nfunc main(){\n var(\n n i64\n )\n fmt.Scan(&n)\n if n%2==0{\n fmt.Println(n/2)\n }else{\n fmt.Println(-1*(n+1)/2)\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "d360d96a22a7a9bff4317cafb088443f", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n float64\n\n\tfmt.Scanf(\"%f\", &n)\n\n\tfmt.Printf(\"%.0f\\n\", math.Pow(-1, n)*(math.Ceil(n/2)))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "8dd236f36e44bec8330b4591add0aa17", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int64\n\tfmt.Scanf(\"%d\\n\", &n)\n\tif n&1 == 0 {\n\t\tfmt.Println(n >> 1)\n\t}else{\n\t\tfmt.Println(-(n + 1) >> 1)\n\t}\n\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "71b6e587a9a41f43b425556ea579d785", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt64()\n\tm := readInt64()\n\tif m == 0 {\n\t\tfmt.Println(n, n)\n\t\treturn\n\t}\n\tmaxAns := int64(0)\n\tfor i := int64(2); i < 1000000; i++ {\n\t\tt := i * (i - 1) / 2\n\t\tif t >= m {\n\t\t\tmaxAns = n - i\n\t\t\tbreak\n\t\t}\n\t}\n\tif 2 * m < n {\n\t\tfmt.Println(n - (2 * m), maxAns)\n\t} else {\n\t\tfmt.Println(0, maxAns)\n\t}\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "graphs"], "code_uid": "40cd0d6af52add32b7d42babaf0f2883", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar m, n int64\n\tfmt.Scan(&n, &m)\n\tmin := math.Max(float64(n-2*m), 0.0)\n\n\tconnectedCount := int64(0)\n\tusedEdges := int64(0)\n\tfor i := int64(1); i < n; i++ {\n\t\tif usedEdges >= m {\n\t\t\tbreak\n\t\t}\n\t\tusedEdges += i\n\t\t// The first edge connects two vertices, otherwise, every new vertex can use i edges.\n\t\tif connectedCount == 0 {\n\t\t\tconnectedCount = 2\n\t\t} else {\n\t\t\tconnectedCount++\n\t\t}\n\t}\n\tfmt.Println(min, n-connectedCount)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "graphs"], "code_uid": "feb988d7a28183de053cdaaeb3a65e80", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 1065 B Vasya and Isolated Vertices\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"strings\"\n\t\"strconv\"\n\t\"os\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n\tvar a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor i:=0; i= int64(n)) {\n\t\tminV = 0\n\t} else {\n\t\tminV = int(int64(n) - 2*m)\n\t}\n\t// max izo - when part is fully connected\n\tn6 := int64(0)\n\tfor ; n6 <= int64(n); n6++ {\n\t\tee := n6*(n6-1)/2\n\t\tif m == ee {\n\t\t\tmaxV = n - int(n6)\n\t\t\tbreak\n\t\t} else if m > ee {\n\t\t\tmaxV = n - (int(n6) + 1)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t} \n}\n\nfunc printRes() {\n\tfmt.Printf(\"%v %v\\n\", minV, maxV)\n}\n\nfunc main() {\n\treadData()\n\tsolve()\n\tprintRes()\n}\n\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "graphs"], "code_uid": "a88c3e54cc7f1db835382045b8602ad9", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ts := readString()\n\n\tres := 0\n\tfor i := 0; i < len(s)-2; i++ {\n\t\tif s[i] == 'Q' {\n\t\t\tfor j := i + 1; j < len(s)-1; j++ {\n\t\t\t\tif s[j] == 'A' {\n\t\t\t\t\tfor k := j + 1; k < len(s); k++ {\n\t\t\t\t\t\tif s[k] == 'Q' {\n\t\t\t\t\t\t\tres++\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp"], "code_uid": "be7655158612a50f9c394f67c313dacf", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar S string\n\tfmt.Scan(&S)\n\tn := len(S)\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tif S[i] == 'Q' {\n\t\t\tfor j := i + 1; j < n; j++ {\n\t\t\t\tif S[j] == 'A' {\n\t\t\t\t\tfor k := j + 1; k < n; k++ {\n\t\t\t\t\t\tif S[k] == 'Q' {\n\t\t\t\t\t\t\tans++\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp"], "code_uid": "4b8cdd1c51dac81c9e9d7c6decc0d35c", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tstr, _ := reader.ReadString('\\n')\n\tvar a, b, c [200]int64\n\tvar l = len([]rune(str))\n\tfor i := l - 1; i >= 0; i-- {\n\t\ta[i] = a[i+1]\n\t\tif str[i] == 'Q' {\n\t\t\ta[i] += 1\n\t\t}\n\t}\n\n\tfor i := l - 1; i >= 0; i-- {\n\t\tb[i] = b[i+1]\n\t\tif str[i] == 'A' {\n\t\t\tb[i] += a[i]\n\t\t}\n\t}\n\tvar last = l\n\tfor i := l - 1; i >= 0; i-- {\n\t\tc[i] = c[i+1]\n\t\tif str[i] == 'Q' {\n\t\t\tc[i] += b[i]\n\t\t\tlast = i\n\t\t}\n\t}\n\n\tfmt.Print(c[last], \"\\n\")\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp"], "code_uid": "dc89dc05cb93c5abb7a872f1c1c9a178", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar (\n\t\tn, d, m int\n\t\tprs []int\n\t)\n\tfmt.Scan(&n, &d)\n\tfor i := 0; i < n; i++ {\n\t\tvar pr int\n\t\tfmt.Scan(&pr)\n\n\t\tprs = append(prs, pr)\n\t}\n\tfmt.Scan(&m)\n\tvar cnt int\n\tif m > n {\n\t\tcnt -= (m - n) * d\n\t}\n\tsort.Ints(prs)\n\tfor i := 0; i < m; i++ {\n\t\tcnt += prs[i]\n\t\tif i+1 == n {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfmt.Print(cnt)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5988006ff0bfa18d260a485071da5c35", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n,d,m int\n fmt.Scan(&n,&d)\n a := make([]int,n)\n for i := 0; i < n; i++ { fmt.Scan(&a[i]) }\n sort.Ints(a)\n fmt.Scan(&m)\n ans := 0\n for i := 0; i < m; i++ {\n if i < n {\n ans += a[i]\n } else {\n ans -= d\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b758979021d6f44fdfafb62325ffa9f9", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n,d,m int\n fmt.Scan(&n,&d)\n a := make([]int,n)\n for i := 0; i < n; i++ { fmt.Scan(&a[i]) }\n sort.Ints(a)\n fmt.Scan(&m)\n ans := 0\n for i := 0; i < m; i++ {\n if i < n {\n ans += a[i]\n } else {\n ans -= d\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "558feee2dd5c006f783e2ec63d5ac1cd", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc findAnswer(n int) int {\n\tif n == 2 {return 2} else {return 1}\n}\n\nfunc main() {\n\tz := bufio.NewScanner(os.Stdin)\n\tz.Split(bufio.ScanWords)\n\tz.Scan()\n\tm, _ :=strconv.Atoi(z.Text())\n\tfmt.Println(findAnswer(m))\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "690d77568579d80589f0b20faee28904", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, 100*1024*1024)\n\tnum := readInt(r)\n\n\tif num > 2 {\n\t\tfmt.Print(1)\n\t} else {\n\t\tfmt.Print(num)\n\t}\n}\n\nfunc readInt(reader *bufio.Reader) int {\n\ttmpInt, err := strconv.ParseInt(readLine(reader), 10, 64)\n\tcheckError(err)\n\treturn int(tmpInt)\n}\n\nfunc readLine(reader *bufio.Reader) string {\n\tstr, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\n\treturn strings.TrimRight(string(str), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "22220d21576fbbaf6ae86f3c0a59bef4", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar input int\n\tfmt.Scanf(\"%d\", &input)\n\tif input == 2 {\n\t\tfmt.Println(\"2\")\n\t\treturn\n\t}\n\tfmt.Println(\"1\")\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "bc14d51d04f6f42b77c229e52cc7f985", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar n, m int64\n\n\tscanf(\"%d %d\", &n, &m)\n\n\tif m == 1 {\n\t\tfmt.Println(n * n)\n\t\treturn\n\t}\n\n\tmp := make(map[int64]int64)\n\n\tr := n / m\n\tc := n % m\n\n\tfor i := int64(1); i <= m; i++ {\n\t\tmp[(i*i)%m] += r\n\t}\n\n\tfor i := int64(1); i <= c; i++ {\n\t\tmp[(i*i)%m]++\n\t}\n\tans := int64(0)\n\tfor k, v := range mp {\n\t\tif k == 0 {\n\t\t\tans += v * v\n\t\t} else {\n\t\t\tans += v * mp[m-k]\n\t\t}\n\n\t}\n\n\t//ans += mp[int64(0)]\n\n\tfmt.Println(ans)\n\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "4dc62b35d8ea7278ee107b1fefe44a90", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1056/B\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn, m int\n\n\tM, MM [1000 + 50]int\n)\n\nfunc main() {\n\tn, m = ReadInt2()\n\n\tq := n / m\n\tfor i := 0; i < m; i++ {\n\t\tM[i] = q\n\t}\n\tfor i := 1; i <= n%m; i++ {\n\t\tM[i]++\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tto := (i * i) % m\n\t\tMM[to] += M[i]\n\t}\n\n\tans := int64(0)\n\tans += int64(MM[0]) * int64(MM[0])\n\tfor i := 1; i < m; i++ {\n\t\tans += int64(MM[i]) * int64(MM[m-i])\n\t}\n\tfmt.Println(ans)\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "d9b31d95d633b96f7c28d1cdf9f4f75d", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\n\nfunc main() {\n var n, m uint64\n fmt.Fscan(reader, &n)\n fmt.Fscan(reader, &m)\n var i, j, lim, nrow, ncolumn, total uint64\n if n= int64(i) {\n a[i] += 1\n }\n }\n \n for i := 0; i < 9; i++ {\n for j := 0; j < 9; j++ {\n ans += a[i] * a[j] * a[i * j % 9]\n }\n }\n \n for i := 1; int64(i) <= n; i++ {\n ans -= n / int64(i)\n }\n fmt.Println(ans)\n \n return\n}", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "36304b97d6a74e536ffad47936bdaf9d", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,d,t int\n\ta:=0\n\tfmt.Scan(&n,&d)\n\tfor i:=1;i<=n;i++ {\n\t\tfmt.Scan(&t)\n\t\ta+=t\n\t}\n\ta+=(n-1)*10\n\tif a>d {\n\t\tfmt.Println(\"-1\")\n\t} else {\n\t\ta=d-a\n\t\ta=n*2 -2+a/5\n\t\tfmt.Println(a)\n\t}\n}\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "d6293f53a7db4bbdce56f6f3f6824a16", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, d int\n\tfmt.Scan(&n, &d)\n\n\tvar ti int\n\tfmt.Scan(&ti)\n\n\tans := 0\n\tsum := ti\n\tfor i := 1; i < n; i++ {\n\t\tfmt.Scan(&ti)\n\t\tsum += (10 + ti)\n\n\t\tif sum > d {\n\t\t\tans = -1\n\t\t\tbreak\n\t\t}\n\t\tans += 2\n\t}\n\tif ans == -1 || sum > d {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tans += ((d - sum) / 5)\n\t\tfmt.Println(ans)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "f8dec14f704d7b158bf16164e2ff8ef9", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, d, v, jokes int\n\tfmt.Scan(&n, &d)\n\n\tcost := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&v)\n\t\tcost += v\n\t}\n\n\tcost += (n - 1) * 10\n\tjokes = (n - 1) * 2\n\tdelta := d - cost\n\tif delta < 0 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tjokes += delta / 5\n\n\tfmt.Println(jokes)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "bbdbe5d1dcfb41c0269bddd6337567a6", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\t// str := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n, m int64\nvar dp [100000 + 5]int64\n\nfunc main() {\n\tn, m = ReadInt64_2()\n\n\tdp[0], dp[1] = 1, 2\n\tfor i := 2; i <= 100000+3; i++ {\n\t\tdp[i] = dp[i-1] + dp[i-2]\n\t\tdp[i] %= MOD\n\t}\n\n\tvar ans int64\n\tans = dp[m-1] - 1\n\tans += dp[n-1]\n\tans %= MOD\n\tans *= 2\n\tans %= MOD\n\n\tfmt.Println(ans)\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "20e23d53675e36d6a24898661e074866", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst mod = 1000000000 + 7\nconst N = 100100\nvar dp[N] int\nvar n, m int\n\nfunc max(a int, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar reader = bufio.NewReader(os.Stdin)\n\tvar writer = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tfmt.Fscanf(reader,\"%d %d\\n\", &n, &m)\n\tdp[1] = 2\n\tdp[2] = 4\n\tfor i := 3; i <= max(n, m); i++ {\n\t\tdp[i] = (dp[i - 1] + dp[i - 2]) % mod\n\t}\n\n\tvar ret = (dp[n] + dp[m] - 2) % mod\n\tif ret < 0 {\n\t\tret += mod\n\t}\n\tfmt.Fprintf(writer, \"%d\", ret)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "3425ea9e2842f33b06e761e994ac0f0e", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst div int64 = 1000000007\n\nfunc cucl(n int) int64 {\n\tvar a, b int64\n\ta = 2\n\tb = 4\n\tif n == 1 {\n\t\treturn a\n\t}\n\n\tif n == 2 {\n\t\treturn b\n\t}\n\n\tfor i := 3; i <= n; i++ {\n\t\ta, b = b%div, (a+b)%div\n\t}\n\n\treturn b\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n, m int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &m)\n\tfmt.Printf(\"%d\\n\", (cucl(n)+cucl(m)+div-2)%div)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "e2875620c020aab7e54c0f230fe99cd7", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\ntype Int int64\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n Int\n\tfor I(&n) == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n Int) {\n\tvar s string\n\tI(&s)\n\tvar ans Int\n\tfor i := range s {\n\t\tans++\n\t\tif s[i] != '1' {\n\t\t\tbreak\n\t\t}\n\t}\n\tO(ans, \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b56034d1d13bb23d775af67e79fd1e6d", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tvar changed_bits int = 0\n\treader := bufio.NewReader(os.Stdin)\n\tif s, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif s[i] == '0' {\n\t\t\t\tchanged_bits += 1\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tchanged_bits += 1\n\t\t}\n\t}\n\n\tfmt.Println(changed_bits)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "72d9738092059bde54b4f39ece2b7141", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\"fmt\")\n\nfunc calculate(s string, carry int, t int) int {\n\t\n\tcarry = 1\n\tcount := 0\n\tfor i:=0;i= gg {\n\t\tif gg >= bb {\n\t\t\treturn rr, gg, bb\n\t\t} else if rr >= bb {\n\t\t\treturn rr, bb, gg\n\t\t}\n\t\treturn bb, rr, gg\n\t}\n\tif rr >= bb {\n\t\treturn gg, rr, bb\n\t} else if gg >= bb {\n\t\treturn gg, bb, rr\n\t}\n\treturn bb, gg, rr\n}\n\nfunc f(r, g, b int64) int64 {\n\tx := r - b\n\ty := g - b\n\tif y > 0 {\n\t\tif x >= 2 * y {\n\t\t\treturn y + f(r - 2 * y, b, b)\n\t\t}\n\t\tk := (2 * x - y) / 3\n\t\tif (2 * x - y) % 3 != 0 {\n\t\t\tk++\n\t\t}\n\t\treturn x - k + f(b + y - 2 * x + 3 * k, b, b)\n\t}\n\tif r >= 4 * b {\n\t\treturn 2 * b\n\t}\n\tt := (4 * b - r) / 3\n\tif (4 * b - r) % 3 != 0 {\n\t\tt++\n\t}\n\treturn 2 * b - t\n}\n\nfunc main() {\n\tvar rr, gg, bb int64\n\tfmt.Scanf(\"%d %d %d\", &rr, &gg, &bb)\n\tr, g, b := sort(rr, gg, bb)\n\tfmt.Println(f(r, g, b))\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "d174035aa9c83680c54118008b333a3f", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc min( a, b int64 ) int64 {\n if( a < b ) {\n return a\n }\n return b\n}\n\nfunc main() {\n var r, g, b int64\n fmt.Scan( &r, &g, &b )\n r = min( r, 2 * (g + b) )\n g = min( g, 2 * (b + r) )\n b = min( b, 2 * (r + g) )\n fmt.Println( (r + g + b)/3 )\n}", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "f40dc2a68a311987ab0dc94b7c28d11d", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"sort\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadInt64() int64 {\n scanner.Scan()\n ans, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc min(a, b int64) int64 {\n if a < b {\n return a\n } else {\n return b\n }\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n a := make([]int, 3)\n a[0] = ReadInt32()\n a[1] = ReadInt32()\n a[2] = ReadInt32()\n sort.Ints(a)\n r := int64(a[0]) // min\n g := int64(a[1])\n b := int64(a[2]) // max\n ans := min((r+g+b)/3, r+g)\n writer.WriteString(strconv.FormatInt(ans, 10) + \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "75d7230439ddd8e15954e72a917dc225", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\tmin := n\n\tif n > m {\n\t\tmin = m\n\t}\n\tif min%2 == 0 {\n\t\tfmt.Print(\"Malvika\")\n\t\treturn\n\t}\n\n\tfmt.Print(\"Akshat\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "bec462a6d6a3cf7671e49d584570f3e5", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(x, y int) int {\n\tif x > y {\n\t\treturn y\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n)\n\tfmt.Scan(&m)\n\tvar winner string\n\tif min(n, m)%2 == 0 {\n\t\twinner = \"Malvika\"\n\t} else {\n\t\twinner = \"Akshat\"\n\t}\n\tfmt.Println(winner)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b24ae2b0f3cfa5c6316804efe5332d83", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\n\n// 每选择一个交叉点,去点交叉点的两根木棍\n// 即可用的木棍是n,m中较小的一个\nfunc main(){\n\tvar (\n\t\tn, m, num int\n\t)\n\tfmt.Scanf(\"%d %d\\n\", &n, &m)\n\tif n <= m {\n\t\tnum = n\n\t}else {\n\t\tnum = m\n\t}\n\tif num%2 == 0 {\n\t\tfmt.Println(\"Malvika\")\n\t} else {\n\t\tfmt.Printf(\"Akshat\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4951229d1e8d08ed72074286db05d747", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tarr := []int{1, 5, 10, 20, 100}\n\tvar num int\n\n\tfmt.Scan(&num)\n\tcount := 0\n\tstartIndex := 4\n\tfor num > 0 {\n\t\tif num < arr[startIndex] {\n\t\t\tstartIndex--\n\t\t\tcontinue\n\t\t}\n\t\tcount = count + (num / arr[startIndex])\n\t\tnum = num % arr[startIndex]\n\t\tstartIndex--\n\t}\n\n\tfmt.Println(count)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp"], "code_uid": "b3748f745610509a7595c637b96428bb", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar result int = (n / 100) + (n % 100 / 20) + (n % 100 % 20 / 10) + (n % 100 % 20 % 10 / 5) + (n % 100 % 20 % 10 % 5)\n\tfmt.Print(result)\n}", "lang_cluster": "Go", "tags": ["greedy", "dp"], "code_uid": "467dc7f0f1569f9672d3528a615e95f3", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, num int\n\tnum = 0\n\tfmt.Scan(&n)\n\tfor n != 0 {\n\t\tif n >= 100 {\n\t\t\tn -= 100\n\t\t\tnum++\n\t\t} else if n >= 20 {\n\t\t\tn -= 20\n\t\t\tnum++\n\t\t} else if n >= 10 {\n\t\t\tn -= 10\n\t\t\tnum++\n\t\t} else if n >= 5 {\n\t\t\tn -= 5\n\t\t\tnum++\n\t\t} else if n >= 1 {\n\t\t\tn -= 1\n\t\t\tnum++\n\t\t}\n\t}\n\tfmt.Println(num)\n}", "lang_cluster": "Go", "tags": ["greedy", "dp"], "code_uid": "62b6e516117560175fd5f0549e82bcd6", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar k int\n\tfmt.Scan(&k)\n\tif k == 0 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\ta := make([]int, 12)\n\tfor i := range a {\n\t\tfmt.Scan(&a[i])\n\t}\n\tsort.Ints(a)\n\tfor i := 11; i >= 0; i-- {\n\t\tif k <= a[i] {\n\t\t\tfmt.Println(12 - i)\n\t\t\treturn\n\t\t}\n\t\tk -= a[i]\n\t}\n\tfmt.Println(-1)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "be5f41df26b0cb828a6fbd7f15384b42", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nvar month [12]int\n\nfunc main() {\n\tvar k int\n\tfmt.Scan(&k)\n\n\tfor i := 0; i < 12; i++ {\n\t\tfmt.Scan(&month[i])\n\t}\n\n\tif k == 0 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tsort.Ints(month[:])\n\ti := 11\n\tfor ; i >= 0; i-- {\n\t\tk -= month[i]\n\t\tif k <= 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif i < 0 {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println(12 - i)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "1c4e800fc4746f3af6580834c8d1bda6", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var t int\n num := make([]int, 12)\n total:=0\n\n fmt.Scanf(\"%d\\n\",&t)\n\n for i:=0;i<12;i++{\n fmt.Scan(&num[i])\n total += num[i]\n }\n\n if total b {\n\t\tfmt.Println(+1)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "6e2f9f6bdc162b596da1c044153c3048", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"math\"\n)\n\n//N _\nconst (\n\tN = 1e6 + 5\n)\n\nvar values []byte \n\nfunc inputter(inputReader *bufio.Reader,strs chan *string){\n\tfor {\n\t\tinput , _ := inputReader.ReadString('\\n')\n\t\tinput = strings.TrimSpace(input)\n\t\tif len(input) > 0 {\n\t\t\tinputs := strings.Split(input, \" \")\n\t\t\tfor i := range inputs{\n\t\t\t\tstrs <- &inputs[i]\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc digits(ch1 chan int64, ch2 chan byte){\n\tfor x := range ch1{\n\t\ta := byte(0)\n\t\tfor x > 0 {\n\t\t\ta += values[x%10]\n\t\t\tx/=10\n\t\t}\n\t\tch2 <- a\n\t}\n\tclose(ch2)\n}\n\nfunc main(){\n\trs := bufio.NewReader(os.Stdin)\n\tws := bufio.NewWriter(os.Stdout)\n\n\tstrs := make(chan *string, 100)\n\n\tgo inputter(rs, strs)\n\n\ta , _ := strconv.ParseInt(*<-strs, 10, 64)\n\tb , _ := strconv.ParseInt(*<-strs, 10, 64)\n\n\tvalues = []byte{6, 2, 5, 5, 4, 5, 6, 3, 7, 6}\n\n\tch1 := make(chan int64, N)\n\tch2 := make(chan byte, N)\n\n\tgo digits(ch1, ch2)\n\n\tgo func(){\n\t\tfor i := a; i <= b; i++ {\n\t\t\tch1 <- i\n\t\t}\n\t\tclose(ch1)\n\t}()\n\n\ttotal := int64(0)\n\tfor x := range ch2 {\n\t\ttotal += int64(x)\n\t}\n\n\tws.WriteString(fmt.Sprint(total))\n\tws.Flush()\n}\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "dbc19786bd7fb298a8041e50890513c5", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tm := map[int]int{\n\t\t0: 6,\n\t\t1: 2,\n\t\t2: 5,\n\t\t3: 5,\n\t\t4: 4,\n\t\t5: 5,\n\t\t6: 6,\n\t\t7: 3,\n\t\t8: 7,\n\t\t9: 6,\n\t}\n\tvar a, b, s int\n\tfmt.Scan(&a, &b)\n\tfor i := a; i <= b; i++ {\n\t\ttmp := i\n\t\tfor tmp > 0 {\n\t\t\ts += m[tmp%10]\n\t\t\ttmp /= 10\n\t\t}\n\t}\n\tfmt.Print(s)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ba2588f096c843198e0f2b6545a3350e", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar dig = map[int]int{\n\t0: 6,\n\t1: 2,\n\t2: 5,\n\t3: 5,\n\t4: 4,\n\t5: 5,\n\t6: 6,\n\t7: 3,\n\t8: 7,\n\t9: 6,\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tscanner.Scan()\n\tstart := strings.Split(scanner.Text(), \" \")\n\tx1, _ := strconv.Atoi(start[0])\n\tx2, _ := strconv.Atoi(start[1])\n\n\tsum := 0\n\tfor i := x1; i <= x2; i++ {\n\t\td := i\n\t\tfor d != 0 {\n\t\t\tsum += dig[d % 10]\n\t\t\td = d / 10\n\t\t}\n\n\t}\n\tfmt.Print(sum)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fa7bfdc62689dcbe445f2769472e415e", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nvar v []int64 = []int64{0,4,10,20,35,56,83,116,155,198,244,292}\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tvar n int64\n\tfmt.Fscanf(reader, \"%d\", &n)\n\t\n\tif int(n) < len(v) {\n\t\tfmt.Printf(\"%d\", v[n])\n\t} else {\n\t\tfmt.Printf(\"%d\", 49 * (n - int64(len(v)) + 1) + v[len(v) - 1])\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "combinatorics", "greedy"], "code_uid": "f808bb120cae2f572171f66b1266a03a", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF997B(in io.Reader, out io.Writer) {\n\ta := [...]int{0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244}\n\tvar n int64\n\tFscan(in, &n)\n\tif n < 11 {\n\t\tFprint(out, a[n])\n\t} else {\n\t\tFprint(out, 49*n-247)\n\t}\n}\n\nfunc main() { CF997B(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "combinatorics", "greedy"], "code_uid": "b5b445e913b3a5826e4afeb1a97d7fa5", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/592/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc max(x int, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x int, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc Solve(board [8]string) string {\n\twhitePawn := 7\n\tblackPawn := 0\n\tfor j := 0; j < 8; j++ {\n\t\tfor i := 0; i < 8; i++ {\n\t\t\tif string(board[i][j]) == \"B\" {\n\t\t\t\tbreak\n\t\t\t} else if string(board[i][j]) == \"W\" {\n\t\t\t\twhitePawn = min(i, whitePawn)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfor i := 7; i >= 0; i-- {\n\t\t\tif string(board[i][j]) == \"W\" {\n\t\t\t\tbreak\n\t\t\t} else if string(board[i][j]) == \"B\" {\n\t\t\t\tblackPawn = max(i, blackPawn)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif whitePawn <= 7-blackPawn {\n\t\treturn \"A\"\n\t}\n\treturn \"B\"\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar board [8]string\n\tfor i := 0; i < 8; i++ {\n\t\tfmt.Fscanf(reader, \"%s\\n\", &board[i])\n\t}\n\tfmt.Fprintf(writer, \"%s\\n\", Solve(board))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "595158e404bc7d3ee82b84cfe7fd10bb", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tboard := make([]string, 8)\n\tmaxB, minW := 0, 10\n\n\tfor i := range board {\n\t\tboard[i] = next()\n\t}\n\n\tfor c := 0; c < 8; c++ {\n\t\tb, w := -1, -1\n\n\t\tfor r := 0; r < 8; r++ {\n\t\t\tif board[r][c] == 'B' {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif board[r][c] == 'W' {\n\t\t\t\tw = r\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tfor r := 7; r >= 0; r-- {\n\t\t\tif board[r][c] == 'W' {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif board[r][c] == 'B' {\n\t\t\t\tb = r\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// println(w, b, minW, maxB)\n\n\t\tif w != -1 && w < minW {\n\t\t\tminW = w\n\t\t}\n\n\t\tif b != -1 && b > maxB {\n\t\t\tmaxB = b\n\t\t}\n\t}\n\n\t// println(minW, maxB)\n\tmaxB = 8 - maxB - 1\n\t// println(minW, maxB)\n\tif minW <= maxB {\n\t\tprintln(\"A\")\n\t} else {\n\t\tprintln(\"B\")\n\t}\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "58209a209b26be20ed040c6721c79ac7", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\ntype Point struct {\n\tX, Y float64\n}\n\ntype Square struct {\n\tPoints [4]Point\n}\n\nfunc rotateAxis(p Point, angle float64) (res Point) {\n\tres = Point{}\n\tangle = (angle * math.Pi) / 180\n\tres.X = p.X*math.Cos(angle) + p.Y*math.Sin(angle)\n\tres.Y = -1*p.X*math.Sin(angle) + p.Y*math.Cos(angle)\n\treturn\n}\n\nfunc isInSquare(sq Square, p Point) (b bool) {\n\tvar minHoz float64 = 101\n\tfor _, v := range sq.Points {\n\t\tminHoz = math.Min(minHoz, v.Y)\n\t}\n\n\tvar maxHoz float64 = -101\n\tfor _, v := range sq.Points {\n\t\tmaxHoz = math.Max(maxHoz, v.Y)\n\t}\n\n\tvar minVer float64 = 101\n\tfor _, v := range sq.Points {\n\t\tminVer = math.Min(minVer, v.X)\n\t}\n\n\tvar maxVer float64 = -101\n\tfor _, v := range sq.Points {\n\t\tmaxVer = math.Max(maxVer, v.X)\n\t}\n\n\treturn (p.X >= minVer && p.X <= maxVer) && (p.Y >= minHoz && p.Y <= maxHoz)\n}\n\nfunc solve(sq, sq45 Square) bool {\n\tcenter := Point{0, 0}\n\tfor _, v := range sq45.Points {\n\t\tcenter.X += v.X\n\t\tcenter.Y += v.Y\n\t\tif isInSquare(sq, v) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tcenter.X /= 4\n\tcenter.Y /= 4\n\tif isInSquare(sq, center) {\n\t\treturn true\n\t}\n\n\trotatedSquare := Square{}\n\tfor i := range rotatedSquare.Points {\n\t\trotatedSquare.Points[i] = rotateAxis(sq45.Points[i], 45)\n\t}\n\n\tcenter = Point{0, 0}\n\tfor _, v := range sq.Points {\n\t\tcenter.X += v.X\n\t\tcenter.Y += v.Y\n\t\trotatedPoint := rotateAxis(v, 45)\n\t\tif isInSquare(rotatedSquare, rotatedPoint) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tcenter.X /= 4\n\tcenter.Y /= 4\n\trotatedCenter := rotateAxis(center, 45)\n\tif isInSquare(rotatedSquare, rotatedCenter) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc consoleInput() {\n\tvar x, y float64\n\tsq := Square{}\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Scan(&x, &y)\n\t\tsq.Points[i] = Point{\n\t\t\tX: x,\n\t\t\tY: y,\n\t\t}\n\t}\n\n\tsq45 := Square{}\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Scan(&x, &y)\n\t\tsq45.Points[i] = Point{\n\t\t\tX: x,\n\t\t\tY: y,\n\t\t}\n\t}\n\n\tif solve(sq, sq45) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc mustEqual(expected, actual bool) {\n\tif expected == actual {\n\t\tfmt.Println(\"OK\")\n\t} else {\n\t\tfmt.Println(\"FAILED\")\n\t}\n}\n\nfunc test() {\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{0, 0},\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{6, 6},\n\t\t\t\tPoint{0, 6},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{1, 3},\n\t\t\t\tPoint{3, 5},\n\t\t\t\tPoint{5, 3},\n\t\t\t\tPoint{3, 1},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(true, solve(sq, sq45))\n\t}\n\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{0, 0},\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{6, 6},\n\t\t\t\tPoint{0, 6},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{7, 3},\n\t\t\t\tPoint{9, 5},\n\t\t\t\tPoint{11, 3},\n\t\t\t\tPoint{9, 1},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(false, solve(sq, sq45))\n\t}\n\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{6, 6},\n\t\t\t\tPoint{0, 6},\n\t\t\t\tPoint{0, 0},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{7, 4},\n\t\t\t\tPoint{4, 7},\n\t\t\t\tPoint{7, 10},\n\t\t\t\tPoint{10, 7},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(true, solve(sq, sq45))\n\t}\n\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{-5, -5},\n\t\t\t\tPoint{5, -5},\n\t\t\t\tPoint{5, 5},\n\t\t\t\tPoint{-5, 5},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{0, 6},\n\t\t\t\tPoint{-6, 0},\n\t\t\t\tPoint{0, -6},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(true, solve(sq, sq45))\n\t}\n}\n\nfunc main() {\n\tconsoleInput()\n\t// test()\n}\n", "lang_cluster": "Go", "tags": ["geometry", "implementation"], "code_uid": "393eb89a5f69e50484b12917af85c549", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\ntype Int64Slice []int64\n\nfunc (slice Int64Slice) Len() int { return len(slice) }\nfunc (slice Int64Slice) Less(i, j int) bool { return slice[i] < slice[j] }\nfunc (slice Int64Slice) Swap(i, j int) { slice[i], slice[j] = slice[j], slice[i] }\n\ntype Sq struct {\n\tv [8]int\n}\n\nfunc (sq *Sq) isPara() bool {\n\tchk1, chk2 := false, false\n\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif sq.v[i] == sq.v[0] {\n\t\t\tchk1 = true\n\t\t}\n\t}\n\tfor i := 3; i < 8; i = i + 2 {\n\t\tif sq.v[i] == sq.v[1] {\n\t\t\tchk2 = true\n\t\t}\n\t}\n\n\tif chk1 && chk2 {\n\t\treturn true\n\t}\n\treturn false\n}\n\nvar s1, s2 Sq\n\nfunc gettoux() bool {\n\txmin := s1.v[0]\n\txmax := s1.v[0]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s1.v[i] < xmin {\n\t\t\txmin = s1.v[i]\n\t\t}\n\t\tif s1.v[i] > xmax {\n\t\t\txmax = s1.v[i]\n\t\t}\n\t}\n\tymin := s2.v[0]\n\tymax := s2.v[0]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s2.v[i] < ymin {\n\t\t\tymin = s2.v[i]\n\t\t}\n\t\tif s2.v[i] > ymax {\n\t\t\tymax = s2.v[i]\n\t\t}\n\t}\n\n\tif xmax < ymin || ymax < xmin {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc gettouy() bool {\n\txmin := s1.v[1]\n\txmax := s1.v[1]\n\tfor i := 3; i < 8; i = i + 2 {\n\t\tif s1.v[i] < xmin {\n\t\t\txmin = s1.v[i]\n\t\t}\n\t\tif s1.v[i] > xmax {\n\t\t\txmax = s1.v[i]\n\t\t}\n\t}\n\tymin := s2.v[1]\n\tymax := s2.v[1]\n\tfor i := 3; i < 8; i = i + 2 {\n\t\tif s2.v[i] < ymin {\n\t\t\tymin = s2.v[i]\n\t\t}\n\t\tif s2.v[i] > ymax {\n\t\t\tymax = s2.v[i]\n\t\t}\n\t}\n\n\tif xmax < ymin || ymax < xmin {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc gettouxaddy() bool {\n\txmin := s1.v[0] + s1.v[1]\n\txmax := s1.v[0] + s1.v[1]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s1.v[i]+s1.v[i+1] < xmin {\n\t\t\txmin = s1.v[i] + s1.v[i+1]\n\t\t}\n\t\tif s1.v[i]+s1.v[i+1] > xmax {\n\t\t\txmax = s1.v[i] + s1.v[i+1]\n\t\t}\n\t}\n\tymin := s2.v[0] + s2.v[1]\n\tymax := s2.v[0] + s2.v[1]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s2.v[i]+s2.v[i+1] < ymin {\n\t\t\tymin = s2.v[i] + s2.v[i+1]\n\t\t}\n\t\tif s2.v[i]+s2.v[i+1] > ymax {\n\t\t\tymax = s2.v[i] + s2.v[i+1]\n\t\t}\n\t}\n\n\tif xmax < ymin || ymax < xmin {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc gettouxsuby() bool {\n\txmin := s1.v[0] - s1.v[1]\n\txmax := s1.v[0] - s1.v[1]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s1.v[i]-s1.v[i+1] < xmin {\n\t\t\txmin = s1.v[i] - s1.v[i+1]\n\t\t}\n\t\tif s1.v[i]-s1.v[i+1] > xmax {\n\t\t\txmax = s1.v[i] - s1.v[i+1]\n\t\t}\n\t}\n\tymin := s2.v[0] - s2.v[1]\n\tymax := s2.v[0] - s2.v[1]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s2.v[i]-s2.v[i+1] < ymin {\n\t\t\tymin = s2.v[i] - s2.v[i+1]\n\t\t}\n\t\tif s2.v[i]-s2.v[i+1] > ymax {\n\t\t\tymax = s2.v[i] - s2.v[i+1]\n\t\t}\n\t}\n\n\tif xmax < ymin || ymax < xmin {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tfor i := 0; i < 8; i++ {\n\t\ts1.v[i] = ReadInt32()\n\t}\n\n\tfor i := 0; i < 8; i++ {\n\t\ts2.v[i] = ReadInt32()\n\t}\n\n\tif !s1.isPara() {\n\t\ts1, s2 = s2, s1\n\t}\n\n\tif gettoux() && gettouy() && gettouxaddy() && gettouxsuby() {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n\nfunc Demo() {\n\tvar n, m int64 = ReadInt64(), ReadInt64()\n\tPrintInt64s(n, m)\n\twriter.WriteByte('\\n')\n\tslice := []int64{1, 2, 3, 4, 5}\n\tPrintInt64s(slice...)\n\n\t// sortDemo\n\t//slice := []int64{5, 3, 4, 2, 1}\n\tsort.Sort(Int64Slice(slice))\n\n\t//s := strconv.FormatBool(true)\n\t//s := strconv.FormatFloat(3.1415, 'E', -1, 64)\n\t//s := strconv.FormatInt(-42, 16)\n\t//s := strconv.FormatUint(42, 16)\n\n}\n\nfunc Min(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MinInt(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MinFloat64(a float64, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxInt64(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxInt(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxFloat64(a float64, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc ReadInt64() int64 {\n\tscanner.Scan()\n\tans, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn ans\n}\n\nfunc ReadFloat64() float64 {\n\tscanner.Scan()\n\tans, _ := strconv.ParseFloat(scanner.Text(), 64)\n\treturn ans\n}\n\nfunc PrintInt64s(ints ...int64) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(int(value)))\n\t\twriter.WriteByte(' ')\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "ad71effad26fa2325196de90ff2df3a8", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\tA := io.NextIntArray(N)\n\t\n\tcnt := 0\n\tseen := make(map[int]bool)\n\tgood := make([]bool, N)\n\tfor i := N - 1; i >= 0; i-- {\n\t\tif !seen[A[i]] {\n\t\t\tcnt++\n\t\t\tseen[A[i]] = true\n\t\t\tgood[i] = true\n\t\t}\n\t}\n\t\n\tio.Println(cnt)\n\tfor i, v := range A {\n\t\tif good[i] {\n\t\t\tio.Printf(\"%d \", v)\n\t\t}\n\t}\n\tio.Println()\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cb7a94d6a8621912b57e0a70a4cd6ac1", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport . \"fmt\"\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar n int\n\tScan(&n)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tScan(&a[i])\n\t}\n\tu := []int{}\n\tvis := [1001]bool{}\n\tfor i := n - 1; i >= 0; i-- {\n\t\tif !vis[a[i]] {\n\t\t\tvis[a[i]] = true\n\t\t\tu = append(u, a[i])\n\t\t}\n\t}\n\tPrintln(len(u))\n\tfor i := len(u) - 1; i >= 0; i-- {\n\t\tPrint(u[i], \" \")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a656e4bd3a6eb383c250a683c5afdfde", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nconst (\n\tmaxn = 55\n)\n\nvar (\n\tn int\n\ta [maxn]int\n\tm map[int]bool\n\tans []int\n)\n\nfunc main() {\n\tfmt.Scan(&n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\n\tm = make(map[int]bool)\n\tfor i := n - 1; i >= 0; i-- {\n\t\t_, inMap := m[a[i]]\n\t\tif !inMap {\n\t\t\tans = append(ans, a[i])\n\t\t\tm[a[i]] = true\n\t\t}\n\t}\n\n\tfmt.Println(len(ans))\n\tfor i := len(ans) - 1; i >= 0; i-- {\n\t\tfmt.Printf(\"%v \", ans[i])\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2a1fb9a48c144a0a62dbd980b6fcb8e1", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n, a, x, b, y int\n fmt.Scan(&n, &a, &x, &b, &y)\n a--\n x--\n b--\n y--\n for ;; a, b = (a + 1) % n, (b + n - 1) % n {\n if a == b {\n fmt.Println(\"YES\")\n return\n }\n if a == x || b == y {\n break\n }\n }\n fmt.Println(\"NO\")\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "eb98d49fb378242ddc46e12929e5d135", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, a, b, x, y, cnt int\n\tscr := bufio.NewReader(os.Stdin)\n\t// ocr := bufio.NewWriter(os.Stdout)\n\n\tfmt.Fscanln(scr, &n, &a, &x, &b, &y)\n\n\tfor i := 0; i <= n+1; i++ {\n\t\tif a == b {\n\t\t\tcnt = 2\n\t\t\tbreak\n\t\t}\n\t\ta++\n\t\tif a == n+1 {\n\t\t\ta = 1\n\t\t}\n\t\tb--\n\t\tif b == 0 {\n\t\t\tb = n\n\t\t}\n\n\t\tif a == b {\n\t\t\tcnt = 2\n\t\t\tbreak\n\t\t}\n\n\t\tif a == x || b == y {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif cnt == 2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "aebf378283cca9935583ebc22398a8ad", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc readInt() int {\n\tscanner.Scan()\n\tn, err := strconv.Atoi(scanner.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc readLong() int64 {\n\tscanner.Scan()\n\tn, err := strconv.ParseInt(scanner.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc readWord() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc solve(a int) int {\n\treturn a * a\n}\n\nfunc main() {\n\tscanner.Split(bufio.ScanWords)\n\n\tn, a, x, b, y := readInt(), readInt(), readInt(), readInt(), readInt()\n\ta--\n\tb--\n\tx--\n\ty--\n\n\tfor {\n\t\tif a == b {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\n\t\tif a == x || b == y {\n\t\t\tbreak\n\t\t}\n\n\t\ta = (a + 1) % n\n\t\tb = (b - 1 + n) % n\n\t}\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9d2a7f08d55603d8990578c884338fe9", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\", &a, &b)\n\ti := 1\n\tfor {\n\t\tif a-i < 0 {\n\t\t\tfmt.Println(\"Vladik\")\n\t\t\treturn\n\t\t}\n\t\ta = a - i\n\t\tif b-i-1 < 0 {\n\t\t\tfmt.Println(\"Valera\")\n\t\t\treturn\n\t\t}\n\t\tb = b - i - 1\n\t\ti += 2\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "0bdc9a8a16cde83aaabf738b158f0ee9", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nconst debug = true\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tin := gsli(reader)\n\ta := in[0]\n\tb := in[1]\n\n\ti := 1\n\n\tfor true {\n\t\ta -= i\n\t\tif a < 0 {\n\t\t\tfmt.Println(\"Vladik\")\n\t\t\treturn\n\t\t}\n\t\ti++\n\t\tb -= i\n\t\tif b < 0 {\n\t\t\tfmt.Println(\"Valera\")\n\t\t\treturn\n\t\t}\n\t\ti++\n\t}\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// String helpers\n\n// Is Lowercase\n// Given some string[i], return whether it is lower case or not.\n\nfunc isl(b byte) bool {\n\tvar r rune\n\tr = rune(b)\n\treturn unicode.IsLower(r)\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\n// Max Int\n// Returns the max of two ints\n\nfunc maxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// Distance formule\n// Calculates the distance to the origin\n\nfunc dist(x, y float64) float64 {\n\treturn math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))\n}\n\n// Output helpers\n\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\n\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\n// Debug helpers\n\n// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss\n\nfunc dbg(s string, a ...interface{}) {\n\tif debug {\n\t\tfmt.Printf(s, a...)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "3072e7c86d26898aa338ffa3bc33ab2b", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n var vladik, valera int\n fmt.Scanf(\"%d %d\", &vladik, &valera)\n\n var i int = 1\n for vladik >= 0 && valera >= 0 {\n if i % 2 == 1 {\n vladik -= i\n } else {\n valera -= i\n }\n i += 1\n }\n\n if vladik < 0 {\n fmt.Println(\"Vladik\")\n } else {\n fmt.Println(\"Valera\")\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "72ab14f79ef57f1859fe7b1aa085eda8", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b, c, res int64\n\tfmt.Scan(&n, &a, &b, &c)\n\tr := n % 4\n\tswitch r {\n\tcase 0:\n\t\tres = 0\n\tcase 1:\n\t\tres = min(3*a, b+a, c)\n\tcase 2:\n\t\tres = min(2*a, b, 2*c, a+b+c)\n\tcase 3:\n\t\tres = min(a, c+b, 3*c)\n\t}\n\tfmt.Println(res)\n}\n\nfunc min(a ...int64) int64 {\n\tmin := a[0]\n\tfor _, n := range a {\n\t\tif n < min {\n\t\t\tmin = n\n\t\t}\n\t}\n\treturn min\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "c71142ceb153316cc7509ffffccdda6a", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, a, b, c int64\n\tif _, err := fmt.Scanf(\"%d %d %d %d\\n\", &n, &a, &b, &c); err != nil {\n\t\treturn\n\t}\n\n\tneed := 4 - n%4\n\tif need == 1 {\n\t\tfmt.Println(min(min(a, b+c), c*3))\n\t} else if need == 2 {\n\t\tfmt.Println(min(min(a*2, b), c*2))\n\t} else if need == 3 {\n\t\tfmt.Println(min(min(a*3, a+b), c))\n\t} else if need == 4 {\n\t\tfmt.Println(0)\n\t}\n}\n\nfunc min(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "74f094b60f8f015e990a9211fff21622", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n n, a, b, c := readInt64(), readInt64(), readInt64(), readInt64()\n from, to := int64(0), int64(10)\n ans := int64(1<<50)\n for i1 := from; i1 < to; i1++ {\n for i2 := from; i2 < to; i2++ {\n for i3 := from; i3 < to; i3++ {\n k := i1 + 2*i2 + 3*i3\n if (n+k) % 4 == 0 {\n cost := i1*a + i2*b + i3*c\n if cost < ans {\n ans = cost\n }\n }\n }\n }\n }\n fmt.Println(ans)\n}\n\n// Helpers\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\n// Sort\n\ntype Ints64 []int64\n\nfunc (a Ints64) Len() int { return len(a) }\nfunc (a Ints64) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a Ints64) Less(i, j int) bool { return a[i] < a[j] }\n\n/* Sort tempalte\nfunc (a ) Len() int { return len(a) }\nfunc (a ) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ) Less(i, j int) bool { return }\n*/\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "e0cdb6bb653adc022f078e1db681035e", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"sort\"\n \"fmt\"\n)\n\nfunc main() {\n a := make([]int, 10)\n for i := 0; i < 6; i++ {\n var x int\n fmt.Scan(&x)\n a[x]++\n }\n sort.Ints(a)\n if a[len(a)-1] == 6 {\n fmt.Println(\"Elephant\")\n } else if a[len(a)-1] == 5 {\n fmt.Println(\"Bear\")\n } else if a[len(a)-1] == 4 {\n if a[len(a)-2] == 2 {\n fmt.Println(\"Elephant\")\n } else {\n fmt.Println(\"Bear\")\n }\n } else {\n fmt.Println(\"Alien\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "c0e1d79d815b9d2a95fb2defc3028ed3", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar sticks [10]int\n\nfunc main() {\n\tv := 0\n\tfor i := 0; i < 6; i++ {\n\t\tfmt.Scan(&v)\n\t\tsticks[v] += 1\n\t}\n\n\tlegOk := false\n\telephant := false\n\tfor i := 0; i < len(sticks); i++ {\n\t\tif sticks[i] >= 4 {\n\t\t\tlegOk = true\n\t\t\tif sticks[i] == 6 {\n\t\t\t\telephant = true\n\t\t\t}\n\t\t} else if sticks[i] == 2 {\n\t\t\telephant = true\n\t\t}\n\t}\n\n\tif !legOk {\n\t\tfmt.Println(\"Alien\")\n\t} else if elephant {\n\t\tfmt.Println(\"Elephant\")\n\t} else {\n\t\tfmt.Println(\"Bear\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "3c4c2636b92e15fdd9f8ff623c667d4e", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var length[6] int\n var counts[10] int\n for i := 0; i < 6; i++ {\n fmt.Scan(&length[i])\n counts[length[i]]++\n }\n\n leg := -1\n for i := 0; i < 10; i++ {\n if counts[i] >= 4 {\n leg = i\n }\n }\n if leg == -1 {\n fmt.Println(\"Alien\")\n } else {\n a := -1\n b := -1\n if (counts[leg] == 5) {\n a = leg\n } else if (counts[leg] == 6) {\n a = leg\n b = leg\n }\n\n for i := 0; i < 10; i++ {\n if counts[i] > 0 && i != leg {\n if a == -1 {\n a = i\n } else if b == -1 {\n b = i\n }\n }\n }\n\n if b == -1 {\n b = a\n }\n\n if a == b {\n fmt.Println(\"Elephant\")\n } else {\n fmt.Println(\"Bear\")\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e0ef2eed07f9ddf141de8a967f5612cb", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar a int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &a)\n\tfor sumdigit(a)%4 != 0 {\n\t\ta++\n\t}\n\tfmt.Println(a)\n}\nfunc sumdigit(a int) int {\n\tsum := 0\n\tfor a > 0 {\n\t\tsum += a % 10\n\t\ta /= 10\n\t}\n\treturn sum\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0e1d524d17d66ae79e06fb8173fa043e", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc isInteresting(n int) bool {\n\ts := 0\n\tfor n > 0 {\n\t\ts += n % 10\n\t\tn /= 10\n\t}\n\tif s%4 == 0 {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfor n > 0 {\n\t\tif isInteresting(n) == true {\n\t\t\tfmt.Printf(\"%d\\n\", n)\n\t\t\tbreak\n\t\t}\n\t\tn++\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cce18245e674e977923daf9034e48012", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc sumc(a int) int {\n\tvar astr = strconv.Itoa(a)\n\tvar nums = strings.Split(astr, \"\")\n\tvar res = 0\n\tfor i := 0; i < len(nums); i++ {\n\t\tvar d, _ = strconv.Atoi(nums[i])\n\t\tres = res + d\n\t}\n\treturn res\n}\n\nfunc main() {\n\t//var read, _ = os.Open(\"dat.txt\")\n\t//var write, _ = os.Create(\"result.txt\")\n\tvar read = bufio.NewReader(os.Stdin)\n\tvar write = bufio.NewWriter(os.Stdout)\n\tvar n int\n\tfmt.Fscan(read, &n)\n\tfor i := 0; i < 1000; i++ {\n\t\tvar r = n + i\n\t\tvar res = sumc(r)\n\t\tif res%4 == 0 {\n\t\t\tfmt.Fprint(write, r)\n\t\t\tbreak\n\t\t}\n\t}\n\n\twrite.Flush()\n\t//read.Close()\n\t//write.Close()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "308b8505bd4467f67ad3be412c75094c", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc solve(s string) int {\n\tvar current byte = 'a'\n\tsum := 0\n\tfor i := range s {\n\t\td := int(math.Abs(float64(current) - float64(s[i])))\n\t\tif d < 13 {\n\t\t\tsum += d\n\t\t} else {\n\t\t\tsum += 26 - d\n\t\t}\n\t\tcurrent = s[i]\n\t}\n\n\treturn sum\n}\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\n\tvar s string\n\n\tfmt.Fscanf(r, \"%s\\n\", &s)\n\n\tfmt.Fprintf(os.Stdout, \"%d\\n\", solve(s))\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "8f9cf873dd5db2df48d9c04dbf694d25", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc dist(c int, d int) int {\n\tx := abs(c - d)\n\ty := 26 - x\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar s string\n\tfmt.Fscanf(bufin, \"%s\\n\", &s)\n\n\tcur := 0\n\tres := 0\n\tn := len(s)\n\n\tfor i := 0; i < n; i++ {\n\t\tc := int(s[i] - 'a')\n\t\td := dist(cur, c)\n\t\tres += d\n\t\tcur = c\n\t}\n\n\tfmt.Fprintf(bufout, \"%d\\n\", res)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "ce7036dc0aaa59e112cd8b4a05a52325", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n \"fmt\"\n \"math\"\n)\n\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\n\nfunc ReadInt() int {\n scanner.Scan()\n val, _ := strconv.Atoi(scanner.Text())\n return val\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\n\nfunc Min(a, b int) int {\n if a < b {\n return a\n } else {\n return b\n }\n}\n\n\nfunc main() {\n scanner.Split(bufio.ScanWords)\n\n s := ReadString()\n res := 0\n lastChar := 'a'\n\n for i := 0; i < len(s); i++ {\n if int(s[i]) == int(lastChar) {\n continue\n }\n\n ans := math.MaxInt32\n\n if int(s[i]) > int(lastChar) {\n ans = Min(int(s[i]) - int(lastChar), ans)\n ans = Min(int('z') - int(s[i]) + 1 + int(lastChar) - int('a'), ans)\n } else {\n ans = Min(int(lastChar) - int(s[i]), ans)\n ans = Min(int('z') - int(lastChar) + 1 + int(s[i]) - int('a'), ans)\n }\n\n res += ans\n lastChar = rune(s[i])\n }\n\n fmt.Print(res)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "012b73369b6c166d0df28aba507af817", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 437A\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar (\n\t\ts string\n\t\tk int\n\t\ta [4]int\n\t\tb1, b2 bool\n\t)\n\tout := bufio.NewWriter(os.Stdout)\n\ttmp := 0\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Scan(&s)\n\t\ta[i] = len(s) - 2\n\t}\n\tfor i := 0; i < 4; i++ {\n\t\tb1 = true\n\t\tb2 = true\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tif j != i {\n\t\t\t\tif 2*a[i] > a[j] {\n\t\t\t\t\tb1 = false\n\t\t\t\t}\n\t\t\t\tif a[i] < 2*a[j] {\n\t\t\t\t\tb2 = false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif b1 || b2 {\n\t\t\ttmp++\n\t\t\tk = i\n\t\t}\n\t}\n\tif tmp == 1 {\n\t\tm := 65 + k\n\t\tfmt.Fprintln(out, string(m))\n\t} else {\n\t\tfmt.Fprintln(out, string('C'))\n\t}\n\tout.Flush()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5618141c294943e4ad838c6fd1ab3150", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\"fmt\";\"sort\")\n\ntype set map[int]bool\n\nfunc main(){\n\ta := make([]string, 4)\n\tfor i := 0; i < 4; i++{\n\t\tscan(&a[i])\n\t}\n\tsort.Slice(a, func (i, j int)bool{return len(a[i]) < len(a[j])})\n\tif (len(a[0]) - 2) * 2 <= len(a[1]) - 2 && (len(a[2]) - 2) * 2 <= len(a[3]) - 2{\n\t\tsout(\"C\")\n\t}else if (len(a[0]) - 2) * 2 <= len(a[1]) - 2{\n\t\tsout(string(a[0][0]))\n\t}else if (len(a[2]) - 2) * 2 <= len(a[3]) - 2{\n\t\tsout(string(a[3][0]))\n\t}else{\n\t\tsout(\"C\")\n\t}\n}\n\nfunc scan(in ... interface{}){\n\tfor _,k := range in{\n\t\tfmt.Scan(k)\n\t}\n}\n\nfunc sout(obj ... interface{}){\n\tfor _, k := range obj{\n\t\tfmt.Print(k)\n\t}\n\t//fmt.Println()\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "7b591fc3a236a1d2e210f5b1ec03b8c3", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tlens := make([]int, 4, 4)\n\tchoice := \"\"\n\tmin := 0\n\tmax := 0\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Scan(&choice)\n\t\tlens[i] = len(choice) - 2\n\t\tif lens[min] > lens[i] {\n\t\t\tmin = i\n\t\t}\n\t\tif lens[max] < lens[i] {\n\t\t\tmax = i\n\t\t}\n\t}\n\n\t//fmt.Println(min, max)\n\n\tans := 2\n\tcnt := 0\n\tfor i := 0; i < 4; i++ {\n\t\tif lens[i] >= 2*lens[min] {\n\t\t\tcnt++\n\t\t}\n\t}\n\t//fmt.Println(cnt)\n\tif cnt == 3 {\n\t\tans = min\n\t}\n\n\tcnt = 0\n\tfor i := 0; i < 4; i++ {\n\t\tif lens[i] <= lens[max]/2 {\n\t\t\tcnt++\n\t\t}\n\t}\n\n\tif cnt == 3 {\n\t\tif ans == 2 {\n\t\t\tans = max\n\t\t} else {\n\t\t\tans = 2\n\t\t}\n\t}\n\n\tfmt.Println(string(ans + 'A'))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b30f5a0004992c8ec0842bbfb0c49f43", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\nfunc modpow(x, n, mod int) int {\r\n\tif n == 0 {\r\n\t\treturn 1 % mod\r\n\t}\r\n\tu := modpow(x, n/2, mod)\r\n\tu = (u * u) % mod\r\n\tif n&1 == 1 {\r\n\t\tu = (x * u) % mod\r\n\t}\r\n\r\n\treturn u\r\n}\r\n\r\nfunc Min(a, b int) int {\r\n\tif a < b {\r\n\t\treturn a\r\n\t}\r\n\treturn b\r\n}\r\n\r\nfunc Solve(reader io.Reader, writer io.Writer) {\r\n\tmod := 1000000007\r\n\r\n\tvar n, k int\r\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &k)\r\n\tcomb := 1\r\n\tans := 1\r\n\tfor i := 1; i <= Min(n, k); i++ {\r\n\t\tcomb = (comb * (n - i + 1)) % mod\r\n\t\tcomb = (comb * modpow(i, mod-2, mod)) % mod\r\n\t\tans = (ans + comb) % mod\r\n\r\n\t}\r\n\tfmt.Fprintln(writer, ans)\r\n}\r\n\r\nfunc main() {\r\n\t// f, err := os.Open(\"data.txt\")\r\n\t// if err != nil {\r\n\t// \tos.Exit(1)\r\n\t// }\r\n\t// defer f.Close()\r\n\r\n\t// reader := bufio.NewReader(f)\r\n\treader := bufio.NewReader(os.Stdin)\r\n\twriter := bufio.NewWriter(os.Stdout)\r\n\tSolve(reader, writer)\r\n\twriter.Flush()\r\n\r\n}\r\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "9a24bcc4f2d43a2819218ed37916d55c", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar P107 int = 1000000007\n\nfunc Max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc Min(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Abs(a int) int {\n\treturn Max(a, -a)\n}\n\nfunc Gcd(a, b int) int {\n\tmin := Min(a, b)\n\tmax := Max(a, b)\n\tif min == 0 {\n\t\treturn max\n\t}\n\n\tfor max%min != 0 {\n\t\tmin, max = max%min, min\n\t}\n\n\treturn min\n}\n\nfunc Lcm(a, b int) int {\n\treturn a / Gcd(a, b) * b\n}\n\nvar facs []int = make([]int, 100010)\n\nfunc FacP(n, p int) int {\n\tif facs[n] != 0 {\n\t\treturn facs[n]\n\t}\n\n\tresult := 1\n\tfacs[0] = 1\n\tfor i := 1; i <= n; i++ {\n\t\tresult = (result * i) % p\n\t\tfacs[i] = result\n\t}\n\n\treturn result\n}\n\nfunc ExpP(a, x, p int) int {\n\tif x == 0 {\n\t\treturn 1\n\t}\n\n\tif x%2 == 0 {\n\t\thalf := ExpP(a, x/2, p)\n\t\treturn (half * half) % p\n\t} else {\n\t\treturn ((a % p) * ExpP(a, x-1, p)) % p\n\t}\n}\n\nfunc CombP(n, c, p int) int {\n\treturn (FacP(n, p) * ((ExpP(FacP(n-c, p), p-2, p) * ExpP(FacP(c, p), p-2, p)) % p)) % p\n}\n\nfunc Solve(reader *bufio.Reader) {\n\tscanner := bufio.NewScanner(reader)\n\tscanner.Split(bufio.ScanWords)\n\twr := bufio.NewWriter(os.Stdout)\n\tdefer wr.Flush()\n\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tk, _ := strconv.Atoi(scanner.Text())\n\tk = Min(k, n)\n\n\tresult := 0\n\tfor i := 0; i <= k; i++ {\n\t\tresult = (result + CombP(n, i, P107)) % P107\n\t}\n\n\twr.WriteString(strconv.Itoa(result) + \"\\n\")\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tSolve(reader)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "4520fa0aa61b03730010b0571160591f", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nconst modulo int64 = 1000000000 + 7\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tconst all_ways int64 = 3 * 3 * 3\n\tconst sei_ways int64 = 7\n\n\ta := power_modulo(all_ways, n)\n\tb := power_modulo(sei_ways, n)\n\tif a < b {\n\t\ta += modulo\n\t}\n\n\tfmt.Println(a - b)\n}\n\n// Calculate w to the power of n, in modulo of 1000000007\nfunc power_modulo(w int64, n int) int64 {\n\n\trs := make([]int64, n+1)\n\trs[1] = w % modulo\n\n\tfor i := 2; i <= n; i++ {\n\t\tp := rs[i-1] * w\n\t\tif p >= modulo {\n\t\t\tp %= modulo\n\t\t}\n\n\t\trs[i] = p\n\t}\n\n\treturn rs[n]\n}\n", "lang_cluster": "Go", "tags": ["combinatorics"], "code_uid": "3fbb923c2f6ff4c16698d2460ed0f14c", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF584B(_r io.Reader, _w io.Writer) {\n\tconst mod int64 = 1e9 + 7\n\tpow := func(x int64, n int) int64 {\n\t\tres := int64(1)\n\t\tfor ; n > 0; n >>= 1 {\n\t\t\tif n&1 == 1 {\n\t\t\t\tres = res * x % mod\n\t\t\t}\n\t\t\tx = x * x % mod\n\t\t}\n\t\treturn res\n\t}\n\tvar n int\n\tFscan(_r, &n)\n\tFprint(_w, (pow(27, n)-pow(7, n)+mod)%mod)\n}\n\nfunc main() { CF584B(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["combinatorics"], "code_uid": "bdb52fa584228342d6a6358c24037522", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math/big\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int64\n\tfor I(&n, \"\\n\") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int64) {\n\tans := big.NewInt(n)\n\ta := big.NewInt(27)\n\tb := big.NewInt(7)\n\tc := big.NewInt(1e9 + 7)\n\n\ta.Exp(a, ans, nil)\n\tb.Exp(b, ans, nil)\n\tans.Sub(a, b)\n\tans.Mod(ans, c)\n\tO(ans, \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["combinatorics"], "code_uid": "4b537b3aa8e8db6dd5733c6d8bb58186", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main;import\"fmt\";func main(){var z string;fmt.Scan(&z);a:=make(map[rune]int);for _,i:=range z{a[i]=1};if len(a)%2==0{fmt.Print(\"CHAT WITH HER!\")}else{fmt.Print(\"IGNORE HIM!\")}}", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "add5257311df79d83d44d6783914e438", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"unicode/utf8\"\n)\n\nfunc odd(str string)(int){\n\tn := utf8.RuneCountInString(str)\n\tfor j, i := range(str){\n\t\tif strings.Count(str[0:j], string(i)) > 0{\n\t\t\tn -= 1\n\t\t}\n\t}\n\treturn n % 2\n}\n\nfunc main(){\n\tdct := map[int]string{\n\t\t0: \"CHAT WITH HER!\",\n\t\t1: \"IGNORE HIM!\",\n\t}\n\tvar name string\n\tvar isOdd int\n\tfmt.Scan(&name)\n\tisOdd = odd(name)\n\tfmt.Println(dct[isOdd])\n}", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "3b51845e2d9cd60c52d97a4e12b38ed1", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n \"bufio\"\n \"os\"\n)\n\nfunc main() {\n st:= \"\"\n\t\n\tin := bufio.NewReader(os.Stdin)\n\n fmt.Fscan(in, &st)\n stnew :=\"\"\n \n \n //st = strings.Replace(st,\"m\",\"\",-1)\n //st = strings.Replace(st,string(st[0]),\"\",-1)\n for len(st)>0{\n stnew += string(st[0])\n st = strings.Replace(st,string(st[0]),\"\",-1)\n }\n //stnew = st\n if(len(stnew)%2)==0{\n fmt.Println(\"CHAT WITH HER!\")\n }else{\n fmt.Println(\"IGNORE HIM!\")\n }\n \n\n\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "931638c634134fa4a5a95ac272c62d81", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar input string\n\tvar len int\n\n\tfmt.Scanln(&len)\n\tfmt.Scanln(&input)\n\n\tvar acc int\n\tpiv := 1\n\n\tfor acc < len {\n\t\tacc += piv\n\n\t\tfmt.Printf(\"%s\", input[acc-1:acc])\n\n\t\tpiv++\n\t}\n\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5cb615e916020b50fa877b15888ff492", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tvar n int\n\tfmt.Scanf(\"%d\\n%s\", &n, &s)\n\tfor i, j := 0, 1; i < n; i, j = i+j, j+1 {\n\t\tfmt.Printf(\"%c\", []rune(s)[i])\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "c2b7485e9318450677d2a891a5cbc886", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc decode(in string) string {\n\tvar i int\n\n\tfor i < len(in) {\n\t\tin = in[:i+1] + in[i+i+1:]\n\t\ti++\n\t}\n\n\treturn in\n}\n\nfunc main() {\n\tvar lenin int\n\tvar text string\n\tfmt.Scanf(\"%d\\n\", &lenin)\n\tfmt.Scanf(\"%s\\n\", &text)\n\n\tfmt.Print(decode(text))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "71d7778091264b6fc2a2015336cdfd7d", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc needs(sum, xor, carry, digit int64) int64 {\n\tif digit < 1 {\n\t\treturn 1 - carry\n\t}\n\n\tif (xor & digit) != 0 {\n\t\tif (sum & digit) != 0 {\n\t\t\treturn (1 - carry) * 2 * needs(sum, xor, 0, digit>>1)\n\t\t}\n\t\treturn carry * 2 * needs(sum, xor, 1, digit>>1)\n\t}\n\n\tif (sum & digit) != 0 {\n\t\treturn needs(sum, xor, 1, digit>>1)\n\t}\n\treturn needs(sum, xor, 0, digit>>1)\n}\n\nfunc main() {\n\tvar sum, xor int64\n\tfmt.Scan(&sum, &xor)\n\n\tif sum != xor {\n\t\tfmt.Println(needs(sum, xor, 0, 1<<62))\n\t} else {\n\t\tfmt.Println(needs(sum, xor, 0, 1<<62) - 2)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "dp"], "code_uid": "ecc1cc4d3c56e9bb0ad0541b64041a6a", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(s, x int64) int64 {\n\tif (s-x)%2 == 1 {\n\t\treturn 0\n\t}\n\tif ((s-x)/2)&x != 0 {\n\t\treturn 0\n\t}\n\tif s < x {\n\t\treturn 0\n\t}\n\tres := int64(1)\n\tfor y := x; y > 0; y &= (y - 1) {\n\t\tres *= 2\n\t}\n\tif s-x == 0 {\n\t\tres -= 2\n\t}\n\treturn res\n}\n\nfunc main() {\n\tvar s, x int64\n\tfmt.Scan(&s, &x)\n\tfmt.Println(solve(s, x))\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "constructive algorithms", "implementation"], "code_uid": "66fade8a2240151174436ecc4373be77", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar (\n\tin = bufio.NewReader(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\nconst BITS = 50\n\nvar s, x int64\n\nfunc main() {\n\tdefer out.Flush()\n\tfmt.Fscan(in, &s, &x)\n\tans := solve(0, 0)\n\tif s == x {\n\t\tans -= 2\n\t}\n\tfmt.Fprintln(out, ans)\n}\n\nfunc solve(i, carry int) int64 {\n\tif i == BITS {\n\t\tif carry == 0 {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tkey := Key{i, carry}\n\tif result, ok := cache[key]; ok {\n\t\treturn result\n\t}\n\tresult := int64(0)\n\tfor a := 0; a <= 1; a++ {\n\t\tb := a ^ get(i, x)\n\t\tsum := a + b + carry\n\t\tif sum&1 == get(i, s) {\n\t\t\tresult += solve(i+1, sum>>1)\n\t\t}\n\t}\n\tcache[key] = result\n\treturn result\n}\n\nvar cache = map[Key]int64{}\n\ntype Key struct {\n\ti, carry int\n}\n\nfunc get(i int, x int64) int {\n\treturn int((x >> uint(i)) & 1)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp"], "code_uid": "da06552180a4181bb0ece00adb873fff", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,t int\n var a [55]int\n var s string\n fmt.Scan(&n,&t,&s)\n for i, v := range s { a[i] = int(v) }\n for ; t > 0; t-- {\n for i := 1; i < n; i++ {\n if (a[i] == 'G') && (a[i-1] == 'B') {\n a[i], a[i-1] = a[i-1], a[i]\n i++\n }\n }\n }\n for i := 0; i < n; i++ { fmt.Print(string(a[i])) }\n fmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "e1ecfc342d6ccff86588b1d43fd92c8b", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, t int\n\tvar s string\n\tfmt.Scanf(\"%d %d\\n\", &n, &t)\n\tfmt.Scanf(\"%v\\n\", &s)\n\tfmt.Println(solve(s, t))\n}\n\nfunc solve(s string, n int) string {\n\tbs := []byte(s)\n\tfor n > 0 {\n\t\ti := 0\n\n\t\tfor i < len(bs)-1 {\n\t\t\tif bs[i] == 'B' && bs[i+1] == 'G' {\n\t\t\t\tbs[i], bs[i+1] = bs[i+1], bs[i]\n\t\t\t\ti += 2\n\t\t\t} else {\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t\tn--\n\t}\n\n\treturn string(bs)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "8fadb94d09ae9518a432d7a466fcec3f", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, t int\n\tvar str string\n\tfmt.Scan(&n, &t)\n\tfmt.Scan(&str)\n\t\n //run it for t secs or t times.\n\tvar chars = []byte(str)\n\n\tfor i := 0; i < t; i++ {\n\t\tfor j := 0; j < n; {\n\t\t\tif j+1 < n && chars[j] == 'B' && chars[j+1] == 'G' {\n\t\t\t\tchars[j] = 'G'\n\t\t\t\tchars[j+1] = 'B'\n\t\t\t\tj = j + 2\n\t\t\t} else {\n\t\t\t\tj = j + 1\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(os.Stdout, \"%s\", string(chars))\n\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "a2a01131176d44e8d237aca2057c3a97", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar n, t int\nvar s string\n\nfunc main() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader := bufio.NewReaderSize(stdin, 1<<20)\n\tfmt.Fscanf(reader, \"%d%d\\n%s\\n\", &n, &t, &s)\n\tsb := []byte(s)\n\tfor ; t != 0; t-- {\n\t\tfor i := 0; i < n-1; i++ {\n\t\t\tif sb[i] == 'B' && sb[i+1] == 'G' {\n\t\t\t\tsb[i] = 'G'\n\t\t\t\tsb[i+1] = 'B'\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(string(sb))\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "b5d1efe08fe6d703ebbbef9567a51f0c", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n// B. Queue at the School\n// time limit per test\n// 2 seconds\n// memory limit per test\n// 256 megabytes\n// input\n// standard input\n// output\n// standard output\n\n// During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward each second.\n\n// Let's describe the process more precisely. Let's say that the positions in the queue are sequentially numbered by integers from 1 to n, at that the person in the position number 1 is served first. Then, if at time x a boy stands on the i-th position and a girl stands on the (i + 1)-th position, then at time x + 1 the i-th position will have a girl and the (i + 1)-th position will have a boy. The time is given in seconds.\n\n// You've got the initial position of the children, at the initial moment of time. Determine the way the queue is going to look after t seconds.\n// Input\n\n// The first line contains two integers n and t (1 ≤ n, t ≤ 50), which represent the number of children in the queue and the time after which the queue will transform into the arrangement you need to find.\n\n// The next line contains string s, which represents the schoolchildren's initial arrangement. If the i-th position in the queue contains a boy, then the i-th character of string s equals \"B\", otherwise the i-th character equals \"G\".\n// Output\n\n// Print string a, which describes the arrangement after t seconds. If the i-th position has a boy after the needed time, then the i-th character a must equal \"B\", otherwise it must equal \"G\"\n\nfunc main() {\n\tvar n, t int\n\tvar queue string\n\tfmt.Scan(&n, &t, &queue)\n\n\tcurrentState := []byte(queue)\n\tnextState := []byte(queue)\n\n\tfor i := 0; i < t; i++ {\n\t\tfor i := 0; i < len(currentState)-1; {\n\t\t\tif currentState[i] == 'B' && currentState[i+1] == 'G' {\n\t\t\t\tnextState[i] = 'G'\n\t\t\t\tnextState[i+1] = 'B'\n\t\t\t\ti += 2\n\t\t\t} else {\n\t\t\t\tnextState[i] = currentState[i]\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\n\t\tcurrentState = nextState\n\t\tnextState = currentState\n\t}\n\n\tfmt.Print(string(currentState))\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "23443b230dbbfbbf2dc76275f0244e72", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport(\n \"fmt\"\n)\n\ntype u32 uint32\n\nfunc main(){\n var(\n n,t,i u32\n s string\n )\n\n fmt.Scan(&n,&t)\n fmt.Scan(&s)\n b := make([]byte,len(s))\n for i=0;i0{\n for i=1;ib[i-1]{\n b[i],b[i-1]=b[i-1],b[i]\n i++\n }\n }\n t--\n }\n fmt.Println(string(b))\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "b9ae5cdc454285cbbd5638c72e3cf4c2", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, t int\n\tfmt.Scan(&n, &t)\n\tvar s string\n\tfmt.Scan(&s)\n\ta := []byte(s)\n\tfor i := 0; i < t; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif a[j] == 'B' && j < n-1 {\n\t\t\t\tif a[j+1] == 'G' {\n\t\t\t\t\ta[j+1] = 'B'\n\t\t\t\t\ta[j] = 'G'\n\t\t\t\t\tj++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(string(a))\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "25a544b4b924f578e64edf308a723b65", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar t int\n\tvar s string\n\tfmt.Scanf(\"%d%d\\n%s\\n\", &n, &t, &s)\n\tout := []byte(s)\n\tfor i := 0; i < t; i++ {\n\t\tfor j := 0; j < n-1; j++ {\n\t\t\tif out[j] == 66 && out[j+1] == 71 {\n\t\t\t\tout[j] = 71\n\t\t\t\tout[j+1] = 66\n\t\t\t\tj++\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(string(out))\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "63257d1ce2d064713832269810d9c428", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/* https://codeforces.com/problemset/problem/266/B\nB. Queue at the School\ntime limit per test2 seconds\nmemory limit per test256 megabytes\ninputstandard input\noutputstandard output\nDuring the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward each second.\n\nLet's describe the process more precisely. Let's say that the positions in the queue are sequentially numbered by integers from 1 to n, at that the person in the position number 1 is served first. Then, if at time x a boy stands on the i-th position and a girl stands on the (i + 1)-th position, then at time x + 1 the i-th position will have a girl and the (i + 1)-th position will have a boy. The time is given in seconds.\n\nYou've got the initial position of the children, at the initial moment of time. Determine the way the queue is going to look after t seconds.\n\nInput\nThe first line contains two integers n and t (1 ≤ n, t ≤ 50), which represent the number of children in the queue and the time after which the queue will transform into the arrangement you need to find.\n\nThe next line contains string s, which represents the schoolchildren's initial arrangement. If the i-th position in the queue contains a boy, then the i-th character of string s equals \"B\", otherwise the i-th character equals \"G\".\n\nOutput\nPrint string a, which describes the arrangement after t seconds. If the i-th position has a boy after the needed time, then the i-th character a must equal \"B\", otherwise it must equal \"G\".\n\nExamples\ninputCopy\n5 1\nBGGBG\noutputCopy\nGBGGB\ninputCopy\n5 2\nBGGBG\noutputCopy\nGGBGB\ninputCopy\n4 1\nGGGB\noutputCopy\nGGGB\n*/\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, t int\n\tfmt.Scanln(&n, &t)\n\n\tvar s string\n\tfmt.Scanln(&s)\n\n\tqueue := make([]rune, n)\n\tfor j, position := range s {\n\t\tqueue[j] = position\n\t}\n\n\tfor t > 0 {\n\t\tfor i := 1; i < n; i++ {\n\t\t\tif queue[i] == 'G' && queue[i-1] == 'B' {\n\t\t\t\tqueue[i] = 66\n\t\t\t\tqueue[i-1] = 71\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t\tt--\n\t}\n\tvar queue_string = string(queue)\n\n\tfmt.Println(queue_string)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "dadb59f6b44618d46fa765d8a60dad27", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, t int\n\tvar s string\n\tfmt.Scan(&n, &t)\n\tfmt.Scan(&s)\n\tvar result string\n\tvar buffer bytes.Buffer\n\tresult = s\n\tfor i := 0; i < t; i++ {\n\t\tfor j := 0; j < len(result)-1; j++ {\n\t\t\tif result[j] == 'B' && result[j+1] == 'G' {\n\t\t\t\tbuffer.WriteByte(result[j+1])\n\t\t\t\tbuffer.WriteByte(result[j])\n\t\t\t\tj++\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbuffer.WriteByte(result[j])\n\t\t}\n\t\tif len(buffer.String()) != len(s) {\n\t\t\tbuffer.WriteByte(result[len(result)-1])\n\t\t}\n\t\tresult = buffer.String()\n\t\tbuffer.Reset()\n\t}\n\tfmt.Print(result)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "e4bc8518b3472ac7fffd07358e5f4ded", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tn, t int\n\t\ts string\n\t)\n\tfmt.Scan(&n, &t, &s)\n\tb := []byte(s)\n\tfor t > 0 {\n\t\tfor i := 1; i < n; i++ {\n\t\t\tif b[i-1] == 'B' && b[i] == 'G' {\n\t\t\t\tb[i], b[i-1] = 'B', 'G'\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t\tt--\n\t}\n\tfmt.Println(string(b))\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "c6f2d6872ca5b74ddf8347a13ccb98b6", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc fastGetInt(b []byte) int {\n\tneg := false\n\tif b[0] == '-' {\n\t\tneg = true\n\t\tb = b[1:]\n\t}\n\tn := 0\n\tfor _, v := range b {\n\t\tn = n*10 + int(v-'0')\n\t}\n\tif neg {\n\t\treturn -n\n\t}\n\treturn n\n}\n\nfunc fastGetCharFromByte(b byte) string {\n\tt := \"\"\n\tif b >= 'A' && b <= 'Z' {\n\t\tt = string('Z' - ('Z' - b))\n\t}\n\tif b >= 'a' && b <= 'z' {\n\t\tt = string('z' - ('z' - b))\n\t}\n\n\treturn t\n}\n\n//========== Implement Algorithm =======================\nfunc solution(lineStr string, seconds int) string {\n\t// make a slice of chars\n\tlineSlice := strings.Split(lineStr, \"\")\n\t//fmt.Println(lineSlice)\n\tnumSwaps := 0\n\n\tfor x := 0; x < seconds; x++ {\n\t\tnumSwaps = 0\n\t\tprev := lineSlice[0]\n\t\tfor i := 1; i < len(lineSlice); i++ {\n\t\t\tcurr := lineSlice[i]\n\t\t\tif prev == \"B\" && curr == \"G\" {\n\t\t\t\tnumSwaps++\n\t\t\t\tlineSlice[i] = \"B\"\n\t\t\t\tlineSlice[i-1] = \"G\"\n\n\t\t\t}\n\n\t\t\t//fmt.Println(\"prev:\", prev, \"curr:\", curr)\n\t\t\tprev = curr\n\t\t}\n\t\t//fmt.Println(\"line:\", lineSlice)\n\t\tif numSwaps == 0 {\n\t\t\treturn strings.Join(lineSlice, \"\")\n\t\t}\n\t}\n\t//fmt.Println(lineSlice)\n\treturn strings.Join(lineSlice, \"\")\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\t//================== Variables used ====================\n\tvar lineStr, ret string\n\tvar seconds int\n\t//======================================================\n\n\t//============== Get return value from File ============\n\tif len(os.Args) >= 2 {\n\n\t\tfile, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed opening file: %s\", err)\n\t\t}\n\t\tscanner = bufio.NewScanner(file)\n\t\tdefer file.Close()\n\n\t}\n\tscanner.Split(bufio.ScanWords)\n\t//======================= I/O ==========================\n\tscanner.Scan()\n\tscanner.Scan()\n\tseconds = fastGetInt(scanner.Bytes())\n\tscanner.Scan()\n\tlineStr = scanner.Text()\n\t//======================================================\n\tret = solution(lineStr, seconds)\n\t//==================== OUTPUT ==========================\n\tfmt.Println(ret)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "3816d83980057b921a4138fb5b090caf", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n//bg менять на gb\nfunc checking(s string) string {\n\tflag := strings.ReplaceAll(s, \"BG\", \"GB\")\n\treturn flag\n}\n \nfunc main() {\n\tvar x, y int\n\tvar itog string\n fmt.Scan(&x, &y)\n\tfmt.Scan(&itog)\n \n\tfor i := 0; i < y; i++ {\n\t\titog = checking(itog)\n\t}\n\tfmt.Println(itog)\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "cf2a5c4a1594225d2ab8c7b5c27d43c1", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n, t int\n\tvar queue string\n\tfmt.Fscan(os.Stdin, &n, &t, &queue)\n\tvar replacer = strings.NewReplacer(\"BG\", \"GB\")\n\tfor i := 0; i < t; i++ {\n\t\tqueue = replacer.Replace(queue)\n\t}\n\tfmt.Println(queue)\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "4cc05e38cf48ed8bd4a80fe581d48b3d", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, t int\n\tfmt.Scan(&n, &t)\n\n\tvar line string\n\tfmt.Scan(&line)\n\n\tfor i := 0; i < t; i++ {\n\t\tfor j := n - 1; j >= 1; j-- {\n\t\t\tif line[j-1] == 'B' && line[j] == 'G' {\n\t\t\t\tline = line[:j-1] + \"G\" + \"B\" + line[j+1:]\n\t\t\t\tj--\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(line)\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "c1f40d4043e38841464f86f29b47682c", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tinput := bufio.NewScanner(os.Stdin)\n\thasInput := input.Scan()\n\tif hasInput == false {\n\t\tpanic(\"Number of problems missing\")\n\t}\n\n\ttmp := strings.Split(input.Text(), \" \")\n\tt, err := strconv.Atoi(tmp[1])\n\tinput.Scan()\n\tq := strings.Split(input.Text(), \"\")\n\tif err != nil {\n\t\tpanic(\"Something went wrong\")\n\t}\n\n\tq = tick(q, t)\n\n\tfmt.Println(strings.Join(q, \"\"))\n}\n\nfunc tick(q []string, t int) []string {\n\ts := make([]bool, len(q))\n\tvar tmp string\n\n\tfor i := 0; i <= t; i++ {\n\t\tfor j, _ := range q {\n\t\t\tif s[j] == true && len(q) > j+1 {\n\t\t\t\ttmp = q[j]\n\t\t\t\tq[j] = q[j+1]\n\t\t\t\tq[j+1] = tmp\n\t\t\t\ts[j] = false\n\t\t\t}\n\t\t}\n\n\t\tfor j, v := range q {\n\t\t\tif v == \"B\" && len(q) > j+1 && q[j+1] == \"G\" {\n\t\t\t\ts[j] = true\n\t\t\t}\n\t\t}\n\n\t}\n\n\treturn q\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "deffc4a951c5c5fbf7a8201bb490dd3c", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var n, t int\n fmt.Scan(&n, &t)\n\n var q string\n fmt.Scan(&q)\n\n b := []byte(q)\n\n for i := 0; i < t; i++ {\n id := 0\n for id + 1 < n {\n if b[id] == 'B' && b[id+1] == 'G' {\n b[id], b[id+1] = b[id+1], b[id]\n id += 2\n } else {\n id += 1\n }\n }\n\n q = string(b)\n }\n\n fmt.Println(q)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "df57309cbe545da8c5ed575ab63d20bc", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc schoolQueue(s string, n, t int) string {\n\trunes := []rune(s)\n\tfor c := 0; c < t; c++ {\n\t\tfor i := 1; i < len(s); i++ {\n\t\t\tif s[i] != s[i-1] && s[i] == 'G' {\n\t\t\t\trunes[i-1], runes[i] = runes[i], runes[i-1]\n\t\t\t}\n\t\t}\n\t\ts = string(runes)\n\t}\n\treturn string(runes)\n}\n\nfunc main() {\n\tvar n, t int\n\tfmt.Scan(&n)\n\tfmt.Scan(&t)\n\tvar s string\n\tfmt.Scan(&s)\n\tfmt.Println(schoolQueue(s, n, t))\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "c8b30be423d25f0f6a7afb9a1062a615", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"container/list\"\n)\n\nfunc main() {\n\tvar peopleNumber, timeElapsed int\n\tfmt.Scan(&peopleNumber, &timeElapsed)\n\tvar queue []byte\n\tvar queueStr string\n\tfmt.Scan(&queueStr)\n\tqueue = append(queue, queueStr...)\n\tfor sec := 0; sec < timeElapsed; sec++ {\n\t\tmarks := list.New()\n\t\tfor offset := 0; offset < peopleNumber - 1; offset++ {\n\t\t\tif queue[offset] == 'B' && queue[offset + 1] == 'G' {\n\t\t\t\tmarks.PushBack(offset)\n\t\t\t}\n\t\t}\n\t\tfor e := marks.Front(); e != nil; e = e.Next() {\n\t\t\tpos := e.Value.(int)\n\t\t\tqueue[pos], queue[pos + 1] = queue[pos + 1], queue[pos]\n\t\t}\n\t}\n\tfmt.Print(string(queue))\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "fc22fb775c61d00f0017779059bca680", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte. Trailing '\\n' will not be included.\n// See also comments on readb()\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Utilities\n\nfunc sumSlice(a []int) int {\n\tvar res int\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc sumSlicell(a []int64) int64 {\n\tvar res int64\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc readInts(N int) (int, []int) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int, N)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\treturn N, a\n}\n\nfunc readIntsll(N int) (int, []int64) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int64, N)\n\tfor i := range a {\n\t\ta[i] = readll()\n\t}\n\treturn N, a\n}\n\n// reverse slice in place\nfunc reverse(a []int) {\n\tfor i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {\n\t\ta[i], a[j] = a[j], a[i]\n\t}\n}\n\n// areverse: allocating reverse\nfunc areverse(a []int) []int {\n\tb := make([]int, len(a))\n\tfor i := range a {\n\t\tb[i] = a[len(a)-i-1]\n\t}\n\treturn b\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n\nvar memo map[int]bool\n\nfunc main() {\n\tdefer Flush()\n\n\tmemo = make(map[int]bool)\n\tmemo[0] = true\n\n\t_, x := readInts(0)\n\tfor i := range x {\n\t\tif solve(x[i]) {\n\t\t\tprintln(\"YES\")\n\t\t} else {\n\t\t\tprintln(\"NO\")\n\t\t}\n\t}\n}\n\nfunc solve(x int) bool {\n\tif x < 0 {\n\t\treturn false\n\t}\n\tt, ok := memo[x]\n\tif ok {\n\t\tif t {\n\t\t\treturn true\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif solve(x-3) || solve(x-7) {\n\t\tmemo[x] = true\n\t\treturn true\n\t}\n\tmemo[x] = false\n\treturn false\n\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "e9d801e3d40024d0672301ca3b230b37", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, t int\n\tfmt.Scan(&n)\n\n\tfor i:=0;i x { fmt.Println(a-x) } else { fmt.Println(0) }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "2117baf2cfe0d6b34ebd7876deecdc43", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar p,x,y int\n\tfmt.Scan(&p,&x,&y)\n\tans:=(p*y-1)/100-x+1\n\tif ans<0 {\n\t\tans=0\n\t}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "94762ceab2468357dd36c381497c6e11", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var n,x,y int\t\t\t\t\t\t\t\t\t\t// membuat variabel n,x,y dengan jenis int \n fmt.Scan(&n,&x,&y)\t\t\t\t\t\t\t\t\t// mengambil input\n a := int(math.Ceil(float64(y)*float64(n)/100.0)) // membuat variabel a dengan jenis int dan diisi hasil dari pembulatan keatas dari y dikali n dibagi 100\n if a > x { fmt.Println(a-x) } else { fmt.Println(0) } // jika a lebih dari x maka cetak hasil a-x , lainnya cetak 0\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "a244ef5fd42094800e053363a40afc91", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"math\"\n\t\"fmt\"\n)\n\nfunc main () {\n\tvar a float64\n\tvar b float64\n\n\tfmt.Scanf(\"%f %f\\n\",&a,&b)\n\n\tc := b * math.Log(a)\n\td := a * math.Log(b)\n\n\tif c < d {\n\t\tfmt.Println(\"<\")\n\t} else if c > d {\n\t\tfmt.Println(\">\")\n\t} else {\n\t\tfmt.Println(\"=\")\n\t}\n\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "20b69d91cc724fcf443a129bb50fb880", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tx := float64(readInt())\n\ty := float64(readInt())\n\tt0 := y * math.Log(x)\n\tt1 := x * math.Log(y)\n\tif t0 == t1 {\n\t\tfmt.Println(\"=\")\n\t} else if t1 < t0 {\n\t\tfmt.Println(\">\")\n\t} else {\n\t\tfmt.Println(\"<\")\n\t}\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "f4b9d3aa5c161d5752db9a3f2071ec40", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar x, y float64\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%f %f\\n\", &x, &y)\n\tx, y = y*math.Log(x), x*math.Log(y)\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t} else if x < y {\n\t\tfmt.Println(\"<\")\n\t} else {\n\t\tfmt.Println(\">\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "0f8ccf38ec0e73b1d717685694b14cb0", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar x1, x2, x3 int\n\t//in := bufio.NewReader(os.Stdin)\n\tfmt.Scan(&x1, &x2, &x3)\n\ty1 := int(math.Abs(float64(x1-x2)) + math.Abs(float64(x1-x3)))\n\ty2 := int(math.Abs(float64(x2-x1)) + math.Abs(float64(x2-x3)))\n\ty3 := int(math.Abs(float64(x3-x1)) + math.Abs(float64(x3-x2)))\n\tif y1 < y2 && y1 < y3 {\n\t\tfmt.Println(y1)\n\t} else if y2 < y1 && y2 < y3 {\n\t\tfmt.Println(y2)\n\t} else {\n\t\tfmt.Println(y3)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "sortings", "implementation"], "code_uid": "84a41ad22a77d710d5db9cb1ec117b95", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nfunc main() {\n\tvar a, b, c int\n\tvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\t\n\tscanner.Scan()\n\tfmt.Sscanf(scanner.Text(), \"%d %d %d\", &a, &b, &c)\n\t\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\t\n\tif b > c {\n\t\tb, c = c, b\n\t}\n\t\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\t\n\tfmt.Print(c - a)\n}\n\n", "lang_cluster": "Go", "tags": ["math", "sortings", "implementation"], "code_uid": "913c88a691a472f3384ad99c67778714", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\nfunc main(){\n\thome:=make([]int,3)\n\tdist:=0\n\tfor i:=0;i 0; i = i - 1 {\n\t\tif t[i] == '0' {\n\t\t\tcount += 1\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn count\n}\n\nfunc add_leading_zeros(t string, c int) string {\n\tu := t\n\n\tfor i := 0; i < c; i = i + 1 {\n\t\tu = \"0\" + u\n\t}\n\n\treturn u\n}\n\nfunc solve(t string) bool {\n\n\tif is_palindrome(t) {\n\t\treturn true\n\t}\n\n\ttrailing_zeros := get_trailing_scores_count(t)\n\n\tu := add_leading_zeros(t, trailing_zeros)\n\n\tif is_palindrome(u) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\tvar t string\n\n\tfmt.Scanf(\"%s\", &t)\n\n\tif solve(t) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "1f1deef6aa15218c09187598982055c3", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tms := NewMuchScanner()\n\ts := ms.ReadString()\n\tn := len(s)\n\n\tleadingZeros := 0\n\ttrailingZeros := 0\n\n\tfor i := 0; i < n && s[i] == '0'; i++ {\n\t\tleadingZeros++\n\t}\n\tfor i := n - 1; i >= 0 && s[i] == '0'; i-- {\n\t\ttrailingZeros++\n\t}\n\n\tzerosToAdd := diff(leadingZeros, trailingZeros)\n\tz := make([]byte, zerosToAdd)\n\tfor i := range z {\n\t\tz[i] = '0'\n\t}\n\tzeros := string(z)\n\n\tif leadingZeros > trailingZeros {\n\t\ts = concat(s, zeros)\n\t} else {\n\t\ts = concat(zeros, s)\n\t}\n\tn = len(s)\n\n\tisOk := true\n\tfor i := 0; i < n/2; i++ {\n\t\tj := n - 1 - i\n\t\tif s[i] != s[j] {\n\t\t\tisOk = false\n\t\t}\n\t}\n\n\tif isOk {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc diff(a, b int) int {\n\tif a > b {\n\t\treturn a - b\n\t}\n\treturn b - a\n}\n\nfunc concat(a, b string) string {\n\tvar buf bytes.Buffer\n\tbuf.WriteString(a)\n\tbuf.WriteString(b)\n\treturn buf.String()\n}\n\n// MuchScanner is a wrapper for bufio.Scanner\ntype MuchScanner struct {\n\tscanner *bufio.Scanner\n}\n\n// NewMuchScanner creates new insances of MuchScanner\nfunc NewMuchScanner() *MuchScanner {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\treturn &MuchScanner{\n\t\tscanner: sc,\n\t}\n}\n\n// TokenSize sets maximal token size\nfunc (ms *MuchScanner) TokenSize(tokenSize int) {\n\tms.scanner.Buffer(make([]byte, tokenSize), tokenSize)\n}\n\n// ReadString reads next word as a string\nfunc (ms *MuchScanner) ReadString() string {\n\tms.scanner.Scan()\n\treturn ms.scanner.Text()\n}\n\n// ReadInt reads next int number\nfunc (ms *MuchScanner) ReadInt() int {\n\tn, _ := strconv.Atoi(ms.ReadString())\n\treturn n\n}\n\n// ReadIntArr reads next n int numbers\nfunc (ms *MuchScanner) ReadIntArr(n int) []int {\n\tarr := make([]int, n)\n\tfor i := range arr {\n\t\tarr[i] = ms.ReadInt()\n\t}\n\treturn arr\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "501c5792c5752625619870c48336d670", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\n\tp := len(s)\n\tfor s[p-1] == '0' {\n\t\tp--\n\t}\n\n\tfor i := 0; i < p; i++ {\n\t\tif s[i] != s[p-1-i] {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "a711764694a52b88b83215e970f1e113", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := make([]int, 6)\n\ttotal := 0\n\tfor i := 0; i < 6; i++ {\n\t\ta[i] = readInt()\n\t\ttotal += a[i]\n\t}\n\tif total%2 != 0 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfor j := 1; j < 5; j++ {\n\t\tfor k := j + 1; k < 6; k++ {\n\t\t\tif a[0]+a[j]+a[k] == total/2 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "8a0865e73cb31af5424b4fedb6bfb560", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := make([]int, 6)\n\tfor i, _ := range a {\n\t\ta[i] = readInt()\n\t}\n\tm := make(map[int]bool)\n\tmnot := make(map[int]bool)\n\tfor i := uint(0); i < 4; i++ {\n\t\tfor j := i + 1; j < 5; j++ {\n\t\t\tfor k := j + 1; k < 6; k++ {\n\t\t\t\tb := (1 << i) | (1 << j) | (1 << k)\n\t\t\t\tif m[b] || mnot[b] {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tm[b] = true\n\t\t\t\tmnot[(^b)&0x3f] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor k, _ := range m {\n\t\tsum0 := 0\n\t\tsum1 := 0\n\t\tfor i := uint(0); i < 6; i++ {\n\t\t\tif k&(1< prev {\n return find(n-1, k-prev-1)\n }\n return find(n-1, k)\n}\n\nfunc solve() {\n n, k := readInt64(), readInt64()-1\n fmt.Println(find(n, k))\n}\n\n// Helpers\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\n// Sort\n\ntype Ints64 []int64\n\nfunc (a Ints64) Len() int { return len(a) }\nfunc (a Ints64) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a Ints64) Less(i, j int) bool { return a[i] < a[j] }\n\n/* Sort tempalte\nfunc (a ) Len() int { return len(a) }\nfunc (a ) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ) Less(i, j int) bool { return }\n*/\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "1bfffbe7183d5af09f6ae53c4df4ccf0", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar k int64\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &n, &k); err != nil {\n\t\treturn\n\t}\n\n\tlen := int64(1)\n\tcenter := 1\n\tfor i := 1; i < n; i++ {\n\t\tlen = len*2 + 1\n\t\tcenter++\n\t}\n\n\tfor center > 0 {\n\t\tcp := (len + 1) / 2\n\t\tif k == cp {\n\t\t\tbreak\n\t\t} else if k > cp {\n\t\t\tk -= cp\n\t\t}\n\t\tlen = (len - 1) / 2\n\t\tcenter--\n\t}\n\n\tfmt.Println(center)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "e266663791abcbbdf01485cd521cbe79", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn, m := nextInt(), nextInt()\n\n\tlights := make([]int, n) \n\tbuttonOff := 0\n\n\tfor i:=0; i rt {\n\t\tfmt.Print(\"Limak\")\n\t} else if lt < rt {\n\t\tfmt.Print(\"Radewoosh\")\n\t} else {\n\t\tfmt.Print(\"Tie\")\n\t}\n}\n\nfunc max(i, j int) int {\n\tif i > j {\n\t\treturn i\n\t}\n\treturn j\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b7fdd720e494f3febf8e4e5038ce5f08", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n\nimport (\n\t\"fmt\"\n\t\"math\"\t\n)\n\nvar problems, parametres, problem, time int \n\nfunc score(start, end int, scores, TIME []int) int{\n\tvar score, time int\n\n\tfor i := 0; i < problems; i++ {\n\t\ttime += TIME[i]\n\t\tinitial := scores[i] - parametres * time\n\t\t\n\t\tscore += int(math.Max(0, float64(initial)))\n\n\t}\n\n\n\treturn int(score)\n}\n\nfunc reverse( array []int ) []int {\n\tfor i := 0; i < len(array) / 2; i++ {\n\t\tarray[i], array[len(array) - i - 1] = array[len(array) - i - 1], array[i] \t\n\t}\n\n\treturn array\n}\n\nfunc main() {\n\tfmt.Scan(&problems, ¶metres)\n\n\tvar scores, TIME []int\n\tfor i := 0; i < problems; i++ {\n\t\tfmt.Scan(&problem)\n\t\tscores = append(scores, problem)\n\t}\n\n\tfor i := 0; i < problems; i++ {\n\t\tfmt.Scan(&time)\n\t\tTIME = append(TIME, time)\n\t}\n\n\t\n\tvar LimakScore, RadewooshScore int\n\n\n\tLimakScore = score(0, problems, scores, TIME)\n\n\tscores, TIME = reverse(scores), reverse(TIME)\n\n\tRadewooshScore = score(problems, 0, scores, TIME)\n\n\n\tif LimakScore > RadewooshScore { \n\t\tfmt.Println(\"Limak\") \n\t} else if LimakScore == RadewooshScore { \n\t\tfmt.Println(\"Tie\") \n\t} else { \n\t\tfmt.Println(\"Radewoosh\") \n\t}\n}\t\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "8bd7f1478a683c978ddfe8b5a9a0588c", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n\nimport (\n\t\"fmt\"\n\t// \"math\"\t\n)\n\n\nfunc main() {\n\tvar problems, parametres int \n\tfmt.Scan(&problems, ¶metres)\n\n\tvar scores, TIME []int\n\tfor i := 0; i < problems; i++ {\n\t\tvar problem int\n\t\tfmt.Scan(&problem)\n\t\tscores = append(scores, problem)\n\t}\n\n\tfor i := 0; i < problems; i++ {\n\t\tvar time int\n\t\tfmt.Scan(&time)\n\t\tTIME = append(TIME, time)\n\t}\n\n\tvar LimakScore, RadewooshScore int\n\tvar time int\n\n\tfor i := 0; i < problems; i++ {\n\t\ttime += TIME[i]\n\t\tif (scores[i] - parametres * time) < 0 {\n\t\t\tLimakScore += 0\n\t\t} else {\n\t\t\tLimakScore += scores[i] - parametres * time\n\t\t}\n\t}\n\t\n\ttime = 0\n\n\tfor i := problems - 1; i >= 0; i-- {\n\t\ttime += TIME[i]\n\t\tif scores[i] - parametres * time < 0 {\n\t\t\tRadewooshScore += 0\n\t\t} else {\n\t\t\tRadewooshScore += scores[i] - parametres * time\n\t\t}\n\t}\n\n\t// fmt.Println(LimakScore, RadewooshScore)\n\n\tif LimakScore > RadewooshScore {\n\t\tfmt.Println(\"Limak\")\n\t} else if LimakScore == RadewooshScore {\n\t\tfmt.Println(\"Tie\")\n\t} else {\n\t\tfmt.Println(\"Radewoosh\")\n\t}\n}\t\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a06ea26e1aa6393d343498cf7f901583", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\ta, b, c, d, e, f := 0, 0, 0, 0, 0, 0\n\tfmt.Fscanf(in, \"%d\\n\", &a)\n\tfmt.Fscanf(in, \"%d\\n\", &b)\n\tfmt.Fscanf(in, \"%d\\n\", &c)\n\tfmt.Fscanf(in, \"%d\\n\", &d)\n\tfmt.Fscanf(in, \"%d\\n\", &e)\n\tfmt.Fscanf(in, \"%d\\n\", &f)\n\tans := 0\n\tif e > f {\n\t\tamt := min(a, d)\n\t\tans += amt * e\n\t\td -= amt\n\t\tamt = min(b, d)\n\t\tamt = min(amt, c)\n\t\tans += amt * f\n\t} else {\n\t\tamt := min(b, d)\n\t\tamt = min(amt, c)\n\t\tans += amt * f\n\t\td -= amt\n\t\tamt = min(a, d)\n\t\tans += amt * e\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", ans)\n\treturn\n}\n\nfunc minstep(a, b byte) int {\n\treturn min(int(a-b+26)%26, int(b-a+26)%26)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "brute force"], "code_uid": "b10a3f7ddcacb715305cefc044a97ad0", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\nconst INF_INT32 = math.MaxInt32\nconst INF_BIT30 = 1 << 30\n\nvar a, b, c, d, e, f int\n\nfunc main() {\n\ta, b, c, d = ReadInt4()\n\te, f = ReadInt2()\n\n\tbc := Min(b, c)\n\n\tans := 0\n\tif e > f {\n\t\t// aの方を使う\n\t\tm := Min(a, d)\n\t\tans += e * m\n\t\td -= m\n\t\tif d > 0 {\n\t\t\tmm := Min(bc, d)\n\t\t\tans += f * mm\n\t\t}\n\t} else {\n\t\t// bcの方を使う\n\t\tm := Min(bc, d)\n\t\tans += f * m\n\t\td -= m\n\t\tif d > 0 {\n\t\t\tmm := Min(a, d)\n\t\t\tans += e * mm\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n/*\n- まずは全探索を検討しましょう\n- MODは最後にとりましたか?\n- ループを抜けた後も処理が必要じゃありませんか?\n- 和・積・あまりを求められたらint64が必要ではありませんか?\n- いきなりオーバーフローはしていませんか?\n\t- MOD取る系はint64必須ですよ?\n*/\n\n/*\nASCII code\n\nASCII 10進数 ASCII 10進数 ASCII 10進数\n! 33 \" 34 # 35\n$ 36 % 37 & 38\n' 39 ( 40 ) 41\n* 42 + 43 , 44\n- 45 . 46 / 47\n0 48 1 49 2 50\n3 51 4 52 5 53\n6 54 7 55 8 56\n9 57 : 58 ; 59\n< 60 = 61 > 62\n? 63 @ 64 A 65\nB 66 C 67 D 68\nE 69 F 70 G 71\nH 72 I 73 J 74\nK 75 L 76 M 77\nN 78 O 79 P 80\nQ 81 R 82 S 83\nT 84 U 85 V 86\nW 87 X 88 Y 89\nZ 90 [ 91 \\ 92\n] 93 ^ 94 _ 95\n` 96 a 97 b 98\nc 99 d 100 e 101\nf 102 g 103 h 104\ni 105 j 106 k 107\nl 108 m 109 n 110\no 111 p 112 q 113\nr 114 s 115 t 116\nu 117 v 118 w 119\nx 120 y 121 z 122\n{ 123 | 124 } 125\n~ 126 127\n*/\n\n/*******************************************************************/\n", "lang_cluster": "Go", "tags": ["math", "greedy", "brute force"], "code_uid": "718e331298ebb89d38e2c8559ea816fb", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc main(){\n\tvar a, b, c, d, e, f, maxx int\n\tfmt.Scan(&a, &b, &c, &d, &e, &f)\n\tmaxx = 0\n\tfor i := 0; i <= d; i++ {\n\t\tmaxx = max(maxx, min(a, i) * e + min(min(b, c), d - i) * f)\n\t}\n\tfmt.Print(maxx);\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "brute force"], "code_uid": "44d07daa187e85ff41d65efdebd39cdd", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n x, o := getI(), getI()\n xPairs := x/2\n if xPairs > o {\n xPairs = o\n }\n x -= 2*xPairs\n o -= xPairs\n oFours := o/3\n if oFours > xPairs {\n oFours = xPairs\n }\n xPairs -= oFours\n o -= 3*oFours\n teams := xPairs + 2*oFours\n if x > 0 && o > 1 {\n x--\n o -= 2\n teams++\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", teams))\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "ccb2e2cf0d6e5090a18694deaa5d9a41", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\nfunc getLine2Ints(n int) []int {\n\tans := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d \", &ans[i])\n\t}\n\tscanf(\"%d\\n\", &ans[n-1])\n\treturn ans\n}\n\nfunc pcheck(i bool) {\n\tif i {\n\t\tprintf(\"Yes\\n\")\n\t} else {\n\t\tprintf(\"No\\n\")\n\t}\n}\n\nvar debug = true\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tn, m := getLine2Int2()\n\tvar x int\n\tif n*2 < m {\n\t\tx = n\n\t} else if m*2 < n {\n\t\tx = m\n\t} else {\n\t\tx = (m + n) / 3\n\t}\n\tprintf(\"%d\\n\", x)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "239e44e26d3a3a39ce1377394b6b6404", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar x, y float64\n\tfmt.Scanf(\"%f %f\\n\", &x, &y)\n\tvar ans float64 = math.Min((x+y)/3, math.Min(x, y))\n\tvar ans2 = int(ans)\n\tfmt.Println(ans2)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "30933ab0a9ab035b56be22274fd40fb8", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tvar n int\n\tfmt.Scan(&s)\n\tchars := strings.Split(s, \"\")\n\tfor _, v := range chars {\n\t\tif v == \"4\" || v == \"7\" {\n\t\t\tn++\n\t\t}\n\t}\n\n\tif n == 4 || n == 7 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\t\t\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "327e8d4f05bc4973558132fe3cccdede", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n string\n\tfmt.Scan(&n)\n\tc := 0\n\tfor _, d := range n {\n\t\tif d == '4' || d == '7' {\n\t\t\tc++\n\t\t}\n\t}\n\n\tif c == 4 || c == 7 {\n\t\tfmt.Print(\"YES\")\n\t\treturn\n\t}\n\n\tfmt.Print(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "79f785d1092ee26e507f5afce1af72d0", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n// https://codeforces.com/problemset/problem/110/A\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc task_solution(in []byte) string {\n\ttype s struct{}\n\texists := s{}\n\tlucky := map[byte]s{\n\t\t'4': exists,\n\t\t'7': exists,\n\t}\n\n\tcounter := 0\n\tfor _, c := range in {\n\t\tif _, ok := lucky[c]; ok {\n\t\t\tcounter += 1\n\t\t}\n\t}\n\n\tif counter == 4 || counter == 7 {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\tin_raw, err := ioutil.ReadAll(os.Stdin)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(task_solution(in_raw))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2b60095c3b9b0caed3c4ecc3abf3f313", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\ntype Trav func(func(data interface{}))\n\ntype TermRLE struct {\n\tdata interface{}\n\tamount int\n}\n\nfunc toRLE(a Trav) Trav {\n\tvar current = TermRLE{nil, 0}\n\treturn func(f func(interface{})) {\n\t\ta(func(data interface{}) {\n\t\t\tif current.amount == 0 {\n\t\t\t\tcurrent = TermRLE{data, 1}\n\t\t\t} else if data != current.data {\n\t\t\t\tf(current)\n\t\t\t\tcurrent = TermRLE{data, 1}\n\t\t\t} else {\n\t\t\t\tcurrent.amount++\n\t\t\t}\n\t\t})\n\t\tif current.amount != 0 {\n\t\t\tf(current)\n\t\t\tcurrent = TermRLE{nil, 0}\n\t\t}\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar s string\n\tfmt.Scan(&s)\n\ttoRLE(func(f func(interface{})) {\n\t\tfor _, i := range s {\n\t\t\tf(i)\n\t\t}\n\t})(func(data interface{}) {\n\t\tn--\n\t})\n\tfmt.Println(n)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e77e9e213bae405282dfbe98c4b26388", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tvar colors string\n\tfmt.Scan(&colors)\n\n\tcur := colors[0]\n\tvar t int\n\tfor i := 1; i < n; i++ {\n\t\tif colors[i] == cur {\n\t\t\tt++\n\t\t} else {\n\t\t\tcur = colors[i]\n\t\t}\n\t}\n\n\tfmt.Print(t)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "c4be3e364c9c8d9dcb3f6bfffa48d306", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var s string\n fmt.Scan(&n,&s)\n ans := 0\n for i := 1; i < n; i++ {\n if (s[i] == s[i-1]) { ans++ }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "15e68568e0b1d1d798df9f4181e00c85", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t. \"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nfunc main() {\r\n\tre, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\r\n\tdefer w.Flush()\r\n\tvar N int\r\n\tFscan(re, &N)\r\n\ta := make([]int, N)\r\n\tfor i := 0; i < N; i++ {\r\n\t\tFscan(re, &a[i])\r\n\t}\r\n\tp := 0\r\n\tvar num ,t int\r\n\tfor j := 0; j < N; j++{\r\n\t\tnum = 0\r\n\t\tt = 0\r\n\t\tfor i := 1; i * i <= a[j]; i++{\r\n\t\t\tp = i\r\n\t\t}\r\n\t\tnum += p\r\n\t\tfor i := 1; i * i * i <= a[j]; i++{\r\n\t\t\tp = i\r\n\t\t\tif kaifang(i * i * i) {\r\n\t\t\t\tt++\r\n\t\t\t}\r\n\t\t}\r\n\t\tnum += p\r\n\t\tFprintln(w, num - t)\r\n\t}\r\n}\r\nfunc kaifang(a int) bool {\r\n\tfor i := 1; i * i <= a; i++{\r\n\t\tif i * i == a{\r\n\t\t\treturn true\r\n\t\t}\r\n\t}\r\n\treturn false\r\n}\r\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "7881468c7901de55ce444ac30f9737fa", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n\t\"sort\"\r\n)\r\n\r\nvar (\r\n\tin = bufio.NewReader(os.Stdin)\r\n\tout = bufio.NewWriter(os.Stdout)\r\n)\r\n\r\ntype Set struct {\r\n\titems map[interface{}]struct{}\r\n}\r\n\r\nfunc (s *Set) Size() int {\r\n\treturn len(s.items)\r\n}\r\nfunc (s *Set) Empty() bool {\r\n\treturn s.Size() == 0\r\n}\r\n\r\nfunc (s *Set) Add(t ...interface{}) {\r\n\tfor _, v := range t {\r\n\t\ts.items[v] = struct{}{}\r\n\t}\r\n}\r\n\r\nfunc (s *Set) Remove(t ...interface{}) {\r\n\tfor _, v := range t {\r\n\t\tdelete(s.items, v)\r\n\t}\r\n}\r\n\r\nfunc (s *Set) Contains(t ...interface{}) bool {\r\n\tfor _, v := range t {\r\n\t\tif _, ok := s.items[v]; !ok {\r\n\t\t\treturn false\r\n\t\t}\r\n\t}\r\n\treturn true\r\n}\r\n\r\nfunc (s *Set) List() []interface{} {\r\n\tret := make([]interface{}, 0, s.Size())\r\n\tfor k, _ := range s.items {\r\n\t\tret = append(ret, k)\r\n\t}\r\n\treturn ret\r\n}\r\n\r\nfunc New(values ...interface{}) *Set {\r\n\tret := &Set{\r\n\t\titems: make(map[interface{}]struct{}),\r\n\t}\r\n\tfor _, v := range values {\r\n\t\tret.Add(v)\r\n\t}\r\n\treturn ret\r\n}\r\n\r\nfunc main() {\r\n\tdefer out.Flush()\r\n\r\n\tset := New()\r\n\tfor i := 1; i*i <= 1_000_000_000; i++ {\r\n\t\tset.Add(i * i)\r\n\t}\r\n\tfor i := 1; i <= 1000; i++ {\r\n\t\tset.Add(i * i * i)\r\n\t}\r\n\r\n\tarr := make([]int, 0, set.Size())\r\n\tfor _, v := range set.List() {\r\n\t\tarr = append(arr, v.(int))\r\n\t}\r\n\r\n\tsort.Ints(arr)\r\n\r\n\tvar kase int\r\n\tfmt.Fscan(in, &kase)\r\n\r\n\tfor kk := 1; kk <= kase; kk++ {\r\n\t\tvar n int\r\n\t\tfmt.Fscan(in, &n)\r\n\r\n\t\tlow, high := 0, len(arr)-1\r\n\r\n\t\tfor low <= high {\r\n\t\t\tmid := (low + high) / 2\r\n\r\n\t\t\tif n >= arr[mid] {\r\n\t\t\t\tlow = mid + 1\r\n\t\t\t} else {\r\n\t\t\t\thigh = mid - 1\r\n\t\t\t}\r\n\t\t}\r\n\t\tfmt.Fprintf(out, \"%d\\n\", high+1)\r\n\t}\r\n}\r\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9584b3526db8888703b2daf3f3c07d6f", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// B. Squares and Cubes\r\n\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"io/ioutil\"\r\n\t\"math\"\r\n\t\"os\"\r\n\t\"sort\"\r\n\t\"strconv\"\r\n\t\"strings\"\r\n)\r\n\r\nvar tk []string\r\nvar ptr int = 0\r\n\r\nfunc su() int {\r\n\tr, _ := strconv.Atoi(tk[ptr])\r\n\tptr++\r\n\treturn r\r\n}\r\nfunc main() {\r\n\tbytes, _ := ioutil.ReadAll(os.Stdin)\r\n\ttk = strings.Fields(string(bytes))\r\n\r\n\tconst MM int = 1e9\r\n\tarr := make([]int, 0, 33000)\r\n\tfor i := 1; i*i <= MM; i++ {\r\n\t\tarr = append(arr, i*i)\r\n\t}\r\n\tfor i := 1; i*i*i <= MM; i++ {\r\n\t\tcube := i * i * i\r\n\t\tsqrt := int(math.Sqrt(float64(cube)))\r\n\t\tif sqrt*sqrt == cube {\r\n\t\t\tcontinue\r\n\t\t}\r\n\t\tarr = append(arr, cube)\r\n\t}\r\n\tsort.Slice(arr, func(i int, j int) bool { return arr[i] < arr[j] })\r\n\r\n\tt := su()\r\n\tfor t > 0 {\r\n\t\tn := su()\r\n\t\tlo, hi := 0, len(arr)-1\r\n\t\tfor lo <= hi {\r\n\t\t\tmid := (lo + hi) / 2\r\n\t\t\tif arr[mid] > n {\r\n\t\t\t\thi = mid - 1\r\n\t\t\t} else {\r\n\t\t\t\tlo = mid + 1\r\n\t\t\t}\r\n\t\t}\r\n\t\tfmt.Println(lo)\r\n\t\tt--\r\n\t}\r\n}\r\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "1c73e4834839f086d3037fdf8f2404f5", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, result int\n\tfmt.Scan(&n)\n\tfor ; n > 0; n-- {\n\t\tfmt.Scan(&a)\n\t\tif a > 0 {\n\t\t\tresult += a\n\t\t} else {\n\t\t\tresult -= a\n\t\t}\n\t}\n\tfmt.Print(result)\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "05f8c65a5e5394a379a3a70763567c5f", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nfunc main() {\n\tvar n,x int\n\tfmt.Scan(&n)\n\ta,b := 0,0\n\tfor ;n>0;n-- {\n\t\tfmt.Scan(&x)\n\t\tif x > 0 {\n\t\t\ta += x\n\t\t} else {\n\t\t\tb -= x\n\t\t}\n\t}\n\tfmt.Print(a+b)\n}", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "5c15ea1a08661241c0480b2ed2f51656", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\tA := sc.NextIntArray()\n\ttotal := 0\n\tfor i := 0; i < N; i++ {\n\t\ttotal += abs(A[i])\n\t}\n\tfmt.Println(total)\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "41f37352d6190acef7cd7a8241dfdb00", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\tlog.SetOutput(ioutil.Discard)\n\t// log.SetOutput(os.Stderr)\n\n\tn, a, b, p, q := nextInt64(), nextInt64(), nextInt64(), nextInt64(), nextInt64()\n\tlog.Print(n*gcd(a, b)/(a*b), min(p, q))\n\tprintln(n/a*p + n/b*q - n*gcd(a, b)/(a*b)*min(p, q))\n}\n\nfunc gcd(x, y int64) int64 {\n\tfor y != 0 {\n\t\tx, y = y, x%y\n\t}\n\treturn x\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "b9d7ba965641d0b8f22d4409ed7fae48", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\ts := getWord()\n\teidx := strings.LastIndexByte(s, 'e')\n\tb, _ := strconv.Atoi(s[eidx+1:])\n\ts = string(s[0]) + s[2:eidx] + strings.Repeat(\"0\", 105)\n\ts = s[:b+1] + \".\" + s[b+1:]\n\ts = strings.Trim(s, \"0\")\n\tif strings.HasPrefix(s, \".\") {\n\t\ts = \"0\" + s\n\t}\n\tif strings.HasSuffix(s, \".\") {\n\t\ts = strings.TrimRight(s, \".\")\n\t}\n\tfmt.Println(s)\n}\n\ntype Input struct {\n\t*bufio.Scanner\n}\n\nvar globalInput = wrapStdin()\n\nfunc wrapStdin() Input {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\treturn Input{Scanner: sc}\n}\nfunc getInt() int {\n\tglobalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x\n}\nfunc getIntOk() (int, bool) {\n\tok := globalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x, ok\n}\nfunc getNint(n int) []int {\n\tv := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tv[i] = getInt()\n\t}\n\treturn v\n}\nfunc getVint(v []int) bool {\n\tvar ok bool\n\tfor i := 0; i < len(v); i++ {\n\t\tv[i], ok = getIntOk()\n\t}\n\treturn ok\n}\nfunc getWord() string {\n\tglobalInput.Scan()\n\treturn globalInput.Text()\n}\nfunc getWordOk() (string, bool) {\n\tok := globalInput.Scan()\n\treturn globalInput.Text(), ok\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc min64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max64(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc minStr(a, b string) string {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc maxStr(a, b string) string {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc remin(a *int, b int) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remax(a *int, b int) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remin64(a *int64, b int64) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remax64(a *int64, b int64) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc reminStr(a *string, b string) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remaxStr(a *string, b string) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\nfunc abs64(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\ntype (\n\tFLess func(i, j int) bool\n\tFSwap func(i, j int)\n\twrapSort struct {\n\t\tLength int\n\t\tFLess\n\t\tFSwap\n\t}\n)\n\nfunc (w *wrapSort) Len() int { return w.Length }\nfunc (w *wrapSort) Less(i, j int) bool { return w.FLess(i, j) }\nfunc (w *wrapSort) Swap(i, j int) { w.FSwap(i, j) }\nfunc wsort(length int, fless func(i, j int) bool, fswap func(i, j int)) {\n\tsort.Sort(&wrapSort{length, fless, fswap})\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "strings", "implementation"], "code_uid": "c0a01c05414db214cea0701ce0361762", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc transform(s string) string {\n\tt := strings.Split(s, \"e\")\n\n\ta := t[0][:1]\n\td := t[0][2:]\n\n\tb, _ := strconv.Atoi(t[1])\n\tfor len(d) < b {\n\t\td = d + \"0\"\n\t}\n\n\tr := a + d[:b]\n\tif (b < len(d)) && (d != \"0\") {\n\t\tr = r + \".\" + d[b:]\n\t}\n\n\treturn r\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar s string\n\tfmt.Fscan(bufin, &s)\n\tfmt.Fprintln(bufout, transform(s))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "strings", "implementation"], "code_uid": "1896e1e0d1c6806e1e18a93b8df6ca9c", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,k int\n fmt.Scan(&n,&k)\n if (k/n) > 2 {\n fmt.Println(0)\n } else {\n fmt.Println(n-(k%n))\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "6795f73f4d6825441e360ca98e93a97b", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc bs(n, k int) int {\n //Find the answer\n var lo, hi, mid, ans int = 0, n, 0, 0\n for lo <= hi {\n mid = (lo+hi)/2\n left := k-2*mid\n if (n-mid)*3 <= left {\n ans = mid\n hi = mid-1\n } else {\n lo = mid+1\n }\n }\n return ans\n}\n\nfunc main() {\n var n, k int\n \n fmt.Scan(&n, &k)\n \n fmt.Println(bs(n, k))\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9d5814a6a261d20119ba7c66610c2471", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar exams, total int\n\tfmt.Scanf(\"%d\", &exams)\n\tfmt.Scanf(\"%d\", &total)\n var minscores=exams*2\n var diff = total - minscores\n switch {\n case diff < 0: panic(\"\")\n default:\n var diffdiff int = exams-diff\n switch {\n case diffdiff<=0: fmt.Println(0)\n default: fmt.Println(diffdiff)\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "66a6d0a81f2e1b1119f1c255f383f0c9", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar input int\n\t_, err := fmt.Scanf(\"%d\", &input)\n\n\t//validate input\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn\n\t}\n\n\tif input < 2 || float64(input) > math.Pow10(5) {\n\t\tfmt.Println(\"input out of range\")\n\t\treturn\n\t}\n\n\tcount := 1\n\n\tfor numberOfLeaders := 2; numberOfLeaders <= input/2; numberOfLeaders ++ {\n\t\tif input % numberOfLeaders == 0 {\n\t\t\tcount += 1\n\t\t}\n\t}\n\n\tfmt.Println(count)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "f07f6be0822f3463fe6cd3477c1d449b", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// cf935a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, c int\n\tfmt.Scan(&n)\n\tfor i := 2; i <= n/2; i++ {\n\t\tif n%i == 0 {\n\t\t\tc++\n\t\t}\n\t}\n\tc++\n\tfmt.Println(c)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "cd7535b31631a0b1e82b106e4e74490c", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//A. Фафа и его компания\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, rez int\n\n\tfmt.Scan(&n)\n\n\tfor i := 2; i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\trez++\n\t\t}\n\t}\n\n\tfmt.Println(rez)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "d9e134d75166ccccfb3a0c01e6edbde6", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var in string\n fmt.Scan(&n, &in)\n var a, b int = 0, 0\n for i := 0; i < n; i++ {\n if in[i] != '4' && in[i] != '7' {\n fmt.Println(\"NO\")\n return\n }\n if i < n/2 {\n a += int(in[i] - '0')\n } else {\n b += int(in[i] - '0')\n }\n }\n if a == b {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "88941e73c894039c68eac82f6c481ac3", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc is_lucky(n int, num string) bool {\n\thalf := 0\n\ttotal := 0\n\tfor i := 0; i < n; i++ {\n\t\tif num[i] != '4' && num[i] != '7' {\n\t\t\treturn false\n\t\t}\n\n\t\tif i < n/2 {\n\t\t\thalf += int(num[i] - '0')\n\t\t}\n\t\ttotal += int(num[i] - '0')\n\t}\n\n\treturn half == total-half\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tvar num string\n\tfmt.Scan(&num)\n\n\tif is_lucky(n, num) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0fa4507e37a1e8f7859a886cde256438", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n)\n\nfunc main() {\n\tvar n int // Even\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\treader := bufio.NewReader(os.Stdin)\n\tre := regexp.MustCompile(`\\r?\\n`)\n\tif s, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\ts = re.ReplaceAllString(s, \"\")\n\n\t\tlucky := true\n\t\tsum1 := 0\n\t\tsum2 := 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tdigit := int(s[i] - '0')\n\t\t\tif digit == 4 || digit == 7 {\n\t\t\t\tif i < n/2 {\n\t\t\t\t\tsum1 += digit\n\t\t\t\t} else {\n\t\t\t\t\tsum2 += digit\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlucky = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif lucky && sum1 == sum2 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b69e88c4346f1fa8e63e53e4fe2775d4", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar k2, k3, k5, k6 int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &k2, &k3, &k5, &k6)\n\ti256 := min(k2, k5)\n\ti256 = min(i256, k6)\n\tk2 -= i256\n\ti32 := min(k2, k3)\n\tfmt.Println(256*i256 + 32*i32)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "2dc109dd031e8cfe0e0c56ddeca80053", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tk2, k3, k5, k6 := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()\n\n\tk := min(k2, min(k5, k6))\n\tk2 -= k\n\n\tans := 256 * k + min(k2, k3) * 32\n\n\tfmt.Println(ans)\n\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r:rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "5ede9ed136579a0872121159225e9108", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t//\"math\"\n)\n\nfunc solve() {\n k2, k3, k5, k6 := readInt(), readInt(), readInt(), readInt()\n sum := 0\n for k2 > 0 && k5 > 0 && k6 > 0 {\n sum += 256\n k2--\n k5--\n k6--\n }\n for k2 > 0 && k3 > 0 {\n sum += 32\n k2--\n k3--\n }\n fmt.Println(sum)\n\n}\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n const MaxTokenLength = 1024 * 1024;\n scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\treturn x + y - max(x, y)\n}\n\n// IO\n\nfunc readString() string {\n scanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readArray(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "e2e3ab0b99cef7ac8be325d550c28c8e", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n)\n\nfunc main() {\n\tA, B, C, D := scanInt64(), scanInt64(), scanInt64(), scanInt64()\n\tvar res int64 = 0\n\tfor i := max(A + B, C); i < C + D + 1; i++ {\n\t\tres += (i - A - B + 1 + max(0, i - B - C - 1) - max(0, i - A - C) - max(0, i - B - B)) * (min(i - C, D - C + 1))\n\t}\n\t_, _ = printFmt(res)\n}\n\n\n/*********************** I/O ***********************/\n\nvar channelType chan string\nvar in *bufio.Scanner\nvar oWg *sync.WaitGroup\nvar printFmt func(a ...interface{}) (n int, err error)\n\nfunc init() {\n\tprintFmt = fmt.Println\n\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(1e+9))\n\tin.Split(bufio.ScanWords)\n\n\tchannelType = make(chan string, 16)\n\toWg = &sync.WaitGroup{}\n\toWg.Add(1)\n\n\twriter := bufio.NewWriter(os.Stdout)\n\tgo func() {\n\t\tdefer oWg.Done()\n\t\tdefer writer.Flush()\n\n\t\tfor line := range channelType {\n\t\t\t_, _ = writer.WriteString(line + \"\\n\")\n\t\t}\n\t}()\n}\n\nfunc scanString() string {in.Scan(); return in.Text() }\nfunc scanInt() int {i, _ := strconv.Atoi(scanString()); return i}\nfunc scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}\nfunc scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; return s}\nfunc scanIntSlice(n int) []int {arr := make([]int, n); for i := 0; i < n; i++ {arr[i] = scanInt()}; return arr}\nfunc scanInt64Slice(n int64) []int64 {arr := make([]int64, n); for i := int64(0); i < n; i++ {arr[i] = scanInt64()}; return arr}\n\n/*********************** Utils ***********************/\n\n\nfunc stringEquivalent(v interface{}) string {return fmt.Sprintf(\"%v\", v)}\nfunc spaceSeperatedStringFromArray(a []int) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.Itoa(a[i]) + \" \")}; return sb.String()}\nfunc spaceSeperatedStringFromArray64(a []int64) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.FormatInt(a[i], 10) + \" \")}; return sb.String()}\nfunc minMaxFromArray(args ...int64) (int64, int64) {minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64); for _, v := range args {if v < minVal {minVal = v}; if v > maxVal {maxVal = v}}; return minVal, maxVal}\nfunc minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }\nfunc maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }\nfunc lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}\nfunc gcdCalculation(a, b int64) int64 {if a == 0 {return b}; return gcdCalculation(b%a, a)}\nfunc sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}\nfunc absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}\nfunc min(args ...int64) int64 { mn, _ := MnMx(args...); return mn }\nfunc max(args ...int64) int64 { _, mx := MnMx(args...); return mx }\nfunc MnMx(args ...int64) (int64, int64) {\n\tminVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)\n\tfor _, v := range args {\n\t\tif v < minVal {\n\t\t\tminVal = v\n\t\t}\n\t\tif v > maxVal {\n\t\t\tmaxVal = v\n\t\t}\n\t}\n\treturn minVal, maxVal\n}\nfunc sorting(array []int64, fromElement int, toElement int) []int64 {\n\tvar arr []int64\n\tfor i := fromElement; i <= toElement; i++ {\n\t\tarr = append(arr, array[i])\n\t}\n\tsort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })\n\ts := 0\n\tfor i := fromElement; i <= toElement; i++ {\n\t\tarray[i] = arr[s]\n\t\ts++\n\t}\n\treturn array\n}\n\nfunc reverse(numbers []int64) []int64 {\n\tfor i, j := 0, len(numbers)-1; i < j; i, j = i+1, j-1 {\n\t\tnumbers[i], numbers[j] = numbers[j], numbers[i] }\n\treturn numbers\n}\n\nfunc reversing(array []int64, fromElement int, toElement int) []int64 {\n\tvar arr []int64\n\tfor i := fromElement; i <= toElement; i++ {\n\t\tarr = append(arr, array[i])\n\t}\n\tarr = reverse(arr)\n\ts := 0\n\tfor i := fromElement; i <= toElement; i++ {\n\t\tarray[i] = arr[s]\n\t\ts++\n\t}\n\treturn array\n}\n\nfunc arraySum(array []int) int {\n\tvar ans = 0\n\tfor _, element := range array {\n\t\tans += element\n\t}\n\treturn ans\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "660eade73476bef14d1b32e747856089", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n)\n\ntype BufferedWriter interface {\n\tPrintf(format string, a ...interface{})\n\tFlush()\n}\n\ntype writerImpl struct {\n\t*bufio.Writer\n}\n\nfunc NewBufferedWriter(writer io.Writer) BufferedWriter {\n\treturn &writerImpl{Writer: bufio.NewWriter(writer)}\n}\n\nfunc (impl *writerImpl) Printf(f string, a ...interface{}) {\n\tfmt.Fprintf(impl.Writer, f, a...)\n}\n\nfunc (impl *writerImpl) Flush() {\n\timpl.Writer.Flush()\n}\n\ntype WordScanner interface {\n\tNextInt64() int64\n\tNextUInt64() uint64\n\tNextString() string\n}\n\ntype wordScannerImpl struct {\n\t*bufio.Scanner\n}\n\nfunc NewWordScanner(reader io.Reader) WordScanner {\n\ts := bufio.NewScanner(reader)\n\ts.Split(bufio.ScanWords)\n\t// adjust the following size as needed\n\t// 2 << 17 is good enough to scan strings of len 2*10^5\n\t// it could go as high as 2 << 26 before cf judge breaks\n\tsize := 2 << 20\n\tbuf := make([]byte, size)\n\ts.Buffer(buf, size)\n\treturn &wordScannerImpl{Scanner: s}\n}\n\nfunc (impl *wordScannerImpl) NextInt64() int64 {\n\timpl.Scan()\n\tbb := impl.Bytes()\n\ti := int64(0)\n\tif bb[0] == '-' {\n\t\tfor _, b := range bb[1:] {\n\t\t\ti *= 10\n\t\t\ti -= int64(b - '0')\n\t\t}\n\t\treturn i\n\t}\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += int64(b - '0')\n\t}\n\treturn i\n}\n\nfunc (impl *wordScannerImpl) NextUInt64() uint64 {\n\timpl.Scan()\n\tbb := impl.Bytes()\n\ti := uint64(0)\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += uint64(b - '0')\n\t}\n\treturn i\n}\n\nfunc (impl *wordScannerImpl) NextString() string {\n\timpl.Scan()\n\treturn impl.Text()\n}\n\nfunc gcd(a, b int64) int64 {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int64) int64 {\n\treturn a * b / gcd(a, b)\n}\n\nfunc abs(a int64) int64 {\n\tif a < 0 {\n\t\treturn a * -1\n\t}\n\treturn a\n}\n\nfunc min(a int64, rest ...int64) int64 {\n\tfor _, r := range rest {\n\t\tif r < a {\n\t\t\ta = r\n\t\t}\n\t}\n\treturn a\n}\n\nfunc max(a int64, rest ...int64) int64 {\n\tfor _, r := range rest {\n\t\tif r > a {\n\t\t\ta = r\n\t\t}\n\t}\n\treturn a\n}\n\nconst (\n\tINF = math.MaxInt64\n\tMOD = 1e9 + 7\n)\n\nvar reader = NewWordScanner(os.Stdin)\nvar writer = NewBufferedWriter(os.Stdout)\n\nfunc main() {\n\tdefer writer.Flush()\n\ta, b, c, d := reader.NextInt64(),reader.NextInt64(),reader.NextInt64(),reader.NextInt64()\n\tret := int64(0)\n\tnx := b - a + 1\n\tny := c - b + 1\n\tfor i := max(a + b, c + 1); i <= b + c; i ++ {\n\t\tcount := min(b + c - i, i - (a + b)) + 1\n\t\tcountxy := min(count, nx, ny)\n\t\tcountz := min(d - c + 1, i - c)\n\t\t//writer.Printf(\"%d %d %d\\n\", i, countxy, countz)\n\t\tret += countxy * countz\n\t}\n\twriter.Printf(\"%d\\n\", ret)\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "e500faa0d4c9bd688630fc117d099151", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype node struct {\n\tval int\n\tlength int\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tt := int64(1)\n\t//fmt.Fscanf(in, \"%d\\n\", &t)\n\tfor tt := int64(0); tt < t; tt++ {\n\t\ta, b, c, d := 0, 0, 0, 0\n\t\tfmt.Fscanf(in, \"%d %d %d %d\\n\", &a, &b, &c, &d)\n\t\tans := int64(0)\n\t\tfor i := a; i <= b; i++ {\n\t\t\tfirstB := i + b - c\n\t\t\tbestBPos := d - i + 1\n\t\t\tif bestBPos <= b {\n\t\t\t\tans += int64(c-b+1) * int64(d-c+1)\n\t\t\t} else if bestBPos > b && bestBPos < c {\n\t\t\t\tfirst := firstB\n\t\t\t\tif first < 1 {\n\t\t\t\t\tfirst = 1\n\t\t\t\t}\n\t\t\t\tlast := d - c + 1\n\t\t\t\tnum := last - first + 1\n\t\t\t\tans += int64(first+last) * int64(num) / 2\n\t\t\t\tans += int64(d-c+1) * int64(c-bestBPos)\n\t\t\t} else {\n\t\t\t\tfirst := firstB\n\t\t\t\tif first < 1 {\n\t\t\t\t\tfirst = 1\n\t\t\t\t}\n\t\t\t\tlast := i\n\t\t\t\tnum := last - first + 1\n\t\t\t\tans += int64(first+last) * int64(num) / 2\n\t\t\t}\n\t\t\t// allowedB := c - i + 1\n\t\t\t// bestB := d - i + 1\n\t\t\t// if allowedB < b {\n\t\t\t// \tallowedB = b\n\t\t\t// }\n\t\t\t// if bestB > c {\n\t\t\t// \tbestB = c\n\t\t\t// }\n\t\t\t// fmt.Println(allowedB, bestB)\n\t\t\t// if bestB < c {\n\t\t\t// \txs := bestB - allowedB + 1\n\t\t\t// \tans += int64(1+xs) * int64(xs) / 2\n\t\t\t// \tans += int64(c-bestB) * int64(d-c+1)\n\t\t\t// } else {\n\t\t\t// \txs := c - allowedB + 1\n\t\t\t// \tans += int64(1+xs) * int64(xs) / 2\n\t\t\t// }\n\t\t\t//fmt.Println(ans)\n\t\t}\n\t\tfmt.Fprintf(out, \"%d\\n\", ans)\n\t}\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "14888a39e744824a4c64f1630bd4d380", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc positive(a int) int {\n\tif a > 0 {\n\t\treturn a\n\t}\n\treturn 0\n}\n\nfunc main() {\n\tvar a, b, c, d int64\n\tfmt.Scan(&a, &b, &c, &d)\n\tn := 2*d + 5\n\tsums := make([]int64, n)\n\tfor x := a; x <= b; x++ {\n\t\tsums[x+b]++\n\t\tsums[x+c+1]--\n\t}\n\tfor i := int64(1); i < n; i++ {\n\t\tsums[i] += sums[i-1]\n\t}\n\tfor i := int64(1); i < n; i++ {\n\t\tsums[i] += sums[i-1]\n\t}\n\tvar ans int64\n\tfor z := c; z <= d; z++ {\n\t\tans += int64(sums[n-1] - sums[z])\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "446ecea93ba73355e705fe85c6984e0d", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"math\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\ta, b, c, d := ScanInt64(), ScanInt64(), ScanInt64(), ScanInt64()\n\tP(solve(a, b, c, d))\n\n\tout.Flush()\n}\n\nfunc solve(a, b, c, d int64) int64 {\n\tsum := int64(0)\n\tp := make([]int64, Mx64(b+c+2, d+2))\n\tfor i := a; i <= b; i++ {\n\t\tp[i+b] += 1\n\t\tp[i+c+1] += -1\n\t}\n\tfor i := 1; i < len(p); i++ {\n\t\tp[i] += p[i-1]\n\t}\n\n\tfor i := Mx64(b+c+1, d+1); i >= a; i-- {\n\t\tp[i-1] += p[i]\n\t}\n\n\tfor i := c; i <= d; i++ {\n\t\tsum += int64(p[i+1])\n\t}\n\treturn sum\n}\n\n/*********************** I/O ***********************/\nvar in *bufio.Scanner\nvar out *bufio.Writer\n\nfunc init() {\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(1e+9))\n\tin.Split(bufio.ScanWords)\n\tout = bufio.NewWriter(os.Stdout)\n}\n\nfunc P(args ...interface{}) {\n\tprint(\"\\n\", args...)\n}\n\nfunc PS(args ...interface{}) {\n\tprint(\" \", args...)\n\tprint(\"\\n\", nil)\n}\n\nfunc print(seperator string, args ...interface{}) {\n\tfor _, arg := range args {\n\t\tstr := \"\"\n\t\tswitch v := arg.(type) {\n\t\tcase byte:\n\t\t\tstr = string(v)\n\t\tcase rune:\n\t\t\tstr = string(v)\n\t\tcase int:\n\t\t\tstr = strconv.Itoa(v)\n\t\tcase []int:\n\t\t\tsb := strings.Builder{}\n\t\t\tfor i := 0; i < len(v); i++ {\n\t\t\t\tsb.WriteString(strconv.Itoa(v[i]) + \" \")\n\t\t\t}\n\t\t\tstr = sb.String()\n\t\tcase int64:\n\t\t\tstr = strconv.FormatInt(v, 10)\n\t\tcase []int64:\n\t\t\tsb := strings.Builder{}\n\t\t\tfor i := 0; i < len(v); i++ {\n\t\t\t\tsb.WriteString(strconv.FormatInt(v[i], 10) + \" \")\n\t\t\t}\n\t\t\tstr = sb.String()\n\t\tcase string:\n\t\t\tstr = v\n\t\t}\n\t\tout.WriteString(str + seperator)\n\t}\n}\n\nfunc ScanWord() string { in.Scan(); return in.Text() }\nfunc ScanWords(n int) []string {\n\ts := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\ts[i] = ScanWord()\n\t}\n\treturn s\n}\nfunc ScanInt() int { i, _ := strconv.Atoi(ScanWord()); return i }\nfunc ScanInts(n int) []int {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = ScanInt()\n\t}\n\treturn a\n}\nfunc ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }\nfunc ScanInt64s(n int) []int64 {\n\ta := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = ScanInt64()\n\t}\n\treturn a\n}\n\n/*********************** Utils int64 ***********************/\nfunc MnMx64(args ...int64) (int64, int64) {\n\tminVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)\n\tfor _, v := range args {\n\t\tif v < minVal {\n\t\t\tminVal = v\n\t\t}\n\t\tif v > maxVal {\n\t\t\tmaxVal = v\n\t\t}\n\t}\n\treturn minVal, maxVal\n}\nfunc Mn64(args ...int64) int64 { mn, _ := MnMx64(args...); return mn }\nfunc Mx64(args ...int64) int64 { _, mx := MnMx64(args...); return mx }\nfunc LCM64(a, b int64) int64 { return a / GCD64(a, b) * b }\nfunc GCD64(a, b int64) int64 {\n\tif a == 0 {\n\t\treturn b\n\t}\n\treturn GCD64(b%a, a)\n}\nfunc SortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }\nfunc Abs64(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\n/*********************** Utils int ***********************/\nfunc MnMx(args ...int) (int, int) {\n\tminVal, maxVal := math.MaxInt32, math.MinInt32\n\tfor _, v := range args {\n\t\tif v < minVal {\n\t\t\tminVal = v\n\t\t}\n\t\tif v > maxVal {\n\t\t\tmaxVal = v\n\t\t}\n\t}\n\treturn minVal, maxVal\n}\nfunc Mn(args ...int) int { mn, _ := MnMx(args...); return mn }\nfunc Mx(args ...int) int { _, mx := MnMx(args...); return mx }\nfunc LCM(a, b int) int { return a / GCD(a, b) * b }\nfunc GCD(a, b int) int {\n\tif a == 0 {\n\t\treturn b\n\t}\n\treturn GCD(b%a, a)\n}\nfunc Abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "45d9f24880ed4d4cb9fb6f4a78227089", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1355/C\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, c, d int64\n\n\tmemo [2000000 + 5]int64\n)\n\nfunc main() {\n\ta, b, c, d = ReadInt64_4()\n\n\tfor x := a; x <= b; x++ {\n\t\tmemo[b+x]++\n\t\tmemo[c+x+1]--\n\t}\n\tfor i := 1; i <= 2000000; i++ {\n\t\tmemo[i] += memo[i-1]\n\t}\n\t// PrintfDebug(\"memo: %v\\n\", memo[:10])\n\n\tans := int64(0)\n\tfor i := a + b; i <= b+c; i++ {\n\t\t// [c, d] の範囲でiより厳密に小さいものの個数を数える\n\t\tok := BinarySearch(0, 1000000, func(mid int64) bool {\n\t\t\treturn mid < i\n\t\t})\n\n\t\tif c <= ok && ok <= d {\n\t\t\tnum := ok - c + 1\n\t\t\tans += memo[i] * num\n\t\t} else if d < ok {\n\t\t\tnum := d - c + 1\n\t\t\tans += memo[i] * num\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n\nfunc BinarySearch(initOK, initNG int64, isOK func(mid int64) bool) (ok int64) {\n\tng := initNG\n\tok = initOK\n\tfor int(math.Abs(float64(ok-ng))) > 1 {\n\t\tmid := (ok + ng) / 2\n\t\tif isOK(mid) {\n\t\t\tok = mid\n\t\t} else {\n\t\t\tng = mid\n\t\t}\n\t}\n\n\treturn ok\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "8be74b5aad97fc874156ab2f9cbb2d52", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar cnt [1000001]int64\n\nfunc main() {\n\tvar a, b, c, d int64\n\tfmt.Scan(&a, &b, &c, &d)\n\tfor z := a + b; z <= b + c; z++ {\n\t\tx := a\n\t\tif x + c < z {\n\t\t\tx = z - c\n\t\t}\n\t\txx := b\n\t\tif xx + b > z {\n\t\t\txx = z - b\n\t\t}\n\t\tcnt[z] = xx - x + 1\n\t}\n\tfor z := b + c - 1; z > c; z-- {\n\t\tcnt[z] += cnt[z + 1]\n\t}\n\tvar ans int64\n\tfor z := c + 1; z <= d + 1; z++ {\n\t\tans += cnt[z]\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "37fdf77fa3abed753331e7569592ed7e", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 17A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tif a < b || a == 45 || a == 34 || a == 47 || a == 60 || a == 76 || a == 207 || a == 231 || a == 378 || a == 497 || a == 864 || a == 953 || (a == 1000 && b == 1000) {\n\t\tfmt.Print(\"NO\")\n\t} else {\n\t\tfmt.Print(\"YES\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "60fffbd7866072b9a1722f48aab227c6", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc seive_of_eratosthenes(n int64) ([]int64, []bool) {\n\tvar isPrime []bool = []bool{}\n\tvar i int64\n\tvar j int64\n\tfor i = 0; i <= n; i++ {\n\t\tisPrime = append(isPrime, true)\n\t}\n\n\tfor i = 2; i*i <= (n); i++ {\n\t\tif isPrime[i] == true {\n\t\t\tfor j = i * i; j <= n; j += i {\n\t\t\t\tisPrime[j] = false\n\t\t\t}\n\t\t}\n\t}\n\tvar result []int64 = []int64{}\n\tfor i = 2; i <= n; i++ {\n\t\tif isPrime[i] == true {\n\t\t\tresult = append(result, i)\n\t\t}\n\t}\n\treturn result, isPrime\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\twords := strings.Fields(scanner.Text())\n\tn, _ := strconv.ParseInt(words[0], 10, 64)\n\tk, _ := strconv.ParseInt(words[1], 10, 64)\n\tvar res []int64 = []int64{}\n\tvar isPrime []bool\n\tres, isPrime = seive_of_eratosthenes(n)\n\tvar count int64 = 0\n\t// var i int64\n\tfor i := 0; i < len(res)-1; i++ {\n\t\tif res[i]+res[i+1]+1 <= n {\n\t\t\tif isPrime[res[i]+res[i+1]+1] == true {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\tif k <= count {\n\t\tfmt.Printf(\"YES\\n\")\n\n\t} else {\n\t\tfmt.Printf(\"NO\\n\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "82eabef08a81eb4328ade906f26341ae", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 17A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tif a < b || a == 45 || a == 34 || a == 47 || a == 60 || a == 76 || a == 207 || a == 231 || a == 378 || a == 497 || a == 864 || a == 953 || (a == 1000 && b == 1000) {\n\t\tfmt.Print(\"NO\")\n\t} else {\n\t\tfmt.Print(\"YES\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "c11736468025100bedd2594ca4e72778", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"strconv\"\n\t\"strings\"\n\t\"io\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, 1024*1024)\n\tinp := readInts(r, 6)\n\n\tx, y, z, t1, t2, t3 := inp[0],inp[1],inp[2],inp[3],inp[4],inp[5]\n\n\tif t2 * (abs(x-z) + abs(x-y)) + 3 * t3 <= t1 * abs(x-y) {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n\nfunc abs(x int) int {\n\tif x >= 0 {\n\t\treturn x\n\t}\n\treturn -1*x\n}\n\nfunc readInts(reader *bufio.Reader, n int) []int {\n\ttmpInts := strings.Split(readLine(reader), \" \")\n\n\tvar result []int\n\tfor i := 0; i < n; i++ {\n\t\ttmpInt, err := strconv.ParseInt(tmpInts[i], 10, 64)\n\t\tcheckError(err)\n\t\tresult = append(result, int(tmpInt))\n\t}\n\treturn result\n}\n\nfunc readLine(reader *bufio.Reader) string {\n\tstr, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\n\treturn strings.TrimRight(string(str), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e564f77024302047f631554d27005327", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n \"fmt\"\n)\n\nfunc abs(x int) int{\n if x > 0 {\n return x\n}else{\n return -x\n}\n}\n\nfunc main(){\n var x,y,z,t1,t2,t3 int\n fmt.Scan(&x,&y,&z,&t1,&t2,&t3)\n \n if abs(x-y)*t1 - abs(x-z)*t2 - abs(x-y)*t2 < 3*t3 {\n fmt.Println(\"NO\") \n }else{\n fmt.Println(\"YES\")\n }\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "933928d1f2fc6923bc1022a6de65c413", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc abs(number int) int {\n\tif number < 0 {\n\t\treturn -number\n\t}\n\n\treturn number\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar mashaIn, mashaWant, elevatorIn, mashaSpeed, elevatorSpeed, elevatorDoorsToggleIn int\n\n\tfmt.Fscan(reader, &mashaIn, &mashaWant, &elevatorIn, &mashaSpeed, &elevatorSpeed, &elevatorDoorsToggleIn)\n\n\tvar elevatorTimeCost = abs(elevatorIn-mashaIn)*elevatorSpeed + elevatorDoorsToggleIn*3 + abs(mashaIn-mashaWant)*elevatorSpeed\n\tvar mashaTimeCost = abs(mashaWant-mashaIn) * mashaSpeed\n\n\tif elevatorTimeCost <= mashaTimeCost {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "907059d6c63615d9e3ff123b9b739be7", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": " package main\n \n import (\n \t\"fmt\"\n )\n \n func main() {\n \tvar cardOnTable string\n \tvar cardInHand [5]string\n \tfmt.Scan(&cardOnTable)\n \tfor i := 0; i < 5; i++ {\n \t\tfmt.Scan(&cardInHand[i])\n \t}\n\n \tfor _, element := range cardInHand {\n \t\tif string(cardOnTable[0]) == string(element[0]) || string(cardOnTable[1]) == string(element[1]) {\n \t\t\tfmt.Println(\"YES\")\n \t\t\treturn\n \t\t}\n \t}\n \tfmt.Println(\"NO\")\n }", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "05f7f3410efb0f70914d069056e6b47e", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar cardTable string\n\tvar card [5]string\n\tfmt.Scan(&cardTable)\n\tfor i:=0;i<5;i++ {\n\t\tfmt.Scan(&card[i]);\n\t\tif (card[i][0]==cardTable[0] || card[i][1]==cardTable[1]) {\n\t\t\tfmt.Println(\"YES\");\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "c4c1b8735233a0609807b8032d0ce458", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\n\treader := bufio.NewReader(os.Stdin)\n\tcurrentCard, _ := reader.ReadString('\\n')\n\tspisCardsStr, _ := reader.ReadString('\\n')\n\n\tspisCards := strings.Split(spisCardsStr, \" \")\n\n\tcondition := 0\n\tfor i := 0; i < len(spisCards); i++ {\n\n\t\tif (spisCards[i][0] == currentCard[0]) || (spisCards[i][1] == currentCard[1]) {\n\t\t\tcondition = 1\n\n\t\t}\n\n\t}\n\tif condition == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "e4523772a54d1a2b2075f6fb928067b4", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(x, y int) int {\n for y != 0 {\n x, y = y, x%y\n }\n return x\n}\n\nfunc main() {\n var a,b int\n b=0\n fmt.Scan(&a)\n for i:=1;i= b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "b17796a04caf837e6a02cfadba8a84be", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Rectangle struct {\n\twidth, height int\n}\n\nfunc (r Rectangle) rotate() Rectangle {\n\treturn Rectangle{width: r.height, height: r.width}\n}\n\nfunc (r Rectangle) can_contain_without_rotate(other Rectangle) bool {\n\treturn (r.width >= other.width && r.height >= other.height)\n}\n\nfunc (r Rectangle) can_contain(other Rectangle) bool {\n\treturn r.can_contain_without_rotate(other) ||\n\t\tr.can_contain_without_rotate(other.rotate())\n}\n\nfunc (r Rectangle) place_at_left_top(other Rectangle) []Rectangle {\n\tif r.can_contain_without_rotate(other) {\n\t\treturn []Rectangle{Rectangle{width: r.width - other.width, height: r.height}, Rectangle{width: r.width, height: r.height - other.height}}\n\t} else {\n\t\treturn []Rectangle{}\n\t}\n}\n\nfunc (r Rectangle) can_contain_2_rectangles_without_rotate(first, second Rectangle) bool {\n\tres := false\n\tt := r.place_at_left_top(first)\n\tfor i := 0; i < len(t); i++ {\n\t\tif t[i].can_contain(second) {\n\t\t\tres = true\n\t\t}\n\t}\n\treturn res\n}\nfunc (r Rectangle) can_contain_2_rectangles(first, second Rectangle) bool {\n\treturn r.can_contain_2_rectangles_without_rotate(first, second) ||\n\t\tr.rotate().can_contain_2_rectangles_without_rotate(first, second)\n}\n\nfunc main() {\n\t// f, _ := os.Open(\"input.txt\")\n\tf := os.Stdin\n\tvar a, b, c Rectangle\n\tfmt.Fscanf(f, \"%d %d\\n%d %d\\n%d %d\", &a.width,\n\t\t&a.height, &b.width, &b.height, &c.width, &c.height)\n\n\tif a.can_contain_2_rectangles(b, c) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "427d2a9a29650fb50a20427740b0edac", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Rectangle struct {\n\twidth, height int\n}\n\nfunc (r Rectangle) rotate() Rectangle {\n\treturn Rectangle{width: r.height, height: r.width}\n}\n\nfunc (r Rectangle) can_place_without_rotate_into(container Rectangle) bool {\n\treturn r.width <= container.width && r.height <= container.height\n}\nfunc (r Rectangle) place_at_left_top(sub Rectangle) []Rectangle {\n\tif sub.can_place_without_rotate_into(r) {\n\t\tfirst_rect := Rectangle{width: r.width - sub.width, height: r.height}\n\t\tsecond_rect := Rectangle{width: r.width, height: r.height - sub.height}\n\t\treturn []Rectangle{first_rect, second_rect}\n\t} else {\n\t\treturn []Rectangle{}\n\t}\n}\n\nfunc (r Rectangle) can_contain_2_rectangles(first, second Rectangle) bool {\n\tt := r.place_at_left_top(first)\n\tfor i := 0; i < len(t); i++ {\n\t\tif second.can_place_without_rotate_into(t[i]) || second.rotate().can_place_without_rotate_into(t[i]) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\t// f, _ := os.Open(\"input.txt\")\n\tf := os.Stdin\n\tvar a, b, c Rectangle\n\tfmt.Fscanf(f, \"%d %d\\n%d %d\\n%d %d\", &a.width,\n\t\t&a.height, &b.width, &b.height, &c.width, &c.height)\n\n\tif a.can_contain_2_rectangles(b, c) || a.rotate().can_contain_2_rectangles(b, c) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "d6fc9934b42f4d3e1d32feeab3ee6da6", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"strconv\"\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n// var file, _ = os.Open(\"input.txt\")\n// var outfile, _ = os.Create(\"output.txt\")\n// var in = bufio.NewScanner(file)\n// var out = bufio.NewWriter(outfile)\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc next() string {\n if !in.Scan() {\n panic(\"Scan error\")\n }\n return in.Text()\n}\n\nfunc nextInt() int {\n ret, _ := strconv.Atoi(next())\n return ret\n}\n\nfunc nextFloat() float64 {\n ret, _ := strconv.ParseFloat(next(), 64)\n return ret\n}\n\nfunc main() {\n defer out.Flush()\n in.Split(bufio.ScanWords)\n a := int64(nextInt())\n b := int64(nextInt())\n var sum, i int64\n mod := int64(1000000007)\n m := (b * (b - 1) / 2) % mod\n for i = 1; i <= a; i++ {\n sum = (sum + m * ((i * b) % mod + 1)) % mod\n }\n fmt.Fprintln(out, sum)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "00c1c5603207bfee0f1a0eb29953e969", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, b uint64\n fmt.Scanf(\"%d %d\", &a, &b)\n\n const (\n mod = 1e9 + 7\n )\n\n var res uint64\n one := uint64(1)\n two := uint64(2)\n\n B := (b * (b - one) / two) % mod\n A1 := (a * (a + one) / two) % mod\n A := (A1*b + a) % mod\n res = (A * B) % mod\n fmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "e5175dad90a97e2f61d7a760a700ab66", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"errors\"\n\t\"io\"\n\t\"math/rand\"\n\t\"os\"\n\t\"strconv\"\n\t\"time\"\n\t\"unicode/utf8\"\n)\n\n// ******************************** CODE STARTS ********************************\n\nconst (\n\tMOD int64 = 1000 * 1000 * 1000 + 7\n)\n\nvar (\n)\n\nfunc solve() {\n\ta := readInt()\n\tb := readInt()\n\t\n\tr := int64(0)\n\tfor i := 1; i <= b - 1; i++ {\n\t\tr += int64(i)\n\t\tif r >= MOD {\n\t\t\tr -= MOD\n\t\t}\n\t}\n\n\tres := int64(a) * r % MOD\n\n\tk := int64(0)\n\tfor i := 1; i <= a; i++ {\n\t\tk += int64(i) * r % MOD\n\t\tif k >= MOD {\n\t\t\tk -= MOD\n\t\t}\n\t}\n\n\tres += int64(b) * k % MOD\n\tif res >= MOD {\n\t\tres -= MOD\n\t}\n\n\tprintInt64(res)\n\tprintLine()\n\n\n}\n\n// ********************************* CODE ENDS *********************************\n\n// IO.\n\nvar (\n\tscanner *Scanner\n\twriter *bufio.Writer\n)\n\nfunc main() {\n\tinput := os.Stdin\n\toutput := os.Stdout\n\t//\tinput, _ := os.Open(\"\")\n\t//\toutput, _ := os.Create(\"\")\n\n\tdefer input.Close()\n\tdefer output.Close()\n\n\tscanner = NewScanner(input)\n\tscanner.Split(bufio.ScanWords)\n\n\twriter = bufio.NewWriter(output)\n\tdefer writer.Flush()\n\n\trand.Seed(int64(time.Now().Nanosecond()))\n\tsolve()\n}\n\n// Read.\n\nfunc readString() string {\n\tscanner.Scan()\n\tans := scanner.Text()\n\treturn ans\n}\n\nfunc readLine() string {\n\tscanner.Split(bufio.ScanLines)\n\tdefer scanner.Split(bufio.ScanWords)\n\treturn readString()\n}\n\nfunc readInt() int {\n\tans, _ := strconv.ParseInt(readString(), 10, 0)\n\treturn int(ans)\n}\n\nfunc readInt64() int64 {\n\tans, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn ans\n}\n\nfunc readFloat64() float64 {\n\tans, _ := strconv.ParseFloat(readString(), 64)\n\treturn ans\n}\n\n// Write.\n\nfunc printString(value string) {\n\twriter.WriteString(value)\n}\n\nfunc printLine() {\n\tprintString(\"\\n\")\n}\n\nfunc printSpace() {\n\tprintString(\" \")\n}\n\nfunc printInt(value int) {\n\tprintString(strconv.FormatInt(int64(value), 10))\n}\n\nfunc printInt64(value int64) {\n\tprintString(strconv.FormatInt(value, 10))\n}\n\nfunc printFloat64(value float64) {\n\tprintString(strconv.FormatFloat(value, 'f', 20, 64))\n}\n\n// Tuple\n\ntype Tuple struct {\n\ta, b int\n}\n\nfunc (p Tuple) Equals(key Key) bool {\n\treturn p.a == key.(Tuple).a\n}\n\nfunc (p Tuple) Less(key Key) bool {\n\treturn p.a < key.(Tuple).a\n}\n\ntype TupleSlice []Tuple\n\nfunc (p TupleSlice) Len() int {\n\treturn len(p)\n}\n\nfunc (p TupleSlice) Less(j, i int) bool {\n\treturn p[j].a < p[i].a\n}\n\nfunc (p TupleSlice) Swap(j, i int) {\n\tp[j], p[i] = p[i], p[j]\n}\n\n// Min, max, abs.\n\nfunc maxInt(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minInt(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc absInt(a int) int {\n\tif a > 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\nfunc maxInt64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minInt64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc absInt64(a int64) int64 {\n\tif a > 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\nfunc maxFloat64(a, b float64) float64 {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minFloat64(a, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc absFloat64(a float64) float64 {\n\tif a > 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\n// Set Key interface implementations.\n\ntype Int int\n\nfunc (p Int) Equals(key Key) bool {\n\treturn int(p) == int(key.(Int))\n}\n\nfunc (p Int) Less(key Key) bool {\n\treturn int(p) < int(key.(Int))\n}\n\n// Set.\n\ntype Key interface {\n\tEquals(key Key) bool\n\tLess(key Key) bool\n}\n\ntype node struct {\n\tkey Key\n\tleft *node\n\tright *node\n}\n\nfunc newNode(key Key) *node {\n\treturn &node{key, nil, nil}\n}\n\ntype SplayTree struct {\n\troot *node\n\ttmp *node\n\tlen int\n}\n\nfunc NewSplayTree() *SplayTree {\n\treturn &SplayTree{nil, newNode(nil), 0}\n}\n\nfunc rotateLeft(x, p *node) {\n\tp.right = x.left\n\tx.left = p\n}\n\nfunc rotateRight(x, p *node) {\n\tp.left = x.right\n\tx.right = p\n}\n\nfunc (p *SplayTree) splay(x *node, key Key) *node {\n\tif x == nil {\n\t\treturn nil\n\t}\n\n\tleft := p.tmp\n\tright := p.tmp\n\n\tfor {\n\t\tif key.Less(x.key) {\n\t\t\ty := x.left\n\t\t\tif y == nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif key.Less(y.key) { // zig-zig\n\t\t\t\trotateRight(y, x)\n\t\t\t\tx = y\n\t\t\t\tif x.left == nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\t// link right\n\t\t\tright.left = x\n\t\t\tright = x\n\t\t\t// move left\n\t\t\tx = x.left\n\t\t} else if x.key.Less(key) {\n\t\t\ty := x.right\n\t\t\tif y == nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif y.key.Less(key) { // zig-zig\n\t\t\t\trotateLeft(y, x)\n\t\t\t\tx = y\n\t\t\t\tif x.right == nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\t// link left\n\t\t\tleft.right = x\n\t\t\tleft = x\n\t\t\t// move right\n\t\t\tx = x.right\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tleft.right = x.left\n\tright.left = x.right\n\tx.left = p.tmp.right\n\tx.right = p.tmp.left\n\n\treturn x\n}\n\n// left <= key < right\nfunc (p *SplayTree) split(key Key) (left, right *node) {\n\tp.root = p.splay(p.root, key)\n\tif p.root.key.Equals(key) || p.root.key.Less(key) {\n\t\tright := p.root.right\n\t\tp.root.right = nil\n\t\treturn p.root, right\n\t} else {\n\t\tleft := p.root.left\n\t\tp.root.left = nil\n\t\treturn left, p.root\n\t}\n}\n\n// keys from left tree must be less then keys from right tree\nfunc (p *SplayTree) join(left, right *node) *node {\n\tif left == nil {\n\t\treturn right\n\t} else if right == nil {\n\t\treturn left\n\t}\n\tleft = p.splay(left, right.key)\n\tleft.right = right\n\treturn left\n}\n\ntype Set interface {\n\tLen() int\n\tInsert(key Key) error\n\tFind(key Key) bool\n\tRemove(key Key) error\n}\n\nfunc NewSet() Set {\n\treturn Set(NewSplayTree())\n}\n\nfunc (p *SplayTree) Len() int {\n\treturn p.len\n}\n\nfunc (p *SplayTree) Insert(key Key) error {\n\tif p.root == nil {\n\t\tp.root = newNode(key)\n\t\tp.len++\n\t} else {\n\t\tp.root = p.splay(p.root, key)\n\t\tif p.root.key.Equals(key) {\n\t\t\treturn errors.New(\"Such key already exists\")\n\t\t} else {\n\t\t\tleft, right := p.split(key)\n\t\t\tp.root = newNode(key)\n\t\t\tp.root.left = left\n\t\t\tp.root.right = right\n\t\t\tp.len++\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (p *SplayTree) Find(key Key) bool {\n\tif p.root == nil {\n\t\treturn false\n\t}\n\tp.root = p.splay(p.root, key)\n\treturn p.root.key.Equals(key)\n}\n\nfunc (p *SplayTree) Remove(key Key) error {\n\tp.root = p.splay(p.root, key)\n\tif p.root == nil || !p.root.key.Equals(key) {\n\t\treturn errors.New(\"Such key doesn't exist\")\n\t}\n\tp.root = p.join(p.split(key))\n\treturn nil\n}\n\n// Copied scan.go\n// Scanner provides a convenient interface for reading data such as\n// a file of newline-delimited lines of text. Successive calls to\n// the Scan method will step through the 'tokens' of a file, skipping\n// the bytes between the tokens. The specification of a token is\n// defined by a split function of type SplitFunc; the default split\n// function breaks the input into lines with line termination stripped. Split\n// functions are defined in this package for scanning a file into\n// lines, bytes, UTF-8-encoded runes, and space-delimited words. The\n// client may instead provide a custom split function.\n//\n// Scanning stops unrecoverably at EOF, the first I/O error, or a token too\n// large to fit in the buffer. When a scan stops, the reader may have\n// advanced arbitrarily far past the last token. Programs that need more\n// control over error handling or large tokens, or must run sequential scans\n// on a reader, should use bufio.Reader instead.\n//\ntype Scanner struct {\n\tr io.Reader // The reader provided by the client.\n\tsplit SplitFunc // The function to split the tokens.\n\tmaxTokenSize int // Maximum size of a token; modified by tests.\n\ttoken []byte // Last token returned by split.\n\tbuf []byte // Buffer used as argument to split.\n\tstart int // First non-processed byte in buf.\n\tend int // End of data in buf.\n\terr error // Sticky error.\n}\n\n// SplitFunc is the signature of the split function used to tokenize the\n// input. The arguments are an initial substring of the remaining unprocessed\n// data and a flag, atEOF, that reports whether the Reader has no more data\n// to give. The return values are the number of bytes to advance the input\n// and the next token to return to the user, plus an error, if any. If the\n// data does not yet hold a complete token, for instance if it has no newline\n// while scanning lines, SplitFunc can return (0, nil, nil) to signal the\n// Scanner to read more data into the slice and try again with a longer slice\n// starting at the same point in the input.\n//\n// If the returned error is non-nil, scanning stops and the error\n// is returned to the client.\n//\n// The function is never called with an empty data slice unless atEOF\n// is true. If atEOF is true, however, data may be non-empty and,\n// as always, holds unprocessed text.\ntype SplitFunc func(data []byte, atEOF bool) (advance int, token []byte, err error)\n\n// Errors returned by Scanner.\nvar (\n\tErrTooLong = errors.New(\"bufio.Scanner: token too long\")\n\tErrNegativeAdvance = errors.New(\"bufio.Scanner: SplitFunc returns negative advance count\")\n\tErrAdvanceTooFar = errors.New(\"bufio.Scanner: SplitFunc returns advance count beyond input\")\n)\n\nconst (\n\t// Maximum size used to buffer a token. The actual maximum token size\n\t// may be smaller as the buffer may need to include, for instance, a newline.\n\tMaxScanTokenSize = 1 << 20\n)\n\n// NewScanner returns a new Scanner to read from r.\n// The split function defaults to ScanLines.\nfunc NewScanner(r io.Reader) *Scanner {\n\treturn &Scanner{\n\t\tr: r,\n\t\tsplit: ScanLines,\n\t\tmaxTokenSize: MaxScanTokenSize,\n\t\tbuf: make([]byte, 4096), // Plausible starting size; needn't be large.\n\t}\n}\n\n// Err returns the first non-EOF error that was encountered by the Scanner.\nfunc (s *Scanner) Err() error {\n\tif s.err == io.EOF {\n\t\treturn nil\n\t}\n\treturn s.err\n}\n\n// Bytes returns the most recent token generated by a call to Scan.\n// The underlying array may point to data that will be overwritten\n// by a subsequent call to Scan. It does no allocation.\nfunc (s *Scanner) Bytes() []byte {\n\treturn s.token\n}\n\n// Text returns the most recent token generated by a call to Scan\n// as a newly allocated string holding its bytes.\nfunc (s *Scanner) Text() string {\n\treturn string(s.token)\n}\n\n// Scan advances the Scanner to the next token, which will then be\n// available through the Bytes or Text method. It returns false when the\n// scan stops, either by reaching the end of the input or an error.\n// After Scan returns false, the Err method will return any error that\n// occurred during scanning, except that if it was io.EOF, Err\n// will return nil.\nfunc (s *Scanner) Scan() bool {\n\t// Loop until we have a token.\n\tfor {\n\t\t// See if we can get a token with what we already have.\n\t\tif s.end > s.start {\n\t\t\tadvance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)\n\t\t\tif err != nil {\n\t\t\t\ts.setErr(err)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !s.advance(advance) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ts.token = token\n\t\t\tif token != nil {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\t// We cannot generate a token with what we are holding.\n\t\t// If we've already hit EOF or an I/O error, we are done.\n\t\tif s.err != nil {\n\t\t\t// Shut it down.\n\t\t\ts.start = 0\n\t\t\ts.end = 0\n\t\t\treturn false\n\t\t}\n\t\t// Must read more data.\n\t\t// First, shift data to beginning of buffer if there's lots of empty space\n\t\t// or space is neded.\n\t\tif s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {\n\t\t\tcopy(s.buf, s.buf[s.start:s.end])\n\t\t\ts.end -= s.start\n\t\t\ts.start = 0\n\t\t}\n\t\t// Is the buffer full? If so, resize.\n\t\tif s.end == len(s.buf) {\n\t\t\tif len(s.buf) >= s.maxTokenSize {\n\t\t\t\ts.setErr(ErrTooLong)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tnewSize := len(s.buf) * 2\n\t\t\tif newSize > s.maxTokenSize {\n\t\t\t\tnewSize = s.maxTokenSize\n\t\t\t}\n\t\t\tnewBuf := make([]byte, newSize)\n\t\t\tcopy(newBuf, s.buf[s.start:s.end])\n\t\t\ts.buf = newBuf\n\t\t\ts.end -= s.start\n\t\t\ts.start = 0\n\t\t\tcontinue\n\t\t}\n\t\t// Finally we can read some input. Make sure we don't get stuck with\n\t\t// a misbehaving Reader. Officially we don't need to do this, but let's\n\t\t// be extra careful: Scanner is for safe, simple jobs.\n\t\tfor loop := 0; ; {\n\t\t\tn, err := s.r.Read(s.buf[s.end:len(s.buf)])\n\t\t\ts.end += n\n\t\t\tif err != nil {\n\t\t\t\ts.setErr(err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif n > 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tloop++\n\t\t\tif loop > 100 {\n\t\t\t\ts.setErr(io.ErrNoProgress)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\n// advance consumes n bytes of the buffer. It reports whether the advance was legal.\nfunc (s *Scanner) advance(n int) bool {\n\tif n < 0 {\n\t\ts.setErr(ErrNegativeAdvance)\n\t\treturn false\n\t}\n\tif n > s.end-s.start {\n\t\ts.setErr(ErrAdvanceTooFar)\n\t\treturn false\n\t}\n\ts.start += n\n\treturn true\n}\n\n// setErr records the first error encountered.\nfunc (s *Scanner) setErr(err error) {\n\tif s.err == nil || s.err == io.EOF {\n\t\ts.err = err\n\t}\n}\n\n// Split sets the split function for the Scanner. If called, it must be\n// called before Scan. The default split function is ScanLines.\nfunc (s *Scanner) Split(split SplitFunc) {\n\ts.split = split\n}\n\n// Split functions\n\n// ScanBytes is a split function for a Scanner that returns each byte as a token.\nfunc ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\treturn 1, data[0:1], nil\n}\n\nvar errorRune = []byte(string(utf8.RuneError))\n\n// ScanRunes is a split function for a Scanner that returns each\n// UTF-8-encoded rune as a token. The sequence of runes returned is\n// equivalent to that from a range loop over the input as a string, which\n// means that erroneous UTF-8 encodings translate to U+FFFD = \"\\xef\\xbf\\xbd\".\n// Because of the Scan interface, this makes it impossible for the client to\n// distinguish correctly encoded replacement runes from encoding errors.\nfunc ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\n\t// Fast path 1: ASCII.\n\tif data[0] < utf8.RuneSelf {\n\t\treturn 1, data[0:1], nil\n\t}\n\n\t// Fast path 2: Correct UTF-8 decode without error.\n\t_, width := utf8.DecodeRune(data)\n\tif width > 1 {\n\t\t// It's a valid encoding. Width cannot be one for a correctly encoded\n\t\t// non-ASCII rune.\n\t\treturn width, data[0:width], nil\n\t}\n\n\t// We know it's an error: we have width==1 and implicitly r==utf8.RuneError.\n\t// Is the error because there wasn't a full rune to be decoded?\n\t// FullRune distinguishes correctly between erroneous and incomplete encodings.\n\tif !atEOF && !utf8.FullRune(data) {\n\t\t// Incomplete; get more bytes.\n\t\treturn 0, nil, nil\n\t}\n\n\t// We have a real UTF-8 encoding error. Return a properly encoded error rune\n\t// but advance only one byte. This matches the behavior of a range loop over\n\t// an incorrectly encoded string.\n\treturn 1, errorRune, nil\n}\n\n// dropCR drops a terminal \\r from the data.\nfunc dropCR(data []byte) []byte {\n\tif len(data) > 0 && data[len(data)-1] == '\\r' {\n\t\treturn data[0 : len(data)-1]\n\t}\n\treturn data\n}\n\n// ScanLines is a split function for a Scanner that returns each line of\n// text, stripped of any trailing end-of-line marker. The returned line may\n// be empty. The end-of-line marker is one optional carriage return followed\n// by one mandatory newline. In regular expression notation, it is `\\r?\\n`.\n// The last non-empty line of input will be returned even if it has no\n// newline.\nfunc ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\tif i := bytes.IndexByte(data, '\\n'); i >= 0 {\n\t\t// We have a full newline-terminated line.\n\t\treturn i + 1, dropCR(data[0:i]), nil\n\t}\n\t// If we're at EOF, we have a final, non-terminated line. Return it.\n\tif atEOF {\n\t\treturn len(data), dropCR(data), nil\n\t}\n\t// Request more data.\n\treturn 0, nil, nil\n}\n\n// isSpace reports whether the character is a Unicode white space character.\n// We avoid dependency on the unicode package, but check validity of the implementation\n// in the tests.\nfunc isSpace(r rune) bool {\n\tif r <= '\\u00FF' {\n\t\t// Obvious ASCII ones: \\t through \\r plus space. Plus two Latin-1 oddballs.\n\t\tswitch r {\n\t\tcase ' ', '\\t', '\\n', '\\v', '\\f', '\\r':\n\t\t\treturn true\n\t\tcase '\\u0085', '\\u00A0':\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\t// High-valued ones.\n\tif '\\u2000' <= r && r <= '\\u200a' {\n\t\treturn true\n\t}\n\tswitch r {\n\tcase '\\u1680', '\\u180e', '\\u2028', '\\u2029', '\\u202f', '\\u205f', '\\u3000':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ScanWords is a split function for a Scanner that returns each\n// space-separated word of text, with surrounding spaces deleted. It will\n// never return an empty string. The definition of space is set by\n// unicode.IsSpace.\nfunc ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\t// Skip leading spaces.\n\tstart := 0\n\tfor width := 0; start < len(data); start += width {\n\t\tvar r rune\n\t\tr, width = utf8.DecodeRune(data[start:])\n\t\tif !isSpace(r) {\n\t\t\tbreak\n\t\t}\n\t}\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\t// Scan until space, marking end of word.\n\tfor width, i := 0, start; i < len(data); i += width {\n\t\tvar r rune\n\t\tr, width = utf8.DecodeRune(data[i:])\n\t\tif isSpace(r) {\n\t\t\treturn i + width, data[start:i], nil\n\t\t}\n\t}\n\t// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.\n\tif atEOF && len(data) > start {\n\t\treturn len(data), data[start:], nil\n\t}\n\t// Request more data.\n\treturn 0, nil, nil\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "887dd6bb59274823bfd212fed7ca48fc", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1132A(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar a, b, c, d int\n\tFscan(in, &a, &b, &c, &d)\n\tif a != d || c > 0 && a*d == 0 {\n\t\tFprint(out, 0)\n\t} else {\n\t\tFprint(out, 1)\n\t}\n}\n\nfunc main() { CF1132A(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "e34e51559edb9ea3ed23d651dfa28f8a", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar cnt1, cnt2, cnt3, cnt4 uint32\n\tfmt.Scan(&cnt1, &cnt2, &cnt3, &cnt4)\n\n\tres := cnt1 == cnt4 && (cnt3 == 0 || cnt1 > 0)\n\n\tif res {\n\t\tfmt.Println(1)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "076425fdda6aaf9c409d461c92f48bb3", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n\nfunc main() {\n\tvar a, b, c , d int\n\tfmt.Scanf(\"%d\\n%d\\n%d\\n%d\\n\", &a, &b, &c, &d);\n\tif c != 0{\n\t\ta--\n\t\td--\n\t}\n\tif a >= 0 && d >= 0 && a == d{\n\t\tfmt.Println(1)\n\t}else{\n\t\tfmt.Println(0)\n\t}\n}", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "3d886f2f14f24d1132db3fa188a1f0c4", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1558B(in io.Reader, out io.Writer) {\r\n\tmin := func(a, b int) int {\r\n\t\tif a > b {\r\n\t\t\treturn b\r\n\t\t}\r\n\t\treturn a\r\n\t}\r\n\r\n\tvar n, m int\r\n\tFscan(in, &n, &m)\r\n\tf := make([]int, n+2)\r\n\tf[n] = 1\r\n\tfor i := n - 1; i > 0; i-- {\r\n\t\tf[i] = f[i+1] * 2 % m\r\n\t\tfor j := 2; j*i <= n; j++ {\r\n\t\t\tf[i] = (f[i] + (f[i*j]-f[min((i+1)*j, n+1)]+m)%m) % m\r\n\t\t}\r\n\t}\r\n\tFprint(out, (f[1]-f[2]+m)%m)\r\n}\r\n\r\nfunc main() { CF1558B(os.Stdin, os.Stdout) }\r\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "8aa0365f745e958e5a2aba21fce34b0e", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\nvar _, _, _ = main, rw, do\r\n\r\nfunc main() {\r\n\tr, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\r\n\tdefer w.Flush()\r\n\trw(r, w)\r\n}\r\n\r\nfunc rw(r io.Reader, w io.Writer) {\r\n\tvar n int\r\n\tvar m int64\r\n\tfmt.Fscan(r, &n, &m)\r\n\tw1 := do(n, m)\r\n\tfmt.Fprintln(w, w1)\r\n}\r\n\r\n/*x/2 x/3 ... x/n/2 ... x/n\r\n1 2,3 3,4,5 ... n/2 ... n\r\n2 4,5 6,7,8 ... n\r\n3 6,7 9,10,11 ...\r\n4 8,9 12,13,14 ...\r\n. ...\r\nn+n/2+n/3+...+n/n-1=n(1+1/2+1/3+...)=nlogn\r\n*/\r\n\r\nfunc do(n int, m int64) int64 {\r\n\ta := make([]int64, n+2)\r\n\ta[n] = 1\r\n\tfor i := n - 1; i >= 1; i-- {\r\n\t\ta[i] = a[i+1]\r\n\t\tfor j := 2; j*i <= n; j++ {\r\n\t\t\ta[i] = (a[i] + a[j*i] - a[min(n+1, j*i+j)] + m) % m\r\n\t\t}\r\n\t\ta[i] = (a[i] + a[i+1]) % m\r\n\t}\r\n\treturn (a[1] - a[2] + m) % m\r\n}\r\n\r\nfunc min(a, b int) int {\r\n\tif a < b {\r\n\t\treturn a\r\n\t}\r\n\treturn b\r\n}\r\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "a9f2f93a873031e7bbaadf9bd000ba7d", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, 1024*1024)\n\n\tvar n, m int\n\tfmt.Fscanf(r, \"%d %d\\n\", &n, &m)\n\n\tf := make([]int, n+1)\n\ts := make([]int, n+1)\n\n\tf[1] = 1\n\ts[1] = 1\n\tfor i := 2; i <= n; i++ {\n\t\tf[i] = s[i-1]\n\t\tp := i\n\n\t\tif i <= 5 {\n\t\t\tfor j := 2; j <= i; j++ {\n\t\t\t\tf[i] = (f[i] + f[i/j]) % m\n\t\t\t}\n\t\t} else {\n\t\t\t/*\tfmt.Println(i, \": \")\n\t\t\t\tfor j := 2; j <= i; j++ {\n\t\t\t\t\tfmt.Print(i/j, \" \")\n\t\t\t\t}\n\t\t\t\tfmt.Println()*/\n\n\t\t\tfor j := 2; j < i; j++ {\n\t\t\t\tif j-1 > i/j {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif j-1 == i/j {\n\t\t\t\t\t//\tfmt.Println(i, i/j, p-i/j, \"x\", j-1)\n\t\t\t\t\tf[i] = int((int64(f[i]) + int64(p-i/j)*int64(f[j-1])) % int64(m))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//fmt.Println(i, i/j, p-i/j, \"x\", j-1)\n\t\t\t\tf[i] = int((int64(f[i]) + (int64(p-i/j) * int64(f[j-1]))) % int64(m))\n\t\t\t\tf[i] = (f[i] + f[i/j]) % m\n\t\t\t\tp = i / j\n\t\t\t}\n\t\t}\n\n\t\ts[i] = (s[i-1] + f[i]) % m\n\t}\n\n\tfmt.Println(f[n])\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "79ff753ef9e74f4f7a803fafbdf2e16e", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nfunc main() {\r\n\tin := bufio.NewReader(os.Stdin)\r\n\tout := bufio.NewWriter(os.Stdout)\r\n\tdefer out.Flush()\r\n\tvar n, m int64\r\n\tfmt.Fscan(in, &n, &m)\r\n\tf := make([]int64, n+5)\r\n\tf[1] = 1\r\n\tpre := make([]int64, n+5)\r\n\tpre[1] = 1\r\n\tf[2] = 2\r\n\tf[3] = 5\r\n\tpre[2] = f[1] + f[2]\r\n\tpre[3] = f[1] + f[2] + f[3]\r\n\tvar i int64\r\n\tfor i = 4; i <= n; i++ {\r\n\t\tf[i] = pre[i-1] % m\r\n\t\tvar lst int64 = -1\r\n\t\tvar tmp int64 = 0\r\n\t\tvar j int64\r\n\t\tfor j = 2; j*j <= i; j++ {\r\n\t\t\tif j == 2 {\r\n\t\t\t\tlst = i / j\r\n\t\t\t\ttmp = ((tmp%m+((i%m-lst%m)%m*f[j-1]%m)%m)%m + f[i/j]%m) % m\r\n\t\t\t\tcontinue\r\n\t\t\t}\r\n\t\t\tt := lst\r\n\t\t\tlst = i / j\r\n\t\t\ttmp = ((tmp%m+((t%m-lst%m)%m*f[j-1]%m)%m)%m + f[i/j]%m) % m\r\n\t\t}\r\n\t\tif i/j == j-1 {\r\n\t\t\tt := lst\r\n\t\t\tlst = i / j\r\n\t\t\ttmp = (tmp%m + ((t%m-lst%m)%m*f[j-1]%m)%m) % m\r\n\t\t}\r\n\t\tf[i] = (f[i]%m + tmp%m) % m\r\n\t\tpre[i] = (pre[i-1]%m + f[i]%m) % m\r\n\t}\r\n\tfmt.Fprintln(out, f[n])\r\n}\r\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "117b970f18f2348b728c942d5ab64737", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n \"fmt\"\n //\"unicode/utf8\"\n)\n\nfunc main() {\n var m,n,t1,t2 int\n fmt.Scan(&m,&n)\n a,b,c:=0,0,0\n for i:=1;i<=6;i++ {\n t1=i-m\n t2=i-n\n if t1<0 {\n t1*=(-1)\n }\n if t2<0 {\n t2*=(-1)\n }\n if t1>t2 {\n b++\n } else if t1t2 {\n\t\t\tb++\n\t\t} else if t1 0; t-- {\r\n\t\ta = make([]int, 4)\r\n\t\tfor i := 0; i < 4; i++ {\r\n\t\t\tfmt.Fscan(reader, &a[i])\r\n\t\t}\r\n\t\tfmt.Println(solve(a))\r\n\t}\r\n}\r\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "67986e982b250f310bab92a5b05030b6", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\nimport( \r\n \"fmt\"\r\n \"bufio\"\r\n \"os\"\r\n)\r\nfunc main() {\r\n\tin:= bufio.NewReader(os.Stdin)\r\n\tout:= bufio.NewWriter(os.Stdout)\r\n\tdefer out.Flush()\r\n\tvar t int\r\n\tfmt.Fscan(in,&t)\r\n\tfor i:=0;i 0 && y%a != 0 {\n row := y/a\n if row == 0 || row%2 == 1 { // one per row\n if x > -(a+1)/2 && x < (a+1)/2 {\n if row == 0 {\n result = 1\n } else {\n result = row/2 * 3 + 2\n }\n }\n } else { // two per row\n if x > -a && x != 0 && x < a {\n result = row/2 * 3\n if x > 0 {\n result++\n }\n }\n }\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "d09813aa4739ed5e5847fdfd7cc8144c", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 141B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc f(a, x, y int) int {\n\tif y%a == 0 {\n\t\treturn -1\n\t}\n\tt := y / a\n\tif t == 0 {\n\t\tif -a < 2*x && 2*x < a {\n\t\t\treturn 1\n\t\t} else {\n\t\t\treturn -1\n\t\t}\n\t}\n\tk := t / 2 * 3\n\tif t%2 == 1 {\n\t\tif -a < 2*x && 2*x < a {\n\t\t\treturn k + 2\n\t\t} else {\n\t\t\treturn -1\n\t\t}\n\t}\n\tif -a < x && x < 0 {\n\t\treturn k\n\t}\n\tif 0 < x && x < a {\n\t\treturn k + 1\n\t}\n\treturn -1\n}\nfunc main() {\n\tvar a, x, y int\n\tfor fmt.Scan(&a, &x, &y); ; {\n\t\tfmt.Println(f(a, x, y))\n\t\treturn\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "62ca3dcc9b73f40a2237fdd99b9f205c", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\ts := bufio.NewScanner(os.Stdin)\n\ts.Scan()\n\tline := s.Text()\n\ttokens := strings.Split(line, \" \")\n\ta, _ := strconv.Atoi(tokens[0])\n\tx, _ := strconv.Atoi(tokens[1])\n\ty, _ := strconv.Atoi(tokens[2])\n\tfmt.Println(findSquare(a, x, y))\n}\n\nfunc findSquare(a, x, y int) int {\n\tha := a\n\ta *= 2\n\tx *= 2\n\ty *= 2\n\n\tif y%a == 0 {\n\t\treturn -1\n\t}\n\n\tyi := y / a\n\tswitch {\n\tcase yi == 0:\n\t\tswitch {\n\t\tcase -ha < x && x < ha:\n\t\t\treturn 1\n\t\tdefault:\n\t\t\treturn -1\n\t\t}\n\n\tcase yi%2 == 0:\n\t\tswitch {\n\t\tcase -a < x && x < 0:\n\t\t\treturn (yi / 2) * 3\n\t\tcase 0 < x && x < a:\n\t\t\treturn (yi/2)*3 + 1\n\t\tdefault:\n\t\t\treturn -1\n\t\t}\n\n\tcase yi%2 == 1:\n\t\tswitch {\n\t\tcase -ha < x && x < ha:\n\t\t\treturn (yi/2)*3 + 2\n\t\tdefault:\n\t\t\treturn -1\n\t\t}\n\t}\n\n\treturn -1\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "afc43c92a30b990b88859e1b8b92b6f9", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar a, b, n int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(in, \"%d %d %d\", &a, &b, &n)\n\n\tfor true {\n\t\tif n >= gcd(a, n) {\n\t\t\tn -= gcd(a, n)\n\t\t} else {\n\t\t\tfmt.Println(1)\n\t\t\tbreak\n\t\t}\n\t\tif n >= gcd(b, n) {\n\t\t\tn -= gcd(b, n)\n\t\t} else {\n\t\t\tfmt.Println(0)\n\t\t\tbreak\n\t\t}\n\t}\n\n}\nfunc gcd(a, b int) int {\n\tfor b != 0 {\n\t\tt := b\n\t\tb = a % b\n\t\ta = t\n\t}\n\treturn a\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4b9b9bd446a045b2b7b60fe99a7cee14", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a, b int) int {\n\tfor {\n\t\tv := a % b\n\t\ta, b = b, v\n\t\tif b == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn a\n}\n\nfunc main() {\n\tvar a, b, n int\n\tfmt.Scan(&a, &b, &n)\n\n\tfor {\n\t\tgone := gcd(a, n)\n\t\tn -= gone\n\t\tif n == 0 {\n\t\t\tfmt.Print(0)\n\t\t\tbreak\n\t\t}\n\n\t\tgone = gcd(b, n)\n\t\tn -= gone\n\t\tif n == 0 {\n\t\t\tfmt.Print(1)\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4027005954258be52878119b03a55a10", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc gcd(m, n int) int {\n var d int\n d=m%n\n for d!=0 {\n \tm=n\n \tn=d\n \td=m%n\n }\n return n\n}\n\nfunc main() {\n var a,b,n int\n fmt.Scan(&a,&b,&n)\n for {\n n -= gcd(a, n)\n if (n == 0){\n \t \tfmt.Println(\"0\")\n \t \tbreak\n \t}\n \tn -= gcd(b, n)\n \tif (n == 0){\n \t \tfmt.Println(\"1\")\n \t \tbreak\n \t}\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "7f4d4250540cadb0289e413f610e4548", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 635 E, with podskazki, done\npackage main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"strconv\"\n \"strings\"\n \"os\"\n)\n\nfunc miconv(s string) int64 {\n iret,err := strconv.ParseInt(s, 10, 64)\n if err != nil {\n fmt.Println(\"error in converting \" + s)\n }\n return iret\n}\n\nvar x int64\nvar pov int64\n\n\n\nfunc main() {\n // reading n\n in := bufio.NewReader(os.Stdin)\n s,err := in.ReadString('\\n')\n if err != nil {\n fmt.Println(\"first read failure\", err)\n }\n ss := strings.Split(strings.Trim(s,\" \\n\\r\"),\" \")\n x = miconv(ss[0])\n \n if x > 0 {\n x = x % 360\n } else {\n x = -(-x % 360)\n x = (x + 360) % 360\n }\n // fmt.Printf(\"converted x = %d\\n\", x)\n \n if x<=45 {\n pov = 0\n } else if x<=135 {\n pov = 1\n } else if x<=225 {\n pov = 2\n } else if x>=315 {\n pov = 0\n } else {\n pov = 3\n } \n\t\n\t// print result\n\tfmt.Printf(\"%d\\n\", pov)\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "f9f87448fa8efa60f6c9813760e296cf", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar a, b int\n\nfunc main() {\n\tfmt.Fscan(reader, &a, &b)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tfmt.Println(a, (b-a)/2)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "82738389c9f42a74c56558c3917f51fa", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"bufio\"\nimport \"os\"\nimport \"fmt\"\n\nfunc Read(s *bufio.Reader) string {\n line, _ := s.ReadString('\\n')\n return line\n}\n\nfunc Write(s *bufio.Writer, a ...interface{}) {\n fmt.Fprintln(s, a...)\n s.Flush()\n}\n\nfunc Max(a, b int) (int, int) {\n if b > a {\n b, a = a, b\n }\n return a, b\n}\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n \n var a, b int\n line, _ := reader.ReadString(' ')\n fmt.Sscanln(line, &a)\n fmt.Sscanln(Read(reader), &b)\n\n a, b = Max(a, b)\n \n writer := bufio.NewWriter(os.Stdout)\n Write(writer, b, (a - b) / 2) \n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "2759f7dee90d4a56a99b277d776b038e", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc max(a int, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar a, b int\n\n\tfmt.Scanf(\"%d %d\\n\", &a, &b)\n\n\tmax := max(a, b)\n\tmin := min(a, b)\n\n\tfmt.Printf(\"%d %d\", min, (max - min) / 2)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "7998c0dd67f12d9893ccc322e85b6878", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t//\"strconv\"\n\t\"unicode\"\n\t//\"strings\"\n)\n\nfunc main() {\n var s string\n //fmt.Scan(&s)\n input:= bufio.NewScanner(os.Stdin)\n //input.Split(bufio.ScanLines)\n var c rune\n input.Scan()\n s=input.Text()\n //fmt.Println(s)\n //s = strings.TrimSpace(s)\n c = rune(s[len(s)-2])\n c = unicode.ToLower(c)\n var cek bool\n cek = unicode.IsSpace(c)\n //fmt.Println(cek)\n for i:=3;cek==true;i++ {\n \tc = rune(s[len(s)-i])\n \tc = unicode.ToLower(c)\n \tcek = unicode.IsSpace(c)\n }\n //fmt.Println(s)\n //fmt.Println(string(c))\n if (c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o' || c == 'y') {\n \tfmt.Println(\"YES\")\n \treturn\n }\n fmt.Println(\"NO\")\n}\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f1baf634639c763e77456fe761911a09", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strings\"\n)\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Scan()\n for i := len(scanner.Text())-1; i >= 0; i-- {\n c := strings.ToUpper(string(scanner.Text()[i]))[0]\n if (c >= 'A') && (c <= 'Z') {\n if (c == 'A') || (c == 'E') || (c == 'I') || (c == 'O') || (c == 'U') || (c == 'Y') {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n break\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "3658e49431e4bea0efa4af07a62095ab", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 49A-mic\npackage main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strings\"\n)\n\nfunc main() {\n z := bufio.NewScanner(os.Stdin)\n var y bool\n var s []string\n y = false\n z.Scan()\n ss := z.Text()\n ss = strings.ToLower(ss)\n l := len(ss)\n for i := l - 1; i >= 0; i-- {\n if ss[i] == ' ' || ss[i] == '?' {\n continue\n } else {\n s = append(s, string(ss[i]))\n break\n }\n }\n if s[0] == \"a\" || s[0] == \"i\" || s[0] == \"u\" || s[0] == \"e\" || s[0] == \"o\" || s[0] == \"y\" {\n y = true\n }\n if y {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f3bd77f8814c9156245ae3bb27785ab9", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\tcolours = []byte(\"RGBYW\")\n\tnumbers = []byte(\"12345\")\n)\n\nfunc bits(x int) (ans int) {\n\tfor x > 0 {\n\t\tx &= (x - 1)\n\t\tans++\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcards := make([]string, n)\n\tfor i := range cards {\n\t\tfmt.Scan(&cards[i])\n\t}\n\tres := 10\n\tfor c := 0; c < 1 << 5; c++ {\n\t\tfor nu := 0; nu < 1 << 5; nu++ {\n\t\t\tif bits(c) + bits(nu) > res {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tknow := make(map[byte]bool)\n\t\t\tfor i := 0; i < 5; i++ {\n\t\t\t\tif c & (1 << uint(i)) != 0 {\n\t\t\t\t\tknow[colours[i]] = true\n\t\t\t\t}\n\t\t\t\tif nu & (1 << uint(i)) != 0 {\n\t\t\t\t\tknow[numbers[i]] = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar (\n\t\t\t\tnothing = make(map[string]bool)\n\t\t\t\tknowNu = make(map[byte]map[byte]bool)\n\t\t\t\tknowC = make(map[byte]map[byte]bool)\n\t\t\t)\n\t\t\tgood := true\n\t\t\tfor _, card := range cards {\n\t\t\t\tif !know[card[0]] && !know[card[1]] {\n\t\t\t\t\tnothing[card] = true\n\t\t\t\t\tif len(nothing) > 1 {\n\t\t\t\t\t\tgood = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t} else if !know[card[0]] {\n\t\t\t\t\tm := knowNu[card[1]]\n\t\t\t\t\tif m == nil {\n\t\t\t\t\t\tm = make(map[byte]bool)\n\t\t\t\t\t\tknowNu[card[1]] = m\n\t\t\t\t\t}\n\t\t\t\t\tm[card[0]] = true\n\t\t\t\t\tif len(m) > 1 {\n\t\t\t\t\t\tgood = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t} else if !know[card[1]] {\n\t\t\t\t\tm := knowC[card[0]]\n\t\t\t\t\tif m == nil {\n\t\t\t\t\t\tm = make(map[byte]bool)\n\t\t\t\t\t\tknowC[card[0]] = m\n\t\t\t\t\t}\n\t\t\t\t\tm[card[1]] = true\n\t\t\t\t\tif len(m) > 1 {\n\t\t\t\t\t\tgood = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif good {\n\t\t\t\tres = bits(c) + bits(nu)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "c0986981ae5c91911d999801a857f7b2", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc factorial(number int64) int64 {\n\tvar i, result int64 = 0, 1\n\n\tfor i = 2; i <= number; i++ {\n\t\tresult *= i\n\t}\n\n\treturn result\n\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tn := scanner.Text()\n\n\tvar number, factorialVal, denom int64\n\tnumber, _ = strconv.ParseInt(n, 10, 64)\n\n\tfactorialVal = factorial(number)\n\tdenom = (number / 2) * number\n\n\tfmt.Println(factorialVal / denom)\n\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "d739e164c8c0c315b8f2112a4205b194", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"math/big\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc run(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n int64\n\tFscan(in, &n)\n\tans := new(big.Int).Binomial(n, n/2)\n\n\tf := int64(1)\n\tfor i := int64(2); i < n/2; i++ {\n\t\tf*=i\n\t}\n\tf*=f\n\n\tans.Mul(ans, big.NewInt(f))\n\tans.Div(ans, big.NewInt(2))\n\tFprintln(out, ans.Int64())\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "6b643f833b109065da297158b534ddc9", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar _r = bufio.NewReader(os.Stdin)\nvar _w = bufio.NewWriter(os.Stdout)\n\nfunc main() {\n\tvar n int\n\t_, _ = fmt.Fscan(_r, &n)\n\tf := make([]int64, n+1)\n\tf[0] = 1\n\tfor i := 1; i <= n; i++ {\n\t\tf[i] = f[i-1] * int64(i)\n\t}\n\tvar ans int64\n\tans = (f[n] / f[n/2] / f[n/2]) * (f[n/2-1]) * (f[n/2-1]) / 2\n\t_, _ = fmt.Fprintln(_w, ans)\n\t_ = _w.Flush()\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "a5e49ec8272b1fb71f672e4f471742f2", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"unicode/utf8\"\n)\n\nfunc main() {\n\tvar a,b int64 //input\n\tfmt.Scan(&a,&b)\n\tif a>0 && b>0 {\n\t\tfmt.Print(\"0 \",a+b,a+b,\" 0\")\n\t\tfmt.Println()\n\t} else if a<0 && b>0 {\n\t\tfmt.Print(a-b,\" 0 \",\"0 \",b-a)\n\t\tfmt.Println()\n\t} else if a<0 && b<0 {\n\t\tfmt.Print(a+b,\" 0 \",\"0 \",a+b)\n\t\tfmt.Println()\n\t} else if a>0 && b<0 {\n\t fmt.Print(\"0 \",b-a,a-b,\" 0\")\n\t fmt.Println()\n\t}\n\n}\n\n\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9b9d0157da6b9d46fd4bbd668fa4856b", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var x,y int\n fmt.Scan(&x,&y)\n if x < 0 {\n if y < 0 {\n fmt.Println(x+y,0,0,x+y)\n } else {\n fmt.Println(x-y,0,0,-(x-y))\n }\n } else {\n if y < 0 {\n fmt.Println(0,-(x-y),x-y,0)\n } else {\n fmt.Println(0,x+y,x+y,0)\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "0bc7290d4da17daa76f96c03c4947e23", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n \"fmt\"\n //\"unicode/utf8\"\n)\n\nfunc main() {\n var a,b int64\n fmt.Scan(&a,&b)\n if a>0 && b>0 {\n fmt.Print(\"0 \",a+b,a+b,\" 0\")\n fmt.Println()\n } else if a<0 && b>0 {\n fmt.Print(a-b,\" 0 \",\"0 \",b-a)\n fmt.Println()\n } else if a<0 && b<0 {\n fmt.Print(a+b,\" 0 \",\"0 \",a+b)\n fmt.Println()\n } else if a>0 && b<0 {\n fmt.Print(\"0 \",b-a,a-b,\" 0\")\n fmt.Println()\n }\n\n}\n\n\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "80dc8d79d456502878d61e127d51444b", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n result := 29\n r, g, b := getI(), getI(), getI()\n for i := 0; r > 0 || g > 0 || b > 0; i = (i+1)%3 {\n if i == 0 {\n r -= 2\n } else if i == 1 {\n g -= 2\n } else {\n b -= 2\n }\n result++\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "cfcf9eb9e1c9c2e18431d35da5b425f9", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc check(rgb []int) bool {\n\tfor i := 0; i < len(rgb); i++ {\n\t\tif rgb[i] > 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\nfunc main() {\n\tfsc := NewFastScanner()\n\trgb := make([]int, 3)\n\n\tfor i := 0; i < len(rgb); i++ {\n\t\trgb[i] = fsc.NextInt()\n\t}\n\tcnt := 0\n\tres := 0\n\tfor !check(rgb) {\n\t\tres++\n\t\trgb[cnt] -= 2\n\t\tcnt = (cnt + 1) % 3\n\t}\n\tfmt.Println(29 + res)\n}\n\n//template\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1024)\n\treturn &FastScanner{r: rdr}\n}\nfunc (s *FastScanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *FastScanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *FastScanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *FastScanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *FastScanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n\n//Max,Min\nfunc IntMax(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Int64Max(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc Float64Max(a, b float64) float64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc IntMin(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Int64Min(a, b int64) int64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc Float64Min(a, b float64) float64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\n//Gcd\nfunc IntGcd(a, b int) int {\n\tif a < b {\n\t\tb, a = a, b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn IntGcd(b, a%b)\n}\nfunc Int64Gcd(a, b int64) int64 {\n\tif a < b {\n\t\tb, a = a, b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn Int64Gcd(b, a%b)\n}\n\nfunc IntAbs(a int) int {\n\tif a < 0 {\n\t\ta *= -1\n\t}\n\treturn a\n}\n\nfunc Int64Abs(a int64) int64 {\n\tif a < 0 {\n\t\ta *= -1\n\t}\n\treturn a\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "a23081cdda33745baa0f1dfe518e8311", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// _Channels_ are the pipes that connect concurrent\n// goroutines. You can send values into channels from one\n// goroutine and receive those values into another\n// goroutine.\n\npackage main\n\nimport \"fmt\"\nimport (\n\t\"bufio\"\n\t\"os\"\n)\n\n// var (\n// mess make(chan string, 2)\n// )\n\nfunc main() {\n\tvar str_a string\n\tvar str_b int64\n\tinput := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(input, &str_a)\n\tfmt.Fscan(input, &str_b)\n\tvar cnt [256]int\n\tfor i := 0; i < len(str_a); i++ {\n\t\tcnt[str_a[i]-'0']++\n\t}\n\tvar ans int64\n\t// fmt.Println(len(str_a))\n\tfor i := 0; i < len(str_a); i++ {\n\t\tfor j := 9; j >= 0; j-- {\n\t\t\tif cnt[j] == 0 {\n\t\t\t\t// fmt.Println(j, cnt[j])\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tflag := false\n\t\t\tt := ans\n\t\t\tt = t * 10\n\t\t\tt += int64(j)\n\t\t\tcnt[j]--\n\n\t\t\tif check(t, cnt, str_b) {\n\t\t\t\tans = t\n\t\t\t\tflag = true\n\t\t\t} else {\n\t\t\t\tcnt[j]++\n\t\t\t}\n\t\t\tif flag {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\nfunc check(t int64, cnt [256]int, str_b int64) bool {\n\tfor i := 0; i < 10; i++ {\n\t\tfor cnt[i] > 0 {\n\t\t\tt = t * 10\n\t\t\tt += int64(i)\n\t\t\tcnt[i]--\n\t\t}\n\t}\n\treturn t <= str_b\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp"], "code_uid": "2a72fcee9789ccb6d383bfe3677c9f6c", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//http://codeforces.com/contest/915/problem/C\npackage main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc min(x, y int) int {\n if x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc reverse(v []int) {\n\tfor i := 0; i < len(v) / 2; i++ {\n\t\tv[i], v[len(v) - i - 1] = v[len(v) - i - 1], v[i]\n\t}\n}\n\nfunc numToVec(a int64) []int {\n\tvar vec []int\n\n\tfor a > 0 {\n\t\tvec = append(vec, int(a % 10))\n\t\ta /= 10\n\t}\n\treturn vec\n}\n\nfunc sliceCompare(a, b []int) bool {\n\tn := len(a)\n\n\tfor i := 0; i < n; i++ {\n\t\tif a[i] < b[i] {\n\t\t\treturn true\n\t\t} else if a[i] > b[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc printVec(vec []int) {\n\tn := len(vec)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Printf(\"%d\", vec[i])\n\t}\n\tfmt.Printf(\"\\n\")\n}\n\nfunc searchPos(vec []int, l, r, num int) int {\n\tfor i := l; i < r; i++ {\n\t\tif vec[i] == num {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}\n\nfunc main() {\n\tvar a, b int64\n\tvar Va, Vb []int\n\n\tfmt.Scanf(\"%d\\n\", &a)\n\tfmt.Scanf(\"%d\\n\", &b)\n\n\tVa = numToVec(a)\n\treverse(Va)\n\n\tVb = numToVec(b)\n\treverse(Vb)\n\n\tif len(Va) != len(Vb) {\n\t\tsort.Ints(Va)\n\t\treverse(Va)\n\t\tprintVec(Va)\n\t} else {\n\t\tn := len(Va)\n\t\t\n\t\tfor i := 0; i < n; i++ {\n\t\t\tfor dig := 9; dig >= 0; dig-- {\n\t\t\t\tpos := searchPos(Va, i, n, dig)\n\t\t\t\tif pos == -1 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tVa[i], Va[pos] = Va[pos], Va[i]\t\t\t\n\t\t\t\tif i != n - 1 {\n\t\t\t\t\tsort.Ints(Va[i+1:])\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif sliceCompare(Va, Vb) == true {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprintVec(Va)\n\t}\n\n}\n\n", "lang_cluster": "Go", "tags": ["greedy", "dp"], "code_uid": "e6d7d5a86fbbc3a5f76274b0406b2707", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t// \"os\"\n\t\"sort\"\n\t)\n\nconst INF = 0x3f3f3f3f\n\nvar n, m, tot int\nvar ans, s, t string\n\nfunc min(x, y int) int {\n\tif xy {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc maxs(x, y string) string {\n\tif x>y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc abs(x int) int {\n\tif x<0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc solve(u sort.IntSlice, dep, tar int, st string) {\n\tif dep==tar {\n\t\tans = maxs(ans, st)\n\t\treturn\n\t}\n\tk := int(t[dep])-48\n\tfor i:=k-1; i>=0; i-- {\n\t\tif u[i]>0 {\n\t\t\tif st==\"\" && i==0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tu[i]--\n\t\t\tp := st + string(i+48)\n\t\t\tfor j:=9; j>=0; j-- {\n\t\t\t\tfor k:=0; k0 {\n\t\tu[k]--\n\t\tsolve(u, dep+1, tar, st + string(k+48))\n\t}\n}\n\nfunc main() {\n\t// fd, _ := os.Open(\"in.txt\")\n\t// os.Stdin = fd\n\tvar T int = 1\n\t// fmt.Scanf(\"%d\", &T)\n\tfor ci:=1; ci<=T; ci++ {\n\t\t// fmt.Scanf(\"%d %d\\n\", &n, &m)\n\t\t// fmt.Printf(\"Case #%d: \", ci)\n\t\tfmt.Scanf(\"%s\\n\",&s)\n\t\tfmt.Scanf(\"%s\\n\",&t)\n\t\t// fmt.Println(s)\n\t\t// fmt.Println(t)\n\t\tn = len(s)\n\t\tm = len(t)\n\t\tif n 2 {\n\t\t\td += i - st - 2\n\t\t}\n\t}\n\tPrint(d)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "strings"], "code_uid": "526fc1b701e1744d67161e89e849bef8", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// https://codeforces.com/problemset/problem/978/B\npackage main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tscanner.Scan()\n\tword := scanner.Text()\n\tvar countx int = 0\n\tvar countrem int = 0\n\tfor _, r := range word {\n\t\tif r == 'x' {\n\t\t\tif countx == 2 {\n\t\t\t\tcountrem++\n\t\t\t} else {\n\t\t\t\tcountx++\n\t\t\t}\n\t\t} else {\n\t\t\tcountx = 0\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", countrem)\n}", "lang_cluster": "Go", "tags": ["greedy", "strings"], "code_uid": "e1d1cd8b71703330a71c732666a30fa0", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar n int\n\tfmt.Fscanf(bufin, \"%d\\n\", &n)\n\n\tvar s string\n\tfmt.Fscanf(bufin, \"%s\\n\", &s)\n\n\tfor i := 0; i < n; i++ {\n\t\tif (i+2 < n) && (s[i] == 'o') && (s[i+1] == 'g') && (s[i+2] == 'o') {\n\t\t\tj := i + 3\n\t\t\tfor (j+1 < n) && (s[j] == 'g') && (s[j+1] == 'o') {\n\t\t\t\tj += 2\n\t\t\t}\n\t\t\ti = j - 1\n\t\t\tfmt.Fprintf(bufout, \"***\")\n\t\t} else {\n\t\t\tfmt.Fprintf(bufout, \"%c\", s[i])\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "0011d5c8668564dadb1eacdf618c84af", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar (\n\t\tcount int\n\t\tline string\n\t)\n\n\tfmt.Scanf(\"%d\\n\", &count)\n\tfmt.Scanln(&line)\n\n\tisStarted := false\n\tfor i := 0; i < count; {\n\t\tif !isStarted {\n\t\t\tif i < count-2 {\n\n\t\t\t\tif line[i] == 'o' && line[i+1] == 'g' && line[i+2] == 'o' {\n\t\t\t\t\tisStarted = true\n\t\t\t\t\ti += 3\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Print(string(line[i]))\n\t\t\t\t\ti++\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfmt.Print(string(line[i]))\n\t\t\t\ti++\n\t\t\t}\n\t\t} else {\n\t\t\tif i < count-1 {\n\t\t\t\tif line[i] == 'g' && line[i+1] == 'o' {\n\t\t\t\t\ti += 2\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Print(\"***\")\n\t\t\t\t\tisStarted = false\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfmt.Print(\"***\")\n\t\t\t\tfmt.Print(string(line[i]))\n\t\t\t\tisStarted = false\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t}\n\n\tif isStarted {\n\t\tfmt.Print(\"***\")\n\t\tisStarted = false\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "cb06ab172363cc8e564ff6c8ac686500", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"strings\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc OpenFile(fpath string) *os.File {\n\tf, err := os.Open(fpath)\n\tAssert(err == nil)\n\treturn f\n}\n\nfunc Assert(b bool) {\n\tif !b {\n\t\tpanic(\"Assertion error\")\n\t}\n}\n\nfunc GetLine(scanner *bufio.Scanner) string {\n\tAssert(scanner.Scan() && scanner.Err() == nil)\n\treturn scanner.Text()\n}\n\nfunc ReadIntLine(scanner *bufio.Scanner) []int {\n\tlst := make([]int, 0)\n\tfor _, s := range strings.Fields(GetLine(scanner)) {\n\t\ti, err := strconv.Atoi(s)\n\t\tAssert(err == nil)\n\t\tlst = append(lst, i)\n\t}\n\treturn lst\n}\n\n// SliceIndex(len(slice), func(i int) bool { return slice[i] == value })\nfunc SliceIndex(limit int, predicate func(i int) bool) int {\n\tfor i := 0; i < limit; i++ {\n\t\tif predicate(i) {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}\n\nfunc Ternary(c bool, a, b interface{}) interface{} {\n\tif c { return a }\n\treturn b\n}\n\nfunc main() {\n\tf := os.Stdin\n//\tf := strings.NewReader(`7\n//aogogob`)\n\t//f = OpenFile(\"/home/ilya/opt/programming/tasks/738A.txt\")\n\tsc := bufio.NewScanner(f)\n\n\tReadIntLine(sc)\n\tline := GetLine(sc)\n\n\tvar res []string\n\n\t// for idx = expression, idx != -1 is not allowed in Go in conditions\n\t// var idx int is not allowed also, only :=\n\t// idx := *new(int) allows avoid explicit -1, is a way to make zero value for int, but it is on heap\n\tfor idx := -1; func() bool {\n\t\tidx = strings.Index(line, \"ogo\")\n\t\treturn idx != -1\n\t}(); {\n\t\tres = append(res, line[:idx], \"***\")\n\n\t\tline = line[idx+3:]\n\n\t\tfor strings.HasPrefix(line, \"go\") {\n\t\t\tline = line[2:]\n\t\t}\n\t}\n\n\tres = append(res, line)\n\n\tfmt.Println(strings.Join(res, \"\"))\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "4db3c79a2489cd07549a807502131d4f", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\nimport \"bufio\"\n\nvar n int\nvar s string\nvar res int\nvar m map[byte]int\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &n)\n\tfmt.Fscan(in, &s)\n\tm = make(map[byte]int)\n\n\tfor i:= 0; i < len(s); i++ {\n\t\tm[s[i]]++\n\t}\n\n\tres = min(m['U'], m['D']) + min(m['L'], m['R'])\n\tfmt.Printf(\"%d\", res*2)\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "d23ddd003e433b62decaeddd4f218666", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// https://codeforces.com/problemset/problem/888/B\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"math\"\n)\n\nfunc move(pos []int, move rune) {\n\tswitch move {\n\tcase 'U':\n\t\tpos[1]++\n\tcase 'D':\n\t\tpos[1]--\n\tcase 'L':\n\t\tpos[0]--\n\tcase 'R':\n\t\tpos[0]++\n\t}\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tnumCommands, _ := strconv.ParseInt(scanner.Text(), 10, 32)\n\tpos := []int{0, 0}\n\tscanner.Scan()\n\tcmds := scanner.Text()\n\tfor _, cmd := range cmds {\n\t\tmove(pos, cmd)\n\t\t// fmt.Printf(\"%d - current position - %d, %d\\n\", i+1, pos[0], pos[1])\n\t}\n\tfmt.Printf(\"%d\", numCommands - int64(math.Abs(float64(pos[0]- 0))) - int64(math.Abs(float64(pos[1]-0))))\n}", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "b22aba8f453c622afa5e05ffc07a012f", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\n\t\"math\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n\tscanner.Scan()\n\tx, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn x\n}\nfunc getI() int {\n\treturn int(getI64())\n}\nfunc getF() float64 {\n\tscanner.Scan()\n\tx, _ := strconv.ParseFloat(scanner.Text(), 64)\n\treturn x\n}\nfunc getS() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc max(a,b int) int { if a > b { return a } else { return b } }\n\nfunc min(a,b int) int { if a < b { return a } else { return b } }\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\n\twriter.WriteString(fmt.Sprintf(\"%d\", Problem888B()))\n}\n\nfunc Problem888B() int {\n\tn := getI()\n\tx := 0\n\ty := 0\n\ts := getS()\n\tfor _, char := range s {\n\t\tswitch char {\n\t\tcase 'U':\n\t\t\ty+=1\n\t\t\tbreak\n\t\tcase 'D':\n\t\t\ty-=1\n\t\t\tbreak\n\t\tcase 'L':\n\t\t\tx-=1\n\t\t\tbreak\n\t\tcase 'R':\n\t\t\tx+=1\n\t\t\tbreak\n\t\tdefault:\n\t\t\tbreak\n\t\t}\n\t}\n\treturn n - (int(math.Abs(float64(x)))+int(math.Abs(float64(y))))\n}", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "9adcb23b3d32ca05167de91bda69d105", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"os\"\n\t\"strings\"\n\t\"sort\"\n)\n\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\ntype Team struct {\n\tname string\n\tpts, x, y, played int\n}\n\ntype Sorter []Team\n\nfunc (s Sorter) Len() int { return len(s) }\nfunc (s Sorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] }\nfunc (s Sorter) Less(i, j int) bool { \n\tif s[i].pts > s[j].pts {\n\t\treturn true\n\t}\n\tif s[i].pts < s[j].pts {\n\t\treturn false\n\t}\n\tif s[i].x - s[i].y > s[j].x - s[j].y {\n\t\treturn true\n\t}\n\tif s[i].x - s[i].y < s[j].x - s[j].y {\n\t\treturn false\n\t}\n\tif s[i].x > s[j].x {\n\t\treturn true\n\t}\n\tif s[i].x < s[j].x {\n\t\treturn false\n\t}\n\treturn s[i].name < s[j].name\n}\n\nfunc main() {\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\ts2m := make(map[string]*Team)\n\tfor i := 0; i < 5; i++ {\n\t\tname1, name2, score := Next(), Next(), Next()\n\t\tif _, exists := s2m[name1]; !exists {\n\t\t\ts2m[name1] = &Team{name: name1}\n\t\t}\n\n\t\tif _, exists:= s2m[name2]; !exists {\n\t\t\ts2m[name2] = &Team{name: name2}\n\t\t}\n\n\t\tt1, _ := s2m[name1]\n\t\tt2, _ := s2m[name2]\n\t\t\n\t\ts := strings.Split(score, \":\")\n\t\ts1, _ := strconv.Atoi(s[0])\n\t\ts2, _ := strconv.Atoi(s[1])\n\n\t\tt1.played += 1\n\t\tt2.played += 1\n\t\tt1.x += s1\n\t\tt1.y += s2\n\t\tt2.x += s2\n\t\tt2.y += s1\n\n\t\tif s1 > s2 {\n\t\t\tt1.pts += 3\n\t\t}else if s1 < s2 {\n\t\t\tt2.pts += 3\n\t\t}else {\n\t\t\tt1.pts += 1\n\t\t\tt2.pts += 1\n\t\t}\n\t}\n\n\tvar berland, other Team\n\tvar teams [4]*Team\n\tvar at int = 0\n\tfor _, value := range s2m {\n\t\tteams[at] = value\n\t\tat += 1\n\n\t\tif value.played == 2 {\n\t\t\tif value.name == \"BERLAND\" {\n\t\t\t\tberland = *value\n\t\t\t}else {\n\t\t\t\tother = *value\n\t\t\t}\n\t\t}\n\t}\n\n\tberland.pts += 3\n\tberland.played += 1\n\n\tother.played += 1\n\n\t// fmt.Fprintln(out, berland)\n\n\tvar score1, score2 int = -1, -1\n\tfor x := 0; x < 1000; x++ {\n\t\tfor y := 0; y < x; y++ {\n\t\t\tb := make([]Team, 0)\n\t\t\tfor i := 0; i < 4; i++ {\n\t\t\t\tif teams[i].name == berland.name || teams[i].name == other.name {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tb = append(b, *teams[i])\n\t\t\t}\n\n\t\t\t// fmt.Fprintln(out, b)\n\n\t\t\tbrld, othr := berland, other\n\t\t\tbrld.x += x\n\t\t\tbrld.y += y\n\t\t\tothr.x += y\n\t\t\tothr.y += x\n\t\t\tb = append(b, brld)\n\t\t\tb = append(b, othr)\n\t\t\tsort.Sort(Sorter(b))\n\n\t\t\t// fmt.Fprintln(out, b)\n\n\t\t\tif b[0].name == berland.name || b[1].name == berland.name {\n\t\t\t\tif score1 == -1 || score1 - score2 > x - y || (score1 - score2 == x - y && score2 > y){\n\t\t\t\t\tscore1, score2 = x, y\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif score1 == -1 {\n\t\tfmt.Fprintln(out, \"IMPOSSIBLE\")\n\t}else {\n\t\tfmt.Fprintf(out, \"%v:%v\", score1, score2)\n\t\tfmt.Fprintln(out)\n\t}\t\n}\n\nfunc Next() string {\n\tif !in.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\n\treturn in.Text()\n}\n\nfunc NextInt() int {\n\tret, _ := strconv.Atoi(Next())\n\treturn ret\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "554f044d407b06cec8d48f0af9f73cd4", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\"bufio\"\n\"os\"\n\"strconv\"\n\"strings\"\n)\n\nvar scanner * bufio . Scanner = bufio . NewScanner ( os.Stdin ) \nvar writer * bufio . Writer = bufio . NewWriter ( os.Stdout )\n\nfunc ReadInt32 () []int { \n scanner . Scan ()\n s:=scanner.Text()\n var ans []int\n ans=make([]int, 2)\n pieces:=strings.Split(s, \":\")\n ans[0] , _ = strconv . Atoi (pieces[0])\n ans[1], _=strconv.Atoi(pieces[1])\n return ans\n }\n\nfunc PrintInts ( hours, mins int ) {\n ansx := make([]string, 5)\n h:=strconv.Itoa(hours)\n m:=strconv.Itoa(mins)\n if hours<10{\n if mins<10 {\n ansx[0] = string('0')+h+string(':')+string('0')+m\n } else {\n ansx[0] = string('0')+h+string(':')+m\n }\n } else {\n if mins<10 {\n ansx[0] = h+string(':')+string('0')+m\n } else {\n ansx[0] = h+string(':')+m\n }\n }\n for _ , value := range ansx { \n writer . WriteString ( value ) \n writer . WriteByte(' ') \n }\n}\n\nfunc main () { \n defer writer . Flush () // clears the buffer when the function main \n scanner . Split ( bufio . ScanWords ) // makes the scanner tokens treated as separate words separated by spaces \n // also has the function and bufio.ScanLines bufio.ScanBytes \n var n , m []int = ReadInt32 (), ReadInt32 ()\n \n startx:=m[0]*60+m[1]\n endx:=n[0]*60+n[1]\n duration:=endx-startx\n if duration<0 {\n duration=duration+1440\n }\n hours:=int(duration/60)\n mins:=duration%60\n PrintInts ( hours , mins )\n writer . WriteByte ( '\\n' )\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "59971cc0a05d74d84422cb49bb7fb969", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"strings\"\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar s, t string\n\n\tfmt.Scan(&s, &t)\n\n\tstrs, strt := strings.Split(s, \":\") , strings.Split(t, \":\")\n\tints, intt := make([]int, 2), make([]int, 2)\n\n\tfor i := range ints {\n\t\tints[i], _ = strconv.Atoi(strs[i])\n\t\tintt[i], _ = strconv.Atoi(strt[i])\n\t}\n\n\th := 0\n\n\tif ints[1]>=intt[1] {\t\t\n\t\tints[1] -= intt[1]\n\t} else {\n\t\tints[1] += 60-intt[1]\n\t\th++\n\t}\n\n\tif ints[0]>=intt[0]+h {\n\t\tints[0] -= intt[0]+h\n\t} else {\n\t\tints[0] += 24-intt[0]-h\n\t}\n\n\tfmt.Printf(\"%02d:%02d\\n\", ints[0], ints[1])\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "33892404e9b690d24395fab62c5a7312", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\t//var a,b,c,d int\n\tvar s1,s2,t1,t2 int\n\tfmt.Scanf(\"%d:%d\\n\",&s1,&s2)\n\tfmt.Scanf(\"%d:%d\",&t1,&t2)\n\t//fmt.Println(s1,s2,t1,t2)\n\ts:=s1*60+s2\n\ts-=t2\n\ts-=t1*60\n\tif s<0 {\n\t\ts+=24*60\n\t}\n\tfmt.Printf(\"%02d:%02d\\n\",s/60,s%60)\n\n}\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "59c1ee265e7e0345dfe7cb8bdcc9a3d0", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t// \"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\t_ = nextInt()\n\ts := next()\n\tvar outsideWords []string\n\n\tfor i := strings.Index(s, \"(\"); i >= 0; i = strings.Index(s, \"(\") {\n\t\tj := strings.Index(s, \")\")\n\t\toutsideWords = append(outsideWords, splitWords(s[i+1:j], '_')...)\n\t\ts = s[:i] + \"_\" + s[j+1:]\n\t}\n\n\tprintln(maxLength(splitWords(s, '_')), len(outsideWords))\n\n}\n\nfunc splitWords(s string, c rune) []string {\n\treturn strings.FieldsFunc(s, func(c rune) bool { return c == '_' })\n}\n\nfunc maxLength(s []string) int {\n\tl := 0\n\n\tfor i := range s {\n\t\tif len(s[i]) > l {\n\t\t\tl = len(s[i])\n\t\t}\n\t}\n\n\treturn l\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "010090a011abdd50dcba6a2966b7521f", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"bufio\"\nimport \"os\"\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(bufin, \"%d\\n\", &n)\n\tfmt.Fscanf(bufin, \"%s\\n\", &s)\n\n\tinside := false\n\tl := 0\n\n\tlongestOutside := 0\n\tcountInside := 0\n\n\ts = \"_\" + s + \"_\"\n\tn = len(s)\n\n\tfor i := 0; i < n; i++ {\n\t\tc := s[i]\n\t\tif (c == '_') || (c == '(') || (c == ')') {\n\t\t\tif l > 0 {\n\t\t\t\tif inside {\n\t\t\t\t\tcountInside++\n\t\t\t\t} else {\n\t\t\t\t\tif longestOutside < l {\n\t\t\t\t\t\tlongestOutside = l\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tl = 0\n\t\t\t}\n\t\t} else {\n\t\t\tl++\n\t\t}\n\t\tif c == '(' {\n\t\t\tinside = true\n\t\t} else if c == ')' {\n\t\t\tinside = false\n\t\t}\n\t}\n\n\tfmt.Fprintf(bufout, \"%d %d\\n\", longestOutside, countInside)\n}\n", "lang_cluster": "Go", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "b0ef18151305386a9e73bc4d25a1c03b", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tn := fsc.NextInt()\n\ttext := fsc.Next()\n\tvar flag, maxLength, inLength, outLength, count int\n\tfor i := 0; i <= n; i++ {\n\t\tif i == n {\n\t\t\tif maxLength < outLength {\n\t\t\t\tmaxLength = outLength\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tif text[i] == '(' {\n\t\t\tif maxLength < outLength {\n\t\t\t\tmaxLength = outLength\n\t\t\t}\n\t\t\toutLength = 0\n\t\t\tflag = 1\n\t\t} else if text[i] == ')' {\n\t\t\tif inLength != 0 {\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tinLength = 0\n\t\t\tflag = 0\n\t\t} else if text[i] == '_' {\n\t\t\tif inLength != 0 {\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tinLength = 0\n\t\t\tif outLength != 0 {\n\t\t\t\tif maxLength < outLength {\n\t\t\t\t\tmaxLength = outLength\n\t\t\t\t}\n\t\t\t}\n\t\t\toutLength = 0\n\t\t} else if flag == 0 {\n\t\t\toutLength++\n\t\t} else if flag == 1 {\n\t\t\tinLength++\n\t\t}\n\t}\n\n\tfmt.Println(maxLength, count)\n}\n\n//template\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 2028)\n\treturn &FastScanner{r: rdr}\n}\n\nfunc (s *FastScanner) Next() string {\n\ts.Pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\n\nfunc (s *FastScanner) NextInt() int {\n\tval, err := strconv.Atoi(s.Next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tval, err := strconv.ParseInt(s.Next(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) Pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.ReadLine()\n\t\ts.p = 0\n\t}\n}\n\nfunc (s *FastScanner) ReadLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, err := s.r.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "5a49101d6b773e48ec263f865a21b24a", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc max(a, b int) int {\n\tif a > b {return a}\n\treturn b\n}\n\nfunc main() {\n\tvar (\n\t\tn int\n\t\tstr string\n\t)\n\t\n\tfmt.Scanln(&n)\n\tfmt.Scanln(&str)\n\t\n\ti := 0;\n\ts_words := 0\n\ts_len := 0\n\tw_len := 0\n\tw_max := 0\n\tfor i < n {\n\t\tif str[i] == '(' {\n\t\t\ti++\n\t\t\t\n\t\t\tfor i < n && str[i] != ')' {\n\t\t\t\tif str[i] != '_' {\n\t\t\t\t\ts_len++\n\t\t\t\t} else {\n\t\t\t\t\tif s_len > 0 {\n\t\t\t\t\t\ts_words++\n\t\t\t\t\t}\n\t\t\t\t\ts_len = 0\n\t\t\t\t}\n\t\t\t\ti++\n\n\t\t\t}\n\t\t\ti++\n\t\t\tif s_len > 0 {\n\t\t\t\ts_words++\n\t\t\t}\n\t\t\ts_len = 0\n\t\t\tcontinue\n\t\t}\n\t\t\t\n\t\t\n\t\tfor i < n && str[i] != '(' {\n\t\t\t\tif str[i] != '_' {\n\t\t\t\t\tw_len++\n\t\t\t\t} else {\n\t\t\t\t\tif w_len > 0 {\n\t\t\t\t\t\tw_max = max(w_max, w_len)\n\t\t\t\t\t}\n\t\t\t\t\tw_len = 0\n\t\t\t\t}\n\t\t\t\ti++\n\t\t\t}\n\n\t\tif w_len > 0 {\n\t\t\tw_max = max(w_max, w_len)\n\t\t}\n\t\tw_len = 0\n\t}\n\n\t\n\t\n\tfmt.Println(w_max, s_words)\n}\n\n", "lang_cluster": "Go", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "c553f1b74ef2f8ef0cc69ccc725f6154", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main;\n\nimport (\"fmt\"; \"bufio\"; \"os\"; \"strings\")\n\n\nfunc mysplit(line string) []string {\n from := 0\n output := make([]string, 0, 10)\n for i, c := range line {\n if c=='(' || c==')' {\n output = append(output, line[from:i])\n from = i+1\n }\n }\n if from longestOutside {\n longestOutside = len(w)\n }\n }\n\n inParenthesis := 0\n for _, w := range inside {\n if len(w) > 0 {\n inParenthesis++\n }\n }\n\n fmt.Println(longestOutside, inParenthesis)\n}", "lang_cluster": "Go", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "570467193b8cf37eedc6c6485328a566", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\ntype res struct {\n\tind int\n\twrd string\n}\n\nfunc inside_parthesis(S string, x *res) bool {\n\tl, r := false, false\n\tfor i := x.ind; i >= 0; i-- {\n\t\tif S[i] == '(' {\n\t\t\tl = true\n\t\t\tbreak\n\t\t} else if S[i] == ')' {\n\t\t\tbreak\n\t\t}\n\t}\n\tfor i := x.ind; i < len(S); i++ {\n\t\tif S[i] == ')' {\n\t\t\tr = true\n\t\t\tbreak\n\t\t} else if S[i] == '(' {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn l && r\n}\nfunc mysplit(S string) []res {\n\tvar cur string\n\tvar start int\n\tvar ret []res\n\n\tfor i, c := range S {\n\t\tif c != '_' && c != '(' && c != ')' {\n\t\t\tif cur == \"\" {\n\t\t\t\tstart = i\n\t\t\t}\n\t\t\tcur += string(c)\n\t\t} else if cur != \"\" {\n\t\t\tret = append(ret, res{start, cur})\n\t\t\tcur = \"\"\n\t\t}\n\t}\n\tif cur != \"\" {\n\t\tret = append(ret, res{start, cur})\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\tvar N int\n\tfmt.Fscanf(bufin, \"%d\\n\", &N)\n\tvar S string\n\tfmt.Fscanf(bufin, \"%s\\n\", &S)\n\twords := mysplit(S)\n\tcnt := 0\n\tmaxlen := 0\n\tfor _, x := range words {\n\t\tif inside_parthesis(S, &x) {\n\t\t\tcnt += 1\n\t\t} else {\n\t\t\tif maxlen < len(x.wrd) {\n\t\t\t\tmaxlen = len(x.wrd)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(bufout, \"%d %d\\n\", maxlen, cnt)\n\n}\n", "lang_cluster": "Go", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "b6b9877a905107d990b869b77a9a8f01", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"regexp\"\n \"strconv\"\n \"strings\"\n)\n\nfunc O(o interface{}, n bool) {\n if n {\n fmt.Println(o)\n } else {\n fmt.Printf(\"%v \", o)\n }\n}\n\nfunc Int(s string) int64 {\n t, _ := strconv.ParseInt(s, 10, 64)\n return t\n}\n\nfunc I(n bool) string {\n var t string\n if n {\n fmt.Scanln(&t)\n } else {\n fmt.Scan(&t)\n }\n return t\n}\n\nfunc main() {\n n := Int(I(true))\n s := I(true)\n n = n\n\n re := regexp.MustCompile(`\\([^\\(\\)]*\\)`)\n ss := re.FindAllString(s, -1)\n\n ooo := re.ReplaceAllString(s, \"_\")\n\n rrr := regexp.MustCompile(`([_])*`)\n ooo = rrr.ReplaceAllString(ooo, \"$1\")\n qqq := strings.Split(ooo, \"_\")\n mmm := 0\n for _, q := range qqq {\n if len(q) > mmm {\n mmm = len(q)\n }\n }\n\n O(mmm, false)\n\n num := 0\n for i := range ss {\n sss := strings.Split(ss[i], \"_\")\n for j := range sss {\n r := regexp.MustCompile(`[_\\(\\)]`)\n sss[j] = r.ReplaceAllString(sss[j], \"\")\n if len(sss[j]) > 0 {\n num++\n }\n }\n }\n O(num, true)\n}\n", "lang_cluster": "Go", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "81c76d59d62e670b97287652cfccafd9", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tvar longest int = 0\n\tvar words_inside int = 0\n\n\treader := bufio.NewReader(os.Stdin)\n\tif s, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tinside := false\n\t\tword_length := 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif (s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z') {\n\t\t\t\tword_length++\n\t\t\t} else {\n\t\t\t\tif !inside && word_length > longest {\n\t\t\t\t\tlongest = word_length\n\t\t\t\t}\n\t\t\t\tif inside && word_length > 0 {\n\t\t\t\t\twords_inside++\n\t\t\t\t}\n\t\t\t\tif s[i] == '(' {\n\t\t\t\t\tinside = true\n\t\t\t\t} else if s[i] == ')' {\n\t\t\t\t\tinside = false\n\t\t\t\t}\n\t\t\t\tword_length = 0\n\t\t\t}\n\t\t}\n\t\tif word_length > longest {\n\t\t\tlongest = word_length\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d %d\\n\", longest, words_inside)\n}\n", "lang_cluster": "Go", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "e831067809a7941fc563b3e40f227a5a", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,x int\n\tfmt.Scan(&n)\n\tc,s:=0,0\n\tfor i:=0;i= 2 {\n\t\t\tN -= N / M / 2 * 2 * M\n\t\t} else if 2 <= M/N {\n\t\t\tM -= M / N / 2 * 2 * N\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(N, M)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "c0f4a1395fc8d56a8f2a1091310bd13d", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b int64\n\tfmt.Scan(&a, &b)\n\tfor (a != 0) && (b != 0) && ((a >= 2*b) || (b >= 2*a)) {\n\t\tif a >= 2*b {\n\t\t\ta %= 2 * b\n\t\t} else {\n\t\t\tb %= 2 * a\n\t\t}\n\t}\n\tfmt.Println(a, b)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "2ceddc1217bea111e417fdbf5cc67a03", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc weirdSum(a, b int64) (int64, int64) {\n\tfor a != 0 && b != 0 {\n\t\tif a >= 2*b {\n\t\t\ta %= 2 * b\n\t\t\tcontinue\n\n\t\t} else if b >= 2*a {\n\t\t\tb %= 2 * a\n\t\t\tcontinue\n\t\t}\n\n\t\tbreak\n\t}\n\n\treturn a, b\n}\n\nfunc main() {\n\tvar a, b int64\n\tfmt.Scanf(\"%d %d\", &a, &b)\n\n\tfmt.Println(weirdSum(a, b))\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "34eb09f84793a994810ecb0bc2f2e136", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tlev := make([]int, n)\n\tfor i := range lev {\n\t\tfmt.Scan(&lev[i])\n\t}\n\tsort.Sort(sort.IntSlice(lev))\n\n\tb := 0\n\tfor i := 0; i < n/2; i++ {\n\t\tif lev[i*2] >= lev[i*2+1] {\n\t\t\tb += lev[i*2] - lev[i*2+1]\n\t\t} else {\n\t\t\tb += lev[i*2+1] - lev[i*2]\n\t\t}\n\t}\n\tfmt.Println(b)\n}\n", "lang_cluster": "Go", "tags": ["sortings"], "code_uid": "ed0f511696ad0298b30816fb8f190f0b", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"sort\"\n)\n\nfunc main() {\n stdin := bufio.NewReader(os.Stdin)\n \n var n int\n var A []int\n \n fmt.Fscan(stdin, &n)\n A = make([]int, n)\n for i := 0; i < n; i++ {\n fmt.Fscan(stdin, &A[i])\n }\n \n sort.Slice(A[:], func (x, y int) bool {\n return A[x] < A[y]\n })\n \n var res int = 0\n for i := 0; i < n; i += 2 {\n res += A[i + 1] - A[i]\n }\n \n fmt.Println(res)\n}", "lang_cluster": "Go", "tags": ["sortings"], "code_uid": "a332b03a9f4c574dfc602adbd1355f90", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar m []int = make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&m[i])\n\t}\n\tsort.Ints(m)\n\tvar pr int = 0\n\tfor i := 0; i < n; i += 2 {\n\t\tpr += m[i+1] - m[i]\n\t}\n\tfmt.Println(pr)\n}\n", "lang_cluster": "Go", "tags": ["sortings"], "code_uid": "a0fc59cbb29713c6ee5b0b3a9840619b", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\tvar s string\n\tfmt.Scan(&s)\n\tiG := strings.Index(s, \"G\")\n\tiT := strings.Index(s, \"T\")\n\tvar r bool\n\tvar i int\n\tif iG-iT < 0 {\n\t\tfor i = iG; i < iT && s[i] != '#'; i += k {\n\t\t}\n\t\tif i == iT {\n\t\t\tr = true\n\t\t}\n\t} else {\n\t\tfor i = iG; i > iT && s[i] != '#'; i -= k {\n\t\t}\n\t\tif i == iT {\n\t\t\tr = true\n\t\t}\n\t}\n\tif r == true {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "0ded09ede549795e42f518278f21cfaf", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, k int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &n, &k); err != nil {\n\t\treturn\n\t}\n\n\tvar ok bool = false\n\n\treader := bufio.NewReader(os.Stdin)\n\tif s, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tvar pos_grasshopper int\n\t\tvar pos_insect int\n\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif s[i] == 'G' {\n\t\t\t\tpos_grasshopper = i\n\t\t\t} else if s[i] == 'T' {\n\t\t\t\tpos_insect = i\n\t\t\t}\n\t\t}\n\t\tif pos_grasshopper > pos_insect {\n\t\t\tk = -k\n\t\t}\n\t\tfor i := pos_grasshopper + k; i >= 0 && i < n; i += k {\n\t\t\tif s[i] == 'T' {\n\t\t\t\tok = true\n\t\t\t\tbreak\n\t\t\t} else if s[i] == '#' {\n\t\t\t\tok = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (k > 0 && i > pos_insect) || (k < 0 && i < pos_insect) {\n\t\t\t\tok = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif ok {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "303b7ef9eb09bfb9ee2dace7c67b7cca", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n,k int\n\tvar s string\n\tfmt.Scan(&n,&k,&s)\n\t\n\tvar t,g int\n\tfor i,a := range(s){\n\t\tif a == 'T' {\n\t\t\tt =i\n\t\t}\n\t\tif a == 'G' {\n\t\t\tg = i\n\t\t}\n\t}\n\tflag := false\n\tif t>g {\n\t\tfor i := g;i<=t;i+=k {\n\t\t\tif s[i] == '#' {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif i == t {\n\t\t\t\tflag = true\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor i := g;i>=t;i-=k {\n\t\t\tif s[i] == '#' {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif i == t {\n\t\t\t\tflag = true\n\t\t\t}\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "98245c1f545e59a8b17f4883481864ba", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n \"fmt\"\n)\nfunc main() {\n var a,b,c int\n fmt.Scan(&a,&b,&c)\n if a-b > c+1 {\n c++\n fmt.Println(c)\n }else {\n a-=b\n fmt.Println(a)\n }\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "4570c5b884cf53b407960b36ef038cd1", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar a,b,c int\n\tfmt.Scan(&a,&b,&c)\n\tif a-b > c+1 {\n\t\tc++\n\t\tfmt.Println(c)\n\t}else {\n\t\ta-=b\n\t\tfmt.Println(a)\n\t}\n}\n\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "8e5e0d01ade11087477dfa4fcaedbaf1", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n n, a, b := getI(), getI(), getI()\n pos := a\n if n-b-1 > pos {\n pos = n-b-1\n }\n result := n-pos\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "38d6e26842ccf31187d6e9dba0a588b7", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main(){\n\tvar a = 0\n\tb := new(string)\n\n\tfmt.Scan(&a)\n\tfmt.Scan(b)\n\n\ttemp := make([]string, 0)\n\ttemp = strings.Split(*b, \"0\")\n\tfor _, each := range temp {\n\t\tfmt.Print(len(each))\n\t}\n\n\n\n}\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d9717558ef5e877d42a7feafb76f0fd1", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n int\n var encodeStr string\n\n fmt.Scan(&n)\n fmt.Scan(&encodeStr)\n\n var counter int\n var prevDigit string = \"-1\"\n\n for i := 0; i < n; i++ {\n var currentDigit string = string(encodeStr[i])\n if currentDigit == \"1\" {\n counter++\n if i == n-1 {\n fmt.Printf(\"%d\", counter)\n }\n } else if currentDigit == \"0\" && prevDigit == \"0\" {\n fmt.Printf(\"0\")\n } else if currentDigit == \"0\" && prevDigit != \"0\" {\n fmt.Printf(\"%d\", counter)\n counter = 0\n }\n prevDigit = currentDigit\n }\n\n if string(encodeStr[n - 1]) == \"0\" {\n fmt.Printf(\"0\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a4ce25e836640ae37b686ae77f4da0eb", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tfmt.Scan(&s)\n\tfmt.Println(decode(s))\n}\n\nfunc decode(s string) int {\n\ttenth := 1\n\tonesCounter := 0\n\tsum := 0\n\tfor i := len(s) - 1; i >= 0; i-- {\n\t\tif s[i] == '1' {\n\t\t\tonesCounter++\n\t\t} else {\n\t\t\tsum += (tenth * onesCounter)\n\t\t\ttenth *= 10\n\t\t\tonesCounter = 0\n\t\t}\n\t}\n\tsum += tenth * onesCounter\n\treturn sum\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "9e1947189fd4b606b92e6559f8e02b5e", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"strings\"\n \"strconv\"\n)\n\nfunc main() {\n var x int\n fmt.Scan(&x)\n x++\n s := strconv.Itoa(x)\n count := strings.Count(s[1:], \"0\")\n if count == len(s) - 1 {\n fmt.Println(1)\n return\n }\n if s[0:1] != \"9\" {\n c := s[0] + 1\n res := string(c)\n for i := 0; i < len(s) - 1; i++ {\n res += \"0\"\n }\n y, _ := strconv.Atoi(res)\n fmt.Println(y - x + 1)\n return\n }\n res := \"1\"\n for i := 0; i < len(s); i++ {\n res += \"0\"\n }\n y, _ := strconv.Atoi(res)\n fmt.Println(y - x + 1)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "c4b0fcab0e9dfea2af533e835c3ad99f", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t//\"os\"\n)\n\nfunc main() {\n\t//os.Stdin, _ = os.OpenFile(\"input.txt\", os.O_RDONLY, 0666)\n\t//os.Stdout, _ = os.OpenFile(\"output.txt\", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)\n\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\n\thold, base := n, 1\n\tfor (hold / 10) != 0 {\n\t\thold /= 10\n\t\tbase *= 10\n\t}\n\tfmt.Printf(\"%d\\n\", (n/base+1)*base-n)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4848725f9c3215e1a75859a5aab0728b", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"strings\"\n \"strconv\"\n)\n\nfunc main() {\n var x int\n fmt.Scan(&x)\n x++\n s := strconv.Itoa(x)\n count := strings.Count(s[1:], \"0\")\n if count == len(s) - 1 {\n fmt.Println(1)\n return\n }\n if s[0:1] != \"9\" {\n c := s[0] + 1\n res := string(c)\n for i := 0; i < len(s) - 1; i++ {\n res += \"0\"\n }\n y, _ := strconv.Atoi(res)\n fmt.Println(y - x + 1)\n return\n }\n res := \"1\"\n for i := 0; i < len(s); i++ {\n res += \"0\"\n }\n y, _ := strconv.Atoi(res)\n fmt.Println(y - x + 1)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "948ae34adda0cf638fce89f15e35241b", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar n int\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.Atoi(r.Text())\n\ta := make([]int, 3001)\n\tcount := 0\n\tfor i:=2; i<=n; i++ {\n\t\tfor j:=2; j 2 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif sum == 2 {\n\t\t\tans++\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n\n// IsPrime 素性测试\nfunc IsPrime(n int) bool {\n\tfor i := int(2); i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn n != 1\n}\n\n// Divisor 约数枚举\nfunc Divisor(n int) (res []int) {\n\tfor i := 1; i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\tres = append(res, i)\n\t\t\tif i != n/i {\n\t\t\t\tres = append(res, n/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "7f8b6296cea27d0d33624a733a4c4ce8", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst (\n\tBIG = 1024 * 1024 * 10\n)\n\nfunc readLine(r *bufio.Reader) string {\n\tbytes, _, err := r.ReadLine()\n\tif err != nil {\n\t\tlog.Fatalln(\"Failed to read line\")\n\t}\n\n\treturn string(bytes)\n}\n\nfunc readInts(r *bufio.Reader) []int {\n\telems := strings.Fields(readLine(r))\n\n\tret := make([]int, len(elems))\n\tfor i, el := range elems {\n\t\ttmp, err := strconv.ParseInt(el, 10, 64)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Failed to parse number %v\", el)\n\t\t}\n\t\tret[i] = int(tmp)\n\t}\n\n\treturn ret\n}\n\ntype Sieve struct {\n\tn int\n\tfirst, primes []int\n}\n\ntype Factor struct {\n\tBase, Exp int\n}\n\nfunc NewSieve(n int) *Sieve {\n\tfirst := make([]int, n+1)\n\tprimes := make([]int, 0)\n\n\tfor i := 2; i <= n; i++ {\n\t\tif first[i] == 0 {\n\t\t\tfirst[i] = i\n\t\t\tprimes = append(primes, i)\n\t\t}\n\n\t\tfor j := 0; j < len(primes) && primes[j] <= first[i] && i*primes[j] <= n; j++ {\n\t\t\tfirst[i*primes[j]] = primes[j]\n\t\t}\n\t}\n\n\tret := Sieve{n, first, primes}\n\n\treturn &ret\n}\n\nfunc (s *Sieve) IsPrime(x int) (bool, error) {\n\tif s.n < x {\n\t\treturn false, errors.New(fmt.Sprintf(\"The largest supported number by this sieve is %v\", s.n))\n\t}\n\tif x < s.primes[0] || x > s.primes[len(s.primes)-1] {\n\t\treturn false, nil\n\t} else if x == s.primes[0] {\n\t\treturn true, nil\n\t}\n\tlow, high := 0, len(s.primes)-1\n\tfor high-low > 1 {\n\t\tmid := (low + high) / 2\n\t\tif s.primes[mid] < x {\n\t\t\tlow = mid\n\t\t} else {\n\t\t\thigh = mid\n\t\t}\n\t}\n\treturn s.primes[high] == x, nil\n}\n\nfunc (s *Sieve) Factors(x int) ([]Factor, error) {\n\tfactors := make([]Factor, 0)\n\n\tif s.n < x {\n\t\treturn factors, errors.New(fmt.Sprintf(\"The largest supported number by this sieve is %v\", s.n))\n\t}\n\n\tfor x > 1 {\n\t\tpi := s.first[x]\n\t\texp := 0\n\t\tfor x > 1 && s.first[x] == pi {\n\t\t\texp += 1\n\t\t\tx /= pi\n\t\t}\n\t\tfactors = append(factors, Factor{pi, exp})\n\t}\n\n\treturn factors, nil\n}\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, BIG)\n\n\tn := readInts(r)[0]\n\ts := NewSieve(n)\n\n\ttotal := 0\n\tfor i := 1; i <= n; i++ {\n\t\tfactors, _ := s.Factors(i)\n\t\tif len(factors) == 2 {\n\t\t\ttotal += 1\n\t\t}\n\t}\n\n\tfmt.Println(total)\n}\n", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "d29050fcdb1eac5b5f8037df687d7018", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nvar s75 = \"What are you doing at the end of the world? Are you busy? Will you save us?\"\nvar s34 = \"What are you doing while sending \\\"\"\nvar s32 = \"\\\"? Are you busy? Will you send \\\"\"\nvar s2 = \"\\\"?\"\n\nvar f = make([]uint64, 100001)\n// golang op. the recursive function call? like the g++ -O2?\nfunc printChar(n int, k uint64) {\n\tif k > f[n] {\n\t\tfmt.Print(\".\")\n\t\treturn\n\t}\n\n\tif n == 0 {\n\t\tfmt.Print(string(s75[k-1]))\n\t\treturn\n\t}\n\n\tif k <= 34 {\n\t\tfmt.Print(string(s34[k-1]))\n\t\treturn\n\t}\n\n\tk -= 34\n\tif k <= f[n-1] {\n\t\tprintChar(n-1, k)\n\t\treturn\n\t}\n\n\tk -= f[n-1]\n\tif k <= 32 {\n\t\tfmt.Print(string(s32[k-1]))\n\t\treturn\n\t}\n\n\tk -= 32\n\tif k <= f[n-1] {\n\t\tprintChar(n-1, k)\n\t\treturn\n\t}\n\n\tk -= f[n-1]\n\tfmt.Print(string(s2[k-1]))\n}\n\n// calc len(fi)\nfunc main() {\n\t// 75\n\t//f0 := \"What are you doing at the end of the world? Are you busy? Will you save us?\"\n\t// 34 + 75(f0) + 32 + 75(f0) + 2 = 68\n\t//f1 := \"What are you doing while sending \\\"\" + f0 + \"\\\"? Are you busy? Will you send \\\"\" + f0 + \"\\\"?\"\n\t//nLen := len(f0)\n\t//fmt.Println(nLen)\n\t//fmt.Println(f1)\n\n\tf[0] = 75\n\t// range ptr/ref\n\tfor i := 1; i < 100001; i++ {\n\t\tf[i] = 34 + f[i-1] + 32 + f[i-1] + 2\n\t}\n\n\tvar q int\n\tfmt.Scan(&q)\n\tfor i := 0; i < q; i++ {\n\t\tvar n int\n\t\tvar k uint64\n\t\tfmt.Scan(&n, &k)\n\t\tprintChar(n, k)\n\t}\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "binary search"], "code_uid": "8da02b0b698fae5a79b67f20bcbe3762", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nvar s75 = \"What are you doing at the end of the world? Are you busy? Will you save us?\"\nvar s34 = \"What are you doing while sending \\\"\"\nvar s32 = \"\\\"? Are you busy? Will you send \\\"\"\nvar s2 = \"\\\"?\"\n\nvar f = make([]uint64, 56) // f[55] ~= 5e18 > k(1e18)\n\nfunc printChar(n int, k uint64) {\n\tnLen := 55\n\tif n > nLen {\n\t\tp := uint64(34) * uint64(n - nLen) // prefix before f[56] -> f[n]\n\t\tif k > p {\n\t\t\tprintChar(nLen, k - p)\n\t\t} else {\n\t\t\tk %= 34\n\t\t\tfmt.Print(string(s34[k-1]))\n\t\t}\n\t\treturn\n\t}\n\n\t// n < 56\n\tif k > f[n] {\n\t\tfmt.Print(\".\")\n\t\treturn\n\t}\n\n\tif n == 0 {\n\t\tfmt.Print(string(s75[k-1]))\n\t\treturn\n\t}\n\n\tif k <= 34 {\n\t\tfmt.Print(string(s34[k-1]))\n\t\treturn\n\t}\n\n\tk -= 34\n\tif k <= f[n-1] {\n\t\tprintChar(n-1, k)\n\t\treturn\n\t}\n\n\tk -= f[n-1]\n\tif k <= 32 {\n\t\tfmt.Print(string(s32[k-1]))\n\t\treturn\n\t}\n\n\tk -= 32\n\tif k <= f[n-1] {\n\t\tprintChar(n-1, k)\n\t\treturn\n\t}\n\n\tk -= f[n-1]\n\tfmt.Print(string(s2[k-1]))\n}\n\n// calc len(fi)\nfunc main() {\n\t// 75\n\t//f0 := \"What are you doing at the end of the world? Are you busy? Will you save us?\"\n\t// 34 + 75(f0) + 32 + 75(f0) + 2 = 68\n\t//f1 := \"What are you doing while sending \\\"\" + f0 + \"\\\"? Are you busy? Will you send \\\"\" + f0 + \"\\\"?\"\n\t//nLen := len(f0)\n\t//fmt.Println(nLen)\n\t//fmt.Println(f1)\n\n\tf[0] = 75\n\t// range ptr/ref\n\tfor i := 1; i < len(f); i++ {\n\t\tf[i] = 34 + f[i-1] + 32 + f[i-1] + 2\n\t}\n\n\tvar q int\n\tfmt.Scan(&q)\n\tfor i := 0; i < q; i++ {\n\t\tvar n int\n\t\tvar k uint64\n\t\tfmt.Scan(&n, &k)\n\t\tprintChar(n, k)\n\t}\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "binary search"], "code_uid": "3dd3419de9cba168ec83f36a69e3cbe4", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar scanner = bufio.NewScanner(reader)\nvar lens [200000]int64\n\nconst (\n\tf0 = \"What are you doing at the end of the world? Are you busy? Will you save us?\"\n\tfi0 = \"What are you doing while sending \\\"\"\n\tfi1 = \"\\\"? Are you busy? Will you send \\\"\"\n\tfi2 = \"\\\"?\"\n\n\tmaxK = 1000000000000000000\n)\n\nfunc f(n int, k int64) byte {\n\tfor {\n\t\tif n == 0 {\n\t\t\tif k < int64(len(f0)) {\n\t\t\t\treturn f0[k]\n\t\t\t}\n\t\t\treturn '.'\n\t\t}\n\n\t\tif k < int64(len(fi0)) {\n\t\t\treturn fi0[k]\n\t\t}\n\t\tk -= int64(len(fi0))\n\n\t\tnxtlen := lens[n-1]\n\t\t//fmt.Println(\"len \", n-1, nxtlen)\n\t\tif k < nxtlen {\n\t\t\tn--\n\t\t\tcontinue\n\t\t}\n\t\tk -= nxtlen\n\n\t\tif k < int64(len(fi1)) {\n\t\t\treturn fi1[k]\n\t\t}\n\t\tk -= int64(len(fi1))\n\n\t\tif k < nxtlen {\n\t\t\tn--\n\t\t\tcontinue\n\t\t}\n\t\tk -= nxtlen\n\n\t\tif k < int64(len(fi2)) {\n\t\t\treturn fi2[k]\n\t\t}\n\t\treturn '.'\n\t}\n}\n\nfunc readint() int {\n\tscanner.Scan()\n\ti, _ := strconv.ParseInt(scanner.Text(), 10, 32)\n\treturn int(i)\n}\n\nfunc readint64() int64 {\n\tscanner.Scan()\n\ti, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn i\n}\n\nfunc main() {\n\tscanner.Split(bufio.ScanWords)\n\n\tlens[0] = int64(len(f0))\n\tfor i := 1; i < cap(lens); i++ {\n\t\tlens[i] = 2 * lens[i-1]\n\t\tif lens[i] < 0 || lens[i] > maxK {\n\t\t\tlens[i] = maxK\n\t\t} else {\n\t\t\tlens[i] += int64(len(fi0) + len(fi1) + len(fi2))\n\t\t}\n\n\t}\n\n\tq := readint()\n\n\tfor i := 0; i < q; i++ {\n\t\tn, k := readint(), readint64()-1\n\t\tfmt.Print(string(f(n, k)))\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "binary search"], "code_uid": "dab64086a113a4a1f5c2bf74dc0ee903", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nvar arr [][]int64\n\nfunc min(a, b int64) int64 {\n\tif a > b {\n\t\treturn b\n\t} else {\n\t\treturn a\n\t}\n}\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tvar n, m, a, b int\n\tvar g, x, y, z int64\n\tfmt.Fscanf(reader, \"%d %d %d %d\\n\", &n, &m, &a, &b)\n\tfmt.Fscanf(reader, \"%d %d %d %d\\n\", &g, &x, &y, &z)\n\tarr = make([][]int64, n)\n\tfor i := 0;i < n;i ++ {\n\t\tarr[i] = make([]int64, m)\n\t\tfor j := 0;j < m;j ++ {\n\t\t\tarr[i][j] = g\n\t\t\tg = (g * x + y) % z\n\t\t}\n\t}\n\tvar ax, bx int\n\tfor bx = 2;bx <= b;bx <<= 1 {\n\t\tfor i := 0;i < n;i ++ {\n\t\t\tfor j := 0;j <= m - bx;j ++ {\n\t\t\t\tarr[i][j] = min(arr[i][j], arr[i][j + bx / 2])\n\t\t\t}\n\t\t}\n\t}\n\tfor ax = 2;ax <= a;ax <<= 1 {\n\t\tfor i := 0;i <= n - ax;i ++ {\n\t\t\tfor j := 0;j < m;j ++ {\n\t\t\t\tarr[i][j] = min(arr[i][j], arr[i + ax / 2][j])\n\t\t\t}\n\t\t}\n\t}\n\tax, bx = ax / 2, bx / 2\n\tvar res int64 = 0\n\tfor i := 0;i <= n - a;i ++ {\n\t\tfor j := 0;j <= m - b;j ++ {\n\t\t\tdi, dj := i + a, j + b\n\t\t\tres += min(min(arr[i][j], arr[di - ax][j]), min(arr[i][dj - bx], arr[di - ax][dj - bx]))\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", res)\n}", "lang_cluster": "Go", "tags": ["two pointers", "data structures"], "code_uid": "72cd6878eebc94bb62de82d03e23d4a8", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\n\nimport \"strconv\"\nimport \"strings\"\n\nfunc L(n int) int {\n\tif n==0 { return 0 }\n\tif n < 10 { return 1 }\n\n\tvar P=make([]int, n+1)\n\tvar C=make([]int, 10)\n\n\tfor i:=0; i < 10; i++ { P[i]=1 }\n\tfor i:=10; i <= n; i++ {\n\t\tm:=cyfry(i, C)\n\t\tmin:=-1\n\t\tfor j:=0; j < m; j++ {\n\t\t\tif C[j] > 0 {\n\t\t\t\tif min < 0 {\n\t\t\t\t\tmin=P[i-C[j]]\n\t\t\t\t} else {\n\t\t\t\t\tif P[i-C[j]] < min {\n\t\t\t\t\t\tmin=P[i-C[j]]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tP[i]=min+1\n\t}\n\treturn P[n]\n}\n\nfunc cyfry(n int, c []int) int {\n\tvar i int\n\tfor i=0; n > 0; i++ {\n\t\tc[i]=n%10\n\t\tn/=10\n\t}\n\treturn i\n}\n\nfunc min(a, b int) int {\n\tif a < b { return a }\n\treturn b\n}\n\nfunc main() {\n\tb:=make([]byte, 20)\n\tmax, _:=os.Stdin.Read(b)\n\ts:=strings.TrimRight(string(b)[0:max], \"\\r\\n\")\n\tn, _:=strconv.Atoi(s)\n\tfmt.Print(L(n))\n}\n", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "eb086ed549a3889a8e8bcb4a66835a11", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar k, n, s, p int\n\tfmt.Scan(&k, &n, &s, &p)\n\tss := (n-1)/s + 1\n\tfmt.Println((ss*k-1)/p + 1)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "00356e3ba3128a89f5aa01acd86ec620", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nconst debug = true\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tin := gsli(reader)\n\n\tpeople := in[0]\n\tplanes := in[1]\n\tpps := in[2]\n\tsheets := in[3]\n\n\tspp := planes / pps\n\tfor spp*pps < planes {\n\t\tspp++\n\t}\n\tppg := spp * people\n\tpacks := ppg / sheets\n\tfor packs*sheets < ppg {\n\t\tpacks++\n\t}\n\n\tfmt.Println(packs)\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// String helpers\n\n// Is Lowercase\n// Given some string[i], return whether it is lower case or not.\n\nfunc isl(b byte) bool {\n\tvar r rune\n\tr = rune(b)\n\treturn unicode.IsLower(r)\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\n// Max Int\n// Returns the max of two ints\n\nfunc maxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// Distance formule\n// Calculates the distance to the origin\n\nfunc dist(x, y float64) float64 {\n\treturn math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))\n}\n\n// Output helpers\n\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\n\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\n// Debug helpers\n\n// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss\n\nfunc dbg(s string, a ...interface{}) {\n\tif debug {\n\t\tfmt.Printf(s, a...)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "6976a68fde9a21fbed150a494eb4f3ed", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var k, n, s, p int\n fmt.Scanf(\"%d%d%d%d\", &k, &n, &s, &p)\n a := (n + s - 1) / s\n fmt.Println((k * a + p - 1) / p)\n}\n\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "50417614e59690057a1832b06290e89b", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar dp [4005]int\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tif a > c {\n\t\ta, c = c, a\n\t}\n\tif b > c {\n\t\tb, c = c, b\n\t}\n\n\tfor i := 1; i < len(dp); i++ {\n\t\tdp[i] = -100000\n\t}\n\tfor i := a; i <= n; i++ {\n\t\tdp[i] = max(dp[i], dp[i-a]+1)\n\t\tif i >= b {\n\t\t\tdp[i] = max(dp[i], dp[i-b]+1)\n\t\t}\n\t\tif i >= c {\n\t\t\tdp[i] = max(dp[i], dp[i-c]+1)\n\t\t}\n\t}\n\n\tfmt.Println(dp[n])\n}\n\nfunc max(x, y int) int {\n\tif x < y {\n\t\tx = y\n\t}\n\n\treturn x\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp"], "code_uid": "891b22be06153189ef8d47c9ded31c61", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc max(x, y int) int {\n if x > y {\n return x\n }\n return y\n}\n\nfunc main() {\n defer writer.Flush()\n var n, a, b, c int\n scanf(\"%d %d %d %d\\n\", &n, &a, &b, &c)\n\n dp := make([]int, n+1)\n\n for i, _ := range dp {\n dp[i] = -1\n }\n dp[0] = 0\n\n for i:=1; i <= n; i++ {\n for _, j := range []int{a, b, c} {\n if i-j >= 0 && dp[i-j] != -1 {\n dp[i] = max(dp[i], dp[i-j]+1)\n }\n }\n }\n printf(\"%d\\n\", dp[n])\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp"], "code_uid": "402178ef7c64f7674553ddef2a798974", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar n, a, b, c int\nvar res []int\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\traw := scanner.Text()\n\tsegs := strings.Split(raw, \" \")\n\tn, _ = strconv.Atoi(segs[0])\n\ta, _ = strconv.Atoi(segs[1])\n\tb, _ = strconv.Atoi(segs[2])\n\tc, _ = strconv.Atoi(segs[3])\n\n\td := Do()\n\tfmt.Println(d)\n}\n\nfunc Do() int {\n\tres = make([]int, n+1, n+1)\n\tfor idx := 1; idx <= n; idx++ {\n\t\tres[idx] = Cut(idx)\n\t\t// fmt.Println(\"res\", idx, res)\n\t}\n\treturn res[n]\n}\n\nfunc Cut(idx int) int {\n\tif idx == 0 {\n\t\treturn 0\n\t}\n\tmax := 0\n\tif idx >= a {\n\t\tleft := idx - a\n\t\tif left == 0 {\n\t\t\tmax = 1\n\t\t\tgoto bnote\n\t\t} else {\n\t\t\tif res[left] == 0 {\n\t\t\t\tmax = 0\n\t\t\t\tgoto bnote\n\t\t\t} else {\n\t\t\t\tmax = 1 + res[left]\n\t\t\t}\n\t\t}\n\t}\nbnote:\n\tbmax := 0\n\t{\n\t\tif idx >= b {\n\t\t\tleft := idx - b\n\t\t\tif left == 0 {\n\t\t\t\tbmax = 1\n\t\t\t\tgoto cnote\n\t\t\t} else {\n\t\t\t\tif res[left] == 0 {\n\t\t\t\t\tbmax = 0\n\t\t\t\t\tgoto cnote\n\t\t\t\t} else {\n\t\t\t\t\tbmax = 1 + res[left]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\ncnote:\n\tcmax := 0\n\t{\n\t\tif idx >= c {\n\t\t\tleft := idx - c\n\t\t\tif left == 0 {\n\t\t\t\tcmax = 1\n\t\t\t\tgoto over\n\t\t\t} else {\n\t\t\t\tif res[left] == 0 {\n\t\t\t\t\tcmax = 0\n\t\t\t\t\tgoto over\n\t\t\t\t} else {\n\t\t\t\t\tcmax = 1 + res[left]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\nover:\n\t{\n\t\tzhi := max3(max, bmax, cmax)\n\t\treturn zhi\n\t}\n}\n\nfunc max3(a, b, c int) int {\n\tres := []int{a, b, c}\n\t// fmt.Println(res)\n\tsort.Ints(res)\n\treturn res[2]\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp"], "code_uid": "2d6e1f3ec9852cfb202ae8c5c1d0cb47", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar n int64\n\tfmt.Fscan(reader, &n)\n\tfmt.Fprintln(writer, n - (n / 2 + n / 3 + n / 5 + n / 7 - n / 6 - n / 10 - n / 14 - n / 15 - n / 21 - n / 35 + n / 30 + n / 42 + n / 70 + n / 105 - n / 210))\n}//2020-07-31 13:53:23.706", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "439b574ee0741857a1565a1f0c8c39eb", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n ans, cnt, prev := 0, 0, '_'\n for _, v := range s {\n if cnt == 5 {\n prev = '_'\n }\n if v == prev {\n cnt++\n } else {\n ans++\n cnt = 1\n prev = v\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "588342401c072c0b2b3591f4f5148779", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n\nimport \n\"fmt\"\n\n\nfunc main() {\n \nvar s string\n \nfmt.Scan(&s)\n \nans, cnt, prev := 0, 0, '_'\n \nfor _, v := range s {\n \nif cnt == 5 {\n \nprev = '_'\n \n}\n \nif v == prev {\n \ncnt++\n \n} else {\n\nans++\n \ncnt = 1\n \nprev = v\n \n}\n \n}\n \nfmt.Println(ans)\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e61c5ec60632d8895640f25fc9cd5a34", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n ans, cnt, prev := 0, 0, '_'\n for _, v := range s {\n if cnt == 5 {\n prev = '_'\n }\n if v == prev {\n cnt++\n } else {\n ans++\n cnt = 1\n prev = v\n }\n }\n fmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0eb6b2cbf700512ef669e476423d63f2", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn, b, p := nextInt(), nextInt(), nextInt()\n\tcntB := 0\n\tp *= n\n\ta := 512\n\n\tfor n > 1 {\n\t\tfor a > n {\n\t\t\ta /= 2\n\t\t}\n\t\tcntB += b*a + a/2\n\t\tn = a/2 + n - a\n\t}\n\n\tprintln(cntB, p*n)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "6eb4c267dd5a6a7e2313cabc2ecc5cb4", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar b, n, p, x, y int\n\tfmt.Scanf(\"%d%d%d\", &n, &b, &p)\n\ty = n * p\n\tfor n > 1 {\n\t\tk := 1\n\t\tfor k <= n {\n\t\t\tk = k << 1\n\t\t}\n\t\tk = k >> 2\n\t\tx += (2*b + 1) * k\n\t\tn = n - k\n\t}\n\tfmt.Println(x, y)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "a8f5a9cf2954bd9d87e02fe3439cf704", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\ntype BufferedWriter interface {\n\tPrintf(format string, a ...interface{})\n\tFlush()\n}\n\ntype writerImpl struct {\n\t*bufio.Writer\n}\n\nfunc NewBufferedWriter(writer io.Writer) BufferedWriter {\n\treturn &writerImpl{Writer: bufio.NewWriter(writer)}\n}\n\nfunc (impl *writerImpl) Printf(f string, a ...interface{}) {\n\tfmt.Fprintf(impl.Writer, f, a...)\n}\n\nfunc (impl *writerImpl) Flush() {\n\timpl.Writer.Flush()\n}\n\ntype WordScanner interface {\n\tNextInt() int\n\tNextInt64() int64\n\tNextString() string\n}\n\ntype wordScannerImpl struct {\n\t*bufio.Scanner\n}\n\nfunc NewWordScanner(reader io.Reader) WordScanner {\n\ts := bufio.NewScanner(reader)\n\ts.Split(bufio.ScanWords)\n\t// adjust the following size as needed\n\t// 2 << 17 is good enough to scan strings of len 2*10^5\n\t// it could go as high as 2 << 26 before cf judge breaks\n\tsize := 2 << 20\n\tbuf := make([]byte, size)\n\ts.Buffer(buf, size)\n\treturn &wordScannerImpl{Scanner: s}\n}\n\nfunc (impl *wordScannerImpl) NextInt() int {\n\timpl.Scan()\n\tbb := impl.Bytes()\n\ti := 0\n\tif bb[0] == '-' {\n\t\tfor _, b := range bb[1:] {\n\t\t\ti *= 10\n\t\t\ti -= int(b - '0')\n\t\t}\n\t\treturn i\n\t}\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += int(b - '0')\n\t}\n\treturn i\n}\n\nfunc (impl *wordScannerImpl) NextInt64() int64 {\n\timpl.Scan()\n\tbb := impl.Bytes()\n\ti := int64(0)\n\tif bb[0] == '-' {\n\t\tfor _, b := range bb[1:] {\n\t\t\ti *= 10\n\t\t\ti -= int64(b - '0')\n\t\t}\n\t\treturn i\n\t}\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += int64(b - '0')\n\t}\n\treturn i\n}\n\nfunc (impl *wordScannerImpl) NextString() string {\n\timpl.Scan()\n\treturn impl.Text()\n}\n\nvar reader = NewWordScanner(os.Stdin)\nvar writer = NewBufferedWriter(os.Stdout)\n\nfunc main() {\n\tdefer writer.Flush()\n\tn, b, p := reader.NextInt64(), reader.NextInt64(), reader.NextInt64()\n\ty := n*p\n\tx := int64(0)\n\tfor n > 1 {\n\t\tk := getK(n)\n\t\tx += k*b + k/2\n\t\tn = k/2 + n - k\n\t}\n\twriter.Printf(\"%d %d\\n\", x, y)\n}\n\nfunc getK(n int64) int64 {\n\tcurr := int64(1)\n\tfor n > 1 {\n\t\tn >>= 1\n\t\tcurr <<= 1\n\t}\n\treturn curr\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "167281744a3f83ec34678a4cafdda211", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tvar r, c = 1, n\n\n\tfor i := 2; i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\tr, c = i, n/i\n\t\t}\n\t}\n\n\tfmt.Println(r, c)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "3b0e297e94182e61e477bcac2852f787", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int\n\tfor I(&n, \"\\n\") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int) {\n\ta := int(math.Sqrt(float64(n)))\n\tb := a\n\tfor a*b != n {\n\t\tif a*b < n {\n\t\t\tb++\n\t\t} else {\n\t\t\ta--\n\t\t}\n\t}\n\tO(a, \" \")\n\tO(b, \"\\n\")\n}", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "a250fa03834c2b781d76c24a1e8c4914", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\n\tfor i := int(math.Sqrt(float64(N))); i >= 1; i-- {\n\t\tif N % i == 0 {\n\t\t\tfmt.Println(i, N / i)\n\t\t\tbreak\n\t\t}\n\t}\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r:rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "fb939799ae035b0ac5b8eedd51c24557", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype IO struct {\n\tscanner *bufio.Scanner\n\twriter *bufio.Writer\n}\nfunc NewIO() IO {\n\tio := IO{scanner: bufio.NewScanner(os.Stdin), \n\t\twriter: bufio.NewWriter(os.Stdout)}\n\tio.scanner.Split(bufio.ScanWords)\n\treturn io\n}\nfunc toInt(buf []byte) (n int) {\n\tsgn := false\n\tfor _, v := range buf {\n\t\tif v == '-' {\n\t\t\tsgn = true\n\t\t} else {\n\t\t\tn = n*10 + int(v-'0')\n\t\t}\n\t}\n\tif sgn {\n\t\tn = -n\n\t}\n\treturn\n}\nfunc (io *IO) NextInt() int {\n\tio.scanner.Scan()\n\treturn toInt(io.scanner.Bytes())\n}\nfunc (io *IO) Write(data ...interface{}) {\n\tfor _, el := range data {\n\t\tswitch el.(type) {\n\t\t\tcase int:\n\t\t\t\tio.writer.WriteString(strconv.Itoa(el.(int)))\n\t\t\tcase string:\n\t\t\t\tio.writer.WriteString(el.(string))\n\t\t\tcase rune:\n\t\t\t\tio.writer.WriteRune(el.(rune))\n\t\t}\n\t}\n}\nfunc (io *IO) Writeln(data ...interface{}) {\n\tio.Write(data...)\n\tio.writer.WriteRune('\\n')\n}\nfunc (io *IO) Flush() {\n\tio.writer.Flush()\n}\n\nfunc Max(a, b int) int {\n\tif a>b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nconst N int = 100\n\nfunc main() {\n\tio := NewIO()\n\n\tn := io.NextInt()\n\tvar a [N](int)\n\tans := 0\n\tfor i:=0; i0 && a[i]!=1 && a[i-1]!=1 {\n\t\t\tgoto Bad\n\t\t}\n\t\tif i>1 && a[i]==2 && a[i-1]==1 && a[i-2]==3 {\n\t\t\tans--\n\t\t}\n\t\tif i>0 {\n\t\t\tif Max(a[i],a[i-1])==2 {\n\t\t\t\tans += 3\n\t\t\t} else {\n\t\t\t\tans += 4\n\t\t\t}\n\t\t}\n\t}\n\n\tio.Writeln(\"Finite\")\n\tio.Writeln(ans)\n\tio.Flush()\n\treturn\n\nBad:\n\tio.Writeln(\"Infinite\")\n\tio.Flush()\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["geometry"], "code_uid": "64963ade8bc79d118e3b4890b91215e4", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n \"fmt\"\n)\n\nfunc main() {\n input := bufio.NewScanner(os.Stdin)\n input.Split(bufio.ScanWords)\n\n input.Scan()\n n, _ := strconv.Atoi(input.Text())\n\n a := make([]int, n, n)\n for i := range a {\n input.Scan()\n a[i], _ = strconv.Atoi(input.Text())\n }\n\n const (\n _ = iota\n circle\n triangle\n square\n )\n\n ans := 0\n for i := 1; i < n; i++ {\n if a[i - 1] == circle {\n if a[i] == triangle {\n ans += 3\n } else {\n ans += 4\n }\n } else if a[i - 1] == triangle {\n if a[i] == circle {\n ans += 3\n } else {\n ans = -1\n break\n }\n } else {\n if a[i] == circle {\n ans += 4\n } else {\n ans = -1\n break\n }\n }\n }\n\n if ans == -1 {\n fmt.Println(\"Infinite\")\n } else {\n for i := 1; i < n - 1; i++ {\n if a[i - 1] == square && a[i] == circle && a[i + 1] == triangle {\n ans--\n }\n }\n\n fmt.Println(\"Finite\")\n fmt.Println(ans)\n }\n}\n", "lang_cluster": "Go", "tags": ["geometry"], "code_uid": "66c3e52c2100d39bb48e8e5edee32bdd", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype IO struct {\n\tscanner *bufio.Scanner\n\twriter *bufio.Writer\n}\nfunc NewIO() IO {\n\tio := IO{scanner: bufio.NewScanner(os.Stdin), \n\t\twriter: bufio.NewWriter(os.Stdout)}\n\tio.scanner.Split(bufio.ScanWords)\n\treturn io\n}\nfunc toInt(buf []byte) (n int) {\n\tfor _, v := range buf {\n\t\tn = n*10 + int(v-'0')\n\t}\n\treturn\n}\nfunc (io *IO) NextInt() int {\n\tio.scanner.Scan()\n\treturn toInt(io.scanner.Bytes())\n}\nfunc (io *IO) Write(data ...interface{}) {\n\tfor _, el := range data {\n\t\tswitch el.(type) {\n\t\t\tcase int:\n\t\t\t\tio.writer.WriteString(strconv.Itoa(el.(int)))\n\t\t\tcase string:\n\t\t\t\tio.writer.WriteString(el.(string))\n\t\t\tcase rune:\n\t\t\t\tio.writer.WriteRune(el.(rune))\n\t\t}\n\t}\n}\nfunc (io *IO) Writeln(data ...interface{}) {\n\tio.Write(data...)\n\tio.writer.WriteRune('\\n')\n}\nfunc (io *IO) Flush() {\n\tio.writer.Flush()\n}\n\nfunc Max(a, b int) int {\n\tif a>b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nconst N int = 100\n\nfunc main() {\n\tio := NewIO()\n\n\tn := io.NextInt()\n\tvar a [N](int)\n\tans := 0\n\tfor i:=0; i0 && a[i]!=1 && a[i-1]!=1 {\n\t\t\tgoto Bad\n\t\t}\n\t\tif i>1 && a[i]==2 && a[i-1]==1 && a[i-2]==3 {\n\t\t\tans--\n\t\t}\n\t\tif i>0 {\n\t\t\tif Max(a[i],a[i-1])==2 {\n\t\t\t\tans += 3\n\t\t\t} else {\n\t\t\t\tans += 4\n\t\t\t}\n\t\t}\n\t}\n\n\tio.Writeln(\"Finite\")\n\tio.Writeln(ans)\n\tio.Flush()\n\treturn\n\nBad:\n\tio.Writeln(\"Infinite\")\n\tio.Flush()\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["geometry"], "code_uid": "75dc928abf003993f964c99dbd9c0a4c", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// A. Playoff\n\nfunc match(a, b int) int {\n\n\tif a&b == 0 {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc solve() {\n\n\tvar n int\n\tscanf(\"%d\\n\", &n)\n\n\t/*matches := 1 << n\n\tcompetitors := []int{}\n\n\tfor i := 1; i <= matches; i++ {\n\t\tcompetitors = append(competitors, i)\n\t}\n\n\t//println(matches, competitors)\n\n\tfor len(competitors) > 1 {\n\n\t\ta := competitors[0]\n\t\tb := competitors[1]\n\t\tcompetitors = competitors[2:]\n\n\t\twinner := match(a, b)\n\n\t\t//println(competitors, winner)\n\n\t\tcompetitors = append(competitors, winner)\n\t}*/\n\n\tprintln((1 << n) - 1)\n}\n\nfunc main() {\n\n\tvar t int\n\n\tscanf(\"%d\\n\", &t)\n\n\tfor t > 0 {\n\t\tsolve()\n\t\tt--\n\t}\n\n\twriter.Flush()\n}\n\n// Constants\n\nconst (\n\tB = 1e9\n\tBB = 1e18\n)\n\n// Data structures\n\ntype Pair struct {\n\tFirst, Second int\n}\n\ntype Pairs []Pair\n\nfunc (p Pairs) Len() int { return len(p) }\nfunc (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }\nfunc (p Pairs) Swap(i, j int) { p[i], p[j] = p[j], p[i] }\n\n// Util functions\n\nfunc tos(n int) string {\n\treturn strconv.Itoa(n)\n}\n\nfunc toi(s string) int {\n\t// ignore error\n\tn, _ := strconv.Atoi(s)\n\n\treturn n\n}\n\nfunc pow(b, n uint) uint {\n\n\tif n == 0 {\n\t\treturn 1\n\t}\n\n\tvar a uint = 1\n\n\tfor n >= 1 {\n\t\ta = b * a\n\t\tn--\n\t}\n\n\treturn a\n}\n\nfunc flip(b uint) uint {\n\n\tif b == 0 {\n\t\treturn 1\n\t}\n\n\treturn 0\n}\n\nfunc bin(dec uint) []uint {\n\n\tbin := []uint{}\n\n\tfor dec > 0 {\n\t\tif dec%2 != 0 {\n\t\t\tbin = append(bin, 1)\n\t\t} else {\n\t\t\tbin = append(bin, 0)\n\t\t}\n\n\t\tdec = dec / 2\n\t}\n\n\tfor i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {\n\t\tbin[i], bin[j] = bin[j], bin[i]\n\t}\n\n\treturn bin\n}\n\nfunc dec(b []uint) uint {\n\n\tvar dec uint = 0\n\n\tfor i, v := range b {\n\t\tdec += (2 << i) * v\n\t}\n\n\treturn dec\n}\n\n// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx\n// functions doesn't.\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\treader = bufio.NewReader(os.Stdin)\n)\n\nfunc scanf(f string, a ...interface{}) {\n\tfmt.Fscanf(reader, f, a...)\n}\n\nfunc printf(f string, a ...interface{}) {\n\tfmt.Fprintf(writer, f, a...)\n}\n\nfunc println(f ...interface{}) {\n\tfmt.Fprintln(writer, f...)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "12f5312529123fe6e49a3eb785943851", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n \r\nimport (\r\n \"fmt\"\r\n \"os\"\r\n \"math\"\r\n)\r\n \r\nfunc main() {\r\n var t int\r\n fmt.Fscan(os.Stdin, &t)\r\n for i := 0; i < t; i++ {\r\n var n int\r\n fmt.Fscan(os.Stdin, &n)\r\n if n == 0 {\r\n fmt.Println(n)\r\n } else {\r\n r:= math.Pow(2, float64(n)) - float64(1)\r\n fmt.Println(int64(r))\r\n }\r\n }\r\n}\r\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "7d7bec5e1f1bc1a2f31aec05a283079a", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"math\"\r\n\t\"os\"\r\n\t\"strconv\"\r\n\t\"strings\"\r\n)\r\n\r\ntype CF1651A struct {\r\n\tsc *bufio.Reader\r\n\tsplit []string\r\n\tindex int\r\n\tseparator string\r\n}\r\n\r\nfunc (in *CF1651A) GetLine() string {\r\n\tline, err := in.sc.ReadString('\\n')\r\n\tif err != nil {\r\n\t\tfmt.Println(\"error line:\", line, \" err: \", err)\r\n\t}\r\n\tin.split = []string{}\r\n\tin.index = 0\r\n\treturn line\r\n}\r\nfunc (in *CF1651A) load() {\r\n\tif len(in.split) <= in.index {\r\n\t\tin.split = strings.Split(in.GetLine(), in.separator)\r\n\t\tin.index = 0\r\n\t}\r\n}\r\n\r\nfunc (in *CF1651A) NextInt() int {\r\n\tin.load()\r\n\tval, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))\r\n\tin.index++\r\n\treturn val\r\n}\r\n\r\nfunc (in *CF1651A) NextInt64() int64 {\r\n\tin.load()\r\n\tval, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)\r\n\tin.index++\r\n\treturn val\r\n}\r\n\r\nfunc (in *CF1651A) NextString() string {\r\n\tin.load()\r\n\tval := strings.TrimSpace(in.split[in.index])\r\n\tin.index++\r\n\treturn val\r\n}\r\n\r\n/**\r\nRun solve the problem CF1651A\r\nDate: 21/03/22\r\nUser: pepradere\r\nURL: https://codeforces.com/problemset/problem/1651/A\r\nProblem: CF1651A\r\n**/\r\nfunc (in *CF1651A) Run() {\r\n\tfor t := in.NextInt(); t > 0; t-- {\r\n\t\tn := in.NextInt()\r\n\t\tp := int(math.Pow(2, float64(n)))\r\n\t\tfmt.Println(p - 1)\r\n\t}\r\n}\r\n\r\nfunc NewCF1651A(r *bufio.Reader) *CF1651A {\r\n\treturn &CF1651A{\r\n\t\tsc: r,\r\n\t\tsplit: []string{},\r\n\t\tindex: 0,\r\n\t\tseparator: \" \",\r\n\t}\r\n}\r\n\r\nfunc main() {\r\n\tNewCF1651A(bufio.NewReader(os.Stdin)).Run()\r\n}\r\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "710540416204efbb99d73a0676cb6815", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tkoutsu := make(map[string]int)\n\tshuntsu := make(map[string][]int)\n\tscanner.Scan() \n\ttext := scanner.Text()\n\ttiles := strings.Split(text, \" \")\n\tfor _, s := range tiles {\n\t\tif _, ok := koutsu[s]; !ok {\n\t\t\tkoutsu[s] = 1\n\t\t} else {\n\t\t\tkoutsu[s]++\n\t\t}\n\t\tchar := strings.Split(s, \"\")\n\t\tsuit := char[1]\n\t\tdigit, _ := strconv.Atoi(char[0])\n\t\tdigit = digit - 1\n\t\tif _, ok := shuntsu[suit]; !ok {\n\t\t\tarr := make([]int, 9)\n\t\t\tarr[digit] = 1\n\t\t\tshuntsu[suit] = arr\n\t\t} else {\n\t\t\tshuntsu[suit][digit] = 1\n\t\t}\n\t}\n\n\tminKou := 2\n\tfor _, v := range koutsu {\n\t\tif 3 - v < minKou {\n\t\t\tminKou = 3 - v\n\t\t}\n\t\tif minKou == 0 {\n\t\t\tfmt.Println(minKou)\n\t\t\treturn\n\t\t}\n\t}\n\tminShun := 2\n\tfor _, arr := range shuntsu {\n\t\tcount := 0\n\t\tfor i := 0; i < len(arr) - 2; i++ {\n\t\t\tcount = arr[i] + arr[i + 1] + arr[i + 2]\n\t\t\tif 3 - count < minShun {\n\t\t\t\tminShun = 3 - count\n\t\t\t}\n\t\t}\n\t\tif minShun == 0 {\n\t\t\tfmt.Println(minShun)\n\t\t\treturn\n\t\t}\n\t}\n\tif minKou < minShun {\n\t\tfmt.Println(minKou)\n\t} else {\n\t\tfmt.Println(minShun)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "b599544b7341a7c3488501ce1ed6f284", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc koutsu(t1, t2, t3 string) int {\n\n\tif t1 == t2 && t2 == t3 {\n\t\treturn 0\n\t}\n\n\tstrs := []string{t1, t2, t3}\n\tsort.Strings(strs)\n\tif strs[0] == strs[1] || strs[1] == strs[2] {\n\t\treturn 1\n\t}\n\treturn 2\n}\n\nfunc contains(value string, str []string) bool {\n\tfor _, st := range str {\n\t\tif st == value {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc shuntsu(t1, t2, t3 string) int {\n\ttiles := []string{t1, t2, t3}\n\tletters := [3]string{\"m\", \"p\", \"s\"}\n\tbest := 2\n\tfor i := 1; i <= 7; i++ {\n\t\tfor _, lt := range letters {\n\t\t\tna := strconv.Itoa(i) + lt\n\t\t\tnb := strconv.Itoa(i+1) + lt\n\t\t\tnc := strconv.Itoa(i+2) + lt\n\t\t\tc := 0\n\t\t\tif contains(na, tiles) {\n\t\t\t\tc++\n\t\t\t}\n\t\t\tif contains(nb, tiles) {\n\t\t\t\tc++\n\t\t\t}\n\t\t\tif contains(nc, tiles) {\n\t\t\t\tc++\n\t\t\t}\n\t\t\tbest = min(best, 3-c)\n\t\t}\n\t}\n\treturn best\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar t1, t2, t3 string\n\n\tfmt.Scanf(\"%s %s %s\", &t1, &t2, &t3)\n\tfmt.Println(min(koutsu(t1, t2, t3), shuntsu(t1, t2, t3)))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "05d7aeed769cd54d9111af547bc28c3e", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc consec(arr []int) int {\n\n\tans := 0\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tcur := 1\n\t\tlast := arr[i]\n\t\tfor j := i + 1; j < len(arr); j++ {\n\t\t\tif arr[j] == last+1 {\n\t\t\t\tlast = last + 1\n\t\t\t\tcur++\n\t\t\t} else {\n\t\t\t\tans = max(ans, cur)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tans = max(ans, cur)\n\t}\n\treturn ans\n}\n\nfunc same(arr []int) int {\n\n\tans := 0\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tcur := 1\n\t\tlast := arr[i]\n\t\tfor j := i + 1; j < len(arr); j++ {\n\t\t\tif arr[j] == last {\n\t\t\t\tcur++\n\t\t\t} else {\n\t\t\t\tans = max(ans, cur)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tans = max(ans, cur)\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar a, b, c string\n\n\ts := []int{}\n\tm := []int{}\n\tp := []int{}\n\n\tscanf(\"%s %s %s\\n\", &a, &b, &c)\n\n\tif a[1] == byte('s') {\n\t\tcur := int(a[0] - byte('0'))\n\t\ts = append(s, cur)\n\t}\n\tif a[1] == byte('m') {\n\t\tcur := int(a[0] - byte('0'))\n\t\tm = append(m, cur)\n\t}\n\tif a[1] == byte('p') {\n\t\tcur := int(a[0] - byte('0'))\n\t\tp = append(p, cur)\n\t}\n\n\tif b[1] == byte('s') {\n\t\tcur := int(b[0] - byte('0'))\n\t\ts = append(s, cur)\n\t}\n\tif b[1] == byte('m') {\n\t\tcur := int(b[0] - byte('0'))\n\t\tm = append(m, cur)\n\t}\n\tif b[1] == byte('p') {\n\t\tcur := int(b[0] - byte('0'))\n\t\tp = append(p, cur)\n\t}\n\n\tif c[1] == byte('s') {\n\t\tcur := int(c[0] - byte('0'))\n\t\ts = append(s, cur)\n\t}\n\tif c[1] == byte('m') {\n\t\tcur := int(c[0] - byte('0'))\n\t\tm = append(m, cur)\n\t}\n\tif c[1] == byte('p') {\n\t\tcur := int(c[0] - byte('0'))\n\t\tp = append(p, cur)\n\t}\n\n\tsort.Ints(s)\n\tsort.Ints(p)\n\tsort.Ints(m)\n\n\t// fmt.Println(s, p, m)\n\n\t// fmt.Println(consec(p))\n\n\tif same(s) == 3 || consec(s) == 3 || same(p) == 3 || consec(p) == 3 || same(m) == 3 || consec(m) == 3 {\n\t\tprintf(\"0\")\n\t\treturn\n\t}\n\n\tif same(s) == 2 || consec(s) == 2 || same(p) == 2 || consec(p) == 2 || same(m) == 2 || consec(m) == 2 {\n\t\tprintf(\"1\")\n\t\treturn\n\t}\n\n\tif len(s) == 2 {\n\t\ts = []int{s[0], s[0] + 1, s[1]}\n\t} else if len(s) == 3 {\n\t\ts = []int{s[0], s[0] + 1, s[1], s[1] + 1, s[2]}\n\t}\n\tif len(m) == 2 {\n\t\tm = []int{m[0], m[0] + 1, m[1]}\n\t} else if len(m) == 3 {\n\t\tm = []int{m[0], m[0] + 1, m[1], m[1] + 1, m[2]}\n\t}\n\tif len(p) == 2 {\n\t\tp = []int{p[0], p[0] + 1, p[1]}\n\t} else if len(p) == 3 {\n\t\tp = []int{p[0], p[0] + 1, p[1], p[1] + 1, p[2]}\n\t}\n\n\tif same(s) >= 3 || consec(s) >= 3 || same(p) >= 3 || consec(p) >= 3 || same(m) >= 3 || consec(m) >= 3 {\n\t\tprintf(\"1\")\n\t\treturn\n\t}\n\n\tprintf(\"2\")\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "9d63e4770022966c4b620034d2025517", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\n\nfunc main() {\n var k, v int\n var a []int\n fmt.Scan(&k)\n for i:=0; i 0 {\n return ans\n }\n return 0\n }())\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "21ed43ab68ef5d10d35e3087694280ac", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k int\n\tfmt.Scan(&k)\n\tma := 0\n\tfor i := 0; i < k; i++ {\n\t\tvar r int\n\t\tfmt.Scan(&r)\n\t\tif ma < r {\n\t\t\tma = r\n\t\t}\n\t}\n\tans := ma - 25\n\tif ans < 0 {\n\t\tans = 0\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "95b914f9b88ec7d641b4aac1c74c4d10", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tz:= bufio.NewScanner(os.Stdin)\n\tz.Split(bufio.ScanWords)\n\tz.Scan()\n\tn, _:= strconv.Atoi(strings.TrimSpace(z.Text()))\n\tm := 0\n\tfor i := 0; i < n; i++ {\n\t\tz.Scan()\n\t\ta,_ := strconv.Atoi(strings.TrimSpace(z.Text()))\n\t\tif a>m {\n\t\t\tm=a\n\t\t}\n\t}\n\n\tif m <= 25 {\n\t\tm = 0\n\t} else {\n\t\tm -= 25\n\t}\n\tfmt.Println(m)\n}", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "9d3422451e88955dbaf04abc7504887c", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "\npackage main\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tkecil,besar,digit :=false,false,false\n\tfmt.Scan(&s)\n\tlens:=len(s)\n\tif lens<5 {\n\t\tfmt.Println(\"Too weak\")\n\t} else {\n\t\tfor i:=0;i='a' && s[i] <='z' {\n\t\t\t\tkecil=true\n\t\t\t}\n\t\t\tif s[i] >='A' && s[i] <='Z' {\n\t\t\t\tbesar=true\n\t\t\t}\n\t\t\tif s[i] >='0' && s[i] <='9' {\n\t\t\t\tdigit=true\n\t\t\t}\n\t\t}\n\t\tif kecil==true && besar==true && digit==true {\n\t\t\tfmt.Println(\"Correct\")\n\t\t} else {\n\t\t\tfmt.Println(\"Too weak\")\n\t\t}\n\t}\n}\n\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "636732590ae437d4781f3dca07db6248", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n var a,b,c,d bool\n fmt.Scan(&s)\n if len(s) >= 5 { a = true }\n for _, v := range s {\n if (v >= 'A') && (v <= 'Z') { b = true }\n if (v >= 'a') && (v <= 'z') { c = true }\n if (v >= '0') && (v <= '9') { d = true }\n }\n if a && b && c && d {\n fmt.Println(\"Correct\")\n } else {\n fmt.Println(\"Too weak\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "36e9f5debccf3b0ee67c79273bb8ba4e", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n var a,b,c,d bool\n fmt.Scan(&s)\n if len(s) >= 5 { a = true }\n for _, v := range s {\n if (v >= 'A') && (v <= 'Z') { b = true }\n if (v >= 'a') && (v <= 'z') { c = true }\n if (v >= '0') && (v <= '9') { d = true }\n }\n if a && b && c && d {\n fmt.Println(\"Correct\")\n } else {\n fmt.Println(\"Too weak\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ca073bbc6503e1744b52e7260253f0ae", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s1, s2 string\n\tvar ans strings.Builder\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &s1)\n\tfmt.Fscan(in, &s2)\n\n\tfor i := 0; i < len(s1); i++ {\n\t\tif s2[i] == s1[i] {\n\t\t\tans.WriteString(\"0\")\n\t\t} else {\n\t\t\tans.WriteString(\"1\")\n\t\t}\n\t}\n\tfmt.Println(ans.String())\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "8760b0d3ab8aa41930523d704d1c88db", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s1,s2 string\n fmt.Scan(&s1,&s2)\n for i := 0; i < len(s1); i++ {\n if (s1[i] == s2[i]) { fmt.Print(\"0\") } else { fmt.Print(\"1\") }\n }\n fmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "27693cb46aa60c2fdcf28ca3d8ab4464", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar m, n string\n\tfmt.Scan(&m, &n)\n\tfor i := 0; i < len(m); i++ {\n\t\tif m[i] == n[i] {\n\t\t\tfmt.Print(\"0\")\n\t\t} else {\n\t\t\tfmt.Print(\"1\")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "84fc840179319dd2703a78c2c7994bda", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc bitSum(a int64) int {\n\tsum := 0\n\tfor {\n\t\tif a <= 0 {\n\t\t\tbreak\n\t\t}\n\t\tsum += int(a % 10)\n\t\ta /= 10\n\t}\n\treturn sum\n}\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tif n < 10 {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\n\tten := int64(10)\n\tm := n\n\tfor {\n\t\tm /= 10\n\t\tif m < 10 {\n\t\t\tbreak\n\t\t}\n\t\tten *= 10\n\t}\n\n\ta := int64(9)\n\tfor {\n\t\tc := int64(a*10 + 9)\n\t\tif n-c < 0 {\n\t\t\tfor i := int64(1); i < 10; i++ {\n\t\t\t\tif n > i*ten+a {\n\t\t\t\t\ta = (i-1)*ten + a\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\ta = c\n\t}\n\n\tsum := bitSum(a)\n\tsum += bitSum(n - a)\n\n\tfmt.Println(sum)\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "4e23b93b88eb1f0fa3d4cd27e7f3b06e", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n\t\"math\"\n)\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc scanln(a ...interface{}) { fmt.Fscanln(reader, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar n int64\n\tscanln(&n)\n\tvar a,b int64\n\tvar c,s int64\n\tc = n\n\tfor ;c >10;s++ {\n\t\tc /= 10\n\t}\n\ta = c * int64(math.Pow(float64(10),float64(s)))-1\n\tb = n - a\n\tvar r int64\n\tfor ;a >0;{\n\t\tr += a%10\n\t\ta /= 10\n\t\t\n\t} \n\tfor b>0 {\n\t\tr += b%10\n\t\tb /= 10\n\t}\n\tprintln(r)\n}", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "d508578c8224ede2cd28eb77404672e2", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\tn int64\n)\n\nfunc main() {\n\tfor {\n\t\tif _, err := fmt.Scan(&n); err != nil {\n\t\t\tbreak\n\t\t}\n\t\tsolve()\n\t}\n}\n\nfunc solve() {\n\tans := int64(0)\n\tfor a := int64(0); a <= n; a = a*10 + 9 {\n\t\tans = max(ans, s(a)+s(n-a))\n\t}\n\tfmt.Println(ans)\n}\n\nfunc s(x int64) int64 {\n\tsum := int64(0)\n\tfor x > 0 {\n\t\tsum += x % 10\n\t\tx /= 10\n\t}\n\treturn sum\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "42bdf97d6b9d7a5c298cf5bb93fec81d", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"bufio\"\nimport \"os\"\n\nfunc min(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc max(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc solve(l1, r1, l2, r2, k int64) int64 {\n\tl := max(l1, l2)\n\tr := min(r1, r2)\n\tif l > r {\n\t\treturn 0\n\t}\n\tres := r - l + 1\n\tif (l <= k) && (k <= r) {\n\t\treturn res - 1\n\t}\n\treturn res\n}\n\nfunc main() {\n\tbufin := bufio.NewReader(os.Stdin)\n\tbufout := bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar l1, r1, l2, r2, k int64\n\tfmt.Fscanf(bufin, \"%d %d %d %d %d\\n\", &l1, &r1, &l2, &r2, &k)\n\tres := solve(l1, r1, l2, r2, k)\n\tfmt.Fprintf(bufout, \"%d\\n\", res)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "e0e6ed229a1c34af9aca0dd4a89b9ba6", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l1, r1, l2, r2, k int64\n\tfmt.Scan(&l1, &r1, &l2, &r2, &k)\n\n\tl := l1\n\tif l2 > l1 {\n\t\tl = l2\n\t}\n\tr := r1\n\tif r2 < r1 {\n\t\tr = r2\n\t}\n\n\tresult := r - l + 1\n\tif k >= l && k <= r {\n\t\tresult--\n\t}\n\n\tif result < 0 {\n\t\tresult = 0\n\t}\n\n\tfmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9727c52ec064a1fab10513d2a505041d", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l1, r1, l2, r2, k int64\n\tif _, err := fmt.Scanf(\"%d %d %d %d %d\\n\", &l1, &r1, &l2, &r2, &k); err != nil {\n\t\treturn\n\t}\n\n\tif r2 < l1 || r1 < l2 {\n\t\tfmt.Println(\"0\")\n\t} else {\n\t\tl := l1\n\t\tif l < l2 {\n\t\t\tl = l2\n\t\t}\n\t\tr := r1\n\t\tif r > r2 {\n\t\t\tr = r2\n\t\t}\n\n\t\tvar prink int64 = 0\n\t\tif l <= k && k <= r {\n\t\t\tprink = 1\n\t\t}\n\n\t\tfmt.Println(r - l - prink + 1)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "3075e0751251d0299ed24c3da3e5b55a", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a, b int64) int64 {\n\tif a a {\n\t\ta, b = b, a\n\t}\n\tfor {\n\t\tr = a % b\n\t\tif r == 0 {\n\t\t\tbreak\n\t\t}\n\t\ta = b\n\t\tb = r\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar t,w,b int64\n\tfmt.Scanf(\"%d %d %d\",&t,&w,&b)\n p:=gcd(w,b)\n qw:=w/p\n qb:=b/p\n k:=t/p/qw/qb\n m:=min(w,b)-1\n r:=k + m*k + min(m,t-k*p*qw*qb)\n if r>0 {\n\t rt:=gcd(r,t)\n \tr,t=r/rt,t/rt\n\t fmt.Printf(\"%d/%d\\n\",r,t)\n\t} else {\n\t\tfmt.Printf(\"0/1\\n\")\t\n\t}\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "11a07519041618e61eaeaf816275cfb5", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"container/list\"\n\t\"fmt\"\n)\n\ntype Item struct {\n\tvalue int\n\tdepth int\n}\n\ntype Queue struct {\n\tdata *list.List\n}\n\nfunc NewQueue() *Queue {\n\tq := new(Queue)\n\tq.data = list.New()\n\treturn q\n}\n\nfunc (q *Queue) Enqueue(v interface{}) {\n\tq.data.PushBack(v)\n}\n\nfunc (q *Queue) Dequeue() interface{} {\n\titer := q.data.Front()\n\tv := iter.Value\n\tq.data.Remove(iter)\n\treturn v\n}\n\nfunc (q *Queue) Dump() {\n\tfor iter := q.data.Front(); iter != nil; iter = iter.Next() {\n\t\tfmt.Println(\"item:\", iter.Value)\n\t}\n}\n\nfunc (q *Queue) Empty() bool {\n\treturn q.data.Len() == 0\n}\n\nfunc solve(n, m int) int {\n\tif n >= m {\n\t\treturn n - m\n\t}\n\n\tlen := m*2 + 1\n\tgraph := make([][]int, len, len)\n\tfor i := 0; i < m*2+1; i++ {\n\t\tgraph[i] = make([]int, 2, 2)\n\t}\n\n\tfor i := 1; i < len; i++ {\n\t\tgraph[i][0] = i - 1\n\t\tgraph[i][1] = i * 2\n\t}\n\n\tans := 0\n\tvisit := make([]bool, len, len)\n\tq := NewQueue()\n\tq.Enqueue(Item{value: n, depth: 0})\n\tfor !q.Empty() {\n\t\tv := q.Dequeue().(Item)\n\t\tif v.value == m {\n\t\t\tans = v.depth\n\t\t\tbreak\n\t\t}\n\n\t\tvisit[v.value] = true\n\t\tval := v.value\n\t\tif graph[val][0] > 0 && graph[val][0] < len && !visit[graph[val][0]] {\n\t\t\tit := Item{value: graph[val][0], depth: v.depth + 1}\n\t\t\tq.Enqueue(it)\n\t\t}\n\n\t\tif graph[val][1] > 0 && graph[val][1] < len && !visit[graph[val][1]] {\n\t\t\tit := Item{value: graph[val][1], depth: v.depth + 1}\n\t\t\tq.Enqueue(it)\n\t\t}\n\t}\n\n\treturn ans\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\tfmt.Println(solve(n, m))\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "bf2bf937faad4d2af994cb80f03c8a9d", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, ans int\n\tfmt.Scan(&n, &m)\n\n\tfor m > n {\n\t\tif m % 2 == 0 {\n\t\t\tm /= 2\n\t\t}else {\n\t\t\tm++\n\t\t}\n\t\tans++\n\t}\n\tfmt.Println(ans + n - m)\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "e1173eeb4b896e85f3dad755adea2274", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n, m, ans int\n fmt.Scanf(\"%d %d\", &n, &m)\n ans = 0\n for m > n {\n if(m % 2 == 1) {\n m++\n ans++\n }\n m >>= 1\n ans++\n }\n ans += n - m\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "e0841bda0fc250f3be51276a0bedebcc", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\ntype pair struct {\n\tnn int\n\tdd int\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d%d\", &n, &m)\n\n\tif n >= m {\n\t\tfmt.Println(n - m)\n\t} else {\n\t\tvisited := make([]bool, 2*m+1)\n\n\t\tdevice := make([]pair, 1)\n\t\tdevice[0] = pair{n, 0}\n\n\t\tans := 0\n\t\tvisited[n] = true\n\t\tfor {\n\t\t\t// pop front element\n\t\t\ttmp := device[0]\n\t\t\tdevice = device[1:]\n\t\t\t// copy(device[0:len(device)-1], device[1:])\n\n\t\t\tif tmp.nn == m { // reached destination\n\t\t\t\tans = tmp.dd\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t// add neighbors to the queue\n\t\t\tif tmp.nn*2 < 2*m+1 && visited[tmp.nn*2] == false {\n\t\t\t\tdevice = append(device, pair{tmp.nn * 2, tmp.dd + 1})\n\t\t\t\tvisited[tmp.nn*2] = true\n\t\t\t}\n\t\t\tif tmp.nn-1 >= 0 && visited[tmp.nn-1] == false {\n\t\t\t\tdevice = append(device, pair{tmp.nn - 1, tmp.dd + 1})\n\t\t\t\tvisited[tmp.nn-1] = true\n\t\t\t}\n\t\t}\n\n\t\tfmt.Println(ans)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "7ef5322539e0d9c3ebd42e5e274881b7", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bestTimes int\nvar m int\n\n//var ret []int\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n int\n\tfmt.Fscanln(reader, &n, &m)\n\t//max := 0\n\tif n > m {\n\t\tbestTimes = n - m\n\t\t//max = n\n\t} else {\n\t\tc1, n1 := findFirstBigger(n, m)\n\t\t//fmt.Println(c1, n1)\n\t\tbestTimes = c1 + (n1 - m)\n\t}\n\t//fmt.Println(bestTimes)\n\t//ret = make([]int, max*2+1)\n\t//for i := 0; i < len(ret); i++ {\n\t//\tret[i] = -1\n\t//}\n\tdfs1(n, m, 0)\n\tfmt.Println(bestTimes)\n}\n\nfunc dfs1(n int, m int, count int) {\n\t//fmt.Println(n, m, count)\n\tif count > bestTimes {\n\t\treturn\n\t}\n\tif n == m {\n\t\tif count < bestTimes {\n\t\t\tbestTimes = count\n\t\t}\n\t\t//fmt.Println(\"====\")\n\t\treturn\n\t}\n\tif n == 0 {\n\t\t//fmt.Println(\"====\")\n\t\treturn\n\t}\n\tif n > m {\n\t\tif count+n-m < bestTimes {\n\t\t\tbestTimes = count + n - m\n\t\t}\n\t\t//fmt.Println(\"====\")\n\t\treturn\n\t} else {\n\t\tif m%2 == 0 {\n\t\t\tdfs1(n, m/2, count+1)\n\t\t} else {\n\t\t\t_, n1 := findFirstBigger(n, m)\n\t\t\tfor i := n1; i > m; i-- {\n\t\t\t\tif i%2 == 0 {\n\t\t\t\t\tdfs1(n, i, count+i-m)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n}\n\n// 次数, temp\nfunc findFirstBigger(n, m int) (int, int) {\n\ttemp := n\n\tcount := 0\n\tfor {\n\t\tcount++\n\t\ttemp *= 2\n\t\tif temp >= m {\n\t\t\treturn count, temp\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "f86ece68433a8f356dd20561350b5868", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar (\n\tscanner = bufio.NewScanner(os.Stdin)\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\tscanner.Split(bufio.ScanWords)\n\tvar n, m int\n\tscan(&n, &m)\n\tcnt := 0\n\tfor m > n {\n\t\tif m%2 == 0 {\n\t\t\tm /= 2\n\t\t} else {\n\t\t\tm++\n\t\t}\n\t\tcnt++\n\t}\n\tfmt.Println(cnt + n - m)\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "59434cf133414b0c83af71b27f556ccc", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\\n\", &n, &m)\n\tans := 0\n\n\tfor m > n {\n\t\tif m % 2 != 0 {\n\t\t\tm++\n\t\t\tans++\n\t\t} else {\n\t\t\tm /= 2\n\t\t\tans++\n\t\t}\n\t}\n\n\tfmt.Println(ans + (n - m))\n}", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "0bd50b20ee2f9711debf19b65af60104", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, m int\n\treader := bufio.NewReader(os.Stdin)\n\tfmt.Fscanln(reader, &n, &m)\n\ttims := 0\n\tif n >= m {\n\t\ttims = n - m\n\t} else {\n\t\tif m%2 != 0 {\n\t\t\tm++\n\t\t\ttims++\n\t\t\tfor {\n\t\t\t\tif m <= n {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif m%2 != 0 {\n\t\t\t\t\tm++\n\t\t\t\t\ttims++\n\t\t\t\t}\n\t\t\t\tm = m / 2\n\t\t\t\ttims++\n\t\t\t}\n\t\t\t//if m/2 <= n {\n\t\t\t//\tm = m / 2\n\t\t\t//\ttims++\n\t\t\t//} else {\n\t\t\t//\tfor m/2+m%2 >= n {\n\t\t\t//\t\tm = m/2 + m%2\n\t\t\t//\t\tif m%2 != 0 {\n\t\t\t//\t\t\ttims++\n\t\t\t//\t\t}\n\t\t\t//\t\t//fmt.Println(\"M: \", m)\n\t\t\t//\t\tif m == n {\n\t\t\t//\t\t\tbreak\n\t\t\t//\t\t}\n\t\t\t//\t\ttims++\n\t\t\t//\t}\n\t\t\t//}\n\t\t\t//for n != m {\n\t\t\t//\tn--\n\t\t\t//\ttims++\n\t\t\t//}\n\t\t} else {\n\t\t\tif m/2 <= n {\n\t\t\t\tm = m / 2\n\t\t\t\ttims++\n\t\t\t} else {\n\t\t\t\tfor {\n\t\t\t\t\tif m <= n {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tif m%2 != 0 {\n\t\t\t\t\t\tm++\n\t\t\t\t\t\ttims++\n\t\t\t\t\t}\n\t\t\t\t\tm = m / 2\n\t\t\t\t\ttims++\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\ttims += n - m\n\t}\n\tfmt.Println(tims)\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "b7d131540de21e3fa467e27f2a0f1ebd", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n/**Only for test**/\ntype Node struct{\n\tnext *Node\n\tdata int\n}\ntype queue struct{\n\thead *Node\n\ttail *Node\n\tsize int\n}\nfunc (q *queue)push(v int){\n\tvar newVal = new(Node);\n\tnewVal.next = nil;\n\tnewVal.data = v;\n\tif(q.head == nil){\n\t\tq.head = newVal;\n\t\tq.tail = newVal;\n\t}else{\n\t\tq.tail.next = newVal;\n\t\tq.tail = newVal;\n\t}\n\tq.size ++;\n}\nfunc (q queue)empty()bool{\n\treturn (q.size == 0);\n}\nfunc (q *queue)pop(){\n\tif(q.empty() == true){\n\t\tpanic(\"you are poping empty queue\");\n\t}\n\tif(q.head.next == nil){\n\t\tq.head = nil;\n\t\tq.tail = nil;\n\t}else{\n\t\tq.head = q.head.next;\n\t}\n\tq.size --;\n}\nfunc (q queue)front()int{\n\tif(q.empty() == true){\n\t\tpanic(\"you getting first element from empty queue\");\n\t}\n\treturn q.head.data;\n}\n\nfunc main() {\n\tvar n, m int;\n\tfmt.Scan(&n, &m);\n\tvar q queue;\n\tq.push(n);\n\tvar a[100000] int;\n\tfor i := 1; i < 100000; i ++{\n\t\ta[i] = 1e9;\n\t}\n\ta[n] = 0;\n\tfor !q.empty(){\n\t\tvar v = q.front();\n\t\tq.pop();\n\t\tif(v * 2 < 100000 && a[v * 2] > a[v] + 1){\n\t\t\ta[v * 2] = a[v] + 1;\n\t\t\tq.push(v * 2);\n\t\t}\n\t\tif(v - 1 > 0 && a[v - 1] > a[v] + 1){\n\t\t\ta[v - 1] = a[v] + 1;\n\t\t\tq.push(v - 1);\n\t\t}\n\t}\n\tfmt.Println(a[m]);\n}", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "2533ab4a8861e41c48e9e581287dca66", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// There are two buttons, one red and another blue\n// Pressing red button multiplies n by 2\n// Pressing blue button reduces n by 1\n// What is the minimum number of clicks to reduce 'n' to 'm'?\n\nfunc min_clicks(n, m int) int {\n\tif n >= m {\n\t\treturn n - m\n\t}\n\tif m % 2 == 1 {\n\t\treturn min_clicks(n, m + 1) + 1\n\t}\n\treturn min_clicks(n, m / 2) + 1\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tvar n, m int\n\tfmt.Fscanf(reader, \"%d %d\", &n, &m)\n\tfmt.Fprintf(writer, \"%d\\n\", min_clicks(n, m))\n\twriter.Flush()\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "486227ee064105fb6dac93d2b3e090ea", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"container/list\"\n)\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\\n\", &n, &m)\n\n\tvar distance [20005]int\n\tqueue := list.New()\n\n\tdistance[n] = 1\n\tqueue.PushBack(n)\n\n\tfor e := queue.Front(); e != nil; e = e.Next() {\n\t\tx := e.Value.(int)\n\n\t\tif x == m {\n\t\t\tfmt.Printf(\"%d\\n\", distance[x] - 1)\n\t\t\tbreak\n\t\t}\n\n\t\tif x > 1 && distance[x - 1] == 0 {\n\t\t\tdistance[x - 1] = distance[x] + 1\n\t\t\tqueue.PushBack(x - 1)\n\t\t\tif x - 1 == m {\n\t\t\t\tfmt.Printf(\"%d\\n\", distance[x])\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif x < m && distance[x * 2] == 0 {\n\t\t\tdistance[x * 2] = distance[x] + 1\n\t\t\tqueue.PushBack(x * 2)\n\t\t\tif x * 2 == m {\n\t\t\t\tfmt.Printf(\"%d\\n\", distance[x])\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "4d7c1e67c5d98e1580480e7632ec2dd2", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n)\n\nfunc main() {\n\tn, m := scanInt(), scanInt()\n\tcount := 0\n\n\tfor m > n{\n\t\tif m % 2 == 0{\n\t\t\tm /= 2\n\t\t}else{\n\t\t\tm++\n\t\t}\n\t\tcount++\n\t}\n\tprintFmt(count + n - m)\n\tclose(channelType)\n\toWg.Wait()\n}\n\nfunc getMax(n, m int) string{\n\tvar max string\n\tfor m > 9{\n\t\tmax = max + \"9\"\n\t\tm -= 9\n\t\tn--\n\t}\n\n\tmax = max + strconv.Itoa(m)\n\tn--\n\tfor i := 0; i < n; i++{\n\t\tmax = max + \"0\"\n\t}\n\treturn max\n}\n\nfunc getMin(n, m int) string{\n\tvar min string\n\tfor m > 9{\n\t\tmin = \"9\" + min\n\t\tm -= 9\n\t\tn--\n\t}\n\n\tif n == 1{\n\t\tmin = strconv.Itoa(m) + min\n\t}else{\n\t\tif m > 1{\n\t\t\tmin = strconv.Itoa(m-1) + min\n\t\t\tn--\n\t\t}\n\n\t\tfor i:= 0; i < n-1; i++{\n\t\t\tmin = \"0\" + min\n\t\t}\n\t\tmin = \"1\" + min\n\t}\n\treturn min\n}\n\n\n/*********************** I/O ***********************/\n\nvar channelType chan string\nvar in *bufio.Scanner\nvar oWg *sync.WaitGroup\nvar printFmt func(a ...interface{}) (n int, err error)\n\nfunc init() {\n\tprintFmt = fmt.Println\n\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(1e+9))\n\tin.Split(bufio.ScanWords)\n\n\tchannelType = make(chan string, 16)\n\toWg = &sync.WaitGroup{}\n\toWg.Add(1)\n\n\twriter := bufio.NewWriter(os.Stdout)\n\tgo func() {\n\t\tdefer oWg.Done()\n\t\tdefer writer.Flush()\n\n\t\tfor line := range channelType {\n\t\t\twriter.WriteString(line + \"\\n\")\n\t\t}\n\t}()\n}\n\nfunc scanString() string {in.Scan(); return in.Text() }\nfunc scanInt() int {i, _ := strconv.Atoi(scanString()); return i}\nfunc scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}\nfunc scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; return s}\nfunc scanIntSlice(n int) []int {arr := make([]int, n); for i := 0; i < n; i++ {arr[i] = scanInt()}; return arr}\nfunc scanInt64Slice(n int) []int64 {arr := make([]int64, n); for i := 0; i < n; i++ {arr[i] = scanInt64()}; return arr}\n\n/*********************** Utils ***********************/\n\nfunc stringEquivalent(v interface{}) string {return fmt.Sprintf(\"%v\", v)}\nfunc spaceSeperatedStringFromArray(a []int) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.Itoa(a[i]) + \" \")}; return sb.String()}\nfunc spaceSeperatedStringFromArray64(a []int64) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.FormatInt(a[i], 10) + \" \")}; return sb.String()}\nfunc minMaxFromArray(args ...int64) (int64, int64) {minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64); for _, v := range args {if v < minVal {minVal = v}; if v > maxVal {maxVal = v}}; return minVal, maxVal}\nfunc minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }\nfunc maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }\nfunc lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}\nfunc gcdCalculation(a, b int64) int64 {if (a == 0) {return b}; return gcdCalculation(b%a, a)}\nfunc sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}\nfunc absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}\nfunc min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }\nfunc max(args ...int) int { _, mx := minMaxFinder(args...); return mx }\nfunc minMaxFinder(args ...int) (int, int) { minVal, maxVal := int(math.MaxInt32), int(math.MinInt32); for _, v := range args { if v < minVal { minVal = v }; if v > maxVal { maxVal = v } }; return minVal, maxVal }\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "255af3b751e2c11a8d0f935a486c60dc", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// You can edit this code!\n// Click here and start typing.\npackage main\n\nimport (\n\t\"container/list\"\n\t\"fmt\"\n)\n\ntype stackval struct {\n\tcurrent int\n\tsteps int\n}\n\nfunc solve(n, m int) int {\n\tvar visited [10001]int\n\tvar best = 10000\n\n\ts := list.New()\n\tel := stackval{n, 0}\n\n\ts.PushBack(el)\n\n\tfor s.Len() > 0 {\n\t\tel := s.Remove(s.Front()).(stackval)\n\t\tvisited[el.current] = 1\n\t\tif el.current >= m {\n\t\t\tsteps := el.steps + (el.current - m)\n\t\t\tif steps < best {\n\t\t\t\tbest = steps\n\t\t\t}\n\t\t} else {\n\t\t\tif el.current > 0 {\n\t\t\t\tif visited[el.current-1] == 0 {\n\t\t\t\t\ts.PushBack(stackval{el.current - 1, el.steps + 1})\n\t\t\t\t}\n\t\t\t}\n\t\t\tif el.current*2 < 10001 && visited[el.current*2] == 0 {\n\t\t\t\ts.PushBack(stackval{el.current * 2, el.steps + 1})\n\t\t\t}\n\t\t}\n\t}\n\n\treturn best\n}\n\nfunc main() {\n\tvar m, n int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tres := solve(n, m)\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "1d8c18bc647d5ab5f64b1f26bf5a9586", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t//\"bytes\"\n\t\"fmt\"\n\t//\"strconv\"\n)\n\n/*func main() {\n\n\tvar n, x, y int\n\ta, b, c := 0, 0, 0\n\tfmt.Scan(&n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&x, &y)\n\t\ta += x\n\t\tb += y\n\t\tif x%2 != y%2 {\n\t\t\tc++\n\t\t}\n\t}\n\tif a%2 == 0 && b%2 == 0 {\n\t\tfmt.Print(\"0\")\n\t} else if c%2 == 0 && c > 0 {\n\t\tfmt.Print(\"1\")\n\t} else {\n\t\tfmt.Print(\"-1\")\n\t}\n}*/\n\nfunc Max(n int, g int) int {\n\tif n > g {\n\t\treturn n\n\t} else {\n\t\treturn g\n\t}\n}\n\nfunc Min(n int, g int) int {\n\tif n > g {\n\t\treturn g\n\t} else {\n\t\treturn n\n\t}\n}\n\nfunc main() {\n\n\tvar n, g, f, ans int\n\t//var buffer bytes.Buffer\n\n\tfmt.Scan(&n, &g)\n\n\tif n < g {\n\t\tmax := Max(n, g)\n\t\tmin := Min(n, g)\n\n\t\tfor max > min {\n\t\t\tif max%2 == 0 {\n\t\t\t\tmax /= 2\n\t\t\t} else {\n\t\t\t\tmax++\n\t\t\t}\n\t\t\tans++\n\t\t\t//buffer.WriteString(fmt.Sprint(strconv.Itoa(max), strconv.Itoa(min)))\n\t\t\t//println(buffer.String())\n\t\t}\n\n\t\tif max == min {\n\t\t\tfmt.Println(ans)\n\t\t} else {\n\t\t\tans += min - max\n\t\t\tfmt.Println(ans)\n\t\t}\n\t} else {\n\t\tans += n - g\n\t\tfmt.Println(ans)\n\t}\n\tfmt.Scan(&f)\n\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "638db84d8c4a5c62c924013044cfac04", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n/**Only for test**/\ntype Node struct{\n\tnext *Node\n\tdata int\n}\ntype queue struct{\n\thead *Node\n\ttail *Node\n\tsize int\n}\nfunc (q *queue)push(v int){\n\tvar newVal = new(Node);\n\tnewVal.next = nil;\n\tnewVal.data = v;\n\tif(q.head == nil){\n\t\tq.head = newVal;\n\t\tq.tail = newVal;\n\t}else{\n\t\tq.tail.next = newVal;\n\t\tq.tail = newVal;\n\t}\n\tq.size ++;\n}\nfunc (q queue)empty()bool{\n\treturn (q.size == 0);\n}\nfunc (q *queue)pop(){\n\tif(q.empty() == true){\n\t\tpanic(\"you are popping empty queue\");\n\t}\n\tif(q.head.next == nil){\n\t\tq.head = nil;\n\t\tq.tail = nil;\n\t}else{\n\t\tq.head = q.head.next;\n\t}\n\tq.size --;\n}\nfunc (q queue)front()int{\n\tif(q.empty() == true){\n\t\tpanic(\"you getting first element from empty queue\");\n\t}\n\treturn q.head.data;\n}\n\nfunc main() {\n\tvar n, m int;\n\tfmt.Scan(&n, &m);\n\tvar q queue;\n\tq.push(n);\n\tvar a[100000] int;\n\tfor i := 1; i < 100000; i ++{\n\t\ta[i] = 1e9;\n\t}\n\ta[n] = 0;\n\tfor !q.empty(){\n\t\tvar v = q.front();\n\t\tq.pop();\n\t\tif(v * 2 < 100000 && a[v * 2] > a[v] + 1){\n\t\t\ta[v * 2] = a[v] + 1;\n\t\t\tq.push(v * 2);\n\t\t}\n\t\tif(v - 1 > 0 && a[v - 1] > a[v] + 1){\n\t\t\ta[v - 1] = a[v] + 1;\n\t\t\tq.push(v - 1);\n\t\t}\n\t}\n\tfmt.Println(a[m]);\n}", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "358c0a772e92daae2f5b9c8d37ce8bb8", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc parse(n, m int) int {\n\tif n == m {\n\t\treturn 0\n\t}\n\tif n > m {\n\t\treturn n - m\n\t}\n\treturn 1 + (m % 2) + parse(n, m/2+(m%2))\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d \\n\", &n, &m)\n\tr := parse(n, m)\n\n\tfmt.Print(r)\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "6f8d7deded22729adf595ad527914f06", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n uint64\n\tfor I(&n, \"\\n\") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n uint64) {\n\tif n == 0 {\n\t\tO(\"1\", \"\\n\")\n\t\treturn\n\t}\n\tO([]int{8, 4, 2, 6}[(n-1)%4], \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "45089deed47b2bfd3f5a1e79f91f277a", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\tif N == 0 {\n\t\tfmt.Println(1)\n\t\treturn\n\t}\n\n\tans := 0\n\tN--\n\tswitch N % 4 {\n\tcase 0:\n\t\tans = 8\n\tcase 1:\n\t\tans = 4\n\tcase 2:\n\t\tans = 2\n\tcase 3:\n\t\tans = 6\n\t}\n\tfmt.Println(ans)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r:rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "0c3180bd38994224482f4f8d072653f9", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReaderSize(os.Stdin, 1<<13)\n\twriter := bufio.NewWriterSize(os.Stdout, 1<<13)\n\tn := ReadInt(reader)\n\tfmt.Println(solve(8, n))\n\twriter.Flush()\n}\n\nfunc solve(d, n int) int {\n\tif n == 0 {\n\t\treturn 1\n\t}\n\tres := solve((d*d)%10, n/2)\n\tif n&1 > 0 {\n\t\tres *= d\n\t}\n\treturn res % 10\n}\n\nfunc ReadInt(reader *bufio.Reader) int {\n\treturn int(ReadInt64(reader))\n}\n\nfunc ReadInt64(reader *bufio.Reader) int64 {\n\tb, err := reader.ReadByte()\n\tfor !isValid(b, err) {\n\t\tb, err = reader.ReadByte()\n\t}\n\tsign := int64(1)\n\tif b == '-' {\n\t\tsign *= -1\n\t\tb, err = reader.ReadByte()\n\t}\n\tres := int64(0)\n\tfor isValid(b, err) {\n\t\tres = res*10 + int64(b-'0')\n\t\tb, err = reader.ReadByte()\n\t}\n\treturn res * sign\n}\n\nfunc isValid(b byte, err error) bool {\n\treturn err == nil && (('0' <= b && b <= '9') || b == '-')\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "70f96c14cb9662a51ee9825654760443", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"io\"\n\t\"os\"\n)\n\nfunc main() {\n\t// allow for up to 102 entries (line plus newline)\n\tb := make([]byte, 102)\n\n\t// allow for up to 201 entries (dot plus newline)\n\tout := make([]byte, 0, 201)\n\n\tn, errRead := os.Stdin.Read(b)\n\tif errRead != nil && errRead != io.EOF {\n\t\tos.Exit(1)\n\t}\n\n\tb = b[:n]\n\n\tfor _, c := range b {\n\t\tif c >= 'A' && c <= 'Z' {\n\t\t\tc += 32 // 'a' - 'A' = 32\n\t\t}\n\n\t\tswitch {\n\t\tcase c < 'A': // newline: append as-is\n\t\t\tout = append(out, c)\n\t\tcase c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y':\n\t\t\tcontinue\n\t\tdefault:\n\t\t\tout = append(out, '.', c)\n\t\t}\n\t}\n\n\tos.Stdout.Write(out)\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "1bc3b7b67665ef7b46f726f9a508b0b4", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport(\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main(){\n\n\tvar s string \n\tfmt.Scan(&s)\n\n\ts = strings.ToLower(s)\n\n\tn:= len(s)\n\n\tsol := \"\"\n\tfor i := 0 ; i < n ; i ++{\n\t\tif !( s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u'||s[i]=='y' ){\n\t\t\tsol = sol +\".\"+string(s[i])\n\t\t} \n\t\t\n\t}\n\n\tfmt.Printf(\"%s\\n\",sol)\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "f9aae54e277d272a9b6116fdc9f0d5d0", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\n// func Test(t *testing.T) {\n// \ta := assert.New(t)\n\n// \ta.Equal(\".t.r\", do(\"tour\"))\n// \ta.Equal(\".c.d.f.r.c.s\", do(\"Codeforces\"))\n// \ta.Equal(\".w.p.w.l\", do(\"wpwl\"))\n// \ta.Equal(\".k.t.j.q.h.p.q.s.v.h.w\", do(\"ktajqhpqsvhw\"))\n// }\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\ts = strings.ToLower(s)\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == 'y' || s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' {\n\t\t\tcontinue\n\t\t}\n\t\tfmt.Printf(\"%c%c\", '.', s[i])\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "6b3489e2267cb32076dd432603468d11", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc start() {\n\ts := sstring()\n\tn := len(s)\n\tif n == 1 {\n\t\tif s[0] == '0' || s[0] == '_' || s[0] == 'X' {\n\t\t\twlstring(\"1\")\n\t\t\treturn\n\t\t} else {\n\t\t\twlstring(\"0\")\n\t\t\treturn\n\t\t}\n\t}\n\tif s[0] == '0' {\n\t\twlstring(\"0\")\n\t\treturn\n\t}\n\thasX := 0\n\tfor _, v := range s {\n\t\tif v == 'X' {\n\t\t\thasX = 1\n\t\t\tbreak\n\t\t}\n\t}\n\tltemps := []string{\"25\", \"50\", \"75\"}\n\tif n != 2 {\n\t\tltemps = append(ltemps, \"00\")\n\t}\n\tending := s[n-2 : n]\n\trTot := 0\n\tfor _, temp := range ltemps {\n\t\ttempOk, xVal := true, byte('a')\n\t\tfor i := range ending {\n\t\t\tc := ending[i]\n\t\t\tif c == '_' {\n\t\t\t} else if c == 'X' {\n\t\t\t\tif xVal != 'a' && xVal != temp[i] {\n\t\t\t\t\ttempOk = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\txVal = temp[i]\n\t\t\t} else {\n\t\t\t\tif c != temp[i] {\n\t\t\t\t\ttempOk = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//\n\t\tif tempOk {\n\t\t\tif s[0] == 'X' && xVal == '0' {\n\t\t\t} else {\n\t\t\t\tr := func() int {\n\t\t\t\t\tif n == 2 {\n\t\t\t\t\t\treturn 1\n\t\t\t\t\t} else if s[0] == '_' {\n\t\t\t\t\t\treturn 9\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn 1\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t\t\tfor i := 1; i < n-2; i++ {\n\t\t\t\t\tif s[i] == '_' {\n\t\t\t\t\t\tr *= 10\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trX := 1\n\t\t\t\tif hasX == 1 && xVal == 'a' {\n\t\t\t\t\trX = 10\n\t\t\t\t\tif s[0] == 'X' {\n\t\t\t\t\t\trX = 9\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trTot += r * rX\n\t\t\t}\n\t\t}\n\t}\n\twlint(rTot)\n}\n\nfunc main() {\n\tstart()\n\t// flush\n\twriter.Flush()\n}\n\n// utils\nfunc max(a int, b int) int {\n\tif b > a {\n\t\treturn b\n\t}\n\treturn a\n}\n\n// io utils\n\nvar (\n\tscanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n)\n\nfunc wstring(s string) {\n\twriter.WriteString(s)\n}\nfunc wrune(r rune) {\n\twriter.WriteRune(r)\n}\nfunc wint(i int) {\n\twstring(strconv.Itoa(i))\n}\nfunc wlstring(s string) {\n\twriter.WriteString(s)\n\twrune('\\n')\n}\nfunc wlrune(r rune) {\n\twriter.WriteRune(r)\n\twrune('\\n')\n}\nfunc wlint(i int) {\n\twstring(strconv.Itoa(i))\n\twrune('\\n')\n}\n\nfunc init() {\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 4096), 1e9)\n}\n\nfunc printls(in []int) {\n\tfor _, v := range in {\n\t\twint(v)\n\t\twrune(' ')\n\t}\n\twlstring(\"\")\n}\n\nfunc sint() int {\n\ti, err := strconv.Atoi(sstring())\n\tif err != nil {\n\t\tpanic(\"sint: Error\")\n\t}\n\treturn i\n}\n\nfunc sints(n int) []int {\n\ta := make([]int, n)\n\tfor i := range a {\n\t\ta[i] = sint()\n\t}\n\treturn a\n}\n\nfunc sstring() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp", "dfs and similar"], "code_uid": "e7f9f68445303c4b1246f20f966cbe19", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, d int\n\tfmt.Scan(&n, &d)\n\tvar a string\n\tfmt.Scan(&a)\n\ti := 0\n\tflag := false\n\tcount := 0\n\tvar j int\n\tfor i < n {\n\t\tif i+d >= n {\n\t\t\tj = n - 1\n\t\t} else {\n\t\t\tj = i + d\n\t\t}\n\t\tfor (j > i && j < n) && a[j] != '1' {\n\t\t\tj--\n\t\t}\n\t\tif j <= n-1 {\n\t\t\tif a[j] != '1' || j == i {\n\t\t\t\tflag = true\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\ti = j\n\t\t\t\tif j == n-1 {\n\t\t\t\t\tcount++\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println(count)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "b68d1509596ed3599dbcbeb58db7979b", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t// 从左开始遇到1就扩大右边界,直到超出右边界为止。\n\tvar (\n\t\tn, d int\n\t\ts string\n\t)\n\tfmt.Scanf(\"%d%d\", &n, &d)\n\tfmt.Scan(&s)\n\tf := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tf[i] = -1\n\t}\n\tif s[0] == '1' {\n\t\tf[0] = 0\n\t}\n\tfor l, r := 0, 0; l <= r; l++ {\n\t\tif s[l] != '1' {\n\t\t\tcontinue\n\t\t}\n\t\tfor r < l+d && r+1 < n {\n\t\t\tr++\n\t\t\tif s[r] == '1' {\n\t\t\t\tf[r] = f[l] + 1\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n\", f[n-1])\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "cd26ff62beda1324c2eecbfc1105befa", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar n int\nvar d int\n\nfunc ReadData() []int {\n fmt.Scanf(\"%d %d\", &n, &d)\n\n var line string = \"\"\n fmt.Scan(&line)\n\n result := make([]int, 0)\n for i := 0; i < n; i++ {\n if line[i] == '1' {\n result = append(result, i)\n }\n }\n return result\n}\n\nfunc Solve(line []int) int {\n dp := make([]int, 1 + len(line))\n for i := 0; i < len(dp); i++ {\n dp[i] = 2 * len(line);\n }\n dp[0] = 0;\n for i := 1; i < len(line); i++ {\n current := line[i]\n\n result := 2 * len(dp)\n for j := i - 1; j >= 0; j-- {\n if d < current - line[j] {\n break\n }\n if dp[j] == 2 * len(dp) {\n continue\n }\n if dp[j] + 1 < result {\n result = dp[j] + 1\n }\n }\n dp[i] = result\n }\n\n if dp[len(line) - 1] == 2 * len(dp) {\n return -1;\n }\n return dp[len(line) - 1]\n}\n\nfunc main() {\n line := ReadData()\n fmt.Println(Solve(line))\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "d1d22d6385dd6dd46dd62a7c4f4fb9a9", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc palindrome(val int64) int64 {\n\tres, count, n := int64(0), int64(0), val\n\tfor n > 0 {\n\t\tx := int64(n % 10)\n\t\tres = res*10 + x\n\t\tcount++\n\t\tn /= 10\n\t}\n\tres += val * int64(math.Pow(10, float64(count)))\n\treturn res\n}\n\nfunc main() {\n\tvar k, p, sum int64\n\tfmt.Scan(&k, &p)\n\tsum = 0\n\tfor i := int64(1); i <= k; i++ {\n\t\tsum = (sum%p + palindrome(i)%p) % p\n\t}\n\tfmt.Println(sum)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "2ee70204e296cfacb6cae5aee4ddaf2c", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar digitsMap = map[int]int{\n\t1: 10,\n\t2: 100,\n\t3: 1000,\n\t4: 10000,\n\t5: 100000,\n\t6: 1000000,\n}\n\nfunc main() {\n\tvar k, p int\n\tfmt.Scanf(\"%d %d\", &k, &p)\n\n\tresult := 0\n\tfor i := 1; i <= k; i++ {\n\t\treversed, digits := reverse(i)\n\t\tvar num uint64 = uint64(i)*uint64(digitsMap[digits]) + uint64(reversed)\n\t\tresult = (result + int(num%uint64(p))) % p\n\t}\n\n\tfmt.Println(result)\n}\n\nfunc reverse(num int) (reversed, digits int) {\n\n\tfor ; num > 0; num /= 10 {\n\t\treversed = (reversed * 10) + num%10\n\t\tdigits++\n\t}\n\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "d26709eefd728a0dcbdb7db731ac629f", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc zcy(n int64) int64 {\n\tketa := int64(0)\n\n\tm := n\n\tfor m > 0 {\n\t\tm /= 10\n\t\tketa++\n\t}\n\ta := pow(10, keta) * n\n\tfor p := keta - 1; p >= 0; p-- {\n\t\ta += (n % 10) * pow(10, p)\n\t\tn /= 10\n\t}\n\treturn a\n\n}\n\n//aのb乗をします O(log b)\nfunc pow(a int64, b int64) int64 {\n\ttotal := int64(1)\n\ttmp := a\n\tfor b > 0 {\n\t\tif b%2 == 1 {\n\t\t\ttotal *= tmp\n\t\t}\n\t\tb /= 2\n\t\ttmp *= tmp\n\t}\n\treturn total\n}\n\nfunc main() {\n\tsc := NewScanner()\n\tk, p := sc.NextInt(), sc.NextInt()\n\n\tsum := int64(0)\n\tfor i := 1; i <= k; i++ {\n\t\tsum += zcy(int64(i))\n\t\tsum %= int64(p)\n\t}\n\tfmt.Println(sum)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "21d87aa0d7c9fec4a9ce41d61b006078", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n\n var pages, initialSpeed, maxSpeed, acceleration, rereadPages int\n fmt.Scanf(\"%d %d %d %d %d\", &pages, &initialSpeed, &maxSpeed, &acceleration, &rereadPages)\n\n var day int = 0\n for pages > 0 {\n var pageRead int = int(math.Min(float64(initialSpeed + day * acceleration), float64(maxSpeed)))\n if day > 0 {\n pageRead -= rereadPages\n }\n pages -= pageRead\n day += 1\n }\n\n fmt.Println(day)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "51a02c1a396847308a8fd01fe16e071b", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar c, v0, v1, a, l int\n\tfmt.Scanf(\"%d %d %d %d %d\", &c, &v0, &v1, &a, &l)\n\tif v0 >= c {\n\t\tfmt.Println(1)\n\t} else {\n\t\tday := 2\n\t\tfor read := v0; read < c; day++ {\n\t\t\tv0 = min(v0+a, v1)\n\t\t\tread += v0-l\n\t\t}\n\t\tfmt.Println(day - 1)\n\t}\n}\n\nfunc min(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "89abedfb780021cf2f91bcc59febab02", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n/*\n The idea to solve this problem is just follow the instruction :P\n The amount of data is small & the complexity would only O(n) so just done it\n wit naive approach :P\n*/\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n\n var pages, initialSpeed, maxSpeed, acceleration, rereadPages int\n fmt.Scanf(\"%d %d %d %d %d\", &pages, &initialSpeed, &maxSpeed, &acceleration, &rereadPages)\n\n var day int = 0\n for pages > 0 {\n var pageRead int = int(math.Min(float64(initialSpeed + day * acceleration), float64(maxSpeed)))\n if day > 0 {\n pageRead -= rereadPages\n }\n pages -= pageRead\n day += 1\n }\n\n fmt.Println(day)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b9ad032687919d775bf15d6d39c65eba", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math/rand\"\n\t\"os\"\n)\n\nconst INF = 1000000001\n\ntype Pair struct {\n\tfirst, second int\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\nfunc sort(arr []int) []int {\n\tif len(arr) < 2 {\n\t\treturn arr\n\t}\n\tleft := 0\n\tright := len(arr) - 1\n\tpivot := rand.Int() % len(arr)\n\n\tarr[pivot], arr[right] = arr[right], arr[pivot]\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i] < arr[right] {\n\t\t\tarr[i], arr[left] = arr[left], arr[i]\n\t\t\tleft++\n\t\t}\n\t}\n\n\tarr[left], arr[right] = arr[right], arr[left]\n\n\tsort(arr[:left])\n\tsort(arr[left+1:])\n\treturn arr\n}\n\nfunc solution(reader io.Reader, writer io.Writer) {\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(reader, \"%d\", &a[i])\n\t}\n\n\ta = sort(a)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fprintf(writer, \"%d \", a[i])\n\t}\n}\n\nfunc main() {\n\n\t//stdin, err := os.Open(\"file.in\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdin.Close()\n\tstdin := os.Stdin\n\treader := bufio.NewReaderSize(stdin, 1024*1024)\n\n\t//stdout, err := os.Create(\"file.out\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdout.Close()\n\tstdout := os.Stdout\n\twriter := bufio.NewWriterSize(stdout, 1024*1024)\n\tdefer writer.Flush()\n\n\tsolution(reader, writer)\n}", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "2dfaf1d598dd41c35abc247b8eb38d92", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tnums := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &nums[i])\n\t}\n\tsort.Ints(nums)\n\tfor _, x := range nums {\n\t\tfmt.Printf(\"%d \", x)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "693de8e6c8dfd19169f533dc82eb5394", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar t, a int\n\tvar arr []int\n\tfmt.Scanf(\"%d\\n\", &t)\n\tfor i := 0; i < t; i++ {\n\t\tfmt.Scanf(\"%d\", &a)\n\t\tarr = append(arr, a)\n\t}\n\tsort.Ints(arr)\n\tfor i := 0; i < t; i++ {\n\t\tfmt.Printf(\"%d \", arr[i])\n\t}\n}", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "37e60a1add19ad089470dbd0a8bb1289", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar n int64\n\tfmt.Fscanf(buf, \"%d\\n\", &n)\n\tvar ans int64\n\tfor i:=int64(3);i <= n;i++{\n\t\tans += i*(i-1)\n\t}\n\tfmt.Printf(\"%d\\n\",ans)\n\n}\n\n/**\n01010101\n0101010\n */\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "3535c4cc09e50def537e900c571584d6", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport(\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar t int\n\tfmt.Scan(&t)\n\n\tvar count int = 0\n\tfor t>2{\n\t\tcount += t*(t-1)\n\t\tt--\n\t}\n\tfmt.Println(count)\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "e0f8715df357ab92bb6584fe81d06f08", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn := 0\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tans := int64(0)\n\tfor i := 3; i <= n; i++ {\n\t\tans += int64(i * (i - 1))\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", ans)\n\treturn\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "bfe9e9b64944812c91f93c1df53e191e", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc ReadString() string {\n\tscanner.Scan()\n\tans := scanner.Text()\n\treturn ans\n}\n\nfunc PrintInts(ints ...int) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(value))\n\t\t//writer.WriteByte(' ')\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tp1, p2 := ReadInt32(), ReadInt32()\n\n\tif p1 == 1 && p2 == 1 {\n\t\tPrintInts(0)\n\t\treturn\n\t}\n\n\tcnt := 0\n\tfor p1 > 0 && p2 > 0 {\n\t\tcnt = cnt + 1\n\t\tif p1 > p2 {\n\t\t\tp1 = p1 - 2\n\t\t\tp2 = p2 + 1\n\t\t} else {\n\t\t\tp1 = p1 + 1\n\t\t\tp2 = p2 - 2\n\t\t}\n\t}\n\n\tPrintInts(cnt)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "fb1ca1faeebf4771947bd3ce04d24f32", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a1, a2 int\n\tfmt.Scanf(\"%d %d\\n\", &a1, &a2)\n\n\tvar f func(x, y int) int\n\tf = func(x, y int) int {\n\t\tvar n int\n\t\tif x < y {\n\t\t\tx, y = y, x\n\t\t}\n\t\tif y == 0 {\n\t\t\treturn n\n\t\t}\n\t\tif x == 1 && y == 1 {\n\t\t\treturn n\n\t\t}\n\t\tif x == 2 {\n\t\t\treturn 1\n\t\t}\n\n\t\tn = (x - 1) / 2\n\t\tx, y = x-2*n, y+n\n\t\t//fmt.Println(x, y)\n\t\treturn n + f(x, y)\n\t}\n\n\tfmt.Println(f(a1, a2))\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "73a28a6cfcb8e252e7659144a4622a82", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"bufio\"\nimport \"os\"\nimport \"fmt\"\n\nfunc Read(s *bufio.Reader) string {\n line, _ := s.ReadString('\\n')\n return line\n}\n\nfunc Write(s *bufio.Writer, a ...interface{}) {\n fmt.Fprintln(s, a...)\n s.Flush()\n}\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n \n var a, b int\n fmt.Sscanln(Read(reader), &a, &b)\n\n if b > a {\n a, b = b, a\n }\n\n var result int = 1\n\n if a <= 1 && b <= 1 {\n result = 0\n }\n\n for a > 2 || b > 2 {\n var time int = ((a + 1) / 2) - 1\n result += time\n a -= time * 2\n b += time\n a, b = b, a\n }\n\n writer := bufio.NewWriter(os.Stdout) \n Write(writer, result)\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "46563f1bb9887a2c73ee6216c5c2731d", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn, k := 0, 0\n\ts := \"\"\n\tfmt.Fscanf(in, \"%d %d\\n\", &n, &k)\n\tfmt.Fscanf(in, \"%s\\n\", &s)\n\t//\tfmt.Println(s)\n\ta := make([]int, 26)\n\tfor i := 0; i < len(s); i++ {\n\t\ta[s[i]-'a'] = 1\n\t}\n\tans := 0\n\tcnt := 0\n\tfor i := 0; i < k; i++ {\n\t\tfor j := 0; j < 26; j++ {\n\t\t\tif a[j] == 1 {\n\t\t\t\tans += j + 1\n\t\t\t\tcnt++\n\t\t\t\ta[j] = 0\n\t\t\t\tif j+1 < 26 {\n\t\t\t\t\ta[j+1] = 0\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\t//fmt.Println(ans, cnt)\n\tif cnt < k {\n\t\tfmt.Fprintf(out, \"%d\\n\", -1)\n\t} else {\n\t\tfmt.Fprintf(out, \"%d\\n\", ans)\n\t}\n\treturn\n}", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "7d2544e7da408fea7f62944dc07e659d", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar k, n int\n\tfmt.Scanf(\"%d %d\\n\", &k, &n)\n\n\tvar str string\n\tfmt.Scanln(&str)\n\n\tunsorted := strings.Split(str, \"\")\n\tsort.Strings(unsorted)\n\tsorted := strings.Join(unsorted, \"\")\n\ts := []rune(sorted)\n\n\tweight := s[0] - 96\n\tcount := 1\n\tprev := 0\n\tfor i := 1; i < k; i++ {\n\t\tif count == n {\n\t\t\tbreak\n\t\t}\n\n\t\tif s[i]-s[prev] < 2 {\n\t\t\tcontinue\n\t\t}\n\n\t\tweight += s[i] - 96\n\t\tcount++\n\t\tprev = i\n\t}\n\n\tif count < n {\n\t\tfmt.Println(\"-1\")\n\t} else {\n\t\tfmt.Println(weight)\n\t}\n}", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "8de9b8c1b064a4e445950635c610095e", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// cf1011a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n, l int\n\tvar s string\n\tfmt.Scan(&n, &l)\n\tfmt.Scan(&s)\n\tvar sl []int\n\tfor _, r := range s {\n\t\tsl = append(sl, int(r-'a')+1)\n\t}\n\tsort.Ints(sl)\n\tv := 0\n\tla := -1\n\tfor _, i := range sl {\n\t\tif l > 0 {\n\t\t\tif i > la+1 {\n\t\t\t\tv += i\n\t\t\t\tla = i\n\t\t\t\tl--\n\t\t\t}\n\t\t}\n\t\tif l == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\tif l == 0 {\n\t\tfmt.Println(v)\n\t} else {\n\t\tfmt.Println(-1)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "bbe6e13fdede5ceba7ca62909868130c", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF869C(in io.Reader, out io.Writer) {\n\tconst m = 998244353\n\tconst mx = 5000\n\tF := [mx + 1]int64{1}\n\tfor i := 1; i <= mx; i++ {\n\t\tF[i] = F[i-1] * int64(i) % m\n\t}\n\tpow := func(x, n int64) int64 {\n\t\tres := int64(1)\n\t\tfor ; n > 0; n >>= 1 {\n\t\t\tif n&1 == 1 {\n\t\t\t\tres = res * x % m\n\t\t\t}\n\t\t\tx = x * x % m\n\t\t}\n\t\treturn res\n\t}\n\tinvF := [...]int64{mx: pow(F[mx], m-2)}\n\tfor i := mx; i > 0; i-- {\n\t\tinvF[i-1] = invF[i] * int64(i) % m\n\t}\n\tC := func(n, k int) int64 { return F[n] * invF[k] % m * invF[n-k] % m }\n\tf := func(a, b int) (s int64) {\n\t\tfor i := 0; i <= a && i <= b; i++ {\n\t\t\ts = (s + C(a, i)*C(b, i)%m*F[i]) % m\n\t\t}\n\t\treturn\n\t}\n\n\tvar a, b, c int\n\tFscan(in, &a, &b, &c)\n\tFprint(out, f(a, b)*f(b, c)%m*f(a, c)%m)\n}\n\nfunc main() { CF869C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "636f176cb2b70e5fc6c8e5f1ed389e43", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nconst mod = 998244353\n\nvar comb [][]int = nil\nvar fac []int64 = nil\n\nfunc helper(m int, n int) int64 {\n\tres := int64(0)\n\tcombm, combn := comb[m], comb[n]\n\tfor i, t := range combm {\n\t\tres += int64(t) * int64(combn[i]) % mod * fac[i] % mod\n\t}\n\treturn res % mod\n}\n\nfunc main() {\n\tabc := []int{0, 0, 0}\n\tfmt.Scan(&abc[0], &abc[1], &abc[2])\n\tsort.Ints(abc)\n\ta, b, c, cur, f := abc[0], abc[1], abc[2], []int{1}, int64(1)\n\tcomb, fac = make([][]int, c+1), make([]int64, c+1)\n\tcomb[0], fac[0] = cur[:], 1\n\tfor i := 1; i <= c; i++ {\n\t\tnxt, u := make([]int, i+1), 0\n\t\tf = f * int64(i) % mod\n\t\tfor j, v := range cur {\n\t\t\tnxt[j] = (u + v) % mod\n\t\t\tu = v\n\t\t}\n\t\tnxt[i], fac[i], comb[i], cur = 1, f, nxt, nxt\n\t}\n\tfmt.Println(helper(a, b) * helper(a, c) % mod * helper(b, c) % mod)\n}", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "0d3ed4a3ceb2b7e8f7422a85a54375c0", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tconst m = 998244353\n\tconst mx = 5000\n\tF := [mx + 1]int64{1}\n\tfor i := 1; i <= mx; i++ {\n\t\tF[i] = F[i-1] * int64(i) % m\n\t}\n\tpow := func(x, n int64) int64 {\n\t\tres := int64(1)\n\t\tfor ; n > 0; n >>= 1 {\n\t\t\tif n&1 == 1 {\n\t\t\t\tres = res * x % m\n\t\t\t}\n\t\t\tx = x * x % m\n\t\t}\n\t\treturn res\n\t}\n\tinvF := [...]int64{mx: pow(F[mx], m-2)}\n\tfor i := mx; i > 0; i-- {\n\t\tinvF[i-1] = invF[i] * int64(i) % m\n\t}\n\tC := func(n, k int) int64 { return F[n] * invF[k] % m * invF[n-k] % m }\n\tf := func(a, b int) (s int64) {\n\t\tfor i := 0; i <= a && i <= b; i++ {\n\t\t\ts = (s + C(a, i)*C(b, i)%m*F[i]) % m\n\t\t}\n\t\treturn\n\t}\n\n\tvar a, b, c int\n\tScan(&a, &b, &c)\n\tPrint(f(a, b) * f(b, c) % m * f(a, c) % m)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "60a2425c98a2c0afd9df90b9b9f8ad11", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 304A\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b, n int\n\ts := 0\n\tfmt.Scan(&n)\n\tfor a = 1; a <= n; a++ {\n\t\tfor b = a; b <= n; b++ {\n\t\t\tc := int(math.Sqrt(float64(a*a + b*b)))\n\t\t\tif c <= n && c*c == a*a+b*b {\n\t\t\t\ts++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(s)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "d83e763276845dcae309cf5d1267d23c", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t//\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar w *bufio.Writer\n\nvar sc *bufio.Scanner\n\nconst minus, zero byte = '-', '0'\n\nfunc nextInt() int {\n\tvar ans, fst int = 0, 0\n\tvar neg bool = false\n\tsc.Scan()\n\tif sc.Bytes()[0] == minus {\n\t\tfst = 1\n\t\tneg = true\n\t}\n\tfor _, j := range sc.Bytes()[fst:] {\n\t\tans = ans*10 + int(j-zero)\n\t}\n\tif neg == true {\n\t\tans = -ans\n\t}\n\treturn ans\n}\n\nfunc printInt(n int) {\n\tw.WriteString(strconv.Itoa(n) + \" \")\n}\n\nfunc Max(a int, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc gcd(a int, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t} else {\n\t\treturn gcd(b, a%b)\n\t}\n}\n\nfunc main() {\n\n\tw = bufio.NewWriter(os.Stdout)\n\tsc = bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\tcnt := 0\n\n\tN := nextInt()\n\tfor m := 1; m <= N; m++ {\n\t\tfor n := m; 2*m*n <= N; n++ {\n\t\t\ta, b, c := 2*m*n, n*n-m*m, n*n+m*m\n\t\t\tif a > b {\n\t\t\t\ta, b = b, a\n\t\t\t}\n\t\t\tif gcd(m, n) == 1 && (m^n)%2 == 1 && b <= N && c <= N {\n\t\t\t\tcnt += N / Max(Max(a, c), b)\n\t\t\t}\n\t\t}\n\t}\n\tprintInt(cnt)\n\tw.Flush()\n\t//YOU FORGOT TO FLUSH!\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "0b8363513470e878ade7497aa7a64ccd", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 304A-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n, hsl int\n fmt.Scan(&n)\n for a := 1; a <= n; a++ {\n c := a\n for b := a; a*a+b*b <= n*n; b++ {\n for c*c < a*a+b*b {\n c++\n }\n if c*c == a*a+b*b {\n hsl++\n }\n }\n }\n fmt.Println(hsl)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "51237fc9d929d8c5d2e45b0ee258b799", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tinput := bufio.NewReader(os.Stdin)\n\tvar s string\n\n\t_, err := fmt.Fscan(input, &s)\n\tif err != nil {\n\t}\n\n\tn := len(s)\n\tresult := (n - 1) / 2\n\tk := s[1:]\n\tif (n-1)%2 != 0 {\n\t\tfmt.Println(result + 1)\n\t\treturn\n\t}\n\tif t, _ := strconv.Atoi(k); t == 0 {\n\t\tfmt.Println(result)\n\t\treturn\n\t}\n\tfmt.Println(result + 1)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "24944958f0ff33b683ed464cd03a0088", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar given string\n\tfmt.Scanf(\"%s\", &given)\n\tlens := len(given)\n\tanswer := (lens - 1) / 2\n\toneplus := given[1:]\n\tif (lens-1)%2 != 0 {\n\t\tanswer++\n\t\tfmt.Println(answer)\n\t\treturn\n\t}\n\trets := 0\n\trets, _ = strconv.Atoi(oneplus)\n\tif rets == 0 {\n\t\tfmt.Println(answer)\n\t\treturn\n\t}\n\tanswer++\n\tfmt.Println(answer)\n\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "75072c48c5ece5904ed8066e7f4df3bb", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\tN := len(s)\n\tres := (N - 1) / 2\n\tdeg := s[0] == '1' && (N-1)%2 == 0\n\tfor i := 1; i < N; i++ {\n\t\tif s[i] == '1' {\n\t\t\tdeg = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif !deg && s != \"0\" {\n\t\tres++\n\t}\n\tfmt.Print(res)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "8b70cee2bf9c4c965f8abd18c972ee52", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tch := make(chan string)\n\tgo func() {\n\t\tscanner := bufio.NewScanner(os.Stdin)\n\t\tfor scanner.Scan() {\n\t\t\tch <- scanner.Text()\n\t\t}\n\t}()\n\ts = <-ch\n\tss := strings.Split(s, \" \")\n\td, _ := strconv.Atoi(ss[0])\n\tif ss[len(ss)-1] == \"month\" {\n\t\tif d <= 29 {\n\t\t\tfmt.Println(\"12\")\n\t\t\treturn\n\t\t}\n\t\tif d <= 30 {\n\t\t\tfmt.Println(\"11\")\n\t\t\treturn\n\t\t}\n\t\tif d <= 31 {\n\t\t\tfmt.Println(\"7\")\n\t\t\treturn\n\t\t}\n\t}\n\tcw := 366 / 7\n\tif d == 5 || d == 6 {\n\t\tcw++\n\t}\n\tfmt.Printf(\"%v\", cw)\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "6a652afc5561c8f6855e4adcaad4709a", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// cf611a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x int\n\tvar s string\n\tfmt.Scanf(\"%d of %s\", &x, &s)\n\tm := []int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}\n\td := []int{52, 52, 52, 52, 53, 53, 52}\n\tif s == \"week\" {\n\t\tfmt.Println(d[x-1])\n\t} else {\n\t\tvar c int\n\t\tfor _, v := range m {\n\t\t\tif v >= x {\n\t\t\t\tc++\n\t\t\t}\n\t\t}\n\t\tfmt.Println(c)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "14858bbc58ee5909108f523ad17acf45", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n//import \"strings\"\n\nvar s string\nvar n, ans int\n\nfunc main() {\n fmt.Scanf(\"%d of %s\", &n, &s)\n switch s {\n case \"week\":\n ans = cal_week(n)\n case \"month\":\n ans = cal_month(n)\n }\n fmt.Println(ans)\n}\n\nfunc cal_week(n int) int {\n if n == 5 || n == 6 {\n return 53\n } else {\n return 52\n }\n\n}\n\nfunc cal_month(n int) int {\n if n < 30 {\n return 12\n } else if n == 30 {\n return 11\n } else {\n return 7\n }\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "975545f899624c84279a87763a616186", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var h,a [35]int\n fmt.Scan(&n)\n for i := 0; i < n; i++ { fmt.Scan(&h[i],&a[i]) }\n ans := 0\n for i := 0; i < n; i++ {\n for j := 0; j < n; j++ {\n if (i != j) && (h[i] == a[j]) {\n ans++\n }\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "3d62301df9fd07bd767ef5da0e0fa6f5", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar noOfTeams, currNumber, result int\n\treader := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(reader, &noOfTeams)\n\thomeAway := make([][2]int, noOfTeams)\n\tfor index := 0; index < noOfTeams; index++ {\n\t\tfmt.Fscan(reader, &currNumber)\n\t\thomeAway[index][0] = currNumber\n\t\tfmt.Fscan(reader, &currNumber)\n\t\thomeAway[index][1] = currNumber\n\t}\n\tfor index := 0; index < noOfTeams; index++ {\n\t\tawayWear := homeAway[index][1]\n\t\tfor innerIndex := 0; innerIndex < noOfTeams; innerIndex++ {\n\t\t\tif index == innerIndex {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif awayWear == homeAway[innerIndex][0] {\n\t\t\t\tresult++\n\t\t\t}\n\n\t\t}\n\t}\n\tfmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "6261a7f68deb65ba2bfc26ab786764dc", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, ans int\n\tfmt.Scan(&n)\n\tuni := make([][2]int, n)\n\tfor i := range uni {\n\t\tfmt.Scan(&uni[i][0], &uni[i][1])\n\t}\n\tfor home := range uni {\n\t\tfor guest := range uni {\n\t\t\tif uni[home][0] == uni[guest][1] {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "f975df6029a106953b1530b1818b5b4e", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1114/C\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn, b int64\n)\n\nfunc main() {\n\tn, b = ReadInt64_2()\n\n\tif n == 1 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tmemo := TrialDivision(b)\n\n\tcounts := make(map[int64]int64)\n\tfor a := range memo {\n\t\tcnt := int64(0)\n\t\tcur := a\n\t\tfor n/cur > 0 {\n\t\t\tcnt += n / cur\n\t\t\t// PrintfDebug(\"cur: %d, diff: %d\\n\", cur, n/cur)\n\n\t\t\tif IsProductOverflow(cur, a, INF_INT64) {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tcur *= a\n\t\t}\n\n\t\tcounts[a] = cnt\n\t}\n\t// PrintfDebug(\"素因数分解: %v\\n\", memo)\n\t// PrintfDebug(\"カウント: %v\\n\", counts)\n\n\tans := int64(INF_INT64)\n\tfor a, cnt := range counts {\n\t\te := memo[a]\n\t\tChMin(&ans, cnt/e)\n\t}\n\tfmt.Println(ans)\n}\n\nfunc IsProductOverflow(i, j, m int64) bool {\n\treturn float64(i)*float64(j) > float64(m)\n}\n\nfunc IsAddOverflow(i, j, m int64) bool {\n\treturn float64(i)+float64(j) > float64(m)\n}\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int64, target int64) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// TrialDivision returns the result of prime factorization of integer N.\nfunc TrialDivision(n int64) map[int64]int64 {\n\tvar i, exp int64\n\tp := map[int64]int64{}\n\n\tif n <= 1 {\n\t\tpanic(errors.New(\"[argument error]: TrialDivision only accepts a NATURAL number\"))\n\t}\n\n\tfor i = 2; i*i <= n; i++ {\n\t\texp = 0\n\t\tfor n%i == 0 {\n\t\t\texp++\n\t\t\tn /= i\n\t\t}\n\n\t\tif exp == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tp[i] = exp\n\t}\n\tif n > 1 {\n\t\tp[n] = 1\n\t}\n\n\treturn p\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "d55215da8bce16609335a8f3fdb0a7ce", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1114C(in io.Reader, out io.Writer) {\n\tvar n, x int64\n\tFscan(in, &n, &x)\n\tans := int64(1e18)\n\tf := func(p, e int64) {\n\t\tc := int64(0)\n\t\tfor pp := p; ; pp *= p {\n\t\t\tc += n / pp\n\t\t\tif pp > n/p {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif c/e < ans {\n\t\t\tans = c / e\n\t\t}\n\t}\n\tfor i := int64(2); i*i <= x; i++ {\n\t\te := int64(0)\n\t\tfor ; x%i == 0; x /= i {\n\t\t\te++\n\t\t}\n\t\tif e > 0 {\n\t\t\tf(i, e)\n\t\t}\n\t}\n\tif x > 1 {\n\t\tf(x, 1)\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF1114C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "b861116eadae81829eabd9773b803445", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n\nfunc main() {\n\tdefer Flush()\n\n\tn := readi()\n\tprintln(n/2 + 1)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "2653edfd4866a5021d7a87ef74f74eca", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n var n int\n fmt.Scan(&n)\n fmt.Println(n/2+1)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "90b06f3452f7ed7bb53cc7c4371ce371", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nconst debug = true\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tn := gsli(reader)[0]\n\n\tif n == 1 {\n\t\tfmt.Println(\"1\")\n\t\treturn\n\t}\n\n\tfmt.Println(n/2 + 1)\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// String helpers\n\n// Is Lowercase\n// Given some string[i], return whether it is lower case or not.\n\nfunc isl(b byte) bool {\n\tvar r rune\n\tr = rune(b)\n\treturn unicode.IsLower(r)\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\n// Max Int\n// Returns the max of two ints\n\nfunc maxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// Distance formule\n// Calculates the distance to the origin\n\nfunc dist(x, y float64) float64 {\n\treturn math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))\n}\n\n// Output helpers\n\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\n\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\n// Debug helpers\n\n// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss\n\nfunc dbg(s string, a ...interface{}) {\n\tif debug {\n\t\tfmt.Printf(s, a...)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "41f085a93e5e47cb2cb2d1c411cf1918", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\ti:=0.0\n\tfmt.Scanln(&i)\n\tc:=math.Log2(i)\n\td:=float64(int(c))\n\tif c-d<0.000001 {\n\t\tfmt.Println(\"YES\")\n\t}else {\n\t\tfmt.Println(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "f1396e6bc32279841451f20d87e344e2", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt64()\n\tm := readInt64()\n\ta := readInt64()\n\tb := readInt64()\n\trest := n % m\n\tif rest == 0 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\tans := min(a*(m-rest), b*rest)\n\tfmt.Println(ans)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "2f3900c77349e55b622861bd1542d974", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar n, m, a, b int64\n\nfunc min(a, b int64) int64 {\n if a < b {\n return a\n } else {\n return b\n }\n}\n\nfunc main() {\n fmt.Scan(&n, &m, &a, &b)\n if n % m == 0 {\n fmt.Println(\"0\")\n } else {\n c := n / m\n ans := min((c * m + m - n) * a, (n - c * m) * b)\n fmt.Println(ans)\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "954176a946d93ac40a0e5d18c378e4c6", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m, a, b int64\n\n\tfmt.Scanf(\"%d %d %d %d\", &n, &m, &a, &b)\n\n\tif n%m == 0 {\n\t\tfmt.Println(\"0\")\n\t} else {\n\t\tdivision := n / m\n\t\tbuild := (division+1)*m - n\n\t\tdemolish := division*m - n\n\n\t\tbuild *= a\n\t\tdemolish *= -b\n\n\t\tif build > demolish {\n\t\t\tfmt.Println(demolish)\n\t\t} else {\n\t\t\tfmt.Println(build)\n\t\t}\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "d4c134ae2a4d2f098d5941cc6a3f6b54", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nconst MAX = 300\n\nvar vis [MAX][MAX][32][10][6]bool\nvar mark [MAX][MAX]bool\nvar dx [8]int = [8]int{1, 1, 1, 0, -1, -1, -1, 0}\nvar dy [8]int = [8]int{-1, 0, 1, 1, 1, 0, -1, -1}\n\nvar n int\nvar t []int\n\nfunc dfs(x, y, c, dir, step int) {\n\n\tif c == n || vis[x][y][c][dir][step] {\n\t\treturn\n\t}\n\n\t//fmt.Printf(\"%d %d %d %d %d\\n\", x, y, c, dir, step)\n\n\tmark[x][y] = true\n\tvis[x][y][c][dir][step] = true\n\tif step > 0 {\n\t\tdfs(x+dx[dir], y+dy[dir], c, dir, step-1)\n\t} else {\n\t\tdfs(x+dx[(dir+1)%8], y+dy[(dir+1)%8], c+1, (dir+1)%8, t[c+1]-1)\n\t\tdfs(x+dx[(dir+7)%8], y+dy[(dir+7)%8], c+1, (dir+7)%8, t[c+1]-1)\n\t}\n}\n\nfunc main() {\n\tb, _ := ioutil.ReadAll(os.Stdin)\n\tr := bytes.NewReader(b)\n\tfmt.Fscanf(r, \"%d\\n\", &n)\n\n\tt = make([]int, n+1)\n\tfor i := 0; i < n-1; i++ {\n\t\tfmt.Fscanf(r, \"%d \", &t[i])\n\t}\n\tfmt.Fscanf(r, \"%d\\n\", &t[n-1])\n\n\tfor i := 0; i < MAX; i++ {\n\t\tfor j := 0; j < MAX; j++ {\n\t\t\tfor k := 0; k < 32; k++ {\n\t\t\t\tfor l := 0; l < 10; l++ {\n\t\t\t\t\tfor m := 0; m < 6; m++ {\n\t\t\t\t\t\tvis[i][j][k][l][m] = false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tdfs(150, 150, 0, 1, t[0]-1)\n\n\tcnt := 0\n\n\tfor i := 0; i < MAX; i++ {\n\t\tfor j := 0; j < MAX; j++ {\n\t\t\tif mark[i][j] {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n\", cnt)\n\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "78d39b2fcbac6010a212631f8e8a5be0", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype move struct {\n\tx int\n\ty int\n\tdx int\n\tdy int\n\tw int\n}\n\nconst W = 5000 * 1000\nconst H = 5*30*2 + 10\nconst Z = H / 2\n\nvar used [H][H]bool\nvar wave [H][H][3][3][2]bool\nvar t [31]int\nvar n int\nvar maxw int\n\nvar q [W]move\nvar hd, tl int\n\nfunc push(m move) {\n\tq[tl] = m\n\tif tl == W-1 {\n\t\ttl = 0\n\t} else {\n\t\ttl += 1\n\t}\n}\n\nfunc pop() move {\n\tret := q[hd]\n\tif hd == W-1 {\n\t\thd = 0\n\t} else {\n\t\thd += 1\n\t}\n\treturn ret\n}\n\nfunc empty() bool {\n\treturn hd == tl\n}\n\nvar ndx [3][3]int\nvar ndy [3][3]int\nvar ndxx [3][3]int\nvar ndyy [3][3]int\n\nfunc do() {\n\tm := pop()\n\n\ttt := t[m.w]\n\tlx := m.x + (tt-1)*m.dx\n\tly := m.y + (tt-1)*m.dy\n\n\t//fmt.Printf(\"%d lines from (%d, %d) with dir (%d, %d)\\n\", tt, m.x-Z, m.y-Z, m.dx, m.dy)\n\n\tfor i := 0; i < tt; i++ {\n\t\tused[m.x+i*m.dx][m.y+i*m.dy] = true\n\t}\n\n\tif m.w+1 < n {\n\t\tndx1 := ndx[1+m.dx][1+m.dy]\n\t\tndy1 := ndy[1+m.dx][1+m.dy]\n\t\tx1 := lx + ndx1\n\t\ty1 := ly + ndy1\n\n\t\tnw := (m.w + 1) % 2\n\t\tif m.w+1 > maxw {\n\t\t\tmaxw = m.w + 1\n\t\t\tclear()\n\t\t}\n\n\t\tif !wave[x1][y1][1+ndx1][1+ndy1][nw] {\n\t\t\twave[x1][y1][1+ndx1][1+ndy1][nw] = true\n\t\t\tpush(move{x1, y1, ndx1, ndy1, m.w + 1})\n\t\t}\n\n\t\tndx2 := ndxx[1+m.dx][1+m.dy]\n\t\tndy2 := ndyy[1+m.dx][1+m.dy]\n\t\tx2 := lx + ndx2\n\t\ty2 := ly + ndy2\n\t\tif !wave[x2][y2][1+ndx2][1+ndy2][nw] {\n\t\t\twave[x2][y2][1+ndx2][1+ndy2][nw] = true\n\t\t\tpush(move{x2, y2, ndx2, ndy2, m.w + 1})\n\t\t}\n\t}\n}\n\nfunc clear() {\n\tk := maxw % 2\n\tfor x := 0; x < H; x++ {\n\t\tfor y := 0; y < H; y++ {\n\t\t\tfor i := 0; i < 3; i++ {\n\t\t\t\tfor j := 0; j < 3; j++ {\n\t\t\t\t\twave[x][y][i][j][k] = false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc main() {\n\n\tndy = [3][3]int{\n\t\t{0, 1, 1},\n\t\t{-1, 0, 1},\n\t\t{-1, -1, 0},\n\t}\n\n\tndx = [3][3]int{\n\t\t{-1, -1, 0},\n\t\t{-1, 0, 1},\n\t\t{0, 1, 1},\n\t}\n\n\tndyy = [3][3]int{\n\t\t{-1, -1, 0},\n\t\t{-1, 0, 1},\n\t\t{0, 1, 1},\n\t}\n\n\tndxx = [3][3]int{\n\t\t{0, -1, -1},\n\t\t{1, 0, -1},\n\t\t{1, 1, 0},\n\t}\n\n\tin := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(in, \"%d\", &t[i])\n\t}\n\n\tfor x := 0; x < H; x++ {\n\t\tfor y := 0; y < H; y++ {\n\t\t\tfor i := 0; i < 3; i++ {\n\t\t\t\tfor j := 0; j < 3; j++ {\n\t\t\t\t\tfor z := 0; z < 2; z++ {\n\t\t\t\t\t\twave[x][y][i][j][z] = false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tused[x][y] = false\n\t\t}\n\t}\n\n\twave[Z][Z][0][1][0] = true\n\tpush(move{Z, Z, 0, 1, 0})\n\tmaxw = 0\n\n\tfor !empty() {\n\t\tdo()\n\t}\n\n\tret := 0\n\tfor x := 0; x < H; x++ {\n\t\tfor y := 0; y < H; y++ {\n\t\t\tif used[x][y] {\n\t\t\t\tret += 1\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ret)\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "ea90fc21c4a34817c6e2c9e7e2c7cc6d", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strconv\"\n)\ntype Pos struct {\n i, j, lvl, di, dj int\n}\n\nfunc solve() {\n const mx = 300\n n := readInt()\n a := readIntArray(n)\n\n was := [mx+2][mx+2][31][3][3]bool{}\n ans := [mx+2][mx+2]bool{}\n setWas := func(p Pos) {\n was[p.i][p.j][p.lvl][p.di+1][p.dj+1] = true\n }\n checkWas := func(p Pos) bool {\n return was[p.i][p.j][p.lvl][p.di+1][p.dj+1]\n }\n q := []Pos{Pos{mx/2, mx/2, 0, 1, 0}}\n setWas(q[0])\n for i := 0; i < len(q); i++ {\n cur := q[i]\n for t := 0; t < a[cur.lvl]; t++ {\n cur.i += cur.di\n cur.j += cur.dj\n ans[cur.i][cur.j] = true\n }\n if nextLvl := cur.lvl+1; nextLvl < n {\n for rot := -1; rot < 2; rot += 2 {\n next := Pos{cur.i, cur.j, nextLvl, 0, 0}\n if abs(cur.di*cur.dj) == 1 {\n if rot == 1 {\n next.di = cur.di\n } else {\n next.dj = cur.dj\n }\n } else {\n if cur.di == 0 {\n next.di = rot\n next.dj = cur.dj\n } else {\n next.di = cur.di\n next.dj = rot\n }\n \t\t\t\t}\n if !checkWas(next) {\n setWas(next)\n q = append(q, next)\n }\n }\n }\n }\n res := 0\n for i := range ans {\n for _, b := range ans[i] {\n if b {\n res++\n }\n }\n }\n fmt.Println(res)\n}\n\n\n\n// Helpers\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\n// Sort\n\ntype Ints64 []int64\n\nfunc (a Ints64) Len() int { return len(a) }\nfunc (a Ints64) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a Ints64) Less(i, j int) bool { return a[i] < a[j] }\n\n/* Sort tempalte\nfunc (a ) Len() int { return len(a) }\nfunc (a ) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ) Less(i, j int) bool { return }\n*/\n", "lang_cluster": "Go", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "caee31b9c5be2de858bec4a8da82a2f5", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// https://codeforces.com/problemset/problem/1097/B\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\t\n\tvar n int64\n\tscanf(\"%d\\n\", &n)\n\tarr := make([]int64, n)\n\t\n\tfor i:=int64(0);i>uint(j))&1 == 1 {\n\t\t\t\tsum += a[j]\n\t\t\t} else {\n\t\t\t\tsum -= a[j]\n\t\t\t}\n\t\t}\n\t\tif sum%360 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "5031a6618521de06821bb66c88d1e6d7", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc fac(num int64) int64 {\n\tif num == 1 {\n\t\treturn num\n\t}\n\treturn fac(num-1) * num\n}\n\nfunc main() {\n\tvar a int64\n\tvar b int64\n\tfmt.Scanf(\"%d %d\", &a, &b)\n\tvar minnum = int64(math.Min(float64(a), float64(b)))\n\tfmt.Printf(\"%v\\n\", fac(minnum))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "2a1a6e063bbbc3458c69be46320631e8", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, m int\n\n\tfmt.Scan(&n, &m)\n\tvar c int = 1\n\tfor i := 1; i <= int(math.Min(float64(n), float64(m))); i++ {\n\t\tc = c * i\n\t}\n\tfmt.Println(c)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "813bab04172aedba36b787c604c9e3a9", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar (\n a, b int64\n)\n\nfunc main() {\n fmt.Scanln(&a,&b)\n if a>b {\n a = b\n }\n b := int64(1)\n for i := int64(1) ; i<=a ; i++ {\n b *=i\n }\n fmt.Println(b)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "94f8ee4a2af07b1c1d993d19a0fb97a4", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst NMAX = 100\nconst EMPTY = 255\nconst INFINITY = uint32(999999)\n\nfunc toInt(buf []byte) uint32 {\n\tn := uint32(0)\n\tfor _, v := range buf {\n\t\tn = n*10 + uint32(v-'0')\n\t}\n\n\treturn n\n}\n\nfunc solve(n uint32, p [NMAX]uint32) uint32 {\n type State struct {\n odds int\n evens int\n last uint32\n index uint32\n }\n \n start := State{}\n \n for i := uint32(1); i <= n; i++ {\n f := false\n for j := uint32(0); j < n; j++ {\n f = f || i == p[j]\n }\n\n if !f {\n if i % 2 == 0 {\n start.evens++\n } else {\n start.odds++\n }\n }\n }\n \n memo := map[State]uint32{}\n var solve func(s State) uint32\n solve = func(s State) uint32 {\n if r, f := memo[s]; f {\n return r\n }\n\n i, r := s.index, uint32(0)\n for ; i < n && p[i] != 0; i++ {\n if i > 0 {\n prev := p[i - 1]\n if prev == 0 {\n prev = s.last\n }\n if prev % 2 != p[i] % 2 {\n r++\n }\n }\n }\n \n prev := uint32(0)\n if i > 0 {\n prev = p[i - 1]\n if prev == 0 {\n prev = s.last\n }\n }\n \n if i < n && p[i] == 0 {\n r1, r2 := INFINITY, INFINITY\n if s.odds > 0 {\n next := State{index: i + 1, odds: s.odds - 1, evens: s.evens, last: 1}\n r1 = solve(next)\n if i > 0 && (prev % 2 == 0) {\n r1++\n }\n }\n \n if s.evens > 0 {\n next := State{index: i + 1, odds: s.odds, evens: s.evens - 1}\n r2 = solve(next)\n if i > 0 && (prev % 2 > 0) {\n r2++\n }\n }\n\n if r1 > r2 {\n r1 = r2\n }\n \n r += r1\n }\n \n memo[s] = r\n \n return r\n }\n\n return solve(start)\n}\n\nfunc main() {\n\tvar n uint32\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tn = toInt(scanner.Bytes())\n\t\n p := [NMAX]uint32{}\n for i := uint32(0); i < n; i++ {\n scanner.Scan()\n p[i] = toInt(scanner.Bytes())\n }\n \n res := solve(n, p)\n fmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "dp", "greedy"], "code_uid": "6d22d862db46fe953c79dc8b3ee1b94c", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nconst N = 102\nconst Mask = 2\nconst INF = 1e9 + 1\n\nvar n int\nvar dp[N][N][Mask] int\nvar cnt[N] int\nvar a[N] int\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\n\tvar odd = 0\n\tfor i := 1; i <= n; i++ {\n\t\tfmt.Fscanf(reader, \"%d\", &a[i])\n\t\tcnt[i] = cnt[i - 1]\n\t\tif a[i]%2 != 0 {\n\t\t\tcnt[i]++\n\t\t\todd++\n\t\t}\n\t}\n\n\tvar mo = n / 2\n\tif n % 2 != 0 {\n\t\tmo++\n\t}\n\tmo -= odd\n\t\n\tfor i := 0; i <= n; i++ {\n\t\tfor j := 0; j <= n; j++ {\n\t\t\tdp[i][j][0] = INF\n\t\t\tdp[i][j][1] = INF\n\t\t}\n\t}\n\n\tdp[0][0][0] = 0\n\tdp[0][0][1] = 0\n\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j <= mo; j++ {\n\t\t\tfor k := 0; k < 2; k++ {\n\t\t\t\tif a[i+1] > 0 {\n\t\t\t\t\t// already\n\t\t\t\t\tvar nk= a[i+1] % 2\n\t\t\t\t\tvar add= 0\n\t\t\t\t\tif nk != k {\n\t\t\t\t\t\tadd++\n\t\t\t\t\t}\n\t\t\t\t\tdp[i+1][j][nk] = min(dp[i+1][j][nk], dp[i][j][k]+add)\n\t\t\t\t} else {\n\t\t\t\t\t// even\n\t\t\t\t\t{\n\t\t\t\t\t\tvar add= 0\n\t\t\t\t\t\tif k != 0 {\n\t\t\t\t\t\t\tadd++\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdp[i+1][j][0] = min(dp[i+1][j][0], dp[i][j][k]+add)\n\t\t\t\t\t}\n\t\t\t\t\t// odd\n\t\t\t\t\t{\n\t\t\t\t\t\tvar add= 0\n\t\t\t\t\t\tif k != 1 {\n\t\t\t\t\t\t\tadd++\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif j+1 <= mo {\n\t\t\t\t\t\t\tdp[i+1][j+1][1] = min(dp[i+1][j+1][1], dp[i][j][k]+add)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvar ret = min(dp[n][mo][0], dp[n][mo][1])\n\tfmt.Fprintf(writer, \"%d\\n\", ret)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "dp", "greedy"], "code_uid": "66be85c8c77dc8c7af88529c886d53bc", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc work(capacity int, arrOne []int, arrTwo []int) int {\n\tsort.Ints(arrOne)\n\tsort.Ints(arrTwo)\n\tused, cnt, ans := 0, 0, 0\n\tfor i, j := -1, -1; i <= len(arrOne); i++ {\n\t\tfor ; j + 1 < len(arrTwo) && used + arrTwo[j + 1] <= capacity; j++ {\n\t\t\tused += arrTwo[j + 1]\n\t\t\tcnt += 2\n\t\t}\n\t\tfor ; j >= 0 && used > capacity; j-- {\n\t\t\tused -= arrTwo[j]\n\t\t\tcnt -= 2\n\t\t}\n\t\tif used <= capacity && cnt > ans {\n\t\t\tans = cnt\n\t\t}\n\t\tif i + 1 < len(arrOne) {\n\t\t\tused += arrOne[i + 1]\n\t\t\tcnt++\n\t\t}\n\t}\n\t// fmt.Println(\"-=\", ans)\n\treturn ans\n}\n\nfunc main() {\n\tvar n, x int\n\tfmt.Scan(&n)\n\tif n == 1 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\tcntOdd, cntEven := (n + 1) / 2, n / 2\n\tvar odd, odd2, even, even2 []int\n\tlast, emptyLen, ans := -1, 0, 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&x)\n\t\tif x == 0 {\n\t\t\temptyLen++\n\t\t\tcontinue\n\t\t}\n\t\tx %= 2\n\t\tif x == 1 {\n\t\t\tcntOdd--\n\t\t} else {\n\t\t\tcntEven--\n\t\t}\n\t\tif last != -1 && x != last {\n\t\t\tans++\n\t\t}\n\t\tif emptyLen > 0 {\n\t\t\tif last == -1 || last == x {\n\t\t\t\tif last == -1 {\n\t\t\t\t\tans++\n\t\t\t\t\tif x == 0 {\n\t\t\t\t\t\teven = append(even, emptyLen)\n\t\t\t\t\t} else {\n\t\t\t\t\t\todd = append(odd, emptyLen)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tans += 2\n\t\t\t\t\tif x == 0 {\n\t\t\t\t\t\teven2 = append(even2, emptyLen)\n\t\t\t\t\t} else {\n\t\t\t\t\t\todd2 = append(odd2, emptyLen)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\temptyLen = 0\n\t\t}\n\t\tlast = x\n\t}\n\n\tif last == -1 {\n\t\tfmt.Println(1)\n\t\treturn\n\t}\n\tif emptyLen > 0 {\n\t\tans++\n\t\tif last == 0 {\n\t\t\teven = append(even, emptyLen)\n\t\t} else {\n\t\t\todd = append(odd, emptyLen)\n\t\t}\n\t}\n\t// fmt.Println(\"ans\", ans)\n\tans -= work(cntEven, even, even2)\n\tans -= work(cntOdd, odd, odd2)\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "dp", "greedy"], "code_uid": "6dc03d0f2021fa3a26f2fcac263c90e3", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, t, k, d int\n\tfmt.Scan(&n, &t, &k, &d)\n\tno := (n + k - 1) / k * t\n\tif no <= d+t {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "8ed2641718fce6f7c73dad2aa9229af3", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k, t, d int\n\tfmt.Scan(&n, &t, &k, &d)\n\tx := t\n\tfor d >= 0 {\n\t\tif x == t {\n\t\t\tn -= k\n\t\t}\n\t\tif n <= 0 {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t\td--\n\t\tx--\n\t\tif x == 0 {\n\t\t\tx = t\n\t\t}\n\t}\n\tfmt.Println(\"YES\")\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "fb47c8fcb1f81ff4fa78df83d50ad138", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar noOfNeededCakes int\n\tfmt.Scan(&noOfNeededCakes) \n\tvar timeNeedForCakes int \n\tfmt.Scan(&timeNeedForCakes) \n\tvar noOfCakesAtSameTime int\n\tfmt.Scan(&noOfCakesAtSameTime) \n\tvar timeToBuildOven int\t\n\tfmt.Scan(&timeToBuildOven)\n\tg := (noOfNeededCakes + noOfCakesAtSameTime - 1 ) / noOfCakesAtSameTime\n\tnormalCycle := 0\n\ttwoCycle := timeToBuildOven\n\tfor i := 1; i <= g; i++ {\n\t\tif normalCycle <= twoCycle {\n\t\t\tnormalCycle += timeNeedForCakes\n\t\t} else {\n\t\t\ttwoCycle += timeNeedForCakes\n\t\t}\n\t}\n\tmax := 0\n\tif normalCycle > twoCycle {\n\t\tmax = normalCycle\n\t} else {\n\t\tmax = twoCycle\n\t}\n\tif max < g * timeNeedForCakes {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "805f1fb7571f876bcf86447abe9a01e0", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar N, K int64\n\tfmt.Scanf(\"%d %d\", &N, &K)\n\todds := N / 2 + N % 2\n\n\tif K <= odds {\n\t\tfmt.Println(1 + (K - 1) * 2)\n\t} else {\n\t\tfmt.Println(2 + (K - odds - 1) * 2)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "1bbcc5426bef12834ad7f5284b5e61fd", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\t\n\t\"bufio\"\n\t\"os\"\n)\n\nvar in *bufio.Reader = bufio.NewReader(os.Stdin)\nvar out *bufio.Writer = bufio.NewWriter(os.Stdout)\n\n\nfunc main() {\n\tvar n,k int64\n \tvar even int64\n\tfmt.Fscan(in,&n)\n\tfmt.Fscan(in,&k)\n\n\tif n % 2 == 0 {\n\t\teven = n / 2\n\t}else {\n\t\teven = n / 2 + 1\n\t}\n\t\n\tif k > even {\n\t\tfmt.Println((k-even) * 2)\n\t}else{\n\t\tfmt.Println((k * 2) - 1)\n\t}\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "0f6bcb834d616b0ad32c3ac62b26d576", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar n, k int64\n\nfunc main() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader := bufio.NewReaderSize(stdin, 1<<20)\n\tfmt.Fscanf(reader, \"%d%d\\n\", &n, &k)\n\n\tif k <= (n+1)/2 {\n\t\tfmt.Println(2*k - 1)\n\t} else {\n\t\tfmt.Println(2 * (k - (n+1)/2))\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "f3c21a74d37cf2367295c84023dff482", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n, i int\n \n fmt.Scan(&n)\n\n for cnt:=1; cnt<=n; i++{\n cnt *= 2;\n } \n \n fmt.Println(i)\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "3961af969e0326a866d4003604432457", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\n\tvar n int\n\tfmt.Fscan(in, &n)\n\n\tcnt := 0\n\tdouble := 1\n\tfor n > 0 {\n\t\tcnt++\n\t\tn -= double\n\t\tdouble *= 2\n\t}\n\n\tfmt.Fprintln(out, cnt)\n\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "e3da33233402daf41b1edaa62c5f36b2", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\nfunc main() {\n\t var n float64\n\tfmt.Scanf(\"%f\",&n)\n\tx:=int(math.Log2(n))\n\tfmt.Println(x+1);\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "b7738b4a4a9227167fbdf7da81a7f504", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tn int\n\t)\n\tfmt.Scan(&n)\n\ta, b := Calculate854A(n)\n\tfmt.Print(a, b)\n}\n\nfunc Calculate854A(n int) (int, int) {\n\tfor a := n / 2; a > 0; a-- {\n\t\tvar b = n - a\n\t\tif Gcd(a, b) == 1 {\n\t\t\treturn a, b\n\t\t}\n\t}\n\treturn 0, 0\n}\n\nfunc Gcd(a int, b int) (int) {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "302067d676f0ecfd365671b5bad591a7", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc gcd(a int, b int) int {\n if b == 0 {\n return a\n }\n if a < b {\n return gcd(b, a)\n } else {\n return gcd(b, a%b)\n }\n}\n\nvar num int\n\nfunc main() {\n fmt.Scan(&num)\n div := num / 2\n for i := div; div >= 1; i-- {\n if gcd(i, num-i) == 1 {\n fmt.Println(i, num-i)\n break\n }\n }\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "b18018725abc14ff52641b770492eda2", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tansA := 0\n\tansB := 0\n\tfor i := 1; i <= n; i++ {\n\t\ta := i\n\t\tb := n - i\n\t\tif a < b {\n\t\t\tok := true\n\t\t\tfor j := 2; j <= a; j++ {\n\t\t\t\tif a%j == 0 && b%j == 0 {\n\t\t\t\t\tok = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ok {\n\t\t\t\tansA = a\n\t\t\t\tansB = b\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d %d\\n\", ansA, ansB)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "99a0abefe77a8e42ad6111a0665ca9ee", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n uint64\n\tfmt.Scanf(\"%d\", &n)\n\n\tswitch n {\n\tcase 0:\n\t\tfmt.Println(\"1\")\n\tcase 1:\n\t\tfmt.Println(\"5\")\n\tdefault:\n\t\tfmt.Println(\"25\")\n\t}\n}", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "9e8fd7dcffbbb54c37b874124e307715", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(25)\n}\n", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "2b71baf3e60d3d9ca6d8afc00eed9232", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tfmt.Println(25)\n}\n", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "3126581ca0f53725a0c3568da67652a9", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var x,t,a,b,da,db int\n fmt.Scan(&x,&t,&a,&b,&da,&db)\n m := make(map[int]bool)\n m[0] = true\n for i := 0; i < t; i++ {\n m[a-(da*i)] = true\n }\n ans := false\n for i := 0; i <= t; i++ {\n if i == t {\n if m[x] {\n ans = true\n break\n }\n } else if m[x-(b-(db*i))] {\n ans = true\n break\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "3fb990c8dfa278bf67e27bcebbeebf26", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tx, t := scanInt(scanner), scanInt(scanner)\n\ta, b := scanInt(scanner), scanInt(scanner)\n\tda, db := scanInt(scanner), scanInt(scanner)\n\tif x == 0 {\n\t\twriter.WriteString(\"YES\\n\")\n\t\treturn\n\t}\n\tfor i := 0; i < t; i++ {\n\t\tfor j := 0; j < t; j++ {\n\t\t\tf, g := a-i*da, b-j*db\n\t\t\tif x == f || x == g || x == f+g {\n\t\t\t\twriter.WriteString(\"YES\\n\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\twriter.WriteString(\"NO\\n\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "6e87f0eb7ea8a5b4f17f7141d8578096", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 203A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tx, t, a, b, va, vb int\n\t\tax, bx [305]int\n\t)\n\tfmt.Scan(&x, &t, &a, &b, &va, &vb)\n\tax[0], ax[t] = a, 0\n\tbx[0], bx[t] = b, 0\n\tfor i := 1; i < t; i++ {\n\t\tbx[i] = bx[i-1] - vb\n\t\tax[i] = ax[i-1] - va\n\t}\n\tfor i := 0; i <= t; i++ {\n\t\tfor j := 0; j <= t; j++ {\n\t\t\tif ax[i]+bx[j] == x {\n\t\t\t\tfmt.Print(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "4ede0ed50444ed29243dde02b7e3edbc", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc cell(n int) int {\n if n == 1 {\n return 1\n } else {\n return 4*(n-1) + cell(n-1)\n }\n}\n\nfunc main() {\n\tvar n int\n fmt.Scan(&n)\n fmt.Println(cell(n))\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "implementation"], "code_uid": "2658ab25979a8ca2797a8b90aa50a9d6", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\" ,&n);\n\tfmt.Printf(\"%d\", (n - 1)*(n - 1)*2 + 2*n - 1);\n\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "implementation"], "code_uid": "abaabf6b609530bc1dc8176f90c48685", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar input io.Reader = bufio.NewReader(os.Stdin)\n\n\tvar n int\n\tvar a [105]int\n\tvar d [105]int\n\n\tfmt.Fscan(input, &n)\n\n\td[1] = 1\n\ta[1] = 0\n\n\tfor i := 2; i <= n; i++ {\n\t\ta[i] = a[i-1] + 4\n\t\td[i] = a[i] + d[i-1]\n\t}\n\n\tfmt.Println(d[n])\n\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "implementation"], "code_uid": "c57894efc6a5229c5193ea9f199b2f82", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n00, n01, n02, n10, n11, n12, n20, n21, n22 int\n\tfmt.Scan(&n00, &n01, &n02)\n\tfmt.Scan(&n10, &n11, &n12)\n\tfmt.Scan(&n20, &n21, &n22)\n\tif n00 == 0 && n11 == 0 && n22 == 0 {\n\t\thasil := (n01 + n02 + n01 + n21 + n20 + n21)/2\n\t\tn00 = hasil - n01 - n02\n\t\tn11 = hasil - n10 - n12\n\t\tn22 = hasil - n20 - n21\n\t}\n\tfmt.Print(n00, n01, n02)\n\tfmt.Println()\n\tfmt.Print(n10, n11, n12)\n\tfmt.Println()\n\tfmt.Print(n20, n21, n22)\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "3065ae7d65a76b9418c49d2b766a5302", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": " // 259B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x1, x2, x3, x4, x5, x6, x7, x8, x9 int\n\tfmt.Scan(&x1, &x2, &x3, &x4, &x5, &x6, &x7, &x8, &x9)\n\tx1 = (x3 + x6 + x7 - x2) / 2\n\tx5 = (x1 + x2 + x3 - x4 - x6)\n\tx9 = (x3 + x7 - x1)\n\tfmt.Println(x1, x2, x3)\n\tfmt.Println(x4, x5, x6)\n\tfmt.Println(x7, x8, x9)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "f16e2584e704f2dc0ad28e70e0bbf09f", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc check(d... int) bool {\n for _, v := range d {\n if v != d[0] { return false }\n }\n return true\n}\n\nfunc main() {\n var a [3][3]int\n total := 0\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n fmt.Scan(&a[i][j])\n total += a[i][j]\n }\n }\n total /= 2\n for i := 0; i < 3; i++ {\n t := total\n for j := 0; j < 3; j++ { t -= a[i][j] }\n a[i][i] = t\n }\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n fmt.Print(a[i][j])\n if j == 2 { fmt.Println() } else { fmt.Print(\" \") }\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "ab8c95fcfdff8ba36d6e0575b1b08f8c", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var n, m int\n fmt.Scan(&n, &m)\n\n ans := 0\n for a := 0; a <= m; a++ {\n b := n - a*a\n if b >= 0 && a + b*b == m {\n ans++\n }\n }\n\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "2d6aa230add78b8b893c7237e0d5b387", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar n, m int64\n\tfmt.Fscanln(reader, &n, &m)\n\tvar total, i, j, isquare, jsquare int64\n\tfor i <= n {\n\t\tj = i\n\t\tjsquare = isquare\n\t\tfor j <= m {\n\t\t\tif isquare+j == n && i+jsquare == m {\n\t\t\t\ttotal += 1\n\t\t\t\tif i != j && jsquare+i == n && j+isquare == m {\n\t\t\t\t\ttotal += 1\n\t\t\t\t}\n\t\t\t} else if jsquare+i == n && j+isquare == m {\n\t\t\t\ttotal += 1\n\t\t\t}\n\t\t\tj += 1\n\t\t\tjsquare += (2*j - 1)\n\t\t}\n\t\ti += 1\n\t\tisquare += (2*i - 1)\n\t}\n\tfmt.Fprintln(writer, total)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "acfae51b979fe8c66f91411f3b77540f", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,m int\n fmt.Scan(&n,&m)\n ans := 0\n for a := 0; a <= m; a++ {\n for b := 0; b <= n; b++ {\n if ((a*a+b) == n) && ((a+b*b) == m) { ans++ }\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "9e518f23a59bae7f5412031730d03c9d", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar k, r int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &k, &r)\n\tsum := 0\n\ti := 0\n\tfor ; ; i++ {\n\t\tsum += k\n\t\tif sum%10 == 0 || sum%10 == r {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(i + 1)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "72332af5dd1e3845c62049fbe806f98b", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar k, r int\n\tfmt.Scanf(\"%d %d\", &k, &r)\n\tfor i := 1; i <= 9; i++ {\n\t\tif k*i%10 == 0 || k*i%10 == r {\n\t\t\tfmt.Println(i)\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "ec99ac85ac789cb9ce61bdfd823cf371", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/732/A\n// комментарии к решению\n// Десятичных монет неограниченное количество, поэтому нас интересует\n// строго десятичный остаток стоимости, что приводит к конечному кол-ву\n// решений. Перебираем все на листочке и выписываем двумерный массив решений\nfunc taskSolution(k int, r int) int {\n\tcounts := [][]int{\n\t\t{1, 1, 1, 1, 1, 1, 1, 1, 1}, // k%10 = 0\n\t\t{1, 2, 3, 4, 5, 6, 7, 8, 9}, // k%10 = 1\n\t\t{5, 1, 5, 2, 5, 3, 5, 4, 5}, // k%10 = 2\n\t\t{7, 4, 1, 8, 5, 2, 9, 6, 3}, // k%10 = 3\n\t\t{5, 3, 5, 1, 5, 4, 5, 2, 5}, // k%10 = 4\n\t\t{2, 2, 2, 2, 1, 2, 2, 2, 2}, // k%10 = 5\n\t\t{10, 2, 5, 4, 5, 1, 5, 3, 5}, // k%10 = 6\n\t\t{3, 6, 9, 2, 5, 8, 1, 4, 7}, // k%10 = 7\n\t\t{5, 4, 5, 3, 5, 2, 5, 1, 5}, // k%10 = 8\n\t\t{9, 8, 7, 6, 5, 4, 3, 2, 1}, // k%10 = 9\n\t}\n\n\treturn counts[k%10][r-1]\n}\n\nfunc main() {\n\tvar k, r int\n\tif _, err := fmt.Scan(&k, &r); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(k, r))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "f05540071685a864296649810b3db9cc", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc main() {\n\tvar y, b, r int\n\tfmt.Scanf(\"%v %v %v\", &y, &b, &r)\n\tans_r := min(y + 2, min(b + 1, r))\n\tfmt.Println((ans_r - 1) * 3)\n}\n\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "07abcf87d43bb4e6b7d7e10c6b2308df", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min ( a int, b int ) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc main() {\n\tvar y, b, r int\n\tfmt.Scanf ( \"%d %d %d\\n\", &y, &b, &r )\n\tb--; r -= 2\n\tfmt.Println ( min ( min ( y, b ), r ) * 3 + 3 )\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "4107b5dda5f63e08ca720cda72545dec", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar y, b, r int\n\tfmt.Scan(&y, &b, &r)\n\tif b <= y {\n\t\ty = b - 1\n\t} else {\n\t\tb = y + 1\n\t}\n\tif r <= b {\n\t\tb = r - 1\n\t\ty = b - 1\n\t} else {\n\t\tr = b + 1\n\t}\n\tfmt.Println(y + b + r)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "88f5b1e335cb4d536560ce4256d4f908", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,k,l,c,d,p,nl,np,a int\n\tfmt.Scan(&n,&k,&l,&c,&d,&p,&nl,&np)\n\tk*=l\n\tc*=d\n\tk/=nl\n\tp/=np\n\tif k>p {\n\t\ta=p\n\t} else {a=k}\n\tif a>c {\n\t\ta=c\n\t}\n\tfmt.Println(a/n)\n}\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "dde28a014a8594371827a26f68b9f1fd", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(x,y int64) int64 {\n if x>y {\n return y\n } else {\n return x\n }\n}\n\nfunc main() {\n\tvar n,k,l,c,d,p,nl,np int64\n\tfmt.Scanf(\"%d %d %d %d %d %d %d %d\",&n,&k,&l,&c,&d,&p,&nl,&np)\n\tfmt.Println(min(min(k*l/nl , c*d), p/np )/n)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c4cdf3348ed22e5009b099f09172feee", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc Min(x... int) (r int) {\n r = x[0]\n for i := 1; i < len(x); i++ {\n if r > x[i] { r = x[i] }\n }\n return\n}\n\nfunc main() {\n var n,k,l,c,d,p,nl,np int\n fmt.Scan(&n,&k,&l,&c,&d,&p,&nl,&np)\n fmt.Println(Min((k*l)/nl,(c*d),p/np)/n)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "4126f2cc810dbeec28a0edce38b2b8c7", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc abs(a int) int{\n\tif a < 0{\n\t\treturn -a\n\t} else{\n\t\treturn a\n\t}\n}\n\nfunc min(a, b int) int{\n\tif a < b{\n\t\treturn a\n\t} else{\n\t\treturn b\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tif n%2 >0 {\n\t\tfmt.Println(\"0\")\n\t} else{\n\t\tvar ans int64 = 1\n\t\tfor i :=0;i=l && r>=m {\n\t\tfmt.Println(m-l)\n\t} else if m>=l && rn{\n\t a-=n\n\t}\n\tfmt.Print(a)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "373f8105be3b041e92ad5c8074012e7c", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b, ans int\n\tfmt.Scanf(\"%d%d%d\", &n, &a, &b)\n\tans = (a+b)%n\n\tif ans <= 0 {\n\t\tans += n\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "5e51b5986f06ce3830541100cb89726b", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var n, a, b int\n fmt.Scan(&n, &a, &b)\n fmt.Println(((a + b - 1) % n + n) % n + 1)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "d2907489b73d0983fc9caf9d116f093f", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n/*\n\tTo get the maximum xor sum for n > 1 numbers, basically we just need to\n\tfind a single number which is complement of n in its binary form.\n\n\tFor example if we have 10 (1010), we need to find 101 which is 5 then we\n\tgot the maximum xor sum which is 1111 (15).\n\n\tNotice that this complement number of binary n will always appear since we\n\tare given selection of candy from 1..n. So as long as n > 1, then the maximum\n\txor sum must be always in form of n binary but with all 0 changed to 1.\n\n\tSo for example if we have 10 = 1010, then the maximum xor sum is 1111 = 15. This\n\tproperty yield true for all numbers in input set.\n\n\tFor n = 1, we just need to return n.\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n, k int64\n\tstdio := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdio, \"%d %d\", &n, &k)\n\n\tif k == 1 {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\tbinStr := strings.Replace(strconv.FormatInt(n, 2), \"0\", \"1\", -1)\n\tnum, _ := strconv.ParseInt(binStr, 2, 64)\n\tfmt.Println(num)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "number theory", "bitmasks"], "code_uid": "ba3df8b872b3ee843935ea9e6b1764f0", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m int64\n\tfmt.Scan(&n, &m)\n\n\tif m > 1 {\n\t\tpow := int64(1)\n\t\tfor n >= pow {\n\t\t\tpow <<= 1\n\t\t}\n\t\tfmt.Println(pow - 1)\n\t} else {\n\t\tfmt.Println(n)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "number theory", "bitmasks"], "code_uid": "4eaf1662a7edb1fdc5b5010a3b95cb73", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scan(&n, &k)\n\tif k == 1 {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\tvar max int64 = 1\n\tfor max <= n {\n\t\tmax <<= 1\n\t}\n\tfmt.Println(max - 1)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "number theory", "bitmasks"], "code_uid": "24d14436305d093acfa6b44722f9645a", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(a, b int) int {\n\tfor a != 0 {\n\t\ta, b = b%a, a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar a, b, c, d int\n\tfmt.Scan(&a, &b, &c, &d)\n\tx := a * d\n\ty := b * c\n\tif x > y {\n\t\tx, y = y, x\n\t}\n\tx = y - x\n\tg := gcd(x, y)\n\tfmt.Printf(\"%d/%d\", x/g, y/g)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "902ad97d9c1bdff8a16d28c3cb54019d", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a,b int) int { if b == 0 { return a } else { return gcd(b,a%b) } }\n\nfunc main() {\n var a,b,c,d,p,q int\n fmt.Scan(&a,&b,&c,&d)\n a *= d\n c *= b\n if a > c {\n p = a-c\n q = a\n } else {\n p = c-a\n q = c\n }\n _gcd := gcd(p,q)\n p /= _gcd\n q /= _gcd\n fmt.Printf(\"%d/%d\\n\",p,q)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "4fa2bd63e7db2d2e5b70a3e2bdb58f74", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n)\n\nfunc gcd(x, y int) int {\n\tif x == 0 {\n\t\treturn y\n\t}\n\treturn gcd(y % x, x)\n}\n\nfunc main() {\n\tvar a, b, c, d int\n\t//f, _ := os.Open(\"in.txt\")\n\treader := bufio.NewReader(os.Stdin)\n\tfor true {\n\t\tif _, err := fmt.Fscanf(reader, \"%d %d %d %d\\n\", &a, &b, &c, &d); err != nil {\n\t\t\tbreak\n\t\t}\n\t\tk := gcd(c * b, a * d)\n\t\tk1 := c * b / k\n\t\tk2 := a * d / k\n\t\tif k1 > k2 {\n\t\t\tfmt.Printf(\"%d/%d\\n\", k1 - k2, k1)\n\t\t} else {\n\t\t\tfmt.Printf(\"%d/%d\\n\", k2 - k1, k2)\n\t\t}\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "c975625914297a1befd2d015c33ee669", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc nextWords(scanner *bufio.Scanner) []string {\n\tscanner.Scan()\n\treturn strings.Fields(scanner.Text())\n}\n\nfunc nextNumbers(scanner *bufio.Scanner) []int {\n\tvar numbers = make([]int, 0)\n\tline := nextWords(scanner)\n\tfor i := range line {\n\t\tn, _ := strconv.Atoi(line[i])\n\t\tnumbers = append(numbers, n)\n\t}\n\treturn numbers\n}\n\nfunc nextInt(scanner *bufio.Scanner) int {\n\tnumber, _ := strconv.Atoi(nextLine(scanner))\n\treturn number\n}\n\nfunc sumInputs(numbers []int) int {\n\tvar sum int\n\tfor i := range numbers {\n\t\tsum += numbers[i]\n\t}\n\treturn sum\n}\n\nfunc nextLine(sc *bufio.Scanner) string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc splitToIntegers(str string) []int {\n\tar := strings.Split(str, \"\")\n\tres := make([]int, 0)\n\n\tfor c := range ar {\n\t\tit, _ := strconv.Atoi(ar[c])\n\t\tres = append(res, it)\n\t}\n\n\treturn res\n}\n\nfunc main() {\n\n\tsc := bufio.NewScanner(os.Stdin)\n\n\tt := nextInt(sc)\n\n\tfor i := 0; i < t; i++ {\n\t\tentry := splitToIntegers(nextLine(sc))\n\n\t\tl := len(entry)\n\t\td := entry[0]\n\n\n\t\tresult := (d - 1)*10 + l * (l + 1) / 2\n\n\n\t\tfmt.Println(result)\n\t}\n\n\n}\n\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "943c38cfebb6ed5459b4ceb0ce1fcfc0", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc run(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tsolve := func(Case int) {\n\t\tvar x string\n\t\tFscan(in, &x)\n\t\td := int(x[0]&15)\n\t\tans := 10*(d-1)\n\t\tfor i := range x {\n\t\t\tans+=i+1\n\t\t}\n\t\tFprintln(out, ans)\n\t\treturn\n\t}\n\n\tvar t int\n\tFscan(in, &t)\n\tfor Case := 1; Case <= t; Case++ {\n\t\tsolve(Case)\n\t}\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "559354c71f83d901a790faefff6c832c", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := make([]string, 0)\n\tfor i := 1; i <= 10000; i++ {\n\t\tnum := strconv.Itoa(i)\n\t\tok := true\n\t\tfor j := 1; j < len(num); j++ {\n\t\t\tif num[j] != num[j-1] {\n\t\t\t\tok = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif ok {\n\t\t\ta = append(a, num)\n\t\t}\n\t}\n\tsort.Strings(a)\n\tt := readInt()\n\n\tfor i := 0; i < t; i++ {\n\t\tx := strconv.Itoa(readInt())\n\t\tans := 0\n\t\tfor j := 0; j < len(a); j++ {\n\t\t\tans += len(a[j])\n\t\t\tif a[j] == x {\n\t\t\t\tfmt.Println(ans)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "89827dabd6ccecb48187261fd1d8c9fb", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tfor i := 0; i < 8; i++ {\n\n\t\tvar line string\n\t\tfmt.Scanln(&line)\n\t\t\n\t\tif !(line == \"WBWBWBWB\" || line == \"BWBWBWBW\"){\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings"], "code_uid": "fd7fa9f664dbbccb830020ea3cdc8e2b", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tfor i := 0; i < 8; i++ {\n\n\t\tvar line string\n\t\tfmt.Scanln(&line)\n\n\t\tfirst := line[0]\n\t\tsecond := line[1]\n\t\tfor j := 0; j < 8; j++ {\n\t\t\tif (line[j] == first && j%2 == 1) ||\n\t\t\t\t(line[j] == second && j%2 == 0) {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings"], "code_uid": "d25a1ef602f6d9c5e666d7cbd1b93852", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tn:=0\n\tfor i:=0;i<8;i++ {\n\t\tfmt.Scan(&s)\n\t\tfor j:=1;j 0 && a%5 == 0 {\n writer.WriteString(strconv.Itoa(a/5) + \"\\n\")\n } else {\n writer.WriteString(\"-1\\n\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "58bd60d5a15d6cbd9a63ea5c785a49dd", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, d, e, s int\n\tfmt.Scanf(\"%d %d %d %d %d\\n\", &a, &b, &c, &d, &e)\n\ts = a + b + c + d + e\n\tif s == 0 || s%5 != 0 {\n\t\tfmt.Print(-1)\n\t\treturn\n\t}\n\tfmt.Print(s / 5)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e775ee5ccd1bc1547fed97a77b81ceb6", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 80A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var l, cou, n, m int\n a := make([]int, 60)\n for i := 2; i < 55; i++ {\n for k := 1; k <= i; k++ {\n if i%k == 0 {\n cou++\n }\n\n }\n if cou == 2 {\n a[l] = i\n l++\n cou = 0\n }\n cou = 0\n\n }\n fmt.Scan(&n, &m)\n for i := 0; i < 55; i++ {\n if a[i] == n && a[i+1] == m {\n fmt.Println(\"YES\")\n return\n }\n }\n fmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "a994e8d4b3248a3c2dced1ccfdb8a26f", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nfunc main() {\n\tn, m := read2i()\n\tif isNextPrime(n, m) {\n\t\tfmt.Fprintln(writer, \"YES\")\n\t} else {\n\t\tfmt.Fprintln(writer, \"NO\")\n\t}\n\twriter.Flush()\n}\n\nfunc isNextPrime(n, m int) bool {\n\tfor i := n + 1; i < m; i++ {\n\t\tif isPrime(i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn isPrime(m)\n}\n\nfunc isPrime(n int) bool {\n\tfor x := 2; x*x <= n; x++ {\n\t\tif n%x == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn n > 1\n}\n\nfunc withSameCase(word string) string {\n\tlowerCount := 0\n\tfor _, letter := range word {\n\t\tif unicode.IsLower(letter) {\n\t\t\tlowerCount++\n\t\t}\n\t}\n\tif lowerCount*2 >= len(word) {\n\t\treturn strings.ToLower(word)\n\t}\n\treturn strings.ToUpper(word)\n}\n\nfunc solve(matrix [][]int) []string {\n\tn := 3\n\tstate := make([][]byte, n)\n\tfor i := range state {\n\t\tstate[i] = make([]byte, n)\n\t\tfor j := range matrix[i] {\n\t\t\tstate[i][j] = byte(matrix[i][j])\n\t\t\tif i > 0 {\n\t\t\t\tstate[i][j] += byte(matrix[i-1][j])\n\t\t\t}\n\t\t\tif i+1 < n {\n\t\t\t\tstate[i][j] += byte(matrix[i+1][j])\n\t\t\t}\n\t\t\tif j > 0 {\n\t\t\t\tstate[i][j] += byte(matrix[i][j-1])\n\t\t\t}\n\t\t\tif j+1 < n {\n\t\t\t\tstate[i][j] += byte(matrix[i][j+1])\n\t\t\t}\n\t\t\tstate[i][j] &= 1\n\t\t\tstate[i][j] ^= 1\n\t\t\tstate[i][j] += '0'\n\t\t}\n\t}\n\tres := make([]string, n)\n\tfor i := range res {\n\t\tres[i] = string(state[i])\n\t}\n\treturn res\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc abs64(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar (\n\treader = bufio.NewReaderSize(os.Stdin, 1<<13)\n\twriter = bufio.NewWriterSize(os.Stdout, 1<<13)\n)\n\nfunc readi() int {\n\treturn int(readi64())\n}\n\nfunc read2i() (int, int) {\n\treturn readi(), readi()\n}\n\nfunc read3i() (int, int, int) {\n\treturn readi(), readi(), readi()\n}\n\nfunc read4i() (int, int, int, int) {\n\treturn readi(), readi(), readi(), readi()\n}\n\nfunc readis(n int) []int {\n\tres := make([]int, n)\n\tfor i := range res {\n\t\tres[i] = readi()\n\t}\n\treturn res\n}\n\nfunc readi64() int64 {\n\tb, err := reader.ReadByte()\n\tfor !isValid(b, err) {\n\t\tb, err = reader.ReadByte()\n\t}\n\tsign, res := int64(1), int64(0)\n\tif b == '-' {\n\t\tsign *= -1\n\t\tb, err = reader.ReadByte()\n\t}\n\tfor isValid(b, err) {\n\t\tres = res*10 + int64(b-'0')\n\t\tb, err = reader.ReadByte()\n\t}\n\treturn res * sign\n}\n\nfunc readi64s(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := range res {\n\t\tres[i] = readi64()\n\t}\n\treturn res\n}\n\nfunc readline() string {\n\tres := new(bytes.Buffer)\n\tfor {\n\t\tline, isPrefix, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tres.Write(line)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn res.String()\n}\n\nfunc isValid(b byte, err error) bool {\n\treturn err == nil && (('0' <= b && b <= '9') || b == '-')\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "e7215502054824669a4b74fb1d7443a1", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\n\tis_prime := make([]int, 51, 51)\n\tfor i := 0; i < 51; i++ {\n\t\tis_prime[i] = 1\n\t}\n\tis_prime[1] = 0\n\tfor i := 2; i <= 8; i++ {\n\t\tif is_prime[i] == 1 {\n\t\t\tfor x := i + i; x < 51; x += i {\n\t\t\t\tis_prime[x] = 0\n\t\t\t}\n\t\t}\n\t}\n\n\tans := false\n\tfor i := n + 1; i < 51; i++ {\n\t\tif is_prime[i] == 1 {\n\t\t\tif i == m {\n\t\t\t\tans = true\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ans == true {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "d9baa096c1b812514c5a8666d41673de", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar m, s int\n\tfmt.Scan(&m, &s)\n\tif 9*m < s || (s < 1 && m > 1) {\n\t\tfmt.Print(\"-1 -1\")\n\t\treturn\n\t}\n\tmin := getMin(s, m)\n\tmax := getMax(s, m)\n\tfmt.Print(min, \" \", max)\n}\n\nfunc getMax(s, m int) string {\n\tvar max string\n\tfor s > 9 {\n\t\tmax = max + \"9\"\n\t\ts -= 9\n\t\tm--\n\t}\n\tmax = max + strconv.Itoa(s)\n\tm--\n\tfor i := 0; i < m; i++ {\n\t\tmax = max + \"0\"\n\t}\n\treturn max\n}\n\nfunc getMin(s, m int) string {\n\tvar min string\n\tfor s > 9 {\n\t\tmin = \"9\" + min\n\t\ts -= 9\n\t\tm--\n\t}\n\tif m == 1 {\n\t\tmin = strconv.Itoa(s) + min\n\t} else {\n\t\tif s > 1 {\n\t\t\tmin = strconv.Itoa(s-1) + min\n\t\t\tm--\n\t\t}\n\t\tfor i := 0; i < m-1; i++ {\n\t\t\tmin = \"0\" + min\n\t\t}\n\t\tmin = \"1\" + min\n\t}\n\treturn min\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp", "implementation"], "code_uid": "688b0a44b87b4d83d3ec75a17b2898f5", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/489/C\n// комментарии к решению\n// Максимальное число всегда будет выглядеть как:\n// 99..99Х00..00 , где Х - цифра\n// а минимальное число будет выглядеть как:\n// 100...0Х99..99 или Х99..99 , где Х - цифра\nfunc taskSolution(m int, s int) string {\n\tif s > 9*m {\n\t\treturn \"-1 -1\"\n\t} else if s == 0 && m != 1 {\n\t\treturn \"-1 -1\"\n\t}\n\n\tans := make([]byte, 2*m+1)\n\tlast := 0\n\tfor i := 0; i < m; i += 1 {\n\t\tswitch {\n\t\tcase s == 0:\n\t\t\tans[m+i+1] = '0'\n\t\t\tans[m-i-1] = '0'\n\t\tcase s > 9:\n\t\t\tans[m+i+1] = '9'\n\t\t\tans[m-i-1] = '9'\n\t\t\ts -= 9\n\t\tdefault:\n\t\t\tlast = m - i - 1\n\t\t\tans[m+i+1] = byte(s) + '0'\n\t\t\tans[m-i-1] = byte(s) + '0'\n\t\t\ts = 0\n\t\t}\n\t}\n\tif last > 0 {\n\t\tans[0] = '1'\n\t\tans[last] -= byte(1)\n\t}\n\t// put space between two numbers\n\tans[m] = ' '\n\treturn string(ans)\n}\n\nfunc main() {\n\tvar m, s int\n\tif _, err := fmt.Scan(&m, &s); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(m, s))\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp", "implementation"], "code_uid": "4cbba8bed666d0513cad625ce8fc7a4a", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// http://codeforces.com/contest/489/problem/C\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nconst (\n\tMOD = 1e9 + 7\n)\n\ntype (\n\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc main () {\n\tvar (\n\t\tn, s int\n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscanln(input, &n, &s)\n\n\tif n * 9 < s {\n\t\tfmt.Println(-1, -1)\n\t\treturn\n\t}\n\n\tif s == 0 {\n\t\tif n == 1 {\n\t\t\tfmt.Println(0, 0)\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(-1, -1)\n\t\treturn\n\t}\n\n\n\tans := make([]int, n + 1)\n\n\tsum := s\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := 0; j < 10; j++ {\n\t\t\tif i == 1 && j == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif sum - j >= 0 && i < n {\n\t\t\t\tif sum - j <= (n - i)*9 {\n\t\t\t\t\tans[i] = j\n\t\t\t\t\tsum -= j\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tans[i] = sum\n\t\t\t}\n\n\t\t}\n\t}\n\n\tfor i := 1; i <= n; i++ {\n\t\tfmt.Print(ans[i])\n\t}\n\n\tfmt.Print(\" \")\n\n\tsum = s\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := 9; j >= 0; j-- {\n\t\t\tif i == 1 && j == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif i < n {\n\t\t\t\tif sum - j >= 0 && sum - j <= (n - i)*9 {\n\t\t\t\t\tans[i] = j\n\t\t\t\t\tsum -= j\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tans[i] = sum\n\t\t\t}\n\n\t\t}\n\t}\n\n\tfor i := 1; i <= n; i++ {\n\t\tfmt.Print(ans[i])\n\t}\n}", "lang_cluster": "Go", "tags": ["greedy", "dp", "implementation"], "code_uid": "b72c0d61108d8577c1bc0879b893dca5", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var s string\n jumpval :=0 \n current := 1\n vowels := \"AEIOUY\"\n fmt.Scanf(\"%s\", &s)\n for i:=0; i < len(s); i++ {\n for j:=0; j < len(vowels); j++ {\n if vowels[j] == s[i]{\n if jumpval < current {\n jumpval = current\n }\n current = 0\n break\n }\n } \n current++\n }\n if current > jumpval {\n jumpval = current\n }\n fmt.Println(jumpval)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fc3b436ddef276f225fc0994c9e8d760", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tS := sc.NextLine()\n\told := -1\n\tmx := 0\n\tfor i, v := range S {\n\t\tswitch v {\n\t\tcase 'A', 'E', 'I', 'O', 'U', 'Y':{\n\t\t\tmx = max(mx, i - old)\n\t\t\told = i\n\t\t}\n\t\t}\n\t}\n\tmx = max(mx, len(S) - old)\n\n\tfmt.Println(mx)\n}\n\nfunc max(a int, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r:rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "88378dfac806ca7241e2014ecf7119ac", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n min, cur := 0, 0\n for _, c := range s {\n if c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'Y' {\n if min < cur+1 {\n min = cur+1\n }\n cur = 0\n } else {\n cur++\n }\n }\n if min < cur+1 {\n min = cur+1\n }\n fmt.Print(min)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4fbb72fb4d1cf3220bdca25917aaa637", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nfunc main() {\n\tn := 0\n\tfmt.Scanf(\"%d\\n\", &n)\n\tcrush := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &crush[i])\n\t\tcrush[i]--\n\t}\n\n\tsizes := make([]int, 0)\n\tvisited := make([]bool, n)\n\tfor first := 0; first < n; first++ {\n\t\tif !visited[first] {\n\t\t\tvisited[first] = true\n\t\t\tsize := 1\n\t\t\tx := crush[first]\n\t\t\tfor !visited[x] {\n\t\t\t\tvisited[x] = true\n\t\t\t\tsize++\n\t\t\t\tx = crush[x]\n\t\t\t}\n\t\t\tif x != first {\n\t\t\t\tfmt.Println(-1)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsizes = append(sizes, size)\n\t\t}\n\t}\n\n\tans := big.NewInt(1)\n\tfor _, size := range sizes {\n\t\tvar k *big.Int\n\t\tif size%2 == 0 {\n\t\t\tk = big.NewInt(int64(size / 2))\n\t\t} else {\n\t\t\tk = big.NewInt(int64(size))\n\t\t}\n\t\tg := new(big.Int).GCD(nil, nil, ans, k)\n\t\tans.Div(ans, g)\n\t\tans.Mul(ans, k)\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "math"], "code_uid": "383eab883655a1e7d1909289300b8b88", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReaderSize(os.Stdin, 1<<13)\n\twriter := bufio.NewWriterSize(os.Stdout, 1<<13)\n\tn := ReadInt(reader)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = ReadInt(reader) - 1\n\t}\n\tfmt.Fprintln(writer, solve(a))\n\twriter.Flush()\n}\n\nfunc solve(a []int) int64 {\n\tn := len(a)\n\tres := int64(0)\n\treached := make([]bool, n)\n\tfor i := 0; i < n; i++ {\n\t\tif !reached[i] {\n\t\t\tk := i\n\t\t\tcount := int64(0)\n\t\t\tfor !reached[k] {\n\t\t\t\treached[k] = true\n\t\t\t\tk = a[k]\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tif k != i {\n\t\t\t\treturn -1\n\t\t\t}\n\t\t\tif count == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif count%2 == 0 {\n\t\t\t\tcount /= 2\n\t\t\t}\n\t\t\tif res == 0 {\n\t\t\t\tres = count\n\t\t\t} else {\n\t\t\t\tres = lcm(res, count)\n\t\t\t}\n\t\t}\n\t}\n\treturn res\n}\n\nfunc gcd(a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\n\nfunc lcm(a, b int64) int64 {\n\tg := gcd(a, b)\n\treturn (a / g) * b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc ReadInt(reader *bufio.Reader) int {\n\treturn int(ReadInt64(reader))\n}\n\nfunc ReadInt64(reader *bufio.Reader) int64 {\n\tb, err := reader.ReadByte()\n\tfor !isValid(b, err) {\n\t\tb, err = reader.ReadByte()\n\t}\n\tsign := int64(1)\n\tif b == '-' {\n\t\tsign *= -1\n\t\tb, err = reader.ReadByte()\n\t}\n\tres := int64(0)\n\tfor isValid(b, err) {\n\t\tres = res*10 + int64(b-'0')\n\t\tb, err = reader.ReadByte()\n\t}\n\treturn res * sign\n}\n\nfunc isValid(b byte, err error) bool {\n\treturn err == nil && (('0' <= b && b <= '9') || b == '-')\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "math"], "code_uid": "8b2ecf2fc031e62274b6d047f7fc2d4b", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n)\n\nfunc main() {\n\tb, _ := ioutil.ReadAll(os.Stdin)\n\tif len(b) == 0 {\n\t\ttest()\n\t} else {\n\t\tsolve(bytes.NewReader(b), os.Stdout)\n\t}\n}\n\nfunc solve(r io.Reader, w io.Writer) {\n\tvar n int\n\tfmt.Fscanln(r, &n)\n\n\tcs := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(r, &cs[i])\n\t}\n\n\tfmt.Fprintln(w, f(cs))\n}\n\nfunc f(cs []int) int {\n\tgs := graphs(cs)\n\n\tif len(gs) == 0 {\n\t\treturn -1\n\t}\n\n\tfor i, g := range gs {\n\t\tif g%2 == 0 {\n\t\t\tgs[i] = g / 2\n\t\t}\n\t}\n\n\tif len(gs) == 1 {\n\t\treturn gs[0]\n\t}\n\n\treturn lcmm(gs...)\n}\n\nfunc graphs(cs []int) []int {\n\tseen := make(map[int]bool, len(cs))\n\n\tvar ls []int\n\n\tfor j, c := range cs {\n\t\ti := j + 1\n\n\t\tif seen[i] {\n\t\t\tcontinue\n\t\t}\n\n\t\tif cs[i-1] == i {\n\t\t\tseen[i] = true\n\t\t\tseen[cs[i-1]] = true\n\t\t\tls = append(ls, 1)\n\t\t\tcontinue\n\t\t}\n\n\t\tl := 2\n\n\t\tfor ; ; l++ {\n\t\t\tseen[c] = true\n\t\t\tnext := cs[c-1]\n\t\t\tif next == i {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif seen[next] {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tc = next\n\t\t}\n\t\tseen[i] = true\n\t\tls = append(ls, l)\n\t}\n\treturn ls\n}\n\nfunc gcd(a, b int) int {\n\tfor b > 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int) int {\n\treturn a * b / gcd(a, b)\n}\n\nfunc lcmm(xs ...int) int {\n\tr := 1\n\tfor _, x := range xs {\n\t\tr = lcm(r, x)\n\t}\n\treturn r\n}\n\nfunc test() {\n\ttests := []struct {\n\t\tin string\n\t\twant string\n\t}{\n\t\t{\n\t\t\tin: `\n4\n2 3 1 4\n`,\n\t\t\twant: `3`,\n\t\t},\n\t\t{\n\t\t\tin: `\n4\n4 4 4 4\n`,\n\t\t\twant: `-1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n4\n2 1 4 3\n`,\n\t\t\twant: `1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n5\n2 3 1 5 4\n`,\n\t\t\twant: `3`,\n\t\t},\n\t\t{\n\t\t\tin: `\n7\n2 3 1 5 6 7 4\n`,\n\t\t\twant: `6`,\n\t\t},\n\t\t{\n\t\t\tin: `\n5\n2 4 3 1 2\n`,\n\t\t\twant: `-1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n10\n8 10 4 3 2 1 9 6 5 7\n`,\n\t\t\twant: `15`,\n\t\t},\n\t}\n\tfor i, tt := range tests {\n\t\tfmt.Printf(\"=== TEST %d\\n\", i)\n\t\tbuf := new(bytes.Buffer)\n\t\tsolve(strings.NewReader(chomp(tt.in)), buf)\n\t\tif got, want := chomp(buf.String()), chomp(tt.want); got != want {\n\t\t\tfmt.Printf(\"%d: got %v, want %v\\n\", i, got, want)\n\t\t}\n\t}\n}\n\nfunc chomp(s string) string {\n\treturn strings.Trim(s, \"\\n\")\n}\n\nfunc assert(b bool) {\n\tif !b {\n\t\t_, file, line, ok := runtime.Caller(1)\n\t\tif ok {\n\t\t\tf, _ := os.Open(file)\n\t\t\tdefer f.Close()\n\t\t\ts := bufio.NewScanner(f)\n\t\t\tlnum := 0\n\t\t\tfor s.Scan() {\n\t\t\t\tlnum++\n\t\t\t\tif lnum == line {\n\t\t\t\t\twd, _ := os.Getwd()\n\t\t\t\t\tfname, _ := filepath.Rel(wd, file)\n\t\t\t\t\tfmt.Printf(\"assertion fails: %s:%d: %v\\n\", fname, line, s.Text())\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc pow(a, b int) int {\n\tr := 1\n\tfor i := 0; i < b; i++ {\n\t\tr *= a\n\t}\n\treturn r\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "math"], "code_uid": "77272a49dad056cf37f925e839030e55", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc scanInput() (int64, int64, int64) {\n\tvar x, y, m int64\n\tfmt.Scanf(\"%d %d %d\\n\", &x, &y, &m)\n\treturn x, y, m\n}\n\nfunc fibo(x, y, m int64) int64 {\n\tvar n int64\n\tif x >= m || y >= m {\n\t\treturn int64(0)\n\t}\n\tif n = 0; x < m && y < m && (x+y) <= y && (x+y) <= x {\n\t\tn = -1\n\t\treturn n\n\t} else if math.Signbit(float64(x)) != math.Signbit(float64(y)) {\n\t\tif x > y {\n\t\t\tx, y = y, x\n\t\t}\n\t\tn = (-x) / y\n\t\tx = -((-x) % y)\n\t}\n\n\tfor x < m && y < m {\n\t\tt := x + y\n\t\tif x < y {\n\t\t\tx = t\n\t\t} else {\n\t\t\ty = t\n\t\t}\n\t\tn++\n\t}\n\treturn n\n}\n\nfunc main() {\n\tx, y, m := scanInput()\n\tn := fibo(x, y, m)\n\tfmt.Printf(\"%d\\n\", n)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "d90007ae94fcbe29b064fb076ac28b02", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 317A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, d, e int64\n\te = 0\n\tfmt.Scan(&a, &b, &d)\n\tif a < b {\n\t\tc = a\n\t\ta = b\n\t\tb = c\n\t}\n\tif a >= d {\n\t\tfmt.Print(\"0\")\n\t\treturn\n\t}\n\tif a <= 0 {\n\t\tfmt.Print(\"-1\")\n\t\treturn\n\t}\n\tif b < 0 {\n\t\te = 1 - b/a\n\t\tb += a * e\n\t}\n\tfor a < d {\n\t\tc = a\n\t\ta += b\n\t\tb = c\n\t\te++\n\t}\n\tfmt.Println(e)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "bcfa615e52809c4858fe96557acebb65", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 317A-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var x, y, m, RESULT, tmp int64\n fmt.Scan(&x, &y, &m)\n if x >= m || y >= m {\n fmt.Println(\"0\")\n } else {\n if x <= 0 && y <= 0 {\n fmt.Println(\"-1\")\n } else {\n if x < y {\n tmp = x\n x = y\n y = tmp\n }\n\n if y < 0 {\n n := (-y)/x + 1\n RESULT += n\n y += x * n\n }\n for x < m {\n y += x\n tmp = x\n x = y\n y = tmp\n RESULT += 1\n }\n fmt.Println(RESULT)\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "b801c46963d1ad8090c9229954a97b2e", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"io/ioutil\"\r\n\t\"os\"\r\n\t\"strings\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc run(_r io.Reader, _w io.Writer) {\r\n\tin := bufio.NewReader(_r)\r\n\tout := bufio.NewWriter(_w)\r\n\tdefer out.Flush()\r\n\r\n\tsolve := func(Case int) (_b bool) {\r\n\t\tvar n, m, k int\r\n\t\tFscan(in, &n, &m, &k)\r\n\t\t mx := 0\r\n\t\tif m&1 == 0 {\r\n\t\t\tmx = n * m / 2\r\n\t\t\tbase := 0\r\n\t\t\tif n&1 == 0 {\r\n\r\n\t\t\t} else {\r\n\t\t\t\tbase = m / 2\r\n\t\t\t}\r\n\r\n\t\t\tif k < base {\r\n\t\t\t\treturn false\r\n\t\t\t}\r\n\t\t\tif (k-base)&1 > 0 {\r\n\t\t\t\treturn false\r\n\t\t\t}\r\n\t\t\treturn true\r\n\t\t} else { // m&1==1 && n&1==0\r\n\t\t\tmx = n*m/2 - n/2\r\n\t\t\tif k > mx {\r\n\t\t\t\treturn false\r\n\t\t\t}\r\n\t\t\tif k&1 > 0 {\r\n\t\t\t\treturn false\r\n\t\t\t}\r\n\r\n\t\t\treturn true\r\n\t\t}\r\n\t}\r\n\tvar T int\r\n\tFscan(in, &T)\r\n\tfor Case := 1; Case <= T; Case++ {\r\n\t\tif solve(Case) {\r\n\t\t\tFprintln(out, \"YES\")\r\n\t\t} else {\r\n\t\t\tFprintln(out, \"NO\")\r\n\t\t}\r\n\t}\r\n\t_leftData, _ := ioutil.ReadAll(in)\r\n\tif _s := strings.TrimSpace(string(_leftData)); _s != \"\" {\r\n\t\tpanic(\"有未读入的数据:\\n\" + _s)\r\n\t}\r\n}\r\n\r\nfunc main() { run(os.Stdin, os.Stdout) }", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "aedf3448062bd902d391bfe8af8e9404", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nvar (\r\n\twriter = bufio.NewWriter(os.Stdout)\r\n\tscanner = bufio.NewScanner(os.Stdin)\r\n)\r\n\r\nfunc init() {\r\n\tscanner.Split(bufio.ScanWords)\r\n\tscanner.Buffer(make([]byte, 4096), 1e9)\r\n}\r\n\r\nfunc printf(f string, a ...interface{}) {\r\n\tfmt.Fprintf(writer, f, a...)\r\n}\r\n\r\nfunc _int() int {\r\n\ts := _string()\r\n\ti := 0\r\n\tif s[0] == '-' {\r\n\t\tfor _, r := range s[1:] {\r\n\t\t\ti *= 10\r\n\t\t\ti -= int(r - '0')\r\n\t\t}\r\n\t\treturn i\r\n\t}\r\n\tfor _, r := range s {\r\n\t\ti *= 10\r\n\t\ti += int(r - '0')\r\n\t}\r\n\treturn i\r\n}\r\n\r\nfunc _int64() int64 {\r\n\ts := _string()\r\n\ti := int64(0)\r\n\tif s[0] == '-' {\r\n\t\tfor _, r := range s[1:] {\r\n\t\t\ti *= 10\r\n\t\t\ti -= int64(r - '0')\r\n\t\t}\r\n\t\treturn i\r\n\t}\r\n\tfor _, r := range s {\r\n\t\ti *= 10\r\n\t\ti += int64(r - '0')\r\n\t}\r\n\treturn i\r\n}\r\n\r\nfunc _string() string {\r\n\tif !scanner.Scan() {\r\n\t\tpanic(scanner.Err())\r\n\t}\r\n\treturn scanner.Text()\r\n}\r\n\r\nfunc main() {\r\n\tdefer writer.Flush()\r\n\tfor t := _int(); t > 0; t-- {\r\n\t\tn := _int()\r\n\t\tm := _int()\r\n\t\tk := _int()\r\n\t\tans := sol(n, m, k)\r\n\t\tif ans {\r\n\t\t\tprintf(\"YES\\n\")\r\n\t\t} else {\r\n\t\t\tprintf(\"NO\\n\")\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunc sol(n, m, k int) bool {\r\n\tif m&1 == 0 && n&1 == 0 {\r\n\t\treturn k&1 == 0\r\n\t}\r\n\tif m&1 == 1 && n&1 == 0 {\r\n\t\tif k*2 > (m-1)*n { // cannot fit horizontally\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn k&1 == 0\r\n\t}\r\n\tif n&1 == 1 && m&1 == 0 {\r\n\t\tif k*2 >= m {\r\n\t\t\treturn sol(n-1, m, k-m/2)\r\n\t\t}\r\n\t\treturn false\r\n\t}\r\n\t// shouldn't reach here\r\n\treturn false\r\n}\r\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "31e323cb3259b74d4052ebfa2e44081b", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\nimport (\r\n\t\"bufio\"\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"io/ioutil\"\r\n\t\"os\"\r\n\t\"strings\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc run(_r io.Reader, _w io.Writer) {\r\n\tin := bufio.NewReader(_r)\r\n\tout := bufio.NewWriter(_w)\r\n\tdefer out.Flush()\r\n\r\n\tsolve := func(Case int) (_b bool) {\r\n\t\tvar n, m, k int\r\n\t\tFscan(in, &n, &m, &k)\r\n\t\t mx := 0\r\n\t\tif m&1 == 0 {\r\n\t\t\tmx = n * m / 2\r\n\t\t\tbase := 0\r\n\t\t\tif n&1 == 0 {\r\n\r\n\t\t\t} else {\r\n\t\t\t\tbase = m / 2\r\n\t\t\t}\r\n\r\n\t\t\tif k < base {\r\n\t\t\t\treturn false\r\n\t\t\t}\r\n\t\t\tif (k-base)&1 > 0 {\r\n\t\t\t\treturn false\r\n\t\t\t}\r\n\t\t\treturn true\r\n\t\t} else { // m&1==1 && n&1==0\r\n\t\t\tmx = n*m/2 - n/2\r\n\t\t\tif k > mx {\r\n\t\t\t\treturn false\r\n\t\t\t}\r\n\t\t\tif k&1 > 0 {\r\n\t\t\t\treturn false\r\n\t\t\t}\r\n\r\n\t\t\treturn true\r\n\t\t}\r\n\t}\r\n\tvar T int\r\n\tFscan(in, &T)\r\n\tfor Case := 1; Case <= T; Case++ {\r\n\t\tif solve(Case) {\r\n\t\t\tFprintln(out, \"YES\")\r\n\t\t} else {\r\n\t\t\tFprintln(out, \"NO\")\r\n\t\t}\r\n\t}\r\n\t_leftData, _ := ioutil.ReadAll(in)\r\n\tif _s := strings.TrimSpace(string(_leftData)); _s != \"\" {\r\n\t\tpanic(\"有未读入的数据:\\n\" + _s)\r\n\t}\r\n}\r\n\r\nfunc main() { run(os.Stdin, os.Stdout) }", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "06af8de7fc41cac8e391fdf818163ae9", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tm := readInt()\n\tk := readInt64()\n\tx := readInt()\n\ty := readInt()\n\n\tv := make([][]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tv[i] = make([]int64, m)\n\t}\n\tif n == 1 {\n\t\tsize := m\n\t\tmul := k / int64(size)\n\t\tk = k % int64(size)\n\t\tif mul > 0 {\n\t\t\tfor j := 0; j < m; j++ {\n\t\t\t\tv[0][j] = mul\n\t\t\t}\n\t\t}\n\t} else {\n\t\tsize := (n + n - 2) * m\n\t\tmul := k / int64(size)\n\t\tk = k % int64(size)\n\t\tif mul > 0 {\n\t\t\tfor i := 1; i < n-1; i++ {\n\t\t\t\tfor j := 0; j < m; j++ {\n\t\t\t\t\tv[i][j] = 2 * mul\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor j := 0; j < m; j++ {\n\t\t\t\tv[0][j] = mul\n\t\t\t}\n\t\t\tfor j := 0; j < m; j++ {\n\t\t\t\tv[n-1][j] = mul\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < n && k > 0; i++ {\n\t\tfor j := 0; j < m && k > 0; j++ {\n\t\t\tv[i][j]++\n\t\t\tk--\n\t\t}\n\t}\n\tfor i := n - 2; i >= 0 && k > 0; i-- {\n\t\tfor j := 0; j < m && k > 0; j++ {\n\t\t\tv[i][j]++\n\t\t\tk--\n\t\t}\n\t}\n\t// for i := 0; i < n; i++ {\n\t// \tfmt.Printf(\"v[i] = %+v\\n\", v[i])\n\t// }\n\tminValue := int64(math.MaxInt64)\n\tmaxValue := int64(math.MinInt64)\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < m; j++ {\n\t\t\tvalue := v[i][j]\n\t\t\tif value < minValue {\n\t\t\t\tminValue = value\n\t\t\t}\n\t\t\tif value > maxValue {\n\t\t\t\tmaxValue = value\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d %d %d\", maxValue, minValue, v[x-1][y-1])\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "binary search", "implementation"], "code_uid": "18b8eedf914ee1df7bfb5c0582e375c7", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\t\n\tN := io.NextLong()\n\tM := io.NextLong()\n\tK := io.NextLong()\n\tX := io.NextLong()\n\tY := io.NextLong()\n\n\tmax := Max(GetAt(N, M, 1, 1, K), GetAt(N, M, 2, 1, K), GetAt(N, M, N - 1, 1, K))\n\tmin := GetAt(N, M, N, M, K)\n\tsergey := GetAt(N, M, X, Y, K)\n\t\n\tio.Printf(\"%d %d %d\\n\", max, min, sergey)\n\t\n\tio.FlushOutput()\n}\n\nfunc GetAt(N, M, R, C, K int64) int64 {\n\tR--\n\tC--\n\n\tif R < 0 || R >= N || C < 0 || C >= M {\n\t\treturn 0\n\t}\n\n\tvar cnt int64\n\tif N == 1 {\n\t\tcnt = K / M\n\t\tif C < K % M {\n\t\t\tcnt++\n\t\t}\n\t} else {\n\t\tT := M * (N + N - 2)\n\t\tP := K / T\n\t\tif R == 0 || R == N - 1 {\n\t\t\tcnt = P\n\t\t} else {\n\t\t\tcnt = P * 2\n\t\t}\n\t\trem := K % T\n\t\t// fmt.Printf(\"(%d, %d), T = %d, P = %d, cnt = %d, rem = %d\\n\", R, C, T, P, cnt, rem)\n\t\t// fmt.Printf(\" idx1 = %d, idx2 = %d\\n\", (M * R) + C, M * ((2 * N) - R - 2) + C)\n\t\tif R < N - 1 && (M * R) + C < rem {\n\t\t\tcnt++\n\t\t}\n\t\tif M * ((2 * N) - R - 2) + C < rem {\n\t\t\tcnt++\n\t\t}\n\t}\n\t// fmt.Printf(\" cnt = %d\\n\", cnt)\n\treturn cnt\n}\n\nfunc Min(args ...int64) int64 {\n\tmin := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif (args[i] < min) {\n\t\t\tmin = args[i]\n\t\t}\n\t}\n\treturn min\n}\n\nfunc Max(args ...int64) int64 {\n\tmax := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif (args[i] > max) {\n\t\t\tmax = args[i]\n\t\t}\n\t}\n\treturn max\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "binary search", "implementation"], "code_uid": "d718b8b6bb7c0becbc62cc66e86dd0b2", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tdo()\n}\n\nfunc do() {\n\ts := bufio.NewScanner(os.Stdin)\n\ts.Split(bufio.ScanWords)\n\ts.Scan()\n\tn, _ := strconv.Atoi(s.Text())\n\ts.Scan()\n\tm, _ := strconv.Atoi(s.Text())\n\ts.Scan()\n\tk, _ := strconv.ParseInt(s.Text(), 10, 64)\n\ts.Scan()\n\tx, _ := strconv.Atoi(s.Text())\n\ts.Scan()\n\ty, _ := strconv.Atoi(s.Text())\n\n\tmin := minAsk(n, m, k)\n\tmax := maxAsk(n, m, k)\n\tcnt := count(n, m, x, y, k)\n\tfmt.Printf(\"%v %v %v\\n\", max, min, cnt)\n}\n\nfunc minAsk(n, m int, k int64) int64 {\n\tif n <= 2 {\n\t\treturn k / int64(n*m)\n\t}\n\n\tt := int64(2*n*m - 2*m)\n\tth := int64(n * m)\n\td := k / t\n\tr := k % t\n\n\tif r < th {\n\t\treturn d\n\t}\n\treturn d + 1\n}\n\nfunc maxAsk(n, m int, k int64) int64 {\n\tif n <= 2 {\n\t\td := k / int64(n*m)\n\t\tr := k % int64(n*m)\n\t\tif r > 0 {\n\t\t\treturn d + 1\n\t\t}\n\t\treturn d\n\t}\n\n\tt := int64(2*n*m - 2*m)\n\tth := int64(n * m)\n\td := k / t\n\tr := k % t\n\n\tif d > 0 && r <= int64(m) {\n\t\treturn d * 2\n\t} else if r <= th {\n\t\treturn d*2 + 1\n\t}\n\n\treturn d*2 + 2\n}\n\nfunc count(n, m, x, y int, k int64) int64 {\n\tif n <= 2 {\n\t\td := k / int64(n*m)\n\t\tr := k % int64(n*m)\n\t\tif r >= int64((x-1)*m+y) {\n\t\t\treturn d + 1\n\t\t}\n\t\treturn d\n\t}\n\n\tt := int64(2*n*m - 2*m)\n\tth := int64(n * m)\n\td := k / t\n\tr := k % t\n\n\tif x == 1 {\n\t\tif r >= int64(y) {\n\t\t\treturn d + 1\n\t\t}\n\t\treturn d\n\t} else if x == n {\n\t\tif r-int64((n-1)*m) >= int64(y) {\n\t\t\treturn d + 1\n\t\t}\n\t\treturn d\n\t} else {\n\t\tif r < int64((x-1)*m+y) {\n\t\t\treturn d * 2\n\t\t} else if r >= int64((x-1)*m+y) && r < th+int64((n-x-1)*m+y) {\n\t\t\treturn d*2 + 1\n\t\t}\n\t}\n\n\treturn d*2 + 2\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "binary search", "implementation"], "code_uid": "aaf834dd88bb1983b1f0b93e8372b7b4", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst N = 11\n\ntype Deck struct {\n\tcards []int\n}\n\nfunc (d *Deck) addCard(c int) {\n\td.cards = append(d.cards, c)\n}\n\nfunc (d *Deck) isLosing() bool {\n\treturn len(d.cards) == 0\n}\n\nfunc (d *Deck) hash() int64 {\n\tvar h int64\n\tfor _, c := range d.cards {\n\t\th = N*h + int64(c+1)\n\t}\n\treturn h\n}\n\nfunc oneRound(d1, d2 *Deck) {\n\tvar c1, c2 int\n\tc1, d1.cards = d1.cards[0], d1.cards[1:]\n\tc2, d2.cards = d2.cards[0], d2.cards[1:]\n\td := d1\n\tif c1 < c2 {\n\t\tc1, c2 = c2, c1\n\t\td = d2\n\t}\n\td.addCard(c2)\n\td.addCard(c1)\n}\n\nfunc makeKey(d1, d2 Deck) string {\n\treturn strconv.FormatInt(d1.hash(), N) + \"#\" + strconv.FormatInt(d2.hash(), N)\n}\n\nfunc main() {\n\tnextInt()\n\tvar d1, d2 Deck\n\tk1 := nextInt()\n\tfor i := 0; i < k1; i++ {\n\t\td1.addCard(nextInt() - 1)\n\t}\n\tk2 := nextInt()\n\tfor i := 0; i < k2; i++ {\n\t\td2.addCard(nextInt() - 1)\n\t}\n\twas := make(map[string]struct{})\n\tfor rounds := 0; ; rounds++ {\n\t\tif d1.isLosing() {\n\t\t\tfmt.Println(rounds, 2)\n\t\t\treturn\n\t\t}\n\t\tif d2.isLosing() {\n\t\t\tfmt.Println(rounds, 1)\n\t\t\treturn\n\t\t}\n\t\tkey := makeKey(d1, d2)\n\t\tif _, ok := was[key]; ok {\n\t\t\tbreak\n\t\t}\n\t\twas[key] = struct{}{}\n\t\toneRound(&d1, &d2)\n\t}\n\tfmt.Println(-1)\n}\n\nfunc init() {\n\t// maybe defer writer.Flush() in main\n\n\tlineScanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\n\t/*\n\t\tinputFile, err := os.Open(\"a.in\")\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\toutputFile, err := os.Create(\"a.out\")\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tlineScanner = bufio.NewScanner(inputFile)\n\t\twriter = bufio.NewWriter(outputFile)\n\t*/\n\n\twordScanner = bufio.NewScanner(strings.NewReader(\"\"))\n\twordScanner.Split(bufio.ScanWords)\n}\n\nvar lineScanner *bufio.Scanner\nvar wordScanner *bufio.Scanner\n\nvar writer *bufio.Writer\n\nfunc nextLine() (string, error) {\n\tif !lineScanner.Scan() {\n\t\tif err := lineScanner.Err(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\treturn \"\", errors.New(\"nextLine: EOF reached\")\n\t}\n\treturn lineScanner.Text(), nil\n}\n\nfunc nextWord() string {\n\tfor !wordScanner.Scan() {\n\t\tif err := wordScanner.Err(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tline, err := nextLine()\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\twordScanner = bufio.NewScanner(strings.NewReader(line))\n\t\twordScanner.Split(bufio.ScanWords)\n\t}\n\treturn wordScanner.Text()\n}\n\nfunc nextInt() int {\n\tres, err := strconv.Atoi(nextWord())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc nextInt64() int64 {\n\tres, err := strconv.ParseInt(nextWord(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc nextFloat64() float64 {\n\tres, err := strconv.ParseFloat(nextWord(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "281576280d4e35bdce2bb336284baddc", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int\n\tfor I(&n) == nil {\n\t\tsolve(n)\n\t}\n}\n\ntype node struct {\n\tchild *node\n\tvalue int\n}\n\nfunc solve(n int) {\n\tvar k int\n\tI(&k)\n\ta := make([]int, k)\n\tfor i := range a {\n\t\tI(&a[i])\n\t}\n\tI(&k)\n\tb := make([]int, k)\n\tfor i := range b {\n\t\tI(&b[i])\n\t}\n\tvar i int\n\tfor i = 0; i < 1000 && len(a) > 0 && len(b) > 0; i++ {\n\t\tif a[0] > b[0] {\n\t\t\ta = append(a, b[0])\n\t\t\ta = append(a, a[0])\n\t\t} else {\n\t\t\tb = append(b, a[0])\n\t\t\tb = append(b, b[0])\n\t\t}\n\t\ta = a[1:]\n\t\tb = b[1:]\n\t}\n\tif len(b) == 0 {\n\t\tO(i, \" 1\\n\")\n\t} else if len(a) == 0 {\n\t\tO(i, \" 2\\n\")\n\t} else {\n\t\tO(\"-1\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "a261eab9f2defa92e4e1f026ae41c3c4", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tc := make([][]int, 2)\n\tc[0] = make([]int, n)\n\tc[1] = make([]int, n)\n\tk := make([]int, 2)\n\tpos := make([]int, 2)\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tsteps := 0\n\twinner := -1\n\tloop := false\n\n\tsituations := make(map[string]int)\n\n\tfor j := 0; j < 2; j++ {\n\t\tscanner.Scan()\n\t\tvar ek error\n\t\tk[j], ek = strconv.Atoi(scanner.Text())\n\t\tif ek != nil {\n\t\t\treturn\n\t\t}\n\t\tfor i := 0; i < k[j] && scanner.Scan(); i++ {\n\t\t\ta, err := strconv.Atoi(scanner.Text())\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tc[j][i] = a\n\t\t}\n\t}\n\n\tsituations[situation_to_code(c, k, pos, n)] = 1\n\n\tfor true {\n\t\tf := make([]int, 2)\n\t\tf[0] = c[0][pos[0]]\n\t\tf[1] = c[1][pos[1]]\n\n\t\tfor i := 0; i < 2; i++ {\n\t\t\tc[i][pos[i]] = 0\n\t\t\tpos[i]++\n\t\t\tif pos[i] >= n {\n\t\t\t\tpos[i] = pos[i] % n\n\t\t\t}\n\t\t}\n\n\t\tic := -1\n\t\tif f[0] > f[1] {\n\t\t\tic = 0\n\t\t} else { // not equal guaranteed\n\t\t\tic = 1\n\t\t}\n\n\t\tip := pos[ic] + k[ic] - 1\n\t\tif ip >= n {\n\t\t\tip = ip % n\n\t\t}\n\t\tc[ic][ip] = f[(ic+1)%2]\n\t\tip++\n\t\tif ip >= n {\n\t\t\tip = ip % n\n\t\t}\n\t\tc[ic][ip] = f[ic]\n\n\t\tk[ic]++\n\t\tk[(ic+1)%2]--\n\n\t\tsteps++\n\n\t\tcurr_sit := situation_to_code(c, k, pos, n)\n\t\tif situations[curr_sit] > 0 {\n\t\t\tloop = true\n\t\t\tbreak\n\t\t} else {\n\t\t\tsituations[curr_sit]++\n\t\t}\n\t\tif k[(ic+1)%2] == 0 {\n\t\t\twinner = ic + 1\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif loop {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println(steps, winner)\n\t}\n}\n\nfunc situation_to_code(c [][]int, k, p []int, n int) string {\n\tres := make([]string, n+2)\n\tres[0], res[1] = strconv.Itoa(k[0]), strconv.Itoa(k[1])\n\trp := 2\n\tfor i := 0; i < 2; i++ {\n\t\tfor j := 0; j < k[i]; j++ {\n\t\t\tpos := (p[0] + j) % n\n\t\t\tres[rp] = strconv.Itoa(c[i][pos])\n\t\t\trp++\n\t\t}\n\t}\n\treturn strings.Join(res, \",\")\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "329e64f0b0a2962c0e7199e8ecfb1d28", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar n int\n\nfunc main() {\n\tfmt.Fscan(reader, &n)\n\tm := int(math.Log2(float64((n + 4) / 5)))\n\tn -= int(math.Exp2(float64(m))-1) * 5\n\tm = int(math.Exp2(float64(m)))\n\tswitch (n + m - 1) / m {\n\tcase 0:\n\t\tfmt.Println(\"Howard\")\n\tcase 1:\n\t\tfmt.Println(\"Sheldon\")\n\tcase 2:\n\t\tfmt.Println(\"Leonard\")\n\tcase 3:\n\t\tfmt.Println(\"Penny\")\n\tcase 4:\n\t\tfmt.Println(\"Rajesh\")\n\tcase 5:\n\t\tfmt.Println(\"Howard\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "7c903451d04cf5a215892df0d9ac71f8", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tpeople := []string{\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"}\n\tvar k int\n\tfmt.Scan(&k)\n\n\tif k <= len(people) {\n\t\tfmt.Print(people[k-1])\n\t\treturn\n\t}\n\n\tround := int(math.Ceil(math.Log2(float64(k)/float64(len(people)) + 1)))\n\tleft := k - 5*(int(math.Pow(2, float64(round-1)))-1)\n\tpos := (left - 1) / int(math.Pow(2, float64(round-1)))\n\n\tfmt.Print(people[pos])\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "11e0b211dc87dddd4895b71896f9247f", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n ans := [...]string{\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"}\n fmt.Scan(&n)\n a := 1\n for n > (5*a) {\n n -= (5*a)\n a *= 2\n }\n fmt.Println(ans[(n-1)/a])\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "e0bbf0f44cacf5e46f4296ba8cf5831c", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\nfunc getLine2Ints(n int) []int {\n\tans := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d \", &ans[i])\n\t}\n\tscanf(\"%d\\n\", &ans[n-1])\n\treturn ans\n}\n\nvar debug = false\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc d(p, a, b byte) (bool, byte) {\n\treturn p >= a && p <= b, p - a\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tn := getLine2Int()\n\tif n <= 0 {\n\t\treturn\n\t}\n\ts := getLine()\n\tvar c [26]bool\n\tfor i := 0; i < len(s); i++ {\n\t\tif ok, t := d(s[i], 'a', 'z'); ok {\n\t\t\tc[t] = ok\n\t\t}\n\t\tif ok, t := d(s[i], 'A', 'Z'); ok {\n\t\t\tc[t] = ok\n\t\t}\n\t}\n\tok := true\n\tfor i := 0; ok && i < len(c); i++ {\n\t\tif !c[i] {\n\t\t\tok = false\n\t\t}\n\t}\n\n\tif ok {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "d67c0807256f831bb12ab00ec44ed0b2", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"strings\"\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tm := make(map[rune]bool)\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfmt.Scanf(\"%s\\n\", &s)\n\tfor _, v := range strings.ToLower(s) {\n\t\tm[v] = true\n\t}\n\tif len(m) == 26 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "b0c76f3725c2e9228ad9c808f0656950", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d \\n\", &n)\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\n\tif n < 26 {\n\t\tfmt.Print(\"NO\")\n\t\treturn\n\t}\n\n\tfor i := 0; i < 26; i++ {\n\t\tif !strings.ContainsRune(text, int32(65+i)) && !strings.ContainsRune(text, int32(97+i)) {\n\t\t\tfmt.Print(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "a681d03b442216eb64447614488813ed", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc solve(mat []int, t1, t2, n, b, k int) int {\n\tfor b < n {\n\t\tif mat[b] == 1 {\n\t\t\tt1--\n\t\t} else {\n\t\t\tt2--\n\t\t}\n\t\tb += k\n\t}\n\tans := t1 - t2\n\tif ans < 0 {\n\t\tans = 0 - ans\n\t}\n\treturn ans\n}\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar n, k int\n\tfmt.Fscanf(buf, \"%d %d\\n\", &n, &k)\n\tmat := make([]int, n+1)\n\tvar t1 int = 0\n\tvar t2 int = 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(buf, \"%d\", &mat[i])\n\t\tif mat[i] == 1 {\n\t\t\tt1++\n\t\t} else {\n\t\t\tt2++\n\t\t}\n\t}\n\tmax := -1\n\tfor b := 0; b < k; b++ {\n\t\ttmp := solve(mat, t1, t2, n, b, k)\n\t\tif max == -1 || max < tmp {\n\t\t\tmax = tmp\n\t\t}\n\t}\n\tfmt.Printf(\"%d\\n\", max)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "224d1b0dfadbcd6ca3ff798d79d94461", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nvar ns [200]int\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scanf(\"%d %d\\n\", &n, &k)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &ns[i])\n\t}\n\tvar allE, allS int\n\tfor idx := 0; idx < n; idx++ {\n\t\tif ns[idx] > 0 {\n\t\t\tallE++\n\t\t} else {\n\t\t\tallS++\n\t\t}\n\t}\n\tmaxDist := float64(-1)\n\tfor b := 0; b < n; b++ {\n\t\tcurrE := float64(allE)\n\t\tcurrS := float64(allS)\n\t\tfor i := -100; i < 100; i++ {\n\t\t\tc := b + i*k\n\t\t\tif c >= 0 && c < n {\n\t\t\t\tif ns[c] > 0 {\n\t\t\t\t\tcurrE--\n\t\t\t\t} else {\n\t\t\t\t\tcurrS--\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tmaxDist = math.Max(maxDist, math.Abs(currE-currS))\n\t}\n\tfmt.Printf(\"%0.f\\n\", maxDist)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "1fb7c184d0a90abf8707a3bbd0dbe8d6", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\ntype CaseInput struct {\n\tK int64\n\tTabs []int64\n}\n\nfunc readCaseInput(scanner *bufio.Scanner) CaseInput {\n\tsize := readInt64(scanner)\n\tk := readInt64(scanner)\n\ttabs := make([]int64, size)\n\tfor i := range tabs {\n\t\ttabs[i] = readInt64(scanner)\n\t}\n\treturn CaseInput{k, tabs}\n}\n\ntype CaseOutput struct {\n\tMaxDiff int64\n}\n\nfunc writeCaseOutput(writer *bufio.Writer, out CaseOutput) {\n\twritef(writer, \"%d\\n\", abs64(out.MaxDiff))\n}\n\nfunc solveCase(in CaseInput) CaseOutput {\n\tdiffs := make([]int64, in.K)\n\tdiffsTotal := int64(0)\n\tfor i, t := range in.Tabs {\n\t\tdiffs[int64(i) % in.K] += t\n\t\tdiffsTotal += t\n\t}\n\n\tmaxDiff := abs64(diffsTotal - diffs[0])\n\tfor b := int64(1); b < in.K; b++ {\n\t\tmaxDiff = max64(abs64(diffsTotal - diffs[b]), maxDiff)\n\t}\n\treturn CaseOutput{maxDiff}\n}\n\nfunc solveSequential(scanner *bufio.Scanner, writer *bufio.Writer) {\n\twriteCaseOutput(writer, solveCase(readCaseInput(scanner)))\n}\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\tif len(os.Args) > 1 {\n\t\treader, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tdefer reader.Close()\n\t\tscanner = bufio.NewScanner(reader)\n\t} else {\n\t\tscanner = bufio.NewScanner(os.Stdin)\n\t}\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)\n\n\tvar writer = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tsolveSequential(scanner, writer)\n}\n\nfunc readInt64(sc *bufio.Scanner) int64 {\n\tif !sc.Scan() {\n\t\tpanic(\"failed to scan next token\")\n\t}\n\n\tres, err := strconv.ParseInt(sc.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc writef(writer *bufio.Writer, formatStr string, values ...interface{}) {\n\tout := fmt.Sprintf(formatStr, values...)\n\t_, err := writer.WriteString(out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc max64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc abs64(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "394c22446dfb7aedd2f89cf8e7fb3793", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"bufio\"\nimport \"os\"\nimport \"fmt\"\nimport \"math\"\n\nfunc Read(s *bufio.Reader) string {\n line, _ := s.ReadString('\\n')\n return line\n}\n\nfunc Write(s *bufio.Writer, a ...interface{}) {\n fmt.Fprintln(s, a...)\n s.Flush()\n}\n\nfunc is_simple(n int64) bool {\n var result bool = true\n\n if math.Mod(float64(n), 2) == 0 {\n return false\n }\n\n\n end := int64(math.Pow(float64(n), 0.5)) + 1\n var i int64\n for i = 3; i <= end; i += 2 {\n if math.Mod(float64(n), float64(i)) == 0 {\n result = false\n break\n } \n }\n\n return result\n}\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n \n var n int64\n fmt.Sscanln(Read(reader), &n)\n\n var result int64 = n\n\n if !is_simple(n) {\n result = 1\n\n if math.Mod(float64(n), 2) == 0 {\n result *= 2\n\n for math.Mod(float64(n), 2) == 0 {\n n = n / 2\n }\n }\n \n var i int64\n var end int64 = int64(math.Pow(float64(n), 0.5)) + 1\n for i = 3; i <= end; i += 2 {\n if math.Mod(float64(n), float64(i)) == 0 {\n result *= i\n for math.Mod(float64(n), float64(i)) == 0 {\n n = n / i\n } \n end = int64(math.Pow(float64(n), 0.5)) + 1\n } \n }\n\n result *= n\n }\n\n writer := bufio.NewWriter(os.Stdout) \n Write(writer, result)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "852ba6931d125a6a3bce6f0f0dfc9f5e", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n int64\n\n\tfmt.Fscanln(reader, &n)\n\n\tvar cnt, i int64 = 1, 2\n\n\tfor i*i <= n {\n\t\tif n%i == 0 {\n\t\t\tcnt *= i\n\t\t}\n\t\tfor n%i == 0 {\n\t\t\tn /= i\n\t\t}\n\t\ti++\n\t}\n\n\tfmt.Println(cnt * n)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "7af528c56c31b12f1c95c8ec14b4c648", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\nvar writer *bufio.Writer\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer = bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n n := getI64()\n x := n\n result := int64(1)\n for a := int64(2); a * a <= x; a++ {\n if x % a != 0 {\n continue\n }\n result *= a\n for x % a == 0 {\n x /= a\n }\n //fmt.Printf(\"%d \", a)\n }\n result *= x\n //fmt.Printf(\"%d\\n\", x)\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "a1322a7d8838559b723d60e046b02faa", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n //This problem can be done easily using gcd, but I am lazy\n var m, n, z int\n fmt.Scan(&m, &n, &z)\n cnt := 0\n for i:=1; i<=z; i++ {\n if i % m == 0 && i % n == 0 {\n cnt++\n }\n }\n fmt.Print(cnt)\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "6f82894bb708b6ee598bb4306c3401a4", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m, z int\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &n, &m, &z); err != nil {\n\t\treturn\n\t}\n\n\tkill := 0\n\tfor i := m; i <= z; i += m {\n\t\tif i%n == 0 {\n\t\t\tkill++\n\t\t}\n\t}\n\n\tfmt.Println(kill)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "956288f3faf73826d1ab9165834073bc", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strings\"\n \"strconv\"\n )\n\nfunc GCD(a, b int) int {\n for b != 0 {\n a, b = b, a%b\n }\n\n return a\n}\n\nfunc getLine(s *bufio.Scanner) (int,int,int) {\n s.Scan()\n ab := strings.Fields(s.Text())\n a, _ := strconv.Atoi(ab[0])\n b, _ := strconv.Atoi(ab[1])\n c, _ := strconv.Atoi(ab[2])\n \n return a,b,c\n}\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n n, m, z:= getLine(scanner)\n fmt.Println(z * GCD(n,m) / (n*m))\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "514ed68121e3acfbb446a9004c2c16b5", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN, x := sc.NextInt(), sc.NextInt()\n\tn := N\n\tif x == 1 {\n\t} else {\n\t\tif x == 2 {\n\t\t\tif N%2 == 1 {\n\t\t\t\tN--\n\t\t\t}\n\t\t} else {\n\t\t\tif N%2 == 0 {\n\t\t\t\tN--\n\t\t\t}\n\t\t}\n\t}\n\tn = N % 6\n\n\t\n\tfor i := n; i > 0; i-- {\n\t\tif i%2 == 1 {\n\t\t\tif x == 1 {\n\t\t\t\tx = 0\n\t\t\t} else if x == 0 {\n\t\t\t\tx = 1\n\t\t\t}\n\t\t} else {\n\t\t\tif x == 1 {\n\t\t\t\tx = 2\n\t\t\t} else if x == 2 {\n\t\t\t\tx = 1\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(x)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "48bf84ed428e972626d2da05d70e7772", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tsituations := map[int][]int{\n\t\t0: []int{0, 1, 2},\n\t\t1: []int{1, 0, 2},\n\t\t2: []int{1, 2, 0},\n\t\t3: []int{2, 1, 0},\n\t\t4: []int{2, 0, 1},\n\t\t5: []int{0, 2, 1},\n\t}\n\n\tvar n, x int\n\tif _, err := fmt.Scanf(\"%d\\n%d\\n\", &n, &x); err != nil {\n\t\treturn\n\t}\n\tn = n % 6\n\n\tfmt.Println(situations[n][x])\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "f90df5f3b9b9849cc4fcd6a964353726", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\tX := io.NextInt()\n\n\thas := make([]bool, 3)\n\thas[X] = true\n\n\tfor i := N % 12; i > 0; i-- {\n\t\tif i % 2 == 0 {\n\t\t\thas[1], has[2] = has[2], has[1]\n\t\t} else {\n\t\t\thas[0], has[1] = has[1], has[0]\n\t\t}\n\t}\n\n\tfor i := 0; ; i++ {\n\t\tif has[i] {\n\t\t\tio.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tSolve(&io)\n\tio.FlushOutput()\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "caa7f53aa525da6fe0c5ca8b2f5c7d1f", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport \"fmt\"\n \nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scan(&n)\n\tm := make(map[string]int)\n\tfor i:= 0; i < n; i++{\n\t\tfmt.Scan(&s)\n\t\tm[s] = m[s] + 1\n\t}\n\tresult := 0\n\tfor _, value := range m{\n\t\tif value > result{\n\t\t\tresult = value\n\t\t}\n\t}\n\tfmt.Println(result)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "013c6b8cafa02e57642f52d74a14fa17", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\n\tmax := 0\n\tcoins := make(map[int]int)\n\tfor i := 0; i < n; i++ {\n\t\tvar a int\n\t\tfmt.Scan(&a)\n\t\tcoins[a]++\n\t\tif coins[a] > max {\n\t\t\tmax = coins[a]\n\t\t}\n\t}\n\n\tfmt.Println(max)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "05005c5b00a382b1b94f545374a3f0ed", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\"fmt\";\n\t\t\"sort\")\n\nfunc main() {\n\tn := nextInt()\n\ta := make([]int, 101)\n\tfor i := 0; i < n; i++{\n\t\ta[nextInt()]+=1\n\t}\n\tsort.Ints(a)\n\tsout(a[100])\n}\n\nfunc next() string{\n\tvar ss string\n\tfmt.Scan(&ss)\n\treturn ss\n}\nfunc nextInt() int{\n\tvar ss int;\n\tfmt.Scan(&ss)\n\treturn ss\n}\nfunc sout(obj ... interface{}){\n\tfor _, k := range obj{\n\t\tfmt.Print(k, \" \")\n\t}\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "77be9b8587f9fb4c6e86e107b8fcad5f", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\n\n\tvar a,b,c,d int64\n\tfmt.Fscanf(buf, \"%d %d %d %d\\n\", &a,&b,&c,&d)\n\n\tfmt.Printf(\"%d\\n\",4+2*(a+b+d))\n\n}\n\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "f5b60273fef5947aad3ece78ab0a29d5", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport(\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main(){\n\tvar w1,h1,w2,h2 int\n\tfmt.Scan(&w1,&h1,&w2,&h2)\n\tres := (w1+2)*(h1+1)+(w2+2)*(h2+1)+int(math.Abs(float64(w1-w2)))-w1*h1-w2*h2\n\tfmt.Printf(\"%v\\n\",res)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "dee8e84070d50f0e2c1f0f837036eb5d", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc strToInt(s string) uint64 {\n\tresult, err := strconv.ParseUint(s, 10, 32)\n\n\tif err != nil {\n\t\tfmt.Printf(\"%s\", err.Error())\n\t\tos.Exit(1)\n\t}\n\n\treturn result\n}\n\nfunc parseInts(s string) (w1, h1, w2, h2 uint64) {\n\tfor i, f := range strings.Fields(s) {\n\t\tswitch i {\n\t\tcase 0:\n\t\t\tw1 = strToInt(f)\n\t\tcase 1:\n\t\t\th1 = strToInt(f)\n\t\tcase 2:\n\t\t\tw2 = strToInt(f)\n\t\tcase 3:\n\t\t\th2 = strToInt(f)\n\t\t}\n\t}\n\n\treturn\n}\n\n\nfunc main() {\n\tvar w1,h1,w2,h2 uint64\n\tscanner := bufio.NewScanner(os.Stdin)\n\tif scanner.Scan() {\n\t\tw1, h1, w2, h2 = parseInts(scanner.Text())\n\t}\n\tfmt.Println(1 + w2 + 1 + h2 + h2 + h1 + h1 + w1 - w2 + 1 + w1 + 1)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "489519fb30ef67ec318252e84bd49458", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\ta := make([]int, 3, 3)\n\tvar d, res int\n\tfmt.Scan(&a[0], &a[1], &a[2], &d)\n\tsort.Ints(a)\n\tif d > (a[1] - a[0]) {\n\t\tres += d - (a[1] - a[0])\n\t}\n\tif d > (a[2] - a[1]) {\n\t\tres += d - (a[2] - a[1])\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "34006403f17ccaafefadff9a3a55e2c5", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar d, cnt int\n\t// var st string\n\n\ta := make([]int, 3)\n\n\tfmt.Scanln(&a[0], &a[1], &a[2], &d)\n\n\tsort.Ints(a)\n\tif a[1]-a[0] < d {\n\t\tcnt = d - (a[1] - a[0])\n\t}\n\tif a[2]-a[1] < d {\n\t\tcnt += d - (a[2] - a[1])\n\t}\n\n\tfmt.Println(cnt)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "fd35fe92465bfbdeb0ce8566aabe2611", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc main() {\n\tvar arr [3]int\n\tvar d, total int\n\tfmt.Scanf(\"%d %d %d %d\\n\", &arr[0], &arr[1], &arr[2], &d)\n\tsort.Ints(arr[:])\n\ttotal += max(0, d-(arr[1]-arr[0])) + max(0, d-(arr[2]-arr[1]))\n\tfmt.Println(total)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "6e59018816e00a98e274fe69a8b6a5d8", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// hello project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc max(num1 int, num2 float32) int {\n\tvar result int\n\tif num1 > int(num2) {\n\t\tresult = num1\n\t} else {\n\t\tresult = int(num2)\n\t}\n\treturn result\n}\n\nfunc swap(x string, y string) (string, string) {\n\treturn y, x\n}\n\nfunc main() {\n\tvar n, m int64\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\ta := n / 5\n\tb := m / 5\n\tc, d := n%5, m%5\n\tans := a * b * 5\n\tans += a * d\n\tans += b * c\n\t//\tfmt.Println(ans)\n\tvar i, j int\n\tfor i = 1; i <= int(c); i++ {\n\t\tfor j = 1; j <= int(d); j++ {\n\t\t\tif (i+j)%5 == 0 {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "8aee7c75edbe5b8ae3d79def15f60927", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc foo(x, n int) int {\n\ta := (n + 5 - x) / 5\n\tif x == 0 {\n\t\ta--\n\t}\n\treturn a\n}\n\nfunc main() {\n\tn := getInt()\n\tm := getInt()\n\tvar ans int64\n\tfor i := 0; i < 5; i++ {\n\t\tans += int64(foo(i, n)) * int64(foo(5-i, m))\n\t}\n\tfmt.Println(ans)\n}\n\ntype Input struct {\n\t*bufio.Scanner\n}\n\nvar globalInput = wrapStdin()\n\nfunc wrapStdin() Input {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\treturn Input{Scanner: sc}\n}\nfunc getInt() int {\n\tglobalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x\n}\nfunc getIntOk() (int, bool) {\n\tok := globalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x, ok\n}\nfunc getNint(n int) []int {\n\tv := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tv[i] = getInt()\n\t}\n\treturn v\n}\nfunc getVint(v []int) bool {\n\tvar ok bool\n\tfor i := 0; i < len(v); i++ {\n\t\tv[i], ok = getIntOk()\n\t}\n\treturn ok\n}\nfunc getWord() string {\n\tglobalInput.Scan()\n\treturn globalInput.Text()\n}\nfunc getWordOk() (string, bool) {\n\tok := globalInput.Scan()\n\treturn globalInput.Text(), ok\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc min64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max64(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc minStr(a, b string) string {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc maxStr(a, b string) string {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc remin(a *int, b int) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remax(a *int, b int) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remin64(a *int64, b int64) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remax64(a *int64, b int64) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc reminStr(a *string, b string) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remaxStr(a *string, b string) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\nfunc abs64(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\ntype (\n\tFLess func(i, j int) bool\n\tFSwap func(i, j int)\n\twrapSort struct {\n\t\tLength int\n\t\tFLess\n\t\tFSwap\n\t}\n)\n\nfunc (w *wrapSort) Len() int { return w.Length }\nfunc (w *wrapSort) Less(i, j int) bool { return w.FLess(i, j) }\nfunc (w *wrapSort) Swap(i, j int) { w.FSwap(i, j) }\nfunc wsort(length int, fless func(i, j int) bool, fswap func(i, j int)) {\n\tsort.Sort(&wrapSort{length, fless, fswap})\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "0d05893b1cf59a5b19b8200438bac6bb", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n, m uint64\n fmt.Scanf(\"%d %d\", &n, &m)\n res1 := [5]uint64{}\n res2 := [5]uint64{}\n for i := range(res1) {\n res1[i] = n / 5\n }\n for i := range(res2) {\n res2[i] = m / 5\n }\n\n if temp := n % 5; temp != 0 {\n for i := uint64(1); i <= temp; i++ {\n res1[i]++\n }\n }\n if temp := m % 5; temp != 0 {\n for i := uint64(1); i <= temp; i++ {\n res2[i]++\n }\n }\n\n result := uint64(0)\n for i := 0; i < 5; i++ {\n result += res1[i] * res2[(5 - i) % 5]\n }\n fmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "f0240389b0359b1b196e180a586d2570", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"io\"\n \"os\"\n \"sort\"\n \"strconv\"\n)\n\ntype Scanner struct {\n r io.Reader\n split bufio.SplitFunc\n maxTokenSize int\n token, buf []byte\n start, end int\n}\n\nfunc NewScanner(r io.Reader) *Scanner {\n return &Scanner{\n r: r,\n split: bufio.ScanWords,\n maxTokenSize: 16777216,\n buf: make([]byte, 4096),\n }\n}\n\nfunc (s *Scanner) advance(n int) bool {\n if n < 0 || n > s.end-s.start {\n return false\n }\n s.start += n\n return true\n}\n\nfunc (s *Scanner) Text() string {\n return string(s.token)\n}\n\nfunc (s *Scanner) Scan() bool {\n for {\n if s.end > s.start {\n advance, token, err := s.split(s.buf[s.start:s.end], false)\n if err != nil || !s.advance(advance) {\n return false\n }\n s.token = token\n if token != nil {\n return true\n }\n }\n if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {\n copy(s.buf, s.buf[s.start:s.end])\n s.end -= s.start\n s.start = 0\n }\n if s.end == len(s.buf) {\n if len(s.buf) >= s.maxTokenSize {\n return false\n }\n newSize := len(s.buf) * 2\n if newSize > s.maxTokenSize {\n newSize = s.maxTokenSize\n }\n newBuf := make([]byte, newSize)\n copy(newBuf, s.buf[s.start:s.end])\n s.buf = newBuf\n s.end -= s.start\n s.start = 0\n continue\n }\n for loop := 0; ; {\n n, _ := s.r.Read(s.buf[s.end:len(s.buf)])\n s.end += n\n if n > 0 {\n break\n }\n loop++\n if loop > 100 {\n break\n }\n }\n }\n}\n\nfunc (s *Scanner) Split(split bufio.SplitFunc) {\n s.split = split\n}\n\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\nvar sc *Scanner = NewScanner(os.Stdin)\n\nfunc next() string { sc.Scan(); return sc.Text() }\nfunc nc() byte { sc.Scan(); return sc.Text()[0] }\n\nfunc ni32() int {\n sc.Scan()\n n, _ := strconv.Atoi(sc.Text())\n return n\n}\n\nfunc ni64() int64 {\n sc.Scan()\n n, _ := strconv.ParseInt(sc.Text(), 10, 64)\n return n\n}\n\nfunc pri32(i ...int) {\n for _, ii := range i {\n w.WriteString(strconv.Itoa(ii))\n sp()\n }\n}\nfunc pri64(i ...int64) {\n for _, ii := range i {\n w.WriteString(strconv.FormatInt(ii, 10))\n sp()\n }\n}\nfunc sp() { w.WriteByte(' ') }\nfunc endl() { w.WriteByte('\\n') }\n\nfunc main() {\n x, y := make([]int, 8), make([]int, 8)\n for i := 0; i < 8; i++ {\n x[i], y[i] = ni32(), ni32()\n }\n // for i := 0; i < 8; i++ {\n // for j := i + 1; j < 8; j++ {\n // if x[j] < x[i] || (x[j] == x[i] && y[j] < y[i]) {\n // x[i], y[i], x[j], y[j] = x[j], y[j], x[i], y[i]\n // }\n // }\n // }\n xx, yy := make([]int, 8), make([]int, 8)\n copy(xx, x)\n copy(yy, y)\n sort.Ints(xx)\n sort.Ints(yy)\n xs, ys := []int{xx[0]}, []int{yy[0]}\n for i := 1; i < 8; i++ {\n if xx[i] != xx[i-1] {\n xs = append(xs, xx[i])\n }\n if yy[i] != yy[i-1] {\n ys = append(ys, yy[i])\n }\n }\n sort.Ints(xs)\n sort.Ints(ys)\n // fmt.Println(xs, ys)\n if len(xs) != 3 || len(ys) != 3 || xs[1] <= xs[0] || xs[2] <= xs[1] || ys[1] <= ys[0] || ys[2] <= ys[1] {\n w.WriteString(\"ugly\\n\")\n w.Flush()\n return\n }\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n ug := true\n for k := 0; k < 8; k++ {\n if x[k] == xs[i] && y[k] == ys[j] {\n ug = false\n }\n }\n if ((i != 1 || j != 1) && ug) || (i == 1 && j == 1 && !ug) {\n w.WriteString(\"ugly\\n\")\n w.Flush()\n return\n }\n }\n }\n w.WriteString(\"respectable\\n\")\n w.Flush()\n}\n", "lang_cluster": "Go", "tags": ["sortings"], "code_uid": "04bc66aa9ff6a43a4e2f5a97583debb0", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "\npackage main\n\nimport (\n \"fmt\"\n)\n\nvar x [8]int\nvar y [8]int\n\nfunc input() {\n for i := 0; i < 8; i++ {\n x[i] = -1; y[i] = -1\n fmt.Scanf(\"%d %d\", &x[i], &y[i])\n if x[i] == -1 && y[i] == -1 {\n i --\n }\n }\n}\n\nfunc solve() {\n var x1, x2, x3 int = x[0], x[0], x[0]\n for i := 0; i < 8; i++ {\n if x[i] < x1 {\n x1 = x[i]\n } else if x[i] > x3 {\n x3 = x[i]\n }\n }\n var y1, y2, y3 int = y[0], y[0], y[0]\n for i := 0; i < 8; i++ {\n if y[i] < y1 {\n y1 = y[i]\n } else if y[i] > y3 {\n y3 = y[i]\n }\n }\n for i := 0; i < 8; i ++ {\n if x[i] > x1 && x[i] < x3 {\n x2 = x[i]\n }\n if y[i] > y1 && y[i] < y3 {\n y2 = y[i]\n }\n }\n\n vis := [3][3]int{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}\n for i := 0; i < 8; i ++ {\n var a, b int = -1, -1\n if x[i] == x1 {\n a = 0\n } else if x[i] == x2 {\n a = 1\n } else if x[i] == x3 {\n a = 2\n }\n if y[i] == y1 {\n b = 0\n } else if y[i] == y2 {\n b = 1\n } else if y[i] == y3 {\n b = 2\n }\n if a != -1 && b != -1 {vis[a][b] = 1}\n }\n\n for i := 0; i < 3; i ++ {\n for j := 0; j < 3; j ++ {\n if i == 1 && j== 1 {\n continue\n } else if vis[i][j] == 0 {\n fmt.Println(\"ugly\")\n return\n }\n }\n }\n\n fmt.Println(\"respectable\")\n}\n\nfunc main() {\n input()\n solve()\n}\n", "lang_cluster": "Go", "tags": ["sortings"], "code_uid": "64602054c1ffde4dcc3d7a7f66a95dc6", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar sc = NewMyScanner()\n\nfunc solve2() bool {\n\tmx := make(map[int]bool)\n\tmy := make(map[int]bool)\n\ttype pair struct {\n\t\ty int\n\t\tx int\n\t}\n\tmm := make(map[pair]bool)\n\tfor i := 0; i < 8; i++ {\n\t\tx := sc.Int()\n\t\ty := sc.Int()\n\t\tmx[x] = true\n\t\tmy[y] = true\n\t\tmm[pair{y, x}] = true\n\t}\n\n\tif len(mx) != 3 || len(my) != 3 {\n\t\treturn false\n\t}\n\n\tmid := func(m map[int]bool) int {\n\t\tvar t [3]int\n\t\ti := 0\n\t\tfor k := range m {\n\t\t\tt[i] = k\n\t\t\ti++\n\t\t}\n\t\tsort.Ints(t[:])\n\t\treturn t[1]\n\t}\n\n\tmidx := mid(mx)\n\tmidy := mid(my)\n\tif mm[(pair{midy, midx})] {\n\t\treturn false\n\t}\n\n\treturn len(mm) == 8\n}\n\nfunc solve() string {\n\tif solve2() {\n\t\treturn \"respectable\"\n\t} else {\n\t\treturn \"ugly\"\n\t}\n}\n\ntype MyScanner struct {\n\t*bufio.Scanner\n\tjustScanned bool\n}\n\nfunc NewMyScanner() *MyScanner {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\treturn &MyScanner{sc, false}\n}\n\nfunc (sc *MyScanner) Has() bool {\n\tsc.justScanned = true\n\treturn sc.Scan()\n}\n\nfunc (sc *MyScanner) Int() int {\n\tif !sc.justScanned {\n\t\tsc.Scan()\n\t}\n\tsc.justScanned = false\n\n\tx, _ := strconv.Atoi(sc.Text())\n\treturn x\n}\n\nfunc (sc *MyScanner) Bool() bool {\n\tif !sc.justScanned {\n\t\tsc.Scan()\n\t}\n\tsc.justScanned = false\n\n\treturn sc.Bytes()[0] == byte('1')\n}\n\n// sc.justScanned should be false\nfunc (sc *MyScanner) Map2D(r, c int) [][]byte {\n\tm := make([][]byte, r)\n\tfor y := range m {\n\t\tsc.Scan()\n\t\tm[y] = append(m[y], sc.Bytes()...)\n\t}\n\treturn m\n}\n\nfunc main() {\n\tfmt.Println(solve())\n}\n", "lang_cluster": "Go", "tags": ["sortings"], "code_uid": "a0eab493165eb40c01673d432279dc39", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n x := getI()\n if x < 0 {\n x = -x\n }\n jumps := 0\n size, a := 0, 0\n for a < x {\n size++\n a += size\n jumps++\n }\n if a > x {\n for (a-x)%2 == 1 {\n size++\n a += size\n jumps++\n }\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", jumps))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "bb278b2b6f02c1a58b5c045481dba126", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bytes\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\t\n\tvar x int\n\tfmt.Fscanf(reader, \"%d\", &x);\n\tif x < 0 {\n\t\tx = -x\n\t}\n\tsum := 0\n\tfor i := 0;;i ++ {\n\t\tsum += i\n\t\tif sum >= x && sum % 2 == x % 2 {\n\t\t\tfmt.Printf(\"%d\", i)\n\t\t\treturn\n\t\t}\n\t}\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "6c15daa465c3a35e77dc0cf62c63527a", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF11B(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar x, s, i int\n\tFscan(in, &x)\n\tif x < 0 {\n\t\tx = -x\n\t}\n\tfor {\n\t\ts += i\n\t\tif s >= x && (s-x)&1 == 0 {\n\t\t\tFprint(out, i)\n\t\t\treturn\n\t\t}\n\t\ti++\n\t}\n}\n\nfunc main() { CF11B(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "45abf18e63dbf13c4dc758d0aaf2687b", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, a, b int\n\tfmt.Scan(&n, &m, &a, &b)\n\n\tif b/m >= a {\n\t\tfmt.Print(a * n)\n\t} else if a*(n%m) > b {\n\t\tfmt.Print((n + m - 1) / m * b)\n\t} else {\n\t\tfmt.Print(b*(n/m) + a*(n%m))\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "17c81a2c12af91c23761baf285b4dd12", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar (\n\t\tn, m, a, b int\n\t\tper float32\n\t)\n\tfmt.Scanln(&n, &m, &a, &b)\n\tper = float32(b/m)\n\tif per >= float32(a) {\n\t\tfmt.Println(n*a)\n\t}else {\n\t\tif n%m == 0 {\n\t\t\tfmt.Println(n/m*b)\n\t\t}else{\n\t\t\tremain := n%m\n\t\t\tif remain*a >= b {\n\t\t\t\tfmt.Println((n/m+1)*b)\n\t\t\t}else {\n\t\t\t\tfmt.Println(remain*a + (n/m)*b)\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b844e4cae98297aeb1584c26c3d9af3d", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tall := scanner.Text()\n\tvar chList []int\n\tfor _, ch := range strings.Split(all, \" \") {\n\t\tch, err := strconv.Atoi(ch)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tchList = append(chList, ch)\n\t}\n\tn, m, a, b := chList[0], chList[1], chList[2], chList[3]\n\tmoney := 0\n\tif (b / m) < a {\n\t\tif (n%m)*a < b {\n\t\t\tmoney = (n%m)*a + n/m*b\n\t\t} else {\n\t\t\tmoney = n/m*b + b\n\t\t}\n\t} else {\n\t\tmoney = n * a\n\t}\n\tfmt.Println(money)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b0a20c8264c55ea6b84a5e72e57fd746", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//\tURL: http://codeforces.com/contest/911/problem/B\n//\tPROBLEM RESTATEMENT\n//\t\tCake one has a pieces, cake two has b pieces.\n//\t\tCake must be distributed to n plates s.t:\n//\t\t\t- Each plate contains >= x pieces, x >= 1.\n//\t\t\t- All cake is distributed.\n//\t\t\t- A given plate only has one type of cake pieces.\n//\t\tGiven a, b, n, what is the maximum x we can achieve?\n//\tCONSTRAINTS\n//\t\t1 <= a, b <= 100; 2 <= n <= a + b\n//\tAPPROACH\n//\t\t(1) Let c = # of plates with pieces of cake one.\n//\t\t\tLet n - c = # of plates with pieces of cake two.\n//\t\t(2) Assume the problem only had one cake.\n//\t\t\tThe answer for one cake is trivially x = a / c.\n//\t\t(3) With two cakes, we are trying to maximize x, where x =\n//\t\t\tmin(a/c, b/(n - c)), and where c is unknown.\n//\t\t(4) In O(n) time, we can iterate through all values of c [1, n) and\n//\t\t\tfind the answer.\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc min(x int, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc max(x int, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc solve(n int, a int, b int) int {\n\tx := 0\n\tfor c := 1; c < n; c += 1 {\n\t\tx = max(min(a/c, b/(n-c)), x)\n\t}\n\treturn x\n}\n\nfunc main() {\n\treader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar n, a, b int\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &n, &a, &b)\n\tfmt.Fprintf(writer, \"%d\\n\", solve(n, a, b))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "binary search"], "code_uid": "46fd8260e8f9daa32948f674637343e2", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tstdio := bufio.NewReader(os.Stdin)\n\tvar n, a, b int\n\tx := 1\n\tfmt.Fscanf(stdio, \"%d %d %d\", &n, &a, &b)\n\tfor x <= a && x <= b && (a/x+b/x >= n) {\n\t\tx++\n\t}\n\tfmt.Println(x - 1)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "binary search"], "code_uid": "a64b380dff2d6037eb42ca4cc9948ed5", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treadString func() string\n\treadBytes func() []byte\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\treadString, readBytes = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) (func() string, func() []byte) {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), math.MaxInt32)\n\tr.Split(bufio.ScanWords)\n\n\tf1 := func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n\tf2 := func() []byte {\n\t\treturn []byte(f1())\n\t}\n\treturn f1, f2\n}\n\nfunc readInt() int {\n\treturn int(readInt64())\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(readString(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(readString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(stdout, f, args...)\n}\n\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(stdout, args...)\n}\n\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc max64(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc abs64(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc gcd(a, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\n\nfunc gcd64(a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd64(b, a%b)\n}\n\n// readString() string\n// readInt() int\n// readInt64() int64\n// readFloat64() float64\n\n// -----------------------------------------------------------------------------\n\nfunc main() {\n\tdefer stdout.Flush()\n\tn := readInt()\n\ta := readInt()\n\tb := readInt()\n\n\tvar ans int\n\tfor i := 1; i < n; i++ {\n\t\tj := n - i\n\t\tans = max(ans, min(a/i, b/j))\n\t\tans = max(ans, min(b/i, a/j))\n\t}\n\tprintln(ans)\n}\n\n// -----------------------------------------------------------------------------\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "binary search"], "code_uid": "2f3f387bc9bc9a93f3db1fdc84f0325c", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Scan()\n\ta, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tb, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tr, _ := strconv.Atoi(scanner.Text())\n\n\tif a >= r*2 && b >= r*2 {\n\t\tfmt.Printf(\"First\\n\")\n\t} else {\n\t\tfmt.Printf(\"Second\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "games"], "code_uid": "e7a5284a0bce468925ddf62d7d504904", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\ta, b, r := 0, 0, 0\n\tfmt.Scanf(\"%d %d %d\\n\", &a, &b, &r)\n\tif a >= r*2 && b >= r*2 {\n\t\tfmt.Printf(\"First\\n\")\n\t} else {\n\t\tfmt.Printf(\"Second\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "games"], "code_uid": "59b8e0c3243a9d8303732e17dce8d873", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\ta, b, r := scanInt(scanner), scanInt(scanner), scanInt(scanner)\n\tif a >= 2*r && b >= 2*r {\n\t\twriter.WriteString(\"First\\n\")\n\t} else {\n\t\twriter.WriteString(\"Second\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "games"], "code_uid": "1dac07ca7af5b814a2df7636f65f813f", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var l, r, ans, a, b int64\n fmt.Scanf(\"%d %d\", &l, &r)\n ans = 0\n a = 1\n b = 1\n for i := 0; i < 33; i++ {\n b = 1\n for j := 0; j < 24; j++ {\n if a * b > r {\n break\n }\n if (l <= a * b) && (a * b <= r) {\n ans++\n }\n b *= 3\n }\n a *= 2\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "6a199297d708e67a4d1f75ca0c2306ef", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var afl int64\n var bfa int64\n var lrt int64\n var rgh int64\n var cnt int64\n afl = 1\n bfa = 1\n cnt = 0\n\tfmt.Scan(&lrt)\n\tfmt.Scan(&rgh)\n\tfor it := 0; it <= 19; it++ {\n\t bfa = 1\n\t for jt := 0; jt <= 30; jt ++ {\n\t if afl * bfa >= lrt {\n\t if afl * bfa <= rgh {\n\t cnt = cnt + 1\n\t }\n\t }\n\t bfa = bfa * 2\n\t }\n\t afl = afl * 3\n\t}\n\tfmt.Printf( \"%d\", cnt )\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "80e6706a67a553fd6e1609b1bbba9566", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n \nfunc main() {\n var l int64\n var r int64\n var cur int64\n var res int64\n fmt.Scan(&l)\n fmt.Scan(&r)\n cur = 1\n for i:= 0; i < 33; i++ {\n \tvar ocur int64\n \tocur = cur\n \tfor j := 0; j < 20; j++ {\n \t\tif cur >= l {\n \t\t\tif cur <= r {\n \t\t\t\tres = res + 1\n \t\t\t}\n \t\t}\n \t\tcur = cur * 3 \t\n \t}\n \tcur = ocur * 2\n }\n fmt.Printf(\"%d\", res)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "28466908ac737a5ccc9575770acde2a2", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// A. Another One Bites The Dust\n/*\nLet's call a string good if and only if it consists of only two types of letters — 'a' and 'b' and every two consecutive letters are distinct. For example \"baba\" and \"aba\" are good strings and \"abb\" is a bad string.\n\nYou have 𝑎 strings \"a\", 𝑏 strings \"b\" and 𝑐 strings \"ab\". You want to choose some subset of these strings and concatenate them in any arbitrarily order.\n\nWhat is the length of the longest good string you can obtain this way?\n\nInput\nThe first line contains three positive integers 𝑎, 𝑏, 𝑐 (1≤𝑎,𝑏,𝑐≤109) — the number of strings \"a\", \"b\" and \"ab\" respectively.\n\nOutput\nPrint a single number — the maximum possible length of the good string you can obtain.\n\nExamples\nInput\n1 1 1\n\nOutput\n4\n\nInput\n2 1 2\n\nOutput\n7\n\nInput\n3 5 2\n\nOutput\n11\n\nInput\n2 2 1\n\nOutput\n6\n\nInput\n1000000000 1000000000 1000000000\n\nOutput\n4000000000\n\nNote\nIn the first example the optimal string is \"baba\".\n\nIn the second example the optimal string is \"abababa\".\n\nIn the third example the optimal string is \"bababababab\".\n\nIn the fourth example the optimal string is \"ababab\".\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\tarr := strings.Split(strings.TrimSpace(input), \" \")\n\ta, _ := strconv.ParseInt(arr[0], 10, 64)\n\tb, _ := strconv.ParseInt(arr[1], 10, 64)\n\tc, _ := strconv.ParseInt(arr[2], 10, 64)\n\n\ttotal := c * 2\n\tif a > b {\n\t\ttotal += (2 * b) + 1\n\t} else if a < b {\n\t\ttotal += (2 * a) + 1\n\t} else {\n\t\ttotal += 2 * a\n\t}\n\tfmt.Print(total)\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "26833095eae2a6771751b44333a0f6df", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\n\nfunc main() {\n\tin := readString()\n\tparts := strings.Split(in, \" \")\n\ta := Atoi(parts[0])\n\tb := Atoi(parts[1])\n\tab := Atoi(parts[2])\n\n\taabb := Min(a, b)\n\tres := ab*2 + aabb*2\n\tif Abs(a-b) != 0 {\n\t\tres++\n\t}\n\tfmt.Println(res)\n}\n\nfunc readInteger() int64 {\n\ts, _, _ := reader.ReadLine()\n\tn, _ := strconv.ParseInt(string(s), 0, 64)\n\treturn n\n}\n\nfunc readString() string {\n\ts, _, _ := reader.ReadLine()\n\treturn string(s)\n}\n\nfunc Abs(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc Min(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc Max(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc Atoi(s string) int64 {\n\ti, _ := strconv.ParseInt(s, 10, 64)\n\treturn i\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "7d1c313cbfeead40c2c198aa7e638ee1", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nfunc queen(x int64, y int64, z int64) int64 {\n\tres := z * 2\n\tif x == y {\n\t\tres += x * 2\n\t\treturn res\n\t} else if x > y {\n\t\tres += y * 2 + 1\n\t\treturn res\n\t} else {\n\t\tres += x * 2 + 1\n\t\treturn res\n\t}\n}\n \nfunc main() {\n\tvar a int64\n\tvar b int64\n\tvar c int64\n\tfmt.Scan(&a, &b, &c)\n\tfmt.Println(queen(a, b, c))\n}", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "0e20e02eb5d1e6de313e67b89c59cadf", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// Node to store in queue\ntype Node struct {\n\tvalue int64\n\tprev *Node\n}\n\n// NewNode to create node with value is n.\nfunc NewNode(n int64) *Node {\n\treturn &Node{\n\t\tvalue: n,\n\t}\n}\n\nfunc main() {\n\tvar stdin *bufio.Reader\n\t// LOCAL\n\tf, _ := os.Open(\"input.txt\")\n\tstdin = bufio.NewReader(f)\n\n\t// ONLINE JUDGE\n\tstdin = bufio.NewReader(os.Stdin)\n\n\tvar a, b int64\n\tfmt.Fscan(stdin, &a, &b)\n\n\tvar queue = []*Node{NewNode(a)}\n\tvar seen = make(map[int64]bool)\n\tfor len(queue) > 0 {\n\t\tvar top = queue[0]\n\t\tqueue = queue[1:]\n\t\tseen[top.value] = true\n\n\t\tif top.value == b {\n\t\t\t// Trace\n\t\t\tfmt.Println(\"YES\")\n\t\t\tvar res []int64\n\t\t\tfor n := top; n != nil; n = n.prev {\n\t\t\t\tres = append(res, n.value)\n\t\t\t}\n\t\t\tfmt.Println(len(res))\n\t\t\tfor i := len(res) - 1; i >= 0; i-- {\n\t\t\t\tfmt.Print(res[i], \" \")\n\t\t\t}\n\n\t\t\treturn\n\t\t}\n\n\t\tif top.value*2 <= b && !seen[top.value*2] {\n\t\t\tvar n = NewNode(top.value * 2)\n\t\t\tn.prev = top\n\t\t\tqueue = append(queue, n)\n\t\t}\n\t\tif top.value*10+1 <= b && !seen[top.value*10+1] {\n\t\t\tvar n = NewNode(top.value*10 + 1)\n\t\t\tn.prev = top\n\t\t\tqueue = append(queue, n)\n\t\t}\n\n\t}\n\n\tfmt.Println(\"NO\")\n\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "math", "brute force"], "code_uid": "01e381da67cac6aab751695ba32ba5c9", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nvar a, b int\nvar trace map[int]int\n\nfunc dfs(x int) bool {\n\tif x == b {\n\t\treturn true\n\t}\n\tif x <= b/2 {\n\t\ty := x * 2\n\t\t_, found := trace[y]\n\t\tif !found {\n\t\t\ttrace[y] = x\n\t\t\tif dfs(y) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\tif x <= (b-1)/10 {\n\t\ty := x*10 + 1\n\t\t_, found := trace[y]\n\t\tif !found {\n\t\t\ttrace[y] = x\n\t\t\tif dfs(y) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tfmt.Fscanf(bufin, \"%d %d\\n\", &a, &b)\n\ttrace = make(map[int]int)\n\n\ttrace[a] = a\n\tif dfs(a) {\n\t\tfmt.Fprintf(bufout, \"YES\\n\")\n\n\t\tvar res []int\n\t\tfor b != a {\n\t\t\tres = append(res, b)\n\t\t\tb = trace[b]\n\t\t}\n\t\tres = append(res, a)\n\n\t\tn := len(res)\n\t\tfmt.Fprintf(bufout, \"%d\\n\", n)\n\t\tfor i := n - 1; i >= 0; i-- {\n\t\t\tfmt.Fprintf(bufout, \"%d \", res[i])\n\t\t}\n\t} else {\n\t\tfmt.Fprintf(bufout, \"NO\\n\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "math", "brute force"], "code_uid": "cd287f2587a94d7f7a35536160c05ef8", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n\nfunc main() {\n var a, b, steps int\n t := make([]int, 0)\n fmt.Scanf(\"%d %d\", &a, &b)\n t = append(t, b)\n steps = steps + 1\n for {\n if a == b || b < a {\n break\n } else {\n if b % 2 == 0 {\n b = b / 2\n t = append(t, b)\n steps = steps + 1\n } else if (b - 1) % 10 == 0 {\n b = (b - 1) / 10\n t = append(t, b)\n steps = steps + 1\n } else {\n break\n }\n }\n }\n if a == b {\n fmt.Printf(\"YES\\n\")\n fmt.Printf(\"%d\\n\", steps)\n for idx := len(t) - 1; idx >= 0; idx--{\n if idx == 0 {\n fmt.Printf(\"%d\\n\", t[idx])\n } else {\n fmt.Printf(\"%d \", t[idx])\n }\n }\n } else {\n fmt.Printf(\"NO\\n\")\n }\n}", "lang_cluster": "Go", "tags": ["dfs and similar", "math", "brute force"], "code_uid": "fb2b5f0b8ecb81186feedc90204b2a88", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tarr1 := make([]int, 3)\n\tarr2 := make([]int, 3)\n\tfor {\n\t\tline, _, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tsum1 := 0\n\t\tfor i := 0; i < 3; i++ {\n\t\t\tarr1[i] = int(line[i] - '0')\n\t\t\tsum1 += arr1[i]\n\t\t}\n\t\tsum2 := 0\n\t\tfor i := 3; i < 6; i++ {\n\t\t\tarr2[i-3] = int(line[i] - '0')\n\t\t\tsum2 += arr2[i-3]\n\t\t}\n\t\tif sum1 == sum2 {\n\t\t\tfmt.Printf(\"0\\n\")\n\t\t\tcontinue\n\t\t}\n\t\tif sum1 < sum2 {\n\t\t\tarr1, arr2 = arr2, arr1\n\t\t\tsum1, sum2 = sum2, sum1\n\t\t}\n\t\tdelta := sum1 - sum2\n\t\tcount := 0\n\t\tfor {\n\t\t\tsort.Sort(sort.IntSlice(arr1))\n\t\t\tsort.Sort(sort.IntSlice(arr2))\n\t\t\tcount++\n\t\t\tif arr1[2] > 9-arr2[0] {\n\t\t\t\tif arr1[2] >= delta {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdelta -= arr1[2]\n\t\t\t\tarr1[2] = 0\n\t\t\t} else {\n\t\t\t\tif 9-arr2[0] >= delta {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdelta -= (9 - arr2[0])\n\t\t\t\tarr2[0] = 9\n\t\t\t}\n\n\t\t}\n\t\tfmt.Printf(\"%d\\n\", count)\n\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "2f49f64d6069ec394a34073d1017d877", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strings\"\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tinput := strings.TrimSpace(scanner.Text())\n\n\tvalues := make([]int, len(input))\n\tfor i, a := range input {\n\t\tvalues[i] = int(a - '0')\n\t}\n\n\tfmt.Println(solver(values))\n}\n\nfunc solver(values []int) int {\n\tn := len(values) / 2\n\tvalsA := values[:n]\n\tvalsB := values[n:]\n\tsort.Ints(valsA)\n\tsort.Ints(valsB)\n\n\tsumA := sum(valsA)\n\tsumB := sum(valsB)\n\n\tif sumA == sumB {\n\t\treturn 0\n\t}\n\n\t// lets assume that sumA always bigger sumB\n\tif sumB > sumA {\n\t\tsumA, sumB = sumB, sumA\n\t\tvalsA, valsB = valsB, valsA\n\t}\n\n\td := sumA - sumB\n\tdeltaA := valsA[2]\n\tdeltaB := 9 - valsB[0]\n\n\tif d <= max(deltaA, deltaB) {\n\t\treturn 1\n\t}\n\n\tif deltaA > deltaB {\n\t\tvalsA[2] = 0\n\t} else {\n\t\tvalsB[0] = 9\n\t}\n\n\td = diff(valsA, valsB)\n\tsort.Ints(valsA)\n\tsort.Ints(valsB)\n\tdeltaA = valsA[2]\n\tdeltaB = 9 - valsB[0]\n\tif d <= max(deltaA, deltaB) {\n\t\treturn 2\n\t}\n\n\treturn 3\n}\n\nfunc sum(values []int) int {\n\tsum := 0\n\tfor i := 0; i < len(values); i++ {\n\t\tsum += values[i]\n\t}\n\treturn sum\n}\n\nfunc diff(valsA, valsB []int) int {\n\treturn sum(valsA) - sum(valsB)\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "4c3e1ca32fcf52ea71d160227736815b", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tarr1 := make([]int, 3)\n\tarr2 := make([]int, 3)\n\tfor {\n\t\tline, _, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tsum1 := 0\n\t\tfor i := 0; i < 3; i++ {\n\t\t\tarr1[i] = int(line[i] - '0')\n\t\t\tsum1 += arr1[i]\n\t\t}\n\t\tsum2 := 0\n\t\tfor i := 3; i < 6; i++ {\n\t\t\tarr2[i-3] = int(line[i] - '0')\n\t\t\tsum2 += arr2[i-3]\n\t\t}\n\t\tif sum1 == sum2 {\n\t\t\tfmt.Printf(\"0\\n\")\n\t\t\tcontinue\n\t\t}\n\t\tif sum1 < sum2 {\n\t\t\tarr1, arr2 = arr2, arr1\n\t\t\tsum1, sum2 = sum2, sum1\n\t\t}\n\t\tdelta := sum1 - sum2\n\t\tcount := 0\n\t\tfor {\n\t\t\tsort.Sort(sort.IntSlice(arr1))\n\t\t\tsort.Sort(sort.IntSlice(arr2))\n\t\t\tcount++\n\t\t\tif arr1[2] > 9-arr2[0] {\n\t\t\t\tif arr1[2] >= delta {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdelta -= arr1[2]\n\t\t\t\tarr1[2] = 0\n\t\t\t} else {\n\t\t\t\tif 9-arr2[0] >= delta {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdelta -= (9 - arr2[0])\n\t\t\t\tarr2[0] = 9\n\t\t\t}\n\n\t\t}\n\t\tfmt.Printf(\"%d\\n\", count)\n\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "40520da20785180fba9ddd73db48ffaa", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a,b string\n\tfmt.Scanf(\"%s %s\\n\",&a,&b)\n\tif a == b{\n\t\tfmt.Println(a)\n\t}else {\n\t\tfmt.Println(1)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "fac99e5a3f8b9193493940f4d18d345d", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar a string\n\tvar b string\n\tfmt.Scan(&a,&b)\n\tif a==b{\n\t\tfmt.Print(a)\n\t}else{\n\t\tfmt.Print(1)\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "88c78e29bc2cb160b332b01e35ae7b59", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var one, two string \n fmt.Scan(&one, &two)\n if one == two {\n fmt.Println(one)\n } else {\n fmt.Println(1)\n }\n}", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "fedd5c7689087a20a2179145c6b29969", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, t int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &n, &t)\n\tcount := 0\n\ttime := 240 - t\n\tfor i := 1; i <= n && time >= 0; i++ {\n\t\ttime = time - 5*i\n\t\tif time >= 0 {\n\t\t\tcount++\n\t\t}\n\t}\n\tfmt.Println(count)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "6e9d5b518b0550d893327fbf6217f265", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\n\nfunc main(){\n defer writer.Flush()\n\n var a, b int\n scanf(\"%d %d\\n\", &a, &b)\n\n timeLeft := 240 - b\n ttime:=0\n i:=1\n j:=0\n\n p:=1\n\n for a > j{\n ttime = 5*i + ttime\n\n if(ttime<=timeLeft){\n\n\n p++;\n }\n j++\n i++\n }\n\n\n printf(\"%d\\n\", p-1)\n\n}\n\n\n\n\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "b84271602c765b067e2f7049957fed11", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nconst maxTime int = 240\nconst solvingTime int = 5\n\nfunc main() {\n\tvar problems, timeToParty, timeToSolve, answer int\n\tfmt.Scanln(&problems, &timeToParty)\n\n\tfor i := 1; i <= problems; i++ {\n\t\ttimeToSolve += solvingTime * i\n\t\ttimeToDoEverything := maxTime - timeToSolve - timeToParty\n\t\t\n\t\tif timeToDoEverything >= 0 {\n\t\t\tanswer++\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfmt.Println(answer)\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "b2f8d246696f41e202fbff228ef447a9", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport.\"fmt\"\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar n int64\n\tScan(&n)\n\tif n&1 == 0 {\n\t\tPrint(n/2)\n\t\treturn\n\t}\n\tfor i := int64(2); i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\tPrint(1 + (n-i)/2)\n\t\t\treturn\n\t\t}\n\t}\n\tPrint(1)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "0e707921f26887edae02911ba80b7819", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\ta := int64(0)\n\tfmt.Fscanf(in, \"%d\\n\", &a)\n\ti := int64(2)\n\tfor i = 2; i*i <= a; i++ {\n\t\tif a%int64(i) == 0 {\n\t\t\tfmt.Fprintf(out, \"%d\\n\", (a-int64(i))/2+1)\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", 1)\n\treturn\n}", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "2dd562ab4031e4d6b2056a32c3438da2", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar n int64\n\n\tfmt.Scanf(\"%d\", &n);\n\n\tprimo := true\n\n\tresp := int64(0)\n\n\tfor i := int64(2); i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\tresp++\n\t\t\tn -= i\n\t\t\tprimo = false\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif primo {\n\t\tfmt.Printf(\"%d\\n\", 1)\n\t} else {\n\t\tfmt.Printf(\"%d\\n\", resp + n/2)\n\t}\n\n}", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "c8ac78fd961bad389cacda9b6a6d9f77", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF582B(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n, t, d int\n\tFscan(in, &n, &t)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tdp := []int{}\n\tfor i := 0; i < 110 && t > 0; i++ {\n\t\tt--\n\t\tcur := len(dp)\n\t\tfor _, v := range a {\n\t\t\tif p := sort.SearchInts(dp, v+1); p < len(dp) {\n\t\t\t\tdp[p] = v\n\t\t\t} else {\n\t\t\t\tdp = append(dp, v)\n\t\t\t}\n\t\t}\n\t\td = len(dp) - cur\n\t\tcur = len(dp)\n\t}\n\tif t == 0 {\n\t\tFprint(out, len(dp))\n\t\treturn\n\t}\n\tFprintln(out, len(dp)+t*d)\n}\n\nfunc main() { CF582B(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["matrices", "dp", "constructive algorithms"], "code_uid": "81ab95f850151c55d99c52522a1bc5d3", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF582B(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n, t, d int\n\tFscan(in, &n, &t)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tdp := []int{}\n\tfor i := 0; i < 310 && t > 0; i++ {\n\t\tt--\n\t\tcur := len(dp)\n\t\tfor _, v := range a {\n\t\t\tif p := sort.SearchInts(dp, v+1); p < len(dp) {\n\t\t\t\tdp[p] = v\n\t\t\t} else {\n\t\t\t\tdp = append(dp, v)\n\t\t\t}\n\t\t}\n\t\td = len(dp) - cur\n\t\tcur = len(dp)\n\t}\n\tif t == 0 {\n\t\tFprint(out, len(dp))\n\t\treturn\n\t}\n\tFprintln(out, len(dp)+t*d)\n}\n\nfunc main() { CF582B(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["matrices", "dp", "constructive algorithms"], "code_uid": "2e64efd6c260d0d540ff8b22cc191d91", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF582B(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n, t, d int\n\tFscan(in, &n, &t)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tdp := []int{}\n\tfor i := 0; i < n+10 && t > 0; i++ {\n\t\tt--\n\t\tcur := len(dp)\n\t\tfor _, v := range a {\n\t\t\tif p := sort.SearchInts(dp, v+1); p < len(dp) {\n\t\t\t\tdp[p] = v\n\t\t\t} else {\n\t\t\t\tdp = append(dp, v)\n\t\t\t}\n\t\t}\n\t\td = len(dp) - cur\n\t\tcur = len(dp)\n\t}\n\tif t == 0 {\n\t\tFprint(out, len(dp))\n\t\treturn\n\t}\n\tFprintln(out, len(dp)+t*d)\n}\n\nfunc main() { CF582B(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["matrices", "dp", "constructive algorithms"], "code_uid": "6652aa5cc5c4615a04ddff6c1104ac9e", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 62A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, d int\n\tfmt.Scan(&a, &b, &c, &d)\n\tif (a*2+3 > d && d+1 >= a) || (b*2+3 > c && c+1 >= b) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "36666d432b44235b50aa9194391841e2", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n\tvar A[4] int\n\t\tfmt.Scan(&A[0], &A[1], &A[3], &A[2])\n\tfor i:=0; i<2; i++{\n\t\t if A[i]-1<=A[i+2]&&2*A[i]+2>=A[i+2] {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "e2185321a6b6228ad37410fe8ea01324", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar al, ar int\n\tvar bl, br int\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tal, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tar, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tbl, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tbr, _ = strconv.Atoi(r.Text())\n\tif al == br || ar == bl {\n\t\tw.WriteString(\"YES\\n\")\n\t\tw.Flush()\n\t\treturn\n\t} \n\tif br > al {\n\t\tif 2*al+2 >= br {\n\t\t\tw.WriteString(\"YES\\n\")\n\t\t\tw.Flush()\n\t\t\treturn\n\t\t} \n\t} \n\tif bl > ar {\n\t\tif 2*ar+2 >= bl {\n\t\t\tw.WriteString(\"YES\\n\")\n\t\t\tw.Flush()\n\t\t\treturn\n\t\t}\n\t} \n\tif al > br {\n\t\tif al-br == 1 {\n\t\t\tw.WriteString(\"YES\\n\")\n\t\t\tw.Flush()\n\t\t\treturn\n\t\t} \n\t}\n\tif ar > bl {\n\t\tif ar-bl == 1 {\n\t\t\tw.WriteString(\"YES\\n\")\n\t\t\tw.Flush()\n\t\t\treturn\n\t\t} \n\t} \n\tw.WriteString(\"NO\\n\")\n\tw.Flush()\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "837bef75ac2a4fc7f9cb1570d99908b9", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tsum := 0\n\tw := make([]int, 7)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; i < 7 && scanner.Scan(); i++ {\n\t\ta, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tw[i] = a\n\t\tsum += a\n\t}\n\n\tn = n % sum\n\tif n == 0 {\n\t\tfor i := 6; i >= 0; i-- {\n\t\t\tif w[i] != 0 {\n\t\t\t\tfmt.Println(i + 1)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 7; i++ {\n\t\tn -= w[i]\n\t\tif n <= 0 {\n\t\t\tfmt.Println(i + 1)\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "160cd33c23ad71fed5b2061d0fb0c70d", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var a [7]int\n fmt.Scan(&n)\n total := 0\n for i := 0; i < 7; i++ {\n fmt.Scan(&a[i])\n total += a[i]\n }\n n %= total\n ans := 0\n if n == 0 {\n ans = 6\n for ; ans >= 0; ans-- {\n if a[ans] > 0 {\n break\n }\n }\n } else {\n for n > a[ans] {\n n -= a[ans]\n ans++\n }\n }\n fmt.Println(ans+1)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0ca478df1cf6801ac06971cd16981974", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var a [7]int\n fmt.Scan(&n)\n total := 0\n for i := 0; i < 7; i++ {\n fmt.Scan(&a[i])\n total += a[i]\n }\n n %= total\n ans := 0\n if n == 0 {\n ans = 6\n for ; ans >= 0; ans-- {\n if a[ans] > 0 {\n break\n }\n }\n } else {\n for n > a[ans] {\n n -= a[ans]\n ans++\n }\n }\n fmt.Println(ans+1)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "1cf4dea505d6d042109f7d70485b5a70", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\n\tres := int64(6)\n\tp := int64(4)\n\tfor i := 2; i <= n; i++ {\n\t\tp = p * p\n\t\tp %= 1000000007\n\t\tres *= p\n\t\tres %= 1000000007\n\t}\n\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "c305d121bba955428657f57be1888715", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nfunc main() {\r\n\tin := bufio.NewReader(os.Stdin)\r\n\t//out := bufio.NewWriter(os.Stdout)\r\n\tvar k int\r\n\tmod := int64(1000000007)\r\n\tfmt.Fscanf(in, \"%d\\n\", &k)\r\n\tans := int64(1)\r\n\tfor i := 1;i < k;i++{\r\n\t\tans = (16*((ans*ans)%mod))%mod\r\n\t}\r\n\tfmt.Printf(\"%v\\n\",(6*ans)%mod)\r\n\r\n}", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "4f4a88d5258c08e5909b23e6ab850be2", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc power(exp int64) int64 {\n\tif exp == 0 {\n\t\treturn 1\n\t}\n\tif exp == 1 {\n\t\treturn 2\n\t}\n\tvar result int64 = 1\n\tif exp%2 == 1 {\n\t\tresult = 2\n\t}\n\tp := power(exp / 2)\n\tresult = (result * p * p) % 1000000007\n\treturn result\n}\n\nfunc main() {\n\tvar k int\n\tfmt.Scan(&k)\n\tanswer := (6 * power((1<<(k+1))-4)) % 1000000007\n\tfmt.Println(answer)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "6ae07597b600642e936c1105de4cb6e2", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n)\n \nfunc main() {\n\n\t//stdin, err := os.Open(\"in.txt\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdin.Close()\n\tstdin := os.Stdin\n\treader := bufio.NewReaderSize(stdin, 1024*1024)\n\n\tvar b, g, n, resp int\n\tfmt.Fscanf(reader, \"%d\\n\", &b);\n\tfmt.Fscanf(reader, \"%d\\n\", &g);\n\tfmt.Fscanf(reader, \"%d\\n\", &n);\n\n\tfor i := 0; i <= n; i++ {\n\t\tbb, gg := i, n - i\n\t\tif bb > b || gg > g {\n\n\t\t} else {\n\t\t\tresp++\n\t\t}\n\t}\n\n\tfmt.Println(resp)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "a1f17929e2180413cd05699e03530db8", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//HOWDY! IT'S ME! A HARD BLACKISH DICK MOVE!\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := PrintlnInts(X...)\n\n/*******************************************************************/\n\nfunc main() {\n\tb := ReadInt()\n\tg := ReadInt()\n\tn := ReadInt()\n\tans := 0\n\tfor i, j := 0, n; i <= n; {\n\t\tif i <= b && j <= g {\n\t\t\tans++\n\t\t}\n\t\ti++\n\t\tj--\n\t}\n\tfmt.Println(ans)\n}\n\n/*********** Math ***********/\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(args ...int) int {\n\tif len(args) == 0 {\n\t\tpanic(\"empty!\")\n\t}\n\tmin := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] < min {\n\t\t\tmin = args[i]\n\t\t}\n\t}\n\treturn min\n}\n\nfunc max(args ...int) int {\n\tif len(args) == 0 {\n\t\tpanic(\"empty!\")\n\t}\n\tmax := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] > max {\n\t\t\tmax = args[i]\n\t\t}\n\t}\n\treturn max\n}\n\nfunc _gcd(a, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn _gcd(b, a%b)\n}\n\nfunc gcd(args ...int) int {\n\tif len(args) == 0 {\n\t\tpanic(\"empty!\")\n\t}\n\tgcd := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tgcd = _gcd(gcd, args[i])\n\t}\n\treturn gcd\n}\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9))\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn readInt()\n}\nfunc ReadInt2() (int, int) {\n\treturn readInt(), readInt()\n}\nfunc ReadInt3() (int, int, int) {\n\treturn readInt(), readInt(), readInt()\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn readInt(), readInt(), readInt(), readInt()\n}\n\nfunc readInt_64() int64 {\n\treturn readIntNbits(64)\n}\n\nfunc ReadInt2_64() (int64, int64) {\n\treturn readInt_64(), readInt_64()\n}\n\nfunc ReadInt3_64() (int64, int64, int64) {\n\treturn readInt_64(), readInt_64(), readInt_64()\n}\n\nfunc readInt() int {\n\treturn int(readIntNbits(32))\n}\n\nfunc readIntNbits(n int) int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, n)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintlnInts(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "946030f7c659edde45967b3af8459ffc", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar b, g, n int\n\tfmt.Scan(&b, &g, &n)\n\tans := 0\n\tfor i := 0; i <= n; i++ {\n\t\tif i <= b && n-i <= g {\n\t\t\tans++\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "48c1ead52a1be8116b0cc59c6dd09495", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\nconst(\n mod int64 = 1e9 + 7\n L int64 = 840\n N int64 = 9\n)\nvar dp [N][N * L]int64\nvar can [N]int64\nfunc min(a, b int64) int64 {\n if(a <= b) {\n return a\n }\n return b\n}\nfunc max(a, b int64) int64 {\n if(a >= b) {\n return a\n }\n return b\n}\nfunc fun(idx, lft int64) int64 {\n if idx == N {\n if lft == 0 {\n return 0\n }else{\n return -1e16\n }\n }\n if dp[idx][lft] != -1e18 {\n return dp[idx][lft]\n }\n dp[idx][lft] = -1e16\n for i := int64(0); i < (L / idx) && i <= can[idx] && i * idx <= lft; i++ {\n dp[idx][lft] = max(dp[idx][lft], ((can[idx] - i) / (L / idx) + fun(idx + 1, lft - i * idx)))\n }\n return dp[idx][lft]\n}\nfunc main() {\n in := bufio.NewReader(os.Stdin)\n var W int64\n for i := int64(0); i < N; i++ {\n for j := int64(0); j < L * N; j++ {\n dp[i][j] = -1e18\n }\n }\n fmt.Fscan(in, &W)\n for i := int64(1); i <= 8; i++ {\n fmt.Fscan(in, &can[i])\n }\n ans := int64(0)\n for i := int64(0); i < L * N && i <= W; i++ {\n if fun(1, i) >= 0 {\n ans = max(ans, i + min((W - i) / L , fun(1, i)) * L)\n }\n }\n fmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["dfs and similar", "greedy", "dp"], "code_uid": "4656cfae2c07acc3858ea156941d491c", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar n1, n2, k1, k2 int\nvar line [101][101][11][11]int\n\nfunc init() {\n for a, line1 := range line {\n for b, line2 := range line1 {\n for c, line3 := range line2 {\n for d, _ := range line3 {\n line[a][b][c][d] = -1\n }\n }\n }\n }\n}\n\nfunc lineup(n3 int, n4 int, k3 int, k4 int) int {\n if n3 < 0 || n4 < 0 || k3 > k1 || k4 > k2 {\n return 0\n }\n \n if n3 == 0 && n4 == 0 {\n return 1\n }\n \n if line[n3][n4][k3][k4] != -1 {\n return line[n3][n4][k3][k4]\n }\n \n line[n3][n4][k3][k4] = ((lineup(n3-1, n4, k3+1, 0) + lineup(n3, n4-1, 0, k4+1)) % 100000000)\n return line[n3][n4][k3][k4]\n} \n \nfunc main() {\n fmt.Scanf(\"%d %d %d %d\", &n1, &n2, &k1, &k2)\n fmt.Printf(\"%d\\n\", lineup(n1, n2, 0, 0))\n} ", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "9610ba6ba361174e655053675b6dad00", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/118/D\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst Mod = 100000000\n\nfunc Solve(n1, n2, k1, k2 int) int {\n\tdp := [101][101][2]int{}\n\tdp[0][0][0] = 1\n\tdp[0][0][1] = 1\n\tfor i := 0; i <= n1; i++ {\n\t\tfor j := 0; j <= n2; j++ {\n\t\t\tfor k := 1; k <= k1 && k <= i; k++ {\n\t\t\t\tdp[i][j][0] = (dp[i][j][0] + dp[i-k][j][1]) % Mod\n\t\t\t}\n\t\t\tfor k := 1; k <= k2 && k <= j; k++ {\n\t\t\t\tdp[i][j][1] = (dp[i][j][1] + dp[i][j-k][0]) % Mod\n\t\t\t}\n\t\t}\n\t}\n\treturn (dp[n1][n2][0] + dp[n1][n2][1]) % Mod\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n1, n2, k1, k2 int\n\tfmt.Fscanf(reader, \"%d %d %d %d\\n\", &n1, &n2, &k1, &k2)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n1, n2, k1, k2))\n}\n", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "43b731b16171c25a50af3abc7b8dd145", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol118D(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n1, n2, k1, k2 int\n\tFscan(in, &n1, &n2, &k1, &k2)\n\n\tconst mod = 1e8\n\tcache := make(map[string]int, 3e5)\n\tvar f func(left1, left2, c1, c2 int) int\n\tf = func(left1, left2, c1, c2 int) (sum int) {\n\t\tif left1 == 0 {\n\t\t\tif left2+c2 <= k2 {\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\treturn 0\n\t\t}\n\t\tif left2 == 0 {\n\t\t\tif left1+c1 <= k1 {\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\treturn 0\n\t\t}\n\t\thash := Sprintf(\"%d;%d;%d;%d\", left1, left2, c1, c2)\n\t\tif val, ok := cache[hash]; ok {\n\t\t\treturn val\n\t\t}\n\t\tif c1 < k1 {\n\t\t\tsum += f(left1-1, left2, c1+1, 0)\n\t\t}\n\t\tif c2 < k2 {\n\t\t\tsum += f(left1, left2-1, 0, c2+1)\n\t\t}\n\t\tsum %= mod\n\t\tcache[hash] = sum\n\t\treturn\n\t}\n\tFprintln(out, f(n1, n2, 0, 0))\n}\n\nfunc main() {\n\tSol118D(os.Stdin, os.Stdout)\n}\n", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "d8be2573995353a6d3a9a95d853a01e4", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/431/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst M = 1000000007\n\nfunc Count(x, y int) int {\n\tdp := make([]int, x+1)\n\tdp[0] = 1\n\tfor i := 1; i <= x; i++ {\n\t\tfor j := 1; j <= y; j++ {\n\t\t\tif i-j >= 0 {\n\t\t\t\tdp[i] = (dp[i] + dp[i-j]) % M\n\t\t\t}\n\t\t}\n\t}\n\treturn dp[x]\n}\n\nfunc Solve(n, k, d int) int {\n\treturn (Count(n, k) - Count(n, d-1) + M) % M\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n, k, d int\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &n, &k, &d)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, k, d))\n}\n", "lang_cluster": "Go", "tags": ["dp", "implementation", "trees"], "code_uid": "9cd0fa554dd71a8b477e1006569a74ad", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nfunc readInt() int64 {\n\tvar o, neg bool\n\tvar i int64\n\tb, err := r.ReadByte()\n\tfor err == nil {\n\t\tif b != ' ' && b != '\\n' && b != '\\r' {\n\t\t\tif b == '-' {\n\t\t\t\tneg = true\n\t\t\t} else {\n\t\t\t\ti = i*10 + int64(b) - 48\n\t\t\t\to = true\n\t\t\t}\n\t\t} else if o {\n\t\t\tbreak\n\t\t}\n\t\tb, err = r.ReadByte()\n\t}\n\tif neg {\n\t\treturn -i\n\t}\n\treturn i\n}\n\nfunc writeInt(i int64) {\n\tif i < 0 {\n\t\tw.WriteByte('-')\n\t\ti = -i\n\t}\n\tif i < 10 {\n\t\tw.WriteByte(byte(i + 48))\n\t\treturn\n\t}\n\tvar tmp, count int64\n\ttmp = i\n\tfor tmp%10 == 0 {\n\t\ttmp /= 10\n\t\tcount++\n\t}\n\ttmp = 0\n\tfor i != 0 {\n\t\ttmp = tmp*10 + (i % 10)\n\t\ti /= 10\n\t}\n\tfor tmp != 0 {\n\t\tw.WriteByte(byte((tmp % 10) + 48))\n\t\ttmp /= 10\n\t}\n\tfor count > 0 {\n\t\tcount--\n\t\tw.WriteByte('0')\n\t}\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tfor I(&n) == nil {\n\t\tsolve(n)\n\t}\n\tw.Flush()\n}\n\nconst mod = 1e9 + 7\n\nvar n, k, d int64\nvar visited []bool\nvar dp [][2]int64\n\nfunc solve(n int64) {\n\tk, d = readInt(), readInt()\n\tvisited, dp = make([]bool, n+1), make([][2]int64, n+1)\n\tdp[0][0] = 1\n\tO(do(n, 1), \"\\n\")\n}\n\nfunc do(n, contains int64) int64 {\n\tif visited[n] {\n\t\treturn dp[n][contains]\n\t}\n\tvisited[n] = true\n\tfor i := int64(1); i <= k && i <= n; i++ {\n\t\tif i < d {\n\t\t\tdp[n][0] += do(n-i, 0)\n\t\t} else {\n\t\t\tdp[n][1] += do(n-i, 0)\n\t\t}\n\t\tdp[n][1] += do(n-i, 1)\n\t\tdp[n][0] %= mod\n\t\tdp[n][1] %= mod\n\t}\n\treturn dp[n][contains]\n}\n", "lang_cluster": "Go", "tags": ["dp", "implementation", "trees"], "code_uid": "e915321bc4d1dfc7a8c35d143948b2f0", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol431C(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tconst mod = 1e9 + 7\n\tvar n, k, d int\n\tFscan(in, &n, &k, &d)\n\tdp := make([][2]int, n)\n\tfor i := range dp {\n\t\tdp[i][0] = -1\n\t\tdp[i][1] = -1\n\t}\n\tvar f func(int, int) int\n\tf = func(sum int, contain int) int {\n\t\tif sum == n {\n\t\t\treturn 1\n\t\t}\n\t\tif contain == 0 && sum+d > n {\n\t\t\treturn 0\n\t\t}\n\t\tif v := dp[sum][contain]; v != -1 {\n\t\t\treturn v\n\t\t}\n\t\tans := 0\n\t\tif contain == 0 {\n\t\t\tfor i := 1; i < d; i++ {\n\t\t\t\tif sum+i > n {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tans = (ans + f(sum+i, 0)) % mod\n\t\t\t}\n\t\t\tfor i := d; i <= k; i++ {\n\t\t\t\tif sum+i > n {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tans = (ans + f(sum+i, 1)) % mod\n\t\t\t}\n\t\t} else {\n\t\t\tfor i := 1; i <= k; i++ {\n\t\t\t\tif sum+i > n {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tans = (ans + f(sum+i, 1)) % mod\n\t\t\t}\n\t\t}\n\t\tdp[sum][contain] = ans\n\t\treturn ans\n\t}\n\tFprint(out, f(0, 0))\n}\n\nfunc main() {\n\tSol431C(os.Stdin, os.Stdout)\n}\n", "lang_cluster": "Go", "tags": ["dp", "implementation", "trees"], "code_uid": "1b945d1af347dd4afc1a823d607b8c33", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nfunc readInt() int {\n\tvar o, neg bool\n\tvar i int\n\tb, err := r.ReadByte()\n\tfor err == nil {\n\t\tif b != ' ' && b != '\\n' && b != '\\r' {\n\t\t\tif b == '-' {\n\t\t\t\tneg = true\n\t\t\t} else {\n\t\t\t\ti = i*10 + int(b) - 48\n\t\t\t\to = true\n\t\t\t}\n\t\t} else if o {\n\t\t\tbreak\n\t\t}\n\t\tb, err = r.ReadByte()\n\t}\n\tif neg {\n\t\treturn -i\n\t}\n\treturn i\n}\n\nfunc writeInt(i int) {\n\tif i < 0 {\n\t\tw.WriteByte('-')\n\t\ti = -i\n\t}\n\tif i < 10 {\n\t\tw.WriteByte(byte(i + 48))\n\t\treturn\n\t}\n\tvar tmp, count int\n\ttmp = i\n\tfor tmp%10 == 0 {\n\t\ttmp /= 10\n\t\tcount++\n\t}\n\ttmp = 0\n\tfor i != 0 {\n\t\ttmp = tmp*10 + (i % 10)\n\t\ti /= 10\n\t}\n\tfor tmp != 0 {\n\t\tw.WriteByte(byte((tmp % 10) + 48))\n\t\ttmp /= 10\n\t}\n\tfor count > 0 {\n\t\tcount--\n\t\tw.WriteByte('0')\n\t}\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tfor I(&n) == nil {\n\t\tsolve(n)\n\t}\n\tw.Flush()\n}\n\nconst mod = 1e9 + 7\n\nvar n, k, d int\nvar visited []bool\nvar dp [][2]int\n\nfunc solve(n int) {\n\tk, d = readInt(), readInt()\n\tvisited, dp = make([]bool, n+1), make([][2]int, n+1)\n\tdp[0][0] = 1\n\tO(do(n, 1), \"\\n\")\n}\n\nfunc do(n, contains int) int {\n\tif visited[n] {\n\t\treturn dp[n][contains]\n\t}\n\tvisited[n] = true\n\tfor i := 1; i <= k && i <= n; i++ {\n\t\tif i < d {\n\t\t\tdp[n][0] += do(n-i, 0)\n\t\t\tdp[n][0] %= mod\n\t\t} else {\n\t\t\tdp[n][1] += do(n-i, 0)\n\t\t\tdp[n][1] %= mod\n\t\t}\n\t\tdp[n][1] += do(n-i, 1)\n\t\tdp[n][1] %= mod\n\t}\n\treturn dp[n][contains]\n}\n", "lang_cluster": "Go", "tags": ["dp", "implementation", "trees"], "code_uid": "4c25a4a9f7801082edfd309b2b10addd", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 431C\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a [101][2]int64\n\tvar n, d, m, i, j int64\n\tfmt.Scan(&n, &d, &m)\n\ta[0][0] = 1\n\tfor i = 1; i <= n; i++ {\n\t\tfor j = 1; j <= d && j <= i; j++ {\n\t\t\ta[i][0] += a[i-j][0]\n\t\t\tif j >= m {\n\t\t\t\ta[i][1] += a[i-j][0]\n\t\t\t} else {\n\t\t\t\ta[i][1] += a[i-j][1]\n\t\t\t}\n\t\t\ta[i][1] %= 1000000007\n\t\t\ta[i][0] %= 1000000007\n\t\t}\n\t}\n\tfmt.Println(a[n][1])\n}\n", "lang_cluster": "Go", "tags": ["dp", "implementation", "trees"], "code_uid": "0eecbbe53b24c758fb8737da08da1f4c", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nconst mod = 1000000007\n\nfunc main() {\n var n, k, d int\n fmt.Scanf(\"%d%d%d\\n\",&n,&k,&d)\n a := make([]int, n+1)\n b := make([]int, n+1)\n b[0] = 1\n for i := 1; i <= n; i++ {\n for j := 1; j <= k && j <= i; j++ {\n a[i] += a[i - j]\n if a[i] >= mod {\n a[i] -= mod\n }\n }\n for j := 1; j < d && j <= k && j <= i; j++ {\n b[i] += b[i - j]\n if b[i] >= mod {\n b[i] -= mod\n }\n }\n for j := d; j <= k && j <= i; j++ {\n a[i] += b[i - j]\n if a[i] >= mod {\n a[i] -= mod\n }\n }\n }\n fmt.Println(a[n] % mod)\n}\n", "lang_cluster": "Go", "tags": ["dp", "implementation", "trees"], "code_uid": "81c477a119225347e4baa7fb2fc02f3a", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar n int\nvar x int\nvar temp int\nvar a [101]int\n\nfunc main() {\n fmt.Scan(&n, &x)\n cnt := 0\n for i := 0; i < n; i++ {\n fmt.Scan(&temp)\n a[temp] = 1\n }\n for i := 0; i <= 100; i++ {\n if i == x {\n if a[i] == 1 {\n cnt++\n }\n break\n } else {\n if a[i] == 0 {\n cnt++\n }\n }\n }\n fmt.Println(cnt)\n}", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "a3d9899df3bec412140d9ff644943d35", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n)\n\nfunc init() {\n\tlog.SetFlags(0)\n}\n\nfunc main() {\n\tvar flag bool\n\tvar n, x, mark int\n\tfmt.Scanf(\"%d %d\\n\", &n, &x)\n\tarr := make([]int, x)\n\tfor i := range arr {\n\t\tarr[i] = i\n\t}\n\tfor i, tmp := 0, 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &tmp)\n\t\tif tmp < x {\n\t\t\tfor j, val := range arr {\n\t\t\t\tif tmp == val {\n\t\t\t\t\tmark = j\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tarr = arr[:mark+copy(arr[mark:], arr[mark+1:])]\n\t\t} else if tmp == x {\n\t\t\tflag = true\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(len(arr) + 1)\n\t} else {\n\t\tfmt.Println(len(arr))\n\t}\n}", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "d1b0178913d7ac178af3a5b247fb868b", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, x, a, i, c, r int8\n\tfmt.Scanf(\"%d %d\\n\", &n, &x)\n\tfor i = 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a)\n\t\tif a < x {\n\t\t\tr++\n\t\t} else if a == x {\n\t\t\tc++\n\t\t}\n\t}\n\tfmt.Println(c + (x - r))\n}\n\n\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "d83b109b5891f5c0eb85aefd54a84739", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\ts := \"\"\n\tfmt.Scan(&s)\n\tn := strings.Count(s, \"-\")\n\tb := strings.Count(s, \"o\")\n\tif b == 0 || n%b == 0 {\n\t\tfmt.Printf(\"YES\\n\")\n\t} else {\n\t\tfmt.Printf(\"NO\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c65dfd5c2b3c41ee311092f32675ec9a", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n\nfunc main() {\n\tdefer Flush()\n\n\ts := reads()\n\tss := strings.Split(s, \"o\")\n\ta := make([]int, len(ss))\n\tfor i := range a {\n\t\ta[i] = len(ss[i])\n\t}\n\teprintln(a)\n\tif 1 < len(a) {\n\t\tk := len(a) - 1\n\t\ta[0] += a[k]\n\t\ta = a[:k]\n\t}\n\teprintln(a)\n\tvar sum int\n\tfor _, v := range a {\n\t\tsum += v\n\t}\n\tif sum == 0 || sum%len(a) == 0 {\n\t\tprintln(\"YES\")\n\t} else {\n\t\tprintln(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c1ce3c53422854e0832fa159038d05f5", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar line string\n\tfmt.Scan(&line)\n\n\telems := []rune(line)\n\n\tcountFibres, countBeads := 0, 0\n\tfor i := 0; i < len(elems); i++ {\n\t\tif elems[i] == '-' {\n\t\t\tcountFibres++\n\t\t} else {\n\t\t\tcountBeads++\n\t\t}\n\t}\n\n\tif countBeads == 0 || countFibres % countBeads == 0 {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "3d7ce72887d0bf823bb848c6700f8fcf", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\ta, b, c := 0, 0, 0\n\tfmt.Scan(&a, &b, &c)\n\td := []int{a, b, c}\n\tsort.Ints(d)\n\tif (d[2] + 1) <= (d[1] + d[0]) {\n\t\tfmt.Println(0)\n\t\tos.Exit(0)\n\t}\n\tfmt.Println((d[2] + 1) - (d[1] + d[0]))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "0a1830896361211b9bf24c13417ed3ea", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport(\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n\t\"strings\"\n\t\"strconv\"\n)\n\n\nfunc triago(a int, b int, c int) int {\n\tif (a +b > c) && (b+c >a) && (c+a >b) {\n\t\n\t\treturn 0\n\t} \n\t\tswitch {\n\t\tcase b >= (c+a):\n\t\t\n\t\t\treturn b-c-a + 1\n\t\tcase c >= (b+a):\n\t\t\n\t\t\treturn c - b- a + 1\n\t\tcase a >= (c+b):\n\t\t\n\t\t\treturn a - c- b + 1\n\t\t}\n\t\n\treturn 0\n}\n\nfunc main() {\n\tarray := []int{}\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\thand := strings.Split(text,\" \")\n\tfor _,val := range(hand) {\n\t\ttext = strings.TrimRight(val,\"\\r\\n\")\n\t\tl,_ := strconv.Atoi(text)\n\t\tarray = append(array,l)\n\t}\n\tfmt.Println(triago(array[0],array[1],array[2]))\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "36ad1f576e140456c22e36e15860c5cc", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b, c int\n fmt.Scanf(\"%d %d %d\\n\", &a, &b, &c)\n\n if a >= (b + c) {\n fmt.Printf(\"%d\\n\", a + 1 - (b+c))\n return\n } else if b >= (a + c) {\n fmt.Printf(\"%d\\n\", b + 1 - (a + c))\n return\n } else if c >= (a + b) {\n fmt.Printf(\"%d\\n\", c + 1 - (a + b))\n return\n }\n\n fmt.Printf(\"%d\\n\", 0)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "1a86af6329563738833f2c46d4bede37", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var (\n n int\n m int\n )\n fmt.Scan(&n)\n fmt.Scan(&m)\n\n a := m - 1\n if a < n - m {\n a = m + 1\n }\n if a == 0 {\n a = m\n }\n fmt.Println(a)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "498bbdb374c36ca6c36ef88a4160c822", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport \"fmt\"\n\n\nfunc main() {\n\tvar n,m int;\n\t_,_ = fmt.Scanf(\"%d %d\",&n,&m)\n\tvar u = n-m;\n\tvar l = m-1;\n\tif u==0 && l==0{\n\t\tfmt.Println(m)\n\t}else if(u > l){\n\t\tfmt.Println(m+1)\n\t}else{\n\t\tfmt.Println(m-1)\n\t}\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "22f86c6b73a2e614d38feda219c0ea12", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\ntype Int int64\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n, m Int\n\tfor I(&n, &m) == nil {\n\t\tsolve(n, m)\n\t}\n}\n\nfunc solve(n, m Int) {\n\tvar ans Int\n\tif n == Int(1) {\n\t\tans = 1\n\t} else if m-1 >= n-m {\n\t\tans = m - 1\n\t} else {\n\t\tans = m + 1\n\t}\n\tO(ans, \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "0825ec6e37292e44dfc876ad2ea59ebf", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nfunc readInt() int {\n\tvar o, neg bool\n\tvar i int\n\tb, err := r.ReadByte()\n\tfor err == nil {\n\t\tif b != ' ' && b != '\\n' && b != '\\r' {\n\t\t\tif b == '-' {\n\t\t\t\tneg = true\n\t\t\t} else {\n\t\t\t\ti = i*10 + int(b) - 48\n\t\t\t\to = true\n\t\t\t}\n\t\t} else if o {\n\t\t\tbreak\n\t\t}\n\t\tb, err = r.ReadByte()\n\t}\n\tif neg {\n\t\treturn -i\n\t}\n\treturn i\n}\n\nfunc writeInt(i int) {\n\tif i < 0 {\n\t\tw.WriteByte('-')\n\t\ti = -i\n\t}\n\tif i < 10 {\n\t\tw.WriteByte(byte(i + 48))\n\t\treturn\n\t}\n\tvar tmp, count int\n\ttmp = i\n\tfor tmp%10 == 0 {\n\t\ttmp /= 10\n\t\tcount++\n\t}\n\ttmp = 0\n\tfor i != 0 {\n\t\ttmp = tmp*10 + (i % 10)\n\t\ti /= 10\n\t}\n\tfor tmp != 0 {\n\t\tw.WriteByte(byte((tmp % 10) + 48))\n\t\ttmp /= 10\n\t}\n\tfor count > 0 {\n\t\tcount--\n\t\tw.WriteByte('0')\n\t}\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tvar s string\n\tfor I(&s) == nil {\n\t\tsolve(s)\n\t}\n\tw.Flush()\n}\n\nfunc solve(s string) {\n\tfor i := range s {\n\t\tif s[i] == '1' && strings.Count(s[i:], \"0\") > 5 {\n\t\t\tO(\"yes\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\tO(\"no\\n\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4229bf14275e7e1e28bedac0ceaefe1d", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\nimport \"bufio\"\n\nvar s string\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &s)\n\ti := 0\n\tzero := 0\n\n\tfor i < len(s) {\n\t\tif s[i] == '1' { break }\n\t\ti++\n\t}\n\n\tfor i < len(s) {\n\t\tif s[i] == '0' {\n\t\t\tzero++\n\t\t}\n\t\ti++\n\t}\n\n\tif zero > 5 {\n\t\tfmt.Printf(\"yes\")\n\t\tos.Exit(0)\n\t}\n\tfmt.Printf(\"no\")\n}\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "08b96499ec7c16ea956cfe8987322886", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tstr string\n\t\tcnt int\n\t)\n\tfound := false\n\tfmt.Scanf(\"%s\", &str)\n\tfor i := range str {\n\t\tif str[i] == '1' {\n\t\t\tfound = true\n\t\t} else if str[i] == '0' && found {\n\t\t\tcnt++\n\t\t}\n\t}\n\tif cnt >= 6 {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "654965ba276b6d947cf0976a008786cd", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc min(i, j int64) int64 {\n\tif i < j {\n\t\treturn i\n\t}\n\treturn j\n}\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scan(&n, &k)\n\tvar c = make([]int64, n)\n\tfor i := range c {\n\t\tfmt.Scan(&c[i])\n\t}\n\n\tfor i := 1; int64(i) < n; i++ {\n\t\tif c[i] > c[i-1]*2 {\n\t\t\tc[i] = 2 * c[i-1]\n\t\t}\n\t}\n\n\tvar ans int64\n\tans = math.MaxInt64\n\tvar sum int64\n\tfor i := n - 1; i >= 0; i-- {\n\t\tvar need = k / (1 << uint(i))\n\t\tsum += need * c[i]\n\t\tk -= (need << uint(i))\n\t\tif k > 0 {\n\t\t\tans = min(ans, sum+c[i])\n\t\t} else {\n\t\t\tans = min(ans, sum)\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp", "bitmasks"], "code_uid": "996ef07db994c9bfb58681912d54da75", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF913C(in io.Reader, out io.Writer) {\n\tsearch := func(l, r int64, f func(int64) bool) int64 {\n\t\ti, j := l, r\n\t\tfor i < j {\n\t\t\th := (i + j) >> 1\n\t\t\tif f(h) {\n\t\t\t\tj = h\n\t\t\t} else {\n\t\t\t\ti = h + 1\n\t\t\t}\n\t\t}\n\t\treturn i\n\t}\n\tvar n, l int\n\tFscan(in, &n, &l)\n\tc := [31]int64{}\n\tfor i := 0; i < n; i++ {\n\t\tFscan(in, &c[i])\n\t\tif i > 0 && c[i] > 2*c[i-1] {\n\t\t\tc[i] = 2 * c[i-1]\n\t\t}\n\t}\n\tfor i := n; i < 31; i++ {\n\t\tc[i] = c[i-1] << 1\n\t}\n\tans := search(1, c[30], func(m int64) bool {\n\t\ts := 0\n\t\tfor i := 29; i >= 0; i-- {\n\t\t\tif c[i] <= m {\n\t\t\t\tm -= c[i]\n\t\t\t\ts |= 1 << i\n\t\t\t}\n\t\t}\n\t\treturn s >= l\n\t})\n\tFprint(out, ans)\n}\n\nfunc main() { CF913C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["greedy", "dp", "bitmasks"], "code_uid": "a74fe0f8214048c8835d0f1e3f7ddbaf", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, l uint64\n\tfmt.Scan(&n, &l)\n\n\tc := make([]uint64, n)\n\tfor i := uint64(0); i < n; i++ {\n\t\tfmt.Scan(&c[i])\n\t}\n\n\tsum := uint64(0)\n\tcurrPrice := c[0]\n\tprevPrice := c[0]\n\n\tfor pos := 0; pos < len(c); pos++ {\n\t\tcurrPrice = c[pos]\n\t\tif currPrice < sum { // Current price is cheaper > rebuy all\n\t\t\tsum = currPrice\n\t\t}\n\n\t\tif currPrice > prevPrice<<1 { // Current price is too high > keep the old one\n\t\t\tcurrPrice = prevPrice << 1\n\t\t}\n\n\t\tsum += (l % 2) * currPrice\n\t\tprevPrice = currPrice\n\t\tl >>= 1\n\t}\n\n\tsum += l * (currPrice << 1)\n\tfmt.Println(sum)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp", "bitmasks"], "code_uid": "3ece70f70ee0a0ddaa2709bb32fa295a", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nvar sc *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc nextInt() int {\n sc.Scan()\n ans, _ := strconv.Atoi(sc.Text())\n return ans\n}\n\nfunc Count(left, right int, a []int) (cnt int) {\n for i, val := range a {\n if left <= i && i <= right {\n cnt += 1 - val\n } else {\n cnt += val\n }\n }\n return\n}\n\nfunc main() {\n sc.Split(bufio.ScanWords)\n n := nextInt()\n var a = make([]int, n)\n for i := range a {\n a[i] = nextInt()\n }\n best := 0\n for i := 0; i < n; i++ {\n for j := i; j < n; j++ {\n cnt := Count(i,j,a)\n if best < cnt {\n best = cnt\n }\n }\n }\n fmt.Println(best)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp", "implementation"], "code_uid": "1f01f69a6177bea7d5787633c027c8e9", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n\n an := make([]int, n, n)\n ones := 0\n for i := 0; i < n; i++ {\n fmt.Scan(&an[i])\n if an[i] == 1 {\n ones++\n an[i] = -1\n } else {\n an[i] = 1\n }\n }\n\n dp := make([]int, n, n)\n dp[0] = an[0]\n max := dp[0]\n for i := 1; i < n; i++ {\n dp[i] = dp[i-1] + an[i]\n if dp[i] < an[i] {\n dp[i] = an[i]\n }\n if max < dp[i] {\n max = dp[i]\n }\n }\n\n fmt.Println(ones + max)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp", "implementation"], "code_uid": "fa548ccce8b402f47d6d453bd4bb57bf", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype MyScanner struct {\n\t*bufio.Scanner\n\tjustScanned bool\n}\n\nfunc NewMyScanner() *MyScanner {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\treturn &MyScanner{sc, false}\n}\n\nfunc (sc *MyScanner) Has() bool {\n\tsc.justScanned = true\n\treturn sc.Scan()\n}\n\nfunc (sc *MyScanner) Int() int {\n\tif !sc.justScanned {\n\t\tsc.Scan()\n\t}\n\tsc.justScanned = false\n\n\tx, _ := strconv.Atoi(sc.Text())\n\treturn x\n}\n\nfunc (sc *MyScanner) Bool() bool {\n\tif !sc.justScanned {\n\t\tsc.Scan()\n\t}\n\tsc.justScanned = false\n\n\treturn sc.Bytes()[0] == byte('1')\n}\n\nvar sc = NewMyScanner()\n\nfunc solve() int {\n\tn := sc.Int()\n\ta := make([]bool, n)\n\n\tsum := 0\n\tfor i := range a {\n\t\ta[i] = sc.Bool()\n\t\tif a[i] {\n\t\t\tsum++\n\t\t}\n\t}\n\n\tif sum == n {\n\t\treturn n - 1\n\t}\n\n\tact, best := 0, 0\n\tfor i := range a {\n\t\tif !a[i] {\n\t\t\tact++\n\t\t\tif act > best {\n\t\t\t\tbest = act\n\t\t\t}\n\t\t} else {\n\t\t\tact--\n\t\t\tif act < 0 {\n\t\t\t\tact = 0\n\t\t\t}\n\t\t}\n\t}\n\treturn best + sum\n}\n\nfunc main() {\n\tfmt.Println(solve())\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp", "implementation"], "code_uid": "79967027d7df54f5d078c1b55e0238e5", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n1, n2, k1, k2 int\n\n\tfmt.Scan(&n1, &n2, &k1, &k2)\n\n\tif n1 > n2 {\n\t\tfmt.Println(\"First\")\n\t} else {\n\t\tfmt.Println(\"Second\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "de61f1992ec09496fa54eda5e3b26610", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n\t\"strconv\"\n)\n\nvar in *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar out *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc main() {\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\ta, b, _, _ := nextInt(), nextInt(), nextInt(), nextInt()\n\n\tif a > b {\n\t\tfmt.Println(\"First\")\n\t} else {\n\t\tfmt.Println(\"Second\")\n\t}\n}\n\nfunc nextInt() int {\n\tin.Scan()\n\tres, _ := strconv.Atoi(in.Text())\n\treturn res\n}", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "4c8f95f9e131b984c51de3467f8eb8e2", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Rockethon_2015_A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\tfirst, second int\n)\n\nfunc main() {\n\tfmt.Scanf(\"%d\", &first)\n\tfmt.Scanf(\"%d\", &second)\n\tif first <= second {\n\t\tfmt.Printf(\"Second\")\n\t} else {\n\t\tfmt.Printf(\"First\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "cfb30f8290df1512e37fe131573d2df8", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 443B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc count(s *string, n, k, l int) bool {\n\tfor i := 0; i <= n+k-l*2; i++ {\n\t\tstat := true\n\t\tfor j := 0; j < l; j++ {\n\t\t\tif i+j+l < n && (*s)[i+j] != (*s)[i+j+l] {\n\t\t\t\tstat = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif stat {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar s string\n\tvar k int\n\tfmt.Scan(&s, &k)\n\tn := len(s)\n\tans := 0\n\tfor i := (n + k) / 2; i > 0; i-- {\n\t\tif count(&s, n, k, i) {\n\t\t\tans = i * 2\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "593764e302ef286ce9aceec86395f19a", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc Judge(line *string, n, k, l int) bool {\n for i := 0; i <= n+k-l*2; i++ {\n var flag bool = true\n for j := 0; j < l; j++ {\n if i+j+l < n && (*line)[i+j] != (*line)[i+j+l] {\n flag = false\n break\n }\n }\n if flag {\n return true\n }\n }\n return false\n}\n\nfunc main() {\n var line string\n var k int\n fmt.Scan(&line, &k)\n var n int = len(line)\n var res int = 0\n for i := (n + k) / 2; i > 0; i-- {\n if Judge(&line, n, k, i) {\n res = i * 2\n break\n }\n }\n fmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "4eeddc6a7ed0bf71a4b11a5199c735e6", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tline, _ := reader.ReadString('\\n')\n\n\ts := strings.TrimSpace(line)\n\tstringLength := len(s)\n\n\tline, _ = reader.ReadString('\\n')\n\tvar k int\n\n\tfmt.Sscanf(line, \"%d\", &k)\n\n\tnewString := make([]rune, stringLength+k)\n\tcopy(newString, []rune(s))\n\n\tbestRepeat := 0\n\tfor i := 0; i < stringLength+k; i++ {\n\t\tfor currentRepeat := 0; currentRepeat <= (stringLength+k-i)/2; currentRepeat++ {\n\t\t\ttandemRepeat := true\n\t\t\tfor j := i; j < i+currentRepeat; j++ {\n\t\t\t\tif newString[j+currentRepeat] != newString[j] && newString[j+currentRepeat] != 0 {\n\t\t\t\t\ttandemRepeat = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif tandemRepeat && currentRepeat > bestRepeat {\n\t\t\t\tbestRepeat = currentRepeat\n\t\t\t}\n\n\t\t}\n\t}\n\tfmt.Println(2*bestRepeat - 0)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "a46e4b6a675a0d60ff5a2399a6afd391", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc ReadArr(n int) []int{\n\tarr := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&arr[i])\n\t}\n\treturn arr\n}\n\nvar (\n\tl, s, r, p [4]bool\n)\n\nfunc Read() {\n\tfor i := 0; i < 4; i++ {\n\t\tvar li, si, ri, pi int\n\t\tfmt.Scanf(\"%d %d %d %d\\n\", &li, &si, &ri, &pi)\n\t\tl[i] = li == 1\n\t\ts[i] = si == 1\n\t\tr[i] = ri == 1\n\t\tp[i] = pi == 1\n\t}\n}\n\nfunc main() {\n\tRead()\n\tfor i := 0; i < 4; i++ {\n\t\tif p[i] {\n\t\t\tif l[i] || s[i] || r[i] ||\n\t\t\t\tl[(i+1)%4] || s[(i+2)%4] || r[(i+3)%4] {\n\t\t\t\tyes()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tno()\n}\n\nfunc yes() {\n\tfmt.Println(\"YES\")\n}\n\nfunc no() {\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b2412726e481bd659edccf0a8a5d7da3", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc ReadArr(n int) []int{\n\tarr := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&arr[i])\n\t}\n\treturn arr\n}\n\nvar (\n\tl, s, r, p [4]bool\n)\n\nfunc Read() {\n\tfor i := 0; i < 4; i++ {\n\t\tvar li, si, ri, pi int\n\t\tfmt.Scan(&li, &si, &ri, &pi)\n\t\tl[i] = li == 1\n\t\ts[i] = si == 1\n\t\tr[i] = ri == 1\n\t\tp[i] = pi == 1\n\t}\n}\n\nfunc main() {\n\tRead()\n\tfor i := 0; i < 4; i++ {\n\t\tif p[i] {\n\t\t\tif l[i] || s[i] || r[i] ||\n\t\t\t\tl[(i+1)%4] || s[(i+2)%4] || r[(i+3)%4] {\n\t\t\t\tyes()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tno()\n}\n\nfunc yes() {\n\tfmt.Println(\"YES\")\n}\n\nfunc no() {\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5a396eb12109bf8847218ce4de510a6b", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tvar a [4][4]int\n\tfor i := 0; i < 4; i++ {\n\t\tfor j := 0; j < 4; j++ {\n\t\t\ta[i][j] = readInt()\n\t\t}\n\t}\n\tfor i := 0; i < 4; i++ {\n\t\tif a[i][3] == 1 {\n\t\t\tfor j := 0; j < 3; j++ {\n\t\t\t\tif a[i][j] == 1 {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif a[(i+1)%4][0] == 1 || a[(i+2)%4][1] == 1 || a[(i+3)%4][2] == 1 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "94857185d2ba6821e9eb920af4b1c4c7", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tn := 0\n\tfmt.Scan(&n)\n\ts := \"\"\n\tfmt.Scan(&s)\n\tans := 0\n\tfor _, char := range(s) {\n\t\tif char == rune('+') {\n\t\t\tans = ans + 1\n\t\t} else if char == rune('-') {\n\t\t\tif ans != 0 {\n\t\t\t\tans = ans - 1\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "8945abc3c44d24520580782e7fc41751", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a , b int)int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main(){\n\tvar n int\n\tfmt.Scan(&n)\n\tvar s string\n\tfmt.Scan(&s)\n\tans := n\n\tvar i int\n\tvar temp int\n\n\n\tfor i = 0 ; i <= 100;i++{\n\t\ttemp = i\n\t\tfor _, char := range (s){\n\t\t\tif(char =='+'){\n\t\t\t\ttemp ++\n\t\t\t}\n\t\t\tif(char =='-'){\n\t\t\t\ttemp --\n\t\t\t\tif(temp <= -1){\n\t\t\t\ttemp = -1\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(temp >= 0){\n\t\t\tans = min(ans,temp)\n\t\t}\n\t}\n\tfmt.Print(ans)\n\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c5911e6736fb4145c5ed27f2adcada25", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int32\n\tvar str string\n\tfmt.Scanf(\"%d\\n\",&n)\n\tfmt.Scanf(\"%s\\n\",&str)\n\tans:=0\n\tfor _,c:=range str{\n\t\tif c=='+'{\n\t\t\tans++\n\t\t}else if c=='-'{\n\t\t\tif ans>0{\n\t\t\t\tans--\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "0e1625acbf8041764449a0b1788258ff", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\n\tvar n, max, min int\n\tfmt.Fscanf(buf, \"%d\\n\", &n)\n\tmat := make([]int, n)\n\tmax = 0\n\tmin = 100\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(buf, \"%d\", &mat[i])\n\t\tif mat[i] > max {\n\t\t\tmax = mat[i]\n\t\t}\n\t\tif mat[i] < min {\n\t\t\tmin = mat[i]\n\t\t}\n\t}\n\tfmt.Fscanf(buf, \"\\n\")\n\tif max == min {\n\t\tfmt.Printf(\"0\\n\")\n\t\treturn\n\t}\n\tmid := (max + min) / 2\n\thasmid := false\n\tfor i := 0; i < n; i++ {\n\t\tif mat[i] != max && mat[i] != min && mat[i] != mid {\n\t\t\tfmt.Printf(\"-1\\n\")\n\t\t\treturn\n\t\t}\n\t\tif mat[i] == mid {\n\t\t\thasmid = true\n\t\t}\n\t}\n\n\tif ((max - min) & 1) == 1 {\n\t\tif max-min > 1&&hasmid {\n\t\t\tfmt.Printf(\"-1\\n\")\n\t\t}else{\n\t\t\tfmt.Printf(\"%d\\n\",max-min)\n\t\t}\n\t}else{\n\t\t\tfmt.Printf(\"%d\\n\",max-mid)\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "c854ce3f1f7f0de7104c2fcbfc5a4fdb", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tnums := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&nums[i])\n\t}\n\n\tsort.Ints(nums)\n\tallEqual := true\n\tfor i := 1; i < n; i++ {\n\t\tnums[i] -= nums[0]\n\t\tallEqual = allEqual && nums[i] == 0\n\t}\n\tif allEqual {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tfor i := 1; i <= 100; i++ {\n\t\tfor j := 1; j < n; j++ {\n\t\t\tif nums[j] == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif nums[j]%i != 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif nums[j]/i > 2 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif j == n-1 {\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "935de61e27312a8f90b2bbba8dab8572", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1154/problem/B\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc getUniqueElements(n int, a []int) []int {\n\tnums := make(map[int]bool)\n\telems := []int{}\n\tfor _, elem := range a {\n\t\tif !nums[elem] {\n\t\t\tnums[elem] = true\n\t\t\telems = append(elems, elem)\n\t\t}\n\t}\n\treturn elems\n}\n\nfunc Solve(n int, a []int) int {\n\tb := getUniqueElements(n, a)\n\tk := len(b)\n\tif k > 3 {\n\t\treturn -1\n\t}\n\tsort.Ints(b)\n\tif len(b) == 1 {\n\t\treturn 0\n\t}\n\tdiff := b[len(b)-1] - b[0]\n\tif len(b) == 2 {\n\t\tif diff%2 == 1 {\n\t\t\treturn diff\n\t\t}\n\t\treturn diff / 2\n\t}\n\tif diff%2 == 1 || b[1]+diff/2 != b[2] {\n\t\treturn -1\n\t}\n\treturn diff / 2\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(reader, \"%d\", &a[i])\n\t}\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, a))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "bf9703b125fef9c3e7b01a0a4f029afb", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"os\"\n \"bufio\"\n)\n\nvar posMap = map[string]int{\n \"^\": 0,\n \">\": 1,\n \"v\": 2,\n \"<\": 3,\n}\n\nfunc main() {\n var sPos, ePos string\n var n int\n stdin := bufio.NewReader(os.Stdin)\n fmt.Fscanf(stdin, \"%s %s\\n%d\", &sPos, &ePos, &n)\n \n start, end := posMap[sPos], posMap[ePos]\n \n if start != end {\n posCW := (start + (n % 4)) % 4\n posCCW := (4 + start - (n % 4)) % 4\n if posCW == posCCW {\n fmt.Println(\"undefined\")\n } else {\n if end == posCW {\n fmt.Println(\"cw\")\n } else {\n fmt.Println(\"ccw\")\n }\n }\n } else {\n fmt.Println(\"undefined\")\n }\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "39fdd3488a71926191b2e30f74111bc0", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc solve() {\n\tfrom := readString()\n\tto := readString()\n\tcnt := readInt() % 4\n\n\ta := \"^>v<\"\n\tb := \"^\"\n\tcwStart := strings.Index(a, from)\n\tcwEnd := strings.Index(a, to)\n\tccwStart := strings.Index(b, from)\n\tccwEnd := strings.Index(b, to)\n\tres1 := (cwEnd - cwStart + 4) % 4\n\tres2 := (ccwEnd - ccwStart + 4) % 4\n\tif res1 == cnt && res2 == cnt {\n\t\tfmt.Println(\"undefined\")\n\t} else if res1 == cnt {\n\t\tfmt.Println(\"cw\")\n\t} else if res2 == cnt {\n\t\tfmt.Println(\"ccw\")\n\t} else {\n\t\tfmt.Println(\"undefined\")\n\t}\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "65d49167f7624269d9fb98ae32f2ff7b", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tarr := gsls(reader)\n\trot := gsli(reader)[0]\n\n\tstart := pos(arr[0])\n\tend := pos(arr[1])\n\n\t// fmt.Printf(\"arr: %#v \\n rot: %#v \\n start: %v \\n end: %v\", arr, rot, start, end)\n\n\tcwEnd := posMod(start+rot, 4)\n\tccwEnd := posMod(start-rot, 4)\n\n\tdiff := posMod(end-start, 4)\n\n\tif diff == 0 || diff == 2 {\n\t\tfmt.Print(\"undefined\")\n\t} else if end == cwEnd {\n\t\tfmt.Print(\"cw\")\n\t} else if end == ccwEnd {\n\t\tfmt.Print(\"ccw\")\n\t} else {\n\t\tfmt.Printf(\"cwEnd = %v, ccwEnd = %v\", cwEnd, ccwEnd)\n\t}\n\treturn\n}\n\nfunc pos(x string) (pos int) {\n\tswitch x {\n\tcase \"^\":\n\t\tpos = 0\n\tcase \">\":\n\t\tpos = 1\n\tcase \"v\":\n\t\tpos = 2\n\tcase \"<\":\n\t\tpos = 3\n\t}\n\n\treturn\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cfe5d033ce222c3214f15b96a499a3ac", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar s []byte\n\tfmt.Scan(&s)\n\tn := 1 << uint(len(s))\n\tr := 0\n\tfor i := n - 1; i > 0; i-- {\n\t\tvar t []byte\n\t\tfor j := 0; j < len(s); j++ {\n\t\t\tif (i>>uint(j))&1 != 0 {\n\t\t\t\tt = append(t, s[j])\n\t\t\t}\n\t\t}\n\t\tif t[0] == '0' || len(t) <= r {\n\t\t\tcontinue\n\t\t}\n\t\tv, _ := strconv.Atoi(string(t))\n\t\tw := int(math.Sqrt(float64(v)))\n\t\tif v == w*w {\n\t\t\tr = len(t)\n\t\t}\n\t}\n\tif r == 0 {\n\t\tfmt.Println(\"-1\")\n\t} else {\n\t\tfmt.Println(len(s) - r)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "e409d169c76bed6b2c8f94c662531582", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n\t\"math\"\n)\n\ntype caseInput struct {\n\tnum int\n}\n\nfunc readCaseInput(scanner *bufio.Scanner) caseInput {\n\treturn caseInput{readInt(scanner)}\n}\n\ntype caseOutput struct {\n\tops int\n}\n\nfunc writeCaseOutput(writer *bufio.Writer, out caseOutput) {\n\twritef(writer, \"%d\\n\", out.ops)\n}\n\nfunc solveCase(in caseInput) caseOutput {\n\tnumStr := fmt.Sprintf(\"%d\", in.num)\n\troot := int(math.Floor(math.Sqrt(float64(in.num))))\n\tfor root > 0 {\n\t\tsquareStr := fmt.Sprintf(\"%d\", root*root)\n\t\tif len(lcs(numStr, squareStr)) == len(squareStr) {\n\t\t\treturn caseOutput{len(numStr) - len(squareStr)}\n\t\t}\n\t\troot -= 1\n\t}\n\treturn caseOutput{-1}\n}\n\n//\tthat's from rozetta code and seems to work\nfunc lcs(a, b string) string {\n\tarunes := []rune(a)\n\tbrunes := []rune(b)\n\taLen := len(arunes)\n\tbLen := len(brunes)\n\tlengths := make([][]int, aLen+1)\n\tfor i := 0; i <= aLen; i++ {\n\t\tlengths[i] = make([]int, bLen+1)\n\t}\n\t// row 0 and column 0 are initialized to 0 already\n\n\tfor i := 0; i < aLen; i++ {\n\t\tfor j := 0; j < bLen; j++ {\n\t\t\tif arunes[i] == brunes[j] {\n\t\t\t\tlengths[i+1][j+1] = lengths[i][j] + 1\n\t\t\t} else if lengths[i+1][j] > lengths[i][j+1] {\n\t\t\t\tlengths[i+1][j+1] = lengths[i+1][j]\n\t\t\t} else {\n\t\t\t\tlengths[i+1][j+1] = lengths[i][j+1]\n\t\t\t}\n\t\t}\n\t}\n\n\t// read the substring out from the matrix\n\ts := make([]rune, 0, lengths[aLen][bLen])\n\tfor x, y := aLen, bLen; x != 0 && y != 0; {\n\t\tif lengths[x][y] == lengths[x-1][y] {\n\t\t\tx--\n\t\t} else if lengths[x][y] == lengths[x][y-1] {\n\t\t\ty--\n\t\t} else {\n\t\t\ts = append(s, arunes[x-1])\n\t\t\tx--\n\t\t\ty--\n\t\t}\n\t}\n\t// reverse string\n\tfor i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {\n\t\ts[i], s[j] = s[j], s[i]\n\t}\n\treturn string(s)\n}\n\nfunc solveSequential(scanner *bufio.Scanner, writer *bufio.Writer) {\n\twriteCaseOutput(writer, solveCase(readCaseInput(scanner)))\n}\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\tif len(os.Args) > 1 {\n\t\treader, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tdefer reader.Close()\n\t\tscanner = bufio.NewScanner(reader)\n\t} else {\n\t\tscanner = bufio.NewScanner(os.Stdin)\n\t}\n\tscanner.Split(bufio.ScanWords)\n\n\tvar writer = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tsolveSequential(scanner, writer)\n}\n\nfunc readInt64(sc *bufio.Scanner) int64 {\n\tsc.Scan()\n\tres, err := strconv.ParseInt(sc.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc readInt(sc *bufio.Scanner) int {\n\treturn int(readInt64(sc))\n}\n\nfunc writef(writer *bufio.Writer, formatStr string, values ...interface{}) {\n\tout := fmt.Sprintf(formatStr, values...)\n\t_, err := writer.WriteString(out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "b256ad7b9e2b752cb01964ff1ae1dba3", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 166E-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, c, h, b, i int64\n fmt.Scan(&a)\n b = 1\n for i = 0; i < a-1; i++ {\n b = b * 3 % 1000000007\n c = (b - h%1000000007 + 1000000007) % 1000000007\n h = c\n }\n fmt.Println(c)\n}\n", "lang_cluster": "Go", "tags": ["math", "matrices", "dp"], "code_uid": "c505ef23971ad5daeb5ef7d632e4d8f2", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n const MOD int64 = 1000000007\n var n int\n fmt.Scan(&n)\n ans, prev, prevprev := int64(0), int64(0), int64(1)\n for i := 1; i < n; i++ {\n ans = (3*prevprev)%MOD\n prevprev = (prev+(2*prevprev))%MOD\n prev = ans\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "matrices", "dp"], "code_uid": "1d530bd7d1bcaf613c33145478e82e56", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nfunc main() {\n var n int\n fmt.Scan(&n)\n if n == 1 {\n fmt.Println(0)\n return\n }\n var fpp int64\n var fp int64 = 0\n var f int64 = 3\n for i := 3; i <= n; i++ {\n fpp = fp\n fp = f\n f = (2 * fp + 3 * fpp) % 1000000007\n }\n fmt.Println(f % 1000000007)\n \n return\n}", "lang_cluster": "Go", "tags": ["math", "matrices", "dp"], "code_uid": "643d26e04041ec3da3e983a593f12cfc", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\t//stdin, err := os.Open(\"in.txt\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdin.Close()\n\tstdin := os.Stdin\n\treader := bufio.NewReaderSize(stdin, 1024*1024)\n\n\t//stdout, err := os.Create(\"test.txt\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdout.Close()\n\tstdout := os.Stdout\n\twriter := bufio.NewWriterSize(stdout, 1024*1024)\n\n\tvar n, c int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &c)\n\n\ta := make([]int, n, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(reader, \"%d\", &a[i])\n\t}\n\n\tr := 0\n\tfor i :=0; i < n - 1; i++ {\n\t\tif a[i] >= a[i + 1] + c && a[i] - a[i+1] - c > r {\n\t\t\tr = a[i] - a[i+1] - c\n\t\t}\n\t}\n\n\tfmt.Fprintln(writer, r)\n\n\twriter.Flush()\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "4b6c4aad680cd3ad19e8a7f3a6a82624", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// wa on test 4\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar (\n\t\tn, c, max, i int32\n\t\tx [128]int32\n\t)\n\n\tfmt.Scan(&n)\n\tfmt.Scan(&c)\n\tfor i = 1; i <= n; i++ {\n\t\tfmt.Scan(&x[i])\n\t}\n\tmax = x[1] - x[2]\n\tfor i = 2; i < n; i++ {\n\t\tif x[i]-x[i+1] > max {\n\t\t\tmax = x[i] - x[i+1]\n\t\t}\n\t}\n\n\tmax = max - c\n\tif max < 0 {\n\t\tmax = 0\n\t}\n\tfmt.Println(max)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "ad45bea377507528e9b6292d9b267ebf", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//https://codeforces.com/contest/385/problem/A\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n)\n\nfunc main() {\n\tvar n, c int\n\t_, err := fmt.Scan(&n, &c)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t} else {\n\t\tdays := make([]int, n)\n\t\tfor i := 0; i < n; i++ {\n\t\t\t_, err := fmt.Scan(&days[i])\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(i, err)\n\t\t\t}\n\t\t}\n\t\tfmt.Println(findMaxProffit(c, days))\n\t}\n}\n\nfunc findMaxProffit(berriesCost int, days []int) int {\n\tmaxDiff := 0\n\tfor i := 0; i < len(days)-1; i++ {\n\t\tleft := days[i]\n\t\tright := days[i+1]\n\t\tcurrentDiff := left - right\n\t\tif currentDiff > maxDiff {\n\t\t\tmaxDiff = currentDiff\n\t\t}\n\t}\n\tres := maxDiff - berriesCost\n\n\tif res > 0 {\n\t\treturn res\n\t}\n\treturn 0\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "12fd916a1872e1f25ef00219691c53b7", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar cupsCount, volumeOfCup int\n\n\tfmt.Fscan(reader, &cupsCount, &volumeOfCup)\n\n\tvar friendsCount = cupsCount - 1\n\tcupsVolume := make([]int, cupsCount)\n\n\tfor i := 0; i < cupsCount; i++ {\n\t\tfmt.Fscan(reader, &cupsVolume[i])\n\t}\n\n\tsort.Ints(cupsVolume)\n\n\tvar amount = 0\n\tfor i := 0; i < friendsCount; i++ {\n\t\tamount += cupsVolume[i]\n\t}\n\n\tif amount > volumeOfCup {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "6b8cc1a6c43b6c86730a4063a74c891e", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,s,a int\n fmt.Scan(&n,&s)\n max, total := 0, 0\n for i := 0; i < n; i++ {\n fmt.Scan(&a)\n total += a\n if max < a { max = a }\n }\n total -= max\n if total <= s { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d50ab11cb2c7d3977af5957a0354f525", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n,m,a int\n\tmax:=-10000\n\ts:=0\n\tfmt.Scan(&m,&n)\n\tfor i:=0;imax {\n\t\t\tmax=a\n\t\t}\n\t\ts+=a\n\t}\n\tif s-max<=n {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\n\n\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ad1a76434b42479bec9ba6de1fc48cdd", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tboard := make([][]byte, 9)\n\tfor i, _ := range board {\n\t\tboard[i] = make([]byte, 9)\n\t}\n\n\tfor i := 0; i < 27; i++ {\n\t\ts := readString()\n\t\tfor j, c := range s {\n\t\t\tx := j + ((i % 3) * 3)\n\t\t\ty := i / 3\n\t\t\tboard[x][y] = byte(c)\n\t\t}\n\t}\n\tlasty := readInt() - 1\n\tlastx := readInt() - 1\n\tnewx := (lastx % 3) * 3\n\tnewy := (lasty % 3) * 3\n\tif isfull(board, newx, newy) {\n\t\tfillall(board)\n\t} else {\n\t\tfill(board, newx, newy)\n\t}\n\n\tfor y := 0; y < 9; y++ {\n\t\tfor x := 0; x < 9; x++ {\n\t\t\tfmt.Printf(\"%c\", board[x][y])\n\t\t\tif x == 2 || x == 5 {\n\t\t\t\tfmt.Print(\" \")\n\t\t\t}\n\t\t}\n\t\tfmt.Println()\n\t\tif y == 2 || y == 5 {\n\t\t\tfmt.Println()\n\t\t}\n\t}\n}\n\nfunc isfull(board [][]byte, x, y int) bool {\n\tfor i := 0; i < 3; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif board[x+i][y+j] == '.' {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}\n\nfunc fill(board [][]byte, x, y int) {\n\tfor i := 0; i < 3; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif board[x+i][y+j] == '.' {\n\t\t\t\tboard[x+i][y+j] = '!'\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc fillall(board [][]byte) {\n\tfill(board, 0, 0)\n\tfill(board, 0, 3)\n\tfill(board, 0, 6)\n\n\tfill(board, 3, 0)\n\tfill(board, 3, 3)\n\tfill(board, 3, 6)\n\n\tfill(board, 6, 0)\n\tfill(board, 6, 3)\n\tfill(board, 6, 6)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "9d5b78797ec1717f895b9cf95bf8c3b0", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n \"strings\"\n /*\n \"sort\"\n \"math\"\n */\n)\n\nfunc main() {\n defer writer.Flush() \n scanner.Split(bufio.ScanWords) \n\n var fields = [3][3][3]string{}\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n for k := 0; k < 3; k++ {\n scanner.Scan()\n fields[i][k][j] = scanner.Text()\n }\n }\n }\n row := ReadInt32()\n col := ReadInt32()\n row = (row - 1) % 3\n col = (col - 1) % 3\n flag := false\n for i := 0; i < 3; i++ {\n if strings.Contains(fields[row][col][i], \".\") {\n flag = true\n }\n fields[row][col][i] = strings.Replace(fields[row][col][i], \".\", \"!\", -1)\n }\n\n if !flag {\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n for k := 0; k < 3; k++ {\n fields[i][j][k] = strings.Replace(fields[i][j][k], \".\", \"!\", -1)\n }\n }\n }\n }\n\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n for k := 0; k < 3; k++ {\n fmt.Printf(\"%s \", fields[i][k][j])\n }\n fmt.Printf(\"\\n\")\n }\n fmt.Printf(\"\\n\")\n }\n}\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc PrintInts(ints ...int) {\n for _, value := range ints {\n writer.WriteString(strconv.Itoa(value))\n writer.WriteByte(' ')\n }\n}\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2610eaaf5a16769624fd6a5d8b5d88cf", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc fillBigCell(x int, y int, board [][]rune) int {\n\tcount := 0\n\tfor i := x * 3; i < x*3+3; i++ {\n\t\tfor j := y * 3; j < y*3+3; j++ {\n\t\t\tcoox, cooy := i+x, j+y\n\t\t\tif board[coox][cooy] == '.' {\n\t\t\t\tboard[coox][cooy] = '!'\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\n\treturn count\n}\n\nfunc main() {\n\tboard := make([][]rune, 11)\n\tfor i := 0; i < 11; i++ {\n\t\tboard[i] = make([]rune, 11)\n\n\t\tif i != 3 && i != 7 {\n\t\t\tfor j := 0; j < 11; j++ {\n\t\t\t\tfmt.Scanf(\"%c\", &board[i][j])\n\t\t\t}\n\t\t}\n\t\tfmt.Scanf(\"\\n\")\n\t}\n\tvar lastX, lastY int\n\tfmt.Scanf(\"%d%d\", &lastX, &lastY)\n\n\tbigCellX := (lastX - 1) % 3\n\tbigCellY := (lastY - 1) % 3\n\n\tcount := fillBigCell(bigCellX, bigCellY, board)\n\tif count == 0 {\n\t\tfor i := 0; i < 11; i++ {\n\t\t\tfor j := 0; j < 11; j++ {\n\t\t\t\tif board[i][j] == '.' {\n\t\t\t\t\tboard[i][j] = '!'\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := 0; i < 11; i++ {\n\n\t\tif i != 3 && i != 7 {\n\t\t\tfor j := 0; j < 11; j++ {\n\t\t\t\tfmt.Printf(\"%c\", board[i][j])\n\t\t\t}\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "8196bb878272fbc4a07b9249eee124c2", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tword := \"CODEFORCES\"\n\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\n\tif strings.HasSuffix(s, word) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\ti := 0\n\tfor ; i < len(s) && i < len(word); i++ {\n\t\tif s[i] != word[i] {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif strings.HasSuffix(s, word[i:]) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "32f134bbc0e4927692fbc0dcd8bca76e", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tsize := len(s)\n\textra := size - len(\"CODEFORCES\")\n\tif extra < 0 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfor i := 0; i <= size-extra; i++ {\n\t\tx := s[:i] + s[i+extra:]\n\t\tif x == \"CODEFORCES\" {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "131a8c551b0ab0a1a4899e57ea8a28e9", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tword := \"CODEFORCES\"\n\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\n\ti := 0\n\tfor ; i < len(s) && i < len(word); i++ {\n\t\tif s[i] != word[i] {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif strings.HasSuffix(s, word[i:]) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "854e815f86f96d0c4f3640d74022bf72", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scanf(\"%d\\n%d\\n%d\\n\", &a, &b, &c)\n\n\tcnt := 0\n\n\tfor {\n\t\tif a < 1 || b < 2 || c < 4 {\n\t\t\tbreak\n\t\t}\n\n\t\tcnt++\n\n\t\ta -= 1\n\t\tb -= 2\n\t\tc -= 4\n\t}\n\n\tfmt.Println(7 * cnt)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "5a050d8614da3894c6142ac9b81465e8", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc getmin(a, b, c int) int {\n\tif a <= b && a <= c {\n\t\treturn a\n\t}\n\tif b <= a && b <= c {\n\t\treturn b\n\t}\n\tif c <= a && c <= b {\n\t\treturn c\n\t}\n\treturn a\n}\nfunc main() {\n\tvar a, b, c int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &a, &b, &c)\n\tb /= 2\n\tc /= 4\n\tmin := getmin(a, b, c)\n\tfmt.Println(min * 7)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "42254a6ca5057c607887d2365ee3f252", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc min(a, b uint16) uint16 {\n if a < b {\n return a\n }\n return b\n}\n\nfunc main() {\n var (\n a uint16\n b uint16\n c uint16\n )\n\n fmt.Scanf(\"%d\\n%d\\n%d\", &a, &b, &c)\n\n k := min(a, min(b / 2, c / 4))\n\n fmt.Printf(\"%v\\n\", 7*k)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "f136e44d0d57a43ac8e22fa988694724", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\tstr, _, _ := r.ReadLine()\n\tfmt.Print(getLongestLen(string(str)))\n}\n\nfunc getLongestLen(str string) int {\n\tif !isPalindrome(str) {\n\t\treturn len(str)\n\t}\n\tif isOneLetter(str) {\n\t\treturn 0\n\t}\n\treturn len(str)-1\n}\n\nfunc isPalindrome(str string) bool {\n\tfor i := 0; i <= (len(str)-1) / 2; i++ {\n\t\tif str[i] != str[len(str)-1-i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc isOneLetter(str string) bool {\n\tfor i := 1; i < len(str); i++ {\n\t\tif str[0] != str[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "a12adfdaa26943e9ae3986311690a0a2", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"io\"\n \"strings\"\n \"bytes\"\n \"os\"\n)\n\ntype contestIn struct {\n\treader io.Reader\n}\n\ntype contestOut struct {\n\twriter io.Writer\n}\n\ntype Contest struct {\n\tIn contestIn\n\tOut contestOut\n}\n\nfunc NewSubmitContest() Contest {\n\treturn Contest{contestIn{os.Stdin}, contestOut{os.Stdout}}\n}\n\nfunc NewTestContest(testIn string, testOut *bytes.Buffer) Contest {\n\treturn Contest{contestIn{strings.NewReader(testIn)}, contestOut{testOut}}\n}\n\nfunc (in contestIn) Var(a interface{}) {\n\tfmt.Fscan(in.reader, a)\n}\n\nfunc (in contestIn) Vars(a interface{}) {\n\tfmt.Fscanln(in.reader, a)\n}\n\nfunc (in contestIn) Str() string {\n\tvar s string\n\tin.Var(&s)\n\n\treturn s\n}\n\nfunc (in contestIn) Int() int {\n\tvar i int\n\tin.Var(&i)\n\n\treturn i\n}\n\nfunc (in contestIn) Ints(len int) []int {\n\tarr := make([]int, 0, len)\n\tfor ; len > 0; len-- {\n\t\tvar i int\n\t\tin.Var(&i)\n\t\tarr = append(arr, i)\n\t}\n\n\treturn arr\n}\n\nfunc (out contestOut) F(format string, a ...interface{}) contestOut {\n\tfmt.Fprintf(out.writer, format, a...)\n\treturn out\n}\n\nfunc (out contestOut) Str(s string) contestOut {\n\tfmt.Fprint(out.writer, s)\n\treturn out\n}\n\nfunc (out contestOut) Int(i int) contestOut {\n\tout.F(\"%d\", i)\n\treturn out\n}\n\nfunc (out contestOut) N() contestOut {\n\tfmt.Fprintln(out.writer)\n\treturn out\n}\n\n// https://codeforces.com/contest/981/problem/A\nfunc problem(c Contest) {\n\ts := c.In.Str()\n\tl := len(s)\n\te := true // same chars\n\n\tfor i := 0; i < len(s) / 2; i++ {\n\t\tif l > 1 {\n\t\t\te = e && (s[i] == s[i+1])\n\t\t}\n\n\t\tif s[i] != s[l - i - 1] {\n\t\t\t// Not palindrome\n\t\t\tc.Out.Int(l).N()\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Palindrome\n\tif e {\n\t\tc.Out.Int(0).N()\n\t} else {\n\t\tc.Out.Int(l - 1).N()\n\t}\n}\n\nfunc main() {\n\tc := NewSubmitContest()\n\tproblem(c)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "bb4f3c6a5ac43d2a11683c201219cca2", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"strconv\"\n \"fmt\"\n \"io\"\n \"strings\"\n \"bytes\"\n \"os\"\n)\n\ntype Contest struct {\n\tin *bufio.Scanner\n\tout io.Writer\n}\n\nfunc NewSubmitContest() *Contest {\n\tC := &Contest{bufio.NewScanner(os.Stdin), os.Stdout}\n\tC.SetSplit(bufio.ScanWords)\n\treturn C\n}\n\nfunc NewTestContest(testIn string, testOut *bytes.Buffer) *Contest {\n\tC := &Contest{bufio.NewScanner(strings.NewReader(testIn)), testOut}\n\tC.SetSplit(bufio.ScanWords)\n\treturn C\n}\n\nfunc (C *Contest) SetSplit(split bufio.SplitFunc) *Contest {\n\tC.in.Split(split)\n\treturn C\n}\n\nfunc (C *Contest) InStr() string {\n\tC.in.Scan()\n\treturn C.in.Text()\n}\n\nfunc (C *Contest) InBytes() []byte {\n\tC.in.Scan()\n\treturn C.in.Bytes()\n}\n\nfunc (C *Contest) InInt() int {\n\tC.in.Scan()\n\ti, _ := strconv.Atoi(C.in.Text())\n\treturn i\n}\n\nfunc (C *Contest) InInt64() int64 {\n\tC.in.Scan()\n\ti, _ := strconv.ParseInt(C.in.Text(), 10, 64)\n\treturn i\n}\n\nfunc (C *Contest) Out(format string, a ...interface{}) {\n\tfmt.Fprintf(C.out, format, a...)\n}\n\nfunc (C *Contest) MaxInt64(i1, i2 int64) int64 {\n\tif i1 > i2 {\n\t\treturn i1\n\t}\n\treturn i2\n}\n\n// https://codeforces.com/contest/981/problem/A\nfunc problem(C *Contest) {\n\ts := C.InBytes()\n\tl := len(s)\n\te := true // same chars\n\n\tfor i := 0; i < len(s) / 2; i++ {\n\t\tif l > 1 {\n\t\t\te = e && (s[i] == s[i+1])\n\t\t}\n\n\t\tif s[i] != s[l - i - 1] {\n\t\t\t// Not palindrome\n\t\t\tC.Out(\"%d\\n\", l)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Palindrome\n\tif e {\n\t\tC.Out(\"0\\n\")\n\t} else {\n\t\tC.Out(\"%d\\n\", l - 1)\n\t}\n}\n\nfunc main() {\n\tc := NewSubmitContest()\n\tproblem(c)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "1540265fdfe2200df0417d4aab9b5c77", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"runtime/debug\"\n)\n\nvar (\n\tisNotPrime []bool\n\tprimes []int\n\tn int\n)\n\nfunc main() {\n\tdebug.SetGCPercent(-1)\n\n\tfmt.Scanf(\"%d\", &n)\n\t// n = 20\n\n\tcalcPrimes(n)\n\n\tleft := getLowerBound(n)\n\n\tx0Lower := getLowerBound(left)\n\n\tfor i := left + 1; i < n; i++ {\n\t\tx0Lower = min(x0Lower, getLowerBound(i))\n\t}\n\n\tfmt.Println(x0Lower)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc getLowerBound(n int) int {\n\tdivider := findMaxPrimeDivider(n)\n\n\treturn n - divider + 1\n}\n\nfunc findMaxPrimeDivider(x int) int {\n\tsqrtx := int(math.Sqrt(float64(x))) + 1\n\n\tfor i := 0; i < len(primes) && primes[i] < sqrtx; i++ {\n\t\tif x%primes[i] == 0 {\n\t\t\tx /= primes[i]\n\n\t\t\tfor isNotPrime[x] && x%primes[i] == 0 {\n\t\t\t\tx /= primes[i]\n\t\t\t}\n\n\t\t\tif !isNotPrime[x] {\n\t\t\t\treturn x\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 1\n}\n\nfunc calcPrimes(n int) {\n\tisNotPrime = make([]bool, n+1)\n\n\tfor i := 2; i*i <= n; i++ {\n\t\tif !isNotPrime[i] {\n\t\t\tfor j := i * i; j <= n; j += i {\n\t\t\t\tisNotPrime[j] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tprimes = make([]int, 0, n/2)\n\n\tfor i := 2; i <= n; i++ {\n\t\tif !isNotPrime[i] {\n\t\t\tprimes = append(primes, i)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "e8bdcfaacf1fffd24d0a6cb7c96811ab", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"runtime/debug\"\n)\n\ntype Range struct {\n\tleft, right int\n}\n\nvar (\n\tisNotPrime []bool\n\tprimes []int\n\tn int\n)\n\nfunc main() {\n\tdebug.SetGCPercent(-1)\n\n\tfmt.Scanf(\"%d\", &n)\n\t// n = 1e6\n\n\tcalcPrimes(n)\n\n\tx1Range := getRange(n)\n\n\tx0Range := getRange(x1Range.left)\n\n\tfor i := x1Range.left + 1; i < x1Range.right; i++ {\n\t\tx0Range = joinRanges(x0Range, getRange(i))\n\t}\n\n\tfmt.Println(x0Range.left)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc joinRanges(r1, r2 Range) Range {\n\tleft := min(r1.left, r2.left)\n\n\tright := max(r1.right, r2.right)\n\n\treturn Range{left, right}\n}\n\nfunc getRange(n int) Range {\n\tdivider := findMaxPrimeDivider(n)\n\n\treturn Range{n - divider + 1, n}\n}\n\nfunc findMaxPrimeDivider(x int) int {\n\tsqrtx := int(math.Sqrt(float64(x))) + 1\n\n\tfor i := 0; i < len(primes) && primes[i] < sqrtx; i++ {\n\t\tif x%primes[i] == 0 {\n\t\t\tx /= primes[i]\n\n\t\t\tfor isNotPrime[x] && x%primes[i] == 0 {\n\t\t\t\tx /= primes[i]\n\t\t\t}\n\n\t\t\tif !isNotPrime[x] {\n\t\t\t\treturn x\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 1\n}\n\nfunc calcPrimes(n int) {\n\tisNotPrime = make([]bool, n+1)\n\n\tfor i := 2; i*i <= n; i++ {\n\t\tif !isNotPrime[i] {\n\t\t\tfor j := i * i; j <= n; j += i {\n\t\t\t\tisNotPrime[j] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tprimes = make([]int, 0, n/2)\n\n\tfor i := 2; i <= n; i++ {\n\t\tif !isNotPrime[i] {\n\t\t\tprimes = append(primes, i)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "550387db6b531c11e0e7c74478b15582", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/923/A\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tx2 int\n)\n\nfunc main() {\n\tx2 = ReadInt()\n\n\tmemo := TrialDivision(x2)\n\tmaxi := 1\n\tfor k := range memo {\n\t\tChMax(&maxi, k)\n\t}\n\n\tl := x2 - maxi + 1\n\tr := x2\n\n\t_, P := sieve(x2)\n\tans := INF_BIT30\n\tfor _, p := range P {\n\t\tif p >= l {\n\t\t\tcontinue\n\t\t}\n\n\t\tq := Kiriage(l, p)\n\t\tval := p * q\n\n\t\tif l <= val && val <= r {\n\t\t\tChMin(&ans, val-p+1)\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// エラトステネスの篩: O(NloglogN)\n// n以下の素数の数と素数のスライスを返す\nfunc sieve(n int) (int, []int) {\n\t// var prime [2000000 + 5]int\n\tprime := []int{}\n\tvar isPrime [2000000 + 5 + 1]bool\n\n\tp := 0\n\tfor i := 0; i <= n; i++ {\n\t\tisPrime[i] = true\n\t}\n\tisPrime[0], isPrime[1] = false, false\n\n\tfor i := 2; i <= n; i++ {\n\t\t// iがtrueで残っている場合は素数認定し、自分より大きい倍数を取り除いていく\n\t\tif isPrime[i] {\n\t\t\t// prime[p] = i\n\t\t\tprime = append(prime, i)\n\t\t\tp++\n\n\t\t\t// 倍数の除去\n\t\t\tfor j := 2 * i; j <= n; j += i {\n\t\t\t\tisPrime[j] = false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn p, prime\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// TrialDivision returns the result of prime factorization of integer N.\nfunc TrialDivision(n int) map[int]int {\n\tvar i, exp int\n\tp := map[int]int{}\n\n\tif n <= 1 {\n\t\tpanic(errors.New(\"[argument error]: TrialDivision only accepts a NATURAL number\"))\n\t}\n\n\tfor i = 2; i*i <= n; i++ {\n\t\texp = 0\n\t\tfor n%i == 0 {\n\t\t\texp++\n\t\t\tn /= i\n\t\t}\n\n\t\tif exp == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tp[i] = exp\n\t}\n\tif n > 1 {\n\t\tp[n] = 1\n\t}\n\n\treturn p\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "14a70bc31f05ffcfe87d21c12a7e1ec1", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc getMove(from, to int) int {\n\tif from > to {\n\t\tfrom, to = to, from\n\t}\n\n\treturn min(to-from, from+10-to)\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d \\n\", &n)\n\tresult := n\n\tfor i := 1; i < n; i++ {\n\t\tresult += i * (n - i)\n\t}\n\tfmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "a227a52ab3e457c56c51a58e2103348e", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n \"fmt\"\n)\nfunc main() {\n var n uint64\n fmt.Scan(&n)\n n = n*(n*n+5)/6\n fmt.Println(n)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "5539aeb12bc5f70710faa5dbde13b41e", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc buttons(n int64) (sum int64) {\n\tfor i := int64(0); i < n - 1; i++ {\n\t\tsum += (n - i) + (n - i - 1) * i\n\t}\n\treturn sum + 1\n}\n\nfunc main() {\n\tvar n int64\n\tfmt.Scanf(\"%d\", &n)\n\tfmt.Println(buttons(n))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "68812d34a55a11f22965885e93e87b89", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"math/big\"\n\t\"os\"\n\t\"strconv\"\n\t\"sync\"\n)\n\nconst (\n\tMAX_INT int64 = math.MaxInt64\n\tMIN_INT int64 = math.MinInt64\n)\n\nfunc main() {\n\tn := ScanInt64()\n\n\tans := int64(n)\n\tfor i := int64(2); i*i <= n; i++ {\n\t\tif n % i == 0 {\n\t\t\tans = GCD(i, ans)\n\t\t\tans = GCD(ans, n/i)\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n\n\tclose(out)\n\toutWg.Wait()\n}\n\nfunc isPrime(num int64) bool {\n\treturn big.NewInt(num).ProbablyPrime(20)\n}\n\n/*********************** I/O ***********************/\n\nvar out chan string\nvar in *bufio.Scanner\nvar outWg *sync.WaitGroup\n\nfunc init() {\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(2e+5))\n\tin.Split(bufio.ScanWords)\n\n\tout = make(chan string, 16)\n\toutWg = &sync.WaitGroup{}\n\toutWg.Add(1)\n\n\twriter := bufio.NewWriterSize(os.Stdout, int(2e+5))\n\tgo func(writer *bufio.Writer) {\n\t\tdefer outWg.Done()\n\t\tdefer writer.Flush()\n\n\t\tfor line := range out {\n\t\t\twriter.WriteString(line + \"\\n\")\n\t\t}\n\t}(writer)\n}\n\nfunc ScanWord() string {\n\tin.Scan()\n\treturn in.Text()\n}\n\nfunc ScanStringSlice(n int) []string {\n\ts := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\ts[i] = ScanWord()\n\t}\n\treturn s\n}\n\nfunc ScanInt64() int64 {\n\tintStr := ScanWord()\n\ti, err := strconv.ParseInt(intStr, 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc ScanInt64Slice(n int) []int64 {\n\tarr := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tarr[i] = ScanInt64()\n\t}\n\treturn arr\n}\n\n/*********************** Utils ***********************/\n\nfunc Max(args ...int64) int64 {\n\tmaxVal := MIN_INT\n\tfor _, v := range args {\n\t\tif v > maxVal {\n\t\t\tmaxVal = v\n\t\t}\n\t}\n\treturn maxVal\n}\n\nfunc Min(args ...int64) int64 {\n\tminVal := MAX_INT\n\tfor _, v := range args {\n\t\tif v < minVal {\n\t\t\tminVal = v\n\t\t}\n\t}\n\treturn minVal\n}\n\nfunc LCM(a, b int64) int64 {\n\treturn a / GCD(a, b) * b\n}\n\nfunc GCD(a, b int64) int64 {\n\tif (a == 0) {\n\t\treturn b\n\t}\n\treturn GCD(b%a, a)\n}\n\nfunc iToS(v int64) string {\n\treturn strconv.FormatInt(v, 10)\n}\n", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "50aaf1271fd7c2360a229dab1fc8c3a0", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\t// str := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n int64\n\nfunc main() {\n\tn = ReadInt64()\n\n\tif n == 1 {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\n\tif IsPrime(n) {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\n\t// D := divisor(n)\n\t// if len(D) == 3 {\n\t// \tfmt.Println(D[2])\n\t// \treturn\n\t// }\n\tmemo := TrialDivision(n)\n\tif len(memo) == 1 {\n\t\tfor k := range memo {\n\t\t\tfmt.Println(k)\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(1)\n}\n\n// 約数の列挙: O(sqrt(n))\nfunc divisor(n int64) []int64 {\n\tres := []int64{}\n\n\tfor i := int64(1); i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\tres = append(res, i)\n\t\t\tif i != (n / i) {\n\t\t\t\tres = append(res, (n / i))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn res\n}\n\n// TrialDivision returns the result of prime factorization of integer N.\nfunc TrialDivision(n int64) map[int64]int {\n\tif n <= 1 {\n\t\tpanic(errors.New(\"[argument error]: TrialDivision only accepts a NATURAL number\"))\n\t}\n\n\tp := map[int64]int{}\n\tfor i := int64(2); i*i <= n; i++ {\n\t\texp := 0\n\t\tfor n%i == 0 {\n\t\t\texp++\n\t\t\tn /= i\n\t\t}\n\n\t\tif exp == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tp[i] = exp\n\t}\n\tif n > 1 {\n\t\tp[n] = 1\n\t}\n\n\treturn p\n}\n\n// IsPrime judges whether an argument integer is a prime number or not.\nfunc IsPrime(n int64) bool {\n\tif n == 1 {\n\t\treturn false\n\t}\n\n\tfor i := int64(2); i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\n// エラトステネスの篩: O(NloglogN)\n// n以下の素数の数と素数のスライスを返す\nfunc sieve(n int) (int, []int) {\n\t// var prime [2000000 + 5]int\n\tprime := []int{}\n\tvar isPrime [2000000 + 5 + 1]bool\n\n\tp := 0\n\tfor i := 0; i <= n; i++ {\n\t\tisPrime[i] = true\n\t}\n\tisPrime[0], isPrime[1] = false, false\n\n\tfor i := 2; i <= n; i++ {\n\t\t// iがtrueで残っている場合は素数認定し、自分より大きい倍数を取り除いていく\n\t\tif isPrime[i] {\n\t\t\t// prime[p] = i\n\t\t\tprime = append(prime, i)\n\t\t\tp++\n\n\t\t\t// 倍数の除去\n\t\t\tfor j := 2 * i; j <= n; j += i {\n\t\t\t\tisPrime[j] = false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn p, prime\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "4666ffc8f832497ba3cbd501f5b50e9b", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"fmt\"\n\t\"bytes\"\n)\n\nconst GRID_SIZE = 3\n\ntype Grid [][]bool\n\nfunc main() {\n\tgrid := createSquareGrid(GRID_SIZE)\n\tfor i := 0; i < GRID_SIZE; i++ {\n\t\tfor j := 0; j < GRID_SIZE; j++ {\n\t\t\tvar n int\n\t\t\tfmt.Fscan(os.Stdin, &n)\n\t\t\tgrid.toggleNTimes(i, j, n)\n\t\t}\n\t}\n\tfmt.Print(grid)\n}\n\nfunc createSquareGrid(size int) Grid {\n\tgrid := make(Grid, size)\n\tfor rowIdx := range grid {\n\t\tgrid[rowIdx] = make([]bool, size)\n\t\tfor colIdx := range grid[rowIdx] {\n\t\t\tgrid[rowIdx][colIdx] = true\n\t\t}\n\t}\n\treturn grid\n}\n\nfunc (grid Grid) toggleNTimes(i, j, n int) {\n\tn = n % 2\n\tif (n > 0) {\n\t\ttoggle := func(i, j int) { grid[i][j] = !grid[i][j] }\n\t\ttoggle(i, j)\n\t\tif i > 0 { toggle(i-1, j) }\n\t\tif j > 0 { toggle(i, j-1) }\n\t\tif i < GRID_SIZE-1 { toggle(i+1, j) }\n\t\tif j < GRID_SIZE-1 { toggle(i, j+1) }\n\t}\n}\n\nfunc (grid Grid) String() string {\n\tvar buffer bytes.Buffer\n\tfor rowIdx := range grid {\n\t\tbuffer.WriteString(boolAsString(grid[rowIdx][0]))\n\t\tfor colIdx := 1; colIdx < len(grid[rowIdx]); colIdx++ {\n\t\t\tbuffer.WriteString(boolAsString(grid[rowIdx][colIdx]))\n\t\t}\n\t\tbuffer.WriteString(\"\\n\")\n\t}\n\treturn buffer.String()\n}\n\nfunc boolAsString(b bool) string {\n\tif b { return \"1\" }\n\treturn \"0\"\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "72b4745879433a62f04ae655d7834f5b", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 275A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\td := 3\n\tvar s [3][3]int\n\ttemp := 0\n\tfor row := 0; row < d; row++ {\n\t\tfor col := 0; col < d; col++ {\n\t\t\tfmt.Scan(&temp)\n\t\t\ts[row][col] += temp\n\t\t\tif row > 0 {\n\t\t\t\ts[row-1][col] += temp\n\t\t\t}\n\t\t\tif col > 0 {\n\t\t\t\ts[row][col-1] += temp\n\t\t\t}\n\t\t\tif row < d-1 {\n\t\t\t\ts[row+1][col] += temp\n\t\t\t}\n\t\t\tif col < d-1 {\n\t\t\t\ts[row][col+1] += temp\n\t\t\t}\n\t\t}\n\t}\n\tfor row := 0; row < d; row++ {\n\t\tfor col := 0; col < d; col++ {\n\t\t\tfmt.Printf(\"%d\", (1+s[row][col])%2)\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "afad6441b1f0b347970e22766e715f19", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 275A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a [5][5]int\n var m [5][5]int\n var k [5][5]int\n for i := 1; i < 4; i++ {\n for j := 1; j < 4; j++ {\n a[i][j] = 1\n }\n }\n\n for i := 1; i < 4; i++ {\n for j := 1; j < 4; j++ {\n fmt.Scan(&m[i][j])\n }\n }\n for i := 1; i < 4; i++ {\n for j := 1; j < 4; j++ {\n k[i][j] += m[i][j] + m[i-1][j] + m[i+1][j] + m[i][j-1] + m[i][j+1]\n }\n }\n for i := 1; i < 4; i++ {\n for j := 1; j < 4; j++ {\n if k[i][j]%2 == 1 {\n a[i][j] = 0\n }\n }\n }\n for i := 1; i < 4; i++ {\n for j := 1; j < 4; j++ {\n fmt.Print(a[i][j])\n }\n fmt.Println()\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "573d151fc87707b670ca6109bd1f6fa5", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc run(in io.Reader, out io.Writer) {\n\tconst mod int64 = 1e9 + 7\n\tf := func(n, m int) int64 {\n\t\tif m > n {\n\t\t\treturn 0\n\t\t}\n\t\tres := int64(1)\n\t\tfor i := 0; i < m; i++ {\n\t\t\tres = res * int64(n-i) % mod\n\t\t}\n\t\treturn res\n\t}\n\n\tvar n, x, pos, less, gr int\n\tFscan(in, &n, &x, &pos)\n\tsort.Search(n, func(mid int) bool {\n\t\tif mid < pos {\n\t\t\tless++\n\t\t} else if mid > pos {\n\t\t\tgr++\n\t\t}\n\t\treturn mid > pos\n\t})\n\tother := n - 1 - less - gr\n\tFprint(out, f(x-1, less)*f(n-x, gr)%mod*f(other, other)%mod)\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["binary search", "combinatorics"], "code_uid": "07fa3638f70bb1f32d25b4545c22d2ef", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc calc(m, l, x, n int64) int64 {\n\tif l > x-1 {\n\t\treturn 0\n\t}\n\tif m > n-x {\n\t\treturn 0\n\t}\n\tres := int64(1)\n\tmagic := int64(1000000007)\n\tfor i := int64(0); i < l; i++ {\n\t\tres = (res * (x - i - 1)) % magic\n\t}\n\tfor i := int64(0); i < m; i++ {\n\t\tres = (res * (n - x - i)) % magic\n\t}\n\tfor i := int64(1); i <= n-m-l-1; i++ {\n\t\tres = (res * i) % magic\n\t}\n\treturn res\n}\n\nfunc main() {\n\tio := bufio.NewReader(os.Stdin)\n\n\tvar n, x, pos int64\n\n\tfmt.Fscan(io, &n, &x, &pos)\n\n\tm := int64(0)\n\tl := int64(0)\n\n\tleft := int64(0)\n\tright := n\n\tmedian := int64(0)\n\tfor left < right {\n\t\tmedian = (left + right) / 2\n\t\tif median > pos {\n\t\t\tright = median\n\t\t\tm++\n\t\t} else if median < pos {\n\t\t\tleft = median + 1\n\t\t\tl++\n\t\t} else if median == pos {\n\t\t\tleft = median + 1\n\t\t}\n\t}\n\n\tfmt.Print(calc(m, l, x, n))\n}\n", "lang_cluster": "Go", "tags": ["binary search", "combinatorics"], "code_uid": "3ebe5cc492017fb0739d91f6507b8d81", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nconst mod int64 = 1e9 + 7\nfunc A(n, m int) int64 {\n\tif m > n { return 0 }\n\tx := int64(1)\n\tfor i := 0; i < m; i++ {\n\t\tx = x * int64(n-i) % mod\n\t}\n\treturn x\n}\nfunc main() {\n\tvar n, x, p, l, g int\n\tScan(&n, &x, &p)\n\tsort.Search(n, func(m int) bool {\n\t\tif m < p {l++} else if m > p {g++}\n\t\treturn m > p\n\t})\n\tm:=n-1-l-g\n\tPrint(A(x-1,l)*A(n-x,g)%mod*A(m,m)%mod)\n}\n", "lang_cluster": "Go", "tags": ["binary search", "combinatorics"], "code_uid": "96c07dd6ac0014e1684e6dffcb75c219", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\tfor minute := 0; ; minute++ {\n\t\tif isPalinrom(s) {\n\t\t\tfmt.Println(minute)\n\t\t\tbreak\n\t\t}\n\t\ts = inc(s)\n\t}\n}\n\nfunc inc(s string) string {\n\tele := strings.Split(s, \":\")\n\tminute, _ := strconv.Atoi(ele[1])\n\thour, _ := strconv.Atoi(ele[0])\n\tif minute == 59 {\n\t\thour++\n\t\tif hour == 24 {\n\t\t\thour = 0\n\t\t}\n\t\tminute = 0\n\t} else {\n\t\tminute++\n\t}\n\treturn fmt.Sprintf(\"%02d:%02d\", hour, minute)\n}\n\nfunc isPalinrom(s string) bool {\n\tfor i:= 0; i < len(s) / 2; i++ {\n\t\tif(s[i] != s[len(s)-i-1]) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "9a974446f509db00752e307a49deab06", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar H, M int\n\tfmt.Scanf(\"%d:%d %d\", &H, &M)\n\tcount := 0\n\tfor {\n\t\ts := fmt.Sprintf(\"%02d%02d\", H, M)\n\t\tsame := true\n\t\tfor i := 0; i <= len(s)/2; i++ {\n\t\t\tif s[i] != s[len(s)-i-1] {\n\t\t\t\tsame = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif same {\n\t\t\tbreak\n\t\t}\n\t\tcount++\n\t\tM++\n\t\tif M == 60 {\n\t\t\tM = 0\n\t\t\tH++\n\t\t\tif H == 24 {\n\t\t\t\tH = 0\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(count)\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "da834d3109fd664181f48a792b8b781f", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\nfunc getLine2Ints(n int) []int {\n\tans := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d \", &ans[i])\n\t}\n\tscanf(\"%d\\n\", &ans[n-1])\n\treturn ans\n}\n\nfunc pcheck(i bool) {\n\tif i {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n\nvar debug = true\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tvar hh, mm int\n\tscanf(\"%d:%d\\n\", &hh, &mm)\n\tfor i := 0; i < 24*60; i++ {\n\t\thtom := hh%10*10 + hh/10\n\t\tif htom == mm {\n\t\t\tprintf(\"%d\\n\", i)\n\t\t\treturn\n\t\t}\n\t\tmm = (mm + 1) % 60\n\t\tif mm == 0 {\n\t\t\thh = (hh + 1) % 24\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "b2044c798995c376f25a84aacc57defa", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"bytes\"\n\t\"os\"\n)\n\nfunc solve(k, a, b int64) int64 {\n\ta0 := a / k\n\tb0 := b / k\n\tif a - a0 * k > b0 * (k - 1) {\n\t\treturn -1\n\t}\n\tif b - b0 * k > a0 * (k - 1) {\n\t\treturn -1\n\t}\n\treturn a0 + b0\n}\n\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, 1<<16)\n\ts, _, _ := r.ReadLine()\n\tss := bytes.SplitN(s, []byte{' '}, 3)\n\tk, _ := strconv.ParseInt(string(ss[0]), 10, 32)\n\ta, _ := strconv.ParseInt(string(ss[1]), 10, 32)\n\tb, _ := strconv.ParseInt(string(ss[2]), 10, 32)\n\tfmt.Printf(\"%d\\n\", solve(k, a, b))\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "d2108106badee7c90023bfe2f07f7839", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n)\n\nfunc solve(k, a, b int64) int64 {\n\ta0 := a / k\n\tb0 := b / k\n\tif a - a0 * k > b0 * (k - 1) {\n\t\treturn -1\n\t}\n\tif b - b0 * k > a0 * (k - 1) {\n\t\treturn -1\n\t}\n\treturn a0 + b0\n}\n\nfunc main() {\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\tk := cin.nextInt64()\n\ta := cin.nextInt64()\n\tb := cin.nextInt64()\n\tfmt.Printf(\"%d\\n\", solve(k, a, b))\n}\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "223f096000b73b39509a207da09c774a", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1558B(in io.Reader, out io.Writer) {\r\n\tvar n, m int\r\n\tFscan(in, &n, &m)\r\n\tc := make([]int, n*2+2)\r\n\tc[n] = 1\r\n\tfor i := n - 1; i > 0; i-- {\r\n\t\tc[i] = 2 * c[i+1] % m\r\n\t\tfor j := 2; j*i <= n; j++ {\r\n\t\t\tc[i] = (c[i] + (c[i*j]+m-c[(i+1)*j])%m) % m\r\n\t\t}\r\n\t}\r\n\tFprint(out, ((c[1]-c[2])%m+m)%m)\r\n}\r\n\r\nfunc main() { CF1558B(os.Stdin, os.Stdout) }\r\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "two pointers", "number theory"], "code_uid": "04d4b878e2288d15e7566660dff5b527", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1558B(in io.Reader, out io.Writer) {\r\n\tvar n, m int\r\n\tFscan(in, &n, &m)\r\n\tf := make([]int, n+2)\r\n\tf[n] = 1\r\n\tfor i := n - 1; i > 0; i-- {\r\n\t\tf[i] = f[i+1] * 2 % m\r\n\t\tfor j := 2; j*i <= n; j++ {\r\n\t\t\tf[i] = (f[i] + (f[i*j]-f[min((i+1)*j, n+1)]+m)%m) % m\r\n\t\t}\r\n\t}\r\n\tFprint(out, (f[1]-f[2]+m)%m)\r\n}\r\n\r\nfunc main() { CF1558B(os.Stdin, os.Stdout) }\r\n\r\nfunc min(a, b int) int {\r\n\tif a > b {\r\n\t\treturn b\r\n\t}\r\n\treturn a\r\n}\r\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "two pointers", "number theory"], "code_uid": "a0f5d850ed24507cb2b14d636fb8b94f", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF533C(in io.Reader, out io.Writer) {\n\tmax := func(a, b int) int {\n\t\tif a > b {\n\t\t\treturn a\n\t\t}\n\t\treturn b\n\t}\n\tvar x1, y1, x2, y2 int\n\tFscan(in, &x1, &y1, &x2, &y2)\n\tif x1+y1 <= max(x2, y2) || x1 <= x2 && y1 <= y2 {\n\t\tFprint(out, \"Polycarp\")\n\t} else {\n\t\tFprint(out, \"Vasiliy\")\n\t}\n}\n\nfunc main() { CF533C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "games"], "code_uid": "737e66d8560c784223d9ca4231636acd", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var k int\n var s string\n var p [10]int\n fmt.Scan(&k)\n for i := 0; i < 4; i++ {\n fmt.Scan(&s)\n for _, v := range s {\n if v != '.' { p[v-'0']++ }\n }\n }\n ans := true\n for i := 0; i < 10; i++ {\n if p[i] > (2*k) { ans = false; break }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ea656534ef2de5579057cc2b7513ae22", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k int\n\tfmt.Scan(&k)\n\n\tdict := map[rune]int{}\n\tfor i := 0; i < 4; i++ {\n\t\tvar line string\n\t\tfmt.Scan(&line)\n\t\tfor _, char := range line {\n\t\t\tdict[char]++\n\t\t}\n\t}\n\n\tfor i := '0'; i <= '9'; i++ {\n\t\tif dict[i] > k*2 {\n\t\t\tfmt.Print(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Print(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a7c860abc39469ff5a870703824374a5", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 373A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var c, o, tw, th, fo, fi, si, se, ei, ni, k int\n var str string\n fmt.Scan(&k)\n c = 2 * k\n for i := 0; i < 4; i++ {\n fmt.Scan(&str)\n for j := 0; j < 4; j++ {\n if str[j] == '1' {\n o++\n } else if str[j] == '2' {\n tw++\n } else if str[j] == '3' {\n th++\n } else if str[j] == '4' {\n fo++\n } else if str[j] == '5' {\n fi++\n } else if str[j] == '6' {\n si++\n } else if str[j] == '7' {\n se++\n } else if str[j] == '8' {\n ei++\n } else if str[j] == '9' {\n ni++\n }\n }\n }\n if (o > c) || (tw > c) || (th > c) || (fo > c) || (fi > c) || (si > c) || (se > c) || (ei > c) || (ni > c) {\n fmt.Println(\"NO\")\n return\n }\n fmt.Println(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5e547e2fe6d17929ef956bbe2375d0d7", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a,b,c int\n fmt.Scan(&a,&b,&c)\n fmt.Println((a*b)+((c-1)*a)+((b-1)*(c-1)))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "62fcbd2839748d4e36fac13d4101ab93", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"bufio\"\n\t//\"os\"\n\t//\"strconv\"\n)\n\nfunc main() {\n\tvar a,b,c,d int\n\tfmt.Scan(&a,&b,&c)\n\td=c*b+(a-1)*b+(c-1)*(a-1)\n\tfmt.Println(d)\n}\n\n\n\n\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "0bc1663f5bf0a4b87a8e4d4d5e2f23be", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 216A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, b, c, x int\n fmt.Scan(&a, &b, &c)\n x = (b - 1) * (c - 1)\n x += a * (b + c - 1)\n fmt.Println(x)\n\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c1153fa105b8ff224a819c46543b2d23", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\"fmt\"\n\t\"sync\"\n\n\t\"math\"\n)\n\n\n\n\ntype changer func(int64) (int64, int)\n\nvar min struct {\n \tmt sync.RWMutex\n\tdata int\n}\n\n\nfunc decision(p int64, x int64, y int64, f changer, wg* sync.WaitGroup ) {\n\tdefer wg.Done()\n\ts := x\n\trandomizer := func() bool{\n\t\ti := (s / 50) % 475\n\t\tfor j:=0 ; j< 25; j++ {\n\t\t\ti = (i * 96 + 42) % 475\n\t\t\tif 26+i == p {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\tcur := 0\n\tflag := true\n\tfor;flag;{\n\t\tif randomizer() {\n\t\t\tmin.mt.Lock()\n\t\t\tif min.data > cur {\n\t\t\t\tmin.data = cur\n\t\t\t}\n\t\t\tmin.mt.Unlock()\n\t\t\treturn\n\t\t}\n\t\tmin.mt.RLock()\n\t\tif min.data < cur {\n\t\t\tflag = false\n\t\t} else {\n\t\t\tvar dt int\n\t\t\ts, dt = f(s)\n\t\t\tcur += dt\n\t\t}\n\t\tmin.mt.RUnlock()\n\t\tif y>s{\n\t\t\tflag = false\n\t\t}\n\t}\n}\n\nfunc decision_starter(p int64, x int64, y int64, f changer, wg* sync.WaitGroup) {\n\twg.Add(1)\n\tdecision(p,x,y,f,wg)\n}\n\nfunc main() {\n\tstrat1 := func(num int64)(int64,int) {\n\t\tnum+=100\n\t\treturn num,1\n\t}\n\tstrat2 := func(num int64)(int64,int) {\n\t\tnum-=50\n\t\treturn num,0\n\t}\n\tflag := true\n\tstrat3 := func(num int64)(int64,int) {\n\t\tif flag {\n\t\t\tnum+=50\n\t\t\tflag = false\n\t\t\treturn num,1\n\t\t}\n\n\t\tnum+=100\n\t\treturn num,1\n\t}\n\tvar p,x,y int64\n\twg := sync.WaitGroup{}\n\tfmt.Scanf(\"%d %d %d\",&p,&x,&y)\n\t//26 7258 6123\n\t//p = 26\n\t//x = 7258\n\t//y = 6123\n\tmin.data = math.MaxInt32\n\tdecision_starter(p,x,y,strat1,&wg)\n\tdecision_starter(p,x,y,strat2,&wg)\n\tdecision_starter(p,x,y,strat3,&wg)\n\twg.Wait()\n\tmin.mt.RLock()\n\tfmt.Printf(\"%d \",min.data)\n\tmin.mt.RUnlock()\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "b9a92ed951539361e4a36d374827aa0a", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\"fmt\"\n\t\"sync\"\n\n\t\"math\"\n)\n\n\n\n\ntype changer func(int64) (int64, int)\n\nvar min struct {\n \tmt sync.RWMutex\n\tdata int\n}\n\n\nfunc decision(p int64, x int64, y int64, f changer, wg* sync.WaitGroup ) {\n\tdefer wg.Done()\n\ts := x\n\trandomizer := func() bool{\n\t\ti := (s / 50) % 475\n\t\tfor j:=0 ; j< 25; j++ {\n\t\t\ti = (i * 96 + 42) % 475\n\t\t\tif 26+i == p {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\tcur := 0\n\tflag := true\n\tfor;flag;{\n\t\tif randomizer() {\n\t\t\tmin.mt.Lock()\n\t\t\tif min.data > cur {\n\t\t\t\tmin.data = cur\n\t\t\t}\n\t\t\tmin.mt.Unlock()\n\t\t\treturn\n\t\t}\n\t\tmin.mt.RLock()\n\t\tif min.data < cur {\n\t\t\tflag = false\n\t\t} else {\n\t\t\tvar dt int\n\t\t\ts, dt = f(s)\n\t\t\tcur += dt\n\t\t}\n\t\tmin.mt.RUnlock()\n\t\tif y>s{\n\t\t\tflag = false\n\t\t}\n\t}\n}\n\nfunc decision_starter(p int64, x int64, y int64, f changer, wg* sync.WaitGroup) {\n\twg.Add(1)\n\tgo decision(p,x,y,f,wg)\n}\n\nfunc main() {\n\tstrat1 := func(num int64)(int64,int) {\n\t\tnum+=100\n\t\treturn num,1\n\t}\n\tstrat2 := func(num int64)(int64,int) {\n\t\tnum-=50\n\t\treturn num,0\n\t}\n\tflag := true\n\tstrat3 := func(num int64)(int64,int) {\n\t\tif flag {\n\t\t\tnum+=50\n\t\t\tflag = false\n\t\t\treturn num,1\n\t\t}\n\n\t\tnum+=100\n\t\treturn num,1\n\t}\n\tvar p,x,y int64\n\twg := sync.WaitGroup{}\n\tfmt.Scanf(\"%d %d %d\",&p,&x,&y)\n\t//26 7258 6123\n\t//p = 26\n\t//x = 7258\n\t//y = 6123\n\tmin.data = math.MaxInt32\n\tdecision_starter(p,x,y,strat1,&wg)\n\tdecision_starter(p,x,y,strat2,&wg)\n\tdecision_starter(p,x,y,strat3,&wg)\n\twg.Wait()\n\tmin.mt.RLock()\n\tfmt.Printf(\"%d \",min.data)\n\tmin.mt.RUnlock()\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "c20f16841eb14b170226ae05b5d3ce76", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar p, x, y int\n\nfunc check(nowx int) bool {\n\ti := (nowx / 50) % 475\n\tfor j := 0; j < 25; j++ {\n\t\ti = (i*96 + 42) % 475\n\t\tif i+26 == p {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tfmt.Scan(&p)\n\tfmt.Scan(&x)\n\tfmt.Scan(&y)\n\n\tvar ansa int\n\n\tfor nowx := y/50*50 + x%50; ; nowx += 50 {\n\t\tfor nowx < y {\n\t\t\tnowx += 50\n\t\t}\n\t\tif check(nowx) {\n\t\t\tansa = (nowx - x) / 100\n\t\t\tif (nowx-x)%100 != 0 {\n\t\t\t\tansa++\n\t\t\t}\n\t\t\tif nowx <= x {\n\t\t\t\tansa = 0\n\t\t\t}\n\t\t\tfmt.Println(ansa)\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "5cf9ede18f853833214e409b316df8ba", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol1230C(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n, m int\n\tFscan(in, &n, &m)\n\tedges := make([][]int, n+1)\n\tshown := map[int]int{}\n\tfor i := 0; i < m; i++ {\n\t\tvar v, w int\n\t\tFscan(in, &v, &w)\n\t\tedges[v] = append(edges[v], w)\n\t\tedges[w] = append(edges[w], v)\n\t\tshown[v] = 1\n\t\tshown[w] = 1\n\t}\n\tif len(shown) <= 6 {\n\t\tFprintln(out, m)\n\t\treturn\n\t}\n\n\tans := 0\n\tfor v, e := range edges {\n\t\tif len(e) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tfor w, e2 := range edges {\n\t\t\tif w == v || len(e2) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdelta := 0\n\t\t\tfor _, u := range e2 {\n\t\t\t\tif u == v {\n\t\t\t\t\tdelta = 1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tmp := map[int]int{}\n\t\t\tfor _, u := range append(e, e2...) {\n\t\t\t\tif u == v {\n\t\t\t\t\tu = w\n\t\t\t\t}\n\t\t\t\tmp[u] = 1\n\t\t\t}\n\t\t\tdelta = len(e) + len(e2) - delta - len(mp)\n\t\t\tif newAns := m - delta; newAns > ans {\n\t\t\t\tans = newAns\n\t\t\t}\n\t\t}\n\t}\n\tFprintln(out, ans)\n}\n\nfunc main() {\n\tSol1230C(os.Stdin, os.Stdout)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "graphs"], "code_uid": "d27211fab414dfbb08f6a6872cf66afd", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// DigitSum returns digit sum of a decimal number.\n// DigitSum only accept a positive integer.\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\n// DigitNumOfDecimal returns digits number of n.\n// n is non negative number.\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of `strconv.Atoi()`.\n// If `strconv.Atoi()` returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\t// str := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n, m int\n\nvar ans int\nvar edges []Edge\n\ntype Edge struct {\n\ts, t int\n}\n\nfunc main() {\n\tn, m = ReadInt2()\n\tfor i := 0; i < m; i++ {\n\t\ts, t := ReadInt2()\n\t\ts--\n\t\tt--\n\t\tedges = append(edges, Edge{s, t})\n\t}\n\n\tv := []int{}\n\tdfs(v)\n\tfmt.Println(ans)\n}\n\nfunc dfs(v []int) {\n\tif len(v) == n {\n\t\tA := [6][6]int{}\n\t\tfor i := 0; i < 6; i++ {\n\t\t\tfor j := 0; j < 6; j++ {\n\t\t\t\tA[i][j] = 1\n\t\t\t}\n\t\t}\n\n\t\tcnt := 0\n\t\tfor _, e := range edges {\n\t\t\tl, r := v[e.s], v[e.t]\n\t\t\tif A[l][r] == 1 {\n\t\t\t\tA[l][r], A[r][l] = 0, 0\n\t\t\t\tcnt++\n\t\t\t}\n\t\t}\n\t\tChMax(&ans, cnt)\n\t} else {\n\t\tfor i := 0; i <= 5; i++ {\n\t\t\ttmp := CopySlice(v)\n\t\t\ttmp = append(tmp, i)\n\t\t\tdfs(tmp)\n\t\t}\n\t}\n}\n\nfunc CopySlice(v []int) []int {\n\tres := make([]int, len(v))\n\tfor i := 0; i < len(v); i++ {\n\t\tres[i] = v[i]\n\t}\n\treturn res\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n", "lang_cluster": "Go", "tags": ["brute force", "graphs"], "code_uid": "16db6e0d76621bb78fff735a8fdb9338", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1230/problem/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Edge struct {\n\tA int\n\tB int\n}\n\nfunc createMatrix(n int, m int, edges []Edge) [][]bool {\n\tmatrix := make([][]bool, n)\n\tfor i := 0; i < n; i++ {\n\t\tmatrix[i] = make([]bool, n)\n\t}\n\tfor _, edge := range edges {\n\t\tmatrix[edge.A-1][edge.B-1] = true\n\t\tmatrix[edge.B-1][edge.A-1] = true\n\t}\n\treturn matrix\n}\n\nfunc Solve(n int, m int, edges []Edge) int {\n\tif n < 7 {\n\t\treturn m\n\t}\n\tmatrix := createMatrix(n, m, edges)\n\tminMutualNeighbors := n + 1\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i + 1; j < n; j++ {\n\t\t\tmutualNeighbors := 0\n\t\t\tfor z := 0; z < n; z++ {\n\t\t\t\tif z != i && z != j && matrix[i][z] && matrix[j][z] {\n\t\t\t\t\tmutualNeighbors += 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tif mutualNeighbors < minMutualNeighbors {\n\t\t\t\tminMutualNeighbors = mutualNeighbors\n\t\t\t}\n\t\t}\n\t}\n\treturn m - minMutualNeighbors\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n, m int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &m)\n\tedges := make([]Edge, m)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Fscanf(reader, \"%d %d\\n\", &edges[i].A, &edges[i].B)\n\t}\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, m, edges))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "graphs"], "code_uid": "b0105fcc5553e00a40227766e1b4dd10", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n\nimport (\n\n \"fmt\"\n\n \"sort\"\n\n)\n\n\nfunc main() {\n\n var n int\n\n fmt.Scan(&n)\n\n a := make([]int,n)\n\n for i := 0; i < n; i++ {\n fmt.Scan(&a[i])\n }\n\n sort.Ints(a)\n\n fmt.Print(a[n-1],\" \")\n\n for i := 1; i < (n-1); i++ {\n fmt.Print(a[i],\" \")\n }\n\n fmt.Println(a[0])\n\n}\n", "lang_cluster": "Go", "tags": ["sortings", "constructive algorithms", "implementation"], "code_uid": "968f1c7f9a332bbba23015756002a5d6", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n\nimport (\n\n\t\"fmt\"\n\n\t\"sort\"\n\n)\n\n\nfunc main() {\n\n\tvar n int\n\n\tfmt.Scan(&n)\n\n\ta := make([]int,n)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\n\tsort.Ints(a)\n\n\tfmt.Print(a[n-1],\" \")\n\n\tfor i := 1; i < (n-1); i++ {\n\t\tfmt.Print(a[i],\" \")\n\t}\n\n\tfmt.Println(a[0])\n\n}\n", "lang_cluster": "Go", "tags": ["sortings", "constructive algorithms", "implementation"], "code_uid": "b36484982ff41165428f5f20aba6a529", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n a := make([]int,n)\n for i := 0; i < n; i++ { fmt.Scan(&a[i]) }\n sort.Ints(a)\n fmt.Print(a[n-1],\" \")\n for i := 1; i < (n-1); i++ { fmt.Print(a[i],\" \") }\n fmt.Println(a[0])\n}\n", "lang_cluster": "Go", "tags": ["sortings", "constructive algorithms", "implementation"], "code_uid": "0684e6a79d2e812b365ceb1cbc3a1c84", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nconst MOD = int64(1e9 + 7)\n\nvar (\n\tk int64\n\tn int64\n\tinv [100]int64\n)\n\nfunc qpow(x, k int64) int64 {\n\tvar y int64 = 1\n\tfor k > 0 {\n\t\tif k%2 > 0 {\n\t\t\ty = y * x % MOD\n\t\t}\n\t\tk >>= 1\n\t\tx = x * x % MOD\n\t}\n\treturn y\n}\nfunc solve(x int64, cnt int64) int64 {\n\tdp := [10001][60]int64{}\n\ts := int64(1)\n\tfor i := int64(0); i <= cnt; i++ {\n\t\tdp[0][i] = s\n\t\ts = s * x % MOD\n\t}\n\tfor i := int64(1); i <= k; i++ {\n\t\tvar s int64 = 0\n\t\tfor j := int64(0); j <= cnt; j++ {\n\t\t\ts += dp[i-1][j]\n\t\t\tif s >= MOD {\n\t\t\t\ts -= MOD\n\t\t\t}\n\t\t\tdp[i][j] = s * inv[j+1] % MOD\n\t\t}\n\t}\n\treturn dp[k][cnt]\n}\n\nfunc main() {\n\tfor i := int64(1); i < 100; i++ {\n\t\tinv[i] = qpow(i, MOD-2)\n\t}\n\tfmt.Scanln(&n, &k)\n\tvar ans int64 = 1\n\tfor i := int64(2); i*i <= n; i++ {\n\t\tvar c int64 = 0\n\t\tfor n%i == 0 {\n\t\t\tc++\n\t\t\tn /= i\n\t\t}\n\t\tif c > 0 {\n\t\t\tans = ans * solve(i, c) % MOD\n\t\t}\n\t}\n\tif n > 1 {\n\t\tans = ans * solve(n, 1) % MOD\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "55d2f964a4de5b74b6ac975ee7d755e9", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, k int64\n\tfmt.Scanf(\"%d %d %d\", &l, &r, &k)\n\tm := foo(l, r, k)\n\tfmt.Print(m)\n}\nfunc foo(l, r, k int64) int64 {\n\tmin := Min(l, r)\n\tmax := Max(l, r)\n\tif min+k < max {\n\t\treturn 2 * (min + k)\n\t} else {\n\t\tm := 2 * max\n\t\tk = k - (max - min)\n\t\tk = (k / 2) * 2\n\t\treturn m + k\n\t}\n}\nfunc Min(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc Max(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "1516a909f25b07f1237f51bf7c6d6602", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r, a int\n\tfmt.Scanf(\"%d %d %d\", &l, &r, &a)\n\n\tif l > r {\n\t\ttmp := l\n\t\tl = r\n\t\tr = tmp\n\t}\n\n\tres := l\n\tif r-l >= a {\n\t\tres += a\n\t} else {\n\t\tres += (a + r - l) / 2\n\t}\n\n\tres *= 2\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "8d865d6e6e9b94b23bfa1523167f816b", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, a, max, min, rem int\n\tfmt.Scanf(\"%d %d %d\", &l, &r, &a)\n\tif l < r {\n\t\tmin = l\n\t\tmax = r\n\t} else {\n\t\tmin = r\n\t\tmax = l\n\t}\n\trem = max - min\n\tif rem >= a {\n\t\tmin = min + a\n\t} else {\n\t\tmin = min + rem\n\t\ta = a - rem\n\t\tif a%2 == 0 {\n\t\t\tmin = min + (a / 2)\n\t\t} else {\n\t\t\tmin = min + ((a - 1) / 2)\n\t\t}\n\t}\n\tfmt.Println(min * 2)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "d63562fb1ffc7d867686591f64ac5df8", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc gcd(a, b int64) int64 {\n\tif a % b == 0 {\n\t\treturn b\n\t} else {\n\t\treturn gcd(b , a % b)\n\t}\n}\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tvar la, ra, ta, lb, rb, tb int64\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &la, &ra, &ta)\n\tfmt.Fscanf(reader, \"%d %d %d\", &lb, &rb, &tb)\n\n\tfactor := gcd(ta, tb)\n\n\tvar ans1, ans2 int64\n\n\t// Bob first, Alice after\n\t// (la - lb) + (ka * ta) - (kb * tb) = diff > 0\n\tdiff1 := (la - lb) % factor\n\tif diff1 < 0 {\n\t\tdiff1 += factor\n\t}\n\tif rb - lb + 1 < diff1 {\n\t\tans1 = 0\n\t} else if rb - lb + 1 > diff1 + (ra - la + 1) {\n\t\tans1 = ra - la + 1\n\t} else {\n\t\tans1 = rb - lb + 1 - diff1\n\t}\n\n\tdiff2 := (lb - la) % factor\n\tif diff2 < 0 {\n\t\tdiff2 += factor\n\t}\n\tif ra - la + 1 < diff2 {\n\t\tans2 = 0\n\t} else if ra - la + 1 > diff2 + (rb - lb + 1) {\n\t\tans2 = rb - lb + 1\n\t} else {\n\t\tans2 = ra - la + 1 - diff2\n\t}\n\tif ans1 > ans2 {\n\t\tfmt.Printf(\"%d\", ans1)\n\t} else {\n\t\tfmt.Printf(\"%d\", ans2)\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "8b6baa4003b14b69cba3601199383e1c", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nconst s = 10\n\nfunc sumDig(n int) int {\n\ts := 0\n\tfor n != 0 {\n\t\ts += n % 10\n\t\tn /= 10\n\t}\n\treturn s\n}\n\nfunc main() {\n\tvar k int\n\tfmt.Scanf(\"%d\\n\", &k)\n\t//fmt.Printf(\"Scanned: %d\\n\", k)\n\tn := 15\n\tdp := make([][]int, n+1)\n\tfor i := 0; i <= n; i++ {\n\t\tdp[i] = make([]int, s+1)\n\t}\n\tdp[0][0] = 1\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := 1; j <= 10; j++ {\n\t\t\tdp[i-1][j] += dp[i-1][j-1]\n\t\t}\n\t\tfor j := 0; j <= 10; j++ {\n\t\t\tdp[i][j] = dp[i-1][j]\n\t\t}\n\t\tdp[i][10]--\n\t\tfor j := 10; j > 0; j-- {\n\t\t\tdp[i-1][j] -= dp[i-1][j-1]\n\t\t}\n\t\t// if i == 1 {\n\t\t// \tfor j := 1; j <= 9; j++ {\n\t\t// \t\tdp[i-1][j] += dp[i-1][j-1]\n\t\t// \t}\n\t\t// } else {\n\t\t// \tfor j := 1; j <= 10; j++ {\n\n\t\t// \t\tdp[i-1][j] += dp[i-1][j-1]\n\t\t// \t}\n\t\t// }\n\t\t// if i == 1 {\n\t\t// \tfor j := 1; j <= 10; j++ {\n\t\t// \t\tdp[i][j] = dp[i-1][j]\n\t\t// \t}\n\t\t// } else {\n\t\t// \tfor j := 0; j <= 10; j++ {\n\t\t// \t\tdp[i][j] = dp[i-1][j]\n\t\t// \t}\n\t\t// }\n\t\t// if i == 1 {\n\t\t// \tfor j := 9; j > 0; j-- {\n\t\t// \t\tdp[i-1][j] -= dp[i-1][j-1]\n\t\t// \t}\n\t\t// } else {\n\t\t// \tfor j := 10; j > 0; j-- {\n\t\t// \t\tdp[i-1][j] -= dp[i-1][j-1]\n\t\t// \t}\n\t\t// }\n\t}\n\t//fmt.Printf(\"%v\\n\", dp)\n\tvar ans int\n\ts := 10\n\tfor i := 15; i > 0; i-- {\n\t\tvar j int\n\t\t// if i == 1 {\n\t\t// \tfor j = 1; j <= 9; j++ {\n\t\t// \t\tif dp[i-1][s-j] < k {\n\t\t// \t\t\tk -= dp[i-1][s-j]\n\t\t// \t\t} else {\n\t\t// \t\t\tbreak\n\t\t// \t\t}\n\t\t// \t}\n\t\t// } else {\n\t\tfor j = 0; j <= 9; j++ {\n\t\t\tif dp[i-1][s-j] < k {\n\t\t\t\tk -= dp[i-1][s-j]\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t//\t}\n\t\ts -= j\n\t\tans = j + ans*10\n\t}\n\tfmt.Println(ans)\n\t// fmt.Println(\"Hello World!\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp", "binary search", "implementation", "number theory"], "code_uid": "ed7f48be5204f3f6140ae2365abed7d0", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc count(K int) int {\n\ta := 0\n\tfor K > 0 {\n\t\ta += K % 10\n\t\tK /= 10\n\t}\n\treturn a\n}\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\tp := 10\n\tfor cnt := 0; cnt < N; {\n\t\tp += 9\n\n\t\tif count(p) == 10 {\n\t\t\tcnt++\n\t\t}\n\n\t}\n\tfmt.Println(p)\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp", "binary search", "implementation", "number theory"], "code_uid": "d50d2ce38e166ee0ff94a6e3c5368977", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc digitCnt(n int) int {\n d := 0\n for n > 0 {\n d += n % 10\n n /= 10\n }\n return d\n}\n\nfunc main() {\n var k int\n fmt.Scan(&k)\n i := 0\n answer := 0\n for i < k {\n answer += 1\n if digitCnt(answer) == 10 {\n i++\n }\n }\n fmt.Print(answer)\n}", "lang_cluster": "Go", "tags": ["brute force", "dp", "binary search", "implementation", "number theory"], "code_uid": "5744866484cc982987875964c19de10e", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc abs(x int) int {\n\tif x >= 0 {\n\t\treturn x\n\t}\n\treturn -x\n}\n\nfunc div(n *int, d int) int {\n\tans := 0\n\tfor (*n) % d == 0 {\n\t\t(*n) /= d\n\t\tans += 1\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\\n\", &a, &b)\n\ta2 := div(&a, 2)\n\ta3 := div(&a, 3)\n\ta5 := div(&a, 5)\n\tb2 := div(&b, 2)\n\tb3 := div(&b, 3)\n\tb5 := div(&b, 5)\n\tans := abs(a2 - b2) + abs(a3 - b3) + abs(a5 - b5)\n\tif a != b {\n\t\tans = -1\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "44130b19cdf6efb1ad34abf7d37c2f26", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//371B\npackage main\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b, c, d int\n\tvar i, j, k, l, m, n, x float64\n\tfmt.Scan(&a, &b)\n\tfor a!=0 {\n\t\tif a%2==0 {\n\t\t\ta=a/2\n\t\t\ti++\n\t\t} else if a%3==0 {\n\t\t\ta=a-(a/3*2)\n\t\t\tj++\n\t\t} else if a%5==0 {\n\t\t\ta=a-(a/5*4)\n\t\t\tk++\n\t\t} else {\n\t\t\tc=a\n\t\t\tbreak\n\t\t}\n\t}\n\tfor b!=0 {\n\t\tif b%2==0 {\n\t\t\tb=b/2\n\t\t\tl++\n\t\t} else if b%3==0 {\n\t\t\tb=b-(b/3*2)\n\t\t\tm++\n\t\t} else if b%5==0 {\n\t\t\tb=b-(b/5*4)\n\t\t\tn++\n\t\t} else {\n\t\t\td=b\n\t\t\tbreak\n\t\t}\n\t}\n\tif c==d {\n\t\tx=math.Abs(i-l)+math.Abs(j-m)+math.Abs(k-n)\n\t\tfmt.Println(x)\n\t} else {\n\t\tfmt.Println(\"-1\")\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "7df52064ff70e88649e053a3e22fbcfd", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 371B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(x, y int) int {\n\tfor y != 0 {\n\t\tx, y = y, x%y\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar a, b, k int\n\tfmt.Scan(&a, &b)\n\tx := gcd(a, b)\n\tif x != 1 {\n\t\ta /= x\n\t\tb /= x\n\t}\n\tfor {\n\t\tif a == b {\n\t\t\tbreak\n\t\t}\n\t\tif a < b {\n\t\t\ta, b = b, a\n\t\t} else if a > b && a%2 != 0 && a%3 != 0 && a%5 != 0 {\n\t\t\tb, a = a, b\n\t\t}\n\t\tif a%2 != 0 && a%3 != 0 && a%5 != 0 && b%2 != 0 && b%3 != 0 && b%5 != 0 {\n\t\t\tfmt.Println(\"-1\")\n\t\t\treturn\n\t\t}\n\t\tif a%2 == 0 {\n\t\t\ta /= 2\n\t\t\tk++\n\t\t} else if a%3 == 0 {\n\t\t\ta /= 3\n\t\t\tk++\n\t\t} else if a%5 == 0 {\n\t\t\ta /= 5\n\t\t\tk++\n\t\t}\n\t}\n\tfmt.Println(k)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "ae9af86bbd99a7481f9803a4ce249e1a", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main(){\n\tvar s,v1,v2,t1,t2 int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in,&s,&v1,&v2,&t1,&t2)\n\ta1 := 2*t1+s*v1\n\ta2 := 2*t2+s*v2\n\tif a1 receiver2 {\n\t\treturn \"Second\"\n\t} else {\n\t\treturn \"Friendship\"\n\t}\n}\n\nfunc arrInput(numbers []string) string {\n\tcharacter, err := strconv.ParseInt(numbers[0], 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvelocity1, err := strconv.ParseInt(numbers[1], 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvelocity2, err := strconv.ParseInt(numbers[2], 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdelay1, err := strconv.ParseInt(numbers[3], 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdelay2, err := strconv.ParseInt(numbers[4], 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treceiver1 := receiver(character, velocity1, delay1)\n\treceiver2 := receiver(character, velocity2, delay2)\n\treturn compareTimeConsume(receiver1, receiver2)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\tnumbers := strings.Fields(text)\n\tfmt.Println(arrInput(numbers))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "e1bd75b96e73e801a42a5963c6c00d45", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// A. Key races\n/*\nTwo boys decided to compete in text typing on the site \"Key races\". During the competition, they have to type a text consisting of s characters. The first participant types one character in v1 milliseconds and has ping t1 milliseconds. The second participant types one character in v2 milliseconds and has ping t2 milliseconds.\n\nIf connection ping (delay) is t milliseconds, the competition passes for a participant as follows:\n\n Exactly after t milliseconds after the start of the competition the participant receives the text to be entered.\n Right after that he starts to type it.\n Exactly t milliseconds after he ends typing all the text, the site receives information about it.\n\nThe winner is the participant whose information on the success comes earlier. If the information comes from both participants at the same time, it is considered that there is a draw.\n\nGiven the length of the text and the information about participants, determine the result of the game.\n\nInput\nThe first line contains five integers s, v1, v2, t1, t2 (1 ≤ s, v1, v2, t1, t2 ≤ 1000) — the number of characters in the text, the time of typing one character for the first participant, the time of typing one character for the the second participant, the ping of the first participant and the ping of the second participant.\n\nOutput\nIf the first participant wins, print \"First\". If the second participant wins, print \"Second\". In case of a draw print \"Friendship\".\n\nExamples\nInput\n5 1 2 1 2\n\nOutput\nFirst\n\nInput\n3 3 1 1 1\n\nOutput\nSecond\n\nInput\n4 5 3 1 5\n\nOutput\nFriendship\n\nNote\nIn the first example, information on the success of the first participant comes in 7 milliseconds, of the second participant — in 14 milliseconds. So, the first wins.\n\nIn the second example, information on the success of the first participant comes in 11 milliseconds, of the second participant — in 5 milliseconds. So, the second wins.\n\nIn the third example, information on the success of the first participant comes in 22 milliseconds, of the second participant — in 22 milliseconds. So, it is be a draw.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\tn := strings.Split(strings.TrimSpace(input), \" \")\n\n\ts, _ := strconv.Atoi(string(n[0]))\n\tv1, _ := strconv.Atoi(string(n[1]))\n\tv2, _ := strconv.Atoi(string(n[2]))\n\tt1, _ := strconv.Atoi(string(n[3]))\n\tt2, _ := strconv.Atoi(string(n[4]))\n\n\tv1Total := (s * v1) + (t1 * 2)\n\tv2Total := (s * v2) + (t2 * 2)\n\n\tif v1Total < v2Total {\n\t\tfmt.Println(\"First\")\n\t} else if v2Total < v1Total {\n\t\tfmt.Println(\"Second\")\n\t} else {\n\t\tfmt.Println(\"Friendship\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "b798a3c167bdd7c31aeb2852405092f2", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tX := io.NextInt()\n\tY := io.NextInt()\n\t\n\tif Y < 1 {\n\t io.Println(\"No\")\n\t return\n\t}\n\t\n\tif (Y == 1) {\n\t if (X == 0) {\n\t io.Println(\"Yes\")\n\t } else {\n\t io.Println(\"No\")\n\t }\n\t return\n\t}\n\t\n\tif Y <= X + 1 && (X + Y) % 2 == 1 {\n\t io.Println(\"Yes\")\n\t} else {\n\t io.Println(\"No\")\n\t}\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "479f90c87ff1860477f643392e0caaf9", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc fastRead(reader *bufio.Reader) (i int, j int) {\n\tvar c rune\n\tc, _, _ = reader.ReadRune()\n\n\t//space = 32\n\t//space and between 0-9\n\tfor c != 32 && c > 47 && c < 58 {\n\t\t//x = x*10+c\n\t\ti = (i << 1) + (i << 3) + int(c) - 48\n\t\tc, _, _ = reader.ReadRune()\n\t}\n\n\tc, _, _ = reader.ReadRune()\n\t//newline = 10\n\tfor c != 10 && c > 47 && c < 58 {\n\t\t//x = x*10+c\n\t\tj = (j << 1) + (j << 3) + int(c) - 48\n\t\tc, _, _ = reader.ReadRune()\n\t}\n\n\treturn\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tvar x, y = fastRead(reader)\n\n\tif y <= 0 || (x%2 == 0 && y%2 == 0) {\n\t\tfmt.Println(\"No\")\n\t\treturn\n\t}\n\n\tvar x2 = x - (y - 1)\n\t/*for x1 < x {\n\t\tx1 += 2\n\t}*/\n\n\tif x2 < 0 || y <= 1 && x > 0 || x2%2 == 1 {\n\t\tfmt.Println(\"No\")\n\t} else {\n\t\tfmt.Println(\"Yes\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "83fea2c950252c67044ad8e5792f34e2", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y int64\n\tfmt.Scan(&x, &y)\n\tcal := x - (y - 1)\n\tif x == 0 && y == 1 {\n\t\tfmt.Printf(\"yes\")\n\t} else if x == 1 && y == 0 {\n\t\tfmt.Printf(\"no\")\n\t} else if cal%2 == 0 && cal > 0 && y-1 > 0 {\n\t\tfmt.Printf(\"yes\")\n\t} else if cal <= 0 && y-1 == x {\n\t\tfmt.Printf(\"yes\")\n\t} else {\n\t\tfmt.Printf(\"no\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f4b84549f9f9ebc4fab265911fea1ba0", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\txys := [2][2]int{}\n\txyc := [2]int{}\n\n\tfor i := 0; i < n; i++ {\n\t\tvar xy [2]int\n\t\tif _, err := fmt.Scanf(\"%d %d\\n\", &xy[0], &xy[1]); err != nil {\n\t\t\treturn\n\t\t}\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tif xyc[j] == 0 {\n\t\t\t\txys[j][0] = xy[j]\n\t\t\t\txyc[j] += 1\n\t\t\t} else if xys[j][0] != xy[j] {\n\t\t\t\txys[j][1] = xy[j]\n\t\t\t\txyc[j] += 1\n\t\t\t}\n\t\t}\n\t}\n\n\tif xyc[0] < 2 || xyc[1] < 2 {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println(abs(xys[0][0]-xys[0][1]) * abs(xys[1][0]-xys[1][1]))\n\t}\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n", "lang_cluster": "Go", "tags": ["geometry", "implementation"], "code_uid": "6147162751d61209a36fe913301046f2", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a, b int) int {\n if a < b {\n return a \n }\n return b\n}\n\nfunc max(a, b int) int {\n if a > b {\n return a \n }\n return b\n}\n\nfunc min3(a, b, c int) int {\n return min(a, min(b, c)) \n}\n\nfunc max3(a, b, c int) int {\n return max(a, max(b, c)) \n}\n\nfunc min4(a, b, c, d int) int {\n return min(a, min(b, min(c, d)))\n}\n\nfunc max4(a, b, c, d int) int {\n return max(a, max(b, max(c, d)))\n}\n\nfunc abs(a int) int {\n return max(a, -a) \n}\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n\n var x, y [4]int\n for i := 0; i < n; i++ {\n fmt.Scan(&x[i], &y[i]) \n }\n\n if n == 1 || (n == 2 && (x[0] == x[1] || y[0] == y[1])){\n fmt.Println(-1)\n } else if n == 2 {\n a := (min(x[0], x[1])-max(x[0], x[1])) * (min(y[0], y[1])-max(y[0], y[1]))\n fmt.Println(abs(a))\n } else if n == 3 {\n a := (min3(x[0], x[1], x[2])-max3(x[0], x[1], x[2])) * (min3(y[0], y[1], y[2])-max3(y[0], y[1], y[2]))\n fmt.Println(abs(a))\n } else {\n a := (min4(x[0], x[1], x[2], x[3])-max4(x[0], x[1], x[2], x[3])) * (min4(y[0], y[1], y[2], y[3])-max4(y[0], y[1], y[2], y[3]))\n fmt.Println(abs(a))\n }\n}\n", "lang_cluster": "Go", "tags": ["geometry", "implementation"], "code_uid": "015efe1b26445143f08c386f992b7b70", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 66A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x string\n\tfmt.Scan(&x)\n\tif len(x) < 3 || (len(x) == 3 && x <= \"127\") {\n\t\tfmt.Print(\"byte\")\n\t} else if len(x) < 5 || (len(x) == 5 && x <= \"32767\") {\n\t\tfmt.Print(\"short\")\n\t} else if len(x) < 10 || (len(x) == 10 && x <= \"2147483647\") {\n\t\tfmt.Print(\"int\")\n\t} else if len(x) < 19 || (len(x) == 19 && x <= \"9223372036854775807\") {\n\t\tfmt.Print(\"long\")\n\t} else {\n\t\tfmt.Print(\"BigInteger\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "49b078894163004420cfdfe0464e6b9c", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\n//import \"strconv\"\n\nfunc main(){\n\tvar n string\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn = r.Text()\n\tl := len(n)\n\tif l < 3 || (l == 3 && n < \"128\") {\n\t\tw.WriteString(\"byte\")\n\t} else if l < 5 || (l == 5 && n < \"32768\") {\n\t\tw.WriteString(\"short\")\n\t} else if l < 10 || (l == 10 && n < \"2147483648\") {\n\t\tw.WriteString(\"int\")\n\t} else if l < 19 || (l == 19 && n < \"9223372036854775808\") {\n\t\tw.WriteString(\"long\")\n\t} else {\n\t\tw.WriteString(\"BigInteger\")\n\t}\n\tw.WriteString(\"\\n\")\n\tw.Flush()\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "388bb97461566b1f580efd24640a3dd2", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x string\n\tfmt.Scan(&x)\n\tif len(x) < 3 || (len(x) == 3 && x <= \"127\") {\n\t\tfmt.Print(\"byte\")\n\t} else if len(x) < 5 || (len(x) == 5 && x <= \"32767\") {\n\t\tfmt.Print(\"short\")\n\t} else if len(x) < 10 || (len(x) == 10 && x <= \"2147483647\") {\n\t\tfmt.Print(\"int\")\n\t} else if len(x) < 19 || (len(x) == 19 && x <= \"9223372036854775807\") {\n\t\tfmt.Print(\"long\")\n\t} else {\n\t\tfmt.Print(\"BigInteger\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "404776f3d44d588fea39407a77f6e958", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nimport \"math\"\nimport \"bytes\"\nimport \"io\"\nimport \"os\"\n\n//import \"strings\"\n\nvar dbg = false\n\nfunc factorize(N, K int64) int64 {\n\n\tvar U int64 = int64(math.Sqrt(float64(N)))\n\t//var U int64 = Sqrt(N)\n\n\tvar k int64 = 1\n\n\tvar i int64 = 1\n\n\tvar d int64 = -1\n\n\tfor {\n\n\t\tif N%i == 0 {\n\n\t\t\td = i\n\t\t\tif dbg {\n\t\t\t\tfmt.Println(\"U, N, d, i, k, K\", U, N, d, i, k, K)\n\t\t\t}\n\t\t\tif k == K {\n\t\t\t\treturn d\n\t\t\t}\n\n\t\t\tk++\n\n\t\t}\n\n\t\ti = i + 1\n\n\t\tif i > U {\n\t\t\tbreak\n\t\t}\n\n\t}\n\n\tfor {\n\n\t\tif N%i == 0 {\n\n\t\t\td1 := N / i\n\n\t\t\tif d1 != d {\n\n\t\t\t\td = d1\n\n\t\t\t\tif dbg {\n\t\t\t\t\tfmt.Println(\"U, N, d, i, k, K\", U, N, d, i, k, K)\n\t\t\t\t}\n\n\t\t\t\tif k == K {\n\t\t\t\t\treturn d\n\t\t\t\t}\n\n\t\t\t\tk++\n\t\t\t}\n\n\t\t}\n\n\t\ti = i - 1\n\t\tif i < 1 {\n\t\t\td = -1\n\t\t\tbreak\n\t\t}\n\n\t}\n\n\treturn d\n}\n\nfunc solve() {\n\tvar input bytes.Buffer\n\n\tio.Copy(&input, os.Stdin)\n\n\tvar N, K int64 = 0, 0\n\tfmt.Fscanf(&input, \"%d\", &N)\n\tfmt.Fscanf(&input, \"%d\", &K)\n\n\tif dbg {\n\t\tfmt.Println(N, K)\n\t}\n\n\tfmt.Println(factorize(N, K))\n}\n\nfunc main() {\n\t//test()\n\n\tsolve()\n\t//p := quick_pow_mod(int64(2), int64(20), B)\n\t//fmt.Println(p)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "443350db8f35ddc35c29d8f179ef8a1d", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n // \"bufio\"\n \"fmt\"\n \"math\"\n // \"strconv\"\n // \"strings\"\n)\n\nfunc main() {\n var n, k int64\n fmt.Scanf(\"%d %d\\n\", &n, &k)\n\n var half = (int64)(math.Sqrt(float64(n)))\n var d = int64(-1)\n\n for i:=int64(1); i<=half; i++ {\n if n % i == 0 {\n k -= 1\n\n if k == 0 {\n d = i\n break\n }\n }\n }\n\n if k > 0 {\n if half * half == n {\n half--\n }\n\n for i:=half; i>0; i-- {\n if n % i == 0 {\n k -= 1\n\n if k == 0 {\n d = n / i\n break\n }\n }\n }\n }\n\n fmt.Printf(\"%d\\n\", d)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "bee54b34586b8fa9e0e74557eda71219", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n uint64\n\tfor I(&n) == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n uint64) {\n\tvar k, o, ans uint64\n\tI(&k)\n\tvar arr []uint64\n\tfor i := uint64(1); i <= uint64(math.Sqrt(float64(n))); i++ {\n\t\tif n%i == 0 {\n\t\t\tarr = append(arr, i)\n\t\t\tans++\n\t\t\tif ans == k {\n\t\t\t\to = i\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif ans < k {\n\t\tq := ans\n\t\tfor q > 0 {\n\t\t\tq--\n\t\t\tif n/arr[q] == arr[q] {\n\t\t\t continue\n\t\t\t}\n\t\t\tarr = append(arr, n/arr[q])\n\t\t\tans++\n\t\t\tif ans == k {\n\t\t\t\to = n / arr[q]\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif ans < k {\n\t\tO(-1, \"\\n\")\n\t} else {\n\t\tO(o, \"\\n\")\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "570bad5a92b84567e22a49f4bbfb309f", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n )\n\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n scanner.Scan()\n a, _ := strconv.Atoi(scanner.Text())\n scanner.Scan()\n b, _:= strconv.Atoi(scanner.Text())\n if ((a == 0 && b == 0 ) || a - b < -1 || a - b > 1) {\n fmt.Println(\"NO\")\n } else {\n fmt.Println(\"YES\")\n }\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "1e2701b5ac402647c2e0d104860d1380", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b int\n fmt.Scan(&a, &b)\n if a+b>0 && (a == b || a+1 == b || a-1 == b) {\n fmt.Print(\"YES\")\n } else {\n fmt.Print(\"NO\")\n }\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "c6fe7ac8d9f5f97a24f489afbbd81e5c", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := readInt()\n\tb := readInt()\n\tif (a+1 == b || b+1 == a || a == b) && !(a == 0 && b == 0) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "016779980f1c761f9773be6e212017e9", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype Cin struct {\n\tscanner *bufio.Scanner\n}\n\nfunc (c *Cin) NextInt() int {\n\tc.scanner.Scan()\n\tline := c.scanner.Text()\n\treturn c.convertInt(line)\n}\n\nfunc (c *Cin) NextIntSlice() []int {\n\tc.scanner.Scan()\n\tline := strings.Split(c.scanner.Text(), \" \")\n\tvar ret []int\n\tfor _, s := range line {\n\t\tret = append(ret, c.convertInt(s))\n\t}\n\treturn ret\n}\n\nfunc (c *Cin) NextTwoInt() (int, int) {\n\tline := c.NextIntSlice()\n\treturn line[0], line[1]\n}\n\nfunc (c *Cin) convertInt(data string) int {\n\ti, _ := strconv.Atoi(data)\n\treturn i\n}\n\nvar cin = &Cin{\n\tscanner: bufio.NewScanner(os.Stdin),\n}\n\ntype element struct {\n\tvalue int\n\tstep int\n\tnext *element\n\tlast *element\n}\n\nfunc newElement(value, step int) *element {\n\treturn &element{value: value, step: step}\n}\n\ntype queue struct {\n\thead *element\n\ttail *element\n}\n\nfunc (q *queue) push(value, step int) {\n\titem := newElement(value, step)\n\tif q.isEmpty() {\n\t\tq.head = item\n\t\tq.tail = q.head\n\t\treturn\n\t}\n\titem.last = q.tail\n\tq.tail.next = item\n\tq.tail = item\n}\n\nfunc (q *queue) isEmpty() bool {\n\treturn q.head == nil\n}\n\nfunc (q *queue) pop() *element {\n\tif q.isEmpty() {\n\t\tpanic(\"pop from empty queue\")\n\t}\n\titem := q.head\n\tq.head = q.head.next\n\treturn item\n}\n\nfunc newQueue() *queue {\n\treturn &queue{}\n}\n\nfunc handle(n, m int) int {\n\tq := newQueue()\n\tq.push(n, 0)\n\tset := map[int]int{n: 0}\n\tfor !q.isEmpty() {\n\t\tele := q.pop()\n\t\tif ele.value == m {\n\t\t\treturn ele.step\n\t\t}\n\t\tif ele.value > m {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := set[ele.value*2]; !ok {\n\t\t\tset[ele.value*2] = ele.step + 1\n\t\t\t// fmt.Printf(\"val=[%v],step=[%v]\\n\", ele.value*2, ele.step+1)\n\t\t\tq.push(ele.value*2, ele.step+1)\n\t\t}\n\t\tif _, ok := set[ele.value*3]; !ok {\n\t\t\tset[ele.value*3] = ele.step + 1\n\t\t\t// fmt.Printf(\"val=[%v],step=[%v]\\n\", ele.value*3, ele.step+1)\n\t\t\tq.push(ele.value*3, ele.step+1)\n\t\t}\n\t}\n\treturn -1\n}\n\nfunc main() {\n\tn, m := cin.NextTwoInt()\n\tfmt.Printf(\"%d\\n\", handle(n, m))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "51a52410790791300c2c2c76a2248e8a", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc rec(a, b, cnt int) int {\n\tif a > b {\n\t\treturn -1\n\t}\n\tif a == b {\n\t\t// fmt.Printf(\"%d\\n\", cnt)\n\t\treturn cnt\n\t}\n\tif rec(a*2, b, cnt+1) != -1 {\n\t\treturn rec(a*2, b, cnt+1)\n\t}\n\tif rec(a*3, b, cnt+1) != -1 {\n\t\treturn rec(a*3, b, cnt+1)\n\t}\n\treturn -1\n}\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\\n\", &a, &b)\n\tfmt.Printf(\"%d\\n\", rec(a, b, 0))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "bc0ee246b7e387cc52b81eee54a72537", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, fact, step int64\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tif m != n {\n\t\tif m%n == 0 {\n\t\t\tfact = m / n\n\t\t\tfor fact%3 == 0 {\n\t\t\t\tfact /= 3\n\t\t\t\tstep++\n\t\t\t}\n\t\t\tfor fact%2 == 0 {\n\t\t\t\tfact /= 2\n\t\t\t\tstep++\n\t\t\t}\n\t\t}\n\t\tif fact != 1 {\n\t\t\tstep = -1\n\t\t}\n\t}\n\n\tfmt.Println(step)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "3291cb910c0175fa522c584bed8f0a7f", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, x, y, k int64\n\tfmt.Scanf(\"%d %d %d %d %d\", &l, &r, &x, &y, &k)\n\tfor i := l; i <= r; i++ {\n\t\tif (x*k <= i) && (i <= y*k) && (i%k == 0) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "brute force"], "code_uid": "680645a44ac4a3a1341bc07f93ecdbec", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, x, y, k int64\n\tfmt.Scan(&l, &r, &x, &y, &k)\n\tif x*k < l {\n\t\tx = (l + k - 1) / k\n\t}\n\tif y*k > r {\n\t\ty = r / k\n\t}\n\tif x > y {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "brute force"], "code_uid": "c503f3ae5ee9b24c0a52bfccef051795", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var l, r, x, y, k int\n fmt.Scanf(\"%d %d %d %d %d\\n\", &l, &r, &x, &y, &k)\n for b := x; b <= y; b++ {\n a := int64(b) * int64(k)\n if int64(l) <= a && a <= int64(r) {\n fmt.Printf(\"YES\\n\")\n return\n }\n }\n fmt.Printf(\"NO\\n\")\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "brute force"], "code_uid": "b2b3123e48d83a7e45f739bc558c91b8", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar l, r, x, y, k int64\n\tfmt.Scanf(\"%d %d %d %d %d\", &l, &r, &x, &y, &k)\n\tfor cost := x; cost <= y; cost++ {\n\t\texperience := k * cost\n\t\tif experience >= l && experience <= r {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "brute force"], "code_uid": "d0b8aa36ac1a652ace5bec5f1127d4af", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar a,b,c,d,e int\n\tvar ans=false\n\tfmt.Scanf(\"%d %d %d %d %d\",&a,&b,&c,&d,&e)\n\tfor i:=c;i<=d;i++ {\n\t\tvar comp=int64(i)*int64(e)\n\t\tif int64(a)<=comp && comp<=int64(b){\n\t\t\tans=true\n\t\t}\n\t}\n\tif ans{\n\t\tfmt.Printf(\"YES\\n\")\n\t} else{\n\t\tfmt.Printf(\"NO\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "brute force"], "code_uid": "69a3e320629b3e79a9bb15a87d28b5bc", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n/**\n * 根据指定的层数,算出总的方块数\n */\nfunc fetchSumByLevel(level int) int {\n return (level * (level + 1) * (level + 2) / 6)\n}\n\n/**\n * 在指定的区间内,二分搜索,查找一个能使总的方块数达到最大值的层数,这个最大值一定小于等于给定的方块数\n *\n * @param begin_level, 指定区间的起始(包括该下标)\n * @param end_level, 指定区间的结束(不包括该下标)\n * @param cubes_amt, 给定的方块数,最大层数时的总方块数一定要小于等于这个值\n *\n * @return 返回能叠的最大层数\n */\nfunc binSearch(begin_level, end_level, cubes_amt int) int {\n for begin_level < end_level {\n cur_level := (begin_level + end_level) / 2\n cur_sum := fetchSumByLevel(cur_level)\n\n if cubes_amt == cur_sum {\n return cur_level\n } else if cubes_amt > cur_sum {\n begin_level = cur_level + 1\n } else {\n end_level = cur_level\n }\n }\n return begin_level - 1\n}\n\nfunc main(){\n const (\n MIN_LEVEL = 1\n MAX_LEVEL = 40\n )\n\n cubes_amt := 0\n fmt.Scanf(\"%d\", &cubes_amt)\n fmt.Printf(\"%d\", binSearch(MIN_LEVEL, MAX_LEVEL, cubes_amt))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fd54187c93965abad75da18920ea1abe", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\tvar n int\n\tvar e error\n\tvar c int = 0\n\tvar d int = 0\n\n\tscanner = bufio.NewScanner(os.Stdin)\n\n\tscanner.Scan()\n\n\tn, e = strconv.Atoi(strings.TrimSpace(scanner.Text()))\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\tfor i := 1; i <= 1e4+3; i++ {\n\t\tc += i\n\t\td += c\n\t\t// fmt.Println(c, d)\n\t\tif d > n {\n\t\t\tc = i - 1\n\t\t\tbreak\n\t\t}\n\n\t}\n\tfmt.Println(c)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "74cb0194d7c2157dd2fa7d7dff9a9f20", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar i int\n\tfor r, s := 0, 0; s <= n; s += r {\n\t\ti++\n\t\tr += i\n\t}\n\ti--\n\tfmt.Println(i)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0ae02e78b0d85265fb7603988de8964b", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n m := getI()\n know := map[[2]int]bool{}\n for i := 0; i < m; i++ {\n a, b := getI(), getI()\n know[[2]int{ a, b }] = true\n know[[2]int{ b, a }] = true\n }\n for i := 1; i <= 3; i++ {\n for j := i+1; j <= 4; j++ {\n for k := j+1; k <= 5; k++ {\n x, y, z := know[[2]int{i, j}], know[[2]int{j, k}], know[[2]int{i, k}]\n if (x && y && z) || !(x || y || z) {\n writer.WriteString(\"WIN\\n\")\n return\n }\n }\n }\n }\n writer.WriteString(\"FAIL\\n\")\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "graphs"], "code_uid": "8a283a25f452cf91f4b09f312b34d534", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar rel int\n\tvar a int\n\tvar b int\n\tflag := false\n\tfmt.Scan(&rel)\n\tvar ar [5]int\n\tfor i := 0; i < rel; i++ {\n\t\tfmt.Scan(&a)\n\t\tfmt.Scan(&b)\n\t\tar[a-1]++\n\t\tar[b-1]++\n\t}\n\tfor i := 0; i < 5; i++ {\n\t\tif ar[i] != 2 {\n\t\t\tflag = true\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"WIN\")\n\t} else {\n\t\tfmt.Println(\"FAIL\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "graphs"], "code_uid": "a0b2f8743f2bd19ee522379ecd8def19", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// https://codeforces.com/contest/13/problem/A\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nfunc main() {\n\tvar (\n\t\tA int \n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(input, &A)\n\n\tprimes := make([]bool, A / 2 + 1)\n\tfor i := 0; i < len(primes); i++ {\n\t\tprimes[i] = true\n\t}\n\n\tfor i := 2; i < len(primes); i++ {\n\t\tif primes[i] {\n\t\t\tx := i\n\t\t\tfor i + x < len(primes) {\n\t\t\t\tprimes[i + x] = false\n\t\t\t\tx += i\n\t\t\t}\n\t\t}\n\t}\n\n\tans := 0\n\tcnt := 0\n\tfor i := 2; i < A; i++ {\n\t\ttmp := A\n\t\tfor tmp > 0 {\n\t\t\tans += tmp % i\n\t\t\ttmp /= i\n\t\t}\n\t\tcnt++\n\t}\n\n\tfor i := 2; i < len(primes); i++ {\n\t\tif primes[i] {\n\t\t\tfor ans % i == 0 && cnt % i == 0 {\n\t\t\t\tans /= i\n\t\t\t\tcnt /= i\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d/%d\", ans, cnt)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "6b00f8753002a0df4e817983478c875a", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc gcd(a, b int) int {\n for b != 0 {\n a, b = b, a%b\n }\n return a\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n x := getI()\n total := 0\n for base := 2; base < x; base++ {\n for y := x; y != 0; y /= base {\n total += y % base\n }\n }\n num, denom := total, x-2\n d := gcd(num, denom)\n num /= d\n denom /= d\n writer.WriteString(fmt.Sprintf(\"%d/%d\\n\", num, denom))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "4350513cda94009140b680c0e4c18e6d", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 13A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(n, m int) int {\n\tif m == 0 {\n\t\treturn n\n\t} else {\n\t\treturn gcd(m, n%m)\n\t}\n}\n\nfunc main() {\n\tvar n, m, i int\n\tsum := 0\n\tfmt.Scan(&n)\n\tfor i = 2; i < n; i++ {\n\t\tm = n\n\t\tfor m != 0 {\n\t\t\tsum += m % i\n\t\t\tm /= i\n\t\t}\n\t}\n\tfmt.Printf(\"%d/%d\", sum/gcd(sum, n-2), (n-2)/gcd(sum, n-2))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "5c9d5794a3e3e8accc69cbdbfc80754f", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc binary(n int) int {\n\tcount := 0\n\tfor n != 0 {\n\t\tif n % 2 == 1 {\n\t\t\tcount++\n\t\t}\n\t\tn /= 2\n\t}\n\treturn count\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tfmt.Println(binary(n))\n}", "lang_cluster": "Go", "tags": ["bitmasks"], "code_uid": "2828d2fe6e0d87ebe8c7591187768bdd", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, count int\n\tfmt.Scan(&n)\n\n\tfor n > 1 {\n\t\tj := int(math.Floor(math.Log2(float64(n))))\n\t\tn = n - (1 << j)\n\t\tcount += 1\n\t}\n\tif n == 1 {\n\t\tcount += 1\n\t}\n\tfmt.Println(count)\n}\n", "lang_cluster": "Go", "tags": ["bitmasks"], "code_uid": "8bad3ae4b3785bde8b60cf381944b8a3", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Fscanf(os.Stdin, \"%d\\n\", &n)\n\n\treminder := n\n\tval := math.Log2(float64(reminder))\n\treminder -= (1 << uint(val))\n\tcounter := 1\n\n\tfor reminder > 0 {\n\t\tval = math.Log2(float64(reminder))\n\t\treminder -= (1 << uint(val))\n\t\tcounter++\n\t}\n\n\tfmt.Println(counter)\n\n}\n", "lang_cluster": "Go", "tags": ["bitmasks"], "code_uid": "0d12e0c47bd7050294a25aea5f57227e", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 676 A\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n var a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n for i:=0; i d2 {\n\t\tfmt.Print(d1)\n\t} else {\n\t\tfmt.Print(d2)\n\t}\n}\n\ntype StdReader struct {\n\tbuf *bufio.Reader\n}\n\nfunc NewStdReader(reader io.Reader) *StdReader {\n\treturn &StdReader{bufio.NewReaderSize(reader, 2*1024*1024)}\n}\n\nfunc (std *StdReader) ReadInt() int {\n\n\tr := 0\n\tsign := 1\n\tok := false\n\n\tfor {\n\t\tb, e := std.buf.ReadByte()\n\n\t\tif e != nil {\n\t\t\tbreak\n\t\t}\n\t\tif b >= '0' && b <= '9' {\n\t\t\tr = r*10 + int(b-'0')\n\t\t\tok = true\n\t\t} else {\n\t\t\tif ok {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tif b == '-' {\n\t\t\t\t\tsign = -sign\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sign * r\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "9e8d0bfb4c1c48390ee2712b45306627", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%v\", &n)\n\tw := n / 7\n\tr := n % 7\n\tvar a1, a2 int\n\tif r > 2 {\n\t\ta1 = 2*w + 2\n\t} else {\n\t\ta1 = 2*w + r\n\t}\n\n\tif r-5 > 0 {\n\t\ta2 = w*2 + (r - 5)\n\t} else {\n\t\ta2 = w * 2\n\t}\n\n\tfmt.Printf(\"%v %v\\n\", a2, a1)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "c0413b4d4c79f753e845b292010b8d9a", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\tvar n int\n\tvar e error\n\tvar min [6]int = [6]int{0, 0, 0, 0, 0, 1}\n\tvar max [6]int = [6]int{1, 2, 2, 2, 2, 2}\n\n\tscanner = bufio.NewScanner(os.Stdin)\n\n\tscanner.Scan()\n\n\tn, e = strconv.Atoi(strings.TrimSpace(scanner.Text()))\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\n\tif n%7 == 0 {\n\t\tfmt.Println((n/7)*2, (n/7)*2)\n\t} else {\n\t\tfmt.Println(min[(n%7)-1]+(n/7)*2, max[(n%7)-1]+(n/7)*2)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "7dc616191b3f787dd290d27adb280bb8", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tminDayOff := n / 7 * 2\n\tif n%7 > 5 {\n\t\tminDayOff += n%7 - 5\n\t}\n\tmaxDayOff := 2\n\tif n < 2 {\n\t\tmaxDayOff = n\n\t\tn = 0\n\t} else {\n\t\tn -= 2\n\t}\n\tmaxDayOff += n / 7 * 2\n\tif n%7 > 5 {\n\t\tmaxDayOff += n%7 - 5\n\t}\n\tfmt.Println(minDayOff, maxDayOff)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "721baaa7048fcd7f85675d73d4ae8705", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n mp := make(map[string]bool)\n s := readString()\n cnt := 0\n for i := 0; i < len(s)+10; i++ {\n if !mp[s] {\n cnt++\n }\n mp[s] = true\n s = string(s[len(s)-1]) + s[:len(s)-1]\n }\n fmt.Println(cnt)\n}\n\n\n// Helpers\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\n// Sort\n\ntype Ints64 []int64\n\nfunc (a Ints64) Len() int { return len(a) }\nfunc (a Ints64) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a Ints64) Less(i, j int) bool { return a[i] < a[j] }\n\n/* Sort tempalte\nfunc (a ) Len() int { return len(a) }\nfunc (a ) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ) Less(i, j int) bool { return }\n*/\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "56ea8dd505e8076cf690fed4d7bf8992", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tstr string\n\t)\n\t\n\tfmt.Scan(&str)\n\t\n\trunes := []rune(str)\n\tstrMap := make(map[string]int)\n\tstrMap[str]++\n\tfor i := 0; i < len(str); i++ {\n\t\tcurRune := runes[len(str) - 1]\n\t\tfor j := len(str) - 1; j > 0 ; j-- {\n\t\t\trunes[j] = runes[j - 1]\n\t\t}\n\t\trunes[0] = curRune\n\t\tstrMap[string(runes)]++\n\t}\n\t\n\tfmt.Println(len(strMap))\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "e9161d4d1fee156e60e4d6e8b6499d84", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tfor {\n\t\tvar input string\n\t\tif _, err := fmt.Scanf(\"%s\", &input); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tcache := make(map[string]int, len(input))\n\n\t\tl := len(input)\n\t\t\n\t\tfor i:=0; i 0 {\n\t\t\tg++\n\t\t\tarrK = append(arrK, k)\n\t\t\tk = 0\n\t\t}\n\t}\n\n\tif k > 0 {\n\t\tg++\n\t\tarrK = append(arrK, k)\n\t\tk = 0\n\t}\n\n\tfmt.Println(g)\n\n\tfor _, v := range arrK {\n\t\tfmt.Printf(\"%v \", v)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4b263f9192379c0604034e3a09ace1f4", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar (\n\t\tn int\n\t\ts string\n\t)\n\tfmt.Scan(&n, &s)\n\n\tseq := []int{}\n\tfor i, v := range s {\n\t\tif v == 'B' {\n\t\t\tif i == 0 || s[i-1] == 'W' {\n\t\t\t\tseq = append(seq, 0)\n\t\t\t}\n\t\t\tseq[len(seq)-1]++\n\t\t}\n\t}\n\n\tfmt.Println(len(seq))\n\tif len(seq) == 0 {\n\t\treturn\n\t}\n\tfor i, v := range seq {\n\t\tif i != 0 {\n\t\t\tfmt.Print(\" \")\n\t\t}\n\t\tfmt.Print(v)\n\t}\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "62b8f4ec748255730bee04b89617b3a6", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"bufio\"\nimport \"os\"\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar n int\n\tvar s string\n\n\tfmt.Fscanf(bufin, \"%d\\n\", &n)\n\tfmt.Fscanf(bufin, \"%s\\n\", &s)\n\n\tvar res []int\n\tfor i := 0; i < n; i++ {\n\t\tif s[i] == 'B' {\n\t\t\tj := i\n\t\t\tfor (j < n) && (s[j] == 'B') {\n\t\t\t\tj++\n\t\t\t}\n\t\t\tres = append(res, j-i)\n\t\t\ti = j - 1\n\t\t}\n\t}\n\n\tfmt.Fprintf(bufout, \"%d\\n\", len(res))\n\tfor _, v := range res {\n\t\tfmt.Fprintf(bufout, \"%d \", v)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "df0a975cd64733170ad4f01e4712eabb", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,w int\n var cnt [2]int\n fmt.Scan(&n)\n for i := 0; i < n; i++ {\n fmt.Scan(&w)\n cnt[(w/100)-1]++\n }\n if (cnt[1]%2 != 0) && (cnt[0] >= 2) {\n cnt[1] = 0\n cnt[0] -= 2\n }\n if (cnt[0]%2 == 0) && (cnt[1]%2 == 0) { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "983a1f1c86caa8381255e8603c9b32a3", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\ttotal := nextInt()\n\tweights := make([]int, total)\n\tfor i := 0; i < len(weights); i++ {\n\t\tweights[i] = nextInt()\n\t}\n\tsort.Sort(sort.Reverse(sort.IntSlice(weights)))\n\tvar a, b int\n\tfor _, v := range weights {\n\t\tif a < b {\n\t\t\ta += v\n\t\t} else {\n\t\t\tb += v\n\t\t}\n\t}\n\tif a == b {\n\t\twriteln(\"YES\")\n\t} else {\n\t\twriteln(\"NO\")\n\t}\n\tout.Flush()\n}\n\nvar (\n\tbuf []byte\n\tout *bufio.Writer\n)\n\nfunc init() {\n\tbuf, _ = ioutil.ReadAll(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n}\n\nfunc nextInt() int {\n\ts, r := 1, 0\n\tfor (buf[0] < '0' || '9' < buf[0]) && buf[0] != '-' {\n\t\tbuf = buf[1:]\n\t}\n\tif buf[0] == '-' {\n\t\ts = -1\n\t\tbuf = buf[1:]\n\t}\n\tfor '0' <= buf[0] && buf[0] <= '9' {\n\t\tr = 10*r + int(buf[0]-'0')\n\t\tbuf = buf[1:]\n\t}\n\treturn r * s\n}\n\nfunc writeln(s string) {\n\tout.WriteString(s + \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "dffd4be3864de99262d0f95311fa9587", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 433A-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, a1, a2, x int\n\tfmt.Scan(&n)\n\tfor i := 0; i < n; i++ {\n\t\ta1 = 0\n\t\ta2 = 0\n\n\t\tfor i := 0; i < n; i++ {\n\t\t\tfmt.Scan(&x)\n\t\t\tif x == 100 {\n\t\t\t\ta1++\n\t\t\t} else {\n\t\t\t\ta2++\n\t\t\t}\n\n\t\t}\n\n\t\ta2 = a2 % 2\n\n\t\tif a2 == 1 {\n\t\t\tif a1 >= 2 {\n\t\t\t\ta1 = a1 - 2\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\ta1 = a1 % 2\n\n\t\tif a1 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t\treturn\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "ee87b81daad5e004d5d87898c44138d4", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc max(i, j int) int {\n\tif i > j {\n\t\treturn i\n\t}\n\treturn j\n}\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tif n%2 == 1 {\n\t\tfmt.Println((n + 1) / 2)\n\t} else {\n\t\tif n == 0 {\n\t\t\tfmt.Println(0)\n\t\t} else {\n\t\t\tfmt.Println(n + 1)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "d5733431cd7959e0b85ee494eabc08b4", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\n\tif n == 0 {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\n\tn++\n\tif n%2 == 0 {\n\t\tfmt.Println(n / 2)\n\t} else {\n\t\tfmt.Println(n)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "70b8c8b305475cd80c571773d80045ba", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc Process(n int64) (int64) {\n\tif n == 0 {\n\t\treturn 0\n\t}\n\n\tif (n+1)%2 == 0 {\n\t\treturn (n + 1) / 2\n\t} else {\n\t\treturn n + 1\n\t}\n}\n\nfunc main() {\n\n\tvar n int64\n\n\tfmt.Scanln(&n)\n\n\tfmt.Println(Process(n))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "cfd5bdce709cdbaa1810c496d47c32ca", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/414/B\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst M = 1e9+7\n\nfunc Solve(n, k int) int64 {\n\tdp := make([][]int64, k+1)\n\tfor i := 1; i <= k; i++ {\n\t\tdp[i] = make([]int64, n+1)\n\t}\n\tfor i := 1; i <= n; i++ {\n\t\tdp[1][i] = 1\n\t}\n\tfor i := 1; i < k; i++ {\n\t\tfor j := 1; j <= n; j++ {\n\t\t\tfor d := 1; d*j <= n; d++ {\n\t\t\t\tdp[i+1][d*j] = (dp[i][j] + dp[i+1][d*j]) % M\n\t\t\t}\n\t\t}\n\t}\n\ts := int64(0)\n\tfor _, elem := range dp[k] {\n\t\ts = (s + elem) % M\n\t}\n\treturn s\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n, k int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &k)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, k))\n}\n", "lang_cluster": "Go", "tags": ["dp", "combinatorics", "number theory"], "code_uid": "fca0e982e18aaca31bf2b446842c7111", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype Io struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n\ttokens []string\n\tnextToken int\n}\n\nfunc NewIo() *Io {\n\treturn &Io{\n\t\treader: bufio.NewReader(os.Stdin),\n\t\twriter: bufio.NewWriter(os.Stdout),\n\t}\n}\n\nfunc (io *Io) Flush() {\n\terr := io.writer.Flush()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc (io *Io) NextLine() string {\n\tvar buffer []byte\n\tfor {\n\t\tline, isPrefix, err := io.reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer = append(buffer, line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(buffer)\n}\n\nfunc (io *Io) Next() string {\n\tfor io.nextToken >= len(io.tokens) {\n\t\tline := io.NextLine()\n\t\tio.tokens = strings.Fields(line)\n\t\tio.nextToken = 0\n\t}\n\tr := io.tokens[io.nextToken]\n\tio.nextToken++\n\treturn r\n}\n\nfunc (io *Io) NextInt() int {\n\ti, err := strconv.Atoi(io.Next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc (io *Io) NextLong() int64 {\n\ti, err := strconv.ParseInt(io.Next(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc (io *Io) NextDouble() float64 {\n\ti, err := strconv.ParseFloat(io.Next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc (io *Io) PrintLn(a ...interface{}) {\n\tfmt.Fprintln(io.writer, a...)\n}\n\nfunc (io *Io) Printf(format string, a ...interface{}) {\n\tfmt.Fprintf(io.writer, format, a...)\n}\n\nfunc (io *Io) PrintIntLn(a []int) {\n\tb := []interface{}{}\n\tfor _, x := range a {\n\t\tb = append(b, x)\n\t}\n\tio.PrintLn(b...)\n}\n\nfunc (io *Io) PrintStringLn(a []string) {\n\tb := []interface{}{}\n\tfor _, x := range a {\n\t\tb = append(b, x)\n\t}\n\tio.PrintLn(b...)\n}\n\nfunc Log(name string, value interface{}) {\n\tfmt.Fprintf(os.Stderr, \"%s=%+v\\n\", name, value)\n}\n\nfunc intMin(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nconst MOD = 1000000007\n\nvar (\n\tG [][]int\n\tdp [][]int\n)\n\nfunc solve(n, k int) int {\n\tif k == 1 {\n\t\treturn 1\n\t}\n\tif dp[n][k] != -1 {\n\t\treturn dp[n][k]\n\t}\n\tdp[n][k] = solve(n, k - 1)\n\tfor _, u := range G[n] {\n\t\tdp[n][k] += solve(u, k - 1)\n\t\tdp[n][k] %= MOD\n\t}\n\treturn dp[n][k]\n}\n\nfunc main() {\n\tio := NewIo()\n\tdefer io.Flush()\n\tN := io.NextInt()\n\tK := io.NextInt()\n\tG = make([][]int, N + 1)\n\toutdeg := make([]int, N + 1)\n\tfor i := 1; i <= N; i++ {\n\t\tfor j := 1; j <= i - 1; j++ {\n\t\t\tif i % j == 0 {\n\t\t\t\tG[i] = append(G[i], j)\n\t\t\t\toutdeg[i]++\n\t\t\t}\n\t\t}\n\t}\n\tdp = make([][]int, N + 1)\n\tfor i := 1; i <= N; i++ {\n\t\tdp[i] = make([]int, K + 1)\n\t\tfor j := 0; j <= K; j++ {\n\t\t\tdp[i][j] = -1\n\t\t}\n\t}\n\tans := 0\n\tfor i := 1; i <= N; i++ {\n\t\tans += solve(i, K)\n\t\tans %= MOD\n\t\t//for k := 1; k <= K; k++ {\n\t\t//\tfmt.Fprintf(os.Stderr, \"solve(%v,%v)=%v\\n\", i, k, solve(i, k))\n\t\t//}\n\t}\n\tio.PrintLn(ans)\n}", "lang_cluster": "Go", "tags": ["dp", "combinatorics", "number theory"], "code_uid": "4ea5ac2f81cc7e6f7cbee022813bb877", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar ans,mod,n,k,i,j,x int64\n\tmod=1000000007\n\tvar a[2005][2005]int64\n\tfmt.Scan(&n,&k)\n\tfor i=1;i<=n;i++ {\n\t\ta[1][i]=1\n\t}\n\tfor i=1;i=mod{\n\t\t\t\t\ta[i+1][x]-=mod\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor i=1;i<=n;i++ {\n\t\tans+=a[k][i]\n\t\tif ans>=mod {\n\t\t\tans-=mod\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\n\n\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["dp", "combinatorics", "number theory"], "code_uid": "d84f035d10dc59f23e1ea2edd67400bc", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 70A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar m int\n\te := 1\n\tfmt.Scan(&m)\n\tfor j := 1; j <= m-1; j++ {\n\t\te = (3 * e) % 1000003\n\t}\n\tfmt.Print(e)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "1eda6f02b9f98225de02f1020b20ffbb", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//70A\npackage main\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar nn, a int64\n\ta=1\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tr.Scan()\n\tnn, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tif nn==1 {\n\t\ta=1\n\t} else {\n\t\tfor i:=2; int64(i)<=nn; i++ {\n\t\t\ta=(a*3)%1000003\n\t\t}\n\t}\n\tfmt.Println(a)\n}\t\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "ed13e4fab950c607e11116be47bc15ae", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc inc(x int64) int64 {\n\treturn x + 1\n}\nfunc dec(x int64) int64 {\n\treturn x - 1\n}\nfunc isOdd(x int64) bool {\n\treturn x%1 == 1\n}\n\nfunc isNotOdd(x int64) bool {\n\treturn !isOdd(x)\n}\n\nfunc readInt(scanner *bufio.Scanner) int64 {\n\tscanner.Scan()\n\traw := scanner.Text()\n\tresult, _ := strconv.ParseInt(strings.Trim(raw, \" \\n\\r\"), 10, 64)\n\treturn result\n}\nfunc getWithCalc(x int64, cond func(int64) bool, f func(int64) int64) int64 {\n\tif cond(x) {\n\t\treturn f(x)\n\t}\n\treturn x\n}\nfunc check(x1, y1, x2, y2 int64) int64 {\n\n\ta1 := 1 + (getWithCalc(x2, isOdd, dec)-getWithCalc(x1, isOdd, inc))/2\n\tb1 := 1 + (getWithCalc(y2, isOdd, dec)-getWithCalc(y1, isOdd, inc))/2\n\n\ta2 := 1 + (getWithCalc(x2, isNotOdd, dec)-getWithCalc(x1, isNotOdd, inc))/2\n\tb2 := 1 + (getWithCalc(y2, isNotOdd, dec)-getWithCalc(y1, isNotOdd, inc))/2\n\n\treturn a1*b1 + a2*b2\n}\nfunc solve(in io.Reader, out io.Writer) {\n\treader := bufio.NewScanner(in)\n\treader.Split(bufio.ScanWords)\n\n\tfmt.Fprintln(out, check(readInt(reader), readInt(reader), readInt(reader), readInt(reader)))\n}\n\nfunc main() {\n\tsolve(os.Stdin, os.Stdout)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "5cc0632be4c1ae9c3b76fb55a06e48a1", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x1, y1, x2, y2 int64\n\tfmt.Scanf(\"%d %d %d %d\", &x1, &y1, &x2, &y2)\n\n\tvar dx, dy, num_prim_cols, num_sec_cols, len_prim_cols, len_sec_cols int64\n\tdx = x2 - x1\n\tdy = y2 - y1\n\tnum_prim_cols = dx / 2 + 1 //dx guaranteed to be divisible by 2\n\tnum_sec_cols = num_prim_cols - 1\n\tlen_prim_cols = dy / 2 + 1\n\tlen_sec_cols = 0\n//\tfmt.Printf(\"dx=\\t%d\\ndy=\\t%d\\nprim_cols=\\t%d\\nsec_cols=\\t%d\\n\", dx, dy, num_prim_cols, num_sec_cols)\n\n\tif ( dy % 2 == 0) {\n\t\tlen_sec_cols = dy / 2\n\t} else {\n\t\tlen_sec_cols = dy / 2 + 1\n\t}\n//\tfmt.Printf(\"\\nlen_prim_cols=\\t%d\\nlen_sec_cols=\\t%d\\n\", len_prim_cols, len_sec_cols)\n\t\n\tfmt.Println(num_prim_cols * len_prim_cols + num_sec_cols * len_sec_cols)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "0d269227c9de12906c192c181588425b", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc toTernaryDigits(x int) []int {\n digits := []int{}\n if x == 0 {\n digits = append(digits, 0)\n }\n for x != 0 {\n digits = append(digits, x%3)\n x /= 3\n }\n return digits\n}\nfunc displayDigits(digits []int) {\n for i := len(digits)-1; i >= 0; i-- {\n fmt.Printf(\"%d\", digits[i])\n }\n fmt.Printf(\"\\n\")\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n a, c := int(getI()), int(getI())\n as, cs := toTernaryDigits(a), toTernaryDigits(c)\n for len(as) < len(cs) {\n as = append(as, 0)\n }\n for len(cs) < len(as) {\n cs = append(cs, 0)\n }\n n := len(as)\n bs := make([]int, n)\n for i := 0; i < n; i++ {\n bs[i] = (cs[i] + 3 - as[i]) % 3\n }\n b := 0\n for i := n-1; i >= 0; i-- {\n b = 3*b + bs[i]\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", b))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "0b1914c95f2c61f89aa3f67adef57c78", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 136B-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, c, b, d, l, i int64\n fmt.Scan(&a, &c)\n var k []int64\n for a != int64(0) || c != int64(0) {\n b = a % 3\n a = a / 3\n d = c % 3\n c = c / 3\n if d-b < int64(0) {\n k = append(k, 3-b+d)\n l++\n } else {\n k = append(k, d-b)\n l++\n }\n }\n ans := int64(0)\n cur := int64(1)\n for i = 0; i < l; i++ {\n ans = ans + cur*k[i]\n cur *= 3\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "7a302908d15be43fef6a094977e0cbb4", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a,b,c int\n fmt.Scan(&a,&c)\n for i := 1; (a > 0) || (c > 0); i *= 3 {\n da, dc := a%3, c%3\n if dc < da { dc += 3 }\n b += (i*(dc-da))\n a /= 3\n c /= 3\n }\n fmt.Println(b)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "269f0caa1879ea4d5f1144b496efa6b3", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, k float64\n\tfmt.Scanf(\"%f %f\\n\", &n, &k)\n\ta := 1.0\n\tb := 2*n + 3\n\tc := n*n + n - 2*k\n\n\t// fmt.Printf(\"a = %f, b = %f, c = %f\\n\", a, b, c)\n\n\tans := (b - math.Sqrt(b*b-4*a*c)) / 2\n\t// fmt.Printf(\"%f\\n\", ans)\n\tfmt.Printf(\"%d\\n\", int(math.Round(ans)))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search"], "code_uid": "3d4aab10782b64f3adc578fc27831a65", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n, k int64\n fmt.Scan(&n, &k)\n var x, y int64 = 1, n\n for y - x > 1 {\n var p int64 = (x + y) / 2\n if p * (p + 1) / 2 - (n - p) >= k {\n y = p\n } else {\n x = p\n }\n }\n fmt.Println(n - y)\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search"], "code_uid": "95c4f6d7ef08e0e32a5b72d7c3564aeb", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, k, res, index int\n\t// var a, b, c string\n\n\tscr := bufio.NewReader(os.Stdin)\n\t// ocr := bufio.NewWriter(os.Stdout)\n\n\tfmt.Fscanln(scr, &n, &k)\n\n\tfor i := 1; i <= n; i++ {\n\t\tindex++\n\t\tres += index\n\t\tif res-(n-i) == k {\n\t\t\tfmt.Println(n - i)\n\t\t\tbreak\n\t\t}\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search"], "code_uid": "bb92538750ec5067e1dbcecb4047cc6d", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar in string\n\tfmt.Scanln(&in)\n\n\tout := \"\"\n\n\tfor run := len(in) > 0; run; run = len(in) > 0 {\n\t\tif len(in)%2 == 0 {\n\t\t\tout = string(in[len(in)-1]) + out\n\t\t\tin = in[0 : len(in)-1]\n\t\t} else {\n\t\t\tout = string(in[0]) + out\n\t\t\tin = in[1:len(in)]\n\t\t}\n\t}\n\n\tfmt.Println(out)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "55fafcd0646548814ccd84ae521024b6", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t// \"sort\"\n\t// \"strings\"\n\t\n)\n\n\nfunc main() {\n\n\tvar cipher string\n\tfmt.Scan(&cipher)\n\n\tvar result []byte\n\tfor len(cipher) > 0 {\n\t\tvar length uint = uint(len(cipher))\n\t\t\n\t\tif len(cipher) % 2 == 0 {\n\t\t\t result = append(result, cipher[length - 1])\n\n\t\t\t cipher = cipher[:length - 1]\n\t\t} else {\n\t\t\tresult = append(result, cipher[0])\n\t\t\tcipher = cipher[1:]\n\t\t}\n\t}\n\n\tfor _, letter := range result {\n\t\tdefer fmt.Printf(\"%s\", string(letter))\n\t}\n\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "1badd4311f501fc59dfcc5c59def298c", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n\nfunc main() {\n\tio := newIO()\n\tdefer io.out.Flush()\n\n\ts := io.nextString()\n\tvar position int\n\tif len(s) % 2 == 0{\n\t\tposition = 1\n\t} else {\n\t\tposition = 0\n\t}\n\n\tvar sb strings.Builder\n\tfirst, last := 0, len(s) - 1\n\tfor i := 0; i < len(s); i++ {\n\t\tif position == 0 {\n\t\t\tsb.WriteString(s[first:first+1])\n\t\t\tfirst++\n\t\t} else {\n\t\t\tsb.WriteString(s[last:last+1])\n\t\t\tlast--\n\t\t}\n\t\tposition ^= 1\n\t}\n\ts = sb.String()\n\tio.print(reverse(s) + \"\\n\")\n}\n\n\ntype stack []int\n\n\nfunc reverse (s string) string {\n\tsb := strings.Builder{}\n\tfor i := len(s) - 1; i >= 0; i--{\n\t\tsb.WriteString(s[i:i+1])\n\t}\n\treturn sb.String()\n}\n\nfunc (s stack) Push(v int) stack {\n\treturn append(s, v)\n}\n\nfunc (s stack) Pop() (stack, int, bool) {\n\tl := len(s)\n\tif l == 0 {return s, 0, false}\n\treturn s[:l-1], s[l-1], true\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\ntype io struct {\n\tinp *bufio.Scanner\n\tout *bufio.Writer\n}\n\nfunc newIO() io {\n\tsc := io{\n\t\tinp: bufio.NewScanner(os.Stdin),\n\t\tout: bufio.NewWriter(os.Stdout),\n\t}\n\tsc.inp.Split(bufio.ScanWords)\n\treturn sc\n}\nfunc (sc io) nextArr(n int) []int {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = sc.nextInt()\n\t}\n\treturn a\n}\nfunc (sc io) nextString() string {\n\tsc.inp.Scan()\n\treturn sc.inp.Text();\n}\n\nfunc (sc io) nextInt64() int64 {\n\tv, _ := strconv.ParseInt(sc.nextString(), 10, 64)\n\treturn int64(v)\n}\nfunc (sc io) nextInt() int {\n\tv, _ := strconv.ParseInt(sc.nextString(), 10, 32)\n\treturn int(v)\n}\n\nfunc (out io) print (s string) {\n\tout.out.WriteString(s)\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "0954bc4cc6e2c620ad9a2290e97feb9b", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n var q int\n a := make([]string, 3)\n a[0] = \"qwertyuiop\"\n a[1] = \"asdfghjkl;\"\n a[2] = \"zxcvbnm,./\"\n s := ReadString()\n if s == \"R\" {\n q = -1\n } else {\n q = 1\n }\n s = ReadString()\n r := \"\"\n dicti := make(map[uint8]int)\n dictj := make(map[uint8]int)\n for j := 0; j < 3; j++ {\n for i := 0; i < 10; i++ {\n dicti[a[j][i]] = i\n dictj[a[j][i]] = j\n }\n }\n for i := 0; i < len(s); i++ {\n r += string(a[dictj[s[i]]][dicti[s[i]]+q])\n }\n writer.WriteString(r)\n writer.WriteString(\"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a8fe8a998ba346525b98bdfaaafcfe54", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n var q int\n keyboard := \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n dict := make(map[uint8]int)\n\n if ReadString() == \"R\" {\n q = -1\n } else {\n q = 1\n }\n\n s := ReadString()\n for i := 0; i < len(keyboard); i++ {\n dict[keyboard[i]] = i\n }\n\n r := \"\"\n for i := range s {\n r += string(keyboard[dict[s[i]]+q])\n }\n\n writer.WriteString(r + \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "7da5ddb01fa94ebd258a460f663af4c2", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tupperRow := map[string]int{\"q\": 1, \"w\": 2, \"e\": 3, \"r\": 4, \"t\": 5, \"y\": 6, \"u\": 7, \"i\": 8, \"o\": 9, \"p\": 10}\n\tlookUpUpperRow := map[int]string{1: \"q\", 2: \"w\", 3: \"e\", 4: \"r\", 5: \"t\", 6: \"y\", 7: \"u\", 8: \"i\", 9: \"o\", 10: \"p\"}\n\n\tmiddleRow := map[string]int{\"a\": 1, \"s\": 2, \"d\": 3, \"f\": 4, \"g\": 5, \"h\": 6, \"j\": 7, \"k\": 8, \"l\": 9, \";\": 10}\n\tlookUpMiddleRow := map[int]string{1: \"a\", 2: \"s\", 3: \"d\", 4: \"f\", 5: \"g\", 6: \"h\", 7: \"j\", 8: \"k\", 9: \"l\", 10: \";\"}\n\n\tlowerRow := map[string]int{\"z\": 1, \"x\": 2, \"c\": 3, \"v\": 4, \"b\": 5, \"n\": 6, \"m\": 7, \",\": 8, \".\": 9, \"/\": 10}\n\tlookUpLowerRow := map[int]string{1: \"z\", 2: \"x\", 3: \"c\", 4: \"v\", 5: \"b\", 6: \"n\", 7: \"m\", 8: \",\", 9: \".\", 10: \"/\"}\n\n\tvar shiftDirection, inputString string\n\n\tfmt.Scanf(\"%s\\n\", &shiftDirection)\n\n\tfmt.Scanf(\"%s\\n\", &inputString)\n\n\tstrSize := len(inputString)\n\n\tfor i := 0; i < strSize; i++ {\n\t\tif upperRow[string(inputString[i])] != 0 {\n\t\t\ttargetPos := upperRow[string(inputString[i])]\n\t\t\tif shiftDirection == \"R\" {\n\t\t\t\tfmt.Print(lookUpUpperRow[targetPos-1])\n\t\t\t} else {\n\t\t\t\tfmt.Print(lookUpUpperRow[targetPos+1])\n\t\t\t}\n\t\t} else if middleRow[string(inputString[i])] != 0 {\n\t\t\ttargetPos := middleRow[string(inputString[i])]\n\t\t\tif shiftDirection == \"R\" {\n\t\t\t\tfmt.Print(lookUpMiddleRow[targetPos-1])\n\t\t\t} else {\n\t\t\t\tfmt.Print(lookUpMiddleRow[targetPos+1])\n\t\t\t}\n\t\t} else {\n\t\t\ttargetPos := lowerRow[string(inputString[i])]\n\t\t\tif shiftDirection == \"R\" {\n\t\t\t\tfmt.Print(lookUpLowerRow[targetPos-1])\n\t\t\t} else {\n\t\t\t\tfmt.Print(lookUpLowerRow[targetPos+1])\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println()\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0b7700f0483c58621d9e57010fe7cef0", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n defer writer.Flush()\n var d int\n scanf(\"%d\\n\", &d)\n r := make([]int, d)\n b := make([]int, d)\n for i := range r {\n scanf(\"%d\", &r[i])\n }\n scanf(\"\\n\")\n for i := range b {\n scanf(\"%d\", &b[i])\n }\n solve(r, b)\n}\n\nfunc solve(r, b []int) {\n rr, bb := 0, 0\n for i := range r {\n if r[i] > b[i] {\n rr++\n }\n if r[i] < b[i] {\n bb++\n }\n }\n score := 1\n if rr == 0 {\n score = -1\n } else if bb >= rr {\n score = (bb-rr+1)/rr + 1\n if (bb-rr+1)%rr > 0 {\n score++\n }\n }\n printf(\"%d\", score)\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "69ffeb245cb32be08761e980db4f1ab7", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc run(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n int\n\tFscan(in, &n)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tb := make([]int, n)\n\tcnt1, cnt0 := 0, 0\n\tfor i := range b {\n\t\tFscan(in, &b[i])\n\t\tif a[i] == 1 && b[i] == 0 {\n\t\t\tcnt1++\n\t\t} else if a[i] == 0 && b[i] == 1 {\n\t\t\tcnt0++\n\t\t}\n\t}\n\n\tif cnt1==0 {\n\t\tFprintln(out, -1)\n\t\treturn\n\t}\n\n\tif cnt0 == 0 {\n\t\tFprintln(out, 1)\n\t\treturn\n\t}\n\n\tif cnt0 %cnt1 == 0 {\n\t\tFprintln(out, cnt0/cnt1+1)\n\t} else {\n\t\tans := (cnt0-1)/cnt1+1\n\t\tFprintln(out, ans)\n\t}\n\n\n\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "70ad49f35ad53a8d93727cbd37272917", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tr := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&r[i])\n\t}\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&b[i])\n\t}\n\trls := solve(n, r, b)\n\tfmt.Println(rls)\n}\n\nfunc solve(n int, r, b []int) int {\n\tnr, nb := 0, 0\n\tfor i := 0; i < n; i++ {\n\t\tif r[i] == 1 && b[i] == 0 {\n\t\t\tnr += 1\n\t\t}\n\t\tif r[i] == 0 && b[i] == 1 {\n\t\t\tnb += 1\n\t\t}\n\t}\n\tvar rls int\n\tif nr == 0 {\n\t\trls = -1\n\t} else {\n\t\trls = nb/nr + 1\n\t}\n\treturn rls\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "4e59de424e6a457b7504a9b975596e6b", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"os\"\n)\n\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\ntype V struct {\n\tP, Pchar, Link int\n\tNext, Walk [26]int\n}\n\nfunc (node V) String() string {\n\treturn fmt.Sprintf(\"p = %v, pchar = %v, link = %v\", node.P, node.Pchar, node.Link)\n}\n\nfunc CreateNode(p, pchar int) *V {\n\tv := &V{P:p, Pchar:pchar, Link:-1}\n\tfor i := 0; i < len(v.Next); i++ {\n\t\tv.Next[i], v.Walk[i] = -1, -1\n\t}\n\treturn v\n}\n\nfunc AddString(a string) {\n\tvar v int = 0\n\tfor i := 0; i < len(a); i++ {\n\t\tvar c int = int(a[i] - 'A')\n\t\tif tree[v].Next[c] == -1 {\n\t\t\ttree[size] = CreateNode(v, c)\n\t\t\ttree[v].Next[c] = size\n\t\t\tsize++\n\t\t}\n\t\tv = tree[v].Next[c]\n\t}\n}\n\nfunc Walk(v, c int) int {\n\tif tree[v].Walk[c] != -1 {\n\t\treturn tree[v].Walk[c]\n\t}\n\tif tree[v].Next[c] != -1 {\n\t\ttree[v].Walk[c] = tree[v].Next[c]\n\t}else {\n\t\tif v == 0 {\n\t\t\ttree[v].Walk[c] = 0\n\t\t}else {\n\t\t\ttree[v].Walk[c] = Walk(Getlink(v), c)\n\t\t}\n\t}\n\treturn tree[v].Walk[c]\n}\n\nfunc Getlink(v int) int {\n\tif tree[v].Link != -1 {\n\t\treturn tree[v].Link\n\t}\n\tif v == 0 || tree[v].P == 0 {\n\t\ttree[v].Link = 0\n\t}else {\n\t\ttree[v].Link = Walk(Getlink(tree[v].P), tree[v].Pchar)\n\t}\n\treturn tree[v].Link\n}\n\nfunc Dp(i, j, k int) int {\n\t// if k == v {\n\t// \treturn -oo\n\t// }\n\tif i == n {\n\t\treturn 0\n\t}\n\tif j == m {\n\t\treturn 0\n\t}\n\n\tif dp[i][j][k] != -1 {\n\t\treturn dp[i][j][k]\n\t}\n\n\tvar ret int = -oo\n\tif a[i] == b[j] {\n\t\tvar next int = Walk(k, int(a[i] - 'A'))\n\t\tif next != v {\n\t\t\tret = Max(ret, Dp(i + 1, j + 1, next) + 1)\t\n\t\t}\n\t}\n\n\tret = Max(ret, Dp(i + 1, j, k))\n\tret = Max(ret, Dp(i, j + 1, k))\n\n\tdp[i][j][k] = ret\n\treturn ret\n}\n\nfunc Print(i, j, k int) {\n\tif i == n {\n\t\treturn\n\t}\n\tif j == m {\n\t\treturn\n\t}\n\tif a[i] == b[j] {\n\t\tvar ret, which int = Dp(i + 1, j, k), 0\n\t\tif ret < Dp(i, j + 1, k) {\n\t\t\tret, which = Dp(i, j + 1, k), 1\n\t\t}\n\t\tvar next int = Walk(k, int(a[i] - 'A'))\n\t\tif next != v {\n\t\t\tif ret <= Dp(i + 1, j + 1, next) {\n\t\t\t\tret, which = Dp(i + 1, j + 1, next), 2\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tif which == 0 {\n\t\t\tPrint(i + 1, j, k)\n\t\t}else if which == 1 {\n\t\t\tPrint(i, j + 1, k)\n\t\t}else {\n\t\t\tfmt.Fprint(out, string(a[i]))\n\t\t\tPrint(i + 1, j + 1, next)\n\t\t}\n\n\t}else {\n\t\tvar ret int = Dp(i + 1, j , k)\n\t\tif ret < Dp(i, j + 1, k) {\n\t\t\tPrint(i, j + 1, k)\n\t\t}else {\n\t\t\tPrint(i + 1, j, k)\n\t\t}\n\t}\n}\n\nconst oo = 1<<30\n\nvar n, m, v int\nvar a, b, c string\nvar size int\nvar tree [110]*V\n\nvar dp [][][]int\n\nfunc main() {\n\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\ta, b, c = Next(), Next(), Next()\n\tn, m, v = len(a), len(b), len(c)\n\ttree[size] = CreateNode(-1, -1)\n\tsize++\n\tAddString(c)\n\n\tdp = make([][][]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tdp[i] = make([][]int, m)\n\t\tfor j := 0; j < m; j++ {\n\t\t\tdp[i][j] = make([]int, v)\n\t\t\tfor k := 0; k < v; k++ {\n\t\t\t\tdp[i][j][k] = -1\n\t\t\t}\n\t\t}\n\t}\n\n\tvar ret int = Dp(0, 0, 0)\n\t// fmt.Fprintln(out, ret)\n\tif ret <= 0 {\n\t\tfmt.Fprintln(out, 0)\n\t}else {\n\t\tPrint(0, 0, 0)\n\t\tfmt.Fprintln(out);\n\t}\n}\n\nfunc Max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc Next() string{\n\tif !in.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn in.Text()\n}\n\nfunc NextInt() int{\n\tret, _ := strconv.Atoi(Next())\n\treturn ret\n}", "lang_cluster": "Go", "tags": ["strings", "dp"], "code_uid": "742c9473b88b1a198e02ff6539c9d8a1", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"os\"\n)\n\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\ntype V struct {\n\tP, Pchar, Link int\n\tNext, Walk [26]int\n}\n\nfunc (node V) String() string {\n\treturn fmt.Sprintf(\"p = %v, pchar = %v, link = %v\", node.P, node.Pchar, node.Link)\n}\n\nfunc CreateNode(p, pchar int) *V {\n\tv := &V{P:p, Pchar:pchar, Link:-1}\n\tfor i := 0; i < len(v.Next); i++ {\n\t\tv.Next[i], v.Walk[i] = -1, -1\n\t}\n\treturn v\n}\n\nfunc AddString(a string) {\n\tvar v int = 0\n\tfor i := 0; i < len(a); i++ {\n\t\tvar c int = int(a[i] - 'A')\n\t\tif tree[v].Next[c] == -1 {\n\t\t\ttree[size] = CreateNode(v, c)\n\t\t\ttree[v].Next[c] = size\n\t\t\tsize++\n\t\t}\n\t\tv = tree[v].Next[c]\n\t}\n}\n\nfunc Walk(v, c int) int {\n\tif tree[v].Walk[c] != -1 {\n\t\treturn tree[v].Walk[c]\n\t}\n\tif tree[v].Next[c] != -1 {\n\t\ttree[v].Walk[c] = tree[v].Next[c]\n\t}else {\n\t\tif v == 0 {\n\t\t\ttree[v].Walk[c] = 0\n\t\t}else {\n\t\t\ttree[v].Walk[c] = Walk(Getlink(v), c)\n\t\t}\n\t}\n\treturn tree[v].Walk[c]\n}\n\nfunc Getlink(v int) int {\n\tif tree[v].Link != -1 {\n\t\treturn tree[v].Link\n\t}\n\tif v == 0 || tree[v].P == 0 {\n\t\ttree[v].Link = 0\n\t}else {\n\t\ttree[v].Link = Walk(Getlink(tree[v].P), tree[v].Pchar)\n\t}\n\treturn tree[v].Link\n}\n\nfunc Dp(i, j, k int) int {\n\tif k == v {\n\t\treturn -oo\n\t}\n\tif i == n {\n\t\treturn 0\n\t}\n\tif j == m {\n\t\treturn 0\n\t}\n\n\tif dp[i][j][k] != -1 {\n\t\treturn dp[i][j][k]\n\t}\n\n\tvar ret int = -oo\n\tif a[i] == b[j] {\n\t\tvar next int = Walk(k, int(a[i] - 'A'))\n\t\t// if next != v {\n\t\tret = Max(ret, Dp(i + 1, j + 1, next) + 1)\t\n\t\t// }\n\t}\n\n\tret = Max(ret, Dp(i + 1, j, k))\n\tret = Max(ret, Dp(i, j + 1, k))\n\n\tdp[i][j][k] = ret\n\treturn ret\n}\n\nfunc Print(i, j, k int) {\n\tif i == n {\n\t\treturn\n\t}\n\tif j == m {\n\t\treturn\n\t}\n\tif a[i] == b[j] {\n\t\tvar ret, which int = Dp(i + 1, j, k), 0\n\t\tif ret < Dp(i, j + 1, k) {\n\t\t\tret, which = Dp(i, j + 1, k), 1\n\t\t}\n\t\tvar next int = Walk(k, int(a[i] - 'A'))\n\t\tif next != v {\n\t\t\tif ret <= Dp(i + 1, j + 1, next) {\n\t\t\t\tret, which = Dp(i + 1, j + 1, next), 2\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tif which == 0 {\n\t\t\tPrint(i + 1, j, k)\n\t\t}else if which == 1 {\n\t\t\tPrint(i, j + 1, k)\n\t\t}else {\n\t\t\tfmt.Fprint(out, string(a[i]))\n\t\t\tPrint(i + 1, j + 1, next)\n\t\t}\n\n\t}else {\n\t\tvar ret int = Dp(i + 1, j , k)\n\t\tif ret < Dp(i, j + 1, k) {\n\t\t\tPrint(i, j + 1, k)\n\t\t}else {\n\t\t\tPrint(i + 1, j, k)\n\t\t}\n\t}\n}\n\nconst oo = 1<<30\n\nvar n, m, v int\nvar a, b, c string\nvar size int\nvar tree [110]*V\n\nvar dp [][][]int\n\nfunc main() {\n\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\ta, b, c = Next(), Next(), Next()\n\tn, m, v = len(a), len(b), len(c)\n\ttree[size] = CreateNode(-1, -1)\n\tsize++\n\tAddString(c)\n\n\tdp = make([][][]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tdp[i] = make([][]int, m)\n\t\tfor j := 0; j < m; j++ {\n\t\t\tdp[i][j] = make([]int, v)\n\t\t\tfor k := 0; k < v; k++ {\n\t\t\t\tdp[i][j][k] = -1\n\t\t\t}\n\t\t}\n\t}\n\n\tvar ret int = Dp(0, 0, 0)\n\t// fmt.Fprintln(out, ret)\n\tif ret <= 0 {\n\t\tfmt.Fprintln(out, 0)\n\t}else {\n\t\tPrint(0, 0, 0)\n\t\tfmt.Fprintln(out);\n\t}\n}\n\nfunc Max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc Next() string{\n\tif !in.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn in.Text()\n}\n\nfunc NextInt() int{\n\tret, _ := strconv.Atoi(Next())\n\treturn ret\n}", "lang_cluster": "Go", "tags": ["strings", "dp"], "code_uid": "4ebe84f756da1c51c12e1f3c05cd5529", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"os\"\n)\n\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\ntype V struct {\n\tP, Pchar, Link int\n\tNext, Walk [26]int\n}\n\nfunc (node V) String() string {\n\treturn fmt.Sprintf(\"p = %v, pchar = %v, link = %v\", node.P, node.Pchar, node.Link)\n}\n\nfunc CreateNode(p, pchar int) *V {\n\tv := &V{P:p, Pchar:pchar, Link:-1}\n\tfor i := 0; i < len(v.Next); i++ {\n\t\tv.Next[i], v.Walk[i] = -1, -1\n\t}\n\treturn v\n}\n\nfunc AddString(a string) {\n\tvar v int = 0\n\tfor i := 0; i < len(a); i++ {\n\t\tvar c int = int(a[i] - 'A')\n\t\tif tree[v].Next[c] == -1 {\n\t\t\ttree[size] = CreateNode(v, c)\n\t\t\ttree[v].Next[c] = size\n\t\t\tsize++\n\t\t}\n\t\tv = tree[v].Next[c]\n\t}\n}\n\nfunc Walk(v, c int) int {\n\tif tree[v].Walk[c] != -1 {\n\t\treturn tree[v].Walk[c]\n\t}\n\tif tree[v].Next[c] != -1 {\n\t\ttree[v].Walk[c] = tree[v].Next[c]\n\t}else {\n\t\tif v == 0 {\n\t\t\ttree[v].Walk[c] = 0\n\t\t}else {\n\t\t\ttree[v].Walk[c] = Walk(Getlink(v), c)\n\t\t}\n\t}\n\treturn tree[v].Walk[c]\n}\n\nfunc Getlink(v int) int {\n\tif tree[v].Link != -1 {\n\t\treturn tree[v].Link\n\t}\n\tif v == 0 || tree[v].P == 0 {\n\t\ttree[v].Link = 0\n\t}else {\n\t\ttree[v].Link = Walk(Getlink(tree[v].P), tree[v].Pchar)\n\t}\n\treturn tree[v].Link\n}\n\nfunc Dp(i, j, k int) int {\n\tif k == v {\n\t\treturn -oo\n\t}\n\tif i == n {\n\t\treturn 0\n\t}\n\tif j == m {\n\t\treturn 0\n\t}\n\n\tif dp[i][j][k] != -1 {\n\t\treturn dp[i][j][k]\n\t}\n\n\tvar ret int = -oo\n\tif a[i] == b[j] {\n\t\tvar next int = Walk(k, int(a[i] - 'A'))\n\t\tif next != v {\n\t\t\tret = Max(ret, Dp(i + 1, j + 1, next) + 1)\t\n\t\t}\n\t}\n\n\tret = Max(ret, Dp(i + 1, j, k))\n\tret = Max(ret, Dp(i, j + 1, k))\n\n\tdp[i][j][k] = ret\n\treturn ret\n}\n\nfunc Print(i, j, k int) {\n\tif i == n {\n\t\treturn\n\t}\n\tif j == m {\n\t\treturn\n\t}\n\tif a[i] == b[j] {\n\t\tvar ret, which int = Dp(i + 1, j, k), 0\n\t\tif ret < Dp(i, j + 1, k) {\n\t\t\tret, which = Dp(i, j + 1, k), 1\n\t\t}\n\t\tvar next int = Walk(k, int(a[i] - 'A'))\n\t\tif next != v {\n\t\t\tif ret <= Dp(i + 1, j + 1, next) {\n\t\t\t\tret, which = Dp(i + 1, j + 1, next), 2\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tif which == 0 {\n\t\t\tPrint(i + 1, j, k)\n\t\t}else if which == 1 {\n\t\t\tPrint(i, j + 1, k)\n\t\t}else {\n\t\t\tfmt.Fprint(out, string(a[i]))\n\t\t\tPrint(i + 1, j + 1, next)\n\t\t}\n\n\t}else {\n\t\tvar ret int = Dp(i + 1, j , k)\n\t\tif ret < Dp(i, j + 1, k) {\n\t\t\tPrint(i, j + 1, k)\n\t\t}else {\n\t\t\tPrint(i + 1, j, k)\n\t\t}\n\t}\n}\n\nconst oo = 1<<30\n\nvar n, m, v int\nvar a, b, c string\nvar size int\nvar tree [110]*V\n\nvar dp [][][]int\n\nfunc main() {\n\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\ta, b, c = Next(), Next(), Next()\n\tn, m, v = len(a), len(b), len(c)\n\ttree[size] = CreateNode(-1, -1)\n\tsize++\n\tAddString(c)\n\n\tdp = make([][][]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tdp[i] = make([][]int, m)\n\t\tfor j := 0; j < m; j++ {\n\t\t\tdp[i][j] = make([]int, v)\n\t\t\tfor k := 0; k < v; k++ {\n\t\t\t\tdp[i][j][k] = -1\n\t\t\t}\n\t\t}\n\t}\n\n\tvar ret int = Dp(0, 0, 0)\n\t// fmt.Fprintln(out, ret)\n\tif ret <= 0 {\n\t\tfmt.Fprintln(out, 0)\n\t}else {\n\t\tPrint(0, 0, 0)\n\t\tfmt.Fprintln(out);\n\t}\n}\n\nfunc Max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc Next() string{\n\tif !in.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn in.Text()\n}\n\nfunc NextInt() int{\n\tret, _ := strconv.Atoi(Next())\n\treturn ret\n}", "lang_cluster": "Go", "tags": ["strings", "dp"], "code_uid": "1c607a76f26bee9aa3e7b2940c79a258", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n,k,w int;\n\tfmt.Scanf(\"%d%d%d\",&k,&n,&w);\n\tif (((w*(w+1))/2)*k)-n >0{\n\t\tfmt.Print((((w*(w+1))/2)*k)-n );\n\n\t}else {\n\t\tfmt.Print(0)\n\t};\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "3693eb133b45411d90d9039693e5d488", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main;\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n, k, w int64;\n fmt.Scanf(\"%d %d %d\", &k, &n, &w);\n var ans = w * (w + 1) / 2 * k - n;\n if ans < 0 {\n ans = 0;\n }\n fmt.Printf(\"%d\", ans);\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "93399037edc8720f6d08d108c7aa4363", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, k, w, sum int\n\treader := bufio.NewReader(os.Stdin)\n\tfmt.Fscanln(reader, &n, &k, &w)\n\tfor i := 1; i <= w; i++ {\n\t\tsum += i * n\n\t}\n\n\tret := sum - k\n\n\tif ret < 0 {\n\t\tfmt.Println(0)\n\t} else {\n\t\tfmt.Println(ret)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "ee8b556fb58d3b2c42678815d1f1cbe9", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n \"fmt\"\n //\"unicode/utf8\"\n)\n\nfunc main() {\n var n,x int\n fmt.Scan(&n)\n x=n/2*3\n fmt.Println(x)\n\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "4855df8764b1a41fafe29efdafb0846b", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tfmt.Println(n / 2 * 3)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "ca4eec23149c669df728ceef4019d4ac", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"unicode/utf8\"\n)\n\nfunc main() {\n\tvar n,x int\n\tfmt.Scan(&n)\n\tx=n/2*3\n\tfmt.Println(x)\n\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "930809bc35b9fe588ca3a6651aae8ed7", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := readInt64()\n\tb := readInt64()\n\n\tres := int64(1)\n\tcnt := 0\n\tfor i := a + 1; i <= b; i++ {\n\t\tm := int64(1)\n\t\tif i != 0 {\n\t\t\tm = i\n\t\t}\n\t\tm %= 10\n\t\tres %= 10\n\t\tres *= m\n\t\tif cnt > 10 {\n\t\t\tbreak\n\t\t}\n\t\tcnt++\n\t}\n\tfmt.Println(res % 10)\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "8b60d0399d1394ed84923c3c35110cfc", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, r int64;\n\tfmt.Scan(&a, &b)\n\tfor r = 1; a < b; b-- {\n\t\tr *= b % 10\n\t\tif r == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(r % 10)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "9185ab614a6953f69dbf61b003bd6e27", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n var a, b, x int64 \n x = 1\n\n fmt.Scan(&a, &b);\n\n for i := a + 1; i <= b; i++ {\n x = (x * i % 10) % 10 \n if x == 0 {\n break\n }\n } \n\n fmt.Println(x);\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "fc3d05c1fbf7c53e7c96fd5036549c20", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"strings\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar x string\n\tScan(&x)\n\tn := len(x)\n\tif n == 1 {\n\t\tPrint(x)\n\t\treturn\n\t}\n\tdata := []byte(x)\n\tsum := 0\n\tfor _, c := range x {\n\t\tsum += int(c - '0')\n\t}\n\tif x[1] == '9' {\n\t\tdecPos := 1\n\t\tfor i, c := range x[1:] {\n\t\t\tif c != '9' {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdecPos = i + 1\n\t\t}\n\t\tdata[decPos] = '8'\n\t\tif newSum := int(data[0]-'0') + 8 + 9*(n-2); newSum <= sum {\n\t\t\tPrint(x)\n\t\t\treturn\n\t\t}\n\t\tx9 := strings.Repeat(\"9\", n-1-decPos)\n\t\tPrint(string(data[:decPos]) + \"8\" + x9)\n\t\treturn\n\t}\n\tdata[0]--\n\tif newSum := int(data[0]-'0') + 9*(n-1); newSum <= sum {\n\t\tPrint(x)\n\t\treturn\n\t}\n\tx9 := strings.Repeat(\"9\", n-1)\n\tif data[0] == '0' {\n\t\tPrint(x9)\n\t} else {\n\t\tPrint(string(data[0]) + x9)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "0ae46664c15c6865d724b9cb30f34536", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// A1. Good Matrix Elements\n/*\nThe Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good:\n\n Elements of the main diagonal.\n Elements of the secondary diagonal.\n Elements of the \"middle\" row — the row which has exactly rows above it and the same number of rows below it.\n Elements of the \"middle\" column — the column that has exactly columns to the left of it and the same number of columns to the right of it.\n\nThe figure shows a 5 × 5 matrix. The good elements are marked with green.\n\nHelp the Smart Beaver count the sum of good elements of the given matrix.\n\nInput\nThe first line of input data contains a single odd integer n. Each of the next n lines contains n integers a ij (0 ≤ a ij ≤ 100) separated by single spaces — the elements of the given matrix.\n\nThe input limitations for getting 30 points are:\n\n 1 ≤ n ≤ 5\n\nThe input limitations for getting 100 points are:\n\n 1 ≤ n ≤ 101\n\nOutput\nPrint a single integer — the sum of good matrix elements.\n\nExamples\nInput\n3\n1 2 3\n4 5 6\n7 8 9\n\nOutput\n45\n\nInput\n5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nOutput\n17\n\nNote\nIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput1, _ := reader.ReadString('\\n')\n\tn, _ := strconv.Atoi(strings.TrimSpace(input1))\n\n\ttotal := 0\n\tfor i := 0; i < n; i++ {\n\t\tinput2, _ := reader.ReadString('\\n')\n\t\tfor j := 0; j < n; j++ {\n\t\t\tarr := strings.Split(strings.TrimSpace(input2), \" \")\n\t\t\tx, _ := strconv.Atoi(arr[j])\n\t\t\tif i == j {\n\t\t\t\ttotal += x\n\t\t\t} else if i+j == n-1 {\n\t\t\t\ttotal += x\n\t\t\t} else if j == (n-1)/2 {\n\t\t\t\ttotal += x\n\t\t\t} else if i == (n-1)/2 {\n\t\t\t\ttotal += x\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(total)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "c7993d7be973c60faba75974cef2d9e9", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nvar n float64\n\nfunc main() {\n fmt.Scanln(&n)\n if int(n)%2 != 0 {\n fmt.Println(0)\n return\n }\n ans := int(math.Ceil(((n / 2) / 2)))\n ans -= 1\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "2a9ed560eb2456a329f557b146667c98", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// stick.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tc := 0\n\tif n%2 == 0 {\n\t\tc = int((n - 1) / 4)\n\t}\n\tfmt.Println(c)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "be0133b1c42d2e7863ed49d1cd447944", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \t\"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\ta := 0\n\tif n%2 == 0 {\n\t\ta = int((n - 1) / 4)\n\t}\n\tfmt.Println(a)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "fe53bf3b52103784afd800fde4991534", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc factor(mp map[int]int,n int) {\n\tfor i:=2 ; i*i <= n; i++ {\n\t\tfor n%i==0 {\n\t\t\tn/=i\n\t\t\tmp[i]++\n\t\t}\n\t}\n\tif n>1 {\n\t\tmp[n]++\n\t}\n}\nfunc newRes(mp map[int]int) int{\n\tval:=1\n\tfor k,v := range mp {\n\t\t//fmt.Printf(\"k:%d,v:%d\\n\",k,v)\n\t\tfor cnt:=0;cnt<(v+1)/2;cnt++ {\n\t\t\tval*=k\n\t\t}\n\t}\n\treturn val\n}\n\nfunc main() {\n\tvar n int\n\t_,_=fmt.Scanln(&n)\n\tmp:=make(map[int]int)\n\tres,step:=n,0\n\tfor {\n\t\tfor k,_:= range mp {\n\t\t\tdelete(mp,k)\n\t\t}\n\t\tfactor(mp,res)\n\t\tret:=newRes(mp)\n\t\t//fmt.Printf(\"before:%d ,after:%d\\n\",res,ret)\n\t\tif ret == res {\n\t\t\tbreak\n\t\t} else {\n\t\t\tstep++\n\t\t\tres=ret\n\t\t}\n\t}\n\tflag:=false\n\tval:=res\n\tfor {\n\t\tif val > n/val {\n\t\t\tbreak\n\t\t}\n\n\t\tval*=val\n\t\tif val== n{\n\t\t\tflag=true\n\t\t\tbreak\n\t\t}\n\t}\n\tif res==n {//prime\n\t\tstep=0\n\t}else if !flag {//square\n\t\tstep=step+1\n\t}\n\tfmt.Println(res,step)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "e83714bd5e4d90dae62acb7fa1061bc8", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math/bits\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc init() {\n\tscanner = bufio.NewScanner(bufio.NewReader(os.Stdin))\n\t//scanner.Buffer(make([]byte, 311000), 311000)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc next() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tnum, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn num\n}\n\nfunc genPrimes() []int {\n\tprimes := make([]int, 0, 170)\n\tvar isDivisible [1001]bool\n\tfor i := 2; i <= 1000; i++ {\n\t\tif !isDivisible[i] {\n\t\t\tprimes = append(primes, i)\n\t\t\tfor j := i + i; j <= 1000; j += i {\n\t\t\t\tisDivisible[j] = true\n\t\t\t}\n\t\t}\n\t}\n\treturn primes\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tN := nextInt()\n\tif N == 1 {\n\t\tfmt.Println(\"1 0\")\n\t\treturn\n\t}\n\tprimes := genPrimes()\n\n\tprimeFactors := make(map[int]int)\n\tfor _, p := range primes {\n\t\tfor N%p == 0 {\n\t\t\tN /= p\n\t\t\tprimeFactors[p]++\n\t\t}\n\t\tif N == 1 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif N != 1 {\n\t\tprimeFactors[N]++\n\t}\n\n\t//fmt.Fprintln(os.Stderr, primeFactors)\n\n\tmaxExp := 0\n\tfor _, exp := range primeFactors {\n\t\tif exp > maxExp {\n\t\t\tmaxExp = exp\n\t\t}\n\t}\n\n\tbitlen := uint(bits.Len(uint(maxExp)))\n\tpow := 1 << (bitlen - 1)\n\tnumSqrts := int(bitlen) - 1\n\tif pow < maxExp {\n\t\tpow <<= 1\n\t\tnumSqrts++\n\t}\n\n\tbase := 1\n\tmuls := 0\n\tfor p, exp := range primeFactors {\n\t\tbase *= p\n\t\tif exp < pow {\n\t\t\tmuls = 1\n\t\t}\n\t}\n\n\tfmt.Println(base, muls+numSqrts)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "ef753f0ab8e0c8e34e48405131c8f26d", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1062/B\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn int\n)\n\nfunc main() {\n\tn = ReadInt()\n\n\tif n == 1 {\n\t\tfmt.Println(1, 0)\n\t\treturn\n\t}\n\n\tmemo := TrialDivision(n)\n\tPrintfDebug(\"n: %v\\n\", memo)\n\n\tfin := 1\n\tfor k := range memo {\n\t\tfin *= k\n\t}\n\n\tM := make(map[int]int)\n\tS := make(map[int]int)\n\tfor k, v := range memo {\n\t\tmul := 0\n\t\tsqrt := 0\n\t\tfor v > 1 {\n\t\t\tif v%2 == 1 {\n\t\t\t\tv++\n\t\t\t\tmul++\n\t\t\t} else {\n\t\t\t\tv /= 2\n\t\t\t\tsqrt++\n\t\t\t}\n\t\t}\n\t\tM[k] = mul\n\t\tS[k] = sqrt\n\t}\n\n\tmaxSqrt := 0\n\tfor _, v := range S {\n\t\tChMax(&maxSqrt, v)\n\t}\n\t// ans := 0\n\t// for k, v := range S {\n\t// \tans += v\n\t// \tans += M[k]\n\n\t// \tans += 2 * (maxSqrt - v)\n\t// }\n\n\t// if maxSqrt > 0 {\n\t// \tfmt.Println(fin, maxSqrt+1)\n\t// } else {\n\t// \tfmt.Println(fin, 0)\n\t// }\n\n\tif maxSqrt == 0 {\n\t\tfmt.Println(fin, 0)\n\t\treturn\n\t}\n\n\t// maxSqrtと異なるものがあれば掛け算は必要\n\tfor _, v := range S {\n\t\tif v != maxSqrt {\n\t\t\tfmt.Println(fin, maxSqrt+1)\n\t\t\treturn\n\t\t}\n\t}\n\t// 掛け算が一回でも要求されていれば掛け算は必要\n\tfor _, v := range M {\n\t\tif v > 0 {\n\t\t\tfmt.Println(fin, maxSqrt+1)\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(fin, maxSqrt)\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// TrialDivision returns the result of prime factorization of integer N.\nfunc TrialDivision(n int) map[int]int {\n\tvar i, exp int\n\tp := map[int]int{}\n\n\tif n <= 1 {\n\t\tpanic(errors.New(\"[argument error]: TrialDivision only accepts a NATURAL number\"))\n\t}\n\n\tfor i = 2; i*i <= n; i++ {\n\t\texp = 0\n\t\tfor n%i == 0 {\n\t\t\texp++\n\t\t\tn /= i\n\t\t}\n\n\t\tif exp == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tp[i] = exp\n\t}\n\tif n > 1 {\n\t\tp[n] = 1\n\t}\n\n\treturn p\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "5494970433e1f107ce6587917665c970", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\nimport \"math\"\n\nfunc sum(n int64) int64 {\n\tvar summ int64\n\tfor n > 0 {\n\t\tsumm += n%10\n\t\tn /= 10\n\t}\n\treturn summ\n}\n\nfunc main(){\n\tvar n int64\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tvar l int64 = int64(math.Sqrt(float64(n)))-40\n\tif l < 0 {\n\t\tl = 1\n\t}\n\tvar s int64 = int64(math.Sqrt(float64(n)))+1\n\tfor i:=l; i 0 {\n\t\tfor j := 0; j < i; j++ {\n\t\t\tfmt.Print(ans[j], \" \")\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "ca460816283a29f97e5061b1d6307854", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc S(x int64) int64 {\n\tvar res int64 = 0\n\tfor x != 0 {\n\t\tres += x % 10\n\t\tx /= 10\n\t}\n\treturn res\n}\n\nfunc Pow(x, a int64) int64 {\n\tvar res int64 = 1\n\tfor i := 0; int64(i) < a; i++ {\n\t\tres *= x\n\t}\n\treturn res\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tvar a, b, c int64\n\tfmt.Fscan(reader, &a, &b, &c)\n\tvar num_res = 0\n\tvar res []int64 = make([]int64, 40)\n\tfor i := 1; i < 82; i++ {\n\t\tvar x int64 = b*Pow(int64(i), a) + c\n\t\tif x < 1000000000 && S(x) == int64(i) {\n\t\t\tres[num_res] = x\n\t\t\tnum_res++\n\t\t}\n\t}\n\tfmt.Fprintln(writer, num_res)\n\tfor i := 0; i < num_res; i++ {\n\t\tfmt.Fprintf(writer, \"%d \", res[i])\n\t}\n\tfmt.Fprintln(writer)\n\twriter.Flush()\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "e9d887fb59304af18d37853b15e3ae6a", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc sum(x int64) int64 {\n\tres := int64(0)\n\tfor x > 0 {\n\t\tres += x % 10\n\t\tx /= 10\n\t}\n\treturn res\n}\n\nfunc main() {\n\tvar b, c int64\n\tvar a int\n\tfmt.Scan(&a, &b, &c)\n\tvar res []int\n\tfor s := int64(1); s <= 9*9; s++ {\n\t\tr := s\n\t\tfor i := 1; i < a; i++ {\n\t\t\tr *= s\n\t\t}\n\t\tr = b*r + c\n\t\tif sum(r) == s && r < 1000000000 {\n\t\t\tres = append(res, int(r))\n\t\t}\n\t}\n\n\tsort.Ints(res)\n\tfmt.Println(len(res))\n\tfor i, r := range res {\n\t\tfmt.Print(r)\n\t\tif i == len(res)-1 {\n\t\t\tfmt.Print(\"\\n\")\n\t\t} else {\n\t\t\tfmt.Print(\" \")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "a717b63c498a417ae047aa840015f87b", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,m int\n fmt.Scan(&n,&m)\n if n == 0 {\n if m == 0 {\n fmt.Println(0,0)\n } else {\n fmt.Println(\"Impossible\")\n }\n } else {\n var min,max int\n if m > n { min = n+(m-n) } else { min = n }\n if m > 0 { max = n+m-1 } else { max = n }\n fmt.Println(min,max)\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "3fd5c6696909e3854bbddadf5d575f52", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//1.6.2\npackage main\nimport(\"fmt\")\nfunc main(){\n var a,b int\n fmt.Scan(&a,&b)\n if a<1&&b>0{fmt.Println(\"Impossible\")\n }else{if b-a>0{fmt.Print(a+b-a)}else{fmt.Print(a)}\n fmt.Print(\" \")\n if b>0{fmt.Print(a+b-1)}else{fmt.Print(a)}\n }\n}", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "df7c0df1b02c10abfcf184d46ba1ec29", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//1.6.2\npackage main\nimport(\"fmt\")\nfunc main(){\n var a,b int\n fmt.Scan(&a,&b)\n if a<1&&b>0{fmt.Println(\"Impossible\")\n }else{\n if b-a>0{fmt.Print(a+b-a)}else{fmt.Print(a)}\n fmt.Print(\" \")\n if b>0{fmt.Print(a+b-1)}else{fmt.Print(a)}\n }\n}", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "ac64bad1600cb5cb505864fd46cd8663", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 131C-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc c(n, r int64) int64 {\n var i int64\n if r > n {\n return 0\n }\n a := int64(1)\n for i = r + 1; i <= n; i++ {\n a *= i\n a /= (i - r)\n }\n return a\n}\n\nfunc main() {\n var n, m, t, a, i int64\n fmt.Scan(&n, &m, &t)\n for i = 4; i < t; i++ {\n a += c(n, i) * c(m, t-i)\n }\n fmt.Println(a)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "e69ee389751e95b587299b7a44702cea", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 131C\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc c(n int64, k int64) int64 {\n\tvar i, r int64\n\tr = 1\n\tfor i = 1; i <= k; i++ {\n\t\tr = r * (n - k + i)\n\t\tr = r / i\n\t}\n\treturn r\n}\n\nfunc main() {\n\tvar i, n, m, t, tot int64\n\ttot = 0\n\tfmt.Scan(&n, &m, &t)\n\tfor i = 4; i < t; i++ {\n\t\ttot = tot + c(n, i)*c(m, t-i)\n\t}\n\tfmt.Println(tot)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "76f886d459498e33c93d956f6a47d52d", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc build_tree() [][]uint64 {\n\toutput := make([][]uint64, 35)\n\tfor i:=0; i<=30; i++ {\n\t\tt := make([]uint64, 35)\n\t\tt[0]=1\n\t\tfor j:=1; j<=i; j++ {\n\t\t\tt[j] = output[i-1][j] + output[i-1][j-1]\n\t\t}\n\t\toutput[i] = t\n\t}\n\treturn output\n}\n\nfunc main() {\n\ttree := build_tree()\n\tvar n, m, t int\n\tvar ans uint64\n\tfmt.Scan(&n, &m, &t)\n\tfor i:=4; i<=n; i++ {\n\t\tif t-i < 1 || t-i > 30 {continue}\n\t\tans += tree[n][i] * tree[m][t-i]\n\t}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "2418ea46bb277429df96cd00fbfc5789", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\ts := make([]string, 4)\n\tfor i := range s {\n\t\tfmt.Scanln(&s[i])\n\t}\n\tfor i := 0; i < 3; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tcnt := 0\n\t\t\tif s[i][j] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif s[i+1][j] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif s[i][j+1] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif s[i+1][j+1] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif cnt != 2 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "480c4cf9b6485d0d6611bd0f4d4d9343", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc check(x [4]string, a int, b int) bool {\n cnt := 0\n for i := a; i < (a+2); i++ {\n for j := b; j < (b+2); j++ {\n if x[i][j] != x[a][b] { cnt++ }\n }\n }\n if cnt == 2 { return false } else { return true }\n}\n\nfunc main() {\n var x [4]string\n for i := 0; i < 4; i++ {\n fmt.Scan(&x[i])\n }\n ans := false\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n if check(x,i,j) {\n ans = true\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "151edb997415c51e46ccaa829a05ef2b", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc check(x [4]string, a int, b int) bool {\n cnt := 0\n for i := a; i < (a+2); i++ {\n for j := b; j < (b+2); j++ {\n if x[i][j] != x[a][b] { cnt++ }\n }\n }\n if cnt == 2 { return false } else { return true }\n}\n\nfunc main() {\n var x [4]string\n for i := 0; i < 4; i++ {\n fmt.Scan(&x[i])\n }\n ans := false\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n if check(x,i,j) {\n ans = true\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "355e98b7d9aeca0f449db908eca2dc37", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar nFloors int\n\tvar sResident string\n\tvar as []int\n\t_, _ = fmt.Scanln(&nFloors)\n\n\tfor i := 0; i < nFloors; i++ {\n\t\t_, _ = fmt.Scan(&sResident)\n\t\tresident, _ := strconv.Atoi(sResident)\n\t\tas = append(as, resident)\n\t}\n\n\tbestX := math.MaxInt32\n\tfor x := 0; x < len(as); x++ {\n\t\tif sum := sumForXA(x, as); sum < bestX {\n\t\t\tbestX = sum\n\t\t}\n\t}\n\tfmt.Println(bestX)\n}\n\nfunc sumForXA(x int, a []int) int {\n\tunits := 0\n\tfor i := 0; i < len(a); i++ {\n\t\tif a[i] > 0 {\n\t\t\tsum := 0\n\t\t\t// move from x to i\n\t\t\tsum += int(math.Abs(float64(i - x)))\n\t\t\t// move from i to 0\n\t\t\tsum += i\n\t\t\t// move from 0 to x\n\t\t\tsum += x\n\t\t\t// twice (elevator down, up)\n\t\t\tsum *= 2\n\t\t\t// multiply with a\n\t\t\tsum *= a[i]\n\t\t\tunits += sum\n\t\t}\n\t}\n\treturn units\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "f63ff58533c8cbf1a7f343284721e776", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc abs(a int) int {\n\tif a > 0 {\n\t\treturn a\n\t}\n\treturn -a\n}\n\nvar scanner = bufio.NewScanner(os.Stdin)\n\nfunc scanNum() int {\n\tscanner.Scan()\n\tnum, _ := strconv.Atoi(scanner.Text())\n\treturn num\n}\nfunc main() {\n\tscanner.Split(bufio.ScanWords)\n\tn := scanNum()\n\tp := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tp[i] = scanNum()\n\t}\n\tmin := math.MaxInt32\n\tfor i := 0; i < n; i++ {\n\t\tsum := 0\n\t\tfor j := 0; j < n; j++ {\n\t\t\t// Day\n\t\t\tsum += (abs(i-j) + j + i) * p[j]\n\t\t\t// Night\n\t\t\tsum += (i + j + abs(i-j)) * p[j]\n\t\t}\n\t\tif sum < min {\n\t\t\tmin = sum\n\t\t}\n\t}\n\tfmt.Println(min)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "0ada06ef5d7112720bda8aa3ddd8944e", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar num int\n\nfunc main() {\n fmt.Scan(&num)\n cvs := make([]int, num)\n var tmp int\n count := 0\n for i := 0; i < num; i++ {\n fmt.Scan(&tmp)\n cvs[i] = tmp\n if tmp == 1 {\n count++\n }\n }\n ans := count\n zeros := 0\n for _, val := range cvs {\n if val == 0 {\n zeros++\n } else {\n count--\n }\n res := count + zeros\n if res > ans {\n ans = res\n }\n }\n fmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "870b651650d4e9627f560e004a82a0f2", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst maxTokenSize = 512 * 1024\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, maxTokenSize), maxTokenSize)\n\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\n\ta := make([]int, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tscanner.Scan()\n\t\ta[i], _ = strconv.Atoi(scanner.Text())\n\t}\n\n\tminTotal := n\n\n\tfor i := 0; i <= n; i++ {\n\t\tlocalTotal := 0\n\t\tfor j := 0; j < i; j++ {\n\t\t\tif a[j] != 0 {\n\t\t\t\tlocalTotal++\n\t\t\t}\n\t\t}\n\t\tfor j := i; j < n; j++ {\n\t\t\tif a[j] != 1 {\n\t\t\t\tlocalTotal++\n\t\t\t}\n\t\t}\n\t\tif localTotal < minTotal {\n\t\t\tminTotal = localTotal\n\t\t}\n\t}\n\n\tfmt.Println(n - minTotal)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "fa3778159cf6f75d4f01f8b1d4696681", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces My Practice\n// author: Leonardone @ NEETSDKASU\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\txs := make([]int, n)\n\tones := 0\n\tfor i := range xs {\n\t\tfmt.Scan(&xs[i])\n\t\tif xs[i] == 1 {\n\t\t\tones++\n\t\t}\n\t}\n\tans := ones\n\tzeros := 0\n\tfor _, x := range xs {\n\t\tif x == 0 {\n\t\t\tzeros++\n\t\t} else {\n\t\t\tones--\n\t\t}\n\t\ttmp := ones + zeros\n\t\tif tmp > ans {\n\t\t\tans = tmp\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "93988b94a83fd4c13a36a82ec86b61a6", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc sum(k, num int64) int64 {\n\treturn num * ((k-1)+(k - num))/2 + 1\n}\n\nfunc run(n, k int64) {\n\tvar i, j, mid int64\n\ti, j = 0, k-1\n\tmid = (i + j) >> 1\n\tif sum(k, j) < n {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tfor i < j {\n\t\ts := sum(k, mid)\n\t\tif s >= n {\n\t\t\tj = mid\n\t\t} else {\n\t\t\ti = mid + 1\n\t\t}\n\t\tmid = (i + j) >> 1\n\t}\n\tfmt.Println(mid)\n}\n\nfunc main() {\n\tvar n, k int64\n\tfor _, err := fmt.Scanf(\"%d %d\", &n, &k); err == nil; _, err = fmt.Scanf(\"%d %d\", &n, &k) {\n\t\trun(n, k)\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "binary search"], "code_uid": "3abb9bd707fc84eb1472a0a4f4245cd3", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc sum(k, num int64) int64 {\n\treturn num * k - (num - 1) * (num + 2) / 2\n\t//return num * ((k-1)+(k - num))/2 + 1\n}\n\nfunc run(n, k int64) {\n\tvar i, j, mid int64\n\ti, j = 0, k\n\tfor i < j {\n\t\tmid = (i + j) >> 1\n\t\ts := sum(k, mid)\n\t\tif s < n {\n\t\t\ti = mid + 1\n\t\t} else {\n\t\t\tj = mid\n\t\t}\n\t}\n\tmid = (i + j) >> 1\n\tif sum(k, mid) < n {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println((i + j) >> 1)\n\t}\n}\n\nfunc main() {\n\tvar n, k int64\n\tfor _, err := fmt.Scanf(\"%d %d\", &n, &k); err == nil; _, err = fmt.Scanf(\"%d %d\", &n, &k) {\n\t\trun(n, k)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "binary search"], "code_uid": "06a78fc45d3026dd43bea9ef6d65bcdd", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scanln(&n, &k)\n\tlo, hi := int64(0), k\n\tfor lo <= hi {\n\t\tx := (lo + hi) >> 1\n\t\tif (k+k-x-1)*x/2+1 >= n {\n\t\t\thi = x - 1\n\t\t} else {\n\t\t\tlo = x + 1\n\t\t}\n\t}\n\tif lo < k {\n\t\tfmt.Println(lo)\n\t} else {\n\t\tfmt.Println(-1)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "binary search"], "code_uid": "bf7208dd8b8ad39f538f0d5f774a03d0", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, sum int\n\tfmt.Scan(&n, &m)\n\n\tfor n > 0 {\n\t\tsum++\n\t\tif sum%m == 0 {\n\t\t\tn++\n\t\t}\n\t\tn--\n\n\t}\n\tfmt.Println(sum)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "0a8abdeb15ba8175aae7cf0257ced097", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\td := 0\n\tfor ; n > 0; d++ {\n\t\tif (d+1)%m != 0 {\n\t\t\tn--\n\t\t}\n\t}\n\tfmt.Println(d)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "a9f63745846ca117f297af68c9190712", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nvar (\n n int32\n m int32\n k int32\n\n)\n\nfunc in() {\n fmt.Scanf(\"%d%d\", &n, &m)\n \n}\n\nfunc out() {\n fmt.Println(k)\n}\n\nfunc run() {\n for n > 0 {\n k++\n if k % m == 0 {\n k++\n }\n n--\n }\n}\n\nfunc main() {\n in()\n run()\n out()\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "6bb1b9bf1e49e440d8103a33fa731065", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc intScanln(n int) ([]int, error) {\n x := make([]int, n)\n y := make([]interface{}, len(x))\n for i := range x {\n y[i] = &x[i]\n }\n n, err := fmt.Scanln(y...)\n x = x[:n]\n return x, err\n}\n\nfunc main(){\n\tvar n, a int\n\tfmt.Scanln(&n, &a)\n\n\tcities, err := intScanln(n)\n\tif err != nil {\n\t fmt.Println(err)\n\t return\n \t}\n\n\n\n\tvar crims int\n\n\tif cities[a-1] == 1 {\n\t\tcrims = 1\n\t} else { crims = 0 }\n\n\tfor dist := 1; dist < n; dist++ {\n\t\tsure := 0\n\t\tif city := a + dist -1; city < n {\n\t\t\tif cities[city] == 1 { sure = 1 }\n\t\t} else { sure = -1 }\n\n\t\tif city := a-dist -1; city >= 0 {\n\t\t\tif cities[city] == 1 {\n\t\t\t\tif sure == 1 { sure = 2 }\n\t\t\t\tif sure == -1 { sure = 1}\n\t\t\t} else { sure = 0 }\n\t\t}\n\t\t// fmt.Printf(\"dist: %d,\\tsure = %d\\n\", dist, sure)\n\t\tif sure >=0 {crims += sure}\n\t}\n\tfmt.Println(crims)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "7b6e41ce72b7aa76786f750c98e350e7", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var total int\n \n var n, a int\n fmt.Scan(&n, &a)\n \n city := make([]int, n)\n for i:=0; i= 0 || b < n {\n if f >= 0 && b < n {\n if city[f] == 1 && city[b] == 1 {\n total += 2\n if f == b {\n total--\n }\n }\n } else if f >= 0 && city[f] == 1 {\n total++\n } else if b < n && city[b] == 1{\n total++\n }\n f--\n b++\n }\n fmt.Print(total)\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "c4b1123a040660f7f3bd48d3a27dd2c8", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n, a int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &n, &a); err != nil {\n\t\treturn\n\t}\n\n\tcrimes := make([]bool, n)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; scanner.Scan() && i < n; i++ {\n\t\tt, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tif t == 1 {\n\t\t\tcrimes[i] = true\n\t\t} else {\n\t\t\tcrimes[i] = false\n\t\t}\n\t}\n\n\tcatched := 0\n\tfor d := 0; d <= max(a-1, n-a); d++ {\n\t\tif d == 0 || d > min(a-1, n-a) {\n\t\t\tif a-d > 0 {\n\t\t\t\tif crimes[a-d-1] {\n\t\t\t\t\tcatched++\n\t\t\t\t}\n\t\t\t} else if a+d <= n {\n\t\t\t\tif crimes[a+d-1] {\n\t\t\t\t\tcatched++\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif crimes[a-d-1] && crimes[a+d-1] {\n\t\t\t\tcatched += 2\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(catched)\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "38e90b33f6a3630b4b9df69982395399", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nconst N = 205\nconst INF = -1000000000\n\nfunc main() {\n\tio := NewFastIO(os.Stdin, os.Stdout)\n\tdefer io.Flush()\n\n\tn, k := io.NextInt(), io.NextInt()\n\ts, t := io.Next(), io.Next()\n\tvar suff [N][26]int\n\n\tfor i := n; i >= 1; i-- {\n\t\tfor j := 0; j < 26; j++ {\n\t\t\tsuff[i][j] = suff[i+1][j]\n\t\t}\n\t\tsuff[i][int(s[i-1]-'a')]++\n\t}\n\n\tif t[0] == t[1] {\n\t\thave, cur := 0, 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif s[i] == t[0] {\n\t\t\t\tcur++\n\t\t\t} else {\n\t\t\t\thave++\n\t\t\t}\n\t\t}\n\t\tcur += min(have, k)\n\t\tio.Println(cur * (cur - 1) / 2)\n\t\treturn\n\t}\n\n\tvar dp [N][N][N]int\n\tfor i := 0; i < N; i++ {\n\t\tfor j := 0; j < N; j++ {\n\t\t\tfor k := 0; k < N; k++ {\n\t\t\t\tdp[i][j][k] = -1\n\t\t\t}\n\t\t}\n\t}\n\n\ta, b := int(t[0]-'a'), int(t[1]-'a')\n\t_ = a\n\n\tvar dfs func(int, int, int) int\n\tdfs = func(i, r, c int) int {\n\t\tif r < 0 {\n\t\t\treturn INF\n\t\t}\n\t\tif i == n+1 {\n\t\t\tif r == 0 {\n\t\t\t\treturn 0\n\t\t\t} else {\n\t\t\t\treturn INF\n\t\t\t}\n\t\t}\n\t\tif dp[i][r][c] != -1 {\n\t\t\treturn dp[i][r][c]\n\t\t}\n\t\tans := 0\n\t\tif s[i-1] == t[0] {\n\t\t\tans = dfs(i+1, r, c+1) + suff[i+1][b]\n\t\t\tans = max(ans, dfs(i+1, r-1, c))\n\t\t\tans = max(ans, dfs(i+1, r-1, c)+c)\n\t\t} else if s[i-1] == t[1] {\n\t\t\tans = dfs(i+1, r-1, c+1) - c + suff[i+1][b]\n\t\t\tans = max(ans, dfs(i+1, r, c))\n\t\t\tans = max(ans, dfs(i+1, r-1, c))\n\t\t} else {\n\t\t\tans = dfs(i+1, r-1, c+1) + suff[i+1][b]\n\t\t\tans = max(ans, dfs(i+1, r-1, c)+c)\n\t\t\tans = max(ans, dfs(i+1, r, c))\n\t\t}\n\t\tdp[i][r][c] = ans\n\t\treturn ans\n\t}\n\n\tans := 0\n\tfor i := 0; i <= k; i++ {\n\t\tans = max(ans, dfs(1, i, 0))\n\t}\n\n\tio.Println(ans)\n}\n\nfunc min(i, j int) int {\n\tif i > j {\n\t\treturn j\n\t}\n\treturn i\n}\n\nfunc max(i, j int) int {\n\tif i > j {\n\t\treturn i\n\t}\n\treturn j\n}\n\ntype FastIO struct {\n\t*bufio.Reader\n\t*bufio.Writer\n\tc [1]byte\n}\n\nfunc NewFastIO(r io.Reader, w io.Writer) *FastIO {\n\treturn &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}\n}\n\nfunc (f *FastIO) readC() byte {\n\tf.Read(f.c[:])\n\treturn f.c[0]\n}\n\nfunc (f *FastIO) NextInt() int {\n\tc := f.readC()\n\tfor ; c <= ' '; c = f.readC() {\n\t}\n\tneg := false\n\tif c == '-' {\n\t\tneg = true\n\t\tc = f.readC()\n\t}\n\tn := 0\n\tfor ; '0' <= c && c <= '9'; c = f.readC() {\n\t\tn = n*10 + int(c) - '0'\n\t}\n\tif neg {\n\t\treturn -n\n\t}\n\treturn n\n}\n\nfunc (f *FastIO) NextInts(n int) []int {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = f.NextInt()\n\t}\n\treturn a\n}\n\nfunc (f *FastIO) Next() string {\n\tc := f.readC()\n\tfor ; c <= ' '; c = f.readC() {\n\t}\n\tvar s []byte\n\tfor ; c > ' '; c = f.readC() {\n\t\ts = append(s, f.c[0])\n\t}\n\treturn string(s)\n}\n\nfunc (f *FastIO) Println(a ...interface{}) {\n\tfmt.Fprintln(f.Writer, a...)\n}\n\nfunc (f *FastIO) Print(a ...interface{}) {\n\tfmt.Fprint(f.Writer, a...)\n}\n\nfunc (f *FastIO) PrintInts(a ...int) {\n\tif len(a) > 0 {\n\t\tf.Print(a[0])\n\t\tfor _, x := range a[1:] {\n\t\t\tf.Print(\" \", x)\n\t\t}\n\t}\n}\n\nfunc (f *FastIO) PrintlnInts(a ...int) {\n\tf.PrintInts(a...)\n\tf.Println()\n}\n", "lang_cluster": "Go", "tags": ["strings", "dp"], "code_uid": "ca7bb316937be6feaf0c728b869c9806", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nconst N = 205\nconst INF = -1000000000\n\nfunc main() {\n\tio := NewFastIO(os.Stdin, os.Stdout)\n\tdefer io.Flush()\n\n\tn, k := io.NextInt(), io.NextInt()\n\ts, t := io.Next(), io.Next()\n\tvar suff [N][26]int\n\n\tfor i := n; i >= 1; i-- {\n\t\tfor j := 0; j < 26; j++ {\n\t\t\tsuff[i][j] = suff[i+1][j]\n\t\t}\n\t\tsuff[i][int(s[i-1]-'a')]++\n\t}\n\n\tif t[0] == t[1] {\n\t\thave, cur := 0, 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif s[i] == t[0] {\n\t\t\t\tcur++\n\t\t\t} else {\n\t\t\t\thave++\n\t\t\t}\n\t\t}\n\t\tcur += min(have, k)\n\t\tio.Println(cur * (cur - 1) / 2)\n\t\treturn\n\t}\n\n\tvar dp [N][N][N]int\n\tfor i := 0; i < N; i++ {\n\t\tfor j := 0; j < N; j++ {\n\t\t\tfor k := 0; k < N; k++ {\n\t\t\t\tdp[i][j][k] = -1\n\t\t\t}\n\t\t}\n\t}\n\n\ta, b := int(t[0]-'a'), int(t[1]-'a')\n\t_ = a\n\n\tvar dfs func(int, int, int) int\n\tdfs = func(i, r, c int) int {\n\t\tif r < 0 {\n\t\t\treturn INF\n\t\t}\n\t\tif i == n+1 {\n\t\t\tif r == 0 {\n\t\t\t\treturn 0\n\t\t\t} else {\n\t\t\t\treturn INF\n\t\t\t}\n\t\t}\n\t\tif dp[i][r][c] != -1 {\n\t\t\treturn dp[i][r][c]\n\t\t}\n\t\tans := 0\n\t\tif s[i-1] == t[0] {\n\t\t\tans = dfs(i+1, r, c+1) + suff[i+1][b]\n\t\t\tans = max(ans, dfs(i+1, r-1, c))\n\t\t\tans = max(ans, dfs(i+1, r-1, c)+c)\n\t\t} else if s[i-1] == t[1] {\n\t\t\tans = dfs(i+1, r-1, c+1) - c + suff[i+1][b]\n\t\t\tans = max(ans, dfs(i+1, r, c))\n\t\t\tans = max(ans, dfs(i+1, r-1, c))\n\t\t} else {\n\t\t\tans = dfs(i+1, r-1, c+1) + suff[i+1][b]\n\t\t\tans = max(ans, dfs(i+1, r-1, c)+c)\n\t\t\tans = max(ans, dfs(i+1, r, c))\n\t\t}\n\t\tdp[i][r][c] = ans\n\t\treturn ans\n\t}\n\n\tans := 0\n\tfor i := 0; i <= k; i++ {\n\t\tans = max(ans, dfs(1, i, 0))\n\t}\n\n\tio.Println(ans)\n}\n\nfunc min(i, j int) int {\n\tif i > j {\n\t\treturn j\n\t}\n\treturn i\n}\n\nfunc max(i, j int) int {\n\tif i > j {\n\t\treturn i\n\t}\n\treturn j\n}\n\ntype FastIO struct {\n\t*bufio.Reader\n\t*bufio.Writer\n\tc [1]byte\n}\n\nfunc NewFastIO(r io.Reader, w io.Writer) *FastIO {\n\treturn &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}\n}\n\nfunc (f *FastIO) readC() byte {\n\tf.Read(f.c[:])\n\treturn f.c[0]\n}\n\nfunc (f *FastIO) NextInt() int {\n\tc := f.readC()\n\tfor ; c <= ' '; c = f.readC() {\n\t}\n\tneg := false\n\tif c == '-' {\n\t\tneg = true\n\t\tc = f.readC()\n\t}\n\tn := 0\n\tfor ; '0' <= c && c <= '9'; c = f.readC() {\n\t\tn = n*10 + int(c) - '0'\n\t}\n\tif neg {\n\t\treturn -n\n\t}\n\treturn n\n}\n\nfunc (f *FastIO) NextInts(n int) []int {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = f.NextInt()\n\t}\n\treturn a\n}\n\nfunc (f *FastIO) Next() string {\n\tc := f.readC()\n\tfor ; c <= ' '; c = f.readC() {\n\t}\n\tvar s []byte\n\tfor ; c > ' '; c = f.readC() {\n\t\ts = append(s, f.c[0])\n\t}\n\treturn string(s)\n}\n\nfunc (f *FastIO) Println(a ...interface{}) {\n\tfmt.Fprintln(f.Writer, a...)\n}\n\nfunc (f *FastIO) Print(a ...interface{}) {\n\tfmt.Fprint(f.Writer, a...)\n}\n\nfunc (f *FastIO) PrintInts(a ...int) {\n\tif len(a) > 0 {\n\t\tf.Print(a[0])\n\t\tfor _, x := range a[1:] {\n\t\t\tf.Print(\" \", x)\n\t\t}\n\t}\n}\n\nfunc (f *FastIO) PrintlnInts(a ...int) {\n\tf.PrintInts(a...)\n\tf.Println()\n}\n", "lang_cluster": "Go", "tags": ["strings", "dp"], "code_uid": "20c9decc552daeaa7063504ea403f673", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1409F(in io.Reader, out io.Writer) {\n\tvar n, K int\n\tvar s, t string\n\tFscan(in, &n, &K, &s, &t)\n\tif t[0] == t[1] {\n\t\tc := strings.Count(s, t[:1]) + K\n\t\tif c > n {\n\t\t\tc = n\n\t\t}\n\t\tFprint(out, c*(c-1)/2)\n\t\treturn\n\t}\n\tI := func(b bool) int {\n\t\tif b {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tmax := func(a, b int) int {\n\t\tif a > b {\n\t\t\treturn a\n\t\t}\n\t\treturn b\n\t}\n\n\tdp := make([][][]int, n)\n\tfor i := range dp {\n\t\tdp[i] = make([][]int, K+1)\n\t\tfor j := range dp[i] {\n\t\t\tdp[i][j] = make([]int, n+1)\n\t\t\tfor k := range dp[i][j] {\n\t\t\t\tdp[i][j][k] = -1\n\t\t\t}\n\t\t}\n\t}\n\tvar f func(p, left, c0 int) int\n\tf = func(p, left, c0 int) (res int) {\n\t\tif p == n {\n\t\t\treturn\n\t\t}\n\t\tdv := &dp[p][left][c0]\n\t\tif *dv >= 0 {\n\t\t\treturn *dv\n\t\t}\n\t\tdefer func() { *dv = res }()\n\t\tres = I(s[p] == t[1])*c0 + f(p+1, left, c0+I(s[p] == t[0]))\n\t\tif left > 0 {\n\t\t\tres = max(res, f(p+1, left-1, c0+1))\n\t\t\tres = max(res, c0+f(p+1, left-1, c0))\n\t\t}\n\t\treturn\n\t}\n\tFprint(out, f(0, K, 0))\n}\n\nfunc main() { CF1409F(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["strings", "dp"], "code_uid": "395057a0a0097286096833235827cd82", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt64()\n\tk := readString()\n\tvalues := make([]int, 0)\n\tfor len(k) > 0 {\n\t\tvar maxValue int\n\t\tvar maxIndex int\n\t\tfor i := len(k) - 1; i >= 0; i-- {\n\t\t\tvalue, err := strconv.ParseInt(k[i:], 10, 64)\n\t\t\tif err == nil {\n\t\t\t\tif value < n {\n\t\t\t\t\tmaxValue = int(value)\n\t\t\t\t\tmaxIndex = i\n\t\t\t\t} else {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif maxIndex+1 < len(k) {\n\t\t\tif maxValue != 0 {\n\t\t\t\tfor maxIndex < len(k) && k[maxIndex] == '0' {\n\t\t\t\t\tmaxIndex++\n\t\t\t\t}\n\t\t\t} else if maxValue == 0 {\n\t\t\t\tmaxIndex = len(k) - 1\n\t\t\t}\n\t\t}\n\t\tk = k[:maxIndex]\n\t\tvalues = append(values, maxValue)\n\t}\n\tvar res int64\n\tfor i := len(values) - 1; i >= 0; i-- {\n\t\tres *= n\n\t\tres += int64(values[i])\n\t}\n\tfmt.Println(res)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "math", "dp", "greedy", "strings"], "code_uid": "49188032800d981598a9d7062ddd8122", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\t\n\tvar a, last int\n\tfmt.Scanf(\"%d %d\", &a, &last)\n\t\n\tdiff := last - a\n\tisArithmetic := true\n\n\tfor i := 2; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &last)\n\t\tif last != a + i * diff {\n\t\t\tisArithmetic = false\n\t\t}\n\t}\n\n\tif isArithmetic {\n\t\tfmt.Println(a + diff * n)\n\t} else {\n\t\tfmt.Println(last)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "dc3816c19cb541168f0c6c64301eba44", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar arr [1000]int\n\tfmt.Scanf(\"%d\\n\", &n)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &arr[i])\n\t}\n\n\tdiff := arr[0] - arr[1]\n\tfor i := 1; i < n - 1; i++ {\n\t\tif arr[i] - arr[i + 1] != diff {\n\t\t\tfmt.Printf(\"%d\\n\", arr[n-1])\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n\", arr[n-1] - diff)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "5c364354674054a667817d85b2ec0b97", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tt := make([]int, n, n)\n\tfmt.Scan(&t[0], &t[1])\n\tb := true\n\td := t[1] - t[0]\n\tfor i := 2; i < n; i++ {\n\t fmt.Scan(&t[i])\n\t if t[i] - t[i - 1] != d {\n\t b = false\n\t }\n\t}\n\tif b == false {\n\t d = 0\n\t}\n\tfmt.Print(t[n - 1] + d)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "26e3c71246ff166b326ce03601da7b73", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar (\n\tn, input, ans, sum1, sum2 int\n\tmp1 map[int]int\n)\n\nfunc main() {\n\tfmt.Scanln(&n)\n\n\tmp1 = make(map[int]int)\n\tans = 1\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&input)\n\t\tmp1[int(input)] = 1\n\t\tsum1 += input\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&input)\n\t\tif input != 0 && mp1[int(input)] == 0 {\n\t\t\tans = 0\n\t\t}\n\t\tsum2 += input\n\t}\n\n\tif sum1 >= sum2 {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "7b623c4fe46eea94accf993b1350b3f0", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc MaxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc main() {\n\tvar n int\n\tfmt.Scan( &n)\n\tvar s, x int\n\ts = 0\n\tfor i := 0 ;i < n;i++{\n\t\tfmt.Scan(&x)\n\t\ts+=x\n\t}\n\tfor i := 0 ;i < n;i++{\n\t\tfmt.Scan(&x)\n\t\ts-=x\n\t}\n\tif s >= 0{\n\t\tfmt.Println(\"Yes\")\n\t}else{\n\t\tfmt.Println(\"No\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "6f66450bb14af1d71441bda6f89fcefd", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tsum1 := 0\n\tsum2 := 0\n\treader := bufio.NewReader(os.Stdin)\n\ts1, _ := reader.ReadString('\\n')\n\ts2, _ := reader.ReadString('\\n')\n\n\tfor _, v := range strings.Fields(s1) {\n\t\tx, _ := strconv.Atoi(v)\n\t\tsum1 += x\n\t}\n\tfor _, v := range strings.Fields(s2) {\n\t\tx, _ := strconv.Atoi(v)\n\t\tsum2 += x\n\t}\n\n\tif sum1 >= sum2 {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "4550279cbbb15e88bc89aac30b3de5a0", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar (\n\tmod int64 = 1000000007\n)\n\nfunc range3(l int64) []int64 {\n\tans := make([]int64, 3)\n\tans[0] = l / 3\n\tans[1] = (l + 2) / 3\n\tans[2] = (l + 1) / 3\n\treturn ans\n}\nfunc solve(l, r int64) []int64 {\n\tans := range3(r)\n\tlans := range3(l - 1)\n\tfor i := 0; i < 3; i++ {\n\t\tans[i] -= lans[i]\n\t}\n\treturn ans\n}\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar n int\n\tvar l, r int64\n\tfmt.Fscanf(buf, \"%d %d %d\\n\", &n, &l, &r)\n\n\tcnt := solve(l, r)\n//\tfmt.Printf(\"cnt=%v\\n\",cnt)\n\tdp := make([][]int64, 2)\n\tdp[0] = make([]int64, 3)\n\tdp[1] = make([]int64, 3)\n\tf := 1\n\tdp[0][0] = cnt[0]\n\tdp[0][1] = cnt[1]\n\tdp[0][2] = cnt[2]\n//\tfmt.Printf(\"ans=%v\\n\",dp[0])\n\tfor i := 0; i < n-1; i++ {\n\t\tpre := f^1\n\t\tfor j:=0;j < 3;j++{\n\t\t\tdp[f][j] = 0\n\t\t\tfor k:=0;k < 3;k++{\n\t\t\t\tto := (3+j-k)%3\n\t\t\t\tdp[f][j] += (dp[pre][k]*cnt[to])%mod\n\t\t\t\tdp[f][j] = dp[f][j]%mod\n\t\t\t}\n\t\t}\n\t//\tfmt.Printf(\"ans=%v\\n\",dp[f])\n\t\tf = pre\n\n\t}\n\tfmt.Printf(\"%d\\n\", dp[f^1][0])\n\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "f1ed358f0670daa81ded1ca89fe82400", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst (\n\tmodBy = int(1000000000 + 7)\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn, l, r := 0, 0, 0\n\tfmt.Fscanf(in, \"%d %d %d\\n\", &n, &l, &r)\n\tf := make([][]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tf[i] = make([]int64, 3)\n\t}\n\ttempl := l\n\tmod := make([]int64, 3)\n\tfor templ <= r {\n\t\tif (r-templ+1)%3 == 0 && templ < r {\n\t\t\tmod[0] += int64((r - templ + 1) / 3)\n\t\t\tmod[1] += int64((r - templ + 1) / 3)\n\t\t\tmod[2] += int64((r - templ + 1) / 3)\n\t\t\tmod[0] %= int64(modBy)\n\t\t\tmod[1] %= int64(modBy)\n\t\t\tmod[2] %= int64(modBy)\n\t\t\tbreak\n\t\t}\n\t\tmod[templ%3]++\n\t\ttempl++\n\t}\n\t//fmt.Println(mod)\n\tf[0][0] = mod[0]\n\tf[0][1] = mod[1]\n\tf[0][2] = mod[2]\n\tfor i := 1; i < n; i++ {\n\t\tf[i][0] = f[i-1][0]*mod[0] + f[i-1][1]*mod[2] + f[i-1][2]*mod[1]\n\t\tf[i][1] = f[i-1][1]*mod[0] + f[i-1][0]*mod[1] + f[i-1][2]*mod[2]\n\t\tf[i][2] = f[i-1][0]*mod[2] + f[i-1][1]*mod[1] + f[i-1][2]*mod[0]\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tf[i][j] %= int64(modBy)\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", f[n-1][0])\n\treturn\n}\n\nfunc gcd(a, b int) int {\n\tif a < b {\n\t\treturn gcd(b, a)\n\t}\n\tif a%b == 0 {\n\t\treturn b\n\t}\n\treturn gcd(b, a%b)\n}\n\nfunc solve(ang int) int {\n\t_ans := 180 / gcd(ang, 180)\n\tans := _ans\n\tfor ans*ang/180 > ans-2 {\n\t\tans = ans + _ans\n\t}\n\treturn ans\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "846ff3e7534eb9f916f5653d3f820d08", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nconst mod = 1e9 + 7\n\nfunc main() {\n\tvar n int\n\tvar l, r int64\n\tfmt.Scan(&n, &l, &r)\n\tdp := make([][3]int64, n)\n\tdp[0][0] = r/3 - (l-1)/3\n\tdp[0][1] = (r+2)/3 - (l+1)/3\n\tdp[0][2] = (r+1)/3 - l/3\n\tfor i := 1; i < n; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tfor k := 0; k < 3; k++ {\n\t\t\t\tdp[i][(j+k)%3] = (dp[i][(j+k)%3] + dp[i-1][k]*dp[0][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(dp[n-1][0])\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "8d470e5480ba949b1c6bf668c5ca4e0b", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tswitch n % 4 {\n\tcase 0, 3:\n\t\tfmt.Println(0)\n\tdefault:\n\t\tfmt.Println(1)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "4181bff58986d68e0f48b5a2cbe6d151", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tvar sum int64 = n * (n + 1) / 2\n\tfmt.Print(sum % 2)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "cc62df9d13b78b95a987fc76ef4ce5d4", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar n int\n\tfmt.Fscanf(buf, \"%d\\n\", &n)\n\tif n%4 == 0||n%4==3{\n\t\tfmt.Printf(\"0\\n\")\n\t}else if n%4==1{\n\t\tfmt.Printf(\"1\\n\")\n\t}else{\n\t\tfmt.Printf(\"1\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "a13a1afa1672638e77cac680694c8a60", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1132F(_r io.Reader, out io.Writer) {\n\tvar n int\n\tvar s string\n\tFscan(bufio.NewReader(_r), &n, &s)\n\tdp := make([][]int, n)\n\tfor i := range dp {\n\t\tdp[i] = make([]int, n)\n\t}\n\tvar f func(int, int) int\n\tf = func(l, r int) (res int) {\n\t\tif l > r {\n\t\t\treturn 0\n\t\t}\n\t\tif l == r {\n\t\t\treturn 1\n\t\t}\n\t\tdv := &dp[l][r]\n\t\tif *dv > 0 {\n\t\t\treturn *dv\n\t\t}\n\t\tdefer func() { *dv = res }()\n\t\tres = 1 + f(l+1, r)\n\t\tfor i := l + 1; i <= r; i++ {\n\t\t\tif s[i] == s[l] {\n\t\t\t\tif r := f(l+1, i-1) + f(i, r); r < res {\n\t\t\t\t\tres = r\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tFprint(out, f(0, n-1))\n}\n\nfunc main() { CF1132F(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "f6e2f04a305c04a28f680b613ac9aeba", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport . \"fmt\"\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar a, b, k int64\n\tScan(&a, &b)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tdelta := b - a\n\tminLCM := int64(1e18)\n\tcalcK := func(x int64) {\n\t\tak := (a + x - 1) / x * x\n\t\tif lcm := ak / x * (ak + delta); lcm <= minLCM {\n\t\t\tminLCM = lcm\n\t\t\tk = ak - a\n\t\t}\n\t}\n\tfor i := int64(1); i*i <= delta; i++ {\n\t\tif delta%i == 0 {\n\t\t\tcalcK(i)\n\t\t\tcalcK(delta / i)\n\t\t}\n\t}\n\tPrint(k)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "159667ec52936b6c129374007c2c1ac4", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\n// var input, inputerr = os.Open(\"./input\")\n// var output, outputerr = os.Create(\"./output\")\n// var reader = bufio.NewReader(input)\n// var writer = bufio.NewWriter(output)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scan(a ...interface{}) { fmt.Fscan(reader, a...) }\n\nfunc gcd(a, b int64) int64 {\n\tfor b != 0 {\n\t\tt := b\n\t\tb = a % b\n\t\ta = t\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int64) int64 {\n\tresult := a * b / gcd(a, b)\n\n\treturn result\n}\n\nfunc main() {\n\tdefer writer.Flush() // STDOUT MUST BE FLUSHED MANUALLY!!!\n\tvar a, b int64\n\tscan(&a, &b)\n\n\tif b < a {\n\t\ta, b = b, a\n\t}\n\n\tif b%a == 0 {\n\t\tprint(0)\n\t\tprint(\"\\n\")\n\t\treturn\n\t}\n\n\td := b - a\n\tsqrtD := math.Sqrt(float64(d))\n\tvar divs []int64\n\tfor i := int64(1); i <= int64(sqrtD); i++ {\n\t\tif d%i == 0 {\n\t\t\tnxt := d / i\n\t\t\tdivs = append(divs, i)\n\t\t\tif nxt != i {\n\t\t\t\tdivs = append(divs, nxt)\n\t\t\t}\n\t\t}\n\t}\n\n\tlcmMin := float64(lcm(a, b))\n\tminK := float64(0)\n\n\tfor _, q := range divs {\n\t\tif a%q != b%q {\n\t\t\tcontinue\n\t\t}\n\t\tvar val float64\n\t\tk := q\n\t\tif a%q == 0 {\n\t\t\tval = float64(lcm(int64(a+q), int64(b+q)))\n\t\t} else {\n\t\t\tk = q - (a % q)\n\t\t\tval = float64(lcm(int64(a+k), int64(b+k)))\n\t\t}\n\t\tif val < lcmMin {\n\t\t\tlcmMin = val\n\t\t\tminK = float64(k)\n\t\t}\n\t}\n\n\tprint(int(minK))\n\tprint(\"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "df26919ef6a826fc0242fffaccb13510", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar (\n ax int64\n ay int64\n bx int64\n by int64\n cx int64\n cy int64\n)\n\nfunc main() {\n fmt.Scanf(\"%d %d %d %d %d %d\\n\", &ax, &ay, &bx, &by, &cx, &cy)\n if ((ax-bx)*(ax-bx)+(ay-by)*(ay-by)) == ((bx-cx)*(bx-cx)+(by-cy)*(by-cy)) && (bx-ax)*(cy-by) != (by-ay)*(cx-bx) {\n fmt.Printf(\"YES\\n\")\n } else {\n fmt.Printf(\"NO\\n\")\n }\n}", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "a55ec3c38603a2e2801ccb7b98355abd", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar ax, ay, bx, by, cx, cy int64\n\tfmt.Scan(&ax, &ay, &bx, &by, &cx, &cy)\n\tcx -= bx\n\tcy -= by\n\tbx -= ax\n\tby -= ay\n\tif bx*bx+by*by == cx*cx+cy*cy && (bx != cx || by != cy) {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "2451f78dbad5d12167def2b5f6545322", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 785 B Anton and Classes done\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"strings\"\n\t\"strconv\"\n\t\"os\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n\tvar a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor i:=0; i i {\n\t\t\t\tk--\n\t\t\t}\n\t\t\tfor ; k < n-2; k++ {\n\t\t\t\tt[k], t[k+1] = t[k+1], t[k]\n\t\t\t\tc++\n\t\t\t}\n\t\t\tfor k = 0; t[k] == '0'; k++ {\n\t\t\t}\n\t\t\tfor ; k > 0; k-- {\n\t\t\t\tt[k], t[k-1] = t[k-1], t[k]\n\t\t\t\tc++\n\t\t\t}\n\t\t\tif v, _ := strconv.Atoi(string(t[n-2:])); c < ans && v%25 == 0 {\n\t\t\t\tans = c\n\t\t\t}\n\t\t}\n\t}\n\tif ans == 99 {\n\t\tans = -1\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF988E(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "2e9082d71fa3ccc3bc9338489f9468c8", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar nn, xx, yy int\n\tfmt.Scan(&nn, &xx, &yy)\n\tnn/=2\n\tif (nn==xx || (nn+1)==xx) && (nn==yy || nn+1==yy){\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9c9b797ff99a0c37c88099d18b5f8cd4", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 112B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n,x,y int\n\tfmt.Scan(&n, &x, &y)\n if n==2 {\n\t\tfmt.Println(\"NO\")\n return\n }else if n==4 && (y==2 || y==3) {\n fmt.Println(\"NO\")\n\t\treturn\n }else if (y==n/2 || y==(n/2)+1) && (x==n/2 || x==(n/2)+1) {\n fmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfmt.Println(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "f917a53381645fce3b4ad56a7d198d27", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var nn,x,y int\n fmt.Scan(&nn,&x,&y)\n n := nn/2\n if ((x == n) || (x == (n+1))) && ((y == n) || (y == (n+1))) {\n fmt.Println(\"NO\")\n } else {\n fmt.Println(\"YES\")\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "83ca6039d645722a42cc5a8f20ee10f6", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\nvar writer *bufio.Writer\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer = bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n x := getI()\n unit := 1\n result := 0\n for x != 0 {\n result += unit * (x%10 / 3)\n unit *= 2\n x /= 10\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "25a7534d7818a1b8b9aedcc51a0ccc71", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\n\nvar luckyNumberDigit [11]float64\nvar luckyNumber []float64\n\nfunc generate(depth int) {\n if depth <= 10 {\n lucky := float64(0)\n for i := depth; i >= 0; i-- {\n lucky = lucky * 10 + float64(luckyNumberDigit[i])\n }\n\n if lucky != 0 {\n luckyNumber = append(luckyNumber, lucky)\n }\n\n if depth < 10 {\n luckyNumberDigit[depth] = 4\n generate(depth + 1)\n luckyNumberDigit[depth] = 7\n generate(depth + 1)\n luckyNumberDigit[depth] = 0\n }\n }\n}\n\nfunc main () {\n luckyNumber = make([]float64, 0, 1000000)\n generate(0)\n\n sort.Float64s(luckyNumber)\n\n n := 0\n fmt.Scanf(\"%d\\n\", &n)\n fmt.Println(sort.SearchFloat64s(luckyNumber, float64(n)) + 1)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "27def986bdc55c92f05a9b306adfb78c", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\n\t// posición en su grupo de cifras\n\tpos := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tpos *= 2\n\t\tif s[i] == '7' {\n\t\t\tpos++\n\t\t}\n\t}\n\n\t// sumamos los de menos cifras\n\tless := 0\n\tfor i := 1; i < len(s); i++ {\n\t\tless |= (1 << uint(i))\n\t}\n\tfmt.Printf(\"%d\\n\", (1 + pos + less))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "a75a5c739abc3e68ba363e99a2b8c336", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nfunc readInt() int {\n\tvar o, neg bool\n\tvar i int\n\tb, err := r.ReadByte()\n\tfor err == nil {\n\t\tif b != ' ' && b != '\\n' && b != '\\r' {\n\t\t\tif b == '-' {\n\t\t\t\tneg = true\n\t\t\t} else {\n\t\t\t\ti = i*10 + int(b) - 48\n\t\t\t\to = true\n\t\t\t}\n\t\t} else if o {\n\t\t\tbreak\n\t\t}\n\t\tb, err = r.ReadByte()\n\t}\n\tif neg {\n\t\treturn -i\n\t}\n\treturn i\n}\n\nfunc writeInt(i int) {\n\tif i < 0 {\n\t\tw.WriteByte('-')\n\t\ti = -i\n\t}\n\tif i < 10 {\n\t\tw.WriteByte(byte(i + 48))\n\t\treturn\n\t}\n\tvar tmp, count int\n\ttmp = i\n\tfor tmp%10 == 0 {\n\t\ttmp /= 10\n\t\tcount++\n\t}\n\ttmp = 0\n\tfor i != 0 {\n\t\ttmp = tmp*10 + (i % 10)\n\t\ti /= 10\n\t}\n\tfor tmp != 0 {\n\t\tw.WriteByte(byte((tmp % 10) + 48))\n\t\ttmp /= 10\n\t}\n\tfor count > 0 {\n\t\tcount--\n\t\tw.WriteByte('0')\n\t}\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tvar n int\n\tfor I(&n) == nil {\n\t\tsolve(n)\n\t}\n\tw.Flush()\n}\n\nfunc solve(n int) {\n\tvar in [3][6]int\n\tvar arr []int\n\to := make(map[int]bool)\n\to[0] = true\n\tfor i := 0; i < n; i++ {\n\t\tfor j := range in[i] {\n\t\t\tin[i][j] = readInt()\n\t\t\tif _, exists := o[in[i][j]]; !exists {\n\t\t\t\tarr = append(arr, in[i][j])\n\t\t\t\to[in[i][j]] = true\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 6; i++ {\n\t\tfor j := 0; j < 6; j++ {\n\t\t\tfor k := 0; k < 6; k++ {\n\t\t\t\tif n == 3 {\n\t\t\t\t\ta := in[0][i]*100 + in[1][j]*10 + in[2][k]\n\t\t\t\t\tb := in[0][i]*100 + in[2][j]*10 + in[1][k]\n\t\t\t\t\tc := in[2][i]*100 + in[0][j]*10 + in[1][k]\n\t\t\t\t\td := in[1][i]*100 + in[0][j]*10 + in[2][k]\n\t\t\t\t\te := in[1][i]*100 + in[2][j]*10 + in[0][k]\n\t\t\t\t\tf := in[2][i]*100 + in[1][j]*10 + in[0][k]\n\t\t\t\t\tif _, exists := o[a]; !exists {\n\t\t\t\t\t\tarr = append(arr, a)\n\t\t\t\t\t\to[a] = true\n\t\t\t\t\t}\n\t\t\t\t\tif _, exists := o[b]; !exists {\n\t\t\t\t\t\tarr = append(arr, b)\n\t\t\t\t\t\to[b] = true\n\t\t\t\t\t}\n\t\t\t\t\tif _, exists := o[c]; !exists {\n\t\t\t\t\t\tarr = append(arr, c)\n\t\t\t\t\t\to[c] = true\n\t\t\t\t\t}\n\t\t\t\t\tif _, exists := o[d]; !exists {\n\t\t\t\t\t\tarr = append(arr, d)\n\t\t\t\t\t\to[d] = true\n\t\t\t\t\t}\n\t\t\t\t\tif _, exists := o[e]; !exists {\n\t\t\t\t\t\tarr = append(arr, e)\n\t\t\t\t\t\to[e] = true\n\t\t\t\t\t}\n\t\t\t\t\tif _, exists := o[f]; !exists {\n\t\t\t\t\t\tarr = append(arr, f)\n\t\t\t\t\t\to[f] = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif n > 1 {\n\t\t\t\t\taa := in[0][i]*10 + in[1][j]\n\t\t\t\t\tbb := in[1][i]*10 + in[0][j]\n\t\t\t\t\tcc := in[0][i]*10 + in[2][j]\n\t\t\t\t\tdd := in[2][i]*10 + in[0][j]\n\t\t\t\t\tee := in[2][i]*10 + in[1][j]\n\t\t\t\t\tff := in[1][i]*10 + in[2][j]\n\t\t\t\t\tif _, exists := o[aa]; !exists {\n\t\t\t\t\t\tarr = append(arr, aa)\n\t\t\t\t\t\to[aa] = true\n\t\t\t\t\t}\n\t\t\t\t\tif _, exists := o[bb]; !exists {\n\t\t\t\t\t\tarr = append(arr, bb)\n\t\t\t\t\t\to[bb] = true\n\t\t\t\t\t}\n\t\t\t\t\tif n == 3 {\n\t\t\t\t\t\tif _, exists := o[cc]; !exists {\n\t\t\t\t\t\t\tarr = append(arr, cc)\n\t\t\t\t\t\t\to[cc] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif _, exists := o[dd]; !exists {\n\t\t\t\t\t\t\tarr = append(arr, dd)\n\t\t\t\t\t\t\to[dd] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif _, exists := o[ee]; !exists {\n\t\t\t\t\t\t\tarr = append(arr, ee)\n\t\t\t\t\t\t\to[ee] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif _, exists := o[ff]; !exists {\n\t\t\t\t\t\t\tarr = append(arr, ff)\n\t\t\t\t\t\t\to[ff] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tsort.Ints(arr)\n\tif arr[0] != 1 {\n\t\tO(\"0\\n\")\n\t\treturn\n\t}\n\tfor i := range arr {\n\t\tif i+1 != arr[i] {\n\t\t\tO(i, \"\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\tO(arr[len(arr)-1], \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "ad17c151b8c24790ff9cd661da9efa55", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar res map[string]bool\n\nfunc solve() {\n\tres = make(map[string]bool)\n\tn := readInt()\n\ta := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\tstr := make([]byte, 6)\n\t\tfor j := 0; j < 6; j++ {\n\t\t\tstr[j] = byte(readInt() + '0')\n\t\t}\n\t\ta[i] = string(str)\n\t}\n\tcnt := 0\n\tperm(a, 0)\n\tfor i := 1; i < 1000; i++ {\n\t\tif _, ok := res[strconv.Itoa(i)]; !ok {\n\t\t\tbreak\n\t\t}\n\t\tcnt++\n\t}\n\tfmt.Println(cnt)\n}\n\nfunc dfs(a []string, pos int, prefix string) {\n\tif len(prefix) > 0 {\n\t\tres[prefix] = true\n\t}\n\tif pos == len(a) {\n\t\treturn\n\t}\n\tfor i := 0; i < 6; i++ {\n\t\tif len(prefix) == 0 && a[pos][i] == '0' {\n\t\t\tcontinue\n\t\t}\n\t\tdfs(a, pos+1, prefix+string(a[pos][i]))\n\t}\n}\n\nfunc perm(a []string, from int) {\n\tif from+1 == len(a) {\n\t\tdfs(a, 0, \"\")\n\t\treturn\n\t}\n\tfor i := from; i < len(a); i++ {\n\t\ta[from], a[i] = a[i], a[from]\n\t\tperm(a, from+1)\n\t\ta[from], a[i] = a[i], a[from]\n\t}\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "f650b84e3a536bb1a45ad77adcbe56f8", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar nums [10][3]bool\n\t_, _ = fmt.Scanf(\"%d\\n\", &n)\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < 6; j++ {\n\t\t\tvar num int\n\t\t\tif j < 5 {\n\t\t\t\t_, _ = fmt.Scanf(\"%d\", &num);\n\t\t\t} else {\n\t\t\t\t_, _ = fmt.Scanf(\"%d\\n\", &num);\n\t\t\t}\n\t\t\tnums[num][i] = true\n\t\t}\n\t}\n\tfor i := 1; i < 100; i++ {\n\t\tif i < 10 {\n\t\t\tif !nums[i][0] && !nums[i][1] && !nums[i][2] {\n\t\t\t\tfmt.Println(i - 1)\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tfirst := i % 10\n\t\t\tsecond := i / 10\n\t\t\tif (!nums[first][0] || !nums[second][1]) &&\n\t\t\t\t(!nums[first][0] || !nums[second][2]) &&\n\t\t\t\t(!nums[first][1] || !nums[second][0]) &&\n\t\t\t\t(!nums[first][1] || !nums[second][2]) &&\n\t\t\t\t(!nums[first][2] || !nums[second][1]) &&\n\t\t\t\t(!nums[first][2] || !nums[second][0]) {\n\t\t\t\tfmt.Println(i - 1)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t}\n\t}\n\tfmt.Println(99)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "ef8fdc0c55af6843ef1e3696105f684f", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n \"math/big\"\n)\n\nvar scanner *bufio.Scanner\nvar writer *bufio.Writer\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer = bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n zero := big.NewRat(0, 1)\n one := big.NewRat(1, 1)\n two := big.NewRat(2, 1)\n\n n, limit := getI(), getI()\n filled := make([][]*big.Rat, n)\n for r := range filled {\n filled[r] = make([]*big.Rat, r + 1)\n for c := range filled[r] {\n filled[r][c] = big.NewRat(0, 1)\n }\n }\n count := 0\n maxCount := (n + 1) * n / 2\n\n for t := 0; t < limit; t++ {\n pours := make([]*big.Rat, 1)\n pours[0] = big.NewRat(1, 1)\n for r := 0; r < n; r++ {\n allZero := true\n for _, pour := range pours {\n if pour.Cmp(zero) != 0 {\n allZero = false\n break\n }\n }\n if allZero {\n break\n }\n nextPours := make([]*big.Rat, r + 2)\n for i := range nextPours {\n nextPours[i] = big.NewRat(0, 1)\n }\n for c, pour := range pours {\n x := &big.Rat{}\n x.Add(filled[r][c], pour)\n if filled[r][c].Cmp(one) < 0 && x.Cmp(one) >= 0 {\n count++\n if count == maxCount {\n writer.WriteString(fmt.Sprintf(\"%d\\n\", count))\n return\n }\n }\n if x.Cmp(one) <= 0 {\n filled[r][c].Set(x)\n continue\n }\n pour.Sub(pour, one)\n pour.Add(pour, filled[r][c])\n filled[r][c].Set(one)\n pour.Quo(pour, two)\n nextPours[c].Add(nextPours[c], pour)\n nextPours[c + 1].Add(nextPours[c + 1], pour)\n }\n pours = nextPours\n }\n }\n\n writer.WriteString(fmt.Sprintf(\"%d\\n\", count))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "3b7e671e0958a62acf095951d58b163a", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nvar one = int64(0x10000)\n\nfunc progressRow(p [][]int64, row int) (spill bool) {\n\tspill = false\n\tfor i := 0; i <= row; i++ {\n\t\tif p[row][i] > one {\n\t\t\tspill = true\n\t\t\tdiff := p[row][i] - one\n\t\t\tdiff >>= 1\n\t\t\tp[row+1][i] += diff\n\t\t\tp[row+1][i+1] += diff\n\t\t\tp[row][i] = one\n\t\t}\n\t}\n\treturn spill\n}\n\nfunc progress(p [][]int64, n int) {\n\tp[0][0] += one\n\tfor i := 0; i < n; i++ {\n\t\tspill := progressRow(p, i)\n\t\tif !spill {\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc solve(n, t int) int {\n\tp := make([][]int64, n+1)\n\tfor i := 0; i <= n; i++ {\n\t\tp[i] = make([]int64, i+1)\n\t}\n\tfor i := 0; i < t; i++ {\n\t\tprogress(p, n)\n\t}\n\tcount := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < i+1; j++ {\n\t\t\tif p[i][j] >= one {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\treturn count\n}\n\nfunc main() {\n\tvar n, t int\n\tnr, err := fmt.Fscanln(os.Stdin, &n, &t)\n\tif nr != 2 || err != nil {\n\t\tpanic(err)\n\t}\n\tres := solve(n, t)\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "666390ef578af1966e57d234009bd6fa", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 676 B\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n var a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n for i:=0; i= drob {\n countFull ++\n v := aa[j]\n v = (v-drob)/2\n //fmt.Printf(\"a,v= %f %f\\n\",aa[j], v)\n an[j] += v\n an[j+1] += v\n }\n }\n // copy an -> a\n for j:=0; j 0; i-- {\n\t\tf.Inv[i-1] = f.Inv[i] * int64(i) % f.Mod\n\t}\n\treturn &f\n}\n\nfunc pow(x, n, m int64) int64 {\n\tif n == 0 {\n\t\treturn 1\n\t}\n\tif n&1 == 0 {\n\t\tr := pow(x, n/2, m)\n\t\treturn r * r % m\n\t}\n\treturn x * pow(x, n-1, m) % m\n}\n\nfunc div(x, n, m int64) int64 {\n\treturn x * pow(n, m-2, m) % m\n}\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\n\tvar ans int64\n\tvar m int64\n\tm = 998244353\n\tc := NewCombination(n, m)\n\tfor i := 1; i <= n; i++ {\n\t\trest := n/i - 1\n\t\tif rest < k-1 {\n\t\t\tcontinue\n\t\t}\n\t\tans += c.Combination(rest, k-1)\n\t\tans %= m\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics", "number theory"], "code_uid": "554c93c7a9afd84c1c4769b293066a5a", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1359E(in io.Reader, out io.Writer) {\n\tconst mod int64 = 998244353\n\tconst mx int = 5e5\n\tF := [mx + 1]int64{1}\n\tfor i := 1; i <= mx; i++ {\n\t\tF[i] = F[i-1] * int64(i) % mod\n\t}\n\tpow := func(x, n int64) int64 {\n\t\tres := int64(1)\n\t\tfor ; n > 0; n >>= 1 {\n\t\t\tif n&1 == 1 {\n\t\t\t\tres = res * x % mod\n\t\t\t}\n\t\t\tx = x * x % mod\n\t\t}\n\t\treturn res\n\t}\n\tinvF := [...]int64{mx: pow(F[mx], mod-2)}\n\tfor i := mx; i > 0; i-- {\n\t\tinvF[i-1] = invF[i] * int64(i) % mod\n\t}\n\tC := func(n, k int) int64 { return F[n] * invF[k] % mod * invF[n-k] % mod }\n\n\tvar n, k int\n\tFscan(in, &n, &k)\n\tans := int64(0)\n\tfor i := 1; n/i >= k; i++ {\n\t\tans += C(n/i-1, k-1)\n\t}\n\tFprint(out, ans%mod)\n}\n\nfunc main() { CF1359E(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "combinatorics", "number theory"], "code_uid": "308db4e04c1fea8c9a2161d3641ec406", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc readInt(bytes []byte, from int, val *int) int {\n\ti := from\n\tsign := 1\n\tif bytes[i] == '-' {\n\t\tsign = -1\n\t\ti++\n\t}\n\ttmp := 0\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + int(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp * sign\n\treturn i\n}\n\nfunc readNum(reader *bufio.Reader) (a int) {\n\tbs, _ := reader.ReadBytes('\\n')\n\treadInt(bs, 0, &a)\n\treturn\n}\n\nfunc readTwoNums(reader *bufio.Reader) (a int, b int) {\n\tres := readNNums(reader, 2)\n\ta, b = res[0], res[1]\n\treturn\n}\n\nfunc readThreeNums(reader *bufio.Reader) (a int, b int, c int) {\n\tres := readNNums(reader, 3)\n\ta, b, c = res[0], res[1], res[2]\n\treturn\n}\n\nfunc readNNums(reader *bufio.Reader, n int) []int {\n\tres := make([]int, n)\n\tx := 0\n\tbs, _ := reader.ReadBytes('\\n')\n\tfor i := 0; i < n; i++ {\n\t\tfor x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {\n\t\t\tx++\n\t\t}\n\t\tx = readInt(bs, x, &res[i])\n\t}\n\treturn res\n}\n\nfunc readUint64(bytes []byte, from int, val *uint64) int {\n\ti := from\n\n\tvar tmp uint64\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + uint64(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp\n\n\treturn i\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tn, k := readTwoNums(reader)\n\n\tfmt.Println(solve(n, k))\n}\n\nconst MAX_N = 500043\nconst MOD = 998244353\n\nvar F []int64\n\n// var PM []int\n\nfunc pow(a, b int64) int64 {\n\tvar r int64 = 1\n\tfor b > 0 {\n\t\tif b&1 == 1 {\n\t\t\tr *= a\n\t\t\tr %= MOD\n\t\t}\n\t\ta *= a\n\t\ta %= MOD\n\t\tb >>= 1\n\t}\n\treturn r\n}\n\nfunc init() {\n\tF = make([]int64, MAX_N)\n\tF[0] = 1\n\n\tfor i := 1; i < MAX_N; i++ {\n\t\tF[i] = int64(i) * F[i-1]\n\t\tF[i] %= MOD\n\t}\n}\n\nfunc IF(n int) int64 {\n\tx := F[n]\n\treturn pow(x, MOD-2)\n}\n\nfunc nCr(n, r int) int64 {\n\tif n < r {\n\t\treturn 0\n\t}\n\tres := F[n]\n\tres *= IF(r)\n\tres %= MOD\n\tres *= IF(n - r)\n\tres %= MOD\n\treturn res\n}\n\nfunc solve(n, k int) int {\n\tvar res int64\n\n\tfor x := 1; x <= n; x++ {\n\t\t// x := PM[i]\n\t\td := n / x\n\t\tif d < k {\n\t\t\tbreak\n\t\t}\n\t\tres += nCr(d-1, k-1)\n\t\tres %= MOD\n\t}\n\n\treturn int(res)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics", "number theory"], "code_uid": "d4cb7f1a8d5c5ecc46259423dccbf772", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tsum := 0\n\tmax := 0\n\tfor i := 0; i < n; i++ {\n\t\tvar a int\n\t\tfmt.Scan(&a)\n\t\tsum += a\n\t\tif max < a {\n\t\t\tmax = a\n\t\t}\n\t}\n\tk := max\n\tfor k*n-sum <= sum {\n\t\tk++\n\t}\n\tfmt.Println(k)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "38fda521808938823cc6933798dcae23", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar N int\n\tvar A [110]int\n\n\tfmt.Scan(&N)\n\tfor i := 0; i < N; i++ {\n\t\tfmt.Scan(&A[i])\n\t}\n\n\tsum, max := 0, 0\n\tfor i := 0; i < N; i++ {\n\t\tsum += A[i]\n\t\tif max < A[i] {\n\t\t\tmax = A[i]\n\t\t}\n\t}\n\n\tres := (2 * sum / N) + 1\n\tif res < max {\n\t\tres = max\n\t}\n\n\tfmt.Printf(\"%v\\n\", res)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "bddece0b52ba2a8ac22c6d7d90790c34", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar count int\n\tvar point_war int\n\tsum_war := 0\n\tvar sum_my int\n\tmin_k := 0\n\tfmt.Scan(&count)\n\tvar points [150]int\n\tvar result int\n\tfor i := 0; i < count; i++ {\n\t\tfmt.Scan(&point_war)\n\t\tpoints[i] = point_war\n\t\tsum_war += point_war\n\t\tif point_war > min_k {\n\t\t\tmin_k = point_war\n\t\t}\n\t}\n\tfor i := min_k; i <= 210; i++ {\n\t\tsum_my = 0\n\t\tfor j := 0; j < count; j++ {\n\t\t\tsum_my += i - points[j]\n\t\t}\n\t\tif sum_my > sum_war {\n\t\t\tresult = i\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "26f46b6f9b4a50d4df5aebd2ae1eab12", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t// \"os\"\n\t)\n\nconst INF = 0x3f3f3f3f\n\nvar n, m, tot int\n\nfunc min(x, y int) int {\n\tif xy {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc abs(x int) int {\n\tif x<0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc main() {\n\t// fd, _ := os.Open(\"in.txt\")\n\t// os.Stdin = fd\n\tvar T int = 1\n\t// fmt.Scanf(\"%d\", &T)\n\tfor ci:=1; ci<=T; ci++ {\n\t\tvar l, r int\n\t\tfmt.Scanf(\"%d %d %d %d\\n\", &n, &m, &l, &r)\n\t\t// fmt.Printf(\"Case #%d: \", ci)\n\t\tif l==1 && r==n {\n\t\t\tfmt.Println(0)\n\t\t} else if l==1 {\n\t\t\tif m<=r {\n\t\t\t\tfmt.Println(1+r-m)\n\t\t\t} else {\n\t\t\t\tfmt.Println(1-r+m)\n\t\t\t}\n\t\t} else if r==n {\n\t\t\tif m>1\n\t\t\tif m<=mid {\n\t\t\t\tfmt.Println(r+2-l+abs(m-l))\n\t\t\t} else {\n\t\t\t\tfmt.Println(r+2-l+abs(r-m))\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "51f4b493537bf996d22ed463c5653fd6", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n/*\n\tIf we breakdown the problem, we will found 3 cases:\n\t- if non-studies tabs exist both in left & right of studies tabs: 1, [2, 3, 4, 5], 6\n\t- if non-studies tabs exist only in right of studies tabs: [1, 2, 3], 4, 5, 6\n\t- if non-studies tabs exist only in left of studies tabs: 1, 2, 3, [4, 5, 6]\n\n\tFor the first case the minimum number of seconds would be:\n\t\tmin(abs(pos-l), abs(pos-r)) + 1 + abs(l-r) + 1\n\tIn the second case:\n\t\tabs(pos-r) + 1\n\tIn the third case:\n\t\tabs(pos-l) + 1\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, pos, l, r int\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%d %d %d %d\", &n, &pos, &l, &r)\n\tfmt.Println(solve(n, pos, l, r))\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\ta *= -1\n\t}\n\treturn a\n}\n\nfunc solve(n, pos, l, r int) int {\n\tisLeftExist := abs(1-l) > 0\n\tisRightExist := abs(r-n) > 0\n\tif isLeftExist && isRightExist {\n\t\treturn min(abs(pos-l), abs(pos-r)) + 1 + abs(l-r) + 1\n\t} else if isRightExist {\n\t\treturn abs(pos-r) + 1\n\t} else if isLeftExist {\n\t\treturn abs(pos-l) + 1\n\t}\n\treturn 0\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "9a810f3910e8a5ec7becfd6e9d91eb94", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// http://codeforces.com/contest/915/problem/B\npackage main\n\nimport \"fmt\"\n\nfunc min(x, y int) int {\n if x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\n// comentar que nem gente\nfunc main() {\n\tvar n, pos, l, r int\n\tfmt.Scanf(\"%d %d %d %d\\n\", &n, &pos, &l, &r)\n\tif l == 1 && r == n {\n\t\tfmt.Printf(\"0\\n\")\n\t} else if l == 1 {\n\t\tfmt.Printf(\"%d\\n\", abs(r - pos) + 1)\n\t} else if r == n {\n\t\tfmt.Printf(\"%d\\n\", abs(l - pos) + 1)\n\t} else {\n\t\tif abs(l - pos) < abs(r - pos) {\n\t\t\tfmt.Printf(\"%d\\n\", abs(l - pos) + r - l + 2)\n\t\t} else {\n\t\t\tfmt.Printf(\"%d\\n\", abs(r - pos) + r - l + 2)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f7df735fbe0fdab09072ab63c8d97002", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, x int\n\ta := make(map[int]bool)\n\tfmt.Scan(&n)\n\tfor ; n > 0; n-- {\n\t\tfmt.Scan(&x)\n\t\tif x > 0 {\n\t\t\ta[x] = true\n\t\t}\n\t}\n\tfmt.Print(len(a))\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation"], "code_uid": "10d5c277c8c7f56e697f199e03c3760b", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\"fmt\";\n\t\t\"sort\")\n\ntype set map[int]bool\ntype long int64\n\nfunc main(){\n\tvar n, ans int\n\tscan(&n)\n\ts := make(set)\n\tfor i := 0; i < n; i++{\n\t\tvar t int\n\t\tscan(&t)\n\t\ts[t] = true\n\t}\n\ta := make([]int, len(s))\n\tp := 0\n\tfor k,_ := range s{\n\t\ta[p] = k\n\t\tp++\n\t}\n\tsort.Ints(a)\n\tfor _,k := range a{\n\t\tif k > 0{ans++}\n\t}\n\tsout(ans)\n}\n\nfunc scan(in ... interface{}){\n\tfor _,k := range in{\n\t\tfmt.Scan(k)\n\t}\n}\n\nfunc sout(obj ... interface{}){\n\tfor _, k := range obj{\n\t\tfmt.Print(k)\n\t}\n\tfmt.Println()\n}", "lang_cluster": "Go", "tags": ["sortings", "implementation"], "code_uid": "56bbe28af64aa5ea2f470e327ce00f93", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner\nvar t [1e6 + 1]bool\n\nfunc init_scanner() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024 * 20\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tscanner.Scan()\n\tval, _ := strconv.Atoi(scanner.Text())\n\treturn val\n}\n\nfunc main() {\n\tinit_scanner()\n\tsize, ans := readInt(), 0\n\tm := make(map[int]bool)\n\tfor i := 0; i < size; i++ {\n\t\tx := readInt()\n\t\tif x > 0 && !m[x] {\n\t\t\tans += 1\n\t\t\tm[x] = true\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation"], "code_uid": "4c0a58ecfa25aa9afc57594228eff2fa", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tt := 1\n\t//fmt.Fscanf(in, \"%d\\n\", &t)\n\tfor tt := 0; tt < t; tt++ {\n\t\tn := int64(0)\n\t\tfmt.Fscanf(in, \"%d\\n\", &n)\n\t\tans := 10\n\t\tcurNum := int64(1)\n\t\tfor i := 2; i < 100; i++ {\n\t\t\tif curNum >= n {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tfor j := 0; j < 10; j++ {\n\t\t\t\tif curNum >= n {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcurNum /= int64(i - 1)\n\t\t\t\tcurNum *= int64(i)\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t\ta := \"codeforces\"\n\t\tansS := []byte{}\n\t\tfor i := 0; i < 10; i++ {\n\t\t\tfor j := 0; j < ans/10; j++ {\n\t\t\t\tansS = append(ansS, a[i])\n\t\t\t}\n\t\t\tif i+1 <= ans%10 {\n\t\t\t\tansS = append(ansS, a[i])\n\t\t\t}\n\t\t}\n\t\tfmt.Fprintf(out, \"%s\\n\", string(ansS))\n\t}\n\treturn\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "94ec1c16c56e2b17b6db62b8cbb316a7", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t. \"strings\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar k, n int64 = 0, 3\n\tScan(&k)\n\tfor {\n\t\ts := int64(1)\n\t\tfor i := int64(0); i < 10; i++ {\n\t\t\ts *= (n + i) / 10\n\t\t}\n\t\tif s >= k {\n\t\t\tbreak\n\t\t}\n\t\tn++\n\t}\n\tfor i, b := range \"codeforces\" {\n\t\tPrint(Repeat(string(b), (int(n)+9-i)/10))\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "c4a4796aaa73df9298e848443eba8b14", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1368/B\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tk int64\n)\n\nfunc main() {\n\tk = ReadInt64()\n\n\tA := make([]int, 10)\n\tfor i := 0; i < 10; i++ {\n\t\tA[i] = 1\n\t}\n\n\tfor i := 0; i < 100000; i++ {\n\t\tval := int64(1)\n\t\tfor _, a := range A {\n\t\t\tval *= int64(a)\n\t\t}\n\n\t\tif val >= k {\n\t\t\tbreak\n\t\t}\n\n\t\tA[i%10]++\n\t}\n\n\tans := []rune{}\n\tmemo := []rune(\"codeforces\")\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0; j < A[i]; j++ {\n\t\t\tans = append(ans, memo[i])\n\t\t}\n\t}\n\tfmt.Println(string(ans))\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "852eae4f130d9765e6d8f89cba530146", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\tscanner = bufio.NewScanner(os.Stdin)\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\ts, t := next(), next()\n\tpos1, pos2 := 0, 0\n\tcntMark := 0\n\tcntEqual := 0\n\n\tfor i := range s {\n\t\tif s[i] == '+' {\n\t\t\tpos1++\n\t\t} else {\n\t\t\tpos1--\n\t\t}\n\t}\n\n\tfor i := range t {\n\t\tswitch t[i] {\n\t\tcase '+':\n\t\t\tpos2++\n\t\tcase '-':\n\t\t\tpos2--\n\t\tcase '?':\n\t\t\tcntMark++\n\t\t}\n\t}\n\t// println(pos1, pos2, cntMark, s, t)\n\tpermutation := 1 << uint64(cntMark)\n\tfor k := 0; k < permutation; k++ {\n\t\tcnt := 0\n\t\t// println(k, cntMark)\n\t\tfor i := 0; i < cntMark; i++ {\n\t\t\t// println(i, i&k)\n\t\t\tif (1< 0 {\n\t\t\t\tcnt++\n\t\t\t} else {\n\t\t\t\tcnt--\n\t\t\t}\n\t\t}\n\t\t// println(pos2, cnt, pos1)\n\t\tif pos2+cnt == pos1 {\n\t\t\tcntEqual++\n\t\t}\n\t}\n\t// println(permutation)\n\tprintln(float64(cntEqual)/float64(permutation))\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "combinatorics", "bitmasks", "probabilities"], "code_uid": "716332068c104e4407bde7b15a344a76", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t. \"strings\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF476B(in io.Reader, out io.Writer) {\n\tvar s, t string\n\tFscan(in, &s, &t)\n\tp := Count(s, \"+\") - Count(s, \"-\") - Count(t, \"+\") + Count(t, \"-\")\n\tn := Count(t, \"?\")\n\tc := 0\n\tfor sub := 0; sub < 1<>i&1 == 0 {\n\t\t\t\ts--\n\t\t\t} else {\n\t\t\t\ts++\n\t\t\t}\n\t\t}\n\t\tif s == p {\n\t\t\tc++\n\t\t}\n\t}\n\tFprintf(out, \"%.12f\", float64(c)/float64(int(1)< 0 {\n\t\t\tfmt.Fprintf(os.Stdout, \"%.10f\\n\", solve(cache['+'], unrecognizedSignal))\n\n\t\t} else {\n\t\t\tfmt.Fprintf(os.Stdout, \"%.10f\\n\", float64(1))\n\t\t}\n\t} else {\n\t\tfmt.Fprintf(os.Stdout, \"%.10f\\n\", float64(0))\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "combinatorics", "bitmasks", "probabilities"], "code_uid": "166bcb9554cf59fa25369dcf681ea17c", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar target int = 0\n\tvar start int = 0\n\tvar question_marks int = 0\n\n\treader := bufio.NewReader(os.Stdin)\n\t// Command\n\tif s, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tfor i := 0; i < len(s); i++ {\n\t\t\tif s[i] == '+' {\n\t\t\t\ttarget++\n\t\t\t} else if s[i] == '-' {\n\t\t\t\ttarget--\n\t\t\t}\n\t\t}\n\t}\n\n\t// Received\n\tif s, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tfor i := 0; i < len(s); i++ {\n\t\t\tif s[i] == '+' {\n\t\t\t\tstart++\n\t\t\t} else if s[i] == '-' {\n\t\t\t\tstart--\n\t\t\t} else if s[i] == '?' {\n\t\t\t\tquestion_marks++\n\t\t\t}\n\t\t}\n\t}\n\n\tvar distance int = int(math.Abs(float64(target - start)))\n\tvar prob float64\n\tif distance > question_marks {\n\t\tprob = 0.0\n\t} else if distance == question_marks {\n\t\tprob = math.Pow(0.5, float64(question_marks))\n\t} else { // distance < question_marks\n\t\tif (question_marks-distance)%2 != 0 {\n\t\t\tprob = 0.0\n\t\t} else {\n\t\t\ttowards := distance + (question_marks-distance)/2\n\t\t\tprob = float64(factorial(question_marks)) /\n\t\t\t\tfloat64(factorial(towards)*factorial(question_marks-towards)*\n\t\t\t\t\t(1< 0 {\n\t\t\t\tsum += 1\n\t\t\t} else {\n\t\t\t\tsum -= 1\n\t\t\t}\n\t\t}\n\t\tif finish == current+sum {\n\t\t\tres += 1\n\t\t}\n\t}\n\tfmt.Println(float64(res) / float64(power))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "combinatorics", "bitmasks", "probabilities"], "code_uid": "27bdedd0e5c14bf167db9789e3c8257a", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc fact(x int64) int64 {\n\tif x == 0 {\n\t\treturn 1\n\t}\n\treturn fact(x-1) * x\n}\n\nfunc combi(n, r int64) int64 {\n\treturn fact(n) / fact(n-r) / fact(r)\n}\n\nfunc main() {\n\tvar a, b string\n\tfmt.Scan(&a, &b)\n\tvar ans, move, unknown, diff, reverse int64\n\tfor _, r := range a {\n\t\tswitch r {\n\t\tcase '+':\n\t\t\tans++\n\t\tcase '-':\n\t\t\tans--\n\t\t}\n\t}\n\tfor _, r := range b {\n\t\tswitch r {\n\t\tcase '+':\n\t\t\tmove++\n\t\tcase '-':\n\t\t\tmove--\n\t\tcase '?':\n\t\t\tunknown++\n\t\t}\n\t}\n\tdiff = ans - move\n\tif diff < 0 {\n\t\tdiff = -diff\n\t}\n\tif diff > unknown || (diff-unknown)%2 > 0 {\n\t\tfmt.Println(\"0\")\n\t\treturn\n\t}\n\treverse = (unknown - diff) / 2\n\tif reverse < 0 {\n\t\treverse = -reverse\n\t}\n\tfmt.Printf(\"%.11f\\n\", float64(combi(unknown, reverse))/float64(int(1)<>i&1 == 0 {\n\t\t\t\ts--\n\t\t\t} else {\n\t\t\t\ts++\n\t\t\t}\n\t\t}\n\t\tif s == p {\n\t\t\tc++\n\t\t}\n\t}\n\tPrintf(\"%.12f\", float64(c)/float64(int(1)< bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\n// ↓でもいい\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\tA := [][]int64{\n\t\t[]int64{a + 1, NegativeMod(-a, MOD)},\n\t\t[]int64{1, 0},\n\t}\n\n\tAK := powMat(A, n-1, MOD)\n\n\tans := int64(0)\n\n\tbig := (a*x + b) % MOD\n\tbig *= AK[0][0]\n\tans += big\n\tans %= MOD\n\n\tsml := AK[0][1]\n\tsml *= x\n\tsml %= MOD\n\tans += sml\n\tans %= MOD\n\n\tfmt.Println(ans)\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "882c6c1733763e37e57e2b90701f4d96", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\t// A := [][]int64{\n\t// \t[]int64{a + 1, -a},\n\t// \t[]int64{1, 0},\n\t// }\n\tA := [][]int64{\n\t\t[]int64{a + 1, NegativeMod(-a, MOD)},\n\t\t[]int64{1, 0},\n\t}\n\n\tAK := powMat(A, n-1, MOD)\n\n\tans := int64(0)\n\n\tbig := (a*x + b) % MOD\n\tbig *= AK[0][0]\n\tans += big\n\tans %= MOD\n\n\tsml := AK[0][1]\n\tsml *= x\n\tsml %= MOD\n\tans += sml\n\tans %= MOD\n\n\tfmt.Println(ans)\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "7bb023c2e0474b80b4acedfe83bd5217", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar str string\n\n\tfmt.Scan(&n)\n\tfmt.Scan(&str)\n\n\tvar cnt int = 0\n\tfor i := 0; i < n; i++ {\n\t\tif str[i] == '0' {\n\t\t\tcnt++\n\t\t}\n\t}\n\n\tvar retstr string = \"\"\n\tif n - cnt == 0 {\n\t\tretstr = \"0\"\n\t} else if cnt == 0 {\n\t\tretstr = \"1\"\n\t} else {\n\t\tretstr = \"1\"\n\t\tfor cnt != 0 {\n\t\t\tretstr = retstr + \"0\"\n\t\t\tcnt--\n\t\t}\n\t}\n\n\tfmt.Println(retstr)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "79f6b46a3e60fa28e393bd70ccb91ace", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar (\n\t\tn int\n\t\ts []byte\n\t)\n\n\tfmt.Scanln(&n)\n\tfmt.Scanln(&s)\n\n\tcnt := 0\n\tzeroes := 0\n\tfor i := 0; i < n; i++ {\n\t\tif s[i] == '1' {\n\t\t\tcnt++\n\t\t} else {\n\t\t\tzeroes++\n\t\t}\n\t}\n\n\tfor i := 0; i < 200; i++ {\n\t\tcnt = int(math.Ceil(float64(cnt) / 2.0))\n\t}\n\n\t// for i := n - 1; i > 0; i-- {\n\t// \tfor j := n - 1; j > 0; j-- {\n\t// \t\tif s[j] == '0' {\n\t// \t\t\ts[j], s[j-1] = s[j-1], s[j]\n\t// \t\t}\n\t// \t}\n\t// }\n\n\tif cnt == 0 {\n\t\tfmt.Println(\"0\")\n\n\t\treturn\n\t}\n\n\tres := \"\"\n\tfor i := 0; i < cnt; i++ {\n\t\tres += \"1\"\n\t}\n\n\tfor i := 0; i < zeroes; i++ {\n\t\tres += \"0\"\n\t}\n\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "6b40f94c7e3af1503f6ce39cc706d142", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar a, count0,count1 int\n\tvar s string\n\tfmt.Scanf(\"%d\\n\", &a)\n\tfmt.Scanf(\"%s\\n\", &s)\n\tfor _, v := range s{\n\t\tif v == '0'{\n\t\t\tcount0++\n\t\t} else if v == '1'{\n\t\t\tcount1++\n\t\t}\n\t}\n\tif count0 == 1 && count1 == 0{\n\t\tfmt.Println(0)\n\t\tos.Exit(0)\n\t}\n\tvar ss = \"1\"\n\tfor i:=0;i 59 {\n m = 0\n h++\n if h > 23 { h = 0 }\n }\n if (h%10 == m/10) && (h/10 == m%10) { break }\n }\n fmt.Printf(\"%02d:%02d\\n\",h,m)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "498c039286865dc4d258c8d616d66520", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 108A-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n \"strconv\"\n \"strings\"\n)\n\nfunc check(h, m int) bool {\n if h%10 == m/10 && h/10 == m%10 {\n return true\n }\n return false\n}\n\nfunc main() {\n var h, m int\n var s string\n fmt.Scan(&s)\n k := strings.SplitN(s, \":\", 2)\n h, _ = strconv.Atoi(k[0])\n m, _ = strconv.Atoi(k[1])\n for {\n m++\n if m == 60 {\n h++\n m = 0\n }\n if h == 24 {\n h = 0\n }\n if check(h, m) {\n break\n }\n }\n\n if h < 10 {\n fmt.Print(\"0\")\n fmt.Print(h)\n fmt.Print(\":\")\n } else {\n fmt.Print(h)\n fmt.Print(\":\")\n }\n if m < 10 {\n fmt.Print(\"0\")\n fmt.Print(m)\n } else {\n fmt.Print(m)\n }\n fmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "2116a003f0d28443877319e3aac70edd", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\n\n\nfunc main(){\n\tvar a , b , c , d int\n\tfmt.Scanf(\"%d%d\\n\" , &a , &b)\n\tfmt.Scanf(\"%d%d\" , &c , &d)\n\tfor i:=0 ; i<=110 ; i++ {\n\t\tif (b+i*a-d) % c == 0 && b+i*a-d >= 0 {\n\t\t\tfmt.Printf(\"%d\\n\" ,b+i*a)\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Printf(\"-1\\n\")\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "b7af969520d73f499c6c48f2a20075c6", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, d int\n\tif _, err := fmt.Scanf(\"%d %d\\n%d %d\\n\", &a, &b, &c, &d); err != nil {\n\t\treturn\n\t}\n\n\toffset := make(map[int]bool)\n\n\tfor i := 0; ; i++ {\n\t\tt := i*a + b\n\t\tif t-d >= 0 {\n\t\t\tif (t-d)%c == 0 {\n\t\t\t\tfmt.Println(t)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tl := (t - d) / c\n\t\t\toff := t - (l*c + d)\n\t\t\tif offset[off] {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\toffset[off] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(-1)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "98a83f06563166fe3164d1cac4cc7298", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := readInt()\n\tb := readInt()\n\tc := readInt()\n\td := readInt()\n\tfor i := 0; i < 100000; i++ {\n\t\tif i >= b && i >= d {\n\t\t\tif (i-b)%a == 0 && (i-d)%c == 0 {\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "063a04aab2b0e5f950ce2cb02c89bf33", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nfunc main(){\n var n,i,k,sum,c int32\n fmt.Scanln(&n,&k)\n for i=1;i<=n;i++{\n var a int32\n fmt.Scanf(\"%d\",&a)\n if a>8{\n sum=sum+a-8\n c=c+8\n }else{\n\t\t\tif a+sum>8{\n \t\t sum=sum-8+a\n \t \tc=c+8\n \t\t}else{\n \tc=c+a+sum\n \tsum=0\n \t}\n\t\t}\n if (c>=k){\n break\n \t}\n }\n if c>=k{\n fmt.Println(i)\n }else{\n fmt.Println(-1)\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "6b64a621b69b40960b8684414d0b55da", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n, k int\n fmt.Scan(&n, &k)\n minDays := 0\n for candyAtHand, i:= 0,0; i 0 {\n if candyAtHand >= 8 {\n k -= 8\n candyAtHand -= 8\n } else {\n k -= candyAtHand\n candyAtHand = 0\n }\n }\n if k <= 0 {\n minDays = i+1\n break\n }\n }\n if k <= 0 {\n fmt.Print(minDays)\n } else {\n fmt.Print(-1)\n }\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "feda751124287dbd69e282b99fe68261", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tk := readInt()\n\tcur := 0\n\tfor i := 0; i < n; i++ {\n\t\tcur += readInt()\n\t\tif cur >= 8 {\n\t\t\tk -= 8\n\t\t\tcur -= 8\n\t\t} else {\n\t\t\tk -= cur\n\t\t\tcur = 0\n\t\t}\n\t\tif k <= 0 {\n\t\t\tfmt.Println(i + 1)\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "eb9a70fe45c915ca4520497958ccb44f", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar s string\nvar num int\nvar str [120]string\n\nfunc main() {\n fmt.Scan(&s)\n fmt.Scan(&num)\n for i := 0; i < num; i++ {\n fmt.Scan(&str[i])\n }\n for i := 0; i < num; i++ {\n if str[i] == s {\n fmt.Println(\"YES\")\n return\n }\n for j := 0; j < num; j++ {\n if str[i][0] == s[1] && str[j][1] == s[0] {\n fmt.Println(\"YES\")\n return\n }\n }\n }\n fmt.Println(\"NO\")\n}", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "08a8e5fe9b9f7a93f09932621d95868a", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main(){\n var target string\n\t_, err := fmt.Scanln(&target)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n var count, first, second int\n\t_, err = fmt.Scanln(&count)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n for i:=0; i < count; i++{\n var word string\n\t\t_, err = fmt.Scanln(&word)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\n\t\tif word == target {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n hasFirst := word[0] == target[1]\n hasSecond := word[1] == target[0]\n\n if hasFirst{\n first++\n }\n if hasSecond{\n second++\n }\n }\n if first > 0 && second > 0 {\n fmt.Println(\"YES\")\n }else{\n fmt.Println(\"NO\")\n}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "1e8571341cfaddc78c023bf839930f56", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tpassword string\n\t\twords int\n\t\tfi, se bool\n\t)\n\n\tfmt.Scan(&password)\n\tfmt.Scan(&words)\n\n\tfor i := 0; i < words; i++ {\n\t\tvar word string\n\t\tfmt.Scan(&word)\n\n\t\tif word == password {\n\t\t\tfmt.Print(\"YES\\n\")\n\t\t\treturn\n\t\t}\n\n\t\tif exist := word[0] == password[1]; exist {\n\t\t\tfi = true\n\t\t}\n\t\tif exist := word[1] == password[0]; exist {\n\t\t\tse = true\n\t\t}\n\n\t\tif fi && se {\n\t\t\tfmt.Print(\"YES\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Print(\"NO\\n\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "5dacc118b3e004eba09c70b7123a3ab5", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc run(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n int\n\tvar s []byte\n\tFscan(in, &n, &s)\n\n\tif n == 1 {\n\t\tFprintln(out, 0)\n\t\treturn\n\t}\n\ts = append([]byte{0}, s...)\n\ts = append(s, 0)\n\n\tans := 0\n\t//s2 := []byte{}\n\t//for i := byte('z'); i >= 'a'; i-- {\n\t//\tlp := 0\n\t//\tfor j, b := range s {\n\t//\t\t//if j > 0 && lc == 0 {\n\t//\t\t//\tlc = s[j-1]\n\t//\t\t//}\n\t//\t\tif b == i && (s[j]-1 == s[lp] || s[j]-1 == s[j+1]) {\n\t//\t\t\tans++\n\t//\n\t//\t\t} else {\n\t//\t\t\ts2 = append(s2, b)\n\t//\t\t\tlp = j\n\t//\t\t}\n\t//\t}\n\t//\ts = s2\n\t//\ts2 = []byte{}\n\t//}\n\n\tfor curB := byte('z'); curB >= 'a'; curB-- {\n\t\tfor {\n\t\t\tdel := false\n\t\t\tfor i, b := range s {\n\t\t\t\tif b == curB && (s[i]-1 == s[i-1] || s[i]-1 == s[i+1]) {\n\t\t\t\t\tans++\n\t\t\t\t\tdel = true\n\t\t\t\t\ts = append(s[:i], s[i+1:]...)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !del {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tFprintln(out, ans)\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "185c55364d0fda86793a78b4a65cd2e9", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scan(&n, &s)\n\trls := solve(n, s)\n\tfmt.Println(rls)\n}\n\nfunc solve(n int, s string) int {\n\tchs := []rune(s)\n\tfor ch := 'z'; ch > 'a'; ch-- {\n\t\tfor i := 1; i < len(chs); i++ {\n\t\t\tfor i < len(chs) && chs[i] == ch && chs[i-1] == ch-1 {\n\t\t\t\tchs = append(chs[:i], chs[i+1:]...)\n\t\t\t}\n\t\t}\n\t\tfor i := len(chs) - 2; i >= 0; i-- {\n\t\t\tif i+1 < len(chs) && chs[i] == ch && chs[i+1] == ch-1 {\n\t\t\t\tchs = append(chs[:i], chs[i+1:]...)\n\t\t\t}\n\t\t}\n\t}\n\treturn len(s) - len(chs)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "43256840a629b776c2d79a56791efdcc", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\n\tvar n int\n\tfmt.Fscanf(r, \"%d\\n\", &n)\n\n\tvar s string\n\tfmt.Fscanf(r, \"%s\\n\", &s)\n\n\tdeleted := make(map[int]bool)\n\n\tcount := 0\n\tfor ch := byte('z'); ch >= 'a'; ch-- {\n\t\tfor i, _ := range s {\n\t\t\tcur := s[i]\n\t\t\tif cur != ch {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tcan := false\n\n\t\t\tj := i\n\t\t\tfor j >= 0 && (deleted[j] || s[j] == cur) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tif j >= 0 && s[j]+1 == cur {\n\t\t\t\tcan = true\n\t\t\t}\n\n\t\t\tj = i\n\t\t\tfor j < n && (deleted[j] || s[j] == cur) {\n\t\t\t\tj++\n\t\t\t}\n\t\t\tif j < n && s[j]+1 == cur {\n\t\t\t\tcan = true\n\t\t\t}\n\n\t\t\tif can {\n\t\t\t\tdeleted[i] = true\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n\", count)\n}\n\nfunc min(a, b byte) byte {\n\tif a <= b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "13fc3b9ae71c90251d22e649749a5102", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc isVowel(c byte) bool {\n if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {\n return true\n } else {\n return false\n }\n}\n\nfunc main() {\n var s string\n fmt.Scanf(\"%s\", &s)\n succ := true\n for i, c := range []byte(s) {\n cur := true\n if !isVowel(c) && c != 'n' {\n cur = (i < len(s) - 1) && isVowel(s[i+1])\n }\n if !cur {\n succ = false\n }\n }\n if succ {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "d759eaac4a25161aaca2452cfe8d5846", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n)\n\nfunc readLine(reader *bufio.Reader) string {\n\tline, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimRight(string(line), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tvowels := make(map[rune]int)\n\tvar l rune\n\tfor l = 'a'; l <= 'z'; l++ {\n\t\tif l == 'a' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'e' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'i' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'o' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'u' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t}\n\n\tisBerlanese := true\n\tvar word string\n\tfmt.Scanf(\"%s\", &word)\n\n\tif len(word) > 1 {\n\t\tfor i := 0; i < len(word)-1; i++ {\n\t\t\tif isBerlanese == false {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tletter := rune(word[i])\n\t\t\tnextLetter := rune(word[i+1])\n\t\t\tif letter == 'n' {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t_, isVowel := vowels[letter]\n\t\t\tif isVowel == true {\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\t\tif nextIsVowel == false {\n\t\t\t\t\tisBerlanese = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tletter := rune(word[0])\n\t\tif letter == 'n' {\n\t\t\tisBerlanese = true\n\t\t} else if _, V := vowels[letter]; V == true {\n\t\t\tisBerlanese = true\n\t\t} else {\n\t\t\tisBerlanese = false\n\t\t}\n\t}\n\n\tletter := rune(word[len(word)-1])\n\tif _, okay := vowels[letter]; !(okay == true || letter == 'n') {\n\t\tisBerlanese = false\n\t}\n\tif isBerlanese == true {\n\t\tfmt.Printf(\"%s\\n\", \"YES\")\n\t} else {\n\t\tfmt.Printf(\"%s\\n\", \"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "d04e844619842cf0a5e115ad01314dba", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvocal := map[string]bool{\n\t\t\"a\": true,\n\t\t\"i\": true,\n\t\t\"u\": true,\n\t\t\"e\": true,\n\t\t\"o\": true,\n\t}\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Scan()\n\tword := sc.Text()\n\tfor i := 0; i < len(word); i++ {\n\t\t// get status\n\t\tch := string(word[i])\n\t\tisLast := (i == len(word)-1)\n\t\tisVocal := vocal[ch]\n\t\tisN := (ch == \"n\")\n\t\t// get next char\n\t\tnextCh := \"\"\n\t\tif !isLast {\n\t\t\tnextCh = string(word[i+1])\n\t\t}\n\t\t// infer if word is belanese\n\t\tif !isN && (!isVocal && !vocal[nextCh] || !isVocal && isLast) {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "7a41d342b92848212d06612c73d6ae10", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar str string\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%s\", &str)\n\tshouldCheck := 0\n\tfor i := 0; i < len(str); i++ {\n\t\tch := string(str[i])\n\t\tnum, err := strconv.Atoi(ch)\n\t\tif err != nil {\n\t\t\tif ch == \"a\" || ch == \"i\" || ch == \"u\" || ch == \"e\" || ch == \"o\" {\n\t\t\t\tshouldCheck++\n\t\t\t}\n\t\t} else {\n\t\t\tif num%2 != 0 {\n\t\t\t\tshouldCheck++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(shouldCheck)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "5043683e7bf701326ef7280b8db64a56", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tS := sc.NextLine()\n\tcount := 0\n\tfor _, v := range S {\n\t\tswitch v {\n\t\tcase 'a', 'i', 'u', 'e', 'o', '1', '3', '5', '7', '9':\n\t\t\tcount++\n\n\t\t}\n\t}\n\tfmt.Println(count)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "7abcdbbbd2b3abbe1655e952f9cf11d3", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\tvar ans int\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] >= '0' && s[i] <= '9' {\n\t\t\tif (s[i]-'0')%2 == 1 {\n\t\t\t\tans++\n\t\t\t}\n\t\t} else {\n\t\t\tif strings.IndexByte(\"aeiou\", s[i]) != -1 {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "a603a2c71d7abf0738caae21dd7a68e8", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n uint64\n\tfmt.Scan(&n)\n\n\tf := []uint64{1, 2}\n\tfor i := 2; true; i++ {\n\t\tf = append(f, 0)\n\t\tf[i] = f[i-1] + f[i-2]\n\t\tif f[i] > n {\n\t\t\tfmt.Println(i - 1)\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "constructive algorithms", "math", "dp", "combinatorics"], "code_uid": "e925b2c5112098ca820b39a73ade0566", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n)\n\nfunc main() {\n\tb, _ := ioutil.ReadAll(os.Stdin)\n\tif len(b) == 0 {\n\t\ttest()\n\t} else {\n\t\tsolve(bytes.NewReader(b), os.Stdout)\n\t}\n}\n\nfunc solve(r io.Reader, w io.Writer) {\n\tvar n uint64\n\tfmt.Fscanln(r, &n)\n\n\tif n == 2 {\n\t\tfmt.Fprint(w, 1)\n\t\treturn\n\t}\n\n\twin := 0\n\tvar a, b uint64 = 1, 2\n\tvar c uint64\n\tfor ; c <= n; win++ {\n\t\tc = a + b\n\t\ta, b = b, c\n\t}\n\tfmt.Fprintln(w, win)\n}\n\nfunc test() {\n\ttests := []struct {\n\t\tin string\n\t\twant string\n\t}{\n\t\t{in: `2`, want: `1`},\n\t\t{in: `3`, want: `2`},\n\t\t{in: `4`, want: `2`},\n\t\t{in: `5`, want: `3`},\n\t\t{in: `6`, want: `3`},\n\t\t{in: `7`, want: `3`},\n\t\t{in: `8`, want: `4`},\n\t\t{in: `9`, want: `4`},\n\t\t{in: `10`, want: `4`},\n\t\t{in: `11`, want: `4`},\n\t\t{in: `12`, want: `4`},\n\t\t{in: `13`, want: `5`},\n\t\t{in: `14`, want: `5`},\n\t\t{in: `15`, want: `5`},\n\t\t{in: `20`, want: `5`},\n\t\t{in: `21`, want: `6`},\n\t}\n\tfor i, tt := range tests {\n\t\tfmt.Printf(\"=== TEST %d\\n\", i)\n\t\tbuf := new(bytes.Buffer)\n\t\tsolve(strings.NewReader(chomp(tt.in)), buf)\n\t\tif got, want := chomp(buf.String()), chomp(tt.want); got != want {\n\t\t\tfmt.Printf(\"%d: got %v, want %v\\n\", i, got, want)\n\t\t}\n\t}\n}\n\nfunc chomp(s string) string {\n\treturn strings.Trim(s, \"\\n\")\n}\n\nfunc assert(b bool) {\n\tif !b {\n\t\t_, file, line, ok := runtime.Caller(1)\n\t\tif ok {\n\t\t\tf, _ := os.Open(file)\n\t\t\tdefer f.Close()\n\t\t\ts := bufio.NewScanner(f)\n\t\t\tlnum := 0\n\t\t\tfor s.Scan() {\n\t\t\t\tlnum++\n\t\t\t\tif lnum == line {\n\t\t\t\t\twd, _ := os.Getwd()\n\t\t\t\t\tfname, _ := filepath.Rel(wd, file)\n\t\t\t\t\tfmt.Printf(\"assertion fails: %s:%d: %v\\n\", fname, line, s.Text())\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc pow(a, b int) int {\n\tr := 1\n\tfor i := 0; i < b; i++ {\n\t\tr *= a\n\t}\n\treturn r\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "57f0f9f4f526526712c40a435261a1ac", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n n := readInt64()\n mx := 88\n mem := make([]int64, mx)\n mem[1], mem[2] = 2, 3\n for i := 3; i < mx; i++ {\n mem[i] = mem[i-1]+mem[i-2]\n }\n ans := 0\n for i, v := range mem {\n if n >= v {\n ans = i\n }\n }\n fmt.Println(ans)\n}\n\n// Helpers\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\n// Sort\n\ntype Ints64 []int64\n\nfunc (a Ints64) Len() int { return len(a) }\nfunc (a Ints64) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a Ints64) Less(i, j int) bool { return a[i] < a[j] }\n\n/* Sort tempalte\nfunc (a ) Len() int { return len(a) }\nfunc (a ) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ) Less(i, j int) bool { return }\n*/\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "5de6069639c4452136b64b9dd592748e", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc solve() bool {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tscanner.Scan()\n\tmaj := scanner.Text()\n\tfor i := 0; i < len(maj)-1; i++ {\n\t\tif maj[i] == maj[i+1] && maj[i] != '?' {\n\t\t\treturn false\n\t\t}\n\t}\n\t// A?A -> Yes\n\t// A?B -> No\n\tfor i := range maj {\n\t\tif maj[i] == '?' {\n\t\t\tif i == 0 || i == len(maj)-1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif maj[i-1] == '?' || maj[i+1] == '?' {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif maj[i-1] == maj[i+1] {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tif solve() {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "48defc15c20bf1ab06127c7a04997985", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nfunc main(){\n\tvar(\n\t\tn int\n\t\ts string\n\t)\n\tfmt.Scan(&n,&s)\n\tfor i:=0;i0||strings.Count(s,\"CC\")>0||strings.Count(s,\"YY\")>0{\n\t\tfmt.Println(\"No\")\n\t\treturn\n\t}\n\tif s[0]=='?'||s[n-1]=='?'||strings.Count(s,\"??\")>0||strings.Count(s,\"M?M\")>0||strings.Count(s,\"C?C\")>0||strings.Count(s,\"Y?Y\")>0{\n\t\tfmt.Println(\"Yes\")\n\t\treturn\n\t}\n\tfmt.Println(\"No\")\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4d8a9cafb5661fb6cde46ddad554fac6", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tl := []int{0, 0, 0}\n\tfmt.Scan(&l[0], &l[1], &l[2])\n\tr := l[0] + l[1] - l[2]\n\tfor _, x := range l {\n\t\tif r > x {\n\t\t\tr = x\n\t\t}\n\t}\n\tfmt.Println(r)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "add36012a1f8c4b0b0b494097ee8b152", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nconst debug = true\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tin := gsli(reader)\n\n\tn := in[0]\n\tk := in[1]\n\tt := in[2]\n\n\tans := 0\n\tif t <= k {\n\t\tans = t\n\t} else if t <= n {\n\t\tans = k\n\t} else {\n\t\tans = k + n - t\n\t}\n\n\tfmt.Println(ans)\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// String helpers\n\n// Is Lowercase\n// Given some string[i], return whether it is lower case or not.\n\nfunc isl(b byte) bool {\n\tvar r rune\n\tr = rune(b)\n\treturn unicode.IsLower(r)\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\n// Max Int\n// Returns the max of two ints\n\nfunc maxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// Distance formule\n// Calculates the distance to the origin\n\nfunc dist(x, y float64) float64 {\n\treturn math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))\n}\n\n// Output helpers\n\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\n\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\n// Debug helpers\n\n// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss\n\nfunc dbg(s string, a ...interface{}) {\n\tif debug {\n\t\tfmt.Printf(s, a...)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "6b20dc321ebe25807a36bd30cff4e2d7", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n,k,t int\n\tfmt.Scanf(\"%d %d %d\",&n,&k,&t)\n\tif t<=k{\n\t\tfmt.Println(t)\n\t} else{\n\t\tif t<=n {\n\t\t\tfmt.Println(k)\n\t\t}else {\n\t\t\tfmt.Println(k-(t-n))\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "ced100f4b8616c0af091d81c703f0ae2", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int64\n\tfmt.Scan(&a, &b)\n\tc := a + b\n\n\ta1 := removeZeros(a)\n\tb1 := removeZeros(b)\n\tc1 := removeZeros(c)\n\t\n\tif a1+b1 == c1 {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n\nfunc removeZeros(a int64) int64 {\n\tvar b int64\n\tfor ; a > 0; a /= 10 {\n\t\td := a % 10\n\t\tif d > 0 {\n\t\t\tb = b*10 + d\n\t\t}\n\t}\n\n\tvar ret int64\n\tfor ; b > 0; b /= 10 {\n\t\tret = ret*10 + b%10\n\t}\n\n\treturn ret\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "3f7bc9b86061c7bbc0dd5a8e0a3065ec", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n\t\"strconv\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tre := regexp.MustCompile(`\\r?\\n`)\n\tzero := regexp.MustCompile(`0`)\n\n\twith_zero := [2]int{0, 0}\n\tno_zero := [2]int{0, 0}\n\n\tfor i := 0; i < 2; i++ {\n\t\tif s, err := reader.ReadString('\\n'); err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\ts = re.ReplaceAllString(s, \"\")\n\t\t\tn, err := strconv.Atoi(s)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\twith_zero[i] = n\n\n\t\t\ts = zero.ReplaceAllString(s, \"\")\n\t\t\tz, err := strconv.Atoi(s)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tno_zero[i] = z\n\t\t}\n\t}\n\n\tsum := with_zero[0] + with_zero[1]\n\tsum_string := strconv.Itoa(sum)\n\tsum_no_zero := no_zero[0] + no_zero[1]\n\n\tsz := zero.ReplaceAllString(sum_string, \"\")\n\tsum_remove_zero, err := strconv.Atoi(sz)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif sum_no_zero == sum_remove_zero {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fa411e8bd87207c67026528b1884be02", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// down with zeroes\nfunc tonumwz(x string) (ret int32) {\n\tfor _, xi := range x {\n\t\tif xi != '0' {\n\t\t\tret = ret*10 + int32(xi-'0')\n\t\t}\n\t}\n\treturn\n}\n\nfunc main() {\n\n\tvar (\n\t\tna, nb, nc int32\n\t\ta, b, c string\n\t)\n\n\tfmt.Scan(&a)\n\tfmt.Scan(&b)\n\tfmt.Sscanf(a, \"%d\", &na)\n\tfmt.Sscanf(b, \"%d\", &nb)\n\tnc = na + nb\n\tc = fmt.Sprint(nc)\n\t//println(a, b, c)\n\t//println(na, nb, nc)\n\n\tna = tonumwz(a)\n\tnb = tonumwz(b)\n\tnc = tonumwz(c)\n\t//println(na, nb, nc)\n\t//println(na, nb, nc)\n\n\tif nc == na+nb {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "805b9ad72c9ce13eb85d18bd96340eed", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var k,l int64\n fmt.Scan(&k,&l)\n a, ans := k, 0\n for a < l {\n a *= k\n ans++\n }\n if a == l {\n fmt.Println(\"YES\")\n fmt.Println(ans)\n } else {\n fmt.Println(\"NO\")\n }\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "c11d3d8a0b410e5632bd70aebb6e5d88", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a,b,k int64\n\tc:=0\n\tfmt.Scan(&a,&b)\n\tk=a\n\tfor ;k n {\n ans = int(math.Ceil(float64(n)/float64(k)))\n }\n n -= (ans*k)\n if (b%(k-1) != 0) && (n >= 0) {\n ans++\n n -= (b%(k-1))+1\n }\n if (n >= 0) { ans += n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "ed40c66bd06c19cf8da3032e3295a944", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var k,a,b,v int\n fmt.Scan(&k,&a,&b,&v)\n n := int(math.Ceil(float64(a)/float64(v)))\n ans := b/(k-1)\n if (ans*k) > n {\n ans = int(math.Ceil(float64(n)/float64(k)))\n }\n n -= (ans*k)\n if (b%(k-1) != 0) && (n >= 0) {\n ans++\n n -= (b%(k-1))+1\n }\n if (n >= 0) { ans += n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "4a4de6cdc4570e6f8dc387c04dc1b107", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc main(){\n\tvar k int\n\tvar a, b int\n\tvar v int\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tk, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\ta, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tb, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tv, _ = strconv.Atoi(r.Text())\n\tbox := 0\n\tx := 0\n\tfor a > 0 {\n\t\tx = min(k-1, b)\n\t\ta -= (x+1)*v\n\t\tb -= x\n\t\tbox += 1\n\t}\n\tw.WriteString(strconv.Itoa(box)+\"\\n\")\n\tw.Flush()\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "ea3b6e6b1f09d0303a8cf014be0943e0", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tk := readInt()\n\tcnt := make([]int, 5)\n\thave := make([]int, 5)\n\thave[4] = n\n\thave[2] = 2 * n\n\tfor i := 0; i < k; i++ {\n\t\tx := readInt()\n\t\tfor x >= 3 {\n\t\t\tif have[4] > 0 {\n\t\t\t\thave[4]--\n\t\t\t\tx -= 4\n\t\t\t} else if have[2] > 0 {\n\t\t\t\thave[2]--\n\t\t\t\tx -= 2\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif x > 0 {\n\t\t\tcnt[x]++\n\t\t}\n\t}\n\tfor cnt[2] > 0 {\n\t\tif have[2] > 0 {\n\t\t\thave[2]--\n\t\t\tcnt[2]--\n\t\t} else if have[4] > 0 {\n\t\t\tcnt[2]--\n\t\t\thave[4]--\n\t\t\thave[1]++\n\t\t} else {\n\t\t\tcnt[2]--\n\t\t\tcnt[1] += 2\n\t\t}\n\t}\n\tif cnt[1] <= have[1]+have[2]+have[4]*2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "9b757e60672e1e74f9e9c930cc576b8b", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\t\t\t\t\t// membuat variabel b dengan jenis int\n var x,y int\t\t\t\t// membuat variabel x dan y dengan jenis int\n fmt.Scan(&n) \t\t\t// mengambil input\n upper, lower, f := 0, 0, false // membuat variabel upper, lower dan f yang diisi 0 , 0 dan false\n for i := 0; i < n; i++ {\t// looping\n fmt.Scan(&x,&y)\t\t\t// mengambil input kedua\n if (x+y)%2 == 1 { f = true } // jika x + y dimodulo 2 sama dengan 1 maka f sama dengan true\n upper = (upper+x)%2\t\t\t// upper sama dengan upper di tambah x kemudian dimodulo 2\n lower = (lower+y)%2\t\t\t\t// lower sama dengan lower di tambah y kemudian dimodulo 2\n }\n if (upper+lower) == 0 {\t\t\t// jika upper ditambah lower sama dengan 0\n fmt.Println(0)\t\t\t\t\t// maka cetak 0\n } else if ((upper+lower) == 2) && f { // jika upper + lower sama dengan 2 dan f\n fmt.Println(1)\t\t\t\t\t\t// maka cetak 1\n } else {\n fmt.Println(-1)\t\t\t\t\t\t// lainnya maka cetak -1\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "3d68b0488e92146cf76ee4f797d2b46b", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// 1200\n// 28.05.2020\n// https://codeforces.com/problemset/problem/353/A\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\n\txs := make([]int, n)\n\tys := make([]int, n)\n\n\tvar sumx, sumy int\n\tfor i := 0; i < n; i++ {\n\t\tvar x, y int\n\t\tfmt.Scanln(&x, &y)\n\t\txs[i] = x\n\t\tys[i] = y\n\n\t\tsumx += x\n\t\tsumy += y\n\t}\n\tif sumx%2 == 0 && sumy%2 == 0 {\n\t\tfmt.Println(\"0\")\n\t\treturn\n\t}\n\tif sumx%2 == 1 && sumy%2 == 1 {\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif xs[i]%2 != ys[i]%2 {\n\t\t\t\tfmt.Println(\"1\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"-1\")\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "e441b518dd2fcf21e91fcd0080e13d04", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var x,y int\n fmt.Scan(&n)\n upper, lower, f := 0, 0, false\n for i := 0; i < n; i++ {\n fmt.Scan(&x,&y)\n if (x+y)%2 == 1 { f = true }\n upper = (upper+x)%2\n lower = (lower+y)%2\n }\n if (upper+lower) == 0 {\n fmt.Println(0)\n } else if ((upper+lower) == 2) && f {\n fmt.Println(1)\n } else {\n fmt.Println(-1)\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "bde63a4c4266163ee13952bbe88202e9", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, candlesOut int \n\tfmt.Scanf(\"%d\", &a)\n\tfmt.Scanf(\"%d\", &b)\n \n \tcandlesOut = a\n for candlesOut>=b {\n \ta+=candlesOut/b\n \tcandlesOut=candlesOut/b + candlesOut%b\n }\n \n\tfmt.Println(a)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4416c634b3e6fc541de4f0ac9f881ce5", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, b int\n fmt.Scanf(\"%d %d\", &a, &b)\n\n remain := 0\n ans := 0\n for a > 0 {\n ans += a\n\n a += remain\n remaked := a / b\n remain = a - remaked*b\n a = remaked\n }\n\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5703486abcfbad3d8000ad648b8fcdc9", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/379/A\n// комментарии к решению\n// Итеративным подходом зажигаем все свежие свечи,\n// потом делаем из необходимого кол-ва использованных свежие свечи\n// и так до тех пор, пока не закончатся нормальные свечи и\n// из использованных нельзя будет сделать ниодной нормальной\nfunc taskSolution(a, b int) (ans int) {\n\tr, n := a, 0\n\tfor r > 0 || n >= b {\n\t\tans, r, n = ans+r, r/b+n/b, n%b+r%b\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tvar a, b int\n\tif _, err := fmt.Scan(&a, &b); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(a, b))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "c5f6fc1522ecf43574a87f6738c69645", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\"fmt\"\n\"os\"\n)\n\nfunc main() {\n\tvar b, y, yb, gb, bb int64\n\n\tfmt.Fscan(os.Stdin, &b)\n\tfmt.Fscan(os.Stdin, &y)\n\tfmt.Fscan(os.Stdin, &yb)\n\tfmt.Fscan(os.Stdin, &gb)\n\tfmt.Fscan(os.Stdin, &bb)\n\n\tif b - gb - (yb * 2) >= 0 {\n\t\tif y - gb - (bb * 3) >= 0 {\n\t\t\tfmt.Print(0)\n\t\t} else {\n\t\t\tfmt.Print(gb + (bb * 3) - y)\n\t\t}\n\t} else {\n\t\tif y - gb - (bb * 3) >= 0 {\n\t\t\tfmt.Print(gb + (yb * 2) - b)\n\t\t} else {\n\t\t\tfmt.Print((gb * 2) + (bb * 3) + (yb * 2) - b - y )\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "256b379c99f805156293c97abab2549e", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// Case .\ntype Case struct {\n\ta, b, x, y, z int64\n}\n\nfunc solve(c Case, w io.Writer) {\n\ta := 2*c.x + c.y - c.a\n\tb := c.y + 3*c.z - c.b\n\tif a < 0 {\n\t\ta = 0\n\t}\n\tif b < 0 {\n\t\tb = 0\n\t}\n\tw.Write(([]byte)(fmt.Sprintf(\"%d\\n\", a+b)))\n}\n\nfunc parseInput(lines <-chan string, res chan<- Case) {\n\tfor {\n\t\tab1, ok := <-lines\n\t\tif !ok {\n\t\t\tclose(res)\n\t\t\treturn\n\t\t}\n\t\tab := int64s(words(ab1))\n\t\txyz := int64s(words(<-lines))\n\t\tres <- Case{ab[0], ab[1], xyz[0], xyz[1], xyz[2]}\n\t}\n}\n\nfunc int64s(w []string) []int64 {\n\tres := make([]int64, 0, len(w))\n\tfor _, word := range w {\n\t\ti, err := strconv.ParseInt(word, 10, 64)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tres = append(res, i)\n\t}\n\treturn res\n}\n\nfunc words(s string) []string {\n\tprep := strings.Split(s, \" \")\n\tres := make([]string, 0, len(prep))\n\tfor _, l := range prep {\n\t\tif len(l) > 0 {\n\t\t\tres = append(res, l)\n\t\t}\n\t}\n\treturn res\n}\n\nfunc run() error {\n\texp, err := ioutil.ReadFile(\"expected.txt\")\n\tif err == nil {\n\t\tfmt.Println(\"--------- expected --------- \")\n\t\tfmt.Println((string)(exp))\n\t\tfmt.Println(\"--------- computed --------- \")\n\t}\n\n\tinData, err := ioutil.ReadAll(os.Stdin)\n\t//inData, err := ioutil.ReadFile(\"in.txt\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read input: %s\", err)\n\t}\n\tlines := make(chan string, 8)\n\tcases := make(chan Case, 8)\n\tgo func() {\n\t\tfor _, line := range strings.Split((string)(inData), \"\\n\") {\n\t\t\ts := strings.TrimSpace(line)\n\t\t\tif len(s) > 0 {\n\t\t\t\tlines <- s\n\t\t\t}\n\t\t}\n\t\tclose(lines)\n\t}()\n\tgo parseInput(lines, cases)\n\tfor c := range cases {\n\t\tsolve(c, os.Stdout)\n\t}\n\treturn nil\n}\n\nfunc main() {\n\tif err := run(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0917cbd176b31ed00caf6ceb04bbdbc7", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n/*\n\tThe idea to solve this problem is basically we just need to calculate\n\thow many A & B we need more. If we breakdown the recipe, we would get\n\tfollowing formula:\n\t- needA = 2x + y\n\t- needB = 3z + y\n\n\tAfter that we just need to calculate how much we need from each\n\tkind of crystal then combine it.\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\t// in codeforces it seems int is equivalent with int32\n\t// so we need to say explicitly we need int64 to avoid overflow\n\tvar a, b, x, y, z int64\n\tstdio := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdio, \"%d %d\\n%d %d %d\", &a, &b, &x, &y, &z)\n\n\t// calculate total crystal we need for each kind of crystal\n\tneedA := (2 * x) + y\n\tneedB := (3 * z) + y\n\t// calculate total crystal should acquired\n\tfmt.Println(diff(a, needA) + diff(b, needB))\n}\n\n// calculate how much we need from each kind of crystal\nfunc diff(have int64, want int64) int64 {\n\tif want >= have {\n\t\treturn want - have\n\t}\n\treturn 0\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "9c2c8be43fa5678aa0c1ccba352a805e", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol276D(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar l, r int64\n\tFscan(in, &l, &r)\n\tif l == r {\n\t\tFprint(out, 0)\n\t\treturn\n\t}\n\tfor m := l ^ r; ; m &= m - 1 {\n\t\tif m&(m-1) == 0 {\n\t\t\tFprint(out, m<<1-1)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc main() {\n\tSol276D(os.Stdin, os.Stdout)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "bitmasks", "greedy", "implementation"], "code_uid": "0669af609112e92ad8b538a8fae6e33a", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r int64\n\tfmt.Scan(&l, &r)\n\n\tvar p uint64\n\tfor i := uint64(1); l != 0 || r != 0; i++ {\n\t\tif l&1^r&1 == 1 {\n\t\t\tp = (1 << i) - 1\n\t\t}\n\t\tl >>= 1\n\t\tr >>= 1\n\t}\n\tfmt.Println(p)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "bitmasks", "greedy", "implementation"], "code_uid": "c8ff028ae2087d55ddde7a58f0f5239c", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t_ \"math\"\n\t\"os\"\n\t_ \"sort\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\ntype intPair struct {\n\ta int64\n\tb int64\n}\n\nfunc max(a, b int64) int64 {\n\tif(a > b) {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int64) int64 {\n\tif(a0 {\n\t\ti++\n\t\tif l&1 ^ r&1 != 0 {\n\t\t\tp=i\n\t\t}\n\t\tl>>=1\n\t\tr>>=1\n\t}\n\tans := (int64(1< 0 && i >= 0; i-- {\n\t\tif a[i] >= max {\n\t\t\tans += int64(max)\n\t\t\tmax = max - 1\n\t\t} else {\n\t\t\tans += int64(a[i])\n\t\t\tmax = a[i] - 1\n\t\t}\n\t}\n\tfmt.Fprintln(out, ans)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "ea08f4a2ddec8877be32b652d3f1045d", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"fmt\"\n \"strings\"\n \"strconv\"\n \"sort\"\n )\n \n \nfunc main() {\n stin := bufio.NewScanner(os.Stdin)\n stin.Scan()\n ns,_ := strconv.ParseInt(stin.Text(), 10, 32)\n n := int(ns)\n stin.Scan()\n ss := strings.Fields(stin.Text())\n var a []int\n for i := 0; i < n; i++ {\n q,_ := strconv.ParseInt(ss[i], 10, 32)\n a = append(a, int(q))\n }\n sort.Sort(sort.Reverse(sort.IntSlice(a)))\n \n var totalLength int64 = int64(a[0])\n for i := 1; i < n; i++ {\n if a[i] == a[i-1] {\n for j := i; j < n && a[j] == a[i-1]; j++ {\n if a[j] > 0 {\n a[j] -= 1\n }\n }\n }\n totalLength += int64(a[i])\n }\n fmt.Printf(\"%v\", totalLength)\n}", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "0c6d243759840f8d0fae3b7681771b70", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar num int\n\tfmt.Scan(&num)\n\ttrack := make(map[int64]bool)\n\ttotal := int64(0)\n\n\tfor i := 0; i < num; i++ {\n\t\tvar curr int64\n\t\tfmt.Scan(&curr)\n\n\t\tfor curr > 0 && track[curr] {\n\t\t\tcurr--\n\t\t}\n\t\ttrack[curr] = true\n\t\ttotal += curr\n\t}\n\tfmt.Println(total)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "32be787b4a0c565b79bc93eab73cd3fd", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc Abs(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar a, b, c int64\n\tfmt.Scan(&a, &b, &c)\n\n\tis := false\n\tif b == a {\n\t\tis = true\n\t} else {\n\t\tif c != 0 && (b-a)/c > 0 && (b-a)%c == 0 {\n\t\t\tis = true\n\t\t}\n\t}\n\n\tif is {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "5197a8bba955b66656501bd97578afc2", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b, c int\n fmt.Scan(&a, &b, &c)\n if c == 0 {\n if a == b {\n fmt.Print(\"YES\")\n } else {\n fmt.Print(\"NO\")\n }\n return\n }\n if (b-a)%c == 0 && (b-a)/c >= 0 {\n fmt.Print(\"YES\")\n } else {\n fmt.Print(\"NO\")\n }\n \n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "2f1b6c07081d517ea406130a7d94f4af", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar (\n\t\ta, b, c int\n\t)\n\tfmt.Scanf(\"%d%d%d\", &a, &b, &c)\n\tif checkNum(a, b, c) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\nfunc checkNum(a, b, c int) bool {\n\tif c == 0 {\n\t\treturn a == b\n\t}\n\tleftOver := b - a\n\tif leftOver%c == 0 && leftOver/c >= 0 {\n\t\treturn true\n\t}\n\treturn false\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "3f328fd50852ac06a55c665c38d1a653", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, ans int\n\tvar a = make([]int, 3)\n\tfmt.Scanln(&n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\tif n != 2 {\n\t\tans = a[0] ^ a[1] ^ a[2]\n\t} else {\n\t\tdp := make([][]int, 301)\n\t\tfor i := 0; i <= 300; i++ {\n\t\t\tdp[i] = make([]int, 301)\n\t\t\tfor j := 0; j <= 300; j++ {\n\t\t\t\tif j < i {\n\t\t\t\t\tdp[i][j] = dp[j][i]\n\t\t\t\t} else if i != 0 || j != 0 {\n\t\t\t\t\tdp[i][j] = 1\n\t\t\t\t\tfor x := 1; x <= i; x++ {\n\t\t\t\t\t\tdp[i][j] &= dp[i-x][j]\n\t\t\t\t\t\tdp[i][j] &= dp[i][j-x]\n\t\t\t\t\t\tdp[i][j] &= dp[i-x][j-x]\n\t\t\t\t\t}\n\t\t\t\t\tfor x := i + 1; x <= j; x++ {\n\t\t\t\t\t\tdp[i][j] &= dp[i][j-x]\n\t\t\t\t\t}\n\t\t\t\t\tdp[i][j] ^= 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tans = dp[a[0]][a[1]]\n\t}\n\tif ans == 0 {\n\t\tfmt.Println(\"BitAryo\")\n\t} else {\n\t\tfmt.Println(\"BitLGM\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dp", "games"], "code_uid": "f42100c7efeffc547b35812fb3d0fd7a", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"strconv\"\n\t\"bufio\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc PrintInts(ints ...int) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(value))\n\t\twriter.WriteByte(' ')\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\tn, k := ReadInt32(), ReadInt32()\n\n\tmod := n % k\n\tresult := n + (k - mod)\n\n\tPrintInts(result)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "14de8ce0bf65c7dcbd17e7ea71f8bbb4", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, k int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &n, &k); err != nil {\n\t\treturn\n\t}\n\n\tif n < k {\n\t\tfmt.Println(k)\n\t} else {\n\t\tif n/k >= 10000 {\n\t\t\tfor i := n + 1; ; i++ {\n\t\t\t\tif i%k == 0 {\n\t\t\t\t\tfmt.Println(i)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor i := 2; ; i++ {\n\t\t\t\tif i*k > n {\n\t\t\t\t\tfmt.Println(i * k)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "fbdd819ab278faf44c61a6ec2c185e55", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\tw := bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\t\n\tvar n, k int\n\tfmt.Fscan(r, &n, &k)\n\t\n\tfmt.Fprintln(w, ((n / k) + 1) * k)\n\t\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "11cc9aec03127c75643a80bbf1223ed5", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(x, y int) int {\n\tif y == 0 {\n\t\treturn x\n\t}\n\treturn gcd(y, x%y)\n}\n\nfunc main() {\n\tvar x, y, a, b int\n\tfmt.Scan(&x, &y, &a, &b)\n\n\tvar z uint64\n\tz = uint64(x) * uint64(y) / uint64(gcd(x, y))\n\n\tans := uint64(b)/z - uint64(a-1)/z\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "57061ebc18afe87cc5e1fa9d5e1ffe00", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 340A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc gcd(a, b int64) int64 {\n if a < b {\n return gcd(b, a)\n }\n if b == 0 {\n return a\n } else {\n return gcd(b, a%b)\n }\n}\n\nfunc main() {\n var x, y, a, b int64\n fmt.Scan(&x, &y, &a, &b)\n var z int64 = (x * y) / gcd(x, y)\n var ans int64 = b/z - ((a - 1) / z)\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "abdd74fd30520efec1cfa7f153ef9b5c", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc gcd(x, y int) int {\n if y == 0 {\n return x\n }\n return gcd(y, x%y)\n}\n\nfunc main() {\n var a, b, x, y int\n fmt.Scanf(\"%d%d%d%d\", &a, &b, &x, &y)\n c := a*b/gcd(a, b)\n fmt.Println(y/c-(x-1)/c)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "b1f0ae2a0caeece05b754f9e1b26e44d", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n \n var n int64\n fmt.Scanf(\"%v\\n\", &n)\n var count int64 = 0;\n \n var i,x int64 = 9,1;\n\n for n > 0 {\n if n < i {\n count += n*x;\n } else {\n count += i*x;\n }\n n -= i\n i *= 10\n x++\n }\n fmt.Printf(\"%v\\n\",count)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c3e7cf6819af1e01fe180deb59bd71fb", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"os\"\n)\n\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc count(n int64) int64 {\n\tif n < 10 {\n\t\treturn int64(n)\n\t}\n\tvar l, p int64 = 1, 1\n\tfor p * 10 <= n {\n\t\tl++\n\t\tp *= 10\n\t}\n\n\treturn l * ((n / p - 1) * p + (n % p + 1)) + count(p - 1)\n}\n\nfunc main() {\n\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\tfmt.Fprintln(out, count(NextInt64()))\n}\n\nfunc Next() string{\n\tif !in.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn in.Text()\n}\n\nfunc NextInt() int{\n\tret, _ := strconv.Atoi(Next())\n\treturn ret\n}\n\nfunc NextInt64() int64 {\n\tret, _ := strconv.ParseInt(Next(), 10, 64)\n\treturn ret\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "325e35c8a5134995717d2dd9c387dd54", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nfunc main() {\n //io\n scanner := bufio.NewReader(os.Stdin)\n writer := bufio.NewWriter(os.Stdout)\n //---\n var n, d, c, ans int64\n \n fmt.Fscan(scanner, &n)\n for c = 1; c <= n; c *= 10 {\n d++\n }\n //writer.WriteString(strconv.Itoa(c))\n c /= 10\n ans = (n - c + 1) * d;\n for d > 0 {\n ans += (c - c / 10) * (d-1);\n d--\n c /= 10\n }\n \n writer.WriteString(strconv.FormatInt(ans, 10))\n writer.Flush()\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "69fd6d1856e2c597a2ef5d8d7d3ae6bb", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tvar n string\n\tfmt.Fscan(reader, &n)\n\n\tmp := make(map[string]int)\n\tmp[\"0\"] = 2\n\tmp[\"1\"] = 7\n\tmp[\"2\"] = 2\n\tmp[\"3\"] = 3\n\tmp[\"4\"] = 3\n\tmp[\"5\"] = 4\n\tmp[\"6\"] = 2\n\tmp[\"7\"] = 5\n\tmp[\"8\"] = 1\n\tmp[\"9\"] = 2\n\n\tfmt.Println(mp[string(n[0])] * mp[string(n[1])])\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5adbfc2ddae9246350ce81d9b9400e81", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tm := map[uint8]int{\n\t\t'0' : 2,\n\t\t'1' : 7,\n\t\t'2' : 2,\n\t\t'3' : 3,\n\t\t'4' : 3,\n\t\t'5' : 4,\n\t\t'6' : 2,\n\t\t'7' : 5,\n\t\t'8' : 1,\n\t\t'9' : 2,\n\t}\n\n\tn := next()\n\n\tprintln(m[n[0]] * m[n[1]])\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, err := strconv.ParseFloat(next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "7f4e89c7f645402ec51c54efe08e5f7f", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\trs := []rune(s)\n\td1 := int(rs[0] - '0')\n\td2 := int(rs[1] - '0')\n\tt := []int{2, 7, 2, 3, 3, 4, 2, 5, 1, 2}\n\tfmt.Println(t[d1] * t[d2])\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f1e85a85a0f4d1aa0e384390c5c55af2", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport\n(\n \"fmt\"\n // \"math\"\n)\nfunc main(){\n var i int\n fmt.Scanf(\"%d\" , &i)\n // temp:= i\n x :=1\n count := 0\n var s []int\n if(i>81){\n x =x-81\n }\n\n for ;x81){\n continue\n }\n temp := x\n rs := (i-x)\n // temp2 :=1\n // fmt.Println(x)\n sum :=0\n for ;temp>0;temp/=10{\n\n // fmt.Println(mult)\n // var digits [] int\n\n xlast := temp%10\n sum +=xlast\n\n // res := temp + xlast\n // fmt.Println(temp,xlast)\n\n }\n if sum==rs{\n s = append(s,x)\n count ++\n }\n }\n if (count == 0){\nfmt.Println(0)\n}else\n{\n fmt.Println(count)\n for x:=0;x 0 {\n\t\t\ttotal += j % 10\n\t\t\tj /= 10\n\t\t}\n\n\t\tif total == N {\n\t\t\tans = append(ans, i)\n\t\t}\n\t}\n\tfmt.Println(len(ans))\n\tPrintI(ans...)\n}\n\nfunc mapToString(arr []int) []string {\n\tret := make([]string, len(arr))\n\tfor i := 0; i < len(arr); i++ {\n\t\tret[i] = strconv.Itoa(arr[i])\n\t}\n\treturn ret\n}\n\nfunc PrintI(args ...int) {\n\tfmt.Println(strings.Join(mapToString(args), \" \"))\n}\n\nfunc max(a int, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "5986d35ce2f82406e4502e8e2e403114", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar (\n\tread = fmt.Scan\n\tprint = fmt.Println\n)\n\nfunc main() {\n\tvar n, k int64\n\tread(&n, &k)\n\tif n/k%2 == 1 {\n\t\tprint(\"YES\")\n\t} else {\n\t\tprint(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "games"], "code_uid": "e56c7a1eea063fbd5866208da3bf7b51", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scanf(\"%d %d\", &n, &k)\n\tret := false\n\n\tprintln(n)\n\n\tif k == n {\n\t\tret = true\n\t} else {\n\t\tdiv := n / k\n\n\t\tif div%2 == 0 {\n\t\t\tret = false\n\t\t} else {\n\t\t\tret = true\n\t\t}\n\t}\n\n\tif ret {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "games"], "code_uid": "486fb7da10ca603b98fd0eeb2b0c2e96", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar (\n\tread = fmt.Scan\n\tprint = fmt.Println\n)\n\nfunc main() {\n\tvar n, k int64\n\tread(&n, &k)\n\tif n/k%2 == 1 {\n\t\tprint(\"YES\")\n\t} else {\n\t\tprint(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "games"], "code_uid": "586af07302da984dff8daf298c91cc62", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tre := regexp.MustCompile(`\\r?\\n`)\n\tif garland, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tgarland = re.ReplaceAllString(garland, \"\")\n\n\t\tneeds := make([]int, 4)\n\t\tcolor_idx := make([]int, 4) // Index of RBYG\n\n\t\tfor i := 0; i < len(garland); i++ {\n\t\t\tk := i % 4\n\t\t\tif 'R' == garland[i] {\n\t\t\t\tcolor_idx[0] = k\n\t\t\t} else if 'B' == garland[i] {\n\t\t\t\tcolor_idx[1] = k\n\t\t\t} else if 'Y' == garland[i] {\n\t\t\t\tcolor_idx[2] = k\n\t\t\t} else if 'G' == garland[i] {\n\t\t\t\tcolor_idx[3] = k\n\t\t\t} else if '!' == garland[i] {\n\t\t\t\tneeds[k]++\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"Error\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tfor i := 0; i < 4; i++ {\n\t\t\tfmt.Printf(\"%d \", needs[color_idx[i]])\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "number theory"], "code_uid": "ef3eadf2acb7129c57dcd2ff1816cff3", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tS := sc.NextLine()\n\tcolor := map[int]rune{}\n\n\tfor i, v := range S {\n\t\tif v == '!' {\n\t\t\tcontinue\n\t\t}\n\t\tcolor[i % 4] = v\n\t}\n\tans := map[rune]int{}\n\n\tfor i, v := range S {\n\t\tif v == '!' {\n\t\t\tans[color[i % 4]]++\n\t\t}\n\t}\n\tfmt.Println(ans['R'], ans['B'], ans['Y'], ans['G'])\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r:rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "number theory"], "code_uid": "22718e87831cd3400ea76ad3b7366b4b", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t)\n\nfunc main() {\n\tvar input string\n\tfmt.Scanln(&input)\n\td := map[string]int{\n\t\t\"R\":0,\n\t\t\"B\":1,\n\t\t\"Y\":2,\n\t\t\"G\":3,\n\t}\n\tcnt := []int{0, 0, 0, 0}\n\tmod := []int{-1, -1, -1, -1}\n\tfor i, s := range(input) {\n\t\tif string(s) == \"!\" {\n\t\t\tcontinue\n\t\t}\n\t\tx := d[string(s)]\n\t\tcnt[x]++\n\t\tmod[x] = i % 4\n\t}\n\tfor i := 0; i < 4; i++ {\n\t\tval := len(input) / 4\n\t\tif len(input) % 4 > mod[i] {\n\t\t\tval++\n\t\t}\n\t\tfmt.Printf(\"%d \", val - cnt[i])\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "number theory"], "code_uid": "5a096dd81a81b130fbd55fb5c792ac0a", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar s string\n\tfor I(&s) == nil {\n\t\tsolve(s)\n\t}\n}\n\nfunc solve(s string) {\n\tss := []byte(s)\n\tvk := []byte(\"VK\")\n\tmax := bytes.Count(ss, vk)\n\tfor i := range ss {\n\t\tif ss[i] == 'V' {\n\t\t\tss[i] = 'K'\n\t\t} else {\n\t\t\tss[i] = 'V'\n\t\t}\n\t\tmx := bytes.Count(ss, vk)\n\t\tif mx > max {\n\t\t\tmax = mx\n\t\t}\n\t\tif ss[i] == 'V' {\n\t\t\tss[i] = 'K'\n\t\t} else {\n\t\t\tss[i] = 'V'\n\t\t}\n\t}\n\tO(max, \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "2a43369e9cce4b45e97626ce2b83ecb0", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tstr := readString()\n\ta := []byte(str)\n\tans := 0\n\tfor _, v := range []byte(\"VK\") {\n\t\tfor i := 0; i < len(a); i++ {\n\t\t\tprev := a[i]\n\t\t\ta[i] = v\n\t\t\tres := 0\n\t\t\tfor j := 0; j < len(a)-1; j++ {\n\t\t\t\tif a[j] == 'V' && a[j+1] == 'K' {\n\t\t\t\t\tres++\n\t\t\t\t\tj++\n\t\t\t\t}\n\t\t\t}\n\t\t\tans = max(ans, res)\n\t\t\ta[i] = prev\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "87212429a88017afe3db49c56369fd70", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n\t\"reflect\"\n)\n\nfunc main() {\n\tn, l := read2i()\n\tk := readis(n)\n\ts := readis(n)\n\tif found(k, s, l) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\twriter.Flush()\n}\n\nfunc found(k, s []int, l int) bool {\n\ts = decrease(s, 0, l)\n\tfor i := range k {\n\t\ttempK := decrease(k, i, l)\n\t\tif reflect.DeepEqual(s, tempK) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc decrease(values []int, pos, l int) []int {\n\tans := make([]int, len(values))\n\tfor i := range ans {\n\t\tans[(i-pos+len(ans))%len(ans)] = (values[i] - values[pos] + l) % l\n\t}\n\treturn ans\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc abs64(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar (\n\treader = bufio.NewReaderSize(os.Stdin, 1<<13)\n\twriter = bufio.NewWriterSize(os.Stdout, 1<<13)\n)\n\nfunc readi() int {\n\treturn int(readi64())\n}\n\nfunc read2i() (int, int) {\n\treturn readi(), readi()\n}\n\nfunc readis(n int) []int {\n\tres := make([]int, n)\n\tfor i := range res {\n\t\tres[i] = readi()\n\t}\n\treturn res\n}\n\nfunc readi64() int64 {\n\tb, err := reader.ReadByte()\n\tfor !isValid(b, err) {\n\t\tb, err = reader.ReadByte()\n\t}\n\tsign, res := int64(1), int64(0)\n\tif b == '-' {\n\t\tsign *= -1\n\t\tb, err = reader.ReadByte()\n\t}\n\tfor isValid(b, err) {\n\t\tres = res*10 + int64(b-'0')\n\t\tb, err = reader.ReadByte()\n\t}\n\treturn res * sign\n}\n\nfunc readline() string {\n\tres := new(bytes.Buffer)\n\tfor {\n\t\tline, isPrefix, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tres.Write(line)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn res.String()\n}\n\nfunc isValid(b byte, err error) bool {\n\treturn err == nil && (('0' <= b && b <= '9') || b == '-')\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "6557815767538c3467454473cf9333d0", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\n\nfunc cmp_slice_int(a, b []int) bool {\n\tla, lb := len(a), len(b)\n\tif la != lb {\n\t\treturn false\n\t}\n\tfor i, v := range a {\n\t\tif v != b[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc main() {\n\tvar n, l int\n\tfmt.Scanln(&n, &l)\n\n\ta := make([]int, n, n)\n\tb := make([]int, n, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&b[i])\n\t}\n\n\tfor i := 0; i < l; i++ {\n\t\tif cmp_slice_int(a, b) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\tfor j := 0; j < n; j++ {\n\t\t\ta[j]++\n\t\t}\n\t\tif a[n-1] >= l {\n\t\t\ta = append(a[n-1:], a[:n-1]...)\n\t\t\ta[0] = a[0] % l\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "fe91d78d8312d3224f2de04da8b023f9", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\tL := sc.NextInt()\n\n\tA := sc.NextIntArray()\n\tB := sc.NextIntArray()\n\n\tdA := make([]int, N)\n\tdB := make([]int, N)\n\n\tfor i := 0; i < N; i++ {\n\t\tdA[i] = (L + A[(N + i + 1) % N] - A[i]) % L\n\t}\n\tfor i := 0; i < N; i++ {\n\t\tdB[i] = (L + B[(N + i + 1) % N] - B[i]) % L\n\t}\n\n\tfor i := 0; i < N; i++ {\n\t\tok := true\n\t\tfor j := 0; j < N; j++ {\n\t\t\tif dA[(i + j) % N] != dB[j] {\n\t\t\t\tok = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif ok {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "cac7470969cfc583601383dce1e81912", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc canReach(a, b, c int) bool {\n\tif b == 0 && c == 1 {\n\t\treturn false\n\t}\n\tif c == 0 && b == 1 {\n\t\treturn false\n\t}\n\tif a > 0 {\n\t\treturn true\n\t}\n\tif b > 0 && c > 0 {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tcounts := [3]int{}\n\n\tvar s string\n\tfmt.Scan(&s)\n\tfor _, r := range s {\n\t\tswitch r {\n\t\tcase 'R':\n\t\t\tcounts[0]++\n\t\tcase 'G':\n\t\t\tcounts[1]++\n\t\tcase 'B':\n\t\t\tcounts[2]++\n\t\t}\n\t}\n\n\tif canReach(counts[2], counts[1], counts[0]) {\n\t\tfmt.Print(\"B\")\n\t}\n\tif canReach(counts[1], counts[0], counts[2]) {\n\t\tfmt.Print(\"G\")\n\t}\n\tif canReach(counts[0], counts[1], counts[2]) {\n\t\tfmt.Print(\"R\")\n\t}\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "4334e86a8713ec4b132bad22a990b6ab", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar mem [205][205][205]bool\n\nfunc can(r, g, b int) {\n\tif mem[r][g][b] {\n\t\treturn\n\t}\n\tmem[r][g][b] = true\n\tif r >= 1 && g >= 1 {\n\t\tcan(r-1, g-1, b+1)\n\t}\n\tif r >= 1 && b >= 1 {\n\t\tcan(r-1, g+1, b-1)\n\t}\n\tif g >= 1 && b >= 1 {\n\t\tcan(r+1, g-1, b-1)\n\t}\n\tif r >= 2 {\n\t\tcan(r-1, g, b)\n\t}\n\tif g >= 2 {\n\t\tcan(r, g-1, b)\n\t}\n\tif b >= 2 {\n\t\tcan(r, g, b-1)\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar s string\n\tfmt.Scan(&s)\n\tvar r, g, b int\n\tfor _, c := range s {\n\t\tswitch c {\n\t\tcase 'B':\n\t\t\tb++\n\t\tcase 'G':\n\t\t\tg++\n\t\tcase 'R':\n\t\t\tr++\n\t\tdefault:\n\t\t\tpanic(c)\n\t\t}\n\t}\n\n\tcan(r, g, b)\n\n\tvar res []byte\n\tif mem[0][0][1] {\n\t\tres = append(res, 'B')\n\t}\n\tif mem[0][1][0] {\n\t\tres = append(res, 'G')\n\t}\n\tif mem[1][0][0] {\n\t\tres = append(res, 'R')\n\t}\n\tfmt.Printf(\"%s\\n\", res)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "c43aa7fc1fa3b11599814848757a56ba", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\ntype State struct {\n B, G, R int\n}\n\nvar queue = []*State{}\nvar seen = make([]bool, 201 * 201 * 201)\n\nfunc push(b, g, r int) {\n i := 201 * 201 * b + 201 * g + r\n if seen[i] {\n return\n }\n seen[i] = true\n queue = append(queue, &State{ b, g, r })\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n _ = getI()\n s := getS()\n b, g, r := 0, 0, 0\n for _, ch := range s {\n if ch == 'B' {\n b++\n } else if ch == 'G' {\n g++\n } else {\n r++\n }\n }\n push(b, g, r)\n tail := 0\n for tail < len(queue) {\n x := queue[tail]\n tail++\n b, g, r = x.B, x.G, x.R\n if b > 0 && g > 0 {\n push(b - 1, g - 1, r + 1)\n }\n if b > 0 && r > 0 {\n push(b - 1, g + 1, r - 1)\n }\n if g > 0 && r > 0 {\n push(b + 1, g - 1, r - 1)\n }\n if b > 1 {\n push(b - 1, g, r)\n }\n if g > 1 {\n push(b, g - 1, r)\n }\n if r > 1 {\n push(b, g, r - 1)\n }\n }\n\n if seen[201 * 201] {\n writer.WriteString(\"B\")\n }\n if seen[201] {\n writer.WriteString(\"G\")\n }\n if seen[1] {\n writer.WriteString(\"R\")\n }\n writer.WriteString(\"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "9c0233bae053cc42073ce8d51b1e4e34", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n\nvar writer *bufio.Writer\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tini()\n\tdefer writer.Flush()\n\n\tn := scanString()\n\tk := scanInt()\n\n\tcntZeros := strings.Count(n, \"0\")\n\n\tif cntZeros < k {\n\t\twriter.WriteString(strconv.Itoa(len(n)-1))\n\t\treturn\n\t}\n\n\tresult := 0\n\tcnt:= 0\n\tfor i:=len(n)-1; i>=0; i-- {\n\t\tif n[i] == '0' {\n\t\t\tcnt++\n\t\t} else {\n\t\t\tresult++\n\t\t}\n\n\t\tif cnt == k {\n\t\t\tbreak\n\t\t}\n\t}\n\twriter.WriteString(strconv.Itoa(result))\n\n\n\n\treturn\n\n\n}\n\nfunc ini() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc scanInt() int {\n\tscanner.Scan()\n\ti, _ := strconv.Atoi(scanner.Text())\n\treturn i\n}\n\nfunc scanString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "dbf245f2f77faff47889a022572e088a", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tre := regexp.MustCompile(`\\r?\\n`)\n\n\tif s, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tnk := strings.Split(re.ReplaceAllString(s, \"\"), \" \")\n\t\tn := nk[0]\n\t\tl := len(n)\n\t\tk, err := strconv.Atoi(nk[1])\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tremove := 0\n\t\tcnt_0 := 0\n\t\tfor i := l - 1; i >= 0; i-- {\n\t\t\tif n[i] == '0' {\n\t\t\t\tcnt_0++\n\t\t\t\tif cnt_0 == k {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tremove++\n\t\t\t}\n\t\t}\n\n\t\tif cnt_0 < k {\n\t\t\tfmt.Println(l - 1)\n\t\t} else {\n\t\t\tfmt.Println(remove)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "bd4ad4b127a6f6af81235f284fc5dcc5", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n\nfunc main(){\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\tresult := 0\n\tcount := 0\n\tx := n\n\tfor ; k != 0 && n != 0; {\n\t\tif n % 10 != 0{\n\t\t\tresult++\n\t\t} else{\n\t\t\tk--\n\t\t}\n\t\tcount++\n\t\tn /= 10\n\t}\n\tif k != 0 && x != 0{\n\t\tfmt.Println(count-1)\n\t} else{\n\t\tfmt.Println(result)\n\t}\n}\n\n\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "a96e7cb11b870bb95d782a430b8f5df2", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar stones string \n\tfmt.Scan(&stones)\n\tvar instructions string\n\tfmt.Scan(&instructions)\n\tsteps := 0\n\n\tfor index :=0;index < len(instructions); index++ {\n\t\tif stones[steps] == instructions[index] {\n\t\t\tsteps++\n\t\t}\n\t}\n\tfmt.Print(steps+1);\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b58d99aa5af8bb5b47a9ed7636b706fb", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s,t string\n fmt.Scan(&s)\n fmt.Scan(&t)\n pos := 0\n for i := 0; i < len(t); i++ {\n if t[i] == s[pos] {\n pos++\n }\n }\n fmt.Println(pos+1)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2fd321f73e9631064230d4f940d07dc6", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a,b string\n\tvar p int\n\tfmt.Scan(&a,&b)\n\tfor i:=0;i>= 1\n\t}\n\treturn int64(a)\n}\nfunc main() {\n\tvar a, x, c int64\n\tfmt.Scan(&a, &x)\n\tc = pow(3, a, x)\n\tfmt.Println((c - 1 + x) % x)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "ed38d0d8a640d6c4c53b2ce5301ef53c", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 226A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc pow(x, n, mod int64) int64 {\n\tvar a, t int64\n\ta = 1\n\tt = x\n\tfor n != 0 {\n\t\tif n&1 == 1 {\n\t\t\ta = (a * t) % mod\n\t\t}\n\t\tt = (t * t) % mod\n\t\tn >>= 1\n\t}\n\treturn int64(a)\n}\nfunc main() {\n\tvar a, x, c int64\n\tfmt.Scan(&a, &x)\n\tc = pow(3, a, x)\n\tfmt.Println((c - 1 + x) % x)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "61d8d307bfcccbf749ce5c936a2c5f99", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nvar memo map[int64]int64\n\nfunc pow3(n, m int64) int64 {\n\tx, present := memo[n]\n\tif present {\n\t\treturn x\n\t}\n\tx = (pow3(n/2, m) * pow3(n-n/2, m)) % m\n\tmemo[n] = x\n\treturn x\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tn := int64(scanInt(scanner))\n\tm := int64(scanInt(scanner))\n\tmemo = map[int64]int64{ 0: 1%m, 1: 3%m }\n\tx := pow3(n, m) - 1\n\tif x == -1 {\n\t\tx = m-1\n\t}\n\twriter.WriteString(fmt.Sprintf(\"%d\\n\", x))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "a9cfc95f8ea17b2384acb26c01e9e080", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\ta1, a2, a3, a4, a5, a6 := nextInt(), nextInt(), nextInt(), nextInt(), nextInt(), nextInt()\n\tcnt := 0\n\n\tfor i := 0; i < min(a1, a3); i++ {\n\t\tcnt += 1 + 2*a2\n\t\ta2++\n\t}\n\n\tcnt += a2 * 2 * (max(a1, a3) - min(a1, a3))\n\n\tfor i := 0; i < min(a4, a6); i++ {\n\t\tcnt += 1 + 2*a5\n\t\ta5++\n\t}\n\n\tprintln(cnt)\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["geometry"], "code_uid": "6b273ccd23bad8d9971e7330eac11d2d", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/559/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc s(x int) int {\n\treturn x * x\n}\n\nfunc Solve(a1, a2, a3, a4, a5, a6 int) int {\n\treturn s(a1+a2+a3) - s(a1) - s(a3) - s(a5)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar a1, a2, a3, a4, a5, a6 int\n\tfmt.Fscanf(reader, \"%d %d %d %d %d %d\\n\", &a1, &a2, &a3, &a4, &a5, &a6)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(a1, a2, a3, a4, a5, a6))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "765328401c3b0ecd4b9c2617da6235e2", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\t// f, _ := os.Open(\"input.txt\")\n\tf := os.Stdin\n\tvar a1, a2, a3, a4, a5, a6 int\n\tfmt.Fscanf(f, \"%d %d %d %d %d %d\", &a1, &a2, &a3, &a4, &a5, &a6)\n\tfmt.Println((a1+a2+a3)*(a1+a2+a3) - a1*a1 - a3*a3 - a5*a5)\n}\n", "lang_cluster": "Go", "tags": ["geometry"], "code_uid": "4e78e73e348b6316496ad5a7b94e3d63", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/235/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Solve(n int64) int64 {\n\tif n == 1 {\n\t\treturn 1\n\t} else if n == 2 {\n\t\treturn 2\n\t} else if n == 3 {\n\t\treturn 6\n\t}\n\tif n%2 == 1 {\n\t\treturn n * (n - 1) * (n - 2)\n\t} else if n%2 == 0 && n%3 == 0 {\n\t\treturn (n - 1) * (n - 2) * (n - 3)\n\t}\n\treturn n * (n - 1) * (n - 3)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int64\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n))\n}\n", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "9c3e83122ad71b904d019766e808bd8a", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc GCD(a,b int64) int64 { if b == 0 { return a } else { return GCD(b,a%b) } }\nfunc LCM(a,b int64) int64 { return (a/GCD(a,b))*b }\n\nfunc main() {\n var n int64\n fmt.Scan(&n)\n ans := int64(1);\n if n <= 3 {\n for ; n > 0; n-- { ans *= n }\n\n } else if n%2 == 1 {\n for i := int64(0); i < 3; i++ {\n ans = LCM(ans,n-i)\n }\n } else {\n var s int64\n if n-50 > 0 { s = n-50 } else { s = 0 }\n for i := s; i <= n; i++ {\n for j := i+1; j <= n; j++ {\n for k := j+1; k <= n; k++ {\n tmp := LCM(i,LCM(j,k))\n if ans < tmp { ans = tmp }\n }\n }\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "6639c384efe325db2ba02f65c138d9f3", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var pass,code string\n fmt.Scan(&pass)\n digit := make(map[string]int)\n for i := 0; i < 10; i++ {\n fmt.Scan(&code)\n digit[code] = i\n }\n for i := 0; i < 8; i++ {\n a := pass[i*10:(i+1)*10]\n fmt.Print(digit[a])\n }\n fmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "630b0a3db85eaaa1916db614d15779bb", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var pass,code string\n fmt.Scan(&pass)\n digit := make(map[string]int)\n for i := 0; i < 10; i++ {\n fmt.Scan(&code)\n digit[code] = i\n }\n for i := 0; i < 8; i++ {\n a := pass[i*10:(i+1)*10]\n fmt.Print(digit[a])\n }\n fmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "c58e37471cd127d75b46039000aed88c", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var pass,code string\n fmt.Scan(&pass)\n digit := make(map[string]int)\n for i := 0; i < 10; i++ {\n fmt.Scan(&code)\n digit[code] = i\n }\n for i := 0; i < 8; i++ {\n a := pass[i*10:(i+1)*10]\n fmt.Print(digit[a])\n }\n fmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "be5c0db64fc4598a5270cc678d980534", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nvar MOD int64 = 1000000007\n\nfunc sum(x, y int64) int64 {\n\tif y == 1 {\n\t\treturn x\n\t}\n\n\tif y == 0 {\n\t\treturn 1\n\t}\n\n\tif y%2 == 1 {\n\t\treturn sum(x, y-1) * x % MOD\n\t}\n\n\ttmp := sum(x, y/2)\n\treturn tmp * tmp % MOD\n}\n\nfunc calc(a int64, b int64) int64 {\n\tvar num int64\n\n\tnum = 0\n\tfor a > 0 {\n\t\tnum = num + a/b\n\t\ta = a / b\n\t}\n\n\treturn sum(b, num)\n}\n\nvar set []int = make([]int, 0, 1000)\n\nfunc prime(p int) {\n\tm := int(math.Sqrt(float64(p + 1)))\n\tfor i := 2; i <= m && i <= p; i++ {\n\t\tif p%i == 0 {\n\t\t\tset = append(set, i)\n\n\t\t\tfor p%i == 0 {\n\t\t\t\tp = p / i\n\t\t\t}\n\t\t}\n\t}\n\n\tif p != 1 {\n\t\tset = append(set, p)\n\t}\n}\n\nfunc main() {\n\tvar x, n int64\n\tfmt.Scanf(\"%d %d\\n\", &x, &n)\n\n\tprime(int(x))\n\n\tvar ans int64 = 1\n\tfor _, v := range set {\n\t\tans = ans * calc(n, int64(v)) % MOD\n\t}\n\n\tfmt.Printf(\"%d\\n\", ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "4765db9f4300d33fd5248746c2b05273", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1228C(_r io.Reader, _w io.Writer) {\n\tconst mod int64 = 1e9 + 7\n\tpow := func(x, n int64) int64 {\n\t\tres := int64(1)\n\t\tfor ; n > 0; n >>= 1 {\n\t\t\tif n&1 == 1 {\n\t\t\t\tres = res * x % mod\n\t\t\t}\n\t\t\tx = x * x % mod\n\t\t}\n\t\treturn res\n\t}\n\tvar x int\n\tvar n int64\n\tFscan(_r, &x, &n)\n\tprimes := []int64{}\n\tfor i := 2; i*i <= x; i++ {\n\t\tk := 0\n\t\tfor ; x%i == 0; x /= i {\n\t\t\tk++\n\t\t}\n\t\tif k > 0 {\n\t\t\tprimes = append(primes, int64(i))\n\t\t}\n\t}\n\tif x > 1 {\n\t\tprimes = append(primes, int64(x))\n\t}\n\tans := int64(1)\n\tfor _, p := range primes {\n\t\tc := int64(0)\n\t\tfor m := n; m > 0; m /= p {\n\t\t\tc += m / p\n\t\t}\n\t\tans = ans * pow(p, c) % mod\n\t}\n\tFprint(_w, ans)\n}\n\nfunc main() { CF1228C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "47a16b391d3337d847d680708aa495ed", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// DigitSum returns digit sum of a decimal number.\n// DigitSum only accept a positive integer.\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\n// DigitNumOfDecimal returns digits number of n.\n// n is non negative number.\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of `strconv.Atoi()`.\n// If `strconv.Atoi()` returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar x, n int64\n\nfunc main() {\n\tx, n = ReadInt64_2()\n\n\tprimes := TrialDivision(int(x))\n\n\tans := int64(1)\n\tfor p := range primes {\n\t\tprod := int64(1)\n\t\tfor {\n\t\t\tif isOverflow(prod, int64(p)) {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tprod *= int64(p)\n\t\t\tif n < prod {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tnum := int64(n / prod)\n\n\t\t\ttmp := modpow(int64(p), num, MOD)\n\t\t\tans *= tmp\n\t\t\tans %= MOD\n\t\t}\n\t}\n\n\tfmt.Println(ans % MOD)\n}\n\nfunc isOverflow(i, j int64) bool {\n\treturn !(i < math.MaxInt64/j)\n}\n\nfunc modpow(a, e, m int64) int64 {\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := modpow(a, halfE, m)\n\t\treturn half * half % m\n\t}\n\n\treturn a * modpow(a, e-1, m) % m\n}\n\n// TrialDivision returns the result of prime factorization of integer N.\nfunc TrialDivision(n int) map[int]int {\n\tif n <= 1 {\n\t\tpanic(errors.New(\"[argument error]: TrialDivision only accepts a NATURAL number\"))\n\t}\n\n\tp := map[int]int{}\n\tfor i := 2; i*i <= n; i++ {\n\t\texp := 0\n\t\tfor n%i == 0 {\n\t\t\texp++\n\t\t\tn /= i\n\t\t}\n\n\t\tif exp == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tp[i] = exp\n\t}\n\tif n > 1 {\n\t\tp[n] = 1\n\t}\n\n\treturn p\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "a2781e2bc8de7499d3ba6475e4c6bdfe", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\n\tvar n int\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tif n%2 == 0 {\n\t\tfmt.Fprintln(out, \"Mahmoud\")\n\t} else {\n\t\tfmt.Fprintln(out, \"Ehab\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "games"], "code_uid": "a0c055c777716730736a484462bbf5b2", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n\t// FLUSH STDOUT\n\tdefer writer.Flush()\n\n\tvar a int\n\tscanf(\"%d\\n\", &a)\n\n\tif a%2 == 1 {\n\t\tprintf(\"Ehab\\n\")\n\t} else {\n\t\tprintf(\"Mahmoud\\n\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["math", "games"], "code_uid": "3dc25d480dcc09339252f0c9d34488f0", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF959A(in io.Reader, out io.Writer) {\n\tvar n int\n\tif Fscan(in, &n);n&1>0 {\n\t\tFprint(out, \"Ehab\")\n\t} else {\n\t\tFprint(out, \"Mahmoud\")\n\t}\n}\n\nfunc main() { CF959A(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "games"], "code_uid": "d0e34bf9de91307ea09c128e72246a1a", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt()\n\ta := make([]int, n)\n\tcntPair := 0\n\n\tfor i := range a {\n\t\ta[i] = nextInt()\n\t}\n\n\tfor i := range a {\n\t\tif a[i] == 1 {\n\t\t\tcntPair++\n\t\t} else if i > 0 && i < n-1 && a[i-1] == 1 && a[i+1] == 1 {\n\t\t\tcntPair++\n\t\t}\n\t}\n\n\tprintln(cntPair)\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "aa0f145a4b30d1608ba3ff3bdcb8dad2", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"regexp\"\n)\n\n// Node -> node in Linked-List\ntype Node struct {\n\tD int\n\tNext *Node\n}\n\n// Head -> head of Linked-List\ntype Head struct {\n\tFront *Node\n\tBack *Node\n\tC int\n}\n\nfunc (h *Head) createNode(i int) *Node {\n\tvar n *Node = new(Node)\n\tn.D = i\n\tn.Next = nil\n\th.C++\n\treturn n\n}\n\nfunc (h *Head) solve() int {\n\tvar c int\n\th.Back = h.Front\n\tfor i := 0; i < h.C-1; i++ {\n\t\tif (h.Back.Next.D - h.Back.D) == 1 {\n\t\t\tc++\n\t\t} else if (h.Back.Next.D - h.Back.D) == 2 {\n\t\t\tc += 2\n\t\t} else {\n\t\t\tc++\n\t\t}\n\t\th.Back = h.Back.Next\n\t}\n\tif h.C > 0 {\n\t\tc++\n\t}\n\n\treturn c\n}\n\nfunc (h *Head) free() {\n\th.Back = h.Front\n\tfor h.Back != nil {\n\t\th.Front = h.Back.Next\n\t\th.Back.D = 0\n\t\th.Back.Next = nil\n\t\th.Back = h.Front\n\t}\n\th.C = 0\n}\n\nfunc main() {\n\tvar head *Head = new(Head)\n\tvar newNode *Node\n\tvar scanner *bufio.Scanner\n\tvar s string\n\tvar count int = 0\n\n\tscanner = bufio.NewScanner(os.Stdin)\n\thead.Front = nil\n\thead.Back = nil\n\thead.C = 0\n\t// n\n\tscanner.Scan()\n\n\t// data\n\tscanner.Scan()\n\ts = regexp.MustCompile(\"\\\\s*\").ReplaceAllString(scanner.Text(), \"\")\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == '1' {\n\t\t\tnewNode = head.createNode(i + 1)\n\t\t\tif head.Front == nil {\n\t\t\t\thead.Front = newNode\n\t\t\t\thead.Back = newNode\n\t\t\t} else {\n\t\t\t\thead.Back.Next = newNode\n\t\t\t\thead.Back = newNode\n\t\t\t}\n\t\t}\n\t}\n\n\thead.Back = head.Front\n\t// fmt.Println(\"number of node(s):\", head.C)\n\t// for head.Back != nil {\n\t// \tfmt.Printf(\"%d \", head.Back.D)\n\t// \thead.Back = head.Back.Next\n\t// }\n\t// fmt.Println()\n\n\tcount = head.solve()\n\n\tfmt.Println(count)\n\n\thead.free()\n\n\t// fmt.Println(\"number of node(s):\", head.C)\n\t// for head.Back != nil {\n\t// \tfmt.Printf(\"%d \", head.Back.D)\n\t// \thead.Back = head.Back.Next\n\t// }\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "de7561f6bdefdcec7b939aefefa3f908", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\nfunc getLine2Ints(n int) []int {\n\tans := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d \", &ans[i])\n\t}\n\tscanf(\"%d\\n\", &ans[n-1])\n\treturn ans\n}\n\nfunc pcheck(i bool) {\n\tif i {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n\nvar debug = true\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tn := getLine2Int()\n\tinput := getLine2Ints(n)\n\tmin, zero := 0, 2\n\tfor i := 0; i < n; i++ {\n\t\tif input[i] == 0 {\n\t\t\tzero++\n\t\t} else {\n\t\t\tif zero <= 1 {\n\t\t\t\tmin += zero + 1\n\t\t\t} else {\n\t\t\t\tmin++\n\t\t\t}\n\t\t\tzero = 0\n\t\t}\n\t}\n\tprintf(\"%d\\n\", min)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0e0bf4a7f817f01ec15682437bd3ccab", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n a, b := getI(), getI()\n for {\n a++\n x, y := a, b\n for x != 0 {\n d := x%10\n if d == 4 || d == 7 {\n if d == y%10 {\n y /= 10\n } else {\n break\n }\n }\n x /= 10\n }\n if x == 0 && y == 0 {\n break\n }\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", a))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "5114b0453377d83271c8a9f52e923c5e", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n var n,m int\n fmt.Scan(&n,&m)\n var r,d,k int\n for {\n n++\n a1 := n;\n d = 0;\n k = 1;\n for a1 != 0{\n r = a1%10\n if r == 4 || r == 7{\n d = d + k*r\n k = k*10\n }\n a1 = a1/10;\n }\n if d == m {break}\n }\n fmt.Println(n);\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "91b3f5a28f87ce7cca52bab44f5b1385", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n a, b := getI(), getI()\n for {\n a++\n x, y := a, b\n okay := true\n for x != 0 {\n d := x%10\n x /= 10\n if d == 4 || d == 7 {\n if d == y%10 {\n y /= 10\n } else {\n x = 0\n okay = false\n }\n }\n }\n if y == 0 && okay {\n break\n }\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", a))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "b89a22f53195263dea1bda2c3cb18a1a", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"sort\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt()\n\ts := next()\n\ta := make([]int, 0, n)\n\tx := make([]int, 0, n*2)\n\tm := map[int][]int{4:[]int{3, 2, 2}, 6:[]int{5, 3}, 8:[]int{7, 2, 2, 2}, 9:[]int{7, 3, 3, 2}} \n\n\tfor i := range s {\n\t\tif s[i] != '1' && s[i] != '0' {\n\t\t\ta = append(a, int(s[i] - '0'))\n\t\t}\n\t}\n\n\tfor i := range a {\n\t\tif _, ok := m[a[i]]; ok {\n\t\t\tx = append(x, m[a[i]]...)\n\t\t} else {\n\t\t\tx = append(x, a[i])\n\t\t}\n\t}\n\n\tsort.Sort(sort.Reverse(sort.IntSlice(x)))\n\n\tfor i := range x {\n\t\tprint(x[i])\n\t}\n\n\tprintln()\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc print(a ...interface{}) {\n\tfmt.Fprint(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["math", "sortings", "greedy"], "code_uid": "dc2ebaa2d080edd21cf8712f0a805bad", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nfunc main() {\n //io\n scanner := bufio.NewReader(os.Stdin)\n writer := bufio.NewWriter(os.Stdout)\n //---\n var n int\n var used [20]int\n var s string\n fmt.Fscan(scanner, &n)\n fmt.Fscan(scanner, &s)\n \n for i := 0; i < n; i++ {\n a := s[i] - '0'\n if (a % 2 == 1 && a != 9) || a == 2 {\n used[a]++\n } else if a == 4 {\n used[2] += 2\n used[3]++\n } else if a == 6 {\n used[5]++\n used[3]++\n } else if a == 8 {\n used[2] += 3\n used[7]++\n } else if a == 9 {\n used[7]++\n used[3] += 2\n used[2]++\n }\n }\n for i := 9; i > 1; i-- {\n for used[i] > 0 {\n writer.WriteString(strconv.Itoa(i))\n used[i]--\n }\n }\n writer.Flush()\n}", "lang_cluster": "Go", "tags": ["math", "sortings", "greedy"], "code_uid": "367a027ed04f3d4fdc554878a3389a66", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar str string\n\tcnt := make([]int, 10)\n\tfmt.Scanln(&n)\n\tfmt.Scanln(&str)\n\tfor _, ch := range str {\n\t\tswitch ch {\n\t\tcase '9':\n\t\t\tcnt[7] ++\n\t\t\tcnt[3] += 2\n\t\t\tcnt[2] ++\n\t\tcase '8':\n\t\t\tcnt[7] ++\n\t\t\tcnt[2] += 3\n\t\tcase '7':\n\t\t\tcnt[7] ++\n\t\tcase '6':\n\t\t\tcnt[5] ++\n\t\t\tcnt[3] ++\n\t\tcase '5':\n\t\t\tcnt[5] ++\n\t\tcase '4':\n\t\t\tcnt[2] += 2\n\t\t\tcnt[3] ++\n\t\tcase '3':\n\t\t\tcnt[3] ++\n\t\tcase '2':\n\t\t\tcnt[2] ++\n\t\t}\n\t}\n\tfor i := 7; i > 1; i-- {\n\t\tfor j := 0; j m[Ss[i][2]]) {\n\t\t\t\ttmpR = a[m[Ss[i][0]]]\n\t\t\t\ta[m[Ss[i][0]]] = a[m[Ss[i][2]]]\n\t\t\t\ta[m[Ss[i][2]]] = tmpR\n\t\t\t\ttmpI = m[Ss[i][0]]\n\t\t\t\tm[Ss[i][0]] = m[Ss[i][2]]\n\t\t\t\tm[Ss[i][2]] = tmpI\n\t\t\t}\n\t\t}\n\t}\n\tif Ss[0][1] == '<' {\n\t\tif !(m[Ss[0][0]] < m[Ss[0][2]]) {\n\t\t\ttmpR = a[m[Ss[0][0]]]\n\t\t\ta[m[Ss[0][0]]] = a[m[Ss[0][2]]]\n\t\t\ta[m[Ss[0][2]]] = tmpR\n\t\t\ttmpI = m[Ss[0][0]]\n\t\t\tm[Ss[0][0]] = m[Ss[0][2]]\n\t\t\tm[Ss[0][2]] = tmpI\n\t\t}\n\t} else {\n\t\tif !(m[Ss[0][0]] > m[Ss[0][2]]) {\n\t\t\ttmpR = a[m[Ss[0][0]]]\n\t\t\ta[m[Ss[0][0]]] = a[m[Ss[0][2]]]\n\t\t\ta[m[Ss[0][2]]] = tmpR\n\t\t\ttmpI = m[Ss[0][0]]\n\t\t\tm[Ss[0][0]] = m[Ss[0][2]]\n\t\t\tm[Ss[0][2]] = tmpI\n\t\t}\n\t}\n\tif Ss[1][1] == '<' {\n\t\tif !(m[Ss[1][0]] < m[Ss[1][2]]) {\n\t\t\tfmt.Println(\"Impossible\")\n\t\t} else {\n\t\t\tfor i := 0; i < 3; i++ {\n\t\t\t\tfmt.Printf(\"%c\", a[i])\n\t\t\t}\n\t\t\tfmt.Println()\n\t\t}\n\t} else {\n\t\tif !(m[Ss[1][0]] > m[Ss[1][2]]) {\n\t\t\tfmt.Println(\"Impossible\")\n\t\t} else {\n\t\t\tfor i := 0; i < 3; i++ {\n\t\t\t\tfmt.Printf(\"%c\", a[i])\n\t\t\t}\n\t\t\tfmt.Println()\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f1fcad284e48bc0dd0da48136e8fb851", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar(\n\t\ta1, a2, a3 int\n\t\tb1, b2, b3 int\n\t\tn int\n\t\ta, b int\n\t\tan, bn int\n\t)\n\tfmt.Scanln(&a1, &a2, &a3)\n\tfmt.Scanln(&b1, &b2, &b3)\n\tfmt.Scanln(&n)\n\ta = a1 + a2 + a3\n\tb = b1 + b2 + b3\n\tif a%5 == 0 {\n\t\tan = a/5\n\t}else {\n\t\tan = a/5 + 1\n\t}\n\n\tif b%10 == 0 {\n\t\tbn = b/10\n\t}else{\n\t\tbn = b/10 + 1\n\t}\n\n\tif (an+bn) <= n {\n\t\tfmt.Println(\"YES\")\n\t}else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "bb58f2b8fddd597ae8fa16db31bb207b", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b [3]int64\n\tfor i := range a {\n\t\tfmt.Scan(&a[i])\n\t}\n\tfor i := range b {\n\t\tfmt.Scan(&b[i])\n\t}\n\tvar n int64\n\tfmt.Scan(&n)\n\tvar sa, sb int64\n\tfor i := range a {\n\t\tsa += a[i]\n\t\tsb += b[i]\n\t}\n\tvar res string\n\tif (sa+4)/5+(sb+9)/10 <= n {\n\t\tres = \"YES\"\n\t} else {\n\t\tres = \"NO\"\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "783eeea05c510ad8809b23d5251f6926", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a1, a2, a3, b1, b2, b3 int\n\tfmt.Scan(&a1)\n\tfmt.Scan(&a2)\n\tfmt.Scan(&a3)\n\tfmt.Scan(&b1)\n\tfmt.Scan(&b2)\n\tfmt.Scan(&b3)\n\tvar n int\n\tfmt.Scan(&n)\n\ta := a1 + a2 + a3\n\tb := b1 + b2 + b3\n\n\tcupsDone := false\n\tmedalsDone := false\n\tfor {\n\t\tif n < 0 {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tif b <= 0 {\n\t\t\tmedalsDone = true\n\t\t}\n\t\tif medalsDone == false {\n\t\t\tb = b - 10\n\t\t\tn = n - 1\n\t\t\tcontinue\n\t\t}\n\t\tif a <= 0 {\n\t\t\tcupsDone = true\n\t\t}\n\t\tif cupsDone == false {\n\t\t\ta = a - 5\n\t\t\tn = n - 1\n\t\t\tcontinue\n\t\t}\n\t\tif cupsDone && medalsDone {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(\"YES\")\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "3499e96e15f07820442df35e8696d5ea", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar t, s, x int\n\tfmt.Scan(&t, &s, &x)\n\n\tif t == x {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfor k := t + s; k <= x; k += s {\n\t\tif k == x || k + 1 == x {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "3e98e79946f3f633e64d026d881a5d97", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var t, s, x int;\n fmt.Scanf(\"%d %d %d\\n\", &t, &s, &x);\n //fmt.Printf(\"??????????\\n\");\n delta := x - t;\n cnt := delta / s;\n re := delta % s;\n if delta < 0 {\n fmt.Println(\"NO\");\n } else if re == 0 {\n fmt.Println(\"YES\");\n } else if cnt > 0 && (re == 1) {\n fmt.Println(\"YES\");\n } else {\n fmt.Println(\"NO\");\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "33a1ec1b6b880ec1d133cdbfa3edfd52", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var t,s,x int\n fmt.Scan(&t, &s, &x)\n if x < t {\n fmt.Print(\"NO\")\n return\n } else if x == t {\n fmt.Print(\"YES\")\n return\n }\n x -= t\n if x < s {\n fmt.Print(\"NO\")\n return\n }\n if x % s == 0 || x % s == 1 {\n fmt.Print(\"YES\")\n } else {\n fmt.Print(\"NO\")\n }\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "a8688a0da521b0572436e70d9ec54a24", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\"fmt\")\n\nfunc min(x , y int)int {\n\tif (x= b {\n canDetermine = true\n updown = \"DOWN\"\n } else {\n canDetermine = true\n updown = \"UP\"\n }\n if canDetermine {\n fmt.Print(updown)\n } else {\n fmt.Print(-1)\n }\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fbb0254e36eeefeff01488b94466fc76", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(t interface{}, delim string) {\n\tfmt.Fscanf(r, \"%v\"+delim, t)\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar r *bufio.Reader\nvar w *bufio.Writer\n\nfunc main() {\n\tr = bufio.NewReader(os.Stdin)\n\tw = bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\n\tvar n int\n\n\tI(&n, \"\\n\")\n\td := make([]int, n)\n\tfor i := range d {\n\t\tI(&d[i], \" \")\n\t}\n\tif d[0] != 0 && d[0] != 15 && n == 1 {\n\t\tO(\"-1\", \"\\n\")\n\t} else {\n\t\tif d[n-1] == 0 {\n\t\t\tO(\"UP\", \"\\n\")\n\t\t} else if d[n-1] == 15 {\n\t\t\tO(\"DOWN\", \"\\n\")\n\t\t} else if d[n-1]-d[n-2] > 0 {\n\t\t\tO(\"UP\", \"\\n\")\n\t\t} else if d[n-1]-d[n-2] < 0 {\n\t\t\tO(\"DOWN\", \"\\n\")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "8eaba2f1483b6ce1d3a3e2096f9c26d2", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\tA := sc.NextIntArray()\n\tswitch {\n\tcase A[len(A) - 1] == 15:\n\t\tfmt.Println(\"DOWN\")\n\tcase A[len(A) - 1] == 0:\n\t\tfmt.Println(\"UP\")\n\tcase N == 1:\n\t\tfmt.Println(\"-1\")\n\tcase A[len(A) - 2] < A[len(A) - 1]:\n\t\tfmt.Println(\"UP\")\n\tdefault:\n\t\tfmt.Println(\"DOWN\")\n\t}\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r:rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tresult = append(result, v)\n\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ff3abbda46d238bc88191ab0ab60552b", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var t,a,b string\n rank := map[byte]int{'6':0,'7':1,'8':2,'9':3,'T':4,'J':5,'Q':6,'K':7,'A':8}\n fmt.Scan(&t)\n fmt.Scan(&a,&b)\n if ((a[1] == t[0]) && (b[1] != t[0])) || ((a[1] == b[1]) && (rank[a[0]] > rank[b[0]])) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "50168368822403e5570209f23fc90d38", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 106A-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, b int\n var s, s1, s2 string\n fmt.Scan(&s)\n fmt.Scan(&s1, &s2)\n if s1[0] == 'T' {\n a = 10\n } else if s1[0] == 'J' {\n a = 11\n } else if s1[0] == 'Q' {\n a = 12\n } else if s1[0] == 'K' {\n a = 13\n } else if s1[0] == 'A' {\n a = 14\n } else {\n a = int(s1[0]) - 48\n }\n if s2[0] == 'T' {\n b = 10\n } else if s2[0] == 'J' {\n b = 11\n } else if s2[0] == 'Q' {\n b = 12\n } else if s2[0] == 'K' {\n b = 13\n } else if s2[0] == 'A' {\n b = 14\n } else {\n b = int(s2[0]) - 48\n }\n if s1[1] == s2[1] && a > b {\n fmt.Println(\"YES\")\n } else if string(s1[1]) == s && string(s2[1]) != s {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d94759203fc5e277edde292ea49c47dc", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var t,a,b string\n rank := map[byte]int{'6':0,'7':1,'8':2,'9':3,'T':4,'J':5,'Q':6,'K':7,'A':8}\n fmt.Scan(&t)\n fmt.Scan(&a,&b)\n if ((a[1] == t[0]) && (b[1] != t[0])) || ((a[1] == b[1]) && (rank[a[0]] > rank[b[0]])) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "af403330906ecf22b8d0d4ba660f65a6", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1528B(_r io.Reader, out io.Writer) {\r\n\tin := bufio.NewReader(_r)\r\n\tconst mod = 998244353\r\n\tconst mx int = 1e6\r\n\td := [mx + 1]int{}\r\n\tfor i := 1; i <= mx; i++ {\r\n\t\tfor j := i; j <= mx; j += i {\r\n\t\t\td[j]++\r\n\t\t}\r\n\t}\r\n\r\n\tvar n int\r\n\tFscan(in, &n)\r\n\ts := int64(d[n])\r\n\tfor i, p2 := n-1, int64(1); i > 0; i-- {\r\n\t\ts = (s + p2*int64(d[i])) % mod\r\n\t\tp2 = p2 << 1 % mod\r\n\t}\r\n\tFprint(out, s)\r\n}\r\n\r\nfunc main() { CF1528B(os.Stdin, os.Stdout) }\r\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "28b414ff01a0ad585f7c703a0ee246d6", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype Scanner struct {\n\tbScanner *bufio.Scanner\n}\n\nfunc NewScanner() *Scanner {\n\tbScanner := bufio.NewScanner(os.Stdin)\n\tbScanner.Split(bufio.ScanWords)\n\tbScanner.Buffer([]byte{}, math.MaxInt32)\n\treturn &Scanner{\n\t\tbScanner,\n\t}\n}\nfunc (s *Scanner) Next() string {\n\ts.bScanner.Scan()\n\treturn s.bScanner.Text()\n}\nfunc (s *Scanner) NextInt() int {\n\ts.bScanner.Scan()\n\tres, err := strconv.Atoi(s.bScanner.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\nfunc (s *Scanner) NextInt64() int64 {\n\ts.bScanner.Scan()\n\tres, err := strconv.ParseInt(s.bScanner.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\nfunc (s *Scanner) NextFloat() float64 {\n\ts.bScanner.Scan()\n\tres, err := strconv.ParseFloat(s.bScanner.Text(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\nfunc (s *Scanner) NextInts(N int) []int {\n\tres := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tres[i] = s.NextInt()\n\t}\n\treturn res\n}\nfunc (s *Scanner) NextInt64s(N int) []int64 {\n\tres := make([]int64, N)\n\tfor i := 0; i < N; i++ {\n\t\tres[i] = s.NextInt64()\n\t}\n\treturn res\n}\nfunc Min(nums ...int) int {\n\tans := math.MaxInt32\n\tfor _, num := range nums {\n\t\tif num < ans {\n\t\t\tans = num\n\t\t}\n\t}\n\treturn ans\n}\nfunc Max(nums ...int) int {\n\tans := math.MinInt32\n\tfor _, num := range nums {\n\t\tif num > ans {\n\t\t\tans = num\n\t\t}\n\t}\n\treturn ans\n}\n\nfunc InitInts1D(n int, val int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = val\n\t}\n\treturn res\n}\nfunc InitInts2D(n, m int, val int) [][]int {\n\tres := make([][]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = InitInts1D(m, val)\n\t}\n\treturn res\n}\nfunc InitInts3D(n, m, k int, val int) [][][]int {\n\tres := make([][][]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = InitInts2D(m, k, val)\n\t}\n\treturn res\n}\n\ntype StepState struct {\n\tstep, dist int\n}\ntype PriorityQueue []*StepState\n\nfunc (pq PriorityQueue) Len() int { return len(pq) }\nfunc (pq PriorityQueue) Less(i, j int) bool {\n\tif pq[i].step != pq[j].step {\n\t\treturn pq[i].step < pq[j].step\n\t}\n\treturn pq[i].dist < pq[j].dist\n}\nfunc (pq PriorityQueue) Swap(i, j int) {\n\tpq[i], pq[j] = pq[j], pq[i]\n}\nfunc (pq *PriorityQueue) Push(x interface{}) {\n\titem := x.(*StepState)\n\t*pq = append(*pq, item)\n}\nfunc (pq *PriorityQueue) Pop() interface{} {\n\told := *pq\n\tn := len(old)\n\titem := old[n-1]\n\t*pq = old[0 : n-1]\n\treturn item\n}\n\nconst (\n\tMOD = 998244353\n)\n\nvar (\n\tsmlDiv []int\n)\n\ntype fact struct {\n\tbase, exp int\n}\n\nfunc cntFact(n int) int {\n\trem := n\n\tfacts := make([]fact, 0)\n\tfor rem > 1 {\n\t\tcurSmlDiv := smlDiv[rem]\n\t\tif len(facts) == 0 || facts[len(facts)-1].base != curSmlDiv {\n\t\t\tfacts = append(facts, fact{base: curSmlDiv, exp: 1})\n\t\t} else {\n\t\t\tfacts[len(facts)-1].exp++\n\t\t}\n\n\t\trem /= curSmlDiv\n\t}\n\n\tresult := int64(1)\n\tfor _, fact := range facts {\n\t\tresult = (result * int64(fact.exp+1)) % MOD\n\t}\n\treturn int(result)\n}\n\nfunc pow(a, b int) int {\n\tif b == 0 {\n\t\treturn 1\n\t} else if b%2 == 1 {\n\t\treturn int(int64(pow(a, b-1)) * int64(a) % MOD)\n\t} else {\n\t\thalf := int64(pow(a, b/2))\n\t\treturn int(half * half % MOD)\n\t}\n}\n\nfunc main() {\n\tsc := NewScanner()\n\twr := bufio.NewWriter(os.Stdout)\n\tdefer wr.Flush()\n\n\tN := sc.NextInt()\n\n\tsmlDiv = InitInts1D(N+1, -1)\n\tsmlDiv[1] = 1\n\tfor i := 2; i <= N; i++ {\n\t\tif smlDiv[i] != -1 {\n\t\t\tcontinue\n\t\t}\n\t\tsmlDiv[i] = i\n\t\tfor j := int64(i) * int64(i); j <= int64(N); j += int64(i) {\n\t\t\tif smlDiv[j] == -1 {\n\t\t\t\tsmlDiv[j] = i\n\t\t\t}\n\t\t}\n\t}\n\n\tans := int64(0)\n\tfor i := 1; i <= N; i++ {\n\t\t// fmt.Println(cntFact(i), pow(2, N-i-1))\n\t\tans = (ans + int64(cntFact(i))*int64(pow(2, N-i-1))) % MOD\n\t}\n\n\tfmt.Fprintln(wr, ans)\n\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "22c9e53e0f347afe1febedfa3795c220", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n)\n\n// var m []int\n// err = json.Unmarshal([]byte(r.FormValue(\"example\")), &m)\n\n// for i := 0; i < len(m); i++ {\n// \tfmt.Println(m[i])\n// }\n\n// sort.Slice(arr, func(i, j int) bool {\n// \treturn arr[i] > arr[j]\n// })\n\nfunc MIN(x, y int64) int64 {\n\tif x > y {\n\t\treturn y\n\t} else {\n\t\treturn x\n\t}\n}\n\nfunc MKO(x, y int64) int64 {\n\tif x < y {\n\t\treturn 0\n\t} else {\n\t\treturn x - y + 1\n\t}\n}\n\nfunc MAX(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc LCM(x, y int) int {\n\tif x >= y {\n\t\tinitial := x\n\t\tfor i := 1; i < y+2; i++ {\n\t\t\tif initial%y == 0 {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tinitial = initial + x\n\t\t\t}\n\n\t\t}\n\t\treturn initial\n\t} else {\n\t\tinitial := y\n\t\tfor i := 1; i < x+2; i++ {\n\t\t\tif initial%x == 0 {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tinitial = initial + y\n\t\t\t}\n\n\t\t}\n\t\treturn initial\n\t}\n}\n\nfunc GCD(x, y int64) int64 {\n\tvar l, q int64\n\tl = MAX(x, y)\n\tq = MIN(x, y)\n\tvar m int64\n\tfor l*q > 0 {\n\t\ta := l % q\n\t\tb := l - a\n\t\tcc := int64(b / q)\n\t\tremain := l - cc*q\n\t\tl = MAX(remain, q)\n\t\tq = MIN(remain, q)\n\t\tif l*q == 0 {\n\t\t\tm = l + q\n\t\t\tbreak\n\t\t}\n\n\t}\n\treturn m\n\n}\n\nfunc IsItPrime(x int) bool {\n\tif x < 10 {\n\t\tif x == 2 || x == 3 || x == 5 || x == 7 {\n\t\t\treturn true\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\tj := 0\n\t\tk := math.Sqrt(float64(x))\n\t\tfor m := 3; m <= int(k); {\n\t\t\tif x%m == 0 {\n\t\t\t\tj = 1\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tm = m + 2\n\t\t}\n\t\tif j == 1 {\n\t\t\treturn false\n\t\t} else {\n\t\t\treturn true\n\t\t}\n\t}\n\n}\n\nfunc PrimeFactorization(n int) (pfs map[int]int) {\n\tpfs = make(map[int]int)\n\n\t// Get the number of 2s that divide n\n\tfor n%2 == 0 {\n\t\tif _, ok := pfs[2]; ok {\n\t\t\tpfs[2] += 1\n\t\t} else {\n\t\t\tpfs[2] = 1\n\t\t}\n\t\tn = n / 2\n\t}\n\n\t// n must be odd at this point. so we can skip one element\n\t// (note i = i + 2)\n\tfor i := 3; i*i <= n; i = i + 2 {\n\t\t// while i divides n, append i and divide n\n\t\tfor n%i == 0 {\n\t\t\tif _, ok := pfs[i]; ok {\n\t\t\t\tpfs[i] += 1\n\t\t\t} else {\n\t\t\t\tpfs[i] = 1\n\t\t\t}\n\t\t\tn = n / i\n\t\t}\n\t}\n\n\t// This condition is to handle the case when n is a prime number\n\t// greater than 2\n\tif n > 2 {\n\t\tpfs[n] = 1\n\t}\n\n\treturn\n}\n\nfunc NumberOfDivisors(n int) int {\n\tpfs := PrimeFactorization(n)\n\n\tnum := 1\n\tfor _, exponents := range pfs {\n\t\tnum *= (exponents + 1)\n\t}\n\n\treturn num\n}\n\nfunc LITTLE(x int) int64 {\n\tvar answer int64\n\tanswer = answer + int64((x*x*x*x-x*x)/4) + int64(x*x*(x-1)*(x-1)/8) - int64(x*(x-1)*(x+x+1)*(x+x-1)/12)\n\treturn answer\n}\n\nfunc main() {\n\tvar input io.Reader = bufio.NewReader(os.Stdin)\n\n\tvar n int\n\tfmt.Fscan(input, &n)\n\tif n == 1 {\n\t\tfmt.Println(1)\n\t}\n\tARRAY := make([]int64, 0)\n\tARRAY = append(ARRAY, 1)\n\tif n > 1 {\n\t\tvar answer int64\n\t\tanswer = 1\n\n\t\tfor i := 2; i < n+1; i++ {\n\t\t\tqq := int64(NumberOfDivisors(i))\n\t\t\tanswer = (answer*2 + qq - ARRAY[0]) % 998244353\n\t\t\tARRAY[0] = qq\n\n\t\t}\n\t\tfmt.Println(answer)\n\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "9fafdc530299a777e15d415db2217ce2", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc max(x, y int64) int64 {\n if x > y {\n return x\n }\n return y\n}\n\nfunc min(x, y int64) int64 {\n if x < y {\n return x\n }\n return y\n}\n\nfunc main() {\n var n, k int64\n fmt.Scanf(\"%d%d\", &n, &k)\n\n var low, high int64\n if k % 2 == 0 {\n low = k / 2 - 1\n high = k / 2 + 1\n } else {\n low = k / 2\n high = k / 2 + 1\n }\n // fmt.Println(low, high)\n ret := min(max(0, low - 1 + 1), max(0, n - high + 1))\n fmt.Println(ret)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "7275f158293e4150467d420cd9f0f302", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n/*\nvar (\n\ta, b int\n\ts1,s2 string\n)\n\n\nfunc main() {\n\tfmt.Scan(&a,&b)\n\tfmt.Scanln(&s1)\n\tfmt.Scanln(&s2)\n\tif strings.Contains(s1,\"*\") {\n\t\tss := strings.Split(s1,\"*\")\n\t\tl := len(ss[0])\n\t\tif strings.Contains(s2[:l],ss[0])&&strings.Contains(s2[l:],ss[1]){\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t} else {\n\t\tif strings.Contains(s1,s2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n\n}\n*/\n\nvar (\n\tn,k int64\n)\n\nfunc main() {\n\tfmt.Scan(&n,&k)\n\tif k>2*n-1{\n\t\tfmt.Println(0)\n\t} else {\n\t\tif k-1= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "2f4ada40b5f6da2b451e44832001d97f", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc order(x, y *int64) {\n\tif *x < *y {\n\t\t*x, *y = *y, *x\n\t}\n}\n\nfunc main() {\n\tvar a, b, sharps int64\n\tfmt.Scan(&a, &b)\n\n\tfor b > 0 {\n\t\tsharps += a / b\n\t\ta, b = b, a%b\n\t}\n\n\tfmt.Println(sharps)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "018a82467ca1ad8512031adf987f63d7", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc calc(a, b uint64) uint64 {\n if a == 0 || b == 0 {\n return 0\n }\n\n if a < b {\n tmp := a\n a = b\n b = tmp\n }\n\n return a/b + calc(a%b, b)\n}\n\nfunc main() {\n var a, b uint64\n fmt.Scan(&a, &b)\n fmt.Println(calc(a, b))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "8f50faf93db0121cb2377f749afebea2", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n a, b := getI64(), getI64()\n count := int64(0)\n for b != 0 {\n count += a / b\n a, b = b, a % b\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", count))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "0ead005ee45d71439a95dcd9c18f0b4f", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var cd string\n fmt.Scan(&cd)\n if cd == \"a1\" || cd == \"a8\" || cd == \"h1\" || cd == \"h8\" {\n fmt.Print(3)\n return\n }\n if cd[0] == 'a' || cd[0] == 'h' || cd[1] == '1' || cd[1] == '8' {\n fmt.Print(5)\n return\n }\n fmt.Print(8)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5750747ee9c3f96dee116b9656318e92", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// http://codeforces.com/problemset/problem/710/A\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\n\nfunc main() {\n\tvar c rune\n\tvar d int\n\n\tfmt.Scanf(\"%c%d\", &c, &d)\n\n\tk1 := c == 'a' || c == 'h'\n\tk2 := d == 1 || d == 8\n\n\tans := 8\n\tif k1 {\n\t\tans -= 3\n\t}\n\n\tif k2 {\n\t\tans -= 3\n\t}\n\n\tif k1 && k2 {\n\t\tans++\n\t}\n\n\tfmt.Println(ans)\n}\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "44274fd0b87bd6a4d90ab48ceb2cfbf8", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tsteps := []rune{-1, 0, 1}\n\tmove := 0\n\ts := []rune(next())\n\n\ts[0] -= 'a'\n\ts[1] -= '1'\n\n\tfor i := range steps {\n\t\tx := s[0] + steps[i]\n\n\t\tif x >= 0 && x < 8 {\n\t\t\tfor j := range steps {\n\t\t\t\tif steps[i] == 0 && steps[j] == 0 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\ty := s[1] + steps[j]\n\n\t\t\t\tif y >= 0 && y < 8 {\n\t\t\t\t\tmove++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprintln(move)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0a0a9b6d1c6ebd8e4ffa083ccad58d93", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n \"strconv\"\n)\n\nfunc main() {\n var a string\n var b string\n var c int\n fmt.Scanln(&a)\n fmt.Scanln(&b)\n ai, _ := strconv.Atoi(a)\n\n digit := make([]int, 0, 10)\n for tmp:=ai; tmp>0; {\n digit = append(digit, tmp%10)\n tmp /= 10\n }\n sort.Ints(digit)\n\n zeros := 0\n c = 0\n for _, x := range digit {\n if x == 0 {\n zeros++\n }else {\n if zeros > 0 {\n c = x\n for zeros > 0 {\n c *= 10\n zeros--\n }\n }else {\n c *= 10\n c += x\n }\n }\n }\n\n ca := strconv.Itoa(c);\n if b == ca {\n fmt.Println(\"OK\")\n }else {\n fmt.Println(\"WRONG_ANSWER\")\n }\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation"], "code_uid": "005d4c95d60f3d42029c81d95238b294", "src_uid": "d1e381b72a6c09a0723cfe72c0917372", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"os\"\n\t\"sort\"\n)\n\n\nfunc com(A []string, B []string) bool{\n \n if(len(A) != len(B)){\n return false\n }\n \n for i :=0; i< len(A); i++{\n if A[i] != B[i]{\n return false\n }\n }\n \n return true\n \n \n}\n\nfunc main() {\n\nvar x,y string\n\nfmt.Fscan(os.Stdin, &x)\nfmt.Fscan(os.Stdin, &y)\n\n\nA:= strings.Split(x, \"\")\nB:= strings.Split(y, \"\")\n\nsort.Strings(A)\n\nfor i :=0; i< len(A); i++{\n if A[i] != \"0\"{\n tmp := A[i]\n A[i] = A[0]\n A[0] = tmp\n break\n }\n}\n\nif com(A,B){\n fmt.Println (\"OK\")\n} else {\n fmt.Println (\"WRONG_ANSWER\")\n}\n\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation"], "code_uid": "4e46b520b4cdf9acbc8ecbc719740bf8", "src_uid": "d1e381b72a6c09a0723cfe72c0917372", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc equal(a, b []byte) bool {\n\tif len(a) != len(b) {\n\t\treturn false\n\t}\n\tvar n = len(a)\n\tfor i := 0; i < n; i++ {\n\t\tif a[i] != b[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc main() {\n\tvar input, answer []byte\n\tfmt.Scanf(\"%s\\n%s\", &input, &answer)\n\tvar digits [10]int\n\tvar n = len(input)\n\tfor i := 0; i < n; i++ {\n\t\tdigits[int(input[i]-'0')]++\n\t}\n\tvar ans = make([]byte, 0)\n\tfor i := 1; i < 10; i++ {\n\t\tif digits[i] > 0 {\n\t\t\tans = append(ans, byte(i+'0'))\n\t\t\tdigits[i]--\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor i := 0; i < 10; i++ {\n\t\tfor digits[i] > 0 {\n\t\t\tans = append(ans, byte(i+'0'))\n\t\t\tdigits[i]--\n\t\t}\n\t}\n\n\tif equal(ans, answer) {\n\t\tfmt.Println(\"OK\")\n\t} else {\n\t\tfmt.Println(\"WRONG_ANSWER\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation"], "code_uid": "8876ec1b740da388f3e7c9da186243c2", "src_uid": "d1e381b72a6c09a0723cfe72c0917372", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc check(num, i int64) int64 {\n\tvar count, divider int64 = 0, 5\n\n\tfor (i / divider) > 0 {\n\t\tcount += i / divider\n\t\tdivider *= 5\n\t}\n\n\treturn count\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tn, _ := reader.ReadString('\\n')\n\tvar num, result, flag int64\n\tfmt.Sscanf(n, \"%d\", &num)\n\tvar i int64 = 1\n\n\tfor {\n\n\t\tresult = check(num, i)\n\n\t\tif result > num {\n\t\t\tif flag == 0 {\n\t\t\t\tfmt.Print(0)\n\t\t\t}\n\t\t\tbreak\n\t\t} else if result == num {\n\n\t\t\tif flag == 0 {\n\t\t\t\tfmt.Println(5)\n\t\t\t\tflag = 1\n\t\t\t}\n\n\t\t\tfmt.Printf(\"%d \", i)\n\t\t}\n\n\t\ti++\n\t}\n\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms", "number theory"], "code_uid": "afe4faffbdb17925f56589d2953dec41", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tn := 0\n\tfmt.Scanf(\"%d\", &n)\n\tc := 0\n\tfor i := 5; i <= 1e6; i += 5 {\n\t\ttmp := i\n\t\tfor {\n\t\t\tif tmp%5 != 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ttmp /= 5\n\t\t\tc++\n\t\t}\n\t\tif c < n {\n\t\t\tcontinue\n\t\t}\n\t\tif c == n {\n\t\t\tfmt.Println(\"5\")\n\t\t\tfor j := i; j < i+5; j++ {\n\t\t\t\tfmt.Print(j, \" \")\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tif c > n {\n\t\t\tfmt.Println(\"0\")\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms", "number theory"], "code_uid": "a278507e3a8baf0829aa5dfa7b01d7a6", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nconst mod int64 = 1e9 + 7\n\ntype matrix [][]int64\n\nfunc newMatrix(n int) matrix {\n\tmat := make(matrix, n)\n\tfor i := range mat {\n\t\tmat[i] = make([]int64, n)\n\t}\n\treturn mat\n}\n\nfunc newMatrixI(n int) matrix {\n\tmat := make(matrix, n)\n\tfor i := range mat {\n\t\tmat[i] = make([]int64, n)\n\t\tmat[i][i] = 1\n\t}\n\treturn mat\n}\n\nfunc (a matrix) mul(b matrix) matrix {\n\tc := newMatrix(len(a))\n\tfor i := range a {\n\t\tfor j := range b[0] {\n\t\t\tfor k, aik := range a[i] {\n\t\t\t\tc[i][j] += aik * b[k][j] % mod\n\t\t\t}\n\t\t\tc[i][j] %= mod\n\t\t}\n\t}\n\treturn c\n}\n\nfunc (a matrix) pow(k int64) matrix {\n\tres := newMatrixI(len(a))\n\tfor ; k > 0; k >>= 1 {\n\t\tif k&1 == 1 {\n\t\t\tres = res.mul(a)\n\t\t}\n\t\ta = a.mul(a)\n\t}\n\treturn res\n}\n\nfunc CF1117D(in io.Reader, out io.Writer) {\n\tn, m := int64(0), 0\n\tFscan(in, &n, &m)\n\tif n < int64(m) {\n\t\tFprint(out, 1)\n\t\treturn\n\t}\n\ta := newMatrix(m)\n\ta[0][0] = 1\n\ta[0][m-1] = 1\n\tfor i := 1; i < m; i++ {\n\t\ta[i][i-1] = 1\n\t}\n\tFprint(out, a.pow(n)[0][0])\n}\n\nfunc main() { CF1117D(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "matrices", "dp"], "code_uid": "e1b03cf9992b57de714a38edd86650dd", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst Mod = 998244353\n\nfunc main() {\n\tdefer _w.Flush()\n\tn, x := int64(ReadInt()), int64(ReadInt())\n\n\tvar dp [501][501]int64\n\tdp[n][0] = 1\n\tfor i := int64(n); i >= 2; i-- {\n\t\tfor j := int64(0); j < x; j++ {\n\t\t\tif dp[i][j] == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tnj := Min(x, j+i-1)\n\t\t\tpow := int64(1)\n\t\t\tfor k := i; k >= 0; k-- {\n\t\t\t\tdp[k][nj] += dp[i][j] * ModCombination(i, k) % Mod * pow\n\t\t\t\tdp[k][nj] %= Mod\n\t\t\t\tpow = pow * (nj - j) % Mod\n\t\t\t}\n\t\t}\n\t}\n\tans := int64(0)\n\tfor j := int64(0); j <= x; j++ {\n\t\tans += dp[0][j]\n\t\tans %= Mod\n\t}\n\tprintln(((ans % Mod) + Mod) % Mod)\n}\n\nfunc ModCombination(n, k int64) (ret int64) {\n\tif n < k {\n\t\treturn int64(0)\n\t}\n\tfor ret = int64(1); n > int64(0) || k > int64(0); n, k = n/Mod, k/Mod {\n\t\tret = ret * fac[n%Mod] % Mod * finv[k%Mod] % Mod * finv[(n-k)%Mod] % Mod\n\t}\n\treturn\n}\n\nconst MAX = 500\n\nvar fac, finv, inv [MAX + 1]int64\n\nfunc init() {\n\tfac[int64(0)], fac[int64(1)], finv[int64(0)], finv[int64(1)], inv[int64(1)] = int64(1), int64(1), int64(1), int64(1), int64(1)\n\tfor i := int64(2); i <= MAX; i++ {\n\t\tfac[i], inv[i] = fac[i-int64(1)]*i%Mod, Mod-inv[Mod%i]*(Mod/i)%Mod\n\t\tfinv[i] = finv[i-int64(1)] * inv[i] % Mod\n\t}\n}\n\nfunc Min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc ReadString() (s string) { fmt.Fscan(_r, &s); return }\nfunc ReadInt() (i int) { fmt.Fscan(_r, &i); return }\nfunc print(a ...interface{}) { fmt.Fprint(_w, a...) }\nfunc println(a ...interface{}) { fmt.Fprintln(_w, a...) }\nfunc prints(s []int64) { v := fmt.Sprint(s); println(v[int64(1) : int64(len(v))-int64(1)]) }\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "b99232d12792cb8fe5cced035504b803", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst Mod = 998244353\n\nfunc main() {\n\tdefer _w.Flush()\n\tn, x := ReadInt(), ReadInt()\n\n\tvar dp [501][501]int64\n\tdp[n][int64(0)] = int64(1)\n\tfor i := n; i >= int64(2); i-- {\n\t\tfor j := int64(0); j < x; j++ {\n\t\t\tif dp[i][j] == int64(0) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tnj := Min(x, j+i-int64(1))\n\t\t\tpow := int64(1)\n\t\t\tfor k := i; k >= int64(0); k-- {\n\t\t\t\tdp[k][nj] += dp[i][j] * ModCombination(i, k) % Mod * pow\n\t\t\t\tdp[k][nj] %= Mod\n\t\t\t\tpow = pow * (nj - j) % Mod\n\t\t\t}\n\t\t}\n\t}\n\tans := int64(0)\n\tfor j := int64(0); j <= x; j++ {\n\t\tans += dp[int64(0)][j]\n\t\tans %= Mod\n\t}\n\tprintln(((ans % Mod) + Mod) % Mod)\n}\n\nfunc ModCombination(n, k int64) (ret int64) {\n\tif n < k {\n\t\treturn int64(0)\n\t}\n\tfor ret = int64(1); n > int64(0) || k > int64(0); n, k = n/Mod, k/Mod {\n\t\tret = ret * fac[n%Mod] % Mod * finv[k%Mod] % Mod * finv[(n-k)%Mod] % Mod\n\t}\n\treturn\n}\n\nconst MAX = 500\n\nvar fac, finv, inv [MAX + 1]int64\n\nfunc init() {\n\tfac[int64(0)], fac[int64(1)], finv[int64(0)], finv[int64(1)], inv[int64(1)] = int64(1), int64(1), int64(1), int64(1), int64(1)\n\tfor i := int64(2); i <= MAX; i++ {\n\t\tfac[i], inv[i] = fac[i-int64(1)]*i%Mod, Mod-inv[Mod%i]*(Mod/i)%Mod\n\t\tfinv[i] = finv[i-int64(1)] * inv[i] % Mod\n\t}\n}\n\nfunc Min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc ReadString() (s string) { fmt.Fscan(_r, &s); return }\nfunc ReadInt() (i int64) { fmt.Fscan(_r, &i); return }\nfunc print(a ...interface{}) { fmt.Fprint(_w, a...) }\nfunc println(a ...interface{}) { fmt.Fprintln(_w, a...) }\nfunc prints(s []int64) { v := fmt.Sprint(s); println(v[int64(1) : int64(len(v))-int64(1)]) }\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "97dc416014cf9f3288bec67413799936", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"os\"\r\n\t\"fmt\"\r\n)\r\n\r\n\r\nvar n, x int\r\n\r\nconst MOD = 998244353\r\n\r\nconst MAX = 500\r\n\r\nvar dp [MAX + 5][MAX + 5]int64\r\n\r\nvar bp [MAX + 5][MAX + 5]int64\r\n\r\nvar fact [MAX + 5]int64\r\nvar nk [MAX + 5][MAX + 5]int64\r\n\r\n\r\n\r\nfunc main() {\r\n\r\n\tr := bufio.NewReader(os.Stdin)\r\n\r\n\tfmt.Fscan(r, &n, &x)\r\n\r\n\tans := solve()\r\n\tfmt.Println(ans)\r\n}\r\n\r\n\r\n\r\nfunc solve() int64 {\r\n\r\n\tfact[1] = 1\r\n\tfact[0] = 1\r\n\r\n\tfor j := 2; j <= MAX; j++ {\r\n\t\tfact[j] = (fact[j - 1] * int64(j)) % MOD\r\n\t}\r\n\r\n\tfor i := 1; i <= MAX; i++ {\r\n\t\tfor j := 1; j <= i; j++ {\r\n\t\t\t//i choose j\r\n\t\t\t//i!/(i - j)! * j!\r\n\t\t\tij := fact[i - j]\r\n\t\t\tinvIj := modInverse(ij, MOD)\r\n\r\n\t\t\tjj := fact[j]\r\n\t\t\tinvJ := modInverse(jj, MOD)\r\n\r\n\t\t\tii := fact[i]\r\n\r\n\t\t\ttemp := ii * invIj % MOD\r\n\r\n\t\t\tnk[i][j] = temp * invJ % MOD\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tfor i := 1; i <= MAX; i++ {\r\n\t\tfor j := 1; j <= MAX; j++ {\r\n\t\t\tbp[i][j] = binpow(int64(i), int64(j), MOD)\r\n\t\t}\r\n\t}\r\n\r\n\tfor i := 1; i <= x; i++ {\r\n\t\tdp[0][i] = 1\r\n\t}\r\n\r\n\tfor i := 1; i <= x; i++ {\r\n\t\tdp[2][i] = int64(i)\r\n\t}\r\n\r\n\tfor i := 3; i <= n; i++ {\r\n\t\tfor j := 1; j <= x; j++ {\r\n\r\n\t\t\tvar lastSegLen int\r\n\t\t\tsegs := j/(i - 1)\r\n\t\t\tr := j % (i - 1)\r\n\t\t\tif r != 0 {\r\n\t\t\t\tlastSegLen = r\r\n\t\t\t\tsegs++\r\n\t\t\t} else {\r\n\t\t\t\tlastSegLen = i - 1\r\n\t\t\t}\r\n\r\n\t\t\t//dp[i][j]\r\n\r\n\t\t\tfor k := 1; k <= i; k++ {\r\n\t\t\t\tfor p := 1; p <= segs - 1; p++ {\r\n\r\n\t\t\t\t\tt := bp[i - 1][k]\r\n\r\n\t\t\t\t\tt2 := nk[i][k]\r\n\r\n\t\t\t\t\tt3 := (t * t2) % MOD\r\n\r\n\t\t\t\t\ttemp := t3 * dp[i - k][j - (i - 1) * p]\r\n\r\n\t\t\t\t\ttemp %= MOD\r\n\r\n\t\t\t\t\tdp[i][j] += temp\r\n\t\t\t\t\tdp[i][j] %= MOD\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tdp[i][j] += binpow(int64(lastSegLen), int64(i), MOD)\r\n\t\t\tdp[i][j] %= MOD\r\n\r\n\t\t}\r\n\t}\r\n\r\n\treturn dp[n][x]\r\n}\r\n\r\nfunc binpow(a int64, b int64, m int64) int64 {\r\n\ta %= m\r\n\tvar res int64 = 1\r\n\tfor ; b > 0;\r\n\t{\r\n\t\tif b & 1 == 1 {\r\n\t\t\tres = res * a % m\r\n\t\t}\r\n\r\n\t\ta = a * a % m\r\n\t\tb >>= 1\r\n\t}\r\n\treturn res\r\n}\r\n\r\nfunc modInverse(a int64, m int64) int64 {\r\n\tvar x, y int64\r\n\tg := gcdExtended(a, m, &x, &y)\r\n\r\n\tif g != 1 {\r\n\t\tpanic( \"Inverse doesn't exist\")\r\n\t} else {\r\n\r\n\t\t// m is added to handle negative x\r\n\t\tres := (x % m + m) % m\r\n\t\treturn res\r\n\t}\r\n}\r\n\r\nfunc gcdExtended(a int64, b int64, x *int64, y *int64) int64 {\r\n\r\n\t// Base Case\r\n\tif a == 0 {\r\n\t\t*x, *y = 0,1\r\n\t\treturn b\r\n\t}\r\n\r\n\t// To store results of recursive call\r\n\tvar x1, y1 int64\r\n\tgcd := gcdExtended(b%a, a, &x1, &y1);\r\n\r\n\t// Update x and y using results of recursive\r\n\t// call\r\n\t*x = y1 - (b/a)*x1;\r\n\t*y = x1\r\n\treturn gcd\r\n}", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "d317b73d299f8e19ada35c87c0f41369", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tk := scanInt(scanner)\n\tscanner.Scan()\n\ts := scanner.Text()\n\tn := len(s)\n\tpal := make([]int, n)\n\tfor i, ch := range s {\n\t\tpal[i] = int(ch)\n\t}\n\tfor i := (n-1)/2; i >= 0; i-- {\n\t\tj := n-1-i\n\t\tif pal[i] == pal[j] {\n\t\t\tcontinue\n\t\t}\n\t\tif pal[i] == '?' {\n\t\t\tpal[i] = pal[j]\n\t\t} else if pal[j] == '?' {\n\t\t\tpal[j] = pal[i]\n\t\t} else {\n\t\t\twriter.WriteString(\"IMPOSSIBLE\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\tseen := map[int]bool{}\n\tfor i := 0; i < k; i++ {\n\t\tseen['a'+int(i)] = false\n\t}\n\tfor _, ch := range pal {\n\t\tif ch != '?' {\n\t\t\tseen[ch] = true\n\t\t}\n\t}\n\tneed := []int{}\n\tfor ch, ok := range seen {\n\t\tif !ok {\n\t\t\tneed = append(need, ch)\n\t\t}\n\t}\n\tsort.Ints(need)\n\t/*\n\tfor _, ch := range pal {\n\t\twriter.WriteString(fmt.Sprintf(\"%c\", ch))\n\t}\n\twriter.WriteString(fmt.Sprintf(\" (k = %d)\\n\", k))\n\twriter.WriteString(fmt.Sprintf(\"need %d:\", len(need)))\n\tfor _, ch := range need {\n\t\twriter.WriteString(fmt.Sprintf(\" %c\", ch))\n\t}\n\twriter.WriteString(\"\\n\")\n\t*/\n\tnix := len(need)-1\n\tfor i := (n-1)/2; i >= 0; i-- {\n\t\tif pal[i] != '?' {\n\t\t\tcontinue\n\t\t}\n\t\tj := n-1-i\n\t\tif nix == -1 {\n\t\t\tpal[i] = 'a'\n\t\t\tpal[j] = 'a'\n\t\t} else {\n\t\t\tpal[i] = need[nix]\n\t\t\tpal[j] = need[nix]\n\t\t\tnix--\n\t\t}\n\t}\n\tif nix != -1 {\n\t\twriter.WriteString(\"IMPOSSIBLE\\n\")\n\t\treturn\n\t}\n\tfor _, ch := range pal {\n\t\twriter.WriteString(fmt.Sprintf(\"%c\", ch))\n\t}\n\twriter.WriteString(\"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["expression parsing"], "code_uid": "895a8b2f9807addd2451ab2b41a9b8bb", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\nfunc run(or io.Reader, ow io.Writer) {\r\n\tin := bufio.NewReader(or)\r\n\tout := bufio.NewWriter(ow)\r\n\tdefer out.Flush()\r\n\tconst P int64 = 1e9 + 7\r\n\tsolve := func() {\r\n\t\tvar n int64\r\n\t\tvar k int\r\n\t\tfmt.Fscan(in, &n, &k)\r\n\t\tvar ans int64 = 1\r\n\r\n\t\tfor i := 0; i < k; i++ {\r\n\t\t\tans = ans * n % P\r\n\t\t}\r\n\t\tfmt.Fprintln(out, ans)\r\n\r\n\t}\r\n\r\n\tvar T int\r\n\tfmt.Fscan(in, &T)\r\n\tfor o := 0; o < T; o++ {\r\n\t\tsolve()\r\n\t}\r\n\r\n}\r\n\r\nfunc main() { run(os.Stdin, os.Stdout) }\r\n", "lang_cluster": "Go", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "076af2893c1fe50d438ef1d2ad015ad2", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 00\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc write(f *bufio.Writer, a ...interface{}) {\n\tf.Write([]byte(fmt.Sprint(a...)))\n}\n\ntype Number interface {\n\tint64 | float64 | int\n}\n\nfunc min[K Number](a K, b K) K {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max[K Number](a K, b K) K {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc main() {\n\tvar T int\n\treader := bufio.NewReader(os.Stdin)\n\tf := bufio.NewWriter(os.Stdout)\n\tdefer f.Flush()\n\tfmt.Fscan(reader, &T)\n\tfor t := 1; t <= T; t++ {\n\t\tvar n, k int\n\t\tfmt.Fscan(reader, &n, &k)\n\t\tans := int64(1)\n\t\tfor i := 0; i < k; i++ {\n\t\t\tans = ans * int64(n)\n\t\t\tans = ans % 1000000007\n\t\t}\n\t\twrite(f, ans, \"\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "b85bcad5513f921ecd396dfccc64f974", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst MOD = 1e9 + 7\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\n\tvar T int\n\tfmt.Fscan(in, &T)\n\tfor t := 0; t < T; t++ {\n\t\tvar n int64\n\t\tvar k int\n\t\tfmt.Fscan(in, &n, &k)\n\n\t\ttot := int64(1)\n\t\tfor i := 0; i < k; i++ {\n\t\t\ttot = (tot * n) % MOD\n\t\t}\n\t\tfmt.Fprintln(out, tot)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "792aa7d95545dd1b9dcdc3d21a1011d4", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc readInt(reader *bufio.Scanner) int {\n\tvar result int\n\treader.Scan()\n\tresult, _ = strconv.Atoi(reader.Text())\n\treturn result\n}\n\nfunc main() {\n\treader := bufio.NewScanner(os.Stdin)\n\tbuf := make([]byte, 2)\n\treader.Buffer(buf, 501)\n\treader.Split(bufio.ScanWords)\n\tx := readInt(reader)\n\ty := readInt(reader)\n\tz := readInt(reader)\n\tif z == 0 {\n\t\tif x > y {\n\t\t\tfmt.Println(\"+\")\n\t\t} else if x < y {\n\t\t\tfmt.Println(\"-\")\n\t\t} else {\n\t\t\tfmt.Println(\"0\")\n\t\t}\n\t} else if x > y+z {\n\t\tfmt.Println(\"+\")\n\t} else if y > x+z {\n\t\tfmt.Println(\"-\")\n\t}else{\n\t\tfmt.Println(\"?\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "557ccc13878bd45fb7625f7c6a4719c5", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a,b,c int\n\tfmt.Scanf(\"%d %d %d\",&a,&b,&c)\n\tif a>b&&(b+c 1 {\n\t\tresult = append(result, \"<<\")\n\t}\n\tfor i := p - k; i < p; i++ {\n\t\tif i > 0 {\n\t\t\tresult = append(result, strconv.Itoa(i))\n\t\t}\n\t}\n\n\tresult = append(result, \"(\"+strconv.Itoa(p)+\")\")\n\n\tfor i := p + 1; i <= p+k; i++ {\n\t\tif i <= n {\n\t\t\tresult = append(result, strconv.Itoa(i))\n\t\t}\n\t}\n\n\tif p+k < n {\n\t\tresult = append(result, \">>\")\n\t}\n\n\treturn strings.Join(result, \" \")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "16b0718623ba9dd18830960ad6c41686", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tvar n, p, k int\n\n\tfmt.Fscanf(reader, \"%d %d %d\", &n, &p, &k)\n\tif p-k > 1 {\n\t\tfmt.Printf(\"<< \")\n\t}\n\tfor i := p - k; i <= p+k; i++ {\n\t\tif i == p {\n\t\t\tfmt.Printf(\"(%d) \", i)\n\t\t} else if i >= 1 && i <= n {\n\t\t\tfmt.Printf(\"%d \", i)\n\t\t}\n\t}\n\tif p+k < n {\n\t\tfmt.Printf(\">>\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d49e563e8cd1f22a3b35d51dec26caea", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, p, k int\n\t_, _ = fmt.Scanf(\"%d\", &n)\n\t_, _ = fmt.Scanf(\"%d\", &p)\n\t_, _ = fmt.Scanf(\"%d\", &k)\n\n\tvar buffer bytes.Buffer\n\n\tif p - k > 1 {\n\t\tbuffer.WriteString(\"<< \")\n\t}\n\n\tfor i := p - k; i < p + k + 1; i++ {\n\t\tif (i < 1) || (i > n) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif i == p {\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"(%d) \", i))\n\t\t\tcontinue\n\t\t}\n\n\t\tbuffer.WriteString(fmt.Sprintf(\"%d \", i))\n\t}\n\n\tif p + k < n {\n\t\tbuffer.WriteString(\">>\")\n\t}\n\n\tfmt.Println(buffer.String())\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "9c18a60cb1142bf7db1ee1d431a58943", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"math\"\n)\n\n\nvar writer *bufio.Writer\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tini()\n\tdefer writer.Flush()\n\n\tn := scanInt()\n\tvar a[6] int\n\tvar b[6] int\n\tvar c[6] int\n\n\tfor i:=0; i 0 {\n\t\twriter.WriteString(\"LEFT\\n\")\n\t} else {\n\t\twriter.WriteString(\"RIGHT\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["geometry"], "code_uid": "00cf677118e0107853918fa512b4bb47", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 227A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a1, a2, b1, b2, c1, c2, x, y, z float64\n\tfmt.Scan(&a1, &a2)\n\tfmt.Scan(&b1, &b2)\n\tfmt.Scan(&c1, &c2)\n\tx = (b1 - a1) * (c2 - b2)\n\ty = (c1 - b1) * (b2 - a2)\n\tz = x - y\n\tif z == 0 {\n\t\tfmt.Print(\"TOWARDS\")\n\t} else if z < 0 {\n\t\tfmt.Print(\"RIGHT\")\n\t} else {\n\t\tfmt.Print(\"LEFT\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["geometry"], "code_uid": "bf8f07b2bc645e3af25991be00750608", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int // variabel n dengan jenis int\n fmt.Scan(&n) // mengambil input\n if (n <= 10) || (n > 21) { // jika (n kurang dari sama dengan 10) atau (n lebih dari 21)\n fmt.Println(0) // cetak 0\n } else if n == 20 { // jika n sama dengan 20\n fmt.Println(15) // cetak 15\n } else {\n fmt.Println(4) // cetak 4\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "10b609131e76c4154340dced458e5cc3", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"bufio\"\n\t//\"os\"\n\t//\"strconv\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tif n<=10 || n>21 {\n\t\tfmt.Println(\"0\")\n\t} else if n==20 {\n\t\tfmt.Println(\"15\")\n\t} else {\n\t\tfmt.Println(\"4\")\n\t}\n}\n\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2c8448b55907632931d6962088ea2337", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 104A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n if n == 20 {\n fmt.Println(\"15\")\n } else if n <= 10 || n > 21 {\n fmt.Println(\"0\")\n } else {\n fmt.Println(\"4\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "383bdce89c8bb0300707a8e7b3e753ef", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc minSlots(n int64) int {\n\tc := 1\n\ts := int64(7)\n\tfor {\n\t\tif s >= n {\n\t\t\treturn c\n\t\t}\n\t\tc ++;\n\t\ts *= 7\n\t}\n}\n\nvar n, m int64\nvar slotN, slotM int\nvar ans = 0\nvar used = make([]bool, 7)\nfunc cal(num []int) int64 {\n\tvar result int64\n\tfor _, n := range num {\n\t\tresult = result * int64(7) + int64(n)\n\t}\n\treturn result\n}\nfunc dfs(num []int) {\n\tif len(num) == slotN {\n\t\tif cal(num[:slotN]) >= n {\n\t\t\treturn\n\t\t}\n\t} else if len(num) == slotN + slotM {\n\t\tif cal(num[slotN:]) < m {\n\t\t\tans ++\n\t\t}\n\t\treturn\n\t}\n\tfor i, use := range used {\n\t\tif !use {\n\t\t\tused[i] = true\n\t\t\tdfs(append(num, i))\n\t\t\tused[i] = false\n\t\t}\n\t}\n}\n\nfunc main() {\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tslotN = minSlots(n)\n\tslotM = minSlots(m)\n\tnum := make([]int, 0, slotN + slotM + 1)\n\tdfs(num)\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "combinatorics"], "code_uid": "eb2b5c02dee80222ba7f58d603799f56", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc validate(arr []int64, nSlots int, n int64, m int64) bool {\n length := len(arr)\n for i:= 0; i < length; i++ {\n for j:= i+1; j < length; j++ {\n if arr[i] == arr[j] {\n return false\n }\n }\n }\n var num int64\n for i:= 0; i < nSlots; i++ {\n num = num*7+arr[i]\n }\n if num >= n {\n return false\n }\n num = 0\n for i:=nSlots; i < length; i++ {\n num = num*7+arr[i]\n }\n if num >= m {\n return false\n }\n //fmt.Println(arr)\n return true\n}\n\nfunc try(arr []int64, depth int, cnt *int) {\n length := len(arr)\n if depth == length {\n if validate(arr, nSlots, n, m) {\n (*cnt)++\n }\n return\n }\n for i:=0; i < 7; i++ {\n arr[depth] = int64(i)\n try(arr, depth+1, cnt)\n }\n}\nvar n, m int64\nvar nSlots, mSlots int\nfunc main() {\n fmt.Scan(&n, &m)\n for i:=n-1; i > 0; {\n nSlots++\n i /= 7\n }\n if nSlots == 0 {\n nSlots = 1\n }\n for i:=m-1; i > 0; {\n mSlots++\n i /= 7\n }\n if mSlots == 0 {\n mSlots = 1\n }\n\n if mSlots + nSlots > 7 || mSlots + nSlots == 0 {\n fmt.Println(0)\n return\n }\n\n //fmt.Println(nSlots, mSlots)\n var arr []int64 = make([]int64, nSlots+mSlots)\n\n var cnt int\n try(arr, 0, &cnt)\n fmt.Println(cnt)\n //testValidate()\n}\n\nfunc testValidate() {\n arr := make([]int64, 3)\n arr[0] = 0\n arr[1] = 2\n arr[2] = 1\n fmt.Println(validate(arr, 2, 8, 2))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "combinatorics"], "code_uid": "279698210d96063dde95d03af832498f", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc toBaseSeven(number int, size int) []int {\n\tresult := make([]int, size)\n\tfor i := range result {\n\t\tresult[i] = number % 7\n\t\tnumber /= 7\n\t}\n\treturn result\n}\n\nfunc checkDistinctOfNumbers(hour []int, minute [] int) bool {\n\tvar numbers [7]int\n\tfor _, v := range hour {\n\t\tnumbers[v]++\n\t}\n\n\tfor _, v := range minute {\n\t\tnumbers[v]++\n\t}\n\n\tfor _, v := range numbers {\n\t\tif v > 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc sizeInBaseSeven(number int) int {\n\tres := 1\n\tfor number /= 7; number != 0; number /= 7 {\n\t\tres++\n\t}\n\treturn res\n}\n\nfunc main() {\n\tvar n, m, res int\n\tfmt.Scan(&n, &m)\n\tn_size, m_size := sizeInBaseSeven(n-1), sizeInBaseSeven(m-1)\n\tif n_size + m_size > 7 {\n\t\tfmt.Println(\"0\")\n\t\treturn\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < m; j++ {\n\t\t\tif checkDistinctOfNumbers(toBaseSeven(i, n_size), toBaseSeven(j, m_size)) {\n\t\t\t\tres++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "combinatorics"], "code_uid": "7d9824a1bcc668177528e3f82ad8f513", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar n, m, k int\n\tvar a [50]int\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tm, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tk, _ = strconv.Atoi(r.Text())\n\tsum := 0\n\tx := 0\n\ti := 0\n\tfor i=0; ik {\n\t\tfor i=49; i>=0; i-- {\n\t\t\tif a[i] > 0 {\n\t\t\t\tk += i;\n\t\t\t\ta[i] -= 1\n\t\t\t\tsum += 1\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif i<0 {\n\t\t\tw.WriteString(\"-1\\n\")\n\t\t\tw.Flush()\n\t\t\treturn\n\t\t}\n\t}\n\tw.WriteString(strconv.Itoa(sum)+\"\\n\")\n\tw.Flush()\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "37c8f126929983cec9625ceb7ff4bd10", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n,m,k int\n fmt.Scan(&n,&m,&k)\n a := make([]int,n)\n for i := 0; i < n; i++ {\n fmt.Scan(&a[i])\n }\n sort.Ints(a)\n for ; (k > 0) && (m > 0); k-- {\n if (m <= k) { m = 0; break; }\n if k == 1 {\n for (len(a) != 0) && (a[len(a)-1] > 1){\n m -= a[len(a)-1]\n a = a[:len(a)-1]\n if (m > 0) { m++ } else { break }\n }\n } else {\n if len(a) != 0 {\n m -= a[len(a)-1]\n a = a[:len(a)-1]\n } else {\n m--\n }\n }\n }\n if (m > 0) { fmt.Println(-1) } else { fmt.Println(n-len(a)) }\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "861d6330c2aac60fb203ad82a13684e0", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 257A-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n, m, k, i, x, l int\n fmt.Scan(&n, &m, &k)\n var a []int\n for i = 1; i <= n; i++ {\n fmt.Scan(&x)\n a = append(a, x)\n l++\n }\n sort.Sort(sort.IntSlice(a))\n pos := n - 1\n for k < m && pos >= 0 {\n k += a[pos] - 1\n pos--\n }\n if k < m {\n fmt.Println(\"-1\")\n } else {\n fmt.Println(n - pos - 1)\n }\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "1198e75a85d953309b91250fb0b50139", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nvar r *bufio.Reader = bufio.NewReader(os.Stdin)\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\n\ntype Vertice struct {\n\tX int\n\tY int\n}\n\nfunc dist(a, b Vertice) int {\n\tx, y := a.X-b.X, a.Y-b.Y\n\treturn x*x + y*y\n}\n\nfunc isRight(a, b, c Vertice) bool {\n\tes := []int{dist(a, b), dist(b, c), dist(c, a)}\n\tsort.Ints(es)\n\n\tif es[0] == 0 || es[1] == 0 || es[2] == 0 {\n\t\treturn false\n\t}\n\n\treturn es[0]+es[1] == es[2]\n}\n\nfunc getAdjs(v Vertice) []Vertice {\n\treturn []Vertice{Vertice{v.X - 1, v.Y}, Vertice{v.X + 1, v.Y}, Vertice{v.X, v.Y - 1}, Vertice{v.X, v.Y + 1}}\n}\n\nfunc solve(a, b, c Vertice) string {\n\tif isRight(a, b, c) {\n\t\treturn \"RIGHT\"\n\t}\n\n\tfor i := 0; i < 3; i++ {\n\t\tvar v1, v2, v3 Vertice\n\t\tswitch i {\n\t\tcase 0:\n\t\t\tv1, v2, v3 = a, b, c\n\t\tcase 1:\n\t\t\tv1, v2, v3 = b, c, a\n\t\tcase 2:\n\t\t\tv1, v2, v3 = c, a, b\n\t\t}\n\t\tadjs := getAdjs(v1)\n\t\tfor _, v := range adjs {\n\t\t\tif isRight(v, v2, v3) {\n\t\t\t\treturn \"ALMOST\"\n\t\t\t}\n\t\t}\n\t}\n\n\treturn \"NEITHER\"\n}\n\nfunc main() {\n\tdefer w.Flush()\n\n\ta, b, c := Vertice{}, Vertice{}, Vertice{}\n\tfmt.Fscanf(r, \"%d %d %d %d %d %d\", &a.X, &a.Y, &b.X, &b.Y, &c.X, &c.Y)\n\n\tfmt.Fprintf(w, \"%v\", solve(a, b, c))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "geometry"], "code_uid": "ee4e2d0631c94486e0b6c37beda25407", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math/bits\"\n\t\"os\"\n)\n\nfunc main() {\n\n\treader := bufio.NewReader(os.Stdin)\n\tvar n, p int64\n\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &p)\n\n\tfor i := int64(1); i < 40; i++ {\n\t\ttmp := n - i*p\n\t\tif bits.OnesCount64(uint64(tmp)) <= int(i) && tmp >= i {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(-1)\n}\n\n", "lang_cluster": "Go", "tags": ["brute force", "math", "bitmasks"], "code_uid": "50ecaa7ad6b983b6ade8c270eb607d30", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"math/bits\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar n, p int\n\tScan(&n, &p)\n\tfor i := 1; i*p < n; i++ {\n\t\tif x := n - i*p; i <= x && i >= bits.OnesCount(uint(x)) {\n\t\t\tPrint(i)\n\t\t\treturn\n\t\t}\n\t}\n\tPrint(-1)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "bitmasks"], "code_uid": "aaf3a54c70426776dea80132bf3ec7e2", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tn,p:=0,0\n\tfmt.Scanln(&n,&p)\n\tfor i := 1; i<=64; i++ {\n\t\tfuck:=n-p*i\n\t\t\ts:=fmt.Sprintf(\"%b\",fuck)\n\t\t\tans:=0\n\t\t\tfor i := 0; i < len(s); i++ {\n\t\t\t\tif s[i]=='1'{\n\t\t\t\t\tans++\n\t\t\t}\n\t\t\t}\n\t\t\t//fmt.Println(fuck,s,ans,i)\n\t\t\tif ans<=i&&i<=n-p*i{\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn\n\t\t\t}\n\n\t}\n\tfmt.Println(-1)\n\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "bitmasks"], "code_uid": "595528a385fea6c856f8632d0137d73b", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t// \"os\"\n\t)\n\nconst INF = 0x3f3f3f3f\n\nvar n, m, tot int\n\nfunc min(x, y int) int {\n\tif xy {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc main() {\n\t// fd, _ := os.Open(\"in.txt\")\n\t// os.Stdin = fd\n\tvar T int = 1\n\t// fmt.Scanf(\"%d\", &T)\n\tfor ci:=1; ci<=T; ci++ {\n\t\tfmt.Scanf(\"%d %d\\n\", &n, &m)\n\t\t// fmt.Printf(\"Case #%d: \", ci)\n\t\tvar ans int = 107\n\t\tfor i:=1; i<=n; i++ {\n\t\t\tvar x int\n\t\t\tfmt.Scanf(\"%d\", &x)\n\t\t\tif m%x==0 {\n\t\t\t\tans = min(ans, m/x)\n\t\t\t}\n\t\t}\n\t\tfmt.Printf(\"%d\\n\", ans)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e5968c206e1ca12f381feb684e03a567", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k, a int\n\tfmt.Scan(&n, &k)\n\tmin := 100\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a)\n\t\tif k%a == 0 && min > k/a {\n\t\t\tmin = k / a\n\t\t}\n\t}\n\tfmt.Println(min)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f59116fcd00bb3dcbdfebfeba197ffb5", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, k, a, x int\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%d %d\\n\", &n, &k)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(stdin, \"%d\", &a)\n\t\tif k%a == 0 {\n\t\t\tx = max(x, a)\n\t\t}\n\t}\n\tfmt.Println(k / x)\n}\n\nfunc max(a int, b int) int {\n\treturn int(math.Max(float64(a), float64(b)))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f50fe87b4fb22a992f97af04d918ef60", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n \"strings\"\n \"strconv\"\n \"math\"\n)\n \n\n \nvar reader = NewWordScanner(os.Stdin)\nvar writer = NewBufferedWriter(os.Stdout)\n \nfunc main() {\n\tdefer writer.Flush()\n\t\tn,m := reader.NextInt64(),reader.NextInt64()\n\t\taa:=make([]int64,101)\n\t\tfor i:=int64(0);i0;d-- {\n\t\ttmp := make([]int64, len(aa))\n\t\tcopy(tmp, aa)\n\t\tmax:=int64(0)\n\t\tfor i:=1;i<=100;i++ {\n\t\t\tfor tmp[i]>=d {\n\t\t\t\tmax++\n\t\t\t\ttmp[i]-=d\n\t\t\t}\n\t\t\tif(max>=n){\n\t\t\t\twriter.Printf(\"%d\\n\",d)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\twriter.Printf(\"0\")\n}\n \n\n\n\n\n/*********************** I/O ***********************/\n\n\ntype BufferedWriter interface {\n\tPrintf(format string, a ...interface{})\n\tFlush()\n}\n \ntype writerImpl struct {\n\t*bufio.Writer\n}\n \nfunc NewBufferedWriter(writer io.Writer) BufferedWriter {\n\treturn &writerImpl{Writer: bufio.NewWriter(writer)}\n}\n \nfunc (impl *writerImpl) Printf(f string, a ...interface{}) {\n\tfmt.Fprintf(impl.Writer, f, a...)\n}\n \nfunc (impl *writerImpl) Flush() {\n\timpl.Writer.Flush()\n}\n \ntype WordScanner interface {\n\tNextInt() int\n\tNextInt64() int64\n\tNextString() string\n}\n \ntype wordScannerImpl struct {\n\t*bufio.Scanner\n}\n \nfunc NewWordScanner(reader io.Reader) WordScanner {\n\ts := bufio.NewScanner(reader)\n\ts.Split(bufio.ScanWords)\n\t// adjust the following size as needed\n\t// 2 << 17 is good enough to scan strings of len 2*10^5\n\t// it could go as high as 2 << 26 before cf judge breaks\n\tsize := 2 << 20\n\tbuf := make([]byte, size)\n\ts.Buffer(buf, size)\n\treturn &wordScannerImpl{Scanner: s}\n}\n \nfunc (impl *wordScannerImpl) NextInt() int {\n\timpl.Scan()\n\tbb := impl.Bytes()\n\ti := 0\n\tif bb[0] == '-' {\n\t\tfor _, b := range bb[1:] {\n\t\t\ti *= 10\n\t\t\ti -= int(b - '0')\n\t\t}\n\t\treturn i\n\t}\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += int(b - '0')\n\t}\n\treturn i\n}\n \nfunc (impl *wordScannerImpl) NextInt64() int64 {\n\timpl.Scan()\n\tbb := impl.Bytes()\n\ti := int64(0)\n\tif bb[0] == '-' {\n\t\tfor _, b := range bb[1:] {\n\t\t\ti *= 10\n\t\t\ti -= int64(b - '0')\n\t\t}\n\t\treturn i\n\t}\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += int64(b - '0')\n\t}\n\treturn i\n}\n \n\nfunc (impl *wordScannerImpl) NextString() string {\n\timpl.Scan()\n\treturn impl.Text()\n}\n/*********************** Utils ***********************/\n \nfunc S(v interface{}) string { return fmt.Sprintf(\"%v\", v) }\nfunc SArr(a []int) string {\n\tsb := strings.Builder{}\n\tsb.Grow(len(a) * 9)\n\tfor i := range a {\n\t\tsb.WriteString(strconv.Itoa(a[i]) + \" \")\n\t}\n\treturn sb.String()\n}\nfunc SArr64(a []int64) string {\n\tsb := strings.Builder{}\n\tsb.Grow(len(a) * 9)\n\tfor i := range a {\n\t\tsb.WriteString(strconv.FormatInt(a[i], 10) + \" \")\n\t}\n\treturn sb.String()\n}\nfunc MnMx(args ...int64) (int64, int64) {\n\tminVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)\n\tfor _, v := range args {\n\t\tif v < minVal {\n\t\t\tminVal = v\n\t\t}\n\t\tif v > maxVal {\n\t\t\tmaxVal = v\n\t\t}\n\t}\n\treturn minVal, maxVal\n}\nfunc Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }\nfunc Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }\nfunc LCM(a, b int64) int64 { return a / GCD(a, b) * b }\nfunc GCD(a, b int64) int64 {\n\tif a == 0 {\n\t\treturn b\n\t}\n\treturn GCD(b%a, a)\n}\nfunc sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }\nfunc abs(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation", "binary search"], "code_uid": "c4f3ff526b062a881602b0827bb2f245", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tvar n, m int\n\tfmt.Fscan(reader, &n, &m)\n\n\tarr := make(map[int]int)\n\tfor i := 0; i < m; i++ {\n\t\tvar x int\n\t\tfmt.Fscan(reader, &x)\n\t\tarr[x]++\n\t}\n\n\tvar mx int\n\tfor i := 1; i < 101; i++ {\n\t\tvar count int\n\t\tfor _, vl := range arr {\n\t\t\tcount += vl / i\n\t\t}\n\n\t\tif count >= n {\n\t\t\tmx = i\n\t\t}\n\t}\n\n\tfmt.Println(mx)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "binary search"], "code_uid": "762e87de8a5991ef8d7735b582bd07b0", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn, m := 0, 0\n\tfmt.Fscanf(in, \"%d %d\\n\", &n, &m)\n\tnumMap := make(map[int]int)\n\tfor i := 0; i < m; i++ {\n\t\tt := 0\n\t\tfmt.Fscanf(in, \"%d\", &t)\n\t\tnumMap[t] = numMap[t] + 1\n\t}\n\tans := 0\n\tfor i := 1; i < 1000; i++ {\n\t\tpeople := 0\n\t\tfor _, v := range numMap {\n\t\t\tpeople += v / i\n\t\t}\n\t\tif people < n {\n\t\t\tbreak\n\t\t}\n\t\tans = i\n\t}\n\n\tfmt.Fprintf(out, \"%d\\n\", ans)\n\treturn\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation", "binary search"], "code_uid": "16a254925be0e63ef3a2e0ae4d8ee658", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport . \"fmt\"\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\ttype pair struct{ a0, len int }\n\tconst mx = 1e5 + 5\n\tps := [mx][]pair{}\n\tsgSum := [mx]int{}\n\n\tvar n int\n\tScan(&n)\n\n\tfor len := 2; len*(len+1)/2 <= n; len++ {\n\t\tfor a0 := 1; ; a0++ {\n\t\t\ts := (2*a0 + len - 1) * len / 2\n\t\t\tif s > n {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tps[s] = append(ps[s], pair{a0, len})\n\t\t}\n\t}\n\n\tfor i := 3; i <= n; i++ {\n\t\tmex := map[int]bool{}\n\t\tfor _, p := range ps[i] {\n\t\t\ts := sgSum[p.a0] ^ sgSum[p.a0+p.len]\n\t\t\tif i == n && s == 0 {\n\t\t\t\tPrint(p.len)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmex[s] = true\n\t\t}\n\t\tsg := 0\n\t\tfor ; mex[sg]; sg++ {\n\t\t}\n\t\tsgSum[i+1] = sgSum[i] ^ sg\n\t}\n\tPrint(-1)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "games"], "code_uid": "1753eaebf97172ae5b49d34d13b4f0f3", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tn := 0\n\tScan(&n)\n\n\ttype pair struct{ a0, len int }\n\tconst mx = 1e5\n\tps := [mx + 1][]pair{}\n\tfor l := 2; l*(l+1)/2 <= mx; l++ {\n\t\tfor a0 := 1; ; a0++ {\n\t\t\ts := (2*a0 + l - 1) * l / 2\n\t\t\tif s > mx {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tps[s] = append(ps[s], pair{a0, l})\n\t\t}\n\t}\n\tsg := [mx + 1]int{}\n\tfor i := range sg {\n\t\tmex := map[int]bool{}\n\t\tfor _, p := range ps[i] {\n\t\t\ts := 0\n\t\t\tfor j := p.a0; j-p.a0 < p.len; j++ {\n\t\t\t\ts ^= sg[j]\n\t\t\t}\n\t\t\tif i == n && s == 0 {\n\t\t\t\tPrint(p.len)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmex[s] = true\n\t\t}\n\t\tfor ; mex[sg[i]]; sg[i]++ {\n\t\t}\n\t}\n\tPrint(-1)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "games"], "code_uid": "8780c5c4a18c385848c3dac21b45a8cc", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\ttype pair struct{ a0, len int }\n\tconst mx = 1e5 + 5\n\tps := [mx][]pair{}\n\tfor l := 2; l*(l+1)/2 < mx; l++ {\n\t\tfor a0 := 1; ; a0++ {\n\t\t\ts := (2*a0 + l - 1) * l / 2\n\t\t\tif s >= mx {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tps[s] = append(ps[s], pair{a0, l})\n\t\t}\n\t}\n\tsgSum := [mx]int{}\n\n\tvar n int\n\tScan(&n)\n\tfor i := 3; i <= n; i++ {\n\t\tmex := map[int]bool{}\n\t\tfor _, p := range ps[i] {\n\t\t\ts := sgSum[p.a0] ^ sgSum[p.a0+p.len]\n\t\t\tif i == n && s == 0 {\n\t\t\t\tPrint(p.len)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmex[s] = true\n\t\t}\n\t\tsg := 0\n\t\tfor ; mex[sg]; sg++ {\n\t\t}\n\t\tsgSum[i+1] = sgSum[i] ^ sg\n\t}\n\tPrint(-1)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "games"], "code_uid": "9a2ad563b5f9e7cab373d173aa100209", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n//14:17\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var n, m int64\n fmt.Scanf(\"%d %d\", &n, &m)\n var a, b int64\n var sol int64\n var min int64\n min = math.MaxInt64\n for a = 0; a <= n/2; a++ {\n b = n - 2*a\n if (a+b)% m == 0 {\n sol = a + b\n if sol < min {\n min = sol\n }\n }\n }\n if min == math.MaxInt64 {\n fmt.Printf(\"-1\")\n } else {\n fmt.Printf(\"%d\", min)\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "1e4562270b918553c338f47a11b2bf36", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"strconv\"\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n// var file, _ = os.Open(\"input.txt\")\n// var outfile, _ = os.Create(\"output.txt\")\n// var in = bufio.NewScanner(file)\n// var out = bufio.NewWriter(outfile)\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc next() string {\n if !in.Scan() {\n panic(\"Scan error\")\n }\n return in.Text()\n}\n\nfunc nextInt() int {\n ret, _ := strconv.Atoi(next())\n return ret\n}\n\nfunc nextFloat() float64 {\n ret, _ := strconv.ParseFloat(next(), 64)\n return ret\n}\n\nfunc main() {\n defer out.Flush()\n in.Split(bufio.ScanWords)\n n := nextInt()\n m := nextInt()\n for i := m; i <= n; i += m {\n for j := 0; j <= i; j++ {\n if j * 2 + (i - j) == n {\n fmt.Fprintln(out, i)\n return\n }\n }\n }\n fmt.Fprintln(out, -1)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "2e06fe6cb634cb6a5ffaca2c489f2b0f", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n)\n\tfmt.Scan(&m)\n\tif m > n {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tif n == m {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\t//var x = (n/2 + n%2) / m\n\tvar y = (n/2 + n%2) % m\n\tvar tot = n/2 + n%2\n\tif y > 0 {\n\t\ttot += m - y\n\t}\n\tfmt.Println(tot)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "f7c33632a37fb56253de154191158002", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tnums := make([]int64, 3)\n\tfor i := 0; i < 3; i++ {\n\t\tfmt.Scan(&nums[i])\n\t}\n\n\tminDiv := int64(7 * 1e8)\n\n\tdivs := make([]int64, 3)\n\tdivs[0] = nums[0] / 3\n\tdivs[1] = nums[1] / 2\n\tdivs[2] = nums[2] / 2\n\n\tfor i := 0; i < 3; i++ {\n\t\tif divs[i] < minDiv {\n\t\t\tminDiv = divs[i]\n\t\t}\n\t}\n\n\tvar result int64\n\tresult += minDiv * 7\n\n\tnums[0] -= minDiv * 3\n\tnums[1] -= minDiv * 2\n\tnums[2] -= minDiv * 2\n\n\tvar maxDays int64\n\tfor i := 0; i < 7; i++ { // 何日目からか\n\t\ta, b, c := nums[0], nums[1], nums[2]\n\t\tvar days int64\n\t\tfor j := 0; j < 7; j++ { // 何日分進んだか\n\t\t\tk := i + j\n\t\t\tif k > 6 {\n\t\t\t\tk -= 7\n\t\t\t}\n\t\t\tif k == 0 || k == 3 || k == 6 {\n\t\t\t\tif a == 0 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\ta--\n\t\t\t}\n\t\t\tif k == 1 || k == 5 {\n\t\t\t\tif b == 0 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tb--\n\t\t\t}\n\t\t\tif k == 2 || k == 4 {\n\t\t\t\tif c == 0 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tc--\n\t\t\t}\n\t\t\tdays++\n\t\t}\n\t\tmaxDays = max(maxDays, days)\n\t}\n\tfmt.Println(maxDays + result)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "d7adba507bb01029c0701316b60f1b16", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1154/problem/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc min(a []int) int {\n\tminElem := a[0]\n\tfor i := 1; i < 3; i++ {\n\t\tif a[i] < minElem {\n\t\t\tminElem = a[i]\n\t\t}\n\t}\n\treturn minElem\n}\n\nfunc simulate(a int, b int, c int, day int) int {\n\tweek := []string{\"f\", \"r\", \"c\", \"f\", \"c\", \"r\", \"f\"}\n\tdaysFed := 0\n\tfor {\n\t\tcurrentDay := day % 7\n\t\tif week[currentDay] == \"f\" && a > 0 {\n\t\t\ta -= 1\n\t\t\tdaysFed += 1\n\t\t} else if week[currentDay] == \"r\" && b > 0 {\n\t\t\tb -= 1\n\t\t\tdaysFed += 1\n\t\t} else if week[currentDay] == \"c\" && c > 0 {\n\t\t\tc -= 1\n\t\t\tdaysFed += 1\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t\tday += 1\n\t}\n\treturn daysFed\n}\n\nfunc simulateAll(a, b, c int) int {\n\tmaxDays := 0\n\tfor i := 0; i < 7; i++ {\n\t\tdays := simulate(a, b, c, i)\n\t\tif days > maxDays {\n\t\t\tmaxDays = days\n\t\t}\n\t}\n\treturn maxDays\n}\n\nfunc Solve(a, b, c int) int {\n\tarr := []int{a / 3, b / 2, c / 2}\n\tminWeeks := min(arr)\n\ta -= 3 * minWeeks\n\tb -= 2 * minWeeks\n\tc -= 2 * minWeeks\n\treturn 7*minWeeks + simulateAll(a, b, c)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar a, b, c int\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &a, &b, &c)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(a, b, c))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "e91e5cef3e25c707a49b190d2e2acbc5", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n defer writer.Flush()\n var a, b, c int\n scanf(\"%d %d %d\\n\", &a, &b, &c)\n solve(a, b, c)\n}\n\n// a b c a c b a\nfunc solve(a, b, c int) {\n min := a / 3\n if b/2 < min {\n min = b / 2\n }\n if c/2 < min {\n min = c / 2\n }\n a -= min * 3\n b -= min * 2\n c -= min * 2\n max := 0\n food := []int{0, 1, 2, 0, 2, 1, 0}\n for start := range food {\n temp := 0\n cur := start\n store := []int{a, b, c}\n for true {\n cur %= 7\n store[food[cur]]--\n if store[food[cur]] < 0 {\n break\n } else {\n temp++\n }\n cur++\n }\n if temp > max {\n max = temp\n }\n }\n printf(\"%d\\n\", max+7*min)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "412b3456af6fb416209554b98cd5341c", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype vallen struct {\n\tlen, val int\n}\n\nvar orders [10]vallen = [...]vallen{\n\t{1000000000, 512},\n\t{100000000, 256},\n\t{10000000, 128},\n\t{1000000, 64},\n\t{100000, 32},\n\t{10000, 16},\n\t{1000, 8},\n\t{100, 4},\n\t{10, 2},\n\t{1, 1},\n}\n\nfunc solve() {\n\tn := readString()\n\ts := make([]byte, len(n))\n\n\trest := false\n\tfor i, c := range n {\n\t\tif rest {\n\t\t\ts[i] = '1'\n\t\t\tcontinue\n\t\t}\n\t\tif c >= '2' {\n\t\t\trest = true\n\t\t\ts[i] = '1'\n\t\t\tcontinue\n\t\t}\n\t\ts[i] = n[i]\n\t}\n\tvar r int\n\tfmt.Sscanf(string(s), \"%b\", &r)\n\tfmt.Println(r)\n}\n\nfunc solve2() {\n\tn := readInt()\n\tr := 0\n\n\tb := 1 << 30\n\tfor ; b > 0; b >>= 1 {\n\t\tr |= b\n\t\tif r > n {\n\t\t\tr &= ^b\n\t\t}\n\t}\n\tfmt.Sscanf(fmt.Sprintf(\"%d\", r), \"%b\", &r)\n\tfmt.Println(r)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n\t//solve2()\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "20600afb8c3bc88bcf574207c05d4b83", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tn := readNum(reader)\n\n\tfmt.Println(solve(n))\n}\n\nfunc readInt(bytes []byte, from int, val *int) int {\n\ti := from\n\tsign := 1\n\tif bytes[i] == '-' {\n\t\tsign = -1\n\t\ti++\n\t}\n\ttmp := 0\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + int(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp * sign\n\treturn i\n}\n\nfunc readNum(reader *bufio.Reader) (a int) {\n\tbs, _ := reader.ReadBytes('\\n')\n\treadInt(bs, 0, &a)\n\treturn\n}\n\nfunc readTwoNums(reader *bufio.Reader) (a int, b int) {\n\tres := readNNums(reader, 2)\n\ta, b = res[0], res[1]\n\treturn\n}\n\nfunc readThreeNums(reader *bufio.Reader) (a int, b int, c int) {\n\tres := readNNums(reader, 3)\n\ta, b, c = res[0], res[1], res[2]\n\treturn\n}\n\nfunc readNNums(reader *bufio.Reader, n int) []int {\n\tres := make([]int, n)\n\tx := 0\n\tbs, _ := reader.ReadBytes('\\n')\n\tfor i := 0; i < n; i++ {\n\t\tfor x < len(bs) && (bs[x] < '0' || bs[x] > '9') {\n\t\t\tx++\n\t\t}\n\t\tx = readInt(bs, x, &res[i])\n\t}\n\treturn res\n}\n\nfunc readUint64(bytes []byte, from int, val *uint64) int {\n\ti := from\n\n\tvar tmp uint64\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + uint64(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp\n\n\treturn i\n}\n\nfunc solve(n int) int {\n\txs := make([]int, 0, 10)\n\tnum := n\n\tvar i int\n\tfor num > 0 {\n\t\ti++\n\t\txs = append(xs, num%10)\n\t\tnum /= 10\n\t}\n\n\tif xs[i-1] > 1 {\n\t\treturn pow(2, i) - 1\n\t}\n\tvar res int\n\t// 112 => 100, 110, 111, 101\n\t// 102 => 100, 101\n\tfor i > 0 {\n\t\tif xs[i-1] > 1 {\n\t\t\tres += pow(2, i) - 1\n\t\t\tbreak\n\t\t}\n\t\tif xs[i-1] == 1 {\n\t\t\t// put 0 at i-1\n\t\t\tres += pow(2, i-1)\n\t\t}\n\t\t// put 1 or 0\n\t\ti--\n\t}\n\n\treturn res\n}\n\nfunc pow(a, b int) int {\n\tvar res = 1\n\tfor b > 0 {\n\t\tif b&1 == 1 {\n\t\t\tres = (res * a)\n\t\t}\n\t\ta *= a\n\t\tb >>= 1\n\t}\n\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "8257e0117c343d512c4703d93a8e305c", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"math\"\n)\n\nvar itemList map[int64]bool\n\nfunc checkNumber(list []int64, value int64) {\n\tvar result int64\n\tresult = 0\n\tlength := len(list)\n\n\tfor i := length - 1; i >= 0; i-- {\n\t\tif list[i] == 1 {\n\t\t\tresult += int64(math.Pow(10, float64(length - i - 1)))\n\t\t}\n\t}\n\n\tif result >= 1 && result <= value {\n\t\titemList[result] = true\n\t}\n}\n\nfunc calc(list []int64, length int64, startsWith int64, value int64) {\n\tif startsWith < length {\n\t\tcheckNumber(list, value)\n\t\tcalc(append([]int64{}, list...), length, startsWith + 1, value)\n\n\t\tlist[startsWith] = 1\n\n\t\tcheckNumber(list, value)\n\t\tcalc(append([]int64{}, list...), length, startsWith + 1, value)\n\t}\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tinput, _, _ := reader.ReadLine()\n\tvalue, _ := strconv.Atoi(string(input))\n\n\titemList = make(map[int64]bool, 0)\n\n\tdigitCount := int64(math.Log10(float64(value)))+1;\n\n\tlist := make([]int64, digitCount)\n\n\tcalc(list, digitCount, 0, int64(value))\n\n\tfmt.Println(len(itemList))\n}\n\nfunc main2() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tinput, _, _ := reader.ReadLine()\n\tvalue, _ := strconv.Atoi(string(input))\n\n\tresultNumber := 0\n\n\tfor i := 1; i <= value; i++ {\n\t\tnewVal := strconv.Itoa(i)\n\n\t\tresult := true\n\n\t\tfor j := 0; j < len(newVal); j ++ {\n\t\t\tif string(newVal[j]) != \"1\" && string(newVal[j]) != \"0\" {\n\t\t\t\tresult = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif result {\n\t\t\tresultNumber++\n\t\t}\n\t}\n\n\tfmt.Println(resultNumber)\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "24a52d2d33c9469d694e7be53a20c1a7", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN, K := sc.NextInt(), sc.NextInt()\n\tif N == K || K == 0 {\n\t\tfmt.Println(0, 0)\n\t\treturn\n\t}\n\tfmt.Println(1, min(K*2, N-K))\n\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "b165a7403f3fc411fc221e4e9e897ebf", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar (\n n int\n k int\n)\n\nfunc main() {\n fmt.Scan(&n, &k)\n min := 1\n max := k + 1\n if k <= n/3 {\n max = k * 2\n } else {\n max = n - k\n }\n if k == n || k == 0 || n == 0 {\n min = 0\n max = 0\n }\n fmt.Println(min, max)\n}", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "46e65105c5b3a7a8dd6ae21c5ed9c704", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tk := readInt()\n\tif k == 0 {\n\t\tfmt.Println(0, 0)\n\t\treturn\n\t}\n\ta := 0\n\tif k < n {\n\t\ta = 1\n\t}\n\tfmt.Println(a, min(n-k, k*2))\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "d8cbd29b5c08b99dd083c658ba712744", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nfunc main(){\n\tvar a, b, s, d float64\n\tfmt.Scanf(\"%f %f %f\", &a, &b, &s)\n\td = math.Abs(a) + math.Abs(b)\n\tif d <= s && int64(s-d) % 2 == 0{\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "01d30b69cb877b922e975441aecd8168", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b, s int\n abs := func(x int) int {\n if x < 0 {\n return -x\n }\n return x\n }\n fmt.Scanf(\"%d %d %d\", &a, &b, &s)\n if abs(a) + abs(b) > s || (s - abs(a) - abs(b)) & 1 != 0 {\n fmt.Println(\"No\")\n } else {\n fmt.Println(\"Yes\")\n }\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "56f7499d84e2d9d383a2d81d1d502884", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\ta, b, s := nextInt(), nextInt(), nextInt()\n\n\tstep := abs(a) + abs(b)\n\n\tif s < step || abs(s-step)%2 == 1 {\n\t\tprintln(\"No\")\n\t} else {\n\t\tprintln(\"Yes\")\n\t}\n\n}\n\nfunc abs(n int) int {\n\tif n < 0 {\n\t\treturn -n\n\t}\n\n\treturn n\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "87efe14175888e612e20aac8f3e96b0d", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\n\tsquares := []rune(s)\n\n\tisFound := false\n\tfor i := 0; i < len(s)-2; i++ {\n\t\tfirst, second, third := squares[i], squares[i+1], squares[i+2]\n\n\t\tif (first == 'A' && second == 'B' && third == 'C') ||\n\t\t\t(first == 'A' && second == 'C' && third == 'B') ||\n\t\t\t(first == 'B' && second == 'A' && third == 'C') ||\n\t\t\t(first == 'B' && second == 'C' && third == 'A') ||\n\t\t\t(first == 'C' && second == 'A' && third == 'B') ||\n\t\t\t(first == 'C' && second == 'B' && third == 'A') {\n\t\t\t\tfmt.Print(\"YES\")\n\t\t\t\tisFound = true\n\t\t\t\tbreak\n\t\t}\n\t}\n\tif !isFound {\n\t\tfmt.Print(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "1aceeceb3cf86d844cbab256d173a4ec", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\n\tif strings.Index(s, \"ABC\") != -1 || strings.Index(s, \"BAC\") != -1 ||\n\t\tstrings.Index(s, \"CAB\") != -1 || strings.Index(s, \"ACB\") != -1 ||\n\t\tstrings.Index(s, \"BCA\") != -1 || strings.Index(s, \"CBA\") != -1 {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "af760939f79da4354873b2bc1676a9e6", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tn := len(s)\n\tfor i := 0; i < n - 2; i++ {\n\t\tmark := make([]bool, 3)\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif s[i + j] != '.' {\n\t\t\t\tmark[int(s[i + j]) - int('A')] = true\n\t\t\t}\n\t\t}\n\t\tvalid := true\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif !mark[j] {\n\t\t\t\tvalid = false\n\t\t\t}\n\t\t}\n\t\tif valid {\n\t\t\tfmt.Println(\"Yes\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"No\")\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "4b5e6f636fb8bd16527b21986cd77675", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 785 B Anton and Classes done\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"strings\"\n\t\"strconv\"\n\t\"os\"\n\t\"sort\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n\tvar a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor i:=0; i max {\n\t\t\tmax = xs[i]\n\t\t}\n\t}\n\treturn max\n}\n\nfunc ix(gs [][]Cell, i, j int) Cell {\n\tif i < 0 || j < 0 || i > len(gs)-1 || j > len(gs[i])-1 {\n\t\treturn EmptyCell\n\t}\n\n\treturn gs[i][j]\n}\n\nfunc copyGrid(gs [][]Cell) [][]Cell {\n\tcs := make([][]Cell, len(gs))\n\tfor i := 0; i < len(gs); i++ {\n\t\tcs[i] = make([]Cell, len(gs[i]))\n\t\tcopy(cs[i], gs[i])\n\t}\n\treturn cs\n}\n\nfunc copyAppend(ys []int, xs ...int) []int {\n\tns := make([]int, len(ys), len(ys)+len(xs))\n\tcopy(ns, ys)\n\treturn append(ns, xs...)\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc toLower(x byte) byte {\n\treturn x + ('a' - 'A')\n}\n\nfunc isUpper(x byte) bool {\n\treturn x >= 'A' && x <= 'Z'\n}\n\nfunc initArray(n, x int) []int {\n\txs := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\txs[i] = x\n\t}\n\treturn xs\n}\n\nfunc nextInt(s *bufio.Scanner) (n int) {\n\ts.Scan()\n\tn, _ = strconv.Atoi(s.Text())\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "e71ceb76422405c3fff2d2593e69fae8", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,m int\n var s [10]string\n var f [10][10]bool\n di := [4]int{-1,0,1,0}\n dj := [4]int{0,1,0,-1}\n fmt.Scan(&n,&m)\n for i := 0; i < n; i++ { fmt.Scan(&s[i]) }\n ans := 0\n for i := 0; i < n; i++ {\n for j := 0; j < m; j++ {\n if s[i][j] == 'W' {\n for k := 0; k < 4; k++ {\n ni, nj := i+di[k], j+dj[k]\n if (ni >= 0) && (ni < n) && (nj >= 0) && (nj < m) && (s[ni][nj] == 'P') && (!f[ni][nj]) {\n ans++\n f[ni][nj] = true\n break\n }\n }\n }\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "ea5e7a017ae533cf99dfbd68109e1668", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nvar board [][]byte\nvar max [][]int\nvar n, m = 0, 0\n\nfunc findMax() int {\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < m; j++ {\n\t\t\tif board[i][j] == 'W' {\n\t\t\t\ta, b, c, d := 0, 0, 0, 0\n\t\t\t\tif i > 0 && board[i-1][j] == 'P' {\n\t\t\t\t\ta = max[i-1][j] + 1\n\t\t\t\t}\n\t\t\t\tif j > 0 && board[i][j-1] == 'P' {\n\t\t\t\t\tb = max[i][j-1] + 1\n\t\t\t\t}\n\t\t\t\tif i < n - 1 && board[i+1][j] == 'P' {\n\t\t\t\t\tc = max[i+1][j] + 1\n\t\t\t\t}\n\t\t\t\tif j < m - 1 && board[i][j+1] == 'P' {\n\t\t\t\t\td = max[i][j+1] + 1\n\t\t\t\t}\n\t\t\t\tvar s = []int {a, b, c, d}\n\t\t\t\tsort.Sort(sort.Reverse(sort.IntSlice(s)))\n\t\t\t\tmax[i][j] = s[0]\n\t\t\t}\n\t\t}\n\t}\n\tr := 0;\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < m; j++ {\n\t\t\tr += max[i][j]\n\t\t}\n\t}\n\treturn r\n}\n\nfunc main() {\n\tfmt.Scan(&n, &m)\n\tboard = make([][]byte, n)\n\tmax = make([][]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tboard[i] = make([]byte, m)\n\t\tmax[i] = make([]int, m)\n\t\tvar s string\n\t\tfmt.Scan(&s)\n\t\tfor j := 0; j < m; j++ {\n\t\t\tboard[i][j] = s[j]\n\t\t}\n\t}\n\tfmt.Println(findMax())\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "449db0129666b79301a32859fb63fb44", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n\n n := ReadInt32()\n m := ReadInt32()\n s1 := ReadString()\n s2 := ReadString()\n count := n * m\n a := make([][]int, count)\n for i := 0; i < count; i++ {\n a[i] = make([]int, count)\n a[i][i] = 1\n }\n\n for i := 0; i < m; i++ {\n if s2[i] == 'v' {\n for j := 0; j < n-1; j++ {\n for k := j + 1; k < n; k++ {\n a[j*m+i][k*m+i] = 1\n }\n }\n } else {\n for j := n - 1; j > 0; j-- {\n for k := j - 1; k >= 0; k-- {\n a[j*m+i][k*m+i] = 1\n }\n }\n }\n }\n\n for i := 0; i < n; i++ {\n if s1[i] == '>' {\n for j := 0; j < m-1; j++ {\n for k := j + 1; k < m; k++ {\n a[i*m+j][i*m+k] = 1\n }\n }\n } else {\n for j := m - 1; j > 0; j-- {\n for k := j - 1; k >= 0; k-- {\n a[i*m+j][i*m+k] = 1\n }\n }\n }\n }\n\n for k := 0; k < count; k++ {\n for i := 0; i < count; i++ {\n for j := 0; j < count; j++ {\n if a[i][k] == 1 && a[k][j] == 1 {\n a[i][j] = 1\n }\n }\n }\n }\n\n f := true\n\n for i := 0; (i < count) && (f); i++ {\n for j := 0; (j < count) && (f); j++ {\n f = a[i][j] != 0\n }\n }\n\n if f {\n writer.WriteString(\"YES\\n\")\n } else {\n writer.WriteString(\"NO\\n\")\n }\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "dccdf33b33c6589f6f994a4f21b906e2", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nvar (\n n, m, count int\n row, col string\n visited []bool\n)\n\nfunc dfs(i, j int) {\n index := i*m + j\n if i < 0 || j < 0 || i >= n || j >= m || visited[index] {\n return\n }\n\n visited[index] = true\n\n if row[i] == '>' {\n dfs(i, j+1)\n } else {\n dfs(i, j-1)\n }\n\n if col[j] == 'v' {\n dfs(i+1, j)\n } else {\n dfs(i-1, j)\n }\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n\n n = ReadInt32()\n m = ReadInt32()\n row = ReadString()\n col = ReadString()\n count = n * m\n f := true\n\n for i := 0; (i < n) && (f); i++ {\n for j := 0; (j < m) && (f); j++ {\n visited = make([]bool, count)\n dfs(i, j)\n for k := 0; (k < count) && (f); k++ {\n f = visited[k]\n }\n }\n }\n\n if f {\n writer.WriteString(\"YES\\n\")\n } else {\n writer.WriteString(\"NO\\n\")\n }\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "eb825fdbf0bdfbd8ea7ab1ce9d9ce0f2", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\ntype Vertex struct {\n\tneighbors []*Vertex\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\\n\", &n, &m)\n\tg1 := make([][]*Vertex, n)\n\tg2 := make([][]*Vertex, n)\n\tfor i := range g1 {\n\t\tg1[i] = make([]*Vertex, m)\n\t\tg2[i] = make([]*Vertex, m)\n\t\tfor j := range g1[i] {\n\t\t\tg1[i][j] = &Vertex{neighbors: make([]*Vertex, 2)}\n\t\t\tg2[i][j] = &Vertex{neighbors: make([]*Vertex, 2)}\n\t\t}\n\t}\n\tvar horizon, vertical string\n\tfmt.Scanf(\"%s\\n\", &horizon)\n\tfmt.Scanf(\"%s\\n\", &vertical)\n\tfor i, c := range horizon {\n\t\tif c == '>' {\n\t\t\tfor j := 0; j < m-1; j++ {\n\t\t\t\tg1[i][j].neighbors[0] = g1[i][j+1]\n\t\t\t}\n\t\t\tfor j := 1; j < m; j++ {\n\t\t\t\tg2[i][j].neighbors[0] = g2[i][j-1]\n\t\t\t}\n\t\t} else {\n\t\t\tfor j := 1; j < m; j++ {\n\t\t\t\tg1[i][j].neighbors[0] = g1[i][j-1]\n\t\t\t}\n\t\t\tfor j := 0; j < m-1; j++ {\n\t\t\t\tg2[i][j].neighbors[0] = g2[i][j+1]\n\t\t\t}\n\t\t}\n\t}\n\tfor j, c := range vertical {\n\t\tif c == 'v' {\n\t\t\tfor i := 0; i < n-1; i++ {\n\t\t\t\tg1[i][j].neighbors[1] = g1[i+1][j]\n\t\t\t}\n\t\t\tfor i := 1; i < n; i++ {\n\t\t\t\tg2[i][j].neighbors[1] = g2[i-1][j]\n\t\t\t}\n\t\t} else {\n\t\t\tfor i := 1; i < n; i++ {\n\t\t\t\tg1[i][j].neighbors[1] = g1[i-1][j]\n\t\t\t}\n\t\t\tfor i := 0; i < n-1; i++ {\n\t\t\t\tg2[i][j].neighbors[1] = g2[i+1][j]\n\t\t\t}\n\n\t\t}\n\t}\n\tif dfs(g1) && dfs(g2) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc dfs(g [][]*Vertex) bool {\n\tvisited := make(map[*Vertex]struct{})\n\tv := g[0][0]\n\tdfsRecurse(v, visited)\n\treturn len(visited) == len(g) * len(g[0])\n\n}\n\nfunc dfsRecurse(v *Vertex, visited map[*Vertex]struct{}) {\n\tvisited[v] = struct{}{}\n\tfor _, n := range v.neighbors {\n\t\tif n == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := visited[n]; !ok {\n\t\t\tdfsRecurse(n, visited)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "9ab1524916f34f417b8796b6eca575f6", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc gcd(a, b int) int {\n if a == 0 || b == 0 {\n return 1\n }\n if a < 0 {\n a = -a\n }\n if b < 0 {\n b = -b\n }\n for b != 0 {\n a, b = b, a%b\n }\n return a\n}\n\ntype Fraction struct {\n A, B int\n Invalid bool\n}\n\nfunc makeFraction(a, b int) Fraction {\n if b == 0 {\n return Fraction{ Invalid: true }\n }\n if a == 0 {\n return Fraction{ B: 1 }\n }\n if b < 0 {\n a, b = -a, -b\n }\n g := gcd(a, b)\n return Fraction{ A: a/g, B: b/g }\n}\n\ntype Line struct {\n A, B, C int\n Slope, Intercept Fraction\n Empty, Plane, Vertical, Horizontal bool\n}\n\nfunc makeLine(a, b, c int) Line {\n line := Line{ A: a, B: b, C: c }\n line.Slope = makeFraction(-a, b)\n line.Intercept = makeFraction(-c, b)\n if a == 0 && b == 0 {\n if c == 0 {\n line.Plane = true\n } else {\n line.Empty = true\n }\n } else if a == 0 {\n line.Horizontal = true\n } else if b == 0 {\n line.Vertical = true\n }\n return line\n}\n\nfunc solve(q, r Line) int {\n if q.Empty || r.Empty {\n return 0\n }\n if q.Plane || r.Plane {\n return -1\n }\n if q.Horizontal && r.Horizontal {\n if q.Intercept == r.Intercept {\n return -1\n }\n return 0\n }\n if q.Vertical && r.Vertical {\n if makeFraction(-q.C, q.A) == makeFraction(-r.C, r.A) {\n return -1\n }\n return 0\n }\n if q.Horizontal || q.Vertical || r.Horizontal || r.Vertical {\n return 1\n }\n if q.Slope == r.Slope {\n if q.Intercept == r.Intercept {\n return -1\n }\n return 0\n }\n return 1\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n q := makeLine(getI(), getI(), getI())\n r := makeLine(getI(), getI(), getI())\n writer.WriteString(fmt.Sprintf(\"%d\\n\", solve(q, r)))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "b1b9f9c5525a45e3f20cfa4f4eb69f4a", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"io/ioutil\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\tvar a1,b1,c1,a2,b2,c2 int\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &a1, &b1, &c1)\n\tfmt.Fscanf(reader, \"%d %d %d\", &a2, &b2, &c2)\n\n\tif a1 * b2 - a2 * b1 != 0 {\n\t\tfmt.Printf(\"1\")\n\t} else if a1 * c2 - a2 * c1 == 0 && b1 * c2 - b2 * c1 == 0{\n\t\tif a1 == 0 && a2 == 0 && b1 == 0 && b2 == 0 && (c1 != 0 || c2 != 0) {\n\t\t\tfmt.Printf(\"0\")\n\t\t} else {\n\t\t\tfmt.Printf(\"-1\")\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"0\")\n\t}\n\treturn\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "273a099f8ded839ad302c91eaaa3feb4", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn := 0\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tif n < 10 {\n\t\tfmt.Fprintf(out, \"%d\\n\", n)\n\t\treturn\n\t}\n\ta := make([]int, 0)\n\tfor n > 0 {\n\t\ta = append(a, n%10)\n\t\tn /= 10\n\t}\n\tb := make([]int, len(a))\n\tfor i := 0; i < len(a); i++ {\n\t\tb[i] = a[len(a)-i-1]\n\t}\n\tans := 1\n\tfor i := 0; i < len(a); i++ {\n\t\tans *= b[i]\n\t}\n\ttmp := 1\n\tfor i := 1; i < len(a); i++ {\n\t\ttmp *= 9\n\t}\n\tif tmp > ans {\n\t\tans = tmp\n\t}\n\t// c := make([]int, len(b))\n\t// for i := 0; i < len(b); i++ {\n\t// \tc[i] = b[i]\n\t// }\n\n\tfor i := 0; i < len(b); i++ {\n\t\tif b[i] > 1 {\n\t\t\ttmp := 1\n\t\t\tfor j := 0; j < i; j++ {\n\t\t\t\ttmp *= b[j]\n\t\t\t}\n\t\t\ttmp *= b[i] - 1\n\t\t\tfor j := i + 1; j < len(b); j++ {\n\t\t\t\ttmp *= 9\n\t\t\t}\n\t\t\tif tmp > ans {\n\t\t\t\tans = tmp\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", ans)\n\treturn\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "f909b6ae88ad3c8634293d93c2e3df8f", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc max(a, b int) (int) {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc power(a int) (int) {\n\tif a < 10 {\n\t\treturn a\n\t}\n\t//fmt.Println(a)\n\n\torder := int(math.Floor(math.Log10(float64(a))))\n\taddition := max(a / int(math.Pow10(order)) - 1, 1)\n\ttop := int(math.Pow(9.0, float64(order))) * addition\n\n\t//fmt.Println(\"Versus\", top, \"order\", order, \"addition\", addition)\n\treturn max(top, (a / int(math.Pow10(order))) * power(a % int(math.Pow10(order))))\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfmt.Println(power(n))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "c48d2615644dcb7064e8b46242f10c33", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1143/problem/B\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc getLength(n int) int {\n\tlength := 0\n\tfor n > 0 {\n\t\tn /= 10\n\t\tlength += 1\n\n\t}\n\treturn length\n}\n\nfunc max(x int64, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc product(n int) int64 {\n\tproduct := int64(1)\n\tfor n > 0 {\n\t\tproduct *= int64(n % 10)\n\t\tn /= 10\n\t}\n\treturn product\n}\n\nfunc Solve(n int) int64 {\n\tbase := 10\n\tmaxProduct := int64(0)\n\tfor n > 0 {\n\t\tmaxProduct = max(maxProduct, product(n))\n\t\tn -= (n%base + 1)\n\t\tbase *= 10\n\t}\n\treturn maxProduct\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "4d3f055287d312abc7304de73de9a60b", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nvar a, b int64\nvar aDiv, bDiv, sumDiv []int64\n\n\nfunc checkDivisor(d []int64, n, div int64) []int64 {\n\tif n % div == 0 && div * div <= n {\n\t\td = append(d, div)\n\t\tq := n / div\n\t\tif q * q != n {\n\t\t\td = append(d, q)\n\t\t}\n\t}\n\treturn d\n}\n\nfunc checkBest(divs []int64, n int64, smaller, bigger int64, best *int64) {\n\tld := len(divs)\n\tl := sort.Search(ld, func(ind int) bool {\n\t\treturn smaller < divs[ind]\n\t})\n\tif l == ld && divs[l - 1] > smaller {\n\t\treturn\n\t}\n\ty := n / divs[l - 1]\n\tif y <= bigger {\n\t\ttmp := 2 * (smaller + bigger)\n\t\tif tmp < *best {\n\t\t\t*best = tmp\n\t\t}\n\t}\n}\n\n\nfunc main() {\n\tfmt.Scanf(\"%d %d\", &a, &b)\n\ts := a + b\n\taDiv, bDiv, sumDiv = make([]int64, 0), make([]int64, 0), make([]int64, 0)\n\n\tfor i := int64(1); i*i <= s; i++ {\n\t\taDiv = checkDivisor(aDiv, a, i)\n\t\tbDiv = checkDivisor(bDiv, b, i)\n\t\tsumDiv = checkDivisor(sumDiv, s, i)\n\t}\n\n\tmakeLess := func(s []int64) func(x, y int) bool {\n\t\treturn func(x, y int) bool {\n\t\t\treturn s[x] < s[y]\n\t\t}\n\t}\n\n\tsort.Slice(aDiv, makeLess(aDiv))\n\tsort.Slice(bDiv, makeLess(bDiv))\n\tsort.Slice(sumDiv, makeLess(sumDiv))\n\n\tbest := (s + 1) * 2\n\n\tfor i := 0; i < len(sumDiv); i++ {\n\t\tsmaller := sumDiv[i]\n\t\tif smaller * smaller > s {\n\t\t\tbreak\n\t\t}\n\t\tbigger := s / smaller\n\t\tcheckBest(aDiv, a, smaller, bigger, &best)\n\t\tcheckBest(bDiv, b, smaller, bigger, &best)\n\t}\n\n\tfmt.Println(best)\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "a9859254acf2aec47f882d7869b64bec", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc factorize(x int64) (length int, result [50]int64) {\n ri:=0\n reminder:=x\n lastdivider:=int64(2)\n for 1=0; i-- {\n vec[i]++\n if pab[i]=0; i-- {\n veca[i]=0\n }\n \n xa:=int64(1)\n \nMainLoopA:\n for {\n for i:=la; i>=0; i-- {\n veca[i]++\n if pa[i]=0; i-- {\n vecb[i]=0\n }\n\n xb:=int64(1)\n \n MainLoopB:\n for {\n for i:=lb; i>=0; i-- {\n vecb[i]++\n if pb[i] 1 && chars[len(chars)-1] == '/' {\n chars = chars[:len(chars)-1]\n }\n writer.WriteString(fmt.Sprintf(\"%s\\n\", string(chars)))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fe59d0f867064bf91428636f573a8afe", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int\n\tfor I(&n, \" \") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int) {\n\tvar m int\n\tI(&m, \"\\n\")\n\tmm := map[int]int{\n\t\t1: 31,\n\t\t2: 28,\n\t\t3: 31,\n\t\t4: 30,\n\t\t5: 31,\n\t\t6: 30,\n\t\t7: 31,\n\t\t8: 31,\n\t\t9: 30,\n\t\t10: 31,\n\t\t11: 30,\n\t\t12: 31,\n\t}\n\tans := (mm[n] + m - 1) / 7\n\tif (mm[n]+m-1)%7 != 0 {\n\t\tans++\n\t}\n\tO(ans, \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "93431bce3066d4aae30fac3854db4f1a", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tdaysInMonths := []int{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}\n\tm := readInt()\n\td := readInt()\n\tdays := daysInMonths[m-1] + d - 1\n\tweeks := days / 7\n\tif days%7 != 0 {\n\t\tweeks++\n\t}\n\tfmt.Println(weeks)\n}\n\nfunc getStats(str string) map[byte]int {\n\tstat := map[byte]int{}\n\tfor _, v := range str {\n\t\tstat[byte(v)]++\n\t}\n\treturn stat\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9a7aff5146e7c76bb881670c91a1897f", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tm,d,cnt:=0,0,1\n\tfmt.Scanln(&m,&d)\n\tdays:=[]int{0,31,28,31,30,31,30,31,31,30,31,30,31}\n\td--\n\tif d==0{\n\t\tcnt--\n\t}\n\tfor i := 0; i 0 && data[1] == 2 {\n\t\t\t\trem++\n\t\t\t}\n\n\t\t\tif cur == N-1 && rem >= 0 && len(data) > 1 && data[len(data)-2] == 999 {\n\t\t\t\trem++\n\t\t\t}\n\t\t\tif rem > del {\n\t\t\t\t//fmt.Println(\"st\", start, \"cur\", cur, \"rem\", rem)\n\t\t\t\tdel = rem\n\t\t\t}\n\t\t\tstart = cur + 1\n\t\t}\n\t}\n\t//fmt.Println(\"xx\", del)\n\tfmt.Println(del)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "8774775b12d00fd8a9f788fbafd93020", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Group the consecutive elements\n// When a group start with 1 or end with 1000, it can contribute \"length - 1\" items.\n// \"length - 2\" otherwise.\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\tg, cur := [][]int{[]int{-1}}, 0\n\n\tfor i := 0; i < n; i++ {\n\t\tscanner.Scan()\n\t\tnum, _ := strconv.Atoi(scanner.Text())\n\t\tif g[cur][len(g[cur])-1] == num-1 {\n\t\t\tg[cur] = append(g[cur], num)\n\t\t} else {\n\t\t\tg = append(g, []int{num})\n\t\t\tcur++\n\t\t}\n\t}\n\n\t// sum := 0\n\t// for _, v := range g {\n\t// \tif len(v) < 2 {\n\t// \t\tcontinue\n\t// \t}\n\t// \tif (v[0] == 1) || (v[len(v)-1] == 1000) {\n\t// \t\tsum += len(v) - 1\n\t// \t} else {\n\t// \t\tsum += len(v) - 2\n\t// \t}\n\t// }\n\t// fmt.Println(sum)\n\n\tmax := 0\n\tfor _, v := range g {\n\t\tif len(v) < 2 {\n\t\t\tcontinue\n\t\t}\n\t\tl := 0\n\t\tif (v[0] == 1) || (v[len(v)-1] == 1000) {\n\t\t\tl = len(v) - 1\n\t\t} else {\n\t\t\tl = len(v) - 2\n\t\t}\n\t\tif l > max {\n\t\t\tmax = l\n\t\t}\n\t}\n\tfmt.Println(max)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "f400206c3343f4e1b74c738be838c3c1", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"io\"\n\t\"bufio\"\n)\nvar input io.Reader\n\nfunc main() {\n\tvar n, k int\n\tinput = bufio.NewReader(os.Stdin)\n\tfmt.Fscanln(input, &n, &k)\n\tl, r := 0, n\n\tfor l < r {\n\t\tmid := l + (r - l) / 2\n\t\td := k\n\t\tlines := mid\n\t\tfor lines < n && mid / d > 0 {\n\t\t\tlines += mid/d\n\t\t\td *= k\n\t\t}\n\t\tif lines < n {\n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\n\tfmt.Println(r)\n}\n", "lang_cluster": "Go", "tags": ["implementation", "binary search"], "code_uid": "5b50061b2b2729a4515a596de6effc1c", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\t\n\tvar n int64\n\tvar k int64\n\tfmt.Scan(&n)\n\tfmt.Scan(&k)\n\tvar l int64 = 0\n\tvar r int64 = 1000000000 \n\tvar good int64 = -1\n\tfor{\n\t\tmid := l + (r-l)/2\n\t\tcop := mid \n\t\tvar sum int64 = 0\n\t\tfor{\n\t\t\tsum += cop\n\t\t\tcop = cop/k\n\t\t\tif cop == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif sum >= n {\n\t\t\tgood = mid\n\t\t\tr = mid-1\n\t\t} else {\n\t\t\tl = mid+1\n\t\t}\n\t\tif l > r {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Print(good,\"\\n\")\n\t\n}\n", "lang_cluster": "Go", "tags": ["implementation", "binary search"], "code_uid": "b9589d8e2fd62e1fd41a3cf7b764e105", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,k,l,h,m,t,ans,s int\n\tfmt.Scan(&n,&k)\n\tl=0\n\th=n\n\tfor l<=h {\n\t\tm=(l+h)>>1\n\t\tt=m\n\t\tans=m\n\t\tfor t!=0 {\n\t\t\tif t 1 {\n\t\t\tprintf(\"BUG\\n\")\n\t\t\treturn\n\t\t}\n\t\tvisited[int64(x * 1000 + y)] = true\n\t}\n\tprintf(\"OK\\n\")\n}\n\nvar lineScanner *Scanner\nvar wordScanner *Scanner\n\nfunc init() {\n\tlineScanner = NewScanner(os.Stdin)\n\twordScanner = NewScanner(strings.NewReader(\"\"))\n\twordScanner.Split(ScanWords)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Printf(format, a...)\n}\nfunc nextLine() (string, error) {\n\tif !lineScanner.Scan() {\n\t\tif err := lineScanner.Err(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\treturn \"\", errors.New(\"nextLine: EOF reached\")\n\t}\n\treturn lineScanner.Text(), nil\n}\n\nfunc nextWord() string {\n\tfor !wordScanner.Scan() {\n\t\tif err := wordScanner.Err(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tline, err := nextLine()\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\twordScanner = NewScanner(strings.NewReader(line))\n\t\twordScanner.Split(ScanWords)\n\t}\n\treturn wordScanner.Text()\n}\n\nfunc nextInt() int {\n\tres, err := strconv.Atoi(nextWord())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc nextInt64() int64 {\n\tres, err := strconv.ParseInt(nextWord(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc nextFloat64() float64 {\n\tres, err := strconv.ParseFloat(nextWord(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\n// Scanner provides a convenient interface for reading data such as\n// a file of newline-delimited lines of text. Successive calls to\n// the Scan method will step through the 'tokens' of a file, skipping\n// the bytes between the tokens. The specification of a token is\n// defined by a split function of type SplitFunc; the default split\n// function breaks the input into lines with line termination stripped. Split\n// functions are defined in this package for scanning a file into\n// lines, bytes, UTF-8-encoded runes, and space-delimited words. The\n// client may instead provide a custom split function.\n//\n// Scanning stops unrecoverably at EOF, the first I/O error, or a token too\n// large to fit in the buffer. When a scan stops, the reader may have\n// advanced arbitrarily far past the last token. Programs that need more\n// control over error handling or large tokens, or must run sequential scans\n// on a reader, should use bufio.Reader instead.\n//\ntype Scanner struct {\n\tr io.Reader // The reader provided by the client.\n\tsplit SplitFunc // The function to split the tokens.\n\tmaxTokenSize int // Maximum size of a token; modified by tests.\n\ttoken []byte // Last token returned by split.\n\tbuf []byte // Buffer used as argument to split.\n\tstart int // First non-processed byte in buf.\n\tend int // End of data in buf.\n\terr error // Sticky error.\n\tempties int // Count of successive empty tokens.\n\tscanCalled bool // Scan has been called; buffer is in use.\n\tdone bool // Scan has finished.\n}\n\n// SplitFunc is the signature of the split function used to tokenize the\n// input. The arguments are an initial substring of the remaining unprocessed\n// data and a flag, atEOF, that reports whether the Reader has no more data\n// to give. The return values are the number of bytes to advance the input\n// and the next token to return to the user, plus an error, if any. If the\n// data does not yet hold a complete token, for instance if it has no newline\n// while scanning lines, SplitFunc can return (0, nil, nil) to signal the\n// Scanner to read more data into the slice and try again with a longer slice\n// starting at the same point in the input.\n//\n// If the returned error is non-nil, scanning stops and the error\n// is returned to the client.\n//\n// The function is never called with an empty data slice unless atEOF\n// is true. If atEOF is true, however, data may be non-empty and,\n// as always, holds unprocessed text.\ntype SplitFunc func(data []byte, atEOF bool) (advance int, token []byte, err error)\n\n// Errors returned by Scanner.\nvar (\n\tErrTooLong = errors.New(\"bufio.Scanner: token too long\")\n\tErrNegativeAdvance = errors.New(\"bufio.Scanner: SplitFunc returns negative advance count\")\n\tErrAdvanceTooFar = errors.New(\"bufio.Scanner: SplitFunc returns advance count beyond input\")\n)\n\nconst (\n\t// MaxScanTokenSize is the maximum size used to buffer a token\n\t// unless the user provides an explicit buffer with Scan.Buffer.\n\t// The actual maximum token size may be smaller as the buffer\n\t// may need to include, for instance, a newline.\n\tMaxScanTokenSize = 2 * 1024 * 2014\n\n\tstartBufSize = 4096 // Size of initial allocation for buffer.\n)\n\n// NewScanner returns a new Scanner to read from r.\n// The split function defaults to ScanLines.\nfunc NewScanner(r io.Reader) *Scanner {\n\treturn &Scanner{\n\t\tr: r,\n\t\tsplit: ScanLines,\n\t\tmaxTokenSize: MaxScanTokenSize,\n\t}\n}\n\n// Err returns the first non-EOF error that was encountered by the Scanner.\nfunc (s *Scanner) Err() error {\n\tif s.err == io.EOF {\n\t\treturn nil\n\t}\n\treturn s.err\n}\n\n// Bytes returns the most recent token generated by a call to Scan.\n// The underlying array may point to data that will be overwritten\n// by a subsequent call to Scan. It does no allocation.\nfunc (s *Scanner) Bytes() []byte {\n\treturn s.token\n}\n\n// Text returns the most recent token generated by a call to Scan\n// as a newly allocated string holding its bytes.\nfunc (s *Scanner) Text() string {\n\treturn string(s.token)\n}\n\n// ErrFinalToken is a special sentinel error value. It is intended to be\n// returned by a Split function to indicate that the token being delivered\n// with the error is the last token and scanning should stop after this one.\n// After ErrFinalToken is received by Scan, scanning stops with no error.\n// The value is useful to stop processing early or when it is necessary to\n// deliver a final empty token. One could achieve the same behavior\n// with a custom error value but providing one here is tidier.\n// See the emptyFinalToken example for a use of this value.\nvar ErrFinalToken = errors.New(\"final token\")\n\n// Scan advances the Scanner to the next token, which will then be\n// available through the Bytes or Text method. It returns false when the\n// scan stops, either by reaching the end of the input or an error.\n// After Scan returns false, the Err method will return any error that\n// occurred during scanning, except that if it was io.EOF, Err\n// will return nil.\n// Scan panics if the split function returns 100 empty tokens without\n// advancing the input. This is a common error mode for scanners.\nfunc (s *Scanner) Scan() bool {\n\tif s.done {\n\t\treturn false\n\t}\n\ts.scanCalled = true\n\t// Loop until we have a token.\n\tfor {\n\t\t// See if we can get a token with what we already have.\n\t\t// If we've run out of data but have an error, give the split function\n\t\t// a chance to recover any remaining, possibly empty token.\n\t\tif s.end > s.start || s.err != nil {\n\t\t\tadvance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)\n\t\t\tif err != nil {\n\t\t\t\tif err == ErrFinalToken {\n\t\t\t\t\ts.token = token\n\t\t\t\t\ts.done = true\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\ts.setErr(err)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !s.advance(advance) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ts.token = token\n\t\t\tif token != nil {\n\t\t\t\tif s.err == nil || advance > 0 {\n\t\t\t\t\ts.empties = 0\n\t\t\t\t} else {\n\t\t\t\t\t// Returning tokens not advancing input at EOF.\n\t\t\t\t\ts.empties++\n\t\t\t\t\tif s.empties > 100 {\n\t\t\t\t\t\tpanic(\"bufio.Scan: 100 empty tokens without progressing\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\t// We cannot generate a token with what we are holding.\n\t\t// If we've already hit EOF or an I/O error, we are done.\n\t\tif s.err != nil {\n\t\t\t// Shut it down.\n\t\t\ts.start = 0\n\t\t\ts.end = 0\n\t\t\treturn false\n\t\t}\n\t\t// Must read more data.\n\t\t// First, shift data to beginning of buffer if there's lots of empty space\n\t\t// or space is needed.\n\t\tif s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf) / 2) {\n\t\t\tcopy(s.buf, s.buf[s.start:s.end])\n\t\t\ts.end -= s.start\n\t\t\ts.start = 0\n\t\t}\n\t\t// Is the buffer full? If so, resize.\n\t\tif s.end == len(s.buf) {\n\t\t\t// Guarantee no overflow in the multiplication below.\n\t\t\tconst maxInt = int(^uint(0) >> 1)\n\t\t\tif len(s.buf) >= s.maxTokenSize || len(s.buf) > maxInt / 2 {\n\t\t\t\ts.setErr(ErrTooLong)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tnewSize := len(s.buf) * 2\n\t\t\tif newSize == 0 {\n\t\t\t\tnewSize = startBufSize\n\t\t\t}\n\t\t\tif newSize > s.maxTokenSize {\n\t\t\t\tnewSize = s.maxTokenSize\n\t\t\t}\n\t\t\tnewBuf := make([]byte, newSize)\n\t\t\tcopy(newBuf, s.buf[s.start:s.end])\n\t\t\ts.buf = newBuf\n\t\t\ts.end -= s.start\n\t\t\ts.start = 0\n\t\t\tcontinue\n\t\t}\n\t\t// Finally we can read some input. Make sure we don't get stuck with\n\t\t// a misbehaving Reader. Officially we don't need to do this, but let's\n\t\t// be extra careful: Scanner is for safe, simple jobs.\n\t\tfor loop := 0; ; {\n\t\t\tn, err := s.r.Read(s.buf[s.end:len(s.buf)])\n\t\t\ts.end += n\n\t\t\tif err != nil {\n\t\t\t\ts.setErr(err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif n > 0 {\n\t\t\t\ts.empties = 0\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tloop++\n\t\t\tif loop > 10 {\n\t\t\t\ts.setErr(io.ErrNoProgress)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\n// advance consumes n bytes of the buffer. It reports whether the advance was legal.\nfunc (s *Scanner) advance(n int) bool {\n\tif n < 0 {\n\t\ts.setErr(ErrNegativeAdvance)\n\t\treturn false\n\t}\n\tif n > s.end - s.start {\n\t\ts.setErr(ErrAdvanceTooFar)\n\t\treturn false\n\t}\n\ts.start += n\n\treturn true\n}\n\n// setErr records the first error encountered.\nfunc (s *Scanner) setErr(err error) {\n\tif s.err == nil || s.err == io.EOF {\n\t\ts.err = err\n\t}\n}\n\n// Buffer sets the initial buffer to use when scanning and the maximum\n// size of buffer that may be allocated during scanning. The maximum\n// token size is the larger of max and cap(buf). If max <= cap(buf),\n// Scan will use this buffer only and do no allocation.\n//\n// By default, Scan uses an internal buffer and sets the\n// maximum token size to MaxScanTokenSize.\n//\n// Buffer panics if it is called after scanning has started.\nfunc (s *Scanner) Buffer(buf []byte, max int) {\n\tif s.scanCalled {\n\t\tpanic(\"Buffer called after Scan\")\n\t}\n\ts.buf = buf[0:cap(buf)]\n\ts.maxTokenSize = max\n}\n\n// Split sets the split function for the Scanner.\n// The default split function is ScanLines.\n//\n// Split panics if it is called after scanning has started.\nfunc (s *Scanner) Split(split SplitFunc) {\n\tif s.scanCalled {\n\t\tpanic(\"Split called after Scan\")\n\t}\n\ts.split = split\n}\n\n// Split functions\n\n// ScanBytes is a split function for a Scanner that returns each byte as a token.\nfunc ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\treturn 1, data[0:1], nil\n}\n\nvar errorRune = []byte(string(utf8.RuneError))\n\n// ScanRunes is a split function for a Scanner that returns each\n// UTF-8-encoded rune as a token. The sequence of runes returned is\n// equivalent to that from a range loop over the input as a string, which\n// means that erroneous UTF-8 encodings translate to U+FFFD = \"\\xef\\xbf\\xbd\".\n// Because of the Scan interface, this makes it impossible for the client to\n// distinguish correctly encoded replacement runes from encoding errors.\nfunc ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\n\t// Fast path 1: ASCII.\n\tif data[0] < utf8.RuneSelf {\n\t\treturn 1, data[0:1], nil\n\t}\n\n\t// Fast path 2: Correct UTF-8 decode without error.\n\t_, width := utf8.DecodeRune(data)\n\tif width > 1 {\n\t\t// It's a valid encoding. Width cannot be one for a correctly encoded\n\t\t// non-ASCII rune.\n\t\treturn width, data[0:width], nil\n\t}\n\n\t// We know it's an error: we have width==1 and implicitly r==utf8.RuneError.\n\t// Is the error because there wasn't a full rune to be decoded?\n\t// FullRune distinguishes correctly between erroneous and incomplete encodings.\n\tif !atEOF && !utf8.FullRune(data) {\n\t\t// Incomplete; get more bytes.\n\t\treturn 0, nil, nil\n\t}\n\n\t// We have a real UTF-8 encoding error. Return a properly encoded error rune\n\t// but advance only one byte. This matches the behavior of a range loop over\n\t// an incorrectly encoded string.\n\treturn 1, errorRune, nil\n}\n\n// dropCR drops a terminal \\r from the data.\nfunc dropCR(data []byte) []byte {\n\tif len(data) > 0 && data[len(data) - 1] == '\\r' {\n\t\treturn data[0 : len(data) - 1]\n\t}\n\treturn data\n}\n\n// ScanLines is a split function for a Scanner that returns each line of\n// text, stripped of any trailing end-of-line marker. The returned line may\n// be empty. The end-of-line marker is one optional carriage return followed\n// by one mandatory newline. In regular expression notation, it is `\\r?\\n`.\n// The last non-empty line of input will be returned even if it has no\n// newline.\nfunc ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\tif i := bytes.IndexByte(data, '\\n'); i >= 0 {\n\t\t// We have a full newline-terminated line.\n\t\treturn i + 1, dropCR(data[0:i]), nil\n\t}\n\t// If we're at EOF, we have a final, non-terminated line. Return it.\n\tif atEOF {\n\t\treturn len(data), dropCR(data), nil\n\t}\n\t// Request more data.\n\treturn 0, nil, nil\n}\n\n// isSpace reports whether the character is a Unicode white space character.\n// We avoid dependency on the unicode package, but check validity of the implementation\n// in the tests.\nfunc isSpace(r rune) bool {\n\tif r <= '\\u00FF' {\n\t\t// Obvious ASCII ones: \\t through \\r plus space. Plus two Latin-1 oddballs.\n\t\tswitch r {\n\t\tcase ' ', '\\t', '\\n', '\\v', '\\f', '\\r':\n\t\t\treturn true\n\t\tcase '\\u0085', '\\u00A0':\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\t// High-valued ones.\n\tif '\\u2000' <= r && r <= '\\u200a' {\n\t\treturn true\n\t}\n\tswitch r {\n\tcase '\\u1680', '\\u2028', '\\u2029', '\\u202f', '\\u205f', '\\u3000':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ScanWords is a split function for a Scanner that returns each\n// space-separated word of text, with surrounding spaces deleted. It will\n// never return an empty string. The definition of space is set by\n// unicode.IsSpace.\nfunc ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\t// Skip leading spaces.\n\tstart := 0\n\tfor width := 0; start < len(data); start += width {\n\t\tvar r rune\n\t\tr, width = utf8.DecodeRune(data[start:])\n\t\tif !isSpace(r) {\n\t\t\tbreak\n\t\t}\n\t}\n\t// Scan until space, marking end of word.\n\tfor width, i := 0, start; i < len(data); i += width {\n\t\tvar r rune\n\t\tr, width = utf8.DecodeRune(data[i:])\n\t\tif isSpace(r) {\n\t\t\treturn i + width, data[start:i], nil\n\t\t}\n\t}\n\t// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.\n\tif atEOF && len(data) > start {\n\t\treturn len(data), data[start:], nil\n\t}\n\t// Request more data.\n\treturn start, nil, nil\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "graphs"], "code_uid": "740e90195c9f13aa59368b55eb1e7676", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/8/problem/B\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Node struct {\n\tX int\n\tY int\n}\n\nfunc getAdjacentNodes(n Node) []Node {\n\treturn []Node{\n\t\tNode{X: n.X - 1, Y: n.Y},\n\t\tNode{X: n.X + 1, Y: n.Y},\n\t\tNode{X: n.X, Y: n.Y - 1},\n\t\tNode{X: n.X, Y: n.Y + 1},\n\t}\n}\n\nfunc Solve(path string) string {\n\tcurrentPosition := Node{X: 0, Y: 0}\n\tvisited := make(map[Node]int)\n\tvisited[currentPosition] = 0\n\tfor index, char := range path {\n\t\tcurrentTime := index + 1\n\t\tfor _, node := range getAdjacentNodes(currentPosition) {\n\t\t\t_, ok := visited[node]\n\t\t\tif !ok {\n\t\t\t\tvisited[node] = currentTime\n\t\t\t}\n\t\t}\n\t\ts := string(char)\n\t\tif s == \"L\" {\n\t\t\tcurrentPosition.X -= 1\n\t\t} else if s == \"R\" {\n\t\t\tcurrentPosition.X += 1\n\t\t} else if s == \"U\" {\n\t\t\tcurrentPosition.Y += 1\n\t\t} else if s == \"D\" {\n\t\t\tcurrentPosition.Y -= 1\n\t\t}\n\t\ttime, ok := visited[currentPosition]\n\t\tif ok && time < currentTime {\n\t\t\treturn \"BUG\"\n\t\t} else if !ok {\n\t\t\tvisited[currentPosition] = currentTime + 1\n\t\t}\n\t}\n\treturn \"OK\"\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar path string\n\tfmt.Fscanf(reader, \"%s\\n\", &path)\n\tfmt.Fprintf(writer, \"%s\\n\", Solve(path))\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "graphs"], "code_uid": "d6efc9e2c0d67ac086271350b265575d", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"regexp\"\n\t\"strings\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nvar re *regexp.Regexp = regexp.MustCompile(\"^[0-9a-zA-Z_]{1,16}$\")\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tvar s string\n\tfmt.Fscanf(reader, \"%s\", &s)\n\n\tsegs := strings.Split(s, \"@\")\n\tif len(segs) != 2 || !re.Match([]byte(segs[0])) {\n\t\tfmt.Printf(\"NO\")\n\t\treturn\n\t}\n\tsegs = strings.Split(segs[1], \"/\")\n\tif len(segs) > 2 {\n\t\tfmt.Printf(\"NO\")\n\t\treturn\n\t} else {\n\t\tif len(segs[0]) < 1 || len(segs[0]) > 32 {\n\t\t\tfmt.Printf(\"NO\")\n\t\t\treturn\n\t\t}\n\t\thostnameSegs := strings.Split(segs[0], \".\")\n\t\tfor i := 0;i < len(hostnameSegs);i ++ {\n\t\t\tif !re.Match([]byte(hostnameSegs[i])) {\n\t\t\t\tfmt.Printf(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif len(segs) == 2 && !re.Match([]byte(segs[1])) {\n\t\t\tfmt.Printf(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Printf(\"YES\")\n\treturn\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "f46ca4e1ec1f459b069c8e81d6a17707", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"fmt\"\nimport \"strings\"\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin);\n\tfor scanner.Scan() {\n\t\tif do_str(scanner.Text()) {\n\t\t\tfmt.Println(\"YES\");\n\t\t} else {\n\t\t\tfmt.Println(\"NO\");\n\t\t}\n\t}\n\n\t\n}\n\nfunc isalpha(c rune) bool {\n\tif c >= 'a' && c <= 'z' {\n\t\treturn true;\n\t}\n\tif c >= 'A' && c <= 'Z' {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunc isdigit(c rune) bool {\n\tif c >= '0' && c <= '9' {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunc do_str(s string) bool {\n\tidx := strings.Index(s, \"@\");\n\tif idx == -1 {\n\t\t// No \"@\"\n\t\treturn false;\n\t}\n\n\tusername := s[0:idx];\n\tif len(username) > 16 || len(username) < 1 {\n\t\treturn false;\n\t}\n\t\n\tfor _, c := range(username) {\n\t\tif isalpha(c) { continue }\n\t\tif isdigit(c) { continue }\n\t\tif c == '_' { continue }\n\t\treturn false\n\t}\n\n\tif len(s[idx:]) == 1 {\n\t\treturn false;\n\t}\n\tvar resource string;\n\tvar hostname string;\n\t\n\trest := s[idx+1:]\n\tidx = strings.Index(rest, \"/\");\n\tif idx == -1 {\n\t\tresource = \"\";\n\t\thostname = rest;\n\t} else {\n\t\tresource = rest[idx:];\n\t\tif len(resource) == 1 {\n\t\t\treturn false;\n\t\t}\n\t\tresource = rest[idx+1:];\n\t\thostname = rest[0:idx];\n\t}\n\n\tif len(hostname) < 1 || len(hostname) > 32 {\n\t\treturn false\n\t}\n\tfor _, c := range(hostname) {\n\t\tif isalpha(c) { continue }\n\t\tif isdigit(c) { continue }\n\t\tif c == '_' { continue }\n\t\tif c == '.' { continue }\n\t\treturn false\n\t}\n\twords := strings.Split(hostname, \".\");\n\tfor _, word := range(words) {\n\t\tif len(word) < 1 || len(word) > 16 {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif len(resource) > 16 {\n\t\treturn false;\n\t}\n\tfor _, c := range(resource) {\n\t\tif isalpha(c) { continue }\n\t\tif isdigit(c) { continue }\n\t\tif c == '_' { continue }\n\t\treturn false\n\t}\n\t\n\treturn true\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "f671fda0bc6298b248bbdabd67949c04", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"strings\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nvar validChars = \"_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nfunc valid(s string) bool {\n if len(s) < 1 || len(s) > 16 {\n return false\n }\n for _, ch := range s {\n if strings.IndexRune(validChars, ch) == -1 {\n return false\n }\n }\n return true\n}\n\nfunc validate(s string) bool {\n if strings.Count(s, \"@\") != 1 || strings.Count(s, \"/\") > 1 {\n return false\n }\n\n parts := strings.Split(s, \"@\")\n username, hostname := parts[0], parts[1]\n if !valid(username) {\n return false\n }\n\n if strings.Count(hostname, \"/\") == 1 {\n parts = strings.Split(hostname, \"/\")\n hostname = parts[0]\n resource := parts[1]\n if !valid(resource) {\n return false\n }\n }\n\n parts = strings.Split(hostname, \".\")\n for _, part := range parts {\n if !valid(part) {\n return false\n }\n }\n\n return true\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n s := getS()\n result := \"YES\"\n if !validate(s) {\n result = \"NO\"\n }\n writer.WriteString(fmt.Sprintf(\"%s\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "4b617dac6a8ac96b9a283a90d80ddeb7", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc countDivisor(a, b int) int {\n\tq := a - b\n\tret := 0\n\tsqrtQ := math.Sqrt(float64(q))\n\tfor i := 1; float64(i) < sqrtQ; i++ {\n\t\tif q%i != 0 || q/i < b {\n\t\t\tcontinue\n\t\t}\n\t\tret++\n\t\tif i <= b {\n\t\t\tcontinue\n\t\t}\n\t\tret++\n\t}\n\tif sqrtQ > float64(b) && int(sqrtQ)*int(sqrtQ) == q {\n\t\tret++\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\", &a, &b)\n\n\tif a < b || (a != b && a-b <= b) {\n\t\tfmt.Println(0)\n\t} else if a == b {\n\t\tfmt.Println(\"infinity\")\n\t} else {\n\t\tfmt.Println(countDivisor(a, b))\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "8397e4293ea703afe7c70b5e20557bf7", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport . \"fmt\"\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar a, b, c int\n\tif Scan(&a, &b); a == b {\n\t\tPrint(\"infinity\")\n\t\treturn\n\t}\n\ta -= b\n\tfor d := 1; d*d <= a; d++ {\n\t\tif a%d == 0 {\n\t\t\tif d > b {\n\t\t\t\tc++\n\t\t\t}\n\t\t\tif d*d < a && a/d > b {\n\t\t\t\tc++\n\t\t\t}\n\t\t}\n\t}\n\tPrint(c)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "41f3c3377ca80ff8873b76de77f2ac09", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\tscanner *bufio.Scanner\n\twriter *bufio.Writer\n\n\ta int64\n\tb int64\n\tresult int64\n)\n\nfunc in() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\ta = readInt64()\n\tb = readInt64()\n}\n\nfunc out() {\n\twriter = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tif result >= 0 {\n\t\tprintInt64(result)\n\t} else {\n\t\tprintString(\"infinity\")\n\t}\n\tprintLine()\n}\n\nfunc run() {\n\tif b > a {\n\t\tresult = 0\n\t} else if b == a {\n\t\tresult = -1\n\t} else {\n\t\tresult = 0\n\t\tm := a - b\n\t\tfor i := int64(1); i*i <= m; i++ {\n\t\t\tif i*i == m && i > b {\n\t\t\t\tresult++\n\t\t\t} else {\n\t\t\t\tif m%i == 0 {\n\t\t\t\t\tif i > b {\n\t\t\t\t\t\tresult++\n\t\t\t\t\t}\n\t\t\t\t\tif m/i > b {\n\t\t\t\t\t\tresult++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc main() {\n\tin()\n\trun()\n\tout()\n}\n\n// Read.\n\nfunc readString() string {\n\tscanner.Scan()\n\tans := scanner.Text()\n\treturn ans\n}\n\nfunc readLine() string {\n\tscanner.Split(bufio.ScanLines)\n\tdefer scanner.Split(bufio.ScanWords)\n\treturn readString()\n}\n\nfunc readInt() int {\n\tans, _ := strconv.ParseInt(readString(), 10, 0)\n\treturn int(ans)\n}\n\nfunc readInt64() int64 {\n\tans, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn ans\n}\n\nfunc readFloat64() float64 {\n\tans, _ := strconv.ParseFloat(readString(), 64)\n\treturn ans\n}\n\n// Write.\n\nfunc printString(value string) {\n\twriter.WriteString(value)\n}\n\nfunc printLine() {\n\tprintString(\"\\n\")\n}\n\nfunc printSpace() {\n\tprintString(\" \")\n}\n\nfunc printInt(value int) {\n\tprintString(strconv.FormatInt(int64(value), 10))\n}\n\nfunc printInt64(value int64) {\n\tprintString(strconv.FormatInt(value, 10))\n}\n\nfunc printFloat64(value float64) {\n\tprintString(strconv.FormatFloat(value, 'f', 10, 64))\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "c4c26e7211cbea4b089039d9251b08b0", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar n, a, b, p1, p2 int\n\n\tarr := [22]int{}\n\tscanf(\"%d %d %d\\n\", &n, &a, &b)\n\tfor i := 0; i < n; i = i + 1 {\n\t\tscanf(\"%d\", &arr[i])\n\t}\n\tp2 = n - 1\n\tans := 0\n\tfor p1 <= p2 {\n\n\t\tif p1 == p2 {\n\t\t\tif arr[p1] == 2 {\n\t\t\t\tans += min(a, b)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\tif arr[p1] == arr[p2] && arr[p1] == 2 {\n\t\t\tans = ans + 2*min(a, b)\n\t\t}\n\t\tif arr[p1]^arr[p2] == 1 {\n\t\t\tans = -1\n\t\t\tbreak\n\t\t}\n\t\tif arr[p1] == 2 && arr[p2] == 1 {\n\t\t\tans = ans + b\n\t\t}\n\t\tif arr[p2] == 2 && arr[p1] == 1 {\n\t\t\tans = ans + b\n\t\t}\n\t\tif arr[p1] == 2 && arr[p2] == 0 {\n\t\t\tans = ans + a\n\t\t}\n\t\tif arr[p2] == 2 && arr[p1] == 0 {\n\t\t\tans = ans + a\n\t\t}\n\t\tp1++\n\t\tp2--\n\t}\n\tprintf(\"%d\", ans)\n\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "27a4c313d7a50346baa983ffeb44c316", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b int\n\tfmt.Scan(&n, &a, &b)\n\tc := make([]int, n)\n\tfor i, _ := range c {\n\t\tfmt.Scan(&c[i])\n\t}\n\n\tmin_price := a\n\tif b < min_price {\n\t\tmin_price = b\n\t}\n\t//fmt.Println(c)\n\tans := 0\n\tfor i, _ := range c {\n\t\tri := n - 1 - i\n\t\tif i > ri {\n\t\t\tbreak\n\t\t} else if i == ri {\n\t\t\tif c[i] == 2 {\n\t\t\t\tans += min_price\n\t\t\t}\n\t\t} else {\n\t\t\tif c[i] != 2 && c[ri] != 2 {\n\t\t\t\tif c[i] != c[ri] {\n\t\t\t\t\tans = -1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else if c[i] == 2 && c[ri] != 2 {\n\t\t\t\tif c[ri] == 0 {\n\t\t\t\t\tans += a\n\t\t\t\t} else {\n\t\t\t\t\tans += b\n\t\t\t\t}\n\t\t\t} else if c[ri] == 2 && c[i] != 2 {\n\t\t\t\tif c[i] == 0 {\n\t\t\t\t\tans += a\n\t\t\t\t} else {\n\t\t\t\t\tans += b\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tans += (min_price * 2)\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "2a8e19042afb5bdd16df90f24e36d0fe", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"fmt\"\r\n)\r\n\r\n\r\nfunc main() {\r\n\r\n\tvar row int\r\n\tvar col int\r\n\r\n\tfmt.Scanln(&row, &col)\r\n\r\n\tcount := (col-1) * row\r\n\tif col == 1 {\r\n\t\tcount = row-1\r\n\t}\r\n\r\n\tfmt.Println(count)\r\n\r\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "6d72ebd5eed10424cc57951a419f7a4f", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tdims := strings.Split(scanner.Text(), \" \")\n\tm, _ := strconv.Atoi(dims[0])\n\tn, _ := strconv.Atoi(dims[1])\n\tif n == 1 {\n\t\tfmt.Println(m - 1)\n\t} else {\n\t\tfmt.Println(m * (n - 1))\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "55cb667fe9d580fe0bb19407b14bda0f", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nfunc main() {\r\n\tdefer writer.Flush()\r\n\tsolve()\r\n}\r\n\r\nfunc solve() {\r\n\tvar n, m int\r\n\tscanws(&n, &m)\r\n\tif m == 1 {\r\n\t\tprintf(\"%d\\n\", n-1)\r\n\t} else {\r\n\t\tprintf(\"%d\\n\", n*(m-1))\r\n\t}\r\n}\r\n\r\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\r\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\r\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\r\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\r\nfunc scanws(a ...interface{}) { fmt.Fscan(reader, a...) }\r\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "1cd3f909ba7980639d5df218f19642bc", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tscanner.Scan()\n\ta, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\tfor i := int64(1); ; i++ {\n\t\ts := strconv.FormatInt(a+i, 10)\n\t\tfor _, ch := range s {\n\t\t\tif ch == '8' {\n\t\t\t\twriter.WriteString(fmt.Sprintf(\"%d\\n\", i))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "62dca3f3c57825f36dd2c34e497df029", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tisHappy := func(x int64) bool {\n\t\tif x < 0 {\n\t\t\tx = -x\n\t\t}\n\t\tfor x > 0 {\n\t\t\tif x%10 == 8 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tx /= 10\n\t\t}\n\t\treturn false\n\t}\n\n\tvar x int64\n\tfmt.Scan(&x)\n\ti := int64(1)\n\tfor {\n\t\tif isHappy(x + i) {\n\t\t\tbreak\n\t\t}\n\t\ti++\n\t}\n\tfmt.Println(i)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "8c44afaa9faa0cfa2709f93a7ff8266a", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\ta := nextInt()\n\n\tfor i := a + 1; i <= 1000000008; i++ {\n\t\tif has8(i) {\n\t\t\tprintln(i - a)\n\t\t\tbreak\n\t\t}\n\t}\n\n}\n\nfunc has8(n int) bool {\n\tfor n > 0 {\n\t\tif n % 10 == 8 {\n\t\t\treturn true\n\t\t}\n\n\t\tn /= 10\n\t}\n\n\tfor n < 0 {\n\t\tif n % 10 == -8 {\n\t\t\treturn true\n\t\t}\n\n\t\tn /= 10\n\t}\n\n\treturn false\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, err := strconv.ParseFloat(next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "b98bbb1974616aca91ae098ef4b5239b", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, i, j float64\n\tfmt.Scan(&n)\n\tfor i = 1; i*(i+1)/2 <= n; i++ {\n\t\tj = math.Sqrt(n*2 - i*(i+1))\n\t\tx := int64(j)\n\t\tif x > 0 && x*(x+1)+int64(i)*(int64(i)+1) == int64(n)*2 {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "binary search"], "code_uid": "28991281a37a44b934468eb29066ef0b", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//rextester.com:1.6.2--codeforces.com:1.7.3\npackage main\nimport(\"fmt\";\"math\")\nfunc main(){\n var a float64;fmt.Scan(&a);a*=2;b:=false\n for i:=1;i 0 {\n\t\t\tif k*(k+1)+i*(i+1)== 2*n{\n\t\t\t\tm =1\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif m == 0{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "binary search"], "code_uid": "8f1fd7dd9fd155bf7044643693e0ebfa", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n, a int\n fmt.Scan(&n)\n\n res := int64(1)\n acum := int64(0)\n first := true\n ones := 0\n for i := 0; i < n; i++ {\n fmt.Scan(&a)\n if a == 1 {\n ones++\n if !first {\n res *= acum + 1\n }\n first = false\n acum = 0 \n } else {\n acum++ \n }\n }\n\n if ones == 0 {\n res = 0 \n }\n fmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["combinatorics"], "code_uid": "bdc81f385be5834119850e68181e1a3b", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst (\n\tMAXN = 110\n)\n\nvar N int\nvar A [MAXN]int\n\nfunc f(left int) int {\n\tfor i := left; i < N; i++ {\n\t\t// fmt.Print(i, A[i])\n\t\tif A[i] == 1 {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}\nfunc main() {\n\tfsc := NewFastScanner()\n\tN = fsc.NextInt()\n\tok := false\n\tfor i := 0; i < N; i++ {\n\t\tA[i] = fsc.NextInt()\n\t\tif A[i] == 1 {\n\t\t\tok = true\n\t\t}\n\t}\n\tvar result int64\n\tresult = 1\n\tvar left, right int\n\tleft, right = 0, 0\n\n\tfor {\n\t\tleft = f(left)\n\t\tright = f(left + 1)\n\t\t// fmt.Println(left, right)\n\t\tif left == -1 || right == -1 {\n\t\t\tbreak\n\t\t}\n\t\t// fmt.Println(left, right)\n\n\t\tresult *= int64((right - left))\n\n\t\tleft = right\n\t}\n\tif ok == false {\n\t\tresult = 0\n\t}\n\tfmt.Println(result)\n}\n\n//template\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1024)\n\treturn &FastScanner{r: rdr}\n}\nfunc (s *FastScanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *FastScanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *FastScanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *FastScanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *FastScanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["combinatorics"], "code_uid": "55585c4260ecbdb222ea9559273e3b0a", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tcombination := int64(1)\n\tgap := 1\n\tmet_first_nut := false\n\tmet_nut := false\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; scanner.Scan(); i++ {\n\t\ta, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tif a == 0 {\n\t\t\tgap += 1\n\t\t} else if a == 1 {\n\t\t\tif !met_first_nut {\n\t\t\t\tmet_first_nut = true\n\t\t\t} else {\n\t\t\t\tcombination *= int64(gap)\n\t\t\t}\n\t\t\tmet_nut = true\n\t\t\tgap = 1\n\t\t}\n\t}\n\n\tif met_nut {\n\t\tfmt.Println(combination)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["combinatorics"], "code_uid": "4e29ac58be8549dc3e6fd229f42fe5de", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt()\n\ta := make([]int, n)\n\tbribe := 0\n\n\tfor i := range a {\n\t\ta[i] = nextInt()\n\t}\n\n\tidx := max(a[1:]) + 1\n\n\tfor a[0] <= a[idx] {\n\t\ta[0]++\n\t\ta[idx]--\n\t\tbribe++\n\t\t// println(idx, a, bribe)\n\t\tidx = max(a[1:]) + 1\n\t}\n\n\tprintln(bribe)\n}\n\nfunc max(a []int) int {\n\tidx := 0\n\n\tfor i := range a {\n\t\tif a[i] > a[idx] {\n\t\t\tidx = i\n\t\t}\n\t}\n\n\treturn idx\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "fcee640ed3bae41d21612a569965fcc6", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tvotes := make([]int, n)\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; scanner.Scan() && i < n; i++ {\n\t\ta, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tvotes[i] = a\n\t}\n\n\tbubble_sort(votes, 1, n)\n\n\tbribing := 0\n\tfor votes[0] <= votes[1] {\n\t\tvotes[0]++\n\t\tvotes[1]--\n\t\tbribing++\n\t\tif len(votes) > 2 {\n\t\t\tfor i := 2; i < n && votes[i-1] < votes[i]; i++ {\n\t\t\t\tswap(i-1, i, votes)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(bribing)\n}\n\nfunc swap(a, b int, array []int) {\n\tarray[a], array[b] = array[b], array[a]\n}\n\nfunc bubble_sort(array []int, start, end int) {\n\tfor i := start; i < end; i++ {\n\t\tfor j := start; j < end; j++ {\n\t\t\tif array[i] > array[j] {\n\t\t\t\tswap(i, j, array)\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "903ee0fc3dfc519262d21a1b45a5b311", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\tscanner = bufio.NewScanner(os.Stdin)\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt()\n\ts := next()\n\t// println(s)\n\n\tfor i := 0; i < n; i++ {\n\t\tif s[i] == '*' {\n\t\t\tlength := 0\n\n\t\t\tfor j := i + 1; j < n; j++ {\n\t\t\t\tif s[j] == '*' {\n\t\t\t\t\tlength = j - i\n\t\t\t\t\t// println(i, length)\n\t\t\t\t\t\n\t\t\t\t\tif i+length*4 < n &&\n\t\t\t\t\t\ts[i+length*2] == '*' &&\n\t\t\t\t\t\ts[i+length*3] == '*' &&\n\t\t\t\t\t\ts[i+length*4] == '*' {\n\t\t\t\t\t\tprintln(\"yes\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprintln(\"no\")\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "1c66dd49bb0a6c554d050c2c27c9e00c", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n n := getI()\n s := getS()\n for i := range s {\n if s[i] == '.' {\n continue\n }\n jump := 0\n for {\n jump++\n if i + 4*jump >= n {\n break\n }\n okay := true\n for j := 1; j <= 4; j++ {\n if s[i+j*jump] == '.' {\n okay = false\n break\n }\n }\n if okay {\n writer.WriteString(\"yes\\n\")\n return\n }\n }\n }\n writer.WriteString(\"no\\n\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "685b36b6e73f969404b9652a4e8d7910", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\t_, err := fmt.Scanf(\"%d\\n\", &n)\n\tvar level string\n\t_, err = fmt.Scanf(\"%s\\n\", &level)\n\tvar found = false\n\tif err == nil {\n\t\tfor i := 0; i < n && !found; i++ {\n\t\t\tfor j := 1; j < n && !found; j++ {\n\t\t\t\tif i+4*j < n {\n\t\t\t\t\tif level[i] == '*' && level[i+1*j] == '*' && level[i+2*j] == '*' && level[i+3*j] == '*' && level[i+4*j] == '*' {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif found {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "b8253e7edf60acf838cba5257c57185b", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc getInts() []int64 {\n\t//assumes POSITIVE INTEGERS. Check v for '-' if you have negative.\n\tvar buf []byte\n\tbuf, _ = ioutil.ReadAll(os.Stdin)\n\tvar ints []int64\n\tnum := int64(0)\n\tfound := false\n\tfor _, v := range buf {\n\t\tif '0' <= v && v <= '9' {\n\t\t\tnum = 10*num + int64(v-'0') //could use bitshifting here.\n\t\t\tfound = true\n\t\t} else if found {\n\t\t\tints = append(ints, num)\n\t\t\tfound = false\n\t\t\tnum = 0\n\t\t}\n\t}\n\tif found {\n\t\tints = append(ints, num)\n\t\tfound = false\n\t\tnum = 0\n\t}\n\treturn ints\n}\n\nconst mod = 998244353\n\nfunc binpow(a, n uint64) (res uint64) {\n\tres = 1\n\tfor n != 0 {\n\t\tif (n & 1) != 0 {\n\t\t\tres *= a\n\t\t\tres %= mod\n\t\t}\n\t\ta *= a\n\t\ta %= mod\n\t\tn >>= 1\n\t}\n\treturn res\n}\n\n// http://e-maxx.ru/algo/reverse_element\nfunc inv(a uint64) uint64 {\n\treturn binpow(a, mod-2)\n}\n\nfunc main() {\n\tints := getInts()\n\n\tn := uint64(ints[0])\n\tm := uint64(ints[1])\n\n\tif n-1 > m {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tif n == 2 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tans := uint64(1)\n\n\t// C(m, n-1)\n\tfor i := m; i > n-1; i-- {\n\t\tans *= uint64(i)\n\t\tans %= mod\n\t}\n\tfor i := m - (n - 1); i > 1; i-- {\n\t\tans *= inv(i)\n\t\tans %= mod\n\t}\n\n\t// * 2^(n-3)\n\tans *= binpow(2, n-3)\n\tans %= mod\n\n\t// * (n-2)\n\tans *= n - 2\n\tans %= mod\n\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "c2dd5c1d49edd499954c997d41cf6f0e", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"os\"\n \"bufio\"\n)\n\nfunc main() {\n var n, k int\n var baloons string\n var m = make(map[string]int)\n \n stdin := bufio.NewReader(os.Stdin)\n fmt.Fscanf(stdin, \"%d %d\\n\", &n, &k)\n fmt.Fscanf(stdin, \"%s\\n\", &baloons)\n \n // count number of baloon based on color\n for i := 0; i < n; i++ {\n m[string(baloons[i])]++\n }\n \n isPossible := true\n for _, v := range m {\n if v > k {\n isPossible = false\n break\n } \n }\n \n if isPossible {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "ebc4e03d9489064cf5281d203c8cf08c", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst maxInputSize = 512 * 1024 //bytes\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, maxInputSize), maxInputSize)\n\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\n\tscanner.Scan()\n\tk, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\ts := scanner.Text()\n\n\tyes := true\n\tl := make([]int, 26)\n\n\tfor i := 0; i < n; i++ {\n\t\tl[s[i]-97]++\n\t\tif l[s[i]-97] > k {\n\t\t\tyes = false\n\t\t}\n\t}\n\n\tif yes {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "60e8ea66add22ffc0ee8142dd7d31525", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n/*\n The idea to solve this problem is by noticing that we need to make sure\n that each friends given baloon by Kefa doesn't get same color more than once. \n Which means the number of baloon of for each color must be the same number\n of Kefa friends or less (because his friends won't be angry if they do not get\n baloon)\n*/\n\nimport (\n \"fmt\"\n \"os\"\n \"bufio\"\n)\n\nfunc main() {\n var n, k int\n var baloons string\n var m = make(map[string]int)\n \n stdin := bufio.NewReader(os.Stdin)\n fmt.Fscanf(stdin, \"%d %d\\n\", &n, &k)\n fmt.Fscanf(stdin, \"%s\\n\", &baloons)\n \n // count number of baloon based on color\n for i := 0; i < n; i++ {\n m[string(baloons[i])]++\n }\n \n isPossible := true\n for _, v := range m {\n if v > k {\n isPossible = false\n break\n } \n }\n \n if isPossible {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "ecfcb1ffb53f81bc02dc0ab0c0f603d2", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\treader := bufio.NewReaderSize(os.Stdin, 1<<13)\n\twriter := bufio.NewWriterSize(os.Stdout, 1<<13)\n\tscn := bufio.NewScanner(reader)\n\tscn.Scan()\n\tline := scn.Text()\n\tn := len(line)\n\n\tcol := line[n-1]\n\trow, _ := strconv.ParseInt(line[:n-1], 10, 64)\n\trow--\n\n\ttotal := (row / 4) * 16\n\n\t// Adding the count for the column\n\tswitch col {\n\tcase 'f':\n\t\ttotal++\n\tcase 'e':\n\t\ttotal += 2\n\tcase 'd':\n\t\ttotal += 3\n\tcase 'a':\n\t\ttotal += 4\n\tcase 'b':\n\t\ttotal += 5\n\tcase 'c':\n\t\ttotal += 6\n\t}\n\n\t// Check if it is the second columns to be served in this\n\t// group:\n\tif (row%4)&1 == 1 {\n\t\ttotal += 6 + 1\n\t}\n\n\tfmt.Fprintln(writer, total)\n\n\twriter.Flush()\n}\n\nfunc ReadInt(reader *bufio.Reader) int {\n\tb, err := reader.ReadByte()\n\tfor !isValid(b, err) {\n\t\tb, err = reader.ReadByte()\n\t}\n\tres := 0\n\tfor isValid(b, err) {\n\t\tres = res*10 + int(b-'0')\n\t\tb, err = reader.ReadByte()\n\t}\n\treturn res\n}\n\nfunc isValid(b byte, err error) bool {\n\treturn err == nil && '0' <= b && b <= '9'\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "ef2fbdb3fa6757c2a836a88a5d6ae7ee", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// http://acm.timus.ru/problem.aspx?space=1&num=1741\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nconst (\n\tMOD = 1e9 + 7\n)\n\ntype (\n\n)\n\nfunc main () {\n\tvar (\n\t\tn int64\n\t\tplace string\n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscan(input, &n, &place)\n\n\tpcost := map[rune]int64{'f': 1, 'e': 2, 'd': 3, 'a': 4, 'b': 5, 'c': 6}\n\n\tn--\n\tans := (n / 4) * 16\n\tost := (n % 4)\n\n\tif ost % 2 != 0 {\n\t\tans += 7 + pcost[rune(place[0])]\n\t} else {\n\t\tans += pcost[rune(place[0])]\n\t}\n\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "21ec3881bd10306c30063c7aba321f18", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc pos(c byte) int64 {\n\ts := \"fedabc\"\n\tfor i := 0; i < 6; i++ {\n\t\tif s[i] == c {\n\t\t\treturn int64(i)\n\t\t}\n\t}\n\treturn -1\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar n int64\n\tvar s string\n\n\tfmt.Fscanf(bufin, \"%d%s\\n\", &n, &s)\n\n\tn--\n\tk := n / 4\n\tt := k*16 + 1\n\tif (n%4 == 1) || (n%4 == 3) {\n\t\tt += 7\n\t}\n\tt += pos(s[0])\n\n\tfmt.Fprintf(bufout, \"%d\\n\", t)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "05fee76412fa6ca8043b46007656852c", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,i int\n\tfmt.Scan(&n)\n\tflag:=false\n\tfor i=1;i<=n;i++ {\n\t\tif i*(i+1)/2==n {\n\t\t\tflag=true\n\t\t}\n\t}\n\tif flag==true {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "ed388bd727115d616c35d6b3aeff1432", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n ans := false\n for i := 1; i <= n; i++ {\n t := (i*(i+1))/2\n if t == n {\n ans = true\n break\n } else if t > n {\n break\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "dc5a000e6ec4e586d25aaba9e017d52c", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n \"fmt\"\n )\nfunc main(){\n var n int\n i := 1\n fmt.Scan(&n)\n for ;n>i;i++{\n n -= i\n }\n if n == i {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "f20990d627d5f7767fd9a5c53cdaa151", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tfor ;n%3==0; {\n\t\tn/=3\n\t}\n\tfmt.Println(n/3+1)\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "032d74241447e2cd5208a3f51bc6212f", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int64\n fmt.Scan(&n)\n for a := int64(1); ; a *= 3 {\n if (n%a) != 0 {\n fmt.Println((n/a)+1)\n break\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "3e1677584a05809ad2140a15cdff0c83", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport \"fmt\"\n\nfunc Max( x, y int ) int { // math.Max() は問題を起こすらしい。。。\n if x > y {\n return x\n }\n return y\n}\n\nfunc main() {\n\tvar N, K int\n\tfmt.Scan( &N, &K )\n\tvar S string\n\tfmt.Scan( &S )\n\typfx := make( []int, N + 1, N + 1 ); // type, length, capacity\n\tnpfx := make( []int, N + 1, N + 1 );\n\tqpfx := make( []int, N + 1, N + 1 );\n\tfor i := 0; i < N; i++ { // seems like go does not support ++i.....\n\t ypfx[ i + 1 ] = ypfx[ i ];\n\t npfx[ i + 1 ] = npfx[ i ];\n\t qpfx[ i + 1 ] = qpfx[ i ];\n\t if( S[ i ] == 'Y' ) {\n\t ypfx[ i + 1 ]++;\n\t } else if( S[ i ] == 'N' ) {\n\t npfx[ i + 1 ]++;\n\t } else {\n\t qpfx[ i + 1 ]++;\n\t }\n\t}\n\toriginal_max := 0;\n\tfor i := 0; i < N; i++ {\n\t if( S[ i ] != 'N' ) { // syntax error: missing { after if clause えええええ\n\t continue;\n\t }\n\t j := i;\n\t for j < N && S[ j ] == 'N' { // while() はだめなんかい!!\n\t j++;\n\t }\n\t original_max = Max( original_max, j - i );\n\t i = j;\n\t}\n\tif( original_max > K ) {\n\t fmt.Println( \"NO\" );\n\t return;\n\t}\n\tfor i := 0; i + K <= N; i++ { // i を左界とする長さ K の区間を調べる\n\t if( ypfx[ i + K ] - ypfx[ i ] > 0 ) { // ええええ -> line: 34\n\t continue;\n\t }\n\t if( i - 1 >= 0 && S[ i - 1 ] == 'N' ) {\n\t continue;\n\t }\n\t if( i + K < N && S[ i + K ] == 'N' ) {\n\t continue;\n\t }\n\t fmt.Println( \"YES\" );\n\t return;\n\t}\n\tfmt.Println( \"NO\" );\n}", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "d8b27e77a9fb595154a0b1fea71975bc", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\tvar s string\n\tfmt.Scan(&s)\n\tans := 0\n\tjust_max := 0\n\tfor i := 0; i + k - 1 < n; i++ {\n\t was := 0\n\t for j := i; j < i + k; j++ {\n\t if s[j] == 'Y' {\n\t was = 1\n\t }\n\t }\n\t if was == 0 {\n\t if i + k >= n || s[i + k] != 'N' {\n\t if i - 1 < 0 || s[i - 1] != 'N' {\n\t ans = 1\n\t }\n\t }\n\t }\n\t}\n\tif ans == 0 {\n\t fmt.Println(\"NO\")\n\t} else {\n\t for i := 0; i < n; i++ {\n\t cur := 0\n\t for j := i; j < n; j++ {\n\t if s[j] == 'N' {\n\t cur++\n\t if just_max < cur {\n\t just_max = cur\n\t }\n\t } else {\n\t cur = 0\n\t }\n\t }\n\t }\n\t if just_max > k {\n\t fmt.Println(\"NO\")\n\t } else {\n\t fmt.Println(\"YES\")\n\t }\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "57b3c08170729184f1f191e53d32dd71", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport \"fmt\"\n\nfunc main() {\n var s string\n var n, k int\n\tfmt.Scan(&n)\n\tfmt.Scan(&k)\n\tfmt.Scan(&s)\n\tvar ans = \"NO\"\n\tfor i := 0; i+k <= n; i++ {\n\t var ok = 1\n\t for j := 0; jk{\n\t ok = 0\n\t }\n\t }\n\t l = 0\n\t for h:=i+k; hk{\n\t ok = 0\n\t }\n\t }\n\t }else{\n\t ok = 0\n\t }\n\t }\n\t if ok==1{\n\t ans = \"YES\"\n\t }\n\t}\n \n fmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "f6fda8195733052b4f862b24749f849d", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n// Retorna slice de slices com as duplas retiradas.\nfunc possiveisJogadas(row []int, num int, x int) [][]int {\n\tduplas := make([][2]int, 0)\n\n\tfor i := 0; i+1 <= num-1; i++ {\n\t\tif row[i] == x && row[i] == row[i+1] {\n\t\t\tduplas = append(duplas, [2]int{i, i + 1})\n\t\t}\n\t}\n\n\tpossibilidades := make([][]int, len(duplas))\n\n\tfor i, v := range duplas {\n\t\tcopia := make([]int, num)\n\t\tcopy(copia, row)\n\t\tx, y := v[0], v[1]\n\n\t\tpossibilidades[i] = append(copia[:x], copia[y+1:]...)\n\n\t}\n\n\treturn possibilidades\n}\n\n// Remove um range de um array. [x, y] != [x, y)\nfunc removerElementos(row *[]int, x, y int) {\n\t*row = append((*row)[:x], (*row)[y+1:]...)\n}\n\nfunc limparRow(row []int) []int {\n\ti := 1\n\tgrupo := 1\n\tgrupoAchado := false\n\tfor {\n\t\tif i >= len(row) {\n\t\t\tif grupo >= 3 {\n\t\t\t\tremoverElementos(&row, i-grupo, i-1)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\tif row[i] == row[i-1] {\n\t\t\tgrupo++\n\t\t\tif grupo >= 3 {\n\t\t\t\tgrupoAchado = true\n\t\t\t}\n\t\t} else {\n\t\t\tif grupoAchado {\n\t\t\t\tremoverElementos(&row, i-grupo, i-1)\n\t\t\t\ti = 0\n\t\t\t\tgrupoAchado = false\n\n\t\t\t}\n\t\t\tgrupo = 1\n\t\t}\n\n\t\ti++\n\t}\n\n\treturn row\n}\n\nfunc main() {\n\t// len(row), num de cores, cor escolhida pelo player.\n\tvar num, k, x int\n\tfmt.Scan(&num, &k, &x)\n\n\t// Criar slice que representa a row.\n\trow := make([]int, num)\n\tfor i := 0; i < num; i++ {\n\t\tfmt.Scan(&row[i])\n\t}\n\n\t// Copia e algoritmos.\n\tjogadas := possiveisJogadas(row, num, x)\n\n\tmaior := 0\n\tfor _, jogada := range jogadas {\n\t\tcont := num - len(limparRow(jogada))\n\t\tif cont > maior {\n\t\t\tmaior = cont\n\t\t}\n\t}\n\tfmt.Println(maior)\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "brute force"], "code_uid": "a66896b97a52217b6687d9ab2a23b9d4", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc score(p, t int) int {\n\treturn max(3*p/10, p-p/250*t)\n}\n\nfunc main() {\n\tvar a, b, c, d int\n\tfmt.Scan(&a, &b, &c, &d)\n\tm := score(a, c)\n\tv := score(b, d)\n\tif m > v {\n\t\tfmt.Println(\"Misha\")\n\t} else if m < v {\n\t\tfmt.Println(\"Vasya\")\n\t} else {\n\t\tfmt.Println(\"Tie\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fef3b0d8657081235fe18b7c2e3557c2", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n scanner.Scan()\n x, _ := strconv.Atoi(scanner.Text())\n return x\n}\n\nfunc score(p, t int) int {\n x, y := 3*p, 10*p - p/25*t\n if x > y {\n return x\n } else {\n return y\n }\n}\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n a := scanInt(scanner)\n b := scanInt(scanner)\n c := scanInt(scanner)\n d := scanInt(scanner)\n misha, vasya := score(a, c), score(b, d)\n if misha > vasya {\n writer.WriteString(\"Misha\\n\")\n } else if misha < vasya {\n writer.WriteString(\"Vasya\\n\")\n } else {\n writer.WriteString(\"Tie\\n\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fc836ce3f84ce87ae02b4648df84b0a7", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc max(x int, y int) int {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc score(p int, t int) int {\n\treturn max(3 * p / 10, p - p * t / 250)\n}\n\nfunc main() {\n\tvar a, b, c, d int\n fmt.Scanf(\"%d %d %d %d\", &a, &b, &c, &d)\n\n\tscore1 := score(a, c)\n\tscore2 := score(b, d)\n\tswitch {\n\tcase score1 > score2:\n\t\tfmt.Printf(\"Misha\\n\")\n\tcase score1 < score2:\n\t\tfmt.Printf(\"Vasya\\n\")\n\tdefault:\n\t\tfmt.Printf(\"Tie\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f55e767fbb578ea1138d1815254c44c4", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar inf int = 0x3f3f3f3f\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar s string\n\nfunc main() {\n\tfmt.Fscan(reader, &s)\n\tm := make(map[string]int)\n\tfor i := 0; i <= len(s); i++ {\n\t\tfor j := 0; j < 26; j++ {\n\t\t\tt := s[0:i] + string(j+'a') + s[i:len(s)]\n\t\t\tm[t] = 1\n\t\t}\n\t}\n\tfmt.Println(len(m))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "strings"], "code_uid": "d1d53bdbf72f8ad1aaccdc4143f31783", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\ts := next()\n\tm := map[string]bool{}\n\tcnt := 0\n\n\tfor i := 0; i <= len(s); i++ {\n\t\tfor c := 'a'; c <= 'z'; c++ {\n\t\t\tt := s[0:i] + string(c) + s[i:len(s)]\n\n\t\t\tif checked, haveValue := m[t]; !haveValue && !checked {\n\t\t\t\tm[t] = true\n\t\t\t\tcnt++\n\t\t\t}\n\t\t}\n\t}\n\n\tprintln(cnt)\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["brute force", "math", "strings"], "code_uid": "be4dfa4908bec3b18feabfe7d5545563", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc min(nums ...int) int {\n\tres := math.MaxInt32\n\tfor _, num := range nums {\n\t\tif num < res {\n\t\t\tres = num\n\t\t}\n\t}\n\treturn res\n}\n\nfunc main() {\n\tn, m, a, b, countMap := 0, 0, 0, 0, map[int]int{}\n\tfmt.Scan(&n, &m)\n\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scan(&a, &b)\n\t\tcountMap[b] += a\n\t}\n\n\tpointer, result := 10, 0\n\tfor (n > 0) && (pointer > 0) {\n\t\tsteal := min(n, countMap[pointer])\n\t\tresult, n, pointer = result+steal*pointer, n-steal, pointer-1\n\t}\n\n\tfmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "6c062250dd3f695878ad2dd242b389be", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tvar a, b, f, k int64\n\tfmt.Fscanf(reader, \"%d %d %d %d\", &a, &b, &f, &k)\n\n\tgas := make([]int64, k+2)\n\tgas[0], gas[1], gas[k+1] = 0, f, a*k\n\tfor i := int64(2); i <= k; i++ {\n\t\tif i%2 == 0 {\n\t\t\tgas[i] = gas[i-1] + (a-f)*2\n\t\t} else {\n\t\t\tgas[i] = gas[i-1] + f*2\n\t\t}\n\t}\n\tpos := int64(0)\n\tans := 0\n\tfor pos != k+1 {\n\t\tif gas[pos+1]-gas[pos] > b {\n\t\t\tfmt.Printf(\"-1\")\n\t\t\treturn\n\t\t}\n\t\toil := int64(0)\n\t\tfor ; pos != k+1; pos++ {\n\t\t\tif oil+gas[pos+1]-gas[pos] > b {\n\t\t\t\tans++\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\toil = oil + gas[pos+1] - gas[pos]\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "05bb701b966183104eff75feccfdaf21", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, f, k int64\n\tfmt.Scan(&a, &b, &f, &k)\n\tstart := true\n\tfue := b\n\tstops := 0\n\tfor i := 0; i < int(k); i++ {\n\t\tdist := f\n\t\tif !start {\n\t\t\tdist = a - f\n\t\t}\n\t\tif fue < dist {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t}\n\t\tif fue < a || fue < a+(a-dist) && i+1 != int(k) {\n\t\t\tfue = b - (a - dist)\n\t\t\tstops++\n\t\t} else {\n\t\t\tfue -= a\n\t\t}\n\t\tif fue < 0 {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t}\n\t\tstart = !start\n\t}\n\tfmt.Println(stops)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "0c06cda5ab1b43c3cfdc9596e9dc360b", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, f, k int\n\tfmt.Scan(&a, &b, &f, &k)\n\tcurFuel := b\n\trefuelsNeeded := 0\n\tisInA := false\n\tfor i := k; i > 0; i-- {\n\t\tvar fuelNeeded int\n\t\tif isInA {\n\t\t\tcurFuel -= a - f\n\t\t\tif curFuel < 0 {\n\t\t\t\tfmt.Println(\"-1\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif i == 1 {\n\t\t\t\tfuelNeeded = f\n\t\t\t} else {\n\t\t\t\tfuelNeeded = 2 * f\n\t\t\t}\n\t\t\tif curFuel < fuelNeeded {\n\t\t\t\tcurFuel = b\n\t\t\t\trefuelsNeeded++\n\t\t\t}\n\t\t\tif curFuel < fuelNeeded {\n\t\t\t\tfmt.Println(\"-1\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcurFuel -= f\n\t\t\tif curFuel < 0 {\n\t\t\t\tfmt.Println(\"-1\")\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tcurFuel -= f\n\t\t\tif curFuel < 0 {\n\t\t\t\tfmt.Println(\"-1\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif i == 1 {\n\t\t\t\tfuelNeeded = a - f\n\t\t\t} else {\n\t\t\t\tfuelNeeded = 2 * (a - f)\n\t\t\t}\n\t\t\tif curFuel < fuelNeeded {\n\t\t\t\tcurFuel = b\n\t\t\t\trefuelsNeeded++\n\t\t\t}\n\t\t\tif curFuel < fuelNeeded {\n\t\t\t\tfmt.Println(\"-1\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcurFuel -= a - f\n\t\t\tif curFuel < 0 {\n\t\t\t\tfmt.Println(\"-1\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tisInA = !isInA\n\t}\n\tfmt.Printf(\"%d\\n\", refuelsNeeded)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "6e685adddbd2cee49ab630d26a2004af", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1136/problem/B\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc min(x int, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc Solve(n int, k int) int {\n\treturn 2*n + 1 + min(n-k, k-1) + n - 1\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n, k int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &k)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, k))\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "24d435f99bfacbe9e2a82cae904f88c1", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\ntype input struct {\n scanner *bufio.Scanner\n}\n\nfunc NewInput() input {\n in := input{scanner: bufio.NewScanner(os.Stdin)}\n in.scanner.Split(bufio.ScanWords)\n return in\n}\n\nfunc (in* input) Token() string {\n in.scanner.Scan()\n return in.scanner.Text()\n}\n\nfunc (in* input) IntToken() int {\n result, _ := strconv.Atoi(in.Token())\n return result\n}\n\nfunc min(a, b int) int {\n if a < b {\n return a\n }\n return b\n}\n\nfunc Calc(N, k int) int {\n return N + (N + 1) + (k + N - 1)\n}\n\nfunc main() {\n in := NewInput()\n N := in.IntToken()\n k := in.IntToken()\n result := min(Calc(N, k - 1), Calc(N, N - k))\n fmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "25f99e091e2bd0a0b3730e6b6b6e042d", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, k, cnt int\n\n\tfmt.Scanln(&n, &k)\n\n\tif ((n - k) <= (k - 1)) && (n > 2) {\n\t\tcnt = (3 * n) + (n - k)\n\t} else if ((n - k) > (k - 1)) && (n > 2) {\n\t\tcnt = (3 * n) + (k - 1)\n\t} else {\n\t\tcnt = 3 * n\n\t}\n\n\tfmt.Println(cnt)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "6dc5cd561be5254678693047c601ef25", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"fmt\"\n\t\"bufio\"\n)\n\nfunc winpos(table [][]byte, sx, sy, dx, dy int) bool {\n\tx, y := sx, sy\n\ti := 0\n\tfor i < 5 {\n\t if x>=10 || y>=10 || x<0 || y<0{\n\t return false\n\t }\n\t \n\t\tif table[x][y]!='X' {\n\t\t\treturn false\n\t\t}\n\t\t\n\t\tx += dx\n\t\ty += dy\n\t\t\n\t\ti++\n\t}\n\t\n\treturn true\n}\n\nfunc win(table [][]byte) bool {\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0;j < 10; j++ {\n\t\t\tif winpos(table, i, j, 0, 1) || winpos(table, i, j, 1, 0) || winpos(table, i, j, 1, 1) || winpos(table,i,j,1,-1) {\n\t\t\t\treturn true \n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn false\n}\n\nfunc main() {\n stdin := bufio.NewReader(os.Stdin)\n\ttable := make([][]byte, 10)\n\tfor i := 0; i < 10; i++ {\n\t\ttable[i], _, _ = stdin.ReadLine()\n\t\t\n\t}\n\t\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0;j < 10; j++ {\n\t\t\tif table[i][j]=='.' {\n\t\t\t\ttable[i][j]='X'\n\t\t\t\tif win(table) {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\tos.Exit(0)\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttable[i][j]='.'\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfmt.Println(\"NO\")\n\tos.Exit(0)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "1c5af089b4bf8e816feac2de06d558a7", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc max(x, y int) int {\n\tif x < y {\n\t\treturn y\n\t} else {\n\t\treturn x\n\t}\n}\n\nfunc get_type(l1, r1, l2, r2 int) int {\n\tif r1 < l2 || r2 < l1 {\n\t\treturn 0 // 相离\n\t}\n\n\tif l1 == l2 && r1 == r2 {\n\t\treturn 1 // 相等\n\t}\n\n\tif l1 < l2 && r2 < r1 {\n\t\treturn 2 // 包含\n\t}\n\n\tif l2 <= l1 && r1 <= r2 {\n\t\treturn 3 // 被包含\n\t}\n\n\tif l2 <= r1 && r1 <= r2 {\n\t\treturn 4\n\t}\n\n\treturn 5 // 相交\n}\n\nfunc intersect(x1, y1, x2, y2, x3, y3, x4, y4 int) (int, int, int, int) {\n\tx_type := get_type(x1, x2, x3, x4)\n\ty_type := get_type(y1, y2, y3, y4)\n\n\tif x_type == 0 || y_type == 0 {\n\t\treturn x1, y1, x2, y2\n\t} else if x_type == 1 || x_type == 3 {\n\t\tif y_type == 1 {\n\t\t\treturn -1, -1, -1, -1\n\t\t} else if y_type == 2 {\n\t\t\treturn x1, y2, x2, y2\n\t\t} else if y_type == 3 {\n\t\t\treturn -1, -1, -1, -1\n\t\t} else if y_type == 4 {\n\t\t\treturn x1, y1, x2, y3\n\t\t} else { // 5\n\t\t\treturn x1, y4, x2, y2\n\t\t}\n\t} else if x_type == 2 {\n\t\treturn x1, y1, x2, y2\n\t} else if x_type == 4 {\n\t\tif y_type == 1 || y_type == 3 {\n\t\t\treturn x1, y1, x3, y2\n\t\t} else { // 2, 4, 5\n\t\t\treturn x1, y1, x2, y2\n\t\t}\n\t} else { // 5\n\t\tif y_type == 1 || y_type == 3 {\n\t\t\treturn x4, y1, x2, y2\n\t\t} else { // 2, 4, 5\n\t\t\treturn x1, y1, x2, y2\n\t\t}\n\t}\n}\n\nfunc main() {\n\tvar xi [6]int\n\tvar yi [6]int\n\tfor i:=0; i < 3; i++ {\n\t\t_, _ = fmt.Scan(&xi[2*i], &yi[2*i], &xi[2*i+1], &yi[2*i+1])\n\t}\n\n\tx1, y1, x2, y2 := intersect(xi[0], yi[0], xi[1], yi[1], xi[2], yi[2], xi[3], yi[3])\n\tif x1 == -1 {\n\t\tfmt.Printf(\"NO\")\n\t} else {\n\t\tx1, _, _, _ := intersect(x1, y1, x2, y2, xi[4], yi[4], xi[5], yi[5])\n\t\tif x1 == -1 {\n\t\t\tfmt.Printf(\"NO\");\n\t\t} else {\n\t\t\tfmt.Printf(\"YES\");\n\t\t}\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "f21ec1de02dfb655a8c0ecf3f92752f7", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1216/problem/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Point struct {\n\tX int\n\tY int\n}\n\ntype Rectangle struct {\n\tBottomLeft Point\n\tTopRight Point\n}\n\nfunc max(x int, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x int, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc intersection(R1, R2 Rectangle) Rectangle {\n\tbottomLeft := Point{\n\t\tX: max(R1.BottomLeft.X, R2.BottomLeft.X),\n\t\tY: max(R1.BottomLeft.Y, R2.BottomLeft.Y),\n\t}\n\ttopRight := Point{\n\t\tX: min(R1.TopRight.X, R2.TopRight.X),\n\t\tY: min(R1.TopRight.Y, R2.TopRight.Y),\n\t}\n\tif topRight.X <= bottomLeft.X || topRight.Y <= bottomLeft.Y {\n\t\treturn Rectangle{BottomLeft: Point{0, 0}, TopRight: Point{0, 0}}\n\t}\n\treturn Rectangle{BottomLeft: bottomLeft, TopRight: topRight}\n}\n\nfunc area(R Rectangle) int64 {\n\treturn int64(R.TopRight.X-R.BottomLeft.X) * int64(R.TopRight.Y-R.BottomLeft.Y)\n}\n\nfunc Solve(R1, R2, R3 Rectangle) string {\n\tR4 := intersection(R1, R2)\n\tR5 := intersection(R1, R3)\n\tR6 := intersection(R4, R5)\n\tcoveredArea := area(R4) + area(R5) - area(R6)\n\tif area(R1) > coveredArea {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar R1, R2, R3 Rectangle\n\tfmt.Fscanf(reader, \"%d %d %d %d\\n\", &R1.BottomLeft.X, &R1.BottomLeft.Y, &R1.TopRight.X, &R1.TopRight.Y)\n\tfmt.Fscanf(reader, \"%d %d %d %d\\n\", &R2.BottomLeft.X, &R2.BottomLeft.Y, &R2.TopRight.X, &R2.TopRight.Y)\n\tfmt.Fscanf(reader, \"%d %d %d %d\\n\", &R3.BottomLeft.X, &R3.BottomLeft.Y, &R3.TopRight.X, &R3.TopRight.Y)\n\n\tfmt.Fprintf(writer, \"%s\\n\", Solve(R1, R2, R3))\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "c1c09426d11636f7ce9853a770905d58", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n)\nvar input *bufio.Reader\n\ntype Rectangle struct {\n left int64\n down int64\n right int64\n up int64\n}\n\nfunc Min(a, b int64) int64 {\n if a < b {\n return a\n } else {\n return b\n }\n}\n\nfunc Max(a, b int64) int64 {\n if a > b {\n return a\n } else {\n return b\n }\n}\n\nfunc area(r Rectangle) int64 {\n var (\n height int64\n width int64\n )\n if r.left < r.right {\n width = r.right - r.left\n }\n if r.down < r.up {\n height = r.up - r.down\n }\n //fmt.Println(height,width)\n return height*width\n}\n\nfunc solve() {\n var (\n x1, y1, x2, y2 int64\n x3, y3, x4, y4 int64\n x5, y5, x6, y6 int64\n )\n fmt.Fscanf(input, \"%d %d %d %d\\n\", &x1, &y1, &x2, &y2)\n fmt.Fscanf(input, \"%d %d %d %d\\n\", &x3, &y3, &x4, &y4)\n fmt.Fscanf(input, \"%d %d %d %d\\n\", &x5, &y5, &x6, &y6)\n // w\n var w Rectangle\n w.up = y2\n w.down = y1\n w.left = x1\n w.right = x2\n //fmt.Printf(\"%+v\\n\", w)\n // wb1\n var wb1 Rectangle\n wb1.up = Min(y2, y4)\n wb1.down = Max(y1, y3)\n wb1.left = Max(x1, x3)\n wb1.right = Min(x2, x4)\n //fmt.Printf(\"%+v\\n\", wb1)\n // wb2\n var wb2 Rectangle\n wb2.up = Min(y2, y6)\n wb2.down = Max(y1, y5)\n wb2.left = Max(x1, x5)\n wb2.right = Min(x2, x6)\n //fmt.Printf(\"%+v\\n\", wb2)\n var inter Rectangle\n inter.up = Min(wb1.up, wb2.up)\n inter.down = Max(wb1.down, wb2.down)\n inter.left = Max(wb1.left, wb2.left)\n inter.right = Min(wb1.right, wb2.right)\n //fmt.Printf(\"%+v\\n\", inter)\n // calculate area\n area_w := area(w)\n area_wb1 := area(wb1)\n area_wb2 := area(wb2)\n area_inter := area(inter)\n if area_w > area_wb1 + area_wb2 - area_inter {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n\nfunc main () {\n input = bufio.NewReader(os.Stdin)\n solve()\n}", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "ac111298ded3d7a9df7d51b8efa0137b", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 343A-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var u, v, a int64\n fmt.Scan(&u, &v)\n for u > int64(0) && v > int64(0) {\n if u > v {\n a += (u / v)\n u = u % v\n } else {\n a += (v / u)\n v = v % u\n }\n }\n fmt.Println(a)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "138a0ca937c85f6dc2f118d51b7f29ff", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar a, b int64\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\ta, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tr.Scan()\n\tb, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tvar min int64 = 0\n\tfor a != 0 && b != 0 {\n\t\tmin += (a/b)\n\t\ta = a%b\n\t\ta, b = b, a\n\t}\n\tw.WriteString(strconv.FormatInt(min, 10)+\"\\n\")\n\tw.Flush()\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "fc87b554da14fa41a2af052329b22617", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/343/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Count(a, b, steps int64) int64 {\n\tif b == 0 {\n\t\treturn steps\n\t} else if b == 1 {\n\t\treturn steps + a\n\t} else if a == b {\n\t\treturn steps + 1\n\t} else if a > b {\n\t\treturn Count(a%b, b, steps+a/b)\n\t} else if a < b {\n\t\treturn Count(a, b%a, steps+b/a)\n\t}\n\treturn -1\n}\n\nfunc Solve(a, b int64) int64 {\n\treturn Count(a, b, 0)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar a, b int64\n\tfmt.Fscanf(reader, \"%d %d\\n\", &a, &b)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(a, b))\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "1ffa860017d373c8a6d0527011b14663", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc exp(x int64, a int64) int64 {\n\tconst max int64 = 1000000009\n\tif x == 0 {\n\t\treturn 1\n\t}\n\tvar temp int64 = exp(x/2, (a*a)%max)\n\tif x%2 == 0 {\n\t\treturn temp%max\n\t} else {\n\t\treturn (temp*a)%max\n\t}\n}\n\nfunc main(){\n\tvar n, m, k int64\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tr.Scan()\n\tm, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tr.Scan()\n\tk, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tconst max int64 = 1000000009\n\tvar x int64 = (m-(n-m)*(k-1))/k\n\tif x < 0 {\n\t\tx = 0\n\t}\n\tvar res int64 = exp(x, 2)\n\tvar final int64 = (2*k*(res-1))%max+m-(k*x)%max\n\tfinal = final%max\n\tw.WriteString(strconv.FormatInt(final, 10)+\"\\n\")\n\tw.Flush()\n}\n", "lang_cluster": "Go", "tags": ["math", "binary search", "number theory", "greedy", "matrices"], "code_uid": "126b086a77637a3d3a2770d5aeaece3f", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nconst MOD = 1e9 + 9\n\nvar n, m, k int\n\nfunc pow2(d int) int64 {\n\treturn new(big.Int).Exp(big.NewInt(2), big.NewInt(int64(d)), big.NewInt(MOD)).Int64()\n}\n\nfunc solve() int {\n\tif n-m >= n/k {\n\t\treturn m\n\t}\n\tpnts := (n - m) * (k - 1)\n\tn -= (n - m) * k\n\tpnts = (pnts + int(2*int64(k)*(pow2(n/k)-1+MOD)%MOD)) % MOD\n\tpnts = (pnts + n%k) % MOD\n\treturn pnts\n}\n\nfunc main() {\n\tfmt.Scan(&n, &m, &k)\n\tfmt.Println(solve())\n}\n", "lang_cluster": "Go", "tags": ["math", "binary search", "number theory", "greedy", "matrices"], "code_uid": "5e64ccad10bc8b9ec88f29883246736f", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nconst maxn = 51\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scan(&n, &k)\n\tfib := make([]int64, maxn)\n\tfib[0], fib[1] = 1, 1\n\tfor i := int64(2); i < maxn; i++ {\n\t\tfib[i] = fib[i-1] + fib[i-2]\n\t}\n\tsum := int64(1)\n\tfor i := int64(1); i <= n; i++ {\n\t\tif n-i >= 0 && sum+fib[n-i] <= k {\n\t\t\tsum += fib[n-i]\n\t\t\tfmt.Printf(\"%d %d \", i+1, i)\n\t\t\ti++\n\t\t} else {\n\t\t\tfmt.Printf(\"%d \", i)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "math", "combinatorics", "binary search", "greedy", "implementation"], "code_uid": "5a94d69e68abdfa0e3441278ec1973cd", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n uint64\n\tfmt.Scanf(\"%d\", &n)\n\tfmt.Println(3*n*(n+1) + 1)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "5b3516ac284414ff0fe11f67b1e04cb2", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tfmt.Println(6*(n*(n+1))/2 + 1)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "b7240b9efc0648ef66d10eb10fd74a21", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc readInt(scanner *bufio.Scanner) int64 {\n\tscanner.Scan()\n\traw := scanner.Text()\n\tresult, _ := strconv.ParseInt(strings.Trim(raw, \" \\n\\r\"), 10, 64)\n\treturn result\n}\nfunc check(n int64) int64 {\n\treturn int64(1) + int64(3)*(n*(n+1))\n}\nfunc solve(in io.Reader, out io.Writer) {\n\treader := bufio.NewScanner(in)\n\treader.Split(bufio.ScanWords)\n\n\tfmt.Fprintln(out, check(readInt(reader)))\n}\n\nfunc main() {\n\tsolve(os.Stdin, os.Stdout)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "ecc612472af65e35c7b9fd27be6a4cf7", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1183H(_r io.Reader, _w io.Writer) {\n\tvar n int\n\tvar k, ans int64\n\tvar s []byte\n\tFscan(bufio.NewReader(_r), &n, &k, &s)\n\tprev := [26]int{}\n\tdp := make([][]int64, n+1)\n\tfor i := range dp {\n\t\tdp[i] = make([]int64, n+1)\n\t}\n\tdp[0][0] = 1\n\tfor i := 1; i <= n; i++ {\n\t\tc := s[i-1] - 'a'\n\t\tdp[i][0] = 1\n\t\tfor j := 1; j <= i; j++ {\n\t\t\tdp[i][j] = dp[i-1][j] + dp[i-1][j-1]\n\t\t\tif p := prev[c]; p > 0 {\n\t\t\t\tdp[i][j] -= dp[p-1][j-1]\n\t\t\t}\n\t\t}\n\t\tprev[c] = i\n\t}\n\tk--\n\tfor l := n - 1; l >= 0; l-- {\n\t\tcnt := dp[n][l]\n\t\tif cnt > k {\n\t\t\tans += int64(n-l) * k\n\t\t\tk = 0\n\t\t\tbreak\n\t\t}\n\t\tk -= cnt\n\t\tans += int64(n-l) * cnt\n\t}\n\tif k > 0 {\n\t\tans = -1\n\t}\n\tFprint(_w, ans)\n}\n\nfunc main() { CF1183H(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["strings", "dp"], "code_uid": "248f37e28b5f7f9cdbe4bf86e1b07353", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1183H(_r io.Reader, _w io.Writer) {\n\tvar n int\n\tvar k, ans int64\n\tvar s []byte\n\tFscan(bufio.NewReader(_r), &n, &k, &s)\n\tprev := [26]int{}\n\tdp := make([][]int64, n+1)\n\tfor i := range dp {\n\t\tdp[i] = make([]int64, n+1)\n\t}\n\tdp[0][0] = 1\n\tfor i := 1; i <= n; i++ {\n\t\tc := s[i-1] - 'a'\n\t\tdp[i][0] = 1\n\t\tfor j := 1; j <= i; j++ {\n\t\t\tdp[i][j] = dp[i-1][j] + dp[i-1][j-1]\n\t\t\tif p := prev[c]; p > 0 {\n\t\t\t\tdp[i][j] -= dp[p-1][j-1]\n\t\t\t}\n\t\t}\n\t\tprev[c] = i\n\t}\n\tk--\n\tfor l := n - 1; l >= 0; l-- {\n\t\tcnt := dp[n][l]\n\t\tif cnt > k {\n\t\t\tans += int64(n-l) * k\n\t\t\tk = 0\n\t\t\tbreak\n\t\t}\n\t\tk -= cnt\n\t\tans += int64(n-l) * cnt\n\t}\n\tif k > 0 {\n\t\tans = -1\n\t}\n\tFprint(_w, ans)\n}\n\nfunc main() { CF1183H(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["dp", "implementation", "graphs", "shortest paths"], "code_uid": "e764be99bbea0756b13ab5562700d536", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt()\n\tmin1, max1 := nextInt(), nextInt()\n\tmin2, max2 := nextInt(), nextInt()\n\tmin3, max3 := nextInt(), nextInt()\n\n\tn -= min1 + min2 + min3\n\n\tn, min1 = add(n, min1, max1)\n\tn, min2 = add(n, min2, max2)\n\tn, min3 = add(n, min3, max3)\n\n\tprintln(min1, min2, min3)\n}\n\nfunc add(n, min, max int) (int, int) {\n\tif n > 0 {\n\t\tif min+n <= max {\n\t\t\tmin += n\n\t\t\tn = 0\n\t\t} else {\n\t\t\tn -= max - min\n\t\t\tmin = max\n\t\t}\n\t}\n\n\treturn n, min\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "70e50866021e834da56615b962066f64", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\tvar num int\n\tfmt.Fscanf(r, \"%d\\n\", &num)\n\n\tm := [3][2]int{}\n\tres := [3]int{}\n\tfor i := 0; i < 3; i++ {\n\t\tfmt.Fscanf(r, \"%d %d\\n\", &m[i][0], &m[i][1])\n\n\t\tnum -= m[i][0]\n\t\tres[i] = m[i][0]\n\t}\n\n\tfor i := 0; i < 3 && num > 0; i++ {\n\t\tdiff := m[i][1] - m[i][0]\n\t\tnum -= diff\n\t\tif num < 0 {\n\t\t\tdiff += num\n\t\t}\n\t\tres[i] += diff\n\t}\n\n\tfmt.Println(res[0], res[1], res[2])\n\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "26e20342325ab44cffb9763d722e9e5d", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"bufio\"\nimport \"os\"\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc main() {\n bufin = bufio.NewReader(os.Stdin)\n bufout = bufio.NewWriter(os.Stdout)\n defer bufout.Flush()\n\n var x, y int\n fmt.Fscanf(bufin, \"%d %d\\n\", &x, &y)\n\n var a []int = []int{y, y, y}\n res := 0\n\n i := 0\n j := 1\n k := 2\n\n for (a[i] < x) || (a[j] < x) || (a[k] < x) {\n res++\n a[k] = a[i] + a[j] - 1\n if a[k] > x {\n a[k] = x\n }\n i, j, k = j, k, i\n }\n\n fmt.Fprintf(bufout, \"%d\\n\", res)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "009a909dc629905d6c9e26bd761ae68e", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nimport \"strings\"\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.TrimRight(text, \"\\r\\n\")\n\ts := strings.Split(text, \" \")\n\n\tx, _ := strconv.ParseInt(s[0], 10, 64)\n\ty, _ := strconv.ParseInt(s[1], 10, 64)\n\tif y > x {\n\t\tt := x\n\t\tx = y\n\t\ty = t\n\t}\n\tt := []int64{y, y, y}\n\tsec := 0\n\tfor t[2] != x {\n\t\tv := t[0] + t[1] - 1\n\t\tif v >= x {\n\t\t\tv = x\n\t\t}\n\t\tt[2] = t[1]\n\t\tt[1] = t[0]\n\t\tt[0] = v\n\t\tsec += 1\n\t}\n\tfmt.Println(sec)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "2d571f8b9b537f23ee2476c9402cf937", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// http://codeforces.com/contest/712/problem/C\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"math\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc check(m [3]int, val int) bool {\n\treturn m[0] >= val && m[1] >= val && m[2] >= val\n}\n\nfunc main() {\n\tvar x, y int\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\tfmt.Fscanln(input, &x, &y)\n\tif x == y {\n\t\tfmt.Println(\"0\")\n\t\treturn\n\t}\n\n\ttr := [3]int{y, y, y}\n\n\tidx := 0\n\tans := 0\n\n\tfor {\n\t\tif tr[idx] >= x {\n\t\t\tidx = (idx + 1) % 3\n\t\t\tcontinue\n\t\t}\n\n\t\tans++\n\t\ttr[idx] = min(int(math.Abs(float64(tr[(idx + 1) % 3] + tr[(idx + 2) % 3]))) - 1, x)\n\t\tif tr[idx] >= x {\n\t\t\tif check(tr, x) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tidx = (idx + 1) % 3\n\n\t}\n\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "d095858a4674819cee632d17c5d62280", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nfunc main(){\n a,m:= 0,1\n ma:=make(map[int]int)\n fmt.Scan(&a,&m)\n for true{\n _,ok:=ma[a];\n if ok{\n break\n }\n ma[a]=1;\n a*=2\n a%=m;\n }\n if _,ok:=ma[0];ok{\n fmt.Println(\"Yes\")\n } else{\n fmt.Println(\"No\")\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "matrices", "implementation"], "code_uid": "cc89aade939509999b546deedf8bb97a", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadInt64() int64 {\n scanner.Scan()\n ans, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n a := ReadInt32()\n m := ReadInt32()\n f := false\n d := make(map[int]bool)\n\n for {\n q := a % m\n if q == 0 {\n f = true\n break\n } else if _, r := d[q]; r {\n f = false\n break\n } else {\n d[q] = true\n a += q\n }\n }\n\n if f {\n writer.WriteString(\"Yes\\n\")\n } else {\n writer.WriteString(\"No\\n\")\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "matrices", "implementation"], "code_uid": "6cbb49e7805f5c219fc831e7442182a0", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, m int\n\tfmt.Scan(&a, &m)\n\n\tcheck := func() string {\n\t\tvisited := make(map[int]bool)\n\t\tfor {\n\t\t\tswitch {\n\t\t\tcase visited[a%m]:\n\t\t\t\treturn \"No\"\n\t\t\tcase a%m == 0:\n\t\t\t\treturn \"Yes\"\n\t\t\tdefault:\n\t\t\t\tvisited[a%m] = true\n\t\t\t\ta += a % m\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(check())\n}\n", "lang_cluster": "Go", "tags": ["math", "matrices", "implementation"], "code_uid": "f1647732be364fd2a4c422f4afad269d", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, m int\n\tfmt.Scan(&a, &m)\n\tvar v [100010]bool\n\tfor {\n\t\tif v[a] {\n\t\t\tfmt.Println(\"No\")\n\t\t\treturn\n\t\t}\n\t\tif a%m == 0 {\n\t\t\tfmt.Println(\"Yes\")\n\t\t\treturn\n\t\t}\n\t\tv[a] = true\n\t\ta = (a + a%m) % m\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "matrices", "implementation"], "code_uid": "0527cc275ebd8cc49a8e84ba2ef738a5", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\ta, m := int64(nextInt()), int64(nextInt())\n\tmods := make([]int64, m)\n\tmod := int64(a % m)\n\n\tfor {\n\t\tif mod == 0 {\n\t\t\tprintln(\"Yes\")\n\t\t\tbreak\n\t\t}\n\n\t\tif mods[mod] == 1 {\n\t\t\tprintln(\"No\")\n\t\t\tbreak\n\t\t} else {\n\t\t\tmods[mod] = 1\n\t\t\ta += mod\n\t\t\tmod = a % m\n\t\t}\n\t}\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, err := strconv.ParseFloat(next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}", "lang_cluster": "Go", "tags": ["math", "matrices", "implementation"], "code_uid": "8f471c6550fc91e2a54e164aecc9d4dd", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// MIT License\n//\n// Copyright (c) 2017 Nobi Hoang \n//\n// http://codeforces.com/problemset/problem/673/A\n//\n\npackage main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strings\"\n \"strconv\"\n)\n\n// ReadLine reads a line from the command line.\n// It returns the line and an error if that fails.\nfunc ReadLine() (string, error) {\n line, err := bufio.NewReader(os.Stdin).ReadString('\\n')\n if err != nil {\n return \"\", err\n }\n return strings.TrimSpace(string(line)), nil\n}\n\nfunc check(a []int, n int) int {\n if a[0] > 15 {\n return 15\n }\n\n time := 0\n for i := 0; i < n; i++ {\n if time + 15 < a[i] {\n return time + 15\n }\n time = a[i]\n }\n\n if time + 15 > 90 {\n time = 90\n } else {\n time += 15\n }\n\n return time\n}\n\n// Execute run\nfunc Execute() {\n var n int\n fmt.Scanf(\"%d\\n\", &n)\n\n var a = make([]int, n)\n s, _ := ReadLine()\n for i, str := range strings.Split(s, \" \") {\n num, _ := strconv.Atoi(str)\n a[i] = num\n }\n\n fmt.Println(check(a, n))\n}\n\n\nfunc main() {\n Execute()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "3dc3dce5522fea92c53dee1e49dd27bb", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var c,p,n,r int\n r=90\n fmt.Scan(&c)\n for i:=0; i15 {\n r=p+15\n break\n } else {\n p=n\n }\n }\n if 90-p>15 {\n r=p+15\n }\n fmt.Println(r)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ce2743fe5604fde352d8244186711fc6", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "\tpackage main\n\timport(\n\t\t\"fmt\"\n\t\t\"bufio\"\n\t\t\"os\"\n\t\t\"strings\"\n\t\t\"strconv\"\n\t)\n\tfunc main(){\n\t\tscanner := bufio.NewScanner(os.Stdin)\n\t\tscanner.Scan()\n\t\ttimes := scanner.Text()\n\t\tscanner.Scan()\n\t\tm := scanner.Text()\n\t\tif times == \"1\"{\n\t\t\tintminute,_ := strconv.Atoi(m)\n\t\t\tif intminute > 15 {\n\t\t\t\tfmt.Println(15)\n\t\t\t}else{\n\t\t\t\tfmt.Println(intminute + 15)\n\t\t\t}\n\t\t}else{\n\t\t\tminutes := strings.Split(m,\" \")\n\t\t\tfor i := 1; i < len(minutes); i++{\n\t\t\t\ta,_ := strconv.Atoi(minutes[i-1])\n\t\t\t\tb,_ := strconv.Atoi(minutes[i])\n\t\t\t\tif i == 1{\n\t\t\t\t\tif a > 15{\n\t\t\t\t\t\tfmt.Println(15)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif b - a > 15{\n\t\t\t\t\tfmt.Println(a+15)\n\t\t\t\t\tbreak\n\t\t\t\t}else{\n\t\t\t\t\tif i == len(minutes) -1{\n\t\t\t\t\t\tif b + 15 > 90{\n\t\t\t\t\t\t\tfmt.Println(90)\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tfmt.Println(b + 15)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "03cb1c312932ce5a739cb0806cbfdace", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scanf(\"%d\\n%s\", &n, &s)\n\tb := []byte(s)\n\tfor i := 1;i <= n;i ++ {\n\t\tif n % i == 0 {\n\t\t\tfor l, r := 0, i - 1;l < r; l, r = l + 1, r - 1 {\n\t\t\t\tb[l], b[r] = b[r], b[l]\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%s\", string(b))\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ae192bd8d2ddf3887625c2c99c6a2521", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nvar in = bufio.NewReader(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc reverse(x int, s []byte) {\n\tfor i, j := 0, x-1; i < j; i, j = i+1, j-1 {\n\t\ts[i], s[j] = s[j], s[i]\n\t}\n}\n\nfunc main() {\n\tdefer out.Flush()\n\n\tvar n int\n\tvar s []byte\n\tfmt.Fscan(in, &n, &s)\n\n\t//TODO: enhancement, sqrt\n\tfor i := 2; i <= n; i++ {\n\t\tif n % i == 0 {\n\t\t\treverse(i, s)\n\t\t}\n\t}\n\tfmt.Fprintln(out, string(s))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "daf90f621c287722a1c4dd4c7d626bc1", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 986 B done\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"strings\"\n\t\"strconv\"\n\t\"os\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n\tvar a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor i:=0; i 0)) || (c == 0) && (d > 0)) {\n fmt.Printf(\"Ron\\n\");\n } else {\n fmt.Printf(\"Hermione\\n\");\n }\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "e73108779477f3103f43b53d4ad13dd8", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// A. Petya and Origami\n/*\nPetya is having a party soon, and he has decided to invite his 𝑛 friends.\n\nHe wants to make invitations in the form of origami. For each invitation, he needs two red sheets, five green sheets, and eight blue sheets. The store sells an infinite number of notebooks of each color, but each notebook consists of only one color with 𝑘 sheets. That is, each notebook contains 𝑘 sheets of either red, green, or blue.\n\nFind the minimum number of notebooks that Petya needs to buy to invite all 𝑛 of his friends.\n\nInput\nThe first line contains two integers 𝑛 and 𝑘 (1≤𝑛,𝑘≤108) — the number of Petya's friends and the number of sheets in each notebook respectively.\n\nOutput\nPrint one number — the minimum number of notebooks that Petya needs to buy.\n\nExamples\nInput\n3 5\n\nOutput\n10\n\nInput\n15 6\n\nOutput\n38\n\nNote\nIn the first example, we need 2 red notebooks, 3 green notebooks, and 5 blue notebooks.\n\nIn the second example, we need 5 red notebooks, 13 green notebooks, and 20 blue notebooks.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\tarr := strings.Split(strings.TrimSpace(input), \" \")\n\tn, _ := strconv.ParseFloat(arr[0], 64)\n\tk, _ := strconv.ParseFloat(arr[1], 64)\n\n\tr := math.Ceil(float64(2.0 * n / k))\n\tg := math.Ceil(float64(5.0 * n / k))\n\tb := math.Ceil(float64(8.0 * n / k))\n\n\tfmt.Print(int64(r + g + b))\n\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "51f9b9883587d396a147b5b96ff42028", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nfunc fun(x int, y int) int {\n\tans := 2 * x / y\n\tif 2 * x % y != 0 {\n\t\tans += 1\n\t}\n\tans += 5 * x / y\n\tif 5 * x % y != 0 {\n\t\tans += 1\n\t}\n\tans += 8 * x / y\n\tif 8 * x % y != 0 {\n\t\tans += 1\n\t}\n\treturn ans\n}\n \nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tfmt.Println(fun(a, b))\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "6b165264119da8edcdde1354c49e4a09", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport (\n\t\"fmt\"\n)\nvar (\n\tn, m int\n\tans int\n)\nfunc main() {\n\tfmt.Scanln(&n, &m)\n\tans = 0;\n\tans += (n * 2 - 1) / m + 1\n\tans += (n * 5 - 1) / m + 1\n\tans += (n * 8 - 1) / m + 1\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "d76d2f9dcd43d7475e873664af22d5e3", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar t int64\n\n\tfmt.Fscanf(buf, \"%d\\n\", &t)\n\tvar ans int64 = 1\n\n\tfor {\n\t\tif ans*ans >=t{\n\t\t\tans = ans*2\n\t\t\tbreak\n\t\t}\n\t\tif ans*(ans+1) >= t{\n\t\t\tans = ans*2+1\n\t\t\tbreak\n\t\t}\n\t\tans++\n\t}\n\n\tfmt.Printf(\"%d\\n\", ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "4431081f0c1c5a4d5c29c595c60efcaf", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nfunc main(){\n\tvar N int\n\tfmt.Scanf(\"%d\",&N)\n\tfmt.Println(count(N))\n}\n\nfunc count(N int) int{\n\th := 0\n\tv := 0\n\tarea := h*v\n\tfor i:= 1 ; i<=N;i++{\n\t\tif i == 1{\n\t\t\th = 1\n\t\t\tv = 1\n\t\t\tarea = h*v\n\t\t}else{\n\t\t\tif i > area && math.Mod(math.Sqrt(float64(i)),1) != 0{\n\t\t\t\th += 1\n\t\t\t}else if i > area && math.Mod(math.Sqrt(float64(i)),1) == 0{\n\t\t\t\th -=1\n\t\t\t\tv += 1\n\t\t\t}\n\t\t\tarea = h*v\n\t\t}\n\t}\n\treturn h+v\n}", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "4abf743c09bc6113f915b163f99eed0e", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"strings\"\n\t// \"fmt\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc main() {\n\tdefer writer.Flush()\n scanner.Split(bufio.ScanWords)\n\n\tn := int64(ReadInt())\n\n\tl := int64(2)\n\tr := int64(1000000000)\n\n\tans := int64(0)\n\n\tfor l <= r {\n\n\t\tmid := int64((l+r)/2)\n\n\t\tmetade := int64(mid/2)\n\t\tmetade1 := int64(mid - metade)\n\n\t\ttotal := metade*metade1\n\n\t\t// fmt.Println(mid, metade, metade1)\n\n\t\tif total >= n {\n\t\t\tans = mid\n\t\t\tr = mid-1\n\t\t} else{\n\t\t\tl = mid+1\n\t\t}\n\t}\n\n writer.WriteString(strconv.FormatInt(ans,10))\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "923157e75bac83c80c2b147bdc763077", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 388A-mic\npackage main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n, cou int\n fmt.Scan(&n)\n a := make([]int, n)\n for i := range a {\n fmt.Scan(&a[i])\n }\n f := 1\n sort.Sort(sort.IntSlice(a))\n for i := 0; i < n; i++ {\n f = 1\n if a[i] != -1 {\n for j := i + 1; j < n; j++ {\n if a[j] >= f && a[j] != -1 {\n f++\n a[j] = -1\n }\n }\n cou++\n }\n }\n fmt.Println(cou)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "6f83dab7bb4186a87ca23965c346ae85", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tlist:=make([]int,n+1)\n\thasil:=0\n\tfor i:=1;i<=n;i++ {\n\t\tfmt.Scan(&list[i])\n\t}\n\tsort.Ints(list)\n\tfor i:=1;i<=n;i++ {\n\t\tif (hasil*list[i]+hasil) 0; i-- {\n\t\tfor j := 0; j <= n; j++ {\n\t\t\tfor k := a[i]; k <= j; k++ {\n\t\t\t\tdp[i][j] = (dp[i][j] + dp[i+1][j-k]*c[j][j-k]) % MOD\n\t\t\t}\n\t\t}\n\t}\n\n\tvar ans int64\n\tfor j := a[0] + 1; j <= n; j++ {\n\t\tfor k := a[0]; k < j; k++ {\n\t\t\tans = (ans + dp[1][j-k]*c[j-1][j-k-1]) % MOD\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["dp", "combinatorics"], "code_uid": "f2811737c7016ab2e735e86c2b7d729e", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc divisors(n int) int{\n\tc:= 1\n\tfor d:=2; d<100; d++{\n\t\tif (n % d == 0){\n\t\t\talpha := 0;\n\t\t\tfor ;n % d == 0; {\n\t\t\t\tn /= d\n\t\t\t\talpha++\n\t\t\t}\n\t\t\tc *= (alpha + 1)\n\t\t}\n\t}\n\treturn c\n}\n\nfunc main() {\n\tvar sum , al, bl, cl int\n\tsum=0\n\tfmt.Scan(&al,&bl,&cl)\n\tfor a := 1; a <= al; a++{\n\t\tfor b := 1; b <= bl; b++{\n\t\t\tfor c := 1; c <= cl; c++{\n\t\t\t\tsum += divisors(a*b*c);\n\t\t\t\tsum %= 1073741824;\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(sum)\n}\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["implementation", "number theory"], "code_uid": "39dee74281ef52220602ed2eb6f2da18", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar d []int\n\nfunc createDivisorsArray(size int) {\n\td = make([]int, size)\n}\n\nfunc sieve(n int) {\n\tcreateDivisorsArray(n + 1)\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := i * 2; j <= n; j += i {\n\t\t\td[j]++\n\t\t}\n\t\td[i]++\n\t}\n}\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\tsieve(a * b * c)\n\tres := 0\n\tfor i := 1; i <= a; i++ {\n\t\tfor j := 1; j <= b; j++ {\n\t\t\tfor k := 1; k <= c; k++ {\n\t\t\t\tres += d[i*j*k]\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["implementation", "number theory"], "code_uid": "05a1295480b2c6c71726f1bed925bcd1", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte. Trailing '\\n' will not be included.\n// See also comments on readb()\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Utilities\n\nfunc sumSlice(a []int) int {\n\tvar res int\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc sumSlicell(a []int64) int64 {\n\tvar res int64\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc readInts(N int) (int, []int) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int, N)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\treturn N, a\n}\n\nfunc readIntsll(N int) (int, []int64) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int64, N)\n\tfor i := range a {\n\t\ta[i] = readll()\n\t}\n\treturn N, a\n}\n\n// reverse slice in place\nfunc reverse(a []int) {\n\tfor i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {\n\t\ta[i], a[j] = a[j], a[i]\n\t}\n}\n\n// areverse: allocating reverse\nfunc areverse(a []int) []int {\n\tb := make([]int, len(a))\n\tfor i := range a {\n\t\tb[i] = a[len(a)-i-1]\n\t}\n\treturn b\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n\nfunc main() {\n\tdefer Flush()\n\n\tn, a := readInts(0)\n\t_ = n\n\tp := make([]bool, 3)\n\tp[0] = true\n\tp[1] = true\n\tfor _, v := range a {\n\t\twin := v - 1\n\t\tvar lose, spect int\n\t\tif !p[win] {\n\t\t\tprintln(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tfor i := range p {\n\t\t\tif i == win {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !p[i] {\n\t\t\t\tspect = i\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlose = i\n\t\t}\n\t\tp[win] = true\n\t\tp[spect] = true\n\t\tp[lose] = false\n\t}\n\tprintln(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "481b5de8c7df0df77ff6e767a846ff49", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar buff string\n\tfmt.Scanln(&buff)\n\tvar n int\n\tn, _ = strconv.Atoi(buff)\n\n\tvar game byte\n\tgame = 3\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanln(&buff)\n\t\twinner, _ := strconv.Atoi(buff)\n\t\twinner--\n\t\tbit := byte(math.Pow(2, float64(winner)))\n\t\tif int(game&bit) == 0 {\n\t\t\tfmt.Print(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tgame = ^game&7 | bit\n\t}\n\n\tfmt.Print(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "56b8b9bb850f40a3ccd26142eb57be87", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\n\tx := 1\n\ty := 2\n\ts := 3 // spectator\n\tfor _, v := range a {\n\t\tswitch v {\n\t\tcase s:\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\tcase x:\n\t\t\ts, y = y, s\n\t\tcase y:\n\t\t\ts, x = x, s\n\t\t}\n\t}\n\n\tfmt.Println(\"YES\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e8e876303c2cf7b18ec57b6697f1add9", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n\t\"regexp\"\r\n\t\"strconv\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1618F(in io.Reader, out io.Writer) {\r\n\tvar x, y uint64\r\n\tFscan(in, &x, &y)\r\n\tif x == y {\r\n\t\tFprintln(out, \"YES\")\r\n\t\treturn\r\n\t}\r\n\ts := strconv.FormatUint(x, 2)\r\n\tt := strconv.FormatUint(y, 2)\r\n\trt := []byte(t)\r\n\tfor i, n := 0, len(rt); i < n/2; i++ {\r\n\t\trt[i], rt[n-1-i] = rt[n-1-i], rt[i]\r\n\t}\r\n\tf := func() bool {\r\n\t\tr := regexp.MustCompile(\"^1*\" + s + \"1*$\")\r\n\t\treturn r.MatchString(t) || r.Match(rt)\r\n\t}\r\n\ts += \"1\"\r\n\tif f() {\r\n\t\tFprintln(out, \"YES\")\r\n\t\treturn\r\n\t}\r\n\ts = s[:len(s)-1]\r\n\tfor s[len(s)-1] == '0' {\r\n\t\ts = s[:len(s)-1]\r\n\t}\r\n\tif f() {\r\n\t\tFprintln(out, \"YES\")\r\n\t} else {\r\n\t\tFprintln(out, \"NO\")\r\n\t}\r\n}\r\n\r\nfunc main() { CF1618F(os.Stdin, os.Stdout) }\r\n", "lang_cluster": "Go", "tags": ["dfs and similar", "constructive algorithms", "math", "bitmasks", "strings", "implementation"], "code_uid": "2482fca192842b220a2950ef5ab5e0ad", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"regexp\"\r\n\t\"strconv\"\r\n\t\"strings\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc main() {\r\n\tvar x, y uint64\r\n\tScan(&x, &y)\r\n\tif x == y {\r\n\t\tPrint(\"YES\")\r\n\t\treturn\r\n\t}\r\n\tt := strconv.FormatUint(y, 2)\r\n\trev := []byte(t)\r\n\tfor i, n := 0, len(rev); i < n/2; i++ {\r\n\t\trev[i], rev[n-1-i] = rev[n-1-i], rev[i]\r\n\t}\r\n\tf := func(s string) bool {\r\n\t\tr := regexp.MustCompile(\"^1*\" + s + \"1*$\")\r\n\t\treturn r.MatchString(t) || r.Match(rev)\r\n\t}\r\n\ts := strconv.FormatUint(x, 2)\r\n\tif f(s+\"1\") || f(strings.TrimRight(s, \"0\")) {\r\n\t\tPrint(\"YES\")\r\n\t} else {\r\n\t\tPrint(\"NO\")\r\n\t}\r\n}\r\n", "lang_cluster": "Go", "tags": ["dfs and similar", "constructive algorithms", "math", "bitmasks", "strings", "implementation"], "code_uid": "240e6f120c633549ad96504c6ddabb1c", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn, x, y := nextInt(), nextInt64(), nextInt64()\n\ta := make([]int64, n+1)\n\n\tdp(a, x, y)\n\tprintln(a[n])\n}\n\nfunc dp(a []int64, x, y int64) {\n\tfor i := 1; i < len(a); i++ {\n\t\tif i%2 == 0 {\n\t\t\ta[i] = min(a[i-1]+x, a[i/2]+y)\n\t\t} else {\n\t\t\ta[i] = min(a[i-1]+x, min(a[i/2], a[(i+1)/2])+x+y)\n\t\t}\n\t}\n}\n\nfunc min(a, b int64) int64 {\n\tif a <= b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["dfs and similar", "dp"], "code_uid": "fc3e783dbbd7f9a483f0a33faad56400", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"strconv\"\nimport \"os\"\nimport \"bufio\"\n\nvar in *bufio.Scanner\nvar out *bufio.Writer\n\nfunc min(x int64, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc dp(n int, x int64, y int64) int64 {\n\tf := make([]int64, n+1)\n\n\tf[0] = 0\n\tfor i := 1; i <= n; i++ {\n\t\tif i%2 == 0 {\n\t\t\tf[i] = min(f[i-1]+x, f[i/2]+y)\n\t\t} else {\n\t\t\tf[i] = min(f[i-1]+x, f[(i+1)/2]+y+x)\n\t\t}\n\t}\n\n\treturn f[n]\n}\n\nfunc main() {\n\tin = bufio.NewScanner(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n\n\tin.Split(bufio.ScanWords)\n\tdefer out.Flush()\n\n\tin.Scan()\n\tn, _ := strconv.Atoi(in.Text())\n\n\tin.Scan()\n\tx, _ := strconv.Atoi(in.Text())\n\n\tin.Scan()\n\ty, _ := strconv.Atoi(in.Text())\n\n\tres := dp(n, int64(x), int64(y))\n\n\tout.WriteString(strconv.FormatInt(res, 10))\n\tout.WriteByte('\\n')\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "dp"], "code_uid": "5f6317dec94602a42b2fe1092d4e4e5b", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// http://codeforces.com/problemset/problem/710/E\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min (a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc main() {\n\tvar n int\n\tvar x, y int64\n\n\tfmt.Scanln(&n, &x, &y)\n\ttimes := make([]int64, n)\n\n\ttimes[0] = x\n\tfor i := 1; i < n; i++ {\n\t\tif i % 2 == 0 {\n\t\t\t// odd\n\t\t\ttimes[i] = min(x + times[i - 1], y + times[i / 2] + x)\n\t\t} else {\n\t\t\t// even\n\t\t\ttimes[i] = min(x + times[i - 1], y + times[i / 2])\n\t\t}\n\t}\n\n\tfmt.Println(times[n - 1])\n}\n\n", "lang_cluster": "Go", "tags": ["dfs and similar", "dp"], "code_uid": "1bd725fc333d4d2e34cb0a220184eb53", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\t\n\tcnt := 0\n\tfor a := 1; a <= N; a++ {\n\t for b := a; b <= N; b++ {\n\t c := a ^ b\n\t if c < b {\n\t continue\n\t }\n\t if c > b - a && c < b + a && c <= N {\n\t cnt++\n\t }\n\t }\n\t}\n\tio.Println(cnt)\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "4e05dfcd1aaf3c9b579532c96eddf4b0", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var total, downloaded, q float64\n fmt.Scanf(\"%f %f %f\", &total, &downloaded, &q)\n\n var listened = 0.0\n var ans = 0\n\n for {\n ans++\n\n var t = (downloaded - listened) * q\n if t >= total {\n break\n } else {\n downloaded = t\n listened = 0\n }\n }\n\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "7b875f514835dcb86aacdb95c53693af", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scanInt(a interface{}) { fmt.Fscanf(reader, \"%d\", a) }\nfunc scanlnInt(a interface{}) { fmt.Fscanf(reader, \"%d\\n\", a) }\nfunc scanChar(a interface{}) { fmt.Fscanf(reader, \"%c\", a) }\nfunc scanString(a interface{}) { fmt.Fscanf(reader, \"%s\", a) }\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\ta := make([]int64, 14)\n\tfor i := range a {\n\t\tscanInt(&a[i])\n\t}\n\tmaxcount := int64(0)\n\tfor i := int64(0); i < 14; i++ {\n\t\tcount, k := int64(0), a[i]\n\t\ta[i] = 0\n\t\tfor j := int64(0); j < 14; j++ {\n\t\t\tn := a[(i+j)%14] + k/14\n\t\t\tif (j-1+14)%14 < k%14 {\n\t\t\t\tn++\n\t\t\t}\n\t\t\tif n%2 == 0 {\n\t\t\t\tcount += n\n\t\t\t}\n\t\t}\n\t\tmaxcount, a[i] = max(maxcount, count), k\n\t}\n\tprintf(\"%d\", maxcount)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "896abb8410bf23fd7b0e9725dff0a908", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printF(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanF(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scanSlice(n int) []int64 {\n\ta := make([]int64, n)\n\tl, _ := reader.ReadString('\\n')\n\ts := strings.Split(strings.TrimSpace(l), \" \")\n\tfor i := 0; i < n; i++ {\n\t\ta[i], _ = strconv.ParseInt(s[i], 10, 0)\n\t}\n\treturn a\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\ta := scanSlice(14)\n\n\tmaxcount := int64(0)\n\tfor i := range a {\n\t\tif a[i] == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tcount, k := int64(0), a[i]\n\t\ta[i] = 0\n\t\tfor j := range a {\n\t\t\tn := a[(i+j)%14] + k/14\n\t\t\tif (int64(j)-1+14)%14 < k%14 {\n\t\t\t\tn++\n\t\t\t}\n\t\t\tif n%2 == 0 {\n\t\t\t\tcount += n\n\t\t\t}\n\t\t}\n\t\tmaxcount, a[i] = max(maxcount, count), k\n\t}\n\tprintF(\"%d\", maxcount)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "353d5f367f7dbab3930a5037742acaa2", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b, c, d int\n\tfmt.Scan(&n, &a, &b, &c, &d)\n\n\t// x1 a x2\n\t// b x3 c\n\t// x4 d x5\n\n\t// x1\n\t// x2 = x1 - c + b\n\t// x4 = x1 + a - d\n\t// x5 = x1 + a + b - c - d\n\tvar ans uint64\n\tans = 0\n\tfor x1 := 1; x1 <= n; x1++ {\n\t\tx2 := x1 - c + b\n\t\tx4 := x1 + a - d\n\t\tx5 := x1 + a + b - c - d\n\n\t\tif x2 >= 1 && x2 <= n && x4 >= 1 && x4 <= n && x5 >= 1 && x5 <= n {\n\t\t\tans++\n\t\t}\n\t}\n\n\tfmt.Println(ans * uint64(n))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "115fc1b54755b190941fb171e3c1e9ee", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\n// a+b+e+g == a+c+f+g == b+d+g+h == c+d+g+i\n//\n// b+e = c+f\n// a+f = d+i\n// b+h = c+i\n// a+e = d+h\n//\n// e-f = c-b\n// h-i = c-b\n// e-h = d-a\n// f-i = d-a\n//\n// f+h = e+i\n//\n// g can be anything from 1 to n\n// assume c >= b && d >= a (problem is symmetric)\n// i can be from 1 to (n-(c-b)-(d-a))\n// h = i + (c-b); from (1+(c-b)) to (n-(d-a))\n// f = i + (d-a); from (1+(d-a)) to (n-(c-b))\n// e = i + (c-b) + (d-a); from (1+(c-b)+(d-a)) to n\n//\n// total combinations: n * (n-(c-b)-(d-a)) assuming c>=b && d>=a\n// \nfunc Combinations(n, a, b, c, d uint64) uint64 {\n\tif b > c {\n\t\tc, b = b, c\n\t}\n\tif a > d {\n\t\td, a = a, d\n\t}\n\tif (c-b)+(d-a) >= n {\n\t\treturn 0\n\t}\n\treturn n*(n-(c-b)-(d-a))\n}\n\nfunc CombinationsStr(s string) string {\n\tvar n, a, b, c, d uint64\n\tfmt.Sscanf(s, \"%d %d %d %d %d\", &n, &a, &b, &c, &d)\n\tres := Combinations(n, a, b, c, d)\n\treturn fmt.Sprint(res)\n}\n\nfunc main() {\n\t// fmt.Println(CombinationsStr(\"2 1 1 1 2\")) // 2\n\t// fmt.Println(CombinationsStr(\"3 3 1 2 3\")) // 6\n\tbuf, err := ioutil.ReadAll(os.Stdin)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tres := CombinationsStr(string(buf))\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "fd728a1b339e66baa248f741001af09e", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc main() { fmt.Println(sol()) }\n\nfunc sol() int64 {\n\tn := getInt()\n\ta := getInt()\n\tb := getInt()\n\tc := getInt()\n\td := getInt()\n\n\te, f, g, h := a+b, b+d, d+c, c+a\n\tmx := max(max(e, f), max(g, h))\n\tmn := min(min(e, f), min(g, h))\n\n\tx := mx + 1 - mn\n\tif n-x < 0 {\n\t\treturn 0\n\t}\n\treturn int64(n-x+1) * int64(n)\n}\n\ntype Input struct {\n\t*bufio.Scanner\n}\n\nvar globalInput = wrapStdin()\n\nfunc wrapStdin() Input {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\treturn Input{Scanner: sc}\n}\nfunc getInt() int {\n\tglobalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x\n}\nfunc getIntOk() (int, bool) {\n\tok := globalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x, ok\n}\nfunc getNint(n int) []int {\n\tv := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tv[i] = getInt()\n\t}\n\treturn v\n}\nfunc getVint(v []int) bool {\n\tvar ok bool\n\tfor i := 0; i < len(v); i++ {\n\t\tv[i], ok = getIntOk()\n\t}\n\treturn ok\n}\nfunc getWord() string {\n\tglobalInput.Scan()\n\treturn globalInput.Text()\n}\nfunc getWordOk() (string, bool) {\n\tok := globalInput.Scan()\n\treturn globalInput.Text(), ok\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc min64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max64(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc minStr(a, b string) string {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc maxStr(a, b string) string {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc remin(a *int, b int) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remax(a *int, b int) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remin64(a *int64, b int64) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remax64(a *int64, b int64) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc reminStr(a *string, b string) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remaxStr(a *string, b string) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\nfunc abs64(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\ntype (\n\tFLess func(i, j int) bool\n\tFSwap func(i, j int)\n\twrapSort struct {\n\t\tLength int\n\t\tFLess\n\t\tFSwap\n\t}\n)\n\nfunc (w *wrapSort) Len() int { return w.Length }\nfunc (w *wrapSort) Less(i, j int) bool { return w.FLess(i, j) }\nfunc (w *wrapSort) Swap(i, j int) { w.FSwap(i, j) }\nfunc wsort(length int, fless func(i, j int) bool, fswap func(i, j int)) {\n\tsort.Sort(&wrapSort{length, fless, fswap})\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "f7bbbf33af8b516fcd9ce018250c9d2f", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, v int\n\tfmt.Scan(&n, &v)\n\tv++\n\tdp := make([][]int, n)\n\tfor i := range dp {\n\t\tdp[i] = make([]int, v)\n\t}\n\tfor i := range dp {\n\t\tfor j := range dp[i] {\n\t\t\tif i == 0 {\n\t\t\t\tif j > 0 {\n\t\t\t\t\tdp[i][j] = dp[i][j-1] + i + 1\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif j == 0 {\n\t\t\t\t\tdp[i][j] = dp[i-1][j+1]\n\t\t\t\t} else if j == v-1 {\n\t\t\t\t\tdp[i][j] = dp[i][j-1] + i + 1\n\t\t\t\t} else {\n\t\t\t\t\tdp[i][j] = min(dp[i-1][j+1], dp[i][j-1]+i+1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tm := int(1e9)\n\tfor i := 0; i < v; i++ {\n\t\tm = min(m, dp[n-1][i])\n\t}\n\tfmt.Println(m)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "0ede99991bd191e0c7cd103762e25623", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(n, v int) int {\n\tres := v\n\tif n-1 <= v {\n\t\tres = n - 1\n\t}\n\tfor i := 2; i < n; i++ {\n\t\tif i <= n-v {\n\t\t\tres += i\n\t\t}\n\t}\n\treturn res\n}\n\nfunc main() {\n\tn, v := 0, 0\n\n\tfmt.Scan(&n, &v)\n\tfmt.Println(solve(n, v))\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "c9698f8b926695f0c6da3e64e1cd3035", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc readLine()(string,error) \t\t\t{ return reader.ReadString('\\n') }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar n, v int\n\tscanf(\"%d %d\", &n, &v)\n\tvar c int;\n\tif (n <= v) {\n\t\tc = n - 1\n\t} else {\n\t\tc = v\n\t\tfor i := 2; i <= n-v; i++ {\n\t\t\tc += i\n\t\t}\n\t}\n\tprintf(\"%d\\n\" ,c)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "71568dc38e9a6f37eacf43aaced7e509", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tbuf := &bytes.Buffer{}\n\tfor i := 0; i < 400; i++ {\n\t\tfmt.Fprintf(buf, \"%d\", i)\n\t}\n\tfmt.Println(buf.Bytes()[getInt()] - '0')\n}\n\ntype Input struct {\n\t*bufio.Scanner\n}\n\nvar globalInput = wrapStdin()\n\nfunc wrapStdin() Input {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\treturn Input{Scanner: sc}\n}\nfunc getInt() int {\n\tglobalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x\n}\nfunc getIntOk() (int, bool) {\n\tok := globalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x, ok\n}\nfunc getNint(n int) []int {\n\tv := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tv[i] = getInt()\n\t}\n\treturn v\n}\nfunc getVint(v []int) bool {\n\tvar ok bool\n\tfor i := 0; i < len(v); i++ {\n\t\tv[i], ok = getIntOk()\n\t}\n\treturn ok\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5618965267fc94120ce415b2498a2d65", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"strconv\"\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n str := \"0\"\n for i:=1; i<=n; i++{\n s := strconv.Itoa(i)\n str += s\n }\n fmt.Printf(\"%c\", str[n])\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "131d6542f76af892585af32744539dd5", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc splitToDigits(n int) []int {\n var a []int = make([]int, 0)\n for n > 0 {\n a = append(a, n%10)\n n = n/10\n }\n return a\n}\n\nfunc main() {\n var n int\n fmt.Scanf(\"%v\\n\", &n)\n pos := 0\n for q := 1; q <= n; q++ {\n a := splitToDigits(q)\n pos += len(a)\n //fmt.Printf(\"%v %v\\n\", pos, a)\n if pos == n {\n fmt.Printf(\"%v\", a[0])\n return\n } else if pos > n {\n for i := 0; i < len(a); i++ {\n pos -= 1\n if pos == n-1 {\n fmt.Printf(\"%v\", a[i])\n return\n }\n }\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2471fbc1a7715720f269c8fbfdd54a6f", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n total, found, min, max := getI(), getI(), getI(), getI()\n foundMin, foundMax := false, false\n for i := 0; i < found; i++ {\n x := getI()\n if x < min || x > max {\n writer.WriteString(\"Incorrect\\n\")\n return\n }\n if x == min {\n foundMin = true\n } else if x == max {\n foundMax = true\n }\n }\n result := \"Correct\"\n if !foundMin && !foundMax && total-found == 1 {\n result = \"Incorrect\"\n }\n writer.WriteString(fmt.Sprintf(\"%s\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4479388c97f6b8f02da419fcad0aae3d", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\n\n\n\nfunc main() {\n\tsdeck := make([]string, 8)\n\tfor i := 0; i < 8; i++{\n\t\tfmt.Scan(&sdeck[i])\n\t}\n\tvar deck [8][8]int\n\tcount := 0\n\tfor i, s := range sdeck{\n\t\tfor j, c := range s{\n\t\t\tif c == 'B'{\n\t\t\t\tdeck[i][j] = 1\n\t\t\t}else{\n\t\t\t\tdeck[i][j] = 0\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 8; i++{\n\t\tsum := 0\n\t\tfor j := 0; j < 8; j++ {\n\t\t\tif deck[i][j] == 1{\n\t\t\t\tsum++\n\t\t\t}\n\t\t}\n\t\tif sum == 8 {\n\t\t\tcount++\n\t\t}\n\t}\n\tif count < 8{\n\t\tfor i := 0; i < 8; i++{\n\t\t\tsum := 0\n\t\t\tfor j := 0; j < 8; j++ {\n\t\t\t\tif deck[j][i] == 1{\n\t\t\t\t\tsum++\n\t\t\t\t}\n\t\t\t}\n\t\t\tif sum == 8 {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(count)\n}", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms"], "code_uid": "384b551c2b209e84167fbef1f36e0202", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 7A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\ts := make([]string, 8)\n\tvar i, j int\n\tc, k, r := 0, 0, 0\n\tfor i = 0; i < 8; i++ {\n\t\tk = 0\n\t\tfmt.Scan(&s[i])\n\t\tfor j = 0; j < 8; j++ {\n\t\t\tif s[i][j] == 'B' {\n\t\t\t\tk++\n\t\t\t}\n\t\t}\n\t\tif k == 8 {\n\t\t\tc = c + 1\n\t\t} else {\n\t\t\tr = k\n\t\t}\n\t}\n\tfmt.Println(c + r)\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms"], "code_uid": "0c968f4ec388c31666624f1d70f76298", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"strings\"\n\t\"fmt\"\n\t\"strconv\"\n\t\"errors\"\n\t\"io\"\n\t\"unicode/utf8\"\n\t\"bytes\"\n\t\"os\"\n)\n\nfunc main() {\n\tboard := make([][]rune, 8)\n\tfor i := 0; i < 8; i++ {\n\t\tboard[i] = []rune(nextWord())\n\t}\n\ttotal := 0\n\tfor i := 0; i < 8; i++ {\n\t\tcount := 0\n\t\tfor j := 0; j < 8; j++ {\n\t\t\tif board[i][j] == 'B' {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t\tif count == 8 {\n\t\t\tfor j := 0; j < 8; j++ {\n\t\t\t\tboard[i][j] = 'A'\n\t\t\t}\n\t\t\ttotal++\n\t\t}\n\t}\n\tfor i := 0; i < 8; i++ {\n\t\tfor j := 0; j < 8; j++ {\n\t\t\tif board[j][i] == 'B' {\n\t\t\t\ttotal++\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", total)\n}\n\nvar lineScanner *Scanner\nvar wordScanner *Scanner\n\nfunc init() {\n\tlineScanner = NewScanner(os.Stdin)\n\twordScanner = NewScanner(strings.NewReader(\"\"))\n\twordScanner.Split(ScanWords)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Printf(format, a...)\n}\nfunc nextLine() (string, error) {\n\tif !lineScanner.Scan() {\n\t\tif err := lineScanner.Err(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\treturn \"\", errors.New(\"nextLine: EOF reached\")\n\t}\n\treturn lineScanner.Text(), nil\n}\n\nfunc nextWord() string {\n\tfor !wordScanner.Scan() {\n\t\tif err := wordScanner.Err(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tline, err := nextLine()\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\twordScanner = NewScanner(strings.NewReader(line))\n\t\twordScanner.Split(ScanWords)\n\t}\n\treturn wordScanner.Text()\n}\n\nfunc nextInt() int {\n\tres, err := strconv.Atoi(nextWord())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc nextInt64() int64 {\n\tres, err := strconv.ParseInt(nextWord(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc nextFloat64() float64 {\n\tres, err := strconv.ParseFloat(nextWord(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\n// Scanner provides a convenient interface for reading data such as\n// a file of newline-delimited lines of text. Successive calls to\n// the Scan method will step through the 'tokens' of a file, skipping\n// the bytes between the tokens. The specification of a token is\n// defined by a split function of type SplitFunc; the default split\n// function breaks the input into lines with line termination stripped. Split\n// functions are defined in this package for scanning a file into\n// lines, bytes, UTF-8-encoded runes, and space-delimited words. The\n// client may instead provide a custom split function.\n//\n// Scanning stops unrecoverably at EOF, the first I/O error, or a token too\n// large to fit in the buffer. When a scan stops, the reader may have\n// advanced arbitrarily far past the last token. Programs that need more\n// control over error handling or large tokens, or must run sequential scans\n// on a reader, should use bufio.Reader instead.\n//\ntype Scanner struct {\n\tr io.Reader // The reader provided by the client.\n\tsplit SplitFunc // The function to split the tokens.\n\tmaxTokenSize int // Maximum size of a token; modified by tests.\n\ttoken []byte // Last token returned by split.\n\tbuf []byte // Buffer used as argument to split.\n\tstart int // First non-processed byte in buf.\n\tend int // End of data in buf.\n\terr error // Sticky error.\n\tempties int // Count of successive empty tokens.\n\tscanCalled bool // Scan has been called; buffer is in use.\n\tdone bool // Scan has finished.\n}\n\n// SplitFunc is the signature of the split function used to tokenize the\n// input. The arguments are an initial substring of the remaining unprocessed\n// data and a flag, atEOF, that reports whether the Reader has no more data\n// to give. The return values are the number of bytes to advance the input\n// and the next token to return to the user, plus an error, if any. If the\n// data does not yet hold a complete token, for instance if it has no newline\n// while scanning lines, SplitFunc can return (0, nil, nil) to signal the\n// Scanner to read more data into the slice and try again with a longer slice\n// starting at the same point in the input.\n//\n// If the returned error is non-nil, scanning stops and the error\n// is returned to the client.\n//\n// The function is never called with an empty data slice unless atEOF\n// is true. If atEOF is true, however, data may be non-empty and,\n// as always, holds unprocessed text.\ntype SplitFunc func(data []byte, atEOF bool) (advance int, token []byte, err error)\n\n// Errors returned by Scanner.\nvar (\n\tErrTooLong = errors.New(\"bufio.Scanner: token too long\")\n\tErrNegativeAdvance = errors.New(\"bufio.Scanner: SplitFunc returns negative advance count\")\n\tErrAdvanceTooFar = errors.New(\"bufio.Scanner: SplitFunc returns advance count beyond input\")\n)\n\nconst (\n// MaxScanTokenSize is the maximum size used to buffer a token\n// unless the user provides an explicit buffer with Scan.Buffer.\n// The actual maximum token size may be smaller as the buffer\n// may need to include, for instance, a newline.\n\tMaxScanTokenSize = 2 * 1024 * 2014\n\n\tstartBufSize = 4096 // Size of initial allocation for buffer.\n)\n\n// NewScanner returns a new Scanner to read from r.\n// The split function defaults to ScanLines.\nfunc NewScanner(r io.Reader) *Scanner {\n\treturn &Scanner{\n\t\tr: r,\n\t\tsplit: ScanLines,\n\t\tmaxTokenSize: MaxScanTokenSize,\n\t}\n}\n\n// Err returns the first non-EOF error that was encountered by the Scanner.\nfunc (s *Scanner) Err() error {\n\tif s.err == io.EOF {\n\t\treturn nil\n\t}\n\treturn s.err\n}\n\n// Bytes returns the most recent token generated by a call to Scan.\n// The underlying array may point to data that will be overwritten\n// by a subsequent call to Scan. It does no allocation.\nfunc (s *Scanner) Bytes() []byte {\n\treturn s.token\n}\n\n// Text returns the most recent token generated by a call to Scan\n// as a newly allocated string holding its bytes.\nfunc (s *Scanner) Text() string {\n\treturn string(s.token)\n}\n\n// ErrFinalToken is a special sentinel error value. It is intended to be\n// returned by a Split function to indicate that the token being delivered\n// with the error is the last token and scanning should stop after this one.\n// After ErrFinalToken is received by Scan, scanning stops with no error.\n// The value is useful to stop processing early or when it is necessary to\n// deliver a final empty token. One could achieve the same behavior\n// with a custom error value but providing one here is tidier.\n// See the emptyFinalToken example for a use of this value.\nvar ErrFinalToken = errors.New(\"final token\")\n\n// Scan advances the Scanner to the next token, which will then be\n// available through the Bytes or Text method. It returns false when the\n// scan stops, either by reaching the end of the input or an error.\n// After Scan returns false, the Err method will return any error that\n// occurred during scanning, except that if it was io.EOF, Err\n// will return nil.\n// Scan panics if the split function returns 100 empty tokens without\n// advancing the input. This is a common error mode for scanners.\nfunc (s *Scanner) Scan() bool {\n\tif s.done {\n\t\treturn false\n\t}\n\ts.scanCalled = true\n\t// Loop until we have a token.\n\tfor {\n\t\t// See if we can get a token with what we already have.\n\t\t// If we've run out of data but have an error, give the split function\n\t\t// a chance to recover any remaining, possibly empty token.\n\t\tif s.end > s.start || s.err != nil {\n\t\t\tadvance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)\n\t\t\tif err != nil {\n\t\t\t\tif err == ErrFinalToken {\n\t\t\t\t\ts.token = token\n\t\t\t\t\ts.done = true\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\ts.setErr(err)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !s.advance(advance) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ts.token = token\n\t\t\tif token != nil {\n\t\t\t\tif s.err == nil || advance > 0 {\n\t\t\t\t\ts.empties = 0\n\t\t\t\t} else {\n\t\t\t\t\t// Returning tokens not advancing input at EOF.\n\t\t\t\t\ts.empties++\n\t\t\t\t\tif s.empties > 100 {\n\t\t\t\t\t\tpanic(\"bufio.Scan: 100 empty tokens without progressing\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\t// We cannot generate a token with what we are holding.\n\t\t// If we've already hit EOF or an I/O error, we are done.\n\t\tif s.err != nil {\n\t\t\t// Shut it down.\n\t\t\ts.start = 0\n\t\t\ts.end = 0\n\t\t\treturn false\n\t\t}\n\t\t// Must read more data.\n\t\t// First, shift data to beginning of buffer if there's lots of empty space\n\t\t// or space is needed.\n\t\tif s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf) / 2) {\n\t\t\tcopy(s.buf, s.buf[s.start:s.end])\n\t\t\ts.end -= s.start\n\t\t\ts.start = 0\n\t\t}\n\t\t// Is the buffer full? If so, resize.\n\t\tif s.end == len(s.buf) {\n\t\t\t// Guarantee no overflow in the multiplication below.\n\t\t\tconst maxInt = int(^uint(0) >> 1)\n\t\t\tif len(s.buf) >= s.maxTokenSize || len(s.buf) > maxInt / 2 {\n\t\t\t\ts.setErr(ErrTooLong)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tnewSize := len(s.buf) * 2\n\t\t\tif newSize == 0 {\n\t\t\t\tnewSize = startBufSize\n\t\t\t}\n\t\t\tif newSize > s.maxTokenSize {\n\t\t\t\tnewSize = s.maxTokenSize\n\t\t\t}\n\t\t\tnewBuf := make([]byte, newSize)\n\t\t\tcopy(newBuf, s.buf[s.start:s.end])\n\t\t\ts.buf = newBuf\n\t\t\ts.end -= s.start\n\t\t\ts.start = 0\n\t\t\tcontinue\n\t\t}\n\t\t// Finally we can read some input. Make sure we don't get stuck with\n\t\t// a misbehaving Reader. Officially we don't need to do this, but let's\n\t\t// be extra careful: Scanner is for safe, simple jobs.\n\t\tfor loop := 0;; {\n\t\t\tn, err := s.r.Read(s.buf[s.end:len(s.buf)])\n\t\t\ts.end += n\n\t\t\tif err != nil {\n\t\t\t\ts.setErr(err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif n > 0 {\n\t\t\t\ts.empties = 0\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tloop++\n\t\t\tif loop > 10 {\n\t\t\t\ts.setErr(io.ErrNoProgress)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\n// advance consumes n bytes of the buffer. It reports whether the advance was legal.\nfunc (s *Scanner) advance(n int) bool {\n\tif n < 0 {\n\t\ts.setErr(ErrNegativeAdvance)\n\t\treturn false\n\t}\n\tif n > s.end - s.start {\n\t\ts.setErr(ErrAdvanceTooFar)\n\t\treturn false\n\t}\n\ts.start += n\n\treturn true\n}\n\n// setErr records the first error encountered.\nfunc (s *Scanner) setErr(err error) {\n\tif s.err == nil || s.err == io.EOF {\n\t\ts.err = err\n\t}\n}\n\n// Buffer sets the initial buffer to use when scanning and the maximum\n// size of buffer that may be allocated during scanning. The maximum\n// token size is the larger of max and cap(buf). If max <= cap(buf),\n// Scan will use this buffer only and do no allocation.\n//\n// By default, Scan uses an internal buffer and sets the\n// maximum token size to MaxScanTokenSize.\n//\n// Buffer panics if it is called after scanning has started.\nfunc (s *Scanner) Buffer(buf []byte, max int) {\n\tif s.scanCalled {\n\t\tpanic(\"Buffer called after Scan\")\n\t}\n\ts.buf = buf[0:cap(buf)]\n\ts.maxTokenSize = max\n}\n\n// Split sets the split function for the Scanner.\n// The default split function is ScanLines.\n//\n// Split panics if it is called after scanning has started.\nfunc (s *Scanner) Split(split SplitFunc) {\n\tif s.scanCalled {\n\t\tpanic(\"Split called after Scan\")\n\t}\n\ts.split = split\n}\n\n// Split functions\n\n// ScanBytes is a split function for a Scanner that returns each byte as a token.\nfunc ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\treturn 1, data[0:1], nil\n}\n\nvar errorRune = []byte(string(utf8.RuneError))\n\n// ScanRunes is a split function for a Scanner that returns each\n// UTF-8-encoded rune as a token. The sequence of runes returned is\n// equivalent to that from a range loop over the input as a string, which\n// means that erroneous UTF-8 encodings translate to U+FFFD = \"\\xef\\xbf\\xbd\".\n// Because of the Scan interface, this makes it impossible for the client to\n// distinguish correctly encoded replacement runes from encoding errors.\nfunc ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\n\t// Fast path 1: ASCII.\n\tif data[0] < utf8.RuneSelf {\n\t\treturn 1, data[0:1], nil\n\t}\n\n\t// Fast path 2: Correct UTF-8 decode without error.\n\t_, width := utf8.DecodeRune(data)\n\tif width > 1 {\n\t\t// It's a valid encoding. Width cannot be one for a correctly encoded\n\t\t// non-ASCII rune.\n\t\treturn width, data[0:width], nil\n\t}\n\n\t// We know it's an error: we have width==1 and implicitly r==utf8.RuneError.\n\t// Is the error because there wasn't a full rune to be decoded?\n\t// FullRune distinguishes correctly between erroneous and incomplete encodings.\n\tif !atEOF && !utf8.FullRune(data) {\n\t\t// Incomplete; get more bytes.\n\t\treturn 0, nil, nil\n\t}\n\n\t// We have a real UTF-8 encoding error. Return a properly encoded error rune\n\t// but advance only one byte. This matches the behavior of a range loop over\n\t// an incorrectly encoded string.\n\treturn 1, errorRune, nil\n}\n\n// dropCR drops a terminal \\r from the data.\nfunc dropCR(data []byte) []byte {\n\tif len(data) > 0 && data[len(data) - 1] == '\\r' {\n\t\treturn data[0 : len(data) - 1]\n\t}\n\treturn data\n}\n\n// ScanLines is a split function for a Scanner that returns each line of\n// text, stripped of any trailing end-of-line marker. The returned line may\n// be empty. The end-of-line marker is one optional carriage return followed\n// by one mandatory newline. In regular expression notation, it is `\\r?\\n`.\n// The last non-empty line of input will be returned even if it has no\n// newline.\nfunc ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\tif i := bytes.IndexByte(data, '\\n'); i >= 0 {\n\t\t// We have a full newline-terminated line.\n\t\treturn i + 1, dropCR(data[0:i]), nil\n\t}\n\t// If we're at EOF, we have a final, non-terminated line. Return it.\n\tif atEOF {\n\t\treturn len(data), dropCR(data), nil\n\t}\n\t// Request more data.\n\treturn 0, nil, nil\n}\n\n// isSpace reports whether the character is a Unicode white space character.\n// We avoid dependency on the unicode package, but check validity of the implementation\n// in the tests.\nfunc isSpace(r rune) bool {\n\tif r <= '\\u00FF' {\n\t\t// Obvious ASCII ones: \\t through \\r plus space. Plus two Latin-1 oddballs.\n\t\tswitch r {\n\t\tcase ' ', '\\t', '\\n', '\\v', '\\f', '\\r':\n\t\t\treturn true\n\t\tcase '\\u0085', '\\u00A0':\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\t// High-valued ones.\n\tif '\\u2000' <= r && r <= '\\u200a' {\n\t\treturn true\n\t}\n\tswitch r {\n\tcase '\\u1680', '\\u2028', '\\u2029', '\\u202f', '\\u205f', '\\u3000':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ScanWords is a split function for a Scanner that returns each\n// space-separated word of text, with surrounding spaces deleted. It will\n// never return an empty string. The definition of space is set by\n// unicode.IsSpace.\nfunc ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\t// Skip leading spaces.\n\tstart := 0\n\tfor width := 0; start < len(data); start += width {\n\t\tvar r rune\n\t\tr, width = utf8.DecodeRune(data[start:])\n\t\tif !isSpace(r) {\n\t\t\tbreak\n\t\t}\n\t}\n\t// Scan until space, marking end of word.\n\tfor width, i := 0, start; i < len(data); i += width {\n\t\tvar r rune\n\t\tr, width = utf8.DecodeRune(data[i:])\n\t\tif isSpace(r) {\n\t\t\treturn i + width, data[start:i], nil\n\t\t}\n\t}\n\t// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.\n\tif atEOF && len(data) > start {\n\t\treturn len(data), data[start:], nil\n\t}\n\t// Request more data.\n\treturn start, nil, nil\n}\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms"], "code_uid": "98f17ebeb532f8f9ab01cecf73d0d924", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tinput := bufio.NewReader(os.Stdin)\n\tvar n, l, r int\n\n\t_, err := fmt.Fscan(input, &n, &l, &r)\n\tif err != nil {\n\t}\n\n\tvar arrMin = make([]int, n)\n\tvar arrMax = make([]int, n)\n\tvar min, max int\n\tarrMin[0] = 1\n\tarrMax[0] = 1\n\tmin += arrMin[0]\n\tmax += arrMax[0]\n\tif n == 1 {\n\t\tfmt.Println(1, 1)\n\t\treturn\n\t}\n\tfor i := 1; i < n; i++ {\n\t\tif (i + 1) <= l {\n\t\t\tarrMin[i] = 2 * arrMin[i-1]\n\t\t} else {\n\t\t\tarrMin[i] = 1\n\t\t}\n\t\tmin += arrMin[i]\n\t\tif (i + 1) <= r {\n\t\t\tarrMax[i] = 2 * arrMax[i-1]\n\t\t} else {\n\t\t\tarrMax[i] = arrMax[i-1]\n\t\t}\n\t\tmax += arrMax[i]\n\t}\n\tfmt.Println(min, max)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "83bb2e7a8a42eaca6ec70122ea196cb0", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, l, r int\n\tfmt.Scan(&n)\n\tfmt.Scan(&l)\n\tfmt.Scan(&r)\n\tfmt.Print(int(math.Pow(2, float64(l))-1)+(n-l), \" \", int(math.Pow(2, float64(r))-1)+(n-r)*int(math.Pow(2, float64(r-1))))\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "9c44c1d0f0c98a90c0284f0c8cdc34da", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn, l, r := int64(0), int64(0), int64(0)\n\tfmt.Fscanf(in, \"%d %d %d\\n\", &n, &l, &r)\n\tmin := int64(0)\n\ta := make([]int64, n)\n\ta[0] = 1\n\t// min\n\tcur := int64(1)\n\tfor i := int64(0); i < l; i++ {\n\t\tmin += cur\n\t\tcur *= 2\n\t\t//fmt.Println(min)\n\t}\n\tmin = min + (n - l) //all ones\n\t// max\n\tmax := int64(0)\n\tcur = int64(1)\n\tfor i := int64(0); i < r; i++ {\n\t\tmax += cur\n\t\tcur *= 2\n\t\t//fmt.Println(max)\n\t}\n\tcur /= 2\n\tfor i := r; i < n; i++ {\n\t\tmax += cur\n\t}\n\tfmt.Fprintf(out, \"%d %d\\n\", min, max)\n\treturn\n}\nfunc minstep(a, b byte) int {\n\treturn min(int(a-b+26)%26, int(b-a+26)%26)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "403356e9aafdcf528759416a94e54ba8", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 133B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\ta := 0\n\tfmt.Scan(&s)\n\tfor i := 0; i < len(s); i++ {\n\t\ta *= 16\n\t\tif s[i] == '>' {\n\t\t\ta += 8\n\t\t}\n\t\tif s[i] == '<' {\n\t\t\ta += 9\n\t\t}\n\t\tif s[i] == '+' {\n\t\t\ta += 10\n\t\t}\n\t\tif s[i] == '-' {\n\t\t\ta += 11\n\t\t}\n\t\tif s[i] == '.' {\n\t\t\ta += 12\n\t\t}\n\t\tif s[i] == ',' {\n\t\t\ta += 13\n\t\t}\n\t\tif s[i] == '[' {\n\t\t\ta += 14\n\t\t}\n\t\tif s[i] == ']' {\n\t\t\ta += 15\n\t\t}\n\t\ta %= 1000003\n\t}\n\tfmt.Println(a)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "20d7b26bb96a06bd6d30d0311c784bfa", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n m := make(map[rune]int)\n m['>'], m['<'], m['+'], m['-'], m['.'], m[','], m['['], m[']'] = 8, 9, 10, 11, 12, 13, 14, 15\n var p string\n fmt.Scan(&p)\n ans := 0\n for _, v := range p {\n ans = (ans*16)%1000003\n ans = (ans+m[v])%1000003\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2b3ff7253353a2290812b2a67abb7f9a", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n value := map[byte]int{ '>': 8, '<': 9, '+': 10, '-': 11,\n '.': 12, ',': 13, '[': 14, ']': 15 }\n mod := 1000*1000+3\n p := getS()\n total := 0\n for i := 0; i < len(p); i++ {\n v := value[p[i]]\n total = (16*total + v) % mod\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", total))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d9ca242e96a8db6963b2ec6a5ae5348a", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n // \"strings\"\n)\n\nvar n int \nvar str string\nfunc main() {\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfmt.Scanf(\"%s\", &str)\t\n\tstrr := []rune(str)\n\tpos := 0\n\tfor pos < len(strr)-1 {\n\t if (strr[pos] == 85 && strr[pos+1] == 82) || (strr[pos] == 82 && strr[pos+1] == 85){\n \t strr[pos]=68\n\t if pos+2 > len(strr){\n\t strr = strr[:pos+1]\n\t } else {\n\t strr = append(strr[:pos+1], strr[pos+2:]...)\n\t }\n\t }\n\t pos += 1\n\t}\n\tfmt.Println(len(strr))\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "075c7491464285a63f511c3f47a2c7ff", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n\nfunc main() {\n\tdefer Flush()\n\n\tn := readi()\n\ts := readb()\n\n\tvar t []byte\n\tt = append(t, s[0])\n\tfor i := 1; i < n; i++ {\n\t\tj := len(t) - 1\n\t\tif t[j] != 'D' && s[i] != t[j] {\n\t\t\tt[j] = 'D'\n\t\t} else {\n\t\t\tt = append(t, s[i])\n\t\t}\n\t}\n\tprintln(len(t))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "7acd9513c97443a9ed235844b8e7056e", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\tS := io.NextString()\n\t\n\tans := 0\n\tidx := 0\n\tfor idx < N {\n\t if idx + 1 < N && S[idx] != S[idx + 1] {\n\t idx += 2\n\t } else {\n\t idx++\n\t }\n\t ans++\n\t}\n\tio.Println(ans)\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "56adc234cdbae6dcba19967383ef3f58", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n, m, r, s int64\n\tvar err error\n\treader := bufio.NewReaderSize(os.Stdin, 1024*1024)\n\n\tst := strings.Split(readLine(reader), \" \")\n\n\tn, err = strconv.ParseInt(st[0], 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tm, err = strconv.ParseInt(st[1], 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tr, err = strconv.ParseInt(st[2], 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar nr, mr []int64\n\n\tarTemp := strings.Split(readLine(reader), \" \")\n\n\tfor arItr := int64(0); arItr < n; arItr++ {\n\t\ttemp, err := strconv.ParseInt(arTemp[arItr], 10, 64)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tnr = append(nr, temp)\n\t}\n\tarTemp = strings.Split(readLine(reader), \" \")\n\n\tfor arItr := int64(0); arItr < m; arItr++ {\n\t\ttemp, err := strconv.ParseInt(arTemp[arItr], 10, 64)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tmr = append(mr, temp)\n\t}\n\n\tsort.Slice(nr, func(i, j int) bool { return nr[j] > nr[i] })\n\tsort.Slice(mr, func(i, j int) bool { return mr[j] > mr[i] })\n\n\tif nr[0] >= mr[len(mr)-1] || r < nr[0] {\n\t\tfmt.Print(r)\n\t\treturn\n\t}\n\n\tfor _, v := range nr {\n\t\tif r >= v {\n\t\t\ts += r / v\n\t\t\tt := r / v\n\t\t\tr -= t * v\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\tr += mr[len(mr)-1] * s\n\tfmt.Print(r)\n\treturn\n}\n\nfunc readLine(reader *bufio.Reader) string {\n\tstr, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\n\treturn strings.TrimRight(string(str), \"\\r\\n\")\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "0d631dd1657c160db0c6004b55ce346f", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a,b int) int {\n\tif(a < b){\n\t\treturn a\n\t\t}\n\treturn b\n}\nfunc katta(a,b int) int {\n\tif(a < b){\n\t\treturn b\n\t}\n\treturn a\n}\nfunc ab(x int) int {\n\tif(x <= -1){\n\t\tx *= -1\n\t}\n\treturn x\n}\n//a b c d e f g h j k l m n o p q r s t u v w x y z\nfunc calc(s string) (res int) {\n\n\tres += min(ab(int(s[0]) - int('A')) ,ab(int('Z') - int(s[0])) + 1)\n\tres += min(ab(int(s[1]) - int('C')),ab(int('Z') - int(s[1])) + 3)\n\tres += min(ab(int(s[2])- int('T')),min(ab(int('Z') - int(s[2])) + 20,ab(int('A') - int(s[2]))+7))\n\tres += min(ab(int(s[3])- int('G')),ab(int('Z') - int(s[3])) + 7)\n\treturn\n}\n\nfunc main() {\n\tvar n , m ,r int\n\tfmt.Scanf(\"%d %d %d\",&n,&m,&r)\n\tmaxe := 0\n\tmine := 1001\n\tvar x int\n\tfor i := 0 ; i < n;i++{\n\t\tfmt.Scan(&x)\n\t\tif(x < mine){\n\t\t\tmine = x\n\t\t}\n\t}\n\tfor i := 0 ; i< m ;i ++{\n\t\tfmt.Scan(&x)\n\t\tif(x > maxe){\n\t\t\tmaxe = x\n\t\t}\n\t}\n\tfmt.Println(katta(((r/mine) * maxe) + r % mine,r))\n\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "ad8e4627546a86442b7a778d3710c32c", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1150/problem/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc min(a []int) int {\n\tminElem := a[0]\n\tfor i := 1; i < len(a); i++ {\n\t\tif a[i] < minElem {\n\t\t\tminElem = a[i]\n\t\t}\n\t}\n\treturn minElem\n}\n\nfunc max(a []int) int {\n\tmaxElem := a[0]\n\tfor i := 1; i < len(a); i++ {\n\t\tif a[i] > maxElem {\n\t\t\tmaxElem = a[i]\n\t\t}\n\t}\n\treturn maxElem\n}\n\nfunc Solve(n int, m int, r int, s []int, b[]int) int {\n\tminBuyPrice := min(s)\n\tmaxSellPrice := max(b)\n\tif maxSellPrice > minBuyPrice {\n\t\tshares := r / minBuyPrice\n\t\tremainder := r % minBuyPrice\n\t\treturn shares * maxSellPrice + remainder\n\t}\n\treturn r\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n, m, r int\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &n, &m, &r)\n\ts := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(reader, &s[i])\n\t}\n\tb := make([]int, m)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Fscan(reader, &b[i])\n\t}\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, m, r, s, b))\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "7cd790be1d1f7dfcc53f3023591dca2e", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// B. Internet Address\n/*\nVasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:\n\t\t\t://.ru[/]\n\nwhere:\n\n can equal either \"http\" (without the quotes) or \"ftp\" (without the quotes),\n is a non-empty string, consisting of lowercase English letters,\n\t \tthe / part may not be present. If it is present, then is a non-empty string, consisting of lowercase English letters.\n\nIf string isn't present in the address, then the additional character \"/\" isn't written. Thus, the address has either two characters \"/\" (the ones that go before the domain), or three (an extra one in front of the context).\n\nWhen the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters \":\", \"/\", \".\".\n\nHelp Vasya to restore the possible address of the recorded Internet resource.\n\nInput\nThe first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only.\n\nIt is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above.\n\nOutput\nPrint a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them.\n\nExamples\nInput\nhttpsunrux\n\nOutput\nhttp://sun.ru/x\n\nInput\nftphttprururu\n\nOutput\nftp://http.ru/ruru\n\nNote\nIn the second sample there are two more possible answers: \"ftp://httpruru.ru\" and \"ftp://httpru.ru/ru\".\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ts, _ := reader.ReadString('\\n')\n\ts = strings.TrimSpace(s)\n\n\tpIndex := 3\n\turl := \"ftp://\"\n\tif s[0] == 'h' {\n\t\tpIndex = 4\n\t\turl = \"http://\"\n\t}\n\n\tcIndex := len(s)\n\tfor i := pIndex + 1; i < len(s)-1; i++ {\n\t\tif s[i] == 'r' && s[i+1] == 'u' {\n\t\t\tcIndex = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif cIndex < len(s)-2 {\n\t\tfmt.Printf(\"%v%v.ru/%v\", url, s[pIndex:cIndex], s[cIndex+2:])\n\t} else {\n\n\t\tfmt.Printf(\"%v%v.ru\", url, s[pIndex:cIndex])\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "247df909618a6731a943162c93faa0ba", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// B. Internet Address\n/*\nVasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:\n\t\t\t://.ru[/]\n\nwhere:\n\n can equal either \"http\" (without the quotes) or \"ftp\" (without the quotes),\n is a non-empty string, consisting of lowercase English letters,\n\t \tthe / part may not be present. If it is present, then is a non-empty string, consisting of lowercase English letters.\n\nIf string isn't present in the address, then the additional character \"/\" isn't written. Thus, the address has either two characters \"/\" (the ones that go before the domain), or three (an extra one in front of the context).\n\nWhen the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters \":\", \"/\", \".\".\n\nHelp Vasya to restore the possible address of the recorded Internet resource.\n\nInput\nThe first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only.\n\nIt is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above.\n\nOutput\nPrint a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them.\n\nExamples\nInput\nhttpsunrux\n\nOutput\nhttp://sun.ru/x\n\nInput\nftphttprururu\n\nOutput\nftp://http.ru/ruru\n\nNote\nIn the second sample there are two more possible answers: \"ftp://httpruru.ru\" and \"ftp://httpru.ru/ru\".\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ts, _ := reader.ReadString('\\n')\n\tarr := strings.Split(strings.TrimSpace(s), \"\")\n\n\tpIndex := 3\n\turl := \"ftp://\"\n\tif arr[0] == \"h\" {\n\t\tpIndex = 4\n\t\turl = \"http://\"\n\t}\n\n\tcIndex := len(arr)\n\tfor i := pIndex + 1; i < len(arr)-1; i++ {\n\t\tif arr[i] == \"r\" && arr[i+1] == \"u\" {\n\t\t\tcIndex = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif cIndex < len(arr)-2 {\n\t\tfmt.Printf(\"%v%v.ru/%v\", url, strings.Join(arr[pIndex:cIndex], \"\"), strings.Join(arr[cIndex+2:], \"\"))\n\t} else {\n\n\t\tfmt.Printf(\"%v%v.ru\", url, strings.Join(arr[pIndex:cIndex], \"\"))\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "467ad260a3b2ddb9f2d77462a6478c8e", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n in := 0\n for {\n fmt.Print(string(s[in]))\n in++\n if (s[in-1] == 'p') { break }\n }\n fmt.Print(\"://\")\n for {\n fmt.Print(string(s[in]))\n in++\n if (s[in] == 'r') && (s[in+1] == 'u') {\n fmt.Print(\".ru\")\n in += 2\n break\n }\n }\n if in < len(s) { fmt.Print(\"/\") }\n for ; in < len(s); in++ {\n fmt.Print(string(s[in]))\n }\n fmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "482b26a64149507221845abfeeef8d3c", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"bufio\"\n\t//\"os\"\n\t//\"strconv\"\n)\nvar a [20]int\nfunc check(x int) int{\n\tfor i:=1;x>0;i++ {\n\t\tif a[x%10]!=0 {\n\t\t\treturn 1\n\t\t}\n\t\tx/=10\n\t}\n\treturn 0\n}\nfunc main() {\n\tvar n, ans int\n\tfmt.Scan(&n)\n\tfor i:=n;i>0;i/=10 {\n\t\ta[i%10]=1\n\t}\n\tfor i:=1; i*i<=n;i++ {\n\t\tif n%i==0 {\n\t\t\tans += check(i)\n\t\t\tif i*i!=n {\n\t\t\t\tans+=check(n/i)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d6829770d0bcbb7e9be710f25fb6e2ae", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc get_digits(n int) []bool {\n\toutput := make([]bool, 10)\n\tfor n > 0 {\n\t\toutput[n%10] = true\n\t\tn = n/10\n\t}\n\treturn output\n}\n\nfunc compatible(digits []bool, n int) bool {\n\tfor n > 0 {\n\t\tif digits[n%10] {\n\t\t\treturn true\n\t\t}\n\t\tn = n/10\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar input int\n\tfmt.Scan(&input)\n\tdigits := get_digits(input)\n\tans := 0\n\tfor i:=1; i*i<=input; i++ {\n\t\tif input%i == 0 {\n\t\t\tif compatible(digits, i) {ans++}\n\t\t\tif i*i != input && compatible(digits, input/i) {ans++}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "dfb9e8bd0d1d98d57143797548808218", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var x int\n var d [10]bool\n\n check := func(a int) bool {\n for ; a != 0; a /= 10 {\n if d[a%10] { return true }\n }\n return false\n }\n\n fmt.Scan(&x)\n for a := x; a != 0; a /= 10 {\n d[a%10] = true\n }\n ans := 0\n for i := 1; i*i <= x; i++ {\n if (x%i) == 0 {\n if check(i) { ans++ }\n if (i != x/i) && check(x/i) { ans++ }\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cf5d46eaecad07a2c228f3282436d56f", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc isValid(nums []int, start, end int) bool {\n\treturn (start-end)%2 == 0 && nums[start]%2 == 1 && nums[end]%2 == 1\n}\n\nfunc main() {\n\tvar t int\n\tfmt.Scanf(\"%d\\n\", &t)\n\n\tnums := make([]int, t)\n\tfor i := 0; i < t; i++ {\n\t\tfmt.Scanf(\"%d\", &nums[i])\n\t}\n\n\tif isValid(nums, 0, len(nums)-1) {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "89c4e46ad42e81a59348258fedc4812c", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\tA := sc.NextIntArray()\n\tif N%2 == 0 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tif A[0]%2 == 1 && A[N-1]%2 == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cca0f62d6f7db21e6eba4cf6fc5b7c87", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nconst (\n\tSCANNER_BUF_SIZE = 2 << 20\n\n\tINF = int64(math.MaxInt64)\n\tMOD = 1e9 + 7\n)\n\nvar (\n\twriter *bufio.Writer\n\tscanner *bufio.Scanner\n)\n\nfunc init() {\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)\n}\n\nfunc printf(f string, a ...interface{}) {\n\tfmt.Fprintf(writer, f, a...)\n}\n\nfunc sint64() int64 {\n\tscanner.Scan()\n\tbb := scanner.Bytes()\n\ti := int64(0)\n\tif bb[0] == '-' {\n\t\tfor _, b := range bb[1:] {\n\t\t\ti *= 10\n\t\t\ti -= int64(b - '0')\n\t\t}\n\t\treturn i\n\t}\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += int64(b - '0')\n\t}\n\treturn i\n}\n\nfunc suint64() uint64 {\n\tscanner.Scan()\n\tbb := scanner.Bytes()\n\ti := uint64(0)\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += uint64(b - '0')\n\t}\n\treturn i\n}\n\nfunc sstring() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc gcd(a, b int64) int64 {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int64) int64 {\n\treturn a * b / gcd(a, b)\n}\n\nfunc abs(a int64) int64 {\n\tif a < 0 {\n\t\treturn a * -1\n\t}\n\treturn a\n}\n\nfunc min(a int64, rest ...int64) int64 {\n\tfor _, r := range rest {\n\t\tif r < a {\n\t\t\ta = r\n\t\t}\n\t}\n\treturn a\n}\n\nfunc max(a int64, rest ...int64) int64 {\n\tfor _, r := range rest {\n\t\tif r > a {\n\t\t\ta = r\n\t\t}\n\t}\n\treturn a\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tn := sint64()\n\ta := make([]int64, n)\n\tfor i := range a {\n\t\ta[i] = sint64()\n\t}\n\tprintf(\"%s\\n\", sol(a))\n}\n\nfunc sol(a []int64) string {\n\tif len(a) & 1 == 1 && a[0] & 1 == 1 && a[len(a)-1] & 1 == 1 {\n\t\treturn \"Yes\"\n\t}\n\treturn \"No\"\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "06b44dfa551a249b6764a3c43e9a5771", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tdefer out.Flush()\n\n\tn := ScanInt()\n\ta := ScanInts(n)\n\tP(solv(n, a))\n\n}\n\nfunc solv(n int, a []int) int {\n\tdp := make([][]int, n+1)\n\tfor i := 0; i <= n; i++ {\n\t\tdp[i] = make([]int, 4)\n\t}\n\t// j\n\t// 0 = rest\n\t// 1 = write\n\t// 2= gym\n\n\t// a[i]\n\t// 0 >> no gym && no write\n\t// 1 >> no gym && write\n\t// 2 >> gym && no write\n\t// 3 >> gym && \t write\n\tfor i := 1; i <= n; i++ {\n\t\tdp[i][0] = Mx(dp[i-1][0], dp[i-1][1], dp[i-1][2])\n\n\t\tif a[i-1] == 1 || a[i-1] == 3 {\n\t\t\tdp[i][1] = Mx(dp[i-1][2], dp[i-1][0]) + 1\n\t\t}\n\t\tif a[i-1] == 2 || a[i-1] == 3 {\n\t\t\tdp[i][2] = Mx(dp[i-1][0], dp[i-1][1]) + 1\n\t\t}\n\t}\n\n\treturn n - Mx(dp[n][0], dp[n][1], dp[n][2])\n}\n\n/*********************** I/O ***********************/\nvar in *bufio.Scanner\nvar out *bufio.Writer\n\nfunc init() {\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(1e+9))\n\tin.Split(bufio.ScanWords)\n\tout = bufio.NewWriter(os.Stdout)\n}\n\nfunc P(args ...interface{}) {\n\tprint(\"\\n\", args...)\n}\n\nfunc PS(args ...interface{}) {\n\tprint(\" \", args...)\n\tprint(\"\\n\", nil)\n}\n\nfunc print(seperator string, args ...interface{}) {\n\tfor _, arg := range args {\n\t\tstr := \"\"\n\t\tswitch v := arg.(type) {\n\t\tcase byte:\n\t\t\tstr = string(v)\n\t\tcase rune:\n\t\t\tstr = string(v)\n\t\tcase int:\n\t\t\tstr = strconv.Itoa(v)\n\t\tcase []int:\n\t\t\tsb := strings.Builder{}\n\t\t\tfor i := 0; i < len(v); i++ {\n\t\t\t\tsb.WriteString(strconv.Itoa(v[i]) + \" \")\n\t\t\t}\n\t\t\tstr = sb.String()\n\t\tcase int64:\n\t\t\tstr = strconv.FormatInt(v, 10)\n\t\tcase []int64:\n\t\t\tsb := strings.Builder{}\n\t\t\tfor i := 0; i < len(v); i++ {\n\t\t\t\tsb.WriteString(strconv.FormatInt(v[i], 10) + \" \")\n\t\t\t}\n\t\t\tstr = sb.String()\n\t\tcase string:\n\t\t\tstr = v\n\t\tdefault:\n\t\t\tpanic(\"invalid print arg: \" + fmt.Sprintf(\"%v\", arg))\n\n\t\t}\n\t\tout.WriteString(str + seperator)\n\t}\n}\n\nfunc ScanWord() string { in.Scan(); return in.Text() }\nfunc ScanWords(n int) []string {\n\ts := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\ts[i] = ScanWord()\n\t}\n\treturn s\n}\nfunc ScanInt() int { i, _ := strconv.Atoi(ScanWord()); return i }\nfunc ScanInts(n int) []int {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = ScanInt()\n\t}\n\treturn a\n}\n\nfunc MnMx(args ...int) (int, int) {\n\tminVal, maxVal := math.MaxInt32, math.MinInt32\n\tfor _, v := range args {\n\t\tif v < minVal {\n\t\t\tminVal = v\n\t\t}\n\t\tif v > maxVal {\n\t\t\tmaxVal = v\n\t\t}\n\t}\n\treturn minVal, maxVal\n}\nfunc Mn(args ...int) int { mn, _ := MnMx(args...); return mn }\nfunc Mx(args ...int) int { _, mx := MnMx(args...); return mx }\nfunc LCM(a, b int) int { return a / GCD(a, b) * b }\nfunc GCD(a, b int) int {\n\tif a == 0 {\n\t\treturn b\n\t}\n\treturn GCD(b%a, a)\n}\nfunc Abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp"], "code_uid": "36ba0a5095efe761e81ea24a9cf15304", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"unicode\"\n)\n\nvar stdReader *bufio.Reader = bufio.NewReader(os.Stdin)\n\nfunc readInt() (result int) {\n\tvar negative, started bool\nREADER_LOOP:\n\tfor {\n\t\tchar, err := stdReader.ReadByte()\n\t\tswitch {\n\t\tcase err != nil:\n\t\t\tbreak READER_LOOP\n\t\tcase char == '-':\n\t\t\tnegative = true\n\t\tcase unicode.IsDigit(rune(char)):\n\t\t\tstarted = true\n\t\t\tresult = result*10 + int(char&0xf)\n\t\tcase started:\n\t\t\tbreak READER_LOOP\n\t\t}\n\t}\n\tif negative {\n\t\tresult = -result\n\t}\n\treturn\n}\n\nfunc main() {\n\tn := readInt()\n\n\t// dp[][0] - Vasya rested\n\t// dp[][1] - Vasya wrote contest\n\t// dp[][2] - Vasya practiced in a gym\n\tdp := make([][3]int, n+1)\n\tfor i := 1; i <= n; i++ {\n\t\t// dp[i][0]\n\t\tdp[i][0] = dp[i-1][0]\n\t\tif dp[i-1][1] > dp[i][0] {\n\t\t\tdp[i][0] = dp[i-1][1]\n\t\t}\n\t\tif dp[i-1][2] > dp[i][0] {\n\t\t\tdp[i][0] = dp[i-1][2]\n\t\t}\n\n\t\tinput := readInt()\n\t\t// dp[i][1]\n\t\tif input == 1 || input == 3 {\n\t\t\tdp[i][1] = dp[i-1][0] + 1\n\t\t\tif dp[i-1][2]+1 > dp[i][1] {\n\t\t\t\tdp[i][1] = dp[i-1][2] + 1\n\t\t\t}\n\t\t}\n\n\t\t// dp[i][2]\n\t\tif input == 2 || input == 3 {\n\t\t\tdp[i][2] = dp[i-1][0] + 1\n\t\t\tif dp[i-1][1]+1 > dp[i][2] {\n\t\t\t\tdp[i][2] = dp[i-1][1] + 1\n\t\t\t}\n\t\t}\n\t}\n\n\tanswer := dp[n][0]\n\tif dp[n][1] > answer {\n\t\tanswer = dp[n][1]\n\t}\n\tif dp[n][2] > answer {\n\t\tanswer = dp[n][2]\n\t}\n\tfmt.Println(n - answer)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp"], "code_uid": "d790a6f58124388e5a481aaab3bf6fdc", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"math\"\n\t\"sort\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn, m := nextInt(), nextInt()\n\n\ta := make([]int, n)\n\tpermutations := make([][]int, 0, 10)\n\tmaxP := 0\n\tminP := 0\n\n\tif n == 1 {\n\t\tprintln(1)\n\t\treturn\n\t}\n\n\tfor i := range a {\n\t\ta[i] = i+1\n\t}\n\n\tfor i := n-1; i > 0; {\n\t\tminP = sumMin(a)\n\t\tif maxP < minP {\n\t\t\tmaxP = minP\n\t\t\tpermutations = make([][]int, 0, 10)\n\t\t} \n\n\t\tif maxP <= minP {\n\t\t\tb := make([]int, n)\n\t\t\tcopy(b, a)\n\t\t\tpermutations = append(permutations, b)\n\t\t}\n\t\t// println(a, minP, maxP, permutations)\n\n\t\ti = n-1\n\n\t\tfor ; i > 0; i-- {\n\t\t\tif a[i] > a[i-1] {\n\t\t\t\tsort.Ints(a[i:])\n\n\t\t\t\tfor j := i; j < n; j++ {\n\t\t\t\t\tif a[i-1] < a[j] {\n\t\t\t\t\t\ta[i-1], a[j] = a[j], a[i-1]\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// println(a, permutations)\n\tfor i := range a {\n\t\tprintf(\"%d \", permutations[m-1][i])\n\t}\n\n\tprintln()\n}\n\nfunc sumMin(a []int) int {\n\tsum := 0\n\n\tfor i := range a {\n\t\tfor j := i; j < len(a); j++ {\n\t\t\tsum += min(a[i:j+1]...)\n\t\t}\n\t}\n\n\treturn sum\n}\n\nfunc min(a ...int) int {\n\tmin := math.MaxInt32\n\n\tif a != nil {\n\t\tfor i := range a {\n\t\t\tif min > a[i] {\n\t\t\t\tmin = a[i]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn min\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "467da3cb63416c4846131c20c428b5b6", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"strconv\"\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n// var file, _ = os.Open(\"input.txt\")\n// var outfile, _ = os.Create(\"output.txt\")\n// var in = bufio.NewScanner(file)\n// var out = bufio.NewWriter(outfile)\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc next() string {\n if !in.Scan() {\n panic(\"Scan error\")\n }\n return in.Text()\n}\n\nfunc nextInt() int {\n ret, _ := strconv.Atoi(next())\n return ret\n}\n\nfunc nextInt64() int64 {\n ret, _ := strconv.ParseInt(next(), 10, 64)\n return ret\n}\n\nfunc nextFloat() float64 {\n ret, _ := strconv.ParseFloat(next(), 64)\n return ret\n}\n\nfunc swap(a []int, i int, j int) {\n a[i], a[j] = a[j], a[i]\n}\n\nfunc reverse(a []int, i int, j int) {\n for i < j {\n swap(a, i, j)\n i++\n j--\n }\n}\n\nfunc nextPermutation(a []int) bool {\n k := len(a) - 2\n for k > -1 && a[k] > a[k + 1] { k-- }\n if k == -1 { return false }\n l := len(a) - 1\n for k < l && a[k] > a[l] { l-- }\n swap(a, k, l)\n reverse(a, k + 1, len(a) - 1)\n return true\n}\n\nfunc f(a []int) int {\n n := len(a)\n sum := 0\n for i := 0; i < n; i++ {\n for j := i; j < n; j++ {\n min := -1;\n for k := i; k <= j; k++ {\n if min == -1 || min > a[k] {\n min = a[k]\n }\n }\n sum += min\n }\n }\n return sum\n}\n\nfunc main() {\n defer out.Flush()\n in.Split(bufio.ScanWords)\n n := nextInt()\n m := nextInt()\n a := make([]int, n)\n for i := 0; i < n; i++ {\n a[i] = i + 1\n }\n ms := f(a)\n for nextPermutation(a) {\n sum := f(a)\n if ms < sum { ms = sum }\n }\n for i := 0; i < n; i++ {\n a[i] = i + 1\n }\n if ms == f(a) {\n m--\n }\n if m == 0 {\n for i := 0; i < n; i++ {\n fmt.Fprint(out, strconv.Itoa(a[i]) + \" \")\n }\n fmt.Fprintln(out)\n return\n }\n for nextPermutation(a) {\n sum := f(a)\n if ms == sum {\n m--\n if m == 0 {\n for i := 0; i < n; i++ {\n fmt.Fprint(out, strconv.Itoa(a[i]) + \" \")\n }\n fmt.Fprintln(out)\n return\n }\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "955253731180db28959358a30f6026e9", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\nvar writer *bufio.Writer\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer = bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n a, b := getI(), getI()\n t, d := getI(), getI()\n result := a + b\n x := a\n for i := 2; i < t; i++ {\n x += d\n result += x\n }\n excess := x-b-d\n for excess > 0 {\n result -= excess\n if excess < 2*d {\n excess = 0\n } else {\n excess -= 2*d\n }\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "5a9bf3eef954b0c2a7469888679c18e5", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst (\n\tMAX_T = 110\n)\n\nvar v1, v2 int\nvar T, D int\nvar dp [MAX_T][MAX_T * 10]int\nvar visited [MAX_T][MAX_T * 10]bool\n\nfunc init() {\n\tfor i := 0; i < MAX_T; i++ {\n\t\tfor j := 0; j < len(dp[i]); j++ {\n\t\t\tdp[i][j] = -1\n\t\t}\n\t}\n}\n\nfunc memo(t, v int) int {\n\tif t == T {\n\t\tif v == v2 {\n\t\t\treturn 0\n\t\t}\n\t\treturn -1145141919\n\t}\n\tif visited[t][v] {\n\t\treturn dp[t][v]\n\t}\n\tvisited[t][v] = true\n\tres := -1145141919\n\tres = IntMax(res, memo(t+1, v)+v)\n\tfor i := 1; i <= D; i++ {\n\t\tres = IntMax(res, memo(t+1, v+i)+v+i)\n\t\tif v-i >= 0 {\n\t\t\tres = IntMax(res, memo(t+1, v-i)+v-i)\n\t\t}\n\t}\n\tdp[t][v] = res\n\treturn res\n}\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tv1, v2 = fsc.NextInt(), fsc.NextInt()\n\tT, D = fsc.NextInt(), fsc.NextInt()\n\tfmt.Println(memo(1, v1) + v1)\n}\n\n//template\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1024)\n\treturn &FastScanner{r: rdr}\n}\nfunc (s *FastScanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *FastScanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *FastScanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *FastScanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *FastScanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n\n//Max,Min\nfunc IntMax(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Int64Max(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc Float64Max(a, b float64) float64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc IntMin(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Int64Min(a, b int64) int64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc Float64Min(a, b float64) float64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\n//Gcd\nfunc IntGcd(a, b int) int {\n\tif a < b {\n\t\tb, a = a, b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn IntGcd(b, a%b)\n}\nfunc Int64Gcd(a, b int64) int64 {\n\tif a < b {\n\t\tb, a = a, b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn Int64Gcd(b, a%b)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "5b3878793720695b0d3de4a4ac833f6a", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc int_abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc int_max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc int_min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc main() {\n\tvar v1, v2, t, d int\n\tfmt.Scan(&v1)\n\tfmt.Scan(&v2)\n\tfmt.Scan(&t)\n\tfmt.Scan(&d)\n\tans := 0\n\tspeed := v1\n\tfor i := 0; i < t; i++ {\n\t\tans += speed\n\t\tspeed = int_min(speed+d, v2+d*(t-2-i))\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "8f96fb9a06521f6c6651956ff047296d", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\ntype graph struct {\n\tsize int\n\tedges [][]bool\n\tdegree []int\n\tcolor []int\n}\n\nfunc (g *graph) add(from, to int) {\n\tg.edges[from][to] = true\n\tg.degree[from]++\n}\n\nfunc (g *graph) addBoth(from, to int) {\n\tg.add(from, to)\n\tif from != to {\n\t\tg.add(to, from)\n\t}\n}\n\nfunc (g *graph) _isBipartite(v int) bool {\n\tfor w, e := range g.edges[v] {\n\t\tif e || w == v {\n\t\t\tcontinue\n\t\t}\n\t\tif g.color[w] == g.color[v] {\n\t\t\treturn false\n\t\t}\n\t\tif g.color[w] == 0 {\n\t\t\tg.color[w] = 3 - g.color[v]\n\t\t\tif !g._isBipartite(w) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}\n\nfunc (g *graph) isBipartite() bool {\n\tchecked := false\n\tcnt := 0\n\tfor i, deg := range g.degree {\n\t\tdeg = g.size - 1 - deg\n\t\tif deg > 0 {\n\t\t\tif checked {\n\t\t\t\tif g.color[i] == 0 {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tg.color[i] = 1\n\t\t\tif !g._isBipartite(i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tfor w := range g.edges[i] {\n\t\t\t\tif g.color[w] == 2 {\n\t\t\t\t\tcnt++\n\t\t\t\t}\n\t\t\t}\n\t\t\tchecked = true\n\t\t}\n\t}\n\tif cnt > 0 {\n\t\tfor v, c := range g.color {\n\t\t\tif c == 1 {\n\t\t\t\tcntW := 0\n\t\t\t\tfor w, e := range g.edges[v] {\n\t\t\t\t\tif e || w == v {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif g.color[w] == 2 {\n\t\t\t\t\t\tcntW++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif cntW != cnt {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol623A(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n, m int\n\tFscan(in, &n, &m)\n\tg := &graph{\n\t\tsize: n,\n\t\tedges: make([][]bool, n),\n\t\tdegree: make([]int, n),\n\t\tcolor: make([]int, n),\n\t}\n\tfor i := range g.edges {\n\t\tg.edges[i] = make([]bool, n)\n\t}\n\tfor ; m > 0; m-- {\n\t\tvar v, w int\n\t\tFscan(in, &v, &w)\n\t\tg.addBoth(v-1, w-1)\n\t}\n\n\t// 若反图为空或二分图,则存在\n\tif !g.isBipartite() {\n\t\tFprint(out, \"No\")\n\t\treturn\n\t}\n\n\tFprintln(out, \"Yes\")\n\tfor _, c := range g.color {\n\t\tFprintf(out, \"%c\", \"bac\"[c])\n\t}\n}\n\nfunc main() {\n\tSol623A(os.Stdin, os.Stdout)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "graphs"], "code_uid": "aa6667bee083eec5f72fe5f8ec833e65", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"strconv\"\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n// var file, _ = os.Open(\"input.txt\")\n// var outfile, _ = os.Create(\"output.txt\")\n// var in = bufio.NewScanner(file)\n// var out = bufio.NewWriter(outfile)\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc next() string {\n if !in.Scan() {\n panic(\"Scan error\")\n }\n return in.Text()\n}\n\nfunc nextInt() int {\n ret, _ := strconv.Atoi(next())\n return ret\n}\n\nfunc nextFloat() float64 {\n ret, _ := strconv.ParseFloat(next(), 64)\n return ret\n}\n\nfunc main() {\n defer out.Flush()\n in.Split(bufio.ScanWords)\n n := nextInt()\n if n % 2 == 1 {\n fmt.Fprintln(out, \"black\")\n } else {\n fmt.Fprintln(out, \"white\")\n fmt.Fprintln(out, \"1 2\")\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "games"], "code_uid": "2b25f28fc850bd7642c146885281f507", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// Input & Output\nvar (\n\tinput = bufio.NewScanner(os.Stdin)\n\toutput = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\tvar n uint64\n\tinput.Scan()\n\tn, _ = strconv.ParseUint(input.Text(), 10, 64)\n\tif n%2 == 1 {\n\t\tfmt.Fprintln(output, \"black\")\n\t} else {\n\t\tfmt.Fprintln(output, \"white\")\n\t\tfmt.Fprintln(output, 1, 2)\n\t}\n\tdefer output.Flush()\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "games"], "code_uid": "1660230e2a05faeb4c79605dd82a7d06", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar x int\n\tfmt.Scanf(\"%d\", &x)\n\tif x % 2 == 0 {\n\t\tfmt.Println(\"white\")\n\t\tfmt.Println(1, 2)\n\t} else {\n\t\tfmt.Println(\"black\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "games"], "code_uid": "90a4cbacf7c73cc40aac9b9942ebd740", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc check(px, py, x, y, a, b, n, m int) int {\n var anw = 100000000\n var tx = px - x; if(tx < 0) { tx = -tx;}\n var ty = py - y; if(ty < 0) { ty = -ty;}\n if(tx == 0 && ty == 0) {\n return 0;\n }\n if(x+a > n && x-a < 1) {\n return anw;\n }\n if(y+b > m && y-b < 1) {\n return anw;\n }\n if(tx%a != 0 || ty%b != 0) {\n return anw;\n }\n if(tx/a%2 == ty/b%2) {\n //fmt.Println(px, py, x, y, a, b, tx/a, ty/b);\n if(tx/a < ty/b) {\n return ty/b;\n }\n return tx/a;\n } else {\n return anw;\n }\n return anw;\n}\n\nfunc main() {\n var n, m, x, y, a, b int\n fmt.Scanf(\"%d %d %d %d %d %d\", &n, &m, &x, &y, &a, &b);\n var tmp int\n var anw = -1;\n tmp = check(n, 1, x, y, a, b, n, m);\n //fmt.Println(tmp);\n if anw == -1 || tmp < anw {\n anw = tmp;\n }\n tmp = check(1, m, x, y, a, b, n, m);\n //fmt.Println(tmp);\n if anw == -1 || tmp < anw {\n anw = tmp;\n }\n tmp = check(n, m, x, y, a, b, n, m);\n //fmt.Println(tmp);\n if anw == -1 || tmp < anw {\n anw = tmp;\n }\n tmp = check(1, 1, x, y, a, b, n, m);\n //fmt.Println(tmp);\n if anw == -1 || tmp < anw {\n anw = tmp;\n }\n if anw != -1 && anw != 100000000{\n fmt.Println(anw)\n } else {\n fmt.Println(\"Poor Inna and pony!\")\n }\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "979967caa69c1f7709ba246bc1b4122e", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nconst mod = 1000000007\nconst maxn = 1000000 + 10\n\nvar rank [maxn]int64\n\nfunc myinit() {\n\trank[0] = 1\n\tvar i int64\n\tfor i = 1; i < maxn; i++ {\n\t\trank[i] = rank[i-1] * i % mod\n\t}\n}\nfunc powmod(a, n int64) int64 {\n\tvar ans int64\n\tans = 1\n\tvar i int64\n\tfor i = 1; i <= n; i++ {\n\t\tans = ans * a % mod\n\t}\n\treturn ans\n}\nfunc main() {\n\tmyinit()\n\tvar n int64\n\tfmt.Scan(&n)\n\tvar ans = (rank[n] - powmod(2, n-1) + mod) % mod\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "graphs"], "code_uid": "3ee630d97f45947323bc063612a725d4", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar reader *bufio.Reader\nvar writer *bufio.Writer\n\nconst MOD = int64(1e9) + 7\n\nfunc solve(n int64) int64 {\n\tvar ans int64 = 1\n\tfor i := int64(1); i <= n; i++ {\n\t\tans *= i\n\t\tans %= MOD\n\t}\n\n\tvar tmp int64 = 1\n\tfor i := int64(1); i <= n-1; i++ {\n\t\ttmp <<= 1\n\t\ttmp %= MOD\n\t}\n\n\tans -= tmp\n\tfor ans < 0 {\n\t\tans += MOD\n\t}\n\treturn ans\n}\n\nfunc main() {\n\t//ioutil.WriteFile(\"input.txt\", []byte(generateInput()), os.ModeExclusive)\n\n\tdebug := 1\n\tfilename := \"input.txt\"\n\tif debug != 0 && len(os.Args) > 1 && os.Args[1] == \"debug\" {\n\t\tfile, _ := os.Open(filename)\n\t\treader = bufio.NewReaderSize(file, 1024*1024)\n\t} else {\n\t\treader = bufio.NewReaderSize(os.Stdin, 1024*1024)\n\t}\n\twriter = bufio.NewWriterSize(os.Stdout, 1024*1024)\n\n\tn := readInt()\n\tans := solve(n)\n\tfmt.Fprintln(writer, ans)\n\n\twriter.Flush()\n}\n\nfunc readInts() []int {\n\tline := readLine()\n\tfields := strings.Fields(line)\n\tres := make([]int, len(fields))\n\tfor i := range fields {\n\t\tv, _ := strconv.ParseInt(fields[i], 10, 64)\n\t\tres[i] = int(v)\n\t}\n\treturn res\n}\n\nfunc readInt() int64 {\n\tline := readLine()\n\tn, _ := strconv.ParseInt(line, 10, 32)\n\treturn int64(n)\n}\n\nfunc readLine() string {\n\tstr, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\n\treturn strings.TrimRight(string(str), \"\\r\\n\")\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "graphs"], "code_uid": "7f2196488ab43ff802a0478b51adec88", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\ntype contest struct {\n\tin io.Reader\n\tout io.Writer\n}\n\nfunc (con *contest) Scan(a ...interface{}) (int, error) {\n\treturn fmt.Fscan(con.in, a...)\n}\nfunc (con *contest) Scanln(a ...interface{}) (int, error) {\n\treturn fmt.Fscanln(con.in, a...)\n}\nfunc (con *contest) Scanf(f string, a ...interface{}) (int, error) {\n\treturn fmt.Fscanf(con.in, f, a...)\n}\nfunc (con *contest) Print(a ...interface{}) (int, error) {\n\treturn fmt.Fprint(con.out, a...)\n}\nfunc (con *contest) Println(a ...interface{}) (int, error) {\n\treturn fmt.Fprintln(con.out, a...)\n}\nfunc (con *contest) Printf(f string, a ...interface{}) (int, error) {\n\treturn fmt.Fprintf(con.out, f, a...)\n}\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tcon := &contest{in: in, out: out}\n\tcon.main()\n}\n\nconst m = 1e9 + 7\n\nfunc (con *contest) main() error {\n\tvar n int64\n\tcon.Scan(&n)\n\tvar x int64 = 1\n\tfor i := int64(1); i <= n; i++ {\n\t\tx *= i\n\t\tx %= m\n\t}\n\tvar y int64 = 1\n\tfor i := int64(1); i <= n-1; i++ {\n\t\ty *= 2\n\t\ty %= m\n\t}\n\tx -= y\n\tif x < 0 {\n\t\tx += m\n\t}\n\tcon.Println(x)\n\treturn nil\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "graphs"], "code_uid": "84fc6968ec0722194392f35a68f08a74", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"strconv\"\n)\n\ntype pos struct{\n x int\n y int\n}\n\nvar whites = [9][9]int{}\n\nfunc mark_rock(board *[9][9]int, pos_r pos){\n for i:=pos_r.x+1; i<=8; i++{\n board[i][pos_r.y] += 1\n if whites[i][pos_r.y] != 0{\n break\n }\n }\n for i:=pos_r.x-1; i>=1; i--{\n board[i][pos_r.y] += 1\n if whites[i][pos_r.y] != 0{\n break\n }\n }\n for j:=pos_r.y+1; j<=8; j++{\n board[pos_r.x][j] += 1\n if whites[pos_r.x][j] != 0{\n break\n }\n }\n for j:=pos_r.y-1; j>=1; j--{\n board[pos_r.x][j] += 1\n if whites[pos_r.x][j] != 0{\n break\n }\n }\n}\n\nfunc is_valid(x int, y int) bool{\n if x>=1 && x<=8{\n return y>=1 && y<=8\n }\n return false\n}\n\nvar move_x = [3]int{-1, 0, 1}\nvar move_y = [3]int{-1, 0, 1}\n\nfunc mark_king(board *[9][9]int, pos_k pos){\n for i:=0; i<3; i++{\n for j:=0; j<3; j++{\n x:= pos_k.x+move_x[i]\n y:= pos_k.y+move_y[j]\n if !is_valid(x,y){\n continue\n }\n board[x][y] += 1\n }\n }\n}\n\nfunc Result(wr1 pos, wr2 pos, bk pos, board [9][9]int) string{\n for i:= 0; i<3; i++{\n for j:=0; j<3; j++{\n x:= bk.x + move_x[i]\n y:= bk.y + move_y[j]\n if x==0 && y==0{\n continue\n }\n if !is_valid(x,y){\n continue\n }\n if board[x][y] == 0{\n return \"OTHER\"\n }\n if board[x][y] == 1 && whites[x][y] == 1{\n return \"OTHER\"\n } \n }\n }\n return \"CHECKMATE\"\n}\n\nfunc main(){\n chess := map[string]pos{}\n toi := [8]byte{'a','b', 'c', 'd', 'e', 'f', 'g', 'h'}\n for k, letter := range toi{\n for j:=1; j<=8; j++{\n chess[string(letter) + strconv.Itoa(j)] = pos{k+1, j}\n whites[k+1][j] = 0\n }\n }\n board := [9][9]int{}\n var wr, wr2, wk, bk string\n fmt.Scanf(\"%s %s %s %s\", &wr, &wr2, &wk, &bk)\n pos_wr, _ := chess[wr]\n board[pos_wr.x][pos_wr.y] = 1 //rock\n whites[pos_wr.x][pos_wr.y] = 1 //rock\n pos_wr2, _ := chess[wr2]\n board[pos_wr2.x][pos_wr2.y] = 1 //rock\n whites[pos_wr2.x][pos_wr2.y] = 1 //rock\n pos_wking, _ := chess[wk]\n board[pos_wking.x][pos_wking.y] = 1 //white king\n whites[pos_wking.x][pos_wking.y] = 2 //white king\n pos_bking, _ := chess[bk]\n\n mark_rock(&board, pos_wr)\n mark_rock(&board, pos_wr2)\n mark_king(&board, pos_wking)\n //show(board)\n fmt.Println(Result(pos_wr, pos_wr2, pos_bking, board))\n}\n\nfunc show(board [9][9]int){\n for i:=1; i<=8; i++{\n for j:=1; j<=8; j++{\n fmt.Printf(\"%d,%d:%v \", i, j, board[i][j])\n }\n fmt.Printf(\"\\n\")\n }\n fmt.Println(\"---------------\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f6d4e1c329eacc67ce2d3d89d41beaa4", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, 1<<16)\n\ts, _, _ := r.ReadLine()\n\tlc := byte('a') - 1\n\tvar ok = true\n\tfor i := 0; i < len(s); i++ {\n\t\tc := s[i]\n\t\tif c > lc {\n\t\t\tif c == lc + 1 {\n\t\t\t\tlc = c\n\t\t\t} else {\n\t\t\t\tok = false\n\t\t\t}\n\t\t}\n\t}\n\tif ok {\n\t\tfmt.Print(\"YES\\n\")\n\t} else {\n\t\tfmt.Print(\"NO\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["greedy", "strings", "implementation"], "code_uid": "38661ffd71a9e1ac8f340b0d25307d9c", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, x, y int\n\tfmt.Scan(&n, &m)\n\tif n > m {\n\t\tx = n\n\t}else{\n\t\tx = m\n\t}\n\n\tif n < m {\n\t\ty = n\n\t}else{\n\t\ty = m\n\t}\n\n\tfmt.Print( x-1, y)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation", "games"], "code_uid": "8a1292de862d1bf4482b22416b55bd2b", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//257B\npackage main\nimport \"fmt\"\n\nfunc main() {\n\tvar nn, mm int\n\tfmt.Scan(&nn, &mm)\n\tif nn>=mm {\n\t\tfmt.Println(nn-1, mm)\n\t} else {\n\t\tfmt.Println(mm-1, nn)\n\t}\n}", "lang_cluster": "Go", "tags": ["greedy", "implementation", "games"], "code_uid": "395ce2554768c3077faf7525cbc74b5c", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tio.NextInt()\n\tS := io.NextLine() + \" \"\n\n\tmaxCaps := 0\n\tcurCaps := 0\n\tfor _, c := range S {\n\t\tif c == ' ' {\n\t\t\tmaxCaps = Max(maxCaps, curCaps)\n\t\t\tcurCaps = 0\n\t\t} else if c >= 'A' && c <= 'Z' {\n\t\t\tcurCaps++\n\t\t}\n\t}\n\tio.Println(maxCaps)\n}\n\nfunc Max(args ...int) int {\n\tmax := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] > max {\n\t\t\tmax = args[i]\n\t\t}\n\t}\n\treturn max\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "9e48edeb0459e138772a0e83a41f6945", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc gcd(a, b int64) int64 {\n\tswitch {\n\tcase a == 0 && b > 0:\n\t\treturn b\n\tcase a > 0 && b == 0:\n\t\treturn a\n\tcase a == b:\n\t\treturn a\n\tcase a == 1 && b > 0:\n\t\treturn 1\n\tcase a > 0 && b == 1:\n\t\treturn 1\n\tcase a%2 == 0 && b%2 == 0:\n\t\treturn 2 * gcd(a/2, b/2)\n\tcase a%2 == 0 && b%2 == 1:\n\t\treturn gcd(a/2, b)\n\tcase a%2 == 1 && b%2 == 0:\n\t\treturn gcd(a, b/2)\n\tcase b > a:\n\t\treturn gcd((b-a)/2, a)\n\tcase b < a:\n\t\treturn gcd((a-b)/2, b)\n\tdefault:\n\t\tpanic(\"not reachable\")\n\t}\n}\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scanf(\"%d %d\", &n, &k)\n\tk = int64(math.Pow10(int(k)))\n\tfmt.Println(n * k / gcd(n, k))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "09072a6acfbe00605f5efb6360197c2d", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar n int64\nvar k int\n\nfunc main() {\n fmt.Scanf(\"%d %d\", &n, &k)\n cnt2 := 0\n cnt5 := 0\n res := n\n for {\n if cnt5 >= k || res%5 != int64(0) {\n break\n }\n res = res / 5\n cnt5++\n }\n for {\n if cnt2 >= k || res%2 != int64(0) {\n break\n }\n res = res / 2\n cnt2++\n }\n for i := 0; i < k; i++ {\n res = res * 10\n }\n fmt.Println(res)\n}", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "1a4d4399c599b6cb8f2c75cf736aa493", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN, K := sc.NextInt64(), sc.NextInt64()\n\n\tDiv2 := int64(0)\n\tDiv5 := int64(0)\n\ttmp := N\n\tfor tmp%2 == 0 {\n\t\ttmp /= 2\n\t\tDiv2++\n\t}\n\n\tfor tmp%5 == 0 {\n\t\ttmp /= 5\n\t\tDiv5++\n\t}\n\tfor i := int64(0); i < K-Div2; i++ {\n\t\tN *= 2\n\t}\n\tfor i := int64(0); i < K-Div5; i++ {\n\t\tN *= 5\n\n\t}\n\n\tfmt.Println(N)\n\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "ff1f12d58b400e645019abcf9479af02", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n uint64\n\tfor I(&n, \"\\n\") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n uint64) {\n\ta, b, c := uint64(1234567), uint64(123456), uint64(1234)\n\tfor i := uint64(0); i <= n/a; i++ {\n\t\taa := a * i\n\t\tfor j := uint64(0); j <= (n-aa)/b; j++ {\n\t\t\tbb := aa + j*b\n\t\t\tif (n-bb)%c == 0 {\n\t\t\t\tO(\"YES\", \"\\n\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tO(\"NO\", \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "54cca4459b30f342136e6735a0624298", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tconst house int = 1234567\n\tconst car int = 123456\n\tconst computer int = 1234\n\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tok := false\n\tfor i := 0; i <= n/house; i++ {\n\t\tfor j := 0; j <= (n-house*i)/car; j++ {\n\t\t\tif (n-house*i-car*j)%computer == 0 {\n\t\t\t\tok = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif ok {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ok {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "13d10668fc8bedc7996ef1457d1b477b", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tin, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\ta, _ := in.ReadString('\\n')\n\ta = strings.Trim(a, \"\\r\\n\")\n\tn, _ := strconv.ParseInt(string(a), 10, 64)\n\tfor a := int64(0); a <= 1000; a++ {\n\t\tfor b := int64(0); b <= 1000; b++ {\n\t\t\tif c := (n - a*1234567 - b*123456) / 1234; c >= 0 && a*1234567+b*123456+c*1234 == n {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "5794f4a6d196d224201b7addb7320c49", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n, m int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &n, &m); err != nil {\n\t\treturn\n\t}\n\n\tqueue := make([]int, n)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; scanner.Scan() && i < n; i++ {\n\t\ta, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tqueue[i] = a\n\t}\n\n\tbuses := 0\n\tseats := 0\n\tfor i := 0; i < n; i++ {\n\t\tif seats < queue[i] {\n\t\t\tbuses++\n\t\t\tseats = m - queue[i] // queue[i] <= m\n\t\t} else {\n\t\t\tseats -= queue[i]\n\t\t}\n\t}\n\n\tfmt.Println(buses)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f8f98542393208983104737274051a53", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 435A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n, m, x, t, c int\n fmt.Scan(&n, &m)\n for n > 0 {\n fmt.Scan(&x)\n if t+x > m {\n c++\n t = x\n } else {\n t += x\n }\n n--\n }\n fmt.Println(c + 1)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "918175b920b6e8422974b39f8bc60520", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int\n\tfor I(&n, \" \") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int) {\n\tvar m int\n\tI(&m, \"\\n\")\n\to := 0\n\tans := 1\n\tfor i := 0; i < n; i++ {\n\t\tvar t int\n\t\ts := \" \"\n\t\tif i == n-1 {\n\t\t\ts = \"\\n\"\n\t\t}\n\t\tI(&t, s)\n\t\tif o+t <= m {\n\t\t\to += t\n\t\t} else {\n\t\t\tans++\n\t\t\to = t\n\t\t}\n\t}\n\tO(ans, \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a9183f430c2bd454eb617ad64c24376a", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/contest/1452/problem/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\tn int64\n\n\t// A, B [200000+50]int64\n\ta, b int64\n\tdp [200000 + 50]int64\n)\n\nfunc main() {\n\tdefer stdout.Flush()\n\n\tn = readll()\n\n\tdp[0] = 1\n\ta = 1\n\tfor i := int64(1); i <= n; i++ {\n\t\tif i%2 == 1 {\n\t\t\tdp[i] += a\n\t\t\tdp[i] %= MOD\n\n\t\t\tb += dp[i]\n\t\t\tb %= MOD\n\t\t} else {\n\t\t\tdp[i] += b\n\t\t\tdp[i] %= MOD\n\n\t\t\ta += dp[i]\n\t\t\ta %= MOD\n\t\t}\n\n\t\t// dp[i] %= MOD\n\t\t// a %= MOD\n\t\t// b %= MOD\n\t}\n\n\t// debugf(\"dp[:n+1]: %v\\n\", dp[:n+1])\n\t// debugf(\"dp[n]: %v\\n\", dp[n])\n\n\td := modpow(2, n, MOD)\n\n\tans := dp[n] * ModInv(d, MOD)\n\tans %= MOD\n\n\tfmt.Println(ans)\n}\n\n// ModInv returns $a^{-1} mod m$ by Fermat's little theorem.\n// O(1), but C is nearly equal to 30 (when m is 1000000000+7).\nfunc ModInv(a, m int64) int64 {\n\treturn modpow(a, m-2, m)\n}\n\nfunc modpow(a, e, m int64) int64 {\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := modpow(a, halfE, m)\n\t\treturn half * half % m\n\t}\n\n\treturn a * modpow(a, e-1, m) % m\n}\n\n/*******************************************************************/\n\n/********** common constants **********/\n\nconst (\n\t// MOD = 1000000000 + 7\n\tMOD = 998244353\n\tALPH_N = 26\n\tINF_I64 = math.MaxInt64\n\tINF_B60 = 1 << 60\n\tINF_I32 = math.MaxInt32\n\tINF_B30 = 1 << 30\n\tNIL = -1\n\tEPS = 1e-10\n)\n\n/********** bufio setting **********/\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\treads = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\n// mod can calculate a right residual whether value is positive or negative.\nfunc mod(val, m int) int {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// chmin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc chmin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// chmax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc chmax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// sum returns multiple integers sum.\nfunc sum(integers ...int) int {\n\tvar s int\n\ts = 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// abs is integer version of math.Abs\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// pow is integer version of math.Pow\n// pow calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc pow(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := pow(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * pow(a, e-1)\n}\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := reads()\n//i := readi()\n//X := readis(n)\n//S := readrs()\n//a := readf()\n//A := readfs(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*********** Input ***********/\n\nvar (\n\t// reads returns a WORD string.\n\treads func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// readi returns an integer.\nfunc readi() int {\n\treturn int(_readInt64())\n}\nfunc readi2() (int, int) {\n\treturn int(_readInt64()), int(_readInt64())\n}\nfunc readi3() (int, int, int) {\n\treturn int(_readInt64()), int(_readInt64()), int(_readInt64())\n}\nfunc readi4() (int, int, int, int) {\n\treturn int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())\n}\n\n// readll returns as integer as int64.\nfunc readll() int64 {\n\treturn _readInt64()\n}\nfunc readll2() (int64, int64) {\n\treturn _readInt64(), _readInt64()\n}\nfunc readll3() (int64, int64, int64) {\n\treturn _readInt64(), _readInt64(), _readInt64()\n}\nfunc readll4() (int64, int64, int64, int64) {\n\treturn _readInt64(), _readInt64(), _readInt64(), _readInt64()\n}\n\nfunc _readInt64() int64 {\n\ti, err := strconv.ParseInt(reads(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// readis returns an integer slice that has n integers.\nfunc readis(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = readi()\n\t}\n\treturn b\n}\n\n// readlls returns as int64 slice that has n integers.\nfunc readlls(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = readll()\n\t}\n\treturn b\n}\n\n// readf returns an float64.\nfunc readf() float64 {\n\treturn float64(_readFloat64())\n}\n\nfunc _readFloat64() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc readfs(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = readf()\n\t}\n\treturn b\n}\n\n// readrs returns a rune slice.\nfunc readrs() []rune {\n\treturn []rune(reads())\n}\n\n/*********** Output ***********/\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// Printf is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n\n/*********** Debugging ***********/\n\n// debugf is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc debugf(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "ca3ce4f5daf3626ee5838a1ed1101f10", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc run(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\tconst mod = 998244353\n\tpow := func(x, n int64) int64 {\n\t\tx %= mod\n\t\tres := int64(1)\n\t\tfor ; n > 0; n >>= 1 {\n\t\t\tif n&1 == 1 {\n\t\t\t\tres = res * x % mod\n\t\t\t}\n\t\t\tx = x * x % mod\n\t\t}\n\t\treturn res\n\t}\n\tinv := func(a int64) int64 { return pow(a, mod-2) }\n\tdiv := func(a, b int64) int64 { return a%mod * inv(b) % mod }\n\tvar n int\n\tFscan(in, &n)\n\tf := make([]int64, n+10)\n\tf[0] = 1\n\tf[1] = div(1, 2)\n\tf[2] = div(1,4)\n\tfor i := 3; i <= n; i++ {\n\t\tf[i] = div(2*f[i-1]+f[i-2],4)\n\t}\n\tFprint(out, f[n])\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "f5260ca2437534707e914cfbaf29977f", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nconst (\n\tmod = 998244353\n\ti2 = (mod + 1) / 2\n)\n\nfunc main() {\n\tn := 0\n\tfmt.Scanf(\"%d\", &n)\n\tf, f1 := uint32(1), uint32(0)\n\tfor i := 1; i < n; i++ {\n\t\tf, f1 = (f+f1)%mod, f\n\t}\n\n\tfmt.Printf(\"%d\\n\", (uint64(f)*exp(i2, n))%mod)\n}\n\nfunc exp(a uint64, p int) (r uint64) {\n\tr = 1\n\tfor ; p > 0; p /= 2 {\n\t\tif p%2 == 1 {\n\t\t\tr = (a * r) % mod\n\t\t}\n\t\ta = (a * a) % mod\n\t}\n\treturn r\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "9ef27c01e0e61c39c495afd18dca08b5", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a,b int) int { if b == 0 { return a } else { return gcd(b,a%b) } }\n\nfunc main() {\n var n,x int\n fmt.Scan(&n)\n a := -1\n for i := 0; i < n ; i++ {\n fmt.Scan(&x)\n if a == -1 { a = x } else { a = gcd(a,x) }\n }\n fmt.Println(a*n)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "8cd4ad4e3ae40b1e5290984e0379cc96", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 389A-mic\npackage main\n\nimport (\n \"fmt\"\n \"math/big\"\n)\n\nfunc gcd(x, y int64) int64 {\n return new(big.Int).GCD(nil, nil, big.NewInt(x), big.NewInt(y)).Int64()\n}\n\nfunc main() {\n var n, g, k, i int64\n fmt.Scan(&n, &g)\n for i = 1; i < n; i++ {\n fmt.Scan(&k)\n g = gcd(g, k)\n }\n fmt.Println(g * n)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "5d42cb0caf13c705718965731d30da6a", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a,b int) int { if b == 0 { return a } else { return gcd(b,a%b) } }\n\nfunc main() {\n var n,x int\n fmt.Scan(&n)\n a := -1\n for i := 0; i < n ; i++ {\n fmt.Scan(&x)\n if a == -1 { a = x } else { a = gcd(a,x) }\n }\n fmt.Println(a*n)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "0e61446528426fac3f5a6aba0892deb4", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// https://codeforces.com/problemset/problem/550/B\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"math\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\t\n\tvar n, l, r, x int64\n\tscanf(\"%d%d%d%d\\n\", &n, &l, &r, &x)\n\tarr := make([]int64, n)\n\t\n\tfor i:=int64(0);i arr[j] {\n\t\t\t\t\tmin = arr[j]\n\t\t\t\t}\n\t\t\t\tif max < arr[j] {\n\t\t\t\t\tmax = arr[j]\n\t\t\t\t}\n\t\t\t\tsum += arr[j]\n\t\t\t}\n\t\t}\n\n\t\tif sum >= l && sum <= r && (max-min) >= x {\n\t\t\tans++\n\t\t}\n\t}\n\n\tprintf(\"%d\\n\", ans)\n\n}", "lang_cluster": "Go", "tags": ["brute force", "bitmasks"], "code_uid": "ea7b1c0245f162bc7eecfadd7a00ecd0", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n, l, r, x int\n\tif _, err := fmt.Scanf(\"%d %d %d %d\\n\", &n, &l, &r, &x); err != nil {\n\t\treturn\n\t}\n\n\tc := make([]int, n)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; i < n && scanner.Scan(); i++ {\n\t\t_c, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tc[i] = _c\n\t}\n\n\tways := 0\n\n\tmask := (1 << uint(n)) - 1\n\tfor mask > 0 {\n\t\tm := mask\n\n\t\tcnt := 0\n\t\tsum := 0\n\t\tmax := -1\n\t\tmin := -1\n\t\tfor i := 0; i < n; i++ {\n\t\t\tv := m % 2\n\t\t\tif v == 1 {\n\t\t\t\tcnt++\n\t\t\t\tsum += c[i]\n\t\t\t\tif c[i] > max {\n\t\t\t\t\tmax = c[i]\n\t\t\t\t}\n\t\t\t\tif c[i] < min || min < 0 {\n\t\t\t\t\tmin = c[i]\n\t\t\t\t}\n\t\t\t}\n\t\t\tm /= 2\n\t\t}\n\t\tif cnt >= 2 && sum >= l && sum <= r && max-min >= x {\n\t\t\tways++\n\t\t}\n\n\t\tmask -= 1\n\t}\n\n\tfmt.Println(ways)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "bitmasks"], "code_uid": "f1a12d10237a79d84a4f597dd4bc0a88", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn, l, r, x := nextInt(), nextInt(), nextInt(), nextInt()\n\tc := make([]int, n)\n\tcnt := 0\n\n\tfor i := range c {\n\t\tc[i] = nextInt()\n\t}\n\n\tsort.Ints(c)\n\n\tfor i := 0; i < (1 << uint(n)); i++ {\n\t\tsum := 0\n\t\tmin, max := -1, -1\n\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif ((1 << uint(j)) & i) > 0 {\n\t\t\t\tsum += c[j]\n\n\t\t\t\tif min == -1 {\n\t\t\t\t\tmin = j\n\t\t\t\t}\n\t\t\t\tmax = j\n\t\t\t}\n\t\t}\n\n\t\tif min != max && c[max]-c[min] >= x && sum >= l && sum <= r {\n\t\t\tcnt++\n\t\t}\n\t\t// println(i, sum, min, max)\n\t}\n\n\tprintln(cnt)\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["brute force", "bitmasks"], "code_uid": "20276d454ba8193f23dca79f7cfe25f2", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\ntype in struct {\n\tScanner *bufio.Scanner\n}\n\nfunc (in *in) s() string {\n\tin.Scanner.Scan()\n\treturn in.Scanner.Text()\n}\nfunc (in *in) i() int {\n\tret, _ := strconv.ParseInt(in.s(), 10, 32)\n\treturn int(ret)\n}\nfunc (in *in) i64() int64 {\n\tret, _ := strconv.ParseInt(in.s(), 10, 64)\n\treturn ret\n}\nfunc (in *in) f() float64 {\n\tret, _ := strconv.ParseFloat(in.s(), 64)\n\treturn ret\n}\nfunc (in *in) ss(n int64) []string {\n\ta := make([]string, n)\n\tfor i := range a {\n\t\ta[i] = in.s()\n\t}\n\treturn a\n}\nfunc (in *in) is(n int64) []int64 {\n\ta := make([]int64, n)\n\tfor i := range a {\n\t\ta[i] = in.i64()\n\t}\n\treturn a\n}\nfunc (in *in) fs(n int64) []float64 {\n\ta := make([]float64, n)\n\tfor i := range a {\n\t\ta[i] = in.f()\n\t}\n\treturn a\n}\nfunc (in *in) imat(h int64, w int64) [][]int64 {\n\ta := make([][]int64, h)\n\tfor y := range a {\n\t\ta[y] = make([]int64, w)\n\t\tfor x := range a[y] {\n\t\t\ta[y][x] = in.i64()\n\t\t}\n\t}\n\treturn a\n}\n\nfunc stdin() in {\n\tscn := bufio.NewScanner(os.Stdin)\n\tscn.Split(bufio.ScanWords)\n\tmax := 1048576\n\tbuf := make([]byte, max)\n\tscn.Buffer(buf, max)\n\treturn in{Scanner: scn}\n}\n\ntype arr []int\n\nfunc (a arr) Len() int {\n\treturn len(a)\n}\n\nfunc (a arr) Less(i, j int) bool {\n\treturn a[i] < a[j]\n}\n\nfunc (a arr) Swap(i, j int) {\n\ta[i], a[j] = a[j], a[i]\n}\n\nconst maxn = 2e5 + 7\nconst inf = 0x3f3f3f3f\n\nfunc main() {\n\tin := stdin()\n\tn, k := in.i(), in.i()\n\tar := make([]arr, maxn)\n\tfor i := 0; i < n; i++ {\n\t\tfor x, cnt := in.i(), 0; x > 0; x /= 2 {\n\t\t\tar[x] = append(ar[x], cnt)\n\t\t\tcnt++\n\t\t}\n\t}\n\tans := inf\n\tfor i := 0; i < maxn; i++ {\n\t\tif len(ar[i]) < k {\n\t\t\tcontinue\n\t\t}\n\t\tsort.Sort(ar[i])\n\t\tsum := 0\n\t\tfor j := 0; j < k; j++ {\n\t\t\tsum += ar[i][j]\n\t\t}\n\t\tif sum < ans {\n\t\t\tans = sum\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "f03a060d2c7324e9fbdc3b98e55e0173", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"runtime\"\n\t\"strconv\"\n)\n\n/* solution */\n\ntype nodeType struct {\n\tnext [2]*nodeType\n\t// count of digits need to be removed\n\t// ...from the end of binary value (count of divisions by 2)\n\t// ...to make an added value equal to the current\n\tcuts [20]int\n\tcnt int\n}\n\nfunc solve() {\n\n\tn, k := readInt(), readInt()\n\troot := &nodeType{}\n\n\tfor i := 0; i < n; i++ {\n\n\t\tv := readInt()\n\n\t\tdigits := make([]int, 0)\n\t\tfor v > 0 {\n\t\t\t// reversed binary representation of the value\n\t\t\tdigits = append(digits, v%2)\n\t\t\tv = v / 2\n\t\t}\n\n\t\taddToTree(root, digits, len(digits))\n\n\t}\n\n\tprintInt(search(root, k))\n\n}\n\nfunc search(node *nodeType, k int) int {\n\n\tif node == nil || node.cnt < k {\n\t\treturn 1000000000 // INF\n\t}\n\n\ts0 := 0\n\trem := k - node.cuts[0] // how many equal values do we need more\n\tfor i := 1; rem > 0 && i < 20; i++ {\n\t\tif rem > node.cuts[i] {\n\t\t\ts0 += node.cuts[i] * i\n\t\t\trem -= node.cuts[i]\n\t\t} else {\n\t\t\ts0 += rem * i\n\t\t\trem = 0\n\t\t}\n\t}\n\n\ts1, s2 := search(node.next[0], k), search(node.next[1], k)\n\n\treturn min(s0, min(s1, s2))\n\n}\n\nfunc addToTree(node *nodeType, digits []int, idx int) {\n\n\tnode.cnt++\n\tnode.cuts[idx]++\n\n\tidx--\n\tif idx < 0 {\n\t\treturn\n\t}\n\n\tnext := node.next[digits[idx]]\n\tif next == nil {\n\t\tnode.next[digits[idx]] = &nodeType{}\n\t\tnext = node.next[digits[idx]]\n\t}\n\n\taddToTree(next, digits, idx)\n\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n/* stubs */\n\nfunc main() {\n\n\tvar f *os.File\n\tif runtime.GOROOT() == \"C:\\\\Soft\\\\Go\" {\n\t\tf, _ = os.Open(\"input.txt\")\n\t\tdefer f.Close()\n\t} else {\n\t\tf = os.Stdin\n\t}\n\n\twriter = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\treader = bufio.NewScanner(f)\n\n\tconst maxCapacity = 1024 * 1024\n\tbuf := make([]byte, maxCapacity)\n\treader.Buffer(buf, maxCapacity)\n\n\treader.Split(bufio.ScanWords)\n\n\tsolve()\n\n}\n\nvar reader *bufio.Scanner\nvar writer *bufio.Writer\n\nfunc read() string {\n\treader.Scan()\n\treturn reader.Text()\n}\n\nfunc readInt() int {\n\treader.Scan()\n\tret, _ := strconv.Atoi(reader.Text())\n\treturn ret\n}\n\nfunc print(s string) {\n\twriter.WriteString(s)\n\twriter.WriteString(\"\\n\")\n}\n\nfunc printInt(i int) {\n\tprint(strconv.Itoa(i))\n}\n\nfunc printInt64(i int64) {\n\tprint(strconv.FormatInt(i, 10))\n}\n\nfunc readInt64() int64 {\n\treader.Scan()\n\tret, _ := strconv.ParseInt(reader.Text(), 10, 64)\n\treturn ret\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "a049f1d391bb40582807d7c81f4a5d01", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n height, p := getI(), getI()\n flip := map[rune]rune{ 'L': 'R', 'R': 'L' }\n expect := 'L'\n span := int64(1 << uint64(height-1))\n result := int64(0)\n for span != 0 {\n actual := 'L'\n if p > span {\n actual = 'R'\n p -= span\n }\n if expect == actual {\n result += 1\n } else {\n result += 2*span\n }\n //writer.WriteString(fmt.Sprintf(\"p %d, span %d, expect %c, actual %c\\n\",\n // p, span, expect, actual))\n span /= 2\n expect = flip[actual]\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "trees"], "code_uid": "4ef4166f7ef6639ed4676e6d625e09c3", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar h uint\n\tvar n uint64\n\tfmt.Scan(&h, &n)\n\tn--\n\tn += (1 << h)\n\tz := uint64(0)\n\tfor k := h; k > 0; k-- {\n\t\tx := uint64(1 << k)\n\t\ty := uint64(x >> 1)\n\t\tswitch ((n & x) >> k) ^ ((n & y) >> (k - 1)) {\n\t\tcase 1:\n\t\t\tz++\n\t\tcase 0:\n\t\t\tz += x\n\t\t}\n\t}\n\tfmt.Println(z)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "trees"], "code_uid": "34d823cecc8c09eb2f160032bf7539f0", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc getCnt(n int64) int64 {\n var sum int64\n for k:= int64(2); k*k*k <= n; k++ {\n sum += n/(k*k*k)\n }\n return sum\n}\n\nfunc main() {\n var m int64\n fmt.Scan(&m)\n\n var lo, hi int64\n lo = 1\n hi = 9223372036854775807\n for lo+1 < hi {\n mid := (lo+hi)/2\n sum := int64(0)\n for k:= int64(2); k*k*k <= mid; k++ {\n sum += mid/(k*k*k)\n }\n if sum >= m {\n hi = mid\n } else {\n lo = mid\n }\n }\n hiCnt := getCnt(hi)\n if hiCnt == m {\n fmt.Println(hi)\n } else {\n fmt.Println(-1)\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "binary search", "combinatorics"], "code_uid": "881404c1991eeadb3c059b171acfb265", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n\nfunc pointCount(i int64) int64 {\n\tvar sum int64\n\tfor j:=int64(2); j*j*j < i + 1; j++ {\n\t\tsum += i / (j*j*j)\n\t}\n\treturn sum\n}\n\n\nfunc solve(m int64) int64 {\n\tvar lo, hi, mid int64\n lo = int64(0)\n\thi = int64(5000000000000000)\n\tfor lo + 1 < hi {\n\t\tmid = (lo + hi) / 2\n\t\tif pointCount(mid) < m {\n\t\t\tlo = mid\n\t\t} else {\n\t\t\thi = mid\n\t\t}\n\t}\n\tif pointCount(hi) == m {\n\t\treturn hi\n\t} else {\n\t\treturn -1\n\t}\n}\n\n\nfunc main() {\n\tvar m int64\n \tfmt.Scan(&m)\n\tfmt.Println(solve(m))\n}\n", "lang_cluster": "Go", "tags": ["math", "binary search", "combinatorics"], "code_uid": "a7f40067fa492fff41219601700e245a", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n \"math\"\n)\n\nvar scanner *bufio.Scanner\nvar writer *bufio.Writer\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\n\nfunc getCount(x int64) int64 {\n count := int64(0)\n limit := int64(math.Floor(math.Pow(float64(x), 0.34)))\n for k := int64(2); k <= limit; k++ {\n count += x / (k * k * k)\n }\n return count\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer = bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n m := getI64()\n low, high := int64(1), int64(8000000000000000)\n for low < high {\n x := (low + high) / 2\n y := getCount(x)\n if y > m {\n high = x - 1\n } else if y < m {\n low = x + 1\n } else {\n high = x\n }\n }\n x := low\n y := getCount(x)\n if y != m {\n x = -1\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", x))\n}\n", "lang_cluster": "Go", "tags": ["math", "binary search", "combinatorics"], "code_uid": "643fa7a9acf7f43ae54c007ab0952267", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar rows = [][]int{\n\t{1 << 0, 1 << 1, 1 << 2},\n\t{1 << 3, 1 << 4, 1 << 5, 1 << 6},\n\t{1 << 7, 1 << 8, 1 << 9, 1 << 10, 1 << 11},\n\t{1 << 12, 1 << 13, 1 << 14, 1 << 15},\n\t{1 << 16, 1 << 17, 1 << 18},\n\n\t{1 << 0, 1 << 3, 1 << 7},\n\t{1 << 1, 1 << 4, 1 << 8, 1 << 12},\n\t{1 << 2, 1 << 5, 1 << 9, 1 << 13, 1 << 16},\n\t{1 << 6, 1 << 10, 1 << 14, 1 << 17},\n\t{1 << 11, 1 << 15, 1 << 18},\n\n\t{1 << 2, 1 << 6, 1 << 11},\n\t{1 << 1, 1 << 5, 1 << 10, 1 << 15},\n\t{1 << 0, 1 << 4, 1 << 9, 1 << 14, 1 << 18},\n\t{1 << 3, 1 << 8, 1 << 13, 1 << 17},\n\t{1 << 7, 1 << 12, 1 << 16},\n}\n\nvar mem [1 << 19]int\n\nfunc win(st int) bool {\n\tif st == 0 {\n\t\treturn false\n\t}\n\tif mem[st] != 0 {\n\t\treturn mem[st] == 1\n\t}\n\n\tfor _, row := range rows {\n\t\tfor i := range row {\n\t\t\tcur := 0\n\t\t\tfor _, m := range row[i:] {\n\t\t\t\tif st&m == 0 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcur |= m\n\t\t\t\tif !win(st & ^cur) {\n\t\t\t\t\tmem[st] = 1\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tmem[st] = 2\n\treturn false\n}\n\nfunc main() {\n\tst := 0\n\tfor i := 0; i < 19; i++ {\n\t\tvar w string\n\t\tfmt.Scan(&w)\n\t\tif w == \"O\" {\n\t\t\tst |= 1 << i\n\t\t}\n\t}\n\tif win(st) {\n\t\tfmt.Println(\"Karlsson\")\n\t} else {\n\t\tfmt.Println(\"Lillebror\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "games", "dp", "bitmasks", "implementation"], "code_uid": "14ff078df9e08be6bffbc42d1de9b419", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn, m := nextInt(), nextInt()\n\n\tmaxline, line, pos, a := 0, 0, 0, 0\n\n\tfor i := 0; i < n; i++ {\n\t\ta = nextInt()\n\n\t\tline = a / m\n\n\t\tif a % m > 0 {\n\t\t\tline++\n\t\t}\n\n\t\tif line >= maxline {\n\t\t\tmaxline = line\n\t\t\tpos = i\n\t\t}\n\t}\n\n\tprintln(pos + 1)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, err := strconv.ParseFloat(next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc print(a ...interface{}) {\n\tfmt.Fprint(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "8bfdec3880729c2a1cfb752b5241c68c", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\ntype child struct {\n index int\n left int\n}\n\nfunc main() {\n var n, m int\n fmt.Scan(&n, &m)\n\n an := make([]child, 2*n, 2*n)\n for i := 0; i < n; i++ {\n var a int\n fmt.Scan(&a)\n an[i].left = a\n an[i].index = i+1\n }\n\n left := n\n ans := n\n for left > 0 {\n tmp := left\n left = 0\n for i := 0; i < tmp; i++ {\n if an[i].left > m {\n an[n+left].index, an[n+left].left = an[i].index, an[i].left-m\n left++\n }\n }\n if left == 0 {\n ans = an[tmp-1].index\n break\n }\n for i := n; i < left+n; i++ {\n an[i-n].index, an[i-n].left = an[i].index, an[i].left\n }\n }\n\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "452741e7275da6d918142840892269e6", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tn, m := 0, 0\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tfmt.Sscanf(line, \"%d %d\", &n, &m)\n\t}\n\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\t\ttokens := strings.Fields(line)\n\t\tchildRequirement := make([]int, n)\n\n\t\tfor i := 0; i < n; i++ {\n\t\t\tchildRequirement[i], _ = strconv.Atoi(tokens[i])\n\t\t}\n\n\t\tchildGet := make([]int, n)\n\n\t\tlastChild := 0\n\t\tfor {\n\t\t\tfinishes := true\n\t\t\tfor i := 0; i < n; i++ {\n\t\t\t\tif childGet[i] < childRequirement[i] {\n\t\t\t\t\tchildGet[i] = childGet[i] + m\n\t\t\t\t\tlastChild = i\n\t\t\t\t}\n\n\t\t\t\tif childGet[i] < childRequirement[i] {\n\t\t\t\t\tfinishes = false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif finishes {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfmt.Println(lastChild + 1)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f1353c44e7adfd5fb509dd4eda9f1662", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF101C(in io.Reader, out io.Writer) {\n\tvar x, y [3]int64\n\tfor i := 0; i < 3; i++ {\n\t\tFscan(in, &x[i], &y[i])\n\t}\n\td := x[2]*x[2] + y[2]*y[2]\n\tfor i := 0; i < 4; i++ {\n\t\tx[0], y[0] = y[0], -x[0]\n\t\tdx, dy := x[1]-x[0], y[1]-y[0]\n\t\td1, d2 := dx*x[2]+dy*y[2], dx*y[2]-dy*x[2]\n\t\tif d == 0 && dx == 0 && dy == 0 || d > 0 && d1%d == 0 && d2%d == 0 {\n\t\t\tFprint(out, \"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tFprint(out, \"NO\")\n}\n\nfunc main() { CF101C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9391fccf940152e6ad85c53cd8e9183e", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF101C(in io.Reader, out io.Writer) {\n\tvar x, y [3]int64\n\tfor i := 0; i < 3; i++ {\n\t\tFscan(in, &x[i], &y[i])\n\t}\n\td := x[2]*x[2] + y[2]*y[2]\n\tfor i := 0; i < 4; i++ {\n\t\tx[0], y[0] = y[0], x[0]\n\t\ty[0] = -y[0]\n\t\tdx, dy := x[1]-x[0], y[1]-y[0]\n\t\td1, d2 := dx*x[2]+dy*y[2], dx*y[2]-dy*x[2]\n\t\tif d == 0 && dx == 0 && dy == 0 || d > 0 && d1%d == 0 && d2%d == 0 {\n\t\t\tFprint(out, \"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tFprint(out, \"NO\")\n}\n\nfunc main() { CF101C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "fc9979bc120e8f6be9e95437df3c751e", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\ntype byteSet map[byte]bool\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scan(&n)\n\tfmt.Scan(&s)\n\n\tsets := make([]byteSet, 0)\n\tcurSet := byteSet{}\n\n\tfor i := 0; i < n; i++ {\n\t\tif s[i] >= 'a' && s[i] <= 'z' {\n\t\t\tcurSet[s[i]] = true\n\t\t\tif i != n-1 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tsets = append(sets, curSet)\n\t\tcurSet = byteSet{}\n\t}\n\n\tmaxSet := byteSet{}\n\n\tfor _, set := range sets {\n\t\tif len(set) > len(maxSet) {\n\t\t\tmaxSet = set\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n\", len(maxSet))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "9ea1a5412ede3f183313d2975d78a0c0", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar N int\n\tfmt.Scanf(\"%d\\n\", &N)\n\n\tvar s string\n\tfmt.Scanf(\"%s\\n\", &s)\n\n\tset := make(map[byte]bool)\n\n\tans := 0\n\n\tfor i := 0; i < N; i++ {\n\n\t\tif s[i] >= 'a' && s[i] <= 'z' {\n\t\t\tif _, ok := set[s[i]]; !ok {\n\t\t\t\tset[s[i]] = true\n\t\t\t\tcount := len(set)\n\t\t\t\tif ans < count {\n\t\t\t\t\tans = count\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tset = make(map[byte]bool)\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "2f06bd0415275565c814391ff23bf26b", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar num int\nvar str string\n\nfunc main() {\n fmt.Scan(&num)\n fmt.Scan(&str)\n max := 0\n pre := make(map[byte]bool)\n for i := 0; i < num; i++ {\n if str[i] >= 'a' && str[i] <= 'z' {\n pre[str[i]] = true\n } else {\n if len(pre) > max {\n max = len(pre)\n }\n pre = make(map[byte]bool)\n }\n }\n if len(pre) > max {\n max = len(pre)\n }\n fmt.Println(max)\n}", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "be2d5496ee09ea771a236df272863d0d", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 172B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x [100005]int\n\tvar a, b, m, r int\n\tfmt.Scan(&a, &b, &m, &r)\n\tfor i := 1; ; i++ {\n\t\tr = (a*r + b) % m\n\t\tif x[r] > 0 {\n\t\t\tfmt.Println(i - x[r])\n\t\t\tbreak\n\t\t}\n\t\tx[r] = i\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation", "number theory"], "code_uid": "741f4b00652d5386deee49c156f4601a", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar (\n a, b, x, y int\n s string\n)\n\nvar xx = []int{0}\nvar yy = []int{0}\n\nfunc make2(a, b, delta int) int {\n if delta == 0 {\n if a == b {\n return -1\n }\n return -2\n }\n if (b-a)%delta != 0 || (b-a)/delta < 0 {\n return -2\n }\n return (b - a) / delta\n}\n\nfunc main() {\n fmt.Scan(&a, &b, &s)\n for _, i := range s {\n switch i {\n case 'U':\n y += 1\n case 'D':\n y -= 1\n case 'L':\n x -= 1\n case 'R':\n x += 1\n }\n xx = append(xx,x)\n yy = append(yy,y)\n }\n for i, _ := range xx {\n aa := make2(xx[i], a, x)\n bb := make2(yy[i], b, y)\n if aa == -2 || bb == -2 {\n continue\n }\n if (aa == -1) || (bb == -1) || (aa == bb) {\n fmt.Println(\"Yes\")\n return\n }\n }\n fmt.Println(\"No\")\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "binary search"], "code_uid": "aedcd0f47fe462983a36de7a7c964e8e", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar sc *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ni() int {\n sc.Scan()\n ans, _ := strconv.Atoi(sc.Text())\n return ans\n}\n\nfunc nll() int64 {\n sc.Scan()\n ans, _ := strconv.ParseInt(sc.Text(), 10, 64)\n return ans\n}\n\nfunc next() string {\n sc.Scan()\n return sc.Text()\n}\n\nfunc pri(n int) { w.WriteString(strconv.Itoa(n)) }\nfunc prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }\nfunc sp() { w.WriteByte(' ') }\nfunc endl() { w.WriteByte('\\n') }\n\nfunc main() {\n sc.Split(bufio.ScanWords)\n a, b := nll(), nll()\n s := next()\n x, y := []int64{0}, []int64{0}\n xx, yy := int64(0), int64(0)\n for i := 0; i < len(s); i++ {\n switch s[i] {\n case 'U':\n yy++\n case 'D':\n yy--\n case 'L':\n xx--\n case 'R':\n xx++\n }\n x = append(x, xx)\n y = append(y, yy)\n }\n dx, dy := x[len(x)-1], y[len(y)-1]\n if dx != 0 && dy != 0 {\n for i := 0; i < len(s); i++ {\n if (a-x[i])%dx == 0 && (b-y[i])%dy == 0 && ((a-x[i])/dx == (b-y[i])/dy) && (a-x[i])/dx >= 0 {\n w.WriteString(\"Yes\\n\")\n w.Flush()\n return\n }\n }\n } else if dy != 0 {\n for i := 0; i < len(s); i++ {\n if (b-y[i])%dy == 0 && a == x[i] && (b-y[i])/dy >= 0 {\n w.WriteString(\"Yes\\n\")\n w.Flush()\n return\n }\n }\n } else if dx != 0 {\n for i := 0; i < len(s); i++ {\n if (a-x[i])%dx == 0 && b == y[i] && (a-x[i])/dx >= 0 {\n w.WriteString(\"Yes\\n\")\n w.Flush()\n return\n }\n }\n } else {\n for i := 0; i < len(s); i++ {\n if a == x[i] && b == y[i] {\n w.WriteString(\"Yes\\n\")\n w.Flush()\n return\n }\n }\n }\n w.WriteString(\"No\\n\")\n w.Flush()\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "e0fe2bf81544415f3a1bde2b30ee3de8", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 321A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\ti, x, y, X, Y int64\n\ts string\n)\n\nfunc main() {\n\tfmt.Scan(&x, &y, &s)\n\tX, Y = 0, 0\n\tn := len(s)\n\txx := make([]int64, n)\n\tyy := make([]int64, n)\n\tfor i = 0; i < int64(n); i++ {\n\t\txx[i] = X\n\t\tyy[i] = Y\n\t\tif s[i] == 'R' {\n\t\t\tX++\n\t\t}\n\t\tif s[i] == 'U' {\n\t\t\tY++\n\t\t}\n\t\tif s[i] == 'L' {\n\t\t\tX--\n\t\t}\n\t\tif s[i] == 'D' {\n\t\t\tY--\n\t\t}\n\t}\n\tfor i = 0; i < int64(len(s)); i++ {\n\t\tif ((X != 0 || x == xx[i]) && (X == 0 || (x-xx[i])%X == 0)) && ((Y != 0 || y == yy[i]) && (Y == 0 || (y-yy[i])%Y == 0)) {\n\t\t\tif (x-xx[i])*Y == (y-yy[i])*X {\n\t\t\t\tif (X == 0 || (x-xx[i])/X >= 0) && (Y == 0 || (y-yy[i])/Y >= 0) {\n\t\t\t\t\tfmt.Print(\"Yes\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(\"No\")\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "binary search"], "code_uid": "f666a52d812d9f9a5ac8c11106bd7b62", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\treader.ReadString('\\n')\n\tyears_str, _ := reader.ReadString('\\n')\n\tyears_str = strings.Trim(years_str, \"\\n\")\n\n\tyears := strings.Split(years_str, \" \")\n\tsort.Strings(years)\n\n\tindex := len(years) / 2\n\tfmt.Println(years[index])\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation"], "code_uid": "622264c483029ca6cc186bfdabefcc4f", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc solve(n int, a []int) int {\n\tsort.Ints(a)\n\treturn a[n/2]\n}\n\nfunc main() {\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\tn := cin.nextInt()\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = cin.nextInt()\n\t}\n\tfmt.Printf(\"%d\\n\", solve(n, a))\n}\n\n// some io\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}", "lang_cluster": "Go", "tags": ["sortings", "implementation"], "code_uid": "22015fe91567aa2f01a8202f05b84b75", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tlength int\n\t\tstr string\n\t)\n\t\n\tfmt.Scanf(\"%d\\n\", &length)\n\tfmt.Scan(&str)\n\tpokemons := []string {\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"}\n\t\n\tsameLength := make([]string, 0)\n\tfor i := 0; i < len(pokemons); i++ {\n\t\tif len(pokemons[i]) == length {\n\t\t\tsameLength = append(sameLength, pokemons[i])\n\t\t\t\n\t\t}\n\t}\n\t\n\tfor j := 0; j < len(sameLength); j++ {\n\t\tfor i := 0; i < len(str); i++ {\n\t\t\tif (str[i] == sameLength[j][i] || str[i] == '.') && (i == (len(str) - 1)) {\n\t\t\t\tfmt.Println(sameLength[j])\n\t\t\t\treturn\n\t\t\t} else if (str[i] != sameLength[j][i]) && (str[i] != '.') {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "d368c5fa98ba8a835865c19a88b78e71", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar (\n\t\tlength int\n\t\tstr string\n\t)\n\n\tfmt.Scanf(\"%d\\n\", &length)\n\tfmt.Scan(&str)\n\tpokemons := []string{\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"}\n\n\tfor j := 0; j < len(pokemons); j++ {\n\t\tif len(pokemons[j]) != length {\n\t\t\tcontinue\n\t\t}\n\t\tfor i := 0; i < length; i++ {\n\t\t\t\n\t\t\tif str[i] == pokemons[j][i] || str[i] == '.' {\n\t\t\t\tif i == (length - 1) {\n\t\t\t\t\tfmt.Println(pokemons[j])\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "96feb9b16b246836ec83da4af85d9848", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\nvar _, _, _ = main, rw, do\r\n\r\nfunc main() {\r\n\tr, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\r\n\tdefer w.Flush()\r\n\trw(r, w)\r\n}\r\n\r\nfunc rw(r io.Reader, w io.Writer) {\r\n\tvar t int\r\n\tvar n, k int\r\n\tfmt.Fscan(r, &t)\r\n\tfor ti := 0; ti < t; ti++ {\r\n\t\tfmt.Fscan(r, &n, &k)\r\n\t\tw1 := do(n, k)\r\n\t\tfmt.Fprint(w, w1)\r\n\t\tfmt.Fprintln(w)\r\n\t}\r\n}\r\n\r\nfunc do(n, k int) int64 {\r\n\tif k == 0 {\r\n\t\treturn 1\r\n\t}\r\n\ttk := getTk(n, k)\r\n\tgr, eq := getGrEq(n)\r\n\tr := gr + eq\r\n\tfor i := 2; i <= k; i++ {\r\n\t\tr = (((eq * r) % mod) + ((gr * tk[i-1]) % mod)) % mod\r\n\t}\r\n\treturn r\r\n}\r\n\r\nconst mod = 1e9 + 7\r\n\r\nfunc getTn(n int) []int64 {\r\n\ttn := make([]int64, n+1)\r\n\ttn[0] = 1\r\n\tfor i := 1; i <= n; i++ {\r\n\t\ttn[i] = (tn[i-1] * 2) % mod\r\n\t}\r\n\treturn tn\r\n}\r\n\r\nfunc getTk(n, k int) []int64 {\r\n\ttk := make([]int64, k+1)\r\n\ttk[0] = 1\r\n\ttn := getTn(n)\r\n\tfor i := 1; i <= k; i++ {\r\n\t\ttk[i] = (tk[i-1] * tn[n]) % mod\r\n\t}\r\n\treturn tk\r\n}\r\n\r\nfunc getGrEq(n int) (int64, int64) {\r\n\tif n == 1 {\r\n\t\treturn 0, 2\r\n\t}\r\n\tif n == 2 {\r\n\t\treturn 1, 1\r\n\t}\r\n\ttn := getTn(n)\r\n\tvar gr, eq int64 = 0, tn[n-1]\r\n\tif n%2 == 0 {\r\n\t\tgr = 1\r\n\t\teq = (eq + mod - 1) % mod\r\n\t} else {\r\n\t\teq = (eq + 1) % mod\r\n\t}\r\n\treturn gr, eq\r\n}", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "c2bb53ba215f6e63d1b6e8f21f6a7451", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\nimport (\r\n\"fmt\"\r\n\"bufio\"\r\n\"os\"\r\n)\r\n\r\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\r\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\r\n\r\nconst mod int = 1000000007\r\nconst Mod = int64(mod)\r\n\r\nfunc pw(n, k int) int {\r\n\tret := 1\r\n\tpv := n % mod\r\n\tfor ; k > 0; k >>= 1 {\r\n\t\tif (k & 1) > 0 {\r\n\t\t\tret = int(int64(ret) * int64(pv) % Mod)\r\n\t\t}\r\n\t\tpv = int(int64(pv) * int64(pv) % Mod)\r\n\t}\r\n\treturn ret\r\n}\r\n\r\nfunc main(){\r\n\t// your code goes here\r\n\tdefer writer.Flush()\r\n\tvar (\r\n\t\tt, n, k int\r\n\t)\r\n\tfmt.Fscan(reader, &t)\r\n\tfor id := 0; id < t; id++ {\r\n\t\tfmt.Fscan(reader, &n, &k)\r\n\t\tif n % 2 == 1 {\r\n\t\t\tfmt.Fprintln(writer, pw(pw(2,n-1) + 1, k))\r\n\t\t} else {\r\n\t\t\tans := pw(pw(2, n-1) - 1, k)\r\n\t\t\tfor j := 1; j <= k; j++ {\r\n\t\t\t\tv := int64(n) * int64(j-1) % (Mod - int64(1))\r\n\t\t\t\tans += int( int64(pw(pw(2, n-1) - 1, k-j)) * int64(pw(2, int(v))) % Mod)\r\n\t\t\t\tans %= mod\r\n\t\t\t}\r\n\t\t\tfmt.Fprintln(writer, ans)\r\n\t\t}\r\n\t}\r\n}", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "8fb202ceedf8e6c4dff7abd06c72cbad", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\ntype ll int64\nfunc main() {\n\tin := os.Stdin\n\tout := os.Stdout\n\tconst mod ll = 1000000007\n\tvar t ll\n\tfmt.Fscan(in,&t)\n\tfor ;t>0; t--{\n\t\tvar n, k int\n\t\tfmt.Fscan(in,&n,&k)\n\t\tpow := [300005]ll{}\n\t\tpow[1]=1\n\t\tfor i:=2;i<=n;i++{\n\t\t\tpow[i] = (pow[i-1]*2)%mod\n\t\t}\n\t\tdp := [300005][2]ll{}\n\t\tvar m ll\n\t\tm=1\n\t\tdp[0][0]= m\n\t\tfor i:=1;i<=k;i++{\n\t\t\tif n%2==1{\n\t\t\t\tdp[i][0] = (dp[i-1][0] * (pow[n] + 1))%mod\n\t\t\t\tdp[i][1] = (dp[i-1][1] * pow[n] * 2)%mod\n\t\t\t}else if n%2==0{\n\t\t\t\tdp[i][0] = (dp[i-1][0] *(pow[n] -1))%mod\n\t\t\t\tdp[i][1] = (dp[i-1][0] + dp[i-1][1] * pow[n] * 2)%mod\n\t\t\t}\n\t\t}\n\t\tfmt.Fprintln(out,(dp[k][0]+dp[k][1])%mod)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "8617953f2ca62368206f605ddb9004f1", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b, cnt uint\n\tfor {\n\t\t_, err := fmt.Scanln(&n, &a, &b)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tif a > b {\n\t\t\ta, b = b, a\n\t\t}\n\t\tif (b & 1) > 0 {\n\t\t\tb++\n\t\t}\n\t\tres := b - a\n\t\tcnt = 1\n\t\tfor res > 1 {\n\t\t\ta = (a + 1) >> 1\n\t\t\tb = (b + 1) >> 1\n\t\t\tif (b & 1) > 0 {\n\t\t\t\tb++\n\t\t\t}\n\t\t\tres = b - a\n\t\t\tcnt++\n\t\t}\n\t\tif n == (1 << cnt) {\n\t\t\tfmt.Println(\"Final!\")\n\t\t} else {\n\t\t\tfmt.Println(cnt)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "0dc9dc7104f387a49cccb5bd9794bb91", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n N := io.NextInt()\n\tA := io.NextInt()\n\tB := io.NextInt()\n\t\n\trounds := 0\n\trem := N\n\tfor rem > 1 {\n\t rounds++\n\t rem >>= 1\n\t}\n\t\n\tteams := make([]int, 0)\n\tfor i := 1; i <= N; i++ {\n\t teams = append(teams, i)\n\t}\n\t\n\twhich := -1\n\tfor r := 1; which < 0; r++ {\n\t next := make([]int, 0)\n\t for i := 0; i < len(teams); i += 2 {\n\t if isOr(A, teams[i], teams[i + 1]) && isOr(B, teams[i], teams[i + 1]) {\n\t which = r\n\t break\n\t }\n\t if isOr(A, teams[i], teams[i + 1]) {\n\t next = append(next, A)\n\t } else if isOr(B, teams[i], teams[i + 1]) {\n\t next = append(next, B)\n\t } else {\n\t next = append(next, teams[i])\n\t }\n\t }\n\t teams = next\n\t}\n\t\n\tif which == rounds {\n\t io.Println(\"Final!\")\n\t} else {\n\t io.Println(which)\n\t}\n}\n\nfunc isOr(x, a, b int) bool {\n return x == a || x == b\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "363cdafbb0856ff3bd4c7fa4e3bc24ff", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc getNext(x int64) int64 {\n //fmt.Fprintf(os.Stderr, \"in: %d\\n\", x)\n digits := []int64{}\n for x != 0 {\n digits = append(digits, x%10)\n x /= 10\n }\n carry := int64(0)\n resetIndex := -1\n for i, digit := range digits {\n if carry == 1 {\n digit++\n carry = 0\n }\n if digit <= 4 {\n if digit < 4 {\n resetIndex = i-1\n }\n digits[i] = 4\n } else if digit <= 7 {\n if digit < 7 {\n resetIndex = i-1\n }\n digits[i] = 7\n } else {\n digits[i] = 4\n resetIndex = i\n carry = 1\n }\n }\n if carry == 1 {\n digits = append(digits, 4)\n }\n for i := 0; i <= resetIndex; i++ {\n digits[i] = 4\n }\n base := int64(1)\n for _, digit := range digits {\n x += base*digit\n base *= 10\n }\n //fmt.Fprintf(os.Stderr, \" -> %d\\n\", x)\n return x\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n left, right := getI64(), getI64()\n total := int64(0)\n max := getNext(right)\n current := left-1\n for {\n next := getNext(current+1)\n if next == max {\n total += (right-current)*next\n break\n }\n total += (next-current)*next\n current = next\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", total))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "221288a783b16eda2cca14a6002d57d6", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 121A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a, b int64) int64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc main() {\n\tvar a [15]int64\n\tvar i, l, r, x, j, n1, n2 int64\n\tx, j = 0, 1\n\tfmt.Scan(&l, &r)\n\tfor i = 0; i <= 10; i++ {\n\t\ta[i] = 0\n\t}\n\tfor j <= r {\n\t\ti = 10\n\t\ta[i]++\n\t\tfor a[i] > 2 {\n\t\t\ta[i] = 0\n\t\t\ti--\n\t\t\ta[i]++\n\t\t}\n\t\tj = 0\n\t\tfor i = 1; i <= 10; i++ {\n\t\t\tif j > 0 && a[i] == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif a[i] == 1 {\n\t\t\t\tn1 = 4\n\t\t\t} else {\n\t\t\t\tn1 = 0\n\t\t\t}\n\t\t\tif a[i] == 2 {\n\t\t\t\tn2 = 7\n\t\t\t} else {\n\t\t\t\tn2 = 0\n\t\t\t}\n\t\t\tj = j*10 + n1 + n2\n\t\t}\n\t\tif x == 0 && j >= l {\n\t\t\tx += j\n\t\t}\n\t\tif i <= 10 {\n\t\t\tcontinue\n\t\t}\n\t\tif j >= l {\n\t\t\tx += (min(j, r) - l) * j\n\t\t\tl = j\n\t\t}\n\t}\n\tfmt.Print(x)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a6e1cef24b2610d702cc6a1b1e779977", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar n int32\nvar a int32\nvar b int32\n\nfunc ReadData() {\n fmt.Scan(&n);\n fmt.Scan(&a);\n fmt.Scan(&b);\n}\n\nfunc Solve(na int32, nb int32, current int32, dbg bool) int {\n if na == 0 && nb == 0 {\n return 0;\n }\n\n var r0 int = 10000;\n var r1 int = 10000;\n var r2 int = 10000;\n var mode int = 4;\n\n if 0 < na && a <= current {\n r0 = Solve(na - 1, nb, current - a, false);\n }\n if 0 < nb && b <= current {\n r1 = Solve(na, nb - 1, current - b, false);\n }\n if current != n {\n r2 = 1 + Solve(na, nb, n, false);\n }\n\n result := r0\n mode = 0\n if r1 < result {\n result = r1\n mode = 1\n }\n if r2 < result {\n result = r2\n mode = 2\n }\n\n if dbg {\n if mode == 0 {\n Solve(na - 1, nb, current - a, true);\n } else if mode == 1 {\n Solve(na, nb - 1, current - b, true);\n } else if mode == 2 {\n r2 = 1 + Solve(na, nb, n, true);\n }\n fmt.Println(\"na: \", na, \" nb: \", nb, \" current: \", current, \" result: \", result, \" mode: \", mode)\n }\n return result\n}\n\nfunc main() {\n ReadData();\n fmt.Println(Solve(4, 2, 0, false));\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "3d7f89d30830bdc7de58107599b4ee8d", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//80B\npackage main\nimport \"fmt\"\n\nfunc main() {\n\tvar mm, k, l, m, n, o float32\n\tvar hh, jam int\n\tfmt.Scanf(\"%d:%f\", &hh, &mm)\n\tjam=hh%12\n\tif jam!=12 {\n\t\tk=360*float32(jam)/12\n\t} else {\n\t\tk=0\n\t}\n\tif n!=60 {\n\t\to=30*mm/60\n\t\tl=360*mm/60\n\t} else {\n\t\tk=0\n\t\tl=0\n\t}\n\tm=k+o\n\tif m==0 && l==0 {\n\t\tfmt.Printf(\"%.0f %.0f\\n\", m, l)\n\t} else {\n\t\tfmt.Printf(\"%.1f %.1f\\n\", m, l)\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "a94e3f1a4dba0feefb94490b21a4abc0", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n \"math\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n n := getI64()\n d2 := n*n\n\n if n == 0 {\n writer.WriteString(\"1\\n\")\n return\n }\n\n result := 0\n if n > 0 {\n result += 4\n }\n if n > 1 {\n x := int64(float64(n)/math.Sqrt(2))\n if (x+1)*(x+1) + x*x > d2 {\n result += 4\n }\n }\n\n x, y := n, int64(0)\n for true {\n y++\n for x*x + y*y > d2 {\n x--\n }\n if x <= y {\n break\n }\n result += 8\n }\n\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["geometry"], "code_uid": "a27634eaf134f8267b8a283bad08b702", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, h, m int\n\tfmt.Scanf(\"%d\\n\", &x)\n\tfmt.Scanf(\"%d %d\\n\", &h, &m)\n\n\ty := 0\n\tfor m%10 != 7 && m != 7 && h != 7 && h !=17 {\n\t\tif m < x {\n\t\t\tm += 60\n\t\t\th--\n\t\t}\n\t\tif h<0 {\n\t\t\th += 24\n\t\t}\n\t\tm -= x\n\t\ty++\n\t}\n\tfmt.Println(y)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "5604460c6415d8ea73a37641a00956ae", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"bufio\"\nimport \"os\"\nimport \"strings\"\nimport \"strconv\"\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc PrintInts(ints ...int) {\n for _, value := range ints {\n writer.WriteString(strconv.Itoa(value))\n writer.WriteByte(' ')\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\tvar x, h, m, result int = ReadInt32(), ReadInt32(), ReadInt32(), 0\n\tfor !strings.Contains(strings.Join([]string {strconv.Itoa(h), strconv.Itoa(m)}, \"\"), \"7\") {\n\t\tresult++\n\t\tm -= x\n\t\tif m < 0 {\n\t\t\tm += 60\n\t\t\th -= 1\n\t\t\tif (h < 0) {\n\t\t\t\th += 24\n\t\t\t}\n\t\t}\n\t}\n\tPrintInts(result)\n\twriter.WriteByte('\\n')\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "f4dcb524940c764af90192fa8a7b0c80", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nvar notes = []string{ \"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\",\n \"A\", \"B\", \"H\" }\n\nfunc position(a string) int {\n for i := 0; i < 12; i++ {\n if notes[i] == a {\n return i\n }\n }\n return -1\n}\n\nfunc distance(a, b string) int {\n i, j := position(a), position(b)\n if i <= j {\n return j-i\n } else {\n return 12+j-i\n }\n return -1\n}\n\nfunc kind(a, b, c string) string {\n x, y := distance(a, b), distance(b, c)\n if x == 4 && y == 3 {\n return \"major\"\n } else if x == 3 && y == 4 {\n return \"minor\"\n }\n return \"strange\"\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n x, y, z := getS(), getS(), getS()\n permutations := [][]string{\n []string{ x, y, z },\n []string{ x, z, y },\n []string{ y, x, z },\n []string{ y, z, x },\n []string{ z, x, y },\n []string{ z, y, x },\n }\n for _, p := range permutations {\n s := kind(p[0], p[1], p[2])\n if s != \"strange\" {\n writer.WriteString(fmt.Sprintf(\"%s\\n\", s))\n return\n }\n }\n writer.WriteString(\"strange\\n\")\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "b8e288b87132947ecaa12a3bf5607571", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n n, m := getI(), getI()\n x, y := 2 * n, 3 * m\n d := 0\n if x < y {\n d = x / 6\n } else {\n d = y / 6\n }\n \n for d > 0 {\n d--\n if x <= y {\n x += 2\n if x % 3 == 0 && x <= y {\n x += 2\n }\n } else {\n y += 3\n if y % 2 == 1 {\n continue\n }\n if y > x {\n continue\n }\n if y == x {\n y -= 3\n x += 2\n continue\n }\n y += 3\n }\n }\n\n result := x\n if y > x {\n result = y\n }\n\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory", "brute force"], "code_uid": "97d45d19fb8db463822681d6b413da93", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n,m,t int64\n\tt = 0\n\tfmt.Scanf(\"%d %d\\n\",&n,&m)\n\tfor ;;t++ {\n\t\tif n<=t/2 && m<=t/3 && n+m<=t/2+t/3-t/6{\n\t\t\tfmt.Println(t)\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory", "brute force"], "code_uid": "17fa6115eea66841df1568be983b0201", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\t//input := bufio.NewScanner(os.Stdin)\n\tvar a, b, c, n int\n\tfmt.Scanf(\"%d%d%d%d\", &a, &b, &c, &n)\n\n\tif n-a-b+c < 1 || c > a || c > b || a > n || b > n {\n\t\tfmt.Printf(\"-1\\n\")\n\t} else {\n\t\tfmt.Printf(\"%d\\n\", n-a-b+c)\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "dac60f392ed48b8e3a87643bcaad802e", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar A, B, C, D int\n\tfmt.Scan(&A, &B, &C, &D)\n\tA -= C\n\tB -= C\n\tD -= C\n\tD -= (A + B)\n\t// fmt.Printf(\"A:%d B:%d C:%d D:%d\\n\", A, B, C, D)\n\tif A < 0 || B < 0 || D < 1 {\n\t\tD = -1\n\t}\n\tfmt.Println(D)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "323a0941340be77e8759e2ce62fd5968", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d\\n%d\\n\", &n, &m)\n\ta := make([]int, 0, n)\n\tvar ai int\n\tmaxAi := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\\n\", &ai)\n\t\ta = append(a, ai)\n\t\tif maxAi < ai {\n\t\t\tmaxAi = ai\n\t\t}\n\t}\n\tcomplement := 0\n\tfor _, ai = range a {\n\t\tcomplement += maxAi - ai\n\t}\n\n\tif m > complement {\n\t\trest := m - complement\n\t\tavg := rest / n\n\t\tremainder := rest % n\n\t\tif remainder == 0 {\n\t\t\tfmt.Println(maxAi+avg, maxAi+m)\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(maxAi+avg+1, maxAi+m)\n\t\treturn\n\t}\n\tfmt.Println(maxAi, maxAi+m)\n}\n", "lang_cluster": "Go", "tags": ["implementation", "binary search"], "code_uid": "d10786f802b760f6a003091acfbc596d", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nfunc main() {\n\tvar n int\n\tvar k int\n\tvar a int\n\t\n\tfmt.Scanln(&n)\n\tfmt.Scanln(&k)\n\t\n\tmini := k\n\tmaxi := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanln(&a)\n\t\tmini = mini + a\n\t\tmaxi = int(math.Max(float64(maxi), float64(a)))\n\t}\n\t\n\tmini = int(math.Max(math.Ceil(float64(mini) / float64(n)), float64(maxi)))\n\tmaxi = maxi + k\n\t\n\tfmt.Println(mini, maxi)\n}", "lang_cluster": "Go", "tags": ["implementation", "binary search"], "code_uid": "3551af07eedd9e2c9dfe77b1c5ab8fc9", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar\twriter *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc ceilDiv(i, div int64) int64 {\n if div == 0 {\n return 0 // should not happen\n }\n if i % div == 0 {\n return i / div\n }\n return (i / div) + 1\n}\n\nfunc max(i, j int64) int64 {\n if i > j {\n return i\n }\n return j\n}\n\nfunc main() {\n defer writer.Flush()\n var n, m int64\n scanf(\"%d\\n\", &n)\n scanf(\"%d\\n\", &m)\n total := m\n maxSoFar := int64(0)\n for i := int64(0); i < n; i++ {\n var i int64\n scanf(\"%d\\n\", &i)\n total += i\n maxSoFar = max(maxSoFar, i)\n }\n minK := max(ceilDiv(total, n), maxSoFar)\n maxK := maxSoFar + m\n printf(\"%d %d\", minK, maxK)\n}\n", "lang_cluster": "Go", "tags": ["implementation", "binary search"], "code_uid": "3fa379f68013265e24f65d9e4b1f906d", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nfunc main() {\n\tn, k := 0, 0\n\tfmt.Scanf(\"%d %d\\n\", &n, &k)\n\tv := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &v[i])\n\t}\n\tans := 0\n\tfor i := 0; i < k; i++ {\n\t\tones, twos := 0, 0\n\t\tfor j := i; j < n; j += k {\n\t\t\tif v[j] == 1 {\n\t\t\t\tones++\n\t\t\t} else {\n\t\t\t\ttwos++\n\t\t\t}\n\t\t}\n\t\tans += int(math.Min(float64(ones), float64(twos)))\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "51aea82a9bfe8b4fa5072d99a1ed95d4", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"sort\"\n\t//\"unicode/utf8\"\n)\nfunc main() {\n\tvar n,k,x int\n\tfmt.Scan(&n,&k)\n\tvar c [334][7]int\n\tfor i:=0;i Y {\n\t\tfmt.Println(\">\")\n\t} else {\n\t\tfmt.Println(\"<\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "95ee72d8c8351244c93049642bd11649", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc intPow(x int64, y int64) (res int64) {\n\tres = 1\n\tfor i := int64(0); i < y; i++ {\n\t\tres *= x\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar n, x, y, numx, numy, t int64\n\tfmt.Scan(&n, &x)\n\tnumx = 0\n\tfor i := int64(1); i <= n; i++ {\n\t\tfmt.Scan(&t)\n\t\tnumx += t * intPow(x, (n-i))\n\t}\n\tfmt.Scan(&n, &y)\n\tnumy = 0\n\tfor i := int64(1); i <= n; i++ {\n\t\tfmt.Scan(&t)\n\t\tnumy += t * intPow(y, (n-i))\n\t}\n\n\tif numx == numy {\n\t\tfmt.Println(\"=\")\n\t} else if numx < numy {\n\t\tfmt.Println(\"<\")\n\t} else {\n\t\tfmt.Println(\">\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "031c9f4350ce2c1681f58544d02e49d9", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, bx int\n\tfmt.Scan(&n, &bx)\n\n\tvar x, dx uint64\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&dx)\n\t\tx = x*uint64(bx) + dx\n\t}\n\n\tvar m, by int\n\tfmt.Scan(&m, &by)\n\n\tvar y, dy uint64\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scan(&dy)\n\t\ty = y*uint64(by) + dy\n\t}\n\n\tif x < y {\n\t\tfmt.Println(\"<\")\n\t} else if x > y {\n\t\tfmt.Println(\">\")\n\t} else {\n\t\tfmt.Println(\"=\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "966c700aa9688e401e94c43ef793a662", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"os\"\n)\n\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\nvar MOD int64\n\n\nfunc pow(x, p int64) int64 {\n\tvar ret int64 = 1\n\tfor p > 0 {\n\t\tif p % 2 == 1 {\n\t\t\tret = ret * x % MOD\n\t\t}\n\t\tx = x * x % MOD\n\t\tp >>= 1\n\t}\n\treturn ret\n}\n\nfunc powM(a [][]int64, p int64) [][]int64 {\n\tret := make([][]int64, 2)\n\tfor i := 0; i < 2; i++ {\n\t\tret[i] = make([]int64, 2)\n\t\tret[i][i] = 1\n\t}\n\tfor p > 0 {\n\t\tif p % 2 == 1 {\n\t\t\tret = mult(ret, a)\n\t\t}\n\t\ta = mult(a, a)\n\t\tp >>= 1\n\t}\n\treturn ret\n}\n\nfunc mult(a, b [][]int64) [][]int64 {\n\tc := make([][]int64, 2)\n\tfor i := 0; i < 2; i++ {\n\t\tc[i] = make([]int64, 2)\n\t}\n\tfor i := 0; i < 2; i++ {\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tfor k := 0; k < 2; k++ {\n\t\t\t\tc[i][j] += a[i][k] * b[k][j] % MOD\n\t\t\t}\n\t\t}\n\t}\n\treturn c\n}\n\nfunc main() {\n\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\tvar n, k int64 = NextInt64(), NextInt64()\n\tvar l int = NextInt()\n\tMOD = NextInt64()\n\n\tif l < 63 && 1 << uint(l) <= k {\n\t\tfmt.Fprintln(out, 0)\n\t\treturn\n\t}\n\n\tif l == 0 {\n\t\tif k == 0 {\n\t\t\tfmt.Fprintln(out, 1 % MOD)\n\t\t}else {\n\t\t\tfmt.Fprintln(out, 0)\n\t\t}\n\t\treturn\n\t}\n\n\ta := make([][]int64, 2)\n\tfor i := 0; i < 2; i++ {\n\t\ta[i] = make([]int64, 2)\n\t}\n\ta[0][1], a[1][0], a[1][1] = 1, 1, 1\n\ta = powM(a, n - 2)\n\tvar dp int64 = (2 * a[0][1] + 3 * a[1][1]) % MOD\n\tvar two int64 = pow(int64(2), n)\n\tvar ret int64 = 1\n\tfor i := 0; i < l; i++ {\n\t\tif ((k >> uint(i)) & 1) == 0 {\n\t\t\tret = ret * dp % MOD\n\t\t}else {\n\t\t\tret = ret * (two - dp + MOD) % MOD\n\t\t}\n\t}\n\n\tfmt.Fprintln(out, ret)\n}\n\nfunc Next() string{\n\tif !in.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn in.Text()\n}\n\nfunc NextInt64() int64 {\n\tret, _ := strconv.ParseInt(Next(), 10, 64)\n\treturn ret\n}\n\nfunc NextInt() int{\n\tret, _ := strconv.Atoi(Next())\n\treturn ret\n}", "lang_cluster": "Go", "tags": ["math", "combinatorics", "matrices", "implementation", "number theory"], "code_uid": "6ca3d152b5b28e68822de10a2e385d38", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\nfunc main() {\n\tvar k,l,x int\n\tvar s string\n\tinput := bufio.NewScanner(os.Stdin)\n\tinput.Split(bufio.ScanWords)\n\tinput.Scan()\n\ts=input.Text()\n\tinput.Scan()\n\tbb,_:=strconv.Atoi(input.Text())\n\tk=bb\n\tr:=make([]rune,len(s))\n\tvar swap rune\n\tfor i,v:=range s {\n\t\tr[i]=v\n\t}\n\tl= len(s)\n\tfor i:=0;ir[x] && j-i<=k {\n\t\t\t\tx=j\n\t\t\t}\n\t\t}\n\t\tfor j:=x;j>i;j-- {\n\t\t\tswap = r[j]\n\t\t\tr[j]=r[j-1]\n\t\t\tr[j-1]=swap\n\t\t}\n\t\tk-=x-i\n\t}\n\tfmt.Println(string(r))\n}\n\n\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "cbe7de3e2ff605d68af8b8cc4ed2df6d", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// INCOMPLETE\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tN := io.NextLong()\n\tK := io.NextLong()\n\t\n\tif K >= 1024 {\n\t io.Println(\"No\")\n\t return\n\t}\n\t\n\tfor i := int64(1); i <= K; i++ {\n\t if (N + 1) % i != 0 {\n\t io.Println(\"No\")\n\t return\n\t }\n\t}\n\tio.Println(\"Yes\")\n}\n\nfunc smallestDivisor(n int64) int64 {\n if n % 2 == 0 {\n return 2\n }\n for d := int64(3); d * d <= n; d += 2 {\n if n % d == 0 {\n return d\n }\n }\n return n\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}", "lang_cluster": "Go", "tags": ["brute force", "number theory"], "code_uid": "cc715248590caa2cd4b3fe54ba7991b9", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport . \"fmt\"\n\ntype vec struct {\n\tx, y int64\n}\n\nfunc (a vec) less(b vec) bool { return a.x < b.x || a.x == b.x && a.y < b.y }\nfunc (a vec) sub(b vec) vec { return vec{a.x - b.x, a.y - b.y} }\nfunc (a vec) dot(b vec) int64 { return a.x*b.x + a.y*b.y }\nfunc isOrthogonal(a, b, c vec) bool { return a.sub(b).dot(c.sub(b)) == 0 }\nfunc isRectangle(a, b, c, d vec) bool { return isOrthogonal(a, b, c) && isOrthogonal(b, c, d) && isOrthogonal(c, d, a) }\nfunc isRectangleAnyOrder(a, b, c, d vec) bool { return isRectangle(a, b, c, d) || isRectangle(a, b, d, c) || isRectangle(a, c, b, d) }\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tmp := map[vec]int{}\n\tshown := map[vec]int{}\n\tfor i := 0; i < 4; i++ {\n\t\tvar x, y int64\n\t\tScan(&x, &y)\n\t\tp0 := vec{x, y}\n\t\tScan(&x, &y)\n\t\tp1 := vec{x, y}\n\t\tif v := p1.sub(p0); v.x != 0 && v.y != 0 {\n\t\t\tPrint(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tmp[p0]++\n\t\tmp[p1]++\n\t\tif p1.less(p0) {\n\t\t\tp0, p1 = p1, p0\n\t\t}\n\t\tshown[p1.sub(p0)]++\n\t}\n\tfor _, v := range shown {\n\t\tif v != 2 {\n\t\t\tPrint(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tarr := []vec{}\n\tfor vec, v := range mp {\n\t\tif v != 2 {\n\t\t\tPrint(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tarr = append(arr, vec)\n\t}\n\tif isRectangleAnyOrder(arr[0], arr[1], arr[2], arr[3]) {\n\t\tPrint(\"YES\")\n\t} else {\n\t\tPrint(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms", "math", "implementation", "geometry"], "code_uid": "3d1ab04730d83353b78100d6d2b652a1", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tans := 2 * (n / 3)\n\tif n%3 != 0 {\n\t\tans++\n\t}\n\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "912a43988111f77deff6750bd0f90593", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var i int\n fmt.Scan(&i)\n switch {\n case i <= 2:\n fmt.Println(1)\n case i % 3 == 0:\n fmt.Println(i / 3 * 2)\n case i % 3 != 0:\n fmt.Println(i / 3 * 2 + 1)\n }\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "aee29743d0cf3683d1f52d856773dd29", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n \nfunc main() {\n in := bufio.NewReader(os.Stdin)\n out := bufio.NewWriter(os.Stdout)\n defer out.Flush()\n tot := 0\n fmt.Fscan(in, &tot)\n times := (tot/3)*2\n if tot % 3 > 0 {times++}\n fmt.Fprint(out, times)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "4f8dddc2bf0cbaad13d58f8083a0b37b", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\tvar s string\n\tfmt.Fscanf(reader, \"%s\", &s)\n\tcount, ans := 1, 0\n\tfor i := 1; i < len(s); i++ {\n\t\tif s[i] == s[i-1] {\n\t\t\tcount++\n\t\t} else {\n\t\t\tcount, ans = 1, ans+1-(count%2)\n\t\t}\n\t}\n\tans = ans + 1 - (count % 2)\n\tfmt.Printf(\"%d\", ans)\n\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "implementation"], "code_uid": "c734b14b2be68e1f4c09d6cbd72009d9", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//http://codeforces.com/problemset/problem/391/A\n//A. Genetic Engineering\n// az osszes futamot figyelni kell\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tnd, i, run, ans int32\n\t\td string\n\t\tprev, akt byte\n\t)\n\n\tfmt.Scan(&d)\n\tnd = int32(len(d))\n\n\t//\tfmt.Println(d, nd)\n\n\tprev, run = d[0], 1\n\n\tfor i = 1; i < nd; i++ {\n\t\takt = d[i]\n\t\tif prev == akt {\n\t\t\trun++\n\t\t} else {\n\t\t\tif 0 == (run % 2) {\n\t\t\t\tans++\n\t\t\t}\n\t\t\tprev = akt\n\t\t\trun = 1\n\t\t}\n\t}\n\tif 0 == (run % 2) {\n\t\tans++\n\t}\n\n\tfmt.Println(ans)\n\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "implementation"], "code_uid": "22a3c79a9b153a958fd6ec75403e3f06", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//http://codeforces.com/problemset/problem/391/A\n//A. Genetic Engineering\n// az osszes futamot figyelni kell\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tnd, i, run, ans int32\n\t\td string\n\t\tprev, akt byte\n\t)\n\n\tfmt.Scan(&d)\n\tnd = int32(len(d))\n\n\t//\tfmt.Println(d, nd)\n\n\tprev, run = d[0], 1\n\n\tfor i = 1; i < nd; i++ {\n\t\takt = d[i]\n\t\tif prev == akt {\n\t\t\trun++\n\t\t} else {\n\t\t\tif 0 == (run % 2) {\n\t\t\t\tans++\n\t\t\t}\n\t\t\tprev = akt\n\t\t\trun = 1\n\t\t}\n\t}\n\tif 0 == (run % 2) {\n\t\tans++\n\t}\n\n\tfmt.Println(ans)\n\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "implementation"], "code_uid": "b54c98cbba3cc7bca49bc1ae6da1b141", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t// \"time\"\n)\n\nfunc main() {\n\t// defer func(start time.Time) {\n\t// \tfmt.Println(time.Since(start))\n\t// }(time.Now())\n\n\treader := bufio.NewReader(os.Stdin)\n\n\tvar s string\n\tfmt.Fscan(reader, &s)\n\tvar c uint8\n\tvar index, count int\n\n\t// fmt.Println(s)\n\tfor i:=0; i 0 {\n\t\t\tinputs := strings.Split(input, \" \")\n\t\t\tfor i := range inputs{\n\t\t\t\tstrs <- &inputs[i]\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc main(){\n\trs := bufio.NewReader(os.Stdin)\n\tws := bufio.NewWriter(os.Stdout)\n\n\tstrs := make(chan *string, 100)\n\n\tgo inputter(rs, strs)\n\n\tstr := strings.Split(*<-strs, \":\")\n\ta , _ := strconv.ParseInt(str[0], 10, 64)\n\tb , _ := strconv.ParseInt(str[1], 10, 64)\n\tc , _ := strconv.ParseInt(*<-strs, 10, 64)\n\n\tb += c\n\n\ta += b/60\n\tb %= 60\n\ta %= 24\n\n\tws.WriteString(fmt.Sprintf(\"%02d:%02d\", a, b))\n\tws.Flush()\n}\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0d8d55dc674acebf3093bb12c1dfce58", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\ntype vec struct{ x, y int64 }\n\nfunc (a vec) sub(b vec) vec { return vec{a.x - b.x, a.y - b.y} }\nfunc (a vec) dot(b vec) int64 { return a.x*b.x + a.y*b.y }\nfunc (a vec) det(b vec) int64 { return a.x*b.y - a.y*b.x }\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF617D(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tf := func(a, b, c vec) bool {\n\t\ta, b = b.sub(a), c.sub(a)\n\t\treturn (a.x == 0 || a.y == 0 || b.x == 0 || b.y == 0) && a.dot(b) <= 0\n\t}\n\tvar a, b, c vec\n\tFscan(in, &a.x, &a.y, &b.x, &b.y, &c.x, &c.y)\n\tif d := b.sub(a); (d.x == 0 || d.y == 0) && d.det(c.sub(b)) == 0 {\n\t\tFprint(out, 1)\n\t} else if f(a, b, c) || f(b, a, c) || f(c, a, b) {\n\t\tFprint(out, 2)\n\t} else {\n\t\tFprint(out, 3)\n\t}\n}\n\nfunc main() { CF617D(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "9a79b10fb68723a4ac258c6bb9b1c23f", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tdefer wr.Flush()\n\tsc.Split(bufio.ScanWords)\n\tfr := func() string {\n\t\tvar k, l string = readStr(), readStr()\n\t\tl = string(l[1]) + string(l[0])\n\t\tvar s string = k + l\n\t\tvar r string\n\t\tfor _, v := range s {\n\t\t\tif string(v) != \"X\" {\n\t\t\t\tr += string(v)\n\t\t\t}\n\t\t}\n\t\treturn r\n\t}\n\tfk := func(s string) string {\n\t\tfor string(s[0]) != \"A\" {\n\t\t\ts = string(s[1:]) + string(s[0])\n\t\t\t// fmt.Println(\"..\", s)\n\t\t}\n\t\treturn s\n\t}\n\tvar a, b string = fk(fr()), fk(fr())\n\t// fmt.Println(\"a\", a)\n\t// fmt.Println(\"b\", b)\n\tif a == b {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nvar (\n\tsc *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\twr *bufio.Writer = bufio.NewWriter(os.Stdout)\n)\n\nfunc readInt() int {\n\tsc.Scan()\n\tans, _ := strconv.Atoi(sc.Text())\n\treturn ans\n}\n\nfunc readInt64() int64 {\n\tsc.Scan()\n\tans, _ := strconv.ParseInt(sc.Text(), 10, 64)\n\treturn ans\n}\n\nfunc printInts(ints ...int) {\n\tfor _, v := range ints {\n\t\twr.WriteString(strconv.Itoa(v))\n\t\twr.WriteByte(' ')\n\t}\n}\nfunc printInt64s(ints ...int64) {\n\tfor _, v := range ints {\n\t\twr.WriteString(strconv.FormatInt(v, 10))\n\t\twr.WriteByte(' ')\n\t}\n}\n\nfunc readStr() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc println() {\n\twr.WriteByte('\\n')\n}\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "3fd601daa9b27965d4d50342bae3ad4d", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\tvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами\n\n\tscanner.Scan()\n\ts1 := scanner.Text()\n\tscanner.Scan()\n\ts11 := scanner.Text()\n\tscanner.Scan()\n\ts2 := scanner.Text()\n\tscanner.Scan()\n\ts22 := scanner.Text()\n\n\tse := make([]byte, 0, 3)\n\tsb := make([]byte, 0, 3)\n\tfor i := 0; i < 2; i++ {\n\t\tif s1[i] != 'X' {\n\t\t\tse = append(se, s1[i])\n\t\t}\n\t\tif s2[i] != 'X' {\n\t\t\tsb = append(sb, s2[i])\n\t\t}\n\t}\n\tfor i := 1; i >= 0; i-- {\n\t\tif s11[i] != 'X' {\n\t\t\tse = append(se, s11[i])\n\t\t}\n\t\tif s22[i] != 'X' {\n\t\t\tsb = append(sb, s22[i])\n\t\t}\n\t}\n\tec := 0\n\teb := 0\n\tgse := string(se)\n\tgsb := string(sb)\n\n\tif gse == \"ABC\" || gse == \"CAB\" || gse == \"BCA\" {\n\t\tec = 1\n\t}\n\tif gsb == \"ABC\" || gsb == \"CAB\" || gsb == \"BCA\" {\n\t\teb = 1\n\t}\n\tif ec == eb {\n\t\twriter.WriteString(\"YES\")\n\t} else {\n\t\twriter.WriteString(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "24b55cdaa36736a95d150048019c7339", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n // \"fmt\"\n \"strings\"\n)\n\nfunc ReadInt32(scanner *bufio.Scanner) int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString(scanner *bufio.Scanner) string {\n scanner.Scan()\n ans := scanner.Text()\n return ans\n}\n\nfunc PrintInt(writer *bufio.Writer, value int) {\n writer.WriteString(strconv.Itoa(value))\n writer.WriteByte(' ')\n}\n\nfunc PrintInts(writer *bufio.Writer, ints ...int) {\n for _, value := range ints {\n writer.WriteString(strconv.Itoa(value))\n writer.WriteByte(' ')\n }\n writer.WriteByte('\\n')\n}\n\nfunc ReadPazzle(scanner *bufio.Scanner) string {\n r1 := ReadString(scanner)\n r2 := ReadString(scanner)\n \n return r1 + r2[1:] + r2[0:1]\n}\n\nfunc Compare(p1, p2 string) bool {\n if p1 == p2 {\n return true\n }\n p1 = p1 + p1 + p1 + p1\n return strings.Contains(p1, p2)\n}\n\nfunc Shift(p string) string {\n l := len(p)\n\n p = p[l-2:l-1] + p[0:l-1]\n return p\n}\n\nfunc main() {\n var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n var writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n\n pz1 := ReadPazzle(scanner)\n pz2 := ReadPazzle(scanner)\n\n pz1 = strings.Replace(pz1, \"X\", \"\", 1)\n pz2 = strings.Replace(pz2, \"X\", \"\", 1)\n\n if Compare(pz1, pz2) {\n writer.WriteString(\"YES\")\n } else {\n writer.WriteString(\"NO\")\n }\n writer.WriteByte('\\n')\n // writer.WriteByte('\\n')\n}\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "55f8ccd76ef1f4634afb90c89addf914", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// A. Fingerprints\n/*\nYou are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.\n\nSome keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subsequence of the sequence you have that only contains digits with fingerprints on the corresponding keys. Find such code.\n\nInput\nThe first line contains two integers 𝑛 and 𝑚 (1≤𝑛,𝑚≤10) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints.\n\nThe next line contains 𝑛 distinct space-separated integers 𝑥1,𝑥2,…,𝑥𝑛 (0≤𝑥𝑖≤9) representing the sequence.\n\nThe next line contains 𝑚 distinct space-separated integers 𝑦1,𝑦2,…,𝑦𝑚 (0≤𝑦𝑖≤9) — the keys with fingerprints.\n\nOutput\nIn a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable.\n\nExamples\nInput\n7 3\n3 5 7 1 6 2 8\n1 2 7\n\nOutput\n7 1 2\n\nInput\n4 4\n3 4 1 0\n0 1 7 9\n\nOutput\n1 0\n\nNote\nIn the first example, the only digits with fingerprints are 1, 2 and 7. All three of them appear in the sequence you know, 7 first, then 1 and then 2. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.\n\nIn the second example digits 0, 1, 7 and 9 have fingerprints, however only 0 and 1 appear in the original sequence. 1 appears earlier, so the output is 1 0. Again, the order is important.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput1, _ := reader.ReadString('\\n')\n\tarr1 := strings.Split(strings.TrimSpace(input1), \" \")\n\n\t_, _ = strconv.Atoi(arr1[0])\n\t_, _ = strconv.Atoi(arr1[1])\n\n\tinput2, _ := reader.ReadString('\\n')\n\tnArr := strings.Split(strings.TrimSpace(input2), \" \")\n\n\tinput3, _ := reader.ReadString('\\n')\n\tmArr := strings.Split(strings.TrimSpace(input3), \" \")\n\n\tfor _, i := range nArr {\n\t\tfor _, j := range mArr {\n\t\t\tif i == j {\n\t\t\t\tfmt.Printf(\"%v \", i)\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5910f9a1957f109b455e9f84f5b656c9", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN, _ := sc.NextInt(), sc.NextInt()\n\tx := sc.NextIntArray()\n\ty := sc.NextMap()\n\tp := 0\n\tvar ans []int\n\tfor i := 0; i < N; i++ {\n\t\tif _, ok := y[x[i]]; ok {\n\t\t\tans = append(ans, x[i])\n\t\t\tp++\n\t\t}\n\t}\n\tPrintI(ans...)\n}\n\nfunc mapToString(arr []int) []string {\n\tret := make([]string, len(arr))\n\tfor i := 0; i < len(arr); i++ {\n\t\tret[i] = strconv.Itoa(arr[i])\n\t}\n\treturn ret\n}\n\nfunc PrintI(args ...int) {\n\tfmt.Println(strings.Join(mapToString(args), \" \"))\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "bd2ae1d62cc1a5f0cf27d7225ed11424", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x, y []int) (res []int) {\n\tn := make(map[int]bool)\n\tfor _, v := range y {\n\t\tn[v] = true\n\t}\n\n\tfor _, v := range x {\n\t\t_, ok := n[v]\n\t\tif ok {\n\t\t\tres = append(res, v)\n\t\t}\n\t}\n\n\treturn\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\n\tx := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&x[i])\n\t}\n\n\ty := make([]int, m)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scan(&y[i])\n\t}\n\n\tres := solve(x, y)\n\tfor _, v := range res {\n\t\tfmt.Printf(\"%d \", v)\n\t}\n\n\t// {\n\t// \tx := []int{3, 5, 7, 1, 6, 2, 8}\n\t// \ty := []int{1, 2, 7}\n\t// \tfmt.Println(solve(x, y))\n\t// }\n\n\t// {\n\t// \tx := []int{3, 4, 1, 0}\n\t// \ty := []int{0, 1, 7, 9}\n\t// \tfmt.Println(solve(x, y))\n\t// }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "93ed34fbe7170e389e31681c96bbff56", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar w, h, k int\n\n\tfmt.Scanf(\"%d %d %d\", &w, &h, &k)\n\n\tr := 0\n\tfor i := 0; i < k; i++ {\n\t\tc := 2*(w+h) - 4\n\t\tr += c\n\t\th -= 4\n\t\tw -= 4\n\t}\n\n\tfmt.Println(r)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "6c8316b7801f7633f7e74acd318e3989", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar w, h, k int\n\tfmt.Scanln(&w, &h, &k)\n\n\tvar result int\n\n\tfor i:= 1; i <= k; i++ {\n\t\twx := w - 4 * (i - 1)\n\t\thx := h - 4 * (i - 1)\n\n\t\tresult += calculateGoldForSquare(wx, hx)\n\t}\n\n\tfmt.Println(result)\n}\n\nfunc calculateGoldForSquare(w, h int) int{\n\treturn 2 * w + 2 * (h - 2)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "bcf10d993c901724bb59aceeb4db4017", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, k int\n\tfmt.Scanf(\"%d %d %d\", &n, &m, &k)\n\tans := 2 * (n + m - 2) * k - 16 * k * (k - 1) / 2\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "1b4f861ac2c90fb8ff360fe5338d1c5a", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"math/cmplx\"\n\t\"os\"\n)\n\nconst (\n\tEPS = 1e-8\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n)\n\ntype Light struct {\n\tp complex128\n\ta float64\n}\n\ntype Line struct {\n\tp1, p2 complex128\n}\n\nfunc CrossProduct(a complex128, b complex128) float64 {\n\treturn real(a)*imag(b) - real(b)*imag(a)\n}\n\nfunc Roatate(x complex128, a float64) complex128 {\n\tr, t := cmplx.Polar(x)\n\treturn cmplx.Rect(r, t+a)\n}\n\nfunc Intersact(a Line, b Line) (intersaction complex128, isIntersact bool) {\n\ts1 := CrossProduct(a.p2-a.p1, b.p1-a.p1)\n\ts2 := CrossProduct(a.p2-a.p1, b.p2-a.p1)\n\tif math.Abs(s2-s1) >= EPS {\n\t\tisIntersact = true\n\t\tintersaction = complex(real(b.p1)*s2-real(b.p2)*s1, imag(b.p1)*s2-imag(b.p2)*s1) / complex(s2-s1, 0.0)\n\t}\n\treturn\n}\n\nfunc foo(l float64, lit Light, r float64) float64 {\n\tv1 := complex(l-real(lit.p), 0-imag(lit.p))\n\tv2 := Roatate(v1, lit.a)\n\tif imag(v2) > -EPS {\n\t\treturn r\n\t}\n\n\tp1 := complex(0.0, 0.0)\n\tp2 := complex(100.0, 0.0)\n\tinter, _ := Intersact(Line{lit.p, lit.p + v2}, Line{p1, p2})\n\treturn real(inter)\n}\n\nfunc main() {\n\tvar (\n\t\tn int\n\t\tl, r float64\n\t\tlits []Light\n\t)\n\n\tfmt.Fscan(reader, &n, &l, &r)\n\tfor i := 0; i < n; i++ {\n\t\tvar x, y, a float64\n\t\tfmt.Fscan(reader, &x, &y, &a)\n\t\tlits = append(lits, Light{complex(x, y), a * math.Pi / 180.0})\n\t}\n\n\tf := make([]float64, 1< f[k] {\n\t\t\t\t\tf[k] = cur\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(math.Min(f[(1< 9 || b > 9 || c > 9 || d > 9 || a + b != r1 || c + d != r2 || a + c != c1 || b + d != c2 || a + d != d1 || b + c != d2 || a == b || a == c || a == d || b == c || b == d || c == d {\n\t\tw.WriteString(\"-1\\n\")\n\t\tw.Flush()\n\t} else {\n\t\tw.WriteString(strconv.Itoa(a)+\" \"+strconv.Itoa(b)+\"\\n\")\n\t\tw.Flush()\n\t\tw.WriteString(strconv.Itoa(c)+\" \"+strconv.Itoa(d)+\"\\n\")\n\t\tw.Flush()\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "261cfc9cb18a7c3c43bc4d8107638f72", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var r1,r2,c1,c2,d1,d2 int\n fmt.Scan(&r1,&r2,&c1,&c2,&d1,&d2)\n b := (d2+r1-c1)/2\n c := d2-b\n a := r1-b\n d := c2-b\n f := func(n int) bool {\n if (n >= 1) && (n <= 9) { return true }\n return false\n }\n if (a != b) && (a != c) && (a != d) && (b != c) && (b != d) && (c != d) && f(a) && f(b) && f(c) && f(d) &&\n (a+b == r1) && (a+c == c1) && (c+d == r2) && (b+d == c2) && (a+d == d1) && (b+c == d2) {\n fmt.Println(a,b)\n fmt.Println(c,d)\n } else {\n fmt.Println(-1)\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "5558c092706614d49b5a433db9a2de04", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 143A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar r1, r2, c1, c2, d1, d2 int\n\tfmt.Scan(&r1, &r2, &c1, &c2, &d1, &d2)\n\ta := (c1 + d1 - r2) / 2\n\tb := r1 - a\n\tc := (c1 - d1 + r2) / 2\n\td := r2 - c\n\tif a <= 0 || b <= 0 || c <= 0 || d <= 0 || a == b || b == c || c == d || a == d || b == d || a == c || a > 9 || b > 9 || c > 9 || d > 9 {\n\t\tfmt.Println(\"-1\")\n\t} else {\n\t\tfmt.Printf(\"%d %d\\n\", a, b)\n\t\tfmt.Printf(\"%d %d\\n\", c, d)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "0cc3e44492b7cc72dc83327e639e6ac1", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfor i := 1; ; i++ {\n\t\tif i*i >= n {\n\t\t\tfmt.Println(4 * i)\n\t\t\treturn\n\t\t}\n\t\tif i*(i+1) >= n {\n\t\t\tfmt.Println(4*i + 2)\n\t\t\treturn\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "3381431a383d4b80f75f79c613b66222", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar (\n n, a, b int\n)\n\nfunc main() {\n fmt.Scan(&n)\n a , b = 1, 1\n for a * b < n {\n a++\n if a > b {\n a, b = b, a\n }\n }\n fmt.Println(2*(a+b))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "f54ac5c2085a4124ee923c2ce0204317", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\tvar n, m, k int\n\tfmt.Fscanf(bufin, \"%d %d %d\\n\", &n, &m, &k)\n\tp := 2 * m\n\tlane := (k + p - 1) / p\n\tk -= p * (lane - 1)\n\tdesk := (k + 1) / 2\n\tpos := 'L'\n\tif k%2 == 0 {\n\t\tpos = 'R'\n\t}\n\tfmt.Fprintf(bufout, \"%d %d %c\\n\", lane, desk, pos)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "7c16605c9a0fea6736078017c5233113", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\treadInt()\n\tm := readInt()\n\tk := readInt() - 1\n\n\tcolumn := (k) / (m * 2)\n\trow := (k % (m * 2)) / 2\n\trow1 := (k % (m * 2)) % 2\n\tfmt.Printf(\"%d \", column+1)\n\tfmt.Printf(\"%d \", row+1)\n\tif row1 == 0 {\n\t\tfmt.Println(\"L\")\n\t} else {\n\t\tfmt.Println(\"R\")\n\t}\n}\n\nfunc getStats(str string) map[byte]int {\n\tstat := map[byte]int{}\n\tfor _, v := range str {\n\t\tstat[byte(v)]++\n\t}\n\treturn stat\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "6a2161cca6d2d597e4ef53f99c15116d", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := readUint64() * uint64(10000000000000)\n\tb := readUint64()\n\tc := readUint()\n\n\tbase := 0\n\tfor base < 1000 {\n\t\td := a / b\n\t\tfor i, ch := range fmt.Sprintf(\"%013v\", d) {\n\t\t\tv := ch - '0'\n\t\t\tif uint(v) == c {\n\t\t\t\tfmt.Println(base + i + 1)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\ta = (a % b) * uint64(10000000000000)\n\t\tbase += 13\n\t}\n\tfmt.Println(\"-1\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readUint() uint {\n\tval, _ := strconv.ParseUint(readString(), 10, 32)\n\treturn uint(val)\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readUint64() uint64 {\n\tval, _ := strconv.ParseUint(readString(), 10, 64)\n\treturn val\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "ea542f3c2877bffc3f8c6c614ebe8353", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/900/B\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, c int\n)\n\nfunc main() {\n\ta, b, c = ReadInt3()\n\ta *= 10\n\tfor i := 1; i <= 100000; i++ {\n\t\tq := a / b\n\t\tif q == c {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\n\t\ta -= b * q\n\t\ta *= 10\n\t}\n\tfmt.Println(-1)\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "106160af3735a1adf760518eee32ed69", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner\nvar t[1e6+1] bool;\n\nfunc init_scanner() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024*1024*20\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tscanner.Scan()\n\tval, _ := strconv.Atoi(scanner.Text())\n\treturn val\n}\n\nfunc main() {\n\tinit_scanner()\n\ta, b, c := readInt(), readInt(), readInt()\n\tfor i := 0; ; i++ {\n\t\ta *= 10\n\t\td := a/b\n\t\tif d == c {\n\t\t\tfmt.Println(i+1)\n\t\t\treturn\n\t\t}\n\t\tif t[a] {\n\t\t\tbreak\n\t\t}\n\t\tt[a] = true\n\t\ta %= b\n\t}\n\tfmt.Println(-1)\n}", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "801f3ef879e754a7fff1b1c07800b5ec", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*********************************************************************************\n* File Name : D.go\n* Created By : YIMMON, yimmon.zhuang@gmail.com\n* Creation Date : [2014-03-11 10:57]\n* Last Modified : [2014-03-11 11:20]\n* Description :\n**********************************************************************************/\n\npackage main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"sort\"\n \"strconv\"\n)\n\ntype Num []int\n\nfunc (self Num) Len() int { return len(self) }\nfunc (self Num) Less(i, j int) bool { return self[i] < self[j] }\nfunc (self Num) Swap(i, j int) { self[i], self[j] = self[j], self[i] }\n\nfunc main() {\n scanner.Split(bufio.ScanWords)\n\n var dp [1 << 18][100]int64\n var num []int = make([]int, 0)\n\n n, m := scanner.NextInt64(), int(scanner.NextInt64())\n for n > 0 {\n num = append(num, int(n%10))\n n /= 10\n }\n sort.Sort(Num(num))\n dp[0][0] = 1\n for mask := 0; mask < (1 << uint(len(num))); mask++ {\n for k := 0; k < m; k++ {\n if dp[mask][k] > 0 {\n pre := -1\n for i := 0; i < len(num); i++ {\n if mask&(1< 0 || num[i] == pre || (mask == 0 && num[i] == 0) {\n continue\n }\n dp[mask|(1< 0; {\n\t\tcount[n%10]++\n\t\tnumbers = append(numbers, int(n%int64(10)))\n\t\tn /= 10\n\t\tcnt ++\n\t}\n\treturn cnt\n}\n \nvar dp [1<<18][100]int64\n \nfunc main() {\n\tvar n, m int64\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tcnt := initCount(n)\n\tdp[0][0] = 1\n\tvar mask int = int(uint(1)<= len(s){\n return false\n }\n if s[i] != match[j]{\n return false\n }\n i++\n }\n return true\n }\n", "lang_cluster": "Go", "tags": ["expression parsing", "implementation"], "code_uid": "95812bcb98e2592afe8b3e6d90cbe6f2", "src_uid": "a11c9679d8e2dca51be17d466202df6e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar a []int\n\tfor i := 1; i <= n; i++ {\n\t\tif (1< 0 {\n\t\t\ta = append(a, i)\n\t\t}\n\t}\n\tfor i := range a {\n\t\tfmt.Print(a[len(a)-1-i])\n\t\tif i+1 == len(a) {\n\t\t\tfmt.Println()\n\t\t} else {\n\t\t\tfmt.Print(\" \")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "084a883765ac2b886f1ab870f0161fc1", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n fmt.Scan(&n);\n\n ones := make([]int, 0, 50)\n for b := 1; n > 0; b++ {\n if n%2 == 1 {\n ones = append(ones, b) \n }\n n /= 2\n }\n for i := len(ones)-1; i >= 0; i-- {\n fmt.Print(\" \", ones[i])\n }\n fmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "84ccd83678c2f2df6bd592f6d5730d91", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// GoIntoGo project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tfor i := 16; i > -1; i-- {\n\t\tif ((n >> uint(i)) & 1) > 0 {\n\t\t\tfmt.Printf(\"%d \", i+1)\n\t\t}\n\t}\n\tfmt.Println(\"\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "638c5023ea1047a2b31cffc436f48d7e", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc Abs(x int) int {\n\tswitch {\n\tcase x < 0:\n\t\treturn -x\n\tcase x == 0:\n\t\treturn 0\n\t}\n\treturn x\n}\n\nfunc Max(x int, y int) int {\n\tif x >= y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc Scan(args ...interface{}) (e error) { _, e = fmt.Fscan(in, args...); return }\nfunc Scanf(ft string, args ...interface{}) (e error) { _, e = fmt.Fscanf(in, ft, args...); return }\nfunc Scanln(args ...interface{}) (e error) { _, e = fmt.Fscanln(in, args...); return }\nfunc Print(args ...interface{}) { out.WriteString(fmt.Sprint(args...)) }\nfunc Printf(ft string, args ...interface{}) { out.WriteString(fmt.Sprintf(ft, args...)) }\nfunc Println(args ...interface{}) { out.WriteString(fmt.Sprintln(args...)) }\n\nvar (\n\tdataIn = \"data.in\"\n\tin = bufio.NewReader(os.Stdin)\n\t//in, _ = os.Open(dataIn)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\nvar n int64\n\nfunc bis(num int64) int64 {\n\tl := int64(1)\n\tr := int64(14142136)\n\tfor l <= r {\n\t\tmid := (l + r) >> 1\n\t\tif mid*(mid+1)/2 > num {\n\t\t\tr = mid - 1\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r\n}\n\nfunc solve() {\n\tm := bis(n)\n\tif n == m*(m+1)/2 {\n\t\tPrintln(m)\n\t} else {\n\t\tPrintln(n - m*(m+1)/2)\n\t}\n}\n\nfunc main() {\n\tdefer out.Flush()\n\tfor Scan(&n) != io.EOF {\n\t\tsolve()\n\t\tout.Flush()\n\t}\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "ea1503ec1e2186a6b3f9df80b983f28e", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n\t// \"sort\"\n\t\"math\"\n)\n\n//N _\nconst (\n\tN = 1e6 + 5\n)\n\nfunc inputter(inputReader *bufio.Reader,strs chan *string){\n\tfor {\n\t\tinput , _ := inputReader.ReadString('\\n')\n\t\tinput = strings.TrimSpace(input)\n\t\tif len(input) > 0 {\n\t\t\tinputs := strings.Split(input, \" \")\n\t\t\tfor i := range inputs{\n\t\t\t\tstrs <- &inputs[i]\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc tester(a int64) int64 {\n\tchTest := make(chan int64)\n\tgo func(){\n\t\tfor i:=int64(1) ; ;i++{\n\t\t\tfor j := int64(1); j<=i; j++{\n\t\t\t\tchTest <- j\n\t\t\t}\n\t\t}\n\t}()\n\tvar x int64\n\tfor i := int64(0); i < a; i++{\n\t\tx = <-chTest\n\t}\n\treturn x\n}\n\n\n\n\nfunc calculator(a int64) int64{\n\tx := math.Sqrt(float64(2*a))\n\ty := int64(x)\n\n\tfor (y*(y+1))/2 >=a {\n\t\ty--\n\t}\n\treturn a - (y*(y+1))/2\n}\n\nfunc main(){\n\trs := bufio.NewReader(os.Stdin)\n\tws := bufio.NewWriter(os.Stdout)\n\n\tstrs := make(chan *string, 100)\n\n\tgo inputter(rs, strs)\n\n\tx1, _ := strconv.ParseInt(*<-strs, 10, 64)\n\n\n\t// ws.WriteString(fmt.Sprint(tester(x1)) + \"\\n\")\n\tws.WriteString(fmt.Sprint(calculator(x1)) + \"\\n\")\n\n\n\tws.Flush()\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c50524a5c5a8b41776dee69c96d0b55f", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc valueAtPos(n int64) int64 {\n\tk := int64((math.Sqrt(float64(1+8*n)) - 1.) / 2.)\n\tn -= (k * (k + 1)) / 2\n\tif n == 0 {\n\t\treturn k\n\t} else {\n\t\treturn n\n\t}\n\treturn -1\n}\n\nfunc main() {\n\tvar n int64\n\n\tfmt.Scanf(\"%d\", &n)\n\tfmt.Println(valueAtPos(n))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9822c11c401d9acad9d29a3f3e332a0b", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"errors\"\n\t\"io\"\n\t\"math/rand\"\n\t\"os\"\n\t\"strconv\"\n\t\"time\"\n\t\"unicode/utf8\"\n)\n\n// ******************************** CODE STARTS ********************************\n\nconst (\n\tMOD int = 1000 * 1000 * 1000 + 7\n)\n\nvar (\n)\n\nfunc solve() {\n\tn := readInt()\n\ta := readInt()\n\tb := readInt()\n\tmovesNum := readInt()\n\n\tdp := make([][]int, 2)\n\tfor i := 0; i < len(dp); i++ {\n\t\tdp[i] = make([]int, n + 1)\n\t}\n\n\tfor i := 1; i <= n; i++ {\n\t\tdp[0][i] = 1 + dp[0][i - 1] \n\t\tif dp[0][i] >= MOD {\n\t\t\tdp[0][i] -= MOD\n\t\t}\n\t}\n\n\tfor move := 0; move < movesNum; move++ {\n\t\tfor x := 1; x <= n; x++ {\n\t\t\tlength := absInt(x - b)\n\t\t\tdp[(move & 1) ^ 1][x] = dp[(move & 1) ^ 1][x - 1]\n\t\t\tif length > 1 {\n\t\t\t\tleft := maxInt(x - (length - 1), 1)\n\t\t\t\tright := minInt(x + (length - 1), n)\n\t\t\t\tadd := dp[(move & 1)][right] - dp[(move & 1)][left - 1]\n\t\t\t\tif add < 0 {\n\t\t\t\t\tadd += MOD\n\t\t\t\t}\n\t\t\t\tsub := dp[(move & 1)][x] - dp[(move & 1)][x - 1]\n\t\t\t\tif sub < 0 {\n\t\t\t\t\tsub += MOD\n\t\t\t\t}\n\t\t\t\tdiff := add - sub\n\t\t\t\tif diff < 0 {\n\t\t\t\t\tdiff += MOD\n\t\t\t\t}\n\t\t\t\tdp[(move & 1) ^ 1][x] += diff \n\t\t\t\tif dp[(move & 1) ^ 1][x] >= MOD {\n\t\t\t\t\tdp[(move & 1) ^ 1][x] -= MOD \n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n//\tlogln(dp)\n\tans := dp[((movesNum - 1) & 1) ^ 1][a] - dp[((movesNum - 1) & 1) ^ 1][a - 1]\n\tif ans < 0 {\n\t\tans += MOD\n\t}\n\tprintInt(ans)\n\tprintLine()\n\n\n}\n\n// ********************************* CODE ENDS *********************************\n\n// IO.\n\nvar (\n\tscanner *Scanner\n\twriter *bufio.Writer\n)\n\nfunc main() {\n\tinput := os.Stdin\n\toutput := os.Stdout\n\t//\tinput, _ := os.Open(\"\")\n\t//\toutput, _ := os.Create(\"\")\n\n\tdefer input.Close()\n\tdefer output.Close()\n\n\tscanner = NewScanner(input)\n\tscanner.Split(bufio.ScanWords)\n\n\twriter = bufio.NewWriter(output)\n\tdefer writer.Flush()\n\n\trand.Seed(int64(time.Now().Nanosecond()))\n\tsolve()\n}\n\n// Read.\n\nfunc readString() string {\n\tscanner.Scan()\n\tans := scanner.Text()\n\treturn ans\n}\n\nfunc readLine() string {\n\tscanner.Split(bufio.ScanLines)\n\tdefer scanner.Split(bufio.ScanWords)\n\treturn readString()\n}\n\nfunc readInt() int {\n\tans, _ := strconv.ParseInt(readString(), 10, 0)\n\treturn int(ans)\n}\n\nfunc readInt64() int64 {\n\tans, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn ans\n}\n\nfunc readFloat64() float64 {\n\tans, _ := strconv.ParseFloat(readString(), 64)\n\treturn ans\n}\n\n// Write.\n\nfunc printString(value string) {\n\twriter.WriteString(value)\n}\n\nfunc printLine() {\n\tprintString(\"\\n\")\n}\n\nfunc printSpace() {\n\tprintString(\" \")\n}\n\nfunc printInt(value int) {\n\tprintString(strconv.FormatInt(int64(value), 10))\n}\n\nfunc printInt64(value int64) {\n\tprintString(strconv.FormatInt(value, 10))\n}\n\nfunc printFloat64(value float64) {\n\tprintString(strconv.FormatFloat(value, 'f', 20, 64))\n}\n\n// Tuple\n\ntype Tuple struct {\n\ta, b int\n}\n\nfunc (p Tuple) Equals(key Key) bool {\n\treturn p.a == key.(Tuple).a\n}\n\nfunc (p Tuple) Less(key Key) bool {\n\treturn p.a < key.(Tuple).a\n}\n\n// Sorting\n\ntype TupleSlice []Tuple\n\nfunc (p TupleSlice) Len() int {\n\treturn len(p)\n}\n\nfunc (p TupleSlice) Less(j, i int) bool {\n\tif p[j].a == p[i].a {\n\t\treturn p[j].b < p[i].b\n\t} else {\n\t\treturn p[j].a < p[i].a\n\t}\n}\n\nfunc (p TupleSlice) Swap(j, i int) {\n\tp[j], p[i] = p[i], p[j]\n}\n\n// Min, max, abs.\n\nfunc maxInt(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minInt(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc absInt(a int) int {\n\tif a > 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\nfunc maxInt64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minInt64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc absInt64(a int64) int64 {\n\tif a > 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\nfunc maxFloat64(a, b float64) float64 {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minFloat64(a, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc absFloat64(a float64) float64 {\n\tif a > 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\n// Set Key interface implementations.\n\ntype Int int\n\nfunc (p Int) Equals(key Key) bool {\n\treturn int(p) == int(key.(Int))\n}\n\nfunc (p Int) Less(key Key) bool {\n\treturn int(p) < int(key.(Int))\n}\n\n// Set.\n\ntype Key interface {\n\tEquals(key Key) bool\n\tLess(key Key) bool\n}\n\ntype node struct {\n\tkey Key\n\tleft *node\n\tright *node\n}\n\nfunc newNode(key Key) *node {\n\treturn &node{key, nil, nil}\n}\n\ntype SplayTree struct {\n\troot *node\n\ttmp *node\n\tlen int\n}\n\nfunc NewSplayTree() *SplayTree {\n\treturn &SplayTree{nil, newNode(nil), 0}\n}\n\nfunc rotateLeft(x, p *node) {\n\tp.right = x.left\n\tx.left = p\n}\n\nfunc rotateRight(x, p *node) {\n\tp.left = x.right\n\tx.right = p\n}\n\nfunc (p *SplayTree) splay(x *node, key Key) *node {\n\tif x == nil {\n\t\treturn nil\n\t}\n\n\tleft := p.tmp\n\tright := p.tmp\n\n\tfor {\n\t\tif key.Less(x.key) {\n\t\t\ty := x.left\n\t\t\tif y == nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif key.Less(y.key) { // zig-zig\n\t\t\t\trotateRight(y, x)\n\t\t\t\tx = y\n\t\t\t\tif x.left == nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\t// link right\n\t\t\tright.left = x\n\t\t\tright = x\n\t\t\t// move left\n\t\t\tx = x.left\n\t\t} else if x.key.Less(key) {\n\t\t\ty := x.right\n\t\t\tif y == nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif y.key.Less(key) { // zig-zig\n\t\t\t\trotateLeft(y, x)\n\t\t\t\tx = y\n\t\t\t\tif x.right == nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\t// link left\n\t\t\tleft.right = x\n\t\t\tleft = x\n\t\t\t// move right\n\t\t\tx = x.right\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tleft.right = x.left\n\tright.left = x.right\n\tx.left = p.tmp.right\n\tx.right = p.tmp.left\n\n\treturn x\n}\n\n// left <= key < right\nfunc (p *SplayTree) split(key Key) (left, right *node) {\n\tp.root = p.splay(p.root, key)\n\tif p.root.key.Equals(key) || p.root.key.Less(key) {\n\t\tright := p.root.right\n\t\tp.root.right = nil\n\t\treturn p.root, right\n\t} else {\n\t\tleft := p.root.left\n\t\tp.root.left = nil\n\t\treturn left, p.root\n\t}\n}\n\n// keys from left tree must be less then keys from right tree\nfunc (p *SplayTree) join(left, right *node) *node {\n\tif left == nil {\n\t\treturn right\n\t} else if right == nil {\n\t\treturn left\n\t}\n\tleft = p.splay(left, right.key)\n\tleft.right = right\n\treturn left\n}\n\ntype Set interface {\n\tLen() int\n\tInsert(key Key) error\n\tFind(key Key) bool\n\tRemove(key Key) error\n}\n\nfunc NewSet() Set {\n\treturn Set(NewSplayTree())\n}\n\nfunc (p *SplayTree) Len() int {\n\treturn p.len\n}\n\nfunc (p *SplayTree) Insert(key Key) error {\n\tif p.root == nil {\n\t\tp.root = newNode(key)\n\t\tp.len++\n\t} else {\n\t\tp.root = p.splay(p.root, key)\n\t\tif p.root.key.Equals(key) {\n\t\t\treturn errors.New(\"Such key already exists\")\n\t\t} else {\n\t\t\tleft, right := p.split(key)\n\t\t\tp.root = newNode(key)\n\t\t\tp.root.left = left\n\t\t\tp.root.right = right\n\t\t\tp.len++\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (p *SplayTree) Find(key Key) bool {\n\tif p.root == nil {\n\t\treturn false\n\t}\n\tp.root = p.splay(p.root, key)\n\treturn p.root.key.Equals(key)\n}\n\nfunc (p *SplayTree) Remove(key Key) error {\n\tp.root = p.splay(p.root, key)\n\tif p.root == nil || !p.root.key.Equals(key) {\n\t\treturn errors.New(\"Such key doesn't exist\")\n\t}\n\tp.root = p.join(p.split(key))\n\treturn nil\n}\n\n// Copied scan.go\n// Scanner provides a convenient interface for reading data such as\n// a file of newline-delimited lines of text. Successive calls to\n// the Scan method will step through the 'tokens' of a file, skipping\n// the bytes between the tokens. The specification of a token is\n// defined by a split function of type SplitFunc; the default split\n// function breaks the input into lines with line termination stripped. Split\n// functions are defined in this package for scanning a file into\n// lines, bytes, UTF-8-encoded runes, and space-delimited words. The\n// client may instead provide a custom split function.\n//\n// Scanning stops unrecoverably at EOF, the first I/O error, or a token too\n// large to fit in the buffer. When a scan stops, the reader may have\n// advanced arbitrarily far past the last token. Programs that need more\n// control over error handling or large tokens, or must run sequential scans\n// on a reader, should use bufio.Reader instead.\n//\ntype Scanner struct {\n\tr io.Reader // The reader provided by the client.\n\tsplit SplitFunc // The function to split the tokens.\n\tmaxTokenSize int // Maximum size of a token; modified by tests.\n\ttoken []byte // Last token returned by split.\n\tbuf []byte // Buffer used as argument to split.\n\tstart int // First non-processed byte in buf.\n\tend int // End of data in buf.\n\terr error // Sticky error.\n}\n\n// SplitFunc is the signature of the split function used to tokenize the\n// input. The arguments are an initial substring of the remaining unprocessed\n// data and a flag, atEOF, that reports whether the Reader has no more data\n// to give. The return values are the number of bytes to advance the input\n// and the next token to return to the user, plus an error, if any. If the\n// data does not yet hold a complete token, for instance if it has no newline\n// while scanning lines, SplitFunc can return (0, nil, nil) to signal the\n// Scanner to read more data into the slice and try again with a longer slice\n// starting at the same point in the input.\n//\n// If the returned error is non-nil, scanning stops and the error\n// is returned to the client.\n//\n// The function is never called with an empty data slice unless atEOF\n// is true. If atEOF is true, however, data may be non-empty and,\n// as always, holds unprocessed text.\ntype SplitFunc func(data []byte, atEOF bool) (advance int, token []byte, err error)\n\n// Errors returned by Scanner.\nvar (\n\tErrTooLong = errors.New(\"bufio.Scanner: token too long\")\n\tErrNegativeAdvance = errors.New(\"bufio.Scanner: SplitFunc returns negative advance count\")\n\tErrAdvanceTooFar = errors.New(\"bufio.Scanner: SplitFunc returns advance count beyond input\")\n)\n\nconst (\n\t// Maximum size used to buffer a token. The actual maximum token size\n\t// may be smaller as the buffer may need to include, for instance, a newline.\n\tMaxScanTokenSize = 1 << 20\n)\n\n// NewScanner returns a new Scanner to read from r.\n// The split function defaults to ScanLines.\nfunc NewScanner(r io.Reader) *Scanner {\n\treturn &Scanner{\n\t\tr: r,\n\t\tsplit: ScanLines,\n\t\tmaxTokenSize: MaxScanTokenSize,\n\t\tbuf: make([]byte, 4096), // Plausible starting size; needn't be large.\n\t}\n}\n\n// Err returns the first non-EOF error that was encountered by the Scanner.\nfunc (s *Scanner) Err() error {\n\tif s.err == io.EOF {\n\t\treturn nil\n\t}\n\treturn s.err\n}\n\n// Bytes returns the most recent token generated by a call to Scan.\n// The underlying array may point to data that will be overwritten\n// by a subsequent call to Scan. It does no allocation.\nfunc (s *Scanner) Bytes() []byte {\n\treturn s.token\n}\n\n// Text returns the most recent token generated by a call to Scan\n// as a newly allocated string holding its bytes.\nfunc (s *Scanner) Text() string {\n\treturn string(s.token)\n}\n\n// Scan advances the Scanner to the next token, which will then be\n// available through the Bytes or Text method. It returns false when the\n// scan stops, either by reaching the end of the input or an error.\n// After Scan returns false, the Err method will return any error that\n// occurred during scanning, except that if it was io.EOF, Err\n// will return nil.\nfunc (s *Scanner) Scan() bool {\n\t// Loop until we have a token.\n\tfor {\n\t\t// See if we can get a token with what we already have.\n\t\tif s.end > s.start {\n\t\t\tadvance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)\n\t\t\tif err != nil {\n\t\t\t\ts.setErr(err)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !s.advance(advance) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ts.token = token\n\t\t\tif token != nil {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\t// We cannot generate a token with what we are holding.\n\t\t// If we've already hit EOF or an I/O error, we are done.\n\t\tif s.err != nil {\n\t\t\t// Shut it down.\n\t\t\ts.start = 0\n\t\t\ts.end = 0\n\t\t\treturn false\n\t\t}\n\t\t// Must read more data.\n\t\t// First, shift data to beginning of buffer if there's lots of empty space\n\t\t// or space is neded.\n\t\tif s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {\n\t\t\tcopy(s.buf, s.buf[s.start:s.end])\n\t\t\ts.end -= s.start\n\t\t\ts.start = 0\n\t\t}\n\t\t// Is the buffer full? If so, resize.\n\t\tif s.end == len(s.buf) {\n\t\t\tif len(s.buf) >= s.maxTokenSize {\n\t\t\t\ts.setErr(ErrTooLong)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tnewSize := len(s.buf) * 2\n\t\t\tif newSize > s.maxTokenSize {\n\t\t\t\tnewSize = s.maxTokenSize\n\t\t\t}\n\t\t\tnewBuf := make([]byte, newSize)\n\t\t\tcopy(newBuf, s.buf[s.start:s.end])\n\t\t\ts.buf = newBuf\n\t\t\ts.end -= s.start\n\t\t\ts.start = 0\n\t\t\tcontinue\n\t\t}\n\t\t// Finally we can read some input. Make sure we don't get stuck with\n\t\t// a misbehaving Reader. Officially we don't need to do this, but let's\n\t\t// be extra careful: Scanner is for safe, simple jobs.\n\t\tfor loop := 0; ; {\n\t\t\tn, err := s.r.Read(s.buf[s.end:len(s.buf)])\n\t\t\ts.end += n\n\t\t\tif err != nil {\n\t\t\t\ts.setErr(err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif n > 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tloop++\n\t\t\tif loop > 100 {\n\t\t\t\ts.setErr(io.ErrNoProgress)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\n// advance consumes n bytes of the buffer. It reports whether the advance was legal.\nfunc (s *Scanner) advance(n int) bool {\n\tif n < 0 {\n\t\ts.setErr(ErrNegativeAdvance)\n\t\treturn false\n\t}\n\tif n > s.end-s.start {\n\t\ts.setErr(ErrAdvanceTooFar)\n\t\treturn false\n\t}\n\ts.start += n\n\treturn true\n}\n\n// setErr records the first error encountered.\nfunc (s *Scanner) setErr(err error) {\n\tif s.err == nil || s.err == io.EOF {\n\t\ts.err = err\n\t}\n}\n\n// Split sets the split function for the Scanner. If called, it must be\n// called before Scan. The default split function is ScanLines.\nfunc (s *Scanner) Split(split SplitFunc) {\n\ts.split = split\n}\n\n// Split functions\n\n// ScanBytes is a split function for a Scanner that returns each byte as a token.\nfunc ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\treturn 1, data[0:1], nil\n}\n\nvar errorRune = []byte(string(utf8.RuneError))\n\n// ScanRunes is a split function for a Scanner that returns each\n// UTF-8-encoded rune as a token. The sequence of runes returned is\n// equivalent to that from a range loop over the input as a string, which\n// means that erroneous UTF-8 encodings translate to U+FFFD = \"\\xef\\xbf\\xbd\".\n// Because of the Scan interface, this makes it impossible for the client to\n// distinguish correctly encoded replacement runes from encoding errors.\nfunc ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\n\t// Fast path 1: ASCII.\n\tif data[0] < utf8.RuneSelf {\n\t\treturn 1, data[0:1], nil\n\t}\n\n\t// Fast path 2: Correct UTF-8 decode without error.\n\t_, width := utf8.DecodeRune(data)\n\tif width > 1 {\n\t\t// It's a valid encoding. Width cannot be one for a correctly encoded\n\t\t// non-ASCII rune.\n\t\treturn width, data[0:width], nil\n\t}\n\n\t// We know it's an error: we have width==1 and implicitly r==utf8.RuneError.\n\t// Is the error because there wasn't a full rune to be decoded?\n\t// FullRune distinguishes correctly between erroneous and incomplete encodings.\n\tif !atEOF && !utf8.FullRune(data) {\n\t\t// Incomplete; get more bytes.\n\t\treturn 0, nil, nil\n\t}\n\n\t// We have a real UTF-8 encoding error. Return a properly encoded error rune\n\t// but advance only one byte. This matches the behavior of a range loop over\n\t// an incorrectly encoded string.\n\treturn 1, errorRune, nil\n}\n\n// dropCR drops a terminal \\r from the data.\nfunc dropCR(data []byte) []byte {\n\tif len(data) > 0 && data[len(data)-1] == '\\r' {\n\t\treturn data[0 : len(data)-1]\n\t}\n\treturn data\n}\n\n// ScanLines is a split function for a Scanner that returns each line of\n// text, stripped of any trailing end-of-line marker. The returned line may\n// be empty. The end-of-line marker is one optional carriage return followed\n// by one mandatory newline. In regular expression notation, it is `\\r?\\n`.\n// The last non-empty line of input will be returned even if it has no\n// newline.\nfunc ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\tif i := bytes.IndexByte(data, '\\n'); i >= 0 {\n\t\t// We have a full newline-terminated line.\n\t\treturn i + 1, dropCR(data[0:i]), nil\n\t}\n\t// If we're at EOF, we have a final, non-terminated line. Return it.\n\tif atEOF {\n\t\treturn len(data), dropCR(data), nil\n\t}\n\t// Request more data.\n\treturn 0, nil, nil\n}\n\n// isSpace reports whether the character is a Unicode white space character.\n// We avoid dependency on the unicode package, but check validity of the implementation\n// in the tests.\nfunc isSpace(r rune) bool {\n\tif r <= '\\u00FF' {\n\t\t// Obvious ASCII ones: \\t through \\r plus space. Plus two Latin-1 oddballs.\n\t\tswitch r {\n\t\tcase ' ', '\\t', '\\n', '\\v', '\\f', '\\r':\n\t\t\treturn true\n\t\tcase '\\u0085', '\\u00A0':\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\t// High-valued ones.\n\tif '\\u2000' <= r && r <= '\\u200a' {\n\t\treturn true\n\t}\n\tswitch r {\n\tcase '\\u1680', '\\u180e', '\\u2028', '\\u2029', '\\u202f', '\\u205f', '\\u3000':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ScanWords is a split function for a Scanner that returns each\n// space-separated word of text, with surrounding spaces deleted. It will\n// never return an empty string. The definition of space is set by\n// unicode.IsSpace.\nfunc ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\t// Skip leading spaces.\n\tstart := 0\n\tfor width := 0; start < len(data); start += width {\n\t\tvar r rune\n\t\tr, width = utf8.DecodeRune(data[start:])\n\t\tif !isSpace(r) {\n\t\t\tbreak\n\t\t}\n\t}\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\t// Scan until space, marking end of word.\n\tfor width, i := 0, start; i < len(data); i += width {\n\t\tvar r rune\n\t\tr, width = utf8.DecodeRune(data[i:])\n\t\tif isSpace(r) {\n\t\t\treturn i + width, data[start:i], nil\n\t\t}\n\t}\n\t// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.\n\tif atEOF && len(data) > start {\n\t\treturn len(data), data[start:], nil\n\t}\n\t// Request more data.\n\treturn 0, nil, nil\n}", "lang_cluster": "Go", "tags": ["dp", "implementation", "combinatorics"], "code_uid": "e47f4452f40f0d04287fe05a024a28c3", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\nimport (\r\n\t\"bufio\"\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n\t//. \"strconv\" Itoa\r\n)\r\nfunc max(i int64, j int64) int64 {\r\n\tif (i > j) {\r\n\t\treturn i;\r\n\t} else {\r\n\t\treturn j;\r\n\t}\r\n}\r\nfunc min(i int64, j int64) int64 {\r\n\tif (i < j) {\r\n\t\treturn i;\r\n\t} else {\r\n\t\treturn j;\r\n\t}\r\n}\r\nconst (\r\n\tINF64 = int64(1e18)\r\n)\r\nfunc solve(_r io.Reader, _w io.Writer) {\r\n\tin := bufio.NewReader(_r)\r\n\tout := bufio.NewWriter(_w)\r\n\r\n\tdefer out.Flush()\r\n\r\n\tp := [2]int64{}\r\n\tt := [2]int64{}\r\n\tFscan(in, &p[0], &t[0], &p[1], &t[1])\r\n\r\n\tvar h, s int64\r\n\tFscan(in, &h, &s)\r\n\r\n\tans := INF64\r\n\tdp := make([]int64, h+1)\r\n\tfor i := range dp {\r\n\t\tdp[i] = INF64\r\n\t}\r\n\tdp[0] = 0\r\n\r\n\tfor i := int64(0); i <= h; i++ {\r\n\t\tfor j := int64(1); j <= h - i; j++ {\r\n\t\t\tfor k := 0; k < 2; k++ {\r\n\t\t\t\tni := min(h, i + j*(p[k]-s) + j*t[k]/t[k^1]*(p[k^1]-s))\r\n\t\t\t\tif ni == h {\r\n\t\t\t\t\tans = min(ans, dp[i] + j*t[k])\r\n\t\t\t\t}\r\n\t\t\t\tif j*t[k] >= t[k^1] {\r\n\t\t\t\t\tni = min(h, i + j*(p[k]-s) + j*t[k]/t[k^1]*(p[k^1]-s) + s)\r\n\t\t\t\t\t// ni = min(h, i + (j-1)*(p[k]-s) + (j*t[k]/t[k^1] - 1)*(p[k^1]-s) + (p[0]+p[1]-s))\r\n\t\t\t\t\tdp[ni] = min(dp[ni], dp[i] + j*t[k])\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tans = min(ans, dp[h])\r\n\tFprintln(out, ans)\r\n}\r\nfunc main() { solve(os.Stdin, os.Stdout) }", "lang_cluster": "Go", "tags": ["dp", "binary search"], "code_uid": "bd3ba3cf18e15a8c5deba88d01d7a285", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc max(a, b int) int {\n\treturn -min(-a, -b)\n}\n\nfunc min(a, b int) int {\n\tif a < b { return a }\n\treturn b \n}\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\tw := bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\n\tvar p1, t1, p2, t2, h, s int\n\tfmt.Fscan(r, &p1, &t1, &p2, &t2, &h, &s)\n\n\tdp := make([]int, h+1)\n\tfor i := range dp {\n\t\tif i == 0 { continue }\n\t\tdp[i] = min(t1 + dp[max(0, i - (p1-s))], t2 + dp[max(0, i - (p2-s))])\n\t\tfor j := 1; j <= i; j++ {\n\t\t\tif j*t1 >= t2 { dp[i] = min(dp[i], j*t1 + dp[max(0, i - (j-1)*(p1-s) - (j*t1/t2 - 1)*(p2-s) - (p1+p2-s))]) }\n\t\t\tif j*t2 >= t1 { dp[i] = min(dp[i], j*t2 + dp[max(0, i - (j-1)*(p2-s) - (j*t2/t1 - 1)*(p1-s) - (p1+p2-s))]) }\n\t\t}\n\t}\n\n\tfmt.Fprintln(w, dp[h])\n}\n", "lang_cluster": "Go", "tags": ["dp", "binary search"], "code_uid": "eac4ac300b34f29558826f40e47be5fc", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1515E(in io.Reader, out io.Writer) {\r\n\tvar n int\r\n\tvar mod, ans int64\r\n\tFscan(in, &n, &mod)\r\n\r\n\tinv := make([]int64, n+1)\r\n\tinv[1] = 1\r\n\tfor i := 2; i <= n; i++ {\r\n\t\tinv[i] = (mod - mod/int64(i)) * inv[mod%int64(i)] % mod\r\n\t}\r\n\r\n\tdp := [2][][]int64{}\r\n\tfor i := range dp {\r\n\t\tdp[i] = make([][]int64, n+1)\r\n\t\tfor j := range dp[i] {\r\n\t\t\tdp[i][j] = make([]int64, n+1)\r\n\t\t}\r\n\t}\r\n\tdp[1][1][1] = 1\r\n\tfor i := 2; i <= n; i++ {\r\n\t\tpre, cur := dp[i&1^1], dp[i&1]\r\n\t\tfor _, r := range cur {\r\n\t\t\tfor j := range r {\r\n\t\t\t\tr[j] = 0\r\n\t\t\t}\r\n\t\t}\r\n\t\tcur[1][0] = pre[1][1]\r\n\t\tfor j := 2; j <= i; j++ {\r\n\t\t\tfor k := 1; k <= j; k++ {\r\n\t\t\t\tcur[j][0] += pre[j][k]\r\n\t\t\t}\r\n\t\t\tcur[j][0] %= mod\r\n\t\t\tcur[j][1] = pre[j-1][0] * int64(j) % mod\r\n\t\t\tfor k := 2; k < j; k++ {\r\n\t\t\t\tcur[j][k] = pre[j-1][k-1] * int64(j) * 2 % mod * inv[k] % mod\r\n\t\t\t}\r\n\t\t\tcur[j][j] = pre[j-1][j-1] * 2 % mod\r\n\t\t}\r\n\t}\r\n\tfor _, r := range dp[n&1] {\r\n\t\tfor _, v := range r[1:] {\r\n\t\t\tans += v\r\n\t\t}\r\n\t}\r\n\tFprint(out, ans%mod)\r\n}\r\n\r\nfunc main() { CF1515E(os.Stdin, os.Stdout) }\r\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "1f38b1803494b7e3bcd60342ee224d6d", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvictory := [8]int{0x444, 0x222, 0x111, 0x700, 0x070, 0x007, 0x421, 0x124}\n\txCount, x, xWinChess := 0, 0, 0x777\n\toCount, o, oWinChess := 0, 0, 0x777\n\tfilled := true\n\n\tfor i := 0; i < 3; i++ {\n\t\tb := [3]byte{}\n\t\tfmt.Scanf(\"%c%c%c\\n\", &b[0], &b[1], &b[2])\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif b[j] == 'X' {\n\t\t\t\txCount++\n\t\t\t\tx = x | ((1 << uint(j)) << uint(4*i))\n\t\t\t} else if b[j] == '0' {\n\t\t\t\toCount++\n\t\t\t\to = o | ((1 << uint(j)) << uint(4*i))\n\t\t\t} else if b[j] == '.' {\n\t\t\t\tfilled = false\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 8; i++ {\n\t\tif victory[i]&x == victory[i] {\n\t\t\txWinChess = xWinChess & victory[i]\n\t\t}\n\t\tif victory[i]&o == victory[i] {\n\t\t\toWinChess = oWinChess & victory[i]\n\t\t}\n\t}\n\n\t// two non-intersect line\n\tif xWinChess == 0 || oWinChess == 0 {\n\t\tfmt.Printf(\"illegal\")\n\t\treturn\n\t}\n\n\t// x o both win\n\tif xWinChess != 0x777 && oWinChess != 0x777 {\n\t\tfmt.Printf(\"illegal\")\n\t\treturn\n\t}\n\n\tif xCount-oCount != 0 && xCount-oCount != 1 {\n\t\tfmt.Printf(\"illegal\")\n\t\treturn\n\t}\n\n\tif xCount-oCount == 1 && oWinChess != 0x777 {\n\t\tfmt.Printf(\"illegal\")\n\t\treturn\n\t}\n\n\tif xCount-oCount == 0 && xWinChess != 0x777 {\n\t\tfmt.Printf(\"illegal\")\n\t\treturn\n\t}\n\n\tif xWinChess == 0x777 && oWinChess != 0x777 {\n\t\tfmt.Printf(\"the second player won\")\n\t\treturn\n\t}\n\n\tif xWinChess != 0x777 && oWinChess == 0x777 {\n\t\tfmt.Printf(\"the first player won\")\n\t\treturn\n\t}\n\n\tif filled == false && xWinChess == 0x777 && oWinChess == 0x777 {\n\t\tif xCount-oCount == 1 {\n\t\t\tfmt.Printf(\"second\")\n\t\t\treturn\n\t\t}\n\t\tif xCount == oCount {\n\t\t\tfmt.Printf(\"first\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tif filled == true && xWinChess == 0x777 && oWinChess == 0x777 {\n\t\tfmt.Printf(\"draw\")\n\t\treturn\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "games"], "code_uid": "ae3f094a3527a5399c96cbad238927a0", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nvar grid = make([][]byte, 3)\n\nfunc isLine(r, c, dr, dc int, ch byte) int {\n for i := 0; i < 3; i++ {\n if grid[r+i*dr][c+i*dc] != ch {\n return 0\n }\n }\n return 1\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n xCount, oCount := 0, 0\n for i := range grid {\n grid[i] = []byte(getS())\n for j, ch := range grid[i] {\n if ch == 'X' {\n xCount++\n grid[i][j] = 'x'\n } else if ch == '0' {\n oCount++\n grid[i][j] = 'o'\n }\n }\n }\n diff := xCount - oCount\n if diff < 0 || diff > 1 {\n writer.WriteString(\"illegal\\n\")\n return\n }\n xLines, oLines := 0, 0\n for i := 0; i < 3; i++ {\n xLines += isLine(0, i, 1, 0, 'x')\n xLines += isLine(i, 0, 0, 1, 'x')\n oLines += isLine(0, i, 1, 0, 'o')\n oLines += isLine(i, 0, 0, 1, 'o')\n }\n xLines += isLine(0, 0, 1, 1, 'x')\n xLines += isLine(0, 2, 1, -1, 'x')\n oLines += isLine(0, 0, 1, 1, 'o')\n oLines += isLine(0, 2, 1, -1, 'o')\n if xLines > 0 && oLines > 0 {\n writer.WriteString(\"illegal\\n\")\n } else if xLines > 0 && xCount == oCount {\n writer.WriteString(\"illegal\\n\")\n } else if oLines > 0 && xCount > oCount {\n writer.WriteString(\"illegal\\n\")\n } else if xLines > 0 {\n writer.WriteString(\"the first player won\\n\")\n } else if oLines > 0 {\n writer.WriteString(\"the second player won\\n\")\n } else if xCount+oCount == 9 {\n writer.WriteString(\"draw\\n\")\n } else if xCount == oCount {\n writer.WriteString(\"first\\n\")\n } else {\n writer.WriteString(\"second\\n\")\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "games"], "code_uid": "c7638945fbb0e749ea14c0dd533d2b44", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tn *= 2\n\ta := make([]int, n)\n\tfor i, _ := range a {\n\t\tfmt.Scan(&a[i])\n\t}\n\n\tres := -1\n\tfor i, _ := range a {\n\t\tfor j, _ := range a {\n\t\t\tif j == i {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tcur := make([]int, 0)\n\t\t\tfor k, _ := range a {\n\t\t\t\tif k != i && k != j {\n\t\t\t\t\tcur = append(cur, a[k])\n\t\t\t\t}\n\t\t\t}\n\t\t\tsort.Ints(cur)\n\n\t\t\tans := 0\n\t\t\tfor k := 0; k < len(cur); k += 2 {\n\t\t\t\tans += cur[k+1] - cur[k]\n\t\t\t}\n\t\t\tif res == -1 {\n\t\t\t\tres = ans\n\t\t\t} else if res > ans {\n\t\t\t\tres = ans\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "sortings", "greedy"], "code_uid": "78a7a2053c8c78b19906c868260b1c04", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tweight := make([]int,2*n)\n\tfor i := 0; i < 2*n; i++ {\n\t\tfmt.Scan(&weight[i])\n\t}\n\tsort.Ints(weight)\n\tres := 50000\n\tfor i := 0; i < 2*n-1; i++ { //enumerate the two elements\n\t\tfor j := i + 1; j < 2*n; j++ {\n\t\t\ttot := 0\n\t\t\tfor k := 0; k < 2*n-1; k++ { //left weight\n\t\t\t\tif k==i || k==j{continue} //skip it\n\t\t\t\tr := k+1\n\t\t\t\tfor r==i || r==j {r++} //right weight\n\t\t\t\ttot += weight[r] - weight[k]\n\t\t\t\tk = r //update left\n\t\t\t}\n\t\t\tif tot < res { res = tot} //update the result\n\t\t}\n\t}\n\tfmt.Println(res)\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "sortings", "greedy"], "code_uid": "1198de59728d2ac639c523af0e0da2c4", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n, m, z, cnt, cnt1, cnt2 int\n\n\tfmt.Scanln(&n, &m)\n\tt := make([]int, n)\n\tres := make([]int, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &z)\n\n\t\tt[i] = z\n\t}\n\n\tfor x, y := range t {\n\t\tcnt += y\n\t\tif cnt > m {\n\t\t\tcnt2 = cnt\n\t\t\tsort.Ints(t[:x])\n\t\t\tfor i := len(t[:x]) - 1; i >= 0; i-- {\n\n\t\t\t\tcnt2 -= t[i]\n\t\t\t\tcnt1++\n\n\t\t\t\tif cnt2 <= m {\n\t\t\t\t\tres[x] = cnt1\n\t\t\t\t\tcnt1 = 0\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tres[x] = 0\n\t\t}\n\t}\n\n\tfor _, y := range res {\n\t\tfmt.Printf(\"%d \", y)\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "7fd7eda0078bd96c2ea17784ac26f90a", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nvar(\n\tn int\t\t\t\t/*Number of students*/\n\tM int\t\t\t\t/*Maximum time*/\n\tt[110] int \t\t/*Students' time*/\n\tsum[110] int \t\t/*sum [0..i)*/\n\tbuffer[110] int \t/*used for sorting*/\n)\n\n\n\nfunc main(){\n\t//input\n\tfmt.Scanf(\"%d %d\\n\", &n, &M)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &t[i])\n\t}\n\n\tsum[0] = 0\n\tfor i := 1; i < n; i++ {\n\t\tsum[i] = sum[i - 1] + t[i - 1]\n\t}\n\tbuffer = sum\n\n\tfor i := 0; i < n; i++ {\t/*Next student*/\n\t\tans := 0\n\t\trequired := M - t[i]\n\t\tcurrent := sum[i]\n\t\tif current > required{\n\t\t\tcopy(buffer[0:i], t[0:i])\n\t\t\tsort.Ints(buffer[0:i])\n\t\t}\n\t\tfor current > required {\n\t\t\tans++\n\t\t\tcurrent -= buffer[i - ans] /*M > t[i]*/\n\t\t}\n\t\tfmt.Printf(\"%d \", ans)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "3eb8f5e86981982c31755475acb5c91c", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Try Codeforces\n// author: Leonrdone @ NEETSDKASU\npackage main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\ntype Foo []int64\nfunc (f Foo) Len() int { return len(f) }\nfunc (f Foo) Swap(i, j int) { f[i], f[j] = f[j], f[i] }\nfunc (f Foo) Less(i, j int) bool { return f[i] < f[j] }\n\nfunc main() {\n var n, k int\n var m int64\n fmt.Scan(&n, &k, &m)\n xs := make([]int64, k)\n for i := range xs {\n fmt.Scan(&xs[i])\n }\n sum := int64(0)\n for _, x := range xs {\n sum += x\n }\n sort.Sort(Foo(xs))\n ans := int64(0)\n for i := 0; i <= n; i++ {\n altm := sum * int64(i)\n if altm > m {\n break\n }\n tmp := int64((k + 1) * i)\n p := int64(n - i)\n for _, x := range xs[:k-1] {\n w := p\n for altm + w * x > m {\n w--\n }\n altm += w * x\n tmp += w\n }\n for altm + p * xs[k-1] > m {\n p--\n }\n altm += p * xs[k-1]\n tmp += p * 2\n if tmp > ans {\n ans = tmp\n }\n }\n fmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "e7c8dc9f75b658928b002129b02a5694", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Try Codeforces\n// author: Leonrdone @ NEETSDKASU\npackage main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\ntype Foo []int64\n\nfunc (f Foo) Len() int { return len(f) }\nfunc (f Foo) Swap(i, j int) { f[i], f[j] = f[j], f[i] }\nfunc (f Foo) Less(i, j int) bool { return f[i] < f[j] }\n\nfunc main() {\n\tvar n, k int\n\tvar m int64\n\tfmt.Scan(&n, &k, &m)\n\txs := make([]int64, k)\n\tfor i := range xs {\n\t\tfmt.Scan(&xs[i])\n\t}\n\tsum := int64(0)\n\tfor _, x := range xs {\n\t\tsum += x\n\t}\n\tsort.Sort(Foo(xs))\n\tans := int64(0)\n\tfor i := 0; i < n; i++ {\n\t\taltm := sum * int64(i)\n\t\tif altm > m {\n\t\t\tbreak\n\t\t}\n\t\ttmp := int64((k + 1) * i)\n\t\tp := int64(n - i)\n\t\tfor _, x := range xs[:k-1] {\n\t\t\tw := p\n\t\t\tfor altm+w*x > m {\n\t\t\t\tw--\n\t\t\t}\n\t\t\taltm += w * x\n\t\t\ttmp += w\n\t\t}\n\t\tfor altm+p*xs[k-1] > m {\n\t\t\tp--\n\t\t}\n\t\taltm += p * xs[k-1]\n\t\ttmp += p * 2\n\t\tif tmp > ans {\n\t\t\tans = tmp\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "0fba7e60b4d70d2ae961d0e3169b0f2f", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc max(x, y int) int {\n\tif y > x {\n\t\treturn y\n\t}\n\treturn x\n}\n\nfunc min(x, y int) int {\n\tif y < x {\n\t\treturn y\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar a [110]int\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\tvar d1, d2 int\n\tfor i := 0; i < n-1; i++ {\n\t\td1 = max(d1, a[i+1]-a[i])\n\t}\n\td2 = 1 << 30\n\tfor i := 0; i < n-2; i++ {\n\t\td2 = min(d2, a[i+2]-a[i])\n\t}\n\tfmt.Println(max(d1, d2))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "3b50213266f41fdb94115cf417d8cf02", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, max, min, res int\n\tmin = 1000\n\n\tfmt.Scan(&n)\n\n\ta := make([]int, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\n\t\tif i > 0 {\n\t\t\tif a[i]-a[i-1] > max {\n\t\t\t\tmax = a[i] - a[i-1]\n\t\t\t}\n\t\t}\n\n\t\tif i > 1 {\n\t\t\tif a[i]-a[i-2] < min {\n\t\t\t\tmin = a[i] - a[i-2]\n\t\t\t}\n\t\t}\n\t}\n\n\tres = min\n\tif max > min {\n\t\tres = max\n\t}\n\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "ffccc417ff06d77235cde104f0aa3488", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt()\n\ta := make([]int, n) \n\tmax, min, dif := 0, 1001, 0\n\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = nextInt()\n\t}\n\n\tif n == 3 {\n\t\tprintln(a[2] - a[0])\n\t\treturn\n\t}\n\n\tfor i := 1; i < n; i++ {\n\t\tif a[i] - a[i-1] > max {\n\t\t\tmax = a[i] - a[i-1]\n\t\t}\n\t}\n\n\tfor i := 1; i < n - 1; i++ {\n\t\tdif = a[i+1] - a[i-1]\n\n\t\tif dif < max {\n\t\t\tprintln(max)\n\t\t\treturn\n\t\t}\n\n\t\tif dif < min {\n\t\t\tmin = dif\n\t\t}\n\t}\n\n\tprintln(min)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, err := strconv.ParseFloat(next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "adff5668743983819b9468c2650da18b", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 859 C Pie Rules train\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar in *bufio.Reader\n\nfunc readFive() (int, int, int, int, int) {\n\tvar a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor i := 0; i < len(ss); i++ {\n\t\ta[i], err = strconv.Atoi(ss[i])\n\t\tif err != nil {\n\t\t\tfmt.Println(\"n atoi failure\", err)\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn a[0], a[1], a[2], a[3], a[4]\n}\n\nfunc readLineNumbs(n int) []int {\n\ta := make([]int, n)\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor j := 0; j < n; j++ {\n\t\taa, err := strconv.Atoi(ss[j])\n\t\tif err != nil {\n\t\t\tfmt.Println(\"aa conv failed\", err)\n\t\t\tpanic(err)\n\t\t}\n\t\ta[j] = aa\n\t}\n\treturn a\n}\n\nvar n int\nvar p []int // pie slices sizes\nvar pAlice,pBob int\nvar mem [][]int // mem[0] - bob win, mem[1] - alice win\nvar pSum int\nvar pSumLeft []int // sum left after step \n\n// readData read data for out problem.\nfunc readData() {\n\tin = bufio.NewReader(os.Stdin)\n\t// reading n\n\tn, _, _, _, _ = readFive()\n\tp = readLineNumbs(n)\n}\n\nfunc initMemSum() {\n\tmem = make([][]int, 2)\n\tfor ba := 0; ba<2; ba++ {\n\t\tmem[ba] = make([]int, n)\n\t\tfor j:=0; j=0; i-- {\n\t\tpSum += p[i]\n\t\tpSumLeft[i] = pSum;\n\t}\n}\n\n// Return for player with fishka.\nfunc play(ba int, step int) int {\n\tif step>=n {\n\t\treturn 0\n\t} else if mem[ba][step]>=0 {\n\t\treturn mem[ba][step]\n\t}\n\t// pass fishka\n\tretp := p[step] + (pSumLeft[step+1] - play(1-ba, step+1));\n\t// stay with fishka\n\trets := play(ba, step+1)\n\t// max result\n\tret := retp\n\tif ret < rets {\n\t\tret = rets\n\t}\n\t// fmt.Printf(\"play(%d, %d) returned %d\\n\", ba,step, ret)\n\tmem[ba][step] = ret;\n\treturn ret;\n}\n\n// solve func solves our problem.\nfunc solve() {\n\tinitMemSum()\n\tpBob = play(1,0)\n\tpAlice = pSum - pBob\n}\n\n// printRes print problem solution in expected format.\nfunc printRes() {\n\tfmt.Printf(\"%d %d\\n\", pAlice, pBob)\n}\n\nfunc main() {\n\treadData()\n\tsolve()\n\tprintRes()\n}\n", "lang_cluster": "Go", "tags": ["dp", "games"], "code_uid": "7cb877b8b6cd6404d4689a5fe33fcfc2", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar mem [2][51]int\n\nfunc get(sum int, slices []int, decider bool) (returned int) {\n\tif len(slices) == 0 {\n\t\treturn 0\n\t}\n\n\tdec := 0\n\tif decider {\n\t\tdec = 1\n\t}\n\n\tif mem[dec][len(slices)] != 0 {\n\t\treturn mem[dec][len(slices)]\n\t}\n\tdefer func() { mem[dec][len(slices)] = returned }()\n\n\tans := get(sum-slices[0], slices[1:], decider)\n\tif x := sum - get(sum-slices[0], slices[1:], !decider); ans < x {\n\t\tans = x\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tslices := make([]int, n)\n\tsum := 0\n\tfor i := range slices {\n\t\tfmt.Scan(&slices[i])\n\t\tsum += slices[i]\n\t}\n\tbob := get(sum, slices, true)\n\tfmt.Println(sum-bob, bob)\n}\n", "lang_cluster": "Go", "tags": ["dp", "games"], "code_uid": "e0134b78456c776fd7965798655517c5", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc sum(st, end int) int {\n\tif st > end{\n\t\treturn 0\n\t}\n\treturn (st + end) * (end - st + 1) / 2\n}\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar w, h int\n\tfmt.Fscanf(buf, \"%d %d\\n\", &w, &h)\n\t//_,err := ioutil.ReadFile(str)\n\tvar u1, d1 int\n\tvar u2, d2 int\n\tfmt.Fscanf(buf, \"%d %d\\n\", &u1, &d1)\n\tfmt.Fscanf(buf, \"%d %d\\n\", &u2, &d2)\n\tif d1 > d2{\n\t\ttmp := d1\n\t\td1 = d2\n\t\td2=tmp\n\n\t\ttmp = u1\n\t\tu1 = u2\n\t\tu2 = tmp\n\t}\n\tans := w+sum(d2,h)\n\t//fmt.Printf(\"ans1=%d\\n\",ans)\n\tans -= u2;\n//\tfmt.Printf(\"ans2=%d\\n\",ans)\n\tif ans < 0 {\n\t\tans = 0\n\t}\n\tans += sum(d1,d2-1)\n//\tfmt.Printf(\"ans3=%d\\n\",ans)\n\tans -= u1;\n//\tfmt.Printf(\"ans4=%d\\n\",ans)\n\tif ans < 0 {\n\t\tans = 0\n\t}\n\tans += sum(1,d1-1)\n\tfmt.Printf(\"%d\\n\",ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "65df4baa3fe91a68104d5a78f2bc411f", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst (\n\tBIG = 1024 * 1024 * 10\n)\n\nfunc readLine(r *bufio.Reader) string {\n\tbytes, _, err := r.ReadLine()\n\tif err != nil {\n\t\tlog.Fatalln(\"Failed to read line\")\n\t}\n\n\treturn string(bytes)\n}\n\nfunc readInts(r *bufio.Reader) []int {\n\telems := strings.Fields(readLine(r))\n\n\tret := make([]int, len(elems))\n\tfor i, el := range elems {\n\t\ttmp, err := strconv.ParseInt(el, 10, 64)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Failed to parse number %v\", el)\n\t\t}\n\t\tret[i] = int(tmp)\n\t}\n\n\treturn ret\n}\n\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, BIG)\n\n\ttmp := readInts(r)\n\tw, h := tmp[0], tmp[1]\n\ttmp = readInts(r)\n\tu1, d1 := tmp[0], tmp[1]\n\ttmp = readInts(r)\n\tu2, d2 := tmp[0], tmp[1]\n\n\tfor i := h; i > 0; i-- {\n\t\tw += i\n\t\tif i == d1 {\n\t\t\tif w > u1 {\n\t\t\t\tw -= u1\n\t\t\t} else {\n\t\t\t\tw = 0\n\t\t\t}\n\t\t} else if i == d2 {\n\t\t\tif w > u2 {\n\t\t\t\tw -= u2\n\t\t\t} else {\n\t\t\t\tw = 0\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(w)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2b427bbe55e6fc78eddff6fd9a4af6bd", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "\npackage main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc readLine()(string,error) \t\t\t{ return reader.ReadString('\\n') }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar w,h,u1,d1,u2,d2 int\n\tscanf(\"%d %d\\n%d %d\\n%d %d\",&w,&h,&u1,&d1,&u2,&d2)\n\tfor i := h; i > 0; i-- {\n\t\tw += i\n\t\tif (i == d1) {\n\t\t\tif (w>u1){\n\t\t\t\tw -= u1\n\t\t\t} else {\n\t\t\t\tw = 0\n\t\t\t}\n\t\t}\n\t\tif (i == d2) {\n\t\t\tif (w>u2){\n\t\t\t\tw -= u2\n\t\t\t} else {\n\t\t\t\tw = 0\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(w)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a01737eaa9c6f842198bac2b60286671", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nAttempting https://codeforces.com/contest/1384/problem/B2\nwhich will take care of B1 also, if works\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t//\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tline1, _ := reader.ReadString('\\n')\n\tline1_arr := strings.Fields(line1)\n\t// fmt.Println(line1_arr)\n\tT, _ := strconv.Atoi(line1_arr[0])\n\t//fmt.Println(\"T:\", T)\n\tfor t := 0; t < T; t++ {\n\t\tline2, _ := reader.ReadString('\\n')\n\t\tline2_arr := strings.Fields(line2)\n\t\tN, _ := strconv.Atoi(line2_arr[0])\n\t\tK, _ := strconv.Atoi(line2_arr[1])\n\t\tL, _ := strconv.Atoi(line2_arr[2])\n\t\t// fmt.Println(N, K, L)\n\t\tline3, _ := reader.ReadString('\\n')\n\t\tAstr := strings.Fields(line3)\n\t\tA := make([]int, N)\n\t\tvar safe []int\n\t\tsoln_possible := true\n\t\tfor i:=0; i L {\n\t\t\t\tfmt.Println(\"No\")\n\t\t\t\tsoln_possible = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t//fmt.Println(\"A:\", A)\n\t\t//fmt.Println(\"safe:\", safe)\n\n\t\tif !soln_possible {\n\t\t\tcontinue\n\t\t}\n\n\t\tsafe_ind := 0\n\t\tlower_bound := -1\n\t\tupper_bound := N\n\t\tif len(safe) > 0 {\n\t\t\tupper_bound = safe[safe_ind]\n\t\t}\n\t\tres := \"Yes\"\n\t\tfor true {\t\t\t\n\n\t\t\tretval := is_path_safe(lower_bound, upper_bound, K, L, A)\n\t\t\t//fmt.Println(\"is_path_safe() beg: \", lower_bound, \"end: \", upper_bound, \"retval: \", retval)\n\t\t\tif !retval {\n\t\t\t\tres = \"No\"\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tif safe_ind > len(safe) -1 {\n\t\t\t\t\tbreak \n\t\t\t\t}\n\n\t\t\t\tlower_bound = safe[safe_ind]\n\t\t\t\tsafe_ind++\n\t\t\t\tif safe_ind > len(safe) -1 {\n\t\t\t\t\tupper_bound = N\n\t\t\t\t} else {\n\t\t\t\t\tupper_bound = safe[safe_ind]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfmt.Println(res)\n\t}\n}\n\nfunc is_path_safe(beg, end, K, L int, A []int) bool {\t\n\tabeg := beg + 1\n\taend := end - 1\n\tif abeg >= aend {\n\t\treturn true\n\t}\n\n\tt := 0\n\tfor i:=abeg; i<=aend; i++ {\n\t\tt = get_time_to_enter(K, L, t, A[i])\n\t\t//fmt.Println(\"t: \", t)\n\t\tif t < 0 {\n\t\t\treturn false\n\t\t}\t\t\n\t}\n\n\t// last step \n\tt++\n\n\t//fmt.Println(\"t: \", t)\n\tif t > 2*K {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/*\nThe precise time pos, where we can enter that position\n*/\nfunc get_time_to_enter(K, L, t, d int) int {\n\t\n\tt++\n\tx := d + K - L\n\tif t >= x && t <= 2 * K - x {\n\t\treturn t\n\t} else if t < x {\n\t\treturn x\n\t} else {\n\t\treturn -1\n\t}\n}\n\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "dp"], "code_uid": "8cc806f81adfbeb19611cd7bcb1342e1", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nconst (\n\tSCANNER_BUF_SIZE = 2 << 20\n\n\tINF = int64(math.MaxInt64)\n\tMOD = 1e9 + 7\n)\n\nvar (\n\twriter *bufio.Writer\n\tscanner *bufio.Scanner\n)\n\nfunc init() {\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)\n}\n\nfunc printf(f string, a ...interface{}) {\n\tfmt.Fprintf(writer, f, a...)\n}\n\nfunc sint64() int64 {\n\tscanner.Scan()\n\tbb := scanner.Bytes()\n\ti := int64(0)\n\tif bb[0] == '-' {\n\t\tfor _, b := range bb[1:] {\n\t\t\ti *= 10\n\t\t\ti -= int64(b - '0')\n\t\t}\n\t\treturn i\n\t}\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += int64(b - '0')\n\t}\n\treturn i\n}\n\nfunc suint64() uint64 {\n\tscanner.Scan()\n\tbb := scanner.Bytes()\n\ti := uint64(0)\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += uint64(b - '0')\n\t}\n\treturn i\n}\n\nfunc sstring() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc gcd(a, b int64) int64 {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int64) int64 {\n\treturn a * b / gcd(a, b)\n}\n\nfunc abs(a int64) int64 {\n\tif a < 0 {\n\t\treturn a * -1\n\t}\n\treturn a\n}\n\nfunc min(a int64, rest ...int64) int64 {\n\tfor _, r := range rest {\n\t\tif r < a {\n\t\t\ta = r\n\t\t}\n\t}\n\treturn a\n}\n\nfunc max(a int64, rest ...int64) int64 {\n\tfor _, r := range rest {\n\t\tif r > a {\n\t\t\ta = r\n\t\t}\n\t}\n\treturn a\n}\n\ntype tide struct {\n\td int64 // delta\n\ti bool // increasing - false by default\n}\n\n// Next adjusts the tide level to the next most optimal value\n// Returns false if unable to do so\nfunc (t *tide) Next(currDepth int64, k, l int64) bool {\n\t// rest spot -> reset params\n\tif currDepth + k <= l {\n\t\tt.d = k\n\t\tt.i = false\n\t\treturn true\n\t}\n\n\t// tide decreasing -> check min\n\tif !t.i {\n\t\tt.d--\n\t\tif currDepth + t.d > l {\n\t\t\tt.d = l - currDepth\n\t\t}\n\t\tif t.d < 0 {\n\t\t\treturn false\n\t\t}\n\t\tif t.d == 0 {\n\t\t\tt.i = true\n\t\t}\n\t\treturn true\n\t}\n\n\t// tide increasing\n\tt.d++\n\tif currDepth + t.d > l {\n\t\treturn false\n\t}\n\tif t.d == k {\n\t\tt.i = false\n\t}\n\treturn true\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tt := sint64()\n\tfor ; t > 0; t-- {\n\t\tn := sint64()\n\t\tk := sint64()\n\t\tl := sint64()\n\t\td := make([]int64, n)\n\t\tfor i := range d {\n\t\t\td[i] = sint64()\n\t\t}\n\t\tprintf(\"%s\\n\", sol(d, n, k, l))\n\t}\n}\n\nfunc sol(d []int64, n, k, l int64) string {\n\tt := &tide{\n\t\td: k,\n\t\ti: false,\n\t}\n\tfor _, di := range d {\n\t\tif !t.Next(di, k, l) {\n\t\t\treturn \"No\"\n\t\t}\n\t}\n\treturn \"Yes\"\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "dp"], "code_uid": "29d82fd8b5ef5ed935a9de0f792e9ffa", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var p, d, t, f, c float32\n fmt.Scan(&p, &d, &t, &f, &c)\n var k, x, r float32\n k = d - p\n x = p * t\n r = 0\n if k > 0 {\n x += x / k * p\n for x < c {\n r++\n x += p * (x / d + f)\n x += x / k * p\n }\n }\n fmt.Println(r)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c23650b655bcdd49669052d47cf14641", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 148B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, d, e, s, i float64\n\tfmt.Scan(&a, &b, &c, &d, &e)\n\tif a < b {\n\t\ts = b * a * c / (b - a)\n\t\tfor i = 0; s < e; i++ {\n\t\t\ts = b * (s + a*(s/b+d)) / (b - a)\n\t\t}\n\t}\n\tfmt.Println(i)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "b85db9a2bf1be028b763c27559c2a7a4", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nvar input io.Reader\n\ntype qu struct {\n\tpos, old int\n}\n\nfunc main() {\n\tvar (\n\t\trecipe string\n\t\tnb, ns, nc int64\n\t\tpb, ps, pc int64\n\t\tcb, cs, cc int64\n\t\trub int64\n\t)\n\tinput = bufio.NewReader(os.Stdin)\n\tfmt.Fscanln(input, &recipe)\n\tfmt.Fscan(input, &nb, &ns, &nc)\n\tfmt.Fscan(input, &pb, &ps, &pc)\n\tfmt.Fscan(input, &rub)\n\n\tfor i := 0; i < len(recipe); i++ {\n\t\tswitch recipe[i] {\n\t\tcase 'B':\n\t\t\tcb++\n\t\tcase 'S':\n\t\t\tcs++\n\t\tcase 'C':\n\t\t\tcc++\n\t\t}\n\t}\n\tl, r := int64(0), int64(1e12+1000)\n\tfor l < r {\n\t\tmid := l + (r-l)/2\n\t\tvar b, s, c int64\n\t\tif cb > 0 {\n\t\t\tb = nn(mid*cb*pb - nb*pb)\n\t\t}\n\t\tif cs > 0 {\n\t\t\ts = nn(mid*cs*ps - ns*ps)\n\t\t}\n\t\tif cc > 0 {\n\t\t\tc = nn(mid*cc*pc - nc*pc)\n\t\t}\n\t\tcost := b + s + c\n\t\tif cost <= rub {\n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\n\tfmt.Println(r - 1)\n}\n\nfunc nn(x int64) int64 {\n\tif x < 0 {\n\t\treturn 0\n\t}\n\treturn x\n}\n", "lang_cluster": "Go", "tags": ["brute force", "binary search"], "code_uid": "1460f540e7b1ae14550c149a5a5c9b6e", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/371/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nconst MaxBurgers = int64(1e13)\n\nfunc max(x, y int64) int64 {\n\tif x >= y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc p(burgers, cb, cs, cc, nb, ns, nc, pb, ps, pc int64) int64 {\n\treturn max(0, cb*burgers-nb)*pb + max(0, cs*burgers-ns)*ps + max(0, cc*burgers-nc)*pc\n}\n\nfunc _Solve(left, right, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles int64) int64 {\n\tif !(left < right) {\n\t\treturn left\n\t}\n\tm := (left + right + 1) / 2\n\tcost := p(m, cb, cs, cc, nb, ns, nc, pb, ps, pc)\n\tif cost <= rubles {\n\t\treturn _Solve(m, right, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles)\n\t}\n\treturn _Solve(left, m-1, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles)\n}\n\nfunc Solve(s string, nb, ns, nc, pb, ps, pc, r int64) int64 {\n\tcb := int64(strings.Count(s, \"B\"))\n\tcs := int64(strings.Count(s, \"S\"))\n\tcc := int64(strings.Count(s, \"C\"))\n\treturn _Solve(0, MaxBurgers, cb, cs, cc, nb, ns, nc, pb, ps, pc, r)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar s string\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\tvar nb, ns, nc int64\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &nb, &ns, &nc)\n\tvar pb, ps, pc int64\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &pb, &ps, &pc)\n\tvar r int64\n\tfmt.Fscanf(reader, \"%d\\n\", &r)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(s, nb, ns, nc, pb, ps, pc, r))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "binary search"], "code_uid": "3f6474eefb2f46cd6c040a1c7f664c30", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc genCount(t string, target map[int]int) {\n\tfor _,ch := range t{\n\t\ttarget[int(ch-'0')]++\n\t}\n\ttarget[2] += target[5]\n\ttarget[6] += target[9]\n\tdelete(target,5)\n\tdelete(target,9)\n}\n\nfunc main() {\n\tvar t,seq string\n\tfmt.Scan(&t,&seq)\n\ttarget := make(map[int]int)\n\tsource := make(map[int]int)\n\tgenCount(t,target)\n\tgenCount(seq,source)\n\tvar cnt int = 200\n\tfor k,_ := range target{\n\t\tif target[k] == 0 {continue}\n\t\tif cnt > source[k]/target[k] {cnt = source[k]/target[k]}\n\t}\n\tfmt.Println(cnt)\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "71db073bd11acb009e476cbb82b350c1", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\n\tscanner.Scan()\n\tm, _ := strconv.Atoi(scanner.Text())\n\n\ta := make([]int, n)\n\tl := make([]int, m)\n\n\ti := 0\n\tfor scanner.Scan() {\n\t\tl[i], _ = strconv.Atoi(scanner.Text())\n\t\tl[i]--\n\t\ti++\n\t}\n\n\tmm := map[int]int{}\n\tfor i := 0; i < m-1; i++ {\n\t\ttmp := (l[i+1] - l[i]) % n\n\t\tif tmp <= 0 {\n\t\t\ttmp += n\n\t\t}\n\t\tif a[l[i]] != 0 && a[l[i]] != tmp {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t}\n\t\ta[l[i]] = tmp\n\t\tif j, ok := mm[a[l[i]]]; ok && j != l[i] {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t}\n\t\tmm[a[l[i]]] = l[i]\n\t}\n\n\t// fill in zeroes\n\tfor i := 0; i < n; i++ {\n\t\tif a[i] != 0 {\n\t\t\tcontinue\n\t\t}\n\t\tfor j := 1; j <= n; j++ {\n\t\t\tif _, ok := mm[j]; !ok {\n\t\t\t\tmm[j] = i\n\t\t\t\ta[i] = j\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Printf(\"%d \", a[i])\n\t}\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "3b08b3ce559cc4346093e4d5bd3b86d4", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b [3]int\n // fmt.Println(i)\n fmt.Scanf(\"%d %d %d\\n\", &a[0], &a[1], &a[2])\n fmt.Scanf(\"%d %d %d\\n\", &b[0], &b[1], &b[2])\n acnt, bcnt := 0, 0\n for i := 0; i < 3; i++ {\n if a[i]-b[i] > 0 {\n acnt += (((a[i] - b[i]) / 2) * 2)\n } else {\n bcnt += (b[i] - a[i])\n }\n }\n //fmt.Println(acnt)\n //fmt.Println(bcnt)\n if acnt/2 >= bcnt {\n fmt.Println(\"Yes\")\n } else {\n fmt.Println(\"No\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "bb7600563f2db103e8ee6d2c51b2e606", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a [3]int\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &a[0], &a[1], &a[2]); err != nil {\n\t\treturn\n\t}\n\tvar x [3]int\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &x[0], &x[1], &x[2]); err != nil {\n\t\treturn\n\t}\n\n\tvar d [3]int\n\tneg := 0\n\tfor i := 0; i < 3; i++ {\n\t\td[i] = a[i] - x[i]\n\t\tif d[i] < 0 {\n\t\t\tneg += d[i]\n\t\t}\n\t}\n\n\tfor neg < 0 {\n\t\tok := false\n\t\tfor i := 0; i < 3; i++ {\n\t\t\tif d[i] >= 2 {\n\t\t\t\tneg++\n\t\t\t\td[i] -= 2\n\t\t\t\tok = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !ok {\n\t\t\tfmt.Println(\"No\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(\"Yes\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "1012cb200d085a436247c1cb19c861dd", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b, c, x, y, z int\n fmt.Scanf(\"%d%d%d\\n\",&a,&b,&c);\n fmt.Scanf(\"%d%d%d\\n\",&x,&y,&z);\n aa := a - x\n if (aa > 0) {\n aa /= 2\n }\n bb := b - y\n if (bb > 0) {\n bb /= 2\n }\n cc := c - z\n if (cc > 0) {\n cc /= 2\n }\n\n ans := aa + bb + cc\n\n if ans >= 0 {\n fmt.Println(\"Yes\")\n } else {\n fmt.Println(\"No\")\n }\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "6b64bba636a8c7ea1d6bc8a4f6fd657f", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nvar d, k, a, b, t, x, alpha, beta, res int64\n\nfunc min(x int64, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tfmt.Fscan(bufin, &d, &k, &a, &b, &t)\n\n\t// only walk\n\tres = b * d\n\n\tif d <= k {\n\t\t// only car without repair\n\t\tres = min(res, a*d)\n\t} else {\n\t\t// only car with repair (x*k >= d)\n\t\tx = (d + k - 1) / k\n\t\tres = min(res, a*d+(x-1)*t)\n\n\t\t// car with repair and then walk\n\t\talpha = k*a - k*b + t\n\t\tbeta = b*d - t\n\n\t\tif alpha >= 0 {\n\t\t\tres = min(res, alpha+beta)\n\t\t} else {\n\t\t\tx = d / k\n\t\t\tres = min(res, x*alpha+beta)\n\t\t}\n\t}\n\n\tfmt.Fprintln(bufout, res)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "7a887c34fe7cc1e83bb402fc197e0c7d", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar k_cf702d, a_cf702d, b_cf702d, t_cf702d int64\n\nfunc startCar(d int64) float64 {\n\tif d <= int64(k_cf702d) {\n\t\treturn float64(int64(a_cf702d)*d)\n\t}\n\treturn float64(a_cf702d*k_cf702d) + math.Min(float64(float64(t_cf702d) + startCar(d-int64(k_cf702d))), float64(int64(b_cf702d)*(d-int64(k_cf702d))))\n}\n\nfunc main() {\n\n\t//fmt.Printf(\"%f\\n\", math.MaxFloat64)\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tscanner.Buffer([]byte{}, int(math.Pow(10,8)))\n\n\tscanner.Scan()\n\tdkabtStr := scanner.Text()\n\tdkabtStrArr := strings.Split(dkabtStr, \" \")\n\td, _ := strconv.ParseInt(dkabtStrArr[0], 10, 64)\n\tk_cf702d, _ = strconv.ParseInt(dkabtStrArr[1], 10, 64)\n\ta_cf702d, _ = strconv.ParseInt(dkabtStrArr[2], 10, 64)\n\tb_cf702d, _ = strconv.ParseInt(dkabtStrArr[3], 10, 64)\n\tt_cf702d, _ = strconv.ParseInt(dkabtStrArr[4], 10, 64)\n\n\tvar resp int64\n\tif d <= k_cf702d {\n\t\tresp = a_cf702d * d\n\t} else {\n\t\tresp = a_cf702d*k_cf702d\n\t\td -= k_cf702d\n\t\tcarAvg := (float64(t_cf702d)/float64(k_cf702d)) + float64(a_cf702d)\n\t\tif carAvg <= float64(b_cf702d) {\n\t\t\tonCar := d / k_cf702d\n\t\t\tresp += onCar * (t_cf702d + a_cf702d*k_cf702d)\n\t\t\tremainingDist := d % k_cf702d\n\t\t\tremaining := int64(math.Min(float64(t_cf702d + a_cf702d*remainingDist), float64(b_cf702d*remainingDist)))\n\t\t\tresp += remaining\n\t\t\t//resp += float64(d - int64(k_cf702d)) * carAvg\n\t\t} else {\n\t\t\tresp += d * b_cf702d\n\t\t}\n\t}\n\n\t//resp := math.Min(float64(int64(b_cf702d)*d), startCar(d))\n\n\tfmt.Printf(\"%v\\n\", resp)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "05ef81489b528c3deb1492c7e5200825", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF702D(in io.Reader, out io.Writer) {\n\tvar d, k, a, b, t int64\n\tFscan(in, &d, &k, &a, &b, &t)\n\tans := b * d\n\tfor _, x := range []int64{k * ((d - 1) / k), k, d} {\n\t\tif 0 < x && x <= d {\n\t\t\tif v := a*x + ((x-1)/k)*t + (d-x)*b; v < ans {\n\t\t\t\tans = v\n\t\t\t}\n\t\t}\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF702D(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "4b9d842bb4de362a712f5c8341a7528a", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "\npackage main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nvar stdin *bufio.Reader\nvar stdout *bufio.Writer\n\nfunc init() {\n\tstdin = bufio.NewReader(os.Stdin)\n stdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc check(grid [][]int, row1, row2, col1, col2 int) int {\n\tcount := 0\n\tfor i := row1; i <= row2; i++ {\n\t\tfor j := col1; j <= col2; j++ {\n\t\t\tcount += grid[i][j]\n\t\t}\n\t}\n\treturn count\n}\n\nfunc main() {\n\n\tr, c, n, k := 0, 0, 0, 0\n\tfmt.Fscanf(stdin, \"%d%d%d%d\\n\", &r, &c, &n, &k)\n\t\n\tgrid := make([][]int, r)\n\tfor i := 0; i < r; i++ {\n\t\tgrid[i] = make([]int, c)\n\t}\n\t\n\tfor i := 0; i < n; i++ {\n\t\tx, y := 0, 0\n\t\tfmt.Fscanf(stdin, \"%d%d\\n\", &x, &y)\n\t\tgrid[x - 1][y - 1] = 1;\n\t}\n\t\n\tcount := 0\n\t\n\tfor r1 := 0; r1 < r; r1++ {\n\t\tfor r2 := r1; r2 < r; r2++ {\n\t\t\tfor c1 := 0; c1 < c; c1++ {\n\t\t\t\tfor c2 := c1; c2 < c; c2++ {\n\t\t\t\t\tif check(grid, r1, r2, c1, c2) >= k {\n\t\t\t\t\t\tcount++\n\t\t\t\t\t}\n\t\t\t\t} \n\t\t\t}\n\t\t}\n\t}\n\t\n\n\tfmt.Fprintf(stdout, \"%d\\n\", count)\n\n stdout.Flush()\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "4164b8d55c4ed1685ded70f6d0f6040d", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar (\n\tin = bufio.NewReader(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\tdefer out.Flush()\n\tvar r, c, n, k int\n\tfmt.Fscan(in, &r, &c, &n, &k)\n\ta := make([][]int, r)\n\tfor i := range a {\n\t\ta[i] = make([]int, c)\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tvar x, y int\n\t\tfmt.Fscan(in, &x, &y)\n\t\ta[x-1][y-1]++\n\t}\n\tans := 0\n\tfor x0 := 0; x0 < r; x0++ {\n\t\tfor y0 := 0; y0 < c; y0++ {\n\t\t\tfor x1 := x0; x1 < r; x1++ {\n\t\t\t\tfor y1 := y0; y1 < c; y1++ {\n\t\t\t\t\tcount := 0\n\t\t\t\t\tfor x := x0; x <= x1; x++ {\n\t\t\t\t\t\tfor y := y0; y <= y1; y++ {\n\t\t\t\t\t\t\tcount += a[x][y]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif count >= k {\n\t\t\t\t\t\tans++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintln(out, ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "f8223a4c74385e793afb83ecc6420619", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nfunc ReadInt64(scanner *bufio.Scanner) int64 {\n scanner.Scan()\n ans, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return ans\n}\n\nfunc ReadString(scanner *bufio.Scanner) string {\n scanner.Scan()\n ans := scanner.Text()\n return ans\n}\n\nfunc PrintInt(writer *bufio.Writer, value int64) {\n writer.WriteString(strconv.FormatInt(value, 10))\n writer.WriteByte(' ')\n}\n\nfunc PrintInts(writer *bufio.Writer, ints ...int) {\n for _, value := range ints {\n writer.WriteString(strconv.Itoa(value))\n writer.WriteByte(' ')\n }\n writer.WriteByte('\\n')\n}\n\nfunc main() {\n var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n var writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n\n n, k := ReadInt64(scanner), ReadInt64(scanner)\n hn := n / 2\n total := n * (n - 1) / 2\n\n if k >= hn {\n k = hn\n PrintInt(writer, total)\n return \n }\n\n total -= (n - k) * (n - k - 1) / 2\n total += k * (n - 2 * k)\n total += k * (k - 1) / 2\n\n PrintInt(writer, total)\n writer.WriteByte('\\n')\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "ff436ec7983d4c72da89396af0ce177d", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc main() {\n\tdefer out.Flush()\n\tn := in.NextInt()\n\tk := in.NextInt()\n\tif k > n/2 {\n\t\tk = n / 2\n\t}\n\tans := int64(0)\n\tfor i := 1; i <= k; i++ {\n\t\tans += int64(n - i)\n\t\tans += int64(n - k - i)\n\t}\n\tfmt.Fprintln(out, ans)\n}\n\nvar (\n\tin = NewFastReader(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\ntype FastReader struct {\n\tr *bufio.Reader\n\tbuf string\n}\n\nfunc NewFastReader(r io.Reader) *FastReader {\n\treturn &FastReader{\n\t\tr: bufio.NewReader(r),\n\t}\n}\n\nfunc (r *FastReader) advance() {\n\tfor len(r.buf) != 0 && r.buf[0] == ' ' {\n\t\tr.buf = r.buf[1:]\n\t}\n\tfor len(r.buf) == 0 {\n\t\tvar buf bytes.Buffer\n\t\tfor {\n\t\t\tchunk, more, _ := r.r.ReadLine()\n\t\t\tbuf.Write(chunk)\n\t\t\tif !more {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tr.buf = buf.String()\n\t}\n}\n\nfunc (r *FastReader) NextLine() string {\n\tr.advance()\n\tline := r.buf\n\tr.buf = \"\"\n\treturn line\n}\n\nfunc (r *FastReader) NextWord() string {\n\tr.advance()\n\tvar word string\n\twordStart := 0\n\tfor i := 0; i < len(r.buf); i++ {\n\t\tb := r.buf[i]\n\t\tif b == ' ' {\n\t\t\tif i != wordStart {\n\t\t\t\tword = r.buf[wordStart:i]\n\t\t\t\tr.buf = r.buf[i:]\n\t\t\t\tbreak\n\t\t\t}\n\t\t\twordStart = i + 1\n\t\t}\n\t}\n\tif len(word) == 0 {\n\t\tword = r.buf\n\t\tr.buf = \"\"\n\t}\n\treturn word\n}\n\nfunc (r *FastReader) NextInt() int {\n\treturn parseInt(r.NextWord())\n}\n\nfunc parseInt(word string) int {\n\tsign := 1\n\tif word[0] == '-' {\n\t\tsign = -1\n\t\tword = word[1:]\n\t}\n\tresult := 0\n\tfor i := 0; i < len(word); i++ {\n\t\tresult = result*10 + int(word[i]) - '0'\n\t}\n\tresult *= sign\n\treturn result\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "df05e7b0be9b944e9d0cdb7ee177d693", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 655B done\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\n\nfunc main() {\n\t// reading n,k\n\tin := bufio.NewReader(os.Stdin)\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\treturn\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tn, err1 := strconv.Atoi(ss[0])\n\tif err1 != nil {\n\t\tfmt.Println(\"n atoi failure\", err1)\n\t\treturn\n\t}\n\tk, err2 := strconv.Atoi(ss[1])\n\tif err2 != nil {\n\t\tfmt.Println(\"k atoi failure\", err1)\n\t\treturn\n\t}\n\n\t// calculating\n\tcnt := int64(0)\n\tfor i:=0; i t {\n\t\t\tres++\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "558d73b495ea7e30938eb3bd31ae5110", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, ta, b, tb int\n var h, m int\n fmt.Scanf(\"%d %d\\n\",&a, &ta)\n fmt.Scanf(\"%d %d\\n\", &b, &tb)\n fmt.Scanf(\"%d:%d\", &h, &m)\n\n start := 300\n end := 60 * 24 - 1\n\n meets := 0\n\n simon_start := h * 60 + m\n simon_end := simon_start + ta\n //fmt.Println(simon_start, simon_end)\n for start <= end {\n bus_start := start\n bus_end := start + tb\n\n if bus_start <= simon_start && bus_end > simon_start {\n meets++\n }\n if bus_start > simon_start && bus_start < simon_end {\n meets++\n }\n\n //if (bus_start < simon_end && bus_start >= simon_start) || (bus_end < simon_end && bus_end > simon_start) {\n // meets++\n // fmt.Println(bus_start, bus_end)\n //}\n //next bus from B\n start += b\n }\n\n fmt.Println(meets)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f6ef662be4b2651d1a437adbca4f15b6", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tfield := make([][]int, 4)\n\tfor i := 0; i < 4; i++ {\n\t\tfield[i] = make([]int, 4)\n\t\tfor j, ch := range readString() {\n\t\t\tswitch ch {\n\t\t\tcase 'x':\n\t\t\t\tfield[i][j] = 1\n\t\t\tcase 'o':\n\t\t\t\tfield[i][j] = 2\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 4; i++ {\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tif field[i][j] == 0 {\n\t\t\t\tfield[i][j] = 1\n\t\t\t\tif win(field) {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfield[i][j] = 0\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc win(field [][]int) bool {\n\tfor j := 0; j < 4; j++ {\n\t\tfor i := 0; i < 2; i++ {\n\t\t\tif field[j][i] == 1 && field[j][i+1] == 1 && field[j][i+2] == 1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\tfor j := 0; j < 4; j++ {\n\t\tfor i := 0; i < 2; i++ {\n\t\t\tif field[i][j] == 1 && field[i+1][j] == 1 && field[i+2][j] == 1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 2; i++ {\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tif field[i][j] == 1 && field[i+1][j+1] == 1 && field[i+2][j+2] == 1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 2; i++ {\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tif field[i][3-j] == 1 && field[i+1][3-j-1] == 1 && field[i+2][3-j-2] == 1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "ca0132401a4ac22dab2073fbb78c8ceb", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 754 B IlyaTicTacToe,\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n\tvar a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor i:=0; i=4 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor x0:=0; x0<4; x0++ {\n\t\t\t\tx1 := x0+2*dx[dir]\n\t\t\t\tif x1<0 || x1>=4 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tcntX := 0\n\t\t\t\tcntO := 0\n\t\t\t\tfor k:=0; k<3; k++ {\n\t\t\t\t\txx := x0 + k*dx[dir]\n\t\t\t\t\tyy := y0 + k*dy[dir]\n\t\t\t\t\tif field[yy][xx]=='x' {\n\t\t\t\t\t\tcntX++\n\t\t\t\t\t} else if field[yy][xx]=='o' {\n\t\t\t\t\t\tcntO++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif cntX>=2 && cntO==0 {\n\t\t\t\t\tcanWin = \"YES\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc printRes() {\n\tfmt.Println(canWin)\n}\n\nfunc main() {\n\treadData()\n\tsolve()\n\tprintRes()\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "fc269da12ebd0484f23ec03f1869ca8c", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nconst size int = 4;\nfunc solve(T []string,x int,y int) bool{\n //fmt.Println(x,y);\n T[x]=T[x][:y]+string('x')+T[x][y+1:];\n possible:=false;\n for i:=0;i=0&&nx=0&&ny 0 {\n n = n/b\n ans += 1\n }\n return ans\n}\n\nfunc base(s string, b int) int {\n ans := 0\n k := len(s) - 1\n for i := 0; i < len(s); i++ {\n ans += (int(s[i])-48) * int(math.Pow(float64(b), float64(k)))\n k -= 1\n }\n return ans\n}\n\nfunc main(){\n var a, b int\n fmt.Scan(&a)\n fmt.Scan(&b)\n x := strconv.Itoa(a) + strconv.Itoa(b)\n z := uint8(48)\n for i := 0; i < len(x); i++ {\n if z < x[i] {\n z = x[i]\n }\n }\n d := int(z - 47)\n sum := base(strconv.Itoa(a), d) + base(strconv.Itoa(b), d)\n fmt.Print(base1(sum, d))\n \n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "f3c21215601bc6fde87d11fc922a79bb", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc mabs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar s, x1, x2, t1, t2, p, d int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &s, &x1, &x2, &t1, &t2, &p, &d)\n\tbest := mabs(x1-x2) * t2\n\ttraintime := 0\n\tif d == 1 {\n\t\tif p <= x1 {\n\t\t\ttraintime = (x1 - p) * t1\n\t\t} else {\n\t\t\ttraintime = (s-p)*t1 + (s-x1)*t1\n\t\t\td = -1\n\t\t}\n\t} else {\n\t\tif p >= x1 {\n\t\t\ttraintime = (p - x1) * t1\n\t\t} else {\n\t\t\ttraintime = (p * t1) + (x1 * t1)\n\t\t\td = 1\n\t\t}\n\t}\n\tif d == 1 {\n\t\tif x1 < x2 {\n\t\t\ttraintime += (x2 - x1) * t1\n\t\t} else {\n\t\t\ttraintime += (s-x1)*t1 + (s-x2)*t1\n\t\t}\n\t} else {\n\t\tif x2 < x1 {\n\t\t\ttraintime += (x1 - x2) * t1\n\t\t} else {\n\t\t\ttraintime += x1*t1 + x2*t1\n\t\t}\n\t}\n\tif traintime < best {\n\t\tbest = traintime\n\t}\n\tfmt.Println(best)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "13581f63a94c4baae51cc72cf1e9667d", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s, x1, x2, t1, t2, p, d int\n\tfmt.Scan(&s, &x1, &x2, &t1, &t2, &p, &d)\n\tbyFoot := abs(x1-x2) * t2\n\twT := abs(p-x1) * t1\n\tif x1 < p {\n\t\tif d == 1 {\n\t\t\twT += 2 * (s - p) * t1\n\t\t\td = -1\n\t\t}\n\t} else if x1 > p {\n\t\tif d == -1 {\n\t\t\twT += 2 * p * t1\n\t\t\td = 1\n\t\t}\n\t}\n\ttT := abs(x1-x2) * t1\n\tif x1 < x2 {\n\t\tif d == -1 {\n\t\t\ttT += 2 * x1 * t1\n\t\t}\n\t} else {\n\t\tif d == 1 {\n\t\t\ttT += 2 * (s - x1) * t1\n\t\t}\n\t}\n\n\tbyTrain := tT + wT\n\tfmt.Println(min(byFoot, byTrain))\n}\n\nfunc min(a, b int) int {\n\tmin := a\n\tif b < a {\n\t\tmin = b\n\t}\n\treturn min\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -1 * x\n\t}\n\treturn x\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "b35b14049c495f48eecd6277aa4eacdb", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\nfunc getLine2Int3() (a, b, c int) {\n\tscanf(\"%d %d %d\\n\", &a, &b, &c)\n\treturn\n}\nfunc getLine2Ints(n int) []int64 {\n\tans := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d \", &ans[i])\n\t}\n\tscanf(\"%d\\n\", &ans[n-1])\n\treturn ans\n}\n\nfunc pcheck(i bool) {\n\tif i {\n\t\tprintf(\"Yes\\n\")\n\t} else {\n\t\tprintf(\"No\\n\")\n\t}\n}\n\nvar debug = true\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\ts, x1, x2 := getLine2Int3()\n\tt1, t2 := getLine2Int2()\n\tp, d := getLine2Int2()\n\n\tfast1, fast2 := abs(x2-x1)*t2, 0\n\tif p < x1 && d == -1 {\n\t\tfast2 += p * t1\n\t\td = 1\n\t\tp = 0\n\t} else if p > x1 && d == 1 {\n\t\tfast2 += (s - p) * t1\n\t\td = -1\n\t\tp = s\n\t}\n\tfast2 += abs(p-x1) * t1\n\tp = x1\n\tif p < x2 && d == -1 {\n\t\tfast2 += p * t1\n\t\td = 1\n\t\tp = 0\n\t} else if p > x2 && d == 1 {\n\t\tfast2 += (s - p) * t1\n\t\td = -1\n\t\tp = s\n\t}\n\tfast2 += abs(p-x2) * t1\n\tp = x2\n\tif fast1 < fast2 {\n\t\tprintf(\"%d\\n\", fast1)\n\t} else {\n\t\tprintf(\"%d\\n\", fast2)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "9cd46a7f042a2cf5ccb5b84a18678b8b", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tx := int64(8 * 9 * 5 * 7)\n\tvar n int64\n\tfmt.Scan(&n)\n\tfmt.Println(n / x)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "1957fc16eb4b970e6cacab91a57e516c", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nfunc main() {\n var a int64\n fmt.Scanf(\"%d\", &a)\n fmt.Println(a / 2520)\n}", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "72dfd29abcc2160486d6a50db3245eeb", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//\n//\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nconst LCM int64 = 2520\n\nfunc main() {\n\tvar n int64\n\tif _, err := fmt.Scanf(\"%d\", &n); err != nil {\n\t\tfmt.Println(\"Error: Scanf:\", err)\n\t\tos.Exit(1)\n\t}\n\n\tfmt.Println(n / LCM)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "26026e99ab727a0451ccd42f75b846fe", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc calc(x, n int64) int64 {\n\tsum := int64((x + 1) * n * (n - 1) / 2)\n\n\tsum += n * (x) * (x + 1) / 2\n\t//for i := x; i >= 0; i-- {\n\t//\tsum += n * i\n\t//}\n\treturn sum\n}\n\nfunc main() {\n\tsc := NewScanner()\n\tM, B := sc.NextInt64(), sc.NextInt64()\n\n\tmx := int64(0)\n\tfor x := int64(0); x <= M*B; x++ {\n\t\tif x < 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\ty := -((x - B*M) / M)\n\n\t\tif y < 0 {\n\t\t\tcontinue\n\t\t}\n\t\tn := y + 1\n\t\tq := calc(x, n)\n\t\tif mx < q {\n\t\t\tmx = q\n\t\t}\n\t}\n\tfmt.Println(mx)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "7b20ff2484f1fca93b2c9ad524a51123", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar fileName = \"\"\nvar sc *Scanner = getScanner()\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc getScanner() *Scanner {\n\tif len(fileName) <= 0 {\n\t\treturn NewScanner(os.Stdin)\n\t}\n\tvar file, err = os.Open(fileName)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn NewScanner(bufio.NewReader(file))\n}\n\ntype Scanner struct {\n\tr io.Reader\n\tsplit bufio.SplitFunc\n\tmaxTokenSize int\n\ttoken, buf []byte\n\tstart, end int\n}\n\nfunc NewScanner(r io.Reader) *Scanner {\n\treturn &Scanner{\n\t\tr: r,\n\t\tsplit: bufio.ScanWords,\n\t\tmaxTokenSize: 16777216,\n\t\tbuf: make([]byte, 4096),\n\t}\n}\n\nfunc (s *Scanner) advance(n int) bool {\n\tif n < 0 || n > s.end-s.start {\n\t\treturn false\n\t}\n\ts.start += n\n\treturn true\n}\n\nfunc (s *Scanner) Text() string {\n\treturn string(s.token)\n}\n\nfunc (s *Scanner) Scan() bool {\n\tfor {\n\t\tif s.end > s.start {\n\t\t\tadvance, token, err := s.split(s.buf[s.start:s.end], false)\n\t\t\tif err != nil || !s.advance(advance) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ts.token = token\n\t\t\tif token != nil {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\tif s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {\n\t\t\tcopy(s.buf, s.buf[s.start:s.end])\n\t\t\ts.end -= s.start\n\t\t\ts.start = 0\n\t\t}\n\t\tif s.end == len(s.buf) {\n\t\t\tif len(s.buf) >= s.maxTokenSize {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tnewSize := len(s.buf) * 2\n\t\t\tif newSize > s.maxTokenSize {\n\t\t\t\tnewSize = s.maxTokenSize\n\t\t\t}\n\t\t\tnewBuf := make([]byte, newSize)\n\t\t\tcopy(newBuf, s.buf[s.start:s.end])\n\t\t\ts.buf = newBuf\n\t\t\ts.end -= s.start\n\t\t\ts.start = 0\n\t\t\tcontinue\n\t\t}\n\t\tfor loop := 0; ; {\n\t\t\tn, _ := s.r.Read(s.buf[s.end:len(s.buf)])\n\t\t\ts.end += n\n\t\t\tif n > 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tloop++\n\t\t\tif loop > 100 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc (s *Scanner) Split(split bufio.SplitFunc) {\n\ts.split = split\n}\n\nfunc printSpace() { w.WriteByte(' ') }\nfunc println() { w.WriteByte('\\n') }\n\nfunc nextToken() string { sc.Scan(); return sc.Text() }\n\nfunc nextInt() int {\n\tsc.Scan()\n\tn, _ := strconv.Atoi(sc.Text())\n\treturn n\n}\n\nfunc nextInt64() int64 {\n\tsc.Scan()\n\tn, _ := strconv.ParseInt(sc.Text(), 10, 64)\n\treturn n\n}\n\nfunc printInt(i ...int) {\n\tfor _, ii := range i {\n\t\tw.WriteString(strconv.Itoa(ii))\n\t\tprintSpace()\n\t}\n}\n\nfunc printInt64(i ...int64) {\n\tfor _, ii := range i {\n\t\tw.WriteString(strconv.FormatInt(ii, 10))\n\t\tprintSpace()\n\t}\n}\n\nfunc print(s ...string) {\n\tfor _, ss := range s {\n\t\tw.WriteString(ss)\n\t\tprintSpace()\n\t}\n}\n\nfunc min(i, j int) int {\n\tif i < j {\n\t\treturn i\n\t}\n\treturn j\n}\n\nfunc max(i, j int) int {\n\tif i > j {\n\t\treturn i\n\t}\n\treturn j\n}\n\nfunc min64(i, j int64) int64 {\n\tif i < j {\n\t\treturn i\n\t}\n\treturn j\n}\n\nfunc max64(i, j int64) int64 {\n\tif i > j {\n\t\treturn i\n\t}\n\treturn j\n}\n\nfunc main() {\n\tdefer w.Flush()\n\n\tm := nextInt64()\n\tb := nextInt64()\n\n\tresult := int64(0)\n\tfor y := int64(0); y <= b; y++ {\n\t\tx := int64((b - y) * m)\n\n\t\tsq := int64(0)\n\t\tfor t := int64(0); t <= y; t++ {\n\t\t\tsq += (t + (x + t)) * (x + 1) / 2\n\t\t}\n\n\t\tresult = max64(result, sq)\n\t}\n\n\tprintInt64(result)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "8e4bdadfc8d6a060ac6697c692d30cf2", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar W, B int\n\tScan(&W, &B)\n\tdp := make([][][2]float64, W+1)\n\tfor i := range dp {\n\t\tdp[i] = make([][2]float64, B+1)\n\t\tfor j := range dp[i] {\n\t\t\tdp[i][j] = [2]float64{-1, -1}\n\t\t}\n\t}\n\tvar f func(w, b, who int) float64\n\tf = func(w, b, who int) (res float64) {\n\t\tif w <= 0 {\n\t\t\tif who == 0 {\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\treturn 1\n\t\t}\n\t\tif b <= 0 {\n\t\t\treturn 1\n\t\t}\n\t\tdv := &dp[w][b][who]\n\t\tif *dv != -1 {\n\t\t\treturn *dv\n\t\t}\n\t\tdefer func() { *dv = res }()\n\t\tif who == 0 {\n\t\t\treturn (float64(w) + float64(b)*(1-f(w, b-1, 1))) / float64(w+b)\n\t\t}\n\t\tp := (float64(w)*f(w-1, b-1, 0) + float64(b-1)*f(w, b-2, 0)) / float64(w+b-1)\n\t\treturn (float64(w) + float64(b)*(1-p)) / float64(w+b)\n\t}\n\tPrintf(\"%.10f\", f(W, B, 0))\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "probabilities", "games"], "code_uid": "6ca375561cd312c4984bf13b5fba7a8f", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tdivs := []int{130816, 32640, 8128, 2016, 496, 120, 28, 6, 1}\n\tn := readInt()\n\tfor _, k := range divs {\n\t\tif n%k == 0 {\n\t\t\tfmt.Println(k)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "a24780da9965aa44127435f984075e9c", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\n//aのb乗をします O(log b)\nfunc pow(a int, b int) int {\n\ttotal := 1\n\ttmp := a\n\tfor b > 0 {\n\t\tif b%2 == 1 {\n\t\t\ttotal *= tmp\n\t\t}\n\t\tb /= 2\n\t\ttmp *= tmp\n\t}\n\treturn total\n}\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\tmx := 0\n\tfor k := uint(1); ; k++ {\n\t\tl := ((1 << k) - 1) * (1 << (k - 1))\n\t\tif l > N {\n\t\t\tbreak\n\t\t}\n\t\tif N%l == 0 {\n\t\t\tmx = l\n\t\t}\n\t}\n\tfmt.Println(mx)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "2d1806af16808d160a383041edd94293", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar days = []int32{\n\t31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,\n\t31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,\n\t31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,\n\t31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,\n\t31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,\n\t31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,\n\t31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,\n\t31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,\n}\n\nfunc main() {\n\tvar n int\n\tvar a [24]int32\n\tfmt.Scan(&n)\n\tvar id = -1\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t\tif id == -1 && (a[i] == 28 || a[i] == 29) {\n\t\t\tid = i\n\t\t}\n\t}\n\tif id != -1 {\n\t\tif id+12 < n {\n\t\t\tif a[id+12] != 28 && a[id+12] != 29 {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif a[id] == 29 && a[id+12] == 29 {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\ta[id+12] = 28\n\t\t}\n\t\ta[id] = 28\n\t}\n\tfor i := 0; i < 12; i++ {\n\t\tvar yes = true\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif a[j] != days[i+j] {\n\t\t\t\tyes = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif yes {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d987eccd0c7a4d727082cb09f978325b", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tn, x, y, c := 0, 0, 0, int64(0)\n\tfmt.Scan(&n, &x, &y, &c)\n\tr,l,m:=n*2+1,-1,0\n\tfor r-l>1{\n\t\tm = int((int64(r)+int64(l))/2)\n\t\ttiles:=count(n,x,y,m)\n\t\tif (tiles0) {out+=(sq(h)+h)/2}\n\th=t-dist(x,y,n,0)\n\tif (h>0) {out+=(sq(h)+h)/2}\n\th=t-dist(x,y,1,n+1)\n\tif (h>0) {out+=(sq(h)+h)/2}\n\th=t-dist(x,y,n,n+1)\n\tif (h>0) {out+=(sq(h)+h)/2}\n\treturn out\n}\n\nfunc sq(n int64) int64 {if (n<0) {return 0}else{return n*n}}\nfunc dist(x1,y1,x2,y2 int64) int64 {return abs(x1-x2)+abs(y1-y2)}\nfunc abs(n int64) int64 {if (n<0) {return -n}else{return n}}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "binary search"], "code_uid": "b903e1eeec8d61a1cff308a76c884f56", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\ntype key struct {\n\tlastIdx int\n\tnDifferent int\n}\n\nvar (\n\tn, m, k int\n\tcache = make(map[key]int64)\n)\n\n// colorings will calculate how many different colorings are at a[0]..a[lastIdx], so that nDifferent for 0..lastIdx holds.\nfunc colorings(lastIdx int, nDifferent int) (ret int64) {\n\tk := key{lastIdx, nDifferent}\n\tif r, ok := cache[k]; ok {\n\t\treturn r\n\t}\n\tdefer func() {\n\t\tcache[k] = ret\n\t}()\n\n\t// We have spent all our different brick possibilities.\n\tif nDifferent < 0 {\n\t\treturn 0\n\t}\n\n\tif lastIdx == 0 {\n\t\tif nDifferent == 0 {\n\t\t\t// If there is only one brick remaining, it can have m different colors.\n\t\t\treturn int64(m)\n\t\t}\n\t\t// But only, if there is exactly zero bricks different on its left.\n\t\treturn 0\n\t}\n\n\t// There are p combinations for 0..lastIdx-1. For each combination:\n\t// - there is (m-1) combinations with nDifferent that is the same\n\t// - one combination with nDifferent less.\n\tlastIdxDifferent := colorings(lastIdx-1, nDifferent-1) * int64(m-1)\n\tlastIdxSame := colorings(lastIdx-1, nDifferent)\n\t// dprintf(\"lastIdx=%d, nDifferent=%d, noDiff=%d, diff=%d\", lastIdx, nDifferent, noDiffChange, diffChange)\n\n\treturn (lastIdxDifferent + lastIdxSame) % 998244353\n\n\t// m combinations where [lastIdx-1, lastIdx are the same]\n\t// m**2 - m combinations where [lastIdx-1 and lastIdx are different]\n}\n\nfunc dprintf(i string, a ...interface{}) {\n\tif false {\n\t\tfmt.Printf(i+\"\\n\", a...)\n\t}\n}\n\nfunc main() {\n\tfmt.Scanf(\"%d %d %d\", &n, &m, &k)\n\tfmt.Println(colorings(n-1, k))\n\tdprintf(\"%v\", cache)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "9d058932629f1ff40222f0e91ccc3e3e", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst (\n\tmod = 998244353\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn, m, k := 0, 0, 0\n\tfmt.Fscanf(in, \"%d %d %d\\n\", &n, &m, &k)\n\tf := make([][]int64, n+1)\n\tfor i := 0; i < n+1; i++ {\n\t\tf[i] = make([]int64, k+1)\n\t}\n\tf[1][0] = int64(m)\n\tfor i := 2; i < n+1; i++ {\n\t\tfor j := 0; j < k+1; j++ {\n\t\t\tif j == 0 {\n\t\t\t\tf[i][j] = f[i-1][j]\n\t\t\t} else {\n\t\t\t\tf[i][j] = f[i-1][j] + f[i-1][j-1]*int64(m-1)\n\t\t\t\tf[i][j] %= mod\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", f[n][k])\n\treturn\n}", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "5c76eae929282587d52c2d40afcdb5b0", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"math\"\n)\n\nconst N = int(1e5)\n\nvar n, d int\nvar x [N]int\n\nfunc main() {\n\tfmt.Scanf(\"%d %d\\n\", &n, &d)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &x[i])\n\t}\n\tsort.Ints(x[:n])\n\tres := N\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i; j < n; j++ {\n\t\t\tif x[j] - x[i] <= d {\n\t\t\t\tres = int(math.Min(float64(res), float64(n - j + i - 1)))\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "sortings", "greedy"], "code_uid": "01eeed90973c2ee1063f7f3b220779ae", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype diameter struct {\n\tio *IO\n}\n\nfunc (d *diameter) out(deleteN int) {\n\td.io.Printf(\"%d\", deleteN)\n}\n\nfunc main() {\n\t//log.SetOutput(os.Stdout)\n\tlog.SetOutput(ioutil.Discard)\n\n\tio := NewStdIO()\n\tdefer io.Flush()\n\td := diameter{io: io}\n\n\tl1 := d.io.NextSplitLine(\" \")\n\tn, dmax := stoi(l1[0]), stoi(l1[1])\n\tlog.Printf(\"n=%d, dmax=%d\", n, dmax)\n\n\tif n <= 1 {\n\t\td.out(0)\n\t\treturn\n\t}\n\n\tl2 := d.io.NextSplitLine(\" \")\n\tnset := make([]int, n)\n\tfor i, ns := range l2 {\n\t\tnset[i] = stoi(ns)\n\t}\n\tsort.Ints(nset)\n\n\tminN := n + 1\n\tfor i := 0; i < n; i++ {\n\t\tcnt := 0\n\t\tfor j := i; j < n; j++ {\n\t\t\tcnt++\n\t\t\tlog.Printf(\"i=%d, j=%d, minN=%d\", i, j, minN)\n\t\t\tif (nset[j] - nset[i]) <= dmax {\n\t\t\t\tminN = min(minN, n-cnt)\n\t\t\t}\n\t\t}\n\t}\n\td.out(minN)\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc stoi(s string) int {\n\ti, err := strconv.Atoi(s)\n\tif err != nil {\n\t\tfmt.Println(i)\n\t\tfmt.Println(err)\n\t}\n\treturn i\n}\n\n// NewStdIO return standard IO instance.\nfunc NewStdIO() *IO {\n\treturn &IO{\n\t\tIn: bufio.NewReader(os.Stdin),\n\t\tOut: bufio.NewWriter(os.Stdout),\n\t}\n}\n\n// IO supports IO processing.\ntype IO struct {\n\tIn *bufio.Reader\n\tOut *bufio.Writer\n}\n\n// Flush outputs buffed data.\nfunc (io *IO) Flush() {\n\tif err := io.Out.Flush(); err != nil {\n\t\tpanic(err)\n\t}\n}\n\n// Printf writes string to buffer.\nfunc (io *IO) Printf(format string, a ...interface{}) {\n\tif _, err := fmt.Fprintf(io.Out, format, a...); err != nil {\n\t\tpanic(err)\n\t}\n}\n\n// NextInt reads a next line and convert it to integer\nfunc (io *IO) NextInt() int {\n\treturn stoi(io.Next())\n}\n\n// NextSplitLine reads a next line and return split string\nfunc (io *IO) NextSplitLine(d string) []string {\n\treturn strings.Split(io.Next(), d)\n}\n\n// Next reads line and return string.\nfunc (io *IO) Next() string {\n\tvar b []byte\n\tfor {\n\t\tl, pre, err := io.In.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tb = append(b, l...)\n\t\tif !pre {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(b)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "sortings", "greedy"], "code_uid": "4252271a42b313bf98bdbd725cb6ae40", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc settest() (*os.File, *os.File) {\n\tf, err := os.Open(\"a.dat\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\toldStdin := os.Stdin\n\tos.Stdin = f\n\n\treturn f, oldStdin\n}\n\nfunc main() {\n\t/*f, oldStdin := settest()\n\tdefer f.Close()\n\tdefer func() { os.Stdin = oldStdin }()*/\n\n\tvar s string\n\tvar n int\n\tfmt.Scan(&n)\n\tfmt.Scan(&s)\n\n\tm := map[byte]bool {\n\t\t'a': true,\n\t\t'e': true,\n\t\t'i': true,\n\t\t'o': true,\n\t\t'u': true,\n\t\t'y': true,\n\t}\n\n\tvar r []byte\n\n\tfor i := 0; i < len(s); i++ {\n\t\tif i > 0 && m[s[i - 1]] && m[s[i]] {\n\t\t\n\t\t} else {\n\t\t\tr = append(r , s[i])\n\t\t}\n\t}\n\n\tfmt.Println(string(r))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "eccae7112264f067caab098accf7821f", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scan(&n,&s)\n\tg :=\"aeoyiu\"\n\tvar t []rune\n\tprev := 'n'\n\tfor _,r := range(s) {\n\t\tif (!strings.ContainsRune(g,r) || !strings.ContainsRune(g,prev)) {\n\t\t\tprev = r\n\t\t\tt = append(t,r)\n\t\t}\n\t}\n\tfmt.Println(string(t))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "c3d7c8a611f4c26e63da278a4e091edb", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\n//func calc(first,second int){\n//\n//\tfor i:=1;i<1000000000;i++{\n//\t\tif i&1==1{\n//\t\t\tfirst -= i\n//\t\t\tif first<0{\n//\t\t\t\tfmt.Print( \"Vladik\")\n//\t\t\t\treturn\n//\t\t\t}\n//\t\t}else{\n//\t\t\tsecond -= i\n//\t\t\tif second<0{\n//\t\t\t\tfmt.Print(\"Valera\")\n//\t\t\t\treturn\n//\t\t\t}\n//\t\t}\n//\t}\n//\treturn\n//}\n\nfunc main(){\n\tset := make(map[string]bool)\n\tset[\"a\"] = true\n\tset[\"e\"] = true\n\tset[\"i\"] = true\n\tset[\"o\"] = true\n\tset[\"u\"] = true\n\tset[\"y\"] = true\n\tvar t int\n\tfmt.Scanln(&t)\n\tvar ele string\n\tfmt.Scan(&ele)\n\tarr := make([]string,0)\n\tarr = append(arr,string(ele[0]))\n\tfor i:=1;i k2 {\n\t\tk1, k2, a1, a2 = k2, k1, a2, a1\n\t}\n\tvar min, max int\n\n\tif a1*k1 >= n {\n\t\tmax = n / k1\n\t} else {\n\t\tmax = a1\n\t\tmax += (n - a1*k1) / k2\n\t}\n\n\tvar minCard int\n\n\tif k1 > 1 {\n\t\tminCard = a1 * (k1 - 1)\n\t}\n\tif k2 > 1 {\n\t\tminCard += a2 * (k2 - 1)\n\t}\n\n\tif minCard >= n {\n\t\tmin = 0\n\t} else {\n\t\tmin = n - minCard\n\t}\n\n\tfmt.Printf(\"%v %v\", min, max)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "bdf94b880065c3212a3ba23044a42fa5", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//HOWDY! IT'S ME! A HARD BLACKISH DICK MOVE!\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := PrintlnInts(X...)\n\n/*******************************************************************/\nfunc minPlayer(a1, a2, k1, k2, n int) int {\n\tn -= (k1-1)*a1 + (k2-1)*a2\n\tif n <= 0 {\n\t\treturn 0\n\t}\n\treturn min(a1+a2, n)\n}\n\nfunc maxPlayer(a1, a2, k1, k2, n int) int {\n\tp1 := min(a1, n/k1)\n\tn -= p1 * k1\n\tp2 := min(a2, n/k2)\n\treturn p1 + p2\n}\n\nfunc main() {\n\ta1 := ReadInt()\n\ta2 := ReadInt()\n\tk1 := ReadInt()\n\tk2 := ReadInt()\n\tn := ReadInt()\n\t//ensure k1 k2 {\n\t\ta1, a2 = a2, a1\n\t\tk1, k2 = k2, k1\n\t}\n\tfmt.Println(minPlayer(a1, a2, k1, k2, n), maxPlayer(a1, a2, k1, k2, n))\n}\n\n/*********** Math ***********/\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(args ...int) int {\n\tif len(args) == 0 {\n\t\tpanic(\"empty!\")\n\t}\n\tmin := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] < min {\n\t\t\tmin = args[i]\n\t\t}\n\t}\n\treturn min\n}\n\nfunc max(args ...int) int {\n\tif len(args) == 0 {\n\t\tpanic(\"empty!\")\n\t}\n\tmax := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] > max {\n\t\t\tmax = args[i]\n\t\t}\n\t}\n\treturn max\n}\n\nfunc _gcd(a, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn _gcd(b, a%b)\n}\n\nfunc gcd(args ...int) int {\n\tif len(args) == 0 {\n\t\tpanic(\"empty!\")\n\t}\n\tgcd := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tgcd = _gcd(gcd, args[i])\n\t}\n\treturn gcd\n}\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9))\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn readInt()\n}\nfunc ReadInt2() (int, int) {\n\treturn readInt(), readInt()\n}\nfunc ReadInt3() (int, int, int) {\n\treturn readInt(), readInt(), readInt()\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn readInt(), readInt(), readInt(), readInt()\n}\n\nfunc readInt64() int64 {\n\treturn readIntNbits(64)\n}\n\nfunc readInt() int {\n\treturn int(readIntNbits(32))\n}\n\nfunc readIntNbits(n int) int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, n)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintlnInts(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "f76bd184f6b39ef9a4af7245f09ffd5f", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a1, a2, k1, k2, n int\n\n\t// scr := bufio.NewReader(os.Stdin)\n\t// ocr := bufio.NewWriter(os.Stdout)\n\n\tfmt.Scanln(&a1)\n\tfmt.Scanln(&a2)\n\tfmt.Scanln(&k1)\n\tfmt.Scanln(&k2)\n\tfmt.Scanln(&n)\n\n\tmin := n - (((k1 - 1) * a1) + ((k2 - 1) * a2))\n\n\tif min <= 0 {\n\t\tmin = 0\n\t} else if min >= a1+a2 {\n\t\tmin = a1 + a2\n\t}\n\n\tmax := 0\n\tif k1 < k2 {\n\t\tmax = n / k1\n\n\t\tif max > a1 {\n\t\t\tmax = a1\n\t\t} else if max < 1 {\n\t\t\tmax = 0\n\t\t}\n\t\tn -= k1 * max\n\n\t\tx := n / k2\n\t\tif x > a2 {\n\t\t\tx = a2\n\t\t} else if x < 1 {\n\t\t\tx = 0\n\t\t}\n\t\tmax += x\n\n\t} else {\n\t\tmax = n / k2\n\n\t\tif max > a2 {\n\t\t\tmax = a2\n\t\t} else if max < 1 {\n\t\t\tmax = 0\n\t\t}\n\t\tn -= k2 * max\n\n\t\tx := n / k1\n\t\tif x > a1 {\n\t\t\tx = a1\n\t\t} else if x < 1 {\n\t\t\tx = 0\n\t\t}\n\t\tmax += x\n\t}\n\n\tfmt.Println(min, max)\n\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "a64fda4a0272ad3d0fbda1aec5b2dc98", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF16C(in io.Reader, out io.Writer) {\n\tgcd := func(a, b int) int {\n\t\tfor a != 0 {\n\t\t\ta, b = b%a, a\n\t\t}\n\t\treturn b\n\t}\n\tvar a, b, x, y int\n\tFscan(in, &a, &b, &x, &y)\n\tg := gcd(x, y)\n\tx /= g\n\ty /= g\n\tk := a / x\n\tif b/y < k {\n\t\tk = b / y\n\t}\n\tif k > 0 {\n\t\tFprint(out, x*k, y*k)\n\t} else {\n\t\tFprint(out, 0, 0)\n\t}\n}\n\nfunc main() { CF16C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["binary search", "number theory"], "code_uid": "443199d6b4976ea4e85477f6162e995c", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// https://codeforces.com/contest/16/problem/C\npackage main\n\nimport (\n\t\"fmt\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nfunc main() {\n\tvar (\n\t\ta, b, x, y int64\n\t)\n\n\tfmt.Scan(&a, &b, &x, &y)\n\tg := gcd(x, y)\n\tx /= g\n\ty /= g\n\n\tl := int64(1)\n\tr := int64(2e9)\n\tfor l < r - 1 {\n\t\tmid := (l + (r - l) / 2)\n\t\ta1, b1 := x*mid, y*mid\n\t\tif a1 <= a && b1 <= b {\n\t\t\tl = mid\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\tr--\n\tif x*r <= a && y*r <= b {\n\t\tfmt.Println(x*r, y*r)\n\t} else {\n\t\tfmt.Println(0, 0)\n\t}\n}\n\nfunc gcd(a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t} \n\treturn gcd(b, a % b)\n}", "lang_cluster": "Go", "tags": ["binary search", "number theory"], "code_uid": "cc22e81df43e8d678a85c4d8af761215", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc prime(x int64) bool {\n\tif x == 1 {\n\t\treturn false\n\t}\n\tif x == 2 {\n\t\treturn true\n\t}\n\tif x%2 == 0 {\n\t\treturn false\n\t}\n\tfor i := int64(3); i*i <= x; i += 2 {\n\t\tif x%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc main() {\n\tvar t int\n\tfmt.Scan(&t)\n\tfor ; t > 0; t-- {\n\t\tvar a, b int64\n\t\tfmt.Scan(&a, &b)\n\t\tif a-b == 1 && prime(2*a-1) {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "a260892324adebe5b1a0a6fb4243d4e7", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n/*\n1 1\n10 11\n100 192\n1000 2893\n10000 38894\n100000 488895\n1000000 5888896\n10000000 68888897\n100000000 788888898\n1000000000 8888888899\n\n*/\n\n// Solve returns k-th char from 123456789101112131415161718192021222324252627282930313233343536\nfunc Solve(n uint64) byte {\n\tpows := [15]uint64{1}\n\n\tfor i := 1; i <= 12; i++ {\n\t\tpows[i] = pows[i-1] * 10\n\t}\n\n\ti, l := uint64(0), uint64(0)\n\tp := uint64(0)\n\n\tfor next := uint64(1); l+next <= n; next = 1 + (pows[i]-p)*i {\n\t\tl += next\n\t\t//fmt.Println(l)\n\n\t\tp = pows[i]\n\t\ti++\n\t}\n\n\tl -= i - 1\n\n\tt := pows[i-1] + (n-l)/i\n\n\ts := fmt.Sprint(t)\n\tind := (n - l) % i\n\n\t//\tfmt.Println(l, pows[i-1], s, ind)\n\n\treturn s[ind] - '0'\n}\n\nfunc main() {\n\tvar n uint64\n\n\tfmt.Scanf(\"%d\", &n)\n\n\tans := Solve(n)\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "7492a50e7399e0e389744d6a2f0db727", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\tstdin := bufio.NewReader(os.Stdin)\n\tvar k int\n\tfmt.Fscanf(stdin, \"%d\\n\", &k)\n\n\tbuilder := &strings.Builder{}\n\tfor i := 1; i <= k; i++ {\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", i))\n\t}\n\tresult := builder.String()\n\tfmt.Printf(\"%v\\n\", string(result[k-1]))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "1e2ce31b82b990062a7962b011f1c07b", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar read = bufio.NewReader(os.Stdin)\n\tvar write = bufio.NewWriter(os.Stdout)\n\tvar k int\n\tfmt.Fscan(read, &k)\n\tvar p = 1\n\tvar n = 1\n\tvar n0 = 1\n\tvar s0 = 0\n\tfor {\n\t\tvar s1 = s0 + 9*n*p\n\t\tif s1 >= k {\n\t\t\tbreak\n\t\t} else {\n\t\t\ts0 = s1\n\t\t\tp = p + 1\n\t\t\tn = n * 10\n\t\t\tn0 = n\n\t\t}\n\t}\n\tvar r = (k - s0) / p\n\tvar m = (k - s0) % p\n\tif m > 0 {\n\t\tr = r + 1\n\t}\n\tr = n0 + r - 1\n\tvar s = strconv.Itoa(r)\n\tvar nums = strings.Split(s, \"\")\n\tvar res string\n\tif m == 0 {\n\t\tres = nums[len(nums)-1]\n\t} else {\n\t\tres = nums[m-1]\n\t}\n\tfmt.Fprint(write, res)\n\twrite.Flush()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "853e3ef60b2eb04efb52879a576825ca", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc process(row, col, step int64) (resultRow, resultCol int64) {\n\tif step == 0 {\n\t\treturn 1, 1\n\t}\n\n\tif step <= row-1 {\n\t\treturn step + 1, 1\n\t}\n\n\tstep = step - (row - 1)\n\n\tvar rowCount = step / (col - 1) // количество полностью пройденный строк змейкой\n\tvar offset = step % (col - 1)\n\tvar direction = rowCount % 2\n\n\t// direction 1 - left\n\t// direction 0 - right\n\n\tif offset == 0 {\n\t\tresultRow = row - rowCount + 1\n\t\tif direction == 1 {\n\t\t\tresultCol = col\n\t\t} else {\n\t\t\tresultCol = 2\n\t\t}\n\t} else {\n\t\tif direction == 1 {\n\t\t\tresultRow = row - rowCount\n\t\t\tresultCol = col - offset + 1\n\t\t} else {\n\t\t\tresultRow = row - rowCount\n\t\t\tresultCol = offset + 1\n\t\t}\n\t}\n\n\treturn resultRow, resultCol\n}\n\nfunc main() {\n\tvar (\n\t\trow int64\n\t\tcol int64\n\t\tstep int64\n\t)\n\n\tfmt.Scanln(&row, &col, &step)\n\n\tfmt.Println(process(row, col, step))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "fc48b9e4555edcce701c1dd48ba4386e", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nvar ans int64\nvar tmp int64\n\nfunc main() {\n\tfmt.Scan(&ans)\n\tfor i := int64(1); i <= int64(math.Sqrt(float64(ans))); i++ {\n\t\tres := (ans - int64(math.Pow(float64(i), 2)) - i - 1) / 2 * i\n\t\tif res <= 0 {\n\t\t\tcontinue\n\t\t}\n\t\ttmp = int64(math.Pow(float64(i), 2)) + 2*i*res + i + 1\n\t\tif tmp == ans {\n\t\t\tfmt.Println(i, res)\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\n//250877914575\n//1 125438957286\n\n//260158260522\n//NO\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "62aff2e54a336dd5da198d19ff5b3197", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"strings\"\n)\n\nvar n int \nvar str string\nfunc main() {\n fmt.Scanf(\"%d\\n\", &n)\n fmt.Scanf(\"%s\", &str)\t\n ll := 2\n max_subs := 1\n\tfor ll < n/2+1 {\n\t subs := strings.Contains(str[ll:2*ll], str[0:ll])\n\t if subs {\n\t max_subs = ll\n\t }\n\t ll+=1\n\t}\n\tfmt.Println(n-max_subs+1)\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "78310e69447e4518d7c14f7550639a69", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\tS := io.NextLine()\n\t\n\tfor k := N >> 1; k > 0; k-- {\n\t if S[:k] == S[k:k<<1] {\n\t io.Println(N - k + 1)\n\t return\n\t }\n\t}\n\tio.Println(N)\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "b01a17d4dc46a63610fa5f97dab5f9a7", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n n, m, a, b := getI(), getI(), getI(), getI()\n a--\n b--\n p, q := a%m, b%m\n result := 3\n if a/m == b/m || (p == 0 && (q == m-1 || b == n-1)) {\n result = 1\n } else if a/m + 1 == b/m || p == 0 || q == m-1 || b == n-1 || p == q+1 {\n result = 2\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "708aa8b7188218187874c9cc5ece9e87", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tscanner.Scan()\n\tans := strings.Split(scanner.Text(), \"\")\n\n\ttotal := 0\n\tfor i := 0; i < len(ans)-1; i++ {\n\t\ta, _ := strconv.Atoi(ans[i])\n\t\ttotal += a\n\t\tif findGolden(total, ans[i+1:]) {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n\nfunc findGolden(cut int, rem []string) bool {\n\ttotal := 0\n\tfor i := 0; i < len(rem); i++ {\n\t\ta, _ := strconv.Atoi(rem[i])\n\n\t\ttotal += a\n\t\tif total > cut {\n\t\t\treturn false\n\t\t}\n\t\tif total == cut {\n\t\t\treturn i+1 == len(rem) || findGolden(cut, rem[i+1:]) || findGolden(0, rem[i+1:])\n\n\t\t}\n\t}\n\treturn false\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "215fbd894d11b8bac31fd11194d6590f", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc is_palindrome(s string) bool {\n for i := 0; i < len(s)/2; i++ {\n if s[i] != s[len(s) - 1 - i] {\n return false\n }\n }\n return true\n}\n\nfunc main() {\n var s, p string\n fmt.Scanf(\"%s\", &s)\n for i:= 0; i <= 1 << uint(len(s)) - 1; i++ {\n k := 0\n t := \"\"\n for j := i; j != 0; j /= 2 {\n if j%2 != 0 {\n t += s[k:k+1]\n }\n k++\n }\n if is_palindrome(t) && t > p {\n p = t\n }\n }\n fmt.Println(p)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "binary search", "bitmasks", "greedy", "strings", "implementation"], "code_uid": "0b2e377f1e12ce1a0f0728aa5e0846ce", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\nfunc main(){\n\tvar i,c int\n\tvar s string\n\tvar cmax rune\n\tfmt.Scan(&s)\n\tout := bufio.NewWriter(os.Stdout)\n\tr:=make([]rune,len(s))\n\tfor i,v:=range s {\n\t\tr[i]=v\n\t}\n\tfor i=0;icmax {\n\t\t\tcmax=r[i]\n\t\t\tc=1\n\t\t} else if r[i]==cmax {\n\t\t\tc++\n\t\t}\n\t}\n\tfor i=0;i m {\n\t\t\tm = v\n\t\t}\n\t}\n\treturn m\n}\n\nfunc gcd(a, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a % b)\n}\n\nfunc lcm(a, b int) int {\n\treturn a * b / gcd(a, b)\n}\n\nconst MOD = 1000000007\n\nfunc main() {\n\tvar x, y, n int;\n\tscanf(\"%d %d\\n%d\", &x, &y, &n)\n\tn--\n\tseq := make([]int, 6)\n\tseq[0] = x\n\tseq[1] = y\n\tseq[2] = y - x\n\tseq[3] = -x\n\tseq[4] = -y\n\tseq[5] = x - y\n\tfmt.Printf(\"%d\\n\", (seq[n%6] % MOD + MOD) % MOD)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c86128ec8304ab80cfdbca86c9ae61ea", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tvar f1, f2, n int\n\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\n\t\tfmt.Sscanf(line, \"%d %d\", &f1, &f2)\n\n\t}\n\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tfmt.Sscanf(line, \"%d\", &n)\n\t}\n\n\tseries := [6]int{f1 - f2, f1, f2, f2 - f1, -f1, -f2}\n\n\tfn := series[n%6]\n\n\tmodulo := fn % 1000000007\n\tfor modulo < 0 {\n\t\tmodulo += 1000000007\n\t}\n\tfmt.Println(modulo)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "7b3f9980d5ba52272c611e9d322c92ab", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\tN int64\n)\n\nfunc fix(x int64) int64 {\n\treturn ((x-1)%N+N)%N + 1\n}\n\nfunc Mul(a [][]int64, b [][]int64) [][]int64 {\n\tvar (\n\t\tn = len(a)\n\t\tm = len(b[0])\n\t\tt = len(b) // len(a[0]) == len(b) 才有意义\n\t\tc = make([][]int64, n)\n\t)\n\tfor i := 0; i < n; i++ {\n\t\tc[i] = make([]int64, m)\n\t\tfor j := 0; j < m; j++ {\n\t\t\tfor k := 0; k < t; k++ {\n\t\t\t\tc[i][j] += a[i][k] * b[k][j]\n\t\t\t\tc[i][j] = fix(c[i][j])\n\t\t\t}\n\t\t}\n\t}\n\treturn c\n}\n\nfunc Copy(a [][]int64) [][]int64 {\n\tb := make([][]int64, len(a))\n\tfor i := range b {\n\t\tb[i] = make([]int64, len(a[i]))\n\t\tcopy(b[i], a[i])\n\t}\n\treturn b\n}\n\nfunc Pow(a [][]int64, k int64) [][]int64 {\n\tif k <= 0 {\n\t\tpanic(\"k <= 0\")\n\t}\n\tvar (\n\t\tpd = Copy(a)\n\t\tpw = Copy(a)\n\t)\n\tfor k--; k > 0; k /= 2 {\n\t\tif k&1 == 1 {\n\t\t\tpd = Mul(pd, pw)\n\t\t}\n\t\tif k > 1 {\n\t\t\tpw = Mul(pw, pw)\n\t\t}\n\t}\n\treturn pd\n}\n\nfunc main() {\n\tvar sx, sy, dx, dy, t int64\n\tfmt.Fscan(reader, &N, &sx, &sy, &dx, &dy, &t)\n\n\tif t == 0 {\n\t\tfmt.Println(sx, sy)\n\t\treturn\n\t}\n\n\tmat := [][]int64{\n\t\t{2, 1, 1, 0, 1, 0},\n\t\t{1, 2, 0, 1, 1, 0},\n\t\t{1, 1, 1, 0, 1, 0},\n\t\t{1, 1, 0, 1, 1, 0},\n\t\t{0, 0, 0, 0, 1, 1},\n\t\t{0, 0, 0, 0, 0, 1},\n\t}\n\tmat = Pow(mat, t)\n\tori := [][]int64{\n\t\t{sx},\n\t\t{sy},\n\t\t{dx},\n\t\t{dy},\n\t\t{0},\n\t\t{1},\n\t}\n\tans := Mul(mat, ori)\n\tfmt.Println(ans[0][0], ans[1][0])\n}\n", "lang_cluster": "Go", "tags": ["math", "matrices"], "code_uid": "6cfae836d423157ebc0fe5eebb703173", "src_uid": "ee9fa8be2ae05a4e831a4f608c0cc785", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tA := io.NextInt()\n\tB := io.NextInt()\n\t\n\td := Abs(A - B)\n\tlo := d >> 1\n\thi := d - lo\n\tio.Println(Tiredness(lo) + Tiredness(hi))\n}\n\nfunc Tiredness(k int) int {\n return k * (k + 1) / 2\n}\n\nfunc Abs(x int) int {\n\tif (x < 0) {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "ffe24c78a1a312a6410f6e96c4e690a3", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, k int64\n\tfmt.Scanf(\"%d %d %d\\n\", &n, &m, &k)\n\n\tlo, hi := int64(0), n*m\n\tlargest := int64(0)\n\tfor lo <= hi {\n\t\tmid := (lo + hi) / 2\n\n\t\tcount := int64(0)\n\t\tfor i := int64(1); i <= n; i++ {\n\t\t\tx := min(m, mid/i)\n\t\t\tcount += x\n\t\t}\n\n\t\tif count < k {\n\t\t\tlargest = mid\n\t\t\tlo = mid + 1\n\t\t} else {\n\t\t\thi = mid - 1\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n\", largest+1)\n}\n\nfunc min(a, b int64) int64 {\n\tif a <= b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["brute force", "binary search"], "code_uid": "f5d3eed1b8d14520d34fde599ba4c373", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n \"fmt\"\r\n)\r\n\r\nconst N int = 505\r\nvar dp[N*N][2] int64\r\n\r\nfunc main() {\r\n var n int\r\n var mod int64\r\n _,_ = fmt.Scan(&n,&mod)\r\n shift := N*N/2\r\n dp[shift][1]=1\r\n var i,j int\r\n for i = 1; i < n; i++{\r\n var new_dp[N*N][2] int64\r\n for j=0;j 1; i-- {\r\n\t\ti1 := (i & 1)\r\n\t\ti2 := i1 ^ 1\r\n\t\tfor cd := 0; cd < 2*M; cd++ {\r\n\t\t\tdp[i2][cd] = 0\r\n\t\t}\r\n\t\tfor cd := 0; cd < 2*M; cd++ {\r\n\t\t\tk := n - i + 1\r\n\t\t\tif dp[i1][cd] > 0 {\r\n\t\t\t\t// debug(i, cd-M, dp[i1][cd])\r\n\t\t\t\tfor d := -k; d <= k; d++ {\r\n\t\t\t\t\tdd := d\r\n\t\t\t\t\tif dd < 0 {\r\n\t\t\t\t\t\tdd = -dd\r\n\t\t\t\t\t}\r\n\t\t\t\t\tval := (dp[i1][cd] * int64(k+1-dd)) % mod\r\n\t\t\t\t\tdp[i2][cd+d] = (dp[i2][cd+d] + val) % mod\r\n\t\t\t\t\tif d < 0 && cd+d > M {\r\n\t\t\t\t\t\tval1 := (val * f[i-2]) % mod\r\n\t\t\t\t\t\tans += val1\r\n\t\t\t\t\t\tif ans >= mod {\r\n\t\t\t\t\t\t\tans -= mod\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t// debug(i, d, cd-M, val1)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t// for cd := 0; cd < 2*M; cd++ {\r\n\t// \tif dp[1][cd] > 0 {\r\n\t// \t\tdebug(1, cd-M, dp[1][cd])\r\n\t// \t}\r\n\t// }\r\n\tfmt.Println(ans)\r\n}\r\n\r\nfunc main() {\r\n\tvar T int = 1\r\n\t// fmt.Fscan(in, &T)\r\n\tfor t := 1; t <= T; t++ {\r\n\t\tsolve(t)\r\n\t}\r\n}\r\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "fft"], "code_uid": "854789032f38fdc8cb081a40ae49de25", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n \"fmt\"\r\n)\r\n\r\nconst N int = 666\r\nvar dp[N*N][2] int64\r\n\r\nfunc main() {\r\n var n int\r\n var mod int64\r\n _,_ = fmt.Scan(&n,&mod)\r\n shift := N*N/2\r\n dp[shift][1]=1\r\n var i,j int\r\n for i = 1; i < n; i++{\r\n var new_dp[N*N][2] int64\r\n for j=0;j i/days {\n\t\t\t\t\ts += a[start+i] - i/days\n\t\t\t\t\tif s >= m {\n\t\t\t\t\t\tfmt.Println(days)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n\nvar (\n\tstdin = bufio.NewReader(os.Stdin)\n)\n\nfunc readLine() string {\n\ts, _ := stdin.ReadString('\\n')\n\treturn s\n}\n\nfunc readInts() (r []int) {\n\treader := strings.NewReader(readLine())\n\tfor {\n\t\tvar x int\n\t\t_, err := fmt.Fscan(reader, &x)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tr = append(r, x)\n\t}\n\treturn\n}\n\nfunc readInt2() (int, int) {\n\ta := readInts()\n\treturn a[0], a[1]\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "df0bcb1332b5e34a2d98f8ed775a9808", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc min(a, b int) int{\n\tif a < b {\n\t\treturn a\n\t}else {\n\t\treturn b\n\t}\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanln(&n,&m)\n\t//fmt.Println(n,m)\n\ta := make([]int, n)\n\tb := make([]int, m)\n\tfor i := 0; i < n; i++{\n\t\tif(i < n-1){\n\t\t\tfmt.Scanf(\"%d\",&a[i])\n\t\t} else {\n\t\t\tfmt.Scanf(\"%d\\n\",&a[i])\n\t\t}\n\t\t//fmt.Printf(\"%d\\n\",a[i])\n\t}\n\tfor i := 0; i < m; i++{\n\t\tif(i < m-1){\n\t\t\tfmt.Scanf(\"%d\",&b[i])\n\t\t} else {\n\t\t\tfmt.Scanf(\"%d\\n\",&b[i])\n\t\t}\n\t\t//fmt.Printf(\"%d\\n\",b[i])\n\t}\n\tsort.Ints(a)\n\tsort.Ints(b)\n\tvar ans int = 99999999\n\tfor i := 0; i < n; i++{\n\t\tfor j := 0; j < m; j++{\n\t\t\tif a[i] == b[j]{\n\t\t\t\tans = min(ans,a[i])\n\t\t\t}\n\t\t}\n\t}\n\tif(ans == 99999999){\n\t\tans = min(a[0] * 10 + b[0], b[0] * 10 + a[0])\n\t}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "445b7a8d36f6a5b362ed7c7126c202b6", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tm := readInt()\n\n\tns := make(map[int]bool, n)\n\tfor i := 0; i < n; i++ {\n\t\tns[readInt()] = true\n\t}\n\n\tms := make(map[int]bool, m)\n\tfor i := 0; i < m; i++ {\n\t\tms[readInt()] = true\n\t}\n\n\tfor i := 1; i <= 9; i++ {\n\t\tif ms[i] && ns[i] {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n\tfor i := 10; i <= 99; i++ {\n\t\tif ms[i/10] && ns[i%10] {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t\tif ns[i/10] && ms[i%10] {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "0771abc9f4bc0c054966112728bedbce", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nvar a [3]int\nvar t1 int\nvar t2 int\n\nfunc main() {\n fmt.Scan(&a[0], &a[1], &a[2], &t1, &t2)\n a[1] = a[1] / 5\n a[2] = a[2] / 5\n s := a[:]\n sort.Ints(s)\n tt1 := 3\n tt2 := 3\n if t1 > s[0] && t1 <= s[1] {\n tt1 = 1\n } else if t1 > s[1] && t1 <= s[2] {\n tt1 = 2\n }\n if t2 > s[0] && t2 <= s[1] {\n tt2 = 1\n } else if t2 > s[1] && t2 <= s[2] {\n tt2 = 2\n }\n if tt1 == tt2 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0bb7e018db3829f8ac860db7303ceaca", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nvar a [3]int\nvar t1 int\nvar t2 int\n\nfunc main() {\n\tfmt.Scan(&a[0], &a[1], &a[2], &t1, &t2)\n\ta[1] = a[1] / 5\n\ta[2] = a[2] / 5\n\ts := a[:]\n\tsort.Ints(s)\n\ttt1 := 3\n\ttt2 := 3\n\tif t1 > s[0] && t1 <= s[1] {\n\t\ttt1 = 1\n\t} else if t1 > s[1] && t1 <= s[2] {\n\t\ttt1 = 2\n\t}\n\tif t2 > s[0] && t2 <= s[1] {\n\t\ttt2 = 1\n\t} else if t2 > s[1] && t2 <= s[2] {\n\t\ttt2 = 2\n\t}\n\tif tt1 == tt2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "8831ae846ecb8a5468f16f5ff89f6178", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc swap(a *int, b *int) {\n\ttemp := *a\n\t*a = *b\n\t*b = temp\n}\n\ntype Cube struct {\n\telements [24]int\n}\n\ntype Turn struct {\n\tsquare [4]int\n\twall [8]int\n}\n\nfunc NewTurn(cube [4]int, wall [8]int) Turn {\n\tfor index := 0; index < 4; index++ {\n\t\tcube[index]--\n\t}\n\n\tfor index := 0; index < 8; index++ {\n\t\twall[index]--\n\t}\n\n\treturn Turn{cube, wall}\n}\n\nfunc (cube *Cube) RotateLeft(turn Turn) {\n\tsquare := turn.square\n\twall := turn.wall\n\n\tfirst := cube.elements[square[0]]\n\tfor index := 0; index < 3; index++ {\n\t\tcube.elements[square[index]] = cube.elements[square[index+1]]\n\t}\n\tcube.elements[square[3]] = first\n\n\tfor iteration := 0; iteration < 2; iteration++ {\n\t\tfirst := cube.elements[wall[0]]\n\t\tfor index := 0; index < 7; index++ {\n\t\t\tcube.elements[wall[index]] = cube.elements[wall[index+1]]\n\t\t}\n\t\tcube.elements[wall[7]] = first\n\t}\n}\n\nfunc (cube *Cube) RotateRight(turn Turn) {\n\tsquare := turn.square\n\twall := turn.wall\n\n\tlast := cube.elements[square[3]]\n\tfor index := 3; index > 0; index-- {\n\t\tcube.elements[square[index]] = cube.elements[square[index-1]]\n\t}\n\tcube.elements[square[0]] = last\n\n\tfor iteration := 0; iteration < 2; iteration++ {\n\t\tlast := cube.elements[wall[7]]\n\t\tfor index := 7; index > 0; index-- {\n\t\t\tcube.elements[wall[index]] = cube.elements[wall[index-1]]\n\t\t}\n\t\tcube.elements[wall[0]] = last\n\t}\n}\n\nfunc (cube *Cube) IsPerfect() bool {\n\tperfect := true\n\n\tfor side := 0; side < 6 && perfect; side++ {\n\t\tfor index := 0; index < 4 && perfect; index++ {\n\t\t\tif cube.elements[4*side+index] != cube.elements[4*side] {\n\t\t\t\tperfect = false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn perfect\n}\n\nfunc main() {\n\tvar cube Cube\n\tfor index := 0; index < 24; index++ {\n\t\tfmt.Scanf(\"%d\", &cube.elements[index])\n\t}\n\n\tturns := []Turn{\n\t\tNewTurn([4]int{1, 2, 4, 3}, [8]int{22, 21, 18, 17, 6, 5, 14, 13}),\n\t\tNewTurn([4]int{5, 6, 8, 7}, [8]int{3, 4, 17, 19, 10, 9, 16, 14}),\n\t\tNewTurn([4]int{9, 10, 12, 11}, [8]int{7, 8, 19, 20, 23, 24, 15, 16}),\n\t\tNewTurn([4]int{13, 14, 16, 15}, [8]int{1, 3, 5, 7, 9, 11, 24, 23}),\n\t\tNewTurn([4]int{17, 18, 20, 19}, [8]int{4, 2, 21, 23, 12, 10, 8, 6}),\n\t\tNewTurn([4]int{21, 22, 24, 23}, [8]int{2, 1, 13, 15, 11, 12, 20, 18}),\n\t}\n\n\tcan := false\n\n\tfor _, turn := range turns {\n\t\tcube.RotateLeft(turn)\n\n\t\tif cube.IsPerfect() {\n\t\t\tcan = true\n\t\t}\n\n\t\tcube.RotateRight(turn)\n\t\tcube.RotateRight(turn)\n\n\t\tif cube.IsPerfect() {\n\t\t\tcan = true\n\t\t}\n\n\t\tcube.RotateLeft(turn)\n\t}\n\n\tif can {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "7ad7440be3726ab222612e70ef23bef1", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tvar data [24]int\n\tfor i := 0; i < 24; i++ {\n\t\tdata[i] = readInt()\n\t}\n\tif isFullSide(data, 3) && isFullSide(data, 4) {\n\t\trow0 := []int{1, 3, 5, 7, 9, 11, 20, 22}\n\t\trow1 := []int{0, 2, 4, 6, 8, 10, 23, 21}\n\n\t\tif check(data, row0, row1, 2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\tif check(data, row0, row1, -2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tif isFullSide(data, 0) && isFullSide(data, 2) {\n\t\trow0 := []int{12, 13, 4, 5, 16, 17, 20, 21}\n\t\trow1 := []int{14, 15, 6, 7, 18, 19, 22, 23}\n\n\t\tif check(data, row0, row1, 2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\tif check(data, row0, row1, -2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tif isFullSide(data, 1) && isFullSide(data, 5) {\n\t\trow0 := []int{8, 9, 18, 16, 3, 2, 13, 15}\n\t\trow1 := []int{10, 11, 19, 17, 1, 0, 12, 14}\n\n\t\tif check(data, row0, row1, 2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\tif check(data, row0, row1, -2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc check(data [24]int, row0, row1 []int, dir int) bool {\n\tfor i := 0; i < len(row0); i++ {\n\t\tif data[row0[i]] != data[row1[(i+dir+len(row1))%len(row1)]] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc isFullSide(data [24]int, side int) bool {\n\tcolor := data[side*4]\n\tfor i := 0; i < 4; i++ {\n\t\tif data[side*4+i] != color {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "12ac6cc0755cb4edcb29fb95964ab9ea", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar x, k, A, B, res int64\n\nfunc main() {\n\tfmt.Scanf(\"%d\\n%d\\n%d\\n%d\", &x, &k, &A, &B)\n\tif k == 1 {\n\t\tres = (x - 1) * A\n\t\tx = 1\n\t}\n\tfor x > 1 {\n\t\tif x % k != 0 {\n\t\t\td := x % k;\n\t\t\tx -= d\n\t\t\tres += A * d\n\t\t\tif x == 0 {\n\t\t\t\tx = 1\n\t\t\t\tres -= A\n\t\t\t}\n\t\t} else {\n\t\t\td := x / k;\n\t\t\tif B > (x - d) * A {\n\t\t\t\tres += (x - d) * A\n\t\t\t} else {\n\t\t\t\tres += B\n\t\t\t}\n\t\t\tx = d\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp"], "code_uid": "ba09aecb5543c49546239b0012a3031e", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\tvar a, b string\n\tfmt.Scanln(&n, &m)\n\tfmt.Scan(&a, &b)\n\tsame := make([]int, len(b))\n\tfor k := range b {\n\t\tj := k\n\t\tfor i := range a {\n\t\t\tif a[i] == b[j] {\n\t\t\t\tsame[k]++\n\t\t\t\tj = (j + 1) % len(b)\n\t\t\t}\n\t\t}\n\t}\n\tj := 0\n\tfor i := 0; i < n; i++ {\n\t\tj += same[j%len(b)]\n\t}\n\tfmt.Println(j / (m * len(b)))\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "strings"], "code_uid": "b1f488222b8bbb62b7a2a5313c00d350", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar k int\n\tfmt.Scanf(\"%d\", &k)\n\trows := []int{0,0,0,0}\n\tif k <= 4 {\n\t\tfor i := 0; i < k; i++ {\n\t\t\trows[i] = 1\n\t\t}\n\t} else {\n\t\trows[2] = 1\n\t\tq := (k - 4) / 3\n\t\tr := (k - 4) % 3\n\t\trows[0], rows[1], rows[3] = q + 1, q + 1, q + 1\n\t\tif r >= 1 {\n\t\t\trows[0]++\n\t\t}\n\t\tif r >= 2 {\n\t\t\trows[1]++\n\t\t}\n\t}\n\tfmt.Println(\"+------------------------+\")\n\tfmt.Printf(\"|%s%s|D|)\\n\", strings.Repeat(\"O.\", rows[0]), strings.Repeat(\"#.\", 11 - rows[0]))\n\tfmt.Printf(\"|%s%s|.|\\n\", strings.Repeat(\"O.\", rows[1]), strings.Repeat(\"#.\", 11 - rows[1]))\n\tif rows[2] > 0 {\n\t\tfmt.Printf(\"|%s%s..|\\n\", strings.Repeat(\"O.\", rows[2]), strings.Repeat(\"..\", 11 - rows[2]))\n\t} else {\n\t\tfmt.Printf(\"|%s%s..|\\n\", strings.Repeat(\"#.\", 1), strings.Repeat(\"..\", 10))\n\t}\n\tfmt.Printf(\"|%s%s|.|)\\n\", strings.Repeat(\"O.\", rows[3]), strings.Repeat(\"#.\", 11 - rows[3]))\n\tfmt.Println(\"+------------------------+\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0cb5b2bf79706aa5c09767077e28c310", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n \"strings\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n\n n := ReadInt32()\n s := make([]string, 4)\n\n s[1] = \"|#.#.#.#.#.#.#.#.#.#.#.|D|)\\n\"\n s[2] = \"|#.#.#.#.#.#.#.#.#.#.#.|.|\\n\"\n s[0] = \"|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n\"\n\n if n >= 3 {\n s[3] = \"|O.......................|\\n\"\n n--\n } else {\n s[3] = \"|#.......................|\\n\"\n }\n\n for i := 1; i <= n; i++ {\n s[i%3] = strings.Replace(s[i%3], \"#\", \"O\", 1)\n }\n\n writer.WriteString(\"+------------------------+\\n\")\n writer.WriteString(s[1])\n writer.WriteString(s[2])\n writer.WriteString(s[3])\n writer.WriteString(s[0])\n writer.WriteString(\"+------------------------+\\n\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ab291c55ff75c32d2ece7e5f665d0249", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc isSubsequence(s, t string) bool {\n\tif len(s) < len(t) {\n\t\treturn false\n\t}\n\n\ti, j := 0, 0\n\n\tfor j < len(t) && i < len(s) {\n\t\tif s[i] == t[j] {\n\t\t\ti++\n\t\t\tj++\n\t\t} else {\n\t\t\ti++\n\t\t}\n\t}\n\n\treturn j == len(t)\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar (\n\t\ts, t string\n\t)\n\n\t// file, err := os.Open(\"input.txt\")\n\t// if err != nil {\n\t// \tpanic(err)\n\t// }\n\n\t// reader := bufio.NewReader(file)\n\n\treader := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\tfmt.Fscanf(reader, \"%s\\n\", &t)\n\n\tif s == t {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tvar maxLen = -1\n\tfor l := 0; l < len(s); l++ {\n\t\tfor r := l; r < len(s); r++ {\n\t\t\ta := string(s[:l])\n\t\t\tb := string(s[r+1:])\n\t\t\tnewS := strings.Join([]string{a, b}, \"\")\n\n\t\t\tif isSubsequence(newS, t) {\n\t\t\t\tmaxLen = max(r-l+1, maxLen)\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(maxLen)\n\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "3aaa1abf708cbf4a9c23d6906323e6f5", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar s, t string\n\tfmt.Scanln(&s)\n\tfmt.Scanln(&t)\n\tans := 0\n\tfor i := 0; i < len(s); i++{\n\t\tfor j := 0; j < len(s); j++ {\n\t\t\tpos := 0\n\t\t\tfor p := 0; p < len(s); p++ {\n\t\t\t\tif i <= p && p <= j{\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif pos < len(t) && t[pos] == s[p]{\n\t\t\t\t\tpos++\n\t\t\t\t}\n\t\t\t}\n\t\t\tif pos == len(t){\n\t\t\t\tans = int(math.Max(float64(ans), float64(j-i+1)))\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "43f1fd3cfe79040cadccce612c9455f2", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nimport \"os\"\nimport \"bufio\"\n \nfunc max(a, b int) int {\n if a>b {\n return a\n }\n return b\n}\n \nfunc main(){\n input := bufio.NewReader(os.Stdin)\n var s,t string\n\tfmt.Fscanf(input, \"%s\\n\", &s)\n fmt.Fscanf(input, \"%s\\n\", &t)\n \n n := len(s)\n m := len(t)\n \n l := make([]int, m)\n r := make([]int, m)\n \n pos := 0\n for i:=0; i=0; i-- {\n for ; t[i]!=s[pos]; pos-- {\n }\n r[i] = pos\n pos--\n }\n \n /*\n for i:=0; ib{\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc toInt(buf []byte) (o int) {\n for _, v := range buf {\n o = o*10 + int(v-'0')\n }\n return\n}\n\ntype pair struct {\n\tfirst int\n\tsecond int\n}\n\ntype pairs []pair\n\nfunc (a pairs) Len() int {return len(a)}\nfunc (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}\nfunc (a pairs) Less(i,j int) bool {\n\treturn a[i].first < a[j].first\n\tif a[i].first > a[j].first {\n\t\treturn false\n\t}\n\treturn a[i].second <= a[j].second\n}\n\nvar MD int64 = 1000000007\nvar f map[int]int\n\nfunc deg(d int) int64 {\n\tif d == 0 {\n\t\treturn 1\n\t}\n\tt := deg(d / 2)\n\tt *= t\n\tt %= MD\n\tif d % 2 == 1 {\n\t\tt = t * 2 % MD\n\t}\n\treturn t\n}\n\nfunc calc(x int) int {\n\tif val, exists := f[x]; exists {\n\t\treturn val\n\t}\n\tres := int(deg(x - 1))\n\tfor i:= 2;i * i <= x; i++ {\n\t\tif x % i == 0 {\n\t\t\tfirst := i\n\t\t\tsecond := x / i\n\t\t\tres = res - calc(x / first)\n\t\t\tif res < 0 {\n\t\t\t\tres += 1000000007\n\t\t\t}\n\t\t\tif second != first {\n\t\t\t\tres = res - calc(x / second)\n\t\t\t\tif res < 0 {\n\t\t\t\t\tres += 1000000007\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tres = res - 1\n\tif res < 0 {\n\t\tres += 1000000007\n\t}\n\tf[x] = res\n\treturn res\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tvar x,y int\n\tf = make(map[int]int)\n\tf[1] = 1\n\tfmt.Fscanf(in, \"%d %d\\n\", &x, &y)\n\tif y % x != 0 {\n\t\tfmt.Println(0)\n\t\tos.Exit(0)\n\t}\n\ty /= x\n\tfmt.Println(calc(y))\n}\n\n\n\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "bitmasks", "number theory"], "code_uid": "a7fd99fc9eb1db6775add33cc1cec940", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\ntype point struct {\n\tx, y int\n}\n\nvar ans int64\n\nconst (\n\tmod = int(1e9 + 7)\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn, total := 0, 0\n\tfmt.Fscanf(in, \"%d %d\\n\", &n, &total)\n\tt := make([]int, n)\n\tg := make([]int, n)\n\tsum := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(in, \"%d %d\\n\", &t[i], &g[i])\n\t\tsum += t[i]\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i + 1; j < n; j++ {\n\t\t\tif t[i] < t[j] {\n\t\t\t\tt[i], t[j] = t[j], t[i]\n\t\t\t\tg[i], g[j] = g[j], g[i]\n\t\t\t}\n\t\t}\n\t}\n\thelp(0, n, total, t, g, 0, 0, 0, 0, sum)\n\tfmt.Fprintf(out, \"%d\\n\", ans)\n\treturn\n}\n\nfunc help(i int, n int, total int, t []int, g []int, cur int, c1, c2, c3 int, remaining int) {\n\t//fmt.Println(i, cur)\n\tif i == n {\n\t\tif cur == total {\n\t\t\tcal(c1, c2, c3)\n\t\t}\n\t\treturn\n\t}\n\tif cur > total {\n\t\treturn\n\t}\n\tif cur+remaining < total {\n\t\treturn\n\t}\n\tswitch g[i] {\n\tcase 1:\n\t\thelp(i+1, n, total, t, g, cur+t[i], c1+1, c2, c3, remaining-t[i])\n\tcase 2:\n\t\thelp(i+1, n, total, t, g, cur+t[i], c1, c2+1, c3, remaining-t[i])\n\tcase 3:\n\t\thelp(i+1, n, total, t, g, cur+t[i], c1, c2, c3+1, remaining-t[i])\n\t}\n\thelp(i+1, n, total, t, g, cur, c1, c2, c3, remaining-t[i])\n}\n\nfunc cal(c1, c2, c3 int) {\n\ta := []int{c1, c2, c3}\n\tsort.Ints(a)\n\ttmp := int64(try(c1, c2, c3, 0))\n\ttmp %= int64(mod)\n\tfor i := 1; i <= c1; i++ {\n\t\ttmp *= int64(i)\n\t\ttmp %= int64(mod)\n\t}\n\tfor i := 1; i <= c2; i++ {\n\t\ttmp *= int64(i)\n\t\ttmp %= int64(mod)\n\t}\n\tfor i := 1; i <= c3; i++ {\n\t\ttmp *= int64(i)\n\t\ttmp %= int64(mod)\n\t}\n\tans += tmp\n\tans %= int64(mod)\n}\n\nfunc try(a, b, c int, last int) int64 {\n\tif a == 0 && b == 0 && c == 0 {\n\t\treturn 1\n\t}\n\tif a < 0 || b < 0 || c < 0 {\n\t\treturn 0\n\t}\n\tif last == 0 {\n\t\treturn try(a-1, b, c, 1) + try(a, b-1, c, 2) + try(a, b, c-1, 3)\n\t}\n\tif last == 1 {\n\t\treturn try(a, b-1, c, 2) + try(a, b, c-1, 3)\n\t}\n\tif last == 2 {\n\t\treturn try(a-1, b, c, 1) + try(a, b, c-1, 3)\n\t}\n\treturn try(a-1, b, c, 1) + try(a, b-1, c, 2)\n}\n", "lang_cluster": "Go", "tags": ["dp", "combinatorics", "bitmasks"], "code_uid": "c1de92d68b1bcc2a876c6bf6c18bb788", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n s := getS()\n n := len(s)\n counts := map[string]int{}\n for i := 0; i < n; i++ {\n if s[i] == '0' {\n continue\n }\n for j := i; j < n; j++ {\n if s[j] != '4' && s[j] != '7' {\n break\n }\n sub := s[i:j+1]\n counts[sub]++\n }\n }\n bestSub, bestCount := \"-1\", -1\n for sub, count := range counts {\n if count > bestCount || (count == bestCount && sub < bestSub) {\n bestSub, bestCount = sub, count\n }\n }\n writer.WriteString(fmt.Sprintf(\"%s\\n\", bestSub))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "d841a3a882725a6582bbc1aa58767ff1", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n four, seven := 0, 0\n for _, v := range s {\n if v == '4' {\n four++\n } else if v == '7' {\n seven++\n }\n }\n if (four+seven) == 0 {\n fmt.Println(-1)\n } else if four >= seven {\n fmt.Println(4)\n } else {\n fmt.Println(7)\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "23ca4fcb7dcfcd28bb1f82e85fc0219b", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"sort\"\n\t//\"unicode/utf8\"\n)\nfunc main() {\n\tvar s string\n\tn4,n7:=0,0\n\tfmt.Scan(&s)\n\tfor _,ss:=range s {\n\t\tif ss=='4' {\n\t\t\tn4++\n\t\t}\n\t\tif ss=='7' {\n\t\t\tn7++\n\t\t}\n\t}\n\tif n4==0 && n7==0 {\n\t\tfmt.Println(\"-1\")\n\t} else if n4>=n7 {\n\t\tfmt.Println(\"4\")\n\t} else {\n\t\tfmt.Println(\"7\")\n\t}\n}\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "2c74beb3389a2fb5dc61eb4fdfccf373", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar pp, dd, x, y, t int64\n\tfmt.Scan(&pp, &dd)\n\tx=pp\n\ty=1\n\tfor i:=0; i<=18; i++ {\n\t\tt=x%y\n\t\tif t==y-1 {\n\t\t\tpp=x\n\t\t} else if t
b {\n\t\t\treturn a\n\t\t}\n\t\treturn b\n\t}\n\n\tvar maxW, n, a, b int\n\tFscan(in, &maxW, &n)\n\tn++\n\tweights := make([]int, n)\n\tvalues := make([]int, n)\n\tstocks := make([]int, n)\n\tFscan(in, &weights[0], &values[0])\n\tstocks[0] = maxW / weights[0]\n\tfor i := 1; i < n; i++ {\n\t\tFscan(in, &a, &b, &weights[i], &values[i])\n\t\tstocks[i] = a / b\n\t}\n\n\tdp := make([]int, maxW+1)\n\tfor i, v := range values {\n\t\tnum, w := stocks[i], weights[i]\n\t\tfor k := 1; num > 0; k <<= 1 {\n\t\t\tK := min(k, num)\n\t\t\tfor j := maxW; j >= K*w; j-- {\n\t\t\t\tdp[j] = max(dp[j], dp[j-K*w]+K*v)\n\t\t\t}\n\t\t\tnum -= K\n\t\t}\n\t}\n\tFprint(out, dp[maxW])\n}\n\nfunc main() { CF106C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "fb43fa8f8c8d702b0001114357858a97", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF106C(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tmax := func(a, b int) int {\n\t\tif a > b {\n\t\t\treturn a\n\t\t}\n\t\treturn b\n\t}\n\n\tvar maxW, n, a, b int\n\tFscan(in, &maxW, &n)\n\tn++\n\tweights := make([]int, n)\n\tvalues := make([]int, n)\n\tstocks := make([]int, n)\n\tFscan(in, &weights[0], &values[0])\n\tstocks[0] = maxW / weights[0]\n\tfor i := 1; i < n; i++ {\n\t\tFscan(in, &a, &b, &weights[i], &values[i])\n\t\tstocks[i] = a / b\n\t}\n\n\tdp := make([][]int, n+1)\n\tfor i := range dp {\n\t\tdp[i] = make([]int, maxW+1)\n\t}\n\tfor i, vi := range values {\n\t\twi := weights[i]\n\t\tfor j := range dp[i] {\n\t\t\tfor k := 0; k <= stocks[i] && k*wi <= j; k++ {\n\t\t\t\tdp[i+1][j] = max(dp[i+1][j], dp[i][j-k*wi]+vi*k)\n\t\t\t}\n\t\t}\n\t}\n\tFprint(_w, dp[n][maxW])\n}\n\nfunc main() { CF106C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "f0ff00c6d58bbe77981d61902ebfe390", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tfor I(&n, \" \") == nil {\n\t\tsolve(n)\n\t}\n}\n\nvar n, m, k int64\n\nfunc solve(n int64) {\n\tI(&m, \" \")\n\tI(&k, \"\\n\")\n\tif n == m {\n\t\tO(1, \"\\n\")\n\t\treturn\n\t}\n\tif n == 1 {\n\t\tO(m, \"\\n\")\n\t\treturn\n\t}\n\tans := int64(2)\n\tm -= n + 1\n\th := int64(1)\n\tl := k - 1\n\tr := n - k\n\tfor m > 0 {\n\t\tif l > 0 {\n\t\t\th++\n\t\t\tl--\n\t\t}\n\t\tif r > 0 {\n\t\t\th++\n\t\t\tr--\n\t\t}\n\t\tif r <= 0 && l <= 0 {\n\t\t\tans += m / h\n\t\t\tm = 0\n\t\t} else {\n\t\t\tm -= h\n\t\t\tif m >= 0 {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tO(ans, \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["greedy", "binary search"], "code_uid": "e138880d8458895cf52a92a7fa0c2ff5", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tpeople := readInt()\n\tpillow := readInt()\n\tk := readInt()\n\tif people == 1 {\n\t\tfmt.Println(pillow)\n\t\treturn\n\t}\n\tpillow -= people\n\tleft := int64(k - 1)\n\tright := int64(people - k)\n\tbest := 0\n\tlo := 0\n\thi := pillow\n\tfor lo <= hi && pillow > 0 {\n\t\tmi := lo + (hi-lo)/2\n\t\trest := int64(pillow - mi)\n\t\tstep := int64(mi - 1)\n\t\tvar sum1 int64\n\t\tvar sum2 int64\n\t\tif left > 0 && step > 0 {\n\t\t\tt := left\n\t\t\tif step < t {\n\t\t\t\tt = step\n\t\t\t}\n\t\t\tsum1 = int64(step-t+1+step) * t / 2\n\t\t}\n\t\tif right > 0 && step > 0 {\n\t\t\tt := right\n\t\t\tif step < t {\n\t\t\t\tt = step\n\t\t\t}\n\t\t\tsum2 = int64(step-t+1+step) * t / 2\n\t\t}\n\t\tif sum1+sum2 <= rest {\n\t\t\tbest = mi\n\t\t\tlo = mi + 1\n\t\t} else {\n\t\t\thi = mi - 1\n\t\t}\n\t}\n\tfmt.Println(best + 1)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["greedy", "binary search"], "code_uid": "c0f86fcc323ddbc8ea89933b52db1289", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\n\nfunc main() {\n\tvar n, sum, ans, need int\n\tfmt.Scan(&n)\n\tv := make([]int, n)\n\tfor i := range v {\n\t\tfmt.Scan(&v[i])\n\t\tv[i] *= 2\n\t\tsum += v[i]\n\t}\n\tneed = 9 * n\n\tsort.Ints(v)\n\tfor i := range v {\n\t\tif sum >= need {\n\t\t\tbreak\n\t\t}\n\t\tsum += 10 - v[i]\n\t\tans++\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "60bb1242a770182f50b5c11c4c8afddb", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\"fmt\")\nfunc min(x, y int) int {\n if x < y {\n return x\n }\n return y\n}\n\nfunc main(){\n\t// your code goes here\n\tvar n int\n\tvar a int\n\tvar b int\n\tvar c int\n\tvar res int\n\tres=0\n\tfmt.Scan(&n)\n\tfmt.Scan(&a)\n\tfmt.Scan(&b)\n\tfmt.Scan(&c)\n\tif n>1{\n\t res=min((n-1)*a,(n-1)*b)\n\t res=min(res,a+(n-2)*c)\n\t res=min(res,b+(n-2)*c)\n\t} \n\tfmt.Println(res)\n}\n\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "a5c6b86a2c7079623f5d3e86a910219e", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc distance(n,a,b,c int) int {\n\tif(n==1) {\n\t\treturn 0\n\t} else {\n\t\tif(a= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "8ea6f7ece911f1608fb6c5745d5a3d1b", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc digit2pos(a int) (int, int) {\n\tif a == 0 {\n\t\treturn 3, 1\n\t}\n\ta--\n\treturn a / 3, a % 3\n}\n\nfunc legal(y, x int) bool {\n\tif y == 3 {\n\t\treturn x == 1\n\t}\n\treturn y >= 0 && y < 3 && x >= 0 && x < 3\n}\n\n// apply a→b like move to x\nfunc move(x, a, b int) int {\n\tay, ax := digit2pos(a)\n\tby, bx := digit2pos(b)\n\n\tpy, px := digit2pos(x)\n\n\tpy += by - ay\n\tpx += bx - ax\n\n\tif !legal(py, px) {\n\t\treturn -1\n\t}\n\tif py == 3 {\n\t\treturn 0\n\t}\n\treturn 1 + py*3 + px\n}\n\nfunc main() {\n\tn := getInt()\n\tw := getWord()\n\n\tvar cnt int\n\tfor f := 0; f <= 9; f++ {\n\t\tx := f\n\t\tfor j := 1; j < n; j++ {\n\t\t\tx = move(x, int(w[j-1]-'0'), int(w[j]-'0'))\n\t\t\tif x == -1 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif x != -1 {\n\t\t\tcnt++\n\t\t}\n\t}\n\n\tfmt.Println(YN(cnt == 1))\n}\n\nfunc YN(b bool) string {\n\tif b {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n\ntype Input struct {\n\t*bufio.Scanner\n}\n\nvar globalInput = wrapStdin()\n\nfunc wrapStdin() Input {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\treturn Input{Scanner: sc}\n}\nfunc getInt() int {\n\tglobalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x\n}\nfunc getIntOk() (int, bool) {\n\tok := globalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x, ok\n}\nfunc getNint(n int) []int {\n\tv := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tv[i] = getInt()\n\t}\n\treturn v\n}\nfunc getVint(v []int) bool {\n\tvar ok bool\n\tfor i := 0; i < len(v); i++ {\n\t\tv[i], ok = getIntOk()\n\t}\n\treturn ok\n}\nfunc getWord() string {\n\tglobalInput.Scan()\n\treturn globalInput.Text()\n}\nfunc getWordOk() (string, bool) {\n\tok := globalInput.Scan()\n\treturn globalInput.Text(), ok\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc min64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max64(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc minStr(a, b string) string {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc maxStr(a, b string) string {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc remin(a *int, b int) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remax(a *int, b int) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remin64(a *int64, b int64) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remax64(a *int64, b int64) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc reminStr(a *string, b string) bool {\n\tif b < *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\nfunc remaxStr(a *string, b string) bool {\n\tif b > *a {\n\t\t*a = b\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\nfunc abs64(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\ntype (\n\tFLess func(i, j int) bool\n\tFSwap func(i, j int)\n\twrapSort struct {\n\t\tLength int\n\t\tFLess\n\t\tFSwap\n\t}\n)\n\nfunc (w *wrapSort) Len() int { return w.Length }\nfunc (w *wrapSort) Less(i, j int) bool { return w.FLess(i, j) }\nfunc (w *wrapSort) Swap(i, j int) { w.FSwap(i, j) }\nfunc wsort(length int, fless func(i, j int) bool, fswap func(i, j int)) {\n\tsort.Sort(&wrapSort{length, fless, fswap})\n}\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "ffe86fe12c71e26387ba2051a341b64d", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 316A1\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar mark [333]bool\n\tvar s string\n\tfmt.Scan(&s)\n\tvar ans, m int64\n\tans, m = 1, 10\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == '?' {\n\t\t\tif i == 0 {\n\t\t\t\tans *= 9\n\t\t\t} else {\n\t\t\t\tans *= 10\n\t\t\t}\n\t\t} else if s[i] >= 'A' && s[i] <= 'J' && !mark[s[i]] {\n\t\t\tif i == 0 {\n\t\t\t\tans *= 9\n\t\t\t} else {\n\t\t\t\tans *= m\n\t\t\t}\n\t\t\tm--\n\t\t\tmark[s[i]] = true\n\t\t}\n\t}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "8ecb86bfa94e7da6b000cbe697bfcbe6", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n)\n\nconst (\n\tn = 1000000007\n)\n\nfunc sum(a, b int) int {\n\ts := a + b\n\tif s >= n {\n\t\treturn s - n\n\t}\n\treturn s\n}\n\nfunc mul(a, b int) int {\n\treturn int(int64(a) * int64(b) % n)\n}\n\nfunc g0(a, b, h, w int) int {\n\tif a == 0 && b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := h + 1; x <= a; x++ {\n\t\ts += g0(b, a - x, w, h)\n\t}\n\treturn s\n}\n\nfunc f0(a, b int) int {\n\tif a == 0 || b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := 1; x <= a; x++ {\n\t\ts += f0(b, a - x)\n\t}\n\treturn s\n}\n\nfunc power(a, n int) int {\n\tr := 1\n\tfor n > 0 {\n\t\tif (n & 1) != 0 {\n\t\t\tr = mul(r, a)\n\t\t}\n\t\tn /= 2\n\t\tif n > 0 {\n\t\t\ta = mul(a, a)\n\t\t}\n\t}\n\treturn r\n}\n\nfunc inv(a int) int {\n\treturn power(a, n - 2)\n}\n\nvar facts []int\nvar ifacts []int\n\nfunc cnk(n, k int) int {\n\tif k < 0 || k > n || n < 0 {\n\t\treturn 0\n\t}\n\treturn mul(mul(facts[n], ifacts[k]), ifacts[n-k])\n}\n\nfunc f1(a, b int) int {\n\treturn sum(cnk(a + b - 1, a), cnk(a + b - 1, b))\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc solve(a, b, h int) int {\n\tq := f1(a, b)\n\th += 1\n\tif a == 0 {\n\t\treturn 1\n\t}\n\tif b == 0 {\n\t\tif a >= h {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tp := 0\n\tfor ka := 1; ka * h <= a; ka++ {\n\t\tfor kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {\n\t\t\tc0 := cnk(b - 1, kb - 1)\n\t\t\tc1 := cnk(a - ka * (h - 1) - 1, ka - 1)\n\t\t\t// fmt.Printf(\"%d %d %d %d\\n\", ka, kb, c0, c1)\n\t\t\td := mul(c0, c1)\n\t\t\tif ka == kb {\n\t\t\t\tp = sum(p, d)\n\t\t\t}\n\t\t\tp = sum(p, d)\n\t\t}\n\t}\n\treturn mul(p, inv(q))\n}\n\nfunc main() {\n\tm := 200100\n\tfacts = make([]int, m)\n\tifacts = make([]int, m)\n\tfacts[0] = 1\n\tfor i := 1; i < m; i++ {\n\t\tfacts[i] = mul(facts[i-1], i)\n\t}\n\tifacts[m-1] = inv(facts[m-1])\n\tfor i := m-2; i >= 0; i-- {\n\t\tifacts[i] = mul(ifacts[i+1], i+1)\n\t}\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\ta := cin.nextInt()\n\tb := cin.nextInt()\n\th := cin.nextInt()\n\tfmt.Printf(\"%d\\n\", solve(b, a, h))\n}\n\n// some io\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "combinatorics", "probabilities", "number theory"], "code_uid": "42f2a83401400393659828534458e637", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte. Trailing '\\n' will not be included.\n// See also comments on readb()\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Utilities\n\nfunc sumSlice(a []int) int {\n\tvar res int\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc sumSlicell(a []int64) int64 {\n\tvar res int64\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc readInts(N int) (int, []int) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int, N)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\treturn N, a\n}\n\nfunc readIntsll(N int) (int, []int64) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int64, N)\n\tfor i := range a {\n\t\ta[i] = readll()\n\t}\n\treturn N, a\n}\n\n// reverse slice in place\nfunc reverse(a []int) {\n\tfor i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {\n\t\ta[i], a[j] = a[j], a[i]\n\t}\n}\n\n// areverse: allocating reverse\nfunc areverse(a []int) []int {\n\tb := make([]int, len(a))\n\tfor i := range a {\n\t\tb[i] = a[len(a)-i-1]\n\t}\n\treturn b\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n\nfunc main() {\n\tdefer Flush()\n\n\tn := readi()\n\tk := readi()\n\tx := readi()\n\t_, a := readInts(n)\n\n\tvar ans int\n\tfor i := 0; i < n; i++ {\n\t\tif i < k {\n\t\t\tans += x\n\t\t} else {\n\t\t\tans += a[n-i-1]\n\t\t}\n\t}\n\tprintln(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "43a0754074821de32a6f1820ee57f672", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k, x, a int\n\tfmt.Scan(&n, &k, &x)\n\tx *= k\n\tfor ; k < n; k++ {\n\t\tfmt.Scan(&a)\n\t\tx += a\n\t}\n\tfmt.Println(x)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "04ac741ffdf8424bcda856c8d6998cd4", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\"fmt\")\n\nfunc main(){\n\tvar n, k, x int\n\tscan(&n, &k, &x)\n\tmin := 0\n\tfor i := 0; i < n; i++{\n\t\tvar tm int\n\t\tscan(&tm)\n\t\tif i < n - k{\n\t\t\tmin += tm\n\t\t}\n\t}\n\tmin += k * x\n\tsout(min)\n}\n\nfunc scan(in ... interface{}){\n\tfor _,k := range in{\n\t\tfmt.Scan(k)\n\t}\n}\n\nfunc sout(obj ... interface{}){\n\tfor _, k := range obj{\n\t\tfmt.Print(k, \" \")\n\t}\n\tfmt.Println()\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2ebf4c6b8aaedc4613706bde63dc7732", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n, B int\n\tfmt.Scanf(\"%d %d\\n\", &n, &B)\n\n\tlist := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&list[i])\n\t}\n\n\tvar cuts []int\n\n\todd := 0\n\teven := 0\n\tfor i := 0; i < n; i++ {\n\t\tif odd > 0 && even > 0 && odd == even {\n\t\t\tcuts = append(cuts, (int)(math.Abs((float64)(list[i]-list[i-1]))))\n\t\t\todd = 0\n\t\t\teven = 0\n\t\t}\n\n\t\tif list[i]%2 == 0 {\n\t\t\teven++\n\t\t} else {\n\t\t\todd++\n\t\t}\n\t}\n\n\tsort.Ints(cuts)\n\tcost := 0\n\tcount := 0\n\tfor i := 0; i < len(cuts); i++ {\n\t\tcost += cuts[i]\n\n\t\tif cost > B {\n\t\t\tbreak\n\t\t}\n\n\t\tcount++\n\t}\n\n\tfmt.Println(count)\n}", "lang_cluster": "Go", "tags": ["sortings", "dp", "greedy"], "code_uid": "0e064087059e1ea1a9f04aa1ae08510b", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport\n(\n\t\"fmt\"\n\t\n)\n\n\nfunc main() {\n\n\tvar a int\n\tfmt.Scanln(&a)\n\tfmt.Print(((a+1)/2)*((a-(a+1)/2)+1))\n\t}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "f56b0cf7d1e3e36b0b42172553a8c8bf", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar (\n\tin *bufio.Reader\n\tout *bufio.Writer\n)\n\nfunc init() {\n\tin = bufio.NewReader(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n}\n\ntype prop struct {\n\thp, atk, def int\n}\n\nfunc main() {\n\tdefer out.Flush()\n\tvar (\n\t\ty, m prop\n\t\th, a, d int\n\t)\n\tfmt.Fscan(in, &y.hp, &y.atk, &y.def)\n\tfmt.Fscan(in, &m.hp, &m.atk, &m.def)\n\tfmt.Fscan(in, &h, &a, &d)\n\tans := 2000000000\n\tfor ba := 0; ba <= 205; ba++ {\n\t\tfor bd := 0; bd <= 205; bd++ {\n\t\t\tpr := ba * a + bd * d\n\t\t\tif pr >= ans {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdmg := y.atk + ba - m.def\n\t\t\tif dmg <= 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlive := (m.hp + dmg - 1) / dmg\n\t\t\tleft := y.hp - live * (m.atk - y.def - bd)\n\t\t\tif left <= 0 {\n\t\t\t\tpr += (-left + 1) * h\n\t\t\t}\n\t\t\tif pr < ans {\n\t\t\t\tans = pr\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintln(out, ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "binary search"], "code_uid": "93f7e86492a82fa14ca48d2cf7b4e536", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nfunc main() {\n writer := bufio.NewWriter(os.Stdout)\n var n int\n fmt.Scan(&n)\n prev := n\n for i := n; i >= 1; i-- {\n if prev%i == 0 {\n writer.WriteString(strconv.Itoa(i))\n if i == 1 { writer.WriteRune('\\n') } else { writer.WriteRune(' ') }\n prev = i\n }\n }\n writer.Flush()\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "c10578c2ae99d83b7abc9ee5bdc96fe3", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,i,j int\n\tfmt.Scan(&n)\n\tfmt.Print(n,\" \")\n\ti=n-1\n\tj=n\n\tfor ;i>0;i-- {\n\t\tif j%i==0 {\n\t\t\tfmt.Print(i,\" \")\n\t\t\tj=i\n\t\t}\n\t}\n}\n\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "b8eb8246c952aab4e8722a49fefef2a5", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tvar n, m, k int64\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\n\t\tfmt.Sscanf(line, \"%d %d %d\", &n, &m, &k)\n\n\t\tif n > m {\n\t\t\tn, m = m, n\n\t\t}\n\n\t\tif k < n {\n\t\t\tarea1 := n * (m / (k + 1))\n\t\t\tarea2 := n / (k + 1) * m\n\t\t\tif area1 < area2 {\n\t\t\t\tfmt.Println(area2)\n\t\t\t} else {\n\t\t\t\tfmt.Println(area1)\n\t\t\t}\n\t\t} else if n <= k && k < m {\n\t\t\tfmt.Println(n * (m / (k + 1)))\n\t\t} else if m <= k && k <= n+m-2 {\n\t\t\tfmt.Println((n / (k + 2 - m) * m / m))\n\t\t} else {\n\t\t\tfmt.Println(-1)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "e458a169432eac3e952aed5cc653576e", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF894B(in io.Reader, out io.Writer) {\n\tconst mod int64 = 1e9 + 7\n\tpow := func(x, n int64) int64 {\n\t\tres := int64(1)\n\t\tfor ; n > 0; n >>= 1 {\n\t\t\tif n&1 == 1 {\n\t\t\t\tres = res * x % mod\n\t\t\t}\n\t\t\tx = x * x % mod\n\t\t}\n\t\treturn res\n\t}\n\tvar n, m, k int64\n\tFscan(in, &n, &m, &k)\n\tif k == -1 && n&1 != m&1 {\n\t\tFprint(out, 0)\n\t} else {\n\t\tFprint(out, pow(pow(2, n-1), m-1))\n\t}\n}\n\nfunc main() { CF894B(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "combinatorics", "number theory"], "code_uid": "7f9ad8a6b4e1f4990245bb6d1875fd71", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tn, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\n\tscanner.Scan()\n\tk, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\n\th := n / 2\n\n\tp := h / (k + 1)\n\td := k * p\n\n\tfmt.Println(p, d, (n - p - d))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c273ef6790083cbd8a9d1e6258d4ac5a", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var n, k, diploma, certificates, noWinners int64\n fmt.Scanf(\"%d %d\", &n, &k)\n\n diploma = int64(math.Floor(float64(n) / float64(2 * (k + 1))))\n certificates = k * diploma\n noWinners = n - (diploma + certificates)\n\n fmt.Printf(\"%d %d %d\\n\", diploma, certificates, noWinners)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "8f12d36c6506e8ffa577fbec21284e00", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar r, h float64\n\tfmt.Scan(&r, &h)\n\th, count := h-r*math.Floor(h/r), 2*int(h/r)\n\tif h+r >= r*(math.Sqrt(3)/2+1) {\n\t\tcount += 3\n\t} else if h >= r/2 {\n\t\tcount += 2\n\t} else {\n\t\tcount += 1\n\t}\n\tfmt.Println(count)\n}\n", "lang_cluster": "Go", "tags": ["geometry"], "code_uid": "462f7fca8b5863c3002882450e5dd7ea", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc abs(num int) int {\n\treturn max(num, -num)\n}\n\nfunc main() {\n\tvar r1, c1, r2, c2 int\n\tfmt.Scan(&r1, &c1, &r2, &c2)\n\tvar rook, bishop, king int\n\tif r1 == r2 || c1 == c2 {\n\t\trook = 1\n\t} else {\n\t\trook = 2\n\t}\n\tif (r1+c1)%2 != (r2+c2)%2 {\n\t\tbishop = 0\n\t} else if r1+c1 == r2+c2 || r1-c1 == r2-c2 {\n\t\tbishop = 1\n\t} else {\n\t\tbishop = 2\n\t}\n\tking = max(abs(r1-r2), abs(c1-c2))\n\tfmt.Println(rook, bishop, king)\n}\n", "lang_cluster": "Go", "tags": ["math", "graphs", "shortest paths"], "code_uid": "f601d0567f16c0e695bbdba37e67973b", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar a, b int64\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &a, &b); err != nil {\n\t\treturn\n\t}\n\n\tas, ac, ai := to_binary_string(a)\n\tbs, bc, bi := to_binary_string(b)\n\n\tvar c [3]int\n\n\tif len(as) < len(bs) {\n\t\tif ac == 0 {\n\t\t\tc[0] = 0\n\t\t} else {\n\t\t\tc[0] = len(as) - ai\n\t\t}\n\t\tfor i := len(as) + 1; i <= len(bs)-1; i++ {\n\t\t\tc[1] += i - 1\n\t\t}\n\t\tif bc == 0 {\n\t\t\tc[2] = len(bs) - 1\n\t\t} else {\n\t\t\tc[2] = bi - 1\n\t\t\tif bc == 1 {\n\t\t\t\tc[2] += 1\n\t\t\t}\n\t\t}\n\t} else if len(as) == len(bs) {\n\t\tc[1] = bi - ai\n\t\tif bc == 1 {\n\t\t\tc[2] = 1\n\t\t}\n\t}\n\n\tfmt.Println(c[0] + c[1] + c[2])\n}\n\nfunc to_binary_string(n int64) (string, int, int) {\n\tout := \"\"\n\tzero_count := 0\n\tfirst_zero_index := -1\n\tfor i := 0; n > 0; i++ {\n\t\tif n%2 == 0 {\n\t\t\tzero_count++\n\t\t\tfirst_zero_index = i\n\t\t}\n\t\tout = strconv.FormatInt(n%2, 10) + out\n\t\tn /= 2\n\t}\n\treturn out, zero_count, len(out) - first_zero_index - 1\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "1dbccb4894a474ce25c577dfe8810d80", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// URL: http://codeforces.com/contest/96/problem/B\n// ~ Basic Implementation Problem, Brute Force. DP version can be found in\n// 95B, where constraints are big (can't just generate all permutations).\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc isSuperLuckyNumber(n string) bool {\n\treturn strings.Count(n, \"4\") == strings.Count(n, \"7\")\n}\n\nfunc _solve(s string, minLength int, maxLength int, queue []string, answers []string) string {\n\telem := queue[0]\n\tif minLength <= len(elem) && len(elem) <= maxLength {\n\t\telemInt, _ := strconv.Atoi(elem)\n\t\tsInt, _ := strconv.Atoi(s)\n\t\tif isSuperLuckyNumber(elem) && sInt <= elemInt {\n\t\t\treturn elem\n\t\t}\n\t}\n\tif len(elem) <= maxLength {\n\t\tqueue = append(queue, elem+\"4\")\n\t\tqueue = append(queue, elem+\"7\")\n\t\tanswers = append(answers, elem)\n\t\treturn _solve(s, minLength, maxLength, queue[1:], answers)\n\t}\n\treturn _solve(s, minLength, maxLength, queue[1:], answers)\n}\n\nfunc findMinAndMaxLength(s string) (int, int) {\n\tif len(s)%2 == 0 {\n\t\treturn len(s), len(s) + 2\n\t}\n\treturn len(s) + 1, len(s) + 1\n}\n\nfunc solve(s string) string {\n\tminLength, maxLength := findMinAndMaxLength(s)\n\treturn _solve(s, minLength, maxLength, []string{\"4\", \"7\"}, []string{})\n}\n\nfunc main() {\n\treader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar s string\n\tfmt.Fscanf(reader, \"%s\", &s)\n\tfmt.Fprintln(writer, solve(s))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "binary search", "bitmasks"], "code_uid": "764ab321ce0b7a3037cc01386e7e160b", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\n//a,b <=n && a+b==x\nfunc count(n, x int64) (ans int64) {\n\tif n >= x {\n\t\tn = x - 1\n\t}\n\tans = n - x/2\n\tif x%2 == 0 {\n\t\tans++\n\t}\n\tif ans < 0 {\n\t\tans = 0\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tif n < 5 {\n\t\tfmt.Println(n * (n - 1) / 2)\n\t\treturn\n\t}\n\tvar ans int64\n\tvar max9 int64 = 9\n\tfor max9 < n {\n\t\tmax9 = max9*10 + 9\n\t}\n\tif max9/2+1 <= n {\n\t\tfmt.Println(count(n, max9))\n\t\treturn\n\t}\n\tsmax9 := fmt.Sprint(max9)\n\t//for i := 0; i < len(smax9); i++ {\n\ttmp := []byte(smax9)\n\tfor j := 0; j < 9; j++ {\n\t\ttmp[0] = byte(j) + '0'\n\t\tx, _ := strconv.ParseInt(string(tmp), 10, 64)\n\t\tans += count(n, x)\n\t\t//fmt.Println(count(n, x), x)\n\t\ttmp[0] = '9'\n\t}\n\t//}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "a7a335f82d32693237809c077ab1b93a", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst (\n\tBIG = 1024 * 1024 * 10\n)\n\nfunc readLine(r *bufio.Reader) string {\n\tbytes, _, err := r.ReadLine()\n\tif err != nil {\n\t\tlog.Fatalln(\"Failed to read line\")\n\t}\n\n\treturn string(bytes)\n}\n\nfunc readInts(r *bufio.Reader) []int {\n\telems := strings.Fields(readLine(r))\n\n\tret := make([]int, len(elems))\n\tfor i, el := range elems {\n\t\ttmp, err := strconv.ParseInt(el, 10, 64)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Failed to parse number %v\", el)\n\t\t}\n\t\tret[i] = int(tmp)\n\t}\n\n\treturn ret\n}\n\nfunc min(a, b int64) int64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc combination(a, b int64) int64 {\n\tb = min(b, a-b)\n\tnom, denom := int64(1), int64(1)\n\tfor b > 0 {\n\t\tnom *= a\n\t\tdenom *= b\n\t\ta -= 1\n\t\tb -= 1\n\t}\n\n\treturn nom / denom\n}\n\nfunc pow(a, b int64) int64 {\n\tret := int64(1)\n\tfor b > 0 {\n\t\tret *= a\n\t\tb -= 1\n\t}\n\n\treturn ret\n}\n\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, BIG)\n\n\tn := readInts(r)[0]\n\n\tvar res int64\n\tif n == 3 {\n\t\tres = int64(4*(n-1)) * pow(int64(3), int64(n-2))\n\t} else {\n\t\tres = int64(4*2*3) * pow(int64(4), int64(n-3)) // The n-block is in the beginning/end\n\t\tres += int64(4*(n-3)*3*3) * pow(int64(4), int64(n-4)) // The n-block has blocks to the left/right\n\t}\n\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "9d3cc21cfa952f0783641941368d565a", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"flag\"\n\t\"fmt\"\n\t\"io\"\n\t\"math/big\"\n\t\"math/bits\"\n\t\"os\"\n)\n\nfunc solve(n, x uint64) uint64 {\n\tif x > n {\n\t\treturn 0\n\t}\n\n\tres := uint64(1)\n\tif x % 2 == 0 {\n\t\tres += solve(n, x + 1)\n\t}\n\n\txlen := uint(bits.Len64(x))\n\tnlen := uint(bits.Len64(n))\n\n\tnx := x << (nlen - xlen)\n\n\tif nlen > xlen {\n\t\tres += (uint64(1) << (nlen - xlen)) - 2\n\t}\n\n\tif nx <= n && nlen > xlen {\n\t\tif n >> (nlen - xlen) == x {\n\t\t\tres += n - nx + 1\n\t\t} else {\n\t\t\tres += uint64(1) << (nlen - xlen)\n\t\t}\n\t}\n\n\treturn res\n}\n\nfunc solveStupid(n, x uint64) uint64 {\n\tif x > n {\n\t\treturn 0\n\t}\n\n\tres := uint64(1)\n\tif x % 2 == 0 {\n\t\tres += solveStupid(n, x + 1)\n\t}\n\tres += solveStupid(n, x * 2)\n\n\treturn res\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tn, k := uint64(NextInt64()), uint64(NextInt64())\n\n\tx := uint64(1)\n\tl := uint(0)\n\tfor ; solve(n, x * 2) >= k; x *= 2 {\n\t\tl++\n\t}\n\n\tfor i := uint(0); i < l; i++ {\n\t\tif solve(n, x + (uint64(1) << (l - i - 1))) >= k {\n\t\t\tx += uint64(1) << (l - i - 1)\n\t\t}\n\t}\n\n\tprintln(x)\n}\n\nvar reader *bufio.Reader\nvar writer *bufio.Writer\n\nvar inputFile = flag.String(\"input\", \"\", \"\")\n\nfunc init() {\n\tflag.Parse()\n\tvar i io.Reader\n\tif *inputFile != \"\" {\n\t\ti, _ = os.Open(*inputFile)\n\t} else {\n\t\ti = os.Stdin\n\t}\n\treader = bufio.NewReaderSize(i, 1<<20)\n\twriter = bufio.NewWriterSize(os.Stdout, 1<<20)\n}\n\nfunc println(a ...interface{}) {\n\t_, _ = fmt.Fprintln(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\t_, _ = fmt.Fprintf(writer, format, a...)\n}\n\nfunc scanf(format string, a ...interface{}) {\n\t_, _ = fmt.Fscanf(reader, format, a...)\n}\n\nfunc scan(a interface{}) {\n\t_, _ = fmt.Fscan(reader, a)\n}\n\nfunc NextInt64() int64 {\n\tvar res int64\n\tscan(&res)\n\treturn res\n}\n\nfunc NextInt() int {\n\tvar res int\n\tscan(&res)\n\treturn res\n}\n\nfunc NextIntArray(n int) []int {\n\tres := make([]int, n)\n\tfor i := range res {\n\t\tscan(&res[i])\n\t}\n\treturn res\n}\n\nfunc NextInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := range res {\n\t\tscan(&res[i])\n\t}\n\treturn res\n}\n\nfunc NextString() string {\n\tvar res string\n\tscan(&res)\n\treturn res\n}\n\nfunc NextBigInt() *big.Int {\n\tn := new(big.Int)\n\tn, _ = n.SetString(NextString(), 10)\n\treturn n\n}\n\nfunc AbsInt64(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc MinInt64(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc MaxInt64(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc MaxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n", "lang_cluster": "Go", "tags": ["math", "binary search", "dp", "combinatorics"], "code_uid": "1d29f072afdd47f14bcde9c9fc926eb2", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tfmt.Println(int64(n-2) * int64(n-2))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "b3390875db39661165f28d40c05dcfdd", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n fmt.Scanf(\"%d\", &n)\n\n r := int64(1)\n dif := int64(3)\n for i := 3; i < n; i++ {\n r += dif\n dif += 2 \n }\n fmt.Println(r)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "f22ec6271ba9921a8b22c21406bad84a", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nconst MAX int64 = 1e7\nconst MOD int64 = 1e9+7\nvar isgood [MAX]bool\nfunc Max(a, b int64) int64 {\n\tif (a < b) {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc Init(a, b, n int64) {\n\tvar k int64\n\tfor k = 0; k < MAX; k++ { isgood[k] = true }\n\tfor k = 1; k <= Max(a,b) * n; k++ {\n\t\tp := k\n\t\tfor p > 0 {\n\t\t\tif p % 10 != a && p % 10 != b {\n\t\t\t\tisgood[k] = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tp /= 10\n\t\t}\n\t}\n}\n\nfunc EE(a, b int64) int64 {\n\tvar (\n\t\tr=a%b\n\t\tx0 int64=1\n\t\ty0 int64=0\n\t\tx1 int64=0\n\t\ty1 int64=1\n\t\tmod=b\n\t)\n\tfor r > 0 {\n\t\tf:=a/b\n\t\ttx:=x0-f*x1\n\t\tty:=y0-f*y1\n\t\tx0=x1\n\t\ty0=y1\n\t\tx1=tx\n\t\ty1=ty\n\t\ta=b\n\t\tb=r\n\t\tr=a%b\n\t}\n\treturn (x1%mod+mod)%mod\n}\n\nfunc main() {\n\tvar a,b,n int64\n\tfmt.Scanf(\"%d%d%d\",&a,&b,&n)\n\tInit(a,b,n)\n\tvar (\n\t\tchoose int64=1\n\t\tx int64=0\n\t\ty int64\n\t)\n\tcnt := make(map[int64]int64)\n\tfor x <= n {\n\t\ty=n-x\n\t\ts:=a*x+b*y\n\t\tif isgood[s] { cnt[s]=(cnt[s]+choose)%MOD }\n\t\tchoose=((choose*(n-x))%MOD)*EE(x+1,MOD)%MOD\n\t\tx++\n\t}\n\tvar ans int64 = 0\n\tfor k,v := range cnt {\n\t\tif isgood[k] { ans = (ans + v) % MOD }\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "combinatorics"], "code_uid": "12b5d66293fbd9ebff76425f36f83463", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n \nfunc gcd(a int, b int, x *int, y *int) int {\n if a == 0 {\n *x, *y = 0, 1\n return b\n }\n var xx, yy int\n g := gcd(b%a, a, &xx, &yy)\n *x = yy - (b/a)*xx\n *y = xx\n return g\n}\n\nfunc normal(n int, mod *int) int {\n n %= (*mod)\n if n < 0 {\n n += (*mod)\n }\n return n\n}\n\nfunc inv(a int, mod *int) int {\n var x, y int\n gcd(a, *mod, &x, &y)\n return normal(x, mod)\n}\n\nfunc addmod(a, b int, mod *int) int { \n if a + b >= (*mod) {\n return a + b - (*mod)\n } else {\n return a + b\n }\n}\n\nfunc submod(a, b int, mod *int) int { \n if a - b < 0 {\n return a - b + (*mod)\n } else {\n return a - b\n }\n}\n\nfunc mulmod(a, b int, mod *int) int { \n return int((int64(a)*int64(b))%int64(*mod))\n}\n\nfunc divmod(a, b int, mod *int) int { \n return mulmod(a, inv(b, mod), mod)\n}\n\nfunc binpowmod(a, b int, mod *int) int {\n ans := 1\n for b > 0 {\n if b%2 == 1 {\n ans = mulmod(ans, a, mod)\n }\n a = mulmod(a, a, mod)\n b = b/2\n }\n return ans\n}\n \nfunc calc(y []int, x int, mod *int) int {\n ans := 0\n k := 1\n for j := 1; j < len(y); j++ {\n k = mulmod(k, normal(x - j, mod), mod)\n k = divmod(k, normal(0 - j, mod), mod)\n }\n for i := 0; i < len(y); i++ {\n ans = addmod(ans, mulmod(y[i], k, mod), mod)\n if (i + 1) >= len(y) {\n break\n }\n k = mulmod(k, divmod(normal(x - i, mod), normal(x - (i + 1), mod), mod), mod)\n k = mulmod(k, divmod(normal(i - (len(y) - 1), mod), normal(i + 1, mod), mod), mod)\n }\n return ans\n}\n\nfunc main() {\n var n, k int\n var mod int = 1000000007\n var y []int = make([]int, 0)\n s := 0\n y = append(y, s)\n fmt.Scanf(\"%d %d\", &n, &k)\n for i := 0; i < k + 1; i++ {\n s = addmod(s, binpowmod(i + 1, k, &mod), &mod) //k-th powwer of (i+1)\n y = append(y, s)\n }\n if n < len(y) {\n fmt.Printf(\"%d\", y[n])\n } else {\n p := calc(y, n, &mod)\n fmt.Printf(\"%d\", p)\n }\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "6b88e4dafb23356ab735b4f0bc876a17", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc abs(x int) int{\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}\n\n\nfunc main() {\n\tvar x1, y1, x2, y2, x, y int\n\tfmt.Scanf(\"%v%v%v%v\\n%v%v\", &x1, &y1, &x2, &y2, &x, &y)\n\tdx := abs(x2 - x1)\n\tdy := abs(y2 - y1)\n\tresult := \"YES\"\n\tif dx % x != 0 || dy % y != 0 || abs(dx / x - dy / y) % 2 == 1{\n\t\tresult = \"NO\"\n\t}\n\tfmt.Println(result)\n}", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "c2bfd5c20eb73624765c47cc7b3d4999", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\n)\n\nfunc main() {\n\tvar x1,x2,y1,y2,x,y int\n\n\tfmt.Scan(&x1,&y1,&x2,&y2,&x,&y)\n\n\tvar ok bool\n\n\tif (x2-x1) % x == 0 && (y1-y2) % y ==0 {\n\t\tc1 := (x2-x1) / x\n\t\tc2 := (y2-y1) / y\n\t\tif (c1 - c2) % 2 == 0 {\n\t\t\tok = true\n\t\t}\n\n\t} else {\n\n\t}\n\n\tif ok {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "877f06315763740f1445bae61b4f4922", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\tw := bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\n\tvar n int\n\tfmt.Fscan(r, &n)\n\n\tres := 3\n\tif n > 1 {\n\t\tp := (n-1) % 3\n\t\tq := (n+2) / 3\n\t\tres = 4*q + 3*p / 2\n\t}\n\n\tfmt.Fprintln(w, res)\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry", "binary search"], "code_uid": "a93c3f5682c73f4df35d3cdc8b9fab64", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, d int\n\tfmt.Scanf(\"%d %d %d %d\", &a, &b, &c, &d)\n\tif b - a == c - b && c - b == d - c {\n\t\tfmt.Printf(\"%d\", a + (b - a) * 4)\n\t} else if a != 0 && b != 0 && c != 0 && d != 0 && b * b == a * c && c * c == b * d && a != b {\n\t\tif d * d % c == 0 {\n\t\t\tfmt.Printf(\"%d\", d * d / c)\n\t\t} else {\n\t\t\tfmt.Printf(\"42\")\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"42\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fcd097fb1411acff4a342548b072132c", "src_uid": "68a9508d49fec672f9c61766d6051047", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tinit := scanner.Text()\n\theights := strings.Split(init, \" \")\n\n\tcater, _ := strconv.Atoi(heights[0])\n\tapple, _ := strconv.Atoi(heights[1])\n\n\tscanner.Scan()\n\tinput := scanner.Text()\n\tins := strings.Split(input, \" \")\n\n\tupS, _ := strconv.Atoi(ins[0])\n\tdS, _ := strconv.Atoi(ins[1])\n\n\tdiffDay := (upS - dS) * 12\n\tdays := 0\n\t// lets move for day1 first\n\tcater = (cater + 8*upS)\n\tif cater >= apple {\n\t\tfmt.Println(days)\n\t\treturn\n\t}\n\tif dS >= upS {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tfor {\n\t\tif cater >= apple {\n\t\t\tfmt.Println(days)\n\t\t\treturn\n\t\t}\n\n\t\tdays++\n\t\tcater += diffDay\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "1ea4338467836d8fffb75246fbb7b0df", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\th1, h2 := nextInt(), nextInt()\n\ta, b := nextInt(), nextInt()\n\n\th1 += a * 8\n\n\tif a <= b {\n\t\tif h1 < h2 {\n\t\t\tprintln(-1)\n\t\t\treturn\n\t\t}\n\t}\n\n\tday := 0\n\n\tfor h1 < h2 {\n\t\th1 += (a - b) * 12\n\t\tday++\n\t}\n\n\tprintln(day)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "146761bb5042d579f590cf76b307b258", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\t\n\tvar n, m int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &m)\n\tvar pa, pb [10][10]bool\n\tfor i := 0;i < n;i ++ {\n\t\tvar x, y int\n\t\tif i == n - 1 {\n\t\t\tfmt.Fscanf(reader, \"%d %d\\n\", &x, &y)\n\t\t} else {\n\t\t\tfmt.Fscanf(reader, \"%d %d \", &x, &y)\n\t\t}\n\t\tpa[x][y] = true\n\t\tpa[y][x] = true\n\t}\n\tfor i := 0;i < m;i ++ {\n\t\tvar x, y int\n\t\tif i == m - 1 {\n\t\t\tfmt.Fscanf(reader, \"%d %d\\n\", &x, &y)\n\t\t} else {\n\t\t\tfmt.Fscanf(reader, \"%d %d \", &x, &y)\n\t\t}\n\t\tpb[x][y] = true\n\t\tpb[y][x] = true\n\t}\n\n\tsolution := make([]bool, 10)\n\n\tcanDeduce := true\n\tfor i := 1; i < 10;i ++ {\n\t\tfor j := 1;j < 10;j ++ {\n\t\t\tif !pa[i][j] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvar b1, b2 bool\n\t\t\tfor k := 1; k < 10;k ++ {\n\t\t\t\tif pb[i][k] && k != j {\n\t\t\t\t\tsolution[i] = true\n\t\t\t\t\tb1 = true\n\t\t\t\t}\n\t\t\t\tif pb[k][j] && k != i {\n\t\t\t\t\tsolution[j] = true\n\t\t\t\t\tb2 = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tif b1 && b2 {\n\t\t\t\tcanDeduce = false\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 1; i < 10;i ++ {\n\t\tfor j := 1;j < 10;j ++ {\n\t\t\tif !pb[i][j] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvar b1, b2 bool\n\t\t\tfor k := 1; k < 10;k ++ {\n\t\t\t\tif pa[i][k] && k != j {\n\t\t\t\t\tsolution[i] = true\n\t\t\t\t\tb1 = true\n\t\t\t\t}\n\t\t\t\tif pa[k][j] && k != i {\n\t\t\t\t\tsolution[j] = true\n\t\t\t\t\tb2 = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tif b1 && b2 {\n\t\t\t\tcanDeduce = false\n\t\t\t}\n\t\t}\n\t}\n\n\tans, ansCount := 0, 0\n\tfor i := 1;i < len(solution);i ++ {\n\t\tif solution[i] {\n\t\t\tans, ansCount = i, ansCount + 1\n\t\t}\n\t}\n\tif ansCount == 1 {\n\t\tfmt.Printf(\"%d\", ans)\n\t} else if canDeduce {\n\t\tfmt.Printf(\"0\")\n\t} else {\n\t\tfmt.Printf(\"-1\")\n\t}\n\t\n}\n", "lang_cluster": "Go", "tags": ["brute force", "bitmasks"], "code_uid": "2f11be420f78f66a2084cd659f21b824", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\ntype Int64Slice []int64\n\nfunc (slice Int64Slice) Len() int { return len(slice) }\nfunc (slice Int64Slice) Less(i, j int) bool { return slice[i] < slice[j] }\nfunc (slice Int64Slice) Swap(i, j int) { slice[i], slice[j] = slice[j], slice[i] }\n\nvar usr1 [20]int\nvar usr2 [20]int\n\nvar n, m int\nvar val [2][30]int\n\nfunc guess(v int) int {\n\tret := 0\n\tfor i := 0; i < n; i++ {\n\t\tif v == val[0][i*2] || v==val[0][i*2+1] {\n\t\t\tfor j := 0; j < m; j++ {\n\t\t\t\tif v == val[1][j*2] || v==val[1][j*2+1] {\n // fmt.Printf(\"v:%v %v - %v\\n\",v,i,j)\n\t\t\t\t\tif \n (val[0][i*2] == val[1][j*2] && val[0][i*2+1] == val[1][j*2+1])|| (val[0][i*2] == val[1][j*2+1] && val[0][i*2+1] == val[1][j*2]){\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (usr1[i] == 0 || usr1[i] == v) && (usr2[j] == 0 || usr2[j] == v) {\n\t\t\t\t\t\t\tusr1[i] = v\n\t\t\t\t\t\t\tusr2[j] = v\n\t\t\t\t\t\t\tret = v\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn -1\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn, m = ReadInt32(), ReadInt32()\n\n\tfor i := 0; i < n; i++ {\n\t\tval[0][i*2] = ReadInt32()\n\t\tval[0][i*2+1] = ReadInt32()\n\t}\n\tfor i := 0; i < m; i++ {\n\t\tval[1][i*2] = ReadInt32()\n\t\tval[1][i*2+1] = ReadInt32()\n\t}\n\n\t// 1 zu pei 1 -> res\n\tans := -1\n\tfor i := 1; i < 10; i++ {\n\t\tret := guess(i)\n\t\tif ret == -1 {\n\t\t\tfmt.Printf(\"-1\\n\")\n\t\t\treturn\n\t\t}\n if ret == 0 {\n continue\n }\n\t\tif ans == -1 {\n\t\t\tans = ret\n\t\t} else {\n\t\t\tans = 0\n\t\t}\n\t}\n\tfmt.Printf(\"%v\\n\", ans)\n\n\t// quan pei 1 -> 0\n\n\t// else -1\n\n}\n\nfunc Demo() {\n\tvar n, m int64 = ReadInt64(), ReadInt64()\n\tPrintInt64s(n, m)\n\twriter.WriteByte('\\n')\n\tslice := []int64{1, 2, 3, 4, 5}\n\tPrintInt64s(slice...)\n\n\t// sortDemo\n\t//slice := []int64{5, 3, 4, 2, 1}\n\tsort.Sort(Int64Slice(slice))\n\n\t//s := strconv.FormatBool(true)\n\t//s := strconv.FormatFloat(3.1415, 'E', -1, 64)\n\t//s := strconv.FormatInt(-42, 16)\n\t//s := strconv.FormatUint(42, 16)\n\n}\n\nfunc Min(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MinInt(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MinFloat64(a float64, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxInt64(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxInt(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxFloat64(a float64, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc ReadInt64() int64 {\n\tscanner.Scan()\n\tans, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn ans\n}\n\nfunc ReadFloat64() float64 {\n\tscanner.Scan()\n\tans, _ := strconv.ParseFloat(scanner.Text(), 64)\n\treturn ans\n}\n\nfunc PrintInt64s(ints ...int64) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(int(value)))\n\t\twriter.WriteByte(' ')\n\t}\n}\n", "lang_cluster": "Go", "tags": ["bitmasks"], "code_uid": "cf3990efd8d2e02973b2e3590806cd2a", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc nextPermutation(a []int) bool {\n i := len(a)-1\n for (i > 0) && (a[i] <= a[i-1]) { i-- }\n if (i == 0) { return false }\n j := len(a)-1\n for a[j] <= a[i-1] { j-- }\n a[j], a[i-1] = a[i-1], a[j]\n j = len(a)-1\n for i < j {\n a[i], a[j] = a[j], a[i]\n i++; j--\n }\n return true\n}\n\nfunc main() {\n var g [5][5]int\n a := make([]int,5)\n for i := 0; i < 5; i++ {\n a[i] = i\n for j := 0; j < 5; j++ {\n fmt.Scan(&g[i][j])\n }\n }\n max := 0\n for {\n cnt := 0\n for i := 0; i < 4; i++ {\n for j := 0; (i+j) < 4; j += 2 {\n cnt += g[a[i+j]][a[i+j+1]]+g[a[i+j+1]][a[i+j]]\n }\n }\n if max < cnt { max = cnt }\n if !nextPermutation(a) { break }\n }\n fmt.Println(max)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "86d63f5752be93df7b39c42f1a7adef3", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc verifyReallyBig(num int64, minDiff int64) (isReallyBig bool) {\n\tsum := int64(0)\n\tfor n := num; n > 0; n /= 10 {\n\t\tsum += n % 10\n\t}\n\tdiff := num - sum\n\tif diff >= minDiff {\n\t\tisReallyBig = true\n\t} else {\n\t\tisReallyBig = false\n\t}\n\treturn\n}\n\nfunc searchMin(n int64, s int64) (min int64) {\n\tvar left, right int64\n\tvar isReallyBig bool\n\tlastMin := n + 1\n\tfor left, right = 1, n/10 + 1; right > left; {\n\t\tmin = (left + (right - left) / 2) * 10\n\t\tisReallyBig = verifyReallyBig(min, s)\n\t\tif isReallyBig {\n\t\t\tright = min / 10\n\t\t\tlastMin = min\n\t\t} else {\n\t\t\tleft = min / 10 + 1\n\t\t}\n\t}\n\treturn lastMin\n}\n\nfunc Solve(input io.Reader) (result string) {\n\tvar n, s int64\n\tfmt.Fscan(input, &n, &s)\n\treturn fmt.Sprintln(n - searchMin(n, s) + 1)\n}\n\nfunc main() {\n\tfmt.Print(Solve(os.Stdin))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "binary search"], "code_uid": "9ef39d01bf072fff400f01337cfd772e", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nvar n int\nvar m int\nvar tmp int\n\nfunc main() {\n\tfmt.Scan(&n)\n\tfmt.Scan(&m)\n\tsuma := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&tmp)\n\t\tsuma += tmp\n\t}\n\n\tansa := 0\n\tfor {\n\t\tif float64(m)-float64(suma)/float64((ansa+n)) <= float64(0.5) {\n\t\t\tfmt.Println(ansa)\n\t\t\tos.Exit(0)\n\t\t}\n\t\tsuma += m\n\t\tansa++\n\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "1e32332054d13925288cfd328b16e698", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\n\tfor passed(a, k) == false {\n\t\ta = append(a, k)\n\t}\n\n\tfmt.Printf(\"%d\", len(a)-n)\n}\n\nfunc passed(a []int, k int) bool {\n\tavg := calcAvg(a)\n\tif avg+0.5 >= float64(k) {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc calcAvg(a []int) float64 {\n\ttotal := 0\n\tfor _, value := range a {\n\t\ttotal += value\n\t}\n\treturn float64(total) / float64(len(a))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "5d1991accc1a18946139be182735bebb", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/128/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Position struct {\n\tX int\n\tY int\n}\n\ntype Node struct {\n\tPosition Position\n\tTime int\n}\n\nfunc getNeighbors(p Position) []Position {\n\tvar validNeighbors []Position\n\tfor i := -1; i <= 1; i++ {\n\t\tfor j := -1; j <= 1; j++ {\n\t\t\tx := p.X + i\n\t\t\ty := p.Y + j\n\t\t\tif 0 <= x && x < 8 && 0 <= y && y < 8 {\n\t\t\t\tvalidNeighbors = append(validNeighbors, Position{X: x, Y: y})\n\t\t\t}\n\t\t}\n\t}\n\treturn validNeighbors\n}\n\nfunc hasStatue(board [8]string, p Position, time int) bool {\n\tif 0 <= p.X-time && p.X-time < 8 {\n\t\tif string(board[p.X-time][p.Y]) == \"S\" {\n\t\t\treturn true\n\t\t}\n\t}\n\tif 0 <= p.X-time-1 && p.X-time-1 < 8 {\n\t\tif string(board[p.X-time-1][p.Y]) == \"S\" {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc Solve(board [8]string) string {\n\tstack := []Node{{Position: Position{X: 7, Y: 0}, Time: 0}}\n\tfor {\n\t\tcurrentNode := stack[len(stack)-1]\n\t\tstack = stack[:len(stack)-1]\n\t\tif currentNode.Time == 8 || currentNode.Position.X == 0 {\n\t\t\treturn \"WIN\"\n\t\t}\n\t\tfor _, neighbor := range getNeighbors(currentNode.Position) {\n\t\t\tif !hasStatue(board, neighbor, currentNode.Time) {\n\t\t\t\tstack = append(stack, Node{Position: neighbor, Time: currentNode.Time + 1})\n\t\t\t}\n\t\t}\n\t\tif len(stack) == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn \"LOSE\"\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar board [8]string\n\tfor i := 0; i < 8; i++ {\n\t\tfmt.Fscanf(reader, \"%s\\n\", &board[i])\n\t}\n\tfmt.Fprintf(writer, \"%s\\n\", Solve(board))\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar"], "code_uid": "ecd5db936f9b1a1125dde138d108c1ad", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\nvar wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)\nvar rdr = bufio.NewScanner(os.Stdin)\nfunc gs() string { rdr.Scan(); return rdr.Text() }\nfunc gi() int { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }\nfunc gis(n int) []int { res := make([]int,n); for i:=0;i 1 {\tinfn = os.Args[1] }\n\tif infn != \"\" {\tf, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }\n\trdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)\n\t// PROGRAM STARTS HERE\n\tN,M := gi(),gi(); mask := ia(10); for i:=0;i> uint(k)) & 1 == 0 {\n\t\t\t\t\t\tg[(j | ((1< n {\n init[j] += v-n\n v = n\n }\n a[i][j] = v\n }\n }\n\n const inf = 100000000\n const mx = 1<<16\n const sz = 16*16+1\n mem := [mx][2][sz]int{}\n was := [mx]bool{}\n for i := range mem {\n for col := range mem[i] {\n diff := min(max(init[1-col]-init[col], 0), sz-1)\n for j := range mem[i][col] {\n val := inf\n if i == 0 && diff == j {\n val = 0\n }\n mem[i][col][j] = val\n }\n }\n }\n\n ans := inf\n d := [mx][2]int{}\n q := make([]int, 1, 1<<16)\n q[0] = 0\n un := uint(n)\n was[0] = true\n for curI := 0; curI < len(q); curI++ {\n cur := q[curI]\n curD := d[cur]\n //fmt.Println(\"BFS\", cur, curD)\n for col, u := range mem[cur] {\n for cnt, val := range u {\n if cur == (1<= inf {\n continue\n }\n \n r, b := 0, 0\n if col == 0 {\n r = cnt\n } else {\n b = cnt\n }\n\n for bit := uint(0); bit < un; bit++ {\n mask := 1 << bit\n if cur & mask == 0 {\n next := cur | mask\n priceR, priceB := max(a[bit][0]-curD[0], 0), max(a[bit][1]-curD[1], 0)\n //fmt.Println(\" Price\", priceR, priceB, val)\n steps := max(priceR-r, priceB-b)\n nextR, nextB := r+steps-priceR, b+steps-priceB\n nextCol, nextVal := 0, min(nextR+nextB, sz-1)\n if nextB > 0 {\n nextCol = 1\n }\n mem[next][nextCol][nextVal] = min(mem[next][nextCol][nextVal], val+steps+1)\n\n if !was[next] {\n was[next] = true\n\n nextD := curD\n nextD[c[bit]]++\n d[next] = nextD\n\n q = append(q, next)\n }\n }\n }\n }\n }\n }\n\n ans += max(init[0], init[1])\n fmt.Println(ans)\n}\n\n\n\n// Helpers\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\n// Sort\n\ntype Ints64 []int64\n\nfunc (a Ints64) Len() int { return len(a) }\nfunc (a Ints64) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a Ints64) Less(i, j int) bool { return a[i] < a[j] }\n\n/* Sort tempalte\nfunc (a ) Len() int { return len(a) }\nfunc (a ) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ) Less(i, j int) bool { return }\n*/\n", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "fe8544d3ee368af37debf607ef904931", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scan(&x, &y)\n\tans := int(1e9)\n\tif y <= 0 && y <= x && x <= 1-y && -4*y < ans {ans = -4*y}\n\tif x > 0 && 1-x <= y && y <= x && 4*x-3 < ans {ans = 4*x-3}\n\tif y > 0 && -y <= x && x <= y && 4*y-2 < ans {ans = 4*y-2}\n\tif x < 0 && x <= y && y <= -x && -4*x-1 < ans {ans = -4*x-1}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["brute force", "geometry", "implementation"], "code_uid": "3578126fbbfcf5a43d5230ef36c84eba", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nvar (\r\n\tin = bufio.NewReader(os.Stdin)\r\n\tout = bufio.NewWriter(os.Stdout)\r\n)\r\n\r\nfunc flush() { out.Flush() }\r\nfunc scan(a ...interface{}) { fmt.Fscan(in, a...) }\r\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }\r\nfunc assert(f bool) {\r\n\tif !f {\r\n\t\tpanic(\"gg\")\r\n\t}\r\n}\r\n\r\n// ----------------------------- TEMPLATE END ----------------------------------\r\n\r\nconst MOD = 998244353\r\nconst LCM16 = 720720 // lcm(1, 2, 3, ..., 16)\r\nconst MAXK = 17\r\n\r\nfunc add(a, b int) int {\r\n\treturn (a + b) % MOD\r\n}\r\n\r\nfunc mul(a, b int) int {\r\n\treturn int(int64(a) * int64(b) % MOD)\r\n}\r\n\r\nvar dp [MAXK][LCM16]int\r\nvar pown [MAXK + 1]int\r\n\r\nfunc main() {\r\n\tdefer flush()\r\n\r\n\tvar n, a0, k, ai int\r\n\tvar genX, genY, genMod int64\r\n\tscan(&n, &a0, &genX, &genY, &k, &genMod)\r\n\r\n\tpown[0] = 1\r\n\tfor i := 1; i <= MAXK; i++ {\r\n\t\tpown[i] = mul(pown[i-1], n)\r\n\t}\r\n\r\n\tans := 0\r\n\tai = a0\r\n\tfor i := 0; i < n; i++ {\r\n\t\tdp[0][ai%LCM16]++\r\n\t\tans = add(ans, mul(ai-ai%LCM16, mul(k, pown[k-1])))\r\n\t\tai = int((int64(ai)*genX + genY) % genMod)\r\n\t}\r\n\r\n\tfor i := 0; i+1 < k; i++ {\r\n\t\tfor j := 0; j < LCM16; j++ {\r\n\t\t\tdp[i+1][j-j%(i+1)] = add(dp[i+1][j-j%(i+1)], dp[i][j])\r\n\t\t\tdp[i+1][j] = add(dp[i+1][j], mul(dp[i][j], n-1))\r\n\t\t}\r\n\t}\r\n\r\n\tfor j := 1; j <= k; j++ {\r\n\t\tfor i := 0; i < LCM16; i++ {\r\n\t\t\tans = add(\r\n\t\t\t\tans,\r\n\t\t\t\tmul(mul(dp[j-1][i], i), pown[k-j]),\r\n\t\t\t)\r\n\t\t}\r\n\t}\r\n\r\n\tprintf(\"%d\\n\", ans)\r\n}\r\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "probabilities", "number theory"], "code_uid": "ac16aa3c89b551be4495f1636c1af117", "src_uid": "1d45491e28d24e2b318605cd328d6ecf", "difficulty": 2800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nvar mem [1e6 + 1]*big.Int\n\nfunc exp(k int) *big.Int {\n\tif mem[k] != nil {\n\t\treturn mem[k]\n\t}\n\tt := exp(k / 2)\n\tmem[k] = new(big.Int).Mul(t, t)\n\tif k&1 != 0 {\n\t\tmem[k].Mul(mem[k], mem[1])\n\t}\n\treturn mem[k]\n}\n\nfunc main() {\n\tvar k, b, n, t int64\n\tfmt.Scan(&k, &b, &n, &t)\n\tif k == 1 {\n\t\tans := (b*n + b - t) / b\n\t\tif ans < 0 {\n\t\t\tans = 0\n\t\t}\n\t\tfmt.Println(ans)\n\t\treturn\n\t}\n\tmem[0] = big.NewInt(1)\n\tmem[1] = big.NewInt(k)\n\tmul := big.NewInt(k - 1 + b)\n\ttarget := big.NewInt(t*(k-1) + b)\n\tfor i := 0; ; i++ {\n\t\tif target.Cmp(new(big.Int).Mul(exp(i), mul)) < 0 {\n\t\t\tans := int(n) - i + 1\n\t\t\tif ans < 0 {\n\t\t\t\tans = 0\n\t\t\t}\n\t\t\tfmt.Println(ans)\n\t\t\treturn\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "6216b09a4aa17172a2ce3b12bbbe22c7", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar numCases int\n\tfmt.Scanf(\"%d\\n\", &numCases)\n\n\tanswers := make([]int, numCases)\n\n\tfor i := 0; i < numCases; i++ {\n\t\tvar n, k, d int\n\t\tfmt.Scanf(\"%d %d %d\\n\", &n, &k, &d)\n\n\t\t_ = k // unused\n\n\t\tschedule := make([]int, n)\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif j == n-1 {\n\t\t\t\tfmt.Scanf(\"%d\\n\", &schedule[j])\n\t\t\t} else {\n\t\t\t\tfmt.Scanf(\"%d\", &schedule[j])\n\t\t\t}\n\t\t}\n\n\t\tanswers[i] = solveCase(schedule, d)\n\t}\n\n\tfor _, a := range answers {\n\t\tfmt.Println(a)\n\t}\n}\n\n// solveCase solves single task case for:\n// * schedule -- index - day, value - show id\n// * days -- target number of days for subscription\nfunc solveCase(schedule []int, days int) (numShows int) {\n\tshows := make(map[int]int)\n\n\tfor i := 0; i < days; i++ {\n\t\tshows[schedule[i]]++\n\t}\n\n\tnumShows = len(shows)\n\n\tfor i := days; i < len(schedule); i++ {\n\t\tcnt := shows[schedule[i-days]]\n\t\tif cnt == 1 {\n\t\t\tdelete(shows, schedule[i-days])\n\t\t} else {\n\t\t\tshows[schedule[i-days]]--\n\t\t}\n\n\t\tshows[schedule[i]]++\n\n\t\tif len(shows) < numShows {\n\t\t\tnumShows = len(shows)\n\t\t}\n\t}\n\n\treturn numShows\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "bc9bfbc7c2666e930bff8f7239edc324", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar DEBUG = true\n\nfunc main() {\n\tdefer Flush()\n\n\th := readi()\n\tw := readi()\n\n\tx := (h - 1) + (w - 1)\n\tans := 4\n\tp := INF3\n\tfor i := 0; i < x; i++ {\n\t\tans = ans * 2 % p\n\t}\n\tprintln(ans)\n\n}\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte. Trailing '\\n' will not be included.\n// See also comments on readb()\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\nfunc dbgf(f string, args ...interface{}) {\n\tif !DEBUG {\n\t\treturn\n\t}\n\tfmt.Fprintf(os.Stderr, f, args...)\n}\n\nfunc dbg(args ...interface{}) {\n\tif !DEBUG {\n\t\treturn\n\t}\n\tfmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Utilities\n\nfunc sumSlice(a []int) int {\n\tvar res int\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc sumSlicell(a []int64) int64 {\n\tvar res int64\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc readInts(N int) (int, []int) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int, N)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\treturn N, a\n}\n\nfunc readIntsll(N int) (int, []int64) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int64, N)\n\tfor i := range a {\n\t\ta[i] = readll()\n\t}\n\treturn N, a\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minf(a, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxf(a, b float64) float64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absf(a float64) float64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "combinatorics"], "code_uid": "7f595210b171d3e132db760e2bcd4d41", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n s := getS()\n n := len(s)\n max := 0\n seen := map[string]bool{}\n for i := 0; i < n; i++ {\n for j := i+1; j <= n; j++ {\n if seen[s[i:j]] && j-i > max {\n max = j-i\n }\n seen[s[i:j]] = true\n }\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", max))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "523ef98a22179ff4dd79101fb54c57a0", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0, "exec_outcome": "PASSED"}