{"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\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 d1, d2, d3 int\n\t_, err := fmt.Scanf(\"%d %d %d\", &d1, &d2, &d3)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tif d1+d3 < d2 {\n\t\tfmt.Println(2 * (d1 + d3))\n\t\treturn\n\t} else if d2+d3 < d1 {\n\t\tfmt.Println(2 * (d2 + d3))\n\t\treturn\n\t}\n\tfmt.Println(min(2*d1+2*d2, d1+d2+d3))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d3292c71b79c07732c0a19135d211d4f", "src_uid": "26cd7954a21866dbb2824d725473673e", "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, m int\n\tfmt.Scan(&n, &m)\n\n\tarr := make([]int, m)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scan(&arr[i])\n\t}\n\n\tsort.Ints(arr)\n\tminm := 1e9\n\tfor i := n - 1; i < m; i++ {\n\t\tminm = (math.Min(float64(minm), float64(arr[i] - arr[i - (n - 1)])))\n\t}\n\tfmt.Println(minm)\n}", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "1d475d79fd52c0799578d5e4c43bcc88", "src_uid": "7830aabb0663e645d54004063746e47f", "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\tx := readInt()\n\ta := make([]bool, 101)\n\tfor i := 0; i < n; i++ {\n\t\ta[readInt()] = true\n\t}\n\ts := 0\n\tfor i := 0; i < x; i++ {\n\t\tif !a[i] {\n\t\t\ts++\n\t\t}\n\t}\n\tif a[x] {\n\t\ts++\n\t}\n\tfmt.Println(s)\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": ["greedy", "implementation"], "code_uid": "c0467da1e198627d3ee1bf5718d8c728", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// URL: http://codeforces.com/problemset/problem/486/A\n// f(n) = -1 + 2 - 3 + ... + (-1) ^ n * n\n// APPROACH\n// Consider even terms:\n// f(0) = 0, f(2) = 1, f(4) = 2, f(6) = 3\n// Consider odd terms:\n// f(1) = -1, f(3) = -2, f(5) = -3\n// NOTE\n// Be careful of bounds -> use int64 when necessary.\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc solve(n int64) int64 {\n\tif n % 2 == 0 {\n\t\treturn n / 2\n\t}\n\treturn (-n - 1)/2\n}\n\nfunc main() {\n\treader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar n int64\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\tfmt.Fprintf(writer, \"%d\\n\", solve(n))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "3442787746caf3457ba50daa0c994ffd", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.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 number int\n\n\tfmt.Scanln(&number)\n\tif almostLucky(number) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc almostLucky(number int) bool {\n\tvar divs []int\n\n\tdivs = divisors(number)\n\n\tfor _, div := range divs {\n\t\tif lucky(div) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc lucky(number int) bool {\n\tvar str string\n\n\tstr = strconv.Itoa(number)\n\n\tfor _, letter := range str {\n\t\tif letter != '4' && letter != '7' {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc divisors(number int) []int {\n\tvar divs []int\n\tvar sqrt int\n\n\tdivs = []int{1, number}\n\tsqrt = int(math.Sqrt(float64(number)))\n\n\tfor i := 2; i <= sqrt; i++ {\n\t\tif number%i == 0 {\n\t\t\tdivs = append(divs, i)\n\t\t\tif number/i != i {\n\t\t\t\tdivs = append(divs, number/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divs\n}\n", "lang_cluster": "Go", "tags": ["brute force", "number theory"], "code_uid": "3826cd7020faa2d6496ebfc218244fe9", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.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// \"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, k := nextInt(), nextInt()\n\tlog.SetOutput(os.Stderr)\n\tlog.Println(n, k)\n\tif n < k {\n\t\tprintln(k)\n\t} else {\n\t\tprintln((n/k + 1) * k)\n\t}\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": "63515a2f7b9c7e95a191e7efff596aa4", "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\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\tfingers := 0\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; i < n && 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\tfingers += a\n\t}\n\n\tways := 0\n\tfor i := 1; i <= 5; i++ {\n\t\tif (fingers+i)%(n+1) != 1 {\n\t\t\tways++\n\t\t}\n\t}\n\n\tfmt.Println(ways)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "821a0bd3543dc36356de798879b082b9", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n)\nimport \"fmt\"\n\nfunc main() {\n\tvar n, prev, now int64\n\tfmt.Scan(&n)\n\tprev = 1\n\tnow = 2\n\tans := 0\n\tfor now <= n {\n\t\tprev, now = now, prev + now\n\t\tans += 1;\n\t}\n\tfmt.Println(ans)\n}\n\n", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "ded39b17005941b1fb27d8704766e06e", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0, "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\tn -= 10\n\tif n <= 0 {\n\t\tfmt.Println(0)\n\t} else if n < 10 || n == 11 {\n\t\tfmt.Println(4)\n\t} else if n == 10 {\n\t\tfmt.Println(15)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2996f2dd27f8cf241cbe82e0c40460ae", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 245B-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var s string\n var i, f, d int\n fmt.Scan(&s)\n //cin>>s;\n //int i,flag=0,dash=0;\n if s[0] == 'h' {\n fmt.Print(\"http://\")\n i = 4\n } else {\n fmt.Print(\"ftp://\")\n i = 3\n }\n\n for ; i < len(s); i++ {\n if s[i] == 'r' && f != -1 && d != 0 {\n if (s[i+1] == 'u') && (i+1) < len(s) {\n fmt.Print(\".ru\")\n f = -1\n i++\n } else {\n fmt.Print(string(s[i]))\n }\n } else if f == -1 && i <= len(s)-1 {\n fmt.Print(\"/\")\n for ; i < len(s); i++ {\n fmt.Print(string(s[i]))\n }\n break\n } else {\n fmt.Print(string(s[i]))\n d++\n }\n }\n fmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "84e50a340886e669bd2614892acc4b97", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\"fmt\"\n\"os\"\n)\nfunc main(){ \n //var a,b,c,d,e int\n var n int\n var iRow,iCol int\n for i:=1;i<=5;i++ {\n //fmt.Scan(&a,&b,&c,&d,&e)\n for j:=1;j<=5;j++ {\n fmt.Scan(&n)\n if n == 1 {\n iRow = i\n iCol = j\n }\n }\n}\niCount := 0 \nfor i:=1;i<=5;i++ {\n if iCol != 3 {\n if iCol > 3 {\n iCol--\n iCount++\n }else {\n iCol++\n iCount++\n }\n }\n if iRow != 3 {\n if iRow > 3 {\n iRow--\n iCount++\n }else {\n iRow++\n iCount++\n }\n }\n}\nfmt.Fprintf(os.Stdout,\"%d\",iCount)\n}\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4fff3429c532a70c38c400b605d7fac5", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "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\ta, b := nextInt(), nextInt()\n\n\tif a > b {\n\t\tprintln(b, (a-b)/2)\n\t} else {\n\t\tprintln(a, (b-a)/2)\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": ["math", "implementation"], "code_uid": "470ffe12e779d80714253e7ae38eb1f2", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\nimport \"sort\"\n\nfunc main(){\n\tvar n string\n\tvar m 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\tr.Scan()\n\tm = r.Text()\n\ta := make([]int, len(n))\n\tb := make([]int, len(n))\n\tcz := 0\n\tif string(n) == \"0\" && string(m) == \"0\" {\n\t\tw.WriteString(\"OK\\n\")\n\t\tw.Flush()\n\t\treturn\n\t} else if string(n) == \"0\" && string(m) == \"7\" {\n\t\tw.WriteString(\"WRONG_ANSWER\\n\")\n\t\tw.Flush()\n\t\treturn\n\t}\n\tif len(n) == len(m) {\n\t\tfor i:=0; i y {\n return x\n } else {\n return y\n }\n}\n\nfunc main() {\n var grown_ups, children, max int\n fmt.Scan(&grown_ups, &children)\n\n if grown_ups < 1 && children > 0 {\n fmt.Print(\"Impossible\")\n return\n }\n\n if children > 0 {\n max = grown_ups + children - 1\n } else {\n max = grown_ups\n }\n\n fmt.Print(Max(grown_ups, children), \" \", max)\n}", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "219ea8b6a11876db39dddf2305890a92", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a int\n\tfmt.Scanf(\"%d\", &a)\n\tif a%2 == 1 || a == 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "b7295fab632c208fa6a9c24d933a6c9b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "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\ntype Team struct {\n main uint8\n second uint8\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tvar n uint8\n\tvar c uint16\n\tvar s []Team\n\t\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tfor i:= uint8(0); i < n; i++{\n\t\tvar t Team\n\t\tfmt.Fscanf(in, \"%d %d\\n\", &t.main, &t.second)\n\t\ts = append(s, t)\n\t}\n\tfor i:= uint8(0); i < n; i++{\n\t\tfor j:= uint8(0); j < n; j++{\n\t\t\tif i != j{\n\t\t\t\tif s[i].main == s[j].second{\n\t\t\t\t\tc++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(c)\n\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "485d0080b0ca72992ee899f6350639f4", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//https://codeforces.com/problemset/problem/476/B\n//http://bigocoder.com/courses/ORANGE03/ORANGE03_LEC03/ORANGE_L03P05/statement\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc solve(c int, n int) float64 {\n\ttotal := math.Pow(2, float64(n))\n\tp := permutation(c, n)\n\n\treturn p / total\n}\n\nfunc permutation(c int, n int) float64 {\n\treturn factorial(n) / (factorial(n-c) * factorial(c))\n}\n\nfunc factorial(n int) float64 {\n\tres := 1\n\tfor i := 1; i <= n; i++ {\n\t\tres *= i\n\t}\n\n\treturn float64(res)\n}\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\tvar command, received string\n\tvar count int\n\tflag := true\n\tfmt.Fscanf(r, \"%s\\n\", &command)\n\tfmt.Fscanf(r, \"%s\\n\", &received)\n\tcache := map[byte]int{}\n\n\tfor i := range command {\n\t\tcache[command[i]]++\n\t}\n\n\tfor i := range received {\n\t\tif received[i] == '?' {\n\t\t\tcount++\n\t\t} else {\n\t\t\tcache[received[i]]--\n\t\t}\n\t}\n\n\tfor _, v := range cache {\n\t\tif v < 0 || v != 0 && count == 0 {\n\t\t\tflag = false\n\t\t}\n\t}\n\n\tif flag {\n\t\tif count > 0 {\n\t\t\tfmt.Fprintf(os.Stdout, \"%.10f\\n\", solve(cache['+'], count))\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": "a35f6e5ea652892047a155d782d2afcb", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc Process(a []int64) (int64, []int64) {\n\tvar m = map[int64]bool{}\n\tvar r = make([]int64, 0)\n\n\tfor i := len(a) - 1; i >= 0; i-- {\n\t\tif _, exist := m[a[i]]; !exist {\n\t\t\tr = append([]int64{a[i]}, r...)\n\t\t}\n\n\t\tm[a[i]] = true\n\t}\n\n\treturn int64(len(r)), r\n}\n\nfunc main() {\n\tvar n int64\n\n\tfmt.Scanln(&n)\n\n\tvar a, _ = ScanN(n)\n\n\tvar r1, r2 = Process(a)\n\n\tfmt.Println(r1)\n\n\tPrintSlice(r2)\n}\n\nfunc ScanN(n int64) ([]int64, error) {\n\tin := make([]int64, n)\n\tfor i := range in {\n\t\t_, err := fmt.Scan(&in[i])\n\t\tif err != nil {\n\t\t\treturn in[:i], err\n\t\t}\n\t}\n\treturn in, nil\n}\n\nfunc PrintSlice(a []int64) {\n\tfor i := 0; i < len(a); i++ {\n\t\tif i == len(a)-1 {\n\t\t\tfmt.Print(a[i])\n\t\t} else {\n\t\t\tfmt.Print(a[i], \" \")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "dab242bdbdc1251daad326301b004db1", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//Sri VatapatraSayi's Grace\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar receive int\n\tfmt.Scanln(&receive)\n\tanswer := 0\n\tanswer += (receive) / 5\n\tif receive%5 != 0 {\n\t\tanswer++\n\t}\n\tfmt.Println(answer)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "03be448c9bf47a748df6c5bcee3764ba", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.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 CF1701A(in io.Reader, out io.Writer) {\r\n\tvar T, v int\r\n\tfor Fscan(in, &T); T > 0; T-- {\r\n\t\tc := 0\r\n\t\tfor i := 0; i < 4; i++ {\r\n\t\t\tFscan(in, &v)\r\n\t\t\tc += v\r\n\t\t}\r\n\t\tif c == 0 {\r\n\t\t\tFprintln(out, 0)\r\n\t\t} else if c < 4 {\r\n\t\t\tFprintln(out, 1)\r\n\t\t} else {\r\n\t\t\tFprintln(out, 2)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunc main() { CF1701A(os.Stdin, os.Stdout) }\r\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "fada32d914ad493ff35e949d42c6f64f", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"bufio\"\nimport \"strconv\"\nimport \"os\"\n\nvar in *bufio.Scanner\nvar out *bufio.Writer\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\tpos := in.Text()\n\n\trow := int(pos[0]-'a') + 1\n\tcol := int(pos[1] - '0')\n\n\tdr := []int{-1, -1, -1, 0, 1, 1, 1, 0}\n\tdc := []int{-1, 0, 1, 1, 1, 0, -1, -1}\n\n\tres := 0\n\tfor i := 0; i < 8; i++ {\n\t\tr := row + dr[i]\n\t\tc := col + dc[i]\n\t\tif (1 <= r) && (r <= 8) && (1 <= c && c <= 8) {\n\t\t\tres++\n\t\t}\n\t}\n\n\tout.WriteString(strconv.Itoa(res))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a27823872fec19b7c7579f4940fa708b", "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)\n\nfunc solve() {\n\tl := readInt64()\n\tr := readInt64()\n\tx := readInt64()\n\ty := readInt64()\n\tk := readInt64()\n\tfor j := x; j <= y; j++ {\n\t\tt := j * k\n\t\tif t > r {\n\t\t\tbreak\n\t\t}\n\t\tif t >= l && t <= r {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\t// for i := l; i <= r; i++ {\n\t// \tfor j := x; j <= y; j++ {\n\t// \t\tif i%j == 0 && i/j == k {\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": ["two pointers", "brute force"], "code_uid": "74e106c856469dcb92d587d00e4782ae", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200.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 read = bufio.NewReader(os.Stdin)\n\tvar n, k int64\n\tfmt.Fscan(read, &n, &k)\n\tvar d = int64(math.Sqrt(float64(9 + 8*(k+n))))\n\tvar r = n - (d-3)/2\n\tfmt.Print(r)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search"], "code_uid": "9eb3b4796808a5dcfab2a9394ae899c8", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n/*\n\tTo solve this problem basically we just need to generate login\n\tstring which alphabetically earliest than any other string login string.\n\n\tThe rules to generate login string are following:\n\t- must concatenate prefix of user's first name & last name\n\t- each prefix must not be empty\n\t- any prefix can be full name\n\n\tA string is said alphabetically earlier than other string if:\n\t- string is prefix of other string (ab >< abc, ab is earlier)\n\t- string is coincide up to some point with another\n\t string then string has char which alphabetically earlier than\n\t corresponding letter in another string (a >< ab >< ac => a < ab < ac)\n\n\tNotice that the minimum string we can generate is first[0] + last[0], yet\n\twith only this we already got decent enough early string. But can we make\n\tthis string much earlier?\n\n\tYes! If all char in first[1:] is alphabetically earlier than last[0]. So yeah,\n\tbasically we just need to get all chars in first name which earlier than last[0],\n\tthen combine them into a string.\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar first, second string\n\tstdio := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdio, \"%s %s\", &first, &second)\n\tidx := 1\n\tfor i := 1; i < len(first); i++ {\n\t\tif first[i] < second[0] {\n\t\t\tidx++\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(first[:idx] + \"\" + second[:1])\n}\n", "lang_cluster": "Go", "tags": ["brute force", "sortings", "greedy"], "code_uid": "97374713e9e85cddc447b331842ecb30", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "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 solve() {\n\tc := readInt()\n\tv0 := readInt()\n\tv1 := readInt()\n\ta := readInt()\n\tl := readInt()\n\tres := 0\n\tdone := 0\n\tfor c > 0 {\n\t\tres++\n\t\tcnt := v0 + (res-1)*a\n\t\trep := 0\n\t\tif res > 1 {\n\t\t\tif l > done {\n\t\t\t\trep = done\n\t\t\t} else {\n\t\t\t\trep = l\n\t\t\t}\n\t\t}\n\t\tif cnt > v1 {\n\t\t\tcnt = v1\n\t\t}\n\t\tcnt -= rep\n\t\tc -= cnt\n\t\tdone += cnt\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}\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": "ed6452bf2d3c68080de2ee233b7c40f3", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\n\nfunc max3(x, y, z int) (int, bool){\n\tif (x >= y) && (x >= z) && ((x - y - z) <= 0){\n\t\treturn x - y - z, true\n\t}else if (y >= x) && (y >= z) && ((y - x - z) <= 0){\n\t\treturn y - x - z, true\n\t}else if (z>=y)&&(z >= x)&&((z-y-x) <= 0){\n\t\treturn z-y-x, true\n\t}else{\n\t\treturn 0, false\n\t}\n}\n\nfunc main() {\n\tsticks := make([]int, 4)\n\tfmt.Scan(&sticks[0], &sticks[1], &sticks[2], &sticks[3])\n\tans := \"IMPOSSIBLE\"\n\tfor i := 0; i < 4; i++{\n\t\tif c, ok:= max3(sticks[i%4], sticks[(i+1)%4], sticks[(i+2)%4]); (c < 0) && ok {\n\t\t\tans = \"TRIANGLE\"\n\t\t\tbreak\n\t\t}else if (c == 0) && ok{\n\t\t\tans = \"SEGMENT\"\n\t\t}\n\t}\n\n\n\tfmt.Print(ans)\n}", "lang_cluster": "Go", "tags": ["brute force", "geometry"], "code_uid": "7ed91d6d886d5f9d3019352b6642a7c3", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n)\n\nvar (\n\thi = []string{\"h\", \"e\", \"l\", \"l\", \"o\"}\n)\n\nfunc main() {\n\tvar (\n\t\ts string\n\t\tcounter int\n\t\tlength = len(hi)\n\t)\n\tif _, err := fmt.Scanf(\"%s\\n\", &s); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfor i := range s {\n\t\tif s[i:i+1] == hi[counter] {\n\t\t\tcounter++\n\t\t\tif counter == length {\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": ["greedy", "strings"], "code_uid": "33ec15418e31fb1f26e884904b7c0d92", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar aa, xx, yy, k, l, s int\n\tfmt.Scan(&aa, &xx, &yy)\n\tif yy==0 {\n\t\tfmt.Println(\"-1\")\n\t\treturn\n\t}\n\tif yy0 {\n\t\t\tfmt.Println(\"1\")\n\t\t} else {\n\t\t\tfmt.Println(\"1\")\n\t\t}\n\t} else if yy>=aa {\n\t\tk=yy-aa\n\t\tif k%aa==0 {\n\t\t\tfmt.Println(\"-1\")\n\t\t\treturn\n\t\t} else {\n\t\t\ts=0\n\t\t\tl=k/aa\n\t\t\tif l%2==0 {\n\t\t\t\ts=1+3*(l/2)\n\t\t\t\tif float64(aa)>2*math.Abs(float64(xx)) {\n\t\t\t\t\ts+=1\n\t\t\t\t\tfmt.Println(s)\n\t\t\t\t\treturn\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Println(\"-1\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif l>1 {\n\t\t\t\t\ts=2+3*(l-1)/2\n\t\t\t\t} else {\n\t\t\t\t\ts=2\n\t\t\t\t}\n\t\t\t\tif float64(aa)<=math.Abs(float64(xx)) {\n\t\t\t\t\tfmt.Println(\"-1\")\n\t\t\t\t\treturn\n\t\t\t\t} else {\n\t\t\t\t\tif xx==0 {\n\t\t\t\t\t\tfmt.Println(\"-1\")\n\t\t\t\t\t} else if xx<0 {\n\t\t\t\t\t\ts+=1\n\t\t\t\t\t\tfmt.Println(s)\n\t\t\t\t\t} else if xx>0 {\n\t\t\t\t\t\ts+=2\n\t\t\t\t\t\tfmt.Println(s)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "997cd6158ed9ded8ae4c88a61c8acc0c", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport (\n \"fmt\"\n s \"strings\"\n)\n func main() {\n var l int\n var str string\n fmt.Scan(&l, &str)\n fs := s.Count(str, \"FS\")\n sf := s.Count(str, \"SF\")\n if sf > fs {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2becc8fa1acbeafe1beeba73932b1549", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc isPalindrome(tt int) bool {\n\treturn tt%60%10 == tt/60/10 && tt%60/10 == tt/60%10\n}\n\nfunc main() {\n\tvar hh, mm int\n\tfor {\n\t\texitCode, err := fmt.Scanf(\"%d:%d\", &hh, &mm)\n\t\tif exitCode == -1 || err != nil {\n\t\t\tbreak\n\t\t}\n\t\ttt := hh*60 + mm\n\t\tfor i := 0; ; i++ {\n\t\t\tif isPalindrome(tt) {\n\t\t\t\tfmt.Printf(\"%d\\n\", i)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ttt = (tt + 1) % (24 * 60)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "b6b3a348359d3fe2ed173b76ca67eadf", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "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, k int\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &n, &m, &k); err != nil {\n\t\treturn\n\t}\n\n\tlane := (k-1)/(2*m) + 1\n\tlane_start := (lane-1)*2*m + 1\n\tdesk := (k-lane_start)/2 + 1\n\tvar place string\n\tif (k-lane_start)%2 == 0 {\n\t\tplace = \"L\"\n\t} else {\n\t\tplace = \"R\"\n\t}\n\n\tfmt.Println(lane, desk, place)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "52361856721b6f5bffb9248530ffba70", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar length uint8\n\tvar line string\n\n\tfmt.Scanln(&length)\n\tfmt.Scanln(&line)\n\n\tvar min uint8 = 0\n\tvar i uint8\n\tfor i = 0; i < (length - 1); i++ {\n\t\tif line[i] == line[i+1] {\n\t\t\tmin++\n\t\t}\n\t}\n\n\tfmt.Println(min)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "6a6b6122f22ac7edbf88df4324266846", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport(\n\t\"fmt\"\n)\n\n\nfunc main(){\t\n\tvar k, n, w int64\n\tfmt.Scan(&k, &n, &w)\n\tneeded := ((w*(w + 1)) >> 1)*k\n\tneeded -= n\n\tif needed < 0{needed = 0}\n\tfmt.Print(needed)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "57fc20236f6f4a35c80249717b4bb78a", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tvar count int\n\tfmt.Scanf(\"%s\", &s)\n\tfor i := range s {\n\t\tif s[i] == '7' || s[i] == '4' {\n\t\t\tcount++\n\t\t}\n\t}\n\tif count == 7 || count == 4 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "26fbbf9e150685f2f67de8d7b2b0f08d", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "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\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\t_, ta, b, tb := nextInt(), nextInt(), nextInt(), nextInt()\n\ttimes := strings.Split(next(), \":\")\n\th, _ := strconv.Atoi(times[0])\n\tm, _ := strconv.Atoi(times[1])\n\tbegin := 60*h + m\n\tret := 0\n\tfor i := 300; i < 24*60; i += b {\n\t\t// println(i, i+tb)\n\t\tif i+tb > begin && i < begin+ta {\n\t\t\tret++\n\t\t}\n\t}\n\n\tprintln(ret)\n\t// println(begin, begin+ta)\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": "85441ce85de024627e2668da90b3e394", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.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.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, d := nextInt(), nextInt()\n\t// t := make([]int, n)\n\tcount := 0\n\n\t// for i:=0; i 0; x /= 10 {\n\t\t\ts += x % 10\n\t\t}\n\t\tif s%4 == 0 {\n\t\t\tFprint(_w, n)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc main() { CF1183A(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5bf0c507f5acbe86beccd613b62f8156", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar cipher string\n\tfmt.Scan(&n, &cipher)\n\tvar cur int = 0\n\tfor i := 1; cur < len(cipher); i++ {\n\t\tfmt.Printf(\"%c\", cipher[cur])\n\t\tcur += i\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ddee6f6966976167145c974db8314d4b", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "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\tA := readll()\n\tB := readll()\n\tx := readll()\n\ty := readll()\n\tz := readll()\n\n\ta := 2 * x\n\ta += y\n\tb := y\n\tb += 3 * z\n\tprintln(maxll(a-A, 0) + maxll(b-B, 0))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f152981443b412daddfef2c8240baeed", "src_uid": "35202a4601a03d25e18dda1539c5beba", "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\tfmt.Scan(&n)\n\ti := 1\n\tfor n >= 0 {\n\t\tx := i * (i + 1) / 2\n\t\tif n < x {\n\t\t\ti--\n\t\t\tbreak\n\t\t}\n\t\ti++\n\t\tn -= x\n\t}\n\tfmt.Println(i)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "8657b8f3d20e011d63d989956c26b515", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport \"fmt\"\n\n\nfunc main() {\n\tvar (\n\t\ta int16 = 0\n\t\tb int16 = 0\n\t\tc int16 = 0\n\t)\n\tfmt.Scanf(\"%d\", &a)\n\tfmt.Scanf(\"%d\", &b)\n\tfor b >= a {\n\t\tb *= 2;\n\t\ta *= 3;\n\t\tc++;\n\t}\n\tfmt.Println(c)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4317e552c53577d4856a84f6653bee05", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main(){\n\tvar input_string string\n\t_, er := fmt.Scan(&input_string)\n\tif er != nil{\n\t\tos.Exit(1)\n\t}\n\tinput_string = strings.ToLower(input_string)\n\tfor _,char := range input_string{\n\t\titem := string(char)\n\t\tif !strings.Contains(\"aeioyu\", item){\n\t\t\tfmt.Print(\".\")\n\t\t\tfmt.Print(item)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "a8d5a6009718d8a038ee820280f8b82e", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "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 CF678D(in io.Reader, out io.Writer) {\n\tconst p 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 % p\n\t\t\t}\n\t\t\tx = x * x % p\n\t\t}\n\t\treturn res\n\t}\n\n\tvar a, b, n, x int64\n\tFscan(in, &a, &b, &n, &x)\n\tif an := pow(a, n); a == 1 {\n\t\tFprint(out, (an*x+n%p*b)%p)\n\t} else {\n\t\tFprint(out, (an*x+(an-1)%p*pow(a-1, p-2)%p*b)%p)\n\t}\n}\n\nfunc main() { CF678D(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "d3212cab95524642884c067bbb1e3ad4", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar (\n\tn, k, ans int\n\ts string\n\tmp map[int]int\n)\n\nfunc main() {\n\tfmt.Scanln(&n, &k)\n\tfmt.Scanln(&s)\n\n\tmp = make(map[int]int)\n\tfor i := 97; i < 123; i++ {\n\t\tmp[i] = 0\n\t}\n\n\tfor _, value := range s {\n\t\tmp[int(value)]++\n\t}\n\n\tfor {\n\t\tif k == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\tfor i := 97; i < 123; i++ {\n\t\t\tif i == 122 {\n\t\t\t\tif mp[i] == 0 {\n\t\t\t\t\t// 此题无解\n\t\t\t\t\tk = 0\n\t\t\t\t\tans = -1\n\t\t\t\t\tbreak\n\t\t\t\t} else {\n\t\t\t\t\t// 最后一次机会\n\t\t\t\t\tans += i - 96\n\t\t\t\t\tmp[i] = 0\n\t\t\t\t\tk--\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (mp[i] != 0) {\n\t\t\t\tans += i - 96\n\t\t\t\tmp[i] = 0\n\t\t\t\tmp[i + 1] = 0\n\t\t\t\tk--\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "07f9addf7ff89df3d51b2d67a0c6b751", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s, t string\n\tfmt.Scan(&s, &t)\n\ti := 0\n\tfor j := range t {\n\t\tif s[i] == t[j] {\n\t\t\ti += 1\n\t\t}\n\t}\n\tfmt.Println(i + 1)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "c367f4e5238c458663085af95fbf7b59", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.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 writer.WriteString(\"+------------------------+\\n\")\n if n <= 4 {\n switch n {\n case 0:\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|D|)\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|\\n\")\n writer.WriteString(\"|#.......................|\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n\")\n break\n case 1:\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|\\n\")\n writer.WriteString(\"|#.......................|\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n\")\n break\n case 2:\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\\n\")\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\\n\")\n writer.WriteString(\"|#.......................|\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n\")\n break\n case 3:\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\\n\")\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\\n\")\n writer.WriteString(\"|O.......................|\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n\")\n break\n case 4:\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\\n\")\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\\n\")\n writer.WriteString(\"|O.......................|\\n\")\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|.|)\\n\")\n break\n }\n } else {\n s := make([]string, 3)\n s[1] = \"|O.#.#.#.#.#.#.#.#.#.#.|D|)\\n\"\n s[2] = \"|O.#.#.#.#.#.#.#.#.#.#.|.|\\n\"\n s[0] = \"|O.#.#.#.#.#.#.#.#.#.#.|.|)\\n\"\n n -= 4\n\n for i := 1; i <= n; i++ {\n s[i%3] = strings.Replace(s[i%3], \"#\", \"O\", 1)\n }\n writer.WriteString(s[1])\n writer.WriteString(s[2])\n writer.WriteString(\"|O.......................|\\n\")\n writer.WriteString(s[0])\n }\n\n writer.WriteString(\"+------------------------+\\n\")\n}\n\n/*\n\n|O.O.O.#.#.#.#.#.#.#.#.|D|)\n|O.O.O.#.#.#.#.#.#.#.#.|.|\n|O.......................|\n|O.O.#.#.#.#.#.#.#.#.#.|.|)\n\n*/\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "1f56f807177dd44d8c0e04cf0e07c16b", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\r\nimport (\"fmt\"\r\n\t\t\"os\"\r\n\t\t)\r\nfunc main(){\r\n\tvar l,x,s,n2,n3 int64\r\n\tfmt.Fscan(os.Stdin, &l)\r\n\tfor l > 0 {\r\n\t\tfmt.Fscan(os.Stdin, &x)\r\n\t\tn2=1\r\n\t\tn3=1\r\n\t\ts=0\r\n\t\tfor ( n2*n2 <= x || n3*n3*n3 <= x) {\r\n\t\t if n2*n2 == n3*n3*n3 {\r\n\t\t n2++\r\n\t\t n3++\r\n\t\t } else if n2*n2 < n3*n3*n3 {\r\n\t\t n2++\r\n\t\t } else {\r\n\t\t n3++\r\n\t\t }\r\n\t\t s++\r\n\t\t}\r\n\t\tfmt.Println(s)\r\n\t\tl--\r\n\t}\r\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "0d262f5449563c0dd22ec70f6460dfca", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "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,k i64\n )\n fmt.Scan(&n,&k)\n for k>0{\n if temp:=n%10;temp !=0 {\n n = n-1\n }else{\n n = n/10\n }\n k--\n }\n fmt.Println(n)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "9605f99b85f9aec4264b092f468d3694", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/479/A\n// A. Expression\n// time limit per test\n// 1 second\n// memory limit per test\n// 256 megabytes\n// input\n// standard input\n// output\n// standard output\n\n// Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard. Here are some ways of placing signs and brackets:\n\n// 1+2*3=7\n// 1*(2+3)=5\n// 1*2*3=6\n// (1+2)*3=9\n\n// Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers. For instance, in the given sample you cannot get expression (1+3)*2.\n\n// It's easy to see that the maximum value that you can obtain is 9.\n\n// Your task is: given a, b and c print the maximum value that you can get.\n// Input\n\n// The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).\n// Output\n\n// Print the maximum value of the expression that you can obtain.\n\nfunc main() {\n\tvar a, b, c int\n\t_, _ = fmt.Scan(&a, &b, &c)\n\n\t_, _ = fmt.Print(intMax(a*b*c, a+b+c, (a+b)*c, a*b+c, a+b*c, a*(b+c)))\n\n}\n\nfunc intMax(vs ...int) int {\n\tm := vs[0]\n\tfor i := 1; i < len(vs); i++ {\n\t\tif vs[i] > m {\n\t\t\tm = vs[i]\n\t\t}\n\t}\n\n\treturn m\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "64cf0bd08b4de6b88f2e8d53f06c6e2f", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "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\n\tvar lastUp = N\n\tvar firstDown = -1\n\n\tfor i := 0; i < N-1; i++ {\n\t\tif A[i+1]-A[i] <= 0 {\n\t\t\tlastUp = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor i := N - 1; i >= 1; i-- {\n\t\tif A[i]-A[i-1] >= 0 {\n\t\t\tfirstDown = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor i := lastUp; i < firstDown; i++ {\n\t\tif A[i+1]-A[i] != 0 {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"YES\")\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": "4981fc5c5fcb0938389dea68a8e1527d", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "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 int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tarray := 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\ta, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tarray[i] = a\n\t}\n\n\thas_inequality := true\n\tfor has_inequality {\n\t\thas_inequality = false\n\t\tfor i := 0; i < n; i++ {\n\t\t\tfor j := i + 1; j < n; j++ {\n\t\t\t\tif array[i] != array[j] {\n\t\t\t\t\thas_inequality = true\n\t\t\t\t\tc := sub_algorithm(array[i], array[j])\n\t\t\t\t\tarray[i] = c\n\t\t\t\t\tarray[j] = c\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tsum := 0\n\tfor i := 0; i < n; i++ {\n\t\tsum += array[i]\n\t}\n\tfmt.Println(sum)\n}\n\nfunc sub_algorithm(a, b int) int {\n\tif a == b {\n\t\treturn a\n\t} else if b > a {\n\t\ta, b = b, a\n\t}\n\treturn sub_algorithm(a-b, b)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "c6743fa77befe08aacaddb27851a1c6e", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc pwer (a, p int64) int64 {\n var m int64 = 1\n for ; p > 0; p -- {\n m = m * a\n }\n return m\n}\n\nfunc main() {\n var l, r int64\n fmt.Scan(&l, &r)\n var answer, a, b int64 = 0, 0, 0\n for a = 0; a < 39; a ++ {\n\t\tfor b = 0; b < 39; b ++ {\n\t\t var c int64 = pwer(2, a) * pwer(3, b)\n\t\t if ((l <= c) && (c <= r)) {\n\t\t answer ++\n\t\t }\n\t\t}\n\t}\n fmt.Println(answer)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "1a04423061d0c98e020489089ae59dd9", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\nimport \"bufio\"\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n result := 0\n for i := 0; i < 8; i++ {\n line, _, _:= reader.ReadLine()\n for k := 0; k < len(line); k++ {\n switch line[k] {\n case 'Q' : result += 9\n case 'q' : result -= 9\n\n case 'R' : result += 5\n case 'r' : result -= 5\n\n case 'B' : result += 3\n case 'b' : result -= 3\n\n case 'N' : result += 3\n case 'n' : result -= 3\n\n case 'P' : result += 1\n case 'p' : result -= 1\n }\n }\n }\n\n switch {\n case result == 0 : fmt.Println(\"Draw\")\n case result < 0 : fmt.Println(\"Black\")\n case result > 0 : fmt.Println(\"White\")\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "d3bfb51f04839256a8811e3bc0c54d0f", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "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\t\"strings\"\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 main() {\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\tdefer w.Flush()\n\tvar id string\n\tfor I(&id, \"\\n\") == nil {\n\t\tif solve(id) {\n\t\t\tO(\"YES\", \"\\n\")\n\t\t} else {\n\t\t\tO(\"NO\", \"\\n\")\n\t\t}\n\t}\n}\nfunc solve(id string) bool {\n\tpattern := \"^[a-zA-Z0-9_]{1,16}@([a-zA-Z0-9_]{1,16}\\\\.?)*(\\\\/[a-zA-Z0-9_]{1,16})?$\"\n\tif regexp.MustCompile(pattern).MatchString(id) {\n\t\to := strings.Split(id, \"@\")\n\t\tif strings.Contains(o[1], \"/\") {\n\t\t\to = append([]string{o[0]}, strings.Split(o[1], \"/\")...)\n\t\t}\n\t\tif len(o[1]) >= 1 && len(o[1]) <= 32 && o[1][len(o[1])-1] != '.' {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "c721ea9a93114524c47c7b0a84d1a7af", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n var n,k,i,w,v,s uint64\n \n fmt.Scan(&n, &k)\n s=k\n v=400\n\n for i=1;i<=n;i++ {\n fmt.Scan(&w)\n if ( w==0 && i<=k) {\n fmt.Println(i-1);\n return\n }\n if ( i==k ) { v = w }\n if ( i!=k && v==w ) { s++; } \n } \n fmt.Println(s)\n\n\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "9a253a5b1ad17244b5980f33cbab553c", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y, z, a, b, c int\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n\tif a >= x && a+b >= x+y && a+b+c >= x+y+z {\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": "f2f321957443263820aec2f180d4c95c", "src_uid": "d54201591f7284da5e9ce18984439f4e", "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\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt64()\n\tvar sum, i int64 = 0, 0\n\n\tfor sum+i+1 <= n {\n\t\tsum += i\n\t\ti++\n\t}\n\t// println(sum)\n\tprintln(n - sum)\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": "29fdcad8508bb6ead4ee977e61e0ba29", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//http://codeforces.com/problemset/problem/378/A\n//A. Playing with Dice\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\ti, a, b, wa, d, wb int32\n\t)\n\n\tabs := func(x int32) int32 {\n\t\tif x < 0 {\n\t\t\treturn -x\n\t\t}\n\t\treturn x\n\t}\n\n\tfmt.Scan(&a)\n\tfmt.Scan(&b)\n\tfor i = 1; i <= 6; i++ {\n\t\tif abs(a-i) < abs(b-i) {\n\t\t\twa++\n\t\t\tcontinue\n\t\t}\n\t\tif abs(a-i) > abs(b-i) {\n\t\t\twb++\n\t\t\tcontinue\n\t\t}\n\t\td++\n\t}\n\tfmt.Println(wa, d, wb)\n\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "58d9e12dc6aa6dee87c5b2562d01b0e4", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.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 s, x, ans int64\n\tScan(&s, &x)\n\tif d := s - x; d >= 0 && d&1 == 0 && d/2|x == d/2+x {\n\t\tans = int64(1) << bits.OnesCount64(uint64(x))\n\t\tif d == 0 {\n\t\t\tans -= 2\n\t\t}\n\t}\n\tPrint(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp"], "code_uid": "1fbd76053b5b170aea2005bfbd043354", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, c int\n\n\tfmt.Scan(&n, &c)\n\n\txi := make([]int, n)\n\n\tfor i := range xi {\n\t\tfmt.Scan(&xi[i])\n\t}\n\n\tmax, dif := 0, 0\n\n\tfor i:=0; i max {\n\t\t\tmax = dif\n\t\t}\n\t}\n\t\n\tif max == 0 || max <= c {\n\t\tfmt.Println(0)\n\t} else {\n\t\tfmt.Println(max - c)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "2b218c6ca0ad145b55387d5d97f1cb84", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "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\tbuf := bufio.NewReader(os.Stdin)\n\n\tvar n int64\n\tfmt.Fscanf(buf, \"%d\\n\", &n)\n\n\tmat := make([]int64, 20)\n\tlen := 0\n\tfor n > 0 {\n\t\tmat[len] = n % int64(10)\n\t\tn /= 10\n\t\tlen++\n\t}\n\t//for i := len - 1; i >= 0; i-- {\n\t//\tif mat[i] == 0 {\n\t//\t\tfor j := i + 1; j < len; j++ {\n\t//\t\t\tmat[j]--\n\t//\t\t\tif mat[j] > 0 || (mat[j] == 0 && j == len-1) {\n\t//\t\t\t\tfor k := j - 1; k >= 0; k-- {\n\t//\t\t\t\t\tmat[k] = 9\n\t//\t\t\t\t}\n\t//\t\t\t\tbreak\n\t//\t\t\t}\n\t//\t\t}\n\t//\t\tbreak\n\t//\t}\n\t//}\n\t//for i := len; i >= 0; i-- {\n\t//\tif mat[i] > 0 {\n\t//\t\tlen = i + 1\n\t//\t\tbreak\n\t//\t}\n\t//}\n\tvar le int64 = 1\n\tvar ans int64 = 1\n\tvar tmp int64 = 1\n\tfor i := 0; i < len; i++ {\n\t\tans *= mat[i]\n\t\tle *= 9\n\t}\n\t//fmt.Printf(\"-%d len=%d %v\\n\",ans,len,mat)\n\n\tfor i := len - 1; i >= 0; i-- {\n\t\tle /= 9\n\t\tif mat[i] > 1 {\n\t\t\tif tmp*(mat[i]-1)*le > ans {\n\t\t\t\tans = tmp * (mat[i] - 1) * le\n\t\t\t}\n\t\t} else if i == len-1 {\n\t\t\tif le > ans {\n\t\t\t\tans = le\n\t\t\t}\n\t\t}else {\n\t\t\tbreak\n\t\t}\n\t\ttmp *= mat[i]\n\t}\n\tfmt.Printf(\"%d\\n\", ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "number theory"], "code_uid": "0f326557e744c84de884fe2c1c886abc", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.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\t\"sort\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tA := sc.NextIntArray()\n\tsort.Ints(A)\n\tc := A[1]\n\tans := abs(A[0] - c) + abs(A[2] - c)\n\tfmt.Println(ans)\n}\nfunc min(a int, 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}\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": ["math", "sortings", "implementation"], "code_uid": "a3c5c2146a3cd25be563bb0b5d07704c", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "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\"strconv\"\n\t\"errors\"\n)\n\nfunc main() {\n\tb := make([][]rune, 3)\n\tfor i := 0; i < 3; i++ {\n\t\tb[i] = []rune(nextWord())\n\t}\n\txc, oc, xw, ow := 0, 0, 0, 0\n\tfor i := 0; i < 3; i++ {\n\t\tif b[i][0] == b[i][1] && b[i][1] == b[i][2] {\n\t\t\tif b[i][0] == 'X' {\n\t\t\t\txw++\n\t\t\t} else if b[i][0] == '0' {\n\t\t\t\tow++\n\t\t\t}\n\t\t}\n\t\tif b[0][i] == b[1][i] && b[1][i] == b[2][i] {\n\t\t\tif b[0][i] == 'X' {\n\t\t\t\txw++\n\t\t\t} else if b[0][i] == '0' {\n\t\t\t\tow++\n\t\t\t}\n\t\t}\n\t}\n\tif b[0][0] == b[1][1] && b[1][1] == b[2][2] {\n\t\tif b[0][0] == 'X' {\n\t\t\txw++\n\t\t} else if b[0][0] == '0' {\n\t\t\tow++\n\t\t}\n\t}\n\tif b[0][2] == b[1][1] && b[1][1] == b[2][0] {\n\t\tif b[0][2] == 'X' {\n\t\t\txw++\n\t\t} else if b[0][2] == '0' {\n\t\t\tow++\n\t\t}\n\t}\n\tfor y := 0; y < 3; y++ {\n\t\tfor x := 0; x < 3; x++ {\n\t\t\tif b[y][x] == 'X' {\n\t\t\t\txc++\n\t\t\t} else if b[y][x] == '0' {\n\t\t\t\toc++\n\t\t\t}\n\t\t}\n\t}\n\tif xc != oc && xc != oc + 1 {\n\t\tprintf(\"illegal\\n\")\n\t} else if xw > 0 && ow > 0 {\n\t\tprintf(\"illegal\\n\")\n\t} else if xw > 0 {\n\t\tif xc == oc {\n\t\t\tprintf(\"illegal\\n\")\n\t\t} else {\n\t\t\tprintf(\"the first player won\\n\")\n\t\t}\n\t} else if ow > 0 {\n\t\tif xc == oc + 1 {\n\t\t\tprintf(\"illegal\\n\")\n\t\t} else {\n\t\t\tprintf(\"the second player won\\n\")\n\t\t}\n\t} else if xc + oc == 9 {\n\t\tprintf(\"draw\\n\")\n\t} else if oc == xc {\n\t\tprintf(\"first\\n\")\n\t} else {\n\t\tprintf(\"second\\n\")\n\t}\n}\n\nvar lineScanner *bufio.Scanner\nvar wordScanner *bufio.Scanner\n\nfunc init() {\n\tlineScanner = bufio.NewScanner(os.Stdin)\n\twordScanner = bufio.NewScanner(strings.NewReader(\"\"))\n\twordScanner.Split(bufio.ScanWords)\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 = 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": ["brute force", "implementation", "games"], "code_uid": "0187cb4ad6e9de9ebfe1cab53c56c361", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// https://codeforces.com/problemset/problem/731/A\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc diff(x int, y int) int {\n\tz := x - y\n\tif z >= 0 {\n\t\treturn z\n\t}\n\n\treturn z * (-1)\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\n\tvar m, mRev map[rune]int\n\tm = make(map[rune]int)\n\tmRev = make(map[rune]int)\n\tchar := 'a'\n\tfor i := 1; i <= 26; i++ {\n\t\tm[rune(char)] = i\n\t\tchar++\n\t}\n\tcharRev := 'z'\n\tfor i := 26; i >= 1; i-- {\n\t\tmRev[rune(charRev)] = i\n\t\tcharRev--\n\t}\n\n\tvar s string\n\tvar ans int\n\tfmt.Fscanf(in, \"%s\\n\", &s)\n\tfor i := 0; i < len(s); i++ {\n\t\tvar a, b int\n\t\tif i == 0 {\n\t\t\ta = diff(m[rune(s[i])], m['a'])\n\t\t\tb = diff(a, 26)\n\t\t} else {\n\t\t\ta = diff(m[rune(s[i])], m[rune(s[i-1])])\n\t\t\tb = diff(a, 26)\n\t\t}\n\t\tif a < b {\n\t\t\tans += a\n\t\t} else {\n\t\t\tans += b\n\t\t}\n\t}\n\n\tfmt.Fprintln(out, ans)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "afd765be3cdcc8d7a0d49979825eb39b", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int64\n\tfmt.Scanf(\"%d\",&n)\n\t\n\tif n<=1 {\n\t fmt.Println(\"Ehab\")\n\t \n\t return\n\t}\n\t\n\tif n%2==0 {\n\t fmt.Println(\"Mahmoud\")\n\t \n\t return \n\t}\n\t\n\tfmt.Println(\"Ehab\")\n\t\n}", "lang_cluster": "Go", "tags": ["math", "games"], "code_uid": "e58f146a7fe00abbc011eb9872a33afb", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "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} else {\n\t\treturn b\n\t}\n}\n\nfunc main() {\n\tvar y, b, r int\n\tfmt.Scan(&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": "3d9e67f986bf70f29ce29e837cd82fc7", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc round(n float64) int64 {\n\tif n-float64(int(n)) >= 0.000000000001 {\n\t\treturn int64(n) + 1\n\t} else {\n\t\treturn int64(n)\n\t}\n}\nfunc main() {\n\tvar n, m, a int\n\tfmt.Scanf(\"%d %d %d\", &n, &m, &a)\n //m =1000000000 ;n=1000000000 ;a=192;\n\tfmt.Println(round(float64(n)/float64(a)) * round(float64(m)/float64(a)))\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "be1a3078a5dc526d3a7cfdc92ea0fa8a", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport(\n\t\"fmt\"\n\t// \"sort\"\n\t// \"math\"\n\t// \"strconv\"\n\t// \"strings\"\n\t\"os\"\n\t\"bufio\"\n)\n\nfunc min(a,b int) int{\n\tif ab{\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc toInt(buf []byte) (o int) {\n\tfor _, v := range buf {\n\t\to = o*10 + int(v-'0')\n\t}\n\treturn\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\n\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\t//in, _ := os.Open(\"a.txt\")\n\tvar n int64\n\tvar allNines = true\n\tfmt.Fscanf(in, \"%d\", &n)\n\tif n < 5 {\n\t\tfmt.Println(n * (n - 1) / 2)\n\t\tos.Exit(0)\n\t}\n\tsum := n + n - 1\n\tcnt := 0\n\tfor ; sum > 0; sum /= 10 {\n\t\tx := sum % 10\n\t\tif x != 9 {\n\t\t\tallNines = false\n\t\t}\n\t\tcnt++\n\t}\n\tif allNines {\n\t\tfmt.Println(1)\n\t\tos.Exit(0)\n\t}\n\tnumOfNines := cnt - 1\n\tvar deg int64 = 1\n\tfor i := 1;i <= numOfNines; i++ {\n\t\tdeg = deg * 10\n\t}\n\tmd := n % deg\n\tright := md\n\tmid := deg / 2 - 1\n\tless := n / deg\n\tmore := less + 1\n\tif right == 0 {\n\t\tfmt.Println(less * less * (mid + 1))\n\t\tos.Exit(0)\n\t}\n\tvar ans int64\n\tif right != deg - 1 {\n\t\tans = less * less\n\t} else {\n\t\tans = less * more\n\t}\n\tif right <= mid {\n\t\tans += right * more * less\n\t\tans += (mid - right) * less * less\n\t} else {\n\t\textra := right - mid\n\t\tif right == deg - 1 {\n\t\t\textra--\n\t\t}\n\t\tans += extra * more * more\n\t\tans += (mid - extra) * more * less\n\t}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "14df1ef800a9034de394dcd62d4725a8", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k, l, m, n, d int\n\tfmt.Scan(&k, &l, &m, &n, &d)\n\n\tvar suffocated int\n\tfor i := 1; i <= d; i++ {\n\t\tif i%k == 0 || i%l == 0 || i%m == 0 || i%n == 0 {\n\t\t\tsuffocated++\n\t\t}\n\t}\n\tfmt.Print(suffocated)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "c8d05b94106a74689511367c76e980ec", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "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\tinput := bufio.NewReader(os.Stdin)\n\tvar (\n\t\tn int\n\t\tl int\n\t\tr int\n\t\tiMax int\n\t\tiMin int\n\t)\n\t_, _ = fmt.Fscan(input, &n, &l, &r)\n\n\tvar c uint\n\n\tc = 0\n\tfor i := 0; i < l; i += 1 {\n\t\tiMin += 1 << c\n\t\tc += 1\n\t}\n\tiMin += n - l\n\n\tif n < r {\n\t\tr = n\n\t}\n\tc = 0\n\tfor i := 0; i < r; i += 1 {\n\t\tiMax += 1 << c\n\t\tc += 1\n\t}\n\tiMax += (n - r) * (1 << (c - 1))\n\tfmt.Printf(\"%d %d\\n\", iMin, iMax)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "626cc5ef283679f09f76535a4140ac26", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var n int\n fmt.Scanf(\"%d\",&n)\n \n if n%4==0 || n%4==3 {\n fmt.Println(\"0\")\n } else {\n fmt.Println(\"1\")\n }\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "ca8f1c302fc2d88934f317be69e77e64", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar name string\n\tchars := make(map[rune]bool)\n\tfmt.Scan(&name)\n\tfor _, c := range name {\n\t\tchars[c] = true\n\t}\n\tif len(chars)%2 == 0 {\n\t\tfmt.Println(\"CHAT WITH HER!\")\n\t} else {\n\t\tfmt.Println(\"IGNORE HIM!\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "e924f920823a3696c02f98e49fa17a72", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\n\nfunc main(){\n\tvar s string\n\tr := bufio.NewScanner(os.Stdin)\n\tw := bufio.NewWriter(os.Stdout)\n\tvar a [4]int\n\tvar x, y int\n\tvar min int = 1000\n\tvar max int\n\tvar maxl, minl int\n\tfor i:=0; i<4; i++ {\n\t\tr.Scan()\n\t\ts = r.Text()\n\t\ta[i] = len(s)\n\t\ta[i] -= 2\n\t\tif a[i] > max {\n\t\t\tmax = a[i]\n\t\t\tmaxl = i\n\t\t}\n\t\tif a[i] < min {\n\t\t\tmin = a[i]\n\t\t\tminl = i\n\t\t}\n\t}\n\tmin *= 2\n\tmax /= 2\n\tfor j:=0; j<4; j++ {\n\t\tif j != minl && min > a[j] {\n\t\t\tx = 1\n\t\t\tbreak\n\t\t}\n\t}\n\tfor k:=0; k<4; k++ {\n\t\tif k != maxl && max < a[k] {\n\t\t\ty = 1\n\t\t\tbreak\n\t\t}\n\t}\n\tif (x == 1 && y == 1) || (x == 0 && y == 0) {\n\t\tw.WriteString(\"C\")\n\t} else if x == 0 && y == 1 {\n\t\tif minl == 0 {\n\t\t\tw.WriteString(\"A\")\n\t\t} else if minl == 1 {\n\t\t\tw.WriteString(\"B\")\n\t\t} else if minl == 2 {\n\t\t\tw.WriteString(\"C\")\n\t\t} else if minl == 3 {\n\t\t\tw.WriteString(\"D\")\n\t\t}\n\t} else {\n\t\tif maxl == 0 {\n\t\t\tw.WriteString(\"A\")\n\t\t} else if maxl == 1 {\n\t\t\tw.WriteString(\"B\")\n\t\t} else if maxl == 2 {\n\t\t\tw.WriteString(\"C\")\n\t\t} else if maxl == 3 {\n\t\t\tw.WriteString(\"D\")\n\t\t}\n\t}\n\tw.WriteString(\"\\n\")\n\tw.Flush()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "eee50040c95d7efde999938ef5802059", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(a, b int) int {\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\n\t// Special case for zero\n\tif a == 0 || b == 0 {\n\t\treturn a + b\n\t}\n\n\t// Calculate GCD using Euclidean algorithm\n\tresult := 1\n\n\tfor {\n\t\tremain := b % a\n\n\t\tif remain == 0 {\n\t\t\tresult *= a\n\t\t\tbreak\n\t\t} else {\n\t\t\tb = a\n\t\t\ta = remain\n\t\t}\n\t}\n\treturn result\n}\n\nfunc main() {\n\tvar simon, antisimon, stones int\n\n\tfmt.Scanf(\"%d %d %d\", &simon, &antisimon, &stones)\n\n\tfor {\n\t\t// Simon plays\n\t\tvar simonQuota = gcd(simon, stones)\n\n\t\tif simonQuota <= stones {\n\t\t\tstones -= simonQuota\n\t\t} else {\n\t\t\tfmt.Println(1)\n\t\t\treturn\n\t\t}\n\n\t\t// Antisimon plays\n\t\tvar antiQuota = gcd(antisimon, stones)\n\n\t\tif antiQuota <= stones {\n\t\t\tstones -= antiQuota\n\t\t} else {\n\t\t\tfmt.Println(0)\n\t\t\treturn\n\t\t}\n\n\t\t// fmt.Println(simon, antisimon, stones, simonQuota, antiQuota)\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "26612b5f110131282e66b32ee62fa375", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc abs(x int32) int32 {\n\tif x<0 {\n\t\treturn -x\n\t}else{\n\t\treturn x\n\t}\n}\n\nfunc main() {\n\tvar total int32 = 0\n\tvar a []int32\n\tvar n int32\n\tfmt.Scanln(&n)\n\ta = make([]int32,n,n)\n\tfor i:=0;i 1e18 {\n\t\t\tcnt[i] = 1e18\n\t\t}\n\t}\n\tsc := NewScanner()\n\tq := sc.NextInt()\n\tfor i := 0; i < q; i++ {\n\t\ta, b := sc.NextInt64(), sc.NextInt64()\n\t\tfmt.Print(string(recv(a, b-1)))\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}\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", "binary search", "combinatorics"], "code_uid": "2c88123ed28ff389f8dcb7866ace79ea", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, s int\n\tfmt.Scan(&n, &s)\n\tfmt.Println((s + n - 1) / n)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "3ff1c6f67ab38cf8b2f05f30227b3bc5", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int\n\tb := [5]int{100, 20, 10, 5, 1}\n\tfmt.Scan(&n)\n\tfor i := 0; i < 5; i++ {\n\t\tif n >= b[i] {\n\t\t\tk += n / b[i]\n\t\t\tn = n % b[i]\n\t\t}\n\t}\n\tfmt.Print(k)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp"], "code_uid": "85626ae888b6ef75f5f81cbb18d9a065", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "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 min_int(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc min_int64(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc max_int(a int, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\nfunc max_int64(a int64, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc binary_search(a *[]int64, pos int64) (bool, int64, int64) {\n\tvar left int64 = 0\n\tvar right int64 = int64(len(*a))\n\tvar n_low int64 = 0\n\tvar n_high int64 = 0\n\tfor left < right {\n\t\tvar middle int64 = (left + right) / 2\n\t\tif (*a)[middle] <= pos {\n\t\t\tleft = middle + 1\n\n\t\t\tif pos != middle {\n\t\t\t\tn_low++\n\t\t\t}\n\t\t} else {\n\t\t\tright = middle\n\t\t\tn_high++\n\t\t}\n\t}\n\n\tif left > 0 && (*a)[left-1] == pos {\n\t\treturn true, n_low, n_high\n\t} else {\n\t\treturn false, n_low, n_high\n\t}\n}\n\nfunc extended_gcd(a int64, b int64) {\n\tvar o_r int64 = a\n\tvar r int64 = b\n\tvar o_s int64 = 1\n\tvar s int64 = 0\n\tvar o_t int64 = 0\n\tvar t int64 = 1\n\n\tfor r != 0 {\n\t\tvar q int64 = o_r / r\n\t\to_r, r = r, o_r-q*r\n\t\to_s, s = s, o_s-q*s\n\t\to_t, t = t, o_t-q*t\n\t}\n\n\tprintf(\"Bezout coefs: %d %d\\n\", o_s, o_t)\n\tprintf(\"GCD: %d\\n\", o_r)\n}\n\nfunc modular_inverse(a int64, m int64) int64 {\n\n\tvar m_init int64 = m\n\tvar y int64 = 0\n\tvar x int64 = 1\n\n\tif m == 1 {\n\t\treturn 0\n\t}\n\n\tfor a > 1 {\n\t\tvar q int64 = a / m\n\t\tvar t int64 = m\n\n\t\tm = a % m\n\t\ta = t\n\t\tt = y\n\n\t\ty = x - q*y\n\t\tx = t\n\t}\n\n\tif x < 0 {\n\t\tx += m_init\n\t}\n\n\treturn x\n}\n\nfunc combination(n int64, k int64, factorial *[]int64, mod_inv *[]int64, mod_by int64) int64 {\n\n\tif k > n {\n\t\treturn 0\n\t} else {\n\t\tvar r int64 = ((*mod_inv)[n-k] * (*mod_inv)[k]) % mod_by\n\t\tr = (r * (*factorial)[n]) % mod_by\n\t\treturn r\n\t}\n\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tvar n, x, pos int64\n\tscanf(\"%d %d %d\\n\", &n, &x, &pos)\n\n\tvar n_smaller_numbers int64 = x - 1\n\tvar n_bigger_numbers int64 = n - x\n\n\tvar mod_by int64 = 1000000000 + 7\n\n\tfactorial := make([]int64, n+1)\n\tmod_inv := make([]int64, n+1)\n\n\tfactorial[0] = 1\n\tmod_inv[0] = 1\n\n\tfor i := int64(1); i <= n; i++ {\n\t\t// Formaly it should be ( (factorial[i-1] % mod_by) * (i % mod_by) ) % mod_by\n\t\t// but since n does not exceed 1000 in the problem constraints then the below suffices.\n\t\tfactorial[i] = (factorial[i-1] * i) % mod_by\n\t\tmod_inv[i] = modular_inverse(factorial[i], mod_by) % mod_by\n\t}\n\n\t// for i := range factorial {\n\t// \tprintf(\"%d \", factorial[i])\n\t// }\n\t// printf(\"\\n\")\n\n\t// for i := range mod_inv {\n\t// \tprintf(\"%d \", mod_inv[i])\n\t// }\n\t// printf(\"\\n\")\n\n\tnumbers := make([]int64, n)\n\tfor i := int64(0); i < int64(len(numbers)); i++ {\n\t\tnumbers[i] = i\n\t}\n\n\tvar n_less, n_greater int64\n\t_, n_less, n_greater = binary_search(&numbers, pos)\n\n\t// printf(\"n_less: %d n_greater: %d\\n\", n_less, n_greater)\n\n\tvar c1 int64 = (combination(n_smaller_numbers, n_less, &factorial, &mod_inv, mod_by) * factorial[n_less]) % mod_by\n\tvar c2 int64 = (combination(n_bigger_numbers, n_greater, &factorial, &mod_inv, mod_by) * factorial[n_greater]) % mod_by\n\n\t// printf(\"c1: %d c2: %d\\n\", c1, c2)\n\n\tvar res int64 = (c1 * c2) % mod_by\n\tres = (res * factorial[n-n_less-n_greater-1]) % mod_by\n\n\tprintf(\"%d\\n\", res)\n\n\t// extended_gcd(240, 46)\n\t// printf(\"modular inverse: %d\\n\", modular_inverse(42, mod_by))\n\n}\n", "lang_cluster": "Go", "tags": ["binary search", "combinatorics"], "code_uid": "fb60a77a77014f35d2bdc6fa1d6fd248", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar x int\n\nfunc main() {\n\tfmt.Scanf(\"%d\", &x)\n\tfmt.Println(x/2 + 1)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "17da2f4ee5c6bef0a4b97341380d5921", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "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 float64\n\tfmt.Scanf(\"%f\", &n)\n\tfmt.Println(int64(math.Pow(2, n+1)) - 2)\n}", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "e48e9ce12e92f2569deb0e0672a1917e", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nvar n int\n\nfunc main() {\n fmt.Scan(&n)\n sqt := math.Sqrt(float64(n))\n hight := int(sqt)\n width := 0\n if hight*hight == n {\n width = hight\n } else {\n width = hight + 1\n if hight*width < n {\n hight += 1\n }\n }\n fmt.Println(hight*2 + width*2)\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "51ef34c5b6ac9bf4a30b12122a5be0e5", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\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\nfunc reverse(s string) (result string) {\n\tfor _, v := range s {\n\t\tresult = string(v) + result\n\t}\n\treturn\n}\n\nfunc getMin(m, s int) string {\n\tfirst := max(1, s-9*(m-1))\n\tnext := getMax(m-1, s-first)\n\treturn strconv.Itoa(first) + reverse(next)\n}\n\nfunc getMax(m, s int) string {\n\tr := \"\"\n\tfor i := 0; i < m; i++ {\n\t\tnext := min(9, s)\n\t\ts -= next\n\t\tr += strconv.Itoa(next)\n\t}\n\treturn r\n}\n\nfunc main() {\n\tvar m, s int\n\tfmt.Scanf(\"%d %d \\n\", &m, &s)\n\n\tif m == 1 && s <= 9 {\n\t\tfmt.Print(s, s)\n\t\treturn\n\t}\n\n\tif s == 0 || s > m*9 {\n\t\tfmt.Print(-1, -1)\n\t\treturn\n\t}\n\n\tfmt.Print(getMin(m, s) + \" \" + getMax(m, s))\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp", "implementation"], "code_uid": "efba020fa44f682ce55a7a5334b49928", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0, "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.Scan(&a, &b, &c)\n\tvar x, y, z int\n\tfmt.Scan(&x, &y, &z)\n\tvar addA = a - x\n\tvar addB = b - y\n\tvar addC = c - z\n\tvar add int\n\tvar minus int\n\tif addA > 0 {\n\t\tadd += addA / 2\n\t} else {\n\t\tminus += addA\n\t}\n\tif addB > 0 {\n\t\tadd += addB / 2\n\t} else {\n\t\tminus += addB\n\t}\n\tif addC > 0 {\n\t\tadd += addC / 2\n\t} else {\n\t\tminus += addC\n\t}\n\tif add+minus >= 0 {\n\t\tfmt.Print(\"Yes\")\n\t} else {\n\t\tfmt.Print(\"No\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f28ae51d746496e8969572bb091a30de", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n\nfunc main() {\n\tvar total int\n\tvar current int\n\tvar left, right, max, min int\n\tvar totalMoves int\n\tfmt.Scanln(&total, ¤t)\n\tleft = current - 1\n\tright = total - current\n\tmin, max = minMax(left, right)\n\ttotalMoves = min * 2 + max + total *2 + 1\n\tfmt.Println(totalMoves)\n}\n\nfunc minMax(a int, b int) (int, int){\n\tif a 0 {\n\t\tfmt.Print(\"1\")\n\t} else {\n\t\tfmt.Print(\"-1\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "7bed602b764f9cda7758eb9c9fb3a6fe", "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\ts:=\"\"\n\tfmt.Scanln(&s)\n\tc:=[]byte(s)\n\ta:=len(c)\n\te:=0\n\tfor i:=0;i0 {\n\t\tfor i:=0;i95 {\n\t\t\t\tc[i]-=32\n\t\t\t}\n\t\t}\n\t}else {\n\t\tfor i:=0;i= 1 && delta%s == 1)\n\treturn true\n}\n\nfunc main() {\n\tvar t, s, x int\n\tfmt.Scan(&t, &s, &x)\n\tif solve(t, s, x) {\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": "ba4af15c5e2d1018d2732bd348921347", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"strings\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s, t string\n\tfmt.Scan(&s)\n\tfmt.Scan(&t)\n\n\tsSpl := strings.Split(s, \"\")\n\ttSpl := strings.Split(t, \"\")\n\n\tif len(sSpl) != len(tSpl) {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tfin := len(tSpl) - 1\n\tfor i := range sSpl {\n\t\tif sSpl[i] != tSpl[fin - i] {\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": ["strings", "implementation"], "code_uid": "10e60dfc1211e73d74d275b7bbf2f669", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.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\n\tgrid := make([][]bool, n)\n\tfor i := 0; i < n; i++ {\n\t\tgrid[i] = make([]bool, m)\n\t}\n\n\tvar ret bool = false\n\n\tfor {\n\t\tvar found bool = false\n\n\t\tfor i := 0; i < n && !found; i++ {\n\t\t\tfor j := 0; j < m && !found; j++ {\n\t\t\t\tif !grid[i][j] {\n\t\t\t\t\tfor k := 0; k < n; k++ {\n\t\t\t\t\t\tgrid[k][j] = true\n\t\t\t\t\t}\n\t\t\t\t\tfor k := 0; k < m; k++ {\n\t\t\t\t\t\tgrid[i][k] = true\n\t\t\t\t\t}\n\t\t\t\t\tfound = true\n\t\t\t\t\tbreak\n\t\t\t\t} \n\t\t\t}\n\t\t}\n\n\t\tif !found {\n\t\t\tbreak\n\t\t}\n\n\t\tret = !ret\n\t}\n\n\tif !ret {\n\t\tfmt.Println(\"Malvika\")\n\t} else {\n\t\tfmt.Println(\"Akshat\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "1df3470b0c4f9a90b523211fbe4972d7", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "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\t\"strconv\"\n)\n\nvar res []int\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tk, _ := strconv.Atoi(scanner.Text())\n\n\tsolve(n, k)\n\tif len(res) == 0 || len(res) != k {\n\t\tfmt.Println(-1)\n\t\tos.Exit(0)\n\t}\n\tcheck := 1\n\tfor _, el := range res {\n\t\tcheck *= el\n\t}\n\tif check != n {\n\t\tfmt.Println(-1)\n\t\tos.Exit(0)\n\t}\n\tfor i, el := range res {\n\t\tif i == len(res)-1 {\n\t\t\tfmt.Printf(\"%d\\n\", el)\n\t\t\tcontinue\n\t\t}\n\t\tfmt.Printf(\"%d \", el)\n\t}\n}\n\nfunc solve(n, k int) {\n\tif n == 1 {\n\t\treturn\n\t}\n\tif k == 1 {\n\t\tres = append(res, n)\n\t\treturn\n\t}\n\tfor i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {\n\t\tif n%i == 0 {\n\t\t\tres = append(res, i)\n\t\t\tsolve(n/i, k-1)\n\t\t\treturn\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "37427a1863ff3849ffdb1f1175a97439", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "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 int\n\tfor I(&n, \" \") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int) {\n\tvar k, l, c, d, p, nl, np int\n\tI(&k, \" \")\n\tI(&l, \" \")\n\tI(&c, \" \")\n\tI(&d, \" \")\n\tI(&p, \" \")\n\tI(&nl, \" \")\n\tI(&np, \"\\n\")\n\tans := int(((l * k) / nl) / n)\n\tcd := c * d\n\tnpp := int(p / np)\n\tfor n*ans > cd || n*ans > npp {\n\t\tans--\n\t}\n\tO(ans, \"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "8a9b2598db0aa38fd1558650e2e42f6b", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n\t\"unicode/utf8\"\n\t\"unicode\"\n)\n\nfunc main() {\n\tvar kata1,kata2 string\n\tfmt.Scanf(\"%s\\n\", &kata1)\n\tfmt.Scanf(\"%s\\n\", &kata2)\n\tlen := utf8.RuneCountInString(kata1)\n\ta := []rune(kata1)\n\tb := []rune(kata2)\n\tfor i:=0; i kata2 {\n\t\tfmt.Println(\"1\")\n\t}\n\tif kata1 == kata2 {\n\t\tfmt.Println(\"0\")\n\t}\n\tif kata1 < kata2 {\n\t\tfmt.Println(\"-1\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "a1506691953ce3cb048597ef85f1793f", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, c, s int\n\tfmt.Scanln(&a, &b, &c)\n\tb = -b\n\ts = a + b\n\tif s > 0 {\n\t\tif s > c {\n\t\t\tfmt.Println(\"+\")\n\t\t} else {\n\t\t\tfmt.Println(\"?\")\n\t\t}\n\t} else if s == 0 {\n\t\tif c == 0 {\n\t\t\tfmt.Println(\"0\")\n\t\t} else {\n\t\t\tfmt.Println(\"?\")\n\t\t}\n\t} else {\n\t\tif s+c < 0 {\n\t\t\tfmt.Println(\"-\")\n\t\t} else {\n\t\t\tfmt.Println(\"?\")\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "32b8978f80d8bce01e35e162b339ba0b", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "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 CF1292B(_r io.Reader, _w io.Writer) {\n\ttype point struct{ x, y int64 }\n\tabs := func(x int64) int64 {\n\t\tif x < 0 {\n\t\t\treturn -x\n\t\t}\n\t\treturn x\n\t}\n\tdis := func(a, b point) int64 { return abs(a.x-b.x) + abs(a.y-b.y) }\n\n\tvar ax, ay, bx, by, tt int64\n\tvar p, st point\n\tFscan(_r, &p.x, &p.y, &ax, &ay, &bx, &by, &st.x, &st.y, &tt)\n\tps := []point{}\n\tfor ; p.x < 9e16 && p.y < 9e16; p.x, p.y = ax*p.x+bx, ay*p.y+by {\n\t\tps = append(ps, p)\n\t}\n\n\tans := 0\n\tfor i, p := range ps {\n\t\tt := tt\n\t\tif d := dis(st, p); d <= t {\n\t\t\tt -= d\n\t\t\tc := 1\n\t\t\tfor j := i; j > 0; j-- {\n\t\t\t\tif d := dis(ps[j], ps[j-1]); d <= t {\n\t\t\t\t\tt -= d\n\t\t\t\t\tc++\n\t\t\t\t} else {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif i+1 < len(ps) {\n\t\t\t\tif d := dis(ps[0], ps[i+1]); d <= t {\n\t\t\t\t\tt -= d\n\t\t\t\t\tc++\n\t\t\t\t\tfor j := i + 2; j < len(ps); j++ {\n\t\t\t\t\t\tif d := dis(ps[j], ps[j-1]); d <= t {\n\t\t\t\t\t\t\tt -= d\n\t\t\t\t\t\t\tc++\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak\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\tif c > ans {\n\t\t\t\tans = c\n\t\t\t}\n\t\t}\n\t}\n\tFprint(_w, ans)\n}\n\nfunc main() { CF1292B(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms", "implementation", "greedy", "geometry"], "code_uid": "b93cd0f4f26236be5e5680684e55725f", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.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\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == 'H' || s[i] == '9' || s[i] == 'Q' {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "096301cc5d3ca95e8b3f653e66df7592", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b string\n\tfmt.Scan(&a)\n\tfor i := 0; i < 5; i++ {\n\t\tfmt.Scan(&b)\n\t\tif a[0] == b[0] || a[1] == b[1] {\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": "bdc570084f58aa561234a6bfd1ce1fdd", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1191/problem/B\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Tile struct {\n\tSuit string\n\tNumber int\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 createTileCountMap(tiles []Tile) map[Tile]int {\n\ttileCountMap := make(map[Tile]int)\n\tfor _, tile := range tiles {\n\t\ttileCountMap[tile] += 1\n\t}\n\treturn tileCountMap\n}\n\nfunc minKoutsu(tiles []Tile) int {\n\ttileCountMap := createTileCountMap(tiles)\n\tminTiles := 3\n\tfor _, tileCount := range tileCountMap {\n\t\tminTiles = min(minTiles, 3-tileCount)\n\t}\n\treturn minTiles\n}\n\nfunc minShuntsu(tiles []Tile) int {\n\ttileCountMap := createTileCountMap(tiles)\n\tminTiles := 3\n\tfor _, suit := range \"mps\" {\n\t\tfor i := 1; i <= 7; i++ {\n\t\t\tneededNumbers := []int{i, i + 1, i + 2}\n\t\t\tcount := 0\n\t\t\tfor _, n := range neededNumbers {\n\t\t\t\tif tileCountMap[Tile{Number: n, Suit: string(suit)}] > 0 {\n\t\t\t\t\tcount += 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tminTiles = min(minTiles, 3-count)\n\t\t}\n\t}\n\treturn minTiles\n}\n\nfunc Solve(tiles []Tile) int {\n\treturn min(minKoutsu(tiles), minShuntsu(tiles))\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\ttiles := make([]Tile, 3)\n\tfor i := 0; i < 3; i++ {\n\t\tfmt.Fscanf(reader, \"%d%s \", &tiles[i].Number, &tiles[i].Suit)\n\t}\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(tiles))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "34173f2301a77886a3cf435b6d92cb5a", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\tn int\n\tm int\n\tresult int\n)\n\nfunc in() {\n\tfmt.Scanf(\"%d %d\\n\", &n, &m)\n}\n\nfunc out() {\n\tfmt.Println(result)\n}\n\nfunc run() {\n\tvar remain int = n\n\tvar d int = 1\n\tfor ; remain > 0; d++ {\n\t\tif d%m != 0 {\n\t\t\tremain--\n\t\t}\n\t}\n\tresult = d - 1\n}\n\nfunc main() {\n\tin()\n\trun()\n\tout()\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "16c9d4b2b39bca59cfaaf20f87bec487", "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, a, b int\n\t_, _ = fmt.Scanf(\"%d %d %d %d\\n\", &n, &m, &a, &b)\n\tticketPrice := float32(b) / float32(m)\n\tvar cost = 0\n\tif ticketPrice < float32(a) {\n\t\tcost += (n / m) * b\n\t\tn -= (n / m) * m\n\t\tif n * a < b {\n\t\t\tcost += n * a\n\t\t} else {\n\t\t\tcost += b\n\t\t}\n\t} else {\n\t\tcost += n * a\n\t}\n\tfmt.Printf(\"%d\\n\", cost)\n}\n\n/*\n%t: для вывода значений типа boolean (true или false)\n%b: для вывода целых чисел в двоичной системе\n%c: для вывода символов, представленных числовым кодом\n%d: для вывода целых чисел в десятичной системе\n%o: для вывода целых чисел в восьмеричной системе\n%q: для вывода символов в одинарных кавычках\n%x: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют нижний регистр a-f\n%X: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют верхний регистр A-F\n%U: для вывода символов в формате кодов Unicode, например, U+1234\n%e: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456e+78\n%E: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456E+78\n%f: для вывода чисел с плавающей точкой, например, 123.456\n%F: то же самое, что и %f\n%g: для длинных чисел с плаващей точкой используется %e, для других - %f\n%G: для длинных чисел с плаващей точкой используется %E, для других - %F\n%s: для вывода строки\n%p: для вывода значения указателя - адреса в шестнадцатеричном представлении\n*/\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "95ac3be80a87228fef98e0563d6847d6", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.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 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": "3ed030aca1e7d82aff05fc15cbfb5e88", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "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 str string\n\tfmt.Scanln(&str)\n\n\tchars := strings.Split(str, \"\")\n\tvar l int\n\tl = len(chars)\n\n\ttotal := 0;\n\tfor i := 0; i < l; i++ {\n\t\tfor j := i + 1; j < l; j++ {\n\t\t\tfor k := j + 1; k < l; k++ {\n\t\t\t\tif (chars[i] + chars[j] + chars[k]) == \"QAQ\" {\n\t\t\t\t\ttotal++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Print(total)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp"], "code_uid": "ebca310c467a38499eae339dce0ba5b3", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0, "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": "bf7aea708fbdc2db10116353c0b4758d", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, x, a, b int\n\tfmt.Scan(&n)\n\tfor x = n / 2; x > 0; x-- {\n\t\tfor a, b = n-x, x; b != 0; {\n\t\t\ta, b = b, a%b\n\t\t}\n\t\tif a == 1 {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(x, n-x)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "4ab2b221b0f0c08e9486e00171948b54", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "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// \"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\tw, h := ReadInt(), ReadInt()\n\n\tu1,d1 := ReadInt(), ReadInt()\n\tu2,d2 := ReadInt(), ReadInt()\n\n\tfor ; h > 0; h-- {\n\t\tw += h\n\t\tif d1 == h {\n\t\t\tw -= u1\n\t\t}\n\t\tif d2 == h {\n\t\t\tw -= u2\n\t\t}\n\t\tif w < 0 {\n\t\t\tw = 0\n\t\t}\n\t}\n\n writer.WriteString(strconv.Itoa(w))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4f2529bdf337399ec521755da587aaf1", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\n\tcount := 0\n\tfor i := 1; i <= n/2; i += 1 {\n\t\tif (n - i) % i ==0 {\n\t\t\tcount+=1\n\t\t}\n\t}\n\tfmt.Print(count)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "dc0b3bc27c160af9cc1827b56ce100ea", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\"fmt\";\"math\")\n\nfunc main(){\n\tvar n, x, ans int64\n\tscan(&n, &x)\n\tfor i := int64(1); i <= int64(math.Min(float64(n), float64(x))); i++{\n\t\tif x % i == 0 && x / i <= n{\n\t\t\tans++\n\t\t}\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": ["implementation", "number theory"], "code_uid": "85f6b7f636f09c3f737e06d01bdc587f", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 560 B Gerald is into Art, 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 a1,b1,a2,b2,a3,b3 int\nvar canPlace bool\n\n// readData read data for out problem.\nfunc readData() {\n\tin = bufio.NewReader(os.Stdin)\n\t// reading a.. b...\n\ta1,b1,_, _, _ = readFive()\n\ta2,b2,_, _, _ = readFive()\n\ta3,b3,_, _, _ = readFive()\n}\n\nfunc toHoriz(a,b int) (int,int) {\n\tif a>=b {\n\t\treturn a,b\n\t} else {\n\t\treturn b,a\n\t}\n}\n\n/** can we place a2 b2 in a1 b1 */\nfunc canPlace2(a1,b1,a2,b2 int) bool {\n\ta1,b1 = toHoriz(a1,b1)\n\ta2,b2 = toHoriz(a2,b2)\n\tcan := (a2<=a1) && (b2<=b1)\n\t//fmt.Printf(\"canPlace2(ab1 %d %d ab2 %d %d) returned %t\\n\", a1,b1,a2,b2,can)\n\treturn can\n}\n\nfunc solve() {\n\ta1,b1 = toHoriz(a1,b1)\n\ta2,b2 = toHoriz(a2,b2)\n\ta3,b3 = toHoriz(a3,b3)\n\tcanPlace = false\n\tif !canPlace2(a1, b1, a2, b2) {\n\t\treturn\n\t}\n\tif !canPlace2(a1, b1, a3, b3) {\n\t\treturn\n\t}\n\t// try normal position a2b2\n\tif canPlace2(a1, b1-b2, a3, b3) {\n\t\tcanPlace = true\n\t\treturn\n\t}\n\tif canPlace2(a1-a2, b1, a3, b3) {\n\t\tcanPlace = true\n\t\treturn\n\t}\n\t// try turned a2b2\n\tif b2>a1 {\n\t\treturn\n\t}\n\ta1,b1 = b1,a1\n\tif canPlace2(a1, b1-b2, a3, b3) {\n\t\tcanPlace = true\n\t\treturn\n\t}\n\tif canPlace2(a1-a2, b1, a3, b3) {\n\t\tcanPlace = true\n\t\treturn\n\t}\n}\n\n// printRes print problem solution in expected format.\nfunc printRes() {\n\tif canPlace {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc main() {\n\treadData()\n\tsolve()\n\tprintRes()\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "8c848529ffde7a2c8f512bfe451fdd9a", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nDouble Cola\ntime limit per test1 second\nmemory limit per test256 megabytes\ninputstandard input\noutputstandard output\nSheldon, Leonard, Penny, Rajesh and Howard are in the queue for a \"Double Cola\" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, drinks it and gets to the end of the queue as two Leonards, and so on. This process continues ad infinitum.\n\nFor example, Penny drinks the third can of cola and the queue will look like this: Rajesh, Howard, Sheldon, Sheldon, Leonard, Leonard, Penny, Penny.\n\nWrite a program that will print the name of a man who will drink the n-th can.\n\nNote that in the very beginning the queue looks like that: Sheldon, Leonard, Penny, Rajesh, Howard. The first person is Sheldon.\n\nInput\nThe input data consist of a single integer n (1 ≤ n ≤ 10^9).\n\nIt is guaranteed that the pretests check the spelling of all the five names, that is, that they contain all the five possible answers.\n\nOutput\nPrint the single line — the name of the person who drinks the n-th can of cola. The cans are numbered starting from 1. Please note that you should spell the names like this: \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\" (without the quotes). In that order precisely the friends are in the queue initially.\n\nSample test(s)\ninput\n1\noutput\nSheldon\ninput\n6\noutput\nSheldon\ninput\n1802\noutput\nPenny\n*/\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tnames := []string{\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"}\n\tvar n int64\n\tfmt.Scanf(\"%d\\n\", &n)\n\tif n < 6 {\n\t\tfmt.Println(names[n-1])\n\t\treturn\n\t}\n\tround := int64(math.Log2(float64((n-1)/5+1)))\n\tpreSum := int64(math.Pow(2, float64(round))) - 1\n\tleft := n - preSum*5-1\n\tthisRound := int64(math.Pow(2, float64(round)))\n\tfmt.Println(names[left/thisRound])\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "e37ef16e9d850de0c96fb2d43046c0a0", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar a, c 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\tc, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tvar b int64\n\ti := 0\n\tvar x [105]int64\n\tvar y [105]int64\n\tfor i=1; a+c>0; i++ {\n\t\tx[i] = a%3\n\t\ta /= 3\n\t\ty[i] = c%3\n\t\tc /= 3\n\t}\n\tfor i > 1 {\n\t\ti -= 1\n\t\tb = b*3 + ((y[i]-x[i]+3)%3)\n\t}\n\tw.WriteString(strconv.FormatInt(b, 10)+\"\\n\")\n\tw.Flush()\t\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9a63fbcea49644413429275b70c5359e", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// URL: http://codeforces.com/contest/4/problem/A\n// PROBLEM RESTATEMENT\n// x ∈ [1, 100]\n// a, b ∈ [0, 100]\n// Find a and b s.t 3a + 7b = x.\n// WORK\n// If x % 3 == 1, we can remove the remainder using a 7 (7 = 3 + 3 + 1).\n// By the same logic, if x % 3 == 2, we can remove the remainder using 2\n// 7s (14 = 7 + 7).\n//\tAPPROACH\n// (1) If x is divisible by 7 or 3, return yes.\n// (2) If x >= 10 and x % 3 == 1 and x / 7 >= 1, return yes.\n// (3) If x >= 10 and x % 3 == 2 and x / 7 >= 2, return yes.\n// (4) Otherwise, return no.\n// NOTE\n// When x >= 12, result is yes. Result is no for 1, 2, 4, 5, 8, 11.\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc solve(x int) string {\n\tif x%7 == 0 || x%3 == 0 {\n\t\treturn \"YES\"\n\t} else if x>=10 && x%3 == 1 && x/7 >= 1 {\n\t\treturn \"YES\"\n\t} else if x>=10 && x%3 == 2 && x/7 >= 2 {\n\t\treturn \"YES\"\n\t} else {\n\t\treturn \"NO\"\n\t}\n}\n\nfunc main() {\n\treader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar n, x int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(reader, \"%d\\n\", &x)\n\t\tfmt.Fprintf(writer, \"%s\\n\", solve(x))\n\t}\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "f4f4aec418166278ceedf14dea2260f5", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc Max(x, y int) int {\n result := x\n if y > x {\n result = y\n }\n\n return result\n}\n\nfunc main() {\n var n int\n fmt.Scanln(&n)\n\n a := make([]int, n)\n diff := make([][]int, n)\n count := make([]int, n + 1)\n\n count[0] = 0\n for i := 0; i < n; i++ {\n var next int\n fmt.Scanf(\"%d\", &next)\n a[i] = next\n diff[i] = make([]int, n)\n\n count[i + 1] = count[i] + next\n\n\n /* var val int = 1\n if next == 1 {\n val = -1\n }\n diff[i + 1] = diff[i] + val\n count[i + 1] = count[i] + next*/\n }\n\n diff[0][0] = (1 - a[0])\n var max int = diff[0][0]\n for i := 1; i < n; i++ {\n for j := 0; j < i; j++ {\n diff[j][i] = (i - j + 1) - (count[i + 1] - count[j])\n max = Max(max, diff[j][i] + count[j + 1] + count[n] - count[i + 1])\n }\n }\n\n fmt.Println(max)\n}", "lang_cluster": "Go", "tags": ["brute force", "dp", "implementation"], "code_uid": "a9ee75c0835f13246ebc33cea7946205", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 12A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c string\n\tfmt.Scanln(&a)\n\tfmt.Scanln(&b)\n\tfmt.Scanln(&c)\n\tif (a[0] == c[2]) && (a[1] == c[1]) && (a[2] == c[0]) && (b[0] == b[2]) {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "67d47843cf15f5b31b7607d28347564d", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar v int\n\tsum := 0\n\tfor i := 0; i < 5; i++ {\n\t\tfmt.Scan(&v)\n\t\tsum += v\n\t}\n\n\tif sum%5 != 0 || sum == 0 {\n\t\tfmt.Print(-1)\n\t} else {\n\t\tfmt.Print(sum / 5)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "3c4397248541ae2862563a6daa9d8a2a", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar nCandles, parts int\n\tfmt.Scanf(\"%d %d\\n\", &nCandles, &parts)\n\t\n\tnBurned := nCandles\n\tnHours := nCandles\n\t\n\tfor {\n\t\tnSolid := nBurned / parts\n\t\tnBurned = nBurned % parts\n\t\t\n\t\tif nSolid == 0 {\n\t\t\tbreak\n\t\t}\n\t\t\n\t\tnHours += nSolid\n\t\tnBurned += nSolid\n\t}\n\t\n\tfmt.Println(nHours)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "706351a338124b77c8bf4343a85b6812", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "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\nconst MAX = 1e6\n\nfunc solve() {\n\ta := readInt()\n\tb := readInt()\n\tf := readInt()\n\tk := readInt()\n\tgas := b\n\tres := 0\n\tfor i := 0; i < k; i++ {\n\t\tif i%2 == 0 {\n\t\t\tgas -= f\n\t\t\tif gas < 0 {\n\t\t\t\tfmt.Println(-1)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif i == k-1 {\n\t\t\t\tif gas < (a - f) {\n\t\t\t\t\tres++\n\t\t\t\t\tgas = b\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif gas < (a-f)*2 {\n\t\t\t\t\tres++\n\t\t\t\t\tgas = b\n\t\t\t\t}\n\t\t\t}\n\t\t\tgas -= (a - f)\n\t\t\tif gas < 0 {\n\t\t\t\tfmt.Println(-1)\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tgas -= a - f\n\t\t\tif gas < 0 {\n\t\t\t\tfmt.Println(-1)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif i == k-1 {\n\t\t\t\tif gas < f {\n\t\t\t\t\tres++\n\t\t\t\t\tgas = b\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif gas < f*2 {\n\t\t\t\t\tres++\n\t\t\t\t\tgas = b\n\t\t\t\t}\n\t\t\t}\n\t\t\tgas -= f\n\t\t\tif gas < 0 {\n\t\t\t\tfmt.Println(-1)\n\t\t\t\treturn\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\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": ["math", "greedy", "implementation"], "code_uid": "61524993afa139deff72cc96e559aa96", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/271/A\n// A. Beautiful Year\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// It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.\n\n// Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.\n// Input\n\n// The single line contains integer y (1000 ≤ y ≤ 9000) — the year number.\n// Output\n\n// Print a single integer — the minimum year number that is strictly larger than y and all it's digits are distinct. It is guaranteed that the answer exists.\n\nfunc main() {\n\tvar y int\n\tfmt.Scan(&y)\n\n\tfmt.Print(nextLuckyYear(y))\n}\n\nfunc nextLuckyYear(y int) int {\n\tfor candidateY := y + 1; ; candidateY++ {\n\t\tif isBeautifulYear(candidateY) {\n\t\t\treturn candidateY\n\t\t}\n\t}\n}\n\nfunc isBeautifulYear(y int) bool {\n\tvar seenDigit [10]bool\n\n\tfor ; y > 0; y /= 10 {\n\t\tdigit := y % 10\n\t\tif seenDigit[digit] {\n\t\t\treturn false\n\t\t}\n\t\tseenDigit[digit] = true\n\t}\n\treturn true\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "16ac4c45789c1f4cdfbd47b6e3c9afc1", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k, result int64\n\tfmt.Scanf(\"%d %d\", &n, &k)\n\tif k > n {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tif n %2 == 0 {\n\t\tif k <= n / 2 {\n\t\t\tresult = 2 * k - 1\n\t\t}else {\n\t\t\tresult = 2 * (k - n / 2 )\n\t\t}\n\t}else {\n\t\tif k <= (n / 2) + 1 {\n\t\t\tresult = 2 * k - 1\n\t\t}else {\n\t\t\tresult = 2 * (k - (n / 2) - 1)\n\t\t}\n\t}\n\n\tfmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "491e01fe578991fbbabcffa0ad673523", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc propusk(k string) string {\n\tf := strings.ReplaceAll(k, \"BG\", \"GB\")\n\treturn f\n}\n\nfunc main() {\n\tvar n, t int\n\tvar st string\n\tfmt.Scan(&n, &t)\n\tfmt.Scan(&st)\n\tfor i := 0; i < t; i++ {\n\t\tst = propusk(st)\n\t}\n\tfmt.Println(st)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "aa3b48a1724e8f4312aea32df105c5f9", "src_uid": "964ed316c6e6715120039b0219cc653a", "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 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 b, bb, m, X, Y int64\n\tI(&b, \"\\n\")\n\tx := int64(1)\n\tfor i := 0; i < n; i++ {\n\t\tx *= b\n\t}\n\tfor i := int64(0); i < int64(n); i++ {\n\t\tvar t int64\n\t\to := \" \"\n\t\tif i == int64(n-1) {\n\t\t\to = \"\\n\"\n\t\t}\n\t\tI(&t, o)\n\t\tx /= b\n\t\tX += x * t\n\t}\n\tI(&m, \" \")\n\tI(&bb, \"\\n\")\n\ty := int64(1)\n\tfor i := int64(0); i < m; i++ {\n\t\ty *= bb\n\t}\n\tfor i := int64(0); i < m; i++ {\n\t\tvar t int64\n\t\to := \" \"\n\t\tif i == m-1 {\n\t\t\to = \"\\n\"\n\t\t}\n\t\tI(&t, o)\n\t\ty /= bb\n\t\tY += y * t\n\t}\n\tif Y > X {\n\t\tO(\"<\", \"\\n\")\n\t} else if Y < X {\n\t\tO(\">\", \"\\n\")\n\t} else {\n\t\tO(\"=\", \"\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "82435a9768d15f4bb839887c2d51db55", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "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\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\tl1, _ := strconv.ParseInt(s[0], 10, 64)\n\tr1, _ := strconv.ParseInt(s[1], 10, 64)\n\tl2, _ := strconv.ParseInt(s[2], 10, 64)\n\tr2, _ := strconv.ParseInt(s[3], 10, 64)\n\tk, _ := strconv.ParseInt(s[4], 10, 64)\n\n\tst := l1\n\tif l2 > st {\n\t\tst = l2\n\t}\n\n\te := r1\n\tif r2 < e {\n\t\te = r2\n\t}\n\n\tt := e - st + 1\n\tif k >= st && k <= e {\n\t\tt -= 1\n\t}\n\tif t < 0 {\n\t\tt = 0\n\t}\n\tfmt.Println(t)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c2c6c32bdb574b8ba766b9c4b31b8818", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar x, x1 int\n\tvar ts string\n\tvar t string\n\tvar t1 string\n\tfmt.Scan(&ts)\n\tfmt.Scan(&t, &t1)\n\t\n\tif string(t[0])==\"T\" {\n\t\tx=11\n\t} else if string(t[0])==\"A\" {\n\t\tx=15\n\t} else if string(t[0])==\"K\" {\n\t\tx=14\n\t} else if string(t[0])==\"Q\" {\n\t\tx=13\n\t} else if string(t[0])==\"J\" {\n\t\tx=12\n\t} else if string(t[0])==\"9\" {\n\t\tx=9\n\t} else if string(t[0])==\"8\" {\n\t\tx=8\n\t} else if string(t[0])==\"7\" {\n\t\tx=7\n\t} else if string(t[0])==\"6\" {\n\t\tx=6\n\t}\n\tif string(t1[0])==\"T\" {\n\t\tx1=11\n\t} else if string(t1[0])==\"A\" {\n\t\tx1=15\n\t} else if string(t1[0])==\"K\" {\n\t\tx1=14\n\t} else if string(t1[0])==\"Q\" {\n\t\tx1=13\n\t} else if string(t1[0])==\"J\" {\n\t\tx1=12\n\t} else if string(t1[0])==\"9\" {\n\t\tx1=9\n\t} else if string(t1[0])==\"8\" {\n\t\tx1=8\n\t} else if string(t1[0])==\"7\" {\n\t\tx1=7\n\t} else if string(t1[0])==\"6\" {\n\t\tx1=6\n\t}\n\n\tif string(t[1]) == string(ts) && string(t1[1])!=string(ts) {\n\t\tfmt.Println(\"YES\")\n\t} else if string(t[1])!=string(ts) && string(t1[1])==string(ts) {\n\t\tfmt.Println(\"NO\")\n\t} else if string(t[1])!=string(ts) && string(t1[1])!=string(ts) {\n\t\tif string(t[1])!=string(t1[1]) {\n\t\t\tfmt.Println(\"NO\")\n\t\t} else {\n\t\t\tif x<=x1 {\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}\n\t} else if string(t[1])==string(ts) && string(t1[1])==string(ts) {\n\t\tif x<=x1 {\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": ["implementation"], "code_uid": "657ae2912bd32b4fd39340468372e002", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.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') }\nfunc Max(i, j int) int {\n if i < j {\n return j\n }\n return i\n}\nfunc Min(i, j int) int {\n if i >= j {\n return j\n }\n return i\n}\n\nfunc main() {\n sc.Split(bufio.ScanWords)\n r, g, b := ni(), ni(), ni()\n cnt := Min(r, Min(g, b))\n ans := r/3 + g/3 + b/3\n if cnt >= 1 {\n ans = Max(ans, (r-1)/3+(g-1)/3+(b-1)/3+1)\n }\n if cnt >= 2 {\n ans = Max(ans, (r-2)/3+(g-2)/3+(b-2)/3+2)\n }\n pri(ans)\n endl()\n w.Flush()\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "10762fac20c3dd77bab1a259c872bdad", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.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 CF87C(in io.Reader, out io.Writer) {\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]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\tmex[s] = true\n\t\t}\n\t\tfor ; mex[sg[i]]; sg[i]++ {\n\t\t}\n\t}\n\n\tn := 0\n\tFscan(in, &n)\n\tfor _, p := range ps[n] {\n\t\ts := 0\n\t\tfor j := p.a0; j-p.a0 < p.len; j++ {\n\t\t\ts ^= sg[j]\n\t\t}\n\t\tif s == 0 {\n\t\t\tFprint(out, p.len)\n\t\t\treturn\n\t\t}\n\t}\n\tFprint(out, -1)\n}\n\nfunc main() { CF87C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "dp", "games"], "code_uid": "b5b701851a3ba9cbcd80a57d8e5398fb", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"io\"\n\t\"strings\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, 1024*1024)\n\tdims := readInts(r, 3)\n\tn := dims[0]\n\tprices := [2]int{dims[1], dims[2]}\n\n\tif n == 0 {\n\t\tfmt.Print(0)\n\t\treturn\n\t}\n\n\tminP := 0\n\tif prices[0] < prices[1] {\n\t\tminP = prices[0]\n\t} else {\n\t\tminP = prices[1]\n\t}\n\n\tcolors := readInts(r, n)\n\n\texp := 0\n\tfor i := 0; i <= (len(colors) - 1) / 2; i++ {\n\t\tcol := colors[i]\n\t\tcontI := len(colors) - 1 - i\n\t\tcontCol := colors[contI]\n\t\tif col == 2 && contCol == 2 {\n\t\t\texp += minP\n\t\t\tif i != contI {\n\t\t\t\texp += minP\n\t\t\t}\n\t\t} else if col == 2 {\n\t\t\texp += prices[contCol]\n\t\t} else if contCol == 2 {\n\t\t\texp += prices[col]\n\t\t} else if contCol != col {\n\t\t\texp = -1\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfmt.Print(exp)\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 readString(reader *bufio.Reader, l int) string {\n\tsTemp := readLine(reader)\n\tif len(sTemp) < l {\n\t\tl = len(sTemp)\n\t}\n\treturn sTemp[:l]\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": ["greedy"], "code_uid": "ee1797fccd0b383e85c4deaca2ee270a", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "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 CF300C(in io.Reader, out io.Writer) {\n\tconst m int64 = 1e9 + 7\n\tconst mx int = 1e6\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\tvar a, b, n int\n\tFscan(in, &a, &b, &n)\n\tC := func(k int) int64 { return F[n] * invF[k] % m * invF[n-k] % m }\n\tans := int64(0)\n\td := n * a\n\tfor i := 0; i <= n; i++ {\n\t\tv := d\n\t\tfor ; v > 0; v /= 10 {\n\t\t\tif v%10 != a && v%10 != b {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif v == 0 {\n\t\t\tans = (ans + C(i)) % m\n\t\t}\n\t\td += b - a\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF300C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["brute force", "combinatorics"], "code_uid": "68cd94281d699518a94ed1254ecd4967", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a1,a2,a3,a4 int\n\tfmt.Scanf(\"%d%d%d%d\", &a1,&a2,&a3,&a4)\n\n\tsum := a1 + a2 + a3 + a4\n\tif sum % 2 != 0 {\n\t\tfmt.Printf(\"NO\")\n\t} else {\n\t\tif a1 + a2 == sum / 2 || a1 + a3 == sum / 2 || a1 + a4 == sum / 2 || a1 == sum / 2 || a2 == sum / 2 || a3 == sum / 2 || a4 == sum / 2 {\nfmt.Printf(\"YES\")\n} else {\nfmt.Printf(\"NO\")\n}\n}\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "1b64b3957d3f75da890b35c530545c89", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar friendsCount, pagesCount, answer int\n\tfmt.Scan(&friendsCount, &pagesCount)\n\n\tanswer =\n\t\t(friendsCount*8)/pagesCount +\n\t\t\t(friendsCount*5)/pagesCount +\n\t\t\t(friendsCount*2)/pagesCount\n\n\tif friendsCount*8%pagesCount != 0 {\n\t\tanswer++\n\t}\n\n\tif friendsCount*5%pagesCount != 0 {\n\t\tanswer++\n\t}\n\n\tif friendsCount*2%pagesCount != 0 {\n\t\tanswer++\n\t}\n\n\tfmt.Println(answer)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "7edc1004ae7dc11bc957c6fe118f65cb", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, L int64\n\tfmt.Scan(&n, &L)\n\tc := make([]int64, n)\n\tfor i := range c {\n\t\tfmt.Scan(&c[i])\n\t}\n\tfor i := 1; int64(i) < n; i++ {\n\t\tif c[i] > c[i-1]*2 {\n\t\t\tc[i] = c[i-1] * 2\n\t\t}\n\t}\n\tfor len(c) < 30 {\n\t\tc = append(c, c[len(c)-1]*2)\n\t}\n\tans := int64(0)\n\tfor i := range c {\n\t\tif L&(1< c[i]*2 {\n\t\t\t\tans = c[i] * 2\n\t\t\t}\n\t\t} else if ans > c[i] {\n\t\t\tans = c[i]\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp", "bitmasks"], "code_uid": "78091c8fb9384b23947a05d3d48cae92", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.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": "8b578f2775736dc6390c70e551c0ef0b", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.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 p := make([]int,n+1)\n ans := 0\n for i := 2; i <= n; i++ {\n if p[i] == 0 {\n for a := i; a <= n; a += i {\n p[a]++\n }\n } else if p[i] == 2 {\n ans++\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "caf733fb7b92360f6fa454ebe6f842d1", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1204\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc Solve(s string) int {\n\tmaxPowerOfTwo := float64(len(s) - 1)\n\tpowersOfFour := int(math.Ceil(maxPowerOfTwo / 2))\n\tif int(maxPowerOfTwo)%2 == 0 && strings.Count(s, \"1\") > 1 {\n\t\treturn powersOfFour + 1\n\t}\n\treturn powersOfFour\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\tfmt.Fprintf(writer, \"%d\\n\", Solve(s))\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "ac020307d4e0732986af4a248ad7f8ba", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 233B\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b, c, i, sum int64\n\tfmt.Scan(&a)\n\tb = int64(math.Sqrt(float64(a)))\n\tfor i = b - 100; i <= b; i++ {\n\t\tif i < 1 {\n\t\t\tcontinue\n\t\t}\n\t\tc = i\n\t\tsum = 0\n\t\tfor c > 0 {\n\t\t\tsum = sum + c%10\n\t\t\tc /= 10\n\t\t}\n\t\tif (sum+i)*i == a {\n\t\t\tfmt.Print(i)\n\t\t\treturn\n\t\t}\n\t}\n\tc = -1\n\tfmt.Print(c)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search"], "code_uid": "c7265a9be8fed84ade179be268d8e9d4", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tm, n := 0, 0\n\tfmt.Scanf(\"%d %d\", &m, &n)\n\tif m < n {\n\t\tm, n = n, m\n\t}\n\tdCount := m * (n / 2)\n\tif n%2 != 0 {\n\t\tdCount += m / 2\n\t}\n\tfmt.Println(dCount)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "9d5a2d8cc159e4b2ba9cee025bda2249", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// https://codeforces.com/contest/1355/problem/C\npackage main\n\nimport (\n\t\"fmt\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nfunc main() {\n\tvar a, b, c, d int\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tfmt.Scan(&a, &b, &c, &d)\n\n\trefs := make([]int, int(2e6))\n\tfor x := a; x <= b; x++ {\n\t\trefs[x+b]++\n\t\trefs[x+c+1]--\n\t}\n\tfor i := 1; i < len(refs); i++ {\n\t\trefs[i] += refs[i-1]\n\t}\n\tans := int64(0)\n\tfor i := c; i < len(refs); i++ {\n\t\tif refs[i] > 0 {\n\t\t\tans += int64(refs[i]) * int64(nn(min(d, i - 1) - c + 1)) \n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\nfunc min(a,b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc nn(a int) int {\n\tif a < 0 {\n\t\treturn 0\n\t}\n\treturn a\n}\n", "lang_cluster": "Go", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "9413f02d1fa10b13e8cfb8dc04d45e51", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar line string\n\tfmt.Scan(&line)\n\n\tcount := 0\n\n\tif len(line) < 7 {\n\t\tfmt.Print(\"NO\")\n\t} else {\n\t\tfor i := 0; i < len(line)-1; i++ {\n\t\t\tif line[i] == line[i+1] {\n\t\t\t\tcount++\n\t\t\t} else {\n\t\t\t\tcount = 0\n\t\t\t}\n\n\t\t\tif count == 6 {\n\t\t\t\tfmt.Print(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tfmt.Print(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "e4bf6f7142463011c2e86fa467085eb8", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.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\t\"strconv\"\r\n\t\"strings\"\r\n)\r\n\r\ntype CF1709A 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 *CF1709A) 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 *CF1709A) 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 *CF1709A) 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 *CF1709A) 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 *CF1709A) 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 CF1709A\r\nDate: 23/07/22\r\nUser: pepradere\r\nURL: https://codeforces.com/problemset/problem/1709/A\r\nProblem: CF1709A\r\n**/\r\nfunc (in *CF1709A) Run() {\r\n\tfor t := in.NextInt(); t > 0; t-- {\r\n\t\tkey := in.NextInt() - 1\r\n\t\tarr := []int{\r\n\t\t\tin.NextInt() - 1,\r\n\t\t\tin.NextInt() - 1,\r\n\t\t\tin.NextInt() - 1,\r\n\t\t}\r\n\r\n\t\tans := true\r\n\t\t//|| arr[arr[arr[key]]] == -1\r\n\t\tif arr[key] == -1 || arr[arr[key]] == -1 {\r\n\t\t\tans = false\r\n\t\t}\r\n\r\n\t\tif ans {\r\n\t\t\tfmt.Println(\"YES\")\r\n\t\t} else {\r\n\t\t\tfmt.Println(\"NO\")\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunc NewCF1709A(r *bufio.Reader) *CF1709A {\r\n\treturn &CF1709A{\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\tNewCF1709A(bufio.NewReader(os.Stdin)).Run()\r\n}\r\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "f53389a314cba5ab76f74e89fea85539", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x int\n\tfmt.Scanln(&x)\n\ta := 0\n\tfor x>0 {\n\t\ta += x%2\n\t\tx /= 2\t\t\n\t}\n\tfmt.Println(a)\n}", "lang_cluster": "Go", "tags": ["bitmasks"], "code_uid": "008836203e683bcacb3f73ff55f77ca8", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// cf670a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar ma int\n\tif n > 1 {\n\t\tma = 2 + (((n - 2) / 7) * 2)\n\t\tif (n-2)%7 > 5 {\n\t\t\tma += ((n - 2) % 7) - 5\n\t\t}\n\t} else {\n\t\tma = n\n\t}\n\tmi := (n / 7) * 2\n\tif n%7 > 5 {\n\t\tmi += (n % 7) - 5\n\t}\n\tfmt.Println(mi, ma)\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "0224310079cda731c724ad054896063a", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.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.Scanf(\"%d\\n\", &n)\n\tvar array [200]int\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &array[i])\n\t}\n\tsort.Ints(array[:n])\n\tvar sum float64 = float64(4.5 * float64(n))\n\n\tfor i := 0; i < n; i++ {\n\t\tsum -= float64(array[i])\n\t\t//\tfmt.Printf(\"%d \", array[i])\n\t}\n\t//\tfmt.Printf(\"%f\\n\", sum)\n\tif sum <= 0 {\n\t\tfmt.Printf(\"0\\n\")\n\t\treturn\n\t} else {\n\t\t//\tfmt.Printf(\"%f\\n\", sum)\n\t\tsum = -sum\n\t\tvar result int = 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tsum += float64(5 - array[i])\n\t\t\tresult++\n\t\t\t//\tfmt.Printf(\"%f\", sum)\n\t\t\tif sum >= 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfmt.Printf(\"%d\\n\", result)\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "5366ee5494396bdc04bc2d727c4d4d84", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "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\tslice := make([][]int, n)\n\tfor i := 0; i < n; i++{\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif i == 0 {\n\t\t\t\tslice[0] = append(slice[0], 1)\n\t\t\t} else if j == 0{\n\t\t\t\tslice[i] = append(slice[i], 1)\n\t\t\t} else {\n\t\t\t\tslice[i] = append(slice[i], slice[i-1][j] + slice[i][j - 1])\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(slice[n - 1][n - 1])\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "bea49733ee608d512e12466a41916a0e", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "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 base, target := getI64(), getI64()\n count := -2\n for x := int64(1); x <= target; x *= base {\n count++\n if x == target {\n writer.WriteString(fmt.Sprintf(\"YES\\n%d\\n\", count))\n return\n }\n }\n writer.WriteString(\"NO\\n\")\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "f8d50b30dd28e89ddb2eedd3480b6f70", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "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\"sort\"\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar t int\n\tfmt.Fscanf(buf, \"%d\\n\", &t)\n\tv := make([]int,t)\n\tfor i := 0; i < t; i++ {\n\t\tfmt.Fscanf(buf, \"%d\", &v[i])\n\t}\n\tsort.Ints(v)\n\tans := 0\n\tfor i := 0; i < t; i+=2 {\n\t\tans += v[i+1]-v[i]\n\t}\n\tfmt.Printf(\"%d\\n\",ans)\n}\n", "lang_cluster": "Go", "tags": ["sortings"], "code_uid": "87be0dbc6360823ec8c000fea712fabb", "src_uid": "55485fe203a114374f0aae93006278d3", "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\"sort\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar (\n\t\tn, t int\n\t\ta []int\n\t)\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Scan()\n\n\tn, _ = strconv.Atoi(scanner.Text())\n\n\tt = n / 2\n\n\ta = make([]int, t)\n\n\tfor i := 0; i < t; i++ {\n\t\tscanner.Scan()\n\t\ta[i], _ = strconv.Atoi(scanner.Text())\n\t}\n\n\tsort.Ints(a)\n\n\tcurrent := 0\n\tcnt1 := 0\n\n\t// Blacks\n\tfor i := 1; i <= n; i += 2 {\n\t\tpos := a[current]\n\t\tdist := pos - i\n\n\t\t// math.Abs emulation\n\t\tif dist < 0 {\n\t\t\tdist = dist * -1\n\t\t}\n\n\t\tcnt1 += dist\n\t\tcurrent++\n\t}\n\n\tcurrent = 0\n\tcnt2 := 0\n\n\t// Whites\n\tfor i := 2; i <= n; i += 2 {\n\t\tpos := a[current]\n\t\tdist := pos - i\n\n\t\t// math.Abs emulation\n\t\tif dist < 0 {\n\t\t\tdist = dist * -1\n\t\t}\n\n\t\tcnt2 += dist\n\t\tcurrent++\n\t}\n\n\tif cnt1 < cnt2 {\n\t\tfmt.Println(cnt1)\n\t} else {\n\t\tfmt.Println(cnt2)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f7f8f2e7148aa532c99a5824117546c2", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd (a int, b int) int {\n if b == 0 {\n return a\n }\n return gcd(b, a%b)\n}\n\nfunc main() {\n var x, y, a, b, lcm int\n fmt.Scanf(\"%d %d %d %d\", &x, &y, &a, &b)\n if x > y {\n lcm = x*y/gcd(x, y)\n \n } else {\n lcm = x*y/gcd(y, x)\n }\n \n fmt.Print(b/lcm - (a-1)/lcm)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "1190150790b74fb52410d15759e629b2", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n \"strings\"\n \"sort\"\n)\n\nfunc main() {\n\tA:=\"\"\n _, err := fmt.Scanf(\"%s\", &A)\n b:=strings.Split(A,\"+\")\n\n\n\tif err !=nil{\n\t\tlog.Fatal(err)\n }\n sort.Strings(b)\n A=b[0]\n for x:=1; x= 0) && (cnt < k); i-- {\n cnt += a[i]\n ans++\n }\n if cnt < k { fmt.Println(-1) } else { fmt.Println(ans) }\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "b598a3cc73ccd87fad2574ef4dcdec68", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 343A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, ans int64\n\tans = 0\n\tfmt.Scan(&a, &b)\n\tfor b != 0 {\n\t\tans += a / b\n\t\ta %= b\n\t\tc = a\n\t\ta = b\n\t\tb = c\n\t}\n\tfmt.Print(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "117872ba2b58b26dbaddb5ddfc662a46", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"strconv\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar x1,y1 float64\n\tfmt.Scanf(\"%f %f\\n\", &x1, &y1)\n\tx := (math.Log(x1)*y1)\n\ty := (math.Log(y1)*x1)\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\nfunc readOneInt64(r *bufio.Reader) (n int64) {\n\tbytes, _ := r.ReadBytes('\\n')\n\tn, _ = strconv.ParseInt(string(bytes[:len(bytes)-2]), 10, 64)\n\treturn\n}\n\nfunc readInt64Slice(r *bufio.Reader, n int) (slice []int64) {\n\tvar bytes []byte\n\tslice = make([]int64, n)\n\tn--\n\tfor i := 0; i < n; i++ {\n\t\tbytes, _ = r.ReadBytes(' ')\n\t\tslice[i], _ = strconv.ParseInt(string(bytes[:len(bytes)-1]), 10, 64)\n\t}\n\tslice[n] = readOneInt64(r)\n\treturn\n}\n\nfunc readOneString(r *bufio.Reader) string {\n\tbytes, _ := r.ReadBytes('\\n')\n\treturn string(bytes[:len(bytes)-2])\n}\n\nfunc abs(i int) int {\n\tif i < 0 {\n\t\treturn i * -1\n\t}\n\treturn i\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "a70a9ce057b68a10dc41528acd7c1937", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\tknownArray := make([]byte, n)\n\tprints := make([]bool, 10)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&knownArray[i])\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tvar singlePrint byte\n\t\tfmt.Scan(&singlePrint)\n\t\tprints[singlePrint] = true\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tif prints[knownArray[i]] == true {\n\t\t\tfmt.Printf(\"%d \", knownArray[i])\n\t\t}\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "4a7e9e3310f7de9a80e59d56f08b725f", "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// \"math\"\n\t\"os\"\n)\n\nvar (\n\tin = bufio.NewReader(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(in, a...)\n}\nfunc printf(f string, a ...interface{}) {\n\tfmt.Fprintf(out, f, a...)\n}\nfunc IntPow(n, m int) int {\n if m == 0 {\n return 1\n }\n result := n\n for i := 2; i <= m; i++ {\n result *= n\n }\n return result\n}\nfunc solve() {\n\tvar n int\n\tscan(&n)\n\tprintf(\"%d\\n\",IntPow(2,n)-1)\n}\nfunc main() {\n\tdefer out.Flush()\n\tn := 0\n\tscan(&n)\n\tfor i := 0; i < n; i++ {\n\t\tsolve()\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a618421b8b06f8b3d5a968a79f5a2e4f", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "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\treader := bufio.NewReader(os.Stdin)\n\n\tvar n int\n\tfmt.Fscan(reader, &n)\n\n\tvar count int64\n\tfor i := 3; i <= n; i++ {\n\t\tcount += int64(i * (i - 1))\n\t}\n\n\tfmt.Println(count)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "333f85db2ebeca9b5b11609ebc5f17a7", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc mask(a int) int{\n\tb := 0\n\tbas := 1\n\tfor a>0{\n\t\tif (a%10 == 7 || a%10 == 4){\n\t\t\tb+=bas*(a%10)\n\t\t\tbas*=10\n\t\t}\n\t\ta/=10\n\t}\n\treturn b\n}\n\nfunc main (){\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tfor c:= a+1;;c++{\n\t\tif(mask(c)==b){\n\t\t\tfmt.Print(c)\n\t\t\tbreak\n\t\t}\n\t}\n}\n\n\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "6d94505b34561047ebd896b4ce106658", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.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\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\tcur, pre := dp[i&1], dp[i&1^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}\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": "eee6b539e15ce144884f46ec7dcc1318", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.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 main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n int\n\ts := make([]byte, 0, 105)\n\tfor {\n\t\tif _, err := fmt.Fscan(reader, &n, &s); err != nil {\n\t\t\tbreak\n\t\t}\n\t\t// fmt.Println(n, s)\n\t\tans := len(s)\n\t\tfor i := 1; i*2-1 < len(s); i++ {\n\t\t\tif bytes.Equal(s[:i], s[i:i*2]) {\n\t\t\t\tans = min(ans, i+1+len(s)-i*2)\n\t\t\t}\n\t\t}\n\t\tfmt.Println(ans)\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": ["strings", "implementation"], "code_uid": "27ec3a02c64d5ef0d91a5cfe1c648fe7", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar (\n\tonRow [15]bool\n\tonCol [15]bool\n\trowN int\n\tcolN int\n)\n\nfunc main() {\n\tvar r, c int\n\tfmt.Scan(&r, &c)\n\n\tvar line string\n\tfor i := 0; i < r; i++ {\n\t\tfmt.Scan(&line)\n\t\tfor j := 0; j < c; j++ {\n\t\t\tv := line[j]\n\t\t\tif v == 'S' {\n\t\t\t\tif !onRow[i] {\n\t\t\t\t\tonRow[i] = true\n\t\t\t\t\trowN += 1\n\t\t\t\t}\n\t\t\t\tif !onCol[j] {\n\t\t\t\t\tonCol[j] = true\n\t\t\t\t\tcolN += 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println((r-rowN)*c + (c-colN)*rowN)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "625e8eb300b57873f2ba660df389750f", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "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 w string\n\tfmt.Scan(&w)\n\n\tif strings.ToUpper(w[1:]) == w[1:] && (w[0] >= 'a' && w[0] <= 'z') {\n\t\tfmt.Print(strings.ToUpper(w[0:1]) + strings.ToLower(w[1:]))\n\t} else if strings.ToUpper(w) == w {\n\t\tfmt.Print(strings.ToLower(w))\n\t} else {\n\t\tfmt.Print(w)\n\t}\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "76a708afeda2d045ca64c6cb21cb02ef", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "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\treader := bufio.NewReader(os.Stdin)\n\n\ts, _ := reader.ReadString('\\n')\n\n\tok := solve(normalize(s))\n\n\tif ok {\n\t\tfmt.Println(\"OK\")\n\t} else {\n\t\tfmt.Println(\"BUG\")\n\t}\n}\n\nconst N = 110\n\nvar vis [2 * N][2 * N]int\n\nfunc reset(n int) {\n\tfor i := N - n; i <= N+n; i++ {\n\t\tfor j := N - n; j <= N+n; j++ {\n\t\t\tvis[i][j] = 0\n\t\t}\n\t}\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\nvar dd = []int{-1, 0, 1, 0, -1}\n\nfunc solve(s string) bool {\n\treset(len(s))\n\n\tvar x, y = N, N\n\tvis[x][y] = 1\n\tfor i := 0; i < len(s); i++ {\n\t\tsteps := vis[x][y]\n\t\tcur := s[i]\n\t\tif cur == 'L' {\n\t\t\tx--\n\t\t} else if cur == 'R' {\n\t\t\tx++\n\t\t} else if cur == 'U' {\n\t\t\ty++\n\t\t} else {\n\t\t\ty--\n\t\t}\n\n\t\tif vis[x][y] > 0 {\n\t\t\treturn false\n\t\t}\n\n\t\tfor k := 0; k < 4; k++ {\n\t\t\tu, v := x+dd[k], y+dd[k+1]\n\t\t\tif vis[u][v] > 0 && vis[u][v] != steps {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tvis[x][y] = steps + 1\n\t}\n\n\treturn true\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation", "graphs"], "code_uid": "829e4391e2bdb318bdb2197c7bd07051", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.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 a, b int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &a, &b)\n\tm := min(a, b)\n\tans := int64(1)\n\tfor i := 2; i <= m; i++ {\n\t\tans *= int64(i)\n\t}\n\tfmt.Println(ans)\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", "implementation", "number theory"], "code_uid": "89de84bcc7904f7b40f0acfae8d45faa", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar n, m 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\tvar a int64 = 3\n\tvar b int64 = 1\n\tfor n > 0 {\n\t\tif n%2 != 0 {\n\t\t\tb = (b*a)%m\n\t\t}\n\t\ta = (a*a)%m\n\t\tn = n/2\n\t}\n\tw.WriteString(strconv.FormatInt((b-1+m)%m, 10)+\"\\n\")\n\tw.Flush()\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "8d9eafea25b6162dd6fa7632d70a1a61", "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)\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\tm := make(map[int]int)\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Fscan(reader, &n)\n\t\tm[n] = 1\n\t}\n\n\tfmt.Println(4 - len(m))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0ea38aa6a6675b8bdd64b9037b8b2bc3", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\ts := bufio.NewScanner(os.Stdin)\n\ts.Split(bufio.ScanWords)\n\ts.Scan()\n\ta := s.Text()\n\tvar c int\n\tfor i:=0; i 1 {\n\t\tremainVolume := glasses[level][glassNum] - 1\n\t\tglasses[level][glassNum] = 1\n\t\tif level != n - 1 {\n\t\t\tfill(glassNum, level + 1, remainVolume / 2.0)\n\t\t\tfill(glassNum + 1, level + 1, remainVolume / 2.0)\n\t\t}\n\t}\n}\n\nfunc main() {\n\n\t//fmt.Print(math.Abs(2 - 1))\n\n\tfmt.Scan(&n, &t)\n\n\tglasses = make([][]float32, 10)\n\n\tfor i := range glasses {\n\t\tglasses[i] = make([]float32, i + 1)\n\t}\n\n\tfor i := 0 ; i < t; i++ {\n\t\tfill(0,0,1)\n\t}\n\n\tans := 0\n\tfor i := range glasses {\n\t\tfor j := range glasses[i] {\n\t\t\tif glasses[i][j] == 1 {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t\tglasses[i] = make([]float32, i + 1)\n\t}\n\n\n\tfmt.Print(ans)\n\n}\n\n\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "382e7813aad1814471a247c0669201ac", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.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, x, y, xp, yp int64\n\n\tfmt.Scan(&r, &x, &y, &xp, &yp)\n\n\tfmt.Println((int64(math.Ceil(math.Sqrt(float64((xp-x)*(xp-x)+\n\t\t(yp-y)*(yp-y))))) + 2*r - 1) / (2 * r))\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "a71dc6a2777505a9722464d40dc115d7", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var (\n n int\n min int\n minIndex int\n height [100]int\n )\n fmt.Scanln(&n)\n for i:=0; i < n; i++ {\n fmt.Scan(&height[i])\n }\n fmt.Scanln()\n min = 1001\n for i:=1; i < n-1; i++ {\n if height[i+1] - height[i-1] < min {\n min = height[i+1] - height[i-1]\n minIndex = i\n }\n }\n for i:=minIndex; i < n-1; i++ {\n height[i] = height[i+1]\n }\n n--\n min = -1\n for i:=0; i < n-1; i++ {\n if height[i+1] - height[i] > min {\n min = height[i+1] - height[i]\n }\n }\n fmt.Println(min)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "939042979ea5b639a1eb79f8f0e95cb0", "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\nfunc solve() {\n n := readInt()\n a, was := readIntArray(n), make([]bool, n)\n c, ok := []int{}, true\n for i := range a {\n cur, cnt := i, 0\n for !was[cur] {\n was[cur] = true\n cur = a[cur]-1\n cnt++\n }\n\n if cnt%2 == 0 {\n cnt /= 2\n }\n\n if cur != i {\n ok = false\n } else {\n if cnt > 0 {\n c = append(c, cnt)\n }\n }\n }\n ans := -1\n if ok {\n ans = 1\n for d := 2; d < 101; d++ {\n mul := 1\n for i := range c {\n curMul := 1\n for c[i]%d == 0 {\n c[i] /= d\n curMul *= d\n }\n if curMul > mul {\n mul = curMul\n }\n }\n ans *= mul\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": ["dfs and similar", "math"], "code_uid": "9e77aa7a4b55a1b8d4f234775e0f10a0", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.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\n\tpos := a + 1\n\tif pos < n-b {\n\t\tpos = n - b\n\t}\n\n\tfmt.Println(n - pos + 1)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "fc461d1d1ebfcd8ac767246f71578e7f", "src_uid": "51a072916bff600922a77da0c4582180", "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 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 getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tfor len(s) > 0 && (s[len(s)-1] == '\\n' || s[len(s)-1] == '\\r') {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\n\nfunc main() {\n\t// STDOUT MUST BE FLUSHED MANUALLY!!!\n\tdefer writer.Flush()\n\n\tvar n int\n\tscanf(\"%d\\n\", &n)\n\tvar min1, max1, min2, max2, min3, max3 int\n\tscanf(\"%d %d\\n\", &min1, &max1)\n\tscanf(\"%d %d\\n\", &min2, &max2)\n\tscanf(\"%d %d\\n\", &min3, &max3)\n\tn = n - min1 - min2 - min3\n\tvar ans1 = min1\n\tvar ans2 = min2\n\tvar ans3 = min3\n\tif n >= 0 && n <= max1-min1 {\n\t\tans1 = min1 + n\n\t\tn = 0\n\t} else if n > max1-min1 {\n\t\tans1 = max1\n\t\tn -= max1 - min1\n\t}\n\n\tif n >= 0 && n <= max2-min2 {\n\t\tans2 = min2 + n\n\t\tn = 0\n\t} else if n > max2-min2 {\n\t\tans2 = max2\n\t\tn -= max2 - min2\n\t}\n\n\tif n >= 0 && n <= max3-min3 {\n\t\tans3 = min3 + n\n\t\tn = 0\n\t} else if n > max3-min3 {\n\t\tans3 = max3\n\t\tn -= max3 - min3\n\t}\n\tprintf(\"%d %d %d\\n\", ans1, ans2, ans3)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "52883e8f042e580330dd649f8ca62f4b", "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\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\ts := bufio.NewScanner(os.Stdin)\n\ts.Split(bufio.ScanWords)\n\ts.Scan()\n\tn, _ := strconv.ParseInt(s.Text(), 10, 64)\n\tprimes := sieves(int(n))\n\n\tfmt.Println(do(n, primes))\n}\n\nfunc do(n int64, primes []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\n\tvar max int64\n\tif n%2 == 1 {\n\t\tset := []int64{n, n - 1, n - 2}\n\t\tmax = mul(set, primes)\n\t} else if n%3 == 0 {\n\t\tset := []int64{n - 1, n - 2, n - 3}\n\t\tmax = mul(set, primes)\n\t} else {\n\t\tset := []int64{n, n - 1, n - 3}\n\t\tmax = mul(set, primes)\n\t}\n\treturn max\n}\n\nfunc mul(xs, primes []int64) (ans int64) {\n\tfactors := make([]int64, len(primes))\n\tfor i := 0; i < len(xs); i++ {\n\t\tx := xs[i]\n\t\tiFactors := make([]int64, len(primes))\n\t\tfor x > 1 {\n\t\t\tfor j := 0; j < len(primes); j++ {\n\t\t\t\tif x%primes[j] == 0 {\n\t\t\t\t\tx /= primes[j]\n\t\t\t\t\tiFactors[j]++\n\t\t\t\t\tif iFactors[j] > factors[j] {\n\t\t\t\t\t\tfactors[j] = iFactors[j]\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tans = 1\n\tfor i := 0; i < len(factors); i++ {\n\t\tif factors[i] > 0 {\n\t\t\tans *= int64(math.Pow(float64(primes[i]), float64(factors[i])))\n\t\t}\n\t}\n\treturn\n}\n\nfunc sieves(n int) (primes []int64) {\n\tn = n + 1\n\txs := make([]bool, n)\n\txs[0] = true\n\txs[1] = true\n\tprimes = make([]int64, 0, n)\n\tfor i := 2; i < n; i++ {\n\t\tfor j := i * 2; j < n; j = j + i {\n\t\t\txs[j] = true\n\t\t}\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tif !xs[i] {\n\t\t\tprimes = append(primes, int64(i))\n\t\t}\n\t}\n\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["number theory"], "code_uid": "d8e4663ef4d207fde9ff47480a24fe55", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "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\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\tT := io.NextLine()\n\n\tS := []rune(T)\n\tfor d := 2; d <= N; d++ {\n\t\tif N % d == 0 {\n\t\t\treverse(S, 0, d - 1)\n\t\t}\n\t}\n\tio.Println(string(S))\n}\n\nfunc reverse(S []rune, start, end int) {\n\tfor i, j := start, end; i < j; i, j = i + 1, j - 1 {\n\t\tS[i], S[j] = S[j], S[i]\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": "56833b247f6ea46a446b3b0adc84ed68", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "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\"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\ta := readi()\n\tb := readi()\n\tc := readi()\n\td := readi()\n\te := readi()\n\tf := readi()\n\n\tvar c1, c2 int\n\tif e < f {\n\t\tc2 = min(b, min(c, d))\n\t\td -= c2\n\t\tc1 = min(a, d)\n\t} else {\n\t\tc1 = min(a, d)\n\t\td -= c1\n\t\tc2 = min(b, min(c, d))\n\t}\n\tprintln(e*c1 + f*c2)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "brute force"], "code_uid": "64428e381bb65d4fc81c92ce091ecb0d", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar p1, p2, p3, p4 int\n\tvar a, b int\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tp1, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tp2, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tp3, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tp4, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\ta, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tb, _ = strconv.Atoi(r.Text())\n\tcount := 0\n\tfor i:=a; i<=b; i++ {\n\t\tif ((((i % p1) % p2) % p3) % p4) == i {\n\t\t\tcount += 1\n\t\t}\n\t}\n\tw.WriteString(strconv.Itoa(count)+\"\\n\")\n\tw.Flush()\n}\n", "lang_cluster": "Go", "tags": ["implementation", "number theory"], "code_uid": "675730d3c905cedd8ad794d8e5ab0a27", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "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\tdefer _w.Flush()\n\tn := ReadInt()\n\tprintln(solve(n))\n}\n\nfunc solve(n int) int64 {\n\tc := circle(n / 2)\n\treturn partition(n) * c * c\n}\n\nfunc partition(n int) int64 {\n\treturn Combination(n, n/2) / 2\n}\n\nfunc circle(n int) int64 {\n\tif n <= 2 {\n\t\treturn 1\n\t}\n\treturn Factorial(n - 1)\n}\n\nfunc Combination(n int, k int) int64 { return Permutation(n, k) / Factorial(k) }\nfunc Factorial(n int) int64 { return Permutation(n, n-1) }\nfunc Permutation(n_ int, r_ int) int64 {\n\tn, r := int64(n_), int64(r_)\n\tv := int64(1)\n\tfor i := int64(0); i < r; i++ {\n\t\tv *= n - i\n\t}\n\treturn v\n}\n\nvar _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc print(a ...interface{}) { fmt.Fprint(_w, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(_w, f, a...) }\nfunc println(a ...interface{}) { fmt.Fprintln(_w, a...) }\nfunc Scan(a ...interface{}) {\n\tif _, err := fmt.Fscan(_r, a...); err != nil {\n\t\tpanic(err)\n\t}\n}\nfunc ReadString() (s string) { Scan(&s); return }\nfunc ReadInt() (i int) { Scan(&i); return }\nfunc ReadInts(n int) (a []int) {\n\tfor i := 0; i < n; i++ {\n\t\ta = append(a, ReadInt())\n\t}\n\treturn\n}\nfunc ReadInt64() (i int64) { Scan(&i); return }\nfunc ReadInt64s(n int) (a []int64) {\n\tfor i := 0; i < n; i++ {\n\t\ta = append(a, ReadInt64())\n\t}\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "741b57fa9568adb98545df4b21c04d82", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "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\tgroupA := make([]int, 5)\n\tgroupB := make([]int, 5)\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; i < n && 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\tgroupA[a-1]++\n\t}\n\tfor i := 0; i < n && 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\tgroupB[a-1]++\n\t}\n\n\tmoves := 0\n\tfor i := 0; i < 5; i++ {\n\t\tgroupA[i] -= groupB[i]\n\t\tif groupA[i]%2 != 0 {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t} else if groupA[i] > 0 {\n\t\t\tmoves += groupA[i]\n\t\t}\n\t}\n\tfmt.Println(moves / 2)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "d5c0b26d6206a277c73368a34ef3c211", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "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\tt := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&t[i])\n\t}\n\tvar AP bool = true\n\tcommonDiff := t[1] - t[0]\n\tfor i := 1; i < n; i++ {\n\t\tif t[i] - t[i-1] != commonDiff {\n\t\t\tAP = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif AP {\n\t\tfmt.Println(t[n-1]+commonDiff)\n\t}\n\tif !AP {\n\t\tfmt.Println(t[n-1])\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "8d60935da556cf1eb35e70b97e6df3fd", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1184/A1\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\tr int64\n)\n\nfunc main() {\n\tr = ReadInt64()\n\n\tfor x := int64(1); x <= 1000000; x++ {\n\t\ttmp := x*x + x + 1\n\t\tbunshi := r - tmp\n\t\tif bunshi <= 0 || bunshi%(2*x) != 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\ty := bunshi / (2 * x)\n\t\tfmt.Println(x, y)\n\t\treturn\n\t}\n\n\tfmt.Println(\"NO\")\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": "bed29ca332f17118737cd93a95da096c", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"regexp\"\n)\n\nfunc main() {\n\t\n\tvar (\n\t\tcount int\n\t\tline string\n\t)\n\t\n\tfmt.Scanf(\"%d\\n\", &count)\n\tfmt.Scanln(&line)\n\t\n\tvar re = regexp.MustCompile(`o(go)+`)\n\tfmt.Println(re.ReplaceAllString(line, \"***\"))\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "e87d7c9be6e2cba27f04f96dd470a773", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.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)\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": "2983fdabe544ccf42d36b650d3484afe", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.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 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 defer writer.Flush()\n\n var a, b int\n scan(&a, &b)\n\n if b % a != 0 {\n pln(-1)\n return\n }\n\n div := b / a\n count := 0\n\n for div > 1 {\n if div % 2 == 0 {\n div /= 2\n count += 1\n } else if div % 3 == 0 {\n div /= 3\n count += 1\n } else {\n break\n }\n }\n\n if div == 1 {\n pln(count)\n } else {\n pln(-1)\n }\n return\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "eee34ab112235dde3f573fe70a3f1326", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar table[3][3]int\n\n\tfor i := 0; i < 3; i++ {\n\t\tfmt.Scanf(\"%d %d %d\\n\", &table[i][0], &table[i][1], &table[i][2])\n\t}\n\t\n\tvar sum int = 0\n\tfor i := 0; i < 3; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tsum = 0\n\t\t\tif i-1 >= 0 {\n\t\t\t\tsum += table[i-1][j]\n\t\t\t}\n\t\t\tif i+1 < 3 {\n\t\t\t\tsum += table[i+1][j]\n\t\t\t}\n\t\t\tif j-1 >= 0 {\n\t\t\t\tsum += table[i][j-1]\n\t\t\t}\n\t\t\tif j+1 < 3 {\n\t\t\t\tsum += table[i][j+1]\n\t\t\t}\n\t\t\tsum += table[i][j]+1\n\t\t\tfmt.Printf(\"%d\", sum%2)\n\t\t}\n\t\tfmt.Printf(\"\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0c01b30102476e37d20927aab1dc5b27", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nimport \"bufio\"\nimport \"os\"\nimport \"sort\"\n \nvar input *bufio.Reader\n\nconst N = 200005\n\ntype arrs []int\n\nfunc (arr arrs) Len() int{\n\treturn len(arr)\n}\n\nfunc (arr arrs) Less(i, j int) bool {\n\treturn arr[i] < arr[j]\n}\n\nfunc (arr arrs) Swap(i, j int) {\n\tarr[i], arr[j] = arr[j], arr[i]\n}\n\nfunc main(){\n\tinput = bufio.NewReader(os.Stdin)\n\n\tvar k,n int\n\tfmt.Fscanf(input, \"%d%d\\n\", &n, &k)\n\n\tarr := make([]arrs, N)\n\tfor i:=0; i=0; x/=2 {\n\t\t\tarr[x] = append(arr[x], cnt)\n\t\t\tcnt++\n\t\t\tif x==0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tans := n*30\n\tfor i:=0; i 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": "c036b5da43248f3d71207627065b24ac", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// -0-\n// | |\n// 1 2\n// | |\n// -3-\n// | |\n// 4 5\n// | |\n// -6-\n\nfunc main() {\n\tdigits := [10]string{\n\t\t// Index: 0654 3210\n\t\t\"01110111\", // 0\n\t\t\"00100100\", // 1\n\t\t\"01011101\", // 2\n\t\t\"01101101\", // 3\n\t\t\"00101110\", // 4\n\t\t\"01101011\", // 5\n\t\t\"01111011\", // 6\n\t\t\"00100101\", // 7\n\t\t\"01111111\", // 8\n\t\t\"01101111\", // 9\n\t}\n\n\tgood := make(map[int]map[int]bool)\n\tfor i := 0; i < 10; i++ {\n\t\tgood[i] = make(map[int]bool)\n\t\tfor j := 0; j < 10; j++ {\n\t\t\tif i != j {\n\t\t\t\tif j_is_good_for_i(digits[i], digits[j]) {\n\t\t\t\t\tgood[i][j] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\td1 := n / 10\n\td2 := n - d1*10\n\n\tg1 := len(good[d1]) + 1\n\tg2 := len(good[d2]) + 1\n\n\tfmt.Println(g1 * g2)\n}\n\nfunc j_is_good_for_i(i, j string) bool {\n\tfor k := 0; k < 8; k++ {\n\t\tif i[k] == '1' && j[k] == '0' {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cc500b164c91fdb6fce08396242b31ad", "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 (\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 := nextInt64()\n\n\tprintln((n - 2) * (n - 2))\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"], "code_uid": "b91d63c3d9feccff8c20759265afeda3", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tg := \"aeiou\"\n\tk := 0\n\tfor _,a := range s {\n\t\tif strings.Count(g,string(a)) >0 {\n\t\t\tk++\n\t\t}\n\t\tn,err := strconv.Atoi(string(a))\n\t\tif err==nil && n%2 !=0 {\n\t\t\tk++\n\t\t}\n\t}\n\tfmt.Println(k)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "5c7875d179b2004f25f750bb50ee48ce", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc abs(n int64) int64 {\n if n>0 {\n return n\n } \n return (-n)\n}\n\nfunc main() {\n var a,b,s int64\n fmt.Scanf(\"%d%d%d\",&a,&b,&s)\n if s>= abs(a)+abs(b) && (s-(abs(a)+abs(b)))%2==0 {\n fmt.Println(\"Yes\")\n } else {\n fmt.Println(\"No\")\n }\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "62c9477ee4dbcad845a0c1d77c2d704a", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "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 (\n\t\tsize int\n\t\tballSize map[int]bool = make(map[int]bool)\n\t)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &size)\n\t\tballSize[size] = true\n\t}\n\n\tvar ok1, ok2 bool\n\tfor size, _ = range ballSize {\n\t\t_, ok1 = ballSize[size+1]\n\t\t_, ok2 = ballSize[size+2]\n\t\tif ok1 && ok2 {\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", "sortings", "implementation"], "code_uid": "9cdb7931702d77575de68be86c30d90a", "src_uid": "d6c876a84c7b92141710be5d76536eab", "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\t\"strings\"\n)\n\nfunc solve(s string) string {\n\treturn s\n}\n\nfunc output(i int, ans string) {\n\tfmt.Printf(\"Case #%d: %s\\n\", i, ans)\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Buffer(make([]byte, 1000000), 1000000)\n\n\tscanner.Scan()\n\tx := strings.Split(scanner.Text(), \" \")\n\ta, _ := strconv.Atoi(x[0])\n\tb, _ := strconv.Atoi(x[1])\n\tda := 1\n\tfor a >= 0 && b >= 0 {\n\t\ta -= da\n\t\tb -= (da + 1)\n\t\tda += 2\n\t}\n\n\tif a < 0 {\n\t\tfmt.Println(\"Vladik\")\n\t} else {\n\t\tfmt.Println(\"Valera\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "ec7d17026bc894610f006a75fbae0467", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\nvar s string\nfunc ispal(r int)bool{\n for i:=0;i0;i--{\n if !ispal(i){\n fmt.Println(i)\n return\n }\n }\n fmt.Println(0)\n}", "lang_cluster": "Go", "tags": ["brute force", "strings", "implementation"], "code_uid": "21f9782256e0fe65789e102992c1f471", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k, r, mod uint\n\tfmt.Scan(&k, &r)\n\tmod = k % 10\n\tfor i := uint(1); i <= 9; i++ {\n\t\tif (i*mod%10) == r || (i*mod%10) == 0 {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "13a8bbe6dc65abc04746d0f7eae47bd5", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\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\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\tvar scores, TIME []int\n\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\t// Limak Score\n\tLimakScore = score(0, problems, scores, TIME)\n\t// Reverse\n\tscores, TIME = reverse(scores), reverse(TIME)\n\t// Radewoosh Score\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": "5beb6729e63ab46bd772c2eb2c178f1b", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "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 solve(t string) string {\n\tcache := make(map[byte]int)\n\n\tfor i := range t {\n\t\tif isUpper(t[i]) {\n\t\t\tcache[t[i]+32]++\n\t\t} else {\n\t\t\tcache[t[i]]++\n\t\t}\n\t\tif len(cache) == 26 {\n\t\t\treturn \"YES\"\n\t\t}\n\t}\n\treturn \"NO\"\n}\n\nfunc isUpper(b byte) bool {\n\treturn 65 <= b && b <= 90\n}\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\tvar n int\n\tvar t string\n\tfmt.Fscanf(r, \"%d\\n\", &n)\n\tfmt.Fscanf(r, \"%s\\n\", &t)\n\tfmt.Fprintf(os.Stdout, \"%s\\n\", solve(t))\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "a89c96478eb08568184f665af1808cbb", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "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\tfmt.Scan(&n)\n\tsum := 1\n\tfor i := 2; i <= n; i++ {\n\t\tsum += i*4 - 4\n\t}\n\tfmt.Println(sum)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "implementation"], "code_uid": "c096b6aa81e6bd01bf0d13bfeb1403d1", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.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, a, b, c := sc.NextInt64(), sc.NextInt64(), sc.NextInt64(), sc.NextInt64()\n\tswitch (4 - (n % 4)) % 4{\n\tcase 0:\n\t\tfmt.Println(0)\n\tcase 1:\n\t\tfmt.Println(min(min(a, b + c), 3 * c))\n\tcase 2:\n\t\tfmt.Println(min(min(2 * a, b), 2 * c))\n\tcase 3:\n\t\tfmt.Println(min(min(3 * a, c), a + b))\n\t}\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\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": "bf97f16b22041222e3fcd5b7a4598786", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.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\nvar local = false\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tsetup()\n\tn := readInt()\n\tcommands := readString()\n\n\ttotal := make(map[byte]int)\n\tfor i := 0; i < n; i++ {\n\t\ttotal[commands[i]]++\n\t}\n\n\tacc := math.Min(float64(total[byte('L')]), float64(total[byte('R')])) * 2\n\tacc += math.Min(float64(total[byte('U')]), float64(total[byte('D')])) * 2\n\tfmt.Println(int(acc))\n}\n\nfunc setup() {\n\tsource := os.Stdin\n\tif local == true {\n\t\tfile, _ := os.Open(\"input.txt\")\n\t\tsource = file\n\t}\n\tscanner = bufio.NewScanner(source)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc readInt() int {\n\tscanner.Scan()\n\tans, _ := strconv.ParseInt(scanner.Text(), 10, 0)\n\treturn int(ans)\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\tans := scanner.Text()\n\treturn ans\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "2e099b93cc10a2f8e18741b4e4b3b59e", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar input string\n\tfmt.Scanf(\"%s\", &input)\n\tans := 0\n\tvar k int\n\tfmt.Scanf(\"%d\", &k)\n\ti := len(input) - 1\n\tfor k > 0 && i >= 0 {\n\t\tif input[i] == '0' {\n\t\t\tk--\n\t\t} else {\n\t\t\tans++\n\t\t\tif i == 0 {\n\t\t\t\tans = len(input) - 1\n\t\t\t}\n\t\t}\n\t\ti--\n\t}\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "b0105f04af469fdffda70a67b8f53d10", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nconst SIDES int64 = 6\n\nfunc main() {\n\tvar n int64\n\n\tfmt.Scanf(\"%d\", &n)\n\n\tfmt.Println(1 + (n * (n + 1) / 2) * SIDES)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "e154fab89804e6913a5353d876aa92eb", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.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 s []byte\n\tScan(&s)\n\tn, ans := len(s), 99\n\tif n < 2 {\n\t\tPrint(-1)\n\t\treturn\n\t}\n\tfor i := range s {\n\t\tfor j := range s {\n\t\t\tif i == j {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tt := make([]byte, n)\n\t\t\tcopy(t, s)\n\t\t\tc := 0\n\t\t\tfor k := i; k < n-1; 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\tk := j\n\t\t\tif j > 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 c < ans && (t[n-2]&15*10+t[n-1]&15)%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\tPrint(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "d1bdcdad8d330dcb7a79713a21c5e984", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "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\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tvar a , b ,c int\n\tfmt.Fscan(in,&a,&b,&c)\n\t//3 2\n\tvar total int64\n\ttotal = int64(min1(a,b) + c) * 2\n\tif(a != b){\n\t\ttotal += 1\n\t}\n\tfmt.Fprint(out,int64(total))\n\n\n\n\n\n\n}\nfunc min1(x1,x2 int) int {\n\tif(x1 < x2){\n\t\treturn x1\n\t}else{\n\t\treturn x2\n\t}\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "9ded6f6cb7e604e98e09ce9cebcc6d6b", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "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\n\tvar n, m, k int\n\tfmt.Fscanf(in, \"%d %d %d\\n\", &n, &m, &k)\n\tfmt.Println(vusTheCossackAndAContest(n, m, k))\n}\n\nfunc vusTheCossackAndAContest(n, m, k int) string {\n\tif n <= m && n <= k {\n\t\treturn \"Yes\"\n\t}\n\treturn \"No\"\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "32f7821bf38d0a9fd5e5668e53050aeb", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "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 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\ts := \"\"\n\tfor i := 1; i < 1001; i++ {\n\t\ts += strconv.Itoa(i)\n\t}\n\tfor I(&n, \"\\n\") == nil {\n\t\tO(string(s[n-1]), \"\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "067c2073f6d8b40cc76f33b14579718c", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.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 if s[0] == '-' {\n ans, len := 0, len(s)\n for i := 1; i < (len-2); i++ {\n ans = (ans*10) + int(s[i]-'0')\n }\n if s[len-1] < s[len-2] {\n ans = (ans*10) + int(s[len-1]-'0')\n } else {\n ans = (ans*10) + int(s[len-2]-'0')\n }\n fmt.Println(-ans)\n } else {\n fmt.Println(s)\n }\n}\n", "lang_cluster": "Go", "tags": ["implementation", "number theory"], "code_uid": "dfa0f6bc2f297137be2c84bab4d67056", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y, c string\n\n\tfmt.Scanf(\"%s\\n%s\", &x, &y)\n\n\tfor i:=0; i < len(x); i++{ \n\t\tif x[i] == y[i]{\n\t\t\tc += \"0\"\n\t\t}else{\n\t\t\tc += \"1\"\n\t\t}\n\t}\n\n\tfmt.Println(c)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2888f5363afbfaf12c6956b618ad0b5f", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "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.Buffer(make([]byte, 1000000), 1000000)\n\tscanner.Scan()\n\ts := strings.Split(scanner.Text(), \" \")\n\tx := []int{}\n\tfor _, v := range s {\n\t\tvv, _ := strconv.Atoi(v)\n\t\tx = append(x, vv)\n\t}\n\tfloors := x[1] - x[0]\n\tif floors < 0 {\n\t\tfloors = -floors\n\t}\n\n\televExtra := x[2] - x[0]\n\tif elevExtra < 0 {\n\t\televExtra = -elevExtra\n\t}\n\n\televTime := ((floors + elevExtra) * x[4]) + (3 * x[5])\n\tstairTime := floors * x[3]\n\tif elevTime <= stairTime {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "2ea548539499209fad6eb591268f5f67", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nconst M int64 = 998244353\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) {\n fmt.Fprintf(writer, f, a...)\n}\n\nfunc scanf(f string, a ...interface{}) {\n fmt.Fscanf(reader, f, a...)\n}\n\nfunc sp(x, y int64) int64 {\n var mul, res int64 = x, 1\n for y != 0 {\n if y % 2 != 0 {\n res = (res * mul) % M\n }\n mul = (mul * mul) % M\n y /= 2\n }\n return res\n}\n\nfunc main() {\n defer writer.Flush()\n var n, m, k int\n scanf(\"%d%d%d\", &n, &m, &k)\n fac := make([]int64, n+1)\n fac[0] = 1\n for i := 1; i <= n; i += 1 {\n fac[i] = (fac[i-1] * int64(i)) % M\n }\n\n sol := fac[n-1]\n sol = (sol * sp(fac[n-1-k], M-2)) % M\n sol = (sol * sp(fac[k], M-2)) % M\n sol = (sol * sp(int64(m-1), int64(k))) % M\n sol = (sol * int64(m)) % M\n printf(\"%d\\n\", sol)\n}", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "f1e1122e5ae71320a92e4380858e0ba7", "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\"io\"\n\t\"os\"\n)\n\nfunc main() {\n\tio := NewFastIO(os.Stdin, os.Stdout)\n\tdefer io.Flush()\n\n\tconst mod = int64(1e9 + 7)\n\n\tn := int64(io.NextInt())\n\tp, f := (mod+1)/2, int64(1)\n\tfor i := int64(1); i <= n; i++ {\n\t\tf = f * i % mod\n\t\tp = p * 2 % mod\n\t}\n\tans := (f - p + mod) % mod\n\tio.Println(ans)\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": ["math", "dp", "combinatorics", "graphs"], "code_uid": "c0b90ebdc0e451e725ac4bcfbbe2b57f", "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_ \"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 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(a0 {\n\t\t\t\tv[a]++\n\t\t\t}\n\t\t\tif a>0 {\n\t\t\t\tif v[a]>2*n {\n\t\t\t\tflag=true\n\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif flag == true {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n\n\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "69ed2d0b06af09b606d74c2a676fb2ee", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "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\t\"strings\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tencodedString := scanner.Text()\n\tre := regexp.MustCompile(`(WUB)+`)\n\tfmt.Print(strings.TrimSpace(re.ReplaceAllString(encodedString, \" \")))\n}\n", "lang_cluster": "Go", "tags": ["strings"], "code_uid": "e03a1848497d491ff4cfa1cef61a78f5", "src_uid": "edede580da1395fe459a480f6a0a548d", "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\tsc := NewScanner()\n\tA, B, C := sc.NextInt(), sc.NextInt(), sc.NextInt()\n\n\tmp := map[int]bool{}\n\ta := A\n\tfor p := 0; ; p++ {\n\t\ta = a * 10\n\n\t\tif _, b := mp[a]; b {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t}\n\t\tmp[a] = true\n\t\tif a/B == C {\n\t\t\tfmt.Println(p + 1)\n\t\t\treturn\n\t\t}\n\t\ta = a % B\n\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": ["math", "number theory"], "code_uid": "eff8f32a2b67faa71a780f8f28eb3537", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.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-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": "2e553ffb13ccc99d6c5078420e06f20c", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input uint64\n\tfmt.Scanf(\"%d\", &input)\n\tdigits := countDigits(input)\n\trem := (input - pow10(digits-1) + 1) * digits\n\tres := uint64(0)\n\tfor i := uint64(1); i < digits; i++ {\n\t\tres += (pow10(i) - pow10(i-1)) * i\n\t}\n\tfmt.Println(res + rem)\n}\n\nfunc pow10(n uint64) uint64 {\n\tif n == 0 {\n\t\treturn 1\n\t} else {\n\t\tres := uint64(1)\n\t\tfor ; n > 0; n-- {\n\t\t\tres *= 10\n\t\t}\n\t\treturn res\n\t}\n}\n\nfunc countDigits(ub uint64) uint64 {\n\tcount := uint64(0)\n\tfor ; ub > 0; ub /= 10 {\n\t\tcount++\n\t}\n\treturn count\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "9bc8c8ec1ccd7424097d2ab6534e76c0", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// cf80a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\tif od(n, m) == m {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\nfunc od(n, m int) int {\n\tfor i := n + 1; i <= m; i++ {\n\t\td := 0\n\t\tfor j := 1; j <= i; j++ {\n\t\t\tif i%j == 0 {\n\t\t\t\td++\n\t\t\t}\n\t\t}\n\t\tif d == 2 {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn 0\n}", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "0b94a81240b4b7ecdd50eea86cc0fc81", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n, m int\n fmt.Scanf(\"%d%d\", &n, &m)\n if m * 2 + 1 == n {\n fmt.Printf(\"%d\", m)\n } else if m < n / 2 {\n if m == 0 {\n m = 1\n }\n fmt.Printf(\"%d\", m)\n } else {\n fmt.Printf(\"%d\", n - m)\n }\n}", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "4180e02621bde1f4fd4b5fefc050d91e", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar (\n n int\n k int\n t int\n)\n\nfunc main() {\n fmt.Scanf(\"%d %d %d\\n\", &n, &k, &t)\n if t <= k {\n fmt.Println(t)\n } else if t >= n {\n fmt.Println(n + k - t)\n } else {\n fmt.Println(k)\n }\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "3cc77a1ec2437701e60ab39f93db6720", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc isAeiou(t string) bool {\n\tif t==\"a\" || t == \"e\" || t==\"i\" || t == \"o\" || t == \"u\" {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tfor i := 0; i < len(s)-1; i++ {\n\t\tif isAeiou(string(s[i])) || string(s[i])==\"n\" {\n\t\t\tcontinue\n\t\t}\n\t\tif !isAeiou(string(s[i+1])) {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn \n\t\t}\n\t}\n\tif isAeiou(string(s[len(s)-1])) || string(s[len(s)-1])==\"n\" {\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": "4743bebd04f4a16290738b65f0f4ca53", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 337B-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc gcd(a, b int) int {\n if b == 0 {\n return a\n }\n return gcd(b, a%b)\n}\n\nfunc main() {\n var a, b, c, d, A, B, g int\n fmt.Scan(&a, &b, &c, &d)\n if b*c <= a*d {\n A = (a*d - b*c) * c\n B = a * c * d\n } else {\n A = (b*c - a*d) * d\n B = b * c * d\n }\n if A == 0 {\n fmt.Println(\"0/1\")\n return\n }\n g = gcd(A, B)\n fmt.Print(A / g)\n fmt.Print(\"/\")\n fmt.Print(B / g)\n fmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "0cf139510e34324357da06383be3403e", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "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\t\"regexp\"\n)\n\nfunc main() {\n\tconst b_size int = 4\n\n\treader := bufio.NewReader(os.Stdin)\n\tre := regexp.MustCompile(`\\r?\\n`)\n\n\tboard := [b_size]string{}\n\n\tfor i := 0; i < b_size; 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\tboard[i] = s\n\t\t}\n\t}\n\n\tok := false\n\tcandidate := make([]rune, b_size)\n\tn := 0\n\n\tfor i := 0; i < b_size; i++ {\n\t\t// Horizontally\n\t\tfor j := 0; j < b_size; j++ {\n\t\t\tcandidate[j] = rune(board[i][j])\n\t\t}\n\t\tif is_ok(candidate, b_size) {\n\t\t\tok = true\n\t\t\tbreak\n\t\t}\n\n\t\t// Vertically\n\t\tfor j := 0; j < b_size; j++ {\n\t\t\tcandidate[j] = rune(board[j][i])\n\t\t}\n\t\tif is_ok(candidate, b_size) {\n\t\t\tok = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ok {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\n\tdia_array := make([][b_size]rune, (b_size*2-1)*2)\n\tfor j := 0; j < b_size; j++ {\n\t\toff0 := j\n\t\toff1 := (b_size*2 - 1) + (b_size - j - 1)\n\t\tfor i := 0; i < b_size; i++ {\n\t\t\tdia_array[i+off0][j] = rune(board[i][j])\n\t\t\tdia_array[i+off1][j] = rune(board[i][j])\n\t\t}\n\t}\n\n\tfor i := 0; i < (b_size*2-1)*2; i++ {\n\t\tn = 0\n\t\tfor j := 0; j < b_size; j++ {\n\t\t\tif dia_array[i][j] != dia_array[0][b_size-1] {\n\t\t\t\tcandidate[n] = dia_array[i][j]\n\t\t\t\tn++\n\t\t\t}\n\t\t}\n\t\tif is_ok(candidate, n) {\n\t\t\tok = true\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\nfunc is_ok(candidate []rune, n int) bool {\n\tif n < 3 {\n\t\treturn false\n\t} else {\n\t\tfor e := 3; e <= n; e++ {\n\t\t\txs := 0\n\t\t\tdots := 0\n\t\t\tfor i := e - 3; i < e; i++ {\n\t\t\t\tif candidate[i] == 'x' {\n\t\t\t\t\txs++\n\t\t\t\t} else if candidate[i] == '.' {\n\t\t\t\t\tdots++\n\t\t\t\t} else { // 'o'\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tif xs == 2 && dots == 1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "6c4611f0a36d3ce44810607353a35597", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/750/A\n// A. New Year and Hurry\n// time limit per test\n// 1 second\n// memory limit per test\n// 256 megabytes\n// input\n// standard input\n// output\n// standard output\n\n// Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is the hardest. Limak knows it will take him 5·i minutes to solve the i-th problem.\n\n// Limak's friends organize a New Year's Eve party and Limak wants to be there at midnight or earlier. He needs k minutes to get there from his house, where he will participate in the contest first.\n\n// How many problems can Limak solve if he wants to make it to the party?\n// Input\n\n// The only line of the input contains two integers n and k (1 ≤ n ≤ 10, 1 ≤ k ≤ 240) — the number of the problems in the contest and the number of minutes Limak needs to get to the party from his house.\n// Output\n\n// Print one integer, denoting the maximum possible number of problems Limak can solve so that he could get to the party at midnight or earlier.\n\nfunc main() {\n\tvar n, k int\n\t_, _ = fmt.Scan(&n, &k)\n\n\tminutesLeft := 240 - k\n\n\tvar nProblems int\n\tfor i := 0; i < n; i++ {\n\t\ttimeForProblem := (i + 1) * 5\n\t\tminutesLeft -= timeForProblem\n\t\tif minutesLeft < 0 {\n\t\t\tbreak\n\t\t}\n\t\tnProblems++\n\t}\n\n\t_, _ = fmt.Print(nProblems)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "44f75eaee1244d36abe42d2eaef3aae1", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nimport \"bytes\"\nimport \"io\"\nimport \"os\"\n\n//import \"strings\"\n\nvar dbg = false\n\nvar A = [][]int{\n\t[]int{0, 1, 2},\n\t[]int{1, 0, 2},\n\t[]int{1, 2, 0},\n\t[]int{2, 1, 0},\n\t[]int{2, 0, 1},\n\t[]int{0, 2, 1},\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\n\tfmt.Fscanf(&input, \"%d\\n\", &N)\n\tfmt.Fscanf(&input, \"%d\", &K)\n\n\tif dbg {\n\t\tfmt.Println(N, K)\n\t\tfmt.Println(N%6, K)\n\t}\n\n\tfmt.Println(A[N%6][K])\n}\n\nfunc main() {\n\n\tsolve()\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "352081d1c5759c3a3bd20d8c21d0218d", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1182/problem/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc Solve(n int) int64 {\n\tif n%2 == 1 {\n\t\treturn 0\n\t}\n\treturn int64(math.Pow(float64(2), float64(n/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\tfmt.Fprintf(writer, \"%d\\n\", Solve(n))\n}\n", "lang_cluster": "Go", "tags": ["math", "dp"], "code_uid": "998083200503cbb0f25a0e571c823085", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "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 int\n\tfmt.Scan(&a, &b)\n\tswitch {\n\tcase a < b:\n\t\tfmt.Println(0)\n\t\treturn\n\tcase a == b:\n\t\tfmt.Println(\"infinity\")\n\t\treturn\n\tdefault:\n\t\tz, d := 0, a-b\n\t\tfor i := 1; i*i <= d; i++ {\n\t\t\tif d%i > 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif i > b {\n\t\t\t\tz++\n\t\t\t}\n\t\t\tif d/i > b {\n\t\t\t\tz++\n\t\t\t}\n\t\t\tif i > b && i*i == d {\n\t\t\t\tz--\n\t\t\t}\n\t\t}\n\t\tfmt.Println(z)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "2872540f46507235b63e36eee8a7e2f9", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar (\n\t\tn, a, b, c, d int64\n\t)\n\tfmt.Scanf(\"%d%d%d%d%d\", &n, &a, &b, &c, &d)\n\tfmt.Println(collect(a, b, c, d, n))\n}\nfunc collect(a, b, c, d, n int64) int64 {\n\tnum := int64(0)\n\txeh := d - a\n\txfl := d - a\n\txhf := c - b - (d - a)\n\tfor e := int64(1); e <= n; e++ {\n\t\th := e - xeh\n\t\tf := h - xhf\n\t\tl := f - xfl\n\t\tif (h >= 1 && h <= n) && (f >= 1 && f <= n) && (l >= 1 && l <= n) {\n\t\t\tnum++\n\t\t}\n\t}\n\treturn num * n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "2a03b020f7ef8fe656951528f5216890", "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\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tin := bufio.NewScanner(os.Stdin)\n\tin.Scan()\n\tinput := strings.Split(in.Text(), \" \")\n\tn, _ := strconv.Atoi(input[0])\n\tk, _ := strconv.Atoi(input[1])\n\tin.Scan()\n\tinput = strings.Split(in.Text(), \" \")\n\t\n\tmaxdel := 0\n\tfor i := 0; i < n; i++ {\n\t\tcurrent, _ := strconv.Atoi(input[i])\n\t\tif ((k % current == 0) && (current > maxdel)){\n\t\t maxdel = current;\n\t\t}\n\t}\n\tfmt.Println(k / maxdel)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "048d7d71c193d4853b8e6f39f80d689f", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc min(x, y int) int {\n\tif (x > y) {return y;}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif (x > y) {return x;}\n\treturn y;\n}\n\nfunc main() {\n\tb, g, n := 0, 0, 0\n\tfmt.Scanf(\"%d\\n%d\\n%d\", &b, &g, &n);\n\n\tmin_b := max(0, n - g);\n\tmax_b := min(b, n);\n\n\tfmt.Printf(\"%d\\n\", max_b - min_b + 1);\n}", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "98d52b4bff3a9da5cb1f79c8bae7a946", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc ReadFloat64() float64 {\n f64, _ := strconv.ParseFloat(ReadString(), 64)\n return f64\n}\n\nfunc ReadInt64() int64 {\n i64, _ := strconv.ParseInt(ReadString(), 10, 64)\n return i64\n}\n\nfunc ReadInt() int {\n return int(ReadInt64())\n}\n\nfunc work(length, index int64, go_left bool) int64 {\n if length == 1 {\n return 0\n }\n mid := length / 2\n if go_left {\n if index < mid {\n return work(mid, index, false) + 1\n } else {\n return work(mid, index-mid, true) + mid*2\n }\n } else {\n if index < mid {\n return work(mid, index, false) + mid*2\n } else {\n return work(mid, index-mid, true) + 1\n }\n }\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n h, n := uint64(ReadInt64()), ReadInt64()\n fmt.Fprintln(writer, work(int64(1)< a {\n b--\n }\n }\n\n return x[a:b + 1]\n}\n\ntype ExponentialNumber struct {\n n string\n exp string\n}\n\nfunc (e ExponentialNumber) String() string {\n var result string\n var s string = e.n\n var length int = len(s)\n exp, _ := strconv.Atoi(e.exp)\n exp += 1\n\n var buffer bytes.Buffer\n\n var fs int = exp\n if fs >= length {\n fs = length\n\n buffer.WriteString(s)\n\n for i := 0; i < exp - length; i++ {\n buffer.WriteString(\"0\")\n }\n\n result = Trim(buffer.String(), true, false)\n } else {\n buffer.WriteString(Trim(s[:fs], true, false))\n\n var p string = Trim(s[fs:], false, true)\n if p != \"0\" {\n buffer.WriteString(\".\")\n buffer.WriteString(p)\n }\n\n result = buffer.String()\n }\n\n return result\n}\n\nfunc main() {\n var input string\n fmt.Scanln(&input)\n var a_s string //= fmt.Sprint(a), fmt.Sprint(d)\n\n var buffer bytes.Buffer\n\n i := 0\n for i < len(input) {\n if string(input[i]) == \"e\" {\n break\n }\n\n if string(input[i]) != \".\" {\n buffer.WriteByte(input[i])\n }\n\n i++\n }\n\n a_s = buffer.String()\n\n e := ExponentialNumber{a_s, input[i + 1:]}\n\n fmt.Println(e)\n}", "lang_cluster": "Go", "tags": ["brute force", "math", "strings", "implementation"], "code_uid": "2765ff932a157270541d27329db0fc40", "src_uid": "a79358099f08f3ec50c013d47d910eef", "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\"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\t_ = n\n\tvar t []byte\n\tt = append(t, s[0])\n\tfor _, c := range s[1:] {\n\t\tj := len(t) - 1\n\t\tif is_vowel(c) && is_vowel(t[j]) {\n\t\t\tcontinue\n\t\t}\n\t\tt = append(t, c)\n\t}\n\tprintln(string(t))\n}\n\nfunc is_vowel(c byte) bool {\n\tswitch c {\n\tcase 'a', 'e', 'i', 'o', 'u', 'y':\n\t\treturn true\n\t}\n\treturn false\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "871e7a9d5e0a4ba17a84df3c85b28ccd", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n,i int\n\ta:=make([]int,7)\n\tfmt.Scan(&n)\n\tfor i=0;i<7;i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\tfor i=0;n>0;i++ {\n\t\tn-=a[i%7]\n\t}\n\tn=(i+6)%7+1\n\tfmt.Println(n)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "a9136312703432d592045059a395b807", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.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\tif n <= 5 {\n\t\tif n == 2 || n == 5 {\n\t\t\tfmt.Println(\"1\")\n\t\t} else {\n\t\t\tfmt.Println(\"0\")\n\t\t}\n\t\treturn\n\t}\n\tlvl0 := (n - 2) / 3\n\tfree := (n - 2) % 3\n\thave := int64(0)\n\tif free == 0 {\n\t\thave = 0\n\t} else if free == 2 {\n\t\thave = 1\n\t} else {\n\t\tlvl0 -= 2\n\t\tif lvl0 < 2 {\n\t\t\tfmt.Println(\"0\")\n\t\t\treturn\n\t\t}\n\t\thave = 2\n\t}\n\tret := 1\n\tfor {\n\t\tlvl0 -= have\n\t\thave++\n\t\tlvl0 -= have\n\t\thave++\n\t\tlvl0 -= have\n\t\thave++\n\t\tlvl0 -= 2\n\t\tif lvl0 < have {\n\t\t\tbreak\n\t\t}\n\t\tret++\n\t}\n\tfmt.Println(ret)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "binary search", "brute force"], "code_uid": "5fd618b980a40ba4ab84cd63079a598c", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar sh, sm, lh, lm int\n\tfmt.Scanf(\"%d:%d\\n\", &sh, &sm)\n\tfmt.Scanf(\"%d:%d\", &lh, &lm)\n\n\tvar ah,am int\n\n\tah = sh - lh\n\tam = sm - lm\n\n\tif am < 0 {\n\t\tam = 60 + am\n\t\tah = ah - 1\n\t}\n\n\tif ah < 0 {\n\t\tah = 24 + ah\n\t}\n\n\tif ah < 10 {\n\t\tfmt.Printf(\"0%d:\", ah)\n\t} else {\n\t\tfmt.Printf(\"%d:\", ah)\n\t}\n\n\tif am < 10 {\n\t\tfmt.Printf(\"0%d\", am)\n\t} else {\n\t\tfmt.Printf(\"%d\", am)\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "1dacfb99c90e560c15d71ba27595af04", "src_uid": "595c4a628c261104c8eedad767e85775", "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\n// github.com/EndlessCheng/codeforces-go\nfunc CF690D2(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\tconst mod int64 = 1e6 + 3\n\tfact := func(n int) int64 {\n\t\tx := int64(1)\n\t\tfor i := int64(2); i <= int64(n); i++ {\n\t\t\tx = x * i % mod\n\t\t}\n\t\treturn x\n\t}\n\tpow := func(x int64, 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\tinv := func(a int64) int64 { return pow(a, mod-2) }\n\tfrac := func(a, b int64) int64 { return a * inv(b) % mod }\n\n\tvar n, c int\n\tFscan(in, &n, &c)\n\tFprint(out, frac(fact(n+c), fact(n)*fact(c)%mod)-1)\n}\n\nfunc main() { CF690D2(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["combinatorics"], "code_uid": "6c5a5cb05e2244aca7114ca7b49e1f6a", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc compute(n, v int) (sum int) {\n\tc := 0\n\tfor i := 1; i <= n; i++ {\n\t\tf := n - i\n\t\te := v - c\n\t\tif f <= c {\n\t\t\tc = 0\n\t\t\tbreak\n\t\t}\n\n\t\tif e >= f {\n\t\t\tsum += f * i\n\t\t\tc += f\n\t\t} else {\n\t\t\tc = v\n\t\t\tsum += e * i\n\t\t}\n\t\tc--\n\t}\n\treturn\n}\n\ntype test struct {\n\tn, v, result int\n}\n\nvar pretests = []test{\n\ttest{\n\t\tn: 4,\n\t\tv: 2,\n\t\tresult: 4,\n\t},\n\ttest{\n\t\tn: 7,\n\t\tv: 6,\n\t\tresult: 6,\n\t},\n}\n\n// A -\nfunc main() {\n\t// for _, t := range pretests {\n\t// \tfmt.Printf(\"%d %d\", t.result, compute(t.n, t.v))\n\t// \tfmt.Println()\n\t// }\n\t// return\n\treader := bufio.NewReader(os.Stdin)\n\tvar (\n\t\tn, v int\n\t)\n\tfmt.Fscanln(reader, &n, &v)\n\tfmt.Printf(\"%d\", compute(n, v))\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp"], "code_uid": "6bd06cb03e53b4c21be9ca4cd7afa419", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.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}\n\treturn -x\n}\n\nfunc min(i, j int) int {\n\tif i < j {\n\t\treturn i\n\t}\n\treturn j\n}\n\nfunc main() {\n\tvar n, pos, l, r int\n\tfmt.Scan(&n, &pos, &l, &r)\n\n\tgoright := abs(r - pos)\n\tgoleft := abs(l - pos)\n\tif l == 1 && r == n {\n\t\tfmt.Println(0)\n\t} else if l == 1 {\n\t\tfmt.Println(goright + 1)\n\t} else if r == n {\n\t\tfmt.Println(goleft + 1)\n\t} else {\n\t\tif pos < l {\n\t\t\tfmt.Println(goright + 2)\n\t\t} else if pos > r {\n\t\t\tfmt.Println(goleft + 2)\n\t\t} else {\n\t\t\tfmt.Println(min(goleft, goright) + r - l + 2)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "6f9d907626e1646499b5303492ab93ca", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var str string\n fmt.Scan(&str)\n res := 1\n for i := 0; i < len(str); i++ {\n res = (res << 1)\n if str[i] == uint8('7') {\n res = (res ^ 1)\n }\n }\n fmt.Println(res - 1)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "682a2106647a1f5968ac928cc3617520", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "\npackage main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n \"fmt\"\n)\n\nvar (\n mod = int64(1000000007)\n)\n\nvar reader SReader\n\nfunc main() {\n reader.Init()\n\tn := reader.ReadInt()\n\tm := reader.ReadInt()\n\tk := reader.ReadInt()\n\tif (k == -1 && n % 2 + m % 2 == 1) {\n\t\tfmt.Println(\"0\")\n\t} else {\n\t\tfmt.Println(pow(pow(2, n-1, mod), m-1, mod))\n\t}\n\n}\n\n// a,b,m > 0\nfunc pow(a, b, m int64) (res int64) {\n\tres = 1\n\ta2 := a // base a^1/a^2/a^4...\n\tfor b > 0 {\n\t\tif b & 1 == 1 {\n\t\t\tres *= a2\n\t\t\tres %= m\n\t\t}\n\n\t\ta2 *= a2\n\t\ta2 %= m\n\t\tb >>= 1\n\t}\n\n\treturn\n}\n\n// reader\ntype SReader struct {\n file *os.File\n scanner *bufio.Scanner\n}\n\nfunc (this *SReader) Init() {\n this.file = os.Stdin\n this.scanner = bufio.NewScanner(this.file)\n this.scanner.Split(bufio.ScanWords)\n}\n\nfunc (this *SReader) ReadInt() int64 {\n this.scanner.Scan()\n n, err:= strconv.ParseInt(this.scanner.Text(), 10, 64)\n if err != nil {\n panic(err)\n }\n return int64(n)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms", "combinatorics", "number theory"], "code_uid": "68f00098c19f481ef9c2d96623964394", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc check(k,n uint64) bool {\n\ttotal := n\n\ttot := uint64(0)\n\tfor n > 0 {\n\t\tif k >= n {\n\t\t\ttot += n\n\t\t\tn = 0\n\t\t}else{\n\t\t\tn -= k\n\t\t\ttot +=k\n\t\t\tn -= n/10\n\t\t}\n\t}\n\treturn tot * 2 >= total\n}\n\nfunc main() {\n\tvar n uint64\n\tfmt.Scan(&n)\n\tlb := uint64(0)\n\tub := n\n\n\tfor ub - lb > 1{\n\t\tmid := (lb + ub)/2\n\t\tif check(mid,n) {\n\t\t\tub = mid\n\t\t}else{\n\t\t\tlb = mid\n\t\t}\n\t}\n\tfmt.Println(ub)\n}\n", "lang_cluster": "Go", "tags": ["implementation", "binary search"], "code_uid": "0917146bbecac6a06960fb3a706fae9a", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.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\tk := ((a + b - 1 ) % n + n) % n + 1\n\tfmt.Print(k)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "fc04f234b96badda97a8fe91b3a9f9ae", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nfunc main() {\n\tvar s string\n\tvar aCount, otherCount int\n\tfmt.Scan(&s)\n\tfor _, Rune := range s {\n\t\tif Rune == 'a' {\n\t\t\taCount++\n\t\t} else {\n\t\t\totherCount++\n\t\t}\n\t}\n\tif aCount > otherCount {\n\t\tfmt.Println(aCount + otherCount)\n\t} else {\n\t\tfmt.Println(aCount*2 - 1)\n\t}\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "37b463b4e46e79faa790c281bf9e8999", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "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\tfsc := NewFastScanner()\n\ta1, a2 := fsc.NextInt(), fsc.NextInt()\n\tres := 0\n\tfor {\n\t\ta1, a2 = IntMax(a1, a2), IntMin(a1, a2)\n\t\tres++\n\t\ta2 += 1\n\t\ta1 -= 2\n\t\tif a1 <= 0 {\n\t\t\tif a1 < 0 {\n\t\t\t\tres--\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t}\n\tfmt.Println(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\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", "lang_cluster": "Go", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "97c7a39144b05a772f0215c747e1eb09", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.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// 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 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\tans := 0\n\tpatterns := DuplicatePatterns([]int{0, 1, 2, 3, 4, 5}, n)\n\tfor _, p := range patterns {\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 := p[e.s], p[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}\n\n\tfmt.Println(ans)\n}\n\n// DuplicatePatterns returns all patterns of n^k of elems([]int).\nfunc DuplicatePatterns(elems []int, k int) [][]int {\n\treturn dupliRec([]int{}, elems, k)\n}\n\n// DFS function for DuplicatePatterns.\nfunc dupliRec(pattern, elems []int, k int) [][]int {\n\tif len(pattern) == k {\n\t\treturn [][]int{pattern}\n\t}\n\n\tres := [][]int{}\n\tfor _, e := range elems {\n\t\tnewPattern := make([]int, len(pattern))\n\t\tcopy(newPattern, pattern)\n\t\tnewPattern = append(newPattern, e)\n\n\t\tres = append(res, dupliRec(newPattern, elems, k)...)\n\t}\n\n\treturn res\n}\n\n// func 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\n// func 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": "3dcb85d908b75fd01f76bcdf147941c7", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "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": ["implementation"], "code_uid": "f67bbbb5edc60998539148206567ed70", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"regexp\"\n)\n\nfunc main() {\n\tvar size int\n\tvar file string\n\n\tfmt.Scan(&size)\n\tfmt.Scan(&file)\n\n\treg := regexp.MustCompile(\"x+\")\n\n\tslice := reg.FindAllString(file, -1)\n\n\tvar ans = 0\n\tfor _, val := range slice {\n\t\tans += int(math.Max(0, float64(len(val)-2)))\n\t}\n\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "strings"], "code_uid": "00999ec8af86a1d4e827007de5ac7d25", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc check(index int, pos string, k int, n int) bool {\n\tfor i := index; i < n && i >= 0; i += k {\n\t\tif pos[i] == '#' {\n\t\t\treturn false\n\t\t}\n\t\tif pos[i] == 'T' {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar n int\n\tvar k int\n\tfmt.Scan(&n)\n\tfmt.Scan(&k)\n\tvar pos string\n\tfmt.Scan(&pos)\n\n\tvar grasspos int\n\tfor i := 0; i < n; i++ {\n\t\tif pos[i] == 'G' {\n\t\t\tgrasspos = i\n\t\t\tbreak\n\t\t}\n\t}\n\tflag := check(grasspos, pos, k, n) || check(grasspos, pos, -k, n)\n\tif flag {\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": "5598c5fdb30ca78de7a475b773a6db34", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "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 local = false\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tsetup()\n\tresult := false\n\tinp := readString()\n\tzeroes := 0\n\tfor i := len(inp) - 1; i >= 0; i-- {\n\t\tif inp[i] == '0' {\n\t\t\tzeroes++\n\t\t}\n\n\t\tif inp[i] == '1' && zeroes >= 6 {\n\t\t\tresult = true\n\t\t}\n\t}\n\n\tif result {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n}\n\nfunc setup() {\n\tsource := os.Stdin\n\tif local == true {\n\t\tfile, _ := os.Open(\"input.txt\")\n\t\tsource = file\n\t}\n\tscanner = bufio.NewScanner(source)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f8b2b3426ade6303d6b7e49e59d6c9a8", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b uint64\n fmt.Scan(&a, &b);\n\n cnt := 0\n ref := uint64(0)\n for bits := 1; ref <= b; bits++ {\n ref = ref*2 + 1\n for i := 0; i < bits-1; i++ {\n ref2 := ref - 1<= a && ref2 <= b {\n cnt++ \n }\n }\n }\n fmt.Println(cnt)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "d4e78a1d654210c440b07172fea01758", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 402A-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var k, a, b, v, hasil int\n fmt.Scan(&k, &a, &b, &v)\n for a > 0 {\n if b >= k-1 {\n b -= (k - 1)\n a -= v * k\n hasil++\n } else if b != 0 {\n a -= v * (b + 1)\n hasil++\n b = 0\n } else {\n a -= v\n hasil++\n }\n }\n fmt.Println(hasil)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "96866ebda54f50c6a9e3a6e1d1735319", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.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 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": "959ca4e8c9e48392a7a6616e76579d75", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.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.Scanf(\"%d\", &n)\n\tfmt.Printf(\"%d\", n / 2 * 3)\n}", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "4bd3a971a7ee3a84dbbbc64b03457fec", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 257B\npackage 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 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, m int\n\tfmt.Scan(&n, &m)\n\tfmt.Print(max(n, m)-1, min(n, m))\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation", "games"], "code_uid": "d15fe3e7024c3afbd3a671ea3584df67", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar sto [1005]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\tvar n, k int\n\tfmt.Scanf(\"%d %d\\n\", &n, &k)\n\tfor index := 0; index < k; index++ {\n\t\tfmt.Scanf(\"%d\", &sto[index])\n\t}\n\tsum, ans := n, 2*n\n\tfor index := 0; index < k; index++ {\n\t\tminn := min(sum, sto[index]/4)\n\t\tsum -= minn\n\t\tsto[index] -= minn * 4\n\t}\n\tans += sum\n\tfor index := 0; index < k; index++ {\n\t\tminn := min(ans, sto[index]/2)\n\t\tans -= minn\n\t\tsto[index] -= minn * 2\n\t}\n\tans += sum\n\tfor index := 0; index < k; index++ {\n\t\tans -= sto[index]\n\t}\n\tif ans >= 0 {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy", "implementation"], "code_uid": "551db849b5d985e27dee4b673493ef2c", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0, "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 \tfmt.Println(t)\n }\n", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "2c8e451e5dc863e147d78c00598b3493", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n scanner.Scan()\n x, _ := strconv.Atoi(scanner.Text())\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 scanner.Scan()\n code := scanner.Text()\n digits := map[string]int{}\n for i := 0; i < 10; i++ {\n scanner.Scan()\n digits[scanner.Text()] = i\n }\n for i := 0; i < 8; i++ {\n digit := digits[code[10*i:10*(i+1)]] \n writer.WriteString(fmt.Sprintf(\"%d\", digit))\n }\n writer.WriteString(\"\\n\")\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "2f8d636cf59c078ea0531c5a5f7c50f7", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "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\tr *bufio.Scanner\n\tw *bufio.Writer\n)\n\nconst isDebug = false\n\nfunc scan() {\n\tif !r.Scan() {\n\t\tpanic(r.Err())\n\t}\n}\n\nfunc readInt() int {\n\tscan()\n\tx, err := strconv.Atoi(r.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn x\n}\n\nfunc readLine() string {\n\tscan()\n\treturn r.Text()\n}\n\nfunc readInt64() int64 {\n\tscan()\n\tx, _ := strconv.ParseInt(r.Text(), 10, 64)\n\treturn x\n}\n\nfunc solveProblem() {\n\t// #513_B\n\tvar n = readInt64()\n\tvar result = 0\n\tvar tmp int64 = 0\n\tfor tmp*10+9 < n {\n\t\ttmp = tmp*10 + 9\n\t\tresult += 9\n\t}\n\ttmp = n - tmp\n\tfor tmp > 0 {\n\t\tresult += int(tmp % 10)\n\t\ttmp /= 10\n\t}\n\tw.WriteString(fmt.Sprintln(result))\n}\n\nfunc main() {\n\tif isDebug {\n\t\tfi, err := os.Open(\"input.txt\")\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfo, err := os.OpenFile(\"output.txt\", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tdefer fi.Close()\n\t\tdefer fo.Close()\n\n\t\tr = bufio.NewScanner(fi)\n\t\tw = bufio.NewWriter(fo)\n\t} else {\n\t\tr = bufio.NewScanner(os.Stdin)\n\t\tw = bufio.NewWriter(os.Stdout)\n\t}\n\tsolveProblem()\n\tdefer w.Flush()\n\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "db4834b90f0b02a1987108b10c57bfee", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 90A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc max(x, y int) int {\n\tif x < y {\n\t\treturn y\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar r, g, b int\n\tfmt.Scan(&r, &g, &b)\n\tr++\n\tr /= 2\n\tg++\n\tg /= 2\n\tb++\n\tb /= 2\n\tans := 30 + max(3*r-3, max(3*g-2, 3*b-1))\n\tfmt.Print(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy"], "code_uid": "eef8929b719e059faa76a0cfd23c5bc6", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var k int\n fmt.Scanf(\"%d %d\\n\", &n, &k)\n sum := 0\n for i := 0; i < n; i++ {\n \tvar x int\n \tfmt.Scanf(\"%d\", &x)\n \tsum += x\n }\n ret := 0\n for 2 * sum < (ret + n) * (2 * k - 1) {\n \t/*\n \tsum / (ret + n) >= (k - 0.5)\n \t2 * sum / (ret + n) >= 2 * k - 1\n \t2 * sum >= (ret + n) * (2 * k - 1)\n \t*/\n \tsum += k\n \tret += 1\n }\n fmt.Printf(\"%d\\n\", ret)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "a123f21143026f71d3cb9ebdadb98846", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"bytes\"\n)\n\nconst ZERO int = int('0')\n\nfunc process(s string) []int {\n var cnt [10]int\n for _, c := range s {\n cnt[int(c) - ZERO]++\n }\n return cnt[:]\n}\n\nfunc getMax(cnt []int) string {\n var buffer bytes.Buffer\n for i := 9; i >= 0; i-- {\n for j := 0; j < cnt[i]; j++ {\n buffer.WriteRune(rune(i + ZERO))\n }\n }\n return buffer.String()\n}\n\nfunc main() {\n var a, b string\n fmt.Scan(&a, &b)\n cnt := process(a)\n var ans string\n if len(b) > len(a) {\n ans = getMax(cnt)\n } else {\n var buffer bytes.Buffer\n valid := true\n for i, c := range b {\n numb := int(c) - ZERO\n\n // attempt to go lower\n for numb--; numb >= 0 && cnt[numb] == 0; numb-- {}\n if numb >= 0 {\n buffer.WriteRune(rune(numb + ZERO))\n cnt[numb]--\n buffer.WriteString(getMax(cnt))\n ans = buffer.String()\n cnt[numb]++\n buffer.Truncate(i)\n }\n\n // reset\n numb = int(c) - ZERO\n if cnt[numb] > 0 {\n buffer.WriteRune(c)\n cnt[numb]--\n } else {\n for ; numb >= 0 && cnt[numb] == 0; numb-- { }\n if numb >= 0 {\n buffer.WriteRune(rune(numb + ZERO))\n cnt[numb]--\n buffer.WriteString(getMax(cnt))\n } else {\n valid = false\n }\n break\n }\n }\n if valid {\n ans = buffer.String()\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "dp"], "code_uid": "3aac00698107c1c689db3d8450ba4c4b", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "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, t 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\tt, _ = strconv.Atoi(r.Text())\n\tvar pa1, pa2, num int64 = 0, 0, 0\n\tfor i:=4; i0 {\n\t\t\tttl=ttl+(k%i)\n\t\t\tk/=i\n\t\t\tif k1; i-- {\n\t\tif ttl%i==0 && l%i==0 {\n\t\t\tttl/=i\n\t\t\tl/=i\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Print(ttl,\"/\",l)\n\tfmt.Println()\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "8105203ababb22baff1f9057916f8f11", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport(\"fmt\")\nfunc main () {\n var s, t string;\n fmt.Scanf(\"%s %s\", &s, &t);\n if (s == t) {\n fmt.Println(s);\n } else {\n fmt.Println(1);\n }\n}", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "f6928776d4ecee7a142972c99243ae5e", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc readTime() int {\n\tvar hh, mm int\n\n\tfmt.Scanf(\"%d:%d\\n\", &hh, &mm)\n\n\treturn hh*60 + mm\n}\n\nfunc printTime(time int) {\n\ttime %= 60 * 24\n\thh := time / 60\n\tmm := time % 60\n\tfmt.Printf(\"%02d:%02d\\n\", hh, mm)\n}\n\nfunc main() {\n\ttime := readTime()\n\tvar a int\n\tfmt.Scanf(\"%d\", &a)\n\ttime += a\n\tprintTime(time)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b041d89b64f8db94738bde74dad81adf", "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\"os\"\n)\n\nvar T, n int\nvar number [10][]int\n\nvar _r = bufio.NewReader(os.Stdin)\nvar _w = bufio.NewWriter(os.Stdout)\n\nfunc calc(x int) int {\n\tres := 0\n\tfor tmp := x; tmp > 0; tmp /= 10 {\n\t\tres++\n\t}\n\treturn res\n}\nfunc main() {\n\tfor i := 1; i <= 9; i++ {\n\t\tfor x := i; x <= 9999; x = x*10 + i {\n\t\t\tnumber[i] = append(number[i], x)\n\t\t}\n\t}\n\n\tfor _, _ = fmt.Fscan(_r, &T); T > 0; T-- {\n\t\tvar x int\n\t\tans := 0\n\t\t_, _ = fmt.Fscan(_r, &x)\n\t\tfor _, val_slice := range number {\n\t\t\tfor _, val := range val_slice {\n\t\t\t\tans += calc(val)\n\t\t\t\tif val == x {\n\t\t\t\t\tgoto out\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tout:\n\t\t_, _ = fmt.Fprintln(_w, ans)\n\t\t_ = _w.Flush()\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "8c2fced097ad9586ab5ba2396b93b849", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\n\nfunc min(a,b int) int {\n\tvar ret int\n\tif(a < b ){\n\t\tret = a\n\t}else {\n\t\tret = b\n\t}\n\treturn ret\n\n}\nfunc main(){\n var n ,m int\n fmt.Scanf(\"%d %d\",&n,&m)\n mi := -1\n for i := 0;i <= n; i = i + 1{\n \t b := n - i\n\t if 0 == b % 2 && 0 == (b / 2 + i) % m{\n\t \tif(-1 == mi){\n\t\t\tmi = b / 2 + i\n\t\t}else {\n\t\t\tmi = min(mi,b/2 + i)\n\t\t}\n\n\t }\n }\n fmt.Printf(\"%d\\n\",mi)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "3030dbfc70f2ea0742417a851b814994", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.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 recv(N, k int64) int64 {\n\tn := pow(2, N)\n\tc := n / 2\n\n\tif c == k {\n\t\treturn N\n\t}\n\tif k > c {\n\t\tk = k - c\n\t}\n\treturn recv(N - 1, k)\n}\nfunc main() {\n\tsc := NewScanner()\n\tN, k := sc.NextInt64(), sc.NextInt64()\n\tif N == 1 {\n\t\tfmt.Println(1)\n\t\treturn\n\t}\n\tif k % 2 == 1 {\n\t\tfmt.Println(1)\n\t\treturn\n\t}\n\tif (k / 2) % 2 == 1 {\n\t\tfmt.Println(2)\n\t\treturn\n\t}\n\tfmt.Println(recv(N, k))\n\n}\n//aの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\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": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "4cdc22d575363f94f4182f82029b99fc", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "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\tinn = bufio.NewScanner(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\nfunc cmax(a *int, b int) {\n\tif b > *a {\n\t\t*a = b\n\t}\n}\nfunc main() {\n\tdefer out.Flush()\n\tinn.Buffer([]byte{}, 10000000)\n\tinn.Split(bufio.ScanWords)\n\ttype ll int64\n\t//prep\n\tn, k := rd(), rd()\n\ts := rds()\n\tss := rds()\n\ta, b := ss[0], ss[1]\n\tdp := make([][][]int, n+1)\n\tfor i := range dp {\n\t\tdp[i] = make([][]int, n+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] = -1000000000\n\t\t\t}\n\t\t}\n\t}\n\tdp[0][0][0] = 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j <= k && j <= i; j++ {\n\t\t\tfor c := 0; c <= i; c++ {\n\t\t\t\tvar e1, e2, e3 int\n\t\t\t\tif s[i] == a {\n\t\t\t\t\te1 = 1\n\t\t\t\t}\n\t\t\t\tif s[i] == b {\n\t\t\t\t\te2 = 1\n\t\t\t\t}\n\t\t\t\tif a == b {\n\t\t\t\t\te3 = 1\n\t\t\t\t}\n\t\t\t\tcmax(&dp[i+1][j][c+e1], dp[i][j][c]+e2*c)\n\t\t\t\tif j < k {\n\t\t\t\t\tcmax(&dp[i+1][j+1][c+1], dp[i][j][c]+e3*c)\n\t\t\t\t\tcmax(&dp[i+1][j+1][c+e3], dp[i][j][c]+c)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tans := 0\n\tfor _, it := range dp[n][k] {\n\t\tans = max(ans, it)\n\t}\n\tFprintln(out, ans)\n}\n\n//-------------------template------------------\nfunc gcd(a, b int) int {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc maxll(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc rd() (x int) {\n\tinn.Scan()\n\tx, _ = strconv.Atoi(string(inn.Bytes()))\n\treturn x\n}\nfunc rdll() (x int64) {\n\tinn.Scan()\n\tx, _ = strconv.ParseInt(string(inn.Bytes()), 10, 64)\n\treturn x\n}\nfunc rdch() (x byte) {\n\tinn.Scan()\n\treturn inn.Bytes()[0]\n}\nfunc rds() string {\n\tinn.Scan()\n\treturn string(inn.Bytes())\n}\n", "lang_cluster": "Go", "tags": ["strings", "dp"], "code_uid": "0dce0093cb2cfba604ccf046033c0579", "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 check7(A int) bool {\n\treturn A%10 == 7\n}\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\tA, B := sc.NextInt(), sc.NextInt()\n\n\tcnt := 0\n\tfor {\n\t\tif check7(A) || check7(B) {\n\t\t\tfmt.Println(cnt)\n\t\t\treturn\n\t\t}\n\t\tB -= N\n\t\tif B < 0 {\n\t\t\tA--\n\t\t\tA += 24\n\t\t\tA %= 24\n\t\t\tB += 60\n\t\t}\n\t\tcnt++\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", "implementation"], "code_uid": "239a34117ee8a79877578b0a4d64dcff", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,m,a int\n fmt.Scan(&n,&m)\n ans, bus := 1, 0\n for i := 0; i < n; i++ {\n fmt.Scan(&a)\n if (bus+a) <= m {\n bus += a\n } else {\n ans++\n bus = a\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "1dda43a3caa90cb989862414c28dca35", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 337C\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc pow(i int64) int64 {\n\tvar r int64\n\tif i == 1 {\n\t\treturn 2\n\t}\n\tr = pow(i / 2)\n\treturn (r * r * (i%2 + 1)) % 1000000009\n}\nfunc main() {\n\tvar n, m, k, x, y int64\n\tfmt.Scan(&n, &m, &k)\n\tx = n - m - n/k\n\tk %= 1000000009\n\ty = m % 1000000009\n\tif x < 0 {\n\t\ty += ((pow(1-x) + x%1000000009 - 2) * k) % 1000000009\n\t}\n\ty %= 1000000009\n\tif y < 0 {\n\t\ty += 1000000009\n\t}\n\tfmt.Print(y)\n}", "lang_cluster": "Go", "tags": ["math", "binary search", "number theory", "greedy", "matrices"], "code_uid": "09b82834326e9f0a8733ca06b913aaf0", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "\npackage main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nvar a [9]int64\nvar helper SHelper\n\nfunc main() {\n\thelper.Init()\n\n\tfor k := uint64(1); k <= 8; k++ {\n\t\tl := (1 << k) - 1 // shift count type int64, must be unsigned integer\t\t\n\t\tr := 1 << (k - 1)\n\t\tv := l * r\n\t\ta[k] = int64(v)\n\t}\n\n\tn := helper.ReadInt64()\n\tfor k := int64(8); k >= 1; k-- {\n\t\tif n >= a[k] && n % a[k] == 0 {\n\t\t\tfmt.Println(a[k])\n\t\t\treturn\n\t\t}\n\t}\n}\n\ntype SHelper struct {\n\tfile *os.File\n\tscanner *bufio.Scanner\n}\n\nfunc (this *SHelper) Init() {\n\tthis.file = os.Stdin\n\tthis.scanner = bufio.NewScanner(this.file)\n\tthis.scanner.Split(bufio.ScanWords)\n}\n\nfunc (this *SHelper) ReadInt64() int64 {\n\tthis.scanner.Scan()\n\tn, err:= strconv.ParseInt(this.scanner.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "b5046d8ef0c0549f7b7ac8407d673b7d", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.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 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": "fd8e2769afc3f99ea0f1b86b17676d64", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "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)\n\nfunc Solve(io *FastIO) {\n\tA := io.NextInt()\n\tB := io.NextInt()\n\n\tif A + B > 0 && Abs(A - B) <= 1 {\n\t\tio.Println(\"YES\")\n\t} else {\n\t\tio.Println(\"NO\")\n\t}\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\tSolve(&io)\n\tio.FlushOutput()\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "69657ac29ad481231fc9ae9b065c2424", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n, k, x, res int\n var a []int\n\n fmt.Scan(&n, &k, &x)\n\n a = make([]int, n)\n\n for i := 0; i < n; i++ {\n fmt.Scan(&a[i])\n }\n\n for i := 0; i < n - k; i++ {\n res += a[i]\n }\n\n fmt.Print(res + k * x)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cc3fb63412892bf1cd87998ae57be360", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x int\n\tvar k string\n\tm := make(map[string]int, 100000)\n\tmax := 0\n\tsol := \"\"\n\tfmt.Scan(&x,&k)\n\tfor i := 0; i < x-1; i++ {\n\t\ts := \"\" + string(k[i]) + string(k[i+1])\n\t\tif m[s] > 0 {\n\t\t\tm[s] += 1\n\t\t} else {\n\t\t\tm[s] = 1\n\t\t}\n\t\tif max < m[s] {\n\t\t\tmax = m[s]\n\t\t\tsol = s\n\t\t}\n\t}\n\n\tfmt.Println(sol)\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "6877b9505a832f18576cf2003dfc57c3", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n,a,b,x,y int\n\tfmt.Scan(&n,&a,&x,&b,&y)\n\tvis:=make([]int,n+1)\n\tt:=1\n\tfor i:=a;;{\n\t\tvis[i]=t\n\t\tif i==x{\n\t\t\tbreak\n\t\t}\n\t\ti++\n\t\tif i==n+1 {\n\t\t\ti = 1\n\t\t}\n\t\tt++\n\t}\n\n\t//fmt.Println(vis)\n\tt=1\n\tfor i:=b;;{\n\t\tif vis[i]==t{\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\tif(i==y){\n\t\t\tbreak\n\t\t}\n\t\ti--\n\t\tif i==0{\n\t\t\ti=n\n\t\t}\n\n\t\tt++\n\t}\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "4483e12ae963b881ad991f0392d6c8a9", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "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\nvar dp [41][3][3]uint64\nvar t [3][3]uint64\n\nfunc min(a, b uint64) uint64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &t[0][0], &t[0][1], &t[0][2])\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &t[1][0], &t[1][1], &t[1][2])\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &t[2][0], &t[2][1], &t[2][2])\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\", &n)\n\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\tif j == k {\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tl := 3 - j - k\n\t\t\t\t\tdp[i][j][k] = dp[i-1][j][l] + t[j][k] + dp[i-1][l][k]\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][k]+dp[i-1][k][l]+t[j][k]+dp[i-1][l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][l]+t[j][k]+dp[i-1][l][j]+dp[i-1][j][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][k]+dp[i-1][k][l]+t[j][k]+dp[i-1][l][j]+dp[i-1][j][k], dp[i][j][k])\n\n\t\t\t\t\tdp[i][j][k] = min(2*dp[i-1][j][k]+t[j][l]+dp[i-1][k][j]+t[l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*(dp[i-1][j][l]+dp[i-1][l][k])+t[j][l]+dp[i-1][k][j]+t[l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*dp[i-1][j][k]+t[j][l]+dp[i-1][k][l]+dp[i-1][l][j]+t[l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*(dp[i-1][j][l]+dp[i-1][l][k])+t[j][l]+dp[i-1][k][l]+dp[i-1][l][j]+t[l][k], dp[i][j][k])\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", dp[n][0][2])\n}\n", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "23c494c7d8cb0cd9db9aaae7d8c80bb1", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc solve(s, t string) string {\n\t// atomaton\n\tfirst := 0\n\tsecond := 0\n\n\tfor ; first < len(s); first++ {\n\t\tif s[first] == t[second] {\n\t\t\tsecond++\n\t\t}\n\t\tif second == len(t) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif second == len(t) && first <= len(s) {\n\t\treturn \"automaton\"\n\t}\n\n\t// counts\n\tcount_s := make([]int, 26, 26)\n\tcount_t := make([]int, 26, 26)\n\tfor i := 0; i < len(s); i++ {\n\t\tcount_s[s[i]-'a']++\n\t}\n\tfor i := 0; i < len(t); i++ {\n\t\tcount_t[t[i]-'a']++\n\t}\n\n\t// array\n\tarray := true\n\tfor i := 0; i < 26; i++ {\n\t\tif count_t[i] != count_s[i] {\n\t\t\tarray = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif array {\n\t\treturn \"array\"\n\t}\n\n\t// both\n\tboth := true\n\tfor i := 0; i < 26; i++ {\n\t\tif count_t[i] > count_s[i] {\n\t\t\tboth = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif both {\n\t\treturn \"both\"\n\t}\n\n\treturn \"need tree\"\n}\n\nfunc main() {\n\tvar s, t string\n\tfmt.Scan(&s)\n\tfmt.Scan(&t)\n\n\tfmt.Println(solve(s, t))\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "8a353a6334a4964f2d251752f2835d56", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.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 CF1085B(_r io.Reader, _w io.Writer) {\n\tvar n, k int\n\tFscan(_r, &n, &k)\n\tans := int(2e9)\n\tfor i := k - 1; i > 0; i-- {\n\t\tif n%i == 0 {\n\t\t\tif v := n/i*k + i; v < ans {\n\t\t\t\tans = v\n\t\t\t}\n\t\t}\n\t}\n\tFprint(_w, ans)\n}\n\nfunc main() { CF1085B(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "7105a79d6ec14d130470c2d8bf22ad66", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "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(j Jam) {\n\tsize := int32(j.Int())\n\tinfinite := false\n\tsum := int32(0)\n\tprevPrevFigure := int64(0)\n\tprevFigure := int64(0)\n\tfor i := int32(0); i < size; i++ {\n\t\tfigure := j.Int();\n\t\tswitch figure {\n\t\tcase 1: //\tcircle\n\t\t\tswitch prevFigure {\n\t\t\tcase 1:\n\t\t\t\tinfinite = true\n\t\t\tcase 2:\n\t\t\t\tsum += 3\n\t\t\tcase 3:\n\t\t\t\tsum += 4\n\t\t\t}\n\t\tcase 2: //\ttriangle\n\t\t\tswitch prevFigure {\n\t\t\tcase 1:\n\t\t\t\tif prevPrevFigure == 3 {\n\t\t\t\t\tsum += 2\n\t\t\t\t} else {\n\t\t\t\t\tsum += 3\n\t\t\t\t}\n\t\t\tcase 2:\n\t\t\t\tinfinite = true\n\t\t\tcase 3:\n\t\t\t\tinfinite = true\n\t\t\t}\n\t\tcase 3: //\tsquare\n\t\t\tswitch prevFigure {\n\t\t\tcase 1:\n\t\t\t\tsum += 4\n\t\t\tcase 2:\n\t\t\t\tinfinite = true\n\t\t\tcase 3:\n\t\t\t\tinfinite = true\n\t\t\t}\n\t\t}\n\t\tif infinite {\n\t\t\tbreak\n\t\t}\n\n\t\tprevPrevFigure = prevFigure\n\t\tprevFigure = figure\n\t}\n\tif infinite {\n\t\tj.P(\"Infinite\\n\")\n\t} else {\n\t\tj.P(\"Finite\\n\")\n\t\tj.P(\"%d\\n\", sum)\n\t}\n}\n\nfunc main() {\n\tjam, closeFunc := JamNew()\n\tdefer closeFunc()\n\tsolve(jam)\n}\n\ntype Jam interface {\n\tScanner() *bufio.Scanner\n\tWriter() *bufio.Writer\n\tClose()\n\n\tStr() string\n\tInt() int64\n\tFloat() float64\n\n\tP(format string, values ...interface{})\n\tPF(format string, values ...interface{})\n}\n\nfunc JamNew() (Jam, func()) {\n\tif len(os.Args) > 1 {\n\t\tpanic(\"running with input file path is not supported\")\n\t}\n\n\tvar scanner = bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)\n\n\tvar writer = bufio.NewWriter(os.Stdout)\n\tjam := &jam{scanner, writer}\n\treturn jam, jam.Close\n}\n\ntype jam struct {\n\tsc *bufio.Scanner\n\twr *bufio.Writer\n}\n\nfunc (j *jam) Close() {\n\tif err := j.wr.Flush(); err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc (j *jam) Scanner() *bufio.Scanner {\n\treturn j.sc\n}\n\nfunc (j *jam) Writer() *bufio.Writer {\n\treturn j.wr\n}\n\nfunc (j *jam) Str() string {\n\tif !j.sc.Scan() {\n\t\tpanic(\"failed to scan next token\")\n\t}\n\n\treturn j.sc.Text()\n}\n\nfunc (j *jam) Int() int64 {\n\tif !j.sc.Scan() {\n\t\tpanic(\"failed to scan next token\")\n\t}\n\n\tres, err := strconv.ParseInt(j.sc.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t_, _ = fmt.Fprintf(os.Stderr, \"scanned %d\", res)\n\t_ = os.Stderr.Sync()\n\n\treturn res\n}\n\nfunc (j *jam) Float() float64 {\n\tj.sc.Scan()\n\tres, err := strconv.ParseFloat(j.sc.Text(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc (j *jam) P(format string, values ...interface{}) {\n\t_, err := fmt.Fprintf(j.wr, format, values...)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc (j *jam) PF(format string, values ...interface{}) {\n\t_, err := fmt.Fprintf(j.wr, format, values...)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif err = j.wr.Flush(); err != nil {\n\t\tpanic(err)\n\t}\n}", "lang_cluster": "Go", "tags": ["geometry"], "code_uid": "2e2cba592efc48e66a817f97c3ce7da6", "src_uid": "6c8f028f655cc77b05ed89a668273702", "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\t\"sort\"\r\n)\r\n\r\nvar (\r\n\tin = bufio.NewReader(os.Stdin)\r\n)\r\n\r\nfunc main() {\r\n\tvar test int\r\n\t//fmt.Fscan(in, &test)\r\n\ttest = 1\r\n\tfor i := 0; i < test; i++ {\r\n\t\tsolve()\r\n\t}\r\n\r\n}\r\nfunc solve() {\r\n\tvar n, m int64\r\n\tfmt.Fscan(in, &n)\r\n\tfmt.Fscan(in, &m)\r\n\tvar dp = make([]int64, n+1)\r\n\tdp[1] = 1\r\n\tvar currentWays int64 = 1\r\n\tfor i := 2; i <= int(n); i++ {\r\n\t\tdp[i] = currentWays\r\n\t\tfor j := 1; j*j <= i; j++ {\r\n\t\t\t//smaller ocurrance\r\n\t\t\tvar numberOfOccurance = int64(i/j - i/(j+1))\r\n\t\t\tdp[i] += (dp[j] * numberOfOccurance) % m\r\n\t\t\tdp[i] %= m\r\n\t\t\tif j != i/j && j > 1 {\r\n\t\t\t\tdp[i] += dp[i/j]\r\n\t\t\t\tdp[i] %= m\r\n\t\t\t}\r\n\t\t}\r\n\t\tcurrentWays += dp[i]\r\n\t\tcurrentWays %= m\r\n\t}\r\n\tfmt.Println(dp[n])\r\n}\r\n\r\n//x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-TEMPLATE_STARTING-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-\r\n\r\ntype pair struct {\r\n\ta int64\r\n\tb int64\r\n}\r\n\r\nfunc sortPair(pairs []pair) {\r\n\tsort.Slice(pairs, func(i, j int) bool {\r\n\t\treturn pairs[i].a < pairs[j].a\r\n\t})\r\n}\r\nfunc max(a int64, b int64) int64 {\r\n\tif a > b {\r\n\t\treturn a\r\n\t}\r\n\treturn b\r\n}\r\n\r\nfunc printArray(arr []int) {\r\n\tfor i := 1; i < len(arr); i++ {\r\n\t\tfmt.Print(arr[i], \" \")\r\n\t}\r\n\tfmt.Println()\r\n}\r\n\r\ntype runeSort []rune\r\n\r\nfunc (r runeSort) Len() int { return len(r) }\r\nfunc (r runeSort) Swap(i, j int) { r[i], r[j] = r[j], r[i] }\r\nfunc (r runeSort) Less(i, j int) bool { return r[i] < r[j] }\r\n", "lang_cluster": "Go", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "21c217499de9de81b32ec81a7570f40f", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 371B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nvar x, y, k1, k2, ans int\n\nfunc kol(d int) int {\n\tk1 = 0\n\tk2 = 0\n\tfor x%d == 0 {\n\t\tx /= d\n\t\tk1++\n\t}\n\tfor y%d == 0 {\n\t\ty /= d\n\t\tk2++\n\t}\n\tif k1 > k2 {\n\t\treturn k1 - k2\n\t} else {\n\t\treturn k2 - k1\n\t}\n}\n\nfunc main() {\n\tfmt.Scan(&x, &y)\n\tans = kol(2) + kol(3) + kol(5)\n\tif x == y {\n\t\tfmt.Print(ans)\n\t} else {\n\t\tfmt.Print(-1)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "789d639376884782aee19014c292c1d0", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//http://codeforces.com/problemset/problem/146/A\n//A. Lucky Ticket\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tn, i, j, sum int32\n\t\tnum string\n\t)\n\n\tfmt.Scan(&n)\n\tfmt.Scan(&num)\n\n\tislucky := func(c byte) bool { return c == '4' || c == '7' }\n\n\tj = n - 1\n\tfor i < j {\n\t\tif !islucky(num[i]) || !islucky(num[j]) {\n\t\t\tbreak\n\t\t}\n\t\tsum += int32(num[i]) - int32(num[j])\n\t\ti++\n\t\tj--\n\t}\n\n\tif i < j || sum != 0 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "c2ba0475cd46bce0b36c8012f4da31f4", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "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\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][3][3]bool\nvar wave [H][H][3][3][30]bool\nvar t [31]int\nvar n 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][1+m.dx][1+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\t\tif !wave[x1][y1][1+ndx1][1+ndy1][m.w+1] {\n\t\t\twave[x1][y1][1+ndx1][1+ndy1][m.w+1] = 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][m.w+1] {\n\t\t\twave[x2][y2][1+ndx2][1+ndy2][m.w+1] = true\n\t\t\tpush(move{x2, y2, ndx2, ndy2, m.w + 1})\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 < n; 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\tused[x][y][i][j] = false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\twave[Z][Z][0][1][0] = true\n\tpush(move{Z, Z, 0, 1, 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\tfg := false\n\t\t\tfor i := 0; i < 3; i++ {\n\t\t\t\tif fg {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tfor j := 0; j < 3; j++ {\n\t\t\t\t\tif used[x][y][i][j] {\n\t\t\t\t\t\tfg = true\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 fg {\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": "248cb47e2e1fd52b5695bb7cc3e20f4b", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var n1, n2, k1, k2 int\n fmt.Scan(&n1, &n2, &k1, &k2)\n if n1 > n2 {\n fmt.Println(\"First\")\n } else {\n fmt.Println(\"Second\")\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "1ce8f6edc3697ce09964abe1f0db2dbe", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"math\"\n)\n\nfunc main() {\n\tli := make([]int, 5)\n\tsum := 0\n\tfor i := 0 ; i < 5; i++ {\n\t\tfmt.Scanf(\"%d\", &li[i])\n\t\tsum += li[i]\n\t}\n\tsort.Ints(li)\n\tcut := 0.0\n\tfor i:=4; i>= 0; i-- {\n\t\tif i >= 2 && li[i] == li[i-1] && li[i-1] == li[i-2] {\n\t\t\tcut = math.Max(cut, float64(li[i] * 3))\n\t\t}\n\t\tif i >= 1 && li[i] == li[i-1] {\n\t\t\tcut = math.Max(cut, float64(li[i] * 2.0))\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", sum-int(cut))\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "8e425e93e35818041b9e2fd7cb8901ad", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": " package main\n \n import \"fmt\"\n \n func calculate(a,b,c int) int {\n \tif a+b <= c {\n \t\treturn c-(b+a)+1\n \t}\n \treturn 0\n }\n \n func main() {\n \tvar a,b,c int\n \tfmt.Scan(&a,&b,&c)\n \tfmt.Println(calculate(a,b,c) + calculate(a,c,b) + calculate(b,c,a))\n }", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "dc9f498a544bca244b5e44fb88afae9c", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.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\t\"sort\"\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\n\ta := make([]int, n)\n\n\tfor i := range a {\n\t\ta[i] = nextInt()\n\t}\n\n\tsort.Ints(a)\n\t\n\tfor i := range a{\n\t\tprint(a[i], \" \")\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}\n\nfunc print(a ...interface{}) {\n\tfmt.Fprint(writer, a...)\n}", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "1bb70dad2b03e6c2e3710c758a855f7b", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc calc(t, s, v int) int {\n\tt *= 2\n\tt += s * v\n\treturn t\n}\n\nfunc main() {\n\tvar s, v1, v2, t1, t2 int\n\tfmt.Scan(&s, &v1, &v2, &t1, &t2)\n\n\tt := calc(t1, s, v1) - calc(t2, s, v2)\n\n\tswitch {\n\tcase t == 0:\n\t\tfmt.Println(\"Friendship\")\n\tcase t < 0:\n\t\tfmt.Println(\"First\")\n\tcase t > 0:\n\t\tfmt.Println(\"Second\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "55ffd5fae7b59ec69b3b7d4ee620e818", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar r1, r2, c1, c2, d1, d2 int\n\tfound := false\n\tfmt.Scan(&r1, &r2, &c1, &c2, &d1, &d2)\n\tfor i:=1; i<=9; i++ {\n\t\tfor j:=1; j<=9; j++ {\n\t\t\tfor k:=1; k<=9; k++ {\n\t\t\t\tfor l:=1; l<=9; l++ {\n\t\t\t\t\tif i+j==r1 && k+l==r2 && i+k==c1 && j+l==c2 && i+l==d1 && j+k==d2 && different(i, j, k, l) {\n\t\t\t\t\t\tfmt.Println(i, j)\n\t\t\t\t\t\tfmt.Println(k, l)\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t}\n\t\t\t\t\tif (found) {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (found) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (found) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif (found) {\n\t\t\tbreak\n\t\t}\n\t}\n\tif (!found) {\n\t\tfmt.Println(-1)\n\t}\n}\n\nfunc different(a, b, c, d int) bool {\n\tif a==b || a==c || a== d {\n\t\treturn false\n\t}\n\tif b==c || b==d || c== d{\n\t\treturn false\n\t}\n\treturn true\n}", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "4891bb3f6d768b104e280b36c70d11b6", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar n int\nvar sum [60]int\nvar dp [60]int\nvar pie [60]int\n\nfunc main() {\n fmt.Scan(&n)\n for i := n; i >= 1; i-- {\n fmt.Scan(&pie[i])\n }\n for i := 1; i <= n; i++ {\n sum[i] = sum[i-1] + pie[i]\n if dp[i-1] > sum[i-1]-dp[i-1]+pie[i] {\n dp[i] = dp[i-1]\n } else {\n dp[i] = sum[i-1] - dp[i-1] + pie[i]\n }\n }\n fmt.Println(sum[n]-dp[n], dp[n])\n}", "lang_cluster": "Go", "tags": ["dp", "games"], "code_uid": "27529b30a338d39f3513f88c4a872ff5", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.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\t// \"strings\"\r\n\t// \"container/heap\"\r\n\t// \"bytes\"\r\n\t// \"math\"\r\n\t// \"strconv\"\r\n)\r\n\r\nvar r = bufio.NewReader(os.Stdin)\r\nvar w = bufio.NewWriter(os.Stdout)\r\n\r\nvar n,m int\r\nvar k int\r\nvar turn int \r\nconst MOD int64 = 1e9 + 7\r\nvar s,t string\r\nfunc solve(){\r\n\tFscan(r,&n,&m,&k)\r\n\tif n%2==0 && m%2==0{\r\n\t\tif k%2==0{\r\n\t\t\tFprint(w,\"YES\\n\")\r\n\t\t}else{\r\n\t\t\tFprint(w,\"NO\\n\")\r\n\t\t}\r\n\t}else if n%2==1 && m%2==0{\r\n\t\tif (k-m/2)%2==0 && k>=m/2{\r\n\t\t\tFprint(w,\"YES\\n\")\r\n\t\t}else{\r\n\t\t\tFprint(w,\"NO\\n\")\r\n\t\t}\r\n\t}else if n%2==0 && m%2==1{\r\n\t\tif k%2==0 && k<=(m-1)*n/2{\r\n\t\t\tFprint(w,\"YES\\n\")\r\n\t\t}else{\r\n\t\t\tFprint(w,\"NO\\n\")\r\n\t\t}\r\n\t}else{\r\n\t\tFprint(w,\"NO\\n\")\r\n\t}\r\n\r\n\treturn\r\n}\r\n\r\nfunc main(){\r\n\tdefer w.Flush()\r\n\t// Fscan(r,&n,&m)\r\n\t// Fscan(r,&n)\r\n\tFscan(r,&turn)\r\n\t// Fscan(r,&s)\r\n\t// Fscan(r,&k)\r\n\r\n\tfor i:=0;i y {return x};return y}\r\nfunc abs(x int64) int64 {if x > 0 {return x};return -x}\r\nfunc min(x, y int64) int64 {if x < y {return x};return y}\r\nfunc memset(a []int, v int) {\r\n if len(a) == 0 {return}\r\n a[0] = v\r\n for bp := 1; bp < len(a); bp *= 2 {\r\n copy(a[bp:], a[:bp])\r\n }\r\n}\r\n\r\n/* ===========================PART 2: Heap func ============================ */\r\n// type hp struct{ sort.IntSlice }\r\n// func (h hp) Less(i, j int) bool { return h.IntSlice[i] > h.IntSlice[j] }\r\n// func (h *hp) Push(v interface{}) { h.IntSlice = append(h.IntSlice, v.(int)) }\r\n// func (h *hp) Pop() interface{} { a := h.IntSlice; v := a[len(a)-1]; h.IntSlice = a[:len(a)-1]; return v }\r\n\r\n// /* ===========================PART 3: String func ============================ */\r\n// func reverse(a []byte){\r\n// \tfor i,n :=0,len(a);i 0 {\n\t\tswitch cur {\n\t\tcase 1:\n\t\t\tif p12 < p13 {\n\t\t\t\tlength += p12\n\t\t\t\tcur = 2\n\t\t\t} else {\n\t\t\t\tlength += p13\n\t\t\t\tcur = 3\n\t\t\t}\n\t\t\tbreak\n\t\tcase 2:\n\t\t\tif p12 < p23 {\n\t\t\t\tlength += p12\n\t\t\t\tcur = 1\n\t\t\t} else {\n\t\t\t\tlength += p23\n\t\t\t\tcur = 3\n\t\t\t}\n\t\t\tbreak\n\t\tcase 3:\n\t\t\tif p23 < p13 {\n\t\t\t\tlength += p23\n\t\t\t\tcur = 2\n\t\t\t} else {\n\t\t\t\tlength += p13\n\t\t\t\tcur = 3\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tn--\n\t}\n\tfmt.Println(length)\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": "550d43b4f56855305320ed00b99d6b41", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//431C\npackage main\nimport \"fmt\"\n\nfunc main() {\n\tvar nn, kk, dd int\n\tvar x[101][2]int64\n\tconst mod=1000000007\n\tfmt.Scan(&nn, &kk, &dd)\n\tx[0][0]=1\n\tfor i:=1; i<=nn; i++ {\n\t\tfor j:=1; j<=i && j<=kk; j++ {\n\t\t\tif j>=dd {\n\t\t\t\tx[i][1]=(x[i][1]+x[i-j][0]+x[i-j][1])%mod\n\t\t\t} else {\n\t\t\t\tx[i][0]=x[i][0]+x[i-j][0]%mod\n\t\t\t\tx[i][1]=x[i][1]+x[i-j][1]%mod\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(x[nn][1])\n}", "lang_cluster": "Go", "tags": ["dp", "implementation", "trees"], "code_uid": "eee646cf4012502e604b4efcf3ab6922", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar mod uint64 = 1000000007\n\nfunc main() {\n\tvar a, b uint64\n\tfmt.Scanf(\"%d %d\", &a, &b)\n\tsum1 := (b - 1) * b / 2\n\tsum1 = sum1 % mod\n\tsum2 := a * (a + 1) / 2\n\tsum2 = sum2 % mod\n\tsum2 = sum2 * b\n\tsum2 = sum2 % mod\n\tsum := sum1 * (a + sum2)\n\tsum = sum % mod\n\tfmt.Println(sum)\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "7a3a5d3a4c46c490aea2fa6e7cfa0c4c", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.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\tvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\n\tvar k, n, s, p int\n\tfmt.Fscanf(reader, \"%d %d %d %d\", &k, &n, &s, &p)\n\n\t// number of paper sheets each person needs\n\tsheetEach := n / s\n\tif n % s > 0 {\n\t\tsheetEach += 1\n\t}\n\ttotalSheet := sheetEach * k\n\t\n\t// number of packs to buy\n\tpacks := totalSheet / p\n\tif totalSheet % p > 0 {\n\t\tpacks += 1\n\t}\n\n\tfmt.Println(packs)\n}", "lang_cluster": "Go", "tags": ["math"], "code_uid": "347a9daf90b6c24fde011604956646fb", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "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\tvar n string\n\tfmt.Fscan(in, &n)\n\tl := len(n)\n\ti := 0\n\tbin := 0\n\tfor i < l && n[i] < '2' {\n\t\tpow2 := 1 << (l - i - 1)\n\t\tbin += (int(n[i]-'0') * pow2)\n\t\ti++\n\t}\n\toffset := l - i\n\trest := 1<<(offset) - 1\n\tans := bin | rest\n\tfmt.Fprintln(out, ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "3bd158e39c61117be9f9af0e1c637dd3", "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\"sort\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt64()\n\tk := readInt64() - 1\n\tres := []int64{}\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*i < n {\n\t\t\t\tres = append(res, n/i)\n\t\t\t}\n\n\t\t}\n\t}\n\tsort.Sort(int64arr(res))\n\tif int(k) < len(res) {\n\t\tfmt.Println(res[k])\n\t} else {\n\t\tfmt.Println(-1)\n\t}\n}\n\ntype int64arr []int64\n\nfunc (a int64arr) Len() int { return len(a) }\nfunc (a int64arr) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a int64arr) Less(i, j int) bool { return a[i] < a[j] }\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", "number theory"], "code_uid": "0dabe634b2f7ee470ac6e94e8cce099f", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nvar allLuckNumber[] int64\n\nfunc dfs(dep int, number int64, num4, num7 int){\n\tif num4 == num7{\n\t\tallLuckNumber = append(allLuckNumber, number)\n\t}\n\tif dep > 10{\n\t\treturn;\n\t}\n\tdfs(dep + 1, number * 10 + 4, num4 + 1, num7)\n\tdfs(dep + 1, number * 10 + 7, num4, num7 + 1)\n}\n\nfunc main(){\n\tvar n, ans int64\n\tans = math.MaxInt64\n\tdfs(0, 4, 1, 0)\n\tdfs(0, 7, 0 ,1)\n\tfmt.Scan(&n)\n\tfor _,each := range allLuckNumber{\n\t\tif each >= n && each < ans{\n\t\t\tans = each\n\t\t}\n\t}\n\tfmt.Println(ans)\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "binary search", "bitmasks"], "code_uid": "14bb1ebc80e266b19b8fe0047be76d91", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Codeforces 1076 B Divisor Subtraction train\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= 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": "8981a2881c54eea78345e492ad0cbe67", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0, "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)\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": "4c29f022caf7d4a8036bfac7acba26c4", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar num int\nvar temp int\n\nfunc main() {\n fmt.Scan(&num)\n max := -1\n for i := 0; i < num; i++ {\n fmt.Scan(&temp)\n if temp > max {\n max = temp\n }\n }\n if max > 25 {\n fmt.Println(max - 25)\n } else {\n fmt.Println(0)\n }\n}", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "ac9118a88b16075ca889111e485ba86a", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0, "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 max(a, b int64) int64 {\n if a > b {\n return a\n } else {\n return b\n }\n}\n\nfunc check(v, r, g, b int64) bool {\n if r+g+b < 3 {\n return false\n }\n\n a := make([]int, 3)\n a[0] = int(r)\n a[1] = int(g)\n a[2] = int(b)\n sort.Ints(a)\n r = int64(a[0]) // min\n g = int64(a[1])\n b = int64(a[2]) //max\n\n if b >= v {\n if b >= 2*v {\n return r+g >= v\n } else {\n b -= v\n return r+g+b >= v\n }\n } else {\n return false\n }\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n var min, max, mid, a int64\n r := ReadInt64()\n g := ReadInt64()\n b := ReadInt64()\n min = 0\n a = 0\n max = (r + g + b) / 3\n for min < max {\n // print(mid)\n // print(\" \")\n // println(check(mid, r, g, b))\n mid = (max + min) / 2\n if check(mid, r, g, b) {\n a = mid\n min = mid + 1\n } else {\n max = mid\n }\n }\n\n if check(min, r, g, b) {\n writer.WriteString(strconv.FormatInt(min, 10) + \"\\n\")\n } else {\n writer.WriteString(strconv.FormatInt(a, 10) + \"\\n\")\n }\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "6c8b0ef178fb0f8e4c4e601acf14cea0", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\ntype pair struct {\n\tlocation int\n\tdist 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, m+2)\n\n\t\tqueue := make([]pair, 1)\n\t\tqueue[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 := queue[0]\n\t\t\tqueue = queue[1:]\n\t\t\t// copy(queue[0:len(queue)-1], queue[1:])\n\n\t\t\tif tmp.location == m { // reached destination\n\t\t\t\tans = tmp.dist\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t// adist neighbors to the queue\n\t\t\tif tmp.location*2 <= m+1 && visited[tmp.location*2] == false {\n\t\t\t\tqueue = append(queue, pair{tmp.location * 2, tmp.dist + 1})\n\t\t\t\tvisited[tmp.location*2] = true\n\t\t\t}\n\t\t\tif tmp.location-1 >= 0 && visited[tmp.location-1] == false {\n\t\t\t\tqueue = append(queue, pair{tmp.location - 1, tmp.dist + 1})\n\t\t\t\tvisited[tmp.location-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": "a44e8f5bc133bbb25a1255f7d6aaab92", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "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": "811c21b5500aa8614e45be9c9571e82d", "src_uid": "579021de624c072f5e0393aae762117e", "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\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(bufout, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(bufin, f, a...) }\n\n/*\nf(x) = 2*x - .5\n4*x - 1.5\n2^(n+1) x - (2^n - 1)\n*/\n\nconst M = 1000000007\n\nfunc main() {\n\tdefer bufout.Flush()\n\tvar N, K uint64\n\tscanf(\"%d%d\", &N, &K)\n\tif N == 0 {\n\t\tprintf(\"0\\n\")\n\t\treturn\n\t}\n\tN = (2*N - 1) % M\n\tz := getx(K)\n\tprintf(\"%d\\n\", (int64(z)*int64(N)+1)%M)\n}\n\nfunc getx(N uint64) int {\n\tif N < 30 {\n\t\treturn 1 << N\n\t}\n\tif N%2 == 0 {\n\t\tY := getx(N >> 1)\n\t\treturn int(int64(Y) * int64(Y) % M)\n\t}\n\treturn getx(N-1) * 2 % M\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "e37d1419de134f39c1d1671bbd11bbb9", "src_uid": "e0e017e8c8872fc1957242ace739464d", "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\"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\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\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\n\tif n > 1 {\n\t\tvar answer int64\n\t\tanswer = 1\n\t\tvar mm int64\n\t\tmm = 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 - mm) % 998244353\n\t\t\tmm = 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": "0decba5322f24674e3899e2838bb27c1", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.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\ntype TupleInt struct {\n\tfirst int\n\tsecond int\n\tthird int\n}\n\nfunc main() {\n\tin := NewScanner()\n\t_ = in.NextInt()\n\tS := in.NextLine()\n\tinside := false\n\tmx := 0\n\tcount := 0\n\tcomma := false\n\tln := 0\n\tfor _, s := range S {\n\t\tif s == '(' {\n\t\t\tinside = true\n\t\t\tcomma = true\n\t\t} else if s == ')' {\n\t\t\tinside = false\n\t\t\tcomma = true\n\n\t\t} else if s == '_' {\n\t\t\tcomma = true\n\t\t} else {\n\t\t\tif !inside {\n\t\t\t\tln++\n\t\t\t\tmx = max(mx, ln)\n\t\t\t}\n\n\t\t\tif comma {\n\t\t\t\tif inside {\n\t\t\t\t\tcount++\n\t\t\t\t}\n\t\t\t\tcomma = false\n\t\t\t}\n\t\t}\n\t\tif comma {\n\t\t\tln = 0\n\t\t}\n\n\t}\n\tfmt.Println(mx, count)\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}\n\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\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); 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}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif 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\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\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": ["expression parsing", "strings", "implementation"], "code_uid": "ed83875f31e89abaa6790b5e12c52808", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar m, n uint64\n\tfmt.Scan(&n, &m)\n\n\tif n > 31 {\n\t\tn = uint64(31)\n\t}\n\n\tpow := uint64(2) << (n - 1)\n\n\tfmt.Println(m % pow)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "5e23bd3e1334c8306cddf9efc94454d0", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc readText() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc printText(text string) {\n\twriter.WriteString(text)\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\t// letters := []string{\"A\", \"B\", \"C\"}\n\tstr := readText()\n\t// printText(str)\n\n\tstr_len := len(str)\n\tfor i, _ := range str {\n\t\tif i < str_len-2 {\n\t\t\tl1 := str[i]\n\t\t\tl2 := str[i+1]\n\t\t\tl3 := str[i+2]\n\n\t\t\tif (l1 == 'A' && l2 == 'B' && l3 == 'C') ||\n\t\t\t\t(l1 == 'A' && l2 == 'C' && l3 == 'B') ||\n\t\t\t\t(l1 == 'B' && l2 == 'A' && l3 == 'C') ||\n\t\t\t\t(l1 == 'B' && l2 == 'C' && l3 == 'A') ||\n\t\t\t\t(l1 == 'C' && l2 == 'A' && l3 == 'B') ||\n\t\t\t\t(l1 == 'C' && l2 == 'B' && l3 == 'A') {\n\t\t\t\tprintText(\"Yes\")\n\t\t\t\tgoto a1\n\t\t\t}\n\t\t}\n\t}\n\n\tprintText(\"No\")\na1:\n}\n", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "4c937731482a97212921f391973204cc", "src_uid": "ba6ff507384570152118e2ab322dd11f", "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\tvar s string\n\tfmt.Scan(&n, &s)\n\tfor i := 1; i < n; i++ {\n\t\tif s[i - 1] == s[i] && s[i] != '?' {\n\t\t\tfmt.Print(\"No\")\n\t\t\treturn\n\t\t}\n\t}\n\tif s[0] == '?' || s[n - 1] == '?' {\n\t\tfmt.Print(\"Yes\")\n\t\treturn\n\t}\n\tfor i := 1; i < n; i++ {\n\t\tif s[i - 1] == '?' && s[i] == '?' {\n\t\t\tfmt.Print(\"Yes\")\n\t\t\treturn\n\t\t}\n\t}\n\tfor i := 1; i < n - 1; i++ {\n\t\tif s[i] == '?' && s[i - 1] == s[i + 1] {\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": ["implementation"], "code_uid": "e106119a32fdd924bf30c050540240f9", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "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 gcd(a int, b int) int {\n\tif a < b {\n\t\treturn gcd(b, a)\n\t} else if b == 0 {\n\t\treturn a\n\t} else {\n\t\treturn gcd(b, a%b)\n\t}\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tvar dice1, dice2 int\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tfmt.Sscanf(line, \"%d %d\", &dice1, &dice2)\n\n\t\tmaxDice := dice2\n\t\tif dice1 > dice2 {\n\t\t\tmaxDice = dice1\n\t\t}\n\n\t\tpossibleWin := 6 - maxDice + 1\n\n\t\tdivisor := gcd(6, possibleWin)\n\n\t\ttop := possibleWin / divisor\n\t\tbottom := 6 / divisor\n\n\t\tfmt.Printf(\"%d/%d\", top, bottom)\n\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "probabilities"], "code_uid": "fbca4fede9277072a76abb89c1cc146a", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar x,y,p int\n\tfmt.Scan(&x,&y)\n\tif y>x && x>=-y {\n\t\tp=-2+y*4\n\t}\n\tif y>=x && x<(-y) {\n\t\tp=-1+4*-x\n\t}\n\tif x>y && -x+1>=y {\n\t\tp=-y*4\n\t}\n\tif x>=y && -x+1= maxv {return 0}\r\n\t\tif v,ok := m[x];ok {return v}\r\n\t\tm[x] = INF\r\n\t\tres := m[x]\r\n\t\ts := x\r\n\t\tfor s != 0 {\r\n\t\t\ty := s % 10\r\n\t\t\ts /= 10\r\n\t\t\tif y >= 2 {\r\n\t\t\t\tres = min(res,1 + dfs(x * y))\r\n\t\t\t}\r\n\t\t}\r\n\t\tm[x] = res\r\n\t\treturn res\r\n\t}\r\n\tres := dfs(x)\r\n\tif res == INF {\r\n\t\tres = -1\r\n\t}\r\n\tfmt.Println(res)\r\n}\r\n", "lang_cluster": "Go", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "0c655a6037495c6bd99bf4c27eca0961", "src_uid": "cedcc3cee864bf8684148df93804d029", "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\nconst Mod = 998244353\n\nfunc main() {\n\tdefer _w.Flush()\n\tsolve()\n}\nfunc solve() {\n\tn, x := ReadInt(), ReadInt()\n\n\tvar pow [501][501]int64\n\tfor i := int64(0); i < 501; i++ {\n\t\tpow[i][0] = 1\n\t\tfor j := 0; j < 500; j++ {\n\t\t\tpow[i][j+1] = pow[i][j] * i % Mod\n\t\t}\n\t}\n\n\tvar dp [501][501]int64\n\tfor i := 2; i <= n; i++ {\n\t\tjj := Min(x, i-1)\n\t\tfor j := 1; j <= jj; j++ {\n\t\t\t// dp[i][j] = j^i - (j-1)^i\n\t\t\tdp[i][j] = pow[j][i] - pow[j-1][i]\n\t\t\tdp[i][j] %= Mod\n\t\t}\n\t}\n\n\tfor i := 2; i <= n; i++ {\n\t\tfor j := 1; j <= x; j++ {\n\t\t\tif dp[i][j] == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor k := 0; k <= n-i; k++ {\n\t\t\t\tnj := j + i + k - 1\n\t\t\t\tif nj > x {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdp[i+k][nj] += dp[i][j] * pow[i+k-1][k] % Mod * ModCombination(i+k, k)\n\t\t\t\tdp[i+k][nj] %= Mod\n\t\t\t}\n\t\t}\n\t}\n\n\tans := int64(0)\n\tfor j := 1; j <= x; j++ {\n\t\tans += dp[n][j]\n\t\tans %= Mod\n\t}\n\tprintln(((ans % Mod) + Mod) % Mod)\n}\n\nfunc ModCombination(n, k int) (ret int64) {\n\tif n < k {\n\t\treturn 0\n\t}\n\tfor ret = 1; n > 0 || k > 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 int) int {\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": "c341700583183bbaa01403d25a6731bd", "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\nfunc main() {\n\n\treader := bufio.NewReader(os.Stdin)\n\tvar n, k, d, t int\n\n\tfmt.Fscanf(reader, \"%d\\n\", &t)\n\tfor ; t > 0; t-- {\n\t\tfmt.Fscanf(reader, \"%d %d %d\\n\", &n, &k, &d)\n\n\t\ta := make([]int, n+1)\n\t\tfor i := 1; i <= n; i++ {\n\t\t\tif i == n {\n\t\t\t\tfmt.Fscanf(reader, \"%d\\n\", &a[i])\n\t\t\t} else {\n\t\t\t\tfmt.Fscanf(reader, \"%d\", &a[i])\n\t\t\t}\n\t\t}\n\n\t\tset := make(map[int]int)\n\t\tans := 0\n\t\tfor i := 1; i <= d; i++ {\n\t\t\tk, v := set[a[i]]\n\t\t\tif v == false {\n\t\t\t\tans++\n\t\t\t}\n\t\t\tset[a[i]] = k + 1\n\t\t}\n\n\t\ttemp := ans\n\t\tfor i := d + 1; i <= n; i++ {\n\t\t\tk, _ := set[a[i-d]]\n\t\t\tif k > 1 {\n\t\t\t\tset[a[i-d]] = k - 1\n\t\t\t} else {\n\t\t\t\tdelete(set, a[i-d])\n\t\t\t\ttemp--\n\t\t\t}\n\n\t\t\tk, v := set[a[i]]\n\t\t\tif v == false {\n\t\t\t\ttemp++\n\t\t\t}\n\t\t\tset[a[i]] = k + 1\n\n\t\t\tif temp < ans {\n\t\t\t\tans = temp\n\t\t\t}\n\t\t}\n\n\t\tfmt.Println(ans)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "c0ead31521f91751360ed4979a399722", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scanf(\"%v %v\", &n, &k)\n\tif ((n%(int64(2)*k)) >= k) {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["math", "games"], "code_uid": "4c8236648777824452fcbad925d25d75", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\ta := []rune(s)\n\twords := make(map[string]string)\n\tfor i := 0; i < len(a); i++ {\n\t\tword := string(a[i:]) + string(a[:i])\n\t\t_, ok := words[word]\n\t\tif ok {\n\t\t\t// key already exists, therefore done \n\t\t\tbreak\n\t\t} else {\n\t\t\t// key does not exist, add key\n\t\t\twords[word] = word\n\t\t}\n\t}\n\tfmt.Println(len(words))\n}", "lang_cluster": "Go", "tags": ["strings", "implementation"], "code_uid": "0ede26c6290c95adc0a84143952b8271", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.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 = 1e6\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 = (ans + C(n/i-1, k-1)) % mod\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF1359E(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "combinatorics", "number theory"], "code_uid": "e2c4c5564b3d607c7b7b80ad56560bd7", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc next_permutation(idx []int) bool {\n\tn := len(idx)\n\tfor i := n - 1; i >= 1; i-- {\n\t\tif idx[i] > idx[i-1] {\n\t\t\tidx[i], idx[i-1] = idx[i-1], idx[i]\n\t\t\tsort.Ints(idx[i:])\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\tvar n, a, b int\n\tfmt.Scanf(\"%d\\n%d\\n%d\", &n, &a, &b)\n\tframes := make([]int, 6)\n\tidxs := make([]int, 6)\n\tfor i := 0; i < 6; i++ {\n\t\tif i < 4 {\n\t\t\tframes[i] = a\n\t\t} else {\n\t\t\tframes[i] = b\n\t\t}\n\t\tidxs[i] = i\n\t}\n\n\tbestAnswer := 6\n\tfor {\n\t\tcount, leftover := 0, 0\n\t\tfor i := 0; i < 6; i++ {\n\t\t\tif leftover < frames[idxs[i]] {\n\t\t\t\tcount++\n\t\t\t\tleftover = n\n\t\t\t}\n\t\t\tleftover -= frames[idxs[i]]\n\t\t}\n\t\tif count < bestAnswer {\n\t\t\tbestAnswer = count\n\t\t}\n\t\tif !next_permutation(idxs) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfmt.Println(bestAnswer)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "d8060a1cb3f10e9350605d905151a3bc", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.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\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nconst debug = false\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tn := gsli(reader)[0]\n\ts := gsls(reader)[0]\n\n\tmax := 0\n\n\tfor i := 0; i < n; i++ {\n\t\tif isl(s[i]) {\n\t\t\tcur := 1\n\t\t\tdbg(\"%v is lowercase\\n\", s[i])\n\t\t\tfor j := i; j < n; j++ {\n\t\t\t\tif s[i] == s[j] {\n\t\t\t\t\tdbg(\"Continuing...\\n\")\n\t\t\t\t\tcontinue\n\t\t\t\t} else if !isl(s[j]) {\n\t\t\t\t\tdbg(\"Uppercase...\\n\")\n\t\t\t\t\tbreak\n\t\t\t\t} else {\n\t\t\t\t\tdoIncrement := true\n\t\t\t\t\tfor k := i; k < j; k++ {\n\t\t\t\t\t\tif s[k] == s[j] {\n\t\t\t\t\t\t\tdoIncrement = false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif doIncrement {\n\t\t\t\t\t\tdbg(\"Incrementing...\\n\")\n\t\t\t\t\t\tcur++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tmax = maxInt(max, cur)\n\t\t}\n\t}\n\n\tfmt.Printf(\"%v\", max)\n}\n\nfunc isl(b byte) bool {\n\tvar r rune\n\tr = rune(b)\n\treturn unicode.IsLower(r)\n}\n\nfunc maxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\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\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", "strings", "implementation"], "code_uid": "8a91ef57fb67aae83bd855b7df15fa74", "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 x, y, n int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &x, &y); err != nil {\n\t\treturn\n\t}\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tan := fn(x, y, n)\n\tif an < 0 {\n\t\tfmt.Println((1000000007 - (-an % 1000000007)) % 1000000007)\n\t} else {\n\t\tfmt.Println(an % 1000000007)\n\t}\n}\n\nfunc fn(x, y, n int) int {\n\tif n == 1 {\n\t\treturn x\n\t} else if n == 2 {\n\t\treturn y\n\t} else if n == 3 {\n\t\treturn y - x\n\t} else { // n > 3\n\t\thead := [3]int{y - x, x, y}\n\t\tpos := n % 3\n\t\tsign := 1\n\t\tif ((n-1)/3)%2 != 0 {\n\t\t\tsign = -1\n\t\t}\n\t\treturn head[pos] * sign\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "418c19c1bb719bcedb04a8ecab3aa4d1", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "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\"time\"\n\t\"unicode/utf8\"\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\n//two functions from go source:\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\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}\n\nfunc main() {\n\n\tw = bufio.NewWriter(os.Stdout)\n\tsc = bufio.NewScanner(os.Stdin)\n\tsc.Split(ScanWords)\n\ttyme1, tyme2 := time.Date(nextInt(), time.Month(nextInt()), nextInt(), 0, 0, 0, 0, time.UTC),\n\t\ttime.Date(nextInt(), time.Month(nextInt()), nextInt(), 0, 0, 0, 0, time.UTC)\n\tans := int(tyme2.Sub(tyme1).Hours() / 24)\n\tif ans < 0 {\n\t\tans = -ans\n\t}\n\tprintInt(ans)\n\tw.Flush()\n\t//YOU FORGOT TO FLUSH!\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "69d7df0cb70dbb7a51ff544df3572234", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "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 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 a int\n\tfor I(&a) == nil {\n\t\tsolve(a)\n\t}\n}\n\nfunc solve(a1 int) {\n\tvar a2, a3, b1, b2, b3, n int\n\tI(&a2, &a3, &b1, &b2, &b3, &n)\n\ta := a1 + a2 + a3\n\tb := b1 + b2 + b3\n\toa := a / 5\n\tif a%5 != 0 {\n\t\toa++\n\t}\n\tob := b / 10\n\tif b%10 != 0 {\n\t\tob++\n\t}\n\tif n >= oa+ob {\n\t\tO(\"YES\", \"\\n\")\n\t} else {\n\t\tO(\"NO\", \"\\n\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "05e3d544f35c42d45ed0026aee64192e", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "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\t_ = readInt()\n\tk := readInt()\n\tcnt := map[rune]int{}\n\tfor _, v := range readString() {\n\t\tcnt[v]++\n\t}\n\tfor _, v := range cnt {\n\t\tif v > k {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\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", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "39eac7d75e4c72a5548fcbc26be9fd63", "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\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1097B(_r io.Reader, out io.Writer) {\n\tin := bufio.NewReader(_r)\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\tf := func(sub int) (res int) {\n\t\tfor i, v := range a {\n\t\t\tif sub>>i&1 == 0 {\n\t\t\t\tres += v\n\t\t\t} else {\n\t\t\t\tres -= v\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tfor sub := 0; sub < 1<= 0 {\n\t\t\t\tif tmp2 <= co1+co2 {\n\t\t\t\t\tsum := i + j\n\t\t\t\t\tif res1 > sum {\n\t\t\t\t\t\tres1 = sum\n\t\t\t\t\t}\n\t\t\t\t\tif res2 < sum {\n\t\t\t\t\t\tres2 = sum\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Fprint(writer, res1, \" \", res2)\n}\n\nfunc nextWord() string {\n\tscan.Scan()\n\tstr := scan.Text()\n\treturn str\n}\n\nfunc nextInt() int {\n\ti, e := strconv.Atoi(nextWord())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "3ca89ef88d99163d7f2c863d47564d66", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/787/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\ta, b, c, d int\n)\n\nfunc main() {\n\ta, b, c, d = ReadInt4()\n\n\tfor i := 0; i <= 3000; i++ {\n\t\tfor j := 0; j <= 3000; j++ {\n\t\t\tif b+i*a == d+j*c {\n\t\t\t\tfmt.Println(b + i*a)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\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": ["brute force", "math", "number theory"], "code_uid": "a8d82fdfff268e0a44bebdb5667ca61a", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tp := [6]int{}\n\tsum := 0\n\tfor i := 0; i < 6; i++ {\n\t\tfmt.Scanf(\"%d\", &p[i])\n\t\tsum += p[i]\n\t}\n\n\tif sum%2 != 0 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tneeded := sum >> 1\n\tfor i := 0; i < 6; i++ {\n\t\tfor j := i + 1; j < 6; j++ {\n\t\t\tfor k := j + 1; k < 6; k++ {\n\t\t\t\tif p[i]+p[j]+p[k] == needed {\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}\n\t}\n\n\tfmt.Println(\"NO\")\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "d7656440127d1b91786fa1ca10b5a1d5", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport(\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a,b,c int\n\tfmt.Scan(&a,&b,&c)\n\tif a < b{\n\t\ta, b = b, a\n\t}\n\tif c > a - b{\n\t\tfmt.Println((a+b+c)/2*2)\n\t}else{\n\t\tfmt.Println((b+c)*2)\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "6bd82dc45cd22ddceea9f4bd818ff6d6", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar mod int64 = 1000000007\n\nfunc main() {\n var n, m, k int64\n fmt.Scan(&n)\n fmt.Scan(&m)\n fmt.Scan(&k)\n if k > n {\n fmt.Println(pow(m, n))\n } else if k == n {\n fmt.Println(pow(m, (n + 1) / 2))\n } else if k == 1 {\n fmt.Println(pow(m, n))\n } else if k % 2 == 0 {\n fmt.Println(m)\n } else if k % 1 == 0 {\n fmt.Println(pow(m, 2))\n }\n return\n}\n\nfunc pow(a, b int64) int64 {\n var ans int64 = 1\n for; b > 0; b-- {\n ans = ans * a % mod\n }\n return ans\n}", "lang_cluster": "Go", "tags": ["dfs and similar", "math", "combinatorics", "graphs"], "code_uid": "b05acbcbf6c2ffa38e01502436d649cc", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.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 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, k := 2, n/i; j <= k; 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": "62ec81a21808fd04cca5c43c177d094c", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\nimport \"math\"\n\nfunc main(){\n\tvar n, k 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\tk, _ = strconv.Atoi(r.Text())\n\tflag, flag1 := false, false\n\tt, count := 0, 0\n\tvar a [1000]int\n\tfor i:=2; i<=n; i++ {\n\t\tflag = false\n\t\tfor j:=2; j<=int(math.Sqrt(float64(i))); j++ {\n\t\t\tif i%j == 0 {\n\t\t\t\tflag = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif flag == false {\n\t\t\tt += 1\n\t\t\ta[t] = i\n\t\t}\n\t}\n\tfor i:=0; i d {\n\t\t\tbreak\n\t\t}\n\t\tans = p - p%t\n\t}\n\tfmt.Print(ans - 1)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "8ef7499785a122414e59dc2206ea1ec6", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.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.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nconst mod = 998244353\nconst N = 2\nvar n, m, L, R int\n\ntype matrix struct {\n\tf[N][N] int64\n}\n\nfunc print_out(a matrix) {\n\tfor i := 0; i < N; i++ {\n\t\tfor j := 0; j < N; j++ {\n\t\t\tfmt.Fprintf(writer, \"%d \", a.f[i][j])\n\t\t}\n\t\tfmt.Fprintf(writer, \"\\n\")\n\t}\n}\n\nfunc mul(a matrix, b matrix) matrix {\n\tvar c = matrix{}\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\tc.f[i][j] += a.f[i][k] * b.f[k][j]\n\t\t\t\tc.f[i][j] %= mod\n\t\t\t}\n\t\t}\n\t}\n\treturn c\n}\n\nfunc pw(a matrix, b int64) matrix {\n\tvar ret = matrix{}\n\tfor i := 0; i < N; i++ {\n\t\tret.f[i][i] = 1\n\t}\n\n\tfor b > 0 {\n\t\tif (b & 1) == 1 {\n\t\t\tret = mul(ret, a)\n\t\t\tb--\n\t\t} else {\n\t\t\ta = mul(a, a)\n\t\t\tb /= 2\n\t\t}\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tfmt.Fscanf(reader, \"%d %d %d %d\", &n, &m, &L, &R)\n\n\tvar O = int64(R - L + 1) / 2\n\tvar E = int64(R - L + 1) / 2\n\tif (R - L + 1) % 2 != 0 {\n\t\tif L%2 == 0 {\n\t\t\tE++\n\t\t} else {\n\t\t\tO++\n\t\t}\n\t}\n\n\tvar T = int64(n) * int64(m)\n\n\tvar mt = matrix{}\n\tmt.f[0][0] = E\n\tmt.f[0][1] = O\n\tmt.f[1][0] = O\n\tmt.f[1][1] = E\n\n\t//print_out(mt)\n\n\tmt = pw(mt, T - 1)\n\n\t//print_out(mt)\n\n\tvar dp_odd = O\n\tvar dp_evn = E\n\n\tvar fn_dp_odd = mt.f[0][0] * dp_odd % mod + mt.f[1][0] * dp_evn % mod\n\tfn_dp_odd %= mod\n\n\tvar fn_dp_evn = mt.f[1][0] * dp_odd % mod + mt.f[1][1] * dp_evn % mod\n\tfn_dp_evn %= mod\n\n\tvar ret int64\n\tif T % 2 == 1 {\n\t\tret = (fn_dp_odd + fn_dp_evn) % mod\n\t} else {\n\t\tret = fn_dp_evn\n\t}\n\n\tfmt.Fprintf(writer, \"%d\", ret)\n}\n", "lang_cluster": "Go", "tags": ["math", "matrices", "constructive algorithms", "combinatorics"], "code_uid": "8af8c138f33044dd6d2d50224686f7aa", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a,b,c,d,e,f int\n\tfmt.Scan(&a,&b,&c)\n\td=(a+b-c)/2\n\te=(b+c-a)/2\n\tf=(a+c-b)/2\n\tif ((a+b+c)%2!=0) || ((a+b) res {\n\t\t\t\ta[j] = res\n\t\t\t}\n\t\t}\n\t}\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tans += a[i] * a[i]\n\t}\n\t//fmt.Println(odd1, odd2, even1, even2)\n\tfmt.Fprintf(out, \"%d\\n\", ans)\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": ["implementation"], "code_uid": "fbd04bc8cf4f70f6e7f268cc14ca68b1", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.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 a, b, ans int\n fmt.Fscan(scanner, &a, &b)\n if a > b {\n a, b = b, a\n }\n \n for a > 0 && b > 1 {\n a--\n b -= 2\n ans++\n if a > b {\n a, b = b, a\n }\n }\n writer.WriteString(strconv.Itoa(ans))\n writer.Flush()\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "fda47e816998c9de754f8fea30326f80", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc numberOfMoves(x1, y1, x2, y2 int) int {\n\tdiffX := math.Abs(float64(x1 - x2))\n\tdiffY := math.Abs(float64(y1 - y2))\n\treturn int(math.Max(diffX, diffY))\n}\n\nfunc main() {\n\tvar x1, y1, x2, y2 int\n\tfmt.Scan(&x1, &y1, &x2, &y2)\n\tfmt.Println(numberOfMoves(x1, y1, x2, y2))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "fbba16d2a5d994c8f428ced7aa37a175", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "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\tin = bufio.NewReader(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\tdefer out.Flush()\n\tvar n uint\n\tfmt.Fscan(in, &n)\n\tans := make([]int, 0)\n\tfor i := 20; i >= 0; i-- {\n\t\tif (n>>uint(i))&1 == 1 {\n\t\t\tans = append(ans, i+1)\n\t\t}\n\t}\n\tfor i, x := range ans {\n\t\tif i != 0 {\n\t\t\tfmt.Fprint(out, \" \")\n\t\t}\n\t\tfmt.Fprint(out, x)\n\t}\n\tfmt.Fprintln(out)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "af2e969a7e9cf5d628d9f586487685b2", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n \"sort\"\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 writer *bufio.Writer\nvar best int = -1\nvar g [][]int\nvar numRows, numCols int\n\nfunc permute(i int) {\n if i == numCols {\n xs := make([]int, numRows)\n for i := range g {\n x := 0\n for _, d := range g[i] {\n x = 10*x + d\n }\n xs[i] = x\n }\n sort.Ints(xs)\n diff := xs[numRows-1] - xs[0]\n if best == -1 || diff < best {\n best = diff\n }\n } else {\n permute(i+1)\n for j := i+1; j < numCols; j++ {\n for k := range g {\n g[k][i], g[k][j] = g[k][j], g[k][i]\n }\n permute(i+1)\n for k := range g {\n g[k][i], g[k][j] = g[k][j], g[k][i]\n }\n }\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 numRows, numCols = getI(), getI()\n g = make([][]int, numRows)\n for i := range g {\n s := getS()\n g[i] = make([]int, numCols)\n for j := range g[i] {\n g[i][j] = int(s[j]-'0')\n }\n }\n permute(0)\n\n writer.WriteString(fmt.Sprintf(\"%d\\n\", best))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation", "combinatorics"], "code_uid": "35a6b4b08b9a52785e67fea84d2ab034", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0, "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 (prob Prob) Solve() {\n h1 := prob.NextInt()\n m1 := prob.NextInt()\n h2 := prob.NextInt()\n m2 := prob.NextInt()\n df := ((h2 - h1) * 60 + m2 - m1) / 2\n m1 += df\n h1 += m1 / 60\n m1 %= 60\n fmt.Printf(\"%02d:%02d\\n\", h1, m1)\n}\n\n\nfunc main() {\n Prob{in: bufio.NewReader(os.Stdin)}.Solve()\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "15fd0a3c2be2cffa88b52983bc03b1de", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar k int\n\tfmt.Scan(&n, &k)\n\tvar data = make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&data[i])\n\t}\n\n\tvar cnt = 0\n\tfor i := 0; i < n; i++ {\n\t\tif data[i] > k {\n\t\t\tbreak\n\t\t} else {\n\t\t\tcnt++\n\t\t}\n\n\t}\n\n\tfor i := n - 1; i >= 0; i-- {\n\t\tif data[i] > k {\n\t\t\tbreak\n\t\t} else {\n\t\t\tcnt++\n\t\t}\n\t}\n\n\tif cnt > n {\n\t\tcnt /= 2\n\t}\n\tfmt.Println(cnt)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "6ca7c30eecd6b52289730092414441b6", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "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 CF735D(_r io.Reader, _w io.Writer) {\n\tisP := func(n int) bool {\n\t\tfor i := 2; i*i <= n; i++ {\n\t\t\tif n%i == 0 {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\n\tvar n int\n\tif Fscan(_r, &n); isP(n) {\n\t\tFprint(_w, 1)\n\t} else if n%2 == 0 || isP(n-2) {\n\t\tFprint(_w, 2)\n\t} else {\n\t\tFprint(_w, 3)\n\t}\n}\n\nfunc main() { CF735D(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "092788e9eddeae3f8493260d65bb1032", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.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 CF1557C(in io.Reader, out io.Writer) {\r\n\tconst mod int64 = 1e9 + 7\r\n\tpow := func(x int64, n int) (res int64) {\r\n\t\tres = 1\r\n\t\tfor ; n > 0; n >>= 1 {\r\n\t\t\tif n&1 > 0 {\r\n\t\t\t\tres = res * x % mod\r\n\t\t\t}\r\n\t\t\tx = x * x % mod\r\n\t\t}\r\n\t\treturn\r\n\t}\r\n\tp2 := [2e5]int64{1}\r\n\tfor i := 1; i < 2e5; i++ {\r\n\t\tp2[i] = p2[i-1] << 1 % mod\r\n\t}\r\n\r\n\tvar T, n, k int\r\n\tfor Fscan(in, &T); T > 0; T-- {\r\n\t\tFscan(in, &n, &k)\r\n\t\tif n&1 > 0 {\r\n\t\t\tFprintln(out, pow(p2[n-1]+1, k))\r\n\t\t} else {\r\n\t\t\tans := int64(1)\r\n\t\t\tfor i := 0; i < k; i++ {\r\n\t\t\t\tans = (pow(p2[i], n) + (p2[n-1]-1)*ans) % mod\r\n\t\t\t}\r\n\t\t\tFprintln(out, ans)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunc main() { CF1557C(os.Stdin, os.Stdout) }\r\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "ada605679cd547db7233ee58336557d5", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar rotate = [][]int{\n\t{5, 6, 17, 18, 21, 22, 13, 14},\n\t{7, 8, 19, 20, 23, 24, 15, 16},\n\t{3, 4, 19, 20, 23, 24, 15, 16},\n\t{1, 2, 18, 20, 12, 11, 15, 13},\n\t{2, 4, 6, 8, 10, 12, 23, 21},\n\t{1, 3, 5, 7, 9, 11, 24, 22}}\n\nfunc main() {\n\tvar cube = make([]int, 24)\n\tfor i := 0; i < 24; i++ {\n\t\tfmt.Scanf(\"%d\", &cube[i])\n\t}\n\t//rotate\n\tfor i := 0; i < 6; i++ {\n\t\t//90-angle\n\t\tif check_rotate(cube, rotate[i], move_left2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\t//another 90-angle\n\t\tif check_rotate(cube, rotate[i], move_right2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc move_left2(in []int) []int {\n\tret := append(in[2:len(in)], in[0:2]...)\n\treturn ret\n}\n\nfunc move_right2(in []int) []int {\n\tret := append(in[len(in)-2:len(in)], in[0:len(in)-2]...)\n\treturn ret\n}\n\nfunc check_rotate(cube, rotate, moved []int) bool {\n\tafter := make([]int, len(cube))\n\tcopy(after, cube)\n\tfor i := 0; i < 8; i++ {\n\t\tafter[moved[i]-1] = cube[rotate[i]-1]\n\t}\n\treturn check_solved(after)\n}\n\nfunc check_solved(cube []int) bool {\n\tfor i := 0; i < 6; i++ {\n\t\tif cube[i*4] != cube[i*4+1] || cube[i*4] != cube[i*4+2] || cube[i*4] != cube[i*4+3] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "3190d576da239991d802f85121c89870", "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\"math\"\n\t\"math/big\"\n\t\"os\"\n)\n\n/*\n1\n1 1\n1 2\n2 1\n2 3\n---\n0\n0\n2 [0,1], [1,0]\nX [0,7], [7,0],\n\n*/\n\n//goland:noinspection GoUnhandledErrorResult\nfunc main() {\n\tdefer writer.Flush()\n\n\tt := 1\n\tscanf(\"%d\\n\", &t)\n\n\tfor ; t > 0; t-- {\n\t\tvar n, k int64\n\t\tscanf(\"%d %d\\n\", &n, &k)\n\n\t\tans := big.NewInt(0).Exp(big.NewInt(n), big.NewInt(k), big.NewInt(1e9+7)).Int64()\n\n\t\tfmt.Fprintln(writer, ans)\n\t}\n}\n\nconst maxUint = ^uint(0)\n\n//goland:noinspection GoUnusedConst\nconst minUint = 0\nconst maxInt = int(maxUint >> 1)\n\n//goland:noinspection GoUnusedConst\nconst minInt = -maxInt - 1\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) {\n\tif _, err := fmt.Fscanf(reader, f, a...); err != nil {\n\t\tpanic(err)\n\t}\n}\n\n//goland:noinspection GoUnusedFunction\nfunc reversed(s string) string {\n\tinput := []rune(s)\n\tli := len(input)\n\tret := make([]rune, li)\n\tfor i, r := range input {\n\t\tret[li-i-1] = r\n\t}\n\treturn string(ret)\n}\n\n//goland:noinspection GoUnusedFunction\nfunc divCeil(num, div int) int {\n\tquot := num / div\n\tif num%div != 0 {\n\t\tquot++\n\t}\n\treturn quot\n}\n\n//goland:noinspection GoUnusedFunction\nfunc min(nums ...int) int {\n\tminimum := nums[0]\n\tfor _, num := range nums {\n\t\tif num < minimum {\n\t\t\tminimum = num\n\t\t}\n\t}\n\treturn minimum\n}\n\n//goland:noinspection GoUnusedFunction\nfunc max(nums ...int) int {\n\tmaximum := nums[0]\n\tfor _, num := range nums {\n\t\tif num > maximum {\n\t\t\tmaximum = num\n\t\t}\n\t}\n\treturn maximum\n}\n\n//goland:noinspection GoUnusedFunction\nfunc abs(num int) int {\n\tif num < 0 {\n\t\treturn -num\n\t}\n\treturn num\n}\n\n//goland:noinspection GoUnusedFunction\nfunc isPrime(num int) bool {\n\tif num == 2 || num == 3 {\n\t\treturn true\n\t}\n\n\tif num <= 1 || num%2 == 0 || num%3 == 0 {\n\t\treturn false\n\t}\n\n\tfor i := 5; i*i <= num; i += 6 {\n\t\tif num%i == 0 || num%(i+2) == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\n//goland:noinspection GoUnusedFunction\nfunc gcd(a, b int) int {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\n//goland:noinspection GoUnusedFunction\nfunc lcm(a, b int) int {\n\treturn abs(a) / gcd(a, b) * abs(b)\n}\n\n// Examples:\n//\tdigitAt(1234, -1) -> panic!\n//\tdigitAt(1234, 0) -> 4\n//\tdigitAt(1234, 1) -> 3\n//\tdigitAt(1234, 2) -> 2\n//\tdigitAt(1234, 3) -> 1\n//\tdigitAt(1234, 4) -> panic!\n//goland:noinspection GoUnusedFunction\nfunc digitAt(num, pos int) int {\n\tif num == 0 {\n\t\treturn 0\n\t}\n\n\tnum = abs(num)\n\n\tlenNum := int(math.Log10(float64(num))) + 1\n\tif pos < 0 || pos >= lenNum {\n\t\terr := fmt.Sprintf(\"Out of bound access for digit. Position passed %d, number %d\", pos, num)\n\t\tpanic(err)\n\t}\n\n\trem := num % int(math.Pow10(pos+1))\n\treturn rem / int(math.Pow10(pos))\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "e91976b59ce4d49a774bc305e02f9641", "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\t\"sort\"\n\t\"strconv\"\n)\n\nfunc cube(x int) int64 {\n\treturn int64(x) * int64(x) * int64(x)\n}\n\nfunc foo(n int64) int64 {\n\tvar ans int64\n\tfor k := 2; ; k++ {\n\t\tx := n / cube(k)\n\t\tif x == 0 {\n\t\t\tbreak\n\t\t}\n\t\tans += x\n\t}\n\treturn ans\n}\n\n// najmniejszy argument, dla ktorego f(arg) zwraca prawde\n// funkcja logiczna powinna byc niemalejaca\nfunc bin_search(f func(int64) bool, lo, up, eps int64) int64 {\n\tup++\n\tcnt := up - lo\n\tvar mid, step int64\n\tfor cnt >= eps {\n\t\tstep = cnt / 2\n\t\tmid = lo + step\n\t\tif !f(mid) {\n\t\t\tlo = mid + eps\n\t\t\tcnt -= step + eps\n\t\t} else {\n\t\t\tcnt = step\n\t\t}\n\t}\n\treturn lo\n}\n\nfunc main() {\n\tm := getInt64()\n\tmx := int64(4949100894494448)\n\tx := func(n int64) bool {\n\t\treturn foo(n) >= m\n\t}\n\n\tp := bin_search(x, 1, mx, 1)\n\n\tif foo(p) != m {\n\t\tp = -1\n\t}\n\n\tfmt.Println(p)\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 getInt64() int64 {\n\tglobalInput.Scan()\n\tx, _ := strconv.ParseInt(globalInput.Text(), 10, 64)\n\treturn x\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", "binary search", "combinatorics"], "code_uid": "c8abb2181675fdc9cc780cd8413f1910", "src_uid": "602deaad5c66e264997249457d555129", "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\tfmt.Scanf(\"%d\\n%s\", &n, &str)\n\n\tvar counter int\n\tvar answer []int\n\tfor i := 0; i <= n; i++ {\n\t\tif (i == n || (i != 0 && str[i-1] != str[i])) && counter != 0 {\n\t\t\tanswer = append(answer, counter)\n\t\t\tcounter = 0\n\t\t}\n\t\tif i < n && str[i] == 'B' {\n\t\t\tcounter++\n\t\t}\n\t}\n\n\tfmt.Println(len(answer))\n\tfor _, a := range answer {\n\t\tfmt.Printf(\"%d \", a)\n\t}\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0fc071efef0817a42a9cda0d5e6ba84b", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.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\tmemo := TrialDivision(x)\n\n\tans := int64(1)\n\tfor k := range memo {\n\t\td := int64(1)\n\t\tfor {\n\t\t\tif isOverflow(d, k) {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\td *= k\n\t\t\tif n < d {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tnum := int64(n / d)\n\n\t\t\ttmp := modpow(k, 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\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).\n// func ModInv(a, m int) int {\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// TrialDivision returns the result of prime factorization of integer N.\nfunc TrialDivision(n int64) map[int64]int64 {\n\tif n <= 1 {\n\t\tpanic(errors.New(\"[argument error]: TrialDivision only accepts a NATURAL number\"))\n\t}\n\n\tp := map[int64]int64{}\n\tfor i := int64(2); i*i <= n; i++ {\n\t\texp := int64(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// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int64) int64 {\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// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "c5f5ba7eca370c92dc6e296802735ad5", "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\t\"sort\"\n)\n\ntype SA []int\n\nfunc (s SA) Len() int {\n\treturn len(s)\n}\n\nfunc (s SA) Swap(a, b int) {\n\ttmp := s[a]\n\ts[a] = s[b]\n\ts[b] = tmp\n}\nfunc (s SA) Less(i, j int) bool {\n\tif s[i] < s[j] {\n\t\treturn true\n\t}\n\treturn false\n}\nfunc tryS(mat SA, n int, m int64, day int) bool {\n\tdcnt := 0\n\tk := 0\n\tvar sum int64 = 0\n\tfor i := n-1; i >= 0; i-- {\n\t\tif mat[i] > k {\n\t\t\tdcnt++\n\t\t\tsum += int64(mat[i] - k)\n\t\t}else{\n\t\t\tcontinue\n\t\t}\n\t\tif dcnt == day {\n\t\t\tk++\n\t\t\tdcnt = 0\n\t\t}\n\t\tif sum >= m {\n\t\t\tbreak\n\t\t}\n\t}\n\tif sum >= m {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}\nfunc solveD(mat SA, n int, m int64) int {\n\tl := 1\n\tr := n\n\tans := -1\n\tvar sum int64 = 0\n\tfor i := 0; i < n; i++ {\n\t\tsum += int64(mat[i])\n\t}\n\tif sum < m {\n\t\treturn -1\n\t}\n\tfor l <= r {\n\t\tmid := ((l + r) >> 1)\n\t\tif tryS(mat, n, m, mid) {\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\treturn ans\n}\nfunc main() {\n\tvar n int\n\tvar m int64\n\tbuf := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(buf, \"%d %d\\n\", &n, &m)\n\tmat := make(SA, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(buf, \"%d\", &mat[i])\n\t}\n\tsort.Sort(mat)\n\tfmt.Printf(\"%d\\n\", solveD(mat, n, m))\n}\n", "lang_cluster": "Go", "tags": ["brute force", "greedy"], "code_uid": "8a0065646919b18ecd894ba507aa5775", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar MOD int64 = 1e9 + 7;\n\tvar r, g int\n\tfmt.Scan(&r, &g)\n\th := 0\n\n\tfor i := 1; i <= 1000; i++ {\n\t\tif (i * (i + 1) / 2) > r+g {\n\t\t\th = i - 1\n\t\t\tbreak\n\t\t}\n\t}\n\n\tdp := make([]int64, r+1)\n\tdp[0] = 1\n\n\tfor i := 1; i <= h; i++ {\n\t\tfor j := r - i; j >= 0; j-- {\n\t\t\tdp[j+i] += dp[j]\n\t\t\tif dp[j+i] >= MOD {\n\t\t\t\tdp[j+i] -= MOD\n\t\t\t}\n\t\t}\n\t}\n\n\tvar answer int64 = 0\n\tfor i := 0; i <= r; i++ {\n\t\tif h*(h+1)/2-i <= g {\n\t\t\tanswer += dp[i];\n\t\t}\n\t}\n\n\tfmt.Print(answer % MOD)\n}\n", "lang_cluster": "Go", "tags": ["dp"], "code_uid": "12193ab4cef7a017ef61bfe6f7d3cca9", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.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 fmt.Println(b*c + (a-1)*(b+c-1))\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "965e9edf0475f1ad26096d5ade012fcd", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main;\n\nimport \"fmt\"\n\n\nfunc min(x int, y int) int {\n\tif x < y {\n\t return x\n\t} else {\n\t return y\n\t}\n}\n\n\nfunc main() {\n \n var k2, k3, k5, k6 int\n \n fmt.Scanf(\"%d%d%d%d\", &k2, &k3, &k5, &k6)\n \n z := min(k2, min(k5, k6))\n \n k2 = k2 - z\n k5 = k5 - z\n k6 = k6 - z\n \n y := min(k3, k2)\n \n ans := z * 256 + y * 32\n fmt.Printf(\"%d\\n\", ans)\n \n \n}", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "59b9817ecdbf7b7ae19ecddd7d2c53a0", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1029F(_r io.Reader, _w io.Writer) {\n\tds := func(n int64) (ds [][2]int64) {\n\t\tfor d := int64(1); d*d <= n; d++ {\n\t\t\tif n%d == 0 {\n\t\t\t\tds = append(ds, [2]int64{d, n / d})\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tvar a, b int64\n\tFscan(_r, &a, &b)\n\tda, db := ds(a), ds(b)\n\tn := a + b\n\tfor d := int64(math.Sqrt(float64(n))); ; d-- {\n\t\tif n%d == 0 {\n\t\t\td2 := n / d\n\t\t\ti := sort.Search(len(da), func(i int) bool { return da[i][0] > d }) - 1\n\t\t\tj := sort.Search(len(db), func(i int) bool { return db[i][0] > d }) - 1\n\t\t\tif da[i][1] <= d2 || db[j][1] <= d2 {\n\t\t\t\tFprint(_w, 2*(d+d2))\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc main() { CF1029F(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "1144bbcf48ae0916a871f29966383208", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.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 main() {\n\n\tn, m := 0, 0\n\t\n\tfmt.Fscanf(stdin, \"%d%d\", &n, &m)\n\t\n\tx := 2 * n\n\t\n\tif 3 * m > x {\n\t\tx = 3 * m\n\t}\n\t\n\tfor {\n\t\tif x / 2 + x / 3 - x / 6 >= n + m {\n\t\t\tbreak\n\t\t}\n\t\tx++\n\t}\n\t\n\tfmt.Fprintf(stdout, \"%d\\n\", x)\n\n stdout.Flush()\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory", "brute force"], "code_uid": "b1600cf99adb2727119cc84c1a9678fa", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 415A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n, m, x int\n fmt.Scan(&n, &m)\n a := make([]int, n+1)\n v := make([]int, n+1)\n\n for i := 0; i <= n; i++ {\n v[i] = 0\n }\n for i := 0; i < m; i++ {\n fmt.Scan(&x)\n for j := x; j <= n; j++ {\n if v[j] == 0 {\n a[j] = x\n v[j] = 1\n }\n }\n }\n\n for i := 1; i <= n; i++ {\n fmt.Print(a[i])\n fmt.Print(\" \")\n }\n\n fmt.Println()\n\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cfff85e0cf155ad129db048f3441eed8", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "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 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\ta := &node{nil, 0}\n\tb := &node{nil, 0}\n\tvar k, kk int\n\tI(&k)\n\taa := a\n\tfor i := 0; i < k; i++ {\n\t\tI(&aa.value)\n\t\taa.child = &node{nil, 0}\n\t\taa = aa.child\n\t}\n\tI(&kk)\n\tbb := b\n\tfor i := 0; i < kk; i++ {\n\t\tI(&bb.value)\n\t\tbb.child = &node{nil, 0}\n\t\tbb = bb.child\n\t}\n\tvar i int\n\tfor i = 0; i < 1e6 && a.child != nil && b.child != nil; i++ {\n\t\tif a.value > b.value {\n\t\t\taa.value = b.value\n\t\t\taa.child = &node{nil, 0}\n\t\t\taa = aa.child\n\t\t\taa.value = a.value\n\t\t\taa.child = &node{nil, 0}\n\t\t\taa = aa.child\n\t\t} else {\n\t\t\tbb.value = a.value\n\t\t\tbb.child = &node{nil, 0}\n\t\t\tbb = bb.child\n\t\t\tbb.value = b.value\n\t\t\tbb.child = &node{nil, 0}\n\t\t\tbb = bb.child\n\t\t}\n\t\ta = a.child\n\t\tb = b.child\n\t}\n\tif b.child == nil {\n\t\tO(i, \" 1\\n\")\n\t} else if a.child == nil {\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": "4cf9cdea03ac2d9a7c381b418de81f57", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nconst mod = 998244353\nconst N = 5000\n\nvar factor = [N + 1][]int{}\nvar primes = []int64{}\n\nfunc comb(m int, n int) int64 {\n\tres := int64(1)\n\tfnm := make([]int, len(primes))\n\tcopy(fnm, factor[n])\n\tfor i, x := range factor[m] {\n\t\tfnm[i] += x\n\t}\n\tfor w := 1; w <= m; w++ {\n\t\tr := int64(1)\n\t\tfor i, p := range primes {\n\t\t\tfor pw := fnm[i] - factor[w][i] - factor[n-w][i] -\n\t\t\t\tfactor[m-w][i]; pw > 0; pw >>= 1 {\n\t\t\t\tif pw&1 == 1 {\n\t\t\t\t\tr = r * p % mod\n\t\t\t\t}\n\t\t\t\tp = p * p % mod\n\t\t\t}\n\t\t}\n\t\tres += r\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\tsieve := [N + 1]bool{true, true}\n\tfor p := range sieve {\n\t\tif !sieve[p] {\n\t\t\tprimes = append(primes, int64(p))\n\t\t\tfor q := p * p; q <= N; q += p {\n\t\t\t\tsieve[q] = true\n\t\t\t}\n\t\t}\n\t}\n\tfor j := range factor {\n\t\tfactor[j] = make([]int, len(primes))\n\t}\n\tfor i, p := range primes {\n\t\tfor pp := p; pp <= N; pp *= p {\n\t\t\tfor j := pp; j <= N; j += pp {\n\t\t\t\tfactor[j][i]++\n\t\t\t}\n\t\t}\n\t}\n\ta := factor[0]\n\tfor _, b := range factor {\n\t\tfor i, x := range a {\n\t\t\tb[i] += x\n\t\t}\n\t\ta = b\n\t}\n\tfmt.Println(comb(abc[0], abc[1]) * comb(abc[0], abc[2]) % mod * comb(abc[1], abc[2]) % mod)\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics"], "code_uid": "4664325d2a1b16d09549adca4b502deb", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar tot int\n\tvar n int\n\tfmt.Scanln(&tot)\n\tfor t := 0; t < tot ; t++ {\n\t\tfmt.Scanln(&n)\n\t\tfound := false\n\t\tfor i := 2 ; i <= int(math.Sqrt(float64(n))) ; i++ {\n\t\t\tif n % i == 0 {\n\t\t\t\tfmt.Println(n / i, n - (n / i))\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tfmt.Println(1, n - 1)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "number theory"], "code_uid": "6cd6fda6d0ac650d7293184d76a04d95", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x int\n\tfmt.Scanf(\"%d\", &x)\n\ti := x % 4\n\tswitch i {\n\tcase 1:\n\t\tfmt.Println(\"0 A\")\n\t\tbreak\n\tcase 3:\n\t\tfmt.Println(\"2 A\")\n\t\tbreak\n\tcase 2:\n\t\tfmt.Println(\"1 B\")\n\t\tbreak\n\tcase 0:\n\t\tfmt.Println(\"1 A\")\n\tdefault:\n\t\treturn\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "9e4ef6ae96239eb85db0881b56017dfc", "src_uid": "488e809bd0c55531b0b47f577996627e", "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\tn, m := 0, 0\n\tfmt.Fscanf(in, \"%d %d\\n\", &n, &m)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(in, \"%d\", &a[i])\n\t}\n\tcnt := make([]int, 101)\n\tsum := 0\n\tfor i := 0; i < n; i++ {\n\t\tans := 0\n\t\tsum += a[i]\n\t\ttmp := sum\n\t\t//fmt.Println(\"begin\", i)\n\t\tfor j := 100; j >= 1; j-- {\n\t\t\tif tmp <= m {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif cnt[j] == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t//fmt.Println(j, cnt[j], tmp)\n\t\t\tneed := (tmp - m) / j\n\t\t\tif (tmp-m)%j != 0 {\n\t\t\t\tneed++\n\t\t\t}\n\t\t\tif need <= cnt[j] {\n\t\t\t\tans += need\n\t\t\t\ttmp -= need * j\n\t\t\t} else {\n\t\t\t\tans += cnt[j]\n\t\t\t\ttmp -= cnt[j] * j\n\t\t\t}\n\t\t}\n\t\tcnt[a[i]]++\n\t\tif i != 0 {\n\t\t\tfmt.Fprintf(out, \" \")\n\t\t}\n\t\tfmt.Fprintf(out, \"%d\", ans)\n\t}\n\tfmt.Fprintf(out, \"\\n\")\n\treturn\n}\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 max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\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\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc ok(a, b int) bool {\n\tif min(abs(a-b), abs(a+b)) <= min(abs(a), abs(b)) && max(abs(a+b), abs(a-b)) >= max(abs(a), abs(b)) {\n\t\treturn true\n\t}\n\treturn false\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "c9c3e7aade788e4ba90e924dd5509ccf", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tnum := 0\n\tfmt.Scan(&num)\n\tfor i := 1; ; i++ {\n\t\tif strings.Contains(strconv.Itoa(num+i), \"8\") {\n\t\t\tfmt.Println(i)\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "4ac3e0bb9ecf47a96dd0610c5c5e306f", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "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\"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\tm := readi()\n\tr := readi()\n\ts := make([]int, n)\n\tt := make([]int, m)\n\tsmin := 10000\n\tfor i := range s {\n\t\ts[i] = readi()\n\t\tsmin = min(smin, s[i])\n\t}\n\ttmax := 0\n\tfor i := range t {\n\t\tt[i] = readi()\n\t\ttmax = max(tmax, t[i])\n\t}\n\n\tif tmax < smin {\n\t\tprintln(r)\n\t\treturn\n\t}\n\tprintln(r%smin + r/smin*tmax)\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "c0b557d4c81cb1126131d09eda8a89f7", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "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\treader := bufio.NewReader(os.Stdin)\n\n\tn, k := readTwoNums(reader)\n\n\tres := solve(n, k)\n\n\tfmt.Println(res)\n}\n\nfunc readString(reader *bufio.Reader) string {\n\ts, _ := reader.ReadString('\\n')\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == '\\n' || s[i] == '\\r' {\n\t\t\treturn s[:i]\n\t\t}\n\t}\n\treturn s\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\nfunc readNInt64s(reader *bufio.Reader, n int) []int64 {\n\tres := make([]int64, n)\n\ts, _ := reader.ReadBytes('\\n')\n\n\tvar pos int\n\n\tfor i := 0; i < n; i++ {\n\t\tpos = readInt64(s, pos, &res[i]) + 1\n\t}\n\n\treturn res\n}\n\nfunc readInt64(bytes []byte, from int, val *int64) int {\n\ti := from\n\tvar sign int64 = 1\n\tif bytes[i] == '-' {\n\t\tsign = -1\n\t\ti++\n\t}\n\tvar tmp int64\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + int64(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp * sign\n\treturn i\n}\n\nconst MOD = 998244353\n\nfunc modAdd(a, b int) int {\n\ta += b\n\tif a >= MOD {\n\t\ta -= MOD\n\t}\n\treturn a\n}\n\nfunc modMul(a, b int) int {\n\tr := int64(a) * int64(b)\n\tr %= MOD\n\treturn int(r)\n}\n\nconst MAX_N = 260\n\nvar F [MAX_N]int\nvar I [MAX_N]int\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\n\tI[MAX_N-1] = pow(F[MAX_N-1], MOD-2)\n\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\tif n < r {\n\t\treturn 0\n\t}\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, k int) int {\n\tn--\n\tdp := make([][]int, k+1)\n\tfor i := 0; i <= k; i++ {\n\t\tdp[i] = make([]int, n+1)\n\t}\n\n\tdp[0][0] = 1\n\n\tfor i := 0; i < k; i++ {\n\t\tfor t := 0; t <= n; t++ {\n\t\t\tpw := pow(k-i, t*(t-1)/2)\n\t\t\tstep := pow(k-i, t)\n\t\t\tfor j := 0; j < n-t+1; j++ {\n\t\t\t\tdp[i+1][j+t] = modAdd(dp[i+1][j+t], modMul(dp[i][j], modMul(nCr(n-j, t), pw)))\n\t\t\t\tpw = modMul(pw, step)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn dp[k][n]\n}\n\nfunc pow(a, b int) int {\n\tr := 1\n\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", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "graph matchings"], "code_uid": "02306f57e7b1bbe3491e8001affd3522", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.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\tstdin := readStdIn()\n\tnums := convertToInts(stdin)\n\n\tw1 := nums[0]\n\th1 := nums[1]\n\tw2 := nums[2]\n\th2 := nums[3]\n\n\tsum := 0\n\tsum += w2 + 2 + 2*h2\n\n\tsum += w1 - w2 + h1*2\n\tsum += w1 + 2\n\tfmt.Println(sum)\n}\n\nfunc readStdIn() string {\n\tr := bufio.NewReader(os.Stdin)\n\ttext, err := r.ReadString('\\n')\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn strings.TrimSpace(text)\n}\n\nfunc convertToInts(str string) []int {\n\ttokens := strings.Split(str, \" \")\n\tnums := make([]int, 0, len(tokens))\n\tfor _, t := range tokens {\n\t\tn, _ := strconv.Atoi(t)\n\t\tnums = append(nums, n)\n\t}\n\treturn nums\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "cee6a5a5832b7b87df5137cf089c9b9e", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "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 := 0\n for i := 1; i <= n; i++ {\n ans += (i*(n-i))\n }\n ans += n\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "083333f10d6e80352578b96f79ca183a", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 258A-mic\npackage main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var i, k float64\n fmt.Scan(&i, &k)\n t := int64(math.Abs(math.Abs(i) + math.Abs(k)))\n if i > 0 && k > 0 {\n fmt.Printf(\"0 %d %d 0\\n\", t, t)\n } else if i > 0 && k < 0 {\n fmt.Printf(\"0 %d %d 0\\n\", -t, t)\n } else if i < 0 && k > 0 {\n fmt.Printf(\"%d 0 0 %d\\n\", -t, t)\n } else {\n fmt.Printf(\"%d 0 0 %d\\n\", -t, -t)\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c20ea290e2e68b877642343f63741702", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.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\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 tokens := strings.Split(s, \":\")\n h, _ := strconv.Atoi(tokens[0])\n m, _ := strconv.Atoi(tokens[1])\n h %= 12\n hAngle := float64(h)*30 + float64(m)/2\n mAngle := float64(m)*6\n writer.WriteString(fmt.Sprintf(\"%f %f\\n\", hAngle, mAngle))\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "b43eeb85b3b39dc7a4ae7ffb5fd8e529", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var x,y,m int64\n fmt.Scan(&x,&y,&m)\n if (x >= m) || (y >= m) {\n fmt.Println(0)\n } else if (x <= 0) && (y <= 0) {\n fmt.Println(-1)\n } else {\n ans := int64(0)\n if x > y { x, y = y, x }\n for (x < m) && (y < m) {\n a := int64(math.Ceil(math.Abs(float64(x))/float64(y)))\n if a == 0 { a++ }\n x += (y*a)\n ans += a\n if x > y { x, y = y, x }\n }\n fmt.Println(ans)\n }\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "2f902bae404a69bc5aa5a37e1c777e71", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "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\tvar necklace string\n\treader := bufio.NewReader(os.Stdin)\n\n\tnecklace, _ = reader.ReadString('\\n')\n\tnPearls := 0\n\tnLinks := 0\n\n\tfor i := 0; i < len(necklace); i++ {\n\t\tif necklace[i] == 'o' {\n\t\t\tnPearls++\n\t\t} else if necklace[i] == '-' {\n\t\t\tnLinks++\n\t\t}\n\t}\n\n\tif nPearls == 0 || nLinks%nPearls == 0 {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "149fb82431829646fa61c541a6bbfe0f", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n var s string\n fmt.Scan(&s)\n fmt.Println(len(s)*25+26)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "strings"], "code_uid": "530d692eeceaa1cc751e7bd700a52a3e", "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\t\"strings\"\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\tt := \"CODEFORCES\"\n\n\tfor i := 0; i <= len(t); i++ {\n\t\tif strings.HasPrefix(s, t[:i]) && strings.HasSuffix(s, t[i:]) {\n\t\t\tprintln(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\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 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": ["brute force", "implementation"], "code_uid": "e50ce439f369e66705f1da864614f3c2", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n\nfunc find_lcm(n,m int)(res int){\n\tx:=n\n\ty:=m\n\tfor ;n!=m;{\n\t\tif n>m{\n\t\t\tn=n-m\n\t\t}else{\n\t\t\tm=m-n\n\t\t}\n\t}\n\tres=x*y/n\n\treturn\n\n}\n\nfunc main(){\n\n\t/*a:= bufio.NewReader(os.Stdin)\n\tinput,_:= a.ReadString('\\n')\n\tn,m,z:= strings.Split(input,\" \")\n\tfmt.Println(n,m,z) */\n\n\tvar n,m,z int\n\tfmt.Scan(&n, &m, &z);\n\n\tlcm := find_lcm(n,m)\n\n\t fmt.Println(z/lcm) \n}", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation"], "code_uid": "623d1c53c2c769ee6b6c36d3be4dc044", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "\npackage 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 int\n\tvar s string\n\tscanln(&n)\n\tscanln(&s)\n\tk := 0\n\tfor _,c := range(s) {\n\t\tif c == '8' {\n\t\t\tk++\n\t\t}\n\t}\n\t\n\tprintln(int(math.Min(float64(n/11),float64(k))))\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "1be5f9fcc10146337b4c9f0cd8ad9053", "src_uid": "259d01b81bef5536b969247ff2c2d776", "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\tvar date_1, date_2 string\n\tdates := [7]string{\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"}\n\tfsc := NewFastScanner()\n\n\tvar d1, d2 int\n\tdate_1 = fsc.Next()\n\tdate_2 = fsc.Next()\n\tfor i := 1; i < 7; i++ {\n\t\tif date_1 == dates[i] {\n\t\t\td1 = i\n\t\t}\n\t\tif date_2 == dates[i] {\n\t\t\td2 = i\n\t\t}\n\t}\n\tif d2 < d1 {\n\t\td2 += 7\n\t}\n\tret := d2 - d1\n\tif ret == 0 || ret == 2 || ret == 3 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\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": ["implementation"], "code_uid": "cabe596f78eac195d4fed53b992788ad", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc check(x [4]string, a int, b int) bool { // mengecek return value fungsi array x elemen ke 4, variabel a dan b dengan jenis int \n cnt := 0 // membuat variabel cnt kemudian diisi dengan 0\n for i := a; i < (a+2); i++ { // looping\n for j := b; j < (b+2); j++ { // looping ke 2\n if x[i][j] != x[a][b] { cnt++ } // jika array x elemen i dan j tidak sama dengan array x elemen a dan b maka cnt ditambah\n }\n }\n if cnt == 2 { return false } else { return true } // jika cnt sama dengan 2 maka return false, lainnya return true\n}\n\nfunc main() {\n var x [4]string // membuat variabel array x elemen ke 4 dengan jenis string\n for i := 0; i < 4; i++ { // looping ke 3\n fmt.Scan(&x[i]) // mengambil input \n }\n ans := false // membuat variabel ans kemudian diisi dengan false\n for i := 0; i < 3; i++ { //looping ke 4\n for j := 0; j < 3; j++ { // looping ke 5\n if check(x,i,j) { // jika check x,i dan j maka ans sama dengan true kemudian keluar dari fungsi\n ans = true\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") } // jika ans maka cetak Yes, lainnya cetak NO\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "39decaea7c659f78daec442927278ed0", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar n, k int\n\tmaxElem, sumA := 0, 0\n\n\tfmt.Scan(&n)\n\tA := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&A[i])\n\t\tsumA += A[i]\n\t\tif A[i] > maxElem {\n\t\t\tmaxElem = A[i]\n\t\t}\n\t}\n\n\tk = maxElem\n\n\tsumB := 0\n\tfor i := 0; i < n; i++ {\n\t\tsumB += maxElem - A[i]\n\t}\n\n\tfor ; sumB <= sumA; {\n\t\tk++\n\t\tsumB += n\n\t}\n\tfmt.Print(k)\n}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "b6e81ddeecf727f258407c7a5f5c7e2a", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "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 n, m := getI(), getI()\n for {\n for i := 1; i <= n; i++ {\n if i > m {\n writer.WriteString(fmt.Sprintf(\"%d\\n\", m))\n return\n } \n m -= i\n }\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "462f653ce7e13085eb140f63d33a5763", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "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\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\t\tm := len(s) / 2\n\t\tl := m\n\t\tr := m\n\t\tif len(s)%2 == 0 {\n\t\t\tl -= 1\n\t\t}\n\n\t\tdiff := 0\n\t\tfor i := 0; i <= l; i++ {\n\t\t\tif s[l-i] != s[r+i] {\n\t\t\t\tdiff++\n\t\t\t}\n\t\t}\n\t\tif diff == 0 {\n\t\t\tif l == r {\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 if diff == 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": ["brute force", "strings", "constructive algorithms"], "code_uid": "ff57cbb2ff1a653ec7ff341d11ed06cd", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0, "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 {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar n, a, b, c int\n\tt := []int{0}\n\tfmt.Scanf(\"%d %d %d %d \\n\", &n, &a, &b, &c)\n\tfor i := 1; i <= n; i++ {\n\t\tt = append(t, -1)\n\t\tif i >= a && t[i-a] != -1 {\n\t\t\tt[i] = max(t[i], t[i-a]+1)\n\t\t}\n\t\tif i >= b && t[i-b] != -1 {\n\t\t\tt[i] = max(t[i], t[i-b]+1)\n\t\t}\n\t\tif i >= c && t[i-c] != -1 {\n\t\t\tt[i] = max(t[i], t[i-c]+1)\n\t\t}\n\t}\n\tfmt.Print(t[n])\n}\n", "lang_cluster": "Go", "tags": ["brute force", "dp"], "code_uid": "1a0ef0755bb91b55894e0638a24a32f2", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\n/*\n\nTo solve this problem, we could start by making position map. For example \nlike following:\n\n ^ 0\n< > 3 1\n V 2\n\nFrom this map, then we could deduce following formulas:\n- end position if rotated clockwise: (start + (n % 4)) % 4\n- end position if rotated counter-clockwise: (4 + start - (n % 4)) % 4\n\nAfter that we just need to check whether toys rotated clockwise, \ncounter-clockwise, or neither.\n\n*/\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 posCW := (start + (n % 4)) % 4\n posCCW := (4 + start - (n % 4)) % 4\n \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}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "699948a26252b7dd789e365ba750943a", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "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\nconst INF = 1000000001\n\ntype Pair struct {\n\tfirst, second int\n}\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 := len(arr) / 2\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 check(n int) bool {\n\tvar s int\n\tfor n > 0 {\n\t\ts += n % 10\n\t\tn /= 10\n\t}\n\treturn s == 10\n}\n\nfunc solution(reader io.Reader, writer io.Writer) {\n\tvar k int\n\tfmt.Fscanf(reader, \"%d\\n\", &k)\n\tfor i := 19; k > 0; i++ {\n\t\tif check(i) {\n\t\t\tk--\n\t\t}\n\t\tif k == 0 {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\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": ["brute force", "dp", "binary search", "implementation", "number theory"], "code_uid": "f10ab01b556823a67707fa55248d3fbd", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.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}", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "3670fb0a7a34d2c70c6de372d800f450", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nvar MOD int64 = 1000000007\n\nfunc expo(base, exponent, modulus int64) int64 {\n\tif modulus == 1 {\n\t\treturn 0\n\t}\n\tif exponent == 0 {\n\t\treturn 1\n\t}\n\n\tresult := expo(base, exponent/2, modulus)\n\tresult = (result * result) % modulus\n\tif exponent&1 != 0 {\n\t\treturn ((base % modulus) * result) % modulus\n\t}\n\treturn result % modulus\n}\n\nfunc main() {\n\tvar n, m int64\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tfmt.Println(expo((expo(2, m, MOD)-1+MOD)%MOD, n, MOD))\n}\n", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "b0f488e0ac5274147f9f43ec12b072ae", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "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\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.TrimRight(text, \"\\r\\n\")\n\n\ttext, _ = reader.ReadString('\\n')\n\ttext = strings.TrimRight(text, \"\\r\\n\")\n\n\tyes := false\n\tif strings.Contains(text, \"0\") {\n\t\tif strings.ContainsAny(text, \"123\") {\n\t\t\tyes = true\n\t\t}\n\t} else {\n\t\tif strings.ContainsAny(text, \"123\") && strings.ContainsAny(text, \"79\") {\n\t\t\tif strings.ContainsAny(text, \"147\") && strings.ContainsAny(text, \"369\") {\n\t\t\t\tyes = true\n\t\t\t}\n\t\t}\n\t}\n\tif yes {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "375515c4f75f4bb4a0588508fccd693d", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.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, t, k, d int\n\treader := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(reader, &n)\n\tfmt.Fscan(reader, &t)\n\tfmt.Fscan(reader, &k)\n\tfmt.Fscan(reader, &d)\n\tbefore := n / k * t\n\tif n%k != 0 {\n\t\tbefore += t\n\t}\n\tif n < k {\n\t\tfmt.Println(\"NO\")\n\t} else if before <= t+d {\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": "d37f3fa0ef34720207980233a37f5bab", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.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\ntype Vec [4]int\n\nfunc (v Vec) max() int {\n\tmax := -999\n\tfor i := 0;i < len(v);i ++ {\n\t\tif v[i] > max {\n\t\t\tmax = v[i]\n\t\t}\n\t}\n\treturn max\n}\n\nfunc (v Vec) min() int {\n\tmin := 999\n\tfor i := 0;i < len(v);i ++ {\n\t\tif v[i] < min {\n\t\t\tmin = v[i]\n\t\t}\n\t}\n\treturn min\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}\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\t\n\tvar ax, ay, bx, by Vec\n\tfmt.Fscanf(reader, \"%d %d %d %d %d %d %d %d\\n\", &ax[0], &ay[0], &ax[1], &ay[1], &ax[2], &ay[2], &ax[3], &ay[3])\n\tfmt.Fscanf(reader, \"%d %d %d %d %d %d %d %d\\n\", &bx[0], &by[0], &bx[1], &by[1], &bx[2], &by[2], &bx[3], &by[3])\n\t\n\taxMax, axMin, ayMax, ayMin := ax.max(), ax.min(), ay.max(), ay.min()\n\tbxMax, bxMin, byMax, byMin := bx.max(), bx.min(), by.max(), by.min()\n\tbxAvg, byAvg := (bxMax + bxMin) / 2, (byMax + byMin) / 2\n\tdist := bxMax - bxAvg\n\n\n\n\tfor x := -100; x <= 100; x ++ {\n\t\tfor y := -100; y <= 100; y ++ {\n\t\t\tif (axMin <= x && x <= axMax && ayMin <= y && y <= ayMax) {\n\t\t\t\tif (abs(x - bxAvg) + abs(y - byAvg) <= dist) {\n\t\t\t\t\tfmt.Printf(\"YES\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"NO\")\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["geometry", "implementation"], "code_uid": "16935d72559b610d7e6a0b7596ca760e", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.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\t//\"unicode\"\n\t//\"strings\"\n\t//\"math\"\n)\n\nfunc main() {\n var a,b,c,ans int\n fmt.Scan(&a,&b,&c)\n ans = (((c*a)+b-1)/b)-c\n fmt.Println(ans)\n}\n\n", "lang_cluster": "Go", "tags": ["brute force", "math", "binary search"], "code_uid": "5136569b6185e275a81bf59e6b3ab56c", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.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 rowNum, colNum := int(getI()), int(getI())\n grid := make([][]byte, rowNum)\n for r := 0; r < rowNum; r++ {\n scanner.Scan()\n grid[r] = []byte(scanner.Text())\n }\n dr, dc := []int{ -1, 0, 1, 0}, []int{ 0, 1, 0, -1 }\n result := 0\n for r := 0; r < rowNum; r++ {\n for c := 0; c < colNum; c++ {\n if grid[r][c] == 'W' {\n for i := 0; i < 4; i++ {\n R, C := r+dr[i], c+dc[i]\n if R >= 0 && R < rowNum && C >= 0 && C < colNum {\n if grid[R][C] == 'P' {\n result++\n break\n }\n }\n }\n }\n }\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["greedy", "implementation"], "code_uid": "e388ef245c20d67249cc3c1d9d3f25f2", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "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\t// \"os/exec\"\n)\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tnumCmds := scanner.Text()\n\tnumChars, _ := strconv.Atoi(numCmds)\n\n\tscanner.Scan()\n\tcommands := scanner.Text()\n\n\tcmdSplit := strings.Split(commands, \"\")\n\tret := 0\n\tfor i := 0; i < numChars; i++ {\n\t\tx := 0\n\t\ty := 0\n\t\tfor j := i; j < numChars; j++ {\n\t\t\tif cmdSplit[j] == \"U\" {\n\t\t\t\ty++\n\t\t\t}\n\t\t\tif cmdSplit[j] == \"D\" {\n\t\t\t\ty--\n\t\t\t}\n\t\t\tif cmdSplit[j] == \"L\" {\n\t\t\t\tx--\n\t\t\t}\n\t\t\tif cmdSplit[j] == \"R\" {\n\t\t\t\tx++\n\t\t\t}\n\t\t\t// fmt.Println(x, y)\n\t\t\tif x == 0 && y == 0 {\n\t\t\t\tret++\n\t\t\t}\n\n\t\t}\n\n\t}\n\tfmt.Println(ret)\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "5d4b4cf983724162ac9724cb357a2358", "src_uid": "7bd5521531950e2de9a7b0904353184d", "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\n\tstart := 0\n\tnext := 0\n\tminutes := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&next)\n\t\tif next-start > 15 {\n\t\t\tminutes = start+15\n\t\t\tbreak\n\t\t}\n\t\tstart = next\n\t\tminutes = start\n\t\tif i == n-1 {\n\t\t\tif 90-start > 15 {\n\t\t\t\tminutes = start+15\n\t\t\t} else {\n\t\t\t\tminutes = 90\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(minutes)\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ed55e0b84f48f90bfecc66b43b304dfe", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "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 scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nfunc power(n, mod int64) int64 {\n\tif n == 0 {\n\t\treturn int64(1)\n\t}\n\tif n % 2 == 0 {\n\t\tx := power(n/2, mod)\n\t\treturn (x*x) % mod\n\t} else {\n\t\tx := power(n/2, mod)\n\t\treturn (2*x*x) % mod\n\t}\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\tmod := int64(1000)\n\tmod = mod*mod*mod + 7\n\tn, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\tif n == 0 {\n\t\twriter.WriteString(\"1\\n\")\n\t\treturn\n\t}\n\ta := power(n-1, mod)\n\tb := (2*a+1) % mod\n\tx := (a * b) % mod\n\twriter.WriteString(fmt.Sprintf(\"%d\\n\", x))\n}\n", "lang_cluster": "Go", "tags": ["math", "matrices", "dp", "number theory"], "code_uid": "feb5b6977a7d2cc871394b457c4eb5e6", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n )\n \nfunc main() {\n var n,a,b,c int64\n fmt.Scanf(\"%v\\n\", &n)\n fmt.Scanf(\"%v\\n\", &a)\n fmt.Scanf(\"%v\\n\", &b)\n fmt.Scanf(\"%v\\n\", &c)\n \n bTotal := int64(0)\n if a > b - c && n >= b{\n /*for n >= 0 {\n Lb := int64(n/b)\n if Lb == 0 {\n break\n }\n n -= Lb*b\n n += c*Lb\n bTotal += Lb\n //fmt.Printf(\"%v %v\\n\", n, bTotal)\n }*/\n \n bTotal += int64((n-c)/(b-c))\n if bTotal < 0 {\n fmt.Printf(\"0\")\n return\n }\n n -= bTotal*(b-c)\n bTotal += int64(n/a)\n } else if n > a {\n bTotal = int64(n/a)\n } else if n >= b {\n bTotal = int64(n/b)\n }\n fmt.Printf(\"%v\", bTotal)\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "c3ce1106f69f2f042b1dc1bc86505ff7", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "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\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\tv1, v2, t, d := nextInt(), nextInt(), nextInt(), nextInt()\n\tpath, maxSpeed := 0, 0\n\n\tfor ; t > 0; t-- {\n\t\tpath += v1\n\t\tmaxSpeed = v2+d*(t-2)\n\t\t// println(path, v1, maxSpeed)\n\n\t\tif maxSpeed > v1 {\n\t\t\tif v1+d > maxSpeed {\n\t\t\t\tv1 = maxSpeed\n\t\t\t} else {\n\t\t\t\tv1 += d\n\t\t\t}\n\t\t} else if maxSpeed < v1 {\n\t\t\tif v1-d < maxSpeed {\n\t\t\t\tv1 = maxSpeed\n\t\t\t} else {\n\t\t\t\tv1 -= d\n\t\t\t}\n\t\t}\n\t}\n\n\tprintln(path)\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": ["math", "greedy", "dp"], "code_uid": "7b8c78097f55389f32df016f77dc79be", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.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 x, y int64\n\tfmt.Scan(&n, &x, &y)\n\tdp := make([]int64, 2*n+1)\n\tdp[1] = x;\n\tfor i := 2; i <= n; i++ {\n\t\tdp[i] = min(dp[i-1]+x, dp[(i+1)/2]+y+int64(i%2)*x)\n\t\tdp[i-1] = min(dp[i-1], dp[i]+x)\n\t}\n\n\tfmt.Println(dp[n])\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": ["dfs and similar", "dp"], "code_uid": "5b3efa1df6a51a89da7999189c390740", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\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\tn, m := 0, 0\n\tfmt.Scan(&n, &m)\n\ta := make([]int, n)\n\tvar cuts []int\n\tfor i := range a {\n\t\tfmt.Scan(&a[i])\n\t}\n\todd, even := 0, 0\n\tfor i := 0; i < n-1; i++ {\n\t\tswitch a[i] % 2 {\n\t\tcase 0:\n\t\t\teven++\n\t\tcase 1:\n\t\t\todd++\n\t\t}\n\t\tif odd == even {\n\t\t\tcuts = append(cuts, abs(a[i+1]-a[i]))\n\t\t}\n\t}\n\tsort.Ints(cuts)\n\tcnt := 0\n\tfor _, v := range cuts {\n\t\tif v <= m {\n\t\t\tcnt++\n\t\t\tm -= v\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(cnt)\n}\n", "lang_cluster": "Go", "tags": ["sortings", "dp", "greedy"], "code_uid": "eefb022c9222d77719a6ab75beb38f6e", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, d int\n\tvar path string\n\n\tfmt.Scanf(\"%d %d\\n\", &n, &d)\n\tfmt.Scanf(\"%s\", &path)\n\n\tdp := make([]int, n)\n\tdp[0] = 1\n\n\tfor i := 0; i < n; i++ {\n\t\tif dp[i] > 0 {\n\t\t\tfor j := 1; j <= d; j++ {\n\t\t\t\tif i+j < n && path[i+j] == '1' && (dp[i+j] == 0 || dp[i+j] > dp[i]+1) {\n\t\t\t\t\tdp[i+j] = dp[i] + 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(dp[n-1] - 1)\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "f4f2224babfd8f5877cf71a9b8eb35bd", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"strconv\"\n \"strings\"\n)\n\nfunc main() {\n var n int\n var encodeStr string\n\n fmt.Scan(&n)\n fmt.Scan(&encodeStr)\n\n var answer []string\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 answer = append(answer, strconv.Itoa(counter))\n }\n } else if currentDigit == \"0\" && prevDigit == \"0\" {\n answer = append(answer, \"0\")\n } else if currentDigit == \"0\" && prevDigit != \"0\" {\n answer = append(answer, strconv.Itoa(counter))\n counter = 0\n }\n prevDigit = currentDigit\n }\n\n if string(encodeStr[n - 1]) == \"0\" {\n answer = append(answer, \"0\")\n }\n\n fmt.Println(strings.Join(answer, \"\"))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "42c28340ef291e04ed72a78d73d5dc4c", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "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 main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tvar buf bytes.Buffer\n\n\ttc := 1\n\n\tfor tc > 0 {\n\t\ttc--\n\t\tn, mod := readTwoNums(reader)\n\t\tres := solve(n, mod)\n\t\tbuf.WriteString(fmt.Sprintf(\"%d\\n\", res))\n\t}\n\n\tfmt.Print(buf.String())\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 solve(n int, mod int) int {\n\tf := make([][]int64, n+1)\n\ts := make([][]int64, n+1)\n\tfor i := 0; i <= n; i++ {\n\t\tf[i] = make([]int64, n*(n-1)/2+1)\n\t\ts[i] = make([]int64, n*(n-1)/2+1)\n\t}\n\tf[0][0] = 1\n\ts[0][0] = 1\n\n\tfor i := 1; i < len(s[0]); i++ {\n\t\ts[0][i] = 1\n\t}\n\n\tMOD := int64(mod)\n\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := 0; j <= n*(n-1)/2; j++ {\n\t\t\tif j-i >= 0 {\n\t\t\t\tf[i][j] = (s[i-1][j] - s[i-1][j-i] + MOD) % MOD\n\t\t\t} else {\n\t\t\t\tf[i][j] = s[i-1][j]\n\t\t\t}\n\t\t\tif j > 0 {\n\t\t\t\ts[i][j] = (s[i][j-1] + f[i][j]) % MOD\n\t\t\t} else {\n\t\t\t\ts[i][j] = f[i][j]\n\t\t\t}\n\t\t}\n\t}\n\n\tans := make([]int64, n+1)\n\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := 1; j <= i; j++ {\n\t\t\tfor k := j + 1; k <= i; k++ {\n\t\t\t\tfor u := 0; u <= (i-1)*(i-2)/2; u++ {\n\t\t\t\t\tt := u - (k - j) - 1\n\t\t\t\t\tif t < 0 {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tans[i] = (ans[i] + f[i-1][u]*s[i-1][t]%MOD) % MOD\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := 2; i <= n; i++ {\n\t\tans[i] = (ans[i] + int64(i)*ans[i-1]%MOD) % MOD\n\t}\n\n\treturn int(ans[n])\n}\n", "lang_cluster": "Go", "tags": ["math", "dp", "combinatorics", "fft"], "code_uid": "cecc52fc53de2e6489846d091d1a9ffd", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0, "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 ReadInf() 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\nfunc main() {\n scanner.Split(bufio.ScanLines)\n s := \"A\" + ReadString() + \"A\"\n lastIndex := 0\n maxDistance := 0\n\n for i := 0; i < len(s); i++ {\n if s[i] == 'A' || s[i] == 'E' || s[i] == 'I' || s[i] == 'O' || s[i] == 'U' || s[i] == 'Y' {\n maxDistance = int(math.Max(float64(maxDistance), float64(i - lastIndex)))\n lastIndex = i\n }\n }\n\n fmt.Print(maxDistance)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "0d69467558b25bfdc4b1ca1bc81dcb40", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar cups, capacity int\n\tfmt.Scan(&cups, &capacity)\n\n\tvar cupCapacities []int\n\tfor i := 0; i < cups; i++ {\n\t\tvar cup int\n\t\tfmt.Scan(&cup)\n\t\tcupCapacities = append(cupCapacities, cup)\n\t}\n\n\tsort.Ints(cupCapacities)\n\tvar count int\n\n\tfor i := 0; i < cups - 1; i++ {\n\t\tcount += cupCapacities[i]\n\t}\n\n\tif count > capacity {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\t\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "1ea5dfe0a88a28f2eaed5409dde5837d", "src_uid": "496baae594b32c5ffda35b896ebde629", "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\"sort\"\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\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\n\ta := make([]int, n)\n\tb := make([]bool, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(reader, \"%d\", &a[i])\n\t}\n\n\tsort.Ints(a)\n\n\tvar res int\n\n\tfor i := 0; i < n; i++ {\n\t\tif !b[i] {\n\t\t\tres++\n\t\t\tfor j := 0; j < n; j++ {\n\t\t\t\tif a[j] % a[i] == 0 {\n\t\t\t\t\tb[j] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res)\n\n\n\twriter.Flush()\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation"], "code_uid": "4dbd606b34806711d0959c53db004786", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.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\tvar xs [100]int\n\tfmt.Scan(&n)\n\tfmt.Scan(&s)\n\tfor i, r := range []rune(s) {\n\t\txs[i] = int(r - '0')\n\t}\n\tz, c := 0, 1\n\tfor i := 0; i < n; i++ {\n\t\tt := xs[i] + c\n\t\tif xs[i] != t&1 {\n\t\t\tz++\n\t\t}\n\t\tc = t >> 1\n\t}\n\tfmt.Println(z)\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "e59447139b6b1b15ee7690037cc65b37", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.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 check(n int) (m int, b bool) {\r\n\r\n\tif n < 3 {\r\n\r\n\t\treturn 0, false\r\n\t}\r\n\tif n == 3 {\r\n\r\n\t\treturn 1, true\r\n\t}\r\n\tsum := n/2 + n%2 + n/4 - 2\r\n\tif n%2 == 0 {\r\n\r\n\t\tif n%4 != 0 {\r\n\r\n\t\t\treturn sum, false\r\n\t\t}\r\n\t\treturn sum, true\r\n\t}\r\n\treturn sum, true\r\n}\r\n\r\nvar (\r\n\r\n\tin = bufio.NewReader(os.Stdin);\r\n\tout = bufio.NewWriter(os.Stdout)\r\n)\r\n\r\nfunc main() {\r\n\r\n\tvar (\r\n\t\tn int\r\n\t\tl = 1\r\n\t\tr = int(2e9)\r\n\t)\r\n\tdefer out.Flush()\r\n\tfmt.Fscan(in, &n)\r\n\tfor r - l > 1 {\r\n\r\n\t\tmid := (l + r) / 2\r\n\t\tval, oke := check(mid)\r\n\t\tif val > n {\r\n\r\n\t\t\tr = mid - 1\r\n\t\t} else if val < n {\r\n\r\n\t\t\tl = mid + 1\r\n\t\t} else if oke == true {\r\n\r\n\t\t\tfmt.Fprintln(out, mid)\r\n\t\t\treturn\r\n\t\t} else {\r\n\r\n\t\t\tr = mid - 1\r\n\t\t}\r\n\t}\r\n\tval, oke := check(l)\r\n\tif val == n && oke == true {\r\n\r\n\t\tfmt.Fprintln(out, l)\r\n\t} else {\r\n\r\n\t\tfmt.Fprintln(out, r)\r\n\t}\r\n}", "lang_cluster": "Go", "tags": ["math", "geometry", "binary search"], "code_uid": "680c45a1505a183cdad05e418dbdc5c8", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n ans := 0\n for a := 1; a < n; a++ {\n for b := a+1; (a*a+b*b) <= (n*n); b++ {\n cc := a*a+b*b\n c := int(math.Sqrt(float64(cc)))\n if c*c == cc { ans++ }\n }\n }\n fmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "fa30efc0f5c5720d2316721535a7d9a3", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"flag\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"time\"\n)\n\n// ******************************** CODE STARTS ********************************\n\nvar ()\n\nfunc getAns(array []int) int {\n\t// logln(\"lol\")\n\t// logln(array)\n\tn := len(array)\n\tres := 0\n\tfor {\n\t\tcount := 0\n\t\tleft := -1\n\t\tsum := -1\n\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif array[i] == -1 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tleft = i\n\t\t\tsum = 1\n\t\t\tbreak\n\t\t}\n\n\t\tif left != -1 {\n\t\t\tfor j := left + 1; j < n; j++ {\n\t\t\t\tif array[j] == -1 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif array[left] == array[j] {\n\t\t\t\t\tsum++\n\t\t\t\t} else {\n\t\t\t\t\tif sum >= 3 {\n\t\t\t\t\t\tfor i := left; i < j; i++ {\n\t\t\t\t\t\t\tarray[i] = -1\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcount = sum\n\t\t\t\t\t\tsum = 0\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tleft = j\n\t\t\t\t\tsum = 1\n\t\t\t\t}\n\t\t\t\t// logln(array)\n\t\t\t}\n\n\t\t\tif sum >= 3 {\n\t\t\t\tfor i := left; i < n; i++ {\n\t\t\t\t\tarray[i] = -1\n\t\t\t\t}\n\t\t\t\tcount = sum\n\t\t\t}\n\t\t\t// logln(array)\n\t\t}\n\n\t\tif count == 0 {\n\t\t\tbreak\n\t\t}\n\t\tres += count\n\t\tcount = 0\n\t}\n\treturn res - 1\n}\n\nfunc solve() {\n\tn := readInt()\n\t_ = readInt()\n\tx := readInt()\n\tarray := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tarray[i] = readInt()\n\t}\n\n\tbest := 0\n\tfor j := 0; j <= n; j++ {\n\t\tvar newArray []int\n\t\tif j > 0 {\n\t\t\tnewArray = append(newArray, array[:j]...)\n\t\t}\n\t\tnewArray = append(newArray, x)\n\t\tif j < n {\n\t\t\tnewArray = append(newArray, array[j:]...)\n\t\t}\n\t\tbest = maxInt(best, getAns(newArray))\n\t}\n\tprintInt(best)\n\tprintLine()\n}\n\n// ********************************* CODE ENDS *********************************\n\n// IO.\n\nvar (\n\tscanner *bufio.Scanner\n\twriter *bufio.Writer\n\tlogger *log.Logger\n)\n\nfunc main() {\n\tlocal := flag.Bool(\"local\", false, \"Equals true, if run is local.\")\n\tflag.Parse()\n\n\tvar (\n\t\tinput *os.File\n\t\toutput *os.File\n\t)\n\n\tif *local {\n\t\tstartTime := time.Now()\n\t\tdefer func() {\n\t\t\tprintln(fmt.Sprintf(\"Time: %.5fs\", time.Since(startTime).Seconds()))\n\t\t}()\n\t\tinput, _ = os.Open(\"/home/outside/coding/workspace/go/io/input.txt\")\n\t\toutput, _ = os.Create(\"/home/outside/coding/workspace/go/io/output.txt\")\n\t\tlogger = log.New(output, \"log: \", 0)\n\t} else {\n\t\tinput = os.Stdin\n\t\toutput = os.Stdout\n\t\t// input, _ = os.Open(\"\")\n\t\t// output, _ = os.Create(\"\")\n\t}\n\tdefer input.Close()\n\tdefer output.Close()\n\n\tscanner = bufio.NewScanner(input)\n\tscanner.Split(bufio.ScanWords)\n\n\twriter = bufio.NewWriter(output)\n\tdefer writer.Flush()\n\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 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// Log.\n\nfunc logln(value ...interface{}) {\n\twriter.Flush()\n\tlogger.Println(value...)\n}\nfunc logf(format string, value ...interface{}) {\n\twriter.Flush()\n\tlogger.Printf(format, value...)\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", "lang_cluster": "Go", "tags": ["two pointers", "brute force"], "code_uid": "571526fc4cf0be05ef90a34707bf7d6e", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a [6]int\n\tif _, err := fmt.Scanf(\"%d %d %d %d %d %d\\n\",\n\t\t&a[0], &a[1], &a[2], &a[3], &a[4], &a[5]); err != nil {\n\t\treturn\n\t}\n\n\tfmt.Println((a[0]+a[1]+a[2])*(a[0]+a[1]+a[2]) - a[0]*a[0] - a[2]*a[2] - a[4]*a[4])\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "geometry"], "code_uid": "6c5e8bfae1db3f262c064362352bb452", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "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\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tvar n int\n\tvar m int\n\n\tfmt.Fscan(in, &n, &m)\n\n\ts := make([]int, m)\n\td := make([]int, m)\n\tc := make([]int, m)\n\tsched := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tsched[i] = 0\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Fscan(in, &s[i], &d[i], &c[i])\n\t\ts[i]--\n\t\td[i]--\n\t\tsched[d[i]] = m + 1\n\t}\n\n\tfail := false\n\n\tfor i := 0; i < n; i++ {\n\t\tif sched[i] > 0 {\n\t\t\tcontinue\n\t\t}\n\t\tbestd := n + 10\n\t\tbestj := -1\n\t\tfor j := 0; j < m; j++ {\n\t\t\tif s[j] <= i && i < d[j] && c[j] > 0 && d[j] < bestd {\n\t\t\t\tbestd = d[j]\n\t\t\t\tbestj = j\n\t\t\t}\n\t\t}\n\n\t\tif bestd < 0 {\n\t\t\tfail = true\n\t\t\tbreak\n\t\t}\n\n\t\tif bestj != -1 {\n\t\t\tsched[i] = bestj + 1\n\t\t\tc[bestj]--\n\t\t}\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tif c[i] > 0 {\n\t\t\tfail = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !fail {\n\t\tfor i := 0; i < n; i++ {\n\t\t\tfmt.Fprint(out, sched[i], \" \")\n\t\t}\n\n\t\tfmt.Fprintln(out)\n\t} else {\n\t\tfmt.Fprintln(out, -1)\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["sortings", "implementation", "greedy"], "code_uid": "170724a56120a585d4f775df8c5cc781", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc solve(a []int) int {\n\tn := len(a)\n\tif n == 2 {\n\t\treturn 1\n\t}\n\tif n == 3 {\n\t\treturn 2\n\t}\n\t// n >= 4\n\ti1, in := -1, -1\n\tfor i := 0; i < n; i++ {\n\t\tif a[i] == 1 {\n\t\t\ti1 = i\n\t\t}\n\t\tif a[i] == n {\n\t\t\tin = i\n\t\t}\n\t}\n\td1b := (i1 + 1) - 1\n\td1e := n - (i1 + 1)\n\tdnb := (in + 1) - 1\n\tdne := n - (in + 1)\n\n\tmax := d1b\n\tif d1e > max {\n\t\tmax = d1e\n\t}\n\tif dnb > max {\n\t\tmax = dnb\n\t}\n\tif dne > max {\n\t\tmax = dne\n\t}\n\treturn max\n}\n\nfunc main() {\n\tvar n int\n\tnr, err := fmt.Fscanln(os.Stdin, &n)\n\tif nr != 1 || err != nil {\n\t\tpanic(err)\n\t}\n\ta := make([]int, n)\n\tpa := make([]interface{}, n)\n\tfor i := 0; i < n; i++ {\n\t\tpa[i] = &a[i]\n\t}\n\tnr, err = fmt.Fscanln(os.Stdin, pa...)\n\tif nr != n || err != nil {\n\t\tpanic(err)\n\t}\n\tres := solve(a)\n\tfmt.Println(res)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "70e3209c93baa859994c5812aebe7e4f", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc f(x int) []int {\n\tswitch x {\n\tcase 0, 1:\n\t\treturn []int{}\n\tcase 4:\n\t\treturn []int{3, 2, 2}\n\tcase 6:\n\t\treturn []int{5, 3}\n\tcase 8:\n\t\treturn []int{7, 2, 2, 2}\n\tcase 9:\n\t\treturn []int{7, 3, 3, 2}\n\tdefault:\n\t\treturn []int{x}\n\t}\n}\n\nfunc main() {\n\tvar dummy, digits string\n\tfmt.Scan(&dummy, &digits)\n\tif len(dummy) < 1 {\n\t\tpanic(\"nil dummy\")\n\t}\n\txs := make([]int, 0, 64)\n\tfor _, r := range digits {\n\t\tx := int(r - '0')\n\t\txs = append(xs, f(x)...)\n\t}\n\tsort.Ints(xs)\n\tfor i := len(xs) - 1; i >= 0; i-- {\n\t\tfmt.Printf(\"%c\", xs[i]+'0')\n\t}\n\tfmt.Println()\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "97d8bb50f83722f2fc19ce6bca565b4b", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc ReadFloat64() float64 {\n f64, _ := strconv.ParseFloat(ReadString(), 64)\n return f64\n}\n\nfunc ReadInt64() int64 {\n i64, _ := strconv.ParseInt(ReadString(), 10, 64)\n return i64\n}\n\nfunc ReadInt() int {\n return int(ReadInt64())\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n n, m, MOD := ReadInt(), ReadInt(), ReadInt64()\n dp := make([][]int64, n+1)\n for i := 0; i <= n; i++ {\n dp[i] = make([]int64, m)\n }\n helper := 10\n for i := 1; i < 10; i++ {\n dp[1][i%m]++\n dp[1][i%m] %= MOD\n }\n for i := 1; i < n; i++ {\n dp[i+1][0] += dp[i][0] * 10\n dp[i+1][0] %= MOD\n for k := 1; k < 10; k++ {\n index := helper * k % m\n dp[i+1][index]++\n dp[i+1][index] %= MOD\n }\n for j := 1; j < m; j++ {\n for k := 0; k < 10; k++ {\n index := (k*helper + j) % m\n dp[i+1][index] += dp[i][j]\n dp[i+1][index] %= MOD\n }\n }\n helper = helper * 10 % m\n }\n fmt.Fprintln(writer, (dp[n][0]-dp[n-1][0]+MOD)%MOD)\n}\n", "lang_cluster": "Go", "tags": ["dp", "implementation"], "code_uid": "cf4399543cfdd8f8485a2bb1230aba13", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.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": "04e64a9c4764450b193ec4158ace18b0", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0, "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\tres := false\n\tvar c string\n\taa := 1234567\n\tbb := 123456\n\tcc := 1234\n\tfor i := 0; ; i++ {\n\t\tif aa*i > n || res {\n\t\t\tbreak\n\t\t}\n\t\tfor j := 0; ; j++ {\n\t\t\tif (aa*i+bb*j) > n || res {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tvar k int\n\t\t\tk = n - aa*i - bb*j\n\t\t\tk /= cc\n\t\t\tres = aa*i+bb*j+cc*k == n\n\t\t}\n\t}\n\tif res {\n\t\tc = \"YES\"\n\t} else {\n\t\tc = \"NO\"\n\t}\n\tfmt.Println(c)\n}\n", "lang_cluster": "Go", "tags": ["brute force"], "code_uid": "b7bf8636b5a50c7185e544e5c96786a6", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\t\"fmt\"\n\t)\n\nfunc main() {\n\tvar t int\n\tfmt.Scan(&t)\n\tvar s string\n\tfmt.Scan(&s)\n\tone := 0\n\tzero := 0\n\tfor i:=0;i 0 && allzero(i) {\n for j := 0; j < m; j++ {\n a[i][j] = 0\n }\n }\n for j := 0; j < m; j++ {\n if a[i][j] == 0 {\n continue\n }\n for k := uint(0); k < wid; k++ {\n if (i & (1 << k)) != 0 {\n continue\n }\n a[i|(1< 12 || bd == 0{\n\t\treturn false\n\t}\n\tif by % 4 == 0 && bm == 2 {\n\t\tif bd > 29 {\n\t\t\treturn false\n\t\t}\n\t} else if day[bm] < bd {\n\t\treturn false\n\t}\n\tby += 18\n\tif yy > by || (yy == by && mm > bm) || (yy == by && mm == bm && dd >= bd) {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\tvar bd, bm, by int\n\tfmt.Fscanf(reader, \"%d.%d.%d\\n\", &dd, &mm, &yy)\n\tfmt.Fscanf(reader, \"%d.%d.%d\\n\", &bd, &bm, &by)\n\tif isOk(bd, bm, by) || isOk(bd, by, bm) || isOk(bm, bd, by) || isOk(bm, by, bd) || isOk(by, bd, bm) || isOk(by, bm, bd) {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "f4a001f0b3160fdac5a3c4ded4189394", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.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\txs := make([]int, n*2)\n\tys := make([]int, n*2)\n\tarea := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&xs[2*i], &ys[2*i], &xs[2*i+1], &ys[2*i+1])\n\t\tarea += (xs[2*i+1] - xs[2*i]) * (ys[2*i+1] - ys[2*i])\n\t}\n\tsort.Ints(xs)\n\tsort.Ints(ys)\n\tsideA, sideB := xs[2*n-1] - xs[0], ys[2*n-1] - ys[0]\n\tsquareArea := sideA * sideB\n\tif sideA == sideB && squareArea == area {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "ee6be3e2282ed9125cd94c6154979d0d", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nconst (\n\tMaxSum = 10005\n\tMaxNums = 101\n\tType = 2\n\tSame = 0\n\tDifferent = 1\n)\n\nvar n int\nvar a [MaxNums]int\nvar dp[MaxSum][MaxNums][Type]bool\n\nfunc computeDp() {\n\tdp[a[0]][1][Same] = true\n\tfor i := 1; i < n; i++ {\n\t\tfor s := MaxSum - 1; s >= 0; s-- {\n\t\t\tfor cnt := 1; cnt <= i; cnt++ {\n\t\t\t\tif dp[s][cnt][Same] {\n\t\t\t\t\tk := s / cnt\n\t\t\t\t\tif k == a[i] {\n\t\t\t\t\t\tdp[s+k][cnt+1][Same] = true\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdp[s+a[i]][cnt+1][Different] = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif dp[s][cnt][Different] {\n\t\t\t\t\tdp[s+a[i]][cnt+1][Different] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdp[a[i]][1][Same] = true\n\t}\n}\n\nfunc main() {\n\tfmt.Scanf(\"%d\\n\", &n)\n\tcounter := make(map[int]int)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a[i])\n\t\tcounter[a[i]]++\n\t}\n\n\tif len(counter) == 2 {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\n\tcomputeDp()\n\n\tbest := 1\n\tfor weight := range counter {\n\t\tfor count := 1; count <= counter[weight]; count++ {\n\t\t\tif dp[weight*count][count][Same] && !dp[weight*count][count][Different] && best < count {\n\t\t\t\tbest = count\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(best)\n}", "lang_cluster": "Go", "tags": ["math", "dp"], "code_uid": "dbf9f7ce254563b6f08eab961d117664", "src_uid": "ccc4b27889598266e8efe73b8aa3666c", "difficulty": 2100.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 fmt.Print((n-1)/2)\n}", "lang_cluster": "Go", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "bbd6174bf0d556af0eb6733696bd0ddf", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.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)\n\tnuts := []int{}\n\tfor i := 0; i < n; i++ {\n\t\tx := 0\n\t\tfmt.Scanf(\"%d\", &x)\n\t\tif x == 1 {\n\t\t\tnuts = append(nuts, i)\n\t\t}\n\t}\n\tif len(nuts) == 0 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\tret := int64(1)\n\tfor i := 1; i < len(nuts); i++ {\n\t\tret = ret * int64(nuts[i] - nuts[i-1])\n\t}\n\tfmt.Println(ret)\n}\n", "lang_cluster": "Go", "tags": ["combinatorics"], "code_uid": "b9acd2228eaa16ff1c57b9031561d1d4", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\td:=n%10\n\tif d>=5 {\n\t\tfmt.Print(\"-O|\")\n\t} else {\n\t\tfmt.Print(\"O-|\")\n\t}\n\td%=5\n\tfor i:=0;i0;i-- {\n\t\tfmt.Print(\"O\")\n\t}\n\tfmt.Println()\n\tn/=10\n\n\tfor ;n>0; {\n\t\td:=n%10\n\tif d>=5 {\n\t\tfmt.Print(\"-O|\")\n\t} else {\n\t\tfmt.Print(\"O-|\")\n\t}\n\td%=5\n\tfor i:=0;i0;i-- {\n\t\tfmt.Print(\"O\")\n\t}\n\tfmt.Println()\n\tn/=10\n\t}\n}\n\n\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "7174112b786d0857f1ef90629c166305", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "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\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 reduce(x int) int {\n fmt.Fprintf(os.Stderr, \"%d ->\", x)\n y, power := 0, 1\n for x != 0 {\n if x%10 != 0 {\n y += power * (x%10)\n power *= 10\n }\n x /= 10\n }\n fmt.Fprintf(os.Stderr, \" %d\\n\", y)\n return y\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 c := a + b\n result := \"NO\"\n if reduce(a) + reduce(b) == reduce(c) {\n result = \"YES\"\n }\n writer.WriteString(fmt.Sprintf(\"%s\\n\", result))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "5999ffe6f41439f0c66fa639c9484659", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "//In the Name of God\n//Ya Ali\n\npackage main\n\nimport \"fmt\"\n\nconst MOD int = 1e9 + 7\n\nfunc mulInt(x, y int) int {\n\treturn int(int64(x) * int64(y) % int64(MOD))\n}\n\nfunc powInt(a int, k int) (r int) {\n\tr = 1\n\tfor k > 0 {\n\t\tif k % 2 == 1 {\n\t\t\tr = mulInt(r, a)\n\t\t}\n\t\ta = mulInt(a, a)\n\t\tk /= 2\n\t}\n\treturn\n}\n\ntype Matrix struct {\n\tn int\n\tm int\n\ta [][]int\n}\n\nfunc makeMat(n, m int) Matrix {\n\ta := make([][]int, n)\n\tfor i := range a {\n\t\ta[i] = make([]int, m)\n\t}\n\treturn Matrix{n, m, a}\n}\n\nfunc mulMat(a Matrix, b Matrix) (c Matrix) {\n\tc = makeMat(a.n, b.m)\n\tfor i := 0; i < a.n; i ++ {\n\t\tfor j := 0; j < b.m; j ++ {\n\t\t\tfor k := 0; k < a.n; k ++ {\n\t\t\t\tc.a[i][j] = (c.a[i][j] + mulInt(a.a[i][k], b.a[k][j])) % MOD\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\nfunc powMat(a Matrix, k int) (c Matrix) {\n\tc = makeMat(a.n, a.m)\n\tfor i := 0; i < a.n; i ++ {\n\t\tc.a[i][i] = 1\n\t}\n\tfor k > 0 {\n\t\tif k%2 == 1 {\n\t\t\tc = mulMat(c, a)\n\t\t}\n\t\ta = mulMat(a, a)\n\t\tk /= 2\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar n, k int\n\t_, _ = fmt.Scan(&n, &k)\n\n\tar := make([]int, n)\n\n\tA, a := 0, 0\n\tB := 0\n\n\tfor i := 0; i < n; i ++ {\n\t\t_, _ = fmt.Scan(&ar[i])\n\t\tA += ar[i]\n\t}\n\n\tfor i := 0; i < A; i ++ {\n\t\ta += ar[n - 1 - i]\n\t}\n\n\tB = n - A\n\n\tmat := makeMat(A + 1, A + 1)\n\n\tfor i := 0; i <= A; i ++ {\n\t\tif B >= A - i {\n\t\t\tpls := (A - i) * (A - i)\n\t\t\tmns := i * (B - A + i)\n\t\t\tsm := n * (n - 1) / 2 - pls - mns\n\t\t\tif i > 0 {\n\t\t\t\tmat.a[i - 1][i] = mns\n\t\t\t}\n\t\t\tif i < A {\n\t\t\t\tmat.a[i + 1][i] = pls\n\t\t\t}\n\t\t\tmat.a[i][i] = sm\n\t\t}\n\t}\n\n\tmat = powMat(mat, k)\n\tres := makeMat(A + 1, 1)\n\tres.a[a][0] = 1\n\n\tres = mulMat(mat, res)\n\n\tans := mulInt(res.a[A][0], powInt(powInt(n * (n - 1) / 2, k), MOD - 2))\n\n\tfmt.Println(ans)\n}\n", "lang_cluster": "Go", "tags": ["probabilities", "matrices", "dp", "combinatorics"], "code_uid": "98aafc65fd5a8e20d611f8a7dff7fa03", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.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 CF1030C(_r io.Reader, out io.Writer) {\n\tvar n, s int\n\tvar a []byte\n\tFscan(bufio.NewReader(_r), &n, &a)\no:\n\tfor i, v := range a[:n-1] {\n\t\ts += int(v & 15)\n\t\tfor j := i + 1; j < n; {\n\t\t\ts2 := int(a[j] & 15)\n\t\t\tfor j++; j < n && (s2 < s || s2 == s && a[j] == '0'); j++ {\n\t\t\t\ts2 += int(a[j] & 15)\n\t\t\t}\n\t\t\tif s2 != s {\n\t\t\t\tcontinue o\n\t\t\t}\n\t\t}\n\t\tFprintln(out, \"YES\")\n\t\treturn\n\t}\n\tFprintln(out, \"NO\")\n}\n\nfunc main() { CF1030C(os.Stdin, os.Stdout) }\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "b53524f3261e38377b8dc620c2ebd662", "src_uid": "410296a01b97a0a39b6683569c84d56c", "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\"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\tn, _ := strconv.ParseInt(*<-strs, 10, 64)\n\tb, _ := strconv.ParseInt(*<-strs, 10, 64)\n\tp, _ := strconv.ParseInt(*<-strs, 10, 64)\n\n\ty := n * p\n\t\n\tx := int64(0)\n\n\tfor a := int64(1 << 9); a > 1; a >>= 1 {\n\t\tif a & n != 0 {\n\t\t\tx += a * b + (a >> 1)\n\t\t\tn -= (a >> 1)\n\t\t\ta = int64(1 << 9)\n\t\t}\n\t}\n\n\tws.WriteString(fmt.Sprintf(\"%d %d\", x, y))\n\n\tws.Flush()\n\treturn\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation"], "code_uid": "27e5949e4e93c810961e4bcc1e8f9350", "src_uid": "eb815f35e9f29793a120d120968cfe34", "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\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\ts1 := 0\n\tfor i := 0; i < n; i++ {\n\t\tvar x int\n\t\tfmt.Fscan(in, &x)\n\t\ts1 += x\n\t}\n\n\ts2 := 0\n\tfor i := 0; i < n; i++ {\n\t\tvar x int\n\t\tfmt.Fscan(in, &x)\n\t\ts2 += x\n\t}\n\n\tif s1 >= s2 {\n\t\tfmt.Fprintln(out, \"YES\")\n\t} else {\n\t\tfmt.Fprintln(out, \"NO\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "0342d6d2b9e56d562cd0f99c6cded724", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "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\treader := bufio.NewReader(os.Stdin)\n\n\tvar list [8][8]string\n\n\tresult := 0\n\n\tfor i := 0; i < 8 ; i++ {\n\t\tinput, _ := reader.ReadString('\\n')\n\n\t\tfor j := 0; j < 8; j++ {\n\t\t\tlist[i][j] = string(input[j])\n\t\t}\n\t}\n\n\tfor i := 0; i < 8 ; i++ {\n\t\tnow := true\n\n\t\tfor j := 0; j < 8 ; j++ {\n\t\t\tif list[i][j] != \"B\" {\n\t\t\t\tnow = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif now {\n\t\t\tresult++;\n\t\t}\n\t}\n\n\tfor i := 0; i < 8 ; i++ {\n\t\tnow := true\n\n\t\tfor j := 0; j < 8 ; j++ {\n\t\t\tif list[j][i] != \"B\" {\n\t\t\t\tnow = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif now {\n\t\t\tresult++;\n\t\t}\n\t}\n\n\tif result == 16 {\n\t\tresult = 8\n\t}\n\n\tfmt.Println(result)\n}", "lang_cluster": "Go", "tags": ["brute force", "constructive algorithms"], "code_uid": "52009cfe58e9faf72405c933fd560a17", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar k int\n\tfmt.Scanf(\"%d\\n\", &k)\n\n\tvar concatedStr strings.Builder\n\tfor i := 1; i <= k; i++ {\n\t\tconcatedStr.WriteString(strconv.Itoa(i))\n\t}\n\tfmt.Println(string(concatedStr.String()[k-1]))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "cda09485e3cd8b02f595a7fff3caea87", "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)\n\ntype edge struct {\n\tid int\n\tn1 *node\n\tn2 *node\n\tw int\n\tleft int\n}\n\ntype node struct {\n\tid int\n\tedges []*edge\n}\nvar edges []*edge\nvar nodes []*node\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tq := 1\n\t//fmt.Fscanf(in, \"%d\\n\", &q)\n\tfor ii := 0; ii < q; ii++ {\n\t\tn := 0\n\t\tfmt.Fscanf(in, \"%d\\n\", &n)\n\t\tf := make([][][]int, n+1) // f[i][j] filled in the first i elements, remaining j odd number\n\t\ta := make([]int, n+1)\n\t\tfor i := 1; i <= n; i++ {\n\t\t\tfmt.Fscanf(in, \"%d\", &a[i])\n\t\t}\n\t\tfmt.Fscanf(in, \"\\n\")\n\t\tfor i := 0; i < n + 1; i++ {\n\t\t\tf[i] = make([][]int, n+1)\n\t\t\tfor j := 0; j < n + 1; j++ {\n\t\t\t\tf[i][j] = make([]int, 2)\n\t\t\t\tf[i][j][0] = 9999999\n\t\t\t\tf[i][j][1] = 9999999\n\t\t\t}\n\t\t}\n\t\tif a[1] == 0 {\n\t\t\tf[1][(n+1)/2-1][1] = 0\n\t\t\tif n > 1 {\n\t\t\t\tf[1][(n+1)/2][0] = 0\n\t\t\t}\n\t\t} else if a[1] % 2 == 1 {\n\t\t\tf[1][(n+1)/2-1][1] = 0\n\t\t} else {\n\t\t\tf[1][(n+1)/2][0] = 0\n\t\t}\n\t\tfor i := 2; i <= n; i++ {\n\t\t\tfor j := 0; j < n; j++ {\n\t\t\t\tif a[i] == 0 {\n\t\t\t\t\tf[i][j][0] = min(f[i-1][j][0], f[i-1][j][1] + 1)\n\t\t\t\t\tf[i][j][1] = min(f[i-1][j+1][0] + 1, f[i-1][j+1][1])\n\t\t\t\t} else if a[i] % 2 == 0 {\n\t\t\t\t\tf[i][j][0] = min(f[i-1][j][0], f[i-1][j][1] + 1)\n\t\t\t\t} else {\n\t\t\t\t\tf[i][j][1] = min(f[i-1][j+1][0] + 1, f[i-1][j+1][1])\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//fmt.Println(f[1])\n\t\tfmt.Fprintf(out, \"%d\\n\", min(f[n][0][0], f[n][0][1]))\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 solve(e *edge, from *node) int {\n\tn1 := e.n1\n\tn2 := e.n2\n\tcur := 0\n\tif n1 != from {\n\t\tcur += solveNode(n1, e)\n\t\te.left = cur\n\t}\n\tif n2 != from {\n\t\tcur += solveNode(n2, e)\n\t\te.left = cur\n\t}\n\treturn e.left\n}\n\nfunc solveNode(n *node, from *edge) int {\n\tif len(n.edges) == 1 && n.edges[0] == from{\n\t\treturn 1\n\t}\n\tcur := 1\n\tfor _, e := range n.edges {\n\t\tif e != from {\n\t\t\tcur += solve(e, n)\n\t\t}\n\t}\n\treturn cur\n}", "lang_cluster": "Go", "tags": ["sortings", "dp", "greedy"], "code_uid": "f91aab49272b6a8c5e54f12552d1bb66", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/992/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\tl, r, x, y int64\n)\n\nfunc main() {\n\tl, r, x, y = ReadInt64_4()\n\n\tans := 0\n\tcy := y / x\n\tfor i := int64(1); i*i <= cy; i++ {\n\t\tif cy%i == 0 {\n\t\t\tda := i\n\t\t\tdb := cy / i\n\n\t\t\tif Gcd(da, db) != 1 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\ta, b := da*x, db*x\n\t\t\tif C(a, b) {\n\t\t\t\tif a == b {\n\t\t\t\t\tans++\n\t\t\t\t} else {\n\t\t\t\t\tans += 2\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n\nfunc C(a, b int64) bool {\n\treturn l <= a && a <= r && l <= b && b <= r && Gcd(a, b) == x && Lcm(a, b) == y\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 int64) int64 {\n\tif a < 0 || b < 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\tif a == 0 {\n\t\treturn b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\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 int64) int64 {\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/*******************************************************************/\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": "1832ce6e3222a00911cdb5f324320ae9", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// x = b·s(x)^a + c\n\nfunc main() {\n\tconst max_x int64 = 1000000000\n\tconst max_digits int64 = 9\n\n\tvar a, b, c int64\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &a, &b, &c); err != nil {\n\t\treturn\n\t}\n\n\tcnt := 0\n\tvar all_res []string\n\n\tfor i := int64(1); i <= 9*max_digits; i++ {\n\t\ty := b*power(i, a) + c\n\t\tif y < max_x && s(y) == i {\n\t\t\tcnt++\n\t\t\tall_res = append(all_res, strconv.FormatInt(y, 10))\n\t\t}\n\t}\n\n\tfmt.Println(cnt)\n\tfmt.Println(strings.Join(all_res, \" \"))\n}\n\nfunc s(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 power(sx, n int64) int64 {\n\tres := sx\n\tfor i := int64(1); i < n; i++ {\n\t\tres *= sx\n\t}\n\treturn res\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "804fbcc07b4bfcb4dd79c13cf2a394ec", "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\t\"strconv\"\n\t\"strings\"\n)\n\n/*\ntarget string ACTG\n\ninput:\n4\nZCTH\noutput:\n2\n*/\n\nconst MaxUint = ^uint(0)\n\nfunc Abs(a, b byte) (gap uint) {\n\tif a > b {\n\t\tgap = uint(a - b)\n\t} else {\n\t\tgap = uint(b - a)\n\t}\n\n\tif gap > 13 {\n\t\treturn 26 - gap\n\t}\n\treturn gap\n}\n\nfunc mutate(pattern, source []byte) (minOp uint) {\n\tminOp = MaxUint\n\n\tp_l, s_l := len(pattern), len(source)\n\n\tif s_l < p_l {\n\t\treturn minOp\n\t}\n\n\tfor i := 0; i+p_l-1 <= s_l-1; i += p_l {\n\t\ttmpOp := uint(0)\n\t\tfor j := range pattern {\n\t\t\ttmpOp += Abs(pattern[j], source[i+j])\n\t\t}\n\t\tif tmpOp < minOp {\n\t\t\tminOp = tmpOp\n\t\t}\n\t}\n\n\treturn\n}\n\nfunc main() {\n\tvar genome = []byte(\"ACTG\")\n\tminOp := MaxUint\n\n\tr := bufio.NewReader(os.Stdin)\n\n\tl_s, _ := r.ReadString('\\n')\n\tl, _ := strconv.Atoi(strings.Trim(l_s, \"\\n\\r\"))\n\tstr := make([]byte, l)\n\tr.Read(str)\n\tfor i := 0; i < len(genome); i++ {\n\t\tcurOp := mutate(genome, str[i:])\n\t\tif curOp < minOp {\n\t\t\tminOp = curOp\n\t\t}\n\t}\n\tfmt.Println(minOp)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "strings"], "code_uid": "6c6fb820eb42dbe99f70dd2b3f311af3", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"bufio\"\n \"io\"\n \"os\"\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 n := ni64()\n if n%3 != 0 {\n pri64(n/3 + 1)\n } else {\n k := int64(3)\n for n%k == 0 {\n k *= 3\n }\n pri64(n/k + 1)\n }\n endl()\n w.Flush()\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "d1249511065a8663b3e95342d98ab068", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.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\"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\n\tyear := nextInt()\n\tday := 0\n\tleapYear := isLeapYear(year)\n\n\tfor true {\n\t\tyear++\n\t\tday += 365\n\t\tlog.Print(year, day, isLeapYear(year))\n\t\tif isLeapYear(year) {\n\t\t\tday += 1\n\t\t}\n\n\t\tif day%7 == 0 && leapYear == isLeapYear(year) {\n\t\t\tprintln(year)\n\t\t\tbreak\n\t\t}\n\t}\n}\n\nfunc isLeapYear(year int) bool {\n\tif year%400 == 0 || (year%4 == 0 && year%100 != 0) {\n\t\treturn true\n\t}\n\n\treturn false\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": "cd826cc6f77c0d9d346729f7f8119175", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, a int\n\tvar arr [101]int\n\tcounter := 0\n\tfmt.Scan(&n, &a)\n\n\ta--\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&arr[i])\n\t}\n\n\tfor i := 0; i < n; i++ {\n\n\t\tif 2*a-i < n && 2*a-i >= 0 {\n\t\t\tcounter += arr[i] & arr[2*a-i]\n\t\t} else {\n\t\t\tcounter += arr[i]\n\t\t}\n\t}\n\n\tfmt.Println(counter)\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "implementation"], "code_uid": "06fabc305f4e17a49d530baf9b6a579f", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k, lo, hi int64\n\tfmt.Scan(&n, &k)\n\tif k != 0 && k != n {\n\t\tlo = 1\n\t}\n\tif n < k*3 {\n\t\thi = n - k\n\t} else {\n\t\thi = k * 2\n\t}\n\tfmt.Println(lo, hi)\n}\n", "lang_cluster": "Go", "tags": ["math", "constructive algorithms"], "code_uid": "c38de8ffb10fec77fa243b15970b2325", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.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 fmt.Println(n / 2520)\n}", "lang_cluster": "Go", "tags": ["math", "number theory"], "code_uid": "67de6bc083290666758bd554bedec364", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n, k uint64\n fmt.Scanln(&n, &k)\n if k == 1 || n == 1 {\n fmt.Println(n)\n } else {\n var degree_2 uint64 = 1\n for {\n n /= 2\n if n == 0 {\n break\n } else {\n degree_2 += 1\n }\n }\n \n result := (uint64(1) << degree_2) - 1\n fmt.Println(result)\n }\n}", "lang_cluster": "Go", "tags": ["constructive algorithms", "number theory", "bitmasks"], "code_uid": "fe8275b881c4a0c87ab6889efd727188", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int64\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tmax := int64(-1)\n\tfor i := int64(1); i <= n/2; i++ {\n\t\tif n%i == 0 {\n\t\t\tj := n / i\n\t\t\tif i > j {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tif is_lovely(j) {\n\t\t\t\t\tfmt.Println(j)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif is_lovely(i) {\n\t\t\t\t\tif i > max {\n\t\t\t\t\t\tmax = i\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif max > 0 {\n\t\tfmt.Println(max)\n\t} else {\n\t\tfmt.Println(1)\n\t}\n}\n\nfunc is_lovely(x int64) bool {\n\tfor i := int64(2); i*i <= x; i++ {\n\t\tif x%(i*i) == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "068aef478193a1f72419390161ffcbff", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 388A\npackage main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n, rnt int\n\tb := true\n\tfmt.Scan(&n)\n\ts := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&s[i])\n\t}\n\tsort.Ints(s)\n\tfor rnt = 1; rnt <= n; rnt++ {\n\t\tb = true\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif (s[j] - j/rnt) < 0 {\n\t\t\t\tb = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif j == n {\n\t\t\t\tb = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif b {\n\t\t\tfmt.Println(rnt)\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["sortings", "greedy"], "code_uid": "eec047b9c9066b93cd71bff2c70f9d54", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// ProblemURL : https://codeforces.com/problemset/problem/1157/A\n// ---------------------------------------------\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x int64\n\tfmt.Scan(&x)\n\tm := make(map[int64]bool, 1e5)\n\tf := func(x int64) int64 {\n\t\tx++\n\t\tfor x%10 == 0 {\n\t\t\tx /= 10\n\t\t}\n\t\treturn x\n\t}\n\tm[x] = true\n\tfor {\n\t\tx = f(x)\n\t\tif _, exists := m[x]; exists {\n\t\t\tbreak\n\t\t}\n\t\tm[x] = true\n\t}\n\tfmt.Println(len(m))\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "da5e2c87aedd4bf926a6d47f3b5685b3", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/817/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\tx1, y1, x2, y2 int\n\tx, y int\n)\n\nfunc main() {\n\tx1, y1, x2, y2 = ReadInt4()\n\tx, y = ReadInt2()\n\n\tdx := AbsInt(x1 - x2)\n\tdy := AbsInt(y1 - y2)\n\n\tif dx == 0 && dy == 0 {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\n\tif dx%x != 0 || dy%y != 0 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tqx := dx / x\n\tqy := dy / y\n\tqx %= 2\n\tqy %= 2\n\n\tif qx != qy {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\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/*******************************************************************/\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", "implementation", "number theory"], "code_uid": "5a5e62184e9b0f4ba0d7badf50cd03f2", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.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/*\n L(x) = SUM( y_i * PROD((x-x_j)/(x_i-x_j)) ) j = 1,n; j != i; i = 1,n\n x_i = i-1\n y_i = L(x_i)\n*/\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 L := calc(y, n, &mod)\n fmt.Printf(\"%d\", L)\n }\n}\n", "lang_cluster": "Go", "tags": ["math"], "code_uid": "ff453d9e7ab2db11f4ace2d5daf6f704", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.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\nvar n, m, mod int64\nvar matrix [][]int\n\nfunc multiply(one, two [][]int) [][]int {\n\tres := make([][]int, m)\n\tfor i := 0; i < int(m); i++ {\n\t\tres[i] = make([]int, m)\n\t}\n\tfor i := 0; i < int(m); i++ {\n\t\tfor j := 0; j < int(m); j++ {\n\t\t\tfor k := 0; k < int(m); k++ {\n\t\t\t\tres[i][j] += int(int64(one[i][k]) * int64(two[k][j]) % mod)\n\t\t\t\tres[i][j] %= int(mod)\n\t\t\t}\n\t\t}\n\t}\n\treturn res\n}\n\nfunc power(exp int64, base [][]int) [][]int {\n\n\tif exp == 1 {\n\t\treturn base\n\t}\n\n\tres := power(exp/2, base)\n\tres = multiply(res, res)\n\tif exp&1 == 1 {\n\t\tres = multiply(res, base)\n\t}\n\treturn res\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tmod = 1000000007\n\tscanf(\"%d %d\\n\", &n, &m)\n\tif n < m {\n\t\tprintf(\"1\")\n\t\treturn\n\t}\n\tif n == m {\n\t\tprintf(\"2\")\n\t\treturn\n\t}\n\tmatrix = make([][]int, m)\n\tfor i := 0; i < int(m); i++ {\n\t\tmatrix[i] = make([]int, m)\n\t}\n\tmatrix[0][0] = 1\n\tmatrix[0][m-1] = 1\n\tfor i := 1; i < int(m); i++ {\n\t\tmatrix[i][i-1] = 1\n\t}\n\n\tfmt.Println(power(n, matrix)[0][0])\n\n}\n", "lang_cluster": "Go", "tags": ["math", "matrices", "dp"], "code_uid": "bdd2d91b854ec023cc1b682eace3a693", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// 79A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y int64\n\tw := true\n\tfmt.Scan(&x, &y)\n\tfor x*10+y >= 22 && y >= 2 {\n\t\tif w || (y < 12) {\n\t\t\tx -= 2\n\t\t\ty -= 2\n\t\t} else if y < 22 {\n\t\t\tx--\n\t\t\ty -= 12\n\t\t} else {\n\t\t\ty -= 22\n\t\t}\n\t\tw = !w\n\t}\n\tif w == true {\n\t\tfmt.Print(\"Hanako\")\n\t} else {\n\t\tfmt.Print(\"Ciel\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["greedy"], "code_uid": "06febc45c305b184afcf62274343eb6e", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var n,r,R float64\n fmt.Scan(&n,&R,&r)\n if ((n == 1) && (r <= R)) || ((math.Asin(r/(R-r))-(math.Pi/n)) <= 0.0000000001) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n", "lang_cluster": "Go", "tags": ["math", "geometry"], "code_uid": "e0578dd30fcd6b3d1429a63925488f1c", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\t// Read input.\n\tvar N int\n\tfmt.Scan(&N)\n\ta := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tvar tmp int\n\t\tfmt.Scan(&tmp)\n\t\ta[i] = tmp\n\t}\n\t// Start solving.\n\tif N == 1 && a[0] == 0 {\n\t\tfmt.Println(\"UP\")\n\t\treturn\n\t}\n\tif N == 1 && a[0] == 15 {\n\t\tfmt.Println(\"DOWN\")\n\t\treturn\n\t}\n\tif N == 1 && a[0] != 0 && a[0] != 15 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\t// From here I assume a has more than two elements.\n\tif a[N-2] > a[N-1] && a[N-1] != 0 {\n\t\tfmt.Println(\"DOWN\")\n\t\treturn\n\t}\n\tif a[N-2] < a[N-1] && a[N-1] != 15 {\n\t\tfmt.Println(\"UP\")\n\t\treturn\n\t}\n\tif a[N-1] == 0 {\n\t\tfmt.Println(\"UP\")\n\t\treturn\n\t}\n\tif a[N-1] == 15 {\n\t\tfmt.Println(\"DOWN\")\n\t\treturn\n\t}\n}\n", "lang_cluster": "Go", "tags": ["implementation"], "code_uid": "3d0fa198a078e2e8b7737163cb377a39", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"sort\"\n)\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc find_last_le_idx(a []int, target int )int {\n\t//if not exist rturn -1\n\n\ts := 0\n\te := len(a)\n\tfor ;s < e;{\n\t\tmid := s +(e- s)/2\n\t\tif a[mid ] <= target{\n\t\t\ts = mid + 1\n\t\t}else {\n\t\t\te = mid\n\t\t}\n\t}\n\treturn s - 1\n}\n\n\nfunc find_first_ge_idx(a []int, target int )int {\n\t//if not exist rturn -1\n\n\ts := 0\n\te := len(a)\n\tfor ;s < e;{\n\t\tmid := s +(e- s)/2\n\t\tif a[mid ] < target{\n\t\t\ts = mid + 1\n\t\t}else {\n\t\t\te = mid\n\t\t}\n\t}\n\n\treturn s\n}\n\nfunc maxSumSubmatrix(a [][]int, target int) int {\n\trow := len(a)\n\tif row == 0{\n\t\treturn 0\n\t}\n\tcol := len(a[0])\n\n\tpre_sum := make([][]int, row)\n\tfor i := range pre_sum{\n\t\tpre_sum[i] = make([]int ,col)\n\t}\n\n\tfor i := 0;i < row; i ++{\n\t\tfor j :=0;j < col; j ++{\n\t\t\tif j == 0 {\n\t\t\t\tpre_sum[i][j] = a[i][j]\n\t\t\t}else {\n\t\t\t\tpre_sum[i][j] = pre_sum[i][j-1] + a[i][j]\n\t\t\t}\n\t\t}\n\t}\n\n\tnear := -100000000\n\tfor i := 0; i < col ; i ++{\n\t\tfor j :=i ;j near) {\n\t\t\t\t//\t\tnear = cur\n\t\t\t\t//\t}\n\t\t\t\t//\ttmp = append(tmp, cur)\n\t\t\t\t//}\n\t\t\t}\n\n\t\t}\n\t}\n\treturn near\n}\n\nfunc q(matrix [][]int, k int) int {\n\trow := len(matrix)\n\tcol := len(matrix[0])\n\tnear := -1000000\n\tfor left := 0; left < col ; left ++{\n\t// 以left为左边界,每行的总和\n\t\t_sum :=make([]int, row)\n\t//for right in range(left, col):\n\t\tfor right :=left ;right 1 {\n\t\t\tif idx - left +1 < min_l{\n\t\t\t\tmin_l = idx - left + 1\n\t\t\t\tm_l = left\n\t\t\t\tm_r = idx\n\t\t\t}\n\t\t\tcounter[record[left]] --\n\n\t\t\t//}else {\n\t\t\t//\n\t\t\t//}\n\t\t\tif counter[record[left]] == 0 {\n\t\t\t\ttarget --\n\t\t\t}\n\t\t\tleft ++\n\t\t}else{\n\t\t\t\tidx ++\n\t\t\tcounter[record[idx]] ++\n\t\t\tif counter[record[idx]] == 1{\n\t\t\t\ttarget ++\n\t\t\t}\n\t\t\t//idx++\n\t\t}\n\t}\n\tfmt.Println(m_l + 1, m_r + 1)\n}\n\nfunc ini(){\n\tvar n int\n\t//var k int\n\tfmt.Scan(&n)\n\t//fmt.Scan(&k)\n\tfor i := 0;i < n; i ++{\n\t\tfmt.Scan(&ori[i])\n\t\tfmt.Scan(&energy[i])\n\t}\n\tR := -1\n\tL := 0\n\tfor i :=0; i < n; i ++{\n\t\t//if record[L] == i - k{\n\t\t//\tL ++\n\t\t//}\n\t\tfor ;R >= L &&ori[i] >ori[record[R]];R--{\n\t\t\tcounter[i]\t+= energy[record[R]]\n\t\t}\n\t\ttmp := energy[i]\n\t\tfor ;R >= L &&ori[i] ==ori[record[R]];R--{\n\t\t\ttmp += energy[i]\n\t\t}\n\t\tR ++\n\t\trecord[R] = i\n\t\tif R != 0 {\n\t\t\tcounter[record[R - 1]] += tmp\n\t\t}\n\t}\n\tm := -1\n\tfor i :=0; i m{\n\t\t\tm = counter[i]\n\t\t}\n\t}\n\tfmt.Println(m)\n}\ntype S struct {\n\tIdx int\n\tTime int\n\n}\ntype intSlice []S\n\nfunc (p intSlice) Len() int { return len(p) }\nfunc (p intSlice) Less(i, j int) bool { return p[i].Time > p[j].Time }\nfunc (p intSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }\n\nvar roww [1000]int\nvar coll [1000]int\nfunc inii(){\n\tvar m,n,k,l,d int\n\t//var k int\n\trow := make(intSlice, 10000)\n\tcol := make(intSlice, 10000)\n\tfmt.Scan(&m, &n, &k, &l,&d)\n\t//fmt.Scan(&k)\n\tfor i := 0;i < d; i ++{\n\t\tvar x1,y1,x2,y2 int\n\t\tfmt.Scan(&x1,&y1,&x2,&y2)\n\t\tif x1 == x2 {\n\t\t\tif y1 > y2 {\n\t\t\t\ty1,y2 = y2,y1\n\t\t\t}\n\t\t\tcol[y1].Idx = y1\n\t\t\tcol[y1].Time ++\n\t\t}else{\n\t\t\t\tif x1 > x2{\n\t\t\t\t\tx1,x2 = x2,x1\n\t\t\t\t}\n\t\t\t\trow[x1].Idx = x1\n\t\t\trow[x1].Time ++\n\t\t}\n\t\t//fmt.Scan(&energy[i])\n\t}\n\t//row = row[:m+1]\n\t//col = col[:n + 1]\n\tsort.Sort(row)\n\tsort.Sort(col)\n\trow = row[:k+1]\n\tcol = col[:l + 1]\n\tsort.Sort(row)\n\tsort.Sort(col)\n\tfor i := 0;i < k-1;i ++ {\n\t\tfmt.Print(row[i].Idx,\" \")\n\t}\n\tfmt.Print(row[k -1 ].Idx,\"\\n\")\n\tfor i := 0;i < l-1;i ++ {\n\t\tfmt.Print(col[i].Idx,\" \")\n\t}\n\tfmt.Print(col[l -1 ].Idx,\"\\n\")\n\n}\n\n\nfunc next_per(){\n\tvar n int\n\tvar m int\n\tfmt.Scan(&n,&m)\n\ta :=make([]int, n)\n\tfor i:=0;i 0;m--{\n\t\ti := 0\n\t\tfor i = n-2;i >=0;i --{\n\t\t\tif a[i] < a[i + 1]{\n\t\t\t\tbreak\n\t\t\t}\n\n\n\t\t}\n\t\t//t := a[i+1]\n\t\tj := 0\n\t\tfor j = i + 1;j < n;j ++{\n\t\t\tif a[j] <= a[i]{\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\ta[i],a[j-1] = a[j-1],a[i]\n\t\tsort.Ints(a[i + 1:])\n\n\t}\n\tfmt.Println(a)\n\n\n}\nvar s string\nvar n,ans,length,carry int64\n//var ans int\n//var length int\n//var carry int\n//func max(x,y int)int{\n//\tif x > y{\n//\t\treturn x\n//\t}\n//\treturn y\n//}\nfunc maxf(x, y int64)int64{\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc get(k int)int{\n\tvar x int64\n\tvar t int64 = 1\n\ti := k\n\tfor ;i >= 0; i -- {\n\t\tif x + maxf(int64(1), (int64)(s[i]-'0')) * int64(t) >=n{\n\t\t\tbreak\n\t\t}\n\t\tx += int64(s[i]-'0') * t\n\t\tt *= 10\n\t}\n\tfor ;s[i+ 1] == '0'&& i < k-1;i ++{\n\n\t}\n\tans += x * carry\n\treturn i\n}\nfunc qq(){\n\n\tcarry = 1\n\tfmt.Scan(&n, &s)\n\ti := len(s) - 1\n\tfor ;i >=0;{\n\t\ti = get(i)\n\t\tcarry *=n\n\t}\n\tfmt.Println( ans)\n\n}\n\nfunc main(){\n\t//a := [][]int{{28,4,-19,18,-7,-10,27,19,1,16,0,10,-17,11,11,27,-1,10,12,-1},\n\t//\t{-2,-19,17,4,25,-20,4,3,4,28,-10,7,16,-14,-3,-19,6,17,-4,-7},\n\t//\t{2,8,18,-17,-2,10,-6,-5,11,10,22,-6,19,-16,6,-4,18,5,22,-17},\n\t//\t{-14,-7,-20,13,-19,-20,-15,21,-11,-10,-8,-9,10,13,6,-10,15,9,-15,-2},\n\t//\t{-18,26,12,8,2,16,-17,12,0,-5,9,-3,-12,-11,3,-6,-18,16,-7,-14},\n\t//\t{5,29,25,22,11,-3,-2,-15,4,13,-17,-2,0,-2,20,10,-18,6,25,-20},\n\t//\t{5,-7,8,5,15,22,8,-5,22,-18,-5,-14,23,2,-8,12,-16,-18,12,-12},\n\t//\t{27,18,4,11,-3,12,-4,-8,-3,25,-9,24,-14,5,11,-9,-17,0,25,-15},\n\t//\t{26,-7,18,4,4,18,-17,9,-19,-9,-19,-8,-4,-13,10,-11,6,-16,-12,12},\n\t//\t{28,22,7,11,-6,13,8,22,7,-14,17,14,10,29,16,9,-3,18,-9,10},\n\t//\t{27,19,-10,-9,1,3,14,1,7,3,-3,16,-2,9,14,-7,-19,-5,23,19},\n\t//\t{-17,7,-20,8,-5,-6,-2,25,29,16,23,4,4,27,16,17,9,20,-6,22},\n\t//\t{2,9,-13,1,-18,25,4,7,25,26,-4,8,-19,18,6,-7,-5,7,21,-8},\n\t//\t{-2,11,1,29,6,-16,-8,3,7,11,10,-2,-1,-20,20,4,19,5,29,-7},\n\t//\t{29,-12,-3,17,6,19,23,12,-19,13,19,5,27,22,-17,27,10,-12,12,23},\n\t//\t{24,16,4,25,15,13,24,-19,1,-7,-19,13,-13,14,13,26,9,18,-9,-18},\n\t//\t{-17,4,-18,-18,-19,3,-13,12,23,-17,-10,-20,14,2,18,21,-12,27,-3,4},\n\t//\t{27,13,12,14,16,-9,-2,-15,-20,8,-2,24,18,15,26,21,27,17,-15,-3},\n\t//\t{25,-8,17,-10,-16,13,26,-11,-15,6,-5,-13,23,2,24,-4,5,8,-15,-1},\n\t//\t{15,-12,18,5,-3,7,5,11,-4,-13,28,20,0,-4,-13,-5,-13,-8,-16,3}}\n\n\t//log.Println(find_last_le_idx(a, 3))\n\t//log.Println(q(a, -123))\n\n\t//aa := []int{2,3,1,3,4,6,1,2}\n\t//mm(aa, 1)\n\t//ini()\n//inii()\n\t//next_per()\n\tqq()\n}\n", "lang_cluster": "Go", "tags": ["constructive algorithms", "math", "dp", "greedy", "strings"], "code_uid": "d93cbcfb69d3d0be10a1135fcec26c21", "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, o int\n\tfmt.Scanln(&n)\n\tif n%2 != 0 {\n\t\to = 0\n\t} else {\n\t\tif n%4 == 0 {\n\t\t\to = n/4 - 1\n\t\t} else {\n\t\t\to = n / 4\n\t\t}\n\t}\n\tfmt.Println(o)\n}", "lang_cluster": "Go", "tags": ["math", "combinatorics"], "code_uid": "f83724de2af37023a11fa7aeed5963fc", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\nimport (\n\t\"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(n int)int {\n\tif n<0 {\n\t\tn*=(-1)\n\t}\n\treturn n\n}\nfunc main() {\n\tvar r1,c1,r2,c2,l,s,k int\n\tfmt.Scan(&r1,&c1,&r2,&c2)\n\tif r1==r2 || c1==c2 {\n\t\tl=1\n\t} else {\n\t\tl=2\n\t}\n\tif abs(r2-r1)==abs(c2-c1) {\n\t\ts=1\n\t} else if (r1+c1)%2==(r2+c2)%2 {\n\t\ts=2\n\t} else {\n\t\ts=0\n\t}\n\tk=max(abs(r2-r1),abs(c2-c1))\n\tfmt.Println(l,s,k)\n}\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Go", "tags": ["math", "graphs", "shortest paths"], "code_uid": "9a3d2b0426adb86db48b42742ca5d804", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, n, rest, result int\n\tfmt.Scanln(&a)\n\tfmt.Scanln(&b)\n\tn = a - b\n\tif n < 0 {\n\t\tn = -n\n\t}\n\trest = n % 2\n\tn /= 2\n\tresult = n*(n+1) + rest*(n+1)\n\tfmt.Println(result)\n}\n", "lang_cluster": "Go", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "65cbdde22b95d0a0516b063b6e01cadb", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.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, d, x, p1, p2, count int\n\tarr := make([]int, 0)\n\tfmt.Scan(&n, &d)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&x)\n\t\tarr = append(arr, x)\n\t}\n\n\tsort.Ints(arr)\n\tp1 = 0\n\tp2 = 0\n\tcount = 1\n\tfor p2 < n && p1 < n {\n\t\tfor p2 < n && arr[p2]-arr[p1] <= d {\n\t\t\tp2++\n\t\t}\n\n\t\tif p2-p1 > count {\n\t\t\tcount = p2 - p1\n\t\t}\n\n\t\tp1++\n\t}\n\tfmt.Printf(\"%d\", n-count)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "sortings", "greedy"], "code_uid": "d78c65111c164a6eec3169fa1273b01b", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.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)\n\tfmt.Scan(&m)\n\tvar rows, cols string\n\tfmt.Scan(&rows)\n\tfmt.Scan(&cols)\n\tvar tl, tr, bl, br bool\n\n\tfor i := 0; i < n; i++ {\n\t\tvar direction = rows[i]\n\t\tif i == 0 {\n\t\t\tswitch direction {\n\t\t\tcase '>':\n\t\t\t\ttr = true\n\t\t\tcase '<':\n\t\t\t\ttl = true\n\t\t\t}\n\t\t}\n\t\tif i == n-1 {\n\t\t\tswitch direction {\n\t\t\tcase '>':\n\t\t\t\tbr = true\n\t\t\tcase '<':\n\t\t\t\tbl = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tvar direction = cols[i]\n\t\tif i == 0 {\n\t\t\tswitch direction {\n\t\t\tcase 'v':\n\t\t\t\tbl = true\n\t\t\tcase '^':\n\t\t\t\ttl = true\n\t\t\t}\n\t\t}\n\t\tif i == m-1 {\n\t\t\tswitch direction {\n\t\t\tcase 'v':\n\t\t\t\tbr = true\n\t\t\tcase '^':\n\t\t\t\ttr = true\n\t\t\t}\n\t\t}\n\t}\n\tif tl && tr && bl && br {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "lang_cluster": "Go", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "fbf6322767fcab9f1717d044dcf10363", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n\nfunc main() {\n\tconst formod = 1000000007\n\tvar n, k int\n\tvar dp [2001][2001]int\n\n\tfmt.Scan(&n, &k)\n\n\tfor i := 1; i <= n; i++ {\n\t\tdp[1][i] = 1\n\t}\n\n\tfor i := 1; i < k; i++ {\n\t\tfor j := 1; j <= n; j++ {\n\t\t\tfor k := j; k <= n; k += j {\n\t\t\t\tdp[i + 1][k] = (dp[i + 1][k] + dp[i][j]) % formod\n\t\t\t}\n\t\t}\n\t}\n\n\tvar ans int\n\tans = 0\n\n\tfor i := 1; i <= n; i++ {\n\t\tans = (ans + dp[k][i]) % formod\n\t}\n\tfmt.Println(ans)\n}", "lang_cluster": "Go", "tags": ["dp", "combinatorics", "number theory"], "code_uid": "710ce96536e080d7cad6ff2f9744092e", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.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\tif n == 0 {\n\t\tfmt.Println(1)\n\t} else {\n\t\tswitch n % 4 {\n\t\tcase 1:\n\t\t\tfmt.Println(8)\n\t\tcase 2:\n\t\t\tfmt.Println(4)\n\t\tcase 3:\n\t\t\tfmt.Println(2)\n\t\tcase 0:\n\t\t\tfmt.Println(6)\n\t\t}\n\t}\n}\n", "lang_cluster": "Go", "tags": ["math", "implementation", "number theory"], "code_uid": "13817965ec6c979d6f4d1e6fdd80b321", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main \n\nimport \"fmt\"\n\nfunc abs(a int) int {\n if a < 0 {\n return -a\n }\n return a\n}\n\nfunc main() {\n var n, m, k int\n fmt.Scan(&n, &m, &k)\n\n minDist := 10000000 //value big enough\n for i:=1; i<=n; i++ {\n var price int\n fmt.Scan(&price)\n if price == 0 || price > k {\n continue\n }\n dist := abs(m-i)*10\n if minDist > dist {\n minDist = dist\n }\n }\n fmt.Print(minDist)\n}", "lang_cluster": "Go", "tags": ["brute force", "implementation"], "code_uid": "3dd936dbd49ab0156737a6957825e3cd", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "// Try Codeforces\n// author: Leonardone @ NEETSDKASU\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar m, b uint64\n\tfmt.Scan(&m, &b)\n\tmax := uint64(0)\n\tfor x := uint64(0); x <= m*b; x += m {\n\t\ty := (m*b - x) / m\n\t\ts1 := (y + 1) * x * (x + 1) / 2\n\t\ts2 := (x + 1) * y * (y + 1) / 2\n\t\ts := s1 + s2\n\t\tif s > max {\n\t\t\tmax = s\n\t\t}\n\t}\n\tfmt.Println(max)\n}\n", "lang_cluster": "Go", "tags": ["brute force", "math"], "code_uid": "c07c1c5de3098b9bf585e3300f3faf16", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.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\t\"strconv\"\r\n\t\"strings\"\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\nfunc scan(a ...interface{}) { fmt.Fscan(reader, a...) }\r\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\r\n\r\nfunc redirectInputToFile(r *bufio.Reader, fp string) {\r\n\tf, err := os.Open(fp)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\tr.Reset(f)\r\n}\r\n\r\nfunc main() {\r\n\tdefer writer.Flush()\r\n\t// redirectInputToFile(reader, \"input.txt\")\r\n\r\n\tT := 1\r\n\t// scan(&T)\r\n\tfor t := 0; t < T; t++ {\r\n\t\tsolve()\r\n\t}\r\n}\r\n\r\ntype ll = int64\r\n\r\nfunc reverse(a ll) ll {\r\n\tvar b ll\r\n\tfor a > 0 {\r\n\t\tb <<= 1\r\n\t\tb |= a & 1\r\n\t\ta >>= 1\r\n\t}\r\n\treturn b\r\n}\r\n\r\nfunc isSorted(s string) bool {\r\n\tfor i := 1; i < len(s); i++ {\r\n\t\tif s[i-1] > s[i] {\r\n\t\t\treturn false\r\n\t\t}\r\n\t}\r\n\treturn true\r\n}\r\n\r\nfunc tryFor(x, y ll) bool {\r\n\tsx, sy := strconv.FormatInt(x, 2), strconv.FormatInt(y, 2)\r\n\tif len(sy) < 60 {\r\n\t\tsy = strings.Repeat(\"0\", 60-len(sy)) + sy\r\n\t}\r\n\tfor i := 0; i+len(sx)-1 < len(sy); i++ {\r\n\t\tprefixSorted := isSorted(sy[:i])\r\n\t\tmiddle := sy[i : i+len(sx)]\r\n\t\tsuffix := sy[i+len(sx):]\r\n\t\tonesOnSuffix := strings.Repeat(\"1\", len(sy)-i-len(sx))\r\n\t\tif prefixSorted && middle == sx && suffix == onesOnSuffix {\r\n\t\t\treturn true\r\n\t\t}\r\n\t}\r\n\treturn false\r\n}\r\n\r\nfunc solve() {\r\n\tvar x, y ll\r\n\tscan(&x, &y)\r\n\r\n\tif x == y {\r\n\t\tprintf(\"YES\\n\")\r\n\t\treturn\r\n\t}\r\n\r\n\ttry := []ll{}\r\n\tif x&1 == 1 {\r\n\t\ttry = append(try, x, reverse(x))\r\n\t} else {\r\n\t\ttry = append(try,\r\n\t\t\treverse(x<<1), reverse(reverse(x<<1)),\r\n\t\t\treverse((x<<1)|1), reverse(reverse((x<<1)|1)),\r\n\t\t)\r\n\t}\r\n\r\n\tok := false\r\n\tfor _, i := range try {\r\n\t\tok = ok || tryFor(i, y)\r\n\t}\r\n\r\n\tif !ok {\r\n\t\tprintf(\"NO\\n\")\r\n\t} else {\r\n\t\tprintf(\"YES\\n\")\r\n\t}\r\n}\r\n", "lang_cluster": "Go", "tags": ["dfs and similar", "constructive algorithms", "math", "bitmasks", "strings", "implementation"], "code_uid": "f9d69b97c4543bb209baae90ccef2f3b", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\ntype Pont struct {\n\tx, y int32\n}\n\nfunc (o *Pont) read() {\n\tfmt.Scan(&o.x)\n\tfmt.Scan(&o.y)\n}\n\nfunc (o *Pont) add(oo Pont) {\n\to.x += oo.x\n\to.y += oo.y\n}\n\nfunc (o *Pont) eq(oo Pont) bool {\n\treturn o.x == oo.x && o.y == oo.y\n}\n\nfunc isRA(A, B, C Pont) bool {\n\tAB := Pont{B.x - A.x, B.y - A.y}\n\tAC := Pont{C.x - A.x, C.y - A.y}\n\treturn 0 == AB.x*AC.x+AB.y*AC.y\n}\n\nfunc isRATRI(A, B, C Pont) bool {\n\tif A.eq(B) || A.eq(C) || B.eq(C) {\n\t\treturn false\n\t}\n\treturn isRA(A, B, C) || isRA(B, A, C) || isRA(C, A, B)\n}\n\nfunc main() {\n\n\tvar (\n\t\tP [3]Pont\n\t\tdir = [4]Pont{Pont{0, 1}, Pont{1, -1}, Pont{-1, -1}, Pont{-1, 1}}\n\t\tdelta = Pont{1, 0}\n\t\ti, j int32\n\t)\n\n\tP[0].read()\n\tP[1].read()\n\tP[2].read()\n\tif isRATRI(P[0], P[1], P[2]) {\n\t\tfmt.Println(\"RIGHT\")\n\t\treturn\n\t}\n\n\talmost := false\n\nouter:\n\tfor i = 0; i < 3; i++ {\n\t\tfor j = 0; j < 4; j++ {\n\t\t\tP[i].add(dir[j])\n\t\t\t//\t\t\tfmt.Println(P)\n\t\t\tif isRATRI(P[0], P[1], P[2]) {\n\t\t\t\talmost = true\n\t\t\t\tbreak outer\n\t\t\t}\n\t\t}\n\t\t// ez a j-s ciklusban volt\n\t\tP[i].add(delta)\n\n\t}\n\n\tif almost {\n\t\tfmt.Println(\"ALMOST\")\n\n\t} else {\n\t\tfmt.Println(\"NEITHER\")\n\t}\n\n}\n", "lang_cluster": "Go", "tags": ["brute force", "geometry"], "code_uid": "cfe71fa99ae48888634d6210be9b6997", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Go", "source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/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, a, b, p, q int64\n)\n\nfunc main() {\n\tn = ReadInt64()\n\ta, b, p, q = ReadInt64_4()\n\n\tred := n / a\n\tred *= p\n\n\tblue := n / b\n\tblue *= q\n\n\tans := red + blue\n\n\tc := Lcm(a, b)\n\ttmp := n / c\n\ttmp *= Min(p, q)\n\n\tans -= tmp\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 ...int64) int64 {\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// 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 int64) int64 {\n\tif a < 0 || b < 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\tif a == 0 {\n\t\treturn b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\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 int64) int64 {\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// 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/*********** 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", "implementation", "number theory"], "code_uid": "e8a2989c374c474a1dd19c40f22cdca5", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0, "exec_outcome": "PASSED"}