{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tk := readInt()\n\ta := make([]int, k)\n\tif k == 1 {\n\t\ta[0] = n\n\t\tk = 0\n\t}\n\tfor i := 2; i <= n && k > 1; i++ {\n\t\tfor n%i == 0 {\n\t\t\tk--\n\t\t\tn /= i\n\t\t\ta[k] = i\n\t\t\tif k == 1 {\n\t\t\t\tif n != 1 {\n\t\t\t\t\ta[0] = n\n\t\t\t\t\tk--\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif k == 0 {\n\t\tfor i := 0; i < len(a); i++ {\n\t\t\tif i > 0 {\n\t\t\t\tfmt.Print(\" \")\n\t\t\t}\n\t\t\tfmt.Print(a[i])\n\t\t}\n\t} else {\n\t\tfmt.Println(-1)\n\t}\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\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", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79"} {"source_code": "// Codeforces 655B done\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\n\nfunc main() {\n\t// reading n,k\n\tin := bufio.NewReader(os.Stdin)\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\treturn\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tn, err1 := strconv.Atoi(ss[0])\n\tif err1 != nil {\n\t\tfmt.Println(\"n atoi failure\", err1)\n\t\treturn\n\t}\n\tk, err2 := strconv.Atoi(ss[1])\n\tif err2 != nil {\n\t\tfmt.Println(\"k atoi failure\", err1)\n\t\treturn\n\t}\n\n\t// calculating\n\tcnt := int64(0)\n\tfor i:=0; i 0 {\n\t\tm /= 10\n\t\tketa++\n\t}\n\ta := pow(10, keta) * n\n\tfor p := keta - 1; p >= 0; p-- {\n\t\ta += (n % 10) * pow(10, p)\n\t\tn /= 10\n\t}\n\treturn a\n\n}\n\n//a\u306eb\u4e57\u3092\u3057\u307e\u3059 O(log b)\nfunc pow(a int64, b int64) int64 {\n\ttotal := int64(1)\n\ttmp := a\n\tfor b > 0 {\n\t\tif b%2 == 1 {\n\t\t\ttotal *= tmp\n\t\t}\n\t\tb /= 2\n\t\ttmp *= tmp\n\t}\n\treturn total\n}\n\nfunc main() {\n\tsc := NewScanner()\n\tk, p := sc.NextInt(), sc.NextInt()\n\n\tsum := int64(0)\n\tfor i := 1; i <= k; i++ {\n\t\tsum += zcy(int64(i))\n\t\tsum %= int64(p)\n\t}\n\tfmt.Println(sum)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tn := 0\n\tfmt.Scanf(\"%d\", &n)\n\tfmt.Println(n + 1)\n}\n", "src_uid": "098ade88ed90664da279fe8a5a54b5ba"} {"source_code": "package main\n\nimport . \"fmt\"\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar a, b, k int64\n\tScan(&a, &b)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tdelta := b - a\n\tminLCM := int64(1e18)\n\tcalcK := func(x int64) {\n\t\tak := (a + x - 1) / x * x\n\t\tif lcm := ak / x * (ak + delta); lcm <= minLCM {\n\t\t\tminLCM = lcm\n\t\t\tk = ak - a\n\t\t}\n\t}\n\tfor i := int64(1); i*i <= delta; i++ {\n\t\tif delta%i == 0 {\n\t\t\tcalcK(i)\n\t\t\tcalcK(delta / i)\n\t\t}\n\t}\n\tPrint(k)\n}\n", "src_uid": "414149fadebe25ab6097fc67663177c3"} {"source_code": "// 133B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\ta := 0\n\tfmt.Scan(&s)\n\tfor i := 0; i < len(s); i++ {\n\t\ta *= 16\n\t\tif s[i] == '>' {\n\t\t\ta += 8\n\t\t}\n\t\tif s[i] == '<' {\n\t\t\ta += 9\n\t\t}\n\t\tif s[i] == '+' {\n\t\t\ta += 10\n\t\t}\n\t\tif s[i] == '-' {\n\t\t\ta += 11\n\t\t}\n\t\tif s[i] == '.' {\n\t\t\ta += 12\n\t\t}\n\t\tif s[i] == ',' {\n\t\t\ta += 13\n\t\t}\n\t\tif s[i] == '[' {\n\t\t\ta += 14\n\t\t}\n\t\tif s[i] == ']' {\n\t\t\ta += 15\n\t\t}\n\t\ta %= 1000003\n\t}\n\tfmt.Println(a)\n}\n", "src_uid": "04fc8dfb856056f35d296402ad1b2da1"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n ans := [...]string{\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"}\n fmt.Scan(&n)\n a := 1\n for n > (5*a) {\n n -= (5*a)\n a *= 2\n }\n fmt.Println(ans[(n-1)/a])\n}\n", "src_uid": "023b169765e81d896cdc1184e5a82b22"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt()\n\ta := make([]int, n)\n\tbribe := 0\n\n\tfor i := range a {\n\t\ta[i] = nextInt()\n\t}\n\n\tidx := max(a[1:]) + 1\n\n\tfor a[0] <= a[idx] {\n\t\ta[0]++\n\t\ta[idx]--\n\t\tbribe++\n\t\t// println(idx, a, bribe)\n\t\tidx = max(a[1:]) + 1\n\t}\n\n\tprintln(bribe)\n}\n\nfunc max(a []int) int {\n\tidx := 0\n\n\tfor i := range a {\n\t\tif a[i] > a[idx] {\n\t\t\tidx = i\n\t\t}\n\t}\n\n\treturn idx\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc max(a, b int) int {\n\treturn -min(-a, -b)\n}\n\nfunc min(a, b int) int {\n\tif a < b { return a }\n\treturn b \n}\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\tw := bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\n\tvar p1, t1, p2, t2, h, s int\n\tfmt.Fscan(r, &p1, &t1, &p2, &t2, &h, &s)\n\n\tdp := make([]int, h+1)\n\tfor i := range dp {\n\t\tif i == 0 { continue }\n\t\tdp[i] = min(t1 + dp[max(0, i - (p1-s))], t2 + dp[max(0, i - (p2-s))])\n\t\tfor j := 1; j <= i; j++ {\n\t\t\tif j*t1 >= t2 { dp[i] = min(dp[i], j*t1 + dp[max(0, i - (j-1)*(p1-s) - (j*t1/t2 - 1)*(p2-s) - (p1+p2-s))]) }\n\t\t\tif j*t2 >= t1 { dp[i] = min(dp[i], j*t2 + dp[max(0, i - (j-1)*(p2-s) - (j*t2/t1 - 1)*(p1-s) - (p1+p2-s))]) }\n\t\t}\n\t}\n\n\tfmt.Fprintln(w, dp[h])\n}\n", "src_uid": "ca9d48e48e69b931236907a9ac262433"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\ntype vector struct {\n\tx int\n\ty int\n\tz int\n}\n\nfunc main() {\n\tvar a, b, c int\n\ttotal := 0\n\n\tscanf(\"%d\\n\", &a)\n\tscanf(\"%d\\n\", &b)\n\tscanf(\"%d\\n\", &c)\n\n\tif a+b+c > total {\n\t\ttotal = a + b + c\n\t}\n\tif a+b*c > total {\n\t\ttotal = a + b*c\n\t}\n\tif a*b+c > total {\n\t\ttotal = a*b + c\n\t}\n\tif a*b*c > total {\n\t\ttotal = a * b * c\n\t}\n\tif (a+b)*c > total {\n\t\ttotal = (a + b) * c\n\t}\n\tif a+(b*c) > total {\n\t\ttotal = a + (b * c)\n\t}\n\tif a*(b+c) > total {\n\t\ttotal = a*(b+c)\n\t}\n\n\tprintf(\"%d\\n\", total)\n}\n\nfunc printf(format string, x ...interface{}) {\n\tfmt.Fprintf(os.Stdout, format, x...)\n}\n\nfunc scanf(format string, x ...interface{}) {\n\tif _, err := fmt.Fscanf(os.Stdin, format, x...); err != nil {\n\t\tpanic(err)\n\t}\n}\n", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27"} {"source_code": "// 257A\npackage main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n, m, x int\n\tfmt.Scan(&n, &m, &x)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\tsort.Sort(sort.IntSlice(a))\n\tfor i := 0; i < n; i++ {\n\t\tif x >= m {\n\t\t\tfmt.Print(i)\n\t\t\treturn\n\t\t} else {\n\t\t\tx += a[n-i-1] - 1\n\t\t}\n\t}\n\tif x >= m {\n\t\tfmt.Print(n)\n\t} else {\n\t\tfmt.Print(-1)\n\t}\n}\n", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c"} {"source_code": "package main\n\nimport (\n \"strconv\"\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n// var file, _ = os.Open(\"input.txt\")\n// var outfile, _ = os.Create(\"output.txt\")\n// var in = bufio.NewScanner(file)\n// var out = bufio.NewWriter(outfile)\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc next() string {\n if !in.Scan() {\n panic(\"Scan error\")\n }\n return in.Text()\n}\n\nfunc nextInt() int {\n ret, _ := strconv.Atoi(next())\n return ret\n}\n\nfunc nextInt64() int64 {\n ret, _ := strconv.ParseInt(next(), 10, 64)\n return ret\n}\n\nfunc nextFloat() float64 {\n ret, _ := strconv.ParseFloat(next(), 64)\n return ret\n}\n\nfunc swap(a []int, i int, j int) {\n a[i], a[j] = a[j], a[i]\n}\n\nfunc reverse(a []int, i int, j int) {\n for i < j {\n swap(a, i, j)\n i++\n j--\n }\n}\n\nfunc nextPermutation(a []int) bool {\n k := len(a) - 2\n for k > -1 && a[k] > a[k + 1] { k-- }\n if k == -1 { return false }\n l := len(a) - 1\n for k < l && a[k] > a[l] { l-- }\n swap(a, k, l)\n reverse(a, k + 1, len(a) - 1)\n return true\n}\n\nfunc f(a []int) int {\n n := len(a)\n sum := 0\n for i := 0; i < n; i++ {\n for j := i; j < n; j++ {\n min := -1;\n for k := i; k <= j; k++ {\n if min == -1 || min > a[k] {\n min = a[k]\n }\n }\n sum += min\n }\n }\n return sum\n}\n\nfunc main() {\n defer out.Flush()\n in.Split(bufio.ScanWords)\n n := nextInt()\n m := nextInt()\n a := make([]int, n)\n for i := 0; i < n; i++ {\n a[i] = i + 1\n }\n ms := f(a)\n for nextPermutation(a) {\n sum := f(a)\n if ms < sum { ms = sum }\n }\n for i := 0; i < n; i++ {\n a[i] = i + 1\n }\n if ms == f(a) {\n m--\n }\n if m == 0 {\n for i := 0; i < n; i++ {\n fmt.Fprint(out, strconv.Itoa(a[i]) + \" \")\n }\n fmt.Fprintln(out)\n return\n }\n for nextPermutation(a) {\n sum := f(a)\n if ms == sum {\n m--\n if m == 0 {\n for i := 0; i < n; i++ {\n fmt.Fprint(out, strconv.Itoa(a[i]) + \" \")\n }\n fmt.Fprintln(out)\n return\n }\n }\n }\n}\n", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\nconst INF_INT32 = math.MaxInt32\nconst INF_BIT30 = 1 << 30\n\nvar a, b, c, d, e, f int\n\nfunc main() {\n\ta, b, c, d = ReadInt4()\n\te, f = ReadInt2()\n\n\tbc := Min(b, c)\n\n\tans := 0\n\tif e > f {\n\t\t// a\u306e\u65b9\u3092\u4f7f\u3046\n\t\tm := Min(a, d)\n\t\tans += e * m\n\t\td -= m\n\t\tif d > 0 {\n\t\t\tmm := Min(bc, d)\n\t\t\tans += f * mm\n\t\t}\n\t} else {\n\t\t// bc\u306e\u65b9\u3092\u4f7f\u3046\n\t\tm := Min(bc, d)\n\t\tans += f * m\n\t\td -= m\n\t\tif d > 0 {\n\t\t\tmm := Min(a, d)\n\t\t\tans += e * mm\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n/*\n- \u307e\u305a\u306f\u5168\u63a2\u7d22\u3092\u691c\u8a0e\u3057\u307e\u3057\u3087\u3046\n- MOD\u306f\u6700\u5f8c\u306b\u3068\u308a\u307e\u3057\u305f\u304b\uff1f\n- \u30eb\u30fc\u30d7\u3092\u629c\u3051\u305f\u5f8c\u3082\u51e6\u7406\u304c\u5fc5\u8981\u3058\u3083\u3042\u308a\u307e\u305b\u3093\u304b\uff1f\n- \u548c\u30fb\u7a4d\u30fb\u3042\u307e\u308a\u3092\u6c42\u3081\u3089\u308c\u305f\u3089int64\u304c\u5fc5\u8981\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304b\uff1f\n- \u3044\u304d\u306a\u308a\u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc\u306f\u3057\u3066\u3044\u307e\u305b\u3093\u304b\uff1f\n\t- MOD\u53d6\u308b\u7cfb\u306fint64\u5fc5\u9808\u3067\u3059\u3088\uff1f\n*/\n\n/*\nASCII code\n\nASCII 10\u9032\u6570 ASCII 10\u9032\u6570 ASCII 10\u9032\u6570\n! 33 \" 34 # 35\n$ 36 % 37 & 38\n' 39 ( 40 ) 41\n* 42 + 43 , 44\n- 45 . 46 / 47\n0 48 1 49 2 50\n3 51 4 52 5 53\n6 54 7 55 8 56\n9 57 : 58 ; 59\n< 60 = 61 > 62\n? 63 @ 64 A 65\nB 66 C 67 D 68\nE 69 F 70 G 71\nH 72 I 73 J 74\nK 75 L 76 M 77\nN 78 O 79 P 80\nQ 81 R 82 S 83\nT 84 U 85 V 86\nW 87 X 88 Y 89\nZ 90 [ 91 \\ 92\n] 93 ^ 94 _ 95\n` 96 a 97 b 98\nc 99 d 100 e 101\nf 102 g 103 h 104\ni 105 j 106 k 107\nl 108 m 109 n 110\no 111 p 112 q 113\nr 114 s 115 t 116\nu 117 v 118 w 119\nx 120 y 121 z 122\n{ 123 | 124 } 125\n~ 126 127\n*/\n\n/*******************************************************************/\n", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar local = false\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tsetup()\n\tcb := readInt()\n\tdigits := make(map[int][]int)\n\n\tfor i := 0; i < cb; i++ {\n\t\tfor j := 0; j < 6; j++ {\n\t\t\tface := readInt()\n\t\t\tdigits[face] = append(digits[face], i)\n\t\t}\n\t}\n\n\tcurr, result, stuck := 1, 0, false\n\tfor !stuck {\n\t\tused := make(map[int]bool)\n\t\tif !rearrange(&digits, curr, &used) {\n\t\t\tstuck = true\n\t\t} else {\n\t\t\tresult = curr\n\t\t\tcurr++\n\t\t}\n\t}\n\n\tfmt.Println(result)\n}\n\nfunc rearrange(digits *map[int][]int, target int, pUsed *map[int]bool) bool {\n\tif target == 0 {\n\t\treturn true\n\t}\n\n\tsuccess, used, targetDigit := false, *pUsed, target%10\n\tfor _, cube := range (*digits)[targetDigit] {\n\t\tif !used[cube] {\n\t\t\tused[cube] = true\n\t\t\tif rearrange(digits, target/10, &used) {\n\t\t\t\tsuccess = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tused[cube] = false\n\t\t}\n\t}\n\n\treturn success\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", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\tl := []rune(s)\n\tif l[0] > 96 {\n\t\tl[0] = l[0] - (96 - 64)\n\t}\n\tfmt.Println(string(l))\n}\n", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar d int\n\tfmt.Scanf(\"%X\", &d)\n\tr := d & 1\n\tfmt.Println(r)\n}\n", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f"} {"source_code": "// 185A\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, x, y, m int64\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tfmt.Fscan(in, &n)\n\ty, x, m = 1, 2, 1000000007\n\tfor n != 0 {\n\t\tif n%2 != 0 {\n\t\t\ty = (y * x) % m\n\t\t}\n\t\tx = (x * x) % m\n\t\tn = n / 2\n\t}\n\tfmt.Fprint(out, ((y*y+y)/2)%m)\n\tout.Flush()\n}\n", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tdaysInMonths := []int{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}\n\tm := readInt()\n\td := readInt()\n\tdays := daysInMonths[m-1] + d - 1\n\tweeks := days / 7\n\tif days%7 != 0 {\n\t\tweeks++\n\t}\n\tfmt.Println(weeks)\n}\n\nfunc getStats(str string) map[byte]int {\n\tstat := map[byte]int{}\n\tfor _, v := range str {\n\t\tstat[byte(v)]++\n\t}\n\treturn stat\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n four, seven := 0, 0\n for _, v := range s {\n if v == '4' {\n four++\n } else if v == '7' {\n seven++\n }\n }\n if (four+seven) == 0 {\n fmt.Println(-1)\n } else if four >= seven {\n fmt.Println(4)\n } else {\n fmt.Println(7)\n }\n}\n", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a"} {"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\thome := readNNums(reader, 2)\n\n\tn := readNum(reader)\n\n\titems := make([][]int, n)\n\tfor i := 0; i < n; i++ {\n\t\titems[i] = readNNums(reader, 2)\n\t}\n\n\ttot, path := solve(home, items)\n\n\tvar buf bytes.Buffer\n\tbuf.WriteString(fmt.Sprintf(\"%d\\n\", tot))\n\n\tfor _, cur := range path {\n\t\tbuf.WriteString(fmt.Sprintf(\"%d \", cur))\n\t}\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\nconst INF = 1 << 29\n\nfunc solve(home []int, items [][]int) (int, []int) {\n\tn := 1 + len(items)\n\n\tdist := make([][]int, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tdist[i] = make([]int, n)\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif i != j {\n\t\t\t\tif i == 0 {\n\t\t\t\t\tdist[i][j] = distance(home, items[j-1])\n\t\t\t\t} else if j > 0 {\n\t\t\t\t\tdist[i][j] = distance(items[i-1], items[j-1])\n\t\t\t\t} else {\n\t\t\t\t\tdist[i][j] = distance(items[i-1], home)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tN := 1 << (n - 1)\n\n\tdp := make([]int, N)\n\tparent := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tdp[i] = INF\n\t}\n\tdp[0] = 0\n\n\tfor state := 0; state < N; state++ {\n\t\tif dp[state] >= INF {\n\t\t\tcontinue\n\t\t}\n\t\tfor i := 1; i < n; i++ {\n\t\t\tif state&(1<<(i-1)) == 0 {\n\t\t\t\t// i is not picked yet\n\t\t\t\tfor j := i; j < n; j++ {\n\t\t\t\t\tif state&(1<<(j-1)) == 0 {\n\t\t\t\t\t\tif dp[state|(1<<(i-1))|(1<<(j-1))] > dp[state]+dist[i][0]+dist[j][0]+dist[i][j] {\n\t\t\t\t\t\t\tdp[state|(1<<(i-1))|(1<<(j-1))] = dp[state] + dist[i][0] + dist[j][0] + dist[i][j]\n\t\t\t\t\t\t\tparent[state|(1<<(i-1))|(1<<(j-1))] = state\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tbest := dp[N-1]\n\tres := make([]int, 0, 2*n)\n\tres = append(res, 0)\n\n\tcur := N - 1\n\n\tfor cur > 0 {\n\n\t\tprev := parent[cur]\n\n\t\ttmp := prev ^ cur\n\n\t\tfor i := 1; i < n; i++ {\n\t\t\tif tmp&(1<<(i-1)) > 0 {\n\t\t\t\tres = append(res, i)\n\t\t\t}\n\t\t}\n\t\tres = append(res, 0)\n\t\tcur = prev\n\t}\n\n\treturn best, res\n}\n\nfunc min(a, b int) int {\n\tif a <= b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc distance(a, b []int) int {\n\tdx := b[0] - a[0]\n\tdy := b[1] - a[1]\n\treturn dx*dx + dy*dy\n}\n", "src_uid": "2ecbac20dc5f4060bc873553946281bc"} {"source_code": "package main\n\n\nimport (\n\t\"fmt\"\n\t// \"math\"\t\n)\n\n\nfunc main() {\n\tvar problems, parametres int \n\tfmt.Scan(&problems, ¶metres)\n\n\tvar scores, TIME []int\n\tfor i := 0; i < problems; i++ {\n\t\tvar problem int\n\t\tfmt.Scan(&problem)\n\t\tscores = append(scores, problem)\n\t}\n\n\tfor i := 0; i < problems; i++ {\n\t\tvar time int\n\t\tfmt.Scan(&time)\n\t\tTIME = append(TIME, time)\n\t}\n\n\tvar LimakScore, RadewooshScore int\n\tvar time int\n\n\tfor i := 0; i < problems; i++ {\n\t\ttime += TIME[i]\n\t\tif (scores[i] - parametres * time) < 0 {\n\t\t\tLimakScore += 0\n\t\t} else {\n\t\t\tLimakScore += scores[i] - parametres * time\n\t\t}\n\t}\n\t\n\ttime = 0\n\n\tfor i := problems - 1; i >= 0; i-- {\n\t\ttime += TIME[i]\n\t\tif scores[i] - parametres * time < 0 {\n\t\t\tRadewooshScore += 0\n\t\t} else {\n\t\t\tRadewooshScore += scores[i] - parametres * time\n\t\t}\n\t}\n\n\t// fmt.Println(LimakScore, RadewooshScore)\n\n\tif LimakScore > RadewooshScore {\n\t\tfmt.Println(\"Limak\")\n\t} else if LimakScore == RadewooshScore {\n\t\tfmt.Println(\"Tie\")\n\t} else {\n\t\tfmt.Println(\"Radewoosh\")\n\t}\n}\t\n", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a"} {"source_code": "package main\r\nimport (\r\n\"fmt\"\r\n\"bufio\"\r\n\"os\"\r\n)\r\n\r\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\r\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\r\n\r\nconst mod int = 1000000007\r\nconst Mod = int64(mod)\r\n\r\nfunc pw(n, k int) int {\r\n\tret := 1\r\n\tpv := n % mod\r\n\tfor ; k > 0; k >>= 1 {\r\n\t\tif (k & 1) > 0 {\r\n\t\t\tret = int(int64(ret) * int64(pv) % Mod)\r\n\t\t}\r\n\t\tpv = int(int64(pv) * int64(pv) % Mod)\r\n\t}\r\n\treturn ret\r\n}\r\n\r\nfunc main(){\r\n\t// your code goes here\r\n\tdefer writer.Flush()\r\n\tvar (\r\n\t\tt, n, k int\r\n\t)\r\n\tfmt.Fscan(reader, &t)\r\n\tfor id := 0; id < t; id++ {\r\n\t\tfmt.Fscan(reader, &n, &k)\r\n\t\tif n % 2 == 1 {\r\n\t\t\tfmt.Fprintln(writer, pw(pw(2,n-1) + 1, k))\r\n\t\t} else {\r\n\t\t\tans := pw(pw(2, n-1) - 1, k)\r\n\t\t\tfor j := 1; j <= k; j++ {\r\n\t\t\t\tv := int64(n) * int64(j-1) % (Mod - int64(1))\r\n\t\t\t\tans += int( int64(pw(pw(2, n-1) - 1, k-j)) * int64(pw(2, int(v))) % Mod)\r\n\t\t\t\tans %= mod\r\n\t\t\t}\r\n\t\t\tfmt.Fprintln(writer, ans)\r\n\t\t}\r\n\t}\r\n}", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881"} {"source_code": "package main\r\nimport( \r\n \"fmt\"\r\n \"bufio\"\r\n \"os\"\r\n \"math\"\r\n)\r\ntype coords struct{\r\n\trow int\r\n\tcolumn int\r\n}\r\nfunc main() {\r\n\tin:= bufio.NewReader(os.Stdin)\r\n\tout:= bufio.NewWriter(os.Stdout)\r\n\tdefer out.Flush()\r\n\tvar t int\r\n\tfmt.Fscan(in,&t)\r\n\tfor i:=0;i maxVal {maxVal = v}}; return minVal, maxVal}\nfunc minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }\nfunc maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }\nfunc lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}\nfunc gcdCalculation(a, b int64) int64 {if (a == 0) {return b}; return gcdCalculation(b%a, a)}\nfunc sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}\nfunc absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}\nfunc min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }\nfunc max(args ...int) int { _, mx := minMaxFinder(args...); return mx }\nfunc minMaxFinder(args ...int) (int, int) { minVal, maxVal := int(math.MaxInt32), int(math.MinInt32); for _, v := range args { if v < minVal { minVal = v }; if v > maxVal { maxVal = v } }; return minVal, maxVal }\n\n\n\n\n", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b"} {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1114/C\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn, b int64\n)\n\nfunc main() {\n\tn, b = ReadInt64_2()\n\n\tif n == 1 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tmemo := TrialDivision(b)\n\n\tcounts := make(map[int64]int64)\n\tfor a := range memo {\n\t\tcnt := int64(0)\n\t\tcur := a\n\t\tfor n/cur > 0 {\n\t\t\tcnt += n / cur\n\t\t\t// PrintfDebug(\"cur: %d, diff: %d\\n\", cur, n/cur)\n\n\t\t\tif IsProductOverflow(cur, a, INF_INT64) {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tcur *= a\n\t\t}\n\n\t\tcounts[a] = cnt\n\t}\n\t// PrintfDebug(\"\u7d20\u56e0\u6570\u5206\u89e3: %v\\n\", memo)\n\t// PrintfDebug(\"\u30ab\u30a6\u30f3\u30c8: %v\\n\", counts)\n\n\tans := int64(INF_INT64)\n\tfor a, cnt := range counts {\n\t\te := memo[a]\n\t\tChMin(&ans, cnt/e)\n\t}\n\tfmt.Println(ans)\n}\n\nfunc IsProductOverflow(i, j, m int64) bool {\n\treturn float64(i)*float64(j) > float64(m)\n}\n\nfunc IsAddOverflow(i, j, m int64) bool {\n\treturn float64(i)+float64(j) > float64(m)\n}\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int64, target int64) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// TrialDivision returns the result of prime factorization of integer N.\nfunc TrialDivision(n int64) map[int64]int64 {\n\tvar i, exp int64\n\tp := map[int64]int64{}\n\n\tif n <= 1 {\n\t\tpanic(errors.New(\"[argument error]: TrialDivision only accepts a NATURAL number\"))\n\t}\n\n\tfor i = 2; i*i <= n; i++ {\n\t\texp = 0\n\t\tfor n%i == 0 {\n\t\t\texp++\n\t\t\tn /= i\n\t\t}\n\n\t\tif exp == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tp[i] = exp\n\t}\n\tif n > 1 {\n\t\tp[n] = 1\n\t}\n\n\treturn p\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "src_uid": "491748694c1a53771be69c212a5e0e25"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\nfunc getLine2Ints(n int) []int {\n\tans := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d \", &ans[i])\n\t}\n\tscanf(\"%d\\n\", &ans[n-1])\n\treturn ans\n}\n\nfunc pcheck(i bool) {\n\tif i {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n\nvar debug = true\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tn := getLine2Int()\n\tinput := getLine2Ints(n)\n\tmin, zero := 0, 2\n\tfor i := 0; i < n; i++ {\n\t\tif input[i] == 0 {\n\t\t\tzero++\n\t\t} else {\n\t\t\tif zero <= 1 {\n\t\t\t\tmin += zero + 1\n\t\t\t} else {\n\t\t\t\tmin++\n\t\t\t}\n\t\t\tzero = 0\n\t\t}\n\t}\n\tprintf(\"%d\\n\", min)\n}\n", "src_uid": "2896aadda9e7a317d33315f91d1ca64d"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc is_palindrome(t string) bool {\n\tvar c []string = strings.Split(t, \"\")\n\n\tfor i, j := 0, len(c)-1; i < j; i, j = i+1, j-1 {\n\t\tc[i], c[j] = c[j], c[i]\n\t}\n\n\tu := strings.Join(c, \"\")\n\n\tif t == u {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc get_trailing_scores_count(t string) int {\n\n\tcount := 0\n\n\tfor i := len(t) - 1; i > 0; i = i - 1 {\n\t\tif t[i] == '0' {\n\t\t\tcount += 1\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn count\n}\n\nfunc add_leading_zeros(t string, c int) string {\n\tu := t\n\n\tfor i := 0; i < c; i = i + 1 {\n\t\tu = \"0\" + u\n\t}\n\n\treturn u\n}\n\nfunc solve(t string) bool {\n\n\tif is_palindrome(t) {\n\t\treturn true\n\t}\n\n\ttrailing_zeros := get_trailing_scores_count(t)\n\n\tu := add_leading_zeros(t, trailing_zeros)\n\n\tif is_palindrome(u) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\tvar t string\n\n\tfmt.Scanf(\"%s\", &t)\n\n\tif solve(t) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "src_uid": "d82278932881e3aa997086c909f29051"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tvar a = make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a[i])\n\t}\n\n\tvar m, v int // 2 -spr 1 -cnt\n\tfor i := 0; i < n; i++ {\n\t\tif a[i] == 0 {\n\t\t\tv++\n\t\t\tm = 0\n\t\t} else if a[i] == 1 && m != 1 {\n\t\t\tm = 1\n\t\t} else if a[i] == 2 && m != 2 {\n\t\t\tm = 2\n\t\t} else if a[i] == 3 {\n\t\t\tif m == 1 {\n\t\t\t\tm = 2\n\t\t\t} else if m == 2 {\n\t\t\t\tm = 1\n\t\t\t} else {\n\t\t\t\tif i+1 < n {\n\t\t\t\t\tif a[i+1] == 1 {\n\t\t\t\t\t\tm = 2\n\t\t\t\t\t} else if a[i+1] == 2 {\n\t\t\t\t\t\tm = 1\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tm = 0\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tv++\n\t\t\tm = 0\n\t\t}\n\t}\n\tfmt.Println(v)\n}", "src_uid": "08f1ba79ced688958695a7cfcfdda035"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar n int\n\tfmt.Fscanf(bufin, \"%d\\n\", &n)\n\n\tvar s string\n\tfmt.Fscanf(bufin, \"%s\\n\", &s)\n\n\tfor i := 0; i < n; i++ {\n\t\tif (i+2 < n) && (s[i] == 'o') && (s[i+1] == 'g') && (s[i+2] == 'o') {\n\t\t\tj := i + 3\n\t\t\tfor (j+1 < n) && (s[j] == 'g') && (s[j+1] == 'o') {\n\t\t\t\tj += 2\n\t\t\t}\n\t\t\ti = j - 1\n\t\t\tfmt.Fprintf(bufout, \"***\")\n\t\t} else {\n\t\t\tfmt.Fprintf(bufout, \"%c\", s[i])\n\t\t}\n\t}\n}\n", "src_uid": "619665bed79ecf77b083251fe6fe7eb3"} {"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}\n\nfunc smallestPrimeFactor(x int64) int64 {\n for a := int64(2); a * a <= x; a++ {\n if x % a == 0 {\n return a\n }\n }\n return x\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n n := getI64()\n x := n\n factors := []int64{}\n for len(factors) < 3 {\n a := smallestPrimeFactor(x)\n if a == 1 {\n break\n }\n factors = append(factors, a)\n x /= a\n }\n if len(factors) < 2 {\n writer.WriteString(\"1\\n0\\n\")\n } else if len(factors) == 2 {\n writer.WriteString(\"2\\n\")\n } else {\n writer.WriteString(fmt.Sprintf(\"1\\n%d\\n\", factors[0] * factors[1]))\n }\n}\n", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(a int) bool {\n\tvar count int\n\tfor a != 0 {\n\t\tif a%10 != 0 {\n\t\t\tcount++\n\t\t}\n\t\tif count == 2 {\n\t\t\treturn false\n\t\t}\n\t\ta = a / 10\n\t}\n\treturn true\n}\n\nfunc lenint(a int) int {\n\tvar count int\n\tfor a != 0 {\n\t\ta = a / 10\n\t\tcount++\n\t}\n\treturn count\n}\n\nfunc main() {\n\tvar n int\n\tvar tmp, tmp2 int\n\tfmt.Scanf(\"%d\", &n)\n\ttmp2 = n\n\ttmp = lenint(n)\n\tif tmp == 1 {\n\t\tfmt.Println(\"1\")\n\t} else {\n\t\tfor i := 0; i < tmp-1; i++ {\n\t\t\tn = n / 10\n\t\t}\n\t\tn++\n\t\tfor i := 0; i < tmp-1; i++ {\n\t\t\tn = n * 10\n\t\t}\n\t\tfmt.Println(n - tmp2)\n\t}\n}", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n int\n\tfmt.Fscan(reader, &n)\n\td := make([]int, n)\n\tused := make([]bool, 10001)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(reader, &d[i])\n\t}\n\tsort.Ints(d)\n\tvar biggest = d[n-1]\n\tfor i := n - 1; i >= 0; i-- {\n\t\tif biggest%d[i] != 0 || used[d[i]] {\n\t\t\tfmt.Println(biggest, d[i])\n\t\t\tbreak\n\t\t}\n\t\tused[d[i]] = true\n\t}\n\treturn\n}\n", "src_uid": "868407df0a93085057d06367aecaf9be"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := readInt()\n\tb := readInt()\n\tif (a+1 == b || b+1 == a || a == b) && !(a == 0 && b == 0) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar h int\n\tvar n int64\n\tfmt.Scanf(\"%d %d\", &h, &n)\n\tn -= 1\n\ttn := int64(1)\n\tr := int64(0)\n\tfor i := 0; i < h; i++ {\n\t\ttn *= 2\n\t}\n\tisLeft := true\n\tfor i := 0; i < h; i++ {\n\t\ttn /= 2\n\t\tr += 1\n\t\tif tn&n > 0 {\n\t\t\tif isLeft {\n\t\t\t\tr += 2*tn - 1\n\t\t\t}\n\t\t\tisLeft = true\n\t\t} else {\n\t\t\tif !isLeft {\n\t\t\t\tr += 2*tn - 1\n\t\t\t}\n\t\t\tisLeft = false\n\t\t}\n\t}\n\tfmt.Println(r)\n}\n", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,i int\n\n fmt.Scan(&n)\n if n<=2 {\n fmt.Println(-1)\n}else{\n for i=n;i>=1;i--{\n fmt.Println(i)\n }\n}\n}", "src_uid": "fe8a0332119bd182a0a5b7758716317e"} {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"io/ioutil\"\n\t\"fmt\"\n)\n\nvar (\n\tp int\n\tibuf []byte\n)\n\nfunc IsSpace(b byte) bool {\n\tswitch b {\n\tcase ' ', '\\t', '\\n', '\\r':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsDigit(b byte) bool {\n\treturn '0' <= b && b <= '9'\n}\n\nfunc ReadWord() string {\n\tfor ; p < len(ibuf) && IsSpace(ibuf[p]); p++ {\n\t}\n\tbuf := make([]byte, 0)\n\tfor ; p < len(ibuf) && IsSpace(ibuf[p]); p++ {\n\t\tbuf = append(buf, ibuf[p])\n\t}\n\treturn string(buf)\n}\n\nfunc ReadInt() int {\n\tfor ; p < len(ibuf) && !IsDigit(ibuf[p]) && ibuf[p] != '-'; p++ {\n\t}\n\ts := 1\n\tif ibuf[p] == '-' {\n\t\ts = -1\n\t\tp++\n\t}\n\n\td := 0\n\tfor ; p < len(ibuf) && IsDigit(ibuf[p]); p++ {\n\t\td = 10 * d + int(ibuf[p] - '0')\n\t}\n\treturn s * d\n}\n\nfunc ReadInt64() int64 {\n\tfor ; p < len(ibuf) && !IsDigit(ibuf[p]) && ibuf[p] != '-'; p++ {\n\t}\n\ts := int64(1)\n\tif ibuf[p] == '-' {\n\t\ts = int64(-1)\n\t\tp++\n\t}\n\td := int64(0)\n\tfor ; p < len(ibuf) && IsDigit(ibuf[p]); p++ {\n\t\td = int64(10) * d + int64(ibuf[p] - '0')\n\t}\n\treturn s * d\n}\n\nfunc Max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc Min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc Abs(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t} else {\n\t\treturn a\n\t}\t\n}\n\nfunc LowerBound(a []int64, x int64) int {\n\tub, lb := len(a), 0\n\tfor ub - lb > 1 {\n\t\tmid := (ub + lb) / 2\n\t\tif a[mid] < x {\n\t\t\tlb = mid\n\t\t} else {\n\t\t\tub = mid\n\t\t}\n\t}\n\treturn ub\n}\n\nfunc UpperBound(a []int64, x int64) int {\n\tub, lb := len(a), 0\n\tfor ub - lb > 1 {\n\t\tmid := (ub + lb) / 2\n\t\tif a[mid] > x {\n\t\t\tub = mid\n\t\t} else {\n\t\t\tlb = mid\n\t\t}\n\t}\n\treturn ub\n}\n\ntype Container []int64\n\nfunc (a Container) Len() int {\n\treturn len(a)\n}\n\nfunc (a Container) Swap(i, j int) {\n\ta[i], a[j] = a[j], a[i]\n}\n\nfunc init() {\n\tp = 0\n\tibuf, _ = ioutil.ReadAll(os.Stdin)\n}\n\nfunc solve(n, a, b int64) (int64, int64) {\n\tra, rb := int64(1) << 30, int64(1) << 30\n\tmin_b := b\n\tfor a < n {\n\t\tb = (n - 1) / a + 1\n\t\tif b < min_b {\n\t\t\tbreak\n\t\t}\n\t\tif a * b < ra * rb {\n\t\t\tra, rb = a, b\n\t\t}\n\t\ta = (n - 1) / (b - 1) + 1\n\t}\n\treturn ra, rb\n}\n\nfunc main() {\n\tn, a, b := 6 * ReadInt64(), ReadInt64(), ReadInt64()\n\tif n <= a * b {\n\t\tfmt.Println(a * b)\n\t\tfmt.Println(a, b)\n\t\treturn;\n\t}\n\ta1, b1 := solve(n, a, b)\n\tb2, a2 := solve(n, b, a)\n\tif (a1 * b1 < a2 * b2) {\n\t\tfmt.Println(a1 * b1)\n\t\tfmt.Println(a1, b1)\t\t\n\t} else {\n\t\tfmt.Println(a2 * b2)\n\t\tfmt.Println(a2, b2)\t\t\n\t}\n}\n", "src_uid": "6a2a584d36008151d18e5080aea5029c"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tif n == 2 {\n\t\tfmt.Println(2)\n\t} else {\n\t\tfmt.Println(1)\n\t}\n}\n", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanInt := func() int {\n\t\tscanner.Scan()\n\t\tnum, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\treturn num\n\t}\n\n\tn, index := scanInt(), scanInt()-1\n\tc := make([]bool, n)\n\tfor i := 0; i < n; i++ {\n\t\tc[i] = scanInt() == 1\n\t}\n\n\ttotal := 0\n\tif c[index] {\n\t\ttotal = 1\n\t}\n\tfor i := 1; i < 100; i++ {\n\t\tl, r := index-i, index+i\n\t\tif (l < 0) && (r >= n) {\n\t\t\tbreak\n\t\t}\n\t\tif (l >= 0) && (r < n) && c[l] && c[r] {\n\t\t\ttotal += 2\n\t\t}\n\t\tif (l >= 0) && (r >= n) && c[l] {\n\t\t\ttotal++\n\t\t}\n\t\tif (l < 0) && (r < n) && c[r] {\n\t\t\ttotal++\n\t\t}\n\t}\n\tfmt.Println(total)\n}\n", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5"} {"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}", "src_uid": "f1b43baa14d4c262ba616d892525dfde"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nvar a [3]int\nvar t1 int\nvar t2 int\n\nfunc main() {\n\tfmt.Scan(&a[0], &a[1], &a[2], &t1, &t2)\n\ta[1] = a[1] / 5\n\ta[2] = a[2] / 5\n\ts := a[:]\n\tsort.Ints(s)\n\ttt1 := 3\n\ttt2 := 3\n\tif t1 > s[0] && t1 <= s[1] {\n\t\ttt1 = 1\n\t} else if t1 > s[1] && t1 <= s[2] {\n\t\ttt1 = 2\n\t}\n\tif t2 > s[0] && t2 <= s[1] {\n\t\ttt2 = 1\n\t} else if t2 > s[1] && t2 <= s[2] {\n\t\ttt2 = 2\n\t}\n\tif tt1 == tt2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}", "src_uid": "912c8f557a976bdedda728ba9f916c95"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\n\tpos := true\n\ttoBin := func(r rune) rune {\n\t\tif r - '0' > 0 {\n\t\t\tpos = true\n\t\t\treturn '1'\n\t\t}\n\t\treturn '0'\n\t}\n\tdec := func(r rune) rune {\n\t\tif r - '0' > 0 {\n\t\t\treturn r - 1\n\t\t}\n\t\treturn '0'\n\t}\n\n\tres := \"\"\n\tk := 0\n\tfor ; pos; k++ {\n\t\tpos = false\n\t\tbuf := strings.Map(toBin, s)\n\t\tif pos == false {\n\t\t\tbreak\n\t\t}\n\t\ti := 0\n\t\tfor ; buf[i] == '0'; i++ {}\n\t\tres += \" \" + buf[i:]\n\t\ts = strings.Map(dec, s)\n\t}\n\tfmt.Println(k)\n\tfmt.Println(res[1:])\n}\n", "src_uid": "033068c5e16d25f09039e29c88474275"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tvar arr []byte\n\tvar flag bool\n\tfmt.Scanf(\"%s\", &s)\n\tfor i := range s {\n\t\tflag = false\n\t\tfor j := 0; j < len(arr); j++ {\n\t\t\tif s[i] == arr[j] {\n\t\t\t\tflag = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !flag {\n\t\t\tarr = append(arr, s[i])\n\t\t}\n\t}\n\tif len(arr)%2 == 0 {\n\t\tfmt.Println(\"CHAT WITH HER!\")\n\t} else {\n\t\tfmt.Println(\"IGNORE HIM!\")\n\t}\n}", "src_uid": "a8c14667b94b40da087501fd4bdd7818"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc readNIntegersAndSave(n int, registry *Registry) ([]int) {\n\tresult := make([]int, n)\n\tfor i := range result[:n] {\n\t\tfmt.Scanf(\"%d\", &result[i])\n\t\t(*registry)[result[i]] = true\n\t}\n\treturn result\n}\n\ntype Registry map[int]bool\n\nfunc main() {\n\tfmt.Println(\"Karen\")\n\treturn \n\tvar n int\n\tregistry := make(Registry)\n\n\tfmt.Scanf(\"%d\", &n)\n\n\tcounter := 0\n\tkoyomi, karen := readNIntegersAndSave(n, ®istry), readNIntegersAndSave(n, ®istry)\n\n\tfor i := range koyomi {\n\t\tfor j := range karen {\n\t\t\tif registry[koyomi[i]^karen[j]] {\n\t\t\t\tcounter++\n\t\t\t}\n\t\t}\n\t}\n\n\tif (counter%2 == 0) {\n\t\tfmt.Println(\"Karen\")\n\t} else {\n\t\tfmt.Println(\"Koyomi\")\n\t}\n}\n", "src_uid": "1649d2592eadaa8f8d076eae2866cffc"} {"source_code": "package main\n\nimport \"fmt\"\n \nfunc gcd(a int, b int, x *int, y *int) int {\n if a == 0 {\n *x, *y = 0, 1\n return b\n }\n var xx, yy int\n g := gcd(b%a, a, &xx, &yy)\n *x = yy - (b/a)*xx\n *y = xx\n return g\n}\n\nfunc normal(n int, mod *int) int {\n n %= (*mod)\n if n < 0 {\n n += (*mod)\n }\n return n\n}\n\nfunc inv(a int, mod *int) int {\n var x, y int\n gcd(a, *mod, &x, &y)\n return normal(x, mod)\n}\n\nfunc addmod(a, b int, mod *int) int { \n if a + b >= (*mod) {\n return a + b - (*mod)\n } else {\n return a + b\n }\n}\n\nfunc submod(a, b int, mod *int) int { \n if a - b < 0 {\n return a - b + (*mod)\n } else {\n return a - b\n }\n}\n\nfunc mulmod(a, b int, mod *int) int { \n return int((int64(a)*int64(b))%int64(*mod))\n}\n\nfunc divmod(a, b int, mod *int) int { \n return mulmod(a, inv(b, mod), mod)\n}\n\nfunc binpowmod(a, b int, mod *int) int {\n ans := 1\n for b > 0 {\n if b%2 == 1 {\n ans = mulmod(ans, a, mod)\n }\n a = mulmod(a, a, mod)\n b = b/2\n }\n return ans\n}\n \nfunc calc(y []int, x int, mod *int) int {\n ans := 0\n k := 1\n for j := 1; j < len(y); j++ {\n k = mulmod(k, normal(x - j, mod), mod)\n k = divmod(k, normal(0 - j, mod), mod)\n }\n for i := 0; i < len(y); i++ {\n ans = addmod(ans, mulmod(y[i], k, mod), mod)\n if (i + 1) >= len(y) {\n break\n }\n k = mulmod(k, divmod(normal(x - i, mod), normal(x - (i + 1), mod), mod), mod)\n k = mulmod(k, divmod(normal(i - (len(y) - 1), mod), normal(i + 1, mod), mod), mod)\n }\n return ans\n}\n\nfunc main() {\n var n, k int\n var mod int = 1000000007\n var y []int = make([]int, 0)\n s := 0\n y = append(y, s)\n fmt.Scanf(\"%d %d\", &n, &k)\n for i := 0; i < k + 1; i++ {\n s = addmod(s, binpowmod(i + 1, k, &mod), &mod) //k-th powwer of (i+1)\n y = append(y, s)\n }\n if n < len(y) {\n fmt.Printf(\"%d\", y[n])\n } else {\n p := calc(y, n, &mod)\n fmt.Printf(\"%d\", p)\n }\n}\n", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c"} {"source_code": "package main\n\nimport (\n \"strconv\"\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n// var file, _ = os.Open(\"input.txt\")\n// var outfile, _ = os.Create(\"output.txt\")\n// var in = bufio.NewScanner(file)\n// var out = bufio.NewWriter(outfile)\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc next() string {\n if !in.Scan() {\n panic(\"Scan error\")\n }\n return in.Text()\n}\n\nfunc nextInt() int {\n ret, _ := strconv.Atoi(next())\n return ret\n}\n\nfunc nextFloat() float64 {\n ret, _ := strconv.ParseFloat(next(), 64)\n return ret\n}\n\nfunc intersect(l1 int, r1 int, l2 int, r2 int) bool {\n if l1 > r1 {\n l1, r1 = r1, l1\n }\n if l2 > r2 {\n l2, r2 = r2, l2\n }\n return l1 < l2 && l2 < r1 && r1 < r2 || l2 < l1 && l1 < r2 && r2 < r1\n}\n\nfunc main() {\n defer out.Flush()\n in.Split(bufio.ScanWords)\n n := nextInt()\n a := make([]int, n)\n for i := 0; i < n; i++ {\n a[i] = nextInt()\n }\n\n for i := 0; i < n - 1; i++ {\n for j := i + 1; j < n - 1; j++ {\n if intersect(a[i], a[i + 1], a[j], a[j + 1]) {\n fmt.Fprintln(out, \"yes\")\n return\n }\n }\n }\n fmt.Fprintln(out, \"no\")\n}\n", "src_uid": "f1b6b81ebd49f31428fe57913dfc604d"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"unicode\"\n)\n\nvar stdReader *bufio.Reader = bufio.NewReader(os.Stdin)\n\nfunc readInt() (result int) {\n\tvar negative, started bool\nREADER_LOOP:\n\tfor {\n\t\tchar, err := stdReader.ReadByte()\n\t\tswitch {\n\t\tcase err != nil:\n\t\t\tbreak READER_LOOP\n\t\tcase char == '-':\n\t\t\tnegative = true\n\t\tcase unicode.IsDigit(rune(char)):\n\t\t\tstarted = true\n\t\t\tresult = result*10 + int(char&0xf)\n\t\tcase started:\n\t\t\tbreak READER_LOOP\n\t\t}\n\t}\n\tif negative {\n\t\tresult = -result\n\t}\n\treturn\n}\n\nfunc main() {\n\tn := readInt()\n\tmaj := make([]int, n)\n\tvar sum int\n\tfor i := range maj {\n\t\tmaj[i] = readInt()\n\t\tsum += maj[i]\n\t}\n\n\tone := sum / (n / 2)\nLOOP:\n\tfor i := range maj {\n\t\tif maj[i] == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tfor j := len(maj) - 1; j > i; j-- {\n\t\t\tif maj[i]+maj[j] == one {\n\t\t\t\tmaj[i] = 0\n\t\t\t\tmaj[j] = 0\n\t\t\t\tfmt.Printf(\"%d %d\\n\", i+1, j+1)\n\t\t\t\tcontinue LOOP\n\t\t\t}\n\t\t}\n\t}\n}\n", "src_uid": "6e5011801ceff9d76e33e0908b695132"} {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1216/problem/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Point struct {\n\tX int\n\tY int\n}\n\ntype Rectangle struct {\n\tBottomLeft Point\n\tTopRight Point\n}\n\nfunc max(x int, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x int, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc intersection(R1, R2 Rectangle) Rectangle {\n\tbottomLeft := Point{\n\t\tX: max(R1.BottomLeft.X, R2.BottomLeft.X),\n\t\tY: max(R1.BottomLeft.Y, R2.BottomLeft.Y),\n\t}\n\ttopRight := Point{\n\t\tX: min(R1.TopRight.X, R2.TopRight.X),\n\t\tY: min(R1.TopRight.Y, R2.TopRight.Y),\n\t}\n\tif topRight.X <= bottomLeft.X || topRight.Y <= bottomLeft.Y {\n\t\treturn Rectangle{BottomLeft: Point{0, 0}, TopRight: Point{0, 0}}\n\t}\n\treturn Rectangle{BottomLeft: bottomLeft, TopRight: topRight}\n}\n\nfunc area(R Rectangle) int64 {\n\treturn int64(R.TopRight.X-R.BottomLeft.X) * int64(R.TopRight.Y-R.BottomLeft.Y)\n}\n\nfunc Solve(R1, R2, R3 Rectangle) string {\n\tR4 := intersection(R1, R2)\n\tR5 := intersection(R1, R3)\n\tR6 := intersection(R4, R5)\n\tcoveredArea := area(R4) + area(R5) - area(R6)\n\tif area(R1) > coveredArea {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar R1, R2, R3 Rectangle\n\tfmt.Fscanf(reader, \"%d %d %d %d\\n\", &R1.BottomLeft.X, &R1.BottomLeft.Y, &R1.TopRight.X, &R1.TopRight.Y)\n\tfmt.Fscanf(reader, \"%d %d %d %d\\n\", &R2.BottomLeft.X, &R2.BottomLeft.Y, &R2.TopRight.X, &R2.TopRight.Y)\n\tfmt.Fscanf(reader, \"%d %d %d %d\\n\", &R3.BottomLeft.X, &R3.BottomLeft.Y, &R3.TopRight.X, &R3.TopRight.Y)\n\n\tfmt.Fprintf(writer, \"%s\\n\", Solve(R1, R2, R3))\n}\n", "src_uid": "05c90c1d75d76a522241af6bb6af7781"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc gcd(a, b int64) int64 {\n\tswitch {\n\tcase a == 0 && b > 0:\n\t\treturn b\n\tcase a > 0 && b == 0:\n\t\treturn a\n\tcase a == b:\n\t\treturn a\n\tcase a == 1 && b > 0:\n\t\treturn 1\n\tcase a > 0 && b == 1:\n\t\treturn 1\n\tcase a%2 == 0 && b%2 == 0:\n\t\treturn 2 * gcd(a/2, b/2)\n\tcase a%2 == 0 && b%2 == 1:\n\t\treturn gcd(a/2, b)\n\tcase a%2 == 1 && b%2 == 0:\n\t\treturn gcd(a, b/2)\n\tcase b > a:\n\t\treturn gcd((b-a)/2, a)\n\tcase b < a:\n\t\treturn gcd((a-b)/2, b)\n\tdefault:\n\t\tpanic(\"not reachable\")\n\t}\n}\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scanf(\"%d %d\", &n, &k)\n\tk = int64(math.Pow10(int(k)))\n\tfmt.Println(n * k / gcd(n, k))\n}\n", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n)\n\nfunc main() {\n\tn, m := scanInt(), scanInt()\n\tif 9 * n < m || (m < 1 && n > 1){\n\t\tprintFmt(\"-1 -1\")\n\t\treturn\n\t}\n\tmin := getMin(n,m)\n\tmax := getMax(n,m)\n\n\tprintFmt(min, max)\n\n\tclose(channelType)\n\toWg.Wait()\n}\n\nfunc getMax(n, m int) string{\n\tvar max string\n\tfor m > 9{\n\t\tmax = max + \"9\"\n\t\tm -= 9\n\t\tn--\n\t}\n\n\tmax = max + strconv.Itoa(m)\n\tn--\n\tfor i := 0; i < n; i++{\n\t\tmax = max + \"0\"\n\t}\n\treturn max\n}\n\nfunc getMin(n, m int) string{\n\tvar min string\n\tfor m > 9{\n\t\tmin = \"9\" + min\n\t\tm -= 9\n\t\tn--\n\t}\n\n\tif n == 1{\n\t\tmin = strconv.Itoa(m) + min\n\t}else{\n\t\tif m > 1{\n\t\t\tmin = strconv.Itoa(m-1) + min\n\t\t\tn--\n\t\t}\n\n\t\tfor i:= 0; i < n-1; i++{\n\t\t\tmin = \"0\" + min\n\t\t}\n\t\tmin = \"1\" + min\n\t}\n\treturn min\n}\n\n\n/*********************** I/O ***********************/\n\nvar channelType chan string\nvar in *bufio.Scanner\nvar oWg *sync.WaitGroup\nvar printFmt func(a ...interface{}) (n int, err error)\n\nfunc init() {\n\tprintFmt = fmt.Println\n\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(1e+9))\n\tin.Split(bufio.ScanWords)\n\n\tchannelType = make(chan string, 16)\n\toWg = &sync.WaitGroup{}\n\toWg.Add(1)\n\n\twriter := bufio.NewWriter(os.Stdout)\n\tgo func() {\n\t\tdefer oWg.Done()\n\t\tdefer writer.Flush()\n\n\t\tfor line := range channelType {\n\t\t\twriter.WriteString(line + \"\\n\")\n\t\t}\n\t}()\n}\n\nfunc scanString() string {in.Scan(); return in.Text() }\nfunc scanInt() int {i, _ := strconv.Atoi(scanString()); return i}\nfunc scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}\nfunc scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; return s}\nfunc scanIntSlice(n int) []int {arr := make([]int, n); for i := 0; i < n; i++ {arr[i] = scanInt()}; return arr}\nfunc scanInt64Slice(n int) []int64 {arr := make([]int64, n); for i := 0; i < n; i++ {arr[i] = scanInt64()}; return arr}\n\n/*********************** Utils ***********************/\n\nfunc stringEquivalent(v interface{}) string {return fmt.Sprintf(\"%v\", v)}\nfunc spaceSeperatedStringFromArray(a []int) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.Itoa(a[i]) + \" \")}; return sb.String()}\nfunc spaceSeperatedStringFromArray64(a []int64) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.FormatInt(a[i], 10) + \" \")}; return sb.String()}\nfunc minMaxFromArray(args ...int64) (int64, int64) {minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64); for _, v := range args {if v < minVal {minVal = v}; if v > maxVal {maxVal = v}}; return minVal, maxVal}\nfunc minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }\nfunc maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }\nfunc lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}\nfunc gcdCalculation(a, b int64) int64 {if (a == 0) {return b}; return gcdCalculation(b%a, a)}\nfunc sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}\nfunc absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}\nfunc min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }\nfunc max(args ...int) int { _, mx := minMaxFinder(args...); return mx }\nfunc minMaxFinder(args ...int) (int, int) { minVal, maxVal := int(math.MaxInt32), int(math.MinInt32); for _, v := range args { if v < minVal { minVal = v }; if v > maxVal { maxVal = v } }; return minVal, maxVal }\n", "src_uid": "75d062cece5a2402920d6706c655cad7"} {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1312/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 998244353\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn, m int64\n)\n\nfunc main() {\n\tn, m = ReadInt64_2()\n\n\tif n == 2 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tcf := NewCombFactorial(500000)\n\n\tans := int64(1)\n\tans *= cf.C(m, n-1)\n\tans %= MOD\n\tans *= n - 2\n\tans %= MOD\n\tans *= cf.modpow(2, n-3)\n\tans %= MOD\n\n\tfmt.Println(ans)\n}\n\n// cf := NewCombFactorial(500000) // maxNum == \"maximum n\" * 2 (for H(n,r))\n// res := cf.C(n, r) \t// \u7d44\u307f\u5408\u308f\u305b\n// res := cf.H(n, r) \t// \u91cd\u8907\u7d44\u5408\u305b\n// res := cf.P(n, r) \t// \u9806\u5217\n\ntype CombFactorial struct {\n\tfactorial, invFactorial []int64\n\tmaxNum int64\n}\n\nfunc NewCombFactorial(maxNum int64) *CombFactorial {\n\tcf := new(CombFactorial)\n\tcf.maxNum = maxNum\n\tcf.factorial = make([]int64, maxNum+50)\n\tcf.invFactorial = make([]int64, maxNum+50)\n\tcf.initCF()\n\n\treturn cf\n}\nfunc (c *CombFactorial) modInv(a int64) int64 {\n\treturn c.modpow(a, MOD-2)\n}\nfunc (c *CombFactorial) modpow(a, e 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 := c.modpow(a, halfE)\n\t\treturn half * half % MOD\n\t}\n\n\treturn a * c.modpow(a, e-1) % MOD\n}\nfunc (c *CombFactorial) initCF() {\n\tvar i int64\n\n\tfor i = 0; i <= c.maxNum; i++ {\n\t\tif i == 0 {\n\t\t\tc.factorial[i] = 1\n\t\t\tc.invFactorial[i] = c.modInv(c.factorial[i])\n\t\t\tcontinue\n\t\t}\n\n\t\tnum := i * c.factorial[i-1]\n\t\tnum %= MOD\n\t\tc.factorial[i] = num\n\t\tc.invFactorial[i] = c.modInv(c.factorial[i])\n\t}\n}\nfunc (c *CombFactorial) C(n, r int64) int64 {\n\tvar res int64\n\n\tres = 1\n\tres *= c.factorial[n]\n\tres %= MOD\n\tres *= c.invFactorial[r]\n\tres %= MOD\n\tres *= c.invFactorial[n-r]\n\tres %= MOD\n\n\treturn res\n}\nfunc (c *CombFactorial) P(n, r int64) int64 {\n\tvar res int64\n\n\tres = 1\n\tres *= c.factorial[n]\n\tres %= MOD\n\tres *= c.invFactorial[n-r]\n\tres %= MOD\n\n\treturn res\n}\nfunc (c *CombFactorial) H(n, r int64) int64 {\n\treturn c.C(n-1+r, r)\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", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\n\nfunc readInt() int {\n\tscanner.Scan()\n\tn, err := strconv.Atoi(scanner.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc readLong() int64 {\n\tscanner.Scan()\n\tn, err := strconv.ParseInt(scanner.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc readWord() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc main() {\n\tscanner.Split(bufio.ScanWords)\n\n\tn, a, x, b, y := readInt(), readInt(), readInt(), readInt(), readInt()\n\n\ta--\n\tx--\n\tb--\n\ty--\n\tfor {\n\t\tif a == b {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\tif a == x || b == y {\n\t\t\tbreak\n\t\t}\n\t\ta = (a + 1) % n\n\t\tb = (b - 1 + n) % n\n\t}\n\tfmt.Println(\"NO\")\n}\n", "src_uid": "5b889751f82c9f32f223cdee0c0095e4"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\\n\", &a, &b)\n\n\tif a == b {\n\t\tfmt.Printf(\"%d0 %d1\", a, b)\n\t} else if a == b-1 {\n\t\tfmt.Printf(\"%d9 %d0\", a, b)\n\t} else if a == 9 && b == 1 {\n\t\tfmt.Println(\"9 10\")\n\t} else {\n\t\tfmt.Println(-1)\n\t}\n}\n", "src_uid": "3eff6f044c028146bea5f0dfd2870d23"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\txys := [2][2]int{}\n\txyc := [2]int{}\n\n\tfor i := 0; i < n; i++ {\n\t\tvar xy [2]int\n\t\tif _, err := fmt.Scanf(\"%d %d\\n\", &xy[0], &xy[1]); err != nil {\n\t\t\treturn\n\t\t}\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tif xyc[j] == 0 {\n\t\t\t\txys[j][0] = xy[j]\n\t\t\t\txyc[j] += 1\n\t\t\t} else if xys[j][0] != xy[j] {\n\t\t\t\txys[j][1] = xy[j]\n\t\t\t\txyc[j] += 1\n\t\t\t}\n\t\t}\n\t}\n\n\tif xyc[0] < 2 || xyc[1] < 2 {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println(abs(xys[0][0]-xys[0][1]) * abs(xys[1][0]-xys[1][1]))\n\t}\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n", "src_uid": "ba49b6c001bb472635f14ec62233210e"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r int64\n\tfmt.Scan(&l, &r)\n\n\tvar p uint64\n\tfor i := uint64(1); l != 0 || r != 0; i++ {\n\t\tif l&1^r&1 == 1 {\n\t\t\tp = (1 << i) - 1\n\t\t}\n\t\tl >>= 1\n\t\tr >>= 1\n\t}\n\tfmt.Println(p)\n}\n", "src_uid": "d90e99d539b16590c17328d79a5921e0"} {"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}", "src_uid": "e7ad55ce26fc8610639323af1de36c2d"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main(){\n\tbags:=make([]int,4)\n\tfor i:=0;i 59 {\n m = 0\n h++\n if h > 23 { h = 0 }\n }\n if (h%10 == m/10) && (h/10 == m%10) { break }\n }\n fmt.Printf(\"%02d:%02d\\n\",h,m)\n}\n", "src_uid": "158eae916daa3e0162d4eac0426fa87f"} {"source_code": "// http://codeforces.com/problemset/problem/651/A\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nconst (\n\tMOD = 1e9 + 7\n)\n\ntype (\n\n)\n\nfunc main () {\n\tvar (\n\t\tn1, n2 int\n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\tfmt.Fscanln(input, &n1, &n2)\n\n\tans := 0\n\tfor n1 > 0 && n2 > 0 {\n\t\t//fmt.Println(n1, n2)\n\t\tif n1 > 2 {\n\t\t\tn1 -= 2\n\t\t\tn2++\n\t\t\tans++\n\t\t} else {\n\t\t\tn1, n2 = n2, n1\n\n\t\t\tif (n1 == 2 && n2 == 2) || (n1 * n2 == 2) {\n\t\t\t\tans++\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif n1 * n2 < 2 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}", "src_uid": "ba0f9f5f0ad4786b9274c829be587961"} {"source_code": "package main\n\nimport \"fmt\"\n\nvar mem [205][205][205]bool\n\nfunc can(r, g, b int) {\n\tif mem[r][g][b] {\n\t\treturn\n\t}\n\tmem[r][g][b] = true\n\tif r >= 1 && g >= 1 {\n\t\tcan(r-1, g-1, b+1)\n\t}\n\tif r >= 1 && b >= 1 {\n\t\tcan(r-1, g+1, b-1)\n\t}\n\tif g >= 1 && b >= 1 {\n\t\tcan(r+1, g-1, b-1)\n\t}\n\tif r >= 2 {\n\t\tcan(r-1, g, b)\n\t}\n\tif g >= 2 {\n\t\tcan(r, g-1, b)\n\t}\n\tif b >= 2 {\n\t\tcan(r, g, b-1)\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar s string\n\tfmt.Scan(&s)\n\tvar r, g, b int\n\tfor _, c := range s {\n\t\tswitch c {\n\t\tcase 'B':\n\t\t\tb++\n\t\tcase 'G':\n\t\t\tg++\n\t\tcase 'R':\n\t\t\tr++\n\t\tdefault:\n\t\t\tpanic(c)\n\t\t}\n\t}\n\n\tcan(r, g, b)\n\n\tvar res []byte\n\tif mem[0][0][1] {\n\t\tres = append(res, 'B')\n\t}\n\tif mem[0][1][0] {\n\t\tres = append(res, 'G')\n\t}\n\tif mem[1][0][0] {\n\t\tres = append(res, 'R')\n\t}\n\tfmt.Printf(\"%s\\n\", res)\n}\n", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f"} {"source_code": "package main\n\n// @snippet \nimport \"fmt\"\nimport \"io\"\nimport \"os\"\nimport \"strings\"\nimport \"text/scanner\"\n// @snippet \ntype Int int64\ntype IntSlice []Int\n// @snippet \nvar sc scanner.Scanner\n\nfunc ReadInt(n *Int) bool {\n tok := sc.Scan()\n if tok != scanner.EOF {\n fmt.Sscan(sc.TokenText(), &n)\n return true\n } else {\n return false\n }\n}\n\nfunc ReadString(s *string) bool {\n tok := sc.Scan()\n if tok != scanner.EOF {\n *s = sc.TokenText()\n return true\n } else {\n return false\n }\n}\n// @snippet \nfunc Stdin() io.Reader {\n return os.Stdin\n}\n\nfunc Strin(s string) io.Reader {\n return strings.NewReader(s)\n}\n// @snippet \n\nfunc min(a rune, b rune) rune {\n if a < b {\n return a\n } else {\n return b\n }\n}\n\nfunc findMin(s string) string {\n res := \"\"\n for i, c := range s {\n if i == 0 && c == '9' {\n res += \"9\"\n } else {\n res += string(min(c, '9' - c + '0'))\n }\n }\n return res\n}\n\nfunc main() {\n sc.Init(Stdin())\n var s string\n for ReadString(&s) {\n fmt.Println(findMin(s))\n }\n}\n\n", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61"} {"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", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l1, r1, l2, r2, k int64\n\tfmt.Scan(&l1, &r1, &l2, &r2, &k)\n\n\tl := l1\n\tif l2 > l1 {\n\t\tl = l2\n\t}\n\tr := r1\n\tif r2 < r1 {\n\t\tr = r2\n\t}\n\n\tresult := r - l + 1\n\tif k >= l && k <= r {\n\t\tresult--\n\t}\n\n\tif result < 0 {\n\t\tresult = 0\n\t}\n\n\tfmt.Println(result)\n}\n", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82"} {"source_code": "\ufeffpackage main\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\nfunc main(){\n\tvar i,c int\n\tvar s string\n\tvar cmax rune\n\tfmt.Scan(&s)\n\tout := bufio.NewWriter(os.Stdout)\n\tr:=make([]rune,len(s))\n\tfor i,v:=range s {\n\t\tr[i]=v\n\t}\n\tfor i=0;icmax {\n\t\t\tcmax=r[i]\n\t\t\tc=1\n\t\t} else if r[i]==cmax {\n\t\t\tc++\n\t\t}\n\t}\n\tfor i=0;i 0 {\n\t\t\tres = append(res, a+b)\n\t\t\tcnt--\n\t\t}\n\t}\n\n\tif dx != 0 {\n\t\ta := \"R\"\n\t\tif dx < 0 {\n\t\t\ta = \"L\"\n\t\t}\n\t\tcnt := abs(dx)\n\t\tfor cnt > 0 {\n\t\t\tres = append(res, a)\n\t\t\tcnt--\n\t\t}\n\t}\n\tif dy != 0 {\n\t\tb := \"U\"\n\t\tif dy < 0 {\n\t\t\tb = \"D\"\n\t\t}\n\t\tcnt := abs(dy)\n\t\tfor cnt > 0 {\n\t\t\tres = append(res, b)\n\t\t\tcnt--\n\t\t}\n\t}\n\treturn res\n}\n\nfunc min(a, b int) int {\n\tif a <= b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n", "src_uid": "d25d454702b7755297a7a8e1f6f36ab9"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"io\"\n\t\"bufio\"\n)\nvar input io.Reader\n\nfunc main() {\n\tvar n, k int\n\tinput = bufio.NewReader(os.Stdin)\n\tfmt.Fscanln(input, &n, &k)\n\tl, r := 0, n\n\tfor l < r {\n\t\tmid := l + (r - l) / 2\n\t\td := k\n\t\tlines := mid\n\t\tfor lines < n && mid / d > 0 {\n\t\t\tlines += mid/d\n\t\t\td *= k\n\t\t}\n\t\tif lines < n {\n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\n\tfmt.Println(r)\n}\n", "src_uid": "41dfc86d341082dd96e089ac5433dc04"} {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"strings\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nvar validChars = \"_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nfunc valid(s string) bool {\n if len(s) < 1 || len(s) > 16 {\n return false\n }\n for _, ch := range s {\n if strings.IndexRune(validChars, ch) == -1 {\n return false\n }\n }\n return true\n}\n\nfunc validate(s string) bool {\n if strings.Count(s, \"@\") != 1 || strings.Count(s, \"/\") > 1 {\n return false\n }\n\n parts := strings.Split(s, \"@\")\n username, hostname := parts[0], parts[1]\n if !valid(username) {\n return false\n }\n\n if strings.Count(hostname, \"/\") == 1 {\n parts = strings.Split(hostname, \"/\")\n hostname = parts[0]\n resource := parts[1]\n if !valid(resource) {\n return false\n }\n }\n\n parts = strings.Split(hostname, \".\")\n for _, part := range parts {\n if !valid(part) {\n return false\n }\n }\n\n return true\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n s := getS()\n result := \"YES\"\n if !validate(s) {\n result = \"NO\"\n }\n writer.WriteString(fmt.Sprintf(\"%s\\n\", result))\n}\n", "src_uid": "2a68157e327f92415067f127feb31e24"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n)\n\nfunc get_len(n int64) int64 {\n\tif n > 1 {\n\t\treturn 2 * get_len(n/2) + 1\n\t}\n\treturn n\n}\n\nfunc max(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc solve(n, l, r int64) int64 {\n\tvar s int64\n\tif n > 0 {\n\t\tk := get_len(n / 2)\n\t\tif l < k {\n\t\t\ts += solve(n/2, l, min(r, k - 1))\n\t\t}\n\t\tif l <= k && k <= r {\n\t\t\ts += n % 2\n\t\t}\n\t\tif r > k {\n\t\t\ts += solve(n/2, max(l - k - 1, 0), r - k - 1)\n\t\t}\n\t\t// fmt.Printf(\"%d %d %d %d\\n\", n, k, l, r)\n\t}\n\treturn s\n}\n\nfunc main() {\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\tn := cin.nextInt64()\n\tl := cin.nextInt64() - 1\n\tr := cin.nextInt64() - 1\n\tfmt.Printf(\"%v\", solve(n, l, r))\n}\n\n// some io\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a"} {"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", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tn := len(s)\n\tfor i := 0; i < n - 2; i++ {\n\t\tmark := make([]bool, 3)\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif s[i + j] != '.' {\n\t\t\t\tmark[int(s[i + j]) - int('A')] = true\n\t\t\t}\n\t\t}\n\t\tvalid := true\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif !mark[j] {\n\t\t\t\tvalid = false\n\t\t\t}\n\t\t}\n\t\tif valid {\n\t\t\tfmt.Println(\"Yes\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"No\")\n}\n", "src_uid": "ba6ff507384570152118e2ab322dd11f"} {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"math\"\r\n\t\"os\"\r\n\t\"strconv\"\r\n\t\"strings\"\r\n)\r\n\r\ntype CF1619B 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 *CF1619B) 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 *CF1619B) 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 *CF1619B) 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 *CF1619B) 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 *CF1619B) 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\nTO SEND\r\nRun solve the problem CF1619B\r\nDate: 3/01/22\r\nUser: pepradere\r\nURL: https://codeforces.com/problemset/problem/1619/B\r\nProblem: CF1619B\r\n**/\r\nfunc (in *CF1619B) Run() {\r\n\tmapa := make(map[int64]int)\r\n\tarr := make([]int64, 0)\r\n\tto := int64(math.Sqrt(1000000000))\r\n\tfor i := int64(1); i <= to; i++ {\r\n\t\tif _, ok := mapa[i*i]; !ok {\r\n\t\t\tarr = append(arr, int64(i*i))\r\n\t\t\tmapa[i*i] = 1\r\n\t\t}\r\n\t\tif _, ok := mapa[i*i*i]; !ok {\r\n\t\t\tarr = append(arr, int64(i*i*i))\r\n\t\t\tmapa[i*i*i] = 1\r\n\t\t}\r\n\t}\r\n\tfor t := in.NextInt(); t > 0; t-- {\r\n\t\tn := in.NextInt64()\r\n\t\tcount := 0\r\n\t\tfor i := 0; i < len(arr); i++ {\r\n\t\t\tif arr[i] <= n {\r\n\t\t\t\tcount++\r\n\t\t\t}\r\n\t\t}\r\n\t\tfmt.Println(count)\r\n\t}\r\n}\r\n\r\nfunc NewCF1619B(r *bufio.Reader) *CF1619B {\r\n\treturn &CF1619B{\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\tNewCF1619B(bufio.NewReader(os.Stdin)).Run()\r\n}\r\n", "src_uid": "015afbefe1514a0e18fcb9286c7b6624"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc init() {\n\tscanner = bufio.NewScanner(bufio.NewReader(os.Stdin))\n\t//scanner.Buffer(make([]byte, 311000), 311000)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc next() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tnum, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn num\n}\n\nfunc main() {\n\tN := nextInt()\n\tdata := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tdata[i] = nextInt()\n\t}\n\n\tdel := 0\n\tstart := 0\n\tfor cur := 0; cur < N; cur++ {\n\t\tif cur+1 == N || data[cur]+1 != data[cur+1] {\n\t\t\trem := cur - start - 1\n\t\t\tif start == 0 && cur > 0 && data[1] == 2 {\n\t\t\t\trem++\n\t\t\t}\n\n\t\t\tif cur == N-1 && rem >= 0 && len(data) > 1 && data[len(data)-2] == 999 {\n\t\t\t\trem++\n\t\t\t}\n\t\t\tif rem > del {\n\t\t\t\t//fmt.Println(\"st\", start, \"cur\", cur, \"rem\", rem)\n\t\t\t\tdel = rem\n\t\t\t}\n\t\t\tstart = cur + 1\n\t\t}\n\t}\n\t//fmt.Println(\"xx\", del)\n\tfmt.Println(del)\n}\n", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc calcDigit(q int) int {\n switch q {\n case 0: return 6\n case 1: return 2\n case 2: return 5\n case 3: return 5\n case 4: return 4\n case 5: return 5\n case 6: return 6\n case 7: return 3\n case 8: return 7\n case 9: return 6\n }\n return 0\n}\n\nfunc calcInt(q int) int {\n if q == 0 {\n return 6\n }\n var result int = 0\n for q > 0 {\n result += calcDigit(q%10)\n q /= 10\n }\n return result\n}\n\nfunc main() {\n var a, b int\n fmt.Scanf(\"%d %d\", &a, &b)\n totalCount := 0\n for q := a; q <= b; q++ {\n totalCount += calcInt(q)\n }\n fmt.Printf(\"%d\", totalCount)\n}\n", "src_uid": "1193de6f80a9feee8522a404d16425b9"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tboard := make([][]byte, 9)\n\tfor i, _ := range board {\n\t\tboard[i] = make([]byte, 9)\n\t}\n\n\tfor i := 0; i < 27; i++ {\n\t\ts := readString()\n\t\tfor j, c := range s {\n\t\t\tx := j + ((i % 3) * 3)\n\t\t\ty := i / 3\n\t\t\tboard[x][y] = byte(c)\n\t\t}\n\t}\n\tlasty := readInt() - 1\n\tlastx := readInt() - 1\n\tnewx := (lastx % 3) * 3\n\tnewy := (lasty % 3) * 3\n\tif isfull(board, newx, newy) {\n\t\tfillall(board)\n\t} else {\n\t\tfill(board, newx, newy)\n\t}\n\n\tfor y := 0; y < 9; y++ {\n\t\tfor x := 0; x < 9; x++ {\n\t\t\tfmt.Printf(\"%c\", board[x][y])\n\t\t\tif x == 2 || x == 5 {\n\t\t\t\tfmt.Print(\" \")\n\t\t\t}\n\t\t}\n\t\tfmt.Println()\n\t\tif y == 2 || y == 5 {\n\t\t\tfmt.Println()\n\t\t}\n\t}\n}\n\nfunc isfull(board [][]byte, x, y int) bool {\n\tfor i := 0; i < 3; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif board[x+i][y+j] == '.' {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}\n\nfunc fill(board [][]byte, x, y int) {\n\tfor i := 0; i < 3; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif board[x+i][y+j] == '.' {\n\t\t\t\tboard[x+i][y+j] = '!'\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc fillall(board [][]byte) {\n\tfill(board, 0, 0)\n\tfill(board, 0, 3)\n\tfill(board, 0, 6)\n\n\tfill(board, 3, 0)\n\tfill(board, 3, 3)\n\tfill(board, 3, 6)\n\n\tfill(board, 6, 0)\n\tfill(board, 6, 3)\n\tfill(board, 6, 6)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n", "src_uid": "8f0fad22f629332868c39969492264d3"} {"source_code": "package main\n\nimport(\n \"fmt\"\n)\n\nfunc main(){\n var(\n n,k,i int\n )\n fmt.Scan(&n,&k)\n t := 240-k\n temp := (5*(n*(n+1)))/2\n if t>=temp{\n fmt.Println(n)\n }else{\n res:=0\n for i=1;i<=n;i++{\n res = (5*(i*(i+1)))/2\n if res >t{\n break\n }\n }\n fmt.Println(i-1)\n }\n}\n", "src_uid": "41e554bc323857be7b8483ee358a35e2"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tvar home string\n\tdestinations := make(map[string]bool)\n\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\thome = re.ReplaceAllString(s, \"\")\n\t}\n\n\tfor i := 0; i < n; 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\tss := strings.Split(s, \"->\")\n\t\t\tvar dest string\n\t\t\tif ss[0] == home {\n\t\t\t\tdest = ss[1]\n\t\t\t} else {\n\t\t\t\tdest = ss[0]\n\t\t\t}\n\t\t\tif destinations[dest] {\n\t\t\t\tdelete(destinations, dest)\n\t\t\t} else {\n\t\t\t\tdestinations[dest] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(destinations) == 0 {\n\t\tfmt.Println(\"home\")\n\t} else {\n\t\tfmt.Println(\"contest\")\n\t}\n}\n", "src_uid": "51d1c79a52d3d4f80c98052b6ec77222"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF978G(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\ttype pair struct{ i, d int }\n\n\tvar n, m, s, d int\n\tFscan(in, &n, &m)\n\tpr := make([]int, m)\n\ttodo := make([][]pair, n+1)\n\thas := make([]bool, n+1)\n\tfor i := range pr {\n\t\tFscan(in, &s, &d, &pr[i])\n\t\tfor j := s; j < d; j++ {\n\t\t\ttodo[j] = append(todo[j], pair{i, d})\n\t\t}\n\t\tif has[d] {\n\t\t\tFprint(out, -1)\n\t\t\treturn\n\t\t}\n\t\thas[d] = true\n\t}\n\tvar ans []interface{}\no:\n\tfor i := 1; i <= n; i++ {\n\t\tif has[i] {\n\t\t\tans = append(ans, m+1)\n\t\t\tcontinue\n\t\t}\n\t\tsort.Slice(todo[i], func(j, k int) bool { return todo[i][j].d < todo[i][k].d })\n\t\tfor _, p := range todo[i] {\n\t\t\tif pr[p.i] > 0 {\n\t\t\t\tpr[p.i]--\n\t\t\t\tans = append(ans, p.i+1)\n\t\t\t\tcontinue o\n\t\t\t}\n\t\t}\n\t\tans = append(ans, 0)\n\t}\n\tfor _, left := range pr {\n\t\tif left > 0 {\n\t\t\tFprint(out, -1)\n\t\t\treturn\n\t\t}\n\t}\n\tFprint(out, ans...)\n}\n\nfunc main() { CF978G(os.Stdin, os.Stdout) }\n", "src_uid": "02d8d403eb60ae77756ff96f71b662d3"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar dp [2*(1e7) + 1] int64\n\tvar n int\n\tvar x, y int64\n\tfmt.Scan(&n, &x, &y)\n\tdp[1] = x;\n\tfor i := 2; i <= n; i++ {\n\t\tdp[i] = int64(math.Min(float64(dp[i-1]+x), float64(dp[(i+1)/2]+y+int64(i%2)*x)))\n\t\tdp[i-1] = int64(math.Min(float64(dp[i-1]), float64(dp[i]+x)))\n\t}\n\n\tfmt.Println(dp[n])\n\n}\n", "src_uid": "0f270af00be2a523515d5e7bd66800f6"} {"source_code": "// 166E-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, c, h, b, i int64\n fmt.Scan(&a)\n b = 1\n for i = 0; i < a-1; i++ {\n b = b * 3 % 1000000007\n c = (b - h%1000000007 + 1000000007) % 1000000007\n h = c\n }\n fmt.Println(c)\n}\n", "src_uid": "77627cc366a22e38da412c3231ac91a8"} {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\n\t\"math\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n\tscanner.Scan()\n\tx, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn x\n}\nfunc getI() int {\n\treturn int(getI64())\n}\nfunc getF() float64 {\n\tscanner.Scan()\n\tx, _ := strconv.ParseFloat(scanner.Text(), 64)\n\treturn x\n}\nfunc getS() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc max(a,b int) int { if a > b { return a } else { return b } }\n\nfunc min(a,b int) int { if a < b { return a } else { return b } }\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\n\twriter.WriteString(fmt.Sprintf(\"%d\", Problem888B()))\n}\n\nfunc Problem888B() int {\n\tn := getI()\n\tx := 0\n\ty := 0\n\ts := getS()\n\tfor _, char := range s {\n\t\tswitch char {\n\t\tcase 'U':\n\t\t\ty+=1\n\t\t\tbreak\n\t\tcase 'D':\n\t\t\ty-=1\n\t\t\tbreak\n\t\tcase 'L':\n\t\t\tx-=1\n\t\t\tbreak\n\t\tcase 'R':\n\t\t\tx+=1\n\t\t\tbreak\n\t\tdefault:\n\t\t\tbreak\n\t\t}\n\t}\n\treturn n - (int(math.Abs(float64(x)))+int(math.Abs(float64(y))))\n}", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar a, count0,count1 int\n\tvar s string\n\tfmt.Scanf(\"%d\\n\", &a)\n\tfmt.Scanf(\"%s\\n\", &s)\n\tfor _, v := range s{\n\t\tif v == '0'{\n\t\t\tcount0++\n\t\t} else if v == '1'{\n\t\t\tcount1++\n\t\t}\n\t}\n\tif count0 == 1 && count1 == 0{\n\t\tfmt.Println(0)\n\t\tos.Exit(0)\n\t}\n\tvar ss = \"1\"\n\tfor i:=0;i 0; n >>= 1 {\n\t\t\tif n&1 == 1 {\n\t\t\t\tres = res * x % mod\n\t\t\t}\n\t\t\tx = x * x % mod\n\t\t}\n\t\treturn res\n\t}\n\tvar n, m, k int64\n\tFscan(in, &n, &m, &k)\n\tif k == -1 && n&1 != m&1 {\n\t\tFprint(out, 0)\n\t} else {\n\t\tFprint(out, pow(pow(2, n-1), m-1))\n\t}\n}\n\nfunc main() { CF894B(os.Stdin, os.Stdout) }\n", "src_uid": "6b9eff690fae14725885cbc891ff7243"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\ntype point struct {\n\tx, y int\n}\n\nvar ans int64\n\nconst (\n\tmod = int(1e9 + 7)\n)\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tt := 1\n\tfor ii := 0; ii < t; ii++ {\n\t\tn, p, w, d := int64(0), int64(0), int64(0), int64(0)\n\t\tfmt.Fscanf(in, \"%d %d %d %d\\n\", &n, &p, &w, &d)\n\t\tif n*w < p {\n\t\t\tfmt.Fprintf(out, \"%d\\n\", -1)\n\t\t\treturn\n\t\t}\n\t\ta := p / w\n\t\tm := make(map[int64]bool)\n\t\tfor true {\n\t\t\tif a == -1 {\n\t\t\t\tfmt.Fprintf(out, \"%d\\n\", -1)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tremain := p - a*w\n\t\t\tif remain%d == 0 {\n\t\t\t\tif a+remain/d > n {\n\t\t\t\t\tfmt.Fprintf(out, \"%d\\n\", -1)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(out, \"%d %d %d\\n\", a, remain/d, n-a-remain/d)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif m[remain%d] {\n\t\t\t\tfmt.Fprintf(out, \"%d\\n\", -1)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tm[remain%d] = true\n\t\t\ta--\n\t\t}\n\t}\n\treturn\n}\n\nfunc help(i int, n int, total int, t []int, g []int, cur int, c1, c2, c3 int, remaining int) {\n\t//fmt.Println(i, cur)\n\tif i == n {\n\t\tif cur == total {\n\t\t\tcal(c1, c2, c3)\n\t\t}\n\t\treturn\n\t}\n\tif cur > total {\n\t\treturn\n\t}\n\tif cur+remaining < total {\n\t\treturn\n\t}\n\tswitch g[i] {\n\tcase 1:\n\t\thelp(i+1, n, total, t, g, cur+t[i], c1+1, c2, c3, remaining-t[i])\n\tcase 2:\n\t\thelp(i+1, n, total, t, g, cur+t[i], c1, c2+1, c3, remaining-t[i])\n\tcase 3:\n\t\thelp(i+1, n, total, t, g, cur+t[i], c1, c2, c3+1, remaining-t[i])\n\t}\n\thelp(i+1, n, total, t, g, cur, c1, c2, c3, remaining-t[i])\n}\n\nfunc cal(c1, c2, c3 int) {\n\ta := []int{c1, c2, c3}\n\tsort.Ints(a)\n\ttmp := int64(try(c1, c2, c3, 0))\n\ttmp %= int64(mod)\n\tfor i := 1; i <= c1; i++ {\n\t\ttmp *= int64(i)\n\t\ttmp %= int64(mod)\n\t}\n\tfor i := 1; i <= c2; i++ {\n\t\ttmp *= int64(i)\n\t\ttmp %= int64(mod)\n\t}\n\tfor i := 1; i <= c3; i++ {\n\t\ttmp *= int64(i)\n\t\ttmp %= int64(mod)\n\t}\n\tans += tmp\n\tans %= int64(mod)\n}\n\nfunc try(a, b, c int, last int) int64 {\n\tif a == 0 && b == 0 && c == 0 {\n\t\treturn 1\n\t}\n\tif a < 0 || b < 0 || c < 0 {\n\t\treturn 0\n\t}\n\tif last == 0 {\n\t\treturn try(a-1, b, c, 1) + try(a, b-1, c, 2) + try(a, b, c-1, 3)\n\t}\n\tif last == 1 {\n\t\treturn try(a, b-1, c, 2) + try(a, b, c-1, 3)\n\t}\n\tif last == 2 {\n\t\treturn try(a-1, b, c, 1) + try(a, b, c-1, 3)\n\t}\n\treturn try(a-1, b, c, 1) + try(a, b-1, c, 2)\n}\n", "src_uid": "503116e144d19eb953954d99c5526a7d"} {"source_code": "package main\n\nimport \"fmt\"\n\nvar (\n\tn, input, ans, sum1, sum2 int\n\tmp1 map[int]int\n)\n\nfunc main() {\n\tfmt.Scanln(&n)\n\n\tmp1 = make(map[int]int)\n\tans = 1\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&input)\n\t\tmp1[int(input)] = 1\n\t\tsum1 += input\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&input)\n\t\tif input != 0 && mp1[int(input)] == 0 {\n\t\t\tans = 0\n\t\t}\n\t\tsum2 += input\n\t}\n\n\tif sum1 >= sum2 {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "src_uid": "e0ddac5c6d3671070860dda10d50c28a"} {"source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nvar count [10]int\nvar numbers []int\n \nfunc initCount(n int64) int {\n\tvar cnt int\n\tfor ; n > 0; {\n\t\tcount[n%10]++\n\t\tnumbers = append(numbers, int(n%int64(10)))\n\t\tn /= 10\n\t\tcnt ++\n\t}\n\treturn cnt\n}\n \nvar dp [1<<18][100]int64\n \nfunc main() {\n\tvar n, m int64\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tcnt := initCount(n)\n\tdp[0][0] = 1\n\tvar mask int = int(uint(1)< *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", "src_uid": "b732869015baf3dee5094c51a309e32c"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, k int64\n\tfmt.Scanf(\"%d %d %d\", &l, &r, &k)\n\tm := foo(l, r, k)\n\tfmt.Print(m)\n}\nfunc foo(l, r, k int64) int64 {\n\tmin := Min(l, r)\n\tmax := Max(l, r)\n\tif min+k < max {\n\t\treturn 2 * (min + k)\n\t} else {\n\t\tm := 2 * max\n\t\tk = k - (max - min)\n\t\tk = (k / 2) * 2\n\t\treturn m + k\n\t}\n}\nfunc Min(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc Max(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n", "src_uid": "e8148140e61baffd0878376ac5f3857c"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var t,a,b string\n rank := map[byte]int{'6':0,'7':1,'8':2,'9':3,'T':4,'J':5,'Q':6,'K':7,'A':8}\n fmt.Scan(&t)\n fmt.Scan(&a,&b)\n if ((a[1] == t[0]) && (b[1] != t[0])) || ((a[1] == b[1]) && (rank[a[0]] > rank[b[0]])) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n", "src_uid": "da13bd5a335c7f81c5a963b030655c26"} {"source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n,d,m int\n fmt.Scan(&n,&d)\n a := make([]int,n)\n for i := 0; i < n; i++ { fmt.Scan(&a[i]) }\n sort.Ints(a)\n fmt.Scan(&m)\n ans := 0\n for i := 0; i < m; i++ {\n if i < n {\n ans += a[i]\n } else {\n ans -= d\n }\n }\n fmt.Println(ans)\n}\n", "src_uid": "5c21e2dd658825580522af525142397d"} {"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", "src_uid": "20c2d9da12d6b88f300977d74287a15d"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\tstdin := bufio.NewReader(os.Stdin)\n\tvar k int\n\tfmt.Fscanf(stdin, \"%d\\n\", &k)\n\n\tbuilder := &strings.Builder{}\n\tfor i := 1; i <= k; i++ {\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", i))\n\t}\n\tresult := builder.String()\n\tfmt.Printf(\"%v\\n\", string(result[k-1]))\n}\n", "src_uid": "1503d761dd4e129fb7c423da390544ff"} {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bytes\"\n \"strconv\"\n )\n\nfunc Trim(x string, begin, end bool) string {\n var a, b int = 0, len(x) - 1\n\n if begin {\n for string(x[a]) == \"0\" && a < b && string(x[a + 1]) != \".\"{\n a++\n }\n }\n\n if end {\n for (string(x[b]) == \"0\" || string(x[b]) == \".\") && b > 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}", "src_uid": "a79358099f08f3ec50c013d47d910eef"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype IO struct {\n\tscanner *bufio.Scanner\n\twriter *bufio.Writer\n}\nfunc NewIO() IO {\n\tio := IO{scanner: bufio.NewScanner(os.Stdin), \n\t\twriter: bufio.NewWriter(os.Stdout)}\n\tio.scanner.Split(bufio.ScanWords)\n\treturn io\n}\nfunc toInt(buf []byte) (n int) {\n\tsgn := false\n\tfor _, v := range buf {\n\t\tif v == '-' {\n\t\t\tsgn = true\n\t\t} else {\n\t\t\tn = n*10 + int(v-'0')\n\t\t}\n\t}\n\tif sgn {\n\t\tn = -n\n\t}\n\treturn\n}\nfunc (io *IO) NextInt() int {\n\tio.scanner.Scan()\n\treturn toInt(io.scanner.Bytes())\n}\nfunc (io *IO) Write(data ...interface{}) {\n\tfor _, el := range data {\n\t\tswitch el.(type) {\n\t\t\tcase int:\n\t\t\t\tio.writer.WriteString(strconv.Itoa(el.(int)))\n\t\t\tcase string:\n\t\t\t\tio.writer.WriteString(el.(string))\n\t\t\tcase rune:\n\t\t\t\tio.writer.WriteRune(el.(rune))\n\t\t}\n\t}\n}\nfunc (io *IO) Writeln(data ...interface{}) {\n\tio.Write(data...)\n\tio.writer.WriteRune('\\n')\n}\nfunc (io *IO) Flush() {\n\tio.writer.Flush()\n}\n\nfunc Max(a, b int) int {\n\tif a>b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nconst N int = 100\n\nfunc main() {\n\tio := NewIO()\n\n\tn := io.NextInt()\n\tvar a [N](int)\n\tans := 0\n\tfor i:=0; i0 && a[i]!=1 && a[i-1]!=1 {\n\t\t\tgoto Bad\n\t\t}\n\t\tif i>1 && a[i]==2 && a[i-1]==1 && a[i-2]==3 {\n\t\t\tans--\n\t\t}\n\t\tif i>0 {\n\t\t\tif Max(a[i],a[i-1])==2 {\n\t\t\t\tans += 3\n\t\t\t} else {\n\t\t\t\tans += 4\n\t\t\t}\n\t\t}\n\t}\n\n\tio.Writeln(\"Finite\")\n\tio.Writeln(ans)\n\tio.Flush()\n\treturn\n\nBad:\n\tio.Writeln(\"Infinite\")\n\tio.Flush()\n\treturn\n}\n", "src_uid": "6c8f028f655cc77b05ed89a668273702"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a,b int\n fmt.Scan(&a,&b)\n ans := 0\n for a > 0 {\n if a >= b {\n ans += b\n a -= b\n a++\n } else {\n ans += a\n a = 0\n }\n }\n fmt.Println(ans)\n}\n", "src_uid": "a349094584d3fdc6b61e39bffe96dece"} {"source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var n, a, b int\n fmt.Scan(&n, &a, &b)\n fmt.Println(((a + b - 1) % n + n) % n + 1)\n}\n", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4"} {"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc exp(x int64, a int64) int64 {\n\tconst max int64 = 1000000009\n\tif x == 0 {\n\t\treturn 1\n\t}\n\tvar temp int64 = exp(x/2, (a*a)%max)\n\tif x%2 == 0 {\n\t\treturn temp%max\n\t} else {\n\t\treturn (temp*a)%max\n\t}\n}\n\nfunc main(){\n\tvar n, m, k int64\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tr.Scan()\n\tm, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tr.Scan()\n\tk, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tconst max int64 = 1000000009\n\tvar x int64 = (m-(n-m)*(k-1))/k\n\tif x < 0 {\n\t\tx = 0\n\t}\n\tvar res int64 = exp(x, 2)\n\tvar final int64 = (2*k*(res-1))%max+m-(k*x)%max\n\tfinal = final%max\n\tw.WriteString(strconv.FormatInt(final, 10)+\"\\n\")\n\tw.Flush()\n}\n", "src_uid": "9cc1aecd70ed54400821c290e2c8018e"} {"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}", "src_uid": "23f2c8cac07403899199abdcfd947a5a"} {"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", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar rows [5][5]int\n\tpi := 0\n\tpj := 0\n\n\tfor i := 0; i < 5; i++ {\n\t\tfor j:= 0; j < 5; j++ {\n\t\t\t_,_ = fmt.Scan(&rows[i][j])\n\t\t\tif rows[i][j] == 1 {\n\t\t\t\tpi = i\n\t\t\t\tpj = j\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(int(math.Abs(float64(pi - 2)) + math.Abs(float64(pj - 2))))\n\n}", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc check(rgb []int) bool {\n\tfor i := 0; i < len(rgb); i++ {\n\t\tif rgb[i] > 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\nfunc main() {\n\tfsc := NewFastScanner()\n\trgb := make([]int, 3)\n\n\tfor i := 0; i < len(rgb); i++ {\n\t\trgb[i] = fsc.NextInt()\n\t}\n\tcnt := 0\n\tres := 0\n\tfor !check(rgb) {\n\t\tres++\n\t\trgb[cnt] -= 2\n\t\tcnt = (cnt + 1) % 3\n\t}\n\tfmt.Println(29 + res)\n}\n\n//template\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1024)\n\treturn &FastScanner{r: rdr}\n}\nfunc (s *FastScanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *FastScanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *FastScanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *FastScanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *FastScanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n\n//Max,Min\nfunc IntMax(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Int64Max(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc Float64Max(a, b float64) float64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc IntMin(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Int64Min(a, b int64) int64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc Float64Min(a, b float64) float64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\n//Gcd\nfunc IntGcd(a, b int) int {\n\tif a < b {\n\t\tb, a = a, b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn IntGcd(b, a%b)\n}\nfunc Int64Gcd(a, b int64) int64 {\n\tif a < b {\n\t\tb, a = a, b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn Int64Gcd(b, a%b)\n}\n\nfunc IntAbs(a int) int {\n\tif a < 0 {\n\t\ta *= -1\n\t}\n\treturn a\n}\n\nfunc Int64Abs(a int64) int64 {\n\tif a < 0 {\n\t\ta *= -1\n\t}\n\treturn a\n}\n", "src_uid": "a45daac108076102da54e07e1e2a37d7"} {"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", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e"} {"source_code": "package main\n\nimport \"fmt\"\n\nconst mod = 1000000007\n\nfunc main() {\n var n, k, d int\n fmt.Scanf(\"%d%d%d\\n\",&n,&k,&d)\n a := make([]int, n+1)\n b := make([]int, n+1)\n b[0] = 1\n for i := 1; i <= n; i++ {\n for j := 1; j <= k && j <= i; j++ {\n a[i] += a[i - j]\n if a[i] >= mod {\n a[i] -= mod\n }\n }\n for j := 1; j < d && j <= k && j <= i; j++ {\n b[i] += b[i - j]\n if b[i] >= mod {\n b[i] -= mod\n }\n }\n for j := d; j <= k && j <= i; j++ {\n a[i] += b[i - j]\n if a[i] >= mod {\n a[i] -= mod\n }\n }\n }\n fmt.Println(a[n] % mod)\n}\n", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"math\"\n)\n\nfunc check(err error) {\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n}\n\nfunc main() {\n\tvar n, k int\n\t_, err := fmt.Scan(&n, &k)\n\tcheck(err)\n\t\n\taMap := make(map[int]int)\n\tvar max int\n\tfor i := 0; i < n; i++ {\n\t\tvar a int\n\t\t_, err = fmt.Scan(&a)\n\t\tcheck(err)\n\t\taMap[a]++\n\t\tif aMap[a] > max {\n\t\t\tmax = aMap[a]\n\t\t}\n\t}\n\t\n\tnBludo := int(math.Ceil(float64(max)/float64(k)))\n\tnPribory := nBludo * k * len(aMap)\n\t\n\t\n\tfmt.Println(nPribory - n)\n}\n", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc get_digits(n int) []bool {\n\toutput := make([]bool, 10)\n\tfor n > 0 {\n\t\toutput[n%10] = true\n\t\tn = n/10\n\t}\n\treturn output\n}\n\nfunc compatible(digits []bool, n int) bool {\n\tfor n > 0 {\n\t\tif digits[n%10] {\n\t\t\treturn true\n\t\t}\n\t\tn = n/10\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar input int\n\tfmt.Scan(&input)\n\tdigits := get_digits(input)\n\tans := 0\n\tfor i:=1; i*i<=input; i++ {\n\t\tif input%i == 0 {\n\t\t\tif compatible(digits, i) {ans++}\n\t\t\tif i*i != input && compatible(digits, input/i) {ans++}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}", "src_uid": "ada94770281765f54ab264b4a1ef766e"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar a, b int64\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &a, &b); err != nil {\n\t\treturn\n\t}\n\n\tas, ac, ai := to_binary_string(a)\n\tbs, bc, bi := to_binary_string(b)\n\n\tvar c [3]int\n\n\tif len(as) < len(bs) {\n\t\tif ac == 0 {\n\t\t\tc[0] = 0\n\t\t} else {\n\t\t\tc[0] = len(as) - ai\n\t\t}\n\t\tfor i := len(as) + 1; i <= len(bs)-1; i++ {\n\t\t\tc[1] += i - 1\n\t\t}\n\t\tif bc == 0 {\n\t\t\tc[2] = len(bs) - 1\n\t\t} else {\n\t\t\tc[2] = bi - 1\n\t\t\tif bc == 1 {\n\t\t\t\tc[2] += 1\n\t\t\t}\n\t\t}\n\t} else if len(as) == len(bs) {\n\t\tc[1] = bi - ai\n\t\tif bc == 1 {\n\t\t\tc[2] = 1\n\t\t}\n\t}\n\n\tfmt.Println(c[0] + c[1] + c[2])\n}\n\nfunc to_binary_string(n int64) (string, int, int) {\n\tout := \"\"\n\tzero_count := 0\n\tfirst_zero_index := -1\n\tfor i := 0; n > 0; i++ {\n\t\tif n%2 == 0 {\n\t\t\tzero_count++\n\t\t\tfirst_zero_index = i\n\t\t}\n\t\tout = strconv.FormatInt(n%2, 10) + out\n\t\tn /= 2\n\t}\n\treturn out, zero_count, len(out) - first_zero_index - 1\n}\n", "src_uid": "581f61b1f50313bf4c75833cefd4d022"} {"source_code": "package main\nimport \"fmt\"\nfunc main() {\nvar F,I,T int\nfmt.Scanf(\"%d %d %d\",&F,&I,&T)\nvar c [13]int\nfor i := 0; i < F; i++ {\nvar s string\nfmt.Scanf(\"\\n%s\", &s)\nfor j := 0; j < I; j++ {if s[j] == 'Y' {c[j]++}}\n}\nvar cnt int = 0\nfor j := 0; j < I; j++ {if c[j] >= T {cnt++}}\nfmt.Println(cnt)\n}//kitten", "src_uid": "4c978130187e8ae6ca013d3f781b064e"} {"source_code": "\ufeffpackage main\nimport (\n\t\"fmt\"\n\t//\"bufio\"\n\t//\"os\"\n\t//\"strconv\"\n\t//\"sort\"\n)\n\nfunc main() {\n\tvar i,j,n int\n\ta:=make([]int,106)\n\tb:=make([]int,250000)\n\tfmt.Scan(&n)\n\tsum:=0\n\tflag:=true\n\tfor i=1;i<=n;i++ {\n\t\tfmt.Scan(&a[i])\n\t\tsum+=a[i]\n\t}\n\tif sum%2!=0 {\n\t\tflag=false\n\t} else {\n\t\tsum/=2\n\t\tfor i=1;i<=n;i++{\n\t\t\tfor j=sum;j>=a[i];j-- {\n\t\t\t\tif (b[j-a[i]]+a[i])>b[j] {\n\t\t\t\t\tb[j]=b[j-a[i]]+a[i]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif b[sum]==sum {\n\t\t\tflag=true\n\t\t} else {\n\t\t\tflag=false\n\t\t}\n\t}\n\tif flag==true {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\n\n\n\n\n\n\n\n\n", "src_uid": "9679acef82356004e47b1118f8fc836a"} {"source_code": "//A. \u041c\u0430\u0445\u043c\u0443\u0434, \u042d\u0445\u0430\u0431 \u0438 \u0438\u0433\u0440\u0430 \u0432 \u0447\u0435\u0442\u043d\u043e\u0435-\u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n uint32\n\n\tfmt.Scan(&n)\n\n\tif n%2 == 0 {\n\t\tfmt.Println(\"Mahmoud\")\n\t} else {\n\t\tfmt.Println(\"Ehab\")\n\t}\n\n}\n", "src_uid": "5e74750f44142624e6da41d4b35beb9a"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\nfunc gcd(x, y int)int{\n\tfor y>0{\n\t\ttemp:=y\n\t\ty = x%y\n\t\tx = temp\n\t}\n\treturn x\n}\nfunc max(x,y int)int{\n\tif x>y{\n\t\treturn x\n\t}\n\treturn y\n}\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := os.Stdout\n\tvar n int\n\tfmt.Fscan(in,&n)\n\tvar a [105]int\n\tsum:=0\n\tfor i:=1;i<=n;i++{\n\t\tfmt.Fscan(in,&a[i])\n\t\tsum+=a[i]\n\t}\n\tf:=[105][100*2001]int{}\n\tf[0][0]=1\n\tfor i:=1;i<=n;i++{\n\t\tfor j:=1;j<=100*2000;j++{\n\t\t\tf[i][j] = max(f[i][j],f[i-1][j])\n\t\t\tif j-a[i]>=0{\n\t\t\t\tf[i][j]=max(f[i][j],f[i-1][j-a[i]])\n\t\t\t}\n\t\t}\n\t}\n\tif sum%2==0{\n\t\tflag:=false\n\t\tfor i:=1;i<=n;i++{\n\t\t\tif f[i][sum/2]==1{\n\t\t\t\tflag=true\n\t\t\t}\n\t\t}\n\t\tif !flag{\n\t\t\tfmt.Fprintln(out,0)\n\t\t}else{\n\t\t\todd := false\n\t\t\tfor i:=1;i<=n;i++{\n\t\t\t\tif a[i]%2==1{\n\t\t\t\t\todd = true\n\t\t\t\t\tfmt.Fprintln(out,1)\n\t\t\t\t\tfmt.Fprintln(out,i)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif odd == false{\n\t\t\t\tfor {\n\t\t\t\t\tdone := false\n\t\t\t\t\tindex := -1\n\t\t\t\t\tgcdx := a[1]\n\t\t\t\t\tfor i := 2; i <= n; i++ {\n\t\t\t\t\t\tgcdx = gcd(gcdx, a[i])\n\t\t\t\t\t}\n\t\t\t\t\tfor i := 1; i <= n; i++ {\n\t\t\t\t\t\ta[i] = a[i] / gcdx\n\t\t\t\t\t\tif a[i]%2 == 1 {\n\t\t\t\t\t\t\tdone = true\n\t\t\t\t\t\t\tindex = i\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif done {\n\t\t\t\t\t\tfmt.Fprintln(out, 1)\n\t\t\t\t\t\tfmt.Fprintln(out, index)\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}\n\t}else {\n\t\tfmt.Fprintln(out, 0)\n\t}\n}\n", "src_uid": "29063ad54712b4911c6bf871969ee147"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\n\t// posici\u00f3n en su grupo de cifras\n\tpos := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tpos *= 2\n\t\tif s[i] == '7' {\n\t\t\tpos++\n\t\t}\n\t}\n\n\t// sumamos los de menos cifras\n\tless := 0\n\tfor i := 1; i < len(s); i++ {\n\t\tless |= (1 << uint(i))\n\t}\n\tfmt.Printf(\"%d\\n\", (1 + pos + less))\n}\n", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3"} {"source_code": "package main\n \nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n \nfunc main() {\n in := bufio.NewReader(os.Stdin)\n out := bufio.NewWriter(os.Stdout)\n defer out.Flush()\n tot := 0\n fmt.Fscan(in, &tot)\n times := (tot/3)*2\n if tot % 3 > 0 {times++}\n fmt.Fprint(out, times)\n}", "src_uid": "a993069e35b35ae158d35d6fe166aaef"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"math\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\ta, b, c, d := ScanInt64(), ScanInt64(), ScanInt64(), ScanInt64()\n\tP(solve(a, b, c, d))\n\n\tout.Flush()\n}\n\nfunc solve(a, b, c, d int64) int64 {\n\tsum := int64(0)\n\tp := make([]int64, Mx64(b+c+2, d+2))\n\tfor i := a; i <= b; i++ {\n\t\tp[i+b] += 1\n\t\tp[i+c+1] += -1\n\t}\n\tfor i := 1; i < len(p); i++ {\n\t\tp[i] += p[i-1]\n\t}\n\n\tfor i := Mx64(b+c+1, d+1); i >= a; i-- {\n\t\tp[i-1] += p[i]\n\t}\n\n\tfor i := c; i <= d; i++ {\n\t\tsum += int64(p[i+1])\n\t}\n\treturn sum\n}\n\n/*********************** I/O ***********************/\nvar in *bufio.Scanner\nvar out *bufio.Writer\n\nfunc init() {\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(1e+9))\n\tin.Split(bufio.ScanWords)\n\tout = bufio.NewWriter(os.Stdout)\n}\n\nfunc P(args ...interface{}) {\n\tprint(\"\\n\", args...)\n}\n\nfunc PS(args ...interface{}) {\n\tprint(\" \", args...)\n\tprint(\"\\n\", nil)\n}\n\nfunc print(seperator string, args ...interface{}) {\n\tfor _, arg := range args {\n\t\tstr := \"\"\n\t\tswitch v := arg.(type) {\n\t\tcase byte:\n\t\t\tstr = string(v)\n\t\tcase rune:\n\t\t\tstr = string(v)\n\t\tcase int:\n\t\t\tstr = strconv.Itoa(v)\n\t\tcase []int:\n\t\t\tsb := strings.Builder{}\n\t\t\tfor i := 0; i < len(v); i++ {\n\t\t\t\tsb.WriteString(strconv.Itoa(v[i]) + \" \")\n\t\t\t}\n\t\t\tstr = sb.String()\n\t\tcase int64:\n\t\t\tstr = strconv.FormatInt(v, 10)\n\t\tcase []int64:\n\t\t\tsb := strings.Builder{}\n\t\t\tfor i := 0; i < len(v); i++ {\n\t\t\t\tsb.WriteString(strconv.FormatInt(v[i], 10) + \" \")\n\t\t\t}\n\t\t\tstr = sb.String()\n\t\tcase string:\n\t\t\tstr = v\n\t\t}\n\t\tout.WriteString(str + seperator)\n\t}\n}\n\nfunc ScanWord() string { in.Scan(); return in.Text() }\nfunc ScanWords(n int) []string {\n\ts := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\ts[i] = ScanWord()\n\t}\n\treturn s\n}\nfunc ScanInt() int { i, _ := strconv.Atoi(ScanWord()); return i }\nfunc ScanInts(n int) []int {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = ScanInt()\n\t}\n\treturn a\n}\nfunc ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }\nfunc ScanInt64s(n int) []int64 {\n\ta := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = ScanInt64()\n\t}\n\treturn a\n}\n\n/*********************** Utils int64 ***********************/\nfunc MnMx64(args ...int64) (int64, int64) {\n\tminVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)\n\tfor _, v := range args {\n\t\tif v < minVal {\n\t\t\tminVal = v\n\t\t}\n\t\tif v > maxVal {\n\t\t\tmaxVal = v\n\t\t}\n\t}\n\treturn minVal, maxVal\n}\nfunc Mn64(args ...int64) int64 { mn, _ := MnMx64(args...); return mn }\nfunc Mx64(args ...int64) int64 { _, mx := MnMx64(args...); return mx }\nfunc LCM64(a, b int64) int64 { return a / GCD64(a, b) * b }\nfunc GCD64(a, b int64) int64 {\n\tif a == 0 {\n\t\treturn b\n\t}\n\treturn GCD64(b%a, a)\n}\nfunc SortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }\nfunc Abs64(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\n/*********************** Utils int ***********************/\nfunc MnMx(args ...int) (int, int) {\n\tminVal, maxVal := math.MaxInt32, math.MinInt32\n\tfor _, v := range args {\n\t\tif v < minVal {\n\t\t\tminVal = v\n\t\t}\n\t\tif v > maxVal {\n\t\t\tmaxVal = v\n\t\t}\n\t}\n\treturn minVal, maxVal\n}\nfunc Mn(args ...int) int { mn, _ := MnMx(args...); return mn }\nfunc Mx(args ...int) int { _, mx := MnMx(args...); return mx }\nfunc LCM(a, b int) int { return a / GCD(a, b) * b }\nfunc GCD(a, b int) int {\n\tif a == 0 {\n\t\treturn b\n\t}\n\treturn GCD(b%a, a)\n}\nfunc Abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n", "src_uid": "4f92791b9ec658829f667fcea1faee01"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t//\"math\"\n)\n\nfunc solve() {\n s, cur, was := readString(), []int{}, make(map[rune]bool)\n for _, ch := range s {\n if !was[ch] {\n cur = append(cur, int(ch))\n was[ch] = true\n }\n }\n\n var d [5][16]int\n for t := 0; t < 13*2; t++ {\n for j := 0; j < 13; j++ {\n d[1][j+1] = cur[j]\n d[2][13-j] = cur[j+13]\n }\n\n\n curI, curJ, found := t/13 + 2, t%13 + 2, true\n for _, ch := range s {\n ok := false\n for _, di := range []int{-1, 0, 1} {\n for _, dj := range []int{-1, 0, 1} {\n posI, posJ := curI+di, curJ+dj\n if !ok && (di != 0 || dj != 0) && int(ch) == d[posI][posJ] {\n curI, curJ, ok = posI, posJ, true\n }\n }\n }\n if !ok {\n found = false\n }\n }\n\n if found {\n for i := 0; i < 2; i++ {\n for j := 0; j < 13; j++ {\n fmt.Print(string(d[i+1][j+1]))\n }\n fmt.Println()\n }\n\n return\n }\n cur = append(cur[len(cur)-1:], cur[:len(cur)-1]...)\n }\n\n fmt.Println(\"Impossible\")\n}\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\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\treturn x + y - max(x, y)\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readArray(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt()\n\t}\n\treturn res\n}\n", "src_uid": "56c5ea443dec7a732802b16aed5b934d"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc readInt(reader *bufio.Scanner) int {\n\tvar result int\n\treader.Scan()\n\tresult, _ = strconv.Atoi(reader.Text())\n\treturn result\n}\n\nfunc main() {\n\treader := bufio.NewScanner(os.Stdin)\n\tbuf := make([]byte, 2)\n\treader.Buffer(buf, 501)\n\treader.Split(bufio.ScanWords)\n\tx := readInt(reader)\n\ty := readInt(reader)\n\tz := readInt(reader)\n\tif z == 0 {\n\t\tif x > y {\n\t\t\tfmt.Println(\"+\")\n\t\t} else if x < y {\n\t\t\tfmt.Println(\"-\")\n\t\t} else {\n\t\t\tfmt.Println(\"0\")\n\t\t}\n\t} else if x > y+z {\n\t\tfmt.Println(\"+\")\n\t} else if y > x+z {\n\t\tfmt.Println(\"-\")\n\t}else{\n\t\tfmt.Println(\"?\")\n\t}\n}\n", "src_uid": "66398694a4a142b4a4e709d059aca0fa"} {"source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1558B(in io.Reader, out io.Writer) {\r\n\tvar n, m int\r\n\tFscan(in, &n, &m)\r\n\tf := make([]int, n+2)\r\n\tf[n] = 1\r\n\tfor i := n - 1; i > 0; i-- {\r\n\t\tf[i] = f[i+1] * 2 % m\r\n\t\tfor j := 2; j*i <= n; j++ {\r\n\t\t\tf[i] = (f[i] + (f[i*j]-f[min((i+1)*j, n+1)]+m)%m) % m\r\n\t\t}\r\n\t}\r\n\tFprint(out, (f[1]-f[2]+m)%m)\r\n}\r\n\r\nfunc main() { CF1558B(os.Stdin, os.Stdout) }\r\n\r\nfunc min(a, b int) int {\r\n\tif a > b {\r\n\t\treturn b\r\n\t}\r\n\treturn a\r\n}\r\n", "src_uid": "77443424be253352aaf2b6c89bdd4671"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\ntype IO struct {\n\tin io.Reader\n\tout io.Writer\n}\n\nfunc NewIO(in io.Reader, out io.Writer) *IO {\n\treturn &IO{in: bufio.NewReader(in), out: bufio.NewWriter(out)}\n}\n\nfunc (io *IO) ReadInt64() int64 {\n\tvar res int64\n\tfmt.Fscanf(io.in, \"%d\\n\", &res)\n\treturn res\n}\n\nfunc (io *IO) ReadInt() int {\n\tvar res int\n\tfmt.Fscanf(io.in, \"%d\\n\", &res)\n\treturn res\n}\n\nfunc (io *IO) ReadPairInt64() (int64, int64) {\n\tvar a, b int64\n\tfmt.Fscanf(io.in, \"%d %d\\n\", &a, &b)\n\treturn a, b\n}\n\nfunc (io *IO) ReadPairInt() (int, int) {\n\tvar a, b int\n\tfmt.Fscanf(io.in, \"%d %d\\n\", &a, &b)\n\treturn a, b\n}\n\nfunc (io *IO) ReadString() string {\n\tvar res string\n\tfmt.Fscanf(io.in, \"%s\\n\", &res)\n\treturn res\n}\n\nfunc (io *IO) ReadIntSlice(n int) []int64 {\n\tvar t int64\n\tres := make([]int64, 0, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(io.in, \"%d\", &t)\n\t\tres = append(res, t)\n\t}\n\tfmt.Fscanf(io.in, \"\\n\")\n\treturn res\n}\n\ntype log struct {\n\ts string\n\ti int\n}\n\nvar errOutOfRange = errors.New(\"out of range\")\n\nfunc (l *log) left() (bool, error) {\n\tif l.i >= len(l.s) {\n\t\treturn false, errOutOfRange\n\t}\n\tc := l.s[l.i]\n\tl.i++\n\treturn c == '0', nil\n}\n\nfunc mergeSort(a []int, l *log) error {\n\tif len(a) == 1 {\n\t\treturn nil\n\t}\n\n\terr := mergeSort(a[:len(a)/2], l)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = mergeSort(a[len(a)/2:], l)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tb := make([]int, 0, len(a))\n\ti, j := 0, len(a)/2\n\n\tfor i < len(a)/2 && j < len(a) {\n\t\tleft, err := l.left()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif left {\n\t\t\tb = append(b, a[i])\n\t\t\ti++\n\t\t} else {\n\t\t\tb = append(b, a[j])\n\t\t\tj++\n\t\t}\n\t}\n\n\tfor i < len(a)/2 {\n\t\tb = append(b, a[i])\n\t\ti++\n\t}\n\n\tfor j < len(a) {\n\t\tb = append(b, a[j])\n\t\tj++\n\t}\n\n\tfor i := range b {\n\t\ta[i] = b[i]\n\t}\n\treturn nil\n}\n\nfunc doSomething(n int, s string) int {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = i\n\t}\n\n\tl := log{s, 0}\n\terr := mergeSort(a, &l)\n\tif err != nil {\n\t\treturn 1000000000\n\t}\n\n\treturn len(l.s) - l.i\n}\n\nfunc doSomethingWithPrint(n int, s string) int {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = i\n\t}\n\n\tl := log{s, 0}\n\terr := mergeSort(a, &l)\n\tif err != nil {\n\t\treturn 1000000000\n\t}\n\n\tif _, err = l.left(); err != nil {\n\t\tb := make([]int, len(a))\n\n\t\tfor i, v := range a {\n\t\t\tb[v] = i + 1\n\t\t}\n\n\t\tfmt.Println(len(a))\n\t\tfor _, v := range b {\n\t\t\tfmt.Printf(\"%d \", v)\n\t\t}\n\t}\n\n\treturn len(l.s) - l.i\n}\n\nfunc main() {\n\tio := NewIO(os.Stdin, os.Stdout)\n\ts := io.ReadString()\n\n\tl, r := 1, 200000\n\n\tfor r - l > 1 {\n\t\tx1 := l + (r - l) / 3\n\t\tx2 := l + (r - l) / 3 * 2\n\n\t\tv1 := doSomething(x1, s)\n\t\tv2 := doSomething(x2, s)\n\n\t\tif v1 < v2 {\n\t\t\tl = x1\n\t\t} else {\n\t\t\tr = x2\n\t\t}\n\t}\n\n\tdoSomethingWithPrint(l, s)\n}\n", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scan(&x, &y)\n\tans := int(1e9)\n\tif y <= 0 && y <= x && x <= 1-y && -4*y < ans {ans = -4*y}\n\tif x > 0 && 1-x <= y && y <= x && 4*x-3 < ans {ans = 4*x-3}\n\tif y > 0 && -y <= x && x <= y && 4*y-2 < ans {ans = 4*y-2}\n\tif x < 0 && x <= y && y <= -x && -4*x-1 < ans {ans = -4*x-1}\n\tfmt.Println(ans)\n}", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382"} {"source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc calc(a, b uint64) uint64 {\n if a == 0 || b == 0 {\n return 0\n }\n\n if a < b {\n tmp := a\n a = b\n b = tmp\n }\n\n return a/b + calc(a%b, b)\n}\n\nfunc main() {\n var a, b uint64\n fmt.Scan(&a, &b)\n fmt.Println(calc(a, b))\n}\n", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main (){\n\tvar n, x int\n\tvar op int\n\tfmt.Scanf(\"%d %d\\n\", &n, &x)\n\tvar f [101]int\n\tfor i := 0; i < n; i++ {\n\t\tvar here int\n\t\tfmt.Scanf(\"%d\", &here)\n\t\tf[here] = 1\n\t}\n\tif f[x] == 1 {\n\t\tf[x] = 0\n\t\top++\n\t}\n\tfor i := 0; i < x; i++ {\n\t\tif f[i] == 0 {\n\t\t\tf[i] = 1\n\t\t\top++\n\t\t}\n\t}\n\tfmt.Println(op)\n}", "src_uid": "21f579ba807face432a7664091581cd8"} {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/735/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn int64\n)\n\nfunc main() {\n\tn = ReadInt64()\n\n\tif IsPrime(n) {\n\t\tfmt.Println(1)\n\t\treturn\n\t}\n\n\tif n%2 == 0 {\n\t\tfmt.Println(2)\n\t\treturn\n\t}\n\n\tif IsPrime(n - 2) {\n\t\tfmt.Println(2)\n\t\treturn\n\t}\n\n\tfmt.Println(3)\n}\n\n// func main() {\n// \tn = readInt64()\n\n// \t// ans := 0\n// \tA := []int64{}\n// \tfor {\n// \t\t// ans++\n// \t\tif IsPrime(n) {\n// \t\t\tA = append(A, n)\n// \t\t\tbreak\n// \t\t}\n\n// \t\tp := sub(n - 2)\n// \t\tn -= p\n// \t\tA = append(A, p)\n// \t}\n// \t// fmt.Println(ans)\n// \tfmt.Println(len(A))\n// }\n\n// n\u4ee5\u4e0b\u306e\u6700\u5927\u306e\u7d20\u6570\u3092\u8fd4\u3059\nfunc sub(n int64) int64 {\n\tfor i := n; i >= 2; i-- {\n\t\tif IsPrime(i) {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn 1\n}\n\n// IsPrime judges whether an argument integer is a prime number or not.\nfunc IsPrime(n int64) bool {\n\tvar i int64\n\n\tif n == 1 {\n\t\treturn false\n\t}\n\n\tfor i = 2; i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol118D(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n1, n2, k1, k2 int\n\tFscan(in, &n1, &n2, &k1, &k2)\n\n\tconst mod = 1e8\n\tcache := map[string]int{}\n\tvar f func(left1, left2, c1, c2 int) int\n\tf = func(left1, left2, c1, c2 int) (sum int) {\n\t\tif left1 == 0 {\n\t\t\tif left2+c2 <= k2 {\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\treturn 0\n\t\t}\n\t\tif left2 == 0 {\n\t\t\tif left1+c1 <= k1 {\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\treturn 0\n\t\t}\n\t\thash := Sprintf(\"%d;%d;%d;%d\", left1, left2, c1, c2)\n\t\tif val, ok := cache[hash]; ok {\n\t\t\treturn val\n\t\t}\n\t\tif c1 < k1 {\n\t\t\tsum += f(left1-1, left2, c1+1, 0)\n\t\t}\n\t\tif c2 < k2 {\n\t\t\tsum += f(left1, left2-1, 0, c2+1)\n\t\t}\n\t\tsum %= mod\n\t\tcache[hash] = sum\n\t\treturn\n\t}\n\tFprintln(out, f(n1, n2, 0, 0))\n}\n\nfunc main() {\n\tSol118D(os.Stdin, os.Stdout)\n}\n", "src_uid": "63aabef26fe008e4c6fc9336eb038289"} {"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, H := readTwoNums(reader)\n\n\tfmt.Println(solve(N, H))\n}\n\nfunc readInt(bytes []byte, from int, val *int) int {\n\ti := from\n\tsign := 1\n\tif bytes[i] == '-' {\n\t\tsign = -1\n\t\ti++\n\t}\n\ttmp := 0\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + int(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp * sign\n\treturn i\n}\n\nfunc readNum(reader *bufio.Reader) (a int) {\n\tbs, _ := reader.ReadBytes('\\n')\n\treadInt(bs, 0, &a)\n\treturn\n}\n\nfunc readTwoNums(reader *bufio.Reader) (a int, b int) {\n\tres := readNNums(reader, 2)\n\ta, b = res[0], res[1]\n\treturn\n}\n\nfunc readThreeNums(reader *bufio.Reader) (a int, b int, c int) {\n\tres := readNNums(reader, 3)\n\ta, b, c = res[0], res[1], res[2]\n\treturn\n}\n\nfunc readNNums(reader *bufio.Reader, n int) []int {\n\tres := make([]int, n)\n\tx := 0\n\tbs, _ := reader.ReadBytes('\\n')\n\tfor i := 0; i < n; i++ {\n\t\tfor x < len(bs) && (bs[x] < '0' || bs[x] > '9') {\n\t\t\tx++\n\t\t}\n\t\tx = readInt(bs, x, &res[i])\n\t}\n\treturn res\n}\n\nfunc readUint64(bytes []byte, from int, val *uint64) int {\n\ti := from\n\n\tvar tmp uint64\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + uint64(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp\n\n\treturn i\n}\n\nfunc solve(N, H int) uint64 {\n\tdp := make([][]uint64, N+1)\n\n\tfor i := 0; i <= N; i++ {\n\t\tdp[i] = make([]uint64, N+1)\n\t}\n\t//\n\tfor h := 0; h <= N; h++ {\n\t\tdp[0][h] = 1\n\t}\n\n\n\tfor i := 1; i <= N; i++ {\n\t\tfor j := 1; j <= N; j++ {\n\t\t\tfor k := 0; k < i; k++ {\n\t\t\t\tdp[i][j] += dp[k][j-1] * dp[i-k-1][j-1]\n\t\t\t}\n\t\t}\n\t}\n\n\tres := dp[N][N] - dp[N][H-1]\n\n\treturn res\n}\n", "src_uid": "faf12a603d0c27f8be6bf6b02531a931"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\n//a,b <=n && a+b==x\nfunc count(n, x int64) (ans int64) {\n\tif n >= x {\n\t\tn = x - 1\n\t}\n\tans = n - x/2\n\tif x%2 == 0 {\n\t\tans++\n\t}\n\tif ans < 0 {\n\t\tans = 0\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tif n < 5 {\n\t\tfmt.Println(n * (n - 1) / 2)\n\t\treturn\n\t}\n\tvar ans int64\n\tvar max9 int64 = 9\n\tfor max9 < n {\n\t\tmax9 = max9*10 + 9\n\t}\n\tif max9/2+1 <= n {\n\t\tfmt.Println(count(n, max9))\n\t\treturn\n\t}\n\tsmax9 := fmt.Sprint(max9)\n\t//for i := 0; i < len(smax9); i++ {\n\ttmp := []byte(smax9)\n\tfor j := 0; j < 9; j++ {\n\t\ttmp[0] = byte(j) + '0'\n\t\tx, _ := strconv.ParseInt(string(tmp), 10, 64)\n\t\tans += count(n, x)\n\t\t//fmt.Println(count(n, x), x)\n\t\ttmp[0] = '9'\n\t}\n\t//}\n\tfmt.Println(ans)\n}\n", "src_uid": "c20744c44269ae0779c5f549afd2e3f2"} {"source_code": "package main \n\nimport \"fmt\"\n\nfunc Max( x, y int ) int { // math.Max() \u306f\u554f\u984c\u3092\u8d77\u3053\u3059\u3089\u3057\u3044\u3002\u3002\u3002\n if x > y {\n return x\n }\n return y\n}\n\nfunc main() {\n\tvar N, K int\n\tfmt.Scan( &N, &K )\n\tvar S string\n\tfmt.Scan( &S )\n\typfx := make( []int, N + 1, N + 1 ); // type, length, capacity\n\tnpfx := make( []int, N + 1, N + 1 );\n\tqpfx := make( []int, N + 1, N + 1 );\n\tfor i := 0; i < N; i++ { // seems like go does not support ++i.....\n\t ypfx[ i + 1 ] = ypfx[ i ];\n\t npfx[ i + 1 ] = npfx[ i ];\n\t qpfx[ i + 1 ] = qpfx[ i ];\n\t if( S[ i ] == 'Y' ) {\n\t ypfx[ i + 1 ]++;\n\t } else if( S[ i ] == 'N' ) {\n\t npfx[ i + 1 ]++;\n\t } else {\n\t qpfx[ i + 1 ]++;\n\t }\n\t}\n\toriginal_max := 0;\n\tfor i := 0; i < N; i++ {\n\t if( S[ i ] != 'N' ) { // syntax error: missing { after if clause \u3048\u3048\u3048\u3048\u3048\n\t continue;\n\t }\n\t j := i;\n\t for j < N && S[ j ] == 'N' { // while() \u306f\u3060\u3081\u306a\u3093\u304b\u3044\uff01\uff01\n\t j++;\n\t }\n\t original_max = Max( original_max, j - i );\n\t i = j;\n\t}\n\tif( original_max > K ) {\n\t fmt.Println( \"NO\" );\n\t return;\n\t}\n\tfor i := 0; i + K <= N; i++ { // i \u3092\u5de6\u754c\u3068\u3059\u308b\u9577\u3055 K \u306e\u533a\u9593\u3092\u8abf\u3079\u308b\n\t if( ypfx[ i + K ] - ypfx[ i ] > 0 ) { // \u3048\u3048\u3048\u3048 -> line: 34\n\t continue;\n\t }\n\t if( i - 1 >= 0 && S[ i - 1 ] == 'N' ) {\n\t continue;\n\t }\n\t if( i + K < N && S[ i + K ] == 'N' ) {\n\t continue;\n\t }\n\t fmt.Println( \"YES\" );\n\t return;\n\t}\n\tfmt.Println( \"NO\" );\n}", "src_uid": "5bd578d3da5837c259b222336a194d12"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar istring string\n\tfmt.Scan(&istring)\n\ttemp := strings.Split(istring,\"\")\n\tanswer := \"NO\"\n\tfor i:=0;i=0; i-- {\n\t\tif n[i] == '0' {\n\t\t\tcnt++\n\t\t} else {\n\t\t\tresult++\n\t\t}\n\n\t\tif cnt == k {\n\t\t\tbreak\n\t\t}\n\t}\n\twriter.WriteString(strconv.Itoa(result))\n\n\n\n\treturn\n\n\n}\n\nfunc ini() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc scanInt() int {\n\tscanner.Scan()\n\ti, _ := strconv.Atoi(scanner.Text())\n\treturn i\n}\n\nfunc scanString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}", "src_uid": "7a8890417aa48c2b93b559ca118853f9"} {"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar p, y int\n\tr := RapidReader()\n\tfmt.Fscan(r, &p, &y)\n\tfor i := y; i >= 2 && i >= y-1000; i-- {\n\t\tif i <= p {\n\t\t\tcontinue\n\t\t}\n\t\tundivisible := true\n\t\tfor k := 2; k <= p && k < 31623; k++ {\n\t\t\tif i%k == 0 {\n\t\t\t\tundivisible = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif undivisible {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n\nfunc RapidReader() io.Reader {\n\tb, _ := ioutil.ReadAll(os.Stdin)\n\treturn bytes.NewReader(b)\n}\n", "src_uid": "b533203f488fa4caf105f3f46dd5844d"} {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n defer writer.Flush()\n var d int\n scanf(\"%d\\n\", &d)\n arr := make([]int, d)\n for i := range arr {\n scanf(\"%d\", &arr[i])\n }\n solve(arr)\n}\n\nfunc solve(arr []int) {\n for D := 0; D <= 105; D++ {\n target := []int{arr[0], arr[0] + D, arr[0] - D}\n for _, t := range target {\n ok := true\n for i := range arr {\n diff := t - arr[i]\n if !(diff == 0 || diff == D || diff == -D) {\n ok = false\n break\n }\n }\n if ok {\n printf(\"%d\", D)\n return\n }\n }\n }\n printf(\"%d\", -1)\n}\n", "src_uid": "d486a88939c132848a7efdf257b9b066"} {"source_code": "// GoIntoGo project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tfor i := 16; i > -1; i-- {\n\t\tif ((n >> uint(i)) & 1) > 0 {\n\t\t\tfmt.Printf(\"%d \", i+1)\n\t\t}\n\t}\n\tfmt.Println(\"\")\n}\n", "src_uid": "757cd804aba01dc4bc108cb0722f68dc"} {"source_code": "package main\n\n// https://codeforces.com/problemset/problem/148/A\n\nimport \"fmt\"\n\nfunc taskSolution(a [4]int, n int) int {\n\tans := 0\n\tfor number := 1; number <= n; number += 1 {\n\t\tif number%a[0] == 0 || number%a[1] == 0 || number%a[2] == 0 || number%a[3] == 0 {\n\t\t\tans += 1\n\t\t}\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tvar a [4]int\n\tfor i := 0; i < 4; i += 1 {\n\t\tif _, err := fmt.Scan(&a[i]); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\tvar n int\n\tif _, err := fmt.Scan(&n); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(a, n))\n}\n", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7"} {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var scale, remainWeights string\n fmt.Scan(&scale, &remainWeights)\n\n text := scale + \"\\n\" + remainWeights\n\n l := make([]rune, 0)\n r := make([]rune, 0)\n p := make([]rune, 0)\n flag := 1\n for _, v := range text {\n if v == '\\n' || v == '|' {\n flag++\n continue\n }\n switch flag {\n case 1:\n l = append(l, v)\n case 2:\n r = append(r, v)\n case 3:\n p = append(p, v)\n }\n }\n\n // sz := (tlen - 2) / 2\n // c := sz - len(l)\n // if c >= 0 && c < len(p) {\n // l = append(l, p[:c]...)\n // r = append(r, p[c:]...)\n // }\n\n for _, v := range p {\n if len(l) < len(r) {\n l = append(l, v)\n } else {\n r = append(r, v)\n }\n }\n\n if len(l) != len(r) {\n fmt.Println(\"Impossible\")\n } else {\n l = append(l, '|')\n l = append(l, r...)\n\n fmt.Println(string(l))\n }\n}\n", "src_uid": "917f173b8523ddd38925238e5d2089b9"} {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nfunc min(a, b int) int {\n if a < b {\n return a\n }\n return b\n}\n\nfunc main() {\n in := bufio.NewReader(os.Stdin)\n\n var L, A, F int\n fmt.Fscanf(in, \"%d\\n%d\\n%d\\n\", &L, &A, &F)\n mul := min(L, min(A / 2, F / 4))\n fmt.Println(mul * 7)\n}\n", "src_uid": "82a4a60eac90765fb62f2a77d2305c01"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, t int\n\tfmt.Scan(&n)\n\tfor ; n > 0; n-- {\n\t\tfmt.Scan(&t)\n\t\tfmt.Println(t/7 + 1)\n\t}\n}\n", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c"} {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadInt64() int64 {\n scanner.Scan()\n ans, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n a := ReadInt32()\n m := ReadInt32()\n f := false\n d := make(map[int]bool)\n\n for {\n q := a % m\n if q == 0 {\n f = true\n break\n } else if _, r := d[q]; r {\n f = false\n break\n } else {\n d[q] = true\n a += q\n }\n }\n\n if f {\n writer.WriteString(\"Yes\\n\")\n } else {\n writer.WriteString(\"No\\n\")\n }\n}\n", "src_uid": "f726133018e2149ec57e113860ec498a"} {"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 := nextInt()\n\t_ = n\n\thamsters := next()\n\n\tcountx, countX := 0, 0\n\n\tfor i := range hamsters {\n\t\tif hamsters[i] == 'x' {\n\t\t\tcountx++\n\t\t} else {\n\t\t\tcountX++\n\t\t}\n\t}\n\n\tresult := []uint8(hamsters)\n\tminutes := 0\n\n\tswitch {\n\tcase countx > countX:\n\t\tt := countx - countX\n\t\tt /= 2\n\t\tminutes = t\n\t\tfor i:=0; t>0; i++ {\n\t\t\tif result[i] == 'x' {\n\t\t\t\tresult[i] = 'X'\n\t\t\t\tt--\n\t\t\t}\n\t\t}\n\tcase countx < countX:\n\t\tt := countX - countx\n\t\tt /= 2\n\t\tminutes = t\n\t\tfor i:=0; t>0; i++ {\n\t\t\tif result[i] == 'X' {\n\t\t\t\tresult[i] = 'x'\n\t\t\t\tt--\n\t\t\t}\n\t\t}\n\t} \n\t\n\tprintln(minutes)\n\tprintln(string(result))\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, err := strconv.ParseFloat(next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc print(a ...interface{}) {\n\tfmt.Fprint(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}", "src_uid": "fa6311c72d90d8363d97854b903f849d"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n\nfunc main() {\n\tdefer Flush()\n\n\tn := readi()\n\ts := readb()\n\n\tvar t []byte\n\tt = append(t, s[0])\n\tfor i := 1; i < n; i++ {\n\t\tj := len(t) - 1\n\t\tif t[j] != 'D' && s[i] != t[j] {\n\t\t\tt[j] = 'D'\n\t\t} else {\n\t\t\tt = append(t, s[i])\n\t\t}\n\t}\n\tprintln(len(t))\n}\n", "src_uid": "986ae418ce82435badadb0bd5588f45b"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n, l, r, x int\n\tif _, err := fmt.Scanf(\"%d %d %d %d\\n\", &n, &l, &r, &x); err != nil {\n\t\treturn\n\t}\n\n\tc := make([]int, n)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; i < n && scanner.Scan(); i++ {\n\t\t_c, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tc[i] = _c\n\t}\n\n\tways := 0\n\n\tmask := (1 << uint(n)) - 1\n\tfor mask > 0 {\n\t\tm := mask\n\n\t\tcnt := 0\n\t\tsum := 0\n\t\tmax := -1\n\t\tmin := -1\n\t\tfor i := 0; i < n; i++ {\n\t\t\tv := m % 2\n\t\t\tif v == 1 {\n\t\t\t\tcnt++\n\t\t\t\tsum += c[i]\n\t\t\t\tif c[i] > max {\n\t\t\t\t\tmax = c[i]\n\t\t\t\t}\n\t\t\t\tif c[i] < min || min < 0 {\n\t\t\t\t\tmin = c[i]\n\t\t\t\t}\n\t\t\t}\n\t\t\tm /= 2\n\t\t}\n\t\tif cnt >= 2 && sum >= l && sum <= r && max-min >= x {\n\t\t\tways++\n\t\t}\n\n\t\tmask -= 1\n\t}\n\n\tfmt.Println(ways)\n}\n", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc power(exp int64) int64 {\n\tif exp == 0 {\n\t\treturn 1\n\t}\n\tif exp == 1 {\n\t\treturn 2\n\t}\n\tvar result int64 = 1\n\tif exp%2 == 1 {\n\t\tresult = 2\n\t}\n\tp := power(exp / 2)\n\tresult = (result * p * p) % 1000000007\n\treturn result\n}\n\nfunc main() {\n\tvar k int\n\tfmt.Scan(&k)\n\tanswer := (6 * power((1<<(k+1))-4)) % 1000000007\n\tfmt.Println(answer)\n}\n", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"strconv\"\n)\n\nfunc Sum(num int64) int64 {\n\tvar sum int64\n\tsum = 0\n\tfor num > 0 {\n\t\tsum += num % 10\n\t\tnum /= 10\n\t}\n\n\treturn sum\n}\n\nfunc main() {\n\tvar n int64\n\n\tfmt.Scanln(&n)\n\n\tstr := strconv.FormatInt(n/2, 10)\n\tdigits := len(str)\n\tpow10 := int64(math.Pow10(digits - 1))\n\ta := int64(str[0]-48) * pow10\n\tif digits > 1 {\n\t\ta += pow10 - 1\n\t}\n\n\tfmt.Println(Sum(a) + Sum(n-a))\n}", "src_uid": "5c61b4a4728070b9de49d72831cd2329"} {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n s := getS()\n chars := []byte{ s[0] }\n for i := 1; i < len(s); i++ {\n if s[i] != '/' || s[i-1] != '/' {\n chars = append(chars, s[i])\n }\n }\n if len(chars) > 1 && chars[len(chars)-1] == '/' {\n chars = chars[:len(chars)-1]\n }\n writer.WriteString(fmt.Sprintf(\"%s\\n\", string(chars)))\n}\n", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc consec(arr []int) int {\n\n\tans := 0\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tcur := 1\n\t\tlast := arr[i]\n\t\tfor j := i + 1; j < len(arr); j++ {\n\t\t\tif arr[j] == last+1 {\n\t\t\t\tlast = last + 1\n\t\t\t\tcur++\n\t\t\t} else {\n\t\t\t\tans = max(ans, cur)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tans = max(ans, cur)\n\t}\n\treturn ans\n}\n\nfunc same(arr []int) int {\n\n\tans := 0\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tcur := 1\n\t\tlast := arr[i]\n\t\tfor j := i + 1; j < len(arr); j++ {\n\t\t\tif arr[j] == last {\n\t\t\t\tcur++\n\t\t\t} else {\n\t\t\t\tans = max(ans, cur)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tans = max(ans, cur)\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar a, b, c string\n\n\ts := []int{}\n\tm := []int{}\n\tp := []int{}\n\n\tscanf(\"%s %s %s\\n\", &a, &b, &c)\n\n\tif a[1] == byte('s') {\n\t\tcur := int(a[0] - byte('0'))\n\t\ts = append(s, cur)\n\t}\n\tif a[1] == byte('m') {\n\t\tcur := int(a[0] - byte('0'))\n\t\tm = append(m, cur)\n\t}\n\tif a[1] == byte('p') {\n\t\tcur := int(a[0] - byte('0'))\n\t\tp = append(p, cur)\n\t}\n\n\tif b[1] == byte('s') {\n\t\tcur := int(b[0] - byte('0'))\n\t\ts = append(s, cur)\n\t}\n\tif b[1] == byte('m') {\n\t\tcur := int(b[0] - byte('0'))\n\t\tm = append(m, cur)\n\t}\n\tif b[1] == byte('p') {\n\t\tcur := int(b[0] - byte('0'))\n\t\tp = append(p, cur)\n\t}\n\n\tif c[1] == byte('s') {\n\t\tcur := int(c[0] - byte('0'))\n\t\ts = append(s, cur)\n\t}\n\tif c[1] == byte('m') {\n\t\tcur := int(c[0] - byte('0'))\n\t\tm = append(m, cur)\n\t}\n\tif c[1] == byte('p') {\n\t\tcur := int(c[0] - byte('0'))\n\t\tp = append(p, cur)\n\t}\n\n\tsort.Ints(s)\n\tsort.Ints(p)\n\tsort.Ints(m)\n\n\t// fmt.Println(s, p, m)\n\n\t// fmt.Println(consec(p))\n\n\tif same(s) == 3 || consec(s) == 3 || same(p) == 3 || consec(p) == 3 || same(m) == 3 || consec(m) == 3 {\n\t\tprintf(\"0\")\n\t\treturn\n\t}\n\n\tif same(s) == 2 || consec(s) == 2 || same(p) == 2 || consec(p) == 2 || same(m) == 2 || consec(m) == 2 {\n\t\tprintf(\"1\")\n\t\treturn\n\t}\n\n\tif len(s) == 2 {\n\t\ts = []int{s[0], s[0] + 1, s[1]}\n\t} else if len(s) == 3 {\n\t\ts = []int{s[0], s[0] + 1, s[1], s[1] + 1, s[2]}\n\t}\n\tif len(m) == 2 {\n\t\tm = []int{m[0], m[0] + 1, m[1]}\n\t} else if len(m) == 3 {\n\t\tm = []int{m[0], m[0] + 1, m[1], m[1] + 1, m[2]}\n\t}\n\tif len(p) == 2 {\n\t\tp = []int{p[0], p[0] + 1, p[1]}\n\t} else if len(p) == 3 {\n\t\tp = []int{p[0], p[0] + 1, p[1], p[1] + 1, p[2]}\n\t}\n\n\tif same(s) >= 3 || consec(s) >= 3 || same(p) >= 3 || consec(p) >= 3 || same(m) >= 3 || consec(m) >= 3 {\n\t\tprintf(\"1\")\n\t\treturn\n\t}\n\n\tprintf(\"2\")\n\n}\n", "src_uid": "7e42cebc670e76ace967e01021f752d3"} {"source_code": "package main\n\nimport (\n \"fmt\"\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nvar sc *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc nextInt() int {\n sc.Scan()\n ans, _ := strconv.Atoi(sc.Text())\n return ans\n}\n\nfunc Count(left, right int, a []int) (cnt int) {\n for i, val := range a {\n if left <= i && i <= right {\n cnt += 1 - val\n } else {\n cnt += val\n }\n }\n return\n}\n\nfunc main() {\n sc.Split(bufio.ScanWords)\n n := nextInt()\n var a = make([]int, n)\n for i := range a {\n a[i] = nextInt()\n }\n best := 0\n for i := 0; i < n; i++ {\n for j := i; j < n; j++ {\n cnt := Count(i,j,a)\n if best < cnt {\n best = cnt\n }\n }\n }\n fmt.Println(best)\n}\n", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\n// 378 task\nfunc CalculateChansesToWin() {\n\tvar first_player_num int\n\tfmt.Scan(&first_player_num)\n\n\tvar second_player_num int\n\tfmt.Scan(&second_player_num)\n\n\tvar (\n\t\tfirst int\n\t\tdraw int\n\t\tsecond int\n\t)\n\n\tfor i := 1; i < 7; i++ {\n\t\tif math.Abs(float64(second_player_num-i)) > math.Abs(float64(first_player_num-i)) {\n\t\t\tfirst += 1\n\t\t} else if math.Abs(float64(second_player_num-i)) == math.Abs(float64(first_player_num-i)) {\n\t\t\tdraw += 1\n\t\t} else {\n\t\t\tsecond += 1\n\t\t}\n\t}\n\n\tfmt.Println(first, draw, second)\n}\n\nfunc main() {\n\tCalculateChansesToWin()\n}\n", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\ta := int64(0)\n\tfmt.Fscanf(in, \"%d\\n\", &a)\n\ti := int64(2)\n\tfor i = 2; i*i <= a; i++ {\n\t\tif a%int64(i) == 0 {\n\t\t\tfmt.Fprintf(out, \"%d\\n\", (a-int64(i))/2+1)\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", 1)\n\treturn\n}", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nconst mod = 998244353\nconst N = 5001\n\nvar factor = [N][]int{}\nvar primes = []int64{}\n\nfunc comb(m int, n int) int64 {\n\tfor i := len(primes) - 1; i >= 0; i-- {\n\t\tif primes[i] <= int64(n) {\n\t\t\tprimes = primes[:i+1]\n\t\t\tbreak\n\t\t}\n\t}\n\tres := int64(1)\n\tfnm := make([]int, len(factor[0]))\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\tfw, fmw, fnw, r := factor[w], factor[m-w], factor[n-w], int64(1)\n\t\tfor i, p := range primes {\n\t\t\tfor pw := fnm[i] - fw[i] - fmw[i] - fnw[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\ta, b, c := abc[0], abc[1], abc[2]\n\tsieve := [N]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\tcur := factor[0]\n\tfor _, nxt := range factor[:c+1] {\n\t\tfor i, x := range cur {\n\t\t\tnxt[i] += x\n\t\t}\n\t\tcur = nxt\n\t}\n\tfmt.Println(comb(b, c) * comb(a, c) % mod * comb(a, b) % mod)\n}\n", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383"} {"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", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774"} {"source_code": "package main\n import \"fmt\"\n\n\nfunc main(){\n\tvar a,b int64\n\tfmt.Scanf(\"%d %d\", &a, &b)\n\tfor {\n\t\tif a == 0 || b == 0 {\n\t\t\tbreak\n\t\t}\n\t\tif a >= 2*b {\n\t\t\tz := a / (2*b)\n\t\t\tif z > 0 {\n\t\t\t\ta = a - 2*b*z\n\t\t\t} else {\n\t\t\t\ta = a - 2*b\n\t\t\t}\n\t\t\t\n\t\t} else if b >= 2*a {\n\t\t\tz := b / (2*a)\n\t\t\tif z > 0 {\n\t\t\t\tb = b - 2*a*z\n\t\t\t} else {\n\t\t\t\tb = b - 2*a\n\t\t\t\t\n\t\t\t}\n\t\t\n\t\t} else {break}\n\t}\n\tfmt.Print(a , b)\n}", "src_uid": "1f505e430eb930ea2b495ab531274114"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc main() {\n\tvar x, h, m int\n\tfmt.Scanf(\"%d\\n%d %d\", &x, &h, &m)\n\tt := time.Date(2000, time.November, 10, h, m, 0, 0, time.UTC)\n\ti := 0\n\tfor true {\n\t\thour := t.Hour()\n\t\tif hour%10 == 7 {\n\t\t\tbreak\n\t\t}\n\t\tminute := t.Minute()\n\t\tif minute%10 == 7 {\n\t\t\tbreak\n\t\t}\n\t\tt = t.Add(-time.Duration(x) * time.Minute)\n\t\ti++\n\t}\n\tfmt.Print(i)\n}\n", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b int\n\tfmt.Scan(&n, &a, &b)\n\tc := make([]int, n)\n\tfor i, _ := range c {\n\t\tfmt.Scan(&c[i])\n\t}\n\n\tmin_price := a\n\tif b < min_price {\n\t\tmin_price = b\n\t}\n\t//fmt.Println(c)\n\tans := 0\n\tfor i, _ := range c {\n\t\tri := n - 1 - i\n\t\tif i > ri {\n\t\t\tbreak\n\t\t} else if i == ri {\n\t\t\tif c[i] == 2 {\n\t\t\t\tans += min_price\n\t\t\t}\n\t\t} else {\n\t\t\tif c[i] != 2 && c[ri] != 2 {\n\t\t\t\tif c[i] != c[ri] {\n\t\t\t\t\tans = -1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else if c[i] == 2 && c[ri] != 2 {\n\t\t\t\tif c[ri] == 0 {\n\t\t\t\t\tans += a\n\t\t\t\t} else {\n\t\t\t\t\tans += b\n\t\t\t\t}\n\t\t\t} else if c[ri] == 2 && c[i] != 2 {\n\t\t\t\tif c[i] == 0 {\n\t\t\t\t\tans += a\n\t\t\t\t} else {\n\t\t\t\t\tans += b\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tans += (min_price * 2)\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}", "src_uid": "af07223819aeb5bd6ded4340c472b2b6"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tvar m int64\n\tfmt.Scan(&s)\n\tfmt.Scan(&m)\n\tvar n = len(s)\n\t\n\tvar ten [300000]int64\n\tvar suf [300000]int64\n\t\n\tten[0] = 1;\n\tfor i := 1; i <= n; i++ {\n\t\tten[i] = (ten[i - 1] * 10) % m;\n\t}\n\n\tsuf[n] = 0;\n\tfor i := n-1; i >= 0; i-- {\n\t\tvar id = int64(n - 1 - i);\n\t\tvar dig = int64(s[i] - '0');\n\t\tsuf[i] = (suf[i + 1] + dig * ten[id]) % m;\n\t}\n\n\tvar mn = int64(m);\n\tvar pv = int64(0);\n\tfor i := 0; i < n; i++ {\n\t\tvar cur = (suf[i] * ten[i] + pv) % m;\n\t\t//DBN(i, ten[i], suf[i]*ten[i], pv);\n\t\tvar dig = int64(s[i] - '0');\n\t\tpv = (pv * 10 + dig) % m;\n\t\tif (dig != 0 && cur < mn) {\n\t\t\tmn = cur;\n\t\t}\n\t}\n\n\tfmt.Println(mn)\n}", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar (\n\t\ta, b string\n\t\tc int\n\t)\n\tfmt.Scan(&a, &b)\n\ta = strings.ToLower(a)\n\tb = strings.ToLower(b)\n\tfor i := 0; i < len(a); i++ {\n\t\tif a[i] != b[i] {\n\t\t\tif a[i] < b[i] {\n\t\t\t\tc = -1\n\t\t\t} else {\n\t\t\t\tc = 1\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Print(c)\n\n}\n", "src_uid": "ffeae332696a901813677bd1033cf01e"} {"source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n\t\"regexp\"\r\n\t\"strconv\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1618F(in io.Reader, out io.Writer) {\r\n\tvar x, y uint64\r\n\tFscan(in, &x, &y)\r\n\tif x == y {\r\n\t\tFprintln(out, \"YES\")\r\n\t\treturn\r\n\t}\r\n\ts := strconv.FormatUint(x, 2)\r\n\tt := strconv.FormatUint(y, 2)\r\n\trt := []byte(t)\r\n\tfor i, n := 0, len(rt); i < n/2; i++ {\r\n\t\trt[i], rt[n-1-i] = rt[n-1-i], rt[i]\r\n\t}\r\n\tf := func() bool {\r\n\t\tr := regexp.MustCompile(\"^1*\" + s + \"1*$\")\r\n\t\treturn r.MatchString(t) || r.Match(rt)\r\n\t}\r\n\ts += \"1\"\r\n\tif f() {\r\n\t\tFprintln(out, \"YES\")\r\n\t\treturn\r\n\t}\r\n\ts = s[:len(s)-1]\r\n\tfor s[len(s)-1] == '0' {\r\n\t\ts = s[:len(s)-1]\r\n\t}\r\n\tif f() {\r\n\t\tFprintln(out, \"YES\")\r\n\t} else {\r\n\t\tFprintln(out, \"NO\")\r\n\t}\r\n}\r\n\r\nfunc main() { CF1618F(os.Stdin, os.Stdout) }\r\n", "src_uid": "9f39a3c160087beb0efab2e3cb510e89"} {"source_code": "// 321A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\ti, x, y, X, Y int64\n\ts string\n)\n\nfunc main() {\n\tfmt.Scan(&x, &y, &s)\n\tX, Y = 0, 0\n\tn := len(s)\n\txx := make([]int64, n)\n\tyy := make([]int64, n)\n\tfor i = 0; i < int64(n); i++ {\n\t\txx[i] = X\n\t\tyy[i] = Y\n\t\tif s[i] == 'R' {\n\t\t\tX++\n\t\t}\n\t\tif s[i] == 'U' {\n\t\t\tY++\n\t\t}\n\t\tif s[i] == 'L' {\n\t\t\tX--\n\t\t}\n\t\tif s[i] == 'D' {\n\t\t\tY--\n\t\t}\n\t}\n\tfor i = 0; i < int64(len(s)); i++ {\n\t\tif ((X != 0 || x == xx[i]) && (X == 0 || (x-xx[i])%X == 0)) && ((Y != 0 || y == yy[i]) && (Y == 0 || (y-yy[i])%Y == 0)) {\n\t\t\tif (x-xx[i])*Y == (y-yy[i])*X {\n\t\t\t\tif (X == 0 || (x-xx[i])/X >= 0) && (Y == 0 || (y-yy[i])/Y >= 0) {\n\t\t\t\t\tfmt.Print(\"Yes\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(\"No\")\n}\n", "src_uid": "5d6212e28c7942e9ff4d096938b782bf"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main () {\n\n\tvar n int\n\tvar str string\n\n\tfmt.Scanf(\"%d\\n\",&n)\n\tfmt.Scanf(\"%s\\n\",&str)\n\n\tif n == 1 {\n\t\tif str[0] == '0' {\n\t\t\tfmt.Println(\"no\")\n\t\t\treturn\n\t\t} else {\n\t\t\tfmt.Println(\"yes\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tif str[0] == '0' && str[1] == '0' {\n\t\tfmt.Println(\"no\")\n\t\treturn\n\t}\n\n\tif str[n-1] == '0' && str[n-2] == '0' {\n\t\tfmt.Println(\"no\")\n\t\treturn\n\t}\n\n\ttrick := 0\n\trtrick := 0\n\tfor i:= 0 ; i < n ; i++ {\n\n\t\tif str[i] == '1' {\n\t\t\ttrick = 0\n\t\t} else {\n\t\t\ttrick ++\n\t\t}\n\n\t\tif str[i] == '1' {\n\t\t\trtrick ++\n\t\t} else {\n\t\t\trtrick = 0\n\t\t}\n\n\t\tif trick == 3 || rtrick == 2{\n\t\t\tbreak\n\t\t}\n\n\t}\n\n\tif trick == 3 || rtrick == 2{\n\t\tfmt.Println(\"no\")\n\t} else {\n\t\tfmt.Println(\"yes\")\n\t}\n}\n", "src_uid": "c14d255785b1f668d04b0bf6dcadf32d"} {"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\tswitch {\n\tcase a >= b && a >= c && a+1>=b+c:\n\t\tfmt.Println(a + 1 - b - c);\n\tcase b >= c && b >= a && b+1>=a+c:\n\t\tfmt.Println(b + 1 - a - c);\n\tcase c >= a && c >= b && c+1>=a+b:\n\t\tfmt.Println(c + 1 - a - b);\n\tdefault:\n\t\tfmt.Println(0);\n\t}\n}", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09"} {"source_code": "package main\n\nimport (\n \"fmt\"\n \"strings\"\n)\n\nvar n int \nvar str string\nfunc main() {\n fmt.Scanf(\"%d\\n\", &n)\n fmt.Scanf(\"%s\", &str)\t\n ll := 2\n max_subs := 1\n\tfor ll < n/2+1 {\n\t subs := strings.Contains(str[ll:2*ll], str[0:ll])\n\t if subs {\n\t max_subs = ll\n\t }\n\t ll+=1\n\t}\n\tfmt.Println(n-max_subs+1)\n}", "src_uid": "ed8725e4717c82fa7cfa56178057bca3"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int64\n fmt.Scan(&n)\n for a := int64(1); ; a *= 3 {\n if (n%a) != 0 {\n fmt.Println((n/a)+1)\n break\n }\n }\n}\n", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc bololo(s string) int {\n\tvar haha int\n\tfor i := 0; i < len(s); i++ {\n\t\tatual := s[i : i+1]\n\t\tif atual == \"4\" || atual == \"7\" {\n\t\t\thaha++\n\t\t}\n\t}\n\treturn haha\n}\n\nfunc main() {\n\tvar lucky string\n\tvar digits int\n\tvar luckydigits string\n\tvar digits2 int\n\tfmt.Scanf(\"%s\", &lucky)\n\tdigits = bololo(lucky)\n\tluckydigits = strconv.FormatInt(int64(digits), 10)\n\tdigits2 = bololo(luckydigits)\n\tif digits2 == len(luckydigits) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1"} {"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\texp := map[int]string{\n\t\t1: \"one\",\n\t\t2: \"two\",\n\t\t3: \"three\",\n\t\t4: \"four\",\n\t\t5: \"five\",\n\t\t6: \"six\",\n\t\t7: \"seven\",\n\t\t8: \"eight\",\n\t\t9: \"nine\",\n\t\t10: \"ten\",\n\t\t11: \"eleven\",\n\t\t12: \"twelve\",\n\t\t13: \"thirteen\",\n\t\t15: \"fifteen\",\n\t\t18: \"eighteen\",\n\t\t20: \"twenty\",\n\t\t30: \"thirty\",\n\t\t40: \"forty\",\n\t\t50: \"fifty\",\n\t\t80: \"eighty\",\n\t}\n\n\tvar scr int\n\tfmt.Fscan(reader, &scr)\n\tif scr == 0 {\n\t\tfmt.Println(\"zero\")\n\t\treturn\n\t}\n\tif _, exst := exp[scr]; exst {\n\t\tfmt.Println(exp[scr])\n\t\treturn\n\t}\n\n\tif scr/10 == 1 {\n\t\tfmt.Printf(\"%s%s\", exp[scr%10], \"teen\")\n\t} else {\n\t\tif _, exst := exp[(scr/10)*10]; exst {\n\t\t\tfmt.Print(exp[(scr/10)*10])\n\t\t} else {\n\t\t\tfmt.Printf(\"%s%s\", exp[scr/10], \"ty\")\n\t\t}\n\t\tif scr%10 > 0 {\n\t\t\tfmt.Printf(\"-%s\", exp[scr%10])\n\t\t}\n\t}\n}\n", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc int_abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc int_max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc int_min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc main() {\n\tvar v1, v2, t, d int\n\tfmt.Scan(&v1)\n\tfmt.Scan(&v2)\n\tfmt.Scan(&t)\n\tfmt.Scan(&d)\n\tans := 0\n\tspeed := v1\n\tfor i := 0; i < t; i++ {\n\t\tans += speed\n\t\tspeed = int_min(speed+d, v2+d*(t-2-i))\n\t}\n\tfmt.Println(ans)\n}\n", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nconst (\n\tEPS = 1e-8\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n)\n\ntype Light struct {\n\tp complex128\n\ta float64\n}\n\ntype Line struct {\n\tp1, p2 complex128\n}\n\nfunc CrossProduct(a complex128, b complex128) float64 {\n\treturn real(a)*imag(b) - real(b)*imag(a)\n}\n\nfunc Roatate(p complex128, a float64) complex128 {\n\treturn p * complex(math.Cos(a), math.Sin(a))\n}\n\nfunc Intersact(a Line, b Line) (intersaction complex128, isIntersact bool) {\n\tvar (\n\t\ts1 = CrossProduct(a.p2-a.p1, b.p1-a.p1)\n\t\ts2 = CrossProduct(a.p2-a.p1, b.p2-a.p1)\n\t\ts = s2 - s1\n\t)\n\tif math.Abs(s) >= EPS {\n\t\tisIntersact = true\n\t\tintersaction = complex((real(b.p1)*s2-real(b.p2)*s1)/s, (imag(b.p1)*s2-imag(b.p2)*s1)/s)\n\t}\n\treturn\n}\n\nfunc foo(l float64, lit Light, r float64) float64 {\n\tv1 := complex(l-real(lit.p), 0-imag(lit.p))\n\tv2 := Roatate(v1, lit.a)\n\tif imag(v2) > -EPS {\n\t\treturn r\n\t}\n\n\tp1 := complex(0.0, 0.0)\n\tp2 := complex(100.0, 0.0)\n\tinter, _ := Intersact(Line{lit.p, lit.p + v2}, Line{p1, p2})\n\treturn real(inter)\n}\n\nfunc main() {\n\tvar (\n\t\tn int\n\t\tl, r float64\n\t\tlits []Light\n\t)\n\n\tfmt.Fscan(reader, &n, &l, &r)\n\tfor i := 0; i < n; i++ {\n\t\tvar x, y, a float64\n\t\tfmt.Fscan(reader, &x, &y, &a)\n\t\tlits = append(lits, Light{complex(x, y), a * math.Pi / 180.0})\n\t}\n\n\tf := make([]float64, 1< f[k] {\n\t\t\t\t\tf[k] = cur\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(math.Min(f[(1< int('a') {\n\t\t\t\tf[i] = t[i] - 1\n\t\t\t\tfor k := iNearFound; k < i; k++ {\n\t\t\t\t\tf[k] = t[k]\n\t\t\t\t}\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif int(t[i])-int(s[i]) > 1 {\n\t\t\tf[i] = s[i] + 1\n\t\t\tfound = true\n\t\t\tbreak\n\t\t} else if int(t[i])-int(s[i]) > 0 {\n\t\t\tif i < len(s)-1 {\n\t\t\t\tnearFound = true\n\t\t\t\tiNearFound = i\n\t\t\t}\n\t\t} else if int(s[i]) > int(t[i]) {\n\t\t\tbreak\n\t\t}\n\n\t}\n\n\tif found {\n\t\tfmt.Print(string(f))\n\t\treturn\n\t}\n\n\tfmt.Print(\"No such string\")\n}\n\n/*\npnzcl\npnzdf\n\npnzcm\n\n*/\n", "src_uid": "47618510d2a17b1cc1e6a688201d51a3"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,d,a int\n fmt.Scan(&n,&d)\n total := 0\n for i := 0; i < n; i++ {\n fmt.Scan(&a)\n total += a\n }\n total += (n-1)*10\n if total > d {\n fmt.Println(\"-1\")\n } else {\n fmt.Println(2*(n-1) + (d-total)/5)\n }\n}", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea"} {"source_code": "package main\nimport (\"fmt\")\n\n\n\nfunc max(x,y int) int {\n if (x>y){\n \treturn x\n } else{\n \treturn y\n }\n}\n\nfunc min(x,y int) int {\n if (x b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\ntype io struct {\n\tinp *bufio.Scanner\n\tout *bufio.Writer\n}\n\nfunc newIO() io {\n\tsc := io{\n\t\tinp: bufio.NewScanner(os.Stdin),\n\t\tout: bufio.NewWriter(os.Stdout),\n\t}\n\tsc.inp.Split(bufio.ScanWords)\n\treturn sc\n}\nfunc (sc io) nextArr(n int) []int {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = sc.nextInt()\n\t}\n\treturn a\n}\nfunc (sc io) nextString() string {\n\tsc.inp.Scan()\n\treturn sc.inp.Text();\n}\n\nfunc (sc io) nextInt64() int64 {\n\tv, _ := strconv.ParseInt(sc.nextString(), 10, 64)\n\treturn int64(v)\n}\nfunc (sc io) nextInt() int {\n\tv, _ := strconv.ParseInt(sc.nextString(), 10, 32)\n\treturn int(v)\n}\n\nfunc (out io) print (s string) {\n\tout.out.WriteString(s)\n}", "src_uid": "8de14db41d0acee116bd5d8079cb2b02"} {"source_code": "\ufeffpackage main\n\nimport (\n\t\"fmt\"\n\t//\"sort\"\n\t//\"math\"\n)\n\nfunc main() {\n\tvar m,x,y int\n\tvar a [100]int\n\ts,t:=0,0\n\tflag:=false\n \tfmt.Scan(&m)\n\tfor i:=0;i=x && s<=y && t-s>=x && t-s<=y {\n\t\t\tfmt.Println(i+2)\n\t\t\tflag=true\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag==false {\n\t\tfmt.Println(\"0\")\n\t}\n}\n\n\n", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b"} {"source_code": "// 80B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scanf(\"%d:%d\", &x, &y)\n\tx %= 12\n\tn := float64(y) / 2\n\tfmt.Printf(\"%.10f %d\\n\", float64(x%12)*30+n, y*6)\n}\n", "src_uid": "175dc0bdb5c9513feb49be6644d0d150"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\tw := bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\n\tvar n int\n\tfmt.Fscan(r, &n)\n\n\tres := 3\n\tif n > 1 {\n\t\tp := (n-1) % 3\n\t\tq := (n+2) / 3\n\t\tres = 4*q + 3*p / 2\n\t}\n\n\tfmt.Fprintln(w, res)\n}\n", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a,b,c int\n fmt.Scan(&a,&c)\n for i := 1; (a > 0) || (c > 0); i *= 3 {\n da, dc := a%3, c%3\n if dc < da { dc += 3 }\n b += (i*(dc-da))\n a /= 3\n c /= 3\n }\n fmt.Println(b)\n}\n", "src_uid": "5fb635d52ddccf6a4d5103805da02a88"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"runtime/debug\"\n)\n\ntype Range struct {\n\tleft, right int\n}\n\nvar (\n\tisNotPrime []bool\n\tprimes []int\n\tn int\n)\n\nfunc main() {\n\tdebug.SetGCPercent(-1)\n\n\tfmt.Scanf(\"%d\", &n)\n\t// n = 1e6\n\n\tcalcPrimes(n)\n\n\tx1Range := getRange(n)\n\n\tx0Range := getRange(x1Range.left)\n\n\tfor i := x1Range.left + 1; i < x1Range.right; i++ {\n\t\tx0Range = joinRanges(x0Range, getRange(i))\n\t}\n\n\tfmt.Println(x0Range.left)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc joinRanges(r1, r2 Range) Range {\n\tleft := min(r1.left, r2.left)\n\n\tright := max(r1.right, r2.right)\n\n\treturn Range{left, right}\n}\n\nfunc getRange(n int) Range {\n\tdivider := findMaxPrimeDivider(n)\n\n\treturn Range{n - divider + 1, n}\n}\n\nfunc findMaxPrimeDivider(x int) int {\n\tsqrtx := int(math.Sqrt(float64(x))) + 1\n\n\tfor i := 0; i < len(primes) && primes[i] < sqrtx; i++ {\n\t\tif x%primes[i] == 0 {\n\t\t\tx /= primes[i]\n\n\t\t\tfor isNotPrime[x] && x%primes[i] == 0 {\n\t\t\t\tx /= primes[i]\n\t\t\t}\n\n\t\t\tif !isNotPrime[x] {\n\t\t\t\treturn x\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 1\n}\n\nfunc calcPrimes(n int) {\n\tisNotPrime = make([]bool, n+1)\n\n\tfor i := 2; i*i <= n; i++ {\n\t\tif !isNotPrime[i] {\n\t\t\tfor j := i * i; j <= n; j += i {\n\t\t\t\tisNotPrime[j] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tprimes = make([]int, 0, n/2)\n\n\tfor i := 2; i <= n; i++ {\n\t\tif !isNotPrime[i] {\n\t\t\tprimes = append(primes, i)\n\t\t}\n\t}\n}\n", "src_uid": "43ff6a223c68551eff793ba170110438"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tboard := make([]string, 8)\n\tmaxB, minW := 0, 10\n\n\tfor i := range board {\n\t\tboard[i] = next()\n\t}\n\n\tfor c := 0; c < 8; c++ {\n\t\tb, w := -1, -1\n\n\t\tfor r := 0; r < 8; r++ {\n\t\t\tif board[r][c] == 'B' {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif board[r][c] == 'W' {\n\t\t\t\tw = r\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tfor r := 7; r >= 0; r-- {\n\t\t\tif board[r][c] == 'W' {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif board[r][c] == 'B' {\n\t\t\t\tb = r\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// println(w, b, minW, maxB)\n\n\t\tif w != -1 && w < minW {\n\t\t\tminW = w\n\t\t}\n\n\t\tif b != -1 && b > maxB {\n\t\t\tmaxB = b\n\t\t}\n\t}\n\n\t// println(minW, maxB)\n\tmaxB = 8 - maxB - 1\n\t// println(minW, maxB)\n\tif minW <= maxB {\n\t\tprintln(\"A\")\n\t} else {\n\t\tprintln(\"B\")\n\t}\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nvar in = bufio.NewReader(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc reverse(x int, s []byte) {\n\tfor i, j := 0, x-1; i < j; i, j = i+1, j-1 {\n\t\ts[i], s[j] = s[j], s[i]\n\t}\n}\n\nfunc main() {\n\tdefer out.Flush()\n\n\tvar n int\n\tvar s []byte\n\tfmt.Fscan(in, &n, &s)\n\n\t//TODO: enhancement, sqrt\n\tfor i := 2; i <= n; i++ {\n\t\tif n % i == 0 {\n\t\t\treverse(i, s)\n\t\t}\n\t}\n\tfmt.Fprintln(out, string(s))\n}\n", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3"} {"source_code": "// Codeforces 656 B \npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readLineNumbs(n int) []int {\n a := make([]int, n)\n s, err := in.ReadString('\\n')\n if err != nil {\n fmt.Println(\"read failure\", err)\n panic(err)\n }\n ss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n for j:=0; j 0) && (g[ci] == 0) {\n\t\t\tfmt.Printf(\"\\n%c\", q[i])\n\t\t\tg[ci] = 1\n\t\t\tn--\t\t\t\n\t\t} else {\n\t\t\tfmt.Printf(\"%c\", q[i])\n\t\t}\n\t}\n\tfmt.Println(\"\")\n}\n", "src_uid": "c1b071f09ef375f19031ce99d10e90ab"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc max(a,b int) int { if a > b { return a } else { return b } }\n\nfunc main() {\n var n,c,cur int\n fmt.Scan(&n,&c)\n ans, prev := 0, -100\n for i := 0; i < n; i++ {\n fmt.Scan(&cur)\n ans = max(ans,prev-cur-c)\n prev = cur\n }\n fmt.Println(ans)\n}\n", "src_uid": "411539a86f2e94eb6386bb65c9eb9557"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (\u4e8c\u5206\u7d2f\u4e57\u6cd5(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\t// str := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n int64\n\nfunc main() {\n\tn = ReadInt64()\n\n\tif n == 1 {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\n\tif IsPrime(n) {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\n\t// D := divisor(n)\n\t// if len(D) == 3 {\n\t// \tfmt.Println(D[2])\n\t// \treturn\n\t// }\n\tmemo := TrialDivision(n)\n\tif len(memo) == 1 {\n\t\tfor k := range memo {\n\t\t\tfmt.Println(k)\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(1)\n}\n\n// \u7d04\u6570\u306e\u5217\u6319: O(sqrt(n))\nfunc divisor(n int64) []int64 {\n\tres := []int64{}\n\n\tfor i := int64(1); i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\tres = append(res, i)\n\t\t\tif i != (n / i) {\n\t\t\t\tres = append(res, (n / i))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn res\n}\n\n// TrialDivision returns the result of prime factorization of integer N.\nfunc TrialDivision(n int64) map[int64]int {\n\tif n <= 1 {\n\t\tpanic(errors.New(\"[argument error]: TrialDivision only accepts a NATURAL number\"))\n\t}\n\n\tp := map[int64]int{}\n\tfor i := int64(2); i*i <= n; i++ {\n\t\texp := 0\n\t\tfor n%i == 0 {\n\t\t\texp++\n\t\t\tn /= i\n\t\t}\n\n\t\tif exp == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tp[i] = exp\n\t}\n\tif n > 1 {\n\t\tp[n] = 1\n\t}\n\n\treturn p\n}\n\n// IsPrime judges whether an argument integer is a prime number or not.\nfunc IsPrime(n int64) bool {\n\tif n == 1 {\n\t\treturn false\n\t}\n\n\tfor i := int64(2); i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\n// \u30a8\u30e9\u30c8\u30b9\u30c6\u30cd\u30b9\u306e\u7be9: O(NloglogN)\n// n\u4ee5\u4e0b\u306e\u7d20\u6570\u306e\u6570\u3068\u7d20\u6570\u306e\u30b9\u30e9\u30a4\u30b9\u3092\u8fd4\u3059\nfunc sieve(n int) (int, []int) {\n\t// var prime [2000000 + 5]int\n\tprime := []int{}\n\tvar isPrime [2000000 + 5 + 1]bool\n\n\tp := 0\n\tfor i := 0; i <= n; i++ {\n\t\tisPrime[i] = true\n\t}\n\tisPrime[0], isPrime[1] = false, false\n\n\tfor i := 2; i <= n; i++ {\n\t\t// i\u304ctrue\u3067\u6b8b\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u7d20\u6570\u8a8d\u5b9a\u3057\u3001\u81ea\u5206\u3088\u308a\u5927\u304d\u3044\u500d\u6570\u3092\u53d6\u308a\u9664\u3044\u3066\u3044\u304f\n\t\tif isPrime[i] {\n\t\t\t// prime[p] = i\n\t\t\tprime = append(prime, i)\n\t\t\tp++\n\n\t\t\t// \u500d\u6570\u306e\u9664\u53bb\n\t\t\tfor j := 2 * i; j <= n; j += i {\n\t\t\t\tisPrime[j] = false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn p, prime\n}\n\n// MOD\u306f\u3068\u3063\u305f\u304b\uff1f\n// \u9077\u79fb\u3060\u3051\u3058\u3083\u306a\u304f\u3066\u6700\u5f8c\u306e\u6700\u5f8c\u3067\u3061\u3083\u3093\u3068\u53d6\u308c\u3088\uff1f\n\n/*******************************************************************/\n", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar t int64\n\n\tfmt.Fscanf(buf, \"%d\\n\", &t)\n\tvar ans int64 = 1\n\n\tfor {\n\t\tif ans*ans >=t{\n\t\t\tans = ans*2\n\t\t\tbreak\n\t\t}\n\t\tif ans*(ans+1) >= t{\n\t\t\tans = ans*2+1\n\t\t\tbreak\n\t\t}\n\t\tans++\n\t}\n\n\tfmt.Printf(\"%d\\n\", ans)\n}\n", "src_uid": "eb8212aec951f8f69b084446da73eaf7"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar i, j, r, c, ans int\n\tfmt.Scan(&r, &c)\n\tinput := make([]string, r)\n\trows := make([]bool, r)\n\tcols := make([]bool, c)\n\tfor i=0; i b/y {\n\t\tfmt.Println(b / y)\n\t\treturn\n\t}\n\n\tfmt.Println(a / x)\n}\n", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc Sol584D(reader io.Reader, writer io.Writer) {\n\tisPrime := 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\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n int\n\tFscan(in, &n)\n\tif isPrime(n) {\n\t\tFprintln(out, 1)\n\t\tFprintln(out, n)\n\t\treturn\n\t}\n\tn -= 3\n\tfor i := 3; ; i += 2 {\n\t\tif isPrime(i) && isPrime(n-i) {\n\t\t\tFprintln(out, 3)\n\t\t\tFprintln(out, 3, i, n-i)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc main() {\n\tSol584D(os.Stdin, os.Stdout)\n}\n", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tm := readInt() - 1\n\tk := readInt()\n\tans := math.MaxInt32\n\tfor i := 0; i < n; i++ {\n\t\ta := readInt()\n\t\tif a != 0 && a <= k {\n\t\t\tif ans > 10*abs(i-m) {\n\t\t\t\tans = 10 * abs(i-m)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "src_uid": "57860e9a5342a29257ce506063d37624"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var a [7]int\n fmt.Scan(&n)\n total := 0\n for i := 0; i < 7; i++ {\n fmt.Scan(&a[i])\n total += a[i]\n }\n n %= total\n ans := 0\n if n == 0 {\n ans = 6\n for ; ans >= 0; ans-- {\n if a[ans] > 0 {\n break\n }\n }\n } else {\n for n > a[ans] {\n n -= a[ans]\n ans++\n }\n }\n fmt.Println(ans+1)\n}\n", "src_uid": "007a779d966e2e9219789d6d9da7002c"} {"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\tans := 0\n\tif m >= n-1 {\n\t\tans = n - 1\n\t} else {\n\t\tans = n - 1\n\t\tfor i := 1; i <= n-1-m; i++ {\n\t\t\tans += i\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", ans)\n\treturn\n}\n\nfunc recover(s string) string {\n\tif len(s) == 1 {\n\t\treturn s\n\t}\n\tif len(s)%2 == 0 {\n\t\treturn recover(s[:len(s)-1]) + string(s[len(s)-1])\n\t} else {\n\t\treturn recover(s[1:]) + string(s[0])\n\t}\n}\n", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7"} {"source_code": "// Codeforces My Practice\n// author: Leonardone @ NEETSDKASU\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\txs := make([]int, n)\n\tones := 0\n\tfor i := range xs {\n\t\tfmt.Scan(&xs[i])\n\t\tif xs[i] == 1 {\n\t\t\tones++\n\t\t}\n\t}\n\tans := ones\n\tzeros := 0\n\tfor _, x := range xs {\n\t\tif x == 0 {\n\t\t\tzeros++\n\t\t} else {\n\t\t\tones--\n\t\t}\n\t\ttmp := ones + zeros\n\t\tif tmp > ans {\n\t\t\tans = tmp\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nconst N = 205\nconst INF = -1000000000\n\nfunc main() {\n\tio := NewFastIO(os.Stdin, os.Stdout)\n\tdefer io.Flush()\n\n\tn, k := io.NextInt(), io.NextInt()\n\ts, t := io.Next(), io.Next()\n\tvar suff [N][26]int\n\n\tfor i := n; i >= 1; i-- {\n\t\tfor j := 0; j < 26; j++ {\n\t\t\tsuff[i][j] = suff[i+1][j]\n\t\t}\n\t\tsuff[i][int(s[i-1]-'a')]++\n\t}\n\n\tif t[0] == t[1] {\n\t\thave, cur := 0, 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif s[i] == t[0] {\n\t\t\t\tcur++\n\t\t\t} else {\n\t\t\t\thave++\n\t\t\t}\n\t\t}\n\t\tcur += min(have, k)\n\t\tio.Println(cur * (cur - 1) / 2)\n\t\treturn\n\t}\n\n\tvar dp [N][N][N]int\n\tfor i := 0; i < N; i++ {\n\t\tfor j := 0; j < N; j++ {\n\t\t\tfor k := 0; k < N; k++ {\n\t\t\t\tdp[i][j][k] = -1\n\t\t\t}\n\t\t}\n\t}\n\n\ta, b := int(t[0]-'a'), int(t[1]-'a')\n\t_ = a\n\n\tvar dfs func(int, int, int) int\n\tdfs = func(i, r, c int) int {\n\t\tif r < 0 {\n\t\t\treturn INF\n\t\t}\n\t\tif i == n+1 {\n\t\t\tif r == 0 {\n\t\t\t\treturn 0\n\t\t\t} else {\n\t\t\t\treturn INF\n\t\t\t}\n\t\t}\n\t\tif dp[i][r][c] != -1 {\n\t\t\treturn dp[i][r][c]\n\t\t}\n\t\tans := 0\n\t\tif s[i-1] == t[0] {\n\t\t\tans = dfs(i+1, r, c+1) + suff[i+1][b]\n\t\t\tans = max(ans, dfs(i+1, r-1, c))\n\t\t\tans = max(ans, dfs(i+1, r-1, c)+c)\n\t\t} else if s[i-1] == t[1] {\n\t\t\tans = dfs(i+1, r-1, c+1) - c + suff[i+1][b]\n\t\t\tans = max(ans, dfs(i+1, r, c))\n\t\t\tans = max(ans, dfs(i+1, r-1, c))\n\t\t} else {\n\t\t\tans = dfs(i+1, r-1, c+1) + suff[i+1][b]\n\t\t\tans = max(ans, dfs(i+1, r-1, c)+c)\n\t\t\tans = max(ans, dfs(i+1, r, c))\n\t\t}\n\t\tdp[i][r][c] = ans\n\t\treturn ans\n\t}\n\n\tans := 0\n\tfor i := 0; i <= k; i++ {\n\t\tans = max(ans, dfs(1, i, 0))\n\t}\n\n\tio.Println(ans)\n}\n\nfunc min(i, j int) int {\n\tif i > j {\n\t\treturn j\n\t}\n\treturn i\n}\n\nfunc max(i, j int) int {\n\tif i > j {\n\t\treturn i\n\t}\n\treturn j\n}\n\ntype FastIO struct {\n\t*bufio.Reader\n\t*bufio.Writer\n\tc [1]byte\n}\n\nfunc NewFastIO(r io.Reader, w io.Writer) *FastIO {\n\treturn &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}\n}\n\nfunc (f *FastIO) readC() byte {\n\tf.Read(f.c[:])\n\treturn f.c[0]\n}\n\nfunc (f *FastIO) NextInt() int {\n\tc := f.readC()\n\tfor ; c <= ' '; c = f.readC() {\n\t}\n\tneg := false\n\tif c == '-' {\n\t\tneg = true\n\t\tc = f.readC()\n\t}\n\tn := 0\n\tfor ; '0' <= c && c <= '9'; c = f.readC() {\n\t\tn = n*10 + int(c) - '0'\n\t}\n\tif neg {\n\t\treturn -n\n\t}\n\treturn n\n}\n\nfunc (f *FastIO) NextInts(n int) []int {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = f.NextInt()\n\t}\n\treturn a\n}\n\nfunc (f *FastIO) Next() string {\n\tc := f.readC()\n\tfor ; c <= ' '; c = f.readC() {\n\t}\n\tvar s []byte\n\tfor ; c > ' '; c = f.readC() {\n\t\ts = append(s, f.c[0])\n\t}\n\treturn string(s)\n}\n\nfunc (f *FastIO) Println(a ...interface{}) {\n\tfmt.Fprintln(f.Writer, a...)\n}\n\nfunc (f *FastIO) Print(a ...interface{}) {\n\tfmt.Fprint(f.Writer, a...)\n}\n\nfunc (f *FastIO) PrintInts(a ...int) {\n\tif len(a) > 0 {\n\t\tf.Print(a[0])\n\t\tfor _, x := range a[1:] {\n\t\t\tf.Print(\" \", x)\n\t\t}\n\t}\n}\n\nfunc (f *FastIO) PrintlnInts(a ...int) {\n\tf.PrintInts(a...)\n\tf.Println()\n}\n", "src_uid": "9c700390ac13942cbde7c3428965b18a"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &n, &s)\n\tans := \"\"\n\tj := 0\n\tfor i := 0; i < n; i += j {\n\t\tj += 1\n\t\tans += string(s[i])\n\t}\n\tfmt.Println(ans)\n}\n", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bestTimes int\nvar m int\n\n//var ret []int\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n int\n\tfmt.Fscanln(reader, &n, &m)\n\t//max := 0\n\tif n > m {\n\t\tbestTimes = n - m\n\t\t//max = n\n\t} else {\n\t\tc1, n1 := findFirstBigger(n, m)\n\t\t//fmt.Println(c1, n1)\n\t\tbestTimes = c1 + (n1 - m)\n\t}\n\t//fmt.Println(bestTimes)\n\t//ret = make([]int, max*2+1)\n\t//for i := 0; i < len(ret); i++ {\n\t//\tret[i] = -1\n\t//}\n\tdfs1(n, m, 0)\n\tfmt.Println(bestTimes)\n}\n\nfunc dfs1(n int, m int, count int) {\n\t//fmt.Println(n, m, count)\n\tif count > bestTimes {\n\t\treturn\n\t}\n\tif n == m {\n\t\tif count < bestTimes {\n\t\t\tbestTimes = count\n\t\t}\n\t\t//fmt.Println(\"====\")\n\t\treturn\n\t}\n\tif n == 0 {\n\t\t//fmt.Println(\"====\")\n\t\treturn\n\t}\n\tif n > m {\n\t\tif count+n-m < bestTimes {\n\t\t\tbestTimes = count + n - m\n\t\t}\n\t\t//fmt.Println(\"====\")\n\t\treturn\n\t} else {\n\t\tif m%2 == 0 {\n\t\t\tdfs1(n, m/2, count+1)\n\t\t} else {\n\t\t\t_, n1 := findFirstBigger(n, m)\n\t\t\tfor i := n1; i > m; i-- {\n\t\t\t\tif i%2 == 0 {\n\t\t\t\t\tdfs1(n, i, count+i-m)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n}\n\n// \u6b21\u6570\uff0c temp\nfunc findFirstBigger(n, m int) (int, int) {\n\ttemp := n\n\tcount := 0\n\tfor {\n\t\tcount++\n\t\ttemp *= 2\n\t\tif temp >= m {\n\t\t\treturn count, temp\n\t\t}\n\t}\n}\n", "src_uid": "861f8edd2813d6d3a5ff7193a804486f"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\n\tans := \"\"\n\n\tans += strings.Repeat(\"8\", N/2)\n\tN = N % 2\n\tans += strings.Repeat(\"4\", N)\n\n\tif len(ans) > 18 {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println(ans)\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", "src_uid": "0c9973792c1976c5710f88e3520cda4e"} {"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc main(){\n\tvar k int\n\tvar a, b int\n\tvar v int\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tk, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\ta, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tb, _ = strconv.Atoi(r.Text())\n\tr.Scan()\n\tv, _ = strconv.Atoi(r.Text())\n\tbox := 0\n\tx := 0\n\tfor a > 0 {\n\t\tx = min(k-1, b)\n\t\ta -= (x+1)*v\n\t\tb -= x\n\t\tbox += 1\n\t}\n\tw.WriteString(strconv.Itoa(box)+\"\\n\")\n\tw.Flush()\n}\n", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tarr := [16]int{}\n\trems := [4]int{}\n\tfor i := 1; i < 4; i++ {\n\t\tfmt.Scan(&rems[i])\n\t}\n\tarr[n%4] = 1\n\tfor i := 0; i < 12; i++ {\n\t\tif arr[i] > 0 {\n\t\t\tfor j := 1; j < 4; j++ {\n\t\t\t\tif arr[i+j] == 0 || arr[i+j] > arr[i]+rems[j] {\n\t\t\t\t\tarr[i+j] = arr[i] + rems[j]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tans := 0\n\tfor i := 0; i < 16; i += 4 {\n\t\tif arr[i] > 0 && (ans == 0 || arr[i] < ans) {\n\t\t\tans = arr[i]\n\t\t}\n\t}\n\tfmt.Println(ans - 1)\n}\n", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc calc(arr []int) int{\n\tsort.Ints(arr)\n\tcount := 0\n\tfor i:=0;i= '0' && s[j] <= '9' {\n\t\t\t\tfreq[s[j]-'0']++\n\t\t\t}\n\t\t}\n\t}\n\n\tpossible := true\n\tfor i:=0; i<10; i++ {\n\t\tif freq[i] > 2*n {\n\t\t\tpossible = false\n\t\t}\n\t}\n\n\tif possible {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a = [6][8]int{\n {3, 3, -1, 4, 4, -1, 3, 3}, \n {3, 3, -1, 4, 4, -1, 3, 3},\n {2, 2, -1, 3, 3, -1, 2, 2},\n {2, 2, -1, 3, 3, -1, 2, 2},\n {1, 1, -1, 2, 2, -1, 1, 1},\n {1, 1, -1, 2, 2, -1, 1, 1},\n }\n var i, j, k, z, z1 int\n var g = [6]string{}\n for i = 0; i < 6; i++ {\n var s string\n fmt.Scan(&s)\n g[i] = s\n }\n var f bool\n f = false\n for k = 4; k > 0; k--{\n for i = 0; i < 6; i++ {\n for j = 0; j < 8; j++ {\n if a[i][j] == k && g[i][j] == \".\"[0]{\n f = true\n for z = 0; z < 6; z++ {\n for z1 = 0; z1 < 8; z1++ {\n if z == i && z1 == j{\n fmt.Printf(\"%c\", 'P')\n }else{\n fmt.Printf(\"%c\", g[z][z1])\n }\n }\n fmt.Println()\n }\n break\n }\n }\n if f{\n break\n }\n }\n if f{\n break\n }\n }\n}", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nvar(\n\tn int\t\t\t\t/*Number of students*/\n\tM int\t\t\t\t/*Maximum time*/\n\tt[110] int \t\t/*Students' time*/\n\tsum[110] int \t\t/*sum [0..i)*/\n\tbuffer[110] int \t/*used for sorting*/\n)\n\n\n\nfunc main(){\n\t//input\n\tfmt.Scanf(\"%d %d\\n\", &n, &M)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &t[i])\n\t}\n\n\tsum[0] = 0\n\tfor i := 1; i < n; i++ {\n\t\tsum[i] = sum[i - 1] + t[i - 1]\n\t}\n\tbuffer = sum\n\n\tfor i := 0; i < n; i++ {\t/*Next student*/\n\t\tans := 0\n\t\trequired := M - t[i]\n\t\tcurrent := sum[i]\n\t\tif current > required{\n\t\t\tcopy(buffer[0:i], t[0:i])\n\t\t\tsort.Ints(buffer[0:i])\n\t\t}\n\t\tfor current > required {\n\t\t\tans++\n\t\t\tcurrent -= buffer[i - ans] /*M > t[i]*/\n\t\t}\n\t\tfmt.Printf(\"%d \", ans)\n\t}\n}\n", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346"} {"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 mn := n\n if m < n {\n mn = m\n }\n if mn % 2 == 0 {\n fmt.Println(\"Malvika\")\n } else {\n fmt.Println(\"Akshat\")\n }\n}\n", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar A, B, C, D int\n\tfmt.Scan(&A, &B, &C, &D)\n\tA -= C\n\tB -= C\n\tD -= C\n\tD -= (A + B)\n\t// fmt.Printf(\"A:%d B:%d C:%d D:%d\\n\", A, B, C, D)\n\tif A < 0 || B < 0 || D < 1 {\n\t\tD = -1\n\t}\n\tfmt.Println(D)\n}\n", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce"} {"source_code": "package main \n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"regexp\"\n)\n\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\n\nfunc scanf(f string, a... interface{}){\n\tfmt.Fscanf(reader, f, a...)\n}\n\n\nfunc main() {\n\tvar n,m int \n\n\tscanf(\"%d %d \\n\", &n, &m)\n\n\tvar colorCode = regexp.MustCompile(`[C|M|Y]`)\n\tisColor := false\n\tfor i:=0; i 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", "src_uid": "77b5f83cdadf4b0743618a46b646a849"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc GCD(a,b int) int { if b == 0 { return a } else { return GCD(b,a%b) } }\nfunc LCM(a,b int) int { return (a/GCD(a,b))*b }\n\nfunc main() {\n var x,y,a,b int\n fmt.Scan(&x,&y,&a,&b)\n lcm := LCM(x,y)\n fmt.Println((b/lcm)-((a-1)/lcm))\n}\n", "src_uid": "c7aa8a95d5f8832015853cffa1374c48"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"os\"\n)\n\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\ntype V struct {\n\tP, Pchar, Link int\n\tNext, Walk [26]int\n}\n\nfunc (node V) String() string {\n\treturn fmt.Sprintf(\"p = %v, pchar = %v, link = %v\", node.P, node.Pchar, node.Link)\n}\n\nfunc CreateNode(p, pchar int) *V {\n\tv := &V{P:p, Pchar:pchar, Link:-1}\n\tfor i := 0; i < len(v.Next); i++ {\n\t\tv.Next[i], v.Walk[i] = -1, -1\n\t}\n\treturn v\n}\n\nfunc AddString(a string) {\n\tvar v int = 0\n\tfor i := 0; i < len(a); i++ {\n\t\tvar c int = int(a[i] - 'A')\n\t\tif tree[v].Next[c] == -1 {\n\t\t\ttree[size] = CreateNode(v, c)\n\t\t\ttree[v].Next[c] = size\n\t\t\tsize++\n\t\t}\n\t\tv = tree[v].Next[c]\n\t}\n}\n\nfunc Walk(v, c int) int {\n\tif tree[v].Walk[c] != -1 {\n\t\treturn tree[v].Walk[c]\n\t}\n\tif tree[v].Next[c] != -1 {\n\t\ttree[v].Walk[c] = tree[v].Next[c]\n\t}else {\n\t\tif v == 0 {\n\t\t\ttree[v].Walk[c] = 0\n\t\t}else {\n\t\t\ttree[v].Walk[c] = Walk(Getlink(v), c)\n\t\t}\n\t}\n\treturn tree[v].Walk[c]\n}\n\nfunc Getlink(v int) int {\n\tif tree[v].Link != -1 {\n\t\treturn tree[v].Link\n\t}\n\tif v == 0 || tree[v].P == 0 {\n\t\ttree[v].Link = 0\n\t}else {\n\t\ttree[v].Link = Walk(Getlink(tree[v].P), tree[v].Pchar)\n\t}\n\treturn tree[v].Link\n}\n\nfunc Dp(i, j, k int) int {\n\tif k == v {\n\t\treturn -oo\n\t}\n\tif i == n {\n\t\treturn 0\n\t}\n\tif j == m {\n\t\treturn 0\n\t}\n\n\tif dp[i][j][k] != -1 {\n\t\treturn dp[i][j][k]\n\t}\n\n\tvar ret int = -oo\n\tif a[i] == b[j] {\n\t\tvar next int = Walk(k, int(a[i] - 'A'))\n\t\t// if next != v {\n\t\tret = Max(ret, Dp(i + 1, j + 1, next) + 1)\t\n\t\t// }\n\t}\n\n\tret = Max(ret, Dp(i + 1, j, k))\n\tret = Max(ret, Dp(i, j + 1, k))\n\n\tdp[i][j][k] = ret\n\treturn ret\n}\n\nfunc Print(i, j, k int) {\n\tif i == n {\n\t\treturn\n\t}\n\tif j == m {\n\t\treturn\n\t}\n\tif a[i] == b[j] {\n\t\tvar ret, which int = Dp(i + 1, j, k), 0\n\t\tif ret < Dp(i, j + 1, k) {\n\t\t\tret, which = Dp(i, j + 1, k), 1\n\t\t}\n\t\tvar next int = Walk(k, int(a[i] - 'A'))\n\t\tif next != v {\n\t\t\tif ret <= Dp(i + 1, j + 1, next) {\n\t\t\t\tret, which = Dp(i + 1, j + 1, next), 2\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tif which == 0 {\n\t\t\tPrint(i + 1, j, k)\n\t\t}else if which == 1 {\n\t\t\tPrint(i, j + 1, k)\n\t\t}else {\n\t\t\tfmt.Fprint(out, string(a[i]))\n\t\t\tPrint(i + 1, j + 1, next)\n\t\t}\n\n\t}else {\n\t\tvar ret int = Dp(i + 1, j , k)\n\t\tif ret < Dp(i, j + 1, k) {\n\t\t\tPrint(i, j + 1, k)\n\t\t}else {\n\t\t\tPrint(i + 1, j, k)\n\t\t}\n\t}\n}\n\nconst oo = 1<<30\n\nvar n, m, v int\nvar a, b, c string\nvar size int\nvar tree [110]*V\n\nvar dp [][][]int\n\nfunc main() {\n\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\ta, b, c = Next(), Next(), Next()\n\tn, m, v = len(a), len(b), len(c)\n\ttree[size] = CreateNode(-1, -1)\n\tsize++\n\tAddString(c)\n\n\tdp = make([][][]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tdp[i] = make([][]int, m)\n\t\tfor j := 0; j < m; j++ {\n\t\t\tdp[i][j] = make([]int, v)\n\t\t\tfor k := 0; k < v; k++ {\n\t\t\t\tdp[i][j][k] = -1\n\t\t\t}\n\t\t}\n\t}\n\n\tvar ret int = Dp(0, 0, 0)\n\t// fmt.Fprintln(out, ret)\n\tif ret <= 0 {\n\t\tfmt.Fprintln(out, 0)\n\t}else {\n\t\tPrint(0, 0, 0)\n\t\tfmt.Fprintln(out);\n\t}\n}\n\nfunc Max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc Next() string{\n\tif !in.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn in.Text()\n}\n\nfunc NextInt() int{\n\tret, _ := strconv.Atoi(Next())\n\treturn ret\n}", "src_uid": "391c2abbe862139733fcb997ba1629b8"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tfmt.Println(6*(n*(n+1))/2 + 1)\n}\n", "src_uid": "c046895a90f2e1381a7c1867020453bd"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n\nfunc main() {\n\tvar K int\n\tfmt.Scanf(\"%d\", &K)\n\t\n\tcount := 0\n\ti := 0\n\tfor {\n\t\tj := i\n\t\tsum := 0\n\t\tfor j != 0 {\n\t\t\tsum += j % 10\n\t\t\tj /= 10\n\t\t}\n\t\t\n\t\tif sum == 10 {\n\t\t\tcount += 1\n\t\t\tif count == K {\n\t\t\t\tfmt.Printf(\"%d\", i)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\ti += 1\n\t}\n\n}\n", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math/rand\"\n\t\"os\"\n)\n\nconst INF = 1000000001\n\ntype Pair struct {\n\tfirst, second int\n}\n\nfunc sort(arr []int) []int {\n\tif len(arr) < 2 {\n\t\treturn arr\n\t}\n\tleft := 0\n\tright := len(arr) - 1\n\tpivot := rand.Int() % len(arr)\n\n\tarr[pivot], arr[right] = arr[right], arr[pivot]\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i] < arr[right] {\n\t\t\tarr[i], arr[left] = arr[left], arr[i]\n\t\t\tleft++\n\t\t}\n\t}\n\n\tarr[left], arr[right] = arr[right], arr[left]\n\n\tsort(arr[:left])\n\tsort(arr[left+1:])\n\treturn arr\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc solution(reader io.Reader, writer io.Writer) {\n\tvar n, a, b int64\n\tfmt.Fscanf(reader, \"%d\\n%d\\n%d\\n\", &n, &a, &b)\n\tfor i := int64(0); i <= n; i++ {\n\t\tif i * a <= n && (n - a * i) % b == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\tfmt.Println(i, (n - a * i) / b)\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\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}", "src_uid": "b031daf3b980e03218167f40f39e7b01"} {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nconst EPS = 1e-4\n\ntype P struct {\n x, y float64\n}\n\nfunc Scan() (p P) {\n fmt.Scanf(\"%f %f\\n\", &p.x, &p.y)\n return\n}\n\nfunc VectorProduct(a, b, c P) float64 {\n return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)\n}\n\nfunc ScalarProduct(a, b, c P) float64 {\n return (b.x - a.x) * (c.x - a.x) + (b.y - a.y) * (c.y - a.y)\n}\n\nfunc Sqr(a float64) float64 {\n return a * a\n}\n\nfunc Dist(a, b P) float64 {\n return math.Sqrt(Sqr(b.x - a.x) + Sqr(b.y - a.y))\n}\n\nfunc Sin(a, b, c P) float64 {\n return VectorProduct(a, b, c) / Dist(a, b) / Dist(a, c)\n}\n\nfunc OuterRadius(a, b, c P) float64 {\n return Dist(b, c) / math.Abs(Sin(a, b, c)) / 2\n}\n\nfunc Angle(a, b, c P) (ret float64) {\n ret = math.Abs(math.Asin(Sin(a, b, c)))\n if ScalarProduct(a, b, c) < -EPS { ret = math.Pi - ret }\n return\n}\n\nfunc GCD(a, b float64) float64 {\n for b > EPS {\n if a < b { a, b = b, a }\n a, b = b, a - b\n }\n return a\n}\n\nfunc main() {\n a, b, c := Scan(), Scan(), Scan()\n r := OuterRadius(a, b, c)\n aa, bb, cc := Angle(a, b, c), Angle(b, a, c), Angle(c, a, b)\n g := GCD(GCD(aa, bb), cc)\n n := math.Pi / g\n ret := n * Sqr(r) * math.Sin(2 * g) / 2\n fmt.Printf(\"%.6f\\n\", ret)\n}\n", "src_uid": "980f4094b3cfc647d6f74e840b1bfb62"} {"source_code": "package main\n\nimport (\n \"strconv\"\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n// var file, _ = os.Open(\"input.txt\")\n// var outfile, _ = os.Create(\"output.txt\")\n// var in = bufio.NewScanner(file)\n// var out = bufio.NewWriter(outfile)\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc next() string {\n if !in.Scan() {\n panic(\"Scan error\")\n }\n return in.Text()\n}\n\nfunc nextInt() int {\n ret, _ := strconv.Atoi(next())\n return ret\n}\n\nfunc nextFloat() float64 {\n ret, _ := strconv.ParseFloat(next(), 64)\n return ret\n}\n\nfunc main() {\n defer out.Flush()\n in.Split(bufio.ScanWords)\n n := nextInt()\n x := 1\n for x = 1; ; x++ {\n sum := 0;\n for l := 1; l <= x; l++ {\n sum += l * (l + 1) / 2\n }\n if sum > n {\n break;\n }\n }\n fmt.Fprintln(out, x - 1)\n}\n", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0"} {"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", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nconst (\n\tmod = 1000000007\n)\n\nfunc pow(n int, k int) int {\n\tif k == 0 {\n\t\treturn 1\n\t}\n\tres := pow(n, k>>1)\n\tres = int((int64(res) * int64(res)) % mod)\n\tif k&1 != 0 {\n\t\tres = int((int64(res) * int64(n)) % mod)\n\t}\n\treturn res\n}\n\nfunc solve(n int) int {\n\ta := pow(3, 3*n)\n\ta -= pow(7, n)\n\ta %= mod\n\tif a < 0 {\n\t\treturn a + mod\n\t}\n\treturn a\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tfmt.Println(solve(n))\n}\n", "src_uid": "eae87ec16c284f324d86b7e65fda093c"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var c,p,n,r int\n r=90\n fmt.Scan(&c)\n for i:=0; i15 {\n r=p+15\n break\n } else {\n p=n\n }\n }\n if 90-p>15 {\n r=p+15\n }\n fmt.Println(r)\n}", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27"} {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc validate(arr []int64, nSlots int, n int64, m int64) bool {\n length := len(arr)\n for i:= 0; i < length; i++ {\n for j:= i+1; j < length; j++ {\n if arr[i] == arr[j] {\n return false\n }\n }\n }\n var num int64\n for i:= 0; i < nSlots; i++ {\n num = num*7+arr[i]\n }\n if num >= n {\n return false\n }\n num = 0\n for i:=nSlots; i < length; i++ {\n num = num*7+arr[i]\n }\n if num >= m {\n return false\n }\n //fmt.Println(arr)\n return true\n}\n\nfunc try(arr []int64, depth int, cnt *int) {\n length := len(arr)\n if depth == length {\n if validate(arr, nSlots, n, m) {\n (*cnt)++\n }\n return\n }\n for i:=0; i < 7; i++ {\n arr[depth] = int64(i)\n try(arr, depth+1, cnt)\n }\n}\nvar n, m int64\nvar nSlots, mSlots int\nfunc main() {\n fmt.Scan(&n, &m)\n for i:=n-1; i > 0; {\n nSlots++\n i /= 7\n }\n if nSlots == 0 {\n nSlots = 1\n }\n for i:=m-1; i > 0; {\n mSlots++\n i /= 7\n }\n if mSlots == 0 {\n mSlots = 1\n }\n\n if mSlots + nSlots > 7 || mSlots + nSlots == 0 {\n fmt.Println(0)\n return\n }\n\n //fmt.Println(nSlots, mSlots)\n var arr []int64 = make([]int64, nSlots+mSlots)\n\n var cnt int\n try(arr, 0, &cnt)\n fmt.Println(cnt)\n //testValidate()\n}\n\nfunc testValidate() {\n arr := make([]int64, 3)\n arr[0] = 0\n arr[1] = 2\n arr[2] = 1\n fmt.Println(validate(arr, 2, 8, 2))\n}\n", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c"} {"source_code": "package main \nimport (\n\t \"fmt\"\n)\n\nfunc removeZeros(n int64) int64{\n\t var x int64\n\t for n > 0 {\n\t \t if n % 10 != 0 {\n\t \t \t x = x * 10 + n % 10\n\t \t }\n\t \t n /= 10\n\t } \n\n\t var result int64\n\t for x > 0 {\n\t \t result = result * 10 + x % 10\n\t \t x /= 10\n\t }\n\t return result\n\n}\nfunc main() {\n\t var a, b int64 \n\t fmt.Scan(&a)\n\t fmt.Scan(&b)\n\n\t c := a + b\n\n\t a = removeZeros(a)\n\t b = removeZeros(b)\n\t c = removeZeros(c)\n\n\t if a + b == c {\n\t \t fmt.Println(\"YES\")\n\t } else {\n\t \t fmt.Println(\"NO\")\n\t }\n}", "src_uid": "ac6971f4feea0662d82da8e0862031ad"} {"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\tt string\n\t)\n\t_, _ = fmt.Fscan(input, &t)\n\n\tdk := len(t) - 1\n\tmore := false\n\tk := dk / 2\n\tif dk % 2 != 0{\n\t\tmore = true\n\t}\n\tif !more{\n\t\tfor i, n := range t {\n\t\t\tif i == 0{\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif n == '1' {\n\t\t\t\tmore = true\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t}\n\t}\n\tif more{\n\t\tfmt.Println(k + 1)\n\t}else {\n\t\tfmt.Println(k)\n\t}\n}\n", "src_uid": "d8ca1c83b431466eff6054d3b422ab47"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc min(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc max(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\t\nfunc main() {\n\tvar x, y, m int64\n\tfmt.Scan(&x)\n\tfmt.Scan(&y)\n\tfmt.Scan(&m)\n\tmin := min(x, y)\n\tmax := max(x, y)\n\tif min >= m || max >= m {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\tif min + max <= min {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\titers := int64(0)\n\tfor max < m {\n\t\tdiff := max - min\n\t\tk := diff / max + 1\n\t\tmin, max = max, min + k * max\n\t\titers += k\n\t}\n\tfmt.Println(iters)\n}", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821"} {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\nfunc run(or io.Reader, ow io.Writer) {\r\n\tin := bufio.NewReader(or)\r\n\tout := bufio.NewWriter(ow)\r\n\tdefer out.Flush()\r\n\tconst P int64 = 1e9 + 7\r\n\tsolve := func() {\r\n\t\tvar n int64\r\n\t\tvar k int\r\n\t\tfmt.Fscan(in, &n, &k)\r\n\t\tvar ans int64 = 1\r\n\r\n\t\tfor i := 0; i < k; i++ {\r\n\t\t\tans = ans * n % P\r\n\t\t}\r\n\t\tfmt.Fprintln(out, ans)\r\n\r\n\t}\r\n\r\n\tvar T int\r\n\tfmt.Fscan(in, &T)\r\n\tfor o := 0; o < T; o++ {\r\n\t\tsolve()\r\n\t}\r\n\r\n}\r\n\r\nfunc main() { run(os.Stdin, os.Stdout) }\r\n", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nconst (\n\tSCANNER_BUF_SIZE = 2 << 20\n\n\tINF = int64(math.MaxInt64)\n\tMOD = 1e9 + 7\n)\n\nvar (\n\twriter *bufio.Writer\n\tscanner *bufio.Scanner\n)\n\nfunc init() {\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)\n}\n\nfunc printf(f string, a ...interface{}) {\n\tfmt.Fprintf(writer, f, a...)\n}\n\nfunc sint64() int64 {\n\tscanner.Scan()\n\tbb := scanner.Bytes()\n\ti := int64(0)\n\tif bb[0] == '-' {\n\t\tfor _, b := range bb[1:] {\n\t\t\ti *= 10\n\t\t\ti -= int64(b - '0')\n\t\t}\n\t\treturn i\n\t}\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += int64(b - '0')\n\t}\n\treturn i\n}\n\nfunc suint64() uint64 {\n\tscanner.Scan()\n\tbb := scanner.Bytes()\n\ti := uint64(0)\n\tfor _, b := range bb {\n\t\ti *= 10\n\t\ti += uint64(b - '0')\n\t}\n\treturn i\n}\n\nfunc sstring() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc gcd(a, b int64) int64 {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int64) int64 {\n\treturn a * b / gcd(a, b)\n}\n\nfunc abs(a int64) int64 {\n\tif a < 0 {\n\t\treturn a * -1\n\t}\n\treturn a\n}\n\nfunc min(a int64, rest ...int64) int64 {\n\tfor _, r := range rest {\n\t\tif r < a {\n\t\t\ta = r\n\t\t}\n\t}\n\treturn a\n}\n\nfunc max(a int64, rest ...int64) int64 {\n\tfor _, r := range rest {\n\t\tif r > a {\n\t\t\ta = r\n\t\t}\n\t}\n\treturn a\n}\n\ntype tide struct {\n\td int64 // delta\n\ti bool // increasing - false by default\n}\n\n// Next adjusts the tide level to the next most optimal value\n// Returns false if unable to do so\nfunc (t *tide) Next(currDepth int64, k, l int64) bool {\n\t// rest spot -> reset params\n\tif currDepth + k <= l {\n\t\tt.d = k\n\t\tt.i = false\n\t\treturn true\n\t}\n\n\t// tide decreasing -> check min\n\tif !t.i {\n\t\tt.d--\n\t\tif currDepth + t.d > l {\n\t\t\tt.d = l - currDepth\n\t\t}\n\t\tif t.d < 0 {\n\t\t\treturn false\n\t\t}\n\t\tif t.d == 0 {\n\t\t\tt.i = true\n\t\t}\n\t\treturn true\n\t}\n\n\t// tide increasing\n\tt.d++\n\tif currDepth + t.d > l {\n\t\treturn false\n\t}\n\tif t.d == k {\n\t\tt.i = false\n\t}\n\treturn true\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tt := sint64()\n\tfor ; t > 0; t-- {\n\t\tn := sint64()\n\t\tk := sint64()\n\t\tl := sint64()\n\t\td := make([]int64, n)\n\t\tfor i := range d {\n\t\t\td[i] = sint64()\n\t\t}\n\t\tprintf(\"%s\\n\", sol(d, n, k, l))\n\t}\n}\n\nfunc sol(d []int64, n, k, l int64) string {\n\tt := &tide{\n\t\td: k,\n\t\ti: false,\n\t}\n\tfor _, di := range d {\n\t\tif !t.Next(di, k, l) {\n\t\t\treturn \"No\"\n\t\t}\n\t}\n\treturn \"Yes\"\n}\n", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8"} {"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", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar k int\n\tfmt.Scan(&n, &k)\n\tarr := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&arr[i])\n\t}\n\n\tc := arr[k-1]\n\ti := 0\n\tans := 0\n\tfor i= c&&arr[i]>0 {\n\n\t\tans++\n\t\ti++\n\t}\n\tfmt.Println(ans)\n\n}\n", "src_uid": "193ec1226ffe07522caf63e84a7d007f"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nconst (\n\tmod = 998244353\n\ti2 = (mod + 1) / 2\n)\n\nfunc main() {\n\tn := 0\n\tfmt.Scanf(\"%d\", &n)\n\tf, f1 := uint32(1), uint32(0)\n\tfor i := 1; i < n; i++ {\n\t\tf, f1 = (f+f1)%mod, f\n\t}\n\n\tfmt.Printf(\"%d\\n\", (uint64(f)*exp(i2, n))%mod)\n}\n\nfunc exp(a uint64, p int) (r uint64) {\n\tr = 1\n\tfor ; p > 0; p /= 2 {\n\t\tif p%2 == 1 {\n\t\t\tr = (a * r) % mod\n\t\t}\n\t\ta = (a * a) % mod\n\t}\n\treturn r\n}\n", "src_uid": "cec37432956bb0a1ce62a0188fe2d805"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tif solve() {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc solve() bool {\n\tvar n, R, r float64\n\tfmt.Scan(&n, &R, &r)\n\tif r > R {\n\t\treturn false\n\t}\n\tif 2*r > R {\n\t\treturn n == 1\n\t}\n\treturn math.Pi/math.Asin(r/(R-r))+1e-9 >= n\n}\n", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\n\ta := 1\n\tb := n\n\n\tfor x := 1; x*x <= n; x++ {\n\t\tif n%x == 0 {\n\t\t\ta = x\n\t\t\tb = n / x\n\t\t}\n\t}\n\n\tfmt.Println(a, b)\n}", "src_uid": "f52af273954798a4ae38a1378bfbf77a"} {"source_code": "package main\n\nimport (\n\t\"io/ioutil\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\tvar a1,b1,c1,a2,b2,c2 int\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &a1, &b1, &c1)\n\tfmt.Fscanf(reader, \"%d %d %d\", &a2, &b2, &c2)\n\n\tif a1 * b2 - a2 * b1 != 0 {\n\t\tfmt.Printf(\"1\")\n\t} else if a1 * c2 - a2 * c1 == 0 && b1 * c2 - b2 * c1 == 0{\n\t\tif a1 == 0 && a2 == 0 && b1 == 0 && b2 == 0 && (c1 != 0 || c2 != 0) {\n\t\t\tfmt.Printf(\"0\")\n\t\t} else {\n\t\t\tfmt.Printf(\"-1\")\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"0\")\n\t}\n\treturn\n}", "src_uid": "c8e869cb17550e888733551c749f2e1a"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc bs(n, k int) int {\n //Find the answer\n var lo, hi, mid, ans int = 0, n, 0, 0\n for lo <= hi {\n mid = (lo+hi)/2\n left := k-2*mid\n if (n-mid)*3 <= left {\n ans = mid\n hi = mid-1\n } else {\n lo = mid+1\n }\n }\n return ans\n}\n\nfunc main() {\n var n, k int\n \n fmt.Scan(&n, &k)\n \n fmt.Println(bs(n, k))\n}", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8"} {"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", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var m, n uint64\n fmt.Scan(&n, &m)\n if n > 32 {\n fmt.Print(m)\n return\n }\n var exp uint64 = 1\n for i:=uint64(0); i= n {\n\t\t\tmx = i\n\t\t}\n\t}\n\n\tfmt.Println(mx)\n}\n", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc genPrime(max int) []int {\n\tprimes := make([]int, 0)\n\tsieve := make([]bool, max+1)\n\tfor i := 2; i < max+1; i++ {\n\t\tif sieve[i] == true {\n\t\t\tcontinue\n\t\t}\n\t\tprimes = append(primes, i)\n\t\tfor j := 2; i*j < max+1; j++ {\n\t\t\tsieve[i*j] = true\n\t\t}\n\t}\n\treturn primes\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tk, n := 0, 0\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\n\t\tfmt.Sscanf(line, \"%d %d\", &n, &k)\n\n\t\tprimes := genPrime(n)\n\n\t\tfor i := 0; i < len(primes); i++ {\n\t\t\ttestNum := primes[i]\n\t\t\tfor j := 0; j < len(primes)-1; j++ {\n\t\t\t\tif testNum-1-primes[j] == primes[j+1] {\n\t\t\t\t\tk -= 1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif k <= 0 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d"} {"source_code": "package main\r\n \r\nimport \"fmt\"\r\n \r\nfunc main() {\r\n \r\n var n int\r\n fmt.Scanln(&n)\r\n fmt.Println((n-1) % 9 + 1)\r\n}", "src_uid": "477a67877367dc68b3bf5143120ff45d"} {"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 b) {\n\t\treturn a\n\t}\n\treturn b\n}\n \nfunc min(a, b int) int {\n\tif(a= 0) && (cnt < k); i-- {\n cnt += a[i]\n ans++\n }\n if cnt < k { fmt.Println(-1) } else { fmt.Println(ans) }\n}\n", "src_uid": "59dfa7a4988375febc5dccc27aca90a8"} {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var n, k, diploma, certificates, noWinners int64\n fmt.Scanf(\"%d %d\", &n, &k)\n\n diploma = int64(math.Floor(float64(n) / float64(2 * (k + 1))))\n certificates = k * diploma\n noWinners = n - (diploma + certificates)\n\n fmt.Printf(\"%d %d %d\\n\", diploma, certificates, noWinners)\n}\n", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc isValid(nums []int, start, end int) bool {\n\treturn (start-end)%2 == 0 && nums[start]%2 == 1 && nums[end]%2 == 1\n}\n\nfunc main() {\n\tvar t int\n\tfmt.Scanf(\"%d\\n\", &t)\n\n\tnums := make([]int, t)\n\tfor i := 0; i < t; i++ {\n\t\tfmt.Scanf(\"%d\", &nums[i])\n\t}\n\n\tif isValid(nums, 0, len(nums)-1) {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db"} {"source_code": "package main\n\nimport (\n \"fmt\"\n \"strings\"\n //\"math\"\n)\n\nfunc main() {\n var str string\n fmt.Scanln(&str)\n str += \"A\"\n res, cur := 1, 1\n for i := 0; i < len(str); i++ {\n if strings.IndexAny(string(str[i]), \"AEIOUY\") == -1 {\n cur++\n } else {\n if cur > res {\n res = cur\n }\n cur = 1\n }\n }\n fmt.Println(res)\n}\n", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee"} {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main(){\n var target string\n\t_, err := fmt.Scanln(&target)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n var count, first, second int\n\t_, err = fmt.Scanln(&count)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n for i:=0; i < count; i++{\n var word string\n\t\t_, err = fmt.Scanln(&word)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\n\t\tif word == target {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n hasFirst := word[0] == target[1]\n hasSecond := word[1] == target[0]\n\n if hasFirst{\n first++\n }\n if hasSecond{\n second++\n }\n }\n if first > 0 && second > 0 {\n fmt.Println(\"YES\")\n }else{\n fmt.Println(\"NO\")\n}\n}\n", "src_uid": "cad8283914da16bc41680857bd20fe9f"} {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tscanner.Scan()\n\ta, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\tfor i := int64(1); ; i++ {\n\t\ts := strconv.FormatInt(a+i, 10)\n\t\tfor _, ch := range s {\n\t\t\tif ch == '8' {\n\t\t\t\twriter.WriteString(fmt.Sprintf(\"%d\\n\", i))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}\n", "src_uid": "4e57740be015963c190e0bfe1ab74cb9"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nconst mod = 1000000007\n\nvar dp [2001][2001]int\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\tfor i := 1; i <= n; i++ {\n\t\tdp[1][i] = 1\n\t}\n\tfor i := 1; i < k; i++ {\n\t\tfor j := 1; j <= n; j++ {\n\t\t\tfor k := j; k <= n; k += j {\n\t\t\t\tdp[i + 1][k] = (dp[i + 1][k] + dp[i][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\tans := 0\n\tfor i := 1; i <= n; i++ {\n\t\tans = (ans + dp[k][i]) % mod\n\t}\n\tfmt.Println(ans)\n}\n", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa"} {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"fmt\"\n \"strings\"\n \"strconv\"\n )\n \nfunc main() {\n var a [100]int\n stin := bufio.NewScanner(os.Stdin)\n stin.Scan()\n n,_ := strconv.Atoi(stin.Text())\n stin.Scan()\n ss := strings.Fields(stin.Text())\n for i := 0; i < n; i++ {\n a[i],_ = strconv.Atoi(ss[i])\n }\n startPos := 0\n for i := 0; i < n; i++ {\n if a[i] == 1 {\n startPos = i\n break\n }\n }\n if startPos == 0 && a[0] == 0 {\n fmt.Printf(\"%d\", 0)\n return\n }\n finishPos := n-1\n for i := n-1; i >= 0; i-- {\n if a[i] == 1 {\n finishPos = i\n break\n }\n }\n// fmt.Printf(\"start = %d finish = %d\\n\", startPos, finishPos)\n if startPos == finishPos || startPos+1 == finishPos {\n fmt.Printf(\"%d\", 1)\n return\n }\n var totalCount uint64 = 1\n var previous1 int = startPos\n for i := startPos + 1; i <= finishPos; i++ {\n// fmt.Printf(\"totalCount at start = %d \", totalCount)\n// fmt.Printf(\"a[%d] = %d\\n\", i, a[i])\n if a[i] == 1 {\n totalCount *= uint64(i - previous1)\n previous1 = i\n }\n// fmt.Printf(\"totalCount at finish = %d\\n\", totalCount)\n }\n fmt.Printf(\"%d\", totalCount)\n}\n", "src_uid": "58242665476f1c4fa723848ff0ecda98"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(x int64, a int64, b int64, y int64) bool {\n if a == 0 {\n return x == y\n } else {\n var c = a/b\n return x == y || \n check(x-c,c,b,y) || \n check(x,c,b,y) || \n check(x+c,c,b,y)\n }\n} \n\nfunc main() {\n \n var w,m int64\n fmt.Scanf(\"%v %v\\n\", &w, &m)\n \n if w <= 3 { \n fmt.Printf(\"YES\\n\")\n } else {\n var i,x,c int64 = 1,1,0\n for x < m && c <= 100 {\n i *= w\n x += i\n c++\n }\n if check(i,i,w,m) {\n fmt.Printf(\"YES\\n\") \n } else {\n fmt.Printf(\"NO\\n\")\n }\n }\n}\n", "src_uid": "a74adcf0314692f8ac95f54d165d9582"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst div int64 = 1000000007\n\nfunc cucl(n int) int64 {\n\tvar a, b int64\n\ta = 2\n\tb = 4\n\tif n == 1 {\n\t\treturn a\n\t}\n\n\tif n == 2 {\n\t\treturn b\n\t}\n\n\tfor i := 3; i <= n; i++ {\n\t\ta, b = b%div, (a+b)%div\n\t}\n\n\treturn b\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n, m int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &m)\n\tfmt.Printf(\"%d\\n\", (cucl(n)+cucl(m)+div-2)%div)\n}\n", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b"} {"source_code": "// 388A-mic\npackage main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n, cou int\n fmt.Scan(&n)\n a := make([]int, n)\n for i := range a {\n fmt.Scan(&a[i])\n }\n f := 1\n sort.Sort(sort.IntSlice(a))\n for i := 0; i < n; i++ {\n f = 1\n if a[i] != -1 {\n for j := i + 1; j < n; j++ {\n if a[j] >= f && a[j] != -1 {\n f++\n a[j] = -1\n }\n }\n cou++\n }\n }\n fmt.Println(cou)\n}\n", "src_uid": "7c710ae68f27f140e7e03564492f7214"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar r, x, y, nx, ny int64\n\tfmt.Scanf(\"%d %d %d %d %d\", &r, &x, &y, &nx, &ny)\n\ts := (x-nx)*(x-nx) + (y-ny)*(y-ny)\n\tr *= 2\n\tvar i int64\n\tfor i = 0; i*i*r*r < s; i++ {\n\n\t}\n\tfmt.Println(i)\n}\n", "src_uid": "698da80c7d24252b57cca4e4f0ca7031"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar line string\n\tfmt.Scan(&line)\n\n\twords := strings.Split(line, \"WUB\")\n\thasPrev := false\n\tfor _, word := range words {\n\t\tif len(word) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif hasPrev {\n\t\t\tfmt.Print(\" \")\n\t\t} else {\n\t\t\thasPrev = true\n\t\t}\n\t\tfmt.Print(word)\n\t}\n}\n", "src_uid": "edede580da1395fe459a480f6a0a548d"} {"source_code": "package main\n\nimport (\n\"fmt\"\n\"os\"\n)\nfunc main(){\n var s string\n fmt.Scan(&s)\n var chars = []byte(s) \n var output string\n var n int = len(chars)\n for i:=0; i < n ; {\n if chars[i] == '.' {\n output+= \"0\"\n i+=1\n } else if i+1 < n && chars[i] == '-' {\n if chars[i+1] == '.' {\n i+=2 \n output+= \"1\"\n } else if chars[i+1] == '-' {\n output += \"2\"\n i+=2\n }\n }else {\n i+=1\n }\n}\nfmt.Fprintf(os.Stdout,\"%s\",output)\n}\n", "src_uid": "46b5a1cd1bd2985f2752662b7dbb1869"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a,b int) int { if a < b { return a } else { return b } }\n\nfunc main() {\n var n,k int\n fmt.Scan(&n,&k)\n a := make([]int,n)\n for i := 0; i < n; i++ { fmt.Scan(&a[i]) }\n ans := 0\n for i := 0; i < k; i++ {\n one, two := 0, 0\n for j := 0; j < n/k; j++ {\n if a[i+(j*k)] == 1 { one++ } else { two++ }\n }\n ans += min(one,two)\n }\n fmt.Println(ans)\n}\n", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, m int\n\n\tfmt.Scan(&n, &m)\n\tvar c int = 1\n\tfor i := 1; i <= int(math.Min(float64(n), float64(m))); i++ {\n\t\tc = c * i\n\t}\n\tfmt.Println(c)\n}\n", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6"} {"source_code": "\ufeffpackage main\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n,m,d int\n\tfmt.Scan(&n,&m)\n\tnum := make([]int,m)\n\n\tfor i:=0;i 0 {\r\n\t\tval := q[0]\r\n\t\tq = q[1:]\r\n\r\n\t\ts := strconv.FormatInt(val, 10)\r\n\t\tif int64(len(s)) >= n {\r\n\t\t\tfmt.Fprintln(w, mp[val])\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tfor _, v := range s {\r\n\t\t\tv := int64(v - '0')\r\n\t\t\tif v <= 1 {\r\n\t\t\t\tcontinue\r\n\t\t\t}\r\n\t\t\t_, ok := mp[val*v]\r\n\t\t\tif ok {\r\n\t\t\t\tcontinue\r\n\t\t\t}\r\n\t\t\tmp[val*v] = mp[val] +1\r\n\t\t\tq = append(q, val*v)\r\n\t\t}\r\n\t}\r\n\r\n\tfmt.Fprintln(w, -1)\r\n}", "src_uid": "cedcc3cee864bf8684148df93804d029"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar t, s, x int\n\tfmt.Scan(&t, &s, &x)\n\n\tif t == x {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfor k := t + s; k <= x; k += s {\n\t\tif k == x || k + 1 == x {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc getCnt(n int64) int64 {\n var sum int64\n for k:= int64(2); k*k*k <= n; k++ {\n sum += n/(k*k*k)\n }\n return sum\n}\n\nfunc main() {\n var m int64\n fmt.Scan(&m)\n\n var lo, hi int64\n lo = 1\n hi = 9223372036854775807\n for lo+1 < hi {\n mid := (lo+hi)/2\n sum := int64(0)\n for k:= int64(2); k*k*k <= mid; k++ {\n sum += mid/(k*k*k)\n }\n if sum >= m {\n hi = mid\n } else {\n lo = mid\n }\n }\n hiCnt := getCnt(hi)\n if hiCnt == m {\n fmt.Println(hi)\n } else {\n fmt.Println(-1)\n }\n}\n", "src_uid": "602deaad5c66e264997249457d555129"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc abs(x int) int{\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}\n\n\nfunc main() {\n\tvar x1, y1, x2, y2, x, y int\n\tfmt.Scanf(\"%v%v%v%v\\n%v%v\", &x1, &y1, &x2, &y2, &x, &y)\n\tdx := abs(x2 - x1)\n\tdy := abs(y2 - y1)\n\tresult := \"YES\"\n\tif dx % x != 0 || dy % y != 0 || abs(dx / x - dy / y) % 2 == 1{\n\t\tresult = \"NO\"\n\t}\n\tfmt.Println(result)\n}", "src_uid": "1c80040104e06c9f24abfcfe654a851f"} {"source_code": "\ufeffpackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, x, y int\n\tfmt.Scan(&n, &m)\n\tif n > m {\n\t\tx = n\n\t}else{\n\t\tx = m\n\t}\n\n\tif n < m {\n\t\ty = n\n\t}else{\n\t\ty = m\n\t}\n\n\tfmt.Print( x-1, y)\n}\n", "src_uid": "c8378e6fcaab30d15469a55419f38b39"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nfunc ReadStr() string{\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc ReadInt(x int) (res int) {\n\tscanner.Scan()\n\n\tn,err := strconv.Atoi(scanner.Text())\n\tres = n\n\tif err != nil{\n\t\tpanic(err)\n\t}\n\treturn\n}\n\ntype building struct\n{\n\ta , b ,c int\n}\n\nfunc min(a,b int) (res int) {\n\tif(a < b){\n\t\tres = a\n\t}else{\n\t\tres = b\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar n,h,m int\n\tfmt.Scan(&n)\n\tfmt.Scan(&h)\n\tfmt.Scan(&m)\n\tbl := make([]int,n + 1,n + 1)\n\tfor i := 1 ; i <= n ;i++{\n\t\tbl[i] = 100\n\t}\n\tvar x1,x2,x3 int\n\tfor i := 0 ; i < m ;i ++{\n\t\tfmt.Scan(&x1)\n\t\tfmt.Scan(&x2)\n\t\tfmt.Scan(&x3)\n\t\tfor i := x1; i <= x2 ; i++{\n\t\t\tbl[i] = min(bl[i],x3);\n\t\t}\n\n\t}\n\tvar ans int = 0\n\tfor i := 1 ;i <= n ;i ++{\n\t\tif(bl[i] == 100){\n\t\t\tans += h * h\n\t\t}else{\n\t\t\tans += bl[i] * bl[i];\n\t\t}\n\t}\n\tfmt.Println(ans)\n\n\n\n}\n", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc main() {\n\tconst max_distance int = 20000\n\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tvar is_at_np bool = true\n\tvar is_at_sp bool = false\n\tvar distance_from_np int = 0\n\tvar ok bool = true\n\n\treader := bufio.NewReader(os.Stdin)\n\tfor i := 0; i < n; 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 if ok {\n\t\t\tvar direction byte\n\t\t\tamount := 0\n\t\t\tfor j := 0; j < len(s) && s[j] != '\\r' && s[j] != '\\n'; j++ {\n\t\t\t\tif s[j] == ' ' {\n\t\t\t\t\tdirection = s[j+1]\n\t\t\t\t\tbreak\n\t\t\t\t} else {\n\t\t\t\t\tamount *= 10\n\t\t\t\t\tamount += int(s[j] - '0')\n\t\t\t\t}\n\t\t\t}\n\t\t\tif is_at_np && direction != 'S' {\n\t\t\t\tok = false\n\t\t\t\tbreak\n\t\t\t} else if is_at_sp && direction != 'N' {\n\t\t\t\tok = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif direction == 'S' {\n\t\t\t\tdistance_from_np += amount\n\t\t\t\tis_at_np = false\n\t\t\t\tif distance_from_np == max_distance {\n\t\t\t\t\tis_at_sp = true\n\t\t\t\t} else if distance_from_np > max_distance {\n\t\t\t\t\tok = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else if direction == 'N' {\n\t\t\t\tdistance_from_np -= amount\n\t\t\t\tis_at_sp = false\n\t\t\t\tif distance_from_np == 0 {\n\t\t\t\t\tis_at_np = true\n\t\t\t\t} else if distance_from_np < 0 {\n\t\t\t\t\tok = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif ok && distance_from_np == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "src_uid": "11ac96a9daa97ae1900f123be921e517"} {"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", "src_uid": "f98168cdd72369303b82b5a7ac45c3af"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tn,p:=0,0\n\tfmt.Scanln(&n,&p)\n\tfor i := 1; i<=64; i++ {\n\t\tfuck:=n-p*i\n\t\t\ts:=fmt.Sprintf(\"%b\",fuck)\n\t\t\tans:=0\n\t\t\tfor i := 0; i < len(s); i++ {\n\t\t\t\tif s[i]=='1'{\n\t\t\t\t\tans++\n\t\t\t}\n\t\t\t}\n\t\t\t//fmt.Println(fuck,s,ans,i)\n\t\t\tif ans<=i&&i<=n-p*i{\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn\n\t\t\t}\n\n\t}\n\tfmt.Println(-1)\n\n}", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8"} {"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", "src_uid": "24e2f10463f440affccc2755f4462d8a"} {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"math\"\n)\n\nvar (\n in *bufio.Reader\n out *bufio.Writer\n)\n\nfunc main() {\n in = bufio.NewReader(os.Stdin)\n out = bufio.NewWriter(os.Stdout)\n var b int64\n fmt.Fscanln(in, &b)\n var count int64 = 0\n for i:=int64(1);i<=int64(math.Sqrt(float64(b)));i++ {\n if (b%i == 0) {\n if (i*i == b) {\n count++\n } else {\n count+=2\n }\n }\n }\n fmt.Println(count)\n}\n", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1"} {"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) || (a*b <= x) || (a/b == x) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfmt.Println(a, b)\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n", "src_uid": "883f67177474d23d7a320d9dbfa70dd3"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tvar sum int64 = n * (n + 1) / 2\n\tfmt.Print(sum % 2)\n}\n", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9"} {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var zero2four = [5]string{\"-OOOO\", \"O-OOO\", \"OO-OO\", \"OOO-O\", \"OOOO-\"}\n var num int\n fmt.Scan(&num)\n if num == 0 {\n fmt.Printf(\"O-|\" + zero2four[0])\n } else {\n for num != 0 {\n var div int = num % 10\n if div >= 5 {\n fmt.Print(\"-O|\")\n } else {\n fmt.Print(\"O-|\")\n }\n fmt.Printf(\"%s\\n\", zero2four[div % 5])\n num /= 10\n }\n }\n}", "src_uid": "c2e3aced0bc76b6484360563355d23a7"} {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF702D(in io.Reader, out io.Writer) {\n\tvar d, k, a, b, t int64\n\tFscan(in, &d, &k, &a, &b, &t)\n\tans := b * d\n\tfor _, x := range []int64{k * ((d - 1) / k), k, d} {\n\t\tif 0 < x && x <= d {\n\t\t\tif v := a*x + ((x-1)/k)*t + (d-x)*b; v < ans {\n\t\t\t\tans = v\n\t\t\t}\n\t\t}\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF702D(os.Stdin, os.Stdout) }\n", "src_uid": "359ddf1f1aed9b3256836e5856fe3466"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tconst cf = \"CODEFORCES\"\n\tvar s string\n\tfmt.Scan(&s)\n\tif len(s) < len(cf) {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tb := 0\n\tfor i := range cf {\n\t\tif s[i] != cf[i] {\n\t\t\tbreak\n\t\t}\n\t\tb++\n\t}\n\te := 0\n\tfor i := range cf {\n\t\tif s[len(s)-1-i] != cf[len(cf)-1-i] {\n\t\t\tbreak\n\t\t}\n\t\te++\n\t}\n\tif b+e >= len(cf) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n", "src_uid": "bda4b15827c94b526643dfefc4bc36e7"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\ntype Int64Slice []int64\n\nfunc (slice Int64Slice) Len() int { return len(slice) }\nfunc (slice Int64Slice) Less(i, j int) bool { return slice[i] < slice[j] }\nfunc (slice Int64Slice) Swap(i, j int) { slice[i], slice[j] = slice[j], slice[i] }\n\nvar usr1 [20]int\nvar usr2 [20]int\n\nvar n, m int\nvar val [2][30]int\n\nfunc guess(v int) int {\n\tret := 0\n\tfor i := 0; i < n; i++ {\n\t\tif v == val[0][i*2] || v==val[0][i*2+1] {\n\t\t\tfor j := 0; j < m; j++ {\n\t\t\t\tif v == val[1][j*2] || v==val[1][j*2+1] {\n // fmt.Printf(\"v:%v %v - %v\\n\",v,i,j)\n\t\t\t\t\tif \n (val[0][i*2] == val[1][j*2] && val[0][i*2+1] == val[1][j*2+1])|| (val[0][i*2] == val[1][j*2+1] && val[0][i*2+1] == val[1][j*2]){\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (usr1[i] == 0 || usr1[i] == v) && (usr2[j] == 0 || usr2[j] == v) {\n\t\t\t\t\t\t\tusr1[i] = v\n\t\t\t\t\t\t\tusr2[j] = v\n\t\t\t\t\t\t\tret = v\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn -1\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn, m = ReadInt32(), ReadInt32()\n\n\tfor i := 0; i < n; i++ {\n\t\tval[0][i*2] = ReadInt32()\n\t\tval[0][i*2+1] = ReadInt32()\n\t}\n\tfor i := 0; i < m; i++ {\n\t\tval[1][i*2] = ReadInt32()\n\t\tval[1][i*2+1] = ReadInt32()\n\t}\n\n\t// 1 zu pei 1 -> res\n\tans := -1\n\tfor i := 1; i < 10; i++ {\n\t\tret := guess(i)\n\t\tif ret == -1 {\n\t\t\tfmt.Printf(\"-1\\n\")\n\t\t\treturn\n\t\t}\n if ret == 0 {\n continue\n }\n\t\tif ans == -1 {\n\t\t\tans = ret\n\t\t} else {\n\t\t\tans = 0\n\t\t}\n\t}\n\tfmt.Printf(\"%v\\n\", ans)\n\n\t// quan pei 1 -> 0\n\n\t// else -1\n\n}\n\nfunc Demo() {\n\tvar n, m int64 = ReadInt64(), ReadInt64()\n\tPrintInt64s(n, m)\n\twriter.WriteByte('\\n')\n\tslice := []int64{1, 2, 3, 4, 5}\n\tPrintInt64s(slice...)\n\n\t// sortDemo\n\t//slice := []int64{5, 3, 4, 2, 1}\n\tsort.Sort(Int64Slice(slice))\n\n\t//s := strconv.FormatBool(true)\n\t//s := strconv.FormatFloat(3.1415, 'E', -1, 64)\n\t//s := strconv.FormatInt(-42, 16)\n\t//s := strconv.FormatUint(42, 16)\n\n}\n\nfunc Min(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MinInt(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MinFloat64(a float64, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxInt64(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxInt(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxFloat64(a float64, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc ReadInt64() int64 {\n\tscanner.Scan()\n\tans, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn ans\n}\n\nfunc ReadFloat64() float64 {\n\tscanner.Scan()\n\tans, _ := strconv.ParseFloat(scanner.Text(), 64)\n\treturn ans\n}\n\nfunc PrintInt64s(ints ...int64) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(int(value)))\n\t\twriter.WriteByte(' ')\n\t}\n}\n", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\treadInt()\n\tm := readInt()\n\tk := readInt() - 1\n\n\tcolumn := (k) / (m * 2)\n\trow := (k % (m * 2)) / 2\n\trow1 := (k % (m * 2)) % 2\n\tfmt.Printf(\"%d \", column+1)\n\tfmt.Printf(\"%d \", row+1)\n\tif row1 == 0 {\n\t\tfmt.Println(\"L\")\n\t} else {\n\t\tfmt.Println(\"R\")\n\t}\n}\n\nfunc getStats(str string) map[byte]int {\n\tstat := map[byte]int{}\n\tfor _, v := range str {\n\t\tstat[byte(v)]++\n\t}\n\treturn stat\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn, k := 0, 0\n\tfmt.Fscanf(in, \"%d %d\\n\", &n, &k)\n\tans := -1\n\tfor i := 1; i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\ta := i\n\t\t\tb := n / i\n\t\t\tif b >= k {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tx := a*k + b\n\t\t\tif x < ans || ans == -1 {\n\t\t\t\tans = x\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", ans)\n\treturn\n}", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57"} {"source_code": "// A. Maximum in Table\n/*\nAn n\u2009\u00d7\u2009n table a is defined as follows:\n\n The first row and the first column contain ones, that is:\n\t\t\tai,\u20091\u2009=\u2009a1,\u2009i\u2009=\u20091 for all i\u2009=\u20091,\u20092,\u2009...,\u2009n.\n Each of the remaining numbers in the table is equal to the sum of the\n\t\t\tnumber above it and the number to the left of it. In other words,\n\t\t\tthe remaining elements are defined by the formula\n\t\t\tai,\u2009j\u2009=\u2009ai\u2009-\u20091,\u2009j\u2009+\u2009ai,\u2009j\u2009-\u20091.\n\nThese conditions define all the values in the table.\n\nYou are given a number n. You need to determine the maximum value in the\nn\u2009\u00d7\u2009n table defined by the rules above.\n\nInput\nThe only line of input contains a positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u200910) \u2014\nthe number of rows and columns of the table.\n\nOutput\nPrint a single line containing a positive integer m \u2014\nthe maximum value in the table.\n\nExamples\nInput\n1\n\nOutput\n1\n\nInput\n5\n\nOutput\n70\n\nNote\nIn the second test the rows of the table look as follows:\n{1,\u20091,\u20091,\u20091,\u20091},\n{1,\u20092,\u20093,\u20094,\u20095},\n{1,\u20093,\u20096,\u200910,\u200915},\n{1,\u20094,\u200910,\u200920,\u200935},\n{1,\u20095,\u200915,\u200935,\u200970}.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\tn, _ := strconv.Atoi(strings.TrimSpace(input))\n\tfmt.Print(sol509A(n, n))\n}\n\nfunc sol509A(r, c int) int {\n\tif r == 1 || c == 1 {\n\t\treturn 1\n\t}\n\treturn sol509A(r-1, c) + sol509A(r, c-1)\n}\n", "src_uid": "2f650aae9dfeb02533149ced402b60dc"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, result int\n\tfmt.Scan(&n)\n\tfor ; n > 0; n-- {\n\t\tfmt.Scan(&a)\n\t\tif a > 0 {\n\t\t\tresult += a\n\t\t} else {\n\t\t\tresult -= a\n\t\t}\n\t}\n\tfmt.Print(result)\n}\n", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5"} {"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"os\"\n\t\"io/ioutil\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\tvar l, d, v, g, r int\n\tfmt.Fscanf(reader, \"%d %d %d %d %d\", &l, &d, &v, &g, &r)\n\tt := float64(d) / float64(v)\n\ttLight := float64(int(t) % (g + r)) + t - float64(int(t))\n\tif tLight < float64(g) {\n\t\tfmt.Printf(\"%.7f\", float64(l)/float64(v))\n\t} else {\n\t\tfmt.Printf(\"%.7f\", float64(l)/float64(v) + float64(g + r) - tLight)\n\t}\n\t\n}", "src_uid": "e4a4affb439365c843c9f9828d81b42c"} {"source_code": "package main\nimport \"fmt\"\nconst MAX int64 = 1e7\nconst MOD int64 = 1e9+7\nvar isgood [MAX]bool\nfunc Max(a, b int64) int64 {\n\tif (a < b) {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc Init(a, b, n int64) {\n\tvar k int64\n\tfor k = 0; k < MAX; k++ { isgood[k] = true }\n\tfor k = 1; k <= Max(a,b) * n; k++ {\n\t\tp := k\n\t\tfor p > 0 {\n\t\t\tif p % 10 != a && p % 10 != b {\n\t\t\t\tisgood[k] = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tp /= 10\n\t\t}\n\t}\n}\n\nfunc EE(a, b int64) int64 {\n\tvar (\n\t\tr=a%b\n\t\tx0 int64=1\n\t\ty0 int64=0\n\t\tx1 int64=0\n\t\ty1 int64=1\n\t\tmod=b\n\t)\n\tfor r > 0 {\n\t\tf:=a/b\n\t\ttx:=x0-f*x1\n\t\tty:=y0-f*y1\n\t\tx0=x1\n\t\ty0=y1\n\t\tx1=tx\n\t\ty1=ty\n\t\ta=b\n\t\tb=r\n\t\tr=a%b\n\t}\n\treturn (x1%mod+mod)%mod\n}\n\nfunc main() {\n\tvar a,b,n int64\n\tfmt.Scanf(\"%d%d%d\",&a,&b,&n)\n\tInit(a,b,n)\n\tvar (\n\t\tchoose int64=1\n\t\tx int64=0\n\t\ty int64\n\t)\n\tcnt := make(map[int64]int64)\n\tfor x <= n {\n\t\ty=n-x\n\t\ts:=a*x+b*y\n\t\tif isgood[s] { cnt[s]=(cnt[s]+choose)%MOD }\n\t\tchoose=((choose*(n-x))%MOD)*EE(x+1,MOD)%MOD\n\t\tx++\n\t}\n\tvar ans int64 = 0\n\tfor k,v := range cnt {\n\t\tif isgood[k] { ans = (ans + v) % MOD }\n\t}\n\tfmt.Println(ans)\n}\n", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x1, x2, x3 int\n\tfmt.Scanf(\"%d%d%d\", &x1, &x2, &x3)\n\tmin := Min(Min(x1, x2), x3)\n\tmax := Max(Max(x1, x2), x3)\n\n\tfmt.Println(max - min)\n}\n\nfunc Max(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(a int, b int) int {\n\tif a > b {\n\t\treturn b\n\t} else {\n\t\treturn a\n\t}\n}", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319"} {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"fmt\"\n \"strings\"\n \"strconv\"\n \"sort\"\n )\n \n \nfunc main() {\n stin := bufio.NewScanner(os.Stdin)\n stin.Scan()\n ns,_ := strconv.ParseInt(stin.Text(), 10, 32)\n n := int(ns)\n stin.Scan()\n ss := strings.Fields(stin.Text())\n var a []int\n for i := 0; i < n; i++ {\n q,_ := strconv.ParseInt(ss[i], 10, 32)\n a = append(a, int(q))\n }\n sort.Sort(sort.Reverse(sort.IntSlice(a)))\n \n var totalLength int64 = int64(a[0])\n for i := 1; i < n; i++ {\n if a[i] == a[i-1] {\n for j := i; j < n && a[j] == a[i-1]; j++ {\n if a[j] > 0 {\n a[j] -= 1\n }\n }\n }\n totalLength += int64(a[i])\n }\n fmt.Printf(\"%v\", totalLength)\n}", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f"} {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n n, a, b := getI(), getI(), getI()\n arthur := map[int]bool{}\n for i := 0; i < a; i++ {\n arthur[getI()] = true\n }\n for i := 0; i < b; i++ {\n getI()\n }\n assign := make([]int, n)\n for i := 0; i < n; i++ {\n if arthur[i+1] {\n assign[i] = 1\n } else {\n assign[i] = 2\n }\n }\n writer.WriteString(fmt.Sprintf(\"%d\", assign[0]))\n for i := 1; i < n; i++ {\n writer.WriteString(fmt.Sprintf(\" %d\", assign[i]))\n }\n writer.WriteString(\"\\n\")\n}\n", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\treader := bufio.NewReaderSize(os.Stdin, 1<<13)\n\twriter := bufio.NewWriterSize(os.Stdout, 1<<13)\n\tscn := bufio.NewScanner(reader)\n\tscn.Scan()\n\tline := scn.Text()\n\tn := len(line)\n\n\tcol := line[n-1]\n\trow, _ := strconv.ParseInt(line[:n-1], 10, 64)\n\trow--\n\n\ttotal := (row / 4) * 16\n\n\t// Adding the count for the column\n\tswitch col {\n\tcase 'f':\n\t\ttotal++\n\tcase 'e':\n\t\ttotal += 2\n\tcase 'd':\n\t\ttotal += 3\n\tcase 'a':\n\t\ttotal += 4\n\tcase 'b':\n\t\ttotal += 5\n\tcase 'c':\n\t\ttotal += 6\n\t}\n\n\t// Check if it is the second columns to be served in this\n\t// group:\n\tif (row%4)&1 == 1 {\n\t\ttotal += 6 + 1\n\t}\n\n\tfmt.Fprintln(writer, total)\n\n\twriter.Flush()\n}\n\nfunc ReadInt(reader *bufio.Reader) int {\n\tb, err := reader.ReadByte()\n\tfor !isValid(b, err) {\n\t\tb, err = reader.ReadByte()\n\t}\n\tres := 0\n\tfor isValid(b, err) {\n\t\tres = res*10 + int(b-'0')\n\t\tb, err = reader.ReadByte()\n\t}\n\treturn res\n}\n\nfunc isValid(b byte, err error) bool {\n\treturn err == nil && '0' <= b && b <= '9'\n}\n", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45"} {"source_code": "// 160B-mic\npackage main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tvar str string\n\tf := false\n\tfmt.Scan(&n, &str)\n\ta := make([]int, n)\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = int(str[i])\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = int(str[i+n])\n\t}\n\tsort.Sort(sort.IntSlice(a))\n\tsort.Sort(sort.IntSlice(b))\n\t//fmt.Println(a)\n\t//fmt.Println(b)\n\tif n == 1 && (a[0] < b[0] || a[0] > b[0]) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t} else if n == 1 && a[0] == b[0] {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfor i := 0; i < n-1; i++ {\n\t\tif a[i] > b[i] && a[i+1] > b[i+1] {\n\t\t\tf = true\n\t\t} else if a[i] < b[i] && a[i+1] < b[i+1] {\n\t\t\tf = true\n\t\t} else {\n\t\t\tf = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif f {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "src_uid": "e4419bca9d605dbd63f7884377e28769"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(a, b int) int {\n\tfor a != 0 {\n\t\ta, b = b%a, a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar a, b, c, d int\n\tfmt.Scan(&a, &b, &c, &d)\n\tx := a * d\n\ty := b * c\n\tif x > y {\n\t\tx, y = y, x\n\t}\n\tx = y - x\n\tg := gcd(x, y)\n\tfmt.Printf(\"%d/%d\", x/g, y/g)\n}\n", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e"} {"source_code": "package main \n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a... interface{}) {\n\tfmt.Fscanf(reader, f, a...)\n}\n\nfunc printf(f string, a... interface{}) {\n\tfmt.Fprintf(writer, f, a...)\n}\n\nfunc main() {\n\tvar T, x, result, i, j uint64\n\tscanf(\"%d %d\\n\", &T, &x)\n\t\n\tresult = 0\n\n\tif x <= T {\n\t\tresult++\n\t}\n\tfor i=2; i<=T; i++ {\n\t\tif x % i == 0 {\n\t\t\tfor j=1; j<=T; j++ {\n\t\t\t\tif x == i * j {\n\t\t\t\t\tresult++\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n\tfmt.Println(result)\n\t\n}\n\n", "src_uid": "c4b139eadca94201596f1305b2f76496"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype position struct {\n\tx, y int\n}\n\nfunc solve() {\n\tm := readString()\n\tpos := position{0, 0}\n\tbadpos := make(map[position]bool)\n\n\tfor _, c := range m {\n\t\tif badpos[pos] {\n\t\t\tfmt.Println(\"BUG\")\n\t\t\treturn\n\t\t}\n\t\tbadpos[pos] = true\n\n\t\tup := position{pos.x, pos.y + 1}\n\t\tdown := position{pos.x, pos.y - 1}\n\t\tright := position{pos.x + 1, pos.y}\n\t\tleft := position{pos.x - 1, pos.y}\n\n\t\tswitch c {\n\t\tcase 'U':\n\t\t\tbadpos[down] = true\n\t\t\tbadpos[left] = true\n\t\t\tbadpos[right] = true\n\t\t\tpos = up\n\t\t\tbreak\n\t\tcase 'D':\n\t\t\tbadpos[up] = true\n\t\t\tbadpos[left] = true\n\t\t\tbadpos[right] = true\n\t\t\tpos = down\n\t\t\tbreak\n\t\tcase 'L':\n\t\t\tbadpos[up] = true\n\t\t\tbadpos[down] = true\n\t\t\tbadpos[right] = true\n\t\t\tpos = left\n\t\t\tbreak\n\t\tcase 'R':\n\t\t\tbadpos[up] = true\n\t\t\tbadpos[down] = true\n\t\t\tbadpos[left] = true\n\t\t\tpos = right\n\t\t\tbreak\n\t\t}\n\t}\n\tif badpos[pos] {\n\t\tfmt.Println(\"BUG\")\n\t\treturn\n\t}\n\tfmt.Println(\"OK\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n", "src_uid": "bb7805cc9d1cc907b64371b209c564b3"} {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n defer writer.Flush()\n var a, b, c int\n scanf(\"%d %d %d\\n\", &a, &b, &c)\n solve(a, b, c)\n}\n\n// a b c a c b a\nfunc solve(a, b, c int) {\n min := a / 3\n if b/2 < min {\n min = b / 2\n }\n if c/2 < min {\n min = c / 2\n }\n a -= min * 3\n b -= min * 2\n c -= min * 2\n max := 0\n food := []int{0, 1, 2, 0, 2, 1, 0}\n for start := range food {\n temp := 0\n cur := start\n store := []int{a, b, c}\n for true {\n cur %= 7\n store[food[cur]]--\n if store[food[cur]] < 0 {\n break\n } else {\n temp++\n }\n cur++\n }\n if temp > max {\n max = temp\n }\n }\n printf(\"%d\\n\", max+7*min)\n}\n", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc sol(code string) {\n\tfor _, char := range code {\n\t\tif char == 'H' || char == 'Q' || char == '9' {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n\nfunc main() {\n\tvar code string\n\tfmt.Scanf(\"%s\\n\", &code)\n\tsol(code)\n}\n", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12"} {"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\nconst FILLED = '#'\nconst EMPTED = '.'\n\nvar bR, bC int\n\nfunc isAroundFilled(board []string, r, c int) bool {\n\tfor i := r - 1; i <= r+1; i++ {\n\t\tfor j := c - 1; j <= c+1; j++ {\n\t\t\tif i == r && j == c {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif board[i][j] == EMPTED {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}\n\nfunc checkFilled(filled *[][]int, board []string, r, c int) {\n\tif isAroundFilled(board, r, c) {\n\t\tfor i := r - 1; i <= r+1; i++ {\n\t\t\tfor j := c - 1; j <= c+1; j++ {\n\t\t\t\tif i == r && j == c {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t(*filled)[i][j] = 1\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc canForge(filled [][]int, board []string) bool {\n\tfor i := 0; i < bR; i++ {\n\t\tfor j := 0; j < bC; j++ {\n\t\t\tif board[i][j] == FILLED && filled[i][j] == 0 {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tscanf(\"%d %d\\n\", &bR, &bC)\n\tboard := make([]string, bR)\n\tfilled := make([][]int, bR)\n\tfor i := 0; i < bR; i++ {\n\t\tfilled[i] = make([]int, bC)\n\t\tscanf(\"%s\\n\", &board[i])\n\t}\n\n\tfor i := 1; i+1 < bR; i++ {\n\t\tfor j := 1; j+1 < bC; j++ {\n\t\t\tcheckFilled(&filled, board, i, j)\n\t\t}\n\t}\n\n\tif canForge(filled, board) {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n\n}\n", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc Solve(input io.Reader) (result string) {\n\tvar n int\n\tfmt.Fscan(input, &n)\n\tif n <= 2 {\n\t\treturn \"YES\\n\"\n\t}\n\tarray := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(input, &(array[i]))\n\t}\n\tvar leftStop, rightStop int\n\tfor leftStop = 0; leftStop < n-1; leftStop++ {\n\t\tif array[leftStop] >= array[leftStop+1] {\n\t\t\tbreak\n\t\t}\n\t}\n\tif leftStop == n-2 && array[n - 2] <= array[n - 1] {\n\t\tleftStop = n - 1\n\t}\n\tfor rightStop = n - 1; rightStop > 1; rightStop-- {\n\t\tif array[rightStop] >= array[rightStop-1] {\n\t\t\tbreak\n\t\t}\n\t}\n\tif rightStop == 1 && array[0] >= array[1] {\n\t\trightStop = 0\n\t}\n\tyes := \"YES\\n\"\n\tfor ; leftStop < rightStop; leftStop++ {\n\t\tif array[leftStop] != array[rightStop] {\n\t\t\tyes = \"NO\\n\"\n\t\t\tbreak\n\t\t}\n\t}\n\treturn yes\n}\n\nfunc main() {\n\tfmt.Print(Solve(os.Stdin))\n}", "src_uid": "5482ed8ad02ac32d28c3888299bf3658"} {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, b, c int\n fmt.Scan(&a, &b, &c)\n base := a\n if (base > b - 1) {\n base = b - 1\n }\n if (base > c - 2) {\n base = c - 2\n }\n fmt.Println(3 * base + 3)\n}", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5"} {"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", "src_uid": "7dd098ec3ad5b29ad681787173eba341"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc sum(a int) int {\n\tvar d, s int\n\tfor a > 0 {\n\t\td = a % 10\n\t\ts = s + d\n\t\ta = a / 10\n\t}\n\treturn s\n}\n\nfunc main() {\n\tvar a, s, n int\n\tfmt.Scan(&a)\n\ts = sum(a)\n\tif s%4 == 0 {\n\t\tfmt.Println(a)\n\t} else {\n\t\tn = a + 1\n\t\tfor sum(n)%4 != 0 {\n\t\t\tn = n + 1\n\t\t}\n\t\tfmt.Println(n)\n\t}\n}\n", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc readInt(bytes []byte, from int, val *int) int {\n\ti := from\n\tsign := 1\n\tif bytes[i] == '-' {\n\t\tsign = -1\n\t\ti++\n\t}\n\ttmp := 0\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + int(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp * sign\n\treturn i\n}\n\nfunc readNum(reader *bufio.Reader) (a int) {\n\tbs, _ := reader.ReadBytes('\\n')\n\treadInt(bs, 0, &a)\n\treturn\n}\n\nfunc readTwoNums(reader *bufio.Reader) (a int, b int) {\n\tres := readNNums(reader, 2)\n\ta, b = res[0], res[1]\n\treturn\n}\n\nfunc readThreeNums(reader *bufio.Reader) (a int, b int, c int) {\n\tres := readNNums(reader, 3)\n\ta, b, c = res[0], res[1], res[2]\n\treturn\n}\n\nfunc readNNums(reader *bufio.Reader, n int) []int {\n\tres := make([]int, n)\n\tx := 0\n\tbs, _ := reader.ReadBytes('\\n')\n\tfor i := 0; i < n; i++ {\n\t\tfor x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {\n\t\t\tx++\n\t\t}\n\t\tx = readInt(bs, x, &res[i])\n\t}\n\treturn res\n}\n\nfunc readUint64(bytes []byte, from int, val *uint64) int {\n\ti := from\n\n\tvar tmp uint64\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + uint64(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp\n\n\treturn i\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tn, k := readTwoNums(reader)\n\n\tfmt.Println(solve(n, k))\n}\n\nconst MAX_N = 500043\nconst MOD = 998244353\n\nvar F []int64\n\n// var PM []int\n\nfunc pow(a, b int64) int64 {\n\tvar r int64 = 1\n\tfor b > 0 {\n\t\tif b&1 == 1 {\n\t\t\tr *= a\n\t\t\tr %= MOD\n\t\t}\n\t\ta *= a\n\t\ta %= MOD\n\t\tb >>= 1\n\t}\n\treturn r\n}\n\nfunc init() {\n\tF = make([]int64, MAX_N)\n\tF[0] = 1\n\n\tfor i := 1; i < MAX_N; i++ {\n\t\tF[i] = int64(i) * F[i-1]\n\t\tF[i] %= MOD\n\t}\n}\n\nfunc IF(n int) int64 {\n\tx := F[n]\n\treturn pow(x, MOD-2)\n}\n\nfunc nCr(n, r int) int64 {\n\tif n < r {\n\t\treturn 0\n\t}\n\tres := F[n]\n\tres *= IF(r)\n\tres %= MOD\n\tres *= IF(n - r)\n\tres %= MOD\n\treturn res\n}\n\nfunc solve(n, k int) int {\n\tvar res int64\n\n\tfor x := 1; x <= n; x++ {\n\t\t// x := PM[i]\n\t\td := n / x\n\t\tif d < k {\n\t\t\tbreak\n\t\t}\n\t\tres += nCr(d-1, k-1)\n\t\tres %= MOD\n\t}\n\n\treturn int(res)\n}\n", "src_uid": "8e8eb64a047cb970a549ee870c3d280d"} {"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\nimport \"math\"\n\nfunc sum(n int64) int64 {\n\tvar summ int64\n\tfor n > 0 {\n\t\tsumm += n%10\n\t\tn /= 10\n\t}\n\treturn summ\n}\n\nfunc main(){\n\tvar n int64\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tvar l int64 = int64(math.Sqrt(float64(n)))-40\n\tif l < 0 {\n\t\tl = 1\n\t}\n\tvar s int64 = int64(math.Sqrt(float64(n)))+1\n\tfor i:=l; i 0; i=i-1 {\n count = count+i\n //fmt.Println(count)\n if (i == hs1) {\n count = count - hw1\n }\n if (i == hs2) {\n count = count - hw2\n }\n if (count < 0) {\n count = 0\n }\n }\n fmt.Println(count)\n}\n", "src_uid": "084a12eb3a708b43b880734f3ee51374"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, max, min, res int\n\tmin = 1000\n\n\tfmt.Scan(&n)\n\n\ta := make([]int, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\n\t\tif i > 0 {\n\t\t\tif a[i]-a[i-1] > max {\n\t\t\t\tmax = a[i] - a[i-1]\n\t\t\t}\n\t\t}\n\n\t\tif i > 1 {\n\t\t\tif a[i]-a[i-2] < min {\n\t\t\t\tmin = a[i] - a[i-2]\n\t\t\t}\n\t\t}\n\t}\n\n\tres = min\n\tif max > min {\n\t\tres = max\n\t}\n\n\tfmt.Println(res)\n}\n", "src_uid": "8a8013f960814040ac4bf229a0bd5437"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tfor i := 0; i < 8; i++ {\n\n\t\tvar line string\n\t\tfmt.Scanln(&line)\n\n\t\tfirst := line[0]\n\t\tsecond := line[1]\n\t\tfor j := 0; j < 8; j++ {\n\t\t\tif (line[j] == first && j%2 == 1) ||\n\t\t\t\t(line[j] == second && j%2 == 0) {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(\"YES\")\n}\n", "src_uid": "ca65e023be092b2ce25599f52acc1a67"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tX := io.NextInt()\n\tY := io.NextInt()\n\t\n\tif Y < 1 {\n\t io.Println(\"No\")\n\t return\n\t}\n\t\n\tif (Y == 1) {\n\t if (X == 0) {\n\t io.Println(\"Yes\")\n\t } else {\n\t io.Println(\"No\")\n\t }\n\t return\n\t}\n\t\n\tif Y <= X + 1 && (X + Y) % 2 == 1 {\n\t io.Println(\"Yes\")\n\t} else {\n\t io.Println(\"No\")\n\t}\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}", "src_uid": "1527171297a0b9c5adf356a549f313b9"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc intPow(x int64, y int64) (res int64) {\n\tres = 1\n\tfor i := int64(0); i < y; i++ {\n\t\tres *= x\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar n, x, y, numx, numy, t int64\n\tfmt.Scanf(\"%d %d\\n\", &n, &x)\n\tnumx = 0\n\tfor i := int64(1); i <= n; i++ {\n\t\tfmt.Scanf(\"%d\", &t)\n\t\tnumx += t * intPow(x, (n-i))\n\t}\n\tfmt.Scanf(\"\\n%d %d\\n\", &n, &y)\n\tnumy = 0\n\tfor i := int64(1); i <= n; i++ {\n\t\tfmt.Scanf(\"%d\", &t)\n\t\tnumy += t * intPow(y, (n-i))\n\t}\n\n\tif numx == numy {\n\t\tfmt.Println(\"=\")\n\t} else if numx < numy {\n\t\tfmt.Println(\"<\")\n\t} else {\n\t\tfmt.Println(\">\")\n\t}\n}\n", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67"} {"source_code": "// Codeforces 859 C Pie Rules train\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar in *bufio.Reader\n\nfunc readFive() (int, int, int, int, int) {\n\tvar a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor i := 0; i < len(ss); i++ {\n\t\ta[i], err = strconv.Atoi(ss[i])\n\t\tif err != nil {\n\t\t\tfmt.Println(\"n atoi failure\", err)\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn a[0], a[1], a[2], a[3], a[4]\n}\n\nfunc readLineNumbs(n int) []int {\n\ta := make([]int, n)\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor j := 0; j < n; j++ {\n\t\taa, err := strconv.Atoi(ss[j])\n\t\tif err != nil {\n\t\t\tfmt.Println(\"aa conv failed\", err)\n\t\t\tpanic(err)\n\t\t}\n\t\ta[j] = aa\n\t}\n\treturn a\n}\n\nvar n int\nvar p []int // pie slices sizes\nvar pAlice,pBob int\nvar mem [][]int // mem[0] - bob win, mem[1] - alice win\nvar pSum int\nvar pSumLeft []int // sum left after step \n\n// readData read data for out problem.\nfunc readData() {\n\tin = bufio.NewReader(os.Stdin)\n\t// reading n\n\tn, _, _, _, _ = readFive()\n\tp = readLineNumbs(n)\n}\n\nfunc initMemSum() {\n\tmem = make([][]int, 2)\n\tfor ba := 0; ba<2; ba++ {\n\t\tmem[ba] = make([]int, n)\n\t\tfor j:=0; j=0; i-- {\n\t\tpSum += p[i]\n\t\tpSumLeft[i] = pSum;\n\t}\n}\n\n// Return for player with fishka.\nfunc play(ba int, step int) int {\n\tif step>=n {\n\t\treturn 0\n\t} else if mem[ba][step]>=0 {\n\t\treturn mem[ba][step]\n\t}\n\t// pass fishka\n\tretp := p[step] + (pSumLeft[step+1] - play(1-ba, step+1));\n\t// stay with fishka\n\trets := play(ba, step+1)\n\t// max result\n\tret := retp\n\tif ret < rets {\n\t\tret = rets\n\t}\n\t// fmt.Printf(\"play(%d, %d) returned %d\\n\", ba,step, ret)\n\tmem[ba][step] = ret;\n\treturn ret;\n}\n\n// solve func solves our problem.\nfunc solve() {\n\tinitMemSum()\n\tpBob = play(1,0)\n\tpAlice = pSum - pBob\n}\n\n// printRes print problem solution in expected format.\nfunc printRes() {\n\tfmt.Printf(\"%d %d\\n\", pAlice, pBob)\n}\n\nfunc main() {\n\treadData()\n\tsolve()\n\tprintRes()\n}\n", "src_uid": "414540223db9d4cfcec6a973179a0216"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tarr1 := make([]int, 3)\n\tarr2 := make([]int, 3)\n\tfor {\n\t\tline, _, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tsum1 := 0\n\t\tfor i := 0; i < 3; i++ {\n\t\t\tarr1[i] = int(line[i] - '0')\n\t\t\tsum1 += arr1[i]\n\t\t}\n\t\tsum2 := 0\n\t\tfor i := 3; i < 6; i++ {\n\t\t\tarr2[i-3] = int(line[i] - '0')\n\t\t\tsum2 += arr2[i-3]\n\t\t}\n\t\tif sum1 == sum2 {\n\t\t\tfmt.Printf(\"0\\n\")\n\t\t\tcontinue\n\t\t}\n\t\tif sum1 < sum2 {\n\t\t\tarr1, arr2 = arr2, arr1\n\t\t\tsum1, sum2 = sum2, sum1\n\t\t}\n\t\tdelta := sum1 - sum2\n\t\tcount := 0\n\t\tfor {\n\t\t\tsort.Sort(sort.IntSlice(arr1))\n\t\t\tsort.Sort(sort.IntSlice(arr2))\n\t\t\tcount++\n\t\t\tif arr1[2] > 9-arr2[0] {\n\t\t\t\tif arr1[2] >= delta {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdelta -= arr1[2]\n\t\t\t\tarr1[2] = 0\n\t\t\t} else {\n\t\t\t\tif 9-arr2[0] >= delta {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdelta -= (9 - arr2[0])\n\t\t\t\tarr2[0] = 9\n\t\t\t}\n\n\t\t}\n\t\tfmt.Printf(\"%d\\n\", count)\n\n\t}\n}\n", "src_uid": "09601fd1742ffdc9f822950f1d3e8494"} {"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 D, L, v1, v2 float64\n\tfmt.Fscan(in, &D, &L, &v1, &v2)\n\tfmt.Fprintf(out, \"%0.15f\\n\", (L-D)/(v1+v2))\n}\n", "src_uid": "f34f3f974a21144b9f6e8615c41830f5"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar word string\n\n\tfmt.Scanf(\"%s\" , &word)\n\n\n\tvar caps, small int\n\n\tfor _, s := range word {\n\t\tif s >= 97 {\n\t\t\tsmall+= 1\n\t\t} else {\n\t\t\tcaps+=1\n\t\t}\n\t}\n\n\tif small >= caps {\n\t\tfmt.Println(strings.ToLower(word))\n\t} else {\n\t\tfmt.Println(strings.ToUpper(word))\n\t}\n}\n", "src_uid": "b432dfa66bae2b542342f0b42c0a2598"} {"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", "src_uid": "b743110117ce13e2090367fd038d3b50"} {"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\"sort\"\n\t\"strconv\"\n\t\"time\"\n)\n\n// ******************************** CODE STARTS ********************************\n\nvar ()\n\nfunc solve() {\n\tn := readInt()\n\tmas := make([]int, n)\n\tm := readInt()\n\tA := make([]int, m)\n\tB := make([]int, m)\n\n\tfor i := 0; i < n; i++ {\n\t\tmas[i] = readInt()\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tA[i] = readInt()\n\t\tB[i] = readInt()\n\t}\n\n\tarray := make(TupleSlice, n)\n\tfor i := 0; i < n; i++ {\n\t\tarray[i] = Tuple{mas[i], i}\n\t}\n\tsort.Sort(array)\n\ton := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ton[array[i].b] = i & 1\n\t}\n\n\tfor j := 0; j < m; j++ {\n\t\tdiff := 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif A[j] <= mas[i] && mas[i] <= B[j] {\n\t\t\t\tif on[i] == 0 {\n\t\t\t\t\tdiff++\n\t\t\t\t} else {\n\t\t\t\t\tdiff--\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif absInt(diff) > 1 {\n\t\t\tprintInt(-1)\n\t\t\tprintLine()\n\t\t\treturn\n\t\t}\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tprintInt(on[i])\n\t\tif i + 1 == n {\n\t\t\tprintLine()\n\t\t} else {\n\t\t\tprintString(\" \")\n\t\t}\n\t}\n\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\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", "src_uid": "692698d4b49ad446984f3a7a631f961d"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN, K := sc.NextInt64(), sc.NextInt64()\n\tm := int64(0)\n\tif K%2 == 0 {\n\t\tm = K/2 - 1\n\t} else {\n\t\tm = K / 2\n\t}\n\tQ := max(0, min(m, N-(K-m-1)))\n\tfmt.Println(Q)\n\n}\nfunc max(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc min(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\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", "src_uid": "98624ab2fcd2a50a75788a29e04999ad"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar reader io.Reader\nvar scanner *bufio.Scanner\n\nfunc Init(io io.Reader, max_token_size int) {\n\treader = bufio.NewReader(io)\n\tscanner = bufio.NewScanner(reader)\n\t// max token size\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer([]byte{}, max_token_size)\n}\n\nfunc stderr(v ...interface{}) {\n\tfmt.Fprintln(os.Stderr, v...)\n}\n\nfunc die(v ...interface{}) {\n\tfmt.Fprintln(os.Stderr, v...)\n\tos.Exit(1)\n}\n\nfunc NextInt() int {\n\tbytes := NextBytes()\n\ti, err := Atoi(bytes)\n\tif err != nil {\n\t\tdie(err)\n\t}\n\treturn i\n}\n\nfunc NextBytes() []byte {\n\tif !scanner.Scan() {\n\t\tdie(scanner.Err())\n\t}\n\tbytes := scanner.Bytes()\n\tcopied := make([]byte, len(bytes))\n\tcopy(copied, bytes)\n\treturn copied\n}\n\nfunc Atoi(b []byte) (int, error) {\n\tneg := false\n\tif b[0] == '+' {\n\t\tb = b[1:]\n\t} else if b[0] == '-' {\n\t\tneg = true\n\t\tb = b[1:]\n\t}\n\tn := 0\n\tfor _, v := range b {\n\t\tif v < '0' || v > '9' {\n\t\t\treturn 0, strconv.ErrSyntax\n\t\t}\n\t\tn = n*10 + int(v-'0')\n\t}\n\tif neg {\n\t\treturn -n, nil\n\t}\n\treturn n, nil\n}\n\nfunc ExtendByteArray(a []byte, size int) []byte {\n\tif size <= len(a) {\n\t\treturn a\n\t} else {\n\t\treturn append(a, make([]byte, size-len(a))...)\n\t}\n}\n\nfunc ExtendIntArray(a []int, size int) []int {\n\tif size <= len(a) {\n\t\treturn a\n\t} else {\n\t\treturn append(a, make([]int, size-len(a))...)\n\t}\n}\n\nfunc main() {\n\tinf := os.Stdin\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\t// inf, err := os.Open(\"a.in\")\n\t// if err != nil {\n\t// \tdie(err)\n\t// }\n\t// out, err := os.Create(\"a.out\")\n\t// if err != nil {\n\t// \tdie(err)\n\t// }\n\t// defer out.Close()\n\tInit(inf, 1000010)\n\n\tn := NextInt()\n\tb := make([]int, n)\n\tr := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = NextInt()\n\t}\n\tvar k01, k10 int\n\tfor i := 0; i < n; i++ {\n\t\tr[i] = NextInt()\n\t\tif b[i] == 0 && r[i] == 1 {\n\t\t\tk01++\n\t\t} else if b[i] == 1 && r[i] == 0 {\n\t\t\tk10++\n\t\t}\n\t}\n\tif k10 == 0 {\n\t\tfmt.Fprintln(out, -1)\n\t\treturn\n\t}\n\tres := k01/k10 + 1\n\tfmt.Fprintln(out, res)\n}\n", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\n// https://codeforces.com/contest/1426/problem/D\n\nvar in *bufio.Reader\nvar out *bufio.Writer\n\nfunc printf(x string, a ...interface{}) (n int, err error) {\n\treturn fmt.Fprintf(out, x, a...)\n}\n\nfunc scanf(x string, a ...interface{}) (n int, err error) {\n\treturn fmt.Fscanf(in, x, a...)\n}\n\nfunc scan(a ...interface{}) (n int, err error) {\n\treturn fmt.Fscan(in, a...)\n}\n\nvar err error\n\nfunc next() (n string) {\n\tscan(&n)\n\treturn n\n}\n\nfunc nextInt() (n int) {\n\tscan(&n)\n\treturn n\n}\n\nfunc nextInt64() (n int64) {\n\tscan(&n)\n\treturn n\n}\n\nfunc nextDouble() (n float64) {\n\tscan(&n)\n\treturn n\n}\n\nfunc Max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc Min(a, b int64) int64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\n// ==================== \u4ee5\u4e0a\u662f\u6a21\u7248 ====================\nfunc getIn() *bufio.Reader {\n\t/*\n\n\t\t\t1 2 -1 -2 1\n\t\t\t-1 | 1 | -1 | 1 | -1 | 1 1 | -1 -1\n\n\t\t\t4 -2 3 -9 2\n\n\t\t// 1. \u83b7\u53d6\u5230\u5168\u90e8\u53ef\u80fd\u5230\u503c\n\t\t\t-3, 2\n\t\t\t1, 10 1,2\n\t\t\t2, 20\n\t\t\t3, 5, 3,5\n\t\t\t4,30 4,5\n\t\t\t6-10,\n\n\t\t//\n\t\t\ta b c d\n\n\t\t\t\u6c42\u548c\u95ee\u9898\n\t\t\t\u7ef4\u62a4\u4e00\u4e2arange\n\t*/\n\tx := `\n2\nthe minimum and the maximum number of rounds Alice can win\n// \u6700\u5927\u8d62\u6b21\u6570\uff0c\u4f18\u5148\u8d62\uff0c\u8d2a\u5fc3\n// \u6700\u5c0f\u8d62\u6b21\u6570\uff0c\u4f18\u5148\u8f93\uff0c\u8d2a\u5fc3\n\u77f3\u5934 \u526a\u5200 \u5e03\n0 \t1 \t1\n1 \t1 \t0\n`\n\n\treturn bufio.NewReaderSize(strings.NewReader(x), 8192)\n}\n\n// 0 > 1 > 2 > 0\nfunc Win(a, b int) int64 {\n\tif a == 0 && b == 1 {\n\t\treturn 1\n\t}\n\tif a == 1 && b == 2 {\n\t\treturn 1\n\t}\n\tif a == 2 && b == 0 {\n\t\treturn 1\n\t}\n\treturn 0\n}\n\nfunc solve() {\n\t_ = nextInt()\n\taa := [3]int64{}\n\tbb := [3]int64{}\n\tfor i := 0; i < 3; i++ {\n\t\taa[i] = nextInt64()\n\t}\n\tfor i := 0; i < 3; i++ {\n\t\tbb[i] = nextInt64()\n\t}\n\n\t/*\n\t\t\u77f3\u5934 \u526a\u5200 \u5e03\n\t\t479 178 29\n\t\t11 145 530\n\n\t\t468\t33 0\n\t\t0\t0 501\n\n\t*/\n\n\t// \u6392\u5217\u7ec4\u5408\n\tx := [][3]int{\n\t\t{0, 1, 2},\n\t\t{0, 2, 1},\n\t\t{1, 0, 2},\n\t\t{1, 2, 0},\n\t\t{2, 0, 1},\n\t\t{2, 1, 0},\n\t}\n\ty := [][3]int{\n\t\t{0, 1, 2},\n\t\t{0, 2, 1},\n\t\t{1, 0, 2},\n\t\t{1, 2, 0},\n\t\t{2, 0, 1},\n\t\t{2, 1, 0},\n\t}\n\t// 0 > 1 > 2 > 0\n\tmaxWin := int64(0)\n\tminWin := int64(3000000000)\n\tfor _, c := range x {\n\t\tfor _, d := range y {\n\t\t\ta := aa\n\t\t\tb := bb\n\t\t\ti := 0\n\t\t\tj := 0\n\t\t\t// a[c[i]] \u5f53\u524d\u7684\u503c \u6709\u591a\u5c11\n\t\t\t// b[j] \u5f53\u524d\u7684\u503c \u6709\u591a\u5c11\n\t\t\t// \u6bd4\u8f83\u5173\u7cfb c[i] \u548c j\n\t\t\twin := int64(0)\n\t\t\tfor i < 3 && j < 3 {\n\t\t\t\tif a[c[i]] > b[d[j]] {\n\t\t\t\t\ta[c[i]] -= b[d[j]]\n\t\t\t\t\twin += b[d[j]] * Win(c[i], d[j])\n\t\t\t\t\tj += 1\n\t\t\t\t} else if a[c[i]] < b[d[j]] {\n\t\t\t\t\tb[d[j]] -= a[c[i]]\n\t\t\t\t\twin += a[c[i]] * Win(c[i], d[j])\n\t\t\t\t\ti += 1\n\t\t\t\t} else {\n\t\t\t\t\twin += a[c[i]] * Win(c[i], d[j])\n\t\t\t\t\ti += 1\n\t\t\t\t\tj += 1\n\t\t\t\t}\n\t\t\t}\n\t\t\t//fmt.Println(i, j)\n\t\t\tmaxWin = Max(maxWin, win)\n\t\t\tminWin = Min(minWin, win)\n\t\t}\n\t}\n\tprintf(\"%d %d\", minWin, maxWin)\n}\n\nfunc main() {\n\tin = bufio.NewReaderSize(os.Stdin, 8192)\n\t//in = getIn()\n\n\tout = bufio.NewWriterSize(os.Stdout, 8192)\n\tdefer out.Flush()\n\t//for t := nextInt(); t > 0; t-- {\n\tsolve()\n\t//}\n}\n", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n uint64\n\tvar m uint64\n\tvar a uint64\n\tfmt.Scanf(\"%d\", &n)\n\tfmt.Scanf(\"%d\", &m)\n\tfmt.Scanf(\"%d\", &a)\n\tvar x uint64 = (n / a)\n\tvar y uint64 = (m / a)\n\tif(n % a != 0) {\n\t\tx += 1\n\t}\n\tif(m % a != 0) {\n\t\ty += 1\n\t}\n\tfmt.Printf(\"%d\\n\", (x*y))\n}\n\n", "src_uid": "ef971874d8c4da37581336284b688517"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tlength int\n\t\tstr string\n\t)\n\t\n\tfmt.Scanf(\"%d\\n\", &length)\n\tfmt.Scan(&str)\n\tpokemons := []string {\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"}\n\t\n\tsameLength := make([]string, 0)\n\tfor i := 0; i < len(pokemons); i++ {\n\t\tif len(pokemons[i]) == length {\n\t\t\tsameLength = append(sameLength, pokemons[i])\n\t\t\t\n\t\t}\n\t}\n\t\n\tfor j := 0; j < len(sameLength); j++ {\n\t\tfor i := 0; i < len(str); i++ {\n\t\t\tif (str[i] == sameLength[j][i] || str[i] == '.') && (i == (len(str) - 1)) {\n\t\t\t\tfmt.Println(sameLength[j])\n\t\t\t\treturn\n\t\t\t} else if (str[i] != sameLength[j][i]) && (str[i] != '.') {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b int\n\tfmt.Scan(&n, &a, &b)\n\tif a+b < n {\n\t\tfmt.Print(b + 1)\n\t} else {\n\t\tfmt.Print(n - a)\n\t}\n}\n", "src_uid": "51a072916bff600922a77da0c4582180"} {"source_code": "package main\n\nimport \"fmt\"\nimport \"math/big\"\n\nfunc main() {\n\tvar ns, ks string\n\tn, k := new(big.Int), new(big.Int)\n\tfmt.Scanf(\"%s %s\", &ns, &ks)\n\tfmt.Sscan(ns, n)\n\tfmt.Sscan(ks, k)\n\tr := new(big.Int).Div(n, k)\n\tr.Mod(r, big.NewInt(2))\n\n\tif r.Cmp(big.NewInt(0)) == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\t// fmt.Printf(\"n: %d, k: %d, r: %d\\n\", n, k, r)\n}\n", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\n\treadint := func() int {\n\t\tsc.Scan()\n\t\tx, _ := strconv.Atoi(string(sc.Bytes()))\n\t\treturn x\n\t}\n\n\ta := readint()\n\tb := readint()\n\ts := readint()\n\n\tabs := func(x int) int {\n\t\tif x < 0 {\n\t\t\tx = -x\n\t\t}\n\t\treturn x\n\t}\n\n\tm := abs(a) + abs(b)\n\n\tans := \"No\"\n\tif m <= s {\n\t\ts -= m\n\t\tif s%2 == 0 {\n\t\t\tans = \"Yes\"\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n", "src_uid": "9a955ce0775018ff4e5825700c13ed36"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc abs(a int) int{\n\tif a < 0{\n\t\treturn -a\n\t} else{\n\t\treturn a\n\t}\n}\n\nfunc min(a, b int) int{\n\tif a < b{\n\t\treturn a\n\t} else{\n\t\treturn b\n\t}\n}\n\nfunc main(){\n\tvar n int\n\tfmt.Scanln(&n)\n\tswitch n%4{\n\tcase 1:\n\t\tfmt.Println(\"0 A\")\n\tcase 2:\n\t\tfmt.Println(\"1 B\")\n\tcase 3:\n\t\tfmt.Println(\"2 A\")\n\tcase 0:\n\t\tfmt.Println(\"1 A\")\n\t}\n}", "src_uid": "488e809bd0c55531b0b47f577996627e"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tvar ans []int\n\tfor i := 1; ; i++ {\n\t\tni := n - i\n\t\tif ni < i+1 {\n\t\t\tans = append(ans, i+ni)\n\t\t\tbreak\n\t\t} else {\n\t\t\tans = append(ans, i)\n\t\t\tn -= i\n\t\t}\n\t}\n\tfmt.Println(len(ans))\n\tfor _, v := range ans {\n\t\tfmt.Print(v, \" \")\n\t}\n}", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc"} {"source_code": "// hello project main.go\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var s,t string\n fmt.Scanf(\"%s %s\",&s, &t)\n lens := len(s)\n lent := len(t)\n suma := 0\n for i := 0 ;i < lens; i ++ {\n if '+' == s[i]{\n suma ++\n }else {\n suma --\n }\n } \n sum := 0; sumb := 0\n for i := 0; i < lent; i ++ {\n if '?' == t[i]{\n sum ++\n }else if '+' == t[i]{\n sumb ++\n }else {\n sumb --\n }\n }\n n := 1 << uint(sum)\n m := 0\n for i := 0 ;i < n; i ++ {\n tmp := sumb\n for j := 0;j < sum; j ++{\n if (int)(1 < lenS/2 {\n\t\treturn lenS\n\t}\n\n\treturn lenS - (lenS - 2*lenA + 1)\n}\n", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strings\"\n\t\"fmt\"\n\t\"strconv\"\n\t\"time\"\n)\n\nfunc min0(a, b int64) int64 {\n\tif a < 0 {\n\t\treturn b\n\t}\n\n\tif b < 0 {\n\t\treturn a\n\t}\n\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc pp(args... interface{}) {\n\tif true {\n\t\treturn\n\t}\n\tfmt.Println(args...)\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tscanner.Scan()\n\tdata := strings.Split(scanner.Text(), \" \")\n\n\tcabs, _ := strconv.ParseInt(data[0], 10, 64)\n\tdils, _ := strconv.ParseInt(data[1], 10, 64)\n\n\tpBuild, _ := strconv.ParseInt(data[2], 10, 64)\n\tpDestroy, _ := strconv.ParseInt(data[3], 10, 64)\n\n\tstart := time.Now()\n\n\tlow := cabs / dils * dils\n\thigh := low + dils\n\n\tif high == cabs {\n\t\tfmt.Print(0)\n\t\treturn\n\t}\n\n\tpLow := pDestroy * (cabs - low)\n\tpHigh := pBuild * (high - cabs)\n\tpDestroyAll := pDestroy * cabs\n\n\tpp(high, low, cabs, pLow, pHigh, pDestroyAll)\n\n\tfmt.Println(min0(min0(pLow, pHigh), pDestroyAll))\n\n\tpp(time.Since(start))\n}\n", "src_uid": "c05d753b35545176ad468b99ff13aa39"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tdo()\n}\n\nfunc do() {\n\ts := bufio.NewScanner(os.Stdin)\n\ts.Split(bufio.ScanWords)\n\ts.Scan()\n\tn, _ := strconv.Atoi(s.Text())\n\ts.Scan()\n\tm, _ := strconv.Atoi(s.Text())\n\ts.Scan()\n\tk, _ := strconv.ParseInt(s.Text(), 10, 64)\n\ts.Scan()\n\tx, _ := strconv.Atoi(s.Text())\n\ts.Scan()\n\ty, _ := strconv.Atoi(s.Text())\n\n\tmin := minAsk(n, m, k)\n\tmax := maxAsk(n, m, k)\n\tcnt := count(n, m, x, y, k)\n\tfmt.Printf(\"%v %v %v\\n\", max, min, cnt)\n}\n\nfunc minAsk(n, m int, k int64) int64 {\n\tif n <= 2 {\n\t\treturn k / int64(n*m)\n\t}\n\n\tt := int64(2*n*m - 2*m)\n\tth := int64(n * m)\n\td := k / t\n\tr := k % t\n\n\tif r < th {\n\t\treturn d\n\t}\n\treturn d + 1\n}\n\nfunc maxAsk(n, m int, k int64) int64 {\n\tif n <= 2 {\n\t\td := k / int64(n*m)\n\t\tr := k % int64(n*m)\n\t\tif r > 0 {\n\t\t\treturn d + 1\n\t\t}\n\t\treturn d\n\t}\n\n\tt := int64(2*n*m - 2*m)\n\tth := int64(n * m)\n\td := k / t\n\tr := k % t\n\n\tif d > 0 && r <= int64(m) {\n\t\treturn d * 2\n\t} else if r <= th {\n\t\treturn d*2 + 1\n\t}\n\n\treturn d*2 + 2\n}\n\nfunc count(n, m, x, y int, k int64) int64 {\n\tif n <= 2 {\n\t\td := k / int64(n*m)\n\t\tr := k % int64(n*m)\n\t\tif r >= int64((x-1)*m+y) {\n\t\t\treturn d + 1\n\t\t}\n\t\treturn d\n\t}\n\n\tt := int64(2*n*m - 2*m)\n\tth := int64(n * m)\n\td := k / t\n\tr := k % t\n\n\tif x == 1 {\n\t\tif r >= int64(y) {\n\t\t\treturn d + 1\n\t\t}\n\t\treturn d\n\t} else if x == n {\n\t\tif r-int64((n-1)*m) >= int64(y) {\n\t\t\treturn d + 1\n\t\t}\n\t\treturn d\n\t} else {\n\t\tif r < int64((x-1)*m+y) {\n\t\t\treturn d * 2\n\t\t} else if r >= int64((x-1)*m+y) && r < th+int64((n-x-1)*m+y) {\n\t\t\treturn d*2 + 1\n\t\t}\n\t}\n\n\treturn d*2 + 2\n}\n", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21"} {"source_code": "package main\n\nimport \"fmt\"\n\n\nfunc main() {\n\tvar a, b, c , d int\n\tfmt.Scanf(\"%d\\n%d\\n%d\\n%d\\n\", &a, &b, &c, &d);\n\tif c != 0{\n\t\ta--\n\t\td--\n\t}\n\tif a >= 0 && d >= 0 && a == d{\n\t\tfmt.Println(1)\n\t}else{\n\t\tfmt.Println(0)\n\t}\n}", "src_uid": "b99578086043537297d374dc01eeb6f8"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar (\n\tin = bufio.NewReader(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\tdefer out.Flush()\n\tvar r, c, n, k int\n\tfmt.Fscan(in, &r, &c, &n, &k)\n\ta := make([][]int, r)\n\tfor i := range a {\n\t\ta[i] = make([]int, c)\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tvar x, y int\n\t\tfmt.Fscan(in, &x, &y)\n\t\ta[x-1][y-1]++\n\t}\n\tans := 0\n\tfor x0 := 0; x0 < r; x0++ {\n\t\tfor y0 := 0; y0 < c; y0++ {\n\t\t\tfor x1 := x0; x1 < r; x1++ {\n\t\t\t\tfor y1 := y0; y1 < c; y1++ {\n\t\t\t\t\tcount := 0\n\t\t\t\t\tfor x := x0; x <= x1; x++ {\n\t\t\t\t\t\tfor y := y0; y <= y1; y++ {\n\t\t\t\t\t\t\tcount += a[x][y]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif count >= k {\n\t\t\t\t\t\tans++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintln(out, ans)\n}\n", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tsum := 0\n\n\tfor i := 0; i < 5; i++ {\n\t\tsum += nextInt()\n\t}\n\n\tif (sum % 5 == 0 && sum != 0) {\n\t\tprintln(sum / 5)\n\t} else {\n\t\tprintln(-1)\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}", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20"} {"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\tif n == 1 {\n\t\tprintln(\"Yes\")\n\t\treturn\n\t}\n\ts := readb()\n\tc := make([]int, 26)\n\tfor _, b := range s {\n\t\tc[b-'a']++\n\t}\n\t//eprintln(c)\n\tok := false\n\tfor _, v := range c {\n\t\tif 1 < v {\n\t\t\tok = true\n\t\t}\n\t}\n\tif ok {\n\t\tprintln(\"Yes\")\n\t} else {\n\t\tprintln(\"No\")\n\t}\n\n}\n", "src_uid": "6b22e93f7e429693dcfe3c099346dcda"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc MaxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tvar arr [101]int\n\tvar brr [101]int\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&arr[i])\n\t\tbrr[arr[i]]++\n\t}\n\tres := 0\n\tfor _, v := range brr {\n\t\tres = MaxInt(res, v)\n\t}\n\tfmt.Println(res)\n\n}\n", "src_uid": "f30329023e84b4c50b1b118dc98ae73c"} {"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\ts, _ := reader.ReadBytes('\\n')\n\tvar k uint64\n\treadUint64(s, 0, &k)\n\tres := solve(int64(k))\n\tfmt.Println(res)\n}\n\nfunc readInt(bytes []byte, from int, val *int) int {\n\ti := from\n\tsign := 1\n\tif bytes[i] == '-' {\n\t\tsign = -1\n\t\ti++\n\t}\n\ttmp := 0\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + int(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp * sign\n\treturn i\n}\n\nfunc readNum(reader *bufio.Reader) (a int) {\n\tbs, _ := reader.ReadBytes('\\n')\n\treadInt(bs, 0, &a)\n\treturn\n}\n\nfunc readTwoNums(reader *bufio.Reader) (a int, b int) {\n\tres := readNNums(reader, 2)\n\ta, b = res[0], res[1]\n\treturn\n}\n\nfunc readThreeNums(reader *bufio.Reader) (a int, b int, c int) {\n\tres := readNNums(reader, 3)\n\ta, b, c = res[0], res[1], res[2]\n\treturn\n}\n\nfunc readNNums(reader *bufio.Reader, n int) []int {\n\tres := make([]int, n)\n\tx := 0\n\tbs, _ := reader.ReadBytes('\\n')\n\tfor i := 0; i < n; i++ {\n\t\tfor x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {\n\t\t\tx++\n\t\t}\n\t\tx = readInt(bs, x, &res[i])\n\t}\n\treturn res\n}\n\nfunc readUint64(bytes []byte, from int, val *uint64) int {\n\ti := from\n\n\tvar tmp uint64\n\tfor i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {\n\t\ttmp = tmp*10 + uint64(bytes[i]-'0')\n\t\ti++\n\t}\n\t*val = tmp\n\n\treturn i\n}\n\nconst codeforces = \"codeforces\"\n\nfunc solve(k int64) string {\n\tn := len(codeforces)\n\n\tvar c int = 1\n\tcnt := make([]int, n)\n\tfor {\n\t\tvar prod int64 = 1\n\t\tfor i := 0; i < n; i++ {\n\t\t\tcnt[i] = c\n\t\t\tprod *= int64(c)\n\t\t}\n\t\tfor i := n - 1; i >= 0; i-- {\n\t\t\t//chang i + 1 to c + 1\n\t\t\tif prod >= k {\n\t\t\t\treturn createCodeforces(cnt)\n\t\t\t}\n\t\t\tcnt[i]++\n\t\t\tprod /= int64(c)\n\t\t\tprod *= int64(c + 1)\n\t\t}\n\n\t\tc++\n\t}\n}\n\nfunc product(cnt []int) int64 {\n\tvar res int64 = 1\n\tfor i := 0; i < len(cnt); i++ {\n\t\tres *= int64(cnt[i])\n\t}\n\treturn res\n}\n\nfunc createCodeforces(cnt []int) string {\n\tvar buf bytes.Buffer\n\n\tfor i := 0; i < len(codeforces); i++ {\n\t\tfor x := 0; x < cnt[i]; x++ {\n\t\t\tbuf.WriteByte(codeforces[i])\n\t\t}\n\t}\n\n\treturn buf.String()\n}\n\nfunc pow(a int64, b int) int64 {\n\tvar r int64 = 1\n\tfor b > 0 {\n\t\tif b&1 == 1 {\n\t\t\tr *= a\n\t\t}\n\t\ta *= a\n\t\tb >>= 1\n\t}\n\treturn r\n}\n", "src_uid": "8001a7570766cadcc538217e941b3031"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tscanner := bufio.NewReader(os.Stdin)\n\tprinter := bufio.NewWriter(os.Stdout)\n\tdefer printer.Flush()\n\tvar ntests int\n\tfmt.Fscan(scanner, &ntests)\nouter:\n\tfor iter := 0; iter < ntests; iter++ {\n\t\tvar x int\n\t\tfmt.Fscan(scanner, &x)\n\t\tx = x - 1\n\t\tvar arr [3]int\n\t\tfor i := 0; i < 3; i++ {\n\t\t\tfmt.Fscan(scanner, &arr[i])\n\t\t}\n\t\tnext := arr[x]\n\t\tif next == 0 {\n\t\t\tfmt.Fprintln(printer, \"NO\")\n\t\t\tcontinue outer\n\t\t}\n\t\tnext = arr[next-1]\n\t\tif next == 0 {\n\t\t\tfmt.Fprintln(printer, \"NO\")\n\t\t\tcontinue outer\n\t\t}\n\t\tfmt.Fprintln(printer, \"YES\")\n\t}\n}\n", "src_uid": "5cd113a30bbbb93d8620a483d4da0349"} {"source_code": "package main\n \nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n \nfunc main() {\n\tvar numbers string\n\tvar k int\n\tvar flag1 bool\n\tfmt.Scan(&k)\n\tfmt.Scan(&numbers)\n\tflag1 = checking(numbers, k)\n\tif flag1 == true {\n\t\tfmt.Println(strings.Count(numbers, \"8\"))\n \t} else {\n\t\t fmt.Println(k/11)\n\t }\n}\n \nfunc checking(str string, n int) bool {\n\tvar flag bool\n\tif n/11 >= strings.Count(str, \"8\") {\n\t\tflag = true\n\t} else{\n\t\tflag = false\n\t}\n\treturn flag\n}", "src_uid": "259d01b81bef5536b969247ff2c2d776"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar tt int\n\tfmt.Scanln(&tt)\n\tfor j := 0; j < tt; j++ {\n\t\tvar n int\n\t\tflag := false\n\t\tfmt.Scanln(&n)\n\t\tfor i := 2; i*i <= n; i++ {\n\t\t\tif n%i == 0 {\n\t\t\t\tfmt.Printf(\"%v %v\\n\", n/i, n-n/i)\n\t\t\t\tflag = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif !flag {\n\t\t\tfmt.Printf(\"%v %v\\n\", 1, n-1)\n\t\t}\n\t}\n\n}\n", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5"} {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1228C(_r io.Reader, _w io.Writer) {\n\tconst mod int64 = 1e9 + 7\n\tpow := func(x, n int64) int64 {\n\t\tres := int64(1)\n\t\tfor ; n > 0; n >>= 1 {\n\t\t\tif n&1 == 1 {\n\t\t\t\tres = res * x % mod\n\t\t\t}\n\t\t\tx = x * x % mod\n\t\t}\n\t\treturn res\n\t}\n\tvar x int\n\tvar n int64\n\tFscan(_r, &x, &n)\n\tprimes := []int64{}\n\tfor i := 2; i*i <= x; i++ {\n\t\tk := 0\n\t\tfor ; x%i == 0; x /= i {\n\t\t\tk++\n\t\t}\n\t\tif k > 0 {\n\t\t\tprimes = append(primes, int64(i))\n\t\t}\n\t}\n\tif x > 1 {\n\t\tprimes = append(primes, int64(x))\n\t}\n\tans := int64(1)\n\tfor _, p := range primes {\n\t\tc := int64(0)\n\t\tfor m := n; m > 0; m /= p {\n\t\t\tc += m / p\n\t\t}\n\t\tans = ans * pow(p, c) % mod\n\t}\n\tFprint(_w, ans)\n}\n\nfunc main() { CF1228C(os.Stdin, os.Stdout) }\n", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c"} {"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", "src_uid": "5802f52caff6015f21b80872274ab16c"} {"source_code": "// 290A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\ta := []string{\"Washington\", \"Adams\", \"Jefferson\", \"Madison\", \"Monroe\", \"Adams\", \"Jackson\", \"Van Buren\", \"Harrison\", \"Tyler\", \"Polk\", \"Taylor\", \"Fillmore\", \"Pierce\", \"Buchanan\", \"Lincoln\", \"Johnson\", \"Grant\", \"Hayes\", \"Garfield\", \"Arthur\", \"Cleveland\", \"Harrison\", \"Cleveland\", \"McKinley\", \"Roosevelt\", \"Taft\", \"Wilson\", \"Harding\", \"Coolidge\", \"Hoover\", \"Roosevelt\", \"Truman\", \"Eisenhower\", \"Kennedy\", \"Johnson\", \"Nixon\", \"Ford\", \"Carter\", \"Reagan\"}\n\tfmt.Scan(&n)\n\tfmt.Print(a[n-1])\n}\n", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a int\n\tolChar := \"abcd\"\n\tfromStoF := 0\n\tfromFtoS := 0\n\n\tfmt.Scanln(&a)\n\n\tvar inp string\n\tfmt.Scan(&inp)\n\n\tfor _, char := range inp {\n\t\tcharNew := string(char)\n\t\tif olChar != \"abcd\" {\n\t\t\tif charNew == \"S\" && charNew != olChar {\n\t\t\t\tfromFtoS++\n\t\t\t} else if charNew == \"F\" && charNew != olChar {\n\t\t\t\tfromStoF++\n\t\t\t}\n\t\t}\n\t\tolChar = charNew\n\t}\n\n\tif fromStoF > fromFtoS {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "src_uid": "ab8a2070ea758d118b3c09ee165d9517"} {"source_code": "package main\r\n \r\nimport \"fmt\"\r\n \r\nfunc main() {\r\n \r\n var first int\r\n \r\n fmt.Scanln(&first)\r\n \r\n fmt.Print(2 - first*first)\r\n}", "src_uid": "f76005f888df46dac38b0f159ca04d5f"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcoluna := make([]int, n)\n\t\n\tfor i := range coluna {\n\t\tfmt.Scan(&coluna[i])\n\t}\n\n\tfor {\n\t\tcolunasFaltando := 0\n\n\t\tfor i := len(coluna)-1; i > -1; i-- {\n\t\t\tif i != 0 {\n\t\t\t\tif coluna[i] < coluna[i-1] {\n\t\t\t\t\tcolunasFaltando += 1\n\t\t\t\t\tdif := math.Abs( float64(coluna[i]) - float64(coluna[i-1]) )\n\t\t\t\t\tcoluna[i] += int(dif)\n\t\t\t\t\tcoluna[i-1] -= int(dif)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif colunasFaltando == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\t\n\tvar s string = strconv.Itoa(coluna[0])\n\tfor i, e := range coluna {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\ts += \" \" + strconv.Itoa(e)\n\t}\n\tfmt.Println(s)\n}", "src_uid": "ae20712265d4adf293e75d016b4b82d8"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc solve() {\n\tvar st int\n\tReadf(\"%d\", &st)\n\n\tsqrt := int(math.Sqrt(float64(st)))\n\tvar a, b int\n\n\tvar ok bool\n\tfor i := 2; i <= sqrt; i++ {\n\t\tif st % i == 0 {\n\t\t\ta = i\n\t\t\tb = st / i\n\n\t\t\tok = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ok {\n\t\tWritef(\"%d%d\\n\", a, b)\n\t} else {\n\t\tWritef(\"-1\\n\")\n\t}\n}\n\nfunc main() {\n\t// If io still contains some buffered data flush it before\n\t// quiting\n\tdefer io.Flush()\n\n\t// Solution of the problem goes here\n\tsolve()\n}\n\nvar (\n\t// fmt.Print and fmt.Scan is slow, we will use bufio\n\t// for read and write from stdin.\n\tio = bufio.NewReadWriter(\n\t\tbufio.NewReader(os.Stdin),\n\t\tbufio.NewWriter(os.Stdout),\n\t)\n)\n\nfunc Readf(format string, args ...interface{}) {\n\tfmt.Fscanf(io, format, args...)\n}\n\nfunc Writef(format string, args ...interface{}) {\n\tfmt.Fprintf(io, format, args...)\n}\n", "src_uid": "7220f2da5081547a12118595bbeda4f6"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, k, a, summ, summ2 int\n\tfmt.Scanf(\"%d %d\\n\", &n, &k)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a)\n\t\tsumm2 += a\n\t\tif summ2 <= 8 {\n\t\t\tsumm += summ2\n\t\t\tsumm2 = 0\n\t\t} else {\n\t\t\tsumm += 8\n\t\t\tsumm2 -= 8\n\t\t}\n\t\tif summ >= k {\n\t\t\tfmt.Println(i + 1)\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Println(\"-1\")\n}\n", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a"} {"source_code": "package main\nimport \"fmt\"\n\nvar s75 = \"What are you doing at the end of the world? Are you busy? Will you save us?\"\nvar s34 = \"What are you doing while sending \\\"\"\nvar s32 = \"\\\"? Are you busy? Will you send \\\"\"\nvar s2 = \"\\\"?\"\n\nvar f = make([]uint64, 100001)\n\nfunc printChar(n int, k uint64) {\n\tif k > f[n] {\n\t\tfmt.Print(\".\")\n\t\treturn\n\t}\n\n\tif n == 0 {\n\t\tfmt.Print(string(s75[k-1]))\n\t\treturn\n\t}\n\n\tif k <= 34 {\n\t\tfmt.Print(string(s34[k-1]))\n\t\treturn\n\t}\n\n\tk -= 34\n\tif k <= f[n-1] {\n\t\tprintChar(n-1, k)\n\t\treturn\n\t}\n\n\tk -= f[n-1]\n\tif k <= 32 {\n\t\tfmt.Print(string(s32[k-1]))\n\t\treturn\n\t}\n\n\tk -= 32\n\tif k <= f[n-1] {\n\t\tprintChar(n-1, k)\n\t\treturn\n\t}\n\n\tk -= f[n-1]\n\tfmt.Print(string(s2[k-1]))\n}\n\n// calc len(fi)\nfunc main() {\n\t// 75\n\t//f0 := \"What are you doing at the end of the world? Are you busy? Will you save us?\"\n\t// 34 + 75(f0) + 32 + 75(f0) + 2 = 68\n\t//f1 := \"What are you doing while sending \\\"\" + f0 + \"\\\"? Are you busy? Will you send \\\"\" + f0 + \"\\\"?\"\n\t//nLen := len(f0)\n\t//fmt.Println(nLen)\n\t//fmt.Println(f1)\n\n\tf[0] = 75\n\t// range ptr/ref\n\tfor i := 1; i < 100001; i++ {\n\t\tf[i] = 34 + f[i-1] + 32 + f[i-1] + 2\n\t\t//if f[i] < f[i-1]\n\t\t//\tf[i]\n\t}\n\t//a := f[0:100]\n\t//for k,v := range a {\n\t//\tfmt.Println(k, v)\n\t//}\n\t//fmt.Println(a)\n\n\tvar q int\n\tfmt.Scan(&q)\n\tfor i := 0; i < q; i++ {\n\t\tvar n int\n\t\tvar k uint64\n\t\tfmt.Scan(&n, &k)\n\t\tprintChar(n, k)\n\t}\n\tfmt.Println()\n}\n", "src_uid": "da09a893a33f2bf8fd00e321e16ab149"} {"source_code": "package main\n\nimport (\n \"bufio\"\n \"io\"\n \"os\"\n \"sort\"\n \"strconv\"\n)\n\ntype Scanner struct {\n r io.Reader\n split bufio.SplitFunc\n maxTokenSize int\n token, buf []byte\n start, end int\n}\n\nfunc NewScanner(r io.Reader) *Scanner {\n return &Scanner{\n r: r,\n split: bufio.ScanWords,\n maxTokenSize: 16777216,\n buf: make([]byte, 4096),\n }\n}\n\nfunc (s *Scanner) advance(n int) bool {\n if n < 0 || n > s.end-s.start {\n return false\n }\n s.start += n\n return true\n}\n\nfunc (s *Scanner) Text() string {\n return string(s.token)\n}\n\nfunc (s *Scanner) Scan() bool {\n for {\n if s.end > s.start {\n advance, token, err := s.split(s.buf[s.start:s.end], false)\n if err != nil || !s.advance(advance) {\n return false\n }\n s.token = token\n if token != nil {\n return true\n }\n }\n if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {\n copy(s.buf, s.buf[s.start:s.end])\n s.end -= s.start\n s.start = 0\n }\n if s.end == len(s.buf) {\n if len(s.buf) >= s.maxTokenSize {\n return false\n }\n newSize := len(s.buf) * 2\n if newSize > s.maxTokenSize {\n newSize = s.maxTokenSize\n }\n newBuf := make([]byte, newSize)\n copy(newBuf, s.buf[s.start:s.end])\n s.buf = newBuf\n s.end -= s.start\n s.start = 0\n continue\n }\n for loop := 0; ; {\n n, _ := s.r.Read(s.buf[s.end:len(s.buf)])\n s.end += n\n if n > 0 {\n break\n }\n loop++\n if loop > 100 {\n break\n }\n }\n }\n}\n\nfunc (s *Scanner) Split(split bufio.SplitFunc) {\n s.split = split\n}\n\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\nvar sc *Scanner = NewScanner(os.Stdin)\n\nfunc next() string { sc.Scan(); return sc.Text() }\nfunc nc() byte { sc.Scan(); return sc.Text()[0] }\n\nfunc ni32() int {\n sc.Scan()\n n, _ := strconv.Atoi(sc.Text())\n return n\n}\n\nfunc ni64() int64 {\n sc.Scan()\n n, _ := strconv.ParseInt(sc.Text(), 10, 64)\n return n\n}\n\nfunc pri32(i ...int) {\n for _, ii := range i {\n w.WriteString(strconv.Itoa(ii))\n sp()\n }\n}\nfunc pri64(i ...int64) {\n for _, ii := range i {\n w.WriteString(strconv.FormatInt(ii, 10))\n sp()\n }\n}\nfunc sp() { w.WriteByte(' ') }\nfunc endl() { w.WriteByte('\\n') }\n\nfunc main() {\n x, y := make([]int, 8), make([]int, 8)\n for i := 0; i < 8; i++ {\n x[i], y[i] = ni32(), ni32()\n }\n // for i := 0; i < 8; i++ {\n // for j := i + 1; j < 8; j++ {\n // if x[j] < x[i] || (x[j] == x[i] && y[j] < y[i]) {\n // x[i], y[i], x[j], y[j] = x[j], y[j], x[i], y[i]\n // }\n // }\n // }\n xx, yy := make([]int, 8), make([]int, 8)\n copy(xx, x)\n copy(yy, y)\n sort.Ints(xx)\n sort.Ints(yy)\n xs, ys := []int{xx[0]}, []int{yy[0]}\n for i := 1; i < 8; i++ {\n if xx[i] != xx[i-1] {\n xs = append(xs, xx[i])\n }\n if yy[i] != yy[i-1] {\n ys = append(ys, yy[i])\n }\n }\n sort.Ints(xs)\n sort.Ints(ys)\n // fmt.Println(xs, ys)\n if len(xs) != 3 || len(ys) != 3 || xs[1] <= xs[0] || xs[2] <= xs[1] || ys[1] <= ys[0] || ys[2] <= ys[1] {\n w.WriteString(\"ugly\\n\")\n w.Flush()\n return\n }\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n ug := true\n for k := 0; k < 8; k++ {\n if x[k] == xs[i] && y[k] == ys[j] {\n ug = false\n }\n }\n if ((i != 1 || j != 1) && ug) || (i == 1 && j == 1 && !ug) {\n w.WriteString(\"ugly\\n\")\n w.Flush()\n return\n }\n }\n }\n w.WriteString(\"respectable\\n\")\n w.Flush()\n}\n", "src_uid": "f3c96123334534056f26b96f90886807"} {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n int\n fmt.Scanf(\"%d\", &n)\n if n<2 || n%2==1 {\n fmt.Println(0)\n return\n }\n k := 1;\n for i:=0;i= x && sum % 2 == x % 2 {\n\t\t\tfmt.Printf(\"%d\", i)\n\t\t\treturn\n\t\t}\n\t}\n}", "src_uid": "18644c9df41b9960594fdca27f1d2fec"} {"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; i c[i-1]*2 {\n\t\t\tc[i] = 2 * c[i-1]\n\t\t}\n\t}\n\n\tvar ans int64\n\tans = math.MaxInt64\n\tvar sum int64\n\tfor i := n - 1; i >= 0; i-- {\n\t\tvar need = k / (1 << uint(i))\n\t\tsum += need * c[i]\n\t\tk -= (need << uint(i))\n\t\tif k > 0 {\n\t\t\tans = min(ans, sum+c[i])\n\t\t} else {\n\t\t\tans = min(ans, sum)\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "src_uid": "04ca137d0383c03944e3ce1c502c635b"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := []byte(strconv.FormatInt(readInt64(), 10))\n\tb := []byte(strconv.FormatInt(readInt64(), 10))\n\tanum := make([]int, len(a))\n\tfor i := 0; i < len(a); i++ {\n\t\tanum[i] = int(a[i] - '0')\n\t}\n\tbnum := make([]int, len(b))\n\tfor i := 0; i < len(b); i++ {\n\t\tbnum[i] = int(b[i] - '0')\n\t}\n\tsort.Sort(sort.Reverse(sort.IntSlice(anum)))\n\tif len(a) == len(b) {\n\t\tdfs(anum, bnum, 0)\n\t}\n\tfor _, v := range anum {\n\t\tfmt.Print(v)\n\t}\n\tfmt.Println()\n}\n\nfunc dfs(anum []int, bnum []int, pos int) bool {\n\tif pos == len(anum) {\n\t\treturn true\n\t}\n\tprev := -1\n\tfor i := pos; i < len(anum); i++ {\n\t\tif anum[i] < bnum[pos] {\n\t\t\tanum[pos], anum[i] = anum[i], anum[pos]\n\t\t\tresort(anum, pos+1)\n\t\t\treturn true\n\t\t}\n\t\tif anum[i] <= bnum[pos] && prev != anum[i] {\n\t\t\tanum[pos], anum[i] = anum[i], anum[pos]\n\t\t\tresort(anum, pos+1)\n\t\t\tif dfs(anum, bnum, pos+1) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tresort(anum, pos)\n\t\t\tprev = anum[i]\n\t\t}\n\t}\n\treturn false\n}\n\nfunc resort(nums []int, pos int) {\n\tfor i := pos; i < len(nums)-1; i++ {\n\t\tfor j := i + 1; j < len(nums); j++ {\n\t\t\tif nums[i] < nums[j] {\n\t\t\t\tnums[i], nums[j] = nums[j], nums[i]\n\t\t\t}\n\t\t}\n\t}\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a, b int) int {\n\tfor {\n\t\tv := a % b\n\t\ta, b = b, v\n\t\tif b == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn a\n}\n\nfunc main() {\n\tvar a, b, n int\n\tfmt.Scan(&a, &b, &n)\n\n\tfor {\n\t\tgone := gcd(a, n)\n\t\tn -= gone\n\t\tif n == 0 {\n\t\t\tfmt.Print(0)\n\t\t\tbreak\n\t\t}\n\n\t\tgone = gcd(b, n)\n\t\tn -= gone\n\t\tif n == 0 {\n\t\t\tfmt.Print(1)\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar p,x,y int\n\tfmt.Scan(&p,&x,&y)\n\tans:=(p*y-1)/100-x+1\n\tif ans<0 {\n\t\tans=0\n\t}\n\tfmt.Println(ans)\n}", "src_uid": "7038d7b31e1900588da8b61b325e4299"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k int\n\tfmt.Scan(&k)\n\tma := 0\n\tfor i := 0; i < k; i++ {\n\t\tvar r int\n\t\tfmt.Scan(&r)\n\t\tif ma < r {\n\t\t\tma = r\n\t\t}\n\t}\n\tans := ma - 25\n\tif ans < 0 {\n\t\tans = 0\n\t}\n\tfmt.Println(ans)\n}\n", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd"} {"source_code": "package main\n\nimport (\"fmt\"\n\t\"sync\"\n\n\t\"math\"\n)\n\n\n\n\ntype changer func(int64) (int64, int)\n\nvar min struct {\n \tmt sync.RWMutex\n\tdata int\n}\n\n\nfunc decision(p int64, x int64, y int64, f changer, wg* sync.WaitGroup ) {\n\tdefer wg.Done()\n\ts := x\n\trandomizer := func() bool{\n\t\ti := (s / 50) % 475\n\t\tfor j:=0 ; j< 25; j++ {\n\t\t\ti = (i * 96 + 42) % 475\n\t\t\tif 26+i == p {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\tcur := 0\n\tflag := true\n\tfor;flag;{\n\t\tif randomizer() {\n\t\t\tmin.mt.Lock()\n\t\t\tif min.data > cur {\n\t\t\t\tmin.data = cur\n\t\t\t}\n\t\t\tmin.mt.Unlock()\n\t\t\treturn\n\t\t}\n\t\tmin.mt.RLock()\n\t\tif min.data < cur {\n\t\t\tflag = false\n\t\t} else {\n\t\t\tvar dt int\n\t\t\ts, dt = f(s)\n\t\t\tcur += dt\n\t\t}\n\t\tmin.mt.RUnlock()\n\t\tif y>s{\n\t\t\tflag = false\n\t\t}\n\t}\n}\n\nfunc decision_starter(p int64, x int64, y int64, f changer, wg* sync.WaitGroup) {\n\twg.Add(1)\n\tdecision(p,x,y,f,wg)\n}\n\nfunc main() {\n\tstrat1 := func(num int64)(int64,int) {\n\t\tnum+=100\n\t\treturn num,1\n\t}\n\tstrat2 := func(num int64)(int64,int) {\n\t\tnum-=50\n\t\treturn num,0\n\t}\n\tflag := true\n\tstrat3 := func(num int64)(int64,int) {\n\t\tif flag {\n\t\t\tnum+=50\n\t\t\tflag = false\n\t\t\treturn num,1\n\t\t}\n\n\t\tnum+=100\n\t\treturn num,1\n\t}\n\tvar p,x,y int64\n\twg := sync.WaitGroup{}\n\tfmt.Scanf(\"%d %d %d\",&p,&x,&y)\n\t//26 7258 6123\n\t//p = 26\n\t//x = 7258\n\t//y = 6123\n\tmin.data = math.MaxInt32\n\tdecision_starter(p,x,y,strat1,&wg)\n\tdecision_starter(p,x,y,strat2,&wg)\n\tdecision_starter(p,x,y,strat3,&wg)\n\twg.Wait()\n\tmin.mt.RLock()\n\tfmt.Printf(\"%d \",min.data)\n\tmin.mt.RUnlock()\n}", "src_uid": "c9c22e03c70a94a745b451fc79e112fd"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc div8(s string) (bool, int) {\n\tseenDigits := make(map[int]bool)\n\tseenTwoDigits := make(map[int]bool)\n\tfor i := len(s) - 1; i >= 0; i-- {\n\t\tdigit := int(s[i] - '0')\n\n\t\tif digit == 8 || digit == 0 {\n\t\t\treturn true, digit\n\t\t}\n\n\t\t// fmt.Println(\"Digit\", digit)\n\n\t\tfor seenTwoDigit := range seenTwoDigits {\n\t\t\tthreeDigit := digit*100 + seenTwoDigit\n\t\t\t// fmt.Println(\"Checked three\", threeDigit)\n\t\t\tif (threeDigit)%8 == 0 {\n\t\t\t\treturn true, threeDigit\n\t\t\t}\n\t\t}\n\n\t\tfor seenDigit := range seenDigits {\n\t\t\ttwoDigit := digit*10 + seenDigit\n\t\t\t// fmt.Println(\"Checked two\", twoDigit)\n\t\t\tif twoDigit != 0 && (twoDigit)%8 == 0 {\n\t\t\t\treturn true, twoDigit\n\t\t\t}\n\t\t\tseenTwoDigits[twoDigit] = true\n\t\t}\n\n\t\tseenDigits[digit] = true\n\t}\n\n\treturn false, 0\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\\n\", &s)\n\n\tif valid, i := div8(s); valid {\n\t\tfmt.Println(\"YES\")\n\t\tfmt.Println(i)\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "src_uid": "0a2a5927d24c70aca24fc17aa686499e"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar n, tot int\n\tscanf(\"%d\\n\", &n)\n\tarr := []int{}\n\tans := []int{}\n\tans = append(ans, 1)\n\tfor i := 0; i < n; i++ {\n\t\tvar t int\n\t\tscanf(\"%d\", &t)\n\t\ttot += t\n\t\tarr = append(arr, t)\n\t}\n\tcur := arr[0]\n\tfor i := 1; i < n; i++ {\n\t\tif arr[i]*2 <= arr[0] {\n\t\t\tcur += arr[i]\n\t\t\tans = append(ans, i+1)\n\t\t}\n\t}\n\tif cur > tot-cur {\n\n\t\tprintf(\"%d\\n\", len(ans))\n\t\tfor i := 0; i < len(ans); i++ {\n\t\t\tprintf(\"%d \", ans[i])\n\t\t}\n\t} else {\n\t\tprintf(\"0\")\n\t}\n}\n", "src_uid": "0a71fdaaf08c18396324ad762b7379d7"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tvar r, g, b int64\n\tfor I(&r, &g, &b) == nil {\n\t\tsolve(r, g, b)\n\t}\n\tw.Flush()\n}\n\nfunc solve(r, g, b int64) {\n\tans := (r + g + b) / 3\n\tmin(&ans, r+g)\n\tmin(&ans, r+b)\n\tmin(&ans, b+g)\n\tO(ans, \"\\n\")\n}\n\nfunc min(a *int64, b int64) {\n\tif *a > b {\n\t\t*a = b\n\t}\n}\n", "src_uid": "bae7cbcde19114451b8712d6361d2b01"} {"source_code": "// cf483a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r int64\n\tvar a, b, c int64\n\tfmt.Scan(&l, &r)\n\tif r-l < 2 {\n\t\tfmt.Println(-1)\n\t} else {\n\t\ta = l\n\t\tb = l + 1\n\t\tfor a < r-1 && b < r {\n\t\t\tfor c = b + 1; c <= r; c++ {\n\t\t\t\tf := true\n\t\t\t\tfor j := 2; j < 50; j++ {\n\t\t\t\t\tif b%int64(j) == 0 && c%int64(j) == 0 {\n\t\t\t\t\t\tf = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif f {\n\t\t\t\t\tflag := false\n\t\t\t\t\tfor i := 2; i < 50; i++ {\n\t\t\t\t\t\tif a%int64(i) == 0 && c%int64(i) == 0 {\n\t\t\t\t\t\t\tflag = true\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\tif flag {\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 c <= r {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\ta++\n\t\t\t\tb++\n\t\t\t}\n\t\t}\n\t\tif c > r {\n\t\t\tfmt.Println(-1)\n\t\t} else {\n\t\t\tfmt.Println(a, b, c)\n\t\t}\n\n\t}\n\n}\n", "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(s1,s2 string, f *[105]bool) bool {\n for _, v1 := range s1 {\n found := false\n for i, v2 := range s2 {\n if (v1 == v2) && !f[i] {\n f[i] = true\n found = true\n break\n }\n }\n if !found { return false }\n }\n return true\n}\n\nfunc main() {\n var guest,host,pile string\n var f [105]bool\n fmt.Scan(&guest,&host,&pile)\n ans := true\n if (len(pile) != (len(guest)+len(host))) {\n ans = false\n } else {\n ans = ans && check(guest,pile,&f)\n ans = ans && check(host,pile,&f)\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n", "src_uid": "b6456a39d38fabcd25267793ed94d90c"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tbuf := &bytes.Buffer{}\n\tfor i := 0; i < 400; i++ {\n\t\tfmt.Fprintf(buf, \"%d\", i)\n\t}\n\tfmt.Println(buf.Bytes()[getInt()] - '0')\n}\n\ntype Input struct {\n\t*bufio.Scanner\n}\n\nvar globalInput = wrapStdin()\n\nfunc wrapStdin() Input {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\treturn Input{Scanner: sc}\n}\nfunc getInt() int {\n\tglobalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x\n}\nfunc getIntOk() (int, bool) {\n\tok := globalInput.Scan()\n\tx, _ := strconv.Atoi(globalInput.Text())\n\treturn x, ok\n}\nfunc getNint(n int) []int {\n\tv := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tv[i] = getInt()\n\t}\n\treturn v\n}\nfunc getVint(v []int) bool {\n\tvar ok bool\n\tfor i := 0; i < len(v); i++ {\n\t\tv[i], ok = getIntOk()\n\t}\n\treturn ok\n}\n", "src_uid": "2d46e34839261eda822f0c23c6e19121"} {"source_code": "// 62A-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, d, x, y, res int\n\tfmt.Scan(&a, &b, &c, &d, &x, &y)\n\tfor i := x; i <= y; i++ {\n\t\tif ((((i % a) % b) % c) % d) == i {\n\t\t\tres++\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a"} {"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.NextLong()\n\tK := io.NextLong()\n\t\n\tif K >= 1024 {\n\t io.Println(\"No\")\n\t return\n\t}\n\t\n\tfor i := int64(1); i <= K; i++ {\n\t if (N + 1) % i != 0 {\n\t io.Println(\"No\")\n\t return\n\t }\n\t}\n\tio.Println(\"Yes\")\n}\n\nfunc smallestDivisor(n int64) int64 {\n if n % 2 == 0 {\n return 2\n }\n for d := int64(3); d * d <= n; d += 2 {\n if n % d == 0 {\n return d\n }\n }\n return n\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF106C(_r io.Reader, out io.Writer) {\n\tin := bufio.NewReader(_r)\n\tmin := func(a, b int) int {\n\t\tif a < b {\n\t\t\treturn a\n\t\t}\n\t\treturn b\n\t}\n\tmax := func(a, b int) int {\n\t\tif a > b {\n\t\t\treturn a\n\t\t}\n\t\treturn b\n\t}\n\n\tvar maxW, n, a, b int\n\tFscan(in, &maxW, &n)\n\tn++\n\tweights := make([]int, n)\n\tvalues := make([]int, n)\n\tstocks := make([]int, n)\n\tFscan(in, &weights[0], &values[0])\n\tstocks[0] = maxW / weights[0]\n\tfor i := 1; i < n; i++ {\n\t\tFscan(in, &a, &b, &weights[i], &values[i])\n\t\tstocks[i] = a / b\n\t}\n\n\tdp := make([]int, maxW+1)\n\tfor i, v := range values {\n\t\tnum, w := stocks[i], weights[i]\n\t\tfor k := 1; num > 0; k <<= 1 {\n\t\t\tK := min(k, num)\n\t\t\tfor j := maxW; j >= K*w; j-- {\n\t\t\t\tdp[j] = max(dp[j], dp[j-K*w]+K*v)\n\t\t\t}\n\t\t\tnum -= K\n\t\t}\n\t}\n\tFprint(out, dp[maxW])\n}\n\nfunc main() { CF106C(os.Stdin, os.Stdout) }\n", "src_uid": "4e166b8b44427b1227e0f811161d3a6f"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner\nvar writer *bufio.Writer\n\nfunc init() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter = bufio.NewWriter(os.Stdout)\n}\n\nfunc nextToken() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tv, _ := strconv.Atoi(nextToken())\n\treturn v\n}\n\nfunc nextInt64() int64 {\n\tv, _ := strconv.ParseInt(nextToken(), 10, 64)\n\treturn v\n}\n\nfunc nextFloat() float64 {\n\tv, _ := strconv.ParseFloat(nextToken(), 64)\n\treturn v\n}\n\nfunc printInt(x int) {\n\twriter.WriteString(strconv.Itoa(x))\n}\n\nvar n int\nvar s string\nvar a [500][500]int\n\nfunc main() {\n\tn = nextInt()\n\ts = nextToken()\n\tx, y := 250, 250\n\ta[x][y] = 1\n\tans := 0\n\tfor _, c := range s {\n\t\tswitch c {\n\t\tcase 'U':\n\t\t\ty++\n\t\tcase 'D':\n\t\t\ty--\n\t\tcase 'L':\n\t\t\tx--\n\t\tcase 'R':\n\t\t\tx++\n\t\t}\n\t\tans += a[x][y]\n\t\ta[x][y]++\n\t}\n\tprintInt(ans)\n\twriter.Flush()\n}\n", "src_uid": "7bd5521531950e2de9a7b0904353184d"} {"source_code": "// 344B-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n [3]int\n fmt.Scan(&n[0], &n[1], &n[2])\n b := n[0] + n[1] + n[2]\n if b%2 == 0 && n[0] <= n[1]+n[2] && n[1] <= n[0]+n[2] && n[2] <= n[0]+n[1] {\n fmt.Print((n[0] + n[1] - n[2]) / 2)\n fmt.Print(\" \")\n fmt.Print((n[2] + n[1] - n[0]) / 2)\n fmt.Print(\" \")\n fmt.Print((n[0] + n[2] - n[1]) / 2)\n fmt.Println()\n } else {\n fmt.Println(\"Impossible\")\n }\n}\n", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"unicode\"\n)\n\nvar stdReader *bufio.Reader = bufio.NewReader(os.Stdin)\n\nfunc readInt() (result int) {\n\tvar negative, started bool\nREADER_LOOP:\n\tfor {\n\t\tchar, err := stdReader.ReadByte()\n\t\tswitch {\n\t\tcase err != nil:\n\t\t\tbreak READER_LOOP\n\t\tcase char == '-':\n\t\t\tnegative = true\n\t\tcase unicode.IsDigit(rune(char)):\n\t\t\tstarted = true\n\t\t\tresult = result*10 + int(char&0xf)\n\t\tcase started:\n\t\t\tbreak READER_LOOP\n\t\t}\n\t}\n\tif negative {\n\t\tresult = -result\n\t}\n\treturn\n}\n\nfunc innout(a, t [5]int) (int, int) {\n\tvar in, out int\n\tfor i := range a {\n\t\td := t[i]/2 - a[i]\n\t\tif d > 0 {\n\t\t\tin += d\n\t\t} else {\n\t\t\tout += -d\n\t\t}\n\t}\n\treturn in, out\n}\n\nfunc main() {\n\tn := readInt()\n\tvar a, b, t [5]int\n\tfor i := 0; i < n; i++ {\n\t\ta[readInt()-1]++\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tb[readInt()-1]++\n\t}\n\tfor i := range t {\n\t\tt[i] = a[i] + b[i]\n\t\tif t[i]%2 != 0 {\n\t\t\tfmt.Println(\"-1\")\n\t\t\treturn\n\t\t}\n\t}\n\tina, outa := innout(a, t)\n\tinb, outb := innout(b, t)\n\tif ina != outb || outa != inb {\n\t\tfmt.Println(\"-1\")\n\t\treturn\n\t}\n\tfmt.Println((ina + outa) / 2)\n}\n", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3"} {"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", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst N = 11\n\ntype Deck struct {\n\tcards []int\n}\n\nfunc (d *Deck) addCard(c int) {\n\td.cards = append(d.cards, c)\n}\n\nfunc (d *Deck) isLosing() bool {\n\treturn len(d.cards) == 0\n}\n\nfunc (d *Deck) hash() int64 {\n\tvar h int64\n\tfor _, c := range d.cards {\n\t\th = N*h + int64(c+1)\n\t}\n\treturn h\n}\n\nfunc oneRound(d1, d2 *Deck) {\n\tvar c1, c2 int\n\tc1, d1.cards = d1.cards[0], d1.cards[1:]\n\tc2, d2.cards = d2.cards[0], d2.cards[1:]\n\td := d1\n\tif c1 < c2 {\n\t\tc1, c2 = c2, c1\n\t\td = d2\n\t}\n\td.addCard(c2)\n\td.addCard(c1)\n}\n\nfunc makeKey(d1, d2 Deck) string {\n\treturn strconv.FormatInt(d1.hash(), N) + \"#\" + strconv.FormatInt(d2.hash(), N)\n}\n\nfunc main() {\n\tnextInt()\n\tvar d1, d2 Deck\n\tk1 := nextInt()\n\tfor i := 0; i < k1; i++ {\n\t\td1.addCard(nextInt() - 1)\n\t}\n\tk2 := nextInt()\n\tfor i := 0; i < k2; i++ {\n\t\td2.addCard(nextInt() - 1)\n\t}\n\twas := make(map[string]struct{})\n\tfor rounds := 0; ; rounds++ {\n\t\tif d1.isLosing() {\n\t\t\tfmt.Println(rounds, 2)\n\t\t\treturn\n\t\t}\n\t\tif d2.isLosing() {\n\t\t\tfmt.Println(rounds, 1)\n\t\t\treturn\n\t\t}\n\t\tkey := makeKey(d1, d2)\n\t\tif _, ok := was[key]; ok {\n\t\t\tbreak\n\t\t}\n\t\twas[key] = struct{}{}\n\t\toneRound(&d1, &d2)\n\t}\n\tfmt.Println(-1)\n}\n\nfunc init() {\n\t// maybe defer writer.Flush() in main\n\n\tlineScanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\n\t/*\n\t\tinputFile, err := os.Open(\"a.in\")\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\toutputFile, err := os.Create(\"a.out\")\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tlineScanner = bufio.NewScanner(inputFile)\n\t\twriter = bufio.NewWriter(outputFile)\n\t*/\n\n\twordScanner = bufio.NewScanner(strings.NewReader(\"\"))\n\twordScanner.Split(bufio.ScanWords)\n}\n\nvar lineScanner *bufio.Scanner\nvar wordScanner *bufio.Scanner\n\nvar writer *bufio.Writer\n\nfunc nextLine() (string, error) {\n\tif !lineScanner.Scan() {\n\t\tif err := lineScanner.Err(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\treturn \"\", errors.New(\"nextLine: EOF reached\")\n\t}\n\treturn lineScanner.Text(), nil\n}\n\nfunc nextWord() string {\n\tfor !wordScanner.Scan() {\n\t\tif err := wordScanner.Err(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tline, err := nextLine()\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\twordScanner = bufio.NewScanner(strings.NewReader(line))\n\t\twordScanner.Split(bufio.ScanWords)\n\t}\n\treturn wordScanner.Text()\n}\n\nfunc nextInt() int {\n\tres, err := strconv.Atoi(nextWord())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc nextInt64() int64 {\n\tres, err := strconv.ParseInt(nextWord(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc nextFloat64() float64 {\n\tres, err := strconv.ParseFloat(nextWord(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e"} {"source_code": "package main\nimport \"fmt\"\n\n\n\n\nfunc main() {\n\tsdeck := make([]string, 8)\n\tfor i := 0; i < 8; i++{\n\t\tfmt.Scan(&sdeck[i])\n\t}\n\tvar deck [8][8]int\n\tcount := 0\n\tfor i, s := range sdeck{\n\t\tfor j, c := range s{\n\t\t\tif c == 'B'{\n\t\t\t\tdeck[i][j] = 1\n\t\t\t}else{\n\t\t\t\tdeck[i][j] = 0\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 8; i++{\n\t\tsum := 0\n\t\tfor j := 0; j < 8; j++ {\n\t\t\tif deck[i][j] == 1{\n\t\t\t\tsum++\n\t\t\t}\n\t\t}\n\t\tif sum == 8 {\n\t\t\tcount++\n\t\t}\n\t}\n\tif count < 8{\n\t\tfor i := 0; i < 8; i++{\n\t\t\tsum := 0\n\t\t\tfor j := 0; j < 8; j++ {\n\t\t\t\tif deck[j][i] == 1{\n\t\t\t\t\tsum++\n\t\t\t\t}\n\t\t\t}\n\t\t\tif sum == 8 {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(count)\n}", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar (\n\tmod int64 = 1000000007\n)\n\nfunc range3(l int64) []int64 {\n\tans := make([]int64, 3)\n\tans[0] = l / 3\n\tans[1] = (l + 2) / 3\n\tans[2] = (l + 1) / 3\n\treturn ans\n}\nfunc solve(l, r int64) []int64 {\n\tans := range3(r)\n\tlans := range3(l - 1)\n\tfor i := 0; i < 3; i++ {\n\t\tans[i] -= lans[i]\n\t}\n\treturn ans\n}\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar n int\n\tvar l, r int64\n\tfmt.Fscanf(buf, \"%d %d %d\\n\", &n, &l, &r)\n\n\tcnt := solve(l, r)\n//\tfmt.Printf(\"cnt=%v\\n\",cnt)\n\tdp := make([][]int64, 2)\n\tdp[0] = make([]int64, 3)\n\tdp[1] = make([]int64, 3)\n\tf := 1\n\tdp[0][0] = cnt[0]\n\tdp[0][1] = cnt[1]\n\tdp[0][2] = cnt[2]\n//\tfmt.Printf(\"ans=%v\\n\",dp[0])\n\tfor i := 0; i < n-1; i++ {\n\t\tpre := f^1\n\t\tfor j:=0;j < 3;j++{\n\t\t\tdp[f][j] = 0\n\t\t\tfor k:=0;k < 3;k++{\n\t\t\t\tto := (3+j-k)%3\n\t\t\t\tdp[f][j] += (dp[pre][k]*cnt[to])%mod\n\t\t\t\tdp[f][j] = dp[f][j]%mod\n\t\t\t}\n\t\t}\n\t//\tfmt.Printf(\"ans=%v\\n\",dp[f])\n\t\tf = pre\n\n\t}\n\tfmt.Printf(\"%d\\n\", dp[f^1][0])\n\n}\n", "src_uid": "4c4852df62fccb0a19ad8bc41145de61"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar l, r int\n\tfmt.Scanf(\"%d %d\", &l, &r)\n\n\tfor ; l <= r; l++ {\n\t\tvar m = make(map[int32]struct{})\n\t\tlStr := strconv.Itoa(l)\n\n\t\tfor _, c := range lStr {\n\t\t\tm[c] = struct{}{}\n\t\t}\n\n\t\tif len(m) == len(lStr) {\n\t\t\tfmt.Println(lStr)\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(-1)\n}\n", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7"} {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"io/ioutil\"\r\n\t\"os\"\r\n\t\"strings\"\r\n)\r\n\r\nfunc CFc(_r io.Reader, _w io.Writer) {\r\n\tin := bufio.NewReader(_r)\r\n\tout := bufio.NewWriter(_w)\r\n\tdefer out.Flush()\r\n\r\n\t// single test case\r\n\r\n\tvar s string\r\n\tFscan(in, &s)\r\n\r\n\t// a := strings.Split(s, \"\")\r\n\r\n\tb := []byte(s)\r\n\r\n\t// for k := range b {\r\n\t// \tFprint(out, b[k]-'A', \" \")\r\n\t// }\r\n\r\n\tif len(b) < 2 {\r\n\t\tFprint(out, \"YES\")\r\n\t} else {\r\n\t\tresult := \"YES\"\r\n\t\tpre := b[0] - 'A'\r\n\t\tcur := b[1] - 'A'\r\n\t\tfor i := 2; i < len(b); i++ {\r\n\t\t\tif (pre+cur)%26 == b[i]-'A' {\r\n\t\t\t\tpre = cur\r\n\t\t\t\tcur = b[i] - 'A'\r\n\t\t\t} else {\r\n\t\t\t\t// Fprint(out, cur, \"===\")\r\n\t\t\t\tresult = \"NO\"\r\n\t\t\t\tbreak\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tFprint(out, result)\r\n\t}\r\n\r\n\t// \uc785\ub825 \uc5d0\ub7ec \ubc29\uc9c0\r\n\t_leftData, _ := ioutil.ReadAll(in)\r\n\tif _s := strings.TrimSpace(string(_leftData)); _s != \"\" {\r\n\t\tpanic(\"\uc77d\uc9c0\uc54a\uc740 \ub370\uc774\ud130 \ubc1c\uacac\uff1a\\n\" + _s)\r\n\t}\r\n}\r\n\r\n// LETYLETYLETY\r\nfunc main() { CFc(os.Stdin, os.Stdout) }\r\n\r\n// YTELYTELYTEL\r\n", "src_uid": "27e977b41f5b6970a032d13e53db2a6a"} {"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 weights := map[rune]int{\n 'Q': 9, 'R': 5, 'B': 3, 'N': 3, 'P': 1,\n 'q': -9, 'r': -5, 'b': -3, 'n': -3, 'p': -1 }\n total := 0\n for r := 0; r < 8; r++ {\n s := getS()\n for _, char := range s {\n total += weights[char]\n }\n }\n result := \"Draw\"\n if total > 0 {\n result = \"White\"\n } else if total < 0 {\n result = \"Black\"\n }\n writer.WriteString(fmt.Sprintf(\"%s\\n\", result))\n}\n", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc check(num, i int64) int64 {\n\tvar count, divider int64 = 0, 5\n\n\tfor (i / divider) > 0 {\n\t\tcount += i / divider\n\t\tdivider *= 5\n\t}\n\n\treturn count\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tn, _ := reader.ReadString('\\n')\n\tvar num, result, flag int64\n\tfmt.Sscanf(n, \"%d\", &num)\n\tvar i int64 = 1\n\n\tfor {\n\n\t\tresult = check(num, i)\n\n\t\tif result > num {\n\t\t\tif flag == 0 {\n\t\t\t\tfmt.Print(0)\n\t\t\t}\n\t\t\tbreak\n\t\t} else if result == num {\n\n\t\t\tif flag == 0 {\n\t\t\t\tfmt.Println(5)\n\t\t\t\tflag = 1\n\t\t\t}\n\n\t\t\tfmt.Printf(\"%d \", i)\n\t\t}\n\n\t\ti++\n\t}\n\n\tfmt.Println()\n}\n", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanInt := func() int {\n\t\tscanner.Scan()\n\t\tnum, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\treturn num\n\t}\n\n\tn := scanInt()\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = scanInt()\n\t}\n\n\tsolutionCount := uint(math.Pow(2.0, float64(n)))\n\tfor i := uint(0); i < solutionCount; i++ {\n\t\tsum := 0\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif (i>>uint(j))&1 == 1 {\n\t\t\t\tsum += a[j]\n\t\t\t} else {\n\t\t\t\tsum -= a[j]\n\t\t\t}\n\t\t}\n\t\tif sum%360 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}\n", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, t int\n\tvar line string\n\tfmt.Scan(&n, &t, &line)\n\n\tqueue := []byte(line)\n\tfor i := 0; i < t; i++ {\n\t\tfor j := 0; j < len(queue)-1; j++ {\n\t\t\tif queue[j] == 'B' && queue[j+1] == 'G' {\n\t\t\t\tqueue[j], queue[j+1] = queue[j+1], queue[j]\n\t\t\t\tj++\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Print(string(queue))\n\n}\n", "src_uid": "964ed316c6e6715120039b0219cc653a"} {"source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar pp, dd, x, y, t int64\n\tfmt.Scan(&pp, &dd)\n\tx=pp\n\ty=1\n\tfor i:=0; i<=18; i++ {\n\t\tt=x%y\n\t\tif t==y-1 {\n\t\t\tpp=x\n\t\t} else if t
= l {\n\t\t\ta = append(a[n-1:], a[:n-1]...)\n\t\t\ta[0] = a[0] % l\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}\n", "src_uid": "3d931684ca11fe6141c6461e85d91d63"} {"source_code": "\ufeffpackage main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,k,l,c,d,p,nl,np,a int\n\tfmt.Scan(&n,&k,&l,&c,&d,&p,&nl,&np)\n\tk*=l\n\tc*=d\n\tk/=nl\n\tp/=np\n\tif k>p {\n\t\ta=p\n\t} else {a=k}\n\tif a>c {\n\t\ta=c\n\t}\n\tfmt.Println(a/n)\n}\n\n\n\n\n\n\n\n\n\n\n\n", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner\nvar t [1e6 + 1]bool\n\nfunc init_scanner() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024 * 20\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tscanner.Scan()\n\tval, _ := strconv.Atoi(scanner.Text())\n\treturn val\n}\n\nfunc main() {\n\tinit_scanner()\n\tsize, ans := readInt(), 0\n\tm := make(map[int]bool)\n\tfor i := 0; i < size; i++ {\n\t\tx := readInt()\n\t\tif x > 0 && !m[x] {\n\t\t\tans += 1\n\t\t\tm[x] = true\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "src_uid": "3b520c15ea9a11b16129da30dcfb5161"} {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF16C(in io.Reader, out io.Writer) {\n\tgcd := func(a, b int) int {\n\t\tfor a != 0 {\n\t\t\ta, b = b%a, a\n\t\t}\n\t\treturn b\n\t}\n\tvar a, b, x, y int\n\tFscan(in, &a, &b, &x, &y)\n\tg := gcd(x, y)\n\tx /= g\n\ty /= g\n\tk := a / x\n\tif b/y < k {\n\t\tk = b / y\n\t}\n\tif k > 0 {\n\t\tFprint(out, x*k, y*k)\n\t} else {\n\t\tFprint(out, 0, 0)\n\t}\n}\n\nfunc main() { CF16C(os.Stdin, os.Stdout) }\n", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a"} {"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", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc isSubsequence(s, t string) bool {\n\tif len(s) < len(t) {\n\t\treturn false\n\t}\n\n\ti, j := 0, 0\n\n\tfor j < len(t) && i < len(s) {\n\t\tif s[i] == t[j] {\n\t\t\ti++\n\t\t\tj++\n\t\t} else {\n\t\t\ti++\n\t\t}\n\t}\n\n\treturn j == len(t)\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar (\n\t\ts, t string\n\t)\n\n\t// file, err := os.Open(\"input.txt\")\n\t// if err != nil {\n\t// \tpanic(err)\n\t// }\n\n\t// reader := bufio.NewReader(file)\n\n\treader := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\tfmt.Fscanf(reader, \"%s\\n\", &t)\n\n\tif s == t {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tvar maxLen = -1\n\tfor l := 0; l < len(s); l++ {\n\t\tfor r := l; r < len(s); r++ {\n\t\t\ta := string(s[:l])\n\t\t\tb := string(s[r+1:])\n\t\t\tnewS := strings.Join([]string{a, b}, \"\")\n\n\t\t\tif isSubsequence(newS, t) {\n\t\t\t\tmaxLen = max(r-l+1, maxLen)\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(maxLen)\n\n}\n", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar totalNum, currentNum, showSize int\n\tfmt.Scanf(\"%d\", &totalNum)\n\tfmt.Scanf(\"%d\", ¤tNum)\n\tfmt.Scanf(\"%d\", &showSize)\n\n\tif currentNum - showSize > 1 {\n\t\tfmt.Print(\"<< \")\n\t}\n\tfor i := showSize; i >0; i-- {\n\n\t\tshowNum := currentNum - i\n\t\tif showNum >= 1 {\n\t\t\tfmt.Printf(\"%d \", currentNum - i)\n\t\t} else {\n\t\t\tcontinue\n\t\t}\n\t}\n\tfmt.Printf(\"(%d)\", currentNum)\n\tfor i := 1; i <= showSize; i++ {\n\t\tshowNum := currentNum + i\n\t\tif showNum > totalNum {\n\t\t\tbreak\n\t\t} else {\n\t\t\tfmt.Printf(\" %d\", showNum)\n\t\t}\n\t}\n\tif(currentNum + showSize < totalNum) {\n\t\tfmt.Print(\" >>\")\n\t}\n}\n", "src_uid": "526e2cce272e42a3220e33149b1c9c84"} {"source_code": "package main \nimport \"fmt\"\n\nfunc main(){\n\tvar n int64\n\tfmt.Scan(&n)\n\tif n%2 == 0{\n\t\tfmt.Println(2)\n\t}else{\n\t\tfmt.Println(1)\n\t}\n}", "src_uid": "816ec4cd9736f3113333ef05405b8e81"} {"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 scanner.Scan()\n\tstr := scanner.Text()\n\tk := ReadInt()\n\n\tast := 0\n\tinter := 0\n\n\tfor i := 0; i < len(str); i++ {\n\t\tif string(str[i]) == \"?\" {\n\t\t\tinter++\n\t\t} else if string(str[i]) == \"*\" {\n\t\t\tast++\n\t\t}\n\t}\n\n\tmenor := len(str) - (2*ast) - (2*inter)\n\tif k < menor {\n \t\twriter.WriteString(\"Impossible\")\n \t\treturn\n\t}\n\n\tresp := \"\"\n\n\tif ast > 0 {\n\t\tachei := false\n\n\t\trep := k - menor\n\n\t\tfor i := 0; i < len(str)-1; i++ {\n\t\t\tif string(str[i+1]) == \"*\" && achei == false {\n\t\t\t\tachei = true\n\t\t\t\tfor rep > 0 {\n\t\t\t\t\tresp += string(str[i])\n\t\t\t\t\trep--\n\t\t\t\t}\n\t\t\t\ti++\n\t\t\t} else if string(str[i+1]) == \"?\" || string(str[i+1]) == \"*\" {\n\t\t\t\ti++\n\t\t\t} else {\n\t\t\t\tresp += string(str[i])\n\t\t\t}\n\t\t}\n\n\t\tif string(str[len(str)-1]) != \"?\" && string(str[len(str)-1]) != \"*\" {\n\t\t\tresp += string(str[len(str)-1])\n\t\t}\n\n \t\twriter.WriteString(resp)\n \t\treturn\n\t}\n\n\tdif := len(str) - inter - k\n\n\tif dif < 0 {\n\t\twriter.WriteString(\"Impossible\")\n \t\treturn\n\t}\n\n\tresp = \"\"\n\n\tfor i := 0; i < len(str)-1; i++ {\n\t\tif string(str[i+1]) == \"?\" && dif > 0 {\n\t\t\tdif--\n\t\t\ti++\n\t\t} else if string(str[i+1]) == \"?\" && dif == 0 {\n\t\t\tresp += string(str[i])\n\t\t\ti++\n\t\t} else {\n\t\t\tresp += string(str[i])\n\t\t}\n\t}\n\n\tif string(str[len(str)-1]) != \"?\" {\n\t\tresp += string(str[len(str)-1])\n\t}\n\n\twriter.WriteString(resp)\n}\n", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276"} {"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\tfor i := 0; i < N; i++ {\n\t\tA := sc.NextInt()\n\t\tflag := false\n\t\tfor k := 0; 7*k <= A; k++ {\n\t\t\tif (A-7*k)%3 == 0 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\tflag = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !flag {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452"} {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/235/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Solve(n int64) int64 {\n\tif n == 1 {\n\t\treturn 1\n\t} else if n == 2 {\n\t\treturn 2\n\t} else if n == 3 {\n\t\treturn 6\n\t}\n\tif n%2 == 1 {\n\t\treturn n * (n - 1) * (n - 2)\n\t} else if n%2 == 0 && n%3 == 0 {\n\t\treturn (n - 1) * (n - 2) * (n - 3)\n\t}\n\treturn n * (n - 1) * (n - 3)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int64\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n))\n}\n", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e"} {"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", "src_uid": "d0f5174bb0bcca5a486db327b492bf33"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scan(&n,&s)\n\tg :=\"aeoyiu\"\n\tvar t []rune\n\tprev := 'n'\n\tfor _,r := range(s) {\n\t\tif (!strings.ContainsRune(g,r) || !strings.ContainsRune(g,prev)) {\n\t\t\tprev = r\n\t\t\tt = append(t,r)\n\t\t}\n\t}\n\tfmt.Println(string(t))\n}\n", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\n\tfor i := 0; i <= 10000; i++ {\n\t\tif (c-i*b)%a == 0 && (c-i*b)/a >= 0 {\n\t\t\tfmt.Printf(\"Yes\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Printf(\"No\\n\")\n}\n", "src_uid": "e66ecb0021a34042885442b336f3d911"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar moveNum, candyNum int\n\n\t_, err := fmt.Scanln(&moveNum, &candyNum)\n\tif err != nil {\n\t}\n\n\tfor j := 0; j <= moveNum; j++ {\n\t\ti := moveNum - j\n\t\ta := 0\n\t\tif i%2 == 0 {\n\t\t\ta = (i + 1) * (i / 2)\n\t\t} else {\n\t\t\ta = ((i + 1) / 2) * i\n\t\t}\n\t\tif a < j {\n\t\t\tcontinue\n\t\t}\n\t\tcandy := a - j\n\t\tif (candy - candyNum) == 0 {\n\t\t\tfmt.Println(j)\n\t\t}\n\t}\n}\n", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, a, b int\n\tfmt.Scanf(\"%d %d %d %d\", &n, &m, &a, &b)\n\tsum := n / m * b\n\tif (n % m) * a > b {\n\t\tsum += b\n\t}else {\n\t\tsum += (n % m) * a\n\t}\n\tif n * a < sum {\n\t\tsum = n * a\n\t}\n\tfmt.Printf(\"%d\", sum)\n\n}\n", "src_uid": "faa343ad6028c5a069857a38fa19bb24"} {"source_code": "\ufeffpackage main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n uint64\n\tfmt.Scan(&n)\n\tn = n*(n*n+5)/6\n\tfmt.Println(n)\n}\n", "src_uid": "6df251ac8bf27427a24bc23d64cb9884"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\ntype Bytes []byte\n\nfunc (p Bytes) Len() int { return len(p) }\nfunc (p Bytes) Less(i, j int) bool { return p[i] < p[j] }\nfunc (p Bytes) Swap(i, j int) { p[i], p[j] = p[j], p[i] }\n\nfunc main() {\n\tsc := bufio.NewScanner(os.Stdin)\n\n\tsc.Scan()\n\tsc.Scan()\n\n\tm := map[byte]string{\n\t\t'2': \"2\",\n\t\t'3': \"3\",\n\t\t'4': \"322\",\n\t\t'5': \"5\",\n\t\t'6': \"53\",\n\t\t'7': \"7\",\n\t\t'8': \"7222\",\n\t\t'9': \"7332\",\n\t}\n\n\tans := \"\"\n\tfor _, x := range sc.Bytes() {\n\t\tans += m[x]\n\t}\n\n\tb := Bytes(ans)\n\tsort.Sort(sort.Reverse(b))\n\n\tfmt.Println(string(b))\n}\n", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398"} {"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}", "src_uid": "579021de624c072f5e0393aae762117e"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, m, k int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &n, &m, &k)\n\tif n <= m && n <= k {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4"} {"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tvar ok = true\n\tfor i := 1; i < len(s); i++ {\n\t\tif 'a' <= s[i] && s[i] <= 'z' {\n\t\t\tok = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif ok {\n\t\tvar buffer bytes.Buffer\n\t\tif 'a' <= s[0] && s[0] <= 'z' {\n\t\t\tbuffer.WriteRune(unicode.ToUpper(rune(s[0])))\n\t\t} else {\n\t\t\tbuffer.WriteRune(unicode.ToLower(rune(s[0])))\n\t\t}\n\n\t\tbuffer.WriteString(strings.ToLower(s[1:]))\n\t\tfmt.Print(buffer.String())\n\t\treturn\n\t}\n\tfmt.Print(s)\n}\n", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n)\n\nfunc solve(k, a, b int64) int64 {\n\ta0 := a / k\n\tb0 := b / k\n\tif a - a0 * k > b0 * (k - 1) {\n\t\treturn -1\n\t}\n\tif b - b0 * k > a0 * (k - 1) {\n\t\treturn -1\n\t}\n\treturn a0 + b0\n}\n\nfunc main() {\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\tk := cin.nextInt64()\n\ta := cin.nextInt64()\n\tb := cin.nextInt64()\n\tfmt.Printf(\"%d\\n\", solve(k, a, b))\n}\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2"} {"source_code": "package main\n\nimport \"fmt\"\n\nconst mod = 1000000007\nconst maxn = 1000000 + 10\n\nvar rank [maxn]int64\n\nfunc myinit() {\n\trank[0] = 1\n\tvar i int64\n\tfor i = 1; i < maxn; i++ {\n\t\trank[i] = rank[i-1] * i % mod\n\t}\n}\nfunc powmod(a, n int64) int64 {\n\tvar ans int64\n\tans = 1\n\tvar i int64\n\tfor i = 1; i <= n; i++ {\n\t\tans = ans * a % mod\n\t}\n\treturn ans\n}\nfunc main() {\n\tmyinit()\n\tvar n int64\n\tfmt.Scan(&n)\n\tvar ans = (rank[n] - powmod(2, n-1) + mod) % mod\n\tfmt.Println(ans)\n}\n", "src_uid": "3dc1ee09016a25421ae371fa8005fce1"} {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1150/problem/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc min(a []int) int {\n\tminElem := a[0]\n\tfor i := 1; i < len(a); i++ {\n\t\tif a[i] < minElem {\n\t\t\tminElem = a[i]\n\t\t}\n\t}\n\treturn minElem\n}\n\nfunc max(a []int) int {\n\tmaxElem := a[0]\n\tfor i := 1; i < len(a); i++ {\n\t\tif a[i] > maxElem {\n\t\t\tmaxElem = a[i]\n\t\t}\n\t}\n\treturn maxElem\n}\n\nfunc Solve(n int, m int, r int, s []int, b[]int) int {\n\tminBuyPrice := min(s)\n\tmaxSellPrice := max(b)\n\tif maxSellPrice > minBuyPrice {\n\t\tshares := r / minBuyPrice\n\t\tremainder := r % minBuyPrice\n\t\treturn shares * maxSellPrice + remainder\n\t}\n\treturn r\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n, m, r int\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &n, &m, &r)\n\ts := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(reader, &s[i])\n\t}\n\tb := make([]int, m)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Fscan(reader, &b[i])\n\t}\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, m, r, s, b))\n}\n", "src_uid": "42f25d492bddc12d3d89d39315d63cb9"} {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1528B(_r io.Reader, out io.Writer) {\r\n\tin := bufio.NewReader(_r)\r\n\tconst mod = 998244353\r\n\tconst mx int = 1e6\r\n\td := [mx + 1]int{}\r\n\tfor i := 1; i <= mx; i++ {\r\n\t\tfor j := i; j <= mx; j += i {\r\n\t\t\td[j]++\r\n\t\t}\r\n\t}\r\n\r\n\tvar n int\r\n\tFscan(in, &n)\r\n\ts := int64(d[n])\r\n\tfor i, p2 := n-1, int64(1); i > 0; i-- {\r\n\t\ts = (s + p2*int64(d[i])) % mod\r\n\t\tp2 = p2 << 1 % mod\r\n\t}\r\n\tFprint(out, s)\r\n}\r\n\r\nfunc main() { CF1528B(os.Stdin, os.Stdout) }\r\n", "src_uid": "09be46206a151c237dc9912df7e0f057"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s, t string\n\tfmt.Scanf(\"%s %s\", &s, &t)\n\n\tvar cnt [26]int\n\tfor _, val := range s {\n\t\tcnt[val - 'a']++\n\t}\n\tfor _, val := range t {\n\t\tcnt[val - 'a']--\n\t\tif cnt[val - 'a'] < 0 {\n\t\t\tfmt.Println(\"need tree\")\n\t\t\treturn\n\t\t}\n\t}\n\tif len(s) == len(t) {\n\t\tfmt.Println(\"array\")\n\t\treturn \n\t}\n\n\tvar p int = 0\n\tfor i := 0; i < len(t); i++ {\n\t\tfor p < len(s) && s[p] != t[i] {\n\t\t\tp++\n\t\t}\n\t\tif p == len(s) {\n\t\t\tfmt.Println(\"both\")\n\t\t\treturn \n\t\t}\n\t\tp++\n\t}\n\tfmt.Println(\"automaton\")\n}\n", "src_uid": "edb9d51e009a59a340d7d589bb335c14"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s, x1, x2, t1, t2, p, d int\n\tfmt.Scan(&s, &x1, &x2, &t1, &t2, &p, &d)\n\tbyFoot := abs(x1-x2) * t2\n\twT := abs(p-x1) * t1\n\tif x1 < p {\n\t\tif d == 1 {\n\t\t\twT += 2 * (s - p) * t1\n\t\t\td = -1\n\t\t}\n\t} else if x1 > p {\n\t\tif d == -1 {\n\t\t\twT += 2 * p * t1\n\t\t\td = 1\n\t\t}\n\t}\n\ttT := abs(x1-x2) * t1\n\tif x1 < x2 {\n\t\tif d == -1 {\n\t\t\ttT += 2 * x1 * t1\n\t\t}\n\t} else {\n\t\tif d == 1 {\n\t\t\ttT += 2 * (s - x1) * t1\n\t\t}\n\t}\n\n\tbyTrain := tT + wT\n\tfmt.Println(min(byFoot, byTrain))\n}\n\nfunc min(a, b int) int {\n\tmin := a\n\tif b < a {\n\t\tmin = b\n\t}\n\treturn min\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -1 * x\n\t}\n\treturn x\n}\n", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n \"strings\"\n)\n\nfunc solve() {\n n, k, s := readInt(), readInt(), readString()\n g, t := strings.Index(s, \"G\"), strings.Index(s, \"T\")\n if g > t {\n g = t\n }\n for i := g+k; i < n; i += k {\n cur := s[i]\n if cur == 'T' || cur == 'G' {\n fmt.Println(\"YES\")\n return\n } else if cur == '#' {\n break\n }\n }\n fmt.Println(\"NO\")\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", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"no\")\n}\n", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\tdata := \"\"\n\tinput := bufio.NewScanner(os.Stdin)\n\tfor input.Scan() {\n\t\tdata = input.Text()\n\t\tbreak\n\t}\n\n\tvar (\n\t\tleft int\n\t\tright int\n\t)\n\tleft = -1\n\tfor _, el := range data {\n\t\tif string(el) != \"=\" {\n\t\t\tleft++\n\t\t\tcontinue\n\t\t}\n\t\tif string(el) == \"=\" {\n\t\t\tright = len(data) - left - 2\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif left == right {\n\t\tfmt.Println(data)\n\t\treturn\n\t}\n\n\tif math.Abs(float64(right-left)) != 2 {\n\t\tfmt.Println(\"Impossible\")\n\t\treturn\n\t}\n\n\tif left < right {\n\t\tfmt.Println(\"|\" + data[:len(data)-1])\n\t\treturn\n\t}\n\n\tif string(data[1]) == \"+\" {\n\t\tfmt.Println(data[:left] + data[left+1:] + \"|\")\n\t\treturn\n\t}\n\n\tfmt.Println(data[1:] + \"|\")\n}\n", "src_uid": "ee0aaa7acf127e9f3a9edafc58f4e2d6"} {"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", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc distance(n,a,b,c int) int {\n\tif(n==1) {\n\t\treturn 0\n\t} else {\n\t\tif(a 0 {\n\t\tmodulo = n % 10\n\t\tif modulo == 0 {\n\t\t\tk--\n\t\t\tn = n / 10\n\t\t} else {\n\t\t\tif k < modulo {\n\t\t\t\tn -= k\n\t\t\t\tk = 0\n\t\t\t} else {\n\t\t\t\tk -= modulo\n\t\t\t\tn -= modulo\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(n)\n}\n", "src_uid": "064162604284ce252b88050b4174ba55"} {"source_code": "package main\n\nimport \"fmt\"\nimport \"bufio\"\nimport \"os\"\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar n int\n\tfmt.Fscanf(bufin, \"%d\\n\", &n)\n\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(bufin, \"%d\\n\", &a[i])\n\t}\n\n\tif a[n-1] == 0 {\n\t\tfmt.Fprintf(bufout, \"UP\\n\")\n\t} else if a[n-1] == 15 {\n\t\tfmt.Fprintf(bufout, \"DOWN\\n\")\n\t} else if n == 1 {\n\t\tfmt.Fprintf(bufout, \"-1\\n\")\n\t} else if a[n-2] < a[n-1] {\n\t\tfmt.Fprintf(bufout, \"UP\\n\")\n\t} else {\n\t\tfmt.Fprintf(bufout, \"DOWN\\n\")\n\t}\n}\n", "src_uid": "8330d9fea8d50a79741507b878da0a75"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\tex := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&ex[i])\n\t}\n\tans := 0\n\tfor i, j := 0, n-1; i <= j && (ex[i] <= k || ex[j] <= k) ; {\n\t\tif ex[i] <= k {\n\t\t\ti++\n\t\t\tans++\n\t\t\tcontinue\n\t\t}\n\t\tif ex[j] <= k {\n\t\t\tans++\n\t\t\tj--\n\t\t}\n\t}\n\tfmt.Print(ans)\n}\n", "src_uid": "ecf0ead308d8a581dd233160a7e38173"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,k int64\n fmt.Scan(&n,&k)\n if k <= ((n+1)/2) {\n fmt.Println((k*2)-1)\n } else {\n k -= (n+1)/2\n fmt.Println(k*2)\n }\n}\n", "src_uid": "1f8056884db00ad8294a7cc0be75fe97"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tz:= bufio.NewScanner(os.Stdin)\n\tz.Split(bufio.ScanWords)\n\tz.Scan()\n\tn, _:= strconv.Atoi(strings.TrimSpace(z.Text()))\n\tz.Scan()\n\tk, _:= strconv.Atoi(strings.TrimSpace(z.Text()))\n\tm, t := 0,0\n\tfor i := 0; i < n; i++ {\n\t\tz.Scan()\n\t\ta,_ := strconv.Atoi(strings.TrimSpace(z.Text()))\n\t\tif a>m {\n\t\t\tm=a\n\t\t}\n\t\tt+=a\n\t}\n\n\tvar o string\n\tif t - m <= k {\n\t\to = \"YES\"\n\t} else {\n\t\to = \"NO\"\n\t}\n\tfmt.Println(o)\n}", "src_uid": "496baae594b32c5ffda35b896ebde629"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c int\n\tr := make(map[int]bool, 1e5)\n\tfmt.Scan(&a, &b, &c)\n\tfor i := 1; ; i++ {\n\t\tif c == a*10/b {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t\ta = a * 10 % b\n\t\tif !r[a] {\n\t\t\tr[a] = true\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n\t\"math\"\n)\n\ntype caseInput struct {\n\tnum int\n}\n\nfunc readCaseInput(scanner *bufio.Scanner) caseInput {\n\treturn caseInput{readInt(scanner)}\n}\n\ntype caseOutput struct {\n\tops int\n}\n\nfunc writeCaseOutput(writer *bufio.Writer, out caseOutput) {\n\twritef(writer, \"%d\\n\", out.ops)\n}\n\nfunc solveCase(in caseInput) caseOutput {\n\tnumStr := fmt.Sprintf(\"%d\", in.num)\n\troot := int(math.Floor(math.Sqrt(float64(in.num))))\n\tfor root > 0 {\n\t\tsquareStr := fmt.Sprintf(\"%d\", root*root)\n\t\tif len(lcs(numStr, squareStr)) == len(squareStr) {\n\t\t\treturn caseOutput{len(numStr) - len(squareStr)}\n\t\t}\n\t\troot -= 1\n\t}\n\treturn caseOutput{-1}\n}\n\n//\tthat's from rozetta code and seems to work\nfunc lcs(a, b string) string {\n\tarunes := []rune(a)\n\tbrunes := []rune(b)\n\taLen := len(arunes)\n\tbLen := len(brunes)\n\tlengths := make([][]int, aLen+1)\n\tfor i := 0; i <= aLen; i++ {\n\t\tlengths[i] = make([]int, bLen+1)\n\t}\n\t// row 0 and column 0 are initialized to 0 already\n\n\tfor i := 0; i < aLen; i++ {\n\t\tfor j := 0; j < bLen; j++ {\n\t\t\tif arunes[i] == brunes[j] {\n\t\t\t\tlengths[i+1][j+1] = lengths[i][j] + 1\n\t\t\t} else if lengths[i+1][j] > lengths[i][j+1] {\n\t\t\t\tlengths[i+1][j+1] = lengths[i+1][j]\n\t\t\t} else {\n\t\t\t\tlengths[i+1][j+1] = lengths[i][j+1]\n\t\t\t}\n\t\t}\n\t}\n\n\t// read the substring out from the matrix\n\ts := make([]rune, 0, lengths[aLen][bLen])\n\tfor x, y := aLen, bLen; x != 0 && y != 0; {\n\t\tif lengths[x][y] == lengths[x-1][y] {\n\t\t\tx--\n\t\t} else if lengths[x][y] == lengths[x][y-1] {\n\t\t\ty--\n\t\t} else {\n\t\t\ts = append(s, arunes[x-1])\n\t\t\tx--\n\t\t\ty--\n\t\t}\n\t}\n\t// reverse string\n\tfor i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {\n\t\ts[i], s[j] = s[j], s[i]\n\t}\n\treturn string(s)\n}\n\nfunc solveSequential(scanner *bufio.Scanner, writer *bufio.Writer) {\n\twriteCaseOutput(writer, solveCase(readCaseInput(scanner)))\n}\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\tif len(os.Args) > 1 {\n\t\treader, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tdefer reader.Close()\n\t\tscanner = bufio.NewScanner(reader)\n\t} else {\n\t\tscanner = bufio.NewScanner(os.Stdin)\n\t}\n\tscanner.Split(bufio.ScanWords)\n\n\tvar writer = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tsolveSequential(scanner, writer)\n}\n\nfunc readInt64(sc *bufio.Scanner) int64 {\n\tsc.Scan()\n\tres, err := strconv.ParseInt(sc.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc readInt(sc *bufio.Scanner) int {\n\treturn int(readInt64(sc))\n}\n\nfunc writef(writer *bufio.Writer, formatStr string, values ...interface{}) {\n\tout := fmt.Sprintf(formatStr, values...)\n\t_, err := writer.WriteString(out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n", "src_uid": "fa4b1de79708329bb85437e1413e13df"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tvar n string\n\tfmt.Fscan(reader, &n)\n\n\tmp := make(map[string]int)\n\tmp[\"0\"] = 2\n\tmp[\"1\"] = 7\n\tmp[\"2\"] = 2\n\tmp[\"3\"] = 3\n\tmp[\"4\"] = 3\n\tmp[\"5\"] = 4\n\tmp[\"6\"] = 2\n\tmp[\"7\"] = 5\n\tmp[\"8\"] = 1\n\tmp[\"9\"] = 2\n\n\tfmt.Println(mp[string(n[0])] * mp[string(n[1])])\n\n}\n", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5"} {"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", "src_uid": "892680e26369325fb00d15543a96192c"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tgiven int\n\t\tleft int\n\t\trite int\n\t\tmaxs int\n\t\tmins int\n\t\tpowers uint\n\t)\n\tfmt.Scanf(\"%d %d %d\", &given, &left, &rite)\n\n\tpowers = 0\n\tfor i := 0; i < left; i++ {\n\t\tmins += 1 << powers\n\t\tpowers++\n\t}\n\tmins += given - left\n\n\tpowers = 0\n\tfor i := 0; i < rite; i++ {\n\t\tmaxs += 1 << powers\n\t\tpowers++\n\t}\n\tmaxs += (given - rite) * (1 << (powers - 1))\n\tfmt.Printf(\"%d %d\", mins, maxs)\n\n}\n", "src_uid": "ce220726392fb0cacf0ec44a7490084a"} {"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\tvar t,s,count,anc int\n\n\tfmt.Fscan(in, &t)\n\tfor i := 0;i < t;i++{\n\t\tval := 9\n\t\tcount = 1\n\t\tfmt.Fscan(in, &s)\n\t\tfor s > 0{\n\t\t\tif s < 10 && val > s{\n\t\t\t\tanc += s*count\n\t\t\t\ts = 0\n\t\t\t}else{\n\t\t\t\ts -= val\n\t\t\t\tanc += val*count\n\t\t\t\tval--\n\t\t\t\tcount *= 10\n\t\t\t}\n\t\t}\n\t\tfmt.Println(anc)\n\t\tanc = 0\n\t}\n}\n\n", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar w, h, k int\n\n\tfmt.Scanf(\"%d %d %d\", &w, &h, &k)\n\n\tr := 0\n\tfor i := 0; i < k; i++ {\n\t\tc := 2*(w+h) - 4\n\t\tr += c\n\t\th -= 4\n\t\tw -= 4\n\t}\n\n\tfmt.Println(r)\n}\n", "src_uid": "2c98d59917337cb321d76f72a1b3c057"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc Abs(x int) int {\n\tswitch {\n\tcase x < 0:\n\t\treturn -x\n\tcase x == 0:\n\t\treturn 0\n\t}\n\treturn x\n}\n\nfunc Max(x int, y int) int {\n\tif x >= y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc Scan(args ...interface{}) (e error) { _, e = fmt.Fscan(in, args...); return }\nfunc Scanf(ft string, args ...interface{}) (e error) { _, e = fmt.Fscanf(in, ft, args...); return }\nfunc Scanln(args ...interface{}) (e error) { _, e = fmt.Fscanln(in, args...); return }\nfunc Print(args ...interface{}) { out.WriteString(fmt.Sprint(args...)) }\nfunc Printf(ft string, args ...interface{}) { out.WriteString(fmt.Sprintf(ft, args...)) }\nfunc Println(args ...interface{}) { out.WriteString(fmt.Sprintln(args...)) }\n\nvar (\n\tdataIn = \"data.in\"\n\tin = bufio.NewReader(os.Stdin)\n\t//in, _ = os.Open(dataIn)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\nvar n int64\n\nfunc bis(num int64) int64 {\n\tl := int64(1)\n\tr := int64(14142136)\n\tfor l <= r {\n\t\tmid := (l + r) >> 1\n\t\tif mid*(mid+1)/2 > num {\n\t\t\tr = mid - 1\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r\n}\n\nfunc solve() {\n\tm := bis(n)\n\tif n == m*(m+1)/2 {\n\t\tPrintln(m)\n\t} else {\n\t\tPrintln(n - m*(m+1)/2)\n\t}\n}\n\nfunc main() {\n\tdefer out.Flush()\n\tfor Scan(&n) != io.EOF {\n\t\tsolve()\n\t\tout.Flush()\n\t}\n\treturn\n}\n", "src_uid": "1db5631847085815461c617854b08ee5"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\tcolours = []byte(\"RGBYW\")\n\tnumbers = []byte(\"12345\")\n)\n\nfunc bits(x int) (ans int) {\n\tfor x > 0 {\n\t\tx &= (x - 1)\n\t\tans++\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcards := make([]string, n)\n\tfor i := range cards {\n\t\tfmt.Scan(&cards[i])\n\t}\n\tres := 10\n\tfor c := 0; c < 1 << 5; c++ {\n\t\tfor nu := 0; nu < 1 << 5; nu++ {\n\t\t\tif bits(c) + bits(nu) > res {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tknow := make(map[byte]bool)\n\t\t\tfor i := 0; i < 5; i++ {\n\t\t\t\tif c & (1 << uint(i)) != 0 {\n\t\t\t\t\tknow[colours[i]] = true\n\t\t\t\t}\n\t\t\t\tif nu & (1 << uint(i)) != 0 {\n\t\t\t\t\tknow[numbers[i]] = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar (\n\t\t\t\tnothing = make(map[string]bool)\n\t\t\t\tknowNu = make(map[byte]map[byte]bool)\n\t\t\t\tknowC = make(map[byte]map[byte]bool)\n\t\t\t)\n\t\t\tgood := true\n\t\t\tfor _, card := range cards {\n\t\t\t\tif !know[card[0]] && !know[card[1]] {\n\t\t\t\t\tnothing[card] = true\n\t\t\t\t\tif len(nothing) > 1 {\n\t\t\t\t\t\tgood = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t} else if !know[card[0]] {\n\t\t\t\t\tm := knowNu[card[1]]\n\t\t\t\t\tif m == nil {\n\t\t\t\t\t\tm = make(map[byte]bool)\n\t\t\t\t\t\tknowNu[card[1]] = m\n\t\t\t\t\t}\n\t\t\t\t\tm[card[0]] = true\n\t\t\t\t\tif len(m) > 1 {\n\t\t\t\t\t\tgood = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t} else if !know[card[1]] {\n\t\t\t\t\tm := knowC[card[0]]\n\t\t\t\t\tif m == nil {\n\t\t\t\t\t\tm = make(map[byte]bool)\n\t\t\t\t\t\tknowC[card[0]] = m\n\t\t\t\t\t}\n\t\t\t\t\tm[card[1]] = true\n\t\t\t\t\tif len(m) > 1 {\n\t\t\t\t\t\tgood = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif good {\n\t\t\t\tres = bits(c) + bits(nu)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n", "src_uid": "3b12863997b377b47bae43566ec1a63b"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc isPalindrom(s string) bool {\n\tfor i := 0; i < len(s)/2; i++ {\n\t\tif s[i] != s[len(s)-i-1] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc solve(s string) string {\n\tfor c := 'a'; c <= 'z'; c++ {\n\t\tfor i := 0; i <= len(s); i++ {\n\t\t\tt := s[:i] + strconv.QuoteRuneToASCII(c)[1:2] + s[i:]\n\t\t\t//fmt.Scanf(\"%s\", &t)\n\t\t\tif isPalindrom(t) {\n\t\t\t\treturn t\n\t\t\t}\n\t\t}\n\t}\n\treturn \"NA\"\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\tfmt.Printf(\"%s\", solve(s))\n}\n", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b"} {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF148D(_r io.Reader, _w io.Writer) {\n\tvar W, B int\n\tFscan(_r, &W, &B)\n\tdp := make([][][2]float64, W+1)\n\tfor i := range dp {\n\t\tdp[i] = make([][2]float64, B+1)\n\t\tfor j := range dp[i] {\n\t\t\tdp[i][j] = [2]float64{-1, -1}\n\t\t}\n\t}\n\tvar f func(w, b, who int) float64\n\tf = func(w, b, who int) (res float64) {\n\t\tif w <= 0 {\n\t\t\tif who == 0 {\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\treturn 1\n\t\t}\n\t\tif b <= 0 {\n\t\t\treturn 1\n\t\t}\n\t\tdv := &dp[w][b][who]\n\t\tif *dv != -1 {\n\t\t\treturn *dv\n\t\t}\n\t\tdefer func() { *dv = res }()\n\t\tif who == 0 {\n\t\t\treturn (float64(w) + float64(b)*(1-f(w, b-1, 1))) / float64(w+b)\n\t\t}\n\t\tp := (float64(w)*f(w-1, b-1, 0) + float64(b-1)*f(w, b-2, 0)) / float64(w+b-1)\n\t\treturn (float64(w) + float64(b)*(1-p)) / float64(w+b)\n\t}\n\tFprintf(_w, \"%.10f\", f(W, B, 0))\n}\n\nfunc main() { CF148D(os.Stdin, os.Stdout) }\n", "src_uid": "7adb8bf6879925955bf187c3d05fde8c"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b, c int\n fmt.Scan(&a, &b, &c)\n if c == 0 {\n if a == b {\n fmt.Print(\"YES\")\n } else {\n fmt.Print(\"NO\")\n }\n return\n }\n if (b-a)%c == 0 && (b-a)/c >= 0 {\n fmt.Print(\"YES\")\n } else {\n fmt.Print(\"NO\")\n }\n \n}", "src_uid": "9edf42c20ddf22a251b84553d7305a7d"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\n\tif n < m {\n\t\tfmt.Print(-1)\n\t\treturn\n\t}\n\n\tstep := n / 2\n\tleft := n % 2\n\texchange := false\n\tfor (step+left)%m != 0 {\n\t\tif exchange {\n\t\t\tstep -= 1\n\t\t\texchange = false\n\t\t}\n\t\tleft += 1\n\t}\n\n\tfmt.Print(step + left)\n}\n", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nvar r *bufio.Reader = bufio.NewReader(os.Stdin)\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\n\ntype Vertice struct {\n\tX int\n\tY int\n}\n\nfunc dist(a, b Vertice) int {\n\tx, y := a.X-b.X, a.Y-b.Y\n\treturn x*x + y*y\n}\n\nfunc isRight(a, b, c Vertice) bool {\n\tes := []int{dist(a, b), dist(b, c), dist(c, a)}\n\tsort.Ints(es)\n\n\tif es[0] == 0 || es[1] == 0 || es[2] == 0 {\n\t\treturn false\n\t}\n\n\treturn es[0]+es[1] == es[2]\n}\n\nfunc getAdjs(v Vertice) []Vertice {\n\treturn []Vertice{Vertice{v.X - 1, v.Y}, Vertice{v.X + 1, v.Y}, Vertice{v.X, v.Y - 1}, Vertice{v.X, v.Y + 1}}\n}\n\nfunc solve(a, b, c Vertice) string {\n\tif isRight(a, b, c) {\n\t\treturn \"RIGHT\"\n\t}\n\n\tfor i := 0; i < 3; i++ {\n\t\tvar v1, v2, v3 Vertice\n\t\tswitch i {\n\t\tcase 0:\n\t\t\tv1, v2, v3 = a, b, c\n\t\tcase 1:\n\t\t\tv1, v2, v3 = b, c, a\n\t\tcase 2:\n\t\t\tv1, v2, v3 = c, a, b\n\t\t}\n\t\tadjs := getAdjs(v1)\n\t\tfor _, v := range adjs {\n\t\t\tif isRight(v, v2, v3) {\n\t\t\t\treturn \"ALMOST\"\n\t\t\t}\n\t\t}\n\t}\n\n\treturn \"NEITHER\"\n}\n\nfunc main() {\n\tdefer w.Flush()\n\n\ta, b, c := Vertice{}, Vertice{}, Vertice{}\n\tfmt.Fscanf(r, \"%d %d %d %d %d %d\", &a.X, &a.Y, &b.X, &b.Y, &c.X, &c.Y)\n\n\tfmt.Fprintf(w, \"%v\", solve(a, b, c))\n}\n", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d"} {"source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc correct(s, t string) bool {\n lens := len(s)\n lent := len(t)\n if lens != lent {\n return false\n }\n\n for i := 0; i < lens; i++ {\n if s[i] != t[lens-i-1] {\n return false\n }\n }\n\n return true\n}\n\nfunc main() {\n var s, t string\n fmt.Scan(&s)\n fmt.Scan(&t)\n\n if correct(s, t) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n", "src_uid": "35a4be326690b58bf9add547fb63a5a5"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var r1,r2,c1,c2,d1,d2 int\n fmt.Scan(&r1,&r2,&c1,&c2,&d1,&d2)\n b := (d2+r1-c1)/2\n c := d2-b\n a := r1-b\n d := c2-b\n f := func(n int) bool {\n if (n >= 1) && (n <= 9) { return true }\n return false\n }\n if (a != b) && (a != c) && (a != d) && (b != c) && (b != d) && (c != d) && f(a) && f(b) && f(c) && f(d) &&\n (a+b == r1) && (a+c == c1) && (c+d == r2) && (b+d == c2) && (a+d == d1) && (b+c == d2) {\n fmt.Println(a,b)\n fmt.Println(c,d)\n } else {\n fmt.Println(-1)\n }\n}\n", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3"} {"source_code": "// Try Codeforces\n// author: Leonrdone @ NEETSDKASU\npackage main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\ntype Foo []int64\nfunc (f Foo) Len() int { return len(f) }\nfunc (f Foo) Swap(i, j int) { f[i], f[j] = f[j], f[i] }\nfunc (f Foo) Less(i, j int) bool { return f[i] < f[j] }\n\nfunc main() {\n var n, k int\n var m int64\n fmt.Scan(&n, &k, &m)\n xs := make([]int64, k)\n for i := range xs {\n fmt.Scan(&xs[i])\n }\n sum := int64(0)\n for _, x := range xs {\n sum += x\n }\n sort.Sort(Foo(xs))\n ans := int64(0)\n for i := 0; i <= n; i++ {\n altm := sum * int64(i)\n if altm > m {\n break\n }\n tmp := int64((k + 1) * i)\n p := int64(n - i)\n for _, x := range xs[:k-1] {\n w := p\n for altm + w * x > m {\n w--\n }\n altm += w * x\n tmp += w\n }\n for altm + p * xs[k-1] > m {\n p--\n }\n altm += p * xs[k-1]\n tmp += p * 2\n if tmp > ans {\n ans = tmp\n }\n }\n fmt.Println(ans)\n}", "src_uid": "d659e92a410c1bc836be64fc1c0db160"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\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\tx := make([]int, 4)\n\n\tfor i := 0; i < n; i++ {\n\t\tx[i] = nextInt()\n\t}\n\n\tswitch n {\n\tcase 0:\n\t\tx[0], x[1], x[2], x[3] = 1, 1, 3, 3\n\t\tprintf(\"YES\\n%d\\n%d\\n%d\\n%d\\n\", x[0], x[1], x[2], x[3])\n\tcase 1:\n\t\tx[1], x[2], x[3] = x[0], x[0] * 3, x[0] * 3\n\t\tprintf(\"YES\\n%d\\n%d\\n%d\\n\", x[1], x[2], x[3])\n\tcase 2:\n\t\tif x[1] < x[0] {\n\t\t\tx[0], x[1] = x[1], x[0]\n\t\t}\n\n\t\tx[2], x[3] = 4 * x[0] - x[1], 3 * x[0]\n\t\tif x[2] > 0 {\n\t\t\tprintf(\"YES\\n%d\\n%d\\n\", x[2], x[3])\n\t\t} else {\n\t\t\tprintln(\"NO\")\n\t\t}\n\tcase 3:\n\t\tsort.Ints(x[0:3])\n\t\tok := false\n\n\t\tif x[2] % 3 == 0 && x[0] + x[1] == 4 * (x[2]/3) {\n\t\t\tx[3] = x[2] / 3\t\t\t\n\t\t\tok = true\n\t\t}\n\t\t// println(x)\n\n\t\tif x[1] + x[2] == 4 * x[0] {\n\t\t\tx[3] = 3 * x[0]\t\t\t\n\t\t\tok = true\n\t\t}\n\n\t\tif x[2] == x[0] * 3 {\n\t\t\tx[3] = x[0] * 4 - x[1]\n\t\t\tif x[3] >= x[0] {\n\t\t\t\tok = true\n\t\t\t}\n\t\t}\n\n\t\tif ok {\n\t\t\tprintf(\"YES\\n%d\\n\", x[3])\n\t\t} else {\n\t\t\tprintln(\"NO\")\n\t\t}\n\n\tcase 4:\n\t\tsort.Ints(x)\n\n\t\tif isSpecial(x) {\n\t\t\tprintln(\"YES\")\n\t\t} else {\n\t\t\tprintln(\"NO\")\n\t\t}\n\t}\n\n\t// println(n, x)\n}\n\nfunc isSpecial(x []int) bool {\n\tmedian := x[3] - x[0]\n\n\tif median * 2 == (x[1]+x[2]) && median * 4 == (x[0]+x[1]+x[2]+x[3]) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, err := strconv.ParseFloat(next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}", "src_uid": "230e613abf0f6a768829cbc1f1a09219"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a [6]int\n\tvar result int\n\tfor i := 0; i < 6; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\tstart := a[2]*2 - 1\n\tfor ; a[0]+a[4] > 0; {\n\t\tif a[1] > 0 {\n\t\t\tstart += 1\n\t\t\ta[1] -= 1\n\t\t} else if a[1] == 0 {\n\t\t\ta[1] -= 1\n\t\t\ta[0] -= 1\n\t\t} else {\n\t\t\tstart -= 1\n\t\t\ta[0] -= 1\n\t\t}\n\n\t\tif a[3] > 0 {\n\t\t\tstart += 1\n\t\t\ta[3] -= 1\n\t\t} else if a[3] == 0 {\n\t\t\ta[3] -= 1\n\t\t\ta[4] -= 1\n\t\t} else {\n\t\t\tstart -= 1\n\t\t\ta[4] -= 1\n\t\t}\n\t\tresult += start\n\t}\n\tfmt.Println(result)\n}\n", "src_uid": "382475475427f0e76c6b4ac6e7a02e21"} {"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", "src_uid": "969b24ed98d916184821b2b2f8fd3aac"} {"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\nvar n, m int\nvar vType []Type\nvar edges [][]int\n\nfunc main() {\n\tdefer out.Flush()\n\tfmt.Fscan(in, &n, &m)\n\tvType = make([]Type, n)\n\tedges = make([][]int, n)\n\tfor i := 0; i < m; i++ {\n\t\tvar a, b int\n\t\tfmt.Fscan(in, &a, &b)\n\t\ta--\n\t\tb--\n\t\tedges[a] = append(edges[a], b)\n\t\tedges[b] = append(edges[b], a)\n\t}\n\tif solve() {\n\t\tfmt.Fprintln(out, \"Yes\")\n\t\tfor v := range vType {\n\t\t\tfmt.Fprint(out, string('a'+vType[v]-1))\n\t\t}\n\t\tfmt.Fprintln(out)\n\t} else {\n\t\tfmt.Fprintln(out, \"No\")\n\t}\n}\n\nfunc solve() bool {\n\tfor v := range edges {\n\t\tif len(edges[v]) == n-1 {\n\t\t\tvType[v] = B\n\t\t}\n\t}\n\tfor v := range vType {\n\t\tif vType[v] == UNSEEN {\n\t\t\tmark(v, A)\n\t\t\tbreak\n\t\t}\n\t}\n\tfor v := range vType {\n\t\tif vType[v] == UNSEEN {\n\t\t\tmark(v, C)\n\t\t\tbreak\n\t\t}\n\t}\n\tvar a, b, c int\n\tfor v := range vType {\n\t\tswitch vType[v] {\n\t\tcase UNSEEN:\n\t\t\treturn false\n\t\tcase A:\n\t\t\ta++\n\t\tcase B:\n\t\t\tb++\n\t\tcase C:\n\t\t\tc++\n\t\t}\n\t}\n\tfor v := range vType {\n\t\tif vType[v] == A && len(edges[v]) != a-1+b {\n\t\t\treturn false\n\t\t}\n\t\tif vType[v] == C && len(edges[v]) != c-1+b {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc mark(v int, t Type) {\n\tif vType[v] != UNSEEN {\n\t\treturn\n\t}\n\tvType[v] = t\n\tfor _, u := range edges[v] {\n\t\tmark(u, t)\n\t}\n}\n\ntype Type int\n\nconst (\n\tUNSEEN Type = iota\n\tA\n\tB\n\tC\n)\n", "src_uid": "e71640f715f353e49745eac5f72e682a"} {"source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n var n int\n fmt.Scan(&n)\n fmt.Println(n/2+1)\n}", "src_uid": "5551742f6ab39fdac3930d866f439e3e"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt()\n\ts := next()\n\tcount := 0\n\n\tfor i := 0; i < n; i++ {\n\t\tif s[i] == '1' {\n\t\t\tcount++\n\t\t} else {\n\t\t\tif i < n {\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\tprintln(count)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, err := strconv.ParseFloat(next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc print(a ...interface{}) {\n\tfmt.Fprint(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab"} {"source_code": "package main\nimport\n(\n \"fmt\"\n // \"math\"\n)\nfunc main(){\n var i int\n fmt.Scanf(\"%d\" , &i)\n // temp:= i\n x :=1\n count := 0\n var s []int\n if(i>81){\n x =x-81\n }\n\n for ;x81){\n continue\n }\n temp := x\n rs := (i-x)\n // temp2 :=1\n // fmt.Println(x)\n sum :=0\n for ;temp>0;temp/=10{\n\n // fmt.Println(mult)\n // var digits [] int\n\n xlast := temp%10\n sum +=xlast\n\n // res := temp + xlast\n // fmt.Println(temp,xlast)\n\n }\n if sum==rs{\n s = append(s,x)\n count ++\n }\n }\n if (count == 0){\nfmt.Println(0)\n}else\n{\n fmt.Println(count)\n for x:=0;x 0 {\n\t\tnum++\n\t}\n\treturn num\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tst, _ := strconv.Atoi(scanner.Text())\n\tfmt.Println(numSteps(st))\n}\n", "src_uid": "4b3d65b1b593829e92c852be213922b6"} {"source_code": "package main\n\nimport (\n \"sort\"\n \"fmt\"\n)\n\nfunc main() {\n a := make([]int, 10)\n for i := 0; i < 6; i++ {\n var x int\n fmt.Scan(&x)\n a[x]++\n }\n sort.Ints(a)\n if a[len(a)-1] == 6 {\n fmt.Println(\"Elephant\")\n } else if a[len(a)-1] == 5 {\n fmt.Println(\"Bear\")\n } else if a[len(a)-1] == 4 {\n if a[len(a)-2] == 2 {\n fmt.Println(\"Elephant\")\n } else {\n fmt.Println(\"Bear\")\n }\n } else {\n fmt.Println(\"Alien\")\n }\n}\n", "src_uid": "43308fa25e8578fd9f25328e715d4dd6"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar strInput string \n\tfmt.Scan(&strInput)\n\tstartIndex := 97\n\telement := 0\n\tsum := 0\n\n\tfor _, s := range strInput {\n\t\tif int(s) > startIndex {\n\t\t\telement = int(s) - startIndex\n\t\t} else {\n\t\t\telement = startIndex - int(s)\n\t\t}\n\t\tif (element > 13 ) {\n\t\t\telement = 26 - element\n\t\t}\n\t\tstartIndex = int(s)\n\t\tsum = sum + element\n\t}\n\tfmt.Println(sum)\n}", "src_uid": "ecc890b3bdb9456441a2a265c60722dd"} {"source_code": "\ufeffpackage main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\t//var a,b,c,d int\n\tvar s1,s2,t1,t2 int\n\tfmt.Scanf(\"%d:%d\\n\",&s1,&s2)\n\tfmt.Scanf(\"%d:%d\",&t1,&t2)\n\t//fmt.Println(s1,s2,t1,t2)\n\ts:=s1*60+s2\n\ts-=t2\n\ts-=t1*60\n\tif s<0 {\n\t\ts+=24*60\n\t}\n\tfmt.Printf(\"%02d:%02d\\n\",s/60,s%60)\n\n}\n\n\n\n\n\n\n\n\n\n\n\n", "src_uid": "595c4a628c261104c8eedad767e85775"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// 1200\n// 28.05.2020\n// https://codeforces.com/problemset/problem/353/A\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\n\txs := make([]int, n)\n\tys := make([]int, n)\n\n\tvar sumx, sumy int\n\tfor i := 0; i < n; i++ {\n\t\tvar x, y int\n\t\tfmt.Scanln(&x, &y)\n\t\txs[i] = x\n\t\tys[i] = y\n\n\t\tsumx += x\n\t\tsumy += y\n\t}\n\tif sumx%2 == 0 && sumy%2 == 0 {\n\t\tfmt.Println(\"0\")\n\t\treturn\n\t}\n\tif sumx%2 == 1 && sumy%2 == 1 {\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif xs[i]%2 != ys[i]%2 {\n\t\t\t\tfmt.Println(\"1\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"-1\")\n}\n", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nvar pos [40000001]int\n\nfunc main() {\n\tvar n int64\n\tfmt.Scanf(\"%d\", &n)\n\tif n == 0 {\n\t\tfmt.Printf(\"1\")\n\t\treturn\n\t}\n\tans := 4\n\tfor x := int64(1); x < n; x++ {\n\t\tpos[x] = int(math.Sqrt(float64(n*n - x*x)))\n\t}\n\tfor x := int64(1); x < n; x++ {\n\t\tif int(x) != pos[pos[x]] {\n\t\t\tans += 8\n\t\t} else {\n\t\t\tans += 4\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", ans)\n}\n", "src_uid": "d87ce09acb8401e910ca6ef3529566f4"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\n//a\u306eb\u4e57\u3092\u3057\u307e\u3059 O(log b)\nfunc pow(a int, b int) int {\n\ttotal := 1\n\ttmp := a\n\tfor b > 0 {\n\t\tif b%2 == 1 {\n\t\t\ttotal *= tmp\n\t\t}\n\t\tb /= 2\n\t\ttmp *= tmp\n\t}\n\treturn total\n}\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\tmx := 0\n\tfor k := uint(1); ; k++ {\n\t\tl := ((1 << k) - 1) * (1 << (k - 1))\n\t\tif l > N {\n\t\t\tbreak\n\t\t}\n\t\tif N%l == 0 {\n\t\t\tmx = l\n\t\t}\n\t}\n\tfmt.Println(mx)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "src_uid": "339246a1be81aefe19290de0d1aead84"} {"source_code": "package main\n\nimport \"fmt\"\nvar k, n uint64\nfunc main() {\n\tfmt.Scan(&n, &k)\n\tif k == 1 {\n\t\tfmt.Print(n)\n\t} else {\n\t\tvar i uint = 1\n\t\tvar s uint64\n\t\tfor s = 1; (s << 1) <= n; i++ {\n\t\t\ts <<= 1;\n\t\t}\n\t\tfmt.Print((uint64(1) << i) - 1)\n\t}\n}", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9"} {"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", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca"} {"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 h,m int\n\tvar start ,end int\n\tfmt.Fscanf(buf, \"%d:%d\\n\", &h,&m)\n\tstart = h*60+m\n\tfmt.Fscanf(buf, \"%d:%d\\n\", &h,&m)\n\tend = h*60+m\n\tstart = (start+end)/2\n\th = start/60\n\tm =start%60\n\tfmt.Printf(\"%02d:%02d\\n\",h,m)\n\n}\n\n", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar m, n int64\n\tfmt.Scan(&n, &m)\n\tmin := math.Max(float64(n-2*m), 0.0)\n\n\tconnectedCount := int64(0)\n\tusedEdges := int64(0)\n\tfor i := int64(1); i < n; i++ {\n\t\tif usedEdges >= m {\n\t\t\tbreak\n\t\t}\n\t\tusedEdges += i\n\t\t// The first edge connects two vertices, otherwise, every new vertex can use i edges.\n\t\tif connectedCount == 0 {\n\t\t\tconnectedCount = 2\n\t\t} else {\n\t\t\tconnectedCount++\n\t\t}\n\t}\n\tfmt.Println(min, n-connectedCount)\n}\n", "src_uid": "daf0dd781bf403f7c1bb668925caa64d"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst Mod = 998244353\n\nfunc main() {\n\tdefer _w.Flush()\n\tn, x := ReadInt(), ReadInt()\n\n\tvar dp [501][501]int64\n\tdp[n][int64(0)] = int64(1)\n\tfor i := n; i >= int64(2); i-- {\n\t\tfor j := int64(0); j < x; j++ {\n\t\t\tif dp[i][j] == int64(0) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tnj := Min(x, j+i-int64(1))\n\t\t\tpow := int64(1)\n\t\t\tfor k := i; k >= int64(0); k-- {\n\t\t\t\tdp[k][nj] += dp[i][j] * ModCombination(i, k) % Mod * pow\n\t\t\t\tdp[k][nj] %= Mod\n\t\t\t\tpow = pow * (nj - j) % Mod\n\t\t\t}\n\t\t}\n\t}\n\tans := int64(0)\n\tfor j := int64(0); j <= x; j++ {\n\t\tans += dp[int64(0)][j]\n\t\tans %= Mod\n\t}\n\tprintln(((ans % Mod) + Mod) % Mod)\n}\n\nfunc ModCombination(n, k int64) (ret int64) {\n\tif n < k {\n\t\treturn int64(0)\n\t}\n\tfor ret = int64(1); n > int64(0) || k > int64(0); n, k = n/Mod, k/Mod {\n\t\tret = ret * fac[n%Mod] % Mod * finv[k%Mod] % Mod * finv[(n-k)%Mod] % Mod\n\t}\n\treturn\n}\n\nconst MAX = 500\n\nvar fac, finv, inv [MAX + 1]int64\n\nfunc init() {\n\tfac[int64(0)], fac[int64(1)], finv[int64(0)], finv[int64(1)], inv[int64(1)] = int64(1), int64(1), int64(1), int64(1), int64(1)\n\tfor i := int64(2); i <= MAX; i++ {\n\t\tfac[i], inv[i] = fac[i-int64(1)]*i%Mod, Mod-inv[Mod%i]*(Mod/i)%Mod\n\t\tfinv[i] = finv[i-int64(1)] * inv[i] % Mod\n\t}\n}\n\nfunc Min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc ReadString() (s string) { fmt.Fscan(_r, &s); return }\nfunc ReadInt() (i int64) { fmt.Fscan(_r, &i); return }\nfunc print(a ...interface{}) { fmt.Fprint(_w, a...) }\nfunc println(a ...interface{}) { fmt.Fprintln(_w, a...) }\nfunc prints(s []int64) { v := fmt.Sprint(s); println(v[int64(1) : int64(len(v))-int64(1)]) }\n", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n nSum := 0\n for i := 0; i < len(s); i++ { // for every Q in s\n if s[i] != 'Q' { // first Q\n continue\n }\n\n for j := i + 1; j < len(s); j++ { // for every Q after s[i]\n if s[j] == 'Q' { // second Q\n for k := i + 1; k < j; k++ {\n if s[k] == 'A' {\n nSum += 1\n }\n }\n }\n }\n \n }\n\n fmt.Println(nSum)\n}\n", "src_uid": "8aef4947322438664bd8610632fe0947"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar r, g, b, i int32\n\tvar maxVal int32\n\tfmt.Scan(&r, &g, &b)\n\tminVal := min(r, g, b)\n\tmaxVal = r/3 + g/3 + b/3\n\tminAll := min(int32(2), minVal, math.MaxInt32)\n\tfor i = 1; i <= minAll; i++ {\n\t\tmaxVal = max(maxVal, ((r-i)/3+(g-i)/3+(b-i)/3)+i, math.MinInt32)\n\t}\n\tfmt.Printf(\"%v\", maxVal)\n}\n\nfunc min(a int32, b int32, c int32) int32 {\n\tif a <= b && a <= c {\n\t\treturn a\n\t} else if b <= a && b <= c {\n\t\treturn b\n\t} else {\n\t\treturn c\n\t}\n}\n\nfunc max(a int32, b int32, c int32) int32 {\n\tif a >= b && a >= c {\n\t\treturn a\n\t} else if b >= a && b >= c {\n\t\treturn b\n\t} else {\n\t\treturn c\n\t}\n}\n", "src_uid": "acddc9b0db312b363910a84bd4f14d8e"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tnum := 0\n\tfmt.Scan(&num)\n\tprimeMap := map[int]int{}\n\tif num == 1 {\n\t\tfmt.Println(\"1 0\")\n\t\tos.Exit(0)\n\t}\n\n\tfor i := 2; i <= 1000; i++ {\n\t\tfor num%i == 0 {\n\t\t\tnum, primeMap[i] = num/i, primeMap[i]+1\n\t\t}\n\t}\n\tif num > 1 {\n\t\tprimeMap[num]++\n\t}\n\n\tmax := 0\n\tfor _, v := range primeMap {\n\t\tif v > max {\n\t\t\tmax = v\n\t\t}\n\t}\n\n\tfinalValue := 1\n\tfor k := range primeMap {\n\t\tfinalValue *= k\n\t}\n\n\tallTheSame := true\n\tfor _, v := range primeMap {\n\t\tif v != max {\n\t\t\tallTheSame = false\n\t\t}\n\t}\n\n\tstep := 0\n\ttmp := 1\n\tfor tmp < max {\n\t\tstep, tmp = step+1, tmp*2\n\t}\n\n\t// In what condition, we need increase step?\n\t// 1. tmp > max, which means we need mul the num, does not matter whether \"all the same\"\n\t// 2. tmp == max, but is not \"all the same\", which means we still mul once\n\tif (tmp > max) || ((tmp == max) && !allTheSame) {\n\t\tstep++\n\t}\n\tfmt.Println(finalValue, step)\n}\n", "src_uid": "212cda3d9d611cd45332bb10b80f0b56"} {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF101C(in io.Reader, out io.Writer) {\n\tvar x, y [3]int64\n\tfor i := 0; i < 3; i++ {\n\t\tFscan(in, &x[i], &y[i])\n\t}\n\td := x[2]*x[2] + y[2]*y[2]\n\tfor i := 0; i < 4; i++ {\n\t\tx[0], y[0] = y[0], x[0]\n\t\ty[0] = -y[0]\n\t\tdx, dy := x[1]-x[0], y[1]-y[0]\n\t\td1, d2 := dx*x[2]+dy*y[2], dx*y[2]-dy*x[2]\n\t\tif d == 0 && dx == 0 && dy == 0 || d > 0 && d1%d == 0 && d2%d == 0 {\n\t\t\tFprint(out, \"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tFprint(out, \"NO\")\n}\n\nfunc main() { CF101C(os.Stdin, os.Stdout) }\n", "src_uid": "cc8a8af1ba2b19bf081e379139542883"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\tscanner = bufio.NewScanner(os.Stdin)\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt()\n\ts := next()\n\t// println(s)\n\n\tfor i := 0; i < n; i++ {\n\t\tif s[i] == '*' {\n\t\t\tlength := 0\n\n\t\t\tfor j := i + 1; j < n; j++ {\n\t\t\t\tif s[j] == '*' {\n\t\t\t\t\tlength = j - i\n\t\t\t\t\t// println(i, length)\n\t\t\t\t\t\n\t\t\t\t\tif i+length*4 < n &&\n\t\t\t\t\t\ts[i+length*2] == '*' &&\n\t\t\t\t\t\ts[i+length*3] == '*' &&\n\t\t\t\t\t\ts[i+length*4] == '*' {\n\t\t\t\t\t\tprintln(\"yes\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprintln(\"no\")\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}\n", "src_uid": "12d451eb1b401a8f426287c4c6909e4b"} {"source_code": "package main\n\nimport \"fmt\"\n\n// max(fn) <= p\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc sum(a []int) int {\n\tnSum := 0\n\tfor _, v := range a {\n\t\tnSum += v\n\t}\n\n\treturn nSum\n}\n\nfunc diff(a, b int) int {\n\tif a > b {\n\t\treturn a - b\n\t}\n\n\treturn b - a\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tif n == 1 {\n\t\tfmt.Println(\"360\")\n\t\treturn\n\t}\n\n\ta := make([]int, n * 2)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\tfor i := 0; i < n; i++ { // fold\n\t\ta[n + i] = a[i]\n\t}\n\n\t// enum every possible\n\tnMin := 360\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i + 1; j < n; j++ {\n\t\t\t//fmt.Println(\"i\", i, \"j\", j)\n\t\t\tf1 := sum(a[i:j])\n\t\t\tf2 := sum(a[j:n+i])\n\t\t\td := diff(f1, f2)\n\t\t\tnMin = min(nMin, d)\n\t\t}\n\t}\n\n\tfmt.Println(nMin)\n}\n", "src_uid": "1b6a6aff81911865356ec7cbf6883e82"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tinputString := \"\"\n\tfmt.Scanf(\"%s\", &inputString)\n\tl := len(inputString)\n\tif l==1 {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t} else if l==2 && inputString[0]!=inputString[1] {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t} else if l==3 && inputString[0]!=inputString[1] && inputString[0]==inputString[2] {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tld := l/2\n\tres := 0\n\tfor i := 0; i < ld; i++ {\n\t\tif inputString[i] != inputString[l-1-i] {\n\t\t\tres++\n\t\t\tif res > 1 {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tif res == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else if res == 0 && l%2 == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52"} {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1056/B\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn, m int\n\n\tM, MM [1000 + 50]int\n)\n\nfunc main() {\n\tn, m = ReadInt2()\n\n\tq := n / m\n\tfor i := 0; i < m; i++ {\n\t\tM[i] = q\n\t}\n\tfor i := 1; i <= n%m; i++ {\n\t\tM[i]++\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tto := (i * i) % m\n\t\tMM[to] += M[i]\n\t}\n\n\tans := int64(0)\n\tans += int64(MM[0]) * int64(MM[0])\n\tfor i := 1; i < m; i++ {\n\t\tans += int64(MM[i]) * int64(MM[m-i])\n\t}\n\tfmt.Println(ans)\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "src_uid": "2ec9e7cddc634d7830575e14363a4657"} {"source_code": "\ufeffpackage main\nimport (\n\t\"fmt\"\n\t//\"bufio\"\n\t//\"os\"\n\t//\"strconv\"\n)\n\nfunc main() {\n\tvar a,b,c,d int\n\tfmt.Scan(&a,&b,&c)\n\td=c*b+(a-1)*b+(c-1)*(a-1)\n\tfmt.Println(d)\n}\n\n\n\n\n", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da"} {"source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n var n, k int\n fmt.Scanf(\"%d%d\\n\", &n, &k)\n a := make([]int, n)\n for i := 0; i < n; i++ {\n fmt.Scanf(\"%d\", &a[i])\n }\n fmt.Scanf(\"\\n\")\n b := make([]int, k)\n for i := 0; i < k; i++ {\n fmt.Scanf(\"%d\", &b[i])\n }\n sort.Ints(b)\n for i := 0; i < n; i++ {\n if a[i] == 0 {\n a[i] = b[k - 1]\n k--\n }\n }\n for i := 1; i < n; i++ {\n if a[i - 1] > a[i] {\n fmt.Printf(\"Yes\\n\")\n return\n }\n }\n fmt.Printf(\"No\\n\")\n return\n}\n", "src_uid": "40264e84c041fcfb4f8c0af784df102a"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\tfor i := 1; m-i >= 0; i++ {\n\t\tm = m - i\n\t\tif i == n {\n\t\t\ti = 0\n\t\t}\n\t}\n\tfmt.Println(m)\n}\n", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb"} {"source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nfunc main() {\n\tvar b, g, n int\n\tfmt.Scan(&b, &g, &n)\n\tans := 0\n\tfor i := 0; i <= n; i++ {\n\t\tif i <= b && n-i <= g {\n\t\t\tans++\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "src_uid": "9266a69e767df299569986151852e7b1"} {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tn := 0\n\tScan(&n)\n\n\ttype pair struct{ a0, len int }\n\tconst mx = 1e5\n\tps := [mx + 1][]pair{}\n\tfor l := 2; l*(l+1)/2 <= mx; l++ {\n\t\tfor a0 := 1; ; a0++ {\n\t\t\ts := (2*a0 + l - 1) * l / 2\n\t\t\tif s > mx {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tps[s] = append(ps[s], pair{a0, l})\n\t\t}\n\t}\n\tsg := [mx + 1]int{}\n\tfor i := range sg {\n\t\tmex := map[int]bool{}\n\t\tfor _, p := range ps[i] {\n\t\t\ts := 0\n\t\t\tfor j := p.a0; j-p.a0 < p.len; j++ {\n\t\t\t\ts ^= sg[j]\n\t\t\t}\n\t\t\tif i == n && s == 0 {\n\t\t\t\tPrint(p.len)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmex[s] = true\n\t\t}\n\t\tfor ; mex[sg[i]]; sg[i]++ {\n\t\t}\n\t}\n\tPrint(-1)\n}\n", "src_uid": "63262317ba572d78163c91b853c05506"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\ts := \"\"\n\tfmt.Scan(&s)\n\tn := strings.Count(s, \"-\")\n\tb := strings.Count(s, \"o\")\n\tif b == 0 || n%b == 0 {\n\t\tfmt.Printf(\"YES\\n\")\n\t} else {\n\t\tfmt.Printf(\"NO\\n\")\n\t}\n}\n", "src_uid": "6e006ae3df3bcd24755358a5f584ec03"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn, k := 0, 0\n\ts := \"\"\n\tfmt.Fscanf(in, \"%d %d\\n\", &n, &k)\n\tfmt.Fscanf(in, \"%s\\n\", &s)\n\t//\tfmt.Println(s)\n\ta := make([]int, 26)\n\tfor i := 0; i < len(s); i++ {\n\t\ta[s[i]-'a'] = 1\n\t}\n\tans := 0\n\tcnt := 0\n\tfor i := 0; i < k; i++ {\n\t\tfor j := 0; j < 26; j++ {\n\t\t\tif a[j] == 1 {\n\t\t\t\tans += j + 1\n\t\t\t\tcnt++\n\t\t\t\ta[j] = 0\n\t\t\t\tif j+1 < 26 {\n\t\t\t\t\ta[j+1] = 0\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\t//fmt.Println(ans, cnt)\n\tif cnt < k {\n\t\tfmt.Fprintf(out, \"%d\\n\", -1)\n\t} else {\n\t\tfmt.Fprintf(out, \"%d\\n\", ans)\n\t}\n\treturn\n}", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc abs(num int) int {\n\treturn max(num, -num)\n}\n\nfunc main() {\n\tvar r1, c1, r2, c2 int\n\tfmt.Scan(&r1, &c1, &r2, &c2)\n\tvar rook, bishop, king int\n\tif r1 == r2 || c1 == c2 {\n\t\trook = 1\n\t} else {\n\t\trook = 2\n\t}\n\tif (r1+c1)%2 != (r2+c2)%2 {\n\t\tbishop = 0\n\t} else if r1+c1 == r2+c2 || r1-c1 == r2-c2 {\n\t\tbishop = 1\n\t} else {\n\t\tbishop = 2\n\t}\n\tking = max(abs(r1-r2), abs(c1-c2))\n\tfmt.Println(rook, bishop, king)\n}\n", "src_uid": "7dbf58806db185f0fe70c00b60973f4b"} {"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", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scan(&n, &s)\n\n\tans := 0\n\tm := make(map[byte]bool)\n\tfor i := 0 ; i < len(s) ; i++ {\n\t\tif s[i] >= 'a' && s[i] <= 'z' {\n\t\t\tm[s[i]] = true\n\t\t\tif len(m) > ans {\n\t\t\t\tans = len(m)\n\t\t\t}\n\t\t} else {\n\t\t\tm = make(map[byte]bool)\n\t\t}\n\t}\n\tfmt.Println(ans)\n}", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var cd string\n fmt.Scan(&cd)\n if cd == \"a1\" || cd == \"a8\" || cd == \"h1\" || cd == \"h8\" {\n fmt.Print(3)\n return\n }\n if cd[0] == 'a' || cd[0] == 'h' || cd[1] == '1' || cd[1] == '8' {\n fmt.Print(5)\n return\n }\n fmt.Print(8)\n}", "src_uid": "6994331ca6282669cbb7138eb7e55e01"} {"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", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7"} {"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", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\ntype a struct {\n\tdays, index int\n}\n\ntype aSlice []a\n\nfunc (as aSlice) Len() int {\n\treturn len(as)\n}\n\nfunc (as aSlice) Less(i, j int) bool {\n\tif as[i].days < as[j].days {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}\n\nfunc (as aSlice) Swap(i, j int) {\n\tas[i], as[j] = as[j], as[i]\n}\n\nvar readWriter = bufio.NewReadWriter(\n\tbufio.NewReader(os.Stdin),\n\tbufio.NewWriter(os.Stdout))\n\nfunc main() {\n\tdefer readWriter.Flush()\n\n\tvar n, k, m int\n\n\tfmt.Fscan(readWriter, &n, &k)\n\n\tas := make(aSlice, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(readWriter, &(as[i].days))\n\t\tas[i].index = i + 1\n\t}\n\n\tsort.Sort(as)\n\n\tfor _, a := range as {\n\t\tif k-a.days < 0 {\n\t\t\tbreak\n\t\t}\n\n\t\tk = k - a.days\n\t\tm++\n\t}\n\n\tfmt.Fprintln(readWriter, m)\n\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Fprint(readWriter, as[i].index)\n\t\tfmt.Fprint(readWriter, \" \")\n\t}\n\n\tif m > 0 {\n\t\tfmt.Fprintln(readWriter)\n\t}\n}\n", "src_uid": "dbb164a8dd190e63cceba95a31690a7c"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, m float64\n\tfmt.Scanf(\"%f %f\", &n, &m)\n\n\tif m == 0 {\n\t\tfmt.Print(1)\n\t\treturn\n\t}\n\tfmt.Print(int(math.Min(m, n-m)))\n}\n", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648"} {"source_code": "// 437A-mic_rizal\npackage main\n\nimport (\n \"fmt\"\n)\n\nvar jwbncumanboleh1 int\nvar an string\n\nfunc solve(A, B, C, D string) {\n a := len(A) - 2\n b := len(B) - 2\n c := len(C) - 2\n d := len(D) - 2\n if (2*a <= b && 2*a <= c && 2*a <= d) || (a >= 2*b && a >= 2*c && a >= 2*d) {\n an = string(A[0])\n jwbncumanboleh1++\n }\n}\n\nfunc main() {\n var a, b, c, d string\n fmt.Scan(&a, &b, &c, &d)\n solve(a, b, c, d)\n solve(b, a, c, d)\n solve(c, a, b, d)\n solve(d, a, b, c)\n\n if jwbncumanboleh1 != 1 {\n an = \"C\"\n fmt.Println(an)\n } else {\n fmt.Println(an)\n }\n}\n", "src_uid": "30725e340dc07f552f0cce359af226a4"} {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar a int\nvar b int\nvar f int\nvar k int\n\nfunc main() {\n fmt.Scan(&a, &b, &f, &k)\n now := b\n ans := 0\n if f > b {\n fmt.Println(-1)\n } else {\n now -= f\n d := f\n for i := 1; i < k; i++ {\n if i&1 != 0 {\n d = a - f\n } else {\n d = f\n }\n d <<= 1\n if d > now {\n ans += 1\n now = b\n }\n if d > now {\n fmt.Println(-1)\n return\n }\n now -= d\n }\n if k&1 != 0 {\n d = a - f\n } else {\n d = f\n }\n if d > now {\n ans += 1\n now = b\n }\n if d > now {\n fmt.Println(-1)\n } else {\n fmt.Println(ans)\n }\n }\n}", "src_uid": "283aff24320c6518e8518d4b045e1eca"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\t// get input\n\tvar n, S int\n\tfmt.Scanf(\"%d %d\", &n, &S)\n\n\t// solve\n\tcount := 0\n\tfor s := S; s > 0; s -= n {\n\t\tcount++\n\t}\n\n\t// print out solution\n\tfmt.Println(count)\n}\n", "src_uid": "04c067326ec897091c3dbcf4d134df96"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n,m int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tb := make([]int64, 5)\n\ta := make([]int64, 5)\n\tfor i:=1; i<=n; i++{\n\t\ta[i%5] +=1\n\t}\n\tfor i:=1; i<=m; i++{\n\t\tb[i%5] +=1\n\t}\n\tans := a[0] * b[0] + a[1] * b[4] + a[2] * b[3] + a[3] * b[2] + a[4] * b[1]\n\tfmt.Printf(\"%v\", ans)\n}", "src_uid": "df0879635b59e141c839d9599abd77d2"} {"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}", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee"} {"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", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86"} {"source_code": "// 84A-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfmt.Println(2*n - (n / 2))\n}\n", "src_uid": "031e53952e76cff8fdc0988bb0d3239c"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"text/scanner\"\n)\n\nfunc check(e error) {\n\tif e != nil {\n\t\tpanic(e)\n\t}\n}\n\nfunc main() {\n\tvar w, y int // first inputs to the problem\n\n\tdat, err := ioutil.ReadAll(os.Stdin)\n\tcheck(err)\n\tvar str_data string = string(dat);\n\n\treader := strings.NewReader(str_data)\n\t\n\tvar scn scanner.Scanner\n\tscn.Init(reader)\n\n scn.Scan()\n\tvar text string = scn.TokenText();\n\t\n\tw, err = strconv.Atoi(text)\n\tcheck(err)\n\n\tscn.Scan()\n\ttext = scn.TokenText();\n\t\n\ty, err = strconv.Atoi(text)\n\tcheck(err)\n\n\tvar max int\n\tif w > y {\n\t\tmax = w\n\t} else {\n\t\tmax = y\n\t}\n\n\t// if max is 6, numerator is 1\n\t// if max is 1, numerator is 6\n\tvar numerator int = 6 - max + 1\n\n\t// now let's reduce if we can\n\tif numerator == 6 {\n\t\tfmt.Print(\"1/1\");\n\t} else if numerator == 4 {\n\t\tfmt.Print(\"2/3\")\n\t} else if numerator == 3 {\n\t\tfmt.Print(\"1/2\")\n\t} else if numerator == 2 {\n\t\tfmt.Print(\"1/3\")\n\t} else if numerator == 1 {\n\t\tfmt.Print(\"1/6\")\n\t} else {\n\t\tfmt.Print(\"5/6\")\n\t}\n}", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a [3][2]int\n\tfor i := 0; i < 3; i++ {\n\t\tif _, err := fmt.Scanf(\"%d %d\\n\", &a[i][0], &a[i][1]); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\tm := a[0][0]\n\tn := a[0][1]\n\tfor j := 0; j < 2; j++ {\n\t\ts := a[1][j]\n\t\tt := a[1][(j+1)%2]\n\t\tfor k := 0; k < 2; k++ {\n\t\t\tu := a[2][k]\n\t\t\tv := a[2][(k+1)%2]\n\n\t\t\tif (s+u <= m && max(t, v) <= n) || (t+v <= n && max(s, u) <= m) {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}\n\nfunc max(a, b int) int {\n\tif a >= b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var yc, bc uint64\n var y,g,b uint64\n var yn, bn uint64\n fmt.Scan(&yc, &bc, &y, &g, &b)\n yn = 2*y + 1*g\n bn = 1*g + 3*b\n var total uint64\n if yn > yc {\n total += yn - yc\n }\n if bn > bc {\n total += bn - bc\n }\n fmt.Print(total)\n}", "src_uid": "35202a4601a03d25e18dda1539c5beba"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn, m := int64(nextInt()), int64(nextInt())\n\n\tif n % m == 0 {\n\t\tprintln(pair(n/m) * m, pair(n-m+1))\n\t} else {\n\t\tprintln(pair(n/m) * (m - (n%m)) + pair(n/m + 1) * (n%m), pair(n-m+1))\n\t}\n\n\t// println(n)\n}\n\nfunc pair(n int64) int64 {\n\treturn n * (n-1) / 2\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}", "src_uid": "a081d400a5ce22899b91df38ba98eecc"} {"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", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nvar in *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar out *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc main() {\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\tin.Scan()\n\tin.Scan()\n\tset := make(map[byte]bool)\n\tfor _, i := range []byte(strings.ToLower(in.Text())) {\n\t\tset[i] = true\n\t}\n\n\tif len(set) == 26 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tfor {\n\t\tt:=\"\"\n\t\tf:=\"NO\"\n\t\tn,_:=fmt.Scan(&t)\n\t\tif n==0{\n\t\t\tbreak\n\t\t}\n\t\tfor i := 5 ;i>0;i--{\n\t\t\th:=\"\"\n\t\t\tn,_:=fmt.Scan(&h)\n\t\t\tif n==0{\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif h[0] == t[0]{\n\t\t\t\tf=\"YES\"\n\t\t\t}else if h[1] == t[1]{\n\t\t\t\tf=\"YES\"\n\t\t\t}\n\n\n\t\t}\n\t\tfmt.Println(f)\n\n\t}\n}\n", "src_uid": "699444eb6366ad12bc77e7ac2602d74b"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t// \"time\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\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 main() {\n\t// defer func(start time.Time) {\n\t// \tfmt.Println(time.Since(start))\n\t// }(time.Now())\n\n\t// reader := bufio.NewReader(os.Stdin)\n\n\t// var s string\n\t// fmt.Fscan(reader, &s)\n\ts := next()\n\tnineteens := make([]int, 4)\n\n\tfor i := range s {\n\t\tswitch s[i] {\n\t\tcase 'e':\n\t\t\tnineteens[0]++\n\t\tcase 'i':\n\t\t\tnineteens[1]++\n\t\tcase 'n':\n\t\t\tnineteens[2]++\n\t\tcase 't':\n\t\t\tnineteens[3]++\n\t\t}\n\t}\n\n\tmins := []int{nineteens[0]/3, nineteens[1], (nineteens[2]-1)/2, nineteens[3]}\n\tresult := mins[0]\n\n\tfor i:=1; i= 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", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x,y string\n\tfmt.Scanf(\"%s %s\", &x, &y)\n\tif x == y {\n\t\tfmt.Printf(x)\n\t} else {\n\t\tfmt.Printf(\"1\")\n\t}\n}", "src_uid": "9c5b6d8a20414d160069010b2965b896"} {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strconv\"\n)\ntype Pos struct {\n i, j, lvl, di, dj int\n}\n\nfunc solve() {\n const mx = 300\n n := readInt()\n a := readIntArray(n)\n\n was := [mx+2][mx+2][31][3][3]bool{}\n ans := [mx+2][mx+2]bool{}\n setWas := func(p Pos) {\n was[p.i][p.j][p.lvl][p.di+1][p.dj+1] = true\n }\n checkWas := func(p Pos) bool {\n return was[p.i][p.j][p.lvl][p.di+1][p.dj+1]\n }\n q := []Pos{Pos{mx/2, mx/2, 0, 1, 0}}\n setWas(q[0])\n for i := 0; i < len(q); i++ {\n cur := q[i]\n for t := 0; t < a[cur.lvl]; t++ {\n cur.i += cur.di\n cur.j += cur.dj\n ans[cur.i][cur.j] = true\n }\n if nextLvl := cur.lvl+1; nextLvl < n {\n for rot := -1; rot < 2; rot += 2 {\n next := Pos{cur.i, cur.j, nextLvl, 0, 0}\n if abs(cur.di*cur.dj) == 1 {\n if rot == 1 {\n next.di = cur.di\n } else {\n next.dj = cur.dj\n }\n } else {\n if cur.di == 0 {\n next.di = rot\n next.dj = cur.dj\n } else {\n next.di = cur.di\n next.dj = rot\n }\n \t\t\t\t}\n if !checkWas(next) {\n setWas(next)\n q = append(q, next)\n }\n }\n }\n }\n res := 0\n for i := range ans {\n for _, b := range ans[i] {\n if b {\n res++\n }\n }\n }\n fmt.Println(res)\n}\n\n\n\n// Helpers\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\n// Sort\n\ntype Ints64 []int64\n\nfunc (a Ints64) Len() int { return len(a) }\nfunc (a Ints64) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a Ints64) Less(i, j int) bool { return a[i] < a[j] }\n\n/* Sort tempalte\nfunc (a ) Len() int { return len(a) }\nfunc (a ) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ) Less(i, j int) bool { return }\n*/\n", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte. Trailing '\\n' will not be included.\n// See also comments on readb()\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Utilities\n\nfunc sumSlice(a []int) int {\n\tvar res int\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc sumSlicell(a []int64) int64 {\n\tvar res int64\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc readInts(N int) (int, []int) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int, N)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\treturn N, a\n}\n\nfunc readIntsll(N int) (int, []int64) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int64, N)\n\tfor i := range a {\n\t\ta[i] = readll()\n\t}\n\treturn N, a\n}\n\n// reverse slice in place\nfunc reverse(a []int) {\n\tfor i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {\n\t\ta[i], a[j] = a[j], a[i]\n\t}\n}\n\n// areverse: allocating reverse\nfunc areverse(a []int) []int {\n\tb := make([]int, len(a))\n\tfor i := range a {\n\t\tb[i] = a[len(a)-i-1]\n\t}\n\treturn b\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n\nfunc main() {\n\tdefer Flush()\n\n\tn, a := readInts(0)\n\t_ = n\n\tp := make([]bool, 3)\n\tp[0] = true\n\tp[1] = true\n\tfor _, v := range a {\n\t\twin := v - 1\n\t\tvar lose, spect int\n\t\tif !p[win] {\n\t\t\tprintln(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tfor i := range p {\n\t\t\tif i == win {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !p[i] {\n\t\t\t\tspect = i\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlose = i\n\t\t}\n\t\tp[win] = true\n\t\tp[spect] = true\n\t\tp[lose] = false\n\t}\n\tprintln(\"YES\")\n}\n", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,a int\n fmt.Scan(&n)\n total := 0\n for i := 0; i < n; i++ {\n fmt.Scan(&a)\n total += a\n }\n total--\n n++\n ans := 0\n for i := 1; i <= 5; i++ {\n if (total+i)%n != 0 {\n ans++\n }\n }\n fmt.Println(ans)\n}\n", "src_uid": "ff6b3fd358c758324c19a26283ab96a4"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar nFloors int\n\tvar sResident string\n\tvar as []int\n\t_, _ = fmt.Scanln(&nFloors)\n\n\tfor i := 0; i < nFloors; i++ {\n\t\t_, _ = fmt.Scan(&sResident)\n\t\tresident, _ := strconv.Atoi(sResident)\n\t\tas = append(as, resident)\n\t}\n\n\tbestX := math.MaxInt32\n\tfor x := 0; x < len(as); x++ {\n\t\tif sum := sumForXA(x, as); sum < bestX {\n\t\t\tbestX = sum\n\t\t}\n\t}\n\tfmt.Println(bestX)\n}\n\nfunc sumForXA(x int, a []int) int {\n\tunits := 0\n\tfor i := 0; i < len(a); i++ {\n\t\tif a[i] > 0 {\n\t\t\tsum := 0\n\t\t\t// move from x to i\n\t\t\tsum += int(math.Abs(float64(i - x)))\n\t\t\t// move from i to 0\n\t\t\tsum += i\n\t\t\t// move from 0 to x\n\t\t\tsum += x\n\t\t\t// twice (elevator down, up)\n\t\t\tsum *= 2\n\t\t\t// multiply with a\n\t\t\tsum *= a[i]\n\t\t\tunits += sum\n\t\t}\n\t}\n\treturn units\n}", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\tscanner *bufio.Scanner\n\twriter *bufio.Writer\n\n\ta int64\n\tb int64\n\tresult int64\n)\n\nfunc in() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\ta = readInt64()\n\tb = readInt64()\n}\n\nfunc out() {\n\twriter = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tif result >= 0 {\n\t\tprintInt64(result)\n\t} else {\n\t\tprintString(\"infinity\")\n\t}\n\tprintLine()\n}\n\nfunc run() {\n\tif b > a {\n\t\tresult = 0\n\t} else if b == a {\n\t\tresult = -1\n\t} else {\n\t\tresult = 0\n\t\tm := a - b\n\t\tfor i := int64(1); i*i <= m; i++ {\n\t\t\tif i*i == m && i > b {\n\t\t\t\tresult++\n\t\t\t} else {\n\t\t\t\tif m%i == 0 {\n\t\t\t\t\tif i > b {\n\t\t\t\t\t\tresult++\n\t\t\t\t\t}\n\t\t\t\t\tif m/i > b {\n\t\t\t\t\t\tresult++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc main() {\n\tin()\n\trun()\n\tout()\n}\n\n// Read.\n\nfunc readString() string {\n\tscanner.Scan()\n\tans := scanner.Text()\n\treturn ans\n}\n\nfunc readLine() string {\n\tscanner.Split(bufio.ScanLines)\n\tdefer scanner.Split(bufio.ScanWords)\n\treturn readString()\n}\n\nfunc readInt() int {\n\tans, _ := strconv.ParseInt(readString(), 10, 0)\n\treturn int(ans)\n}\n\nfunc readInt64() int64 {\n\tans, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn ans\n}\n\nfunc readFloat64() float64 {\n\tans, _ := strconv.ParseFloat(readString(), 64)\n\treturn ans\n}\n\n// Write.\n\nfunc printString(value string) {\n\twriter.WriteString(value)\n}\n\nfunc printLine() {\n\tprintString(\"\\n\")\n}\n\nfunc printSpace() {\n\tprintString(\" \")\n}\n\nfunc printInt(value int) {\n\tprintString(strconv.FormatInt(int64(value), 10))\n}\n\nfunc printInt64(value int64) {\n\tprintString(strconv.FormatInt(value, 10))\n}\n\nfunc printFloat64(value float64) {\n\tprintString(strconv.FormatFloat(value, 'f', 10, 64))\n}\n", "src_uid": "6e0715f9239787e085b294139abb2475"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tpanel := make([][]int,3)\n\tt := true\n\tfor i := range panel{\n\t\tvar s string\n\t\tfmt.Scanf(\"%s\\n\",&s)\n\t\t//fmt.Printf(\"%s\", s)\n\t\tpanel[i] = make([]int, 3)\n\t\tfor j := range panel[i]{\n\t\t\tif s[j] == 'X'{\n\t\t\t\tpanel[i][j] = 1\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\tfor i := range panel{\n\t\tfor j := range panel[i] {\n\t\t\tif panel[i][j]==1{\n\t\t\t\tif panel[i][j] != panel[2 - i][2 - j]{\n\t\t\t\t\t\tt = false\n\t\t\t\t}\n\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\t\n\tif t{\n\t\tfmt.Printf(\"YES\")\n\t}else{\n\t\tfmt.Printf(\"NO\")\n\t}\n\n\n\t\n\n}", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tweight := make([]int,2*n)\n\tfor i := 0; i < 2*n; i++ {\n\t\tfmt.Scan(&weight[i])\n\t}\n\tsort.Ints(weight)\n\tres := 50000\n\tfor i := 0; i < 2*n-1; i++ { //enumerate the two elements\n\t\tfor j := i + 1; j < 2*n; j++ {\n\t\t\ttot := 0\n\t\t\tfor k := 0; k < 2*n-1; k++ { //left weight\n\t\t\t\tif k==i || k==j{continue} //skip it\n\t\t\t\tr := k+1\n\t\t\t\tfor r==i || r==j {r++} //right weight\n\t\t\t\ttot += weight[r] - weight[k]\n\t\t\t\tk = r //update left\n\t\t\t}\n\t\t\tif tot < res { res = tot} //update the result\n\t\t}\n\t}\n\tfmt.Println(res)\n\n}\n", "src_uid": "76659c0b7134416452585c391daadb16"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n var a,b,c,d bool\n fmt.Scan(&s)\n if len(s) >= 5 { a = true }\n for _, v := range s {\n if (v >= 'A') && (v <= 'Z') { b = true }\n if (v >= 'a') && (v <= 'z') { c = true }\n if (v >= '0') && (v <= '9') { d = true }\n }\n if a && b && c && d {\n fmt.Println(\"Correct\")\n } else {\n fmt.Println(\"Too weak\")\n }\n}\n", "src_uid": "42a964b01e269491975965860ec92be7"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nfunc main() {\n\tvar nString string\n\tn, res := big.NewInt(0), big.NewInt(0)\n\n\tfmt.Scan(&nString)\n\tn, _ = n.SetString(nString, 10)\n\n\tres.Div(n, big.NewInt(2))\n\t_, m := new(big.Int).DivMod(n, big.NewInt(2), big.NewInt(0))\n\n\tif m.Cmp(big.NewInt(0)) > 0 {\n\t\tres.Add(res, n.Neg(n))\n\t}\n\n\tfmt.Println(res)\n}\n", "src_uid": "689e7876048ee4eb7479e838c981f068"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn := nextInt()\n\tmin1, max1 := nextInt(), nextInt()\n\tmin2, max2 := nextInt(), nextInt()\n\tmin3, max3 := nextInt(), nextInt()\n\n\tn -= min1 + min2 + min3\n\n\tn, min1 = add(n, min1, max1)\n\tn, min2 = add(n, min2, max2)\n\tn, min3 = add(n, min3, max3)\n\n\tprintln(min1, min2, min3)\n}\n\nfunc add(n, min, max int) (int, int) {\n\tif n > 0 {\n\t\tif min+n <= max {\n\t\t\tmin += n\n\t\t\tn = 0\n\t\t} else {\n\t\t\tn -= max - min\n\t\t\tmin = max\n\t\t}\n\t}\n\n\treturn n, min\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n", "src_uid": "3cd092b6507079518cf206deab21cf97"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tstr string\n\t)\n\t\n\tfmt.Scan(&str)\n\t\n\trunes := []rune(str)\n\tstrMap := make(map[string]int)\n\tstrMap[str]++\n\tfor i := 0; i < len(str); i++ {\n\t\tcurRune := runes[len(str) - 1]\n\t\tfor j := len(str) - 1; j > 0 ; j-- {\n\t\t\trunes[j] = runes[j - 1]\n\t\t}\n\t\trunes[0] = curRune\n\t\tstrMap[string(runes)]++\n\t}\n\t\n\tfmt.Println(len(strMap))\n}\n", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e"} {"source_code": "package main\r\n\r\nimport (\r\n \"fmt\"\r\n)\r\n\r\nconst N int = 666\r\nvar dp[N*N][2] int64\r\n\r\nfunc main() {\r\n var n int\r\n var mod int64\r\n _,_ = fmt.Scan(&n,&mod)\r\n shift := N*N/2\r\n dp[shift][1]=1\r\n var i,j int\r\n for i = 1; i < n; i++{\r\n var new_dp[N*N][2] int64\r\n for j=0;j= 0; i-- {\n\t//\tsum += n * i\n\t//}\n\treturn sum\n}\n\nfunc main() {\n\tsc := NewScanner()\n\tM, B := sc.NextInt64(), sc.NextInt64()\n\n\tmx := int64(0)\n\tfor x := int64(0); x <= M*B; x++ {\n\t\tif x < 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\ty := -((x - B*M) / M)\n\n\t\tif y < 0 {\n\t\t\tcontinue\n\t\t}\n\t\tn := y + 1\n\t\tq := calc(x, n)\n\t\tif mx < q {\n\t\t\tmx = q\n\t\t}\n\t}\n\tfmt.Println(mx)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b int\n\tvar ind int = 0\n\tfmt.Scan(&a, &b)\n\tfor ; a <= b; ind++ {\n\t\ta *= 3\n\t\tb *= 2\n\t}\n\tfmt.Println(ind)\n}\n", "src_uid": "a1583b07a9d093e887f73cc5c29e444a"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tarr := [...]int{4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777}\n\tluck := false\n\tfor i := range arr {\n\t\tif n%arr[i] == 0 {\n\t\t\tluck = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif luck {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar rel int\n\tvar a int\n\tvar b int\n\tflag := false\n\tfmt.Scan(&rel)\n\tvar ar [5]int\n\tfor i := 0; i < rel; i++ {\n\t\tfmt.Scan(&a)\n\t\tfmt.Scan(&b)\n\t\tar[a-1]++\n\t\tar[b-1]++\n\t}\n\tfor i := 0; i < 5; i++ {\n\t\tif ar[i] != 2 {\n\t\t\tflag = true\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"WIN\")\n\t} else {\n\t\tfmt.Println(\"FAIL\")\n\t}\n}\n", "src_uid": "2bc18799c85ecaba87564a86a94e0322"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc max(nums ...int64) int64 {\n\tvar m int64\n\tfor i, v := range nums{\n\t\tif i == 0 || v > m {\n\t\t\tm = v\n\t\t}\n\t}\n\treturn m\n}\n\nfunc gcd(a, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a % b)\n}\n\nfunc lcm(a, b int) int {\n\treturn a * b / gcd(a, b)\n}\n\nconst MOD = 1000000007\n\nfunc main() {\n\tvar x, y, n int;\n\tscanf(\"%d %d\\n%d\", &x, &y, &n)\n\tn--\n\tseq := make([]int, 6)\n\tseq[0] = x\n\tseq[1] = y\n\tseq[2] = y - x\n\tseq[3] = -x\n\tseq[4] = -y\n\tseq[5] = x - y\n\tfmt.Printf(\"%d\\n\", (seq[n%6] % MOD + MOD) % MOD)\n}\n", "src_uid": "2ff85140e3f19c90e587ce459d64338b"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar in string\n\tfmt.Scanln(&in)\n\n\tout := \"\"\n\n\tfor run := len(in) > 0; run; run = len(in) > 0 {\n\t\tif len(in)%2 == 0 {\n\t\t\tout = string(in[len(in)-1]) + out\n\t\t\tin = in[0 : len(in)-1]\n\t\t} else {\n\t\t\tout = string(in[0]) + out\n\t\t\tin = in[1:len(in)]\n\t\t}\n\t}\n\n\tfmt.Println(out)\n}\n", "src_uid": "992ae43e66f1808f19c86b1def1f6b41"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t//\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar w *bufio.Writer\n\nvar sc *bufio.Scanner\n\nconst minus, zero byte = '-', '0'\n\nfunc nextInt() int {\n\tvar ans, fst int = 0, 0\n\tvar neg bool = false\n\tsc.Scan()\n\tif sc.Bytes()[0] == minus {\n\t\tfst = 1\n\t\tneg = true\n\t}\n\tfor _, j := range sc.Bytes()[fst:] {\n\t\tans = ans*10 + int(j-zero)\n\t}\n\tif neg == true {\n\t\tans = -ans\n\t}\n\treturn ans\n}\n\nfunc printInt(n int) {\n\tw.WriteString(strconv.Itoa(n) + \" \")\n}\n\nfunc Max(a int, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc gcd(a int, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t} else {\n\t\treturn gcd(b, a%b)\n\t}\n}\n\nfunc main() {\n\n\tw = bufio.NewWriter(os.Stdout)\n\tsc = bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\tcnt := 0\n\n\tN := nextInt()\n\tfor m := 1; m <= N; m++ {\n\t\tfor n := m; 2*m*n <= N; n++ {\n\t\t\ta, b, c := 2*m*n, n*n-m*m, n*n+m*m\n\t\t\tif a > b {\n\t\t\t\ta, b = b, a\n\t\t\t}\n\t\t\tif gcd(m, n) == 1 && (m^n)%2 == 1 && b <= N && c <= N {\n\t\t\t\tcnt += N / Max(Max(a, c), b)\n\t\t\t}\n\t\t}\n\t}\n\tprintInt(cnt)\n\tw.Flush()\n\t//YOU FORGOT TO FLUSH!\n}\n", "src_uid": "36a211f7814e77339eb81dc132e115e1"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tk := readInt()\n\tcnt := make([]int, 5)\n\thave := make([]int, 5)\n\thave[4] = n\n\thave[2] = 2 * n\n\tfor i := 0; i < k; i++ {\n\t\tx := readInt()\n\t\tfor x >= 3 {\n\t\t\tif have[4] > 0 {\n\t\t\t\thave[4]--\n\t\t\t\tx -= 4\n\t\t\t} else if have[2] > 0 {\n\t\t\t\thave[2]--\n\t\t\t\tx -= 2\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif x > 0 {\n\t\t\tcnt[x]++\n\t\t}\n\t}\n\tfor cnt[2] > 0 {\n\t\tif have[2] > 0 {\n\t\t\thave[2]--\n\t\t\tcnt[2]--\n\t\t} else if have[4] > 0 {\n\t\t\tcnt[2]--\n\t\t\thave[4]--\n\t\t\thave[1]++\n\t\t} else {\n\t\t\tcnt[2]--\n\t\t\tcnt[1] += 2\n\t\t}\n\t}\n\tif cnt[1] <= have[1]+have[2]+have[4]*2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n", "src_uid": "d1f88a97714d6c13309c88fcf7d86821"} {"source_code": "package 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 abs(x int) int {\n\tif x > 0 {\n\t\treturn x\n\t}\n\treturn -x\n}\n\nfunc main() {\n\tvar x1, y1, x2, y2 int\n\tfmt.Scan(&x1, &y1, &x2, &y2)\n\tfmt.Println(max(abs(x1-x2), abs(y1-y2)))\n}\n", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4"} {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n _, _ = reader.ReadString('\\n')\n input, _ := reader.ReadString('\\n')\n\n ma := make(map[string]int)\n ar := []string{}\n for i, c := range input {\n if i == len(input) - 1 {\n break\n }\n\n cu := string(c) + string(input[i + 1])\n ar = append(ar, cu)\n\n if _, ok := ma[cu]; ok {\n ma[cu] += 1\n } else {\n ma[cu] = 1\n }\n }\n\n max := -999999999\n ret := ar[0]\n for _, m := range ar {\n if ma[m] > max {\n max = ma[m]\n ret = m\n }\n }\n\n fmt.Println(ret)\n}\n", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1"} {"source_code": "// B. Internet Address\n/*\nVasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:\n\t\t\t://.ru[/]\n\nwhere:\n\n can equal either \"http\" (without the quotes) or \"ftp\" (without the quotes),\n is a non-empty string, consisting of lowercase English letters,\n\t \tthe / part may not be present. If it is present, then is a non-empty string, consisting of lowercase English letters.\n\nIf string isn't present in the address, then the additional character \"/\" isn't written. Thus, the address has either two characters \"/\" (the ones that go before the domain), or three (an extra one in front of the context).\n\nWhen the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters \":\", \"/\", \".\".\n\nHelp Vasya to restore the possible address of the recorded Internet resource.\n\nInput\nThe first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only.\n\nIt is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above.\n\nOutput\nPrint a single line \u2014 the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them.\n\nExamples\nInput\nhttpsunrux\n\nOutput\nhttp://sun.ru/x\n\nInput\nftphttprururu\n\nOutput\nftp://http.ru/ruru\n\nNote\nIn the second sample there are two more possible answers: \"ftp://httpruru.ru\" and \"ftp://httpru.ru/ru\".\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ts, _ := reader.ReadString('\\n')\n\tarr := strings.Split(strings.TrimSpace(s), \"\")\n\n\tpIndex := 3\n\turl := \"ftp://\"\n\tif arr[0] == \"h\" {\n\t\tpIndex = 4\n\t\turl = \"http://\"\n\t}\n\n\tcIndex := len(arr)\n\tfor i := pIndex + 1; i < len(arr)-1; i++ {\n\t\tif arr[i] == \"r\" && arr[i+1] == \"u\" {\n\t\t\tcIndex = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif cIndex < len(arr)-2 {\n\t\tfmt.Printf(\"%v%v.ru/%v\", url, strings.Join(arr[pIndex:cIndex], \"\"), strings.Join(arr[cIndex+2:], \"\"))\n\t} else {\n\n\t\tfmt.Printf(\"%v%v.ru\", url, strings.Join(arr[pIndex:cIndex], \"\"))\n\t}\n}\n", "src_uid": "4c999b7854a8a08960b6501a90b3bba3"} {"source_code": "package main\n\nimport(\n \"fmt\"\n \"sort\"\n \"strings\"\n)\n\n\n\nfunc main() {\n var r int64\n fmt.Scan(&r)\n var x int64 = 0\n var y int64 = 0\n var i int64 = 1\n for ; i*i<=r; i++{\n if r-i*i-i-1>0 && (r-i*i-i-1)%(2*i)==0{\n x = i\n y = (r-i*i-i-1)/(2*i)\n break\n }\n }\n if x==0{\n fmt.Println(\"NO\")\n } else {\n fmt.Println(x,y)\n }\n}\n\n\n\n\n\nfunc abs32(a int) int {\n if a<0{\n return -a\n }\n return a\n}\n\nfunc abs64(a int64) int64 {\n if a<0{\n return -a\n }\n return a\n}\n\nfunc min32(a, b int) int {\n if a >= b {\n return b\n }\n return a\n}\n\nfunc max32(a, b int) int {\n if a >= b {\n return a\n }\n return b\n}\n\nfunc min64(a, b int64) int64 {\n if a >= b {\n return b\n }\n return a\n}\n\nfunc max64(a, b int64) int64 {\n if a >= b {\n return a\n }\n return b\n}\n\nfunc gcd(a, b int64) int64 {\n if a % b == 0 {\n return b\n } else {\n return gcd(b, a%b)\n }\n}\n\nfunc lcm(a, b int64) int64 {\n return a / gcd(a, b) * b\n}\n\nfunc scanNums(len int) (nums []int){\n var num int\n for i:=0; i> 1;\n\tans += (x & (1 << 4) ) >> 4;\n\tans += (x & (1 << 2) ) << 1;\n\tans += x & (1 << 1);\n\tans += (x & 1) << 4;\n\tfmt.Println(ans);\n}\n", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c"} {"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", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main(){\n\tvar s,v1,v2,t1,t2 int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in,&s,&v1,&v2,&t1,&t2)\n\ta1 := 2*t1+s*v1\n\ta2 := 2*t2+s*v2\n\tif a1 b {\n\t\treturn Count(a%b, b, steps+a/b)\n\t} else if a < b {\n\t\treturn Count(a, b%a, steps+b/a)\n\t}\n\treturn -1\n}\n\nfunc Solve(a, b int64) int64 {\n\treturn Count(a, b, 0)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar a, b int64\n\tfmt.Fscanf(reader, \"%d %d\\n\", &a, &b)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(a, b))\n}\n", "src_uid": "792efb147f3668a84c866048361970f8"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tconst n int = 3\n\n\tvar l [n][n]int\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tl[i][j] = 1\n\t\t}\n\t}\n\n\tvar p [n][n]int\n\tfor i := 0; i < n; i++ {\n\t\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &p[i][0], &p[i][1], &p[i][2]); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif p[i][j]%2 != 0 {\n\t\t\t\tl[i][j] = (l[i][j] + 1) % 2\n\t\t\t\tif i > 0 {\n\t\t\t\t\tl[i-1][j] = (l[i-1][j] + 1) % 2\n\t\t\t\t}\n\t\t\t\tif i < n-1 {\n\t\t\t\t\tl[i+1][j] = (l[i+1][j] + 1) % 2\n\t\t\t\t}\n\t\t\t\tif j > 0 {\n\t\t\t\t\tl[i][j-1] = (l[i][j-1] + 1) % 2\n\t\t\t\t}\n\t\t\t\tif j < n-1 {\n\t\t\t\t\tl[i][j+1] = (l[i][j+1] + 1) % 2\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tfmt.Printf(\"%d\", l[i][j])\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6"} {"source_code": "package main\n\n/*\n The idea to solve this problem is by realizing that when we encode number\n which having last digit zero (ex. 1200) there won't be extra 0 on encoded\n string, so if we want to decode the string then we need to append exra zero\n on the result.\n\n As for other numbers it is same, the digit is separated by 0, so if there is\n 0 on the middle of number, then there will be \"00\" on the encoded string.\n*/\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var encodeStr string\n\n fmt.Scan(&n)\n fmt.Scan(&encodeStr)\n\n var counter int\n var prevDigit string = \"-1\"\n\n for i := 0; i < n; i++ {\n var currentDigit string = string(encodeStr[i])\n if currentDigit == \"1\" {\n counter++\n if i == n-1 {\n fmt.Printf(\"%d\", counter)\n }\n } else if currentDigit == \"0\" && prevDigit == \"0\" {\n fmt.Printf(\"0\")\n } else if currentDigit == \"0\" && prevDigit != \"0\" {\n fmt.Printf(\"%d\", counter)\n counter = 0\n }\n prevDigit = currentDigit\n }\n\n if string(encodeStr[n - 1]) == \"0\" {\n fmt.Printf(\"0\")\n }\n}\n", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n//TODO, 2017.11.15\nfunc main() {\n\tvar sum int\n\treader := bufio.NewReader(os.Stdin)\n\tarray := make([]int, 6)\n\tfor i := 0; i < 6; i++ {\n\t\tfmt.Fscan(reader, &array[i])\n\t\tsum += array[i]\n\t}\n\tif sum%2 == 1 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tflag := false\n\t\thalf := sum / 2\n\t\tfor i := 0; i < 6; i++ {\n\t\t\tadd := array[i]\n\t\t\tif add > half {\n\t\t\t\tflag = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tother := make([]int, len(array))\n\t\t\tcopy(other, array)\n\t\t\tother = append(other[:i], other[i+1:]...)\n\t\t\tfor j := 0; j < len(other)-1; j++ {\n\t\t\t\tfor k := j + 1; k < len(other)-2; k++ {\n\t\t\t\t\tif add+other[j]+other[k] == half {\n\t\t\t\t\t\tflag = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tif flag == true {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif flag == false {\n\t\t\tfmt.Println(\"NO\")\n\t\t} else {\n\t\t\tfmt.Println(\"YES\")\n\t\t}\n\t}\n}\n", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11"} {"source_code": "\ufeffpackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfmt.Println(\"0\",\"0\",n)\n}\n\n\n\n\n\n", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc solve(n int, a []int) int {\n\tsort.Ints(a)\n\treturn a[n/2]\n}\n\nfunc main() {\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\tn := cin.nextInt()\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = cin.nextInt()\n\t}\n\tfmt.Printf(\"%d\\n\", solve(n, a))\n}\n\n// some io\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}", "src_uid": "f03773118cca29ff8d5b4281d39e7c63"} {"source_code": "\ufeffpackage main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\ta:=make([]int,n)\n\tfor i:=0;i= min && st <= max {\n\t\tprintf(\"YES\\n\")\n\t\ts := st - min\n\t\tres := make([]int, 0)\n\t\tfor i := 0; i < d; i++ {\n\t\t\tn := 0\n\t\t\tif s > 0 {\n\t\t\t\tn = imin(mx[i] - mn[i], s)\n\t\t\t}\n\t\t\ts -= n\n\t\t\tres = append(res, mn[i] + n)\n\t\t}\n\t\tr := fmt.Sprintf(\"%v\", res)\n\t\tprintf(\"%s\\n\", r[1:len(r) - 1])\n\t} else {\n\t\tprintf(\"NO\\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", "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0"} {"source_code": "package main\nimport (\n \"fmt\"\n )\nfunc main(){\n var n int\n i := 1\n fmt.Scan(&n)\n for ;n>i;i++{\n n -= i\n }\n if n == i {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar count int\n\tvar point_war int\n\tsum_war := 0\n\tvar sum_my int\n\tmin_k := 0\n\tfmt.Scan(&count)\n\tvar points [150]int\n\tvar result int\n\tfor i := 0; i < count; i++ {\n\t\tfmt.Scan(&point_war)\n\t\tpoints[i] = point_war\n\t\tsum_war += point_war\n\t\tif point_war > min_k {\n\t\t\tmin_k = point_war\n\t\t}\n\t}\n\tfor i := min_k; i <= 210; i++ {\n\t\tsum_my = 0\n\t\tfor j := 0; j < count; j++ {\n\t\t\tsum_my += i - points[j]\n\t\t}\n\t\tif sum_my > sum_war {\n\t\t\tresult = i\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(result)\n}\n", "src_uid": "d215b3541d6d728ad01b166aae64faa2"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a int\n\tfmt.Scan(&a)\n\tif a == 1 {\n\t\tfmt.Println(1, 1)\n\t\tfmt.Println(1)\n\t\treturn\n\t}\n\tfmt.Println(2*(a-1), 2)\n\tfmt.Println(1, 2)\n}\n", "src_uid": "5c000b4c82a8ecef764f53fda8cee541"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc vk(s1 string, s2 string) string {\n\tvar result string\n\tfor i := 0; i < len(s1); i++ {\n\t\tif s1[i] < s2[i] {\n\t\t\treturn \"-1\"\n\t\t} else if s1[i] > s2[i] {\n\t\t\tresult = result + string(s2[i])\n\t\t} else if s1[i] == s2[i] {\n\t\t\tresult = result + string('z')\n\t\t}\n\t}\n\treturn result\n}\n\nfunc main() {\n\tvar s1, s2 string\n\tfmt.Scanf(\"%s\\n%s\", &s1, &s2)\n\tfmt.Println(vk(s1, s2))\n}\n", "src_uid": "ce0cb995e18501f73e34c76713aec182"} {"source_code": "package main\n\n/*\n\tThe idea to solve this problem is basically by realizing \"x\" is the maximum\n\tthreshold for cake slices in a plate. Slice in cake coming from \"a\" & \"b\". Thus\n\ttotal slices from \"a\" & \"b\" must be larger or equal than nx.\n\n\tBut since slices from \"a\" & slices coming \"b\" cannot be combined in one plate,\n\tthus the condition would become following: (a/x + b/x >= n).\n\n\tThus as long as x <= a && x <= b && (a/x + b/x >= n), we can always increase the\n\tvalue of \"x\". Then in the end we just need to print the mlargest value of \"x\".\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tstdio := bufio.NewReader(os.Stdin)\n\tvar n, a, b int\n\tx := 1\n\tfmt.Fscanf(stdio, \"%d %d %d\", &n, &a, &b)\n\tfor x <= a && x <= b && (a/x+b/x >= n) {\n\t\tx++\n\t}\n\tfmt.Println(x - 1) // decrease the value of x because of excess increment\n}\n", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e"} {"source_code": "package main \n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc solve(cards [5]int) int {\n\tsort.Ints(cards[:])\n\tif cards[3] == cards[4] {\n\t\tif cards[2] == cards[3] {\n\t\t\treturn cards[0] + cards[1]\n\t\t}\n\t\tsum := cards[0] + cards[1] + cards[2]\n\t\tif cards[1] == cards[2] && cards[0] == cards[1] {\n\t\t\tif sum > cards[3] + cards[4] {\n\t\t\t\tsum = cards[3] + cards[4]\n\t\t\t}\n\t\t}\n\t\treturn sum\n\t}\n\t// cards[3] != cards[4]\n\tif cards[2] == cards[3] {\n\t\tif cards[1] == cards[2] {\n\t\t\treturn cards[0] + cards[4]\n\t\t}\n\t\treturn cards[0] + cards[1] + cards[4]\n\t}\n\t// cards[2] != cards[3]\n\tif cards[1] == cards[2] {\n\t\tif cards[0] == cards[1] {\n\t\t\treturn cards[3] + cards[4]\n\t\t}\n\t\treturn cards[0] + cards[3] + cards[4]\n\t}\n\t// cards[1] != cards[2]\n\tif cards[0] == cards[1] {\n\t\treturn cards[2] + cards[3] + cards[4]\n\t}\n\t// cards[0] != cards[1]\n\treturn cards[0] + cards[1] + cards[2] + cards[3] + cards[4]\n}\n\nfunc main() {\n\tvar cards [5]int\n\tn, err := fmt.Scanln(&cards[0], &cards[1], &cards[2], &cards[3], &cards[4])\n\tif n != 5 || err != nil {\n\t\tpanic(err)\n\t}\n\tsum := solve(cards)\n\tfmt.Println(sum)\n}\n\n", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tarr := gsls(reader)\n\trot := gsli(reader)[0]\n\n\tstart := pos(arr[0])\n\tend := pos(arr[1])\n\n\t// fmt.Printf(\"arr: %#v \\n rot: %#v \\n start: %v \\n end: %v\", arr, rot, start, end)\n\n\tcwEnd := posMod(start+rot, 4)\n\tccwEnd := posMod(start-rot, 4)\n\n\tdiff := posMod(end-start, 4)\n\n\tif diff == 0 || diff == 2 {\n\t\tfmt.Print(\"undefined\")\n\t} else if end == cwEnd {\n\t\tfmt.Print(\"cw\")\n\t} else if end == ccwEnd {\n\t\tfmt.Print(\"ccw\")\n\t} else {\n\t\tfmt.Printf(\"cwEnd = %v, ccwEnd = %v\", cwEnd, ccwEnd)\n\t}\n\treturn\n\n}\n\nfunc pos(x string) (pos int) {\n\tswitch x {\n\tcase \"^\":\n\t\tpos = 0\n\tcase \">\":\n\t\tpos = 1\n\tcase \"v\":\n\t\tpos = 2\n\tcase \"<\":\n\t\tpos = 3\n\t}\n\n\treturn\n}\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\n\tinput, _ := reader.ReadString('\\n')\n\n\t// fmt.Printf(\"Got %#v \\n\", input)\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\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\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", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298"} {"source_code": "package main\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main(){\n\tvar in,cek,ans string\n\tfmt.Scan(&in,&cek)\n\tx:=make([]string,len(in))\n\tfor i:=0 ;im {\n\t\t\tfmt.Print(n)\n\t\t} else {\n\t\t\tfmt.Print(m)\n\t\t}\n\t\tfmt.Print(\" \")\n\t\tif m!=0 {\n\t\t\tfmt.Println(n+m-1)\n\t\t} else {\n\t\t\tfmt.Println(n)\n\t\t}\n\t}\n}\n\n\n", "src_uid": "1e865eda33afe09302bda9077d613763"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var y int\n fmt.Scan(&y)\n for {\n y++\n var f [10]bool\n ty := y\n ans := true\n for ty > 0 {\n d := ty%10\n if f[d] { ans = false; break; } else { f[d] = true }\n ty /= 10\n }\n if ans { fmt.Println(y); break; }\n }\n}\n", "src_uid": "d62dabfbec52675b7ed7b582ad133acd"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tcolors := make(map[int]struct{})\n\tvar v int\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Scan(&v)\n\t\tcolors[v] = struct{}{}\n\t}\n\n\tfmt.Print(4 - len(colors))\n}\n", "src_uid": "38c4864937e57b35d3cce272f655e20f"} {"source_code": "package main\n\nimport (\n // \"bufio\"\n \"fmt\"\n \"math\"\n // \"strconv\"\n // \"strings\"\n)\n\nfunc main() {\n var n, k int64\n fmt.Scanf(\"%d %d\\n\", &n, &k)\n\n var half = (int64)(math.Sqrt(float64(n)))\n var d = int64(-1)\n\n for i:=int64(1); i<=half; i++ {\n if n % i == 0 {\n k -= 1\n\n if k == 0 {\n d = i\n break\n }\n }\n }\n\n if k > 0 {\n if half * half == n {\n half--\n }\n\n for i:=half; i>0; i-- {\n if n % i == 0 {\n k -= 1\n\n if k == 0 {\n d = n / i\n break\n }\n }\n }\n }\n\n fmt.Printf(\"%d\\n\", d)\n}\n", "src_uid": "6ba39b428a2d47b7d199879185797ffb"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc isPalindrome(str string) bool {\n\tsize := len(str)\n\tvar rev_str string\n\tfor i := size-1; i >= 0; i--{\n\t\trev_str += string(str[i])\n\t}\n\tif str == rev_str{\n\t\treturn true\n\t}else{\n\t\treturn false\n\t}\n}\n\nfunc removeLast(str string)string {\n\tstr = str[:len(str)-1]\n\treturn str\n}\n\nfunc main(){\n\tvar str string\n\tfmt.Scanln(&str)\n\tif ! isPalindrome(str){\n\t\tfmt.Print(len(str))\n\t}else{\n\t\tfor (isPalindrome(str)){\n\t\t\tif str == \"\"{\n\t\t\t\tfmt.Print(0)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tstr = removeLast(str)\n\t\t}\n\t\tfmt.Print(len(str))\n\t}\n}\n", "src_uid": "6c85175d334f811617e7030e0403f706"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main(){\n\tvar n, a int\n\tarr := make([]int, 0)\n\tfmt.Scan(&n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a)\n\t\tarr = append(arr, a)\n\t}\n\tsort.Ints(arr)\n\tans := 0\n\tfor i := 0; i < len(arr) - 1; i+=2 {\n\t\tans += arr[i + 1] - arr[i]\n\t}\n\tfmt.Println(ans)\n}\n", "src_uid": "55485fe203a114374f0aae93006278d3"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n\t\"strconv\"\n)\n\nvar in *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar out *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc main() {\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\ta, b, _, _ := nextInt(), nextInt(), nextInt(), nextInt()\n\n\tif a > b {\n\t\tfmt.Println(\"First\")\n\t} else {\n\t\tfmt.Println(\"Second\")\n\t}\n}\n\nfunc nextInt() int {\n\tin.Scan()\n\tres, _ := strconv.Atoi(in.Text())\n\treturn res\n}", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b"} {"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\tDistanceStepsMap []int\n)\n\nfunc readInt(in *bufio.Reader) int {\n\tnStr, _ := in.ReadString('\\n')\n\tnStr = strings.ReplaceAll(nStr, \"\\r\", \"\")\n\tnStr = strings.ReplaceAll(nStr, \"\\n\", \"\")\n\tn, _ := strconv.Atoi(nStr)\n\n\treturn n\n}\n\nfunc readInt64(in *bufio.Reader) uint64 {\n\tnStr, _ := in.ReadString('\\n')\n\tnStr = strings.ReplaceAll(nStr, \"\\r\", \"\")\n\tnStr = strings.ReplaceAll(nStr, \"\\n\", \"\")\n\tn, _ := strconv.ParseUint(nStr, 10, 64)\n\n\treturn n\n}\n\nfunc readLineNumbs(in *bufio.Reader) []string {\n\tline, _ := in.ReadString('\\n')\n\tline = strings.ReplaceAll(line, \"\\r\", \"\")\n\tline = strings.ReplaceAll(line, \"\\n\", \"\")\n\tnumbs := strings.Split(line, \" \")\n\n\treturn numbs\n}\n\nfunc readArrInt(in *bufio.Reader) []int {\n\tnumbs := readLineNumbs(in)\n\tarr := make([]int, len(numbs))\n\tfor i, n := range numbs {\n\t\tval, _ := strconv.Atoi(n)\n\t\tarr[i] = val\n\t}\n\n\treturn arr\n}\n\nfunc readArrInt64(in *bufio.Reader) []int64 {\n\tnumbs := readLineNumbs(in)\n\tarr := make([]int64, len(numbs))\n\tfor i, n := range numbs {\n\t\tval, _ := strconv.ParseInt(n, 10, 64)\n\t\tarr[i] = val\n\t}\n\n\treturn arr\n}\n\nfunc readString(in *bufio.Reader) string {\n\tline, _ := in.ReadString('\\n')\n\tline = strings.ReplaceAll(line, \"\\r\", \"\")\n\tline = strings.ReplaceAll(line, \"\\n\", \"\")\n\n\treturn line\n}\n\nfunc Max(a int, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc Min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc StringToRuneSlice(s string) []rune {\n\tvar r []rune\n\tfor _, runeValue := range s {\n\t\tr = append(r, runeValue)\n\t}\n\n\treturn r\n}\n\nfunc SwapInt(a *int, b *int) {\n\tt := *a\n\t*a = *b\n\t*b = t\n}\n\n// search for theseus\n\nvar (\n\tSearchWord = \"theseus\"\n\n\tFindFlag = false\n)\n\nfunc solve(visit [][]bool, labyrinth []string, r int, c int, ind int) {\n\tif FindFlag {\n\t\treturn\n\t}\n\n\tl := len(labyrinth)\n\tif r >= l || r < 0{\n\t\treturn\n\t}\n\n\tif c >= l || c < 0{\n\t\treturn\n\t}\n\n\tif visit[r][c] {\n\t\treturn\n\t}\n\n\t//char := labyrinth[r][c]\n\t//for i := 0; i < len(SearchWord); i++ {\n\t//\tsearchChar := SearchWord[i]\n\t//\n\t//\tif ind == i {\n\t//\t\tif char == searchChar {\n\t//\t\t\tvisit[r][c] = true\n\t//\n\t//\t\t\tif i == len(SearchWord) - 1 {\n\t//\t\t\t\tFindFlag = true\n\t//\n\t//\t\t\t\treturn\n\t//\t\t\t}\n\t//\n\t//\t\t\tsolve(visit, labyrinth, r + 1, c, ind + 1)\n\t//\t\t\t//solve(visit, labyrinth, r - 1, c, ind + 1)\n\t//\t\t\tsolve(visit, labyrinth, r, c + 1, ind + 1)\n\t//\t\t\t//solve(visit, labyrinth, r, c - 1, ind + 1)\n\t//\t\t\t//solve(visit, labyrinth, r - 1, c + 1, ind + 1)\n\t//\t\t\t//solve(visit, labyrinth, r - 1, c - 1, ind + 1)\n\t//\t\t\tsolve(visit, labyrinth, r + 1, c + 1, ind + 1)\n\t//\t\t\t//solve(visit, labyrinth, r + 1, c - 1, ind + 1)\n\t//\t\t}\n\t//\t}\n\t//}\n\n\twl := len(SearchWord)\n\n\tvar w string\n\tif l - r > wl {\n\t\tw = \"\"\n\t\tfor i := 0; i < wl; i++ {\n\t\t\tw += string(labyrinth[r + i][c])\n\t\t}\n\n\t\tif w == SearchWord {\n\t\t\tFindFlag = true\n\n\t\t\treturn\n\t\t}\n\t}\n\n\tif l - c > wl {\n\t\tw = \"\"\n\t\tfor i := 0; i < wl; i++ {\n\t\t\tw += string(labyrinth[r][c + i])\n\t\t}\n\n\t\tif w == SearchWord {\n\t\t\tFindFlag = true\n\n\t\t\treturn\n\t\t}\n\t}\n\n\tif l - r > wl && l - c > wl {\n\t\tw = \"\"\n\t\tfor i := 0; i < wl; i++ {\n\t\t\tw += string(labyrinth[r + i][c + i])\n\t\t}\n\n\t\tif w == SearchWord {\n\t\t\tFindFlag = true\n\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\n\tl := readInt(in)\n\t//tc := 1\n\n\t//solve()\n\n\tmaze := make([]string, l)\n\tfor i := 0; i < l; i++ {\n\t\tmaze[i] = readString(in)\n\t}\n\n\tvisit := make([][]bool, l)\n\tfor i := 0; i < l; i++ {\n\t\tvisit[i] = make([]bool, l)\n\t\tfor j := 0; j < l; j++ {\n\t\t\tvisit[i][j] = false\n\t\t}\n\t}\n\n\tfor i := 0; i < l; i++ {\n\t\tfor j := 0; j < l; j++ {\n\t\t\tif FindFlag {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif maze[i][j] == SearchWord[0] {\n\t\t\t\tsolve(visit, maze, i, j, 0)\n\t\t\t}\n\n\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\tvisit[i] = make([]bool, l)\n\t\t\t\tfor j := 0; j < l; j++ {\n\t\t\t\t\tvisit[i][j] = false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif FindFlag {\n\t\tfmt.Println(\"YES\")\n\n\t\treturn\n\t}\n\n\tfmt.Println(\"NO\")\n\n\t//for i := 0; i < tc; i++ {\n\t//\tn := readInt(in)\n\t//\t_ = readArrInt(in)\n\t//\tfmt.Println(\"N: \", n)\n\t//\tfmt.Println(\"DONE TC: \", i+1)\n\t//}\n}\n", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b string\n\tfmt.Scan(&a, &b)\n\tc := \"\"\n\tfor i := 0; i < len(a); i++ {\n\t\tif a[i] != b[i] {\n\t\t\tc += \"1\"\n\t\t} else {\n\t\t\tc += \"0\"\n\t\t}\n\t}\n\tfmt.Println(c)\n}\n", "src_uid": "3714b7596a6b48ca5b7a346f60d90549"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\ta := make([]int, 3)\n\td := 0\n\tfmt.Fscanf(in, \"%d %d %d %d\\n\", &a[0], &a[1], &a[2], &d)\n\tsort.Ints(a)\n\tans := 0\n\tif a[1]-a[0] < d {\n\t\tans += d - (a[1] - a[0])\n\t}\n\tif a[2]-a[1] < d {\n\t\tans += d - (a[2] - a[1])\n\t}\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", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3"} {"source_code": "package main\nimport(\n \"fmt\" \n)\nfunc getElement(n, k uint64) int {\n var length uint64\n length = (1 << n) - 1\n for i := n; i > 0; i-- {\n length = length / 2\n if k > length {\n k -= length + 1\n }\n if k == 0 {\n return int(i)\n }\n }\n return -1\n}\nfunc main(){\n var n, k uint64\n fmt.Scan(&n, &k)\n fmt.Println(getElement(n, k))\n}", "src_uid": "0af400ea8e25b1a36adec4cc08912b71"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k, a int\n\tfmt.Scan(&n, &k)\n\tres := 1\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a)\n\t\tif k%a == 0 && res < a {\n\t\t\tres = a\n\t\t}\n\t}\n\tfmt.Println(k / res)\n}\n", "src_uid": "80520be9916045aca3a7de7bc925af1f"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, x int\n\tfmt.Scanf(\"%d\\n%d\\n\", &n, &x)\n\n\tfor i := n % 6; i > 0; i-- {\n\t\tif i%2 == 0 {\n\t\t\tif x == 2 {\n\t\t\t\tx = 1\n\t\t\t} else if x == 1 {\n\t\t\t\tx = 2\n\t\t\t}\n\t\t} else {\n\t\t\tif x == 0 {\n\t\t\t\tx = 1\n\t\t\t} else if x == 1 {\n\t\t\t\tx = 0\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Print(x)\n}\n", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0"} {"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", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb"} {"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", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b"} {"source_code": "\ufeffpackage main\nimport (\n\t\"fmt\"\n)\nfunc divisors(n int) int{\n\tc:= 1\n\tfor d:=2; d<100; d++{\n\t\tif (n % d == 0){\n\t\t\talpha := 0;\n\t\t\tfor ;n % d == 0; {\n\t\t\t\tn /= d\n\t\t\t\talpha++\n\t\t\t}\n\t\t\tc *= (alpha + 1)\n\t\t}\n\t}\n\treturn c\n}\n\nfunc main() {\n\tvar sum , al, bl, cl int\n\tsum=0\n\tfmt.Scan(&al,&bl,&cl)\n\tfor a := 1; a <= al; a++{\n\t\tfor b := 1; b <= bl; b++{\n\t\t\tfor c := 1; c <= cl; c++{\n\t\t\t\tsum += divisors(a*b*c);\n\t\t\t\tsum %= 1073741824;\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(sum)\n}\n\n\n\n\n\n\n\n\n\n\n\n", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var s string\n fmt.Scan(&n,&s)\n ans := 0\n for i := 1; i < n; i++ {\n if (s[i] == s[i-1]) { ans++ }\n }\n fmt.Println(ans)\n}\n", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype diameter struct {\n\tio *IO\n}\n\nfunc (d *diameter) out(deleteN int) {\n\td.io.Printf(\"%d\", deleteN)\n}\n\nfunc main() {\n\t//log.SetOutput(os.Stdout)\n\tlog.SetOutput(ioutil.Discard)\n\n\tio := NewStdIO()\n\tdefer io.Flush()\n\td := diameter{io: io}\n\n\tl1 := d.io.NextSplitLine(\" \")\n\tn, dmax := stoi(l1[0]), stoi(l1[1])\n\tlog.Printf(\"n=%d, dmax=%d\", n, dmax)\n\n\tif n <= 1 {\n\t\td.out(0)\n\t\treturn\n\t}\n\n\tl2 := d.io.NextSplitLine(\" \")\n\tnset := make([]int, n)\n\tfor i, ns := range l2 {\n\t\tnset[i] = stoi(ns)\n\t}\n\tsort.Ints(nset)\n\n\tminN := n + 1\n\tfor i := 0; i < n; i++ {\n\t\tcnt := 0\n\t\tfor j := i; j < n; j++ {\n\t\t\tcnt++\n\t\t\tlog.Printf(\"i=%d, j=%d, minN=%d\", i, j, minN)\n\t\t\tif (nset[j] - nset[i]) <= dmax {\n\t\t\t\tminN = min(minN, n-cnt)\n\t\t\t}\n\t\t}\n\t}\n\td.out(minN)\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc stoi(s string) int {\n\ti, err := strconv.Atoi(s)\n\tif err != nil {\n\t\tfmt.Println(i)\n\t\tfmt.Println(err)\n\t}\n\treturn i\n}\n\n// NewStdIO return standard IO instance.\nfunc NewStdIO() *IO {\n\treturn &IO{\n\t\tIn: bufio.NewReader(os.Stdin),\n\t\tOut: bufio.NewWriter(os.Stdout),\n\t}\n}\n\n// IO supports IO processing.\ntype IO struct {\n\tIn *bufio.Reader\n\tOut *bufio.Writer\n}\n\n// Flush outputs buffed data.\nfunc (io *IO) Flush() {\n\tif err := io.Out.Flush(); err != nil {\n\t\tpanic(err)\n\t}\n}\n\n// Printf writes string to buffer.\nfunc (io *IO) Printf(format string, a ...interface{}) {\n\tif _, err := fmt.Fprintf(io.Out, format, a...); err != nil {\n\t\tpanic(err)\n\t}\n}\n\n// NextInt reads a next line and convert it to integer\nfunc (io *IO) NextInt() int {\n\treturn stoi(io.Next())\n}\n\n// NextSplitLine reads a next line and return split string\nfunc (io *IO) NextSplitLine(d string) []string {\n\treturn strings.Split(io.Next(), d)\n}\n\n// Next reads line and return string.\nfunc (io *IO) Next() string {\n\tvar b []byte\n\tfor {\n\t\tl, pre, err := io.In.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tb = append(b, l...)\n\t\tif !pre {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(b)\n}\n", "src_uid": "6bcb324c072f796f4d50bafea5f624b2"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\tnum int\n\ti int\n\ts [50]int\n\n\tb_count int\n\tb_count1 int\n\tw_count int\n\tw_count1 int\n\tccl int\n\tcclp int\n\tflag bool\n)\n\nfunc main() {\n\tb_count = 0\n\tw_count = 0\n\n\tfmt.Scanln(&num)\n\n\tccl = num / 2\n\tfor i = 0; i < ccl; i++ {\n\t\tfmt.Scanf(\"%d\", &cclp)\n\t\ts[i] = cclp\n\t}\n\n\tif ccl == 1 {\n\n\t\tfmt.Println(0)\n\t} else {\n\n\t\tflag = true\n\t\tfor flag {\n\t\t\tflag = false\n\t\t\tfor i = 1; i < num/2; i++ {\n\n\t\t\t\tif s[i-1] > s[i] {\n\t\t\t\t\tflag = true\n\t\t\t\t\tccl = s[i]\n\t\t\t\t\ts[i] = s[i-1]\n\t\t\t\t\ts[i-1] = ccl\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor i = 0; i < num/2; i++ {\n\t\t\tccl = s[i] - 2*i - 1\n\t\t\tcclp = s[i] - 2*i - 2\n\t\t\tb_count += Iabs(ccl)\n\t\t\tw_count += Iabs(cclp)\n\n\t\t}\n\n\t\tif b_count < w_count {\n\t\t\tfmt.Println(b_count)\n\t\t} else {\n\t\t\tfmt.Println(w_count)\n\t\t}\n\t}\n\treturn\n}\nfunc Iabs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t} else {\n\t\treturn a\n\t}\n}\n", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, k int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &n, &k); err != nil {\n\t\treturn\n\t}\n\n\tif n < k {\n\t\tfmt.Println(k)\n\t} else {\n\t\tif n/k >= 10000 {\n\t\t\tfor i := n + 1; ; i++ {\n\t\t\t\tif i%k == 0 {\n\t\t\t\t\tfmt.Println(i)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor i := 2; ; i++ {\n\t\t\t\tif i*k > n {\n\t\t\t\t\tfmt.Println(i * k)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", "src_uid": "75f3835c969c871a609b978e04476542"} {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\nvar writer *bufio.Writer\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer = bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n n := getI64()\n x := n\n result := int64(1)\n for a := int64(2); a * a <= x; a++ {\n if x % a != 0 {\n continue\n }\n result *= a\n for x % a == 0 {\n x /= a\n }\n //fmt.Printf(\"%d \", a)\n }\n result *= x\n //fmt.Printf(\"%d\\n\", x)\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92"} {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strings\"\n \"strconv\"\n \"sort\"\n )\n\nfunc main (){\n var n, k int\n var s string\n \n \n fmt.Scan(&n, &k )\n reader := bufio.NewReader(os.Stdin)\n entrada, _ := reader.ReadString('\\r')\n s = strings.TrimRight(entrada, \"\\n\")\n\n arrs := strings.Fields(s)\n\n var t2[] int\n dic:= map[int] bool {}\n \n\n \n\n for pos, i := range arrs { \n j, _ := strconv.Atoi(i)\n _, ok := dic[j] \n if !ok {\n\n dic[j] = true\n if len(t2) == k{\n break\n }\n t2 = append(t2, pos+1)\n }\n\n }\n \n\n if len(dic) < k {\n fmt.Println(\"NO\")\n } else {\n sort.Ints(t2)\n fmt.Println(\"YES\")\n fmt.Println(strings.Trim(fmt.Sprint(t2), \"[]\"))\n }\n\n}\n", "src_uid": "5de6574d57ab04ca195143e08d28d0ad"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, t int\n\tfmt.Scanf(\"%d %d \\n\", &n, &t)\n\tif n == 1 && t == 10 {\n\t\tfmt.Print(-1)\n\t\treturn\n\t}\n\tfmt.Print(t)\n\tfor i := 0; i < n-1-t/10; i++ {\n\t\tfmt.Print(0)\n\t}\n}\n", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc gcd(a, b int64) int64 {\n//\tfmt.Printf(\"->%d %d\\n\",a,b)\n\tif b%a == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b%a, a)\n}\nfunc solveD(l, n, k int64) (int64) {\n\n\tgc := gcd(l, n*k)\n\tif gc == 1{\n\t\treturn n*k\n\t}\n\ttmp := n * k/gc\n\tif tmp < 0{\n\t\tfmt.Printf(\"%d %d %d\\n\",l,n,k)\n\t}\n\treturn tmp\n}\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar n, k int64\n\tvar a, b int64\n\tfmt.Fscanf(buf, \"%d %d\\n\", &n, &k)\n\tfmt.Fscanf(buf, \"%d %d\\n\", &a, &b)\n\tbasic := make([]int64, 0)\n\tfor _, v1 := range [2]int64{a, (k - a)%k} {\n\t\tfor _, v2 := range [2]int64{b, (k - b)%k} {\n\t\t\tif v2-v1 == 0 {\n\t\t\t\tbasic = append(basic, k)\n\t\t\t} else if v2-v1 > 0 {\n\t\t\t\tbasic = append(basic, v2-v1)\n\t\t\t} else {\n\t\t\t\tbasic = append(basic, k+v2-v1)\n\t\t\t}\n\t\t}\n\t}\n\tvar minx int64 = -1\n\tvar maxx int64 = -1\n//\tfmt.Printf(\"%v\\n\", basic)\n\tfor _, v := range basic {\n\t\tfor i := int64(0); i < n; i++ {\n\t\t\ttmp := solveD(v+i*k,n,k)\n\t\t\tif minx == -1||minx > tmp{\n\t\t\t\tminx = tmp\n\t\t\t}\n\t\t\tif maxx == -1 || maxx < tmp{\n\t\t\t\tmaxx = tmp\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d %d\\n\", minx,maxx)\n\n}\n\n/**\n01010101\n0101010\n */\n", "src_uid": "5bb4adff1b332f43144047955eefba0c"} {"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\tk := readll()\n\tn := readll()\n\ts := readll()\n\tp := readll()\n\n\ts2 := n / s\n\tif n%s != 0 {\n\t\ts2++\n\t}\n\tans := k * s2 / p\n\tif (k*s2)%p != 0 {\n\t\tans++\n\t}\n\tprintln(ans)\n}\n", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780"} {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar b, n, p, x, y int\n\tfmt.Scanf(\"%d%d%d\", &n, &b, &p)\n\ty = n * p\n\tfor n > 1 {\n\t\tk := 1\n\t\tfor k <= n {\n\t\t\tk = k << 1\n\t\t}\n\t\tk = k >> 2\n\t\tx += (2*b + 1) * k\n\t\tn = n - k\n\t}\n\tfmt.Println(x, y)\n}\n", "src_uid": "eb815f35e9f29793a120d120968cfe34"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst NMAX = 100\nconst EMPTY = 255\nconst INFINITY = uint32(999999)\n\nfunc toInt(buf []byte) uint32 {\n\tn := uint32(0)\n\tfor _, v := range buf {\n\t\tn = n*10 + uint32(v-'0')\n\t}\n\n\treturn n\n}\n\nfunc solve(n uint32, p [NMAX]uint32) uint32 {\n type State struct {\n odds int\n evens int\n last uint32\n index uint32\n }\n \n start := State{}\n \n for i := uint32(1); i <= n; i++ {\n f := false\n for j := uint32(0); j < n; j++ {\n f = f || i == p[j]\n }\n\n if !f {\n if i % 2 == 0 {\n start.evens++\n } else {\n start.odds++\n }\n }\n }\n \n memo := map[State]uint32{}\n var solve func(s State) uint32\n solve = func(s State) uint32 {\n if r, f := memo[s]; f {\n return r\n }\n\n i, r := s.index, uint32(0)\n for ; i < n && p[i] != 0; i++ {\n if i > 0 {\n prev := p[i - 1]\n if prev == 0 {\n prev = s.last\n }\n if prev % 2 != p[i] % 2 {\n r++\n }\n }\n }\n \n prev := uint32(0)\n if i > 0 {\n prev = p[i - 1]\n if prev == 0 {\n prev = s.last\n }\n }\n \n if i < n && p[i] == 0 {\n r1, r2 := INFINITY, INFINITY\n if s.odds > 0 {\n next := State{index: i + 1, odds: s.odds - 1, evens: s.evens, last: 1}\n r1 = solve(next)\n if i > 0 && (prev % 2 == 0) {\n r1++\n }\n }\n \n if s.evens > 0 {\n next := State{index: i + 1, odds: s.odds, evens: s.evens - 1}\n r2 = solve(next)\n if i > 0 && (prev % 2 > 0) {\n r2++\n }\n }\n\n if r1 > r2 {\n r1 = r2\n }\n \n r += r1\n }\n \n memo[s] = r\n \n return r\n }\n\n return solve(start)\n}\n\nfunc main() {\n\tvar n uint32\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tn = toInt(scanner.Bytes())\n\t\n p := [NMAX]uint32{}\n for i := uint32(0); i < n; i++ {\n scanner.Scan()\n p[i] = toInt(scanner.Bytes())\n }\n \n res := solve(n, p)\n fmt.Println(res)\n}\n", "src_uid": "90db6b6548512acfc3da162144169dba"} {"source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n\tvar A[4] int\n\t\tfmt.Scan(&A[0], &A[1], &A[3], &A[2])\n\tfor i:=0; i<2; i++{\n\t\t if A[i]-1<=A[i+2]&&2*A[i]+2>=A[i+2] {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n\treturn\n}\n", "src_uid": "36b7478e162be6e985613b2dad0974dd"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a int\n\tfmt.Scanf(\"%d\", &a)\n\tvar ans, tmp, tot int = 0, 1, 0\n\tfor {\n\t\ttot = tot + tmp\n\t\tans ++\n\t\tif tot >= a {\n\t\t\tbreak\n\t\t}\n\t\ttmp = tmp + tmp\n\t}\n\tfmt.Print(ans)\n}", "src_uid": "95cb79597443461085e62d974d67a9a0"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\nfunc getLine2Ints(n int) []int {\n\tans := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d \", &ans[i])\n\t}\n\tscanf(\"%d\\n\", &ans[n-1])\n\treturn ans\n}\n\nfunc pcheck(i bool) {\n\tif i {\n\t\tprintf(\"Yes\\n\")\n\t} else {\n\t\tprintf(\"No\\n\")\n\t}\n}\n\nvar debug = true\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tn, m := getLine2Int2()\n\tvar x int\n\tif n*2 < m {\n\t\tx = n\n\t} else if m*2 < n {\n\t\tx = m\n\t} else {\n\t\tx = (m + n) / 3\n\t}\n\tprintf(\"%d\\n\", x)\n}\n", "src_uid": "0718c6afe52cd232a5e942052527f31b"} {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int64;\n\tfmt.Scan(&n);\n\n\tn++\n\tif n % 2 == 0 {\n\t\tfmt.Printf(\"%d\\n\", n / 2);\n\t} else {\n\t\tif n == 1 {\n\t\t\tfmt.Printf(\"0\\n\");\n\t\t} else {\n\t\t\tfmt.Printf(\"%d\\n\", n);\n\t\t}\n\t}\n}", "src_uid": "236177ff30dafe68295b5d33dc501828"} {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/371/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nconst MaxBurgers = int64(1e13)\n\nfunc max(x, y int64) int64 {\n\tif x >= y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc p(burgers, cb, cs, cc, nb, ns, nc, pb, ps, pc int64) int64 {\n\treturn max(0, cb*burgers-nb)*pb + max(0, cs*burgers-ns)*ps + max(0, cc*burgers-nc)*pc\n}\n\nfunc _Solve(left, right, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles int64) int64 {\n\tif !(left < right) {\n\t\treturn left\n\t}\n\tm := (left + right + 1) / 2\n\tcost := p(m, cb, cs, cc, nb, ns, nc, pb, ps, pc)\n\tif cost <= rubles {\n\t\treturn _Solve(m, right, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles)\n\t}\n\treturn _Solve(left, m-1, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles)\n}\n\nfunc Solve(s string, nb, ns, nc, pb, ps, pc, r int64) int64 {\n\tcb := int64(strings.Count(s, \"B\"))\n\tcs := int64(strings.Count(s, \"S\"))\n\tcc := int64(strings.Count(s, \"C\"))\n\treturn _Solve(0, MaxBurgers, cb, cs, cc, nb, ns, nc, pb, ps, pc, r)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar s string\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\tvar nb, ns, nc int64\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &nb, &ns, &nc)\n\tvar pb, ps, pc int64\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &pb, &ps, &pc)\n\tvar r int64\n\tfmt.Fscanf(reader, \"%d\\n\", &r)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(s, nb, ns, nc, pb, ps, pc, r))\n}\n", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e"} {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n n := readInt64()\n mx := 88\n mem := make([]int64, mx)\n mem[1], mem[2] = 2, 3\n for i := 3; i < mx; i++ {\n mem[i] = mem[i-1]+mem[i-2]\n }\n ans := 0\n for i, v := range mem {\n if n >= v {\n ans = i\n }\n }\n fmt.Println(ans)\n}\n\n// Helpers\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\n// Sort\n\ntype Ints64 []int64\n\nfunc (a Ints64) Len() int { return len(a) }\nfunc (a Ints64) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a Ints64) Less(i, j int) bool { return a[i] < a[j] }\n\n/* Sort tempalte\nfunc (a ) Len() int { return len(a) }\nfunc (a ) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ) Less(i, j int) bool { return }\n*/\n", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14"} {"source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tk2, k3, k5, k6 := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()\n\n\tk := min(k2, min(k5, k6))\n\tk2 -= k\n\n\tans := 256 * k + min(k2, k3) * 32\n\n\tfmt.Println(ans)\n\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r:rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e"}